|
a/libupnpp/control/cdirectory.cxx |
|
b/libupnpp/control/cdirectory.cxx |
|
... |
|
... |
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 |
|
|
|
57 |
static bool DSAccum(vector<ContentDirectoryService>* out,
|
56 |
static bool DSAccum(vector<CDSH>* out,
|
58 |
const UPnPDeviceDesc& device,
|
57 |
const UPnPDeviceDesc& device,
|
59 |
const UPnPServiceDesc& service)
|
58 |
const UPnPServiceDesc& service)
|
60 |
{
|
59 |
{
|
61 |
if (ContentDirectoryService::isCDService(service.serviceType)) {
|
60 |
if (ContentDirectoryService::isCDService(service.serviceType)) {
|
62 |
out->push_back(ContentDirectoryService(device, service));
|
61 |
out->push_back(CDSH(new ContentDirectoryService(device, service)));
|
63 |
}
|
62 |
}
|
64 |
return true;
|
63 |
return true;
|
65 |
}
|
64 |
}
|
66 |
|
65 |
|
67 |
bool ContentDirectoryService::getServices(vector<ContentDirectoryService>& vds)
|
66 |
bool ContentDirectoryService::getServices(vector<CDSH>& vds)
|
68 |
{
|
67 |
{
|
69 |
//LOGDEB("UPnPDeviceDirectory::getDirServices" << endl);
|
68 |
//LOGDEB("UPnPDeviceDirectory::getDirServices" << endl);
|
70 |
UPnPDeviceDirectory::Visitor visitor = bind(DSAccum, &vds, _1, _2);
|
69 |
UPnPDeviceDirectory::Visitor visitor = bind(DSAccum, &vds, _1, _2);
|
71 |
UPnPDeviceDirectory::getTheDir()->traverse(visitor);
|
70 |
UPnPDeviceDirectory::getTheDir()->traverse(visitor);
|
72 |
return !vds.empty();
|
71 |
return !vds.empty();
|
73 |
}
|
72 |
}
|
74 |
|
73 |
|
75 |
static bool DSFriendlySelect(const string& friendlyName,
|
74 |
static bool DSFriendlySelect(const string& friendlyName,
|
76 |
bool *found,
|
75 |
bool *found,
|
77 |
ContentDirectoryService *out,
|
76 |
CDSH *out,
|
78 |
const UPnPDeviceDesc& device,
|
77 |
const UPnPDeviceDesc& device,
|
79 |
const UPnPServiceDesc& service)
|
78 |
const UPnPServiceDesc& service)
|
80 |
{
|
79 |
{
|
81 |
if (ContentDirectoryService::isCDService(service.serviceType)) {
|
80 |
if (ContentDirectoryService::isCDService(service.serviceType)) {
|
82 |
if (!friendlyName.compare(device.friendlyName)) {
|
81 |
if (!friendlyName.compare(device.friendlyName)) {
|
83 |
*out = ContentDirectoryService(device, service);
|
82 |
*out = CDSH(new ContentDirectoryService(device, service));
|
84 |
*found = true;
|
83 |
*found = true;
|
85 |
return false;
|
84 |
return false;
|
86 |
}
|
85 |
}
|
87 |
}
|
86 |
}
|
88 |
return true;
|
87 |
return true;
|
89 |
}
|
88 |
}
|
90 |
|
89 |
|
91 |
// Get server by friendly name.
|
90 |
// Get server by friendly name.
|
92 |
bool ContentDirectoryService::getServerByName(const string& friendlyName,
|
91 |
bool ContentDirectoryService::getServerByName(const string& friendlyName,
|
93 |
ContentDirectoryService& server)
|
92 |
CDSH& server)
|
94 |
{
|
93 |
{
|
95 |
bool found = false;
|
94 |
bool found = false;
|
96 |
UPnPDeviceDirectory::Visitor visitor =
|
95 |
UPnPDeviceDirectory::Visitor visitor =
|
97 |
bind(DSFriendlySelect, friendlyName, &found, &server, _1, _2);
|
96 |
bind(DSFriendlySelect, friendlyName, &found, &server, _1, _2);
|
98 |
UPnPDeviceDirectory::getTheDir()->traverse(visitor);
|
97 |
UPnPDeviceDirectory::getTheDir()->traverse(visitor);
|
|
... |
|
... |
118 |
0 /*devUDN*/, request, asyncReaddirCB, 0);
|
117 |
0 /*devUDN*/, request, asyncReaddirCB, 0);
|
119 |
sleep(10);
|
118 |
sleep(10);
|
120 |
return -1;
|
119 |
return -1;
|
121 |
#endif
|
120 |
#endif
|
122 |
|
121 |
|
|
|
122 |
void ContentDirectoryService::evtCallback(const unordered_map<string, string>&)
|
|
|
123 |
{
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
void ContentDirectoryService::registerCallback()
|
|
|
127 |
{
|
|
|
128 |
Service::registerCallback(bind(&ContentDirectoryService::evtCallback,
|
|
|
129 |
this, _1));
|
|
|
130 |
}
|
123 |
|
131 |
|
124 |
int ContentDirectoryService::readDirSlice(const string& objectId, int offset,
|
132 |
int ContentDirectoryService::readDirSlice(const string& objectId, int offset,
|
125 |
int count, UPnPDirContent& dirbuf,
|
133 |
int count, UPnPDirContent& dirbuf,
|
126 |
int *didreadp, int *totalp)
|
134 |
int *didreadp, int *totalp)
|
127 |
{
|
135 |
{
|