Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

EventHandler.h

This topic contains the header file for the network awareness event handler class discussed in Network Awareness on Windows Vista.

Subhead

//---------------------------------------------------------------------
//
// <copyright file="EventHandler.h" company="Microsoft">
//    Copyright © 2006 Microsoft Corporation.  All rights reserved.
// </copyright>
//
// Module:
//        EventHandler.h
//
// Description:
//
//---------------------------------------------------------------------

#include "stdafx.h"

#define NP_EVENT_MIN (WM_USER + 0x200)
#define NP_EVENT_NETWORK_ADDED (NP_EVENT_MIN + 0)
#define NP_EVENT_NETWORK_DELETED (NP_EVENT_MIN + 1)
#define NP_EVENT_NETWORK_CONNECTED (NP_EVENT_MIN + 2)
#define NP_EVENT_NETWORK_DISCONNECTED (NP_EVENT_MIN + 3)
#define NP_EVENT_NETWORK_PROPERTY_CHANGE (NP_EVENT_MIN + 4)

#define NP_EVENT_NETWORK_INTERFACE_CONNECTED (NP_EVENT_MIN + 5)
#define NP_EVENT_NETWORK_INTERFACE_DISCONNECTED (NP_EVENT_MIN + 6)
#define NP_EVENT_NETWORK_INTERFACE_PROPERTY_CHANGE (NP_EVENT_MIN + 7)

typedef struct tagNETWORK_PROPERTY_CHANGE_INFO
{
    DWORD dwcb; // count of bytes of this structure
    GUID guid;
    NP_NETWORK_PROPERTY_CHANGE flags;
} NETWORK_PROPERTY_CHANGE_INFO;

typedef struct tagNETWORK_INTERFACE_EVENT_DATA
{
    DWORD dwcb; // count of bytes of this structure
    GUID guid;
    NP_INTERFACE_PROPERTY_CHANGE flags;
    DWORD dwcbInterfaceId; // count of bytes of the pInterfaceId
    BYTE *pInterfaceId;
} NETWORK_INTERFACE_EVENT_DATA;

DWORD StartNetworkEventSinkThread(INetworkListManager *pNetworkListManager, HWND hwndMain);
DWORD WINAPI NetworkEventSinkThreadProc(LPVOID lpParameter);
HRESULT HrGetConnectionPoints(INetworkListManager *pManager, IConnectionPoint **ppcp, IConnectionPoint **ppcpInterface);

class CNetworkEventSink : public INotifyNetworkEvents
{
    HWND m_hWnd; // window in UI thread to message to
    ULONG m_lRef;

public:

    CNetworkEventSink(HWND hWnd);
    ~CNetworkEventSink();

    // IUnknown members
    STDMETHOD(QueryInterface) (REFIID riid, LPVOID* ppv);
    STDMETHOD_(ULONG, AddRef) (VOID);
    STDMETHOD_(ULONG, Release)(VOID);

    // INotifyNetworkEvents members
    STDMETHOD(OnNetworkAdded) (IN const GUID *pNetworkId);
    STDMETHOD(OnNetworkDeleted) (IN const GUID *pNetworkId);
    STDMETHOD(OnNetworkConnected) (IN const GUID *pNetworkId);
    STDMETHOD(OnNetworkDisconnected) (IN const GUID *pNetworkId);
    STDMETHOD(OnNetworkPropertyChange) (IN const GUID *pNetworkId, IN NP_NETWORK_PROPERTY_CHANGE flags);

    /////////////////// To be removed//////////////////////////////////
    STDMETHODIMP OnNetworkSignatureAdded(IN const GUID *pNetworkId, DWORD dwcbSignatureId, IN const BYTE *pbSignatureId)
        { return E_NOTIMPL; }
    STDMETHODIMP OnNetworkSignatureDeleted(IN const GUID *pNetworkId, DWORD dwcbSignatureId, IN const BYTE *pbSignatureId)
        { return E_NOTIMPL; }
    STDMETHODIMP OnNetworkSignatureConnected(IN const GUID *pNetworkId, DWORD dwcbSignatureId, IN const BYTE *pbSignatureId)
        { return E_NOTIMPL; }
    STDMETHODIMP OnNetworkSignatureDisconnected(IN const GUID *pNetworkId, DWORD dwcbSignatureId, IN const BYTE *pbSignatureId)
        { return E_NOTIMPL; }
    STDMETHODIMP OnNetworkSignaturePropertyChange(IN const GUID *pNetworkId, DWORD dwcbSignatureId, IN const BYTE *pbSignatureId, NP_NETWORK_SIGNATURE_PROPERTY_CHANGE flags)
        { return E_NOTIMPL; }
    STDMETHODIMP OnNetworkSignatureMoved(IN const GUID *srcProfileId, IN const GUID *destProfileId, IN DWORD dwcbSignatureId, IN const BYTE *pbSignatureId)
        { return E_NOTIMPL; }
};

class CNetworkInterfaceEventSink : public INotifyNetworkInterfaceEvents
{
    HWND m_hWnd; // window in UI thread to message to
    ULONG m_lRef;

public:
    CNetworkInterfaceEventSink(HWND hWnd);
    ~CNetworkInterfaceEventSink();

    // IUnknown members
    STDMETHOD(QueryInterface) (REFIID riid, LPVOID* ppv);
    STDMETHOD_(ULONG, AddRef) (VOID);
    STDMETHOD_(ULONG, Release)(VOID);

    // INotifyNetworkInterfaceEvents members
    STDMETHOD(OnNetworkInterfaceConnected) (IN const GUID *pNetworkId, IN DWORD dwcbInterfaceId, IN const BYTE *pInterfaceId);
    STDMETHOD(OnNetworkInterfaceDisconnected) (IN const GUID *pNetworkId, IN DWORD dwcbInterfaceId, IN const BYTE *pInterfaceId);
    STDMETHOD(OnInterfacePropertyChange) (IN const GUID *pNetworkId, IN DWORD dwcbInterfaceId, IN const BYTE *pInterfaceId, IN NP_INTERFACE_PROPERTY_CHANGE flags);

private:
    STDMETHOD(PostNetworkInterfaceEventHelper) (UINT message, IN const GUID *pNetworkId, DWORD dwcbInterfaceId, IN const BYTE *pInterfaceId, NP_INTERFACE_PROPERTY_CHANGE flags = (NP_INTERFACE_PROPERTY_CHANGE)0);
};

// End of file

Send comments about this topic to Microsoft

Build date: 12/17/2008

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.