Esempio n. 1
0
 /// <summary>
 /// Contains information about the location of a device on the network.
 /// </summary>
 /// <param name="Client">UPnP Client</param>
 /// <param name="Headers">All headers in notification.</param>
 /// <param name="LocalEndPoint">Local End Point.</param>
 /// <param name="RemoteEndPoint">Remote End Point.</param>
 internal NotificationEventArgs(UPnPClient Client, UPnPHeaders Headers, IPEndPoint LocalEndPoint, IPEndPoint RemoteEndPoint)
 {
     this.client         = Client;
     this.headers        = Headers;
     this.localEndPoint  = LocalEndPoint;
     this.remoteEndPoint = RemoteEndPoint;
 }
Esempio n. 2
0
        /// <summary>
        /// Contains information about a service.
        /// </summary>
        /// <param name="Xml">XML element</param>
        /// <param name="BaseUri">Base URI</param>
        /// <param name="Client">UPnP Client</param>
        public UPnPService(XmlElement Xml, Uri BaseUri, UPnPClient Client)
        {
            this.client = Client;
            this.xml    = Xml;

            foreach (XmlNode N in Xml.ChildNodes)
            {
                switch (N.LocalName)
                {
                case "serviceType":
                    this.serviceType = N.InnerText;
                    break;

                case "serviceId":
                    this.serviceId = N.InnerText;
                    break;

                case "SCPDURL":
                    this.scpdURL = N.InnerText;
                    this.scpdURI = new Uri(BaseUri, this.scpdURL);
                    break;

                case "controlURL":
                    this.controlURL = N.InnerText;
                    this.controlURI = new Uri(BaseUri, this.controlURL);
                    break;

                case "eventSubURL":
                    this.eventSubURL = N.InnerText;
                    this.eventSubURI = new Uri(BaseUri, this.eventSubURL);
                    break;
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Contains information about the location of a device on the network.
 /// </summary>
 /// <param name="Client">UPnP Client.</param>
 /// <param name="SearchTarget">SSDP Search Target</param>
 /// <param name="Server">Server</param>
 /// <param name="Location">Location of device information</param>
 /// <param name="UniqueServiceName">Unique Service Name (USN)</param>
 /// <param name="Headers">All headers in response.</param>
 internal DeviceLocation(UPnPClient Client, string SearchTarget, string Server, string Location, string UniqueServiceName, UPnPHeaders Headers)
 {
     this.client            = Client;
     this.searchTarget      = SearchTarget;
     this.server            = Server;
     this.location          = Location;
     this.uniqueServiceName = UniqueServiceName;
     this.headers           = Headers;
 }
Esempio n. 4
0
 /// <summary>
 /// Contains information about a service.
 /// </summary>
 /// <param name="Client">UPnP Client</param>
 /// <param name="ServiceType">Service type.</param>
 /// <param name="ServiceId">Service ID</param>
 /// <param name="ScpdUrl">URL to SCPD specification.</param>
 public UPnPService(UPnPClient Client, string ServiceType, string ServiceId, string ScpdUrl)
 {
     this.client      = Client;
     this.xml         = null;
     this.serviceType = ServiceType;
     this.serviceId   = ServiceId;
     this.scpdURL     = ScpdUrl;
     this.scpdURI     = new Uri(ScpdUrl);
     this.controlURL  = null;
     this.controlURI  = null;
     this.eventSubURL = null;
     this.eventSubURI = null;
 }
Esempio n. 5
0
        internal DeviceDescriptionDocument(XmlDocument Xml, UPnPClient Client, string BaseUrl)
        {
            this.xml = Xml;

            if (Xml.DocumentElement != null && Xml.DocumentElement.LocalName == "root" &&
                Xml.DocumentElement.NamespaceURI == "urn:schemas-upnp-org:device-1-0")
            {
                if (!string.IsNullOrEmpty(BaseUrl))
                {
                    this.baseUrl = BaseUrl;
                    this.baseUri = new Uri(this.baseUrl);
                }

                foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
                {
                    switch (N.LocalName)
                    {
                    case "specVersion":
                        foreach (XmlNode N2 in N.ChildNodes)
                        {
                            switch (N2.LocalName)
                            {
                            case "major":
                                this.majorVersion = int.Parse(N2.InnerText);
                                break;

                            case "minor":
                                this.minorVersion = int.Parse(N2.InnerText);
                                break;
                            }
                        }
                        break;

                    case "URLBase":
                        this.baseUrl = N.InnerText;
                        this.baseUri = new Uri(this.baseUrl);
                        break;

                    case "device":
                        this.device = new UPnPDevice((XmlElement)N, this.baseUri, Client);
                        break;
                    }
                }
            }
            else
            {
                throw new Exception("Unrecognized file format.");
            }
        }
Esempio n. 6
0
        internal UPnPDevice(XmlElement Xml, Uri BaseUri, UPnPClient Client)
        {
            List <UPnPIcon>    Icons    = new List <UPnPIcon>();
            List <UPnPService> Services = new List <UPnPService>();
            List <UPnPDevice>  Devices  = new List <UPnPDevice>();

            this.xml = Xml;

            foreach (XmlNode N in Xml.ChildNodes)
            {
                switch (N.LocalName)
                {
                case "deviceType":
                    this.deviceType = N.InnerText;
                    break;

                case "friendlyName":
                    this.friendlyName = N.InnerText;
                    break;

                case "manufacturer":
                    this.manufacturer = N.InnerText;
                    break;

                case "manufacturerURL":
                    this.manufacturerURL = N.InnerText;
                    this.manufacturerURI = new Uri(BaseUri, this.manufacturerURL);
                    break;

                case "modelDescription":
                    this.modelDescription = N.InnerText;
                    break;

                case "modelName":
                    this.modelName = N.InnerText;
                    break;

                case "modelNumber":
                    this.modelNumber = N.InnerText;
                    break;

                case "modelURL":
                    this.modelURL = N.InnerText;
                    this.modelURI = new Uri(BaseUri, this.modelURL);
                    break;

                case "serialNumber":
                    this.serialNumber = N.InnerText;
                    break;

                case "UDN":
                    this.udn = N.InnerText;
                    break;

                case "UPC":
                    this.upc = N.InnerText;
                    break;

                case "iconList":
                    foreach (XmlNode N2 in N.ChildNodes)
                    {
                        if (N2.LocalName == "icon")
                        {
                            Icons.Add(new UPnPIcon((XmlElement)N2, BaseUri));
                        }
                    }
                    break;

                case "serviceList":
                    foreach (XmlNode N2 in N.ChildNodes)
                    {
                        if (N2.LocalName == "service")
                        {
                            Services.Add(new UPnPService((XmlElement)N2, BaseUri, Client));
                        }
                    }
                    break;

                case "deviceList":
                    foreach (XmlNode N2 in N.ChildNodes)
                    {
                        if (N2.LocalName == "device")
                        {
                            Devices.Add(new UPnPDevice((XmlElement)N2, BaseUri, Client));
                        }
                    }
                    break;

                case "presentationURL":
                    this.presentationURL = N.InnerText;
                    this.presentationURI = new Uri(BaseUri, this.presentationURL);
                    break;
                }
            }

            this.icons    = Icons.ToArray();
            this.services = Services.ToArray();
            this.devices  = Devices.ToArray();
        }
        internal ServiceDescriptionDocument(XmlDocument Xml, UPnPClient Client, UPnPService Service)
        {
            List <UPnPStateVariable> Variables = new List <UPnPStateVariable>();
            List <UPnPAction>        Actions   = new List <UPnPAction>();

            this.xml     = Xml;
            this.service = Service;

            if (Xml.DocumentElement != null && Xml.DocumentElement.LocalName == "scpd" &&
                Xml.DocumentElement.NamespaceURI == "urn:schemas-upnp-org:service-1-0")
            {
                foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
                {
                    switch (N.LocalName)
                    {
                    case "specVersion":
                        foreach (XmlNode N2 in N.ChildNodes)
                        {
                            switch (N2.LocalName)
                            {
                            case "major":
                                this.majorVersion = int.Parse(N2.InnerText);
                                break;

                            case "minor":
                                this.minorVersion = int.Parse(N2.InnerText);
                                break;
                            }
                        }
                        break;

                    case "actionList":
                        foreach (XmlNode N2 in N.ChildNodes)
                        {
                            if (N2.LocalName == "action")
                            {
                                UPnPAction Action = new UPnPAction((XmlElement)N2, this);
                                Actions.Add(Action);
                                this.actionsByName[Action.Name] = Action;
                            }
                        }
                        break;

                    case "serviceStateTable":
                        foreach (XmlNode N2 in N.ChildNodes)
                        {
                            if (N2.LocalName == "stateVariable")
                            {
                                UPnPStateVariable Variable = new UPnPStateVariable((XmlElement)N2);
                                Variables.Add(Variable);
                                this.variablesByName[Variable.Name] = Variable;
                            }
                        }
                        break;
                    }
                }
            }
            else
            {
                throw new Exception("Unrecognized file format.");
            }

            this.actions   = Actions.ToArray();
            this.variables = Variables.ToArray();
        }