Switch to unified view

a/libupnpp/control/discovery.hxx b/libupnpp/control/discovery.hxx
...
...
21
#include <functional>
21
#include <functional>
22
22
23
#include "description.hxx"
23
#include "description.hxx"
24
24
25
namespace UPnPClient {
25
namespace UPnPClient {
26
27
static void *discoExplorer(void *);
26
28
27
/**
29
/**
28
 * Manage UPnP discovery and maintain a directory of active devices. Singleton.
30
 * Manage UPnP discovery and maintain a directory of active devices. Singleton.
29
 *
31
 *
30
 *
32
 *
...
...
66
    bool traverse(Visitor);
68
    bool traverse(Visitor);
67
69
68
    /** Remaining time until current search complete */
70
    /** Remaining time until current search complete */
69
    time_t getRemainingDelay();
71
    time_t getRemainingDelay();
70
72
73
    /** Set a callback to be called when devices report their existence 
74
     *  The visitor will be called once per device, with an empty service.
75
     */
76
    static unsigned int addCallback(Visitor v);
77
    static void delCallback(unsigned int idx);
78
79
    /** Find device by friendlyName or UDN. Unlike traverse, this does
80
     * not necessarily wait for the initial timeout, it returns as
81
     * soon as a device with this name reports (or the timeout expires). 
82
     * Note that "friendly names" are not necessarily unique.
83
     */
84
    bool getDevByFName(const std::string& fname, UPnPDeviceDesc& ddesc);
85
    bool getDevByUDN(const std::string& udn, UPnPDeviceDesc& ddesc);
86
71
    /** My health */
87
    /** My health */
72
    bool ok() {return m_ok;}
88
    bool ok() {return m_ok;}
73
    /** My diagnostic if health is bad */
89
    /** My diagnostic if health is bad */
74
    const std::string getReason() {return m_reason;}
90
    const std::string getReason() {return m_reason;}
75
91
76
private:
92
private:
77
    UPnPDeviceDirectory(time_t search_window);
93
    UPnPDeviceDirectory(time_t search_window);
78
    UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
94
    UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
79
    UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
95
    UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
96
97
    // Start UPnP search and record start of timeout
80
    bool search();
98
    bool search();
99
    // Look at the current pool and remove expired entries
81
    void expireDevices();
100
    void expireDevices();
101
102
    // This is called by the thread which processes the device events
103
    // when a new device appears. It wakes up any thread waiting for a
104
    // device.
105
    bool deviceFound(const UPnPDeviceDesc&, const UPnPServiceDesc&);
106
107
    // Lookup a device in the pool. If not found and a search is active, 
108
    // use a cond_wait to wait for device events (awaken by deviceFound).
109
    bool getDevBySelector(bool cmp(const UPnPDeviceDesc&, const std::string&), 
110
                          const std::string& value, UPnPDeviceDesc& ddesc);
111
112
    friend void *discoExplorer(void *);
82
113
83
    bool m_ok;
114
    bool m_ok;
84
    std::string m_reason;
115
    std::string m_reason;
85
    int m_searchTimeout;
116
    int m_searchTimeout;
86
    time_t m_lastSearch;
117
    time_t m_lastSearch;