|
a/src/contentdirectory.cxx |
|
b/src/contentdirectory.cxx |
|
... |
|
... |
44 |
using namespace UPnPProvider;
|
44 |
using namespace UPnPProvider;
|
45 |
|
45 |
|
46 |
class ContentDirectory::Internal {
|
46 |
class ContentDirectory::Internal {
|
47 |
public:
|
47 |
public:
|
48 |
Internal (ContentDirectory *sv)
|
48 |
Internal (ContentDirectory *sv)
|
49 |
: service(sv) {
|
49 |
: service(sv), updateID("1") {
|
50 |
}
|
50 |
}
|
51 |
~Internal() {
|
51 |
~Internal() {
|
52 |
for (auto& it : plugins) {
|
52 |
for (auto& it : plugins) {
|
53 |
delete it.second;
|
53 |
delete it.second;
|
54 |
}
|
54 |
}
|
|
... |
|
... |
104 |
}
|
104 |
}
|
105 |
}
|
105 |
}
|
106 |
unordered_map<string, CDPlugin *> plugins;
|
106 |
unordered_map<string, CDPlugin *> plugins;
|
107 |
ContentDirectory *service;
|
107 |
ContentDirectory *service;
|
108 |
string httphp;
|
108 |
string httphp;
|
|
|
109 |
string updateID;
|
109 |
};
|
110 |
};
|
110 |
|
111 |
|
111 |
static const string
|
112 |
static const string
|
112 |
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
|
113 |
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
|
113 |
static const string
|
114 |
static const string
|
|
... |
|
... |
159 |
|
160 |
|
160 |
int ContentDirectory::actGetSystemUpdateID(const SoapIncoming& sc, SoapOutgoing& data)
|
161 |
int ContentDirectory::actGetSystemUpdateID(const SoapIncoming& sc, SoapOutgoing& data)
|
161 |
{
|
162 |
{
|
162 |
LOGDEB("ContentDirectory::actGetSystemUpdateID: " << endl);
|
163 |
LOGDEB("ContentDirectory::actGetSystemUpdateID: " << endl);
|
163 |
|
164 |
|
164 |
std::string out_Id;
|
165 |
std::string out_Id = m->updateID;
|
165 |
data.addarg("Id", out_Id);
|
166 |
data.addarg("Id", out_Id);
|
166 |
return UPNP_E_SUCCESS;
|
167 |
return UPNP_E_SUCCESS;
|
167 |
}
|
168 |
}
|
168 |
|
169 |
|
169 |
static vector<UpSong> rootdir;
|
170 |
static vector<UpSong> rootdir;
|
|
... |
|
... |
271 |
std::string out_TotalMatches;
|
272 |
std::string out_TotalMatches;
|
272 |
std::string out_UpdateID;
|
273 |
std::string out_UpdateID;
|
273 |
|
274 |
|
274 |
// Go fetch
|
275 |
// Go fetch
|
275 |
vector<UpSong> entries;
|
276 |
vector<UpSong> entries;
|
276 |
size_t tot = 0;
|
277 |
size_t totalmatches = 0;
|
277 |
if (!in_ObjectID.compare("0")) {
|
278 |
if (!in_ObjectID.compare("0")) {
|
278 |
// Root directory: we do this ourselves
|
279 |
// Root directory: we do this ourselves
|
279 |
tot = readroot(in_StartingIndex, in_RequestedCount, entries);
|
280 |
totalmatches = readroot(in_StartingIndex, in_RequestedCount, entries);
|
280 |
} else {
|
281 |
} else {
|
281 |
// Pass off request to appropriate app, defined by 1st elt in id
|
282 |
// Pass off request to appropriate app, defined by 1st elt in id
|
282 |
string app = appForId(in_ObjectID);
|
283 |
string app = appForId(in_ObjectID);
|
283 |
LOGDEB("ContentDirectory::actBrowse: app: [" << app << "]\n");
|
284 |
LOGDEB("ContentDirectory::actBrowse: app: [" << app << "]\n");
|
284 |
|
285 |
|
285 |
CDPlugin *plg = m->pluginForApp(app);
|
286 |
CDPlugin *plg = m->pluginForApp(app);
|
286 |
if (plg) {
|
287 |
if (plg) {
|
287 |
out_TotalMatches = plg->browse(in_ObjectID, in_StartingIndex,
|
288 |
totalmatches = plg->browse(in_ObjectID, in_StartingIndex,
|
288 |
in_RequestedCount, entries,
|
289 |
in_RequestedCount, entries,
|
289 |
sortcrits, bf);
|
290 |
sortcrits, bf);
|
290 |
} else {
|
291 |
} else {
|
291 |
LOGERR("ContentDirectory::Browse: unknown app: [" << app << "]\n");
|
292 |
LOGERR("ContentDirectory::Browse: unknown app: [" << app << "]\n");
|
292 |
}
|
293 |
}
|
293 |
}
|
294 |
}
|
294 |
|
295 |
|
295 |
|
296 |
|
296 |
// Process and send out result
|
297 |
// Process and send out result
|
297 |
out_NumberReturned = ulltodecstr(entries.size());
|
298 |
out_NumberReturned = ulltodecstr(entries.size());
|
298 |
out_TotalMatches = ulltodecstr(tot);
|
299 |
out_TotalMatches = ulltodecstr(totalmatches);
|
299 |
out_UpdateID = "1";
|
300 |
out_UpdateID = m->updateID;
|
300 |
out_Result = headDIDL();
|
301 |
out_Result = headDIDL();
|
301 |
for (unsigned int i = 0; i < entries.size(); i++) {
|
302 |
for (unsigned int i = 0; i < entries.size(); i++) {
|
302 |
out_Result += entries[i].didl();
|
303 |
out_Result += entries[i].didl();
|
303 |
}
|
304 |
}
|
304 |
out_Result += tailDIDL();
|
305 |
out_Result += tailDIDL();
|
|
... |
|
... |
366 |
std::string out_TotalMatches = "0";
|
367 |
std::string out_TotalMatches = "0";
|
367 |
std::string out_UpdateID;
|
368 |
std::string out_UpdateID;
|
368 |
|
369 |
|
369 |
// Go fetch
|
370 |
// Go fetch
|
370 |
vector<UpSong> entries;
|
371 |
vector<UpSong> entries;
|
371 |
size_t tot = 0;
|
372 |
size_t totalmatches = 0;
|
372 |
if (!in_ContainerID.compare("0")) {
|
373 |
if (!in_ContainerID.compare("0")) {
|
373 |
// Root directory: can't search in there
|
374 |
// Root directory: can't search in there
|
374 |
LOGERR("ContentDirectory::actSearch: Can't search in root\n");
|
375 |
LOGERR("ContentDirectory::actSearch: Can't search in root\n");
|
375 |
} else {
|
376 |
} else {
|
376 |
// Pass off request to appropriate app, defined by 1st elt in id
|
377 |
// Pass off request to appropriate app, defined by 1st elt in id
|
|
... |
|
... |
378 |
string app = appForId(in_ContainerID);
|
379 |
string app = appForId(in_ContainerID);
|
379 |
LOGDEB("ContentDirectory::actSearch: app: [" << app << "]\n");
|
380 |
LOGDEB("ContentDirectory::actSearch: app: [" << app << "]\n");
|
380 |
|
381 |
|
381 |
CDPlugin *plg = m->pluginForApp(app);
|
382 |
CDPlugin *plg = m->pluginForApp(app);
|
382 |
if (plg) {
|
383 |
if (plg) {
|
383 |
out_TotalMatches = plg->search(in_ContainerID, in_StartingIndex,
|
384 |
totalmatches = plg->search(in_ContainerID, in_StartingIndex,
|
384 |
in_RequestedCount,
|
385 |
in_RequestedCount, in_SearchCriteria,
|
385 |
in_SearchCriteria,
|
386 |
entries, sortcrits);
|
386 |
entries, sortcrits);
|
|
|
387 |
} else {
|
387 |
} else {
|
388 |
LOGERR("ContentDirectory::Browse: unknown app: [" << app << "]\n");
|
388 |
LOGERR("ContentDirectory::Browse: unknown app: [" << app << "]\n");
|
389 |
}
|
389 |
}
|
390 |
}
|
390 |
}
|
391 |
|
391 |
|
392 |
|
392 |
|
393 |
// Process and send out result
|
393 |
// Process and send out result
|
394 |
out_NumberReturned = ulltodecstr(entries.size());
|
394 |
out_NumberReturned = ulltodecstr(entries.size());
|
395 |
out_TotalMatches = ulltodecstr(tot);
|
395 |
out_TotalMatches = ulltodecstr(totalmatches);
|
396 |
out_UpdateID = "1";
|
396 |
out_UpdateID = m->updateID;
|
397 |
out_Result = headDIDL();
|
397 |
out_Result = headDIDL();
|
398 |
for (unsigned int i = 0; i < entries.size(); i++) {
|
398 |
for (unsigned int i = 0; i < entries.size(); i++) {
|
399 |
out_Result += entries[i].didl();
|
399 |
out_Result += entries[i].didl();
|
400 |
}
|
400 |
}
|
401 |
out_Result += tailDIDL();
|
401 |
out_Result += tailDIDL();
|
|
... |
|
... |
404 |
data.addarg("NumberReturned", out_NumberReturned);
|
404 |
data.addarg("NumberReturned", out_NumberReturned);
|
405 |
data.addarg("TotalMatches", out_TotalMatches);
|
405 |
data.addarg("TotalMatches", out_TotalMatches);
|
406 |
data.addarg("UpdateID", out_UpdateID);
|
406 |
data.addarg("UpdateID", out_UpdateID);
|
407 |
return UPNP_E_SUCCESS;
|
407 |
return UPNP_E_SUCCESS;
|
408 |
}
|
408 |
}
|
409 |
|
|
|