} // SwitchToActionView() /// <summary> /// Switches to the service view. /// </summary> /// <param name="service">The service.</param> private void SwitchToServiceView(UpnpService service) { if (this.serviceView == null) { this.serviceView = new ServiceInfoControl(); } // if this.serviceView.Service = service; this.serviceView.CheckForServiceImplementation(); this.SetCurrentViewControl(this.serviceView); this.currentView = this.serviceView; } // SwitchToServiceView()
private void BuildAdvertisementForService(UpnpService service) { var ad = CreateAdvertisement (service.Type.ToString (), string.Format ("{0}::{1}", service.Device.UDN, service.Type)); EventHandler<EventArgs<UpnpService>> onRemoved = null; onRemoved = (sender, args) => { ad.Shutdown(); this.SsdpServer.RemoveAnnouncer(ad); service.Removed -= onRemoved; }; service.Removed += onRemoved; }
private async Task DeleteDlnaContentAsync(UpnpService cds, string id) { if (id == null) { return; } try { await cds.Control(new DestroyObjectRequest { ObjectID = id, }); } catch (SoapException e) { DebugUtil.Log(() => "Failed to delete " + e.StatusCode); } }
} // AddDeviceNode() /// <summary> /// Adds a service node. /// </summary> /// <param name="deviceNode">The device node.</param> /// <param name="service">The service.</param> /// <returns>A <see cref="TreeNode"/>.</returns> private static TreeNode AddServiceNode(TreeNode deviceNode, UpnpService service) { const string ServicePrefix = "urn:schemas-upnp-org:service:"; var type = service.Type; if (type.StartsWith(ServicePrefix)) { type = type.Substring(ServicePrefix.Length); } // if var node = new TreeNode(type); node.ImageKey = @"Service"; node.SelectedImageKey = @"Service"; node.Tag = new NodeData(NodeType.Service, service); deviceNode.Nodes.Add(node); return(node); } // AddServiceNode()
//// --------------------------------------------------------------------- #region CONSTRUCTION /// <summary> /// Initializes a new instance of the <see cref="ContentDirectoryService" /> class. /// </summary> /// <param name="service">The service.</param> public ContentDirectoryService(UpnpService service) { this.Service = service; } // ContentDirectory2Service()
protected virtual void ServiceRemoved(UpnpDevice device, UpnpService service) { }
protected virtual UpnpService FindMatchFor(UpnpService service, IEnumerable<UpnpService> services) { return services.FirstOrDefault(child => service.Id == child.Id); }
protected virtual void CompareService(UpnpService to, UpnpService from) { }
} // FindTreeNode() /// <summary> /// Called when a service has been found. /// </summary> /// <param name="nodeDevice">The node device.</param> /// <param name="upnpDevice">The <c>UPnP</c> device.</param> /// <param name="service">The service.</param> private async void OnServiceFound(TreeNode nodeDevice, UpnpDevice upnpDevice, UpnpService service) { try { var url = UPNP.BuildUrl(upnpDevice, service.ScpdUrl); var text = await UPNP.GetRemoteTextFile(url); var serviceDescription = UPNP.ParseServiceSchema(text); service.UpdateServiceInfo(serviceDescription); service.ScpdUrl = url; service.ControlUrl = UPNP.BuildUrl(upnpDevice, service.ControlUrl); service.EventSubURL = UPNP.BuildUrl(upnpDevice, service.EventSubURL); #if SHOW_SEARCH_RESULTS log.Info($" {service.Type}"); #endif if ((service.Actions.Count == 0) && (service.StateVariables.Count == 0)) { // seems to be a dummy service return; } // if var tn = AddServiceNode(nodeDevice, service); foreach (var action in service.Actions) { action.Service = service; this.OnActionFound(tn, action); } // foreach } catch (Exception ex) { log.Error(ex.Message, ex); } // catch } // OnServiceFound()
public string GetServiceUsn(UpnpService service) => $"urn:{((service))}:serviceId:{this.id.ToString()}";