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); } } }
public static CpDeviceVolkano Create(CpDevice aDevice, DeviceVolkanoHandler aHandler) { string value; if (aDevice.GetAttribute("Upnp.Service.av-openhome-org.Product", out value)) { return(new CpDeviceMain(aDevice, aHandler)); } return(new CpDeviceFallback(aDevice, aHandler)); }
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); }
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); }
public CpDeviceVolkano(CpDevice aDevice, DeviceVolkanoHandler aHandler) { try { iHandler = aHandler; iDevice = aDevice; iDevice.AddRef(); iLock = new object(); iVolkanoService = new CpProxyLinnCoUkVolkano1(iDevice); iModel = "Unknown"; string xml; if (iDevice.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); doc.LoadXml(xml); XmlNode node = doc.SelectSingleNode("/ns:root/ns:device/ns:modelName", manager); if (node != null && node.FirstChild != null) { iModel = node.FirstChild.InnerText; if (iModel.StartsWith("Reprogram-")) { string[] split = iModel.Split(new char[] { '-' }, 2); if (split.Length == 2) { iModel = split[1]; } } } } iVolkanoService.SyncMacAddress(out iMacAddress); iVolkanoService.SyncSoftwareVersion(out iSoftwareVersion); iVolkanoService.SyncProductId(out iProductNumber); iPcbNumberList = new List <string>(); uint count; iVolkanoService.SyncMaxBoards(out count); for (uint i = 0; i < count; ++i) { string number; iVolkanoService.SyncBoardType(i, out number); iPcbNumberList.Add(Convert.ToUInt32(number.Substring(0, 8), 16).ToString()); } } catch { aDevice.RemoveRef(); throw; } }
public CpDeviceRecognisedMediaServer(CpDevice aDevice, RecogniserHandler aRecognised) : base(aDevice) { try { iRecognised = aRecognised; iProductImageUri = kProductImageUri; 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); doc.LoadXml(xml); string baseUri = string.Empty; XmlNode node = doc.SelectSingleNode("/ns:root/ns:URLBase", manager); if (node == null) { string location; if (aDevice.GetAttribute("Upnp.Location", out location)) { Uri uri = new Uri(location); baseUri = string.Format("{0}://{1}", uri.Scheme, uri.Authority); } } else if (node.FirstChild != null) { baseUri = node.FirstChild.InnerText; } iBaseUri = baseUri; XmlNodeList nodes = doc.SelectNodes("/ns:root/ns:device/ns:iconList/ns:icon", manager); int width = 0; int height = 0; foreach (XmlNode n in nodes) { bool found = false; XmlNode w = n.SelectSingleNode("ns:width", manager); XmlNode h = n.SelectSingleNode("ns:height", manager); XmlNode u = n.SelectSingleNode("ns:url", manager); if (w != null && w.FirstChild != null) { try { int i = int.Parse(w.FirstChild.InnerText); if (i > width) { width = i; height = i; found = true; } } catch (FormatException) { } } if (h != null && h.FirstChild != null) { try { int i = int.Parse(h.FirstChild.InnerText); if (i > height) { width = i; height = i; found = true; } } catch (FormatException) { } } if (found && u != null && u.FirstChild != null) { iProductImageUri = baseUri; if (!iProductImageUri.EndsWith("/") && !u.FirstChild.InnerText.StartsWith("/")) { iProductImageUri += "/"; } iProductImageUri += u.FirstChild.InnerText; } } } string name; if (Device.GetAttribute("Upnp.FriendlyName", out name)) { iFriendlyName = name; } else { iFriendlyName = string.Empty; } iRecognised(this); } catch { throw; } }