libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
discovery.hxx
1 /* Copyright (C) 2006-2016 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 _UPNPPDISC_H_X_INCLUDED_
19 #define _UPNPPDISC_H_X_INCLUDED_
20 
21 #include <time.h>
22 
23 #include <string>
24 #include <functional>
25 #include <unordered_map>
26 
27 #include "libupnpp/upnppexports.hxx"
28 
29 namespace UPnPClient {
30 class UPnPDeviceDesc;
31 }
32 namespace UPnPClient {
33 class UPnPServiceDesc;
34 }
35 
36 namespace UPnPClient {
37 
61 class UPNPP_API UPnPDeviceDirectory {
62 public:
69  static UPnPDeviceDirectory *getTheDir(time_t search_window = 2);
70 
72  static void terminate();
73 
76  typedef std::function<bool (const UPnPDeviceDesc&,
78 
81  bool traverse(Visitor);
82 
84  time_t getRemainingDelayMs();
87  time_t getRemainingDelay();
88 
94  static unsigned int addCallback(Visitor v);
95  static void delCallback(unsigned int idx);
96 
107  bool getDevByFName(const std::string& fname, UPnPDeviceDesc& ddesc);
108 
117  bool getDevByUDN(const std::string& udn, UPnPDeviceDesc& ddesc);
118 
126  bool getDescriptionDocuments(
127  const std::string &uidOrFriendly, std::string& deviceXML,
128  std::unordered_map<std::string, std::string>& srvsXML);
129 
130 
132  bool ok();
133 
135  const std::string getReason();
136 
137 private:
138  UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
139  UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
140  UPNPP_LOCAL UPnPDeviceDirectory(time_t search_window);
141 };
142 
143 } // namespace UPnPClient
144 
145 #endif /* _UPNPPDISC_H_X_INCLUDED_ */
std::function< bool(const UPnPDeviceDesc &, const UPnPServiceDesc &)> Visitor
Type of user callback functions used for reporting devices and services.
Definition: discovery.hxx:77
Data holder for a UPnP service, parsed from the device XML description.
Definition: description.hxx:46
Manage UPnP discovery and maintain a directory of active devices.
Definition: discovery.hxx:61
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition: description.hxx:142
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition: avlastchg.cxx:27