コード例 #1
0
        public CpDeviceRecognised Recognise(CpDevice aDevice, RecogniserHandler aRecognised)
        {
            if (aDevice.Udn().StartsWith(kUdnLinnPrefix))
            {
                string xml;
                if (aDevice.GetAttribute("Upnp.DeviceXml", out xml))
                {
                    XmlNameTable        table   = new NameTable();
                    XmlNamespaceManager manager = new XmlNamespaceManager(table);
                    manager.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0");

                    XmlDocument doc = new XmlDocument(manager.NameTable);
                    try
                    {
                        doc.LoadXml(xml);
                    }
                    catch (Exception ex)
                    {
                        UserLog.WriteLine("RecogniserLinn.  Exception caught recognising device xml: " + ex);
                        UserLog.WriteLine(xml);
                        throw;
                    }

                    XmlNodeList nodes = doc.SelectNodes("/ns:root/ns:device/ns:serviceList/ns:service/ns:serviceType", manager);
                    foreach (XmlNode n in nodes)
                    {
                        if (n.FirstChild != null && n.FirstChild.InnerText == kProductServiceType)
                        {
                            UserLog.WriteLine(DateTime.Now + ": RecogniserLinn: Device+             Udn{" + aDevice.Udn() + "}");

                            return(new CpDeviceRecognisedLinn(aDevice, aRecognised));
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        private void Added(CpDeviceList aList, CpDevice aDevice)
        {
            UserLog.WriteLine(DateTime.Now + ": CpDeviceReprogramList: Device+             Udn{" + aDevice.Udn() + "}");

            CpDeviceVolkano device = CpDeviceVolkano.Create(aDevice, ReprogrammableAdded);

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                // check to see if device has been added immediately
                if (!iDeviceListReprogrammable.ContainsKey(device.MacAddress))
                {
                    iDeviceListPending.Add(device);
                }
            }
        }
コード例 #3
0
        private void Added(CpDeviceList aList, CpDevice aDevice)
        {
            UserLog.WriteLine(DateTime.Now + ": CpDeviceRecogniserList: Device+             Udn{" + aDevice.Udn() + "}");

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                foreach (IRecogniser r in iRecognisers)
                {
                    CpDeviceRecognised recognisedDevice = r.Recognise(aDevice, RecogniserAdded);
                    if (recognisedDevice != null)
                    {
                        // check to see if device has been added immediately
                        if (!iDeviceListRecognised.Contains(recognisedDevice))
                        {
                            iDeviceListPending.Add(recognisedDevice);
                        }

                        return;
                    }
                }
            }

            UserLog.WriteLine(DateTime.Now + ": CpDeviceRecogniserList: Device not recognised       Udn{" + aDevice.Udn() + "}");
        }
コード例 #4
0
        public CpDeviceRecognised Recognise(CpDevice aDevice, RecogniserHandler aRecognised)
        {
            string xml;

            if (aDevice.GetAttribute("Upnp.DeviceXml", out xml))
            {
                XmlNameTable        table   = new NameTable();
                XmlNamespaceManager manager = new XmlNamespaceManager(table);
                manager.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0");

                XmlDocument doc = new XmlDocument(manager.NameTable);
                try
                {
                    doc.LoadXml(xml);
                }
                catch (Exception ex)
                {
                    UserLog.WriteLine("RecogniserMediaServer.  Exception caught recognising device xml: " + ex);
                    UserLog.WriteLine(xml);
                    return(null);
                }

                XmlNode n = doc.SelectSingleNode("/ns:root/ns:device/ns:deviceType", manager);
                if (n != null && n.FirstChild != null && n.FirstChild.InnerText == kDeviceType)
                {
                    UserLog.WriteLine(DateTime.Now + ": RecogniserMediaServer: Device+             Udn{" + aDevice.Udn() + "}");

                    return(new CpDeviceRecognisedMediaServer(aDevice, aRecognised));
                }
            }

            return(null);
        }
コード例 #5
0
        public CpDeviceRecognised Recognise(CpDevice aDevice, RecogniserHandler aRecognised)
        {
            string version;

            if (aDevice.GetAttribute("Upnp.Service.schemas-upnp-org.DeviceProperties", out version))
            {
                UserLog.WriteLine(DateTime.Now + ": RecogniserSonos: Device+             Udn{" + aDevice.Udn() + "}");
                try
                {
                    return(new CpDeviceRecognisedSonos(aDevice, aRecognised));
                }
                catch (Exception ex)
                {
                    UserLog.WriteLine(DateTime.Now + "RecogniserSonos:  Exception caught recognising device xml: " + ex);
                    return(null);
                }
            }

            return(null);
        }
コード例 #6
0
        private void Added(CpDeviceList aList, CpDevice aDevice)
        {
            UserLog.WriteLine(DateTime.Now + ": CpDeviceDiagnosticsList: Device+             Udn{" + aDevice.Udn() + "}");

            string version;

            if (!aDevice.GetAttribute("Upnp.Service.av-openhome-org.Product", out version))
            {
                return;
            }

            CpDeviceDiagnostics device = new CpDeviceDiagnostics(aDevice, DiagnosticsAdded);

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                // check to see if device has been added immediately
                if (!iDeviceListDiagnostics.Contains(device))
                {
                    iDeviceListPending.Add(device);
                }
            }
        }