libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
description.hxx
1/* Copyright (C) 2006-2024 J.F.Dockes
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18#ifndef _UPNPDEV_HXX_INCLUDED_
19#define _UPNPDEV_HXX_INCLUDED_
20
26#include <unordered_map>
27#include <vector>
28#include <string>
29#include <sstream>
30
31#include "libupnpp/upnppexports.hxx"
32
33namespace UPnPClient {
34
46class UPNPP_API UPnPServiceDesc {
47public:
49 std::string serviceType;
51 std::string serviceId;
53 std::string SCPDURL;
55 std::string controlURL;
57 std::string eventSubURL;
58
60 void clear() {
61 serviceType.clear();
62 serviceId.clear();
63 SCPDURL.clear();
64 controlURL.clear();
65 eventSubURL.clear();
66 }
67
69 std::string dump() const {
70 std::ostringstream os;
71 os << "SERVICE {serviceType [" << serviceType << "] serviceId [" << serviceId <<
72 "] SCPDURL [" << SCPDURL << "] controlURL [" << controlURL << "] eventSubURL [" <<
73 eventSubURL << "] }" << '\n';
74 return os.str();
75 }
76
79 struct Argument {
80 std::string name;
81 bool todevice;
82 std::string relatedVariable;
83 void clear() {
84 name.clear();
85 todevice = true;
86 relatedVariable.clear();
87 }
88 };
89
91 struct Action {
92 std::string name;
93 std::vector<Argument> argList;
94 void clear() {
95 name.clear();
96 argList.clear();
97 }
98 };
99
102 std::string name;
103 bool sendEvents;
104 std::string dataType;
105 bool hasValueRange;
106 int minimum;
107 int maximum;
108 int step;
109 void clear() {
110 name.clear();
111 sendEvents = false;
112 dataType.clear();
113 hasValueRange = false;
114 }
115 };
116
119 struct Parsed {
120 std::unordered_map<std::string, Action> actionList;
121 std::unordered_map<std::string, StateVariable> stateTable;
122 };
123
129 bool fetchAndParseDesc(const std::string& urlbase, Parsed& parsed,
130 std::string *XMLText = 0) const;
131};
132
139class UPNPP_API UPnPDeviceDesc {
140public:
148 UPnPDeviceDesc(const std::string& url, const std::string& description);
149
150 UPnPDeviceDesc() = default;
151
153 bool ok{false};
155 std::string deviceType;
157 std::string friendlyName;
160 std::string UDN;
162 std::string descURL;
168 std::string URLBase;
170 std::string manufacturer;
172 std::string modelName;
173
175 std::string XMLText;
176
178 std::vector<UPnPServiceDesc> services;
179
183 std::vector<UPnPDeviceDesc> embedded;
184
185 void clear() {
186 *this = UPnPDeviceDesc();
187 }
188 std::string dump() const {
189 std::ostringstream os;
190 os << "DEVICE " << " {deviceType [" << deviceType << "] friendlyName [" << friendlyName <<
191 "] UDN [" << UDN << "] URLBase [" << URLBase << "] Services:" << '\n';
192 for (const auto& service : services) {
193 os << " " << service.dump();
194 }
195 for (const auto& it: embedded) {
196 os << it.dump();
197 }
198 os << "}" << '\n';
199 return os.str();
200 }
201};
202
203} // namespace
204
205#endif /* _UPNPDEV_HXX_INCLUDED_ */
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition description.hxx:139
std::string descURL
URL the device description XML was downloaded from.
Definition description.hxx:162
UPnPDeviceDesc(const std::string &url, const std::string &description)
Build device from the XML description downloaded during discovery.
std::string XMLText
Raw downloaded document.
Definition description.hxx:175
std::string URLBase
scheme:authority/ part of the descURL above, e.g.
Definition description.hxx:168
std::string UDN
Unique Device Number.
Definition description.hxx:160
std::vector< UPnPServiceDesc > services
Services provided by this device.
Definition description.hxx:178
std::string friendlyName
User-configurable name (usually), e.g. Lounge-streamer.
Definition description.hxx:157
std::string manufacturer
Manufacturer: e.g. D-Link, PacketVideo.
Definition description.hxx:170
std::vector< UPnPDeviceDesc > embedded
Embedded devices.
Definition description.hxx:183
std::string deviceType
Device Type: e.g. urn:schemas-upnp-org:device:MediaServer:1.
Definition description.hxx:155
std::string modelName
Model name: e.g. MediaTomb, DNS-327L.
Definition description.hxx:172
Data holder for a UPnP service, parsed from the device XML description.
Definition description.hxx:46
std::string serviceType
Service Type e.g. urn:schemas-upnp-org:service:ConnectionManager:1.
Definition description.hxx:49
std::string SCPDURL
Service description URL.
Definition description.hxx:53
std::string controlURL
Service control URL.
Definition description.hxx:55
std::string dump() const
Debug: return the basic parsed data as a string.
Definition description.hxx:69
std::string eventSubURL
Service event URL.
Definition description.hxx:57
void clear()
Reset all data.
Definition description.hxx:60
std::string serviceId
Service Id inside device: e.g. urn:upnp-org:serviceId:ConnectionManager.
Definition description.hxx:51
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition avlastchg.cxx:28
UPnP service action descriptor, from the service description document.
Definition description.hxx:91
Description of an action argument: name, direction, state variable it relates to (which will yield th...
Definition description.hxx:79
Service description as parsed from the service XML document: actions and state variables.
Definition description.hxx:119
Holder for all the attributes of an UPnP service state variable.
Definition description.hxx:101