|
a/libupnpp/cdirectory.hxx |
|
b/libupnpp/cdirectory.hxx |
|
... |
|
... |
19 |
|
19 |
|
20 |
#include <string>
|
20 |
#include <string>
|
21 |
#include <set>
|
21 |
#include <set>
|
22 |
|
22 |
|
23 |
#include "description.hxx"
|
23 |
#include "description.hxx"
|
|
|
24 |
#include "service.hxx"
|
24 |
#include "cdircontent.hxx"
|
25 |
#include "cdircontent.hxx"
|
|
|
26 |
|
|
|
27 |
namespace UPnPClient {
|
25 |
|
28 |
|
26 |
/**
|
29 |
/**
|
27 |
* Content Directory Service client class.
|
30 |
* Content Directory Service client class.
|
28 |
*
|
31 |
*
|
29 |
* This stores identity data from a directory service
|
32 |
* This stores identity data from a directory service
|
|
... |
|
... |
37 |
* a D-Link NAS 327
|
40 |
* a D-Link NAS 327
|
38 |
*
|
41 |
*
|
39 |
* The value chosen may affect by the UpnpSetMaxContentLength
|
42 |
* The value chosen may affect by the UpnpSetMaxContentLength
|
40 |
* (2000*1024) done during initialization, but this should be ample
|
43 |
* (2000*1024) done during initialization, but this should be ample
|
41 |
*/
|
44 |
*/
|
42 |
class ContentDirectoryService {
|
45 |
class ContentDirectoryService : public Service {
|
43 |
public:
|
46 |
public:
|
44 |
/** Construct by copying data from device and service objects.
|
47 |
/** Construct by copying data from device and service objects.
|
45 |
*
|
48 |
*
|
46 |
* To be used by the discovery service.
|
49 |
* To be used by the discovery service.
|
47 |
* External users must call getDirServices() instead
|
50 |
* External users must call getDirServices() instead
|
48 |
*/
|
51 |
*/
|
49 |
ContentDirectoryService(const UPnPDeviceDesc& device,
|
52 |
ContentDirectoryService(const UPnPDeviceDesc& device,
|
50 |
const UPnPServiceDesc& service)
|
53 |
const UPnPServiceDesc& service)
|
51 |
: m_actionURL(caturl(device.URLBase, service.controlURL)),
|
54 |
: Service(device, service), m_rdreqcnt(200)
|
52 |
m_serviceType(service.serviceType),
|
|
|
53 |
m_deviceId(device.UDN),
|
|
|
54 |
m_friendlyName(device.friendlyName),
|
|
|
55 |
m_manufacturer(device.manufacturer),
|
|
|
56 |
m_modelName(device.modelName),
|
|
|
57 |
m_rdreqcnt(200)
|
|
|
58 |
{
|
55 |
{
|
59 |
if (!m_modelName.compare("MediaTomb")) {
|
56 |
if (!m_modelName.compare("MediaTomb")) {
|
60 |
// Readdir by 200 entries is good for most, but MediaTomb likes
|
57 |
// Readdir by 200 entries is good for most, but MediaTomb likes
|
61 |
// them really big. Actually 1000 is better but I don't dare
|
58 |
// them really big. Actually 1000 is better but I don't dare
|
62 |
m_rdreqcnt = 500;
|
59 |
m_rdreqcnt = 500;
|
|
... |
|
... |
64 |
}
|
61 |
}
|
65 |
|
62 |
|
66 |
/** An empty one */
|
63 |
/** An empty one */
|
67 |
ContentDirectoryService() {}
|
64 |
ContentDirectoryService() {}
|
68 |
|
65 |
|
|
|
66 |
/** Test service type from discovery message */
|
|
|
67 |
static bool isCDService(const std::string& st);
|
|
|
68 |
|
|
|
69 |
/** Retrieve the directory services currently seen on the network */
|
|
|
70 |
static bool getServices(std::vector<ContentDirectoryService>&);
|
|
|
71 |
|
|
|
72 |
/** Retrieve specific service designated by its friendlyName */
|
|
|
73 |
static bool getServerByName(const string& friendlyName,
|
|
|
74 |
ContentDirectoryService& server);
|
|
|
75 |
|
69 |
/** Read a container's children list into dirbuf.
|
76 |
/** Read a full container's children list
|
70 |
*
|
77 |
*
|
71 |
* @param objectId the UPnP object Id for the container. Root has Id "0"
|
78 |
* @param objectId the UPnP object Id for the container. Root has Id "0"
|
72 |
* @param[out] dirbuf stores the entries we read.
|
79 |
* @param[out] dirbuf stores the entries we read.
|
73 |
* @return UPNP_E_SUCCESS for success, else libupnp error code.
|
80 |
* @return UPNP_E_SUCCESS for success, else libupnp error code.
|
74 |
*/
|
81 |
*/
|
75 |
int readDir(const std::string& objectId, UPnPDirContent& dirbuf);
|
82 |
int readDir(const std::string& objectId, UPnPDirContent& dirbuf);
|
76 |
|
83 |
|
|
|
84 |
/** Read a partial slice of a container's children list
|
|
|
85 |
*
|
|
|
86 |
* The entries read are concatenated to the input dirbuf.
|
|
|
87 |
*
|
|
|
88 |
* @param objectId the UPnP object Id for the container. Root has Id "0"
|
|
|
89 |
* @param offset the offset of the first entry to read
|
|
|
90 |
* @param count the maximum number of entries to read
|
|
|
91 |
* @param[out] dirbuf a place to store the entries we read. They are
|
|
|
92 |
* appended to the existing ones.
|
|
|
93 |
* @param[out] didread number of entries actually read.
|
|
|
94 |
* @param[out] total total number of children.
|
|
|
95 |
* @return UPNP_E_SUCCESS for success, else libupnp error code.
|
|
|
96 |
*/
|
77 |
int readDirSlice(const string& objectId, int offset,
|
97 |
int readDirSlice(const std::string& objectId, int offset,
|
78 |
int count, UPnPDirContent& dirbuf,
|
98 |
int count, UPnPDirContent& dirbuf,
|
79 |
int *didread, int *total);
|
99 |
int *didread, int *total);
|
|
|
100 |
|
|
|
101 |
int goodSliceSize()
|
|
|
102 |
{
|
|
|
103 |
return m_rdreqcnt;
|
|
|
104 |
}
|
80 |
|
105 |
|
81 |
/** Search the content directory service.
|
106 |
/** Search the content directory service.
|
82 |
*
|
107 |
*
|
83 |
* @param objectId the UPnP object Id under which the search
|
108 |
* @param objectId the UPnP object Id under which the search
|
84 |
* should be done. Not all servers actually support this below
|
109 |
* should be done. Not all servers actually support this below
|
|
... |
|
... |
107 |
* any tag can be used in a search, or a list of usable tag names.
|
132 |
* any tag can be used in a search, or a list of usable tag names.
|
108 |
* @return UPNP_E_SUCCESS for success, else libupnp error code.
|
133 |
* @return UPNP_E_SUCCESS for success, else libupnp error code.
|
109 |
*/
|
134 |
*/
|
110 |
int getSearchCapabilities(std::set<std::string>& result);
|
135 |
int getSearchCapabilities(std::set<std::string>& result);
|
111 |
|
136 |
|
112 |
/** Retrieve the "friendly name" for this server, useful for display. */
|
137 |
// The service type string for Content Directories:
|
113 |
std::string getFriendlyName() const {return m_friendlyName;}
|
138 |
static const string SType;
|
114 |
|
139 |
|
115 |
private:
|
140 |
private:
|
116 |
std::string m_actionURL;
|
|
|
117 |
std::string m_serviceType;
|
|
|
118 |
std::string m_deviceId;
|
|
|
119 |
std::string m_friendlyName;
|
|
|
120 |
std::string m_manufacturer;
|
|
|
121 |
std::string m_modelName;
|
|
|
122 |
|
|
|
123 |
int m_rdreqcnt; // Slice size to use when reading
|
141 |
int m_rdreqcnt; // Slice size to use when reading
|
124 |
};
|
142 |
};
|
125 |
|
143 |
|
|
|
144 |
}
|
|
|
145 |
|
126 |
#endif /* _UPNPDIR_HXX_INCLUDED_ */
|
146 |
#endif /* _UPNPDIR_HXX_INCLUDED_ */
|