Ejemplo n.º 1
0
 public ConnectionEventsSink(
     OnConnectCompleteHandler connectCallback,
     OnDisconnectCompleteHandler disconnectCallback,
     IConnectionPoint connectionPoint)
 {
     m_ConnectCallback    = new WeakReference <OnConnectCompleteHandler>(connectCallback);
     m_DisconnectCallback = new WeakReference <OnDisconnectCompleteHandler>(disconnectCallback);
     m_ConnectionPoint    = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
Ejemplo n.º 2
0
        private void InitializeEventHandlers()
        {
            try
            {
                // Get the interface
                m_MbnInterface             = m_MbnInterfaceManager.GetInterface(selectedInterfaceId);
                m_MbnConnection            = m_MbnInterface.GetConnection();
                m_MbnDeviceServicesContext = m_MbnDeviceServicesManager.GetDeviceServicesContext(m_MbnInterface.InterfaceID);

                // Register for IMbnConnectionEvents
                if (m_ConnectionEventsSink == null)
                {
                    m_OnConnectCompleteEventDelegate    = new OnConnectCompleteHandler(ProcessOnConnectComplete);
                    m_OnDisconnectCompleteEventDelegate = new OnDisconnectCompleteHandler(ProcessOnDisconnectComplete);
                    m_ConnectionEventsSink = new ConnectionEventsSink(m_OnConnectCompleteEventDelegate,
                                                                      m_OnDisconnectCompleteEventDelegate,
                                                                      GetMbnConnectionEventsConnectionPoint());
                }

                // Register for IMbnDeviceServicesEvents
                if (m_DeviceServicesEventsSink == null)
                {
                    m_OnOpenCommandSessionCompleteEventDelegate = new OnOpenCommandSessionCompleteHandler(ProcessOnOpenCommandSessionComplete);
                    m_OnQueryCommandCompleteEventDelegate       = new OnQueryCommandCompleteHandler(ProcessOnQueryCommandComplete);
                    m_OnSetCommandCompleteEventDelegate         = new OnSetCommandCompleteHandler(ProcessOnSetCommandComplete);
                    m_OnCloseCommandSessionEventDelegate        = new OnCloseCommandSessionCompleteHandler(ProcessOnCloseCommandSessionComplete);
                    m_DeviceServicesEventsSink = new DeviceServicesEventsSink(
                        m_OnOpenCommandSessionCompleteEventDelegate,
                        m_OnQueryCommandCompleteEventDelegate,
                        m_OnCloseCommandSessionEventDelegate,
                        m_OnSetCommandCompleteEventDelegate,
                        GetMbnDeviceServicesEventsConnectionPoint());
                }

                //Register for IMbnRegistrationEvents
                if (m_RegistrationEventsSink == null)
                {
                    m_OnRegisterModeAvailableHandlerEventDelegate    = new OnRegisterModeAvailableHandler(ProcessOnRegisterModeAvailable);
                    m_OnRegisterStateChangeHandlerEventDelegate      = new OnRegisterStateChangeHandler(ProcessOnRegisterStateChange);
                    m_OnPacketServiceStateChangeHandlerEventDelegate = new OnPacketServiceStateChangeHandler(ProcessOnPacketServiceStateChange);
                    m_OnSetRegisterModeCompleteHandlerEventDelegate  = new OnSetRegisterModeCompleteHandler(ProcessOnSetRegisterModeComplete);
                    m_RegistrationEventsSink = new RegistrationEventsSink(
                        m_OnRegisterModeAvailableHandlerEventDelegate,
                        m_OnRegisterStateChangeHandlerEventDelegate,
                        m_OnPacketServiceStateChangeHandlerEventDelegate,
                        m_OnSetRegisterModeCompleteHandlerEventDelegate,
                        GetRegisterEventsConnectionPoint());
                }

                if (m_InterfaceEventsSink == null)
                {
                    OnEmergencyModeChangeHandlerEventDelegate           = new OnEmergencyModeChangeHandler(ProcessOnEmergencyModeChange);
                    OnHomeProviderAvailableHandlerEventDelegate         = new OnHomeProviderAvailableHandler(ProcessOnHomeProviderAvailable);
                    OnInterfaceCapabilityAvailableHandlerEventDelegate  = new OnInterfaceCapabilityAvailableHandler(ProcessOnInterfaceCapabilityAvailable);
                    OnPreferredProvidersChangeHandlerEventDelegate      = new OnPreferredProvidersChangeHandler(ProcessOnPreferredProvidersChange);
                    OnReadyStateChangeHandlerEventDelegate              = new OnReadyStateChangeHandler(ProcessOnReadyStateChange);
                    OnScanNetworkCompleteHandlerEventDelegate           = new OnScanNetworkCompleteHandler(ProcessOnScanNetworkComplete);
                    OnSetPreferredProvidersCompleteHandlerEventDelegate = new OnSetPreferredProvidersCompleteHandler(ProcessOnSetPreferredProvidersComplete);
                    OnSubscriberInformationChangeHandlerEventDelegate   = new OnSubscriberInformationChangeHandler(ProcessOnSubscriberInformationChange);
                    m_InterfaceEventsSink = new InterfaceEventsSink(
                        OnEmergencyModeChangeHandlerEventDelegate,
                        OnHomeProviderAvailableHandlerEventDelegate,
                        OnInterfaceCapabilityAvailableHandlerEventDelegate,
                        OnPreferredProvidersChangeHandlerEventDelegate,
                        OnReadyStateChangeHandlerEventDelegate,
                        OnScanNetworkCompleteHandlerEventDelegate,
                        OnSetPreferredProvidersCompleteHandlerEventDelegate,
                        OnSubscriberInformationChangeHandlerEventDelegate,
                        GetInterfaceEventsConnectionPoint());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(ParseExceptionCode(e));
            }
        }
Ejemplo n.º 3
0
 public ConnectionEventsSink(
     OnConnectCompleteHandler connectCallback,
     OnDisconnectCompleteHandler disconnectCallback,
     IConnectionPoint connectionPoint)
 {
     m_ConnectCallback = new WeakReference<OnConnectCompleteHandler>(connectCallback);
     m_DisconnectCallback = new WeakReference<OnDisconnectCompleteHandler>(disconnectCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
Ejemplo n.º 4
0
        // Register for notifications
        private void RegisterForNotifications()
        {
            try
            {
                if (m_MbnInterface == null)
                {
                    // Get the interface
                    m_MbnInterface = GetFirstInterface();
                }

                if (m_MbnConnection == null)
                {
                    m_MbnConnection = m_MbnInterface.GetConnection();
                }

                if (m_MbnDeviceServicesContext == null)
                {
                    m_MbnDeviceServicesContext = m_MbnDeviceServicesManager.GetDeviceServicesContext(m_MbnInterface.InterfaceID);
                }

                // Register for IMbnInterfaceManagerEvents
                if (m_InterfaceManagerEventsSink == null)
                {
                    m_OnInterfaceArrivalEventDelegate = new OnInterfaceArrivalHandler(ProcessOnInterfaceArrival);
                    m_OnInterfaceRemovalEventDelegate = new OnInterfaceRemovalHandler(ProcessOnInterfaceRemoval);
                    m_InterfaceManagerEventsSink = new InterfaceManagerEventsSink(m_OnInterfaceArrivalEventDelegate,
                                                                                  m_OnInterfaceRemovalEventDelegate,
                                                                                  GetMbnInterfaceManagerEventsConnectionPoint());
                }

                // Register for IMbnPinManagerEvents
                if (m_PinManagerEventsSink == null)
                {
                    m_OnGetPinStateCompleteEventDelegate = new OnGetPinStateCompleteHandler(ProcessOnGetPinStateCompleteHandlerEvt);
                    m_PinManagerEventsSink = new PinManagerEventsSink(m_OnGetPinStateCompleteEventDelegate, GetMbnPinManagerEventsConnectionPoint());
                }

                // Register for IMbnPinEvents
                if (m_PinEventsSink == null)
                {
                    m_OnEnterCompleteEventDelegate = new OnEnterCompleteHandler(ProcessOnEnterComplete);
                    m_PinEventsSink = new PinEventsSink(m_OnEnterCompleteEventDelegate, GetMbnPinEventsConnectionPoint());
                }
                
                // Register for IMbnConnectionEvents
                if (m_ConnectionEventsSink == null)
                {
                    m_OnConnectCompleteEventDelegate = new OnConnectCompleteHandler(ProcessOnConnectComplete);
                    m_OnDisconnectCompleteEventDelegate = new OnDisconnectCompleteHandler(ProcessOnDisconnectComplete);
                    m_ConnectionEventsSink = new ConnectionEventsSink(m_OnConnectCompleteEventDelegate,
                                                                      m_OnDisconnectCompleteEventDelegate,
                                                                      GetMbnConnectionEventsConnectionPoint());
                }
                
                // Register for IMbnDeviceServicesEvents
                if (m_DeviceServicesEventsSink == null)
                {
                    m_OnOpenCommandSessionCompleteEventDelegate = new OnOpenCommandSessionCompleteHandler(ProcessOnOpenCommandSessionComplete);
                    m_OnQueryCommandCompleteEventDelegate = new OnQueryCommandCompleteHandler(ProcessOnQueryCommandComplete);
                    m_OnCloseCommandSessionEventDelegate = new OnCloseCommandSessionCompleteHandler(ProcessOnCloseCommandSessionComplete);
                    m_DeviceServicesEventsSink = new DeviceServicesEventsSink(
                                                    m_OnOpenCommandSessionCompleteEventDelegate,
                                                    m_OnQueryCommandCompleteEventDelegate,
                                                    m_OnCloseCommandSessionEventDelegate,
                                                    GetMbnDeviceServicesEventsConnectionPoint());
                }
            }
            catch (Exception e)
            {
                rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage);
            }
        }
        private void RegisterForNotifications()
        {
            try
            {
                if (m_MbnInterface == null)
                {
                    m_MbnInterface = GetFirstInterface();
                }

                if (m_MbnConnection == null)
                {
                    m_MbnConnection = m_MbnInterface.GetConnection();
                }

                if (m_MbnDeviceServicesContext == null)
                {
                    m_MbnDeviceServicesContext = m_MbnDeviceServicesManager.GetDeviceServicesContext(m_MbnInterface.InterfaceID);
                }

                // Register for IMbnInterfaceManagerEvents
                if (m_InterfaceManagerEventsSink == null)
                {
                    m_OnInterfaceArrivalEventDelegate = new OnInterfaceArrivalHandler(ProcessOnInterfaceArrival);
                    m_OnInterfaceRemovalEventDelegate = new OnInterfaceRemovalHandler(ProcessOnInterfaceRemoval);
                    m_InterfaceManagerEventsSink      = new InterfaceManagerEventsSink(m_OnInterfaceArrivalEventDelegate,
                                                                                       m_OnInterfaceRemovalEventDelegate,
                                                                                       GetMbnInterfaceManagerEventsConnectionPoint());
                }

                // Register for IMbnPinManagerEvents
                if (m_PinManagerEventsSink == null)
                {
                    m_OnGetPinStateCompleteEventDelegate = new OnGetPinStateCompleteHandler(ProcessOnGetPinStateCompleteHandlerEvt);
                    m_PinManagerEventsSink = new PinManagerEventsSink(m_OnGetPinStateCompleteEventDelegate, GetMbnPinManagerEventsConnectionPoint());
                }

                // Register for IMbnPinEvents
                if (m_PinEventsSink == null)
                {
                    m_OnEnterCompleteEventDelegate = new OnEnterCompleteHandler(ProcessOnEnterComplete);
                    m_PinEventsSink = new PinEventsSink(m_OnEnterCompleteEventDelegate, GetMbnPinEventsConnectionPoint());
                }
                // Register for IMbnConnectionEvents

                if (m_ConnectionEventsSink == null)
                {
                    m_OnConnectCompleteEventDelegate    = new OnConnectCompleteHandler(ProcessOnConnectComplete);
                    m_OnDisconnectCompleteEventDelegate = new OnDisconnectCompleteHandler(ProcessOnDisconnectComplete);
                    m_ConnectionEventsSink = new ConnectionEventsSink(m_OnConnectCompleteEventDelegate,
                                                                      m_OnDisconnectCompleteEventDelegate,
                                                                      GetMbnConnectionEventsConnectionPoint());
                }
                // Register for IMbnDeviceServicesEvents

                if (m_DeviceServicesEventsSink == null)
                {
                    m_OnOpenCommandSessionCompleteEventDelegate = new OnOpenCommandSessionCompleteHandler(ProcessOnOpenCommandSessionComplete);
                    m_OnQueryCommandCompleteEventDelegate       = new OnQueryCommandCompleteHandler(ProcessOnQueryCommandComplete);
                    m_OnCloseCommandSessionEventDelegate        = new OnCloseCommandSessionCompleteHandler(ProcessOnCloseCommandSessionComplete);
                    m_DeviceServicesEventsSink = new DeviceServicesEventsSink(
                        m_OnOpenCommandSessionCompleteEventDelegate,
                        m_OnQueryCommandCompleteEventDelegate,
                        m_OnCloseCommandSessionEventDelegate,
                        GetMbnDeviceServicesEventsConnectionPoint());
                }
            }
            catch (Exception e)
            {
                rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage);
            }
        }