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 #include "libupnpp/config.h"
21 
22 #include <time.h>
23 
24 #include <string>
25 #include <functional>
26 #include <unordered_map>
27 
28 namespace UPnPClient {
29 class UPnPDeviceDesc;
30 }
31 namespace UPnPClient {
32 class UPnPServiceDesc;
33 }
34 
35 namespace UPnPClient {
36 
61 public:
68  static UPnPDeviceDirectory *getTheDir(time_t search_window = 2);
69 
71  static void terminate();
72 
75  typedef std::function<bool (const UPnPDeviceDesc&,
77 
80  bool traverse(Visitor);
81 
83  time_t getRemainingDelayMs();
86  time_t getRemainingDelay();
87 
93  static unsigned int addCallback(Visitor v);
94  static void delCallback(unsigned int idx);
95 
106  bool getDevByFName(const std::string& fname, UPnPDeviceDesc& ddesc);
107 
116  bool getDevByUDN(const std::string& udn, UPnPDeviceDesc& ddesc);
117 
126  const std::string &uidOrFriendly, std::string& deviceXML,
127  std::unordered_map<std::string, std::string>& srvsXML);
128 
129 
131  bool ok();
132 
134  const std::string getReason();
135 
136 private:
138  UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &);
139  UPnPDeviceDirectory(time_t search_window);
140 };
141 
142 } // namespace UPnPClient
143 
144 #endif /* _UPNPPDISC_H_X_INCLUDED_ */
bool getDescriptionDocuments(const std::string &uidOrFriendly, std::string &deviceXML, std::unordered_map< std::string, std::string > &srvsXML)
Helper function: retrieve all description data for a named device.
Definition: discovery.cxx:599
time_t getRemainingDelay()
Remaining seconds until current search complete.
Definition: discovery.cxx:461
static unsigned int addCallback(Visitor v)
Set a callback to be called when devices report their existence The function will be called once per ...
Definition: discovery.cxx:217
static UPnPDeviceDirectory * getTheDir(time_t search_window=2)
Retrieve the singleton object for the discovery service, and possibly start it up if this is the firs...
Definition: discovery.cxx:428
std::function< bool(const UPnPDeviceDesc &, const UPnPServiceDesc &)> Visitor
Type of user callback functions used for reporting devices and services.
Definition: discovery.hxx:76
bool getDevByUDN(const std::string &udn, UPnPDeviceDesc &ddesc)
Find device by UDN.
Definition: discovery.cxx:593
const std::string getReason()
My diagnostic if health is bad.
Definition: discovery.cxx:386
bool ok()
My health.
Definition: discovery.cxx:381
bool getDevByFName(const std::string &fname, UPnPDeviceDesc &ddesc)
Find device by &#39;friendly name&#39;.
Definition: discovery.cxx:582
bool traverse(Visitor)
Possibly wait for the end of the initial delay, then traverse the directory and call Visitor for each...
Definition: discovery.cxx:504
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:60
static void terminate()
Clean up before exit.
Definition: discovery.cxx:437
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition: description.hxx:142
time_t getRemainingDelayMs()
Remaining milliseconds until current search complete.
Definition: discovery.cxx:448
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition: avlastchg.cxx:28