Switch to unified view

a/libupnpp/control/cdirectory.cxx b/libupnpp/control/cdirectory.cxx
...
...
41
#include "libupnpp/control/discovery.hxx"
41
#include "libupnpp/control/discovery.hxx"
42
42
43
namespace UPnPClient {
43
namespace UPnPClient {
44
44
45
// The service type string for Content Directories:
45
// The service type string for Content Directories:
46
const string ContentDirectoryService::SType("urn:schemas-upnp-org:service:ContentDirectory:1");
46
const string ContentDirectory::SType("urn:schemas-upnp-org:service:ContentDirectory:1");
47
47
48
// We don't include a version in comparisons, as we are satisfied with
48
// We don't include a version in comparisons, as we are satisfied with
49
// version 1
49
// version 1
50
bool ContentDirectoryService::isCDService(const string& st)
50
bool ContentDirectory::isCDService(const string& st)
51
{
51
{
52
    const string::size_type sz(SType.size()-2);
52
    const string::size_type sz(SType.size()-2);
53
    return !SType.compare(0, sz, st, 0, sz);
53
    return !SType.compare(0, sz, st, 0, sz);
54
}
54
}
55
55
56
static bool DSAccum(vector<CDSH>* out,
56
static bool DSAccum(vector<CDSH>* out,
57
                    const UPnPDeviceDesc& device, 
57
                    const UPnPDeviceDesc& device, 
58
                    const UPnPServiceDesc& service)
58
                    const UPnPServiceDesc& service)
59
{
59
{
60
    if (ContentDirectoryService::isCDService(service.serviceType)) {
60
    if (ContentDirectory::isCDService(service.serviceType)) {
61
        out->push_back(CDSH(new ContentDirectoryService(device, service)));
61
        out->push_back(CDSH(new ContentDirectory(device, service)));
62
    }
62
    }
63
    return true;
63
    return true;
64
}
64
}
65
65
66
bool ContentDirectoryService::getServices(vector<CDSH>& vds)
66
bool ContentDirectory::getServices(vector<CDSH>& vds)
67
{
67
{
68
    //LOGDEB("UPnPDeviceDirectory::getDirServices" << endl);
68
    //LOGDEB("UPnPDeviceDirectory::getDirServices" << endl);
69
    UPnPDeviceDirectory::Visitor visitor = bind(DSAccum, &vds, _1, _2);
69
    UPnPDeviceDirectory::Visitor visitor = bind(DSAccum, &vds, _1, _2);
70
    UPnPDeviceDirectory::getTheDir()->traverse(visitor);
70
    UPnPDeviceDirectory::getTheDir()->traverse(visitor);
71
    return !vds.empty();
71
    return !vds.empty();
...
...
75
                             bool  *found,
75
                             bool  *found,
76
                             CDSH *out,
76
                             CDSH *out,
77
                             const UPnPDeviceDesc& device, 
77
                             const UPnPDeviceDesc& device, 
78
                             const UPnPServiceDesc& service)
78
                             const UPnPServiceDesc& service)
79
{
79
{
80
    if (ContentDirectoryService::isCDService(service.serviceType)) {
80
    if (ContentDirectory::isCDService(service.serviceType)) {
81
        if (!friendlyName.compare(device.friendlyName)) {
81
        if (!friendlyName.compare(device.friendlyName)) {
82
            *out = CDSH(new ContentDirectoryService(device, service));
82
            *out = CDSH(new ContentDirectory(device, service));
83
            *found = true;
83
            *found = true;
84
            return false;
84
            return false;
85
        }
85
        }
86
    }
86
    }
87
    return true;
87
    return true;
88
}
88
}
89
89
90
// Get server by friendly name. 
90
// Get server by friendly name. 
91
bool ContentDirectoryService::getServerByName(const string& friendlyName,
91
bool ContentDirectory::getServerByName(const string& friendlyName,
92
                                              CDSH& server)
92
                                              CDSH& server)
93
{
93
{
94
    bool found = false;
94
    bool found = false;
95
    UPnPDeviceDirectory::Visitor visitor = 
95
    UPnPDeviceDirectory::Visitor visitor = 
96
        bind(DSFriendlySelect, friendlyName, &found, &server, _1, _2);
96
        bind(DSFriendlySelect, friendlyName, &found, &server, _1, _2);
...
...
117
        0 /*devUDN*/, request, asyncReaddirCB, 0);
117
        0 /*devUDN*/, request, asyncReaddirCB, 0);
118
    sleep(10);
118
    sleep(10);
119
    return -1;
119
    return -1;
120
#endif
120
#endif
121
121
122
void ContentDirectoryService::evtCallback(const unordered_map<string, string>&)
122
void ContentDirectory::evtCallback(const unordered_map<string, string>&)
123
{
123
{
124
}
124
}
125
125
126
void ContentDirectoryService::registerCallback()
126
void ContentDirectory::registerCallback()
127
{
127
{
128
    Service::registerCallback(bind(&ContentDirectoryService::evtCallback, 
128
    Service::registerCallback(bind(&ContentDirectory::evtCallback, 
129
                                   this, _1));
129
                                   this, _1));
130
}
130
}
131
131
132
int ContentDirectoryService::readDirSlice(const string& objectId, int offset,
132
int ContentDirectory::readDirSlice(const string& objectId, int offset,
133
                                          int count, UPnPDirContent& dirbuf,
133
                                          int count, UPnPDirContent& dirbuf,
134
                                          int *didreadp, int *totalp)
134
                                          int *didreadp, int *totalp)
135
{
135
{
136
    LOGDEB("CDService::readDirSlice: objId [" << objectId << "] offset " << 
136
    LOGDEB("CDService::readDirSlice: objId [" << objectId << "] offset " << 
137
           offset << " count " << count << endl);
137
           offset << " count " << count << endl);
...
...
176
    *didreadp = didread;
176
    *didreadp = didread;
177
177
178
    return UPNP_E_SUCCESS;
178
    return UPNP_E_SUCCESS;
179
}
179
}
180
180
181
int ContentDirectoryService::readDir(const string& objectId,
181
int ContentDirectory::readDir(const string& objectId,
182
                                     UPnPDirContent& dirbuf)
182
                                     UPnPDirContent& dirbuf)
183
{
183
{
184
    LOGDEB("CDService::readDir: url [" << m_actionURL << "] type [" <<
184
    LOGDEB("CDService::readDir: url [" << m_actionURL << "] type [" <<
185
           m_serviceType << "] udn [" << m_deviceId << "] objId [" <<
185
           m_serviceType << "] udn [" << m_deviceId << "] objId [" <<
186
           objectId << endl);
186
           objectId << endl);
...
...
199
    }
199
    }
200
200
201
    return UPNP_E_SUCCESS;
201
    return UPNP_E_SUCCESS;
202
}
202
}
203
203
204
int ContentDirectoryService::search(const string& objectId,
204
int ContentDirectory::search(const string& objectId,
205
                                    const string& ss,
205
                                    const string& ss,
206
                                    UPnPDirContent& dirbuf)
206
                                    UPnPDirContent& dirbuf)
207
{
207
{
208
    LOGDEB("CDService::search: url [" << m_actionURL << "] type [" << 
208
    LOGDEB("CDService::search: url [" << m_actionURL << "] type [" << 
209
           m_serviceType << "] udn [" << m_deviceId << "] objid [" << 
209
           m_serviceType << "] udn [" << m_deviceId << "] objid [" << 
...
...
249
    }
249
    }
250
250
251
    return UPNP_E_SUCCESS;
251
    return UPNP_E_SUCCESS;
252
}
252
}
253
253
254
int ContentDirectoryService::getSearchCapabilities(set<string>& result)
254
int ContentDirectory::getSearchCapabilities(set<string>& result)
255
{
255
{
256
    LOGDEB("CDService::getSearchCapabilities:" << endl);
256
    LOGDEB("CDService::getSearchCapabilities:" << endl);
257
257
258
    SoapData args(m_serviceType, "GetSearchCapabilities");
258
    SoapData args(m_serviceType, "GetSearchCapabilities");
259
    SoapArgs data;
259
    SoapArgs data;
...
...
280
    }
280
    }
281
281
282
    return UPNP_E_SUCCESS;
282
    return UPNP_E_SUCCESS;
283
}
283
}
284
284
285
int ContentDirectoryService::getMetadata(const string& objectId,
285
int ContentDirectory::getMetadata(const string& objectId,
286
                                         UPnPDirContent& dirbuf)
286
                                         UPnPDirContent& dirbuf)
287
{
287
{
288
    LOGDEB("CDService::getMetadata: url [" << m_actionURL << "] type [" <<
288
    LOGDEB("CDService::getMetadata: url [" << m_actionURL << "] type [" <<
289
           m_serviceType << "] udn [" << m_deviceId << "] objId [" <<
289
           m_serviceType << "] udn [" << m_deviceId << "] objId [" <<
290
           objectId << "]" << endl);
290
           objectId << "]" << endl);