Switch to unified view

a/libupnpp/device/device.hxx b/libupnpp/device/device.hxx
...
...
19
19
20
#include <unordered_map>
20
#include <unordered_map>
21
#include <functional>
21
#include <functional>
22
22
23
#include "libupnpp/soaphelp.hxx"
23
#include "libupnpp/soaphelp.hxx"
24
#include "libupnpp/ptmutex.hxx"
24
25
25
namespace UPnPProvider {
26
namespace UPnPProvider {
26
27
27
class UpnpService;
28
class UpnpService;
28
29
...
...
42
    /**
43
    /**
43
     * Add mapping from service+action-name to handler function.
44
     * Add mapping from service+action-name to handler function.
44
     */
45
     */
45
    void addActionMapping(const UpnpService*, 
46
    void addActionMapping(const UpnpService*, 
46
                          const std::string& actName, soapfun);
47
                          const std::string& actName, soapfun);
47
48
    /** 
49
     * Generate event.
50
     *
51
     * To be called by the device layer when data changes and an
52
     * event should happen. Use is not mandatory because the polling by 
53
     * getEventData() may be sufficient.
54
     */
55
    void notifyEvent(const std::string& serviceId,
56
                     const std::vector<std::string>& names, 
57
                     const std::vector<std::string>& values);
58
48
59
    /** 
49
    /** 
60
     * Main routine. To be called by main() when done with initialization. 
50
     * Main routine. To be called by main() when done with initialization. 
61
     *
51
     *
62
     * This loop mostly polls getEventData and generates an UPnP event if
52
     * This loop mostly polls getEventData and generates an UPnP event if
...
...
91
    // vector for ordered walking while fetching status. Order is
81
    // vector for ordered walking while fetching status. Order is
92
    // determine by addService() call sequence.
82
    // determine by addService() call sequence.
93
    std::unordered_map<std::string, UpnpService*> m_servicemap;
83
    std::unordered_map<std::string, UpnpService*> m_servicemap;
94
    std::vector<std::string> m_serviceids;
84
    std::vector<std::string> m_serviceids;
95
    std::unordered_map<std::string, soapfun> m_calls;
85
    std::unordered_map<std::string, soapfun> m_calls;
86
    unordered_map<string, UpnpService*>::const_iterator findService(const string& serviceid);
87
96
    bool m_needExit;
88
    bool m_needExit;
89
    /* My device handle */
90
    UpnpDevice_Handle m_dvh;
91
92
    /* Lock for device operations. Held during a service callback 
93
       Must not be held when using m_dvh to call into libupnp */
94
    UPnPP::PTMutexInit m_lock;
95
96
    pthread_cond_t m_evloopcond;
97
    UPnPP::PTMutexInit m_evlooplock;
98
99
    /* Gets called when something needs doing */
100
    int callBack(Upnp_EventType et, void* evp);
101
102
    /** 
103
     * Generate event.
104
     *
105
     * Called by the device event loop, which polls the services.
106
     * Use loopwakeup() to expedite things.
107
     */
108
    void notifyEvent(const std::string& serviceId,
109
                     const std::vector<std::string>& names, 
110
                     const std::vector<std::string>& values);
111
112
113
    /** Static array of devices for dispatching */
97
    static unordered_map<std::string, UpnpDevice *> o_devices;
114
    static unordered_map<std::string, UpnpDevice *> o_devices;
98
115
99
    /* Static callback for libupnp. This looks up the appropriate
116
    /* Static callback for libupnp. This looks up the appropriate
100
     * device using the device ID (UDN), the calls its callback
117
     * device using the device ID (UDN), the calls its callback
101
     * method */
118
     * method */
102
    static int sCallBack(Upnp_EventType et, void* evp, void*);
119
    static int sCallBack(Upnp_EventType et, void* evp, void*);
103
104
    /* Gets called when something needs doing */
105
    int callBack(Upnp_EventType et, void* evp);
106
107
    /* My device handle */
108
    UpnpDevice_Handle m_dvh;
109
};
120
};
110
121
111
/**
122
/**
112
 * Upnp service implementation class. This does not do much useful beyond
123
 * Upnp service implementation class. This does not do much useful beyond
113
 * encapsulating the service actions and event callback. In most cases, the
124
 * encapsulating the service actions and event callback. In most cases, the