Switch to unified view

a/libupnpp/control/service.cxx b/libupnpp/control/service.cxx
...
...
28
#include "libupnpp/control/service.hxx"
28
#include "libupnpp/control/service.hxx"
29
#include "libupnpp/control/cdirectory.hxx"
29
#include "libupnpp/control/cdirectory.hxx"
30
#include "libupnpp/control/avlastchg.hxx"
30
#include "libupnpp/control/avlastchg.hxx"
31
31
32
namespace UPnPClient {
32
namespace UPnPClient {
33
34
Service *service_factory(const string& servicetype,
35
                         const UPnPDeviceDesc& device,
36
                         const UPnPServiceDesc& service)
37
{
38
    if (ContentDirectoryService::isCDService(servicetype)) {
39
        return new ContentDirectoryService(device, service);
40
    } else {
41
        LOGERR("service_factory: unknown service type " << servicetype << endl);
42
        return 0;
43
    }
44
}
45
33
46
// A small helper class for the functions which perform
34
// A small helper class for the functions which perform
47
// UpnpSendAction calls: get rid of IXML docs when done.
35
// UpnpSendAction calls: get rid of IXML docs when done.
48
class IxmlCleaner {
36
class IxmlCleaner {
49
public:
37
public:
...
...
116
104
117
    case UPNP_EVENT_RECEIVED:
105
    case UPNP_EVENT_RECEIVED:
118
    {
106
    {
119
        struct Upnp_Event *evp = (struct Upnp_Event *)vevp;
107
        struct Upnp_Event *evp = (struct Upnp_Event *)vevp;
120
        LOGDEB1("Service:srvCB: var change event: Sid: " <<
108
        LOGDEB1("Service:srvCB: var change event: Sid: " <<
121
               evp->Sid << " EventKey " << evp->EventKey << 
109
                evp->Sid << " EventKey " << evp->EventKey << 
122
               " changed: " << ixmlPrintDocument(evp->ChangedVariables)<< endl);
110
                " changed " << ixmlPrintDocument(evp->ChangedVariables)<< endl);
123
124
        
111
        
125
        unordered_map<string, string> props;
112
        unordered_map<string, string> props;
126
        if (!decodePropertySet(evp->ChangedVariables, props)) {
113
        if (!decodePropertySet(evp->ChangedVariables, props)) {
127
            LOGERR("Service::srvCB: could not decode EVENT propertyset" <<endl);
114
            LOGERR("Service::srvCB: could not decode EVENT propertyset" <<endl);
128
            return UPNP_E_BAD_RESPONSE;
115
            return UPNP_E_BAD_RESPONSE;
129
        }
116
        }
130
        //for (auto& entry: props) {
117
        //for (auto& entry: props) {
131
        //LOGDEB(entry.first << " -> " << entry.second << endl;);
118
        //LOGDEB("srvCB: " << entry.first << " -> " << entry.second << endl);
132
        //}
119
        //}
120
133
        std::unordered_map<std::string, evtCBFunc>::iterator it = 
121
        std::unordered_map<std::string, evtCBFunc>::iterator it = 
134
            o_calls.find(evp->Sid);
122
            o_calls.find(evp->Sid);
135
136
        if (it!= o_calls.end()) {
123
        if (it!= o_calls.end()) {
137
            (it->second)(props);
124
            (it->second)(props);
138
        } else {
125
        } else {
139
            LOGINF("Service::srvCB: no callback found for " << evp->Sid << 
126
            LOGINF("Service::srvCB: no callback found for sid " << evp->Sid << 
140
                   endl);
127
                   endl);
141
        }
128
        }
142
        break;
129
        break;
143
    }
130
    }
144
131
...
...
195
    if (ret != UPNP_E_SUCCESS) {
182
    if (ret != UPNP_E_SUCCESS) {
196
        LOGERR("Service:subscribe: failed: " << 
183
        LOGERR("Service:subscribe: failed: " << 
197
               UpnpGetErrorMessage(ret) << endl);
184
               UpnpGetErrorMessage(ret) << endl);
198
        return false;
185
        return false;
199
    } 
186
    } 
200
    LOGDEB("Service::subscribe: sid: " << m_SID << endl);
187
    //LOGDEB("Service::subscribe: sid: " << m_SID << endl);
201
    return true;
188
    return true;
202
}
189
}
203
190
204
void Service::registerCallback(evtCBFunc c)
191
void Service::registerCallback(evtCBFunc c)
205
{
192
{