📄 intelmobilenetworkclassprovider_private.cpp
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*///==============================================================================// IntelMobileNetworkClassProvider_Private.cpp//// Defines the class for the default network provider for IntelMobile. This module// contains the methods for the private interfaces of the inherited classes.//// //==============================================================================//#include "stdafx.h"//#include "util/core_utils.h"#include "IntelMobileNetworkClassProvider.h"#include "inc/framework/win2linux.h"#include "time.h"//#define NO_ERROR 0LDWORD WINAPI NetworkClassProvider::ListenForRouteChanges(LPVOID param){ //TODO: Need Implement return 0;}HRESULT NetworkClassProvider::ProcessRouteChanges(){ // Check for protocol changes // Get group of protocols from the adapter // For each protocol, do a cachedget and compare to a regular get, if they // are different for mediasense then throw a notify for that protocol ServerLinkProtocolClassObject& MyLinks = m_LinkProtocolClass; ServerInstanceCollection* pMyLinksCollection = NULL; DefaultLinkProtocolInstanceObject* pMyProtocolInstance = NULL; HRESULT hr = S_FALSE; long iChangedIndex = 0; // to act like client int iEnumIndex = 0; if ( pMyLinksCollection = MyLinks.GetInstances() ) { pMyLinksCollection->Reset( &iChangedIndex ); bool bHasNext; if ( bHasNext = pMyLinksCollection->HasNext( iEnumIndex, iChangedIndex ) ) { while ( bHasNext ) { if ( !pMyLinksCollection->Next( (ServerInstanceObject**)&pMyProtocolInstance, &iEnumIndex, iChangedIndex ) ) break; // Check all properties that you need to for events other than the "Changed" event. // The automatic RefreshProperties() method will do the rest. bool bMediaSense = pMyProtocolInstance->MediaPresent.GetCachedValue(); // Calling Shim to trigger if necessary. A straight GetValue() call wouldn't trigger pMyProtocolInstance->MediaPresent.GetValueShim(); bool bRealMediaSense = pMyProtocolInstance->MediaPresent.GetCachedValue(); if ( bMediaSense != bRealMediaSense ) { if ( bRealMediaSense ) { //_Log( LOG_INFORMATIONAL, IntelMobileText("*** Triggering Connect event for Protocol InstanceObject" ); // Modify invalidates the collection on the client, this isn't what we want. //pMyProtocolInstance->Modify( ServerEvent::eConnect ); pMyProtocolInstance->FireEvent( ServerEvent( ServerEvent::eMediaConnected, pMyProtocolInstance ) ); } else { //_Log( LOG_INFORMATIONAL, IntelMobileText("*** Triggering Disconnect event for Protocol InstanceObject" ); // Modify invalidates the collection on the client, this isn't what we want. //pMyProtocolInstance->Modify( ServerEvent::eDisconnect ); pMyProtocolInstance->FireEvent( ServerEvent( ServerEvent::eMediaDisconnected, pMyProtocolInstance ) ); } } // Refresh non-static members to trigger changed event if necessary pMyProtocolInstance->RefreshProperties(); //bHasNext = pMyLinksCollection->HasNext( iEnumIndex, iChangedIndex ); if (!(bHasNext = pMyLinksCollection->HasNext( iEnumIndex, iChangedIndex ))) break; // Don't delete these are singletons!!! //delete pMyProtocolInstance; } } // Don't delete these are singletons!!! //delete pMyLinksCollection; } pMyLinksCollection = NULL; return S_OK;}DWORD NetworkClassProvider::ListenForDeviceChanges(LPVOID param){ HRESULT hr;// MSG msg; IntelMobileChar wsMessage[1000];// wsprintf( wsMessage, IntelMobileText("Trace ListenForDeviceChanges(): param=0x%08X", param ); cout<<IntelMobileText("Trace ListenForDeviceChanges(): param=0x%08X")<<param<<endl; //_Log( LOG_DEBUG, wsMessage ); NetworkClassProvider* pMyCore = static_cast<NetworkClassProvider*>(param);/* if ( FAILED ( hr = pMyCore->CreateNotificationWindow() ) ) { //_Log( LOG_DEBUG, IntelMobileText("Trace CreateNotificationWindow() failed" ); } else { //_Log( LOG_DEBUG, IntelMobileText("Trace CreateNotificationWindow() succeeded." ); }*/ if ( FAILED ( hr = pMyCore->RegisterForHwndDeviceNotifications() ) ) { //_Log( LOG_DEBUG, IntelMobileText("Trace RegisterForHwndDeviceNotifications() failed" ); } else { //_Log( LOG_DEBUG, IntelMobileText("Trace RegisterForHwndDeviceNotifications() succeeded." ); } /* // Run a message loop to take care of the message queue while ( GetMessage( &msg, NULL, 0, 0 ) ) { if ( m_bQuit == true ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } */ return 0;}//typedef void *HDEVINFO;// Needs a reference the the main window handleHRESULT NetworkClassProvider::RegisterForHwndDeviceNotifications(){ //No need return S_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -