public ClientConnection(UPnPControlPoint controlPoint, DeviceConnection connection, ClientDescriptor clientDescriptor)
 {
     _controlPoint     = controlPoint;
     _connection       = connection;
     _clientDescriptor = clientDescriptor;
     _connection.DeviceDisconnected += OnUPnPDeviceDisconnected;
     try
     {
         CpService ccsStub = connection.Device.FindServiceByServiceId(UPnPTypesAndIds.CLIENT_CONTROLLER_SERVICE_ID);
         if (ccsStub == null)
         {
             throw new InvalidDataException("ClientController service not found in device '{0}' of type '{1}:{2}'",
                                            clientDescriptor.MPFrontendServerUUID,
                                            UPnPTypesAndIds.FRONTEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.FRONTEND_SERVER_DEVICE_TYPE_VERSION);
         }
         lock (_connection.CPData.SyncObj)
             _clientController = new UPnPClientControllerServiceProxy(ccsStub);
         // TODO: other services
     }
     catch (Exception)
     {
         _connection.DeviceDisconnected -= OnUPnPDeviceDisconnected;
         throw;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="listener">A listener that wishes to be notified about device events.</param>
        public DeviceDetector(IDeviceEventListener listener)
        {
            _deviceEventListener = listener;

            // Setup UPnP device detection.
            UPnPConfiguration.LOGGER = new Tve3Logger();
            _upnpControlPointData    = new CPData();
            _upnpAgent = new UPnPNetworkTracker(_upnpControlPointData);
            _upnpAgent.RootDeviceAdded   += OnUpnpRootDeviceAdded;
            _upnpAgent.RootDeviceRemoved += OnUpnpRootDeviceRemoved;
            _upnpControlPoint             = new UPnPControlPoint(_upnpAgent);

            // Setup other (BDA, PBDA, WDM) device detection.
            try
            {
                InitBdaDetectionGraph();
            }
            catch (Exception ex)
            {
                Log.Log.Error("Failed to initialise the BDA device detection graph!\r\n{0}", ex);
                throw;
            }
            _systemDeviceChangeEventWatcher = new ManagementEventWatcher();
            // EventType 2 and 3 are device arrival and removal. See:
            // http://msdn.microsoft.com/en-us/library/windows/desktop/aa394124%28v=vs.85%29.aspx
            _systemDeviceChangeEventWatcher.Query         = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2 OR EventType = 3");
            _systemDeviceChangeEventWatcher.EventArrived += OnSystemDeviceConnectedOrDisconnected;
        }
Ejemplo n.º 3
0
        //Add this method override
        protected override void OnStartup(StartupEventArgs e)
        {
            m_Mutex = new Mutex(true, "HomeGenieManagerMutex", out createdNew);
            //e.Args is the string[] of command line argruments
            //
            upnpService                 = new Dictionary <string, UPnPDevice>();
            upnpControl                 = new UPnPControlPoint();
            upnpControl.OnSearch       += upnpcontrol_OnSearch;
            upnpControl.OnCreateDevice += upnpcontrol_OnCreateDevice;
            upnpControl.FindDeviceAsync("urn:schemas-upnp-org:device:HomeAutomationServer:1");
            //
            Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
            var myDialogWindow = new LoadingDialog();

            myDialogWindow.Show();
            //
            Task loader = new Task(() =>
            {
                int t = 0;
                while (t < 10)
                {
                    if (upnpService.Count > 0)
                    {
                        Thread.Sleep(2000);
                        for (int s = 0; s < UPnPDevices.Count; s++)
                        {
                            var dev = UPnPDevices.ElementAt(s).Value;
                            if (dev.StandardDeviceType == "HomeAutomationServer")
                            {
                                System.Diagnostics.Process.Start(dev.PresentationURL);
                                t = 10;
                                break;
                            }
                        }
                    }
                    t++;
                    Thread.Sleep(1000);
                }
                //
                Thread.Sleep(2000);
                //
                myDialogWindow.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (!createdNew)
                    {
                        myDialogWindow.Close();
                        Application.Current.Shutdown();
                    }
                    else
                    {
                        var window = new MainWindow();
                        window.Show();
                        myDialogWindow.Close();
                    }
                }), null);
            });

            loader.Start();
        }
Ejemplo n.º 4
0
 public UPnPDeviceTracker()
 {
     _upnpControlPointData         = new CPData();
     _upnpAgent                    = new UPnPNetworkTracker(_upnpControlPointData);
     _upnpAgent.RootDeviceAdded   += OnUpnpRootDeviceAdded;
     _upnpAgent.RootDeviceRemoved += OnUpnpRootDeviceRemoved;
     _upnpControlPoint             = new UPnPControlPoint(_upnpAgent);
 }
        public UPnPClientControlPoint(string homeServerSystemId)
        {
            _homeServerSystemId = homeServerSystemId;
            CPData cpData = new CPData();

            _networkTracker = new UPnPNetworkTracker(cpData);
            _controlPoint   = new UPnPControlPoint(_networkTracker);
            _networkTracker.RootDeviceAdded += OnUPnPRootDeviceAdded;
        }
        public UPnPServerControlPoint()
        {
            CPData cpData = new CPData();

            _networkTracker = new UPnPNetworkTracker(cpData);
            _controlPoint   = new UPnPControlPoint(_networkTracker);
            _networkTracker.RootDeviceAdded   += OnUPnPRootDeviceAdded;
            _networkTracker.RootDeviceRemoved += OnUPnPRootDeviceRemoved;
        }
Ejemplo n.º 7
0
 public UpnpSmartControlPoint()
 {
     this.deviceFactory.OnDevice        += new UPnPDeviceFactory.UPnPDeviceHandler(this.DeviceFactoryCreationSink);
     this.deviceLifeTimeClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.DeviceLifeTimeClockSink);
     this.deviceUpdateClock.OnExpired   += new LifeTimeMonitor.LifeTimeHandler(this.DeviceUpdateClockSink);
     this.hostNetworkInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(this.NetworkInfoNewInterfaceSink));
     this.hostNetworkInfo.OnInterfaceDisabled += new NetworkInfo.InterfaceHandler(this.NetworkInfoOldInterfaceSink);
     this.genericControlPoint           = new UPnPControlPoint(this.hostNetworkInfo);
     this.genericControlPoint.OnSearch += new UPnPControlPoint.SearchHandler(this.UPnPControlPointSearchSink);
     this.genericControlPoint.OnNotify += new SSDP.NotifyHandler(this.SSDPNotifySink);
     this.genericControlPoint.FindDeviceAsync(_searchfilter);
 }
Ejemplo n.º 8
0
        //"ssdp:all"; //

        public UpnpSmartControlPoint()
        {
            deviceFactory.OnDevice        += DeviceFactoryCreationSink;
            deviceLifeTimeClock.OnExpired += DeviceLifeTimeClockSink;
            deviceUpdateClock.OnExpired   += DeviceUpdateClockSink;
            hostNetworkInfo = new NetworkInfo(NetworkInfoNewInterfaceSink);
            hostNetworkInfo.OnInterfaceDisabled += NetworkInfoOldInterfaceSink;
            genericControlPoint           = new UPnPControlPoint(hostNetworkInfo);
            genericControlPoint.OnSearch += UPnPControlPointSearchSink;
            genericControlPoint.OnNotify += SSDPNotifySink;
            genericControlPoint.FindDeviceAsync(searchFilter);
        }
Ejemplo n.º 9
0
 public void ShutDown()
 {
     deviceFactory.OnDevice              -= DeviceFactoryCreationSink;
     deviceLifeTimeClock.OnExpired       -= DeviceLifeTimeClockSink;
     deviceUpdateClock.OnExpired         -= DeviceUpdateClockSink;
     hostNetworkInfo.OnInterfaceDisabled -= NetworkInfoOldInterfaceSink;
     genericControlPoint.OnSearch        -= UPnPControlPointSearchSink;
     genericControlPoint.OnNotify        -= SSDPNotifySink;
     deviceFactory.Shutdown();
     deviceFactory = null;
     foreach (UPnPDevice dev in activeDeviceList)
     {
         dev.Removed();
     }
     hostNetworkInfo = null;
     genericControlPoint.Dispose();
     genericControlPoint = null;
 }
Ejemplo n.º 10
0
 public RemoteResourceInformationService()
 {
     _networkTracker = new UPnPNetworkTracker(new CPData());
     _controlPoint   = new UPnPControlPoint(_networkTracker);
 }