libupnpp
0.16.0
A C++ wrapper for the Portable UPnP reference library
|
Content Directory Service client class. More...
#include <cdirectory.hxx>
Public Types | |
enum | ServiceKind { CDSKIND_UNKNOWN, CDSKIND_BUBBLE, CDSKIND_MEDIATOMB, CDSKIND_MINIDLNA, CDSKIND_MINIM, CDSKIND_TWONKY } |
Public Member Functions | |
ContentDirectory (const UPnPDeviceDesc &dev, const UPnPServiceDesc &srv) | |
Construct by copying data from device and service objects. More... | |
ContentDirectory () | |
An empty one. | |
ServiceKind | getKind () |
virtual bool | serviceTypeMatch (const std::string &tp) |
Perform a comparison to the service type string for this specific service. More... | |
int | readDir (const std::string &objectId, UPnPDirContent &dirbuf) |
Read a full container's children list. More... | |
int | readDirSlice (const std::string &objectId, int offset, int count, UPnPDirContent &dirbuf, int *didread, int *total) |
Read a partial slice of a container's children list. More... | |
int | goodSliceSize () |
int | search (const std::string &objectId, const std::string &searchstring, UPnPDirContent &dirbuf) |
Search the content directory service. More... | |
int | searchSlice (const std::string &objectId, const std::string &searchstring, int offset, int count, UPnPDirContent &dirbuf, int *didread, int *total) |
Same to search() as readDirSlice to readDir() | |
int | getMetadata (const std::string &objectId, UPnPDirContent &dirbuf) |
Read metadata for a given node. More... | |
int | getSearchCapabilities (std::set< std::string > &result) |
Retrieve search capabilities. More... | |
Public Member Functions inherited from UPnPClient::Service | |
Service (const UPnPDeviceDesc &device, const UPnPServiceDesc &service) | |
Construct by copying data from device and service objects. More... | |
Service () | |
Empty object. More... | |
bool | initFromDescription (const UPnPDeviceDesc &description) |
Initialize empty object from device description. More... | |
virtual bool | reSubscribe () |
Restart the subscription to get all the State variable values, in case we get the events before we are ready (e.g. More... | |
const std::string & | getFriendlyName () const |
Accessors for the values extracted from the device description during initialization. | |
const std::string & | getDeviceId () const |
const std::string & | getServiceType () const |
const std::string & | getActionURL () const |
const std::string & | getModelName () const |
const std::string & | getManufacturer () const |
virtual int | runAction (const UPnPP::SoapOutgoing &args, UPnPP::SoapIncoming &data) |
Call Soap action and return resulting data. More... | |
int | runTrivialAction (const std::string &actionName) |
Run trivial action where there are neither input parameters nor return data (beyond the status) | |
template<class T > | |
int | runSimpleGet (const std::string &actnm, const std::string &valnm, T *valuep) |
Run action where there are no input parameters and a single named value is to be retrieved from the result. | |
template<class T > | |
int | runSimpleAction (const std::string &actnm, const std::string &valnm, T value) |
Run action with a single input parameter and no return data. | |
virtual VarEventReporter * | getReporter () |
Get pointer to installed event reporter. More... | |
virtual void | installReporter (VarEventReporter *reporter) |
Install or uninstall event data reporter object. More... | |
Static Public Member Functions | |
static bool | isCDService (const std::string &st) |
Test service type from discovery message. | |
static bool | getServices (std::vector< CDSH > &) |
Retrieve the directory services currently seen on the network. | |
static bool | getServerByName (const std::string &friendlyName, CDSH &server) |
Retrieve specific service designated by its friendlyName. | |
Protected Member Functions | |
virtual bool | serviceInit (const UPnPDeviceDesc &device, const UPnPServiceDesc &service) |
Service-specific part of initialization. More... | |
Protected Member Functions inherited from UPnPClient::Service | |
bool | registerCallback (evtCBFunc c) |
Used by a derived class to register its callback method. More... | |
void | unregisterCallback () |
Cancel subscription to the service events, forget installed callback. | |
Static Protected Attributes | |
static const std::string | SType |
Content Directory Service client class.
This stores identity data from a directory service and the device it belongs to, and has methods to query the directory, using libupnp for handling the UPnP protocols.
Note: m_rdreqcnt: number of entries requested per directory read. 0 means all entries. The device can still return less entries than requested, depending on its own limits. In general it's not optimal becauses it triggers issues, and is sometimes actually slower, e.g. on a D-Link NAS 327
The value chosen may be affected by the UpnpSetMaxContentLength (2000*1024) done during initialization, but this should be ample.
UPnPClient::ContentDirectory::ContentDirectory | ( | const UPnPDeviceDesc & | dev, |
const UPnPServiceDesc & | srv | ||
) |
Construct by copying data from device and service objects.
int UPnPClient::ContentDirectory::getMetadata | ( | const std::string & | objectId, |
UPnPDirContent & | dirbuf | ||
) |
Read metadata for a given node.
objectId | the UPnP object Id. Root has Id "0" | |
[out] | dirbuf | stores the entries we read. At most one entry will be returned. |
int UPnPClient::ContentDirectory::getSearchCapabilities | ( | std::set< std::string > & | result | ) |
Retrieve search capabilities.
[out] | result | an empty vector: no search, or a single '*' element: any tag can be used in a search, or a list of usable tag names. |
int UPnPClient::ContentDirectory::readDir | ( | const std::string & | objectId, |
UPnPDirContent & | dirbuf | ||
) |
Read a full container's children list.
objectId | the UPnP object Id for the container. Root has Id "0" | |
[out] | dirbuf | stores the entries we read. |
int UPnPClient::ContentDirectory::readDirSlice | ( | const std::string & | objectId, |
int | offset, | ||
int | count, | ||
UPnPDirContent & | dirbuf, | ||
int * | didread, | ||
int * | total | ||
) |
Read a partial slice of a container's children list.
The entries read are concatenated to the input dirbuf.
objectId | the UPnP object Id for the container. Root has Id "0" | |
offset | the offset of the first entry to read | |
count | the maximum number of entries to read | |
[out] | dirbuf | a place to store the entries we read. They are appended to the existing ones. |
[out] | didread | number of entries actually read. |
[out] | total | total number of children. |
int UPnPClient::ContentDirectory::search | ( | const std::string & | objectId, |
const std::string & | searchstring, | ||
UPnPDirContent & | dirbuf | ||
) |
Search the content directory service.
objectId | the UPnP object Id under which the search should be done. Not all servers actually support this below root. Root has Id "0" | |
searchstring | an UPnP searchcriteria string. Check the UPnP document: UPnP-av-ContentDirectory-v1-Service-20020625.pdf section 2.5.5. Maybe we'll provide an easier way some day... | |
[out] | dirbuf | stores the entries we read. |
|
protectedvirtual |
Service-specific part of initialization.
This can be called from the constructor or from initFromDescription(). Most services don't need specific initialization, so we provide a default implementation.
Reimplemented from UPnPClient::Service.
|
virtual |
Perform a comparison to the service type string for this specific service.
This allows embedding knowledge of the service type string inside the derived class. It is used, e.g., by initFromDescription() to look up an appropriate entry from the device description service list. Can also be used by external code wishing to do the same.
tp | Service type string to be compared with the one for the derived class. |
Implements UPnPClient::Service.