libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
device.hxx
1/* Copyright (C) 2006-2020 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 _DEVICE_H_X_INCLUDED_
19#define _DEVICE_H_X_INCLUDED_
20
21#include <functional>
22#include <memory>
23#include <string>
24#include <vector>
25#include <map>
26
27#include "libupnpp/device/service.hxx"
28#include "libupnpp/soaphelp.hxx"
29#include "libupnpp/upnperrcodes.hxx"
30#include "libupnpp/upnppexports.hxx"
31
32namespace UPnPProvider {
33
34class UpnpService;
35
36typedef std::function<int (const UPnPP::SoapIncoming&, UPnPP::SoapOutgoing&)>
37soapfun;
38
54class UPNPP_API UpnpDevice {
55public:
56
64 UpnpDevice(const std::string& deviceId);
65
75 UpnpDevice(UpnpDevice *rootdev, const std::string& deviceId);
76
77 virtual ~UpnpDevice();
78
81 void setProductVersion(const char *product, const char *version);
82
84 static bool ipv4(std::string *host, unsigned short *port);
85
108 virtual bool readLibFile(const std::string& name, std::string& contents) = 0;
109
123 bool addVFile(const std::string& name, const std::string& contents,
124 const std::string& mime, std::string& path);
125
131 void addActionMapping(const UpnpService*,
132 const std::string& actName, soapfun);
133
135 const std::string& getDeviceId() const;
136
138 bool ok();
139
163 void eventloop();
164
171 void startloop();
172
182 void loopWakeup();
183
187 void shouldExit();
188
195 bool start();
196
205 void notifyEvent(const UpnpService *service,
206 const std::vector<std::string>& names,
207 const std::vector<std::string>& values);
208
209
210
211 /* *******************************************************************
212 * Methods called by the service constructor to link the
213 * service object and its methods to the Device one, establishing
214 * the eventing and action communication. This is internal and
215 * should not be called by the library user. Not too sure how this
216 * could/should be expressed in C++... */
217
224 bool addService(UpnpService *);
225 void forgetService(const std::string& serviceId);
226
227private:
228 class UPNPP_LOCAL Internal;
229 Internal *m;
230 class InternalStatic;
231 static InternalStatic *o;
232};
233
234} // End namespace UPnPProvider
235
236#endif /* _DEVICE_H_X_INCLUDED_ */
Store incoming Soap data: device action input parameters, or response to CP.
Definition soaphelp.hxx:36
Store the values to be encoded in outgoing SOAP data: device response or CP args.
Definition soaphelp.hxx:88
Definition devdevice.cxx:122
Definition devdevice.cxx:57
Base Device class.
Definition device.hxx:54
virtual bool readLibFile(const std::string &name, std::string &contents)=0
Librarian utility.
UpnpDevice(UpnpDevice *rootdev, const std::string &deviceId)
Construct an embedded device.
UpnpDevice(const std::string &deviceId)
Construct a device object.
Upnp service base class.
Definition service.hxx:36
Virtual directory handler to satisfy libupnp miniserver GETs.
Definition devdevice.cxx:55