⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intelmobilenetworkclassprovider.cpp

📁 270的linux说明
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		for(; itr != netdev_list.end(); itr++)		{			//create adapter and protocol			internalKey = itr->ifname;			externalKey = itr->ifname;			ServerInstanceObject *pAdapterObject = CreateInstanceAdapter(externalKey, internalKey);			if(pAdapterObject != NULL)			{				ServerInstanceObject *pProtocolObject = CreateInstanceProtocol(externalKey, internalKey);				if(pProtocolObject != NULL)				{					//then associate the protocol and adapter					ServerNetworkAdapterInstanceObject* pNetworkAdapterObject =reinterpret_cast<ServerNetworkAdapterInstanceObject*>( pAdapterObject );					ServerLinkProtocolInstanceObject* pNetworkProtocolObject = reinterpret_cast<ServerLinkProtocolInstanceObject*>( pProtocolObject );					if ( pNetworkAdapterObject != NULL && pNetworkProtocolObject != NULL )					{						bool bRet = pNetworkAdapterObject->AddProtocol( pNetworkProtocolObject );						if(bRet)						{							//then cache this device							netdev_cache entry;							memcpy(&(entry.dev), &(*itr), sizeof(netdev_dev)); 							netdev_get_enabled(*itr, entry.enabled);							netdev_get_running(*itr, entry.running);							netdev_cache_list.push_back(entry);						}						else						{							pProtocolObject->RemoveInstance();							pAdapterObject->RemoveInstance();							bRet = false;						}					}					else					{						pProtocolObject->RemoveInstance();						pAdapterObject->RemoveInstance();						bRet = false;					}				}				else				{					pAdapterObject->RemoveInstance();					bRet = false;				}			}			else			{				bRet = false;			}		}	}	else	{		bRet = false;	}			// Add for Special scan instance provider like bluetooth	ServerInstanceCollection *pCollection = GetClassObject(IntelMobileText("NetworkAdapter")).GetInstances();	if ( pCollection )	{		vector<IScanInstanceProvider*> vtScan = ::GetLayer()->GetScanLayerInstanceProvider( IntelMobileText("NetworkAdapter") );		vector<IScanInstanceProvider*>::const_iterator itScan;		m_vtScanInstanceProvider.clear();		for ( itScan = vtScan.begin(); itScan != vtScan.end(); itScan++ )		{			IScanInstanceProvider *pScanInstanceProvider = *itScan;			if ( pScanInstanceProvider )				m_vtScanInstanceProvider.push_back( pScanInstanceProvider );		}	}	// Call each IScanInstanceProvider::Scan	vector<IScanInstanceProvider*>::const_iterator it;	for ( it = m_vtScanInstanceProvider.begin(); it != m_vtScanInstanceProvider.end(); it++ )	{		IScanInstanceProvider *pScanInstanceProvider = *it;		if ( pScanInstanceProvider )		{			//pScanInstanceProvider->SetWindowHandle( m_hWnd );			pScanInstanceProvider->Scan();		}	}	Unlock();	return bRet;}//==============================================================================================ServerClassObject& NetworkClassProvider::GetClassObject( const IntelMobileString& sType ){	if ( sType == IntelMobileText( "NetworkAdapter" ) )		return m_NetworkAdapterClass;	else if ( sType == IntelMobileText( "WiredAdapter" ) )		return m_WiredAdapterClass;	else if ( sType == IntelMobileText( "RadioAdapter" ) )		return m_RadioAdapterClass;	else if ( sType == IntelMobileText( "LinkProtocol" ) )		return m_LinkProtocolClass;	else if ( sType == IntelMobileText( "Protocol802_3" ) )		return m_Protocol802_3Class;	else if ( sType == IntelMobileText( "Protocol802_11" ) )		return m_Protocol802_11Class;	else if ( sType == IntelMobileText( "ProtocolBluetoothPan" ) )		return m_ProtocolBluetoothPanClass;	else		throw;}//================================================================================================ServerInstanceObject* NetworkClassProvider::CreateInstance( /*in*/ const IntelMobileString& externalKey,							/*in*/ const IntelMobileString& internalKey,							/*in*/ const IntelMobileString& sType ){	if ( sType == IntelMobileText( "NetworkAdapter" ) 			|| sType == IntelMobileText( "WiredAdapter" ) 			|| sType == IntelMobileText( "RadioAdapter" ) )	{		return CreateInstanceAdapter( externalKey, internalKey );	}	else if ( sType == IntelMobileText( "LinkProtocol" ) 			|| sType == IntelMobileText( "Protocol802_3" ) 			|| sType == IntelMobileText( "Protocol802_11" ) 			|| sType == IntelMobileText( "ProtocolBluetoothPan" ) )	{		return CreateInstanceProtocol( externalKey, internalKey );	}	else		throw;}//==============================================================================IntelMobileString GetAdapterInfo( const IntelMobileString& internalKey ){	netdev_dev netdev;	if(netdev_get_device(internalKey.c_str(), netdev) != NETDEV_SUCCESS)	{		return IntelMobileText("");	}		netdev_type type;	if(netdev_get_type(netdev, type) != NETDEV_SUCCESS)	{		return IntelMobileText("");	}	switch (type )	{		case TYPE_802_3:			return IntelMobileText("WiredAdapter");		case TYPE_802_11:			return IntelMobileText("RadioAdapter");		case TYPE_UNKNOWN:		case TYPE_BLUETOOTH://here we count out the bluetooth			return IntelMobileText("");		default:			return IntelMobileText("NetworkAdapter");	}}//=============================================================================ServerInstanceObject* NetworkClassProvider::CreateInstanceAdapter( const IntelMobileString& externalKey, const IntelMobileString& internalKey ){	Lock();	bool bNeeded = false;	ServerInstanceObject* pObject = GetClassObject( IntelMobileText("NetworkAdapter") ).GetInstance( internalKey );	ServerInstanceCollection* pCollection = NULL;	if ( pObject == NULL )	{		IntelMobileString sType = GetAdapterInfo( internalKey );		IInstanceProvider* pProvider = GetLayer()->GetLayerInstanceProvider( sType, externalKey );		if ( pProvider != NULL )		{			pObject = pProvider->CreateInstance( internalKey );			if ( pObject != NULL )			{				pCollection = GetClassObject( pObject->GetType() ).GetInstances();				if ( pCollection != NULL )				{					bNeeded = true;				}				else				{					delete pObject;					pObject = NULL;				}			}		}	}	// If adapter successfully created, create the associated protocol	if ( pObject != NULL )	{		// See if protocol already there		ServerInstanceObject* pProtocolObject = GetClassObject( IntelMobileText("LinkProtocol") ).GetInstance( internalKey );		// If it isn't there... 		if ( pProtocolObject == NULL )		{			// ...create it.			pProtocolObject = CreateInstanceProtocol( externalKey, internalKey );			// if couldn't create it...			if ( pProtocolObject == NULL )			{				// ...remove the original adapter instance.				//pCollection->Remove( pObject );				delete pObject;				pObject = NULL;			}		}	}	if (bNeeded)	{		pCollection->Add(pObject);	}	Unlock();	return pObject;}//=========================================================================IntelMobileString GetProtocolInfo( const IntelMobileString& internalKey ){	netdev_dev netdev;	if(netdev_get_device(internalKey.c_str(), netdev) != NETDEV_SUCCESS)	{		return IntelMobileText("");	}		netdev_type type;	if(netdev_get_type(netdev, type) != NETDEV_SUCCESS)	{		return IntelMobileText("");	}	switch (type )	{		case TYPE_802_3:			return IntelMobileText("Protocol802_3");		case TYPE_802_11:			return IntelMobileText("Protocol802_11");		case TYPE_UNKNOWN:		case TYPE_BLUETOOTH://here we count out the bluetooth			return IntelMobileText("");		default:			return IntelMobileText("LinkProtocol");	}}//============================================================================ServerInstanceObject* NetworkClassProvider::CreateInstanceProtocol( const IntelMobileString& externalKey, const IntelMobileString& internalKey ){	Lock();	ServerInstanceObject* pObject = NULL;	pObject = GetClassObject( IntelMobileText("LinkProtocol") ).GetInstance( internalKey );	if ( pObject == NULL )	{		IntelMobileString sType = GetProtocolInfo( internalKey );		IInstanceProvider* pProvider = GetLayer()->GetLayerInstanceProvider( sType, externalKey );		if ( pProvider != NULL )		{			pObject = pProvider->CreateInstance( internalKey );			if ( pObject != NULL )			{				ServerInstanceCollection* pCollection = NULL;				pCollection = GetClassObject( pObject->GetType() ).GetInstances();				if ( pCollection != NULL )					pCollection->Add( pObject );				else				{					delete pObject;					pObject = NULL;				}			}		}	}	Unlock();	return pObject;}//==============================================================================void NetworkClassProvider::Initialize(){	Lock();	{		// This is essential for the navigation objects		// Navigation is automatic when these are added as subclasses properly.		m_NetworkAdapterClass.AddSubClass( m_WiredAdapterClass );		m_NetworkAdapterClass.AddSubClass( m_RadioAdapterClass );		m_LinkProtocolClass.AddSubClass( m_Protocol802_11Class );		m_LinkProtocolClass.AddSubClass( m_Protocol802_3Class );		m_LinkProtocolClass.AddSubClass( m_ProtocolBluetoothPanClass );	}	Unlock();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -