libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
UPnPClient::ContentDirectory Class Reference

Content Directory Service client class. More...

#include <cdirectory.hxx>

Inheritance diagram for UPnPClient::ContentDirectory:
UPnPClient::Service

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 VarEventReportergetReporter ()
 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ContentDirectory()

UPnPClient::ContentDirectory::ContentDirectory ( const UPnPDeviceDesc dev,
const UPnPServiceDesc srv 
)

Construct by copying data from device and service objects.

Member Function Documentation

◆ getMetadata()

int UPnPClient::ContentDirectory::getMetadata ( const std::string &  objectId,
UPnPDirContent dirbuf 
)

Read metadata for a given node.

Parameters
objectIdthe UPnP object Id. Root has Id "0"
[out]dirbufstores the entries we read. At most one entry will be returned.
Returns
UPNP_E_SUCCESS for success, else libupnp error code.

◆ getSearchCapabilities()

int UPnPClient::ContentDirectory::getSearchCapabilities ( std::set< std::string > &  result)

Retrieve search capabilities.

Parameters
[out]resultan empty vector: no search, or a single '*' element: any tag can be used in a search, or a list of usable tag names.
Returns
UPNP_E_SUCCESS for success, else libupnp error code.

◆ readDir()

int UPnPClient::ContentDirectory::readDir ( const std::string &  objectId,
UPnPDirContent dirbuf 
)

Read a full container's children list.

Parameters
objectIdthe UPnP object Id for the container. Root has Id "0"
[out]dirbufstores the entries we read.
Returns
UPNP_E_SUCCESS for success, else libupnp error code.

◆ readDirSlice()

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.

Parameters
objectIdthe UPnP object Id for the container. Root has Id "0"
offsetthe offset of the first entry to read
countthe maximum number of entries to read
[out]dirbufa place to store the entries we read. They are appended to the existing ones.
[out]didreadnumber of entries actually read.
[out]totaltotal number of children.
Returns
UPNP_E_SUCCESS for success, else libupnp error code.

◆ search()

int UPnPClient::ContentDirectory::search ( const std::string &  objectId,
const std::string &  searchstring,
UPnPDirContent dirbuf 
)

Search the content directory service.

Parameters
objectIdthe UPnP object Id under which the search should be done. Not all servers actually support this below root. Root has Id "0"
searchstringan 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]dirbufstores the entries we read.
Returns
UPNP_E_SUCCESS for success, else libupnp error code.

◆ serviceInit()

bool UPnPClient::ContentDirectory::serviceInit ( const UPnPDeviceDesc ,
const UPnPServiceDesc  
)
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.

◆ serviceTypeMatch()

bool UPnPClient::ContentDirectory::serviceTypeMatch ( const std::string &  tp)
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.

Parameters
tpService type string to be compared with the one for the derived class.

Implements UPnPClient::Service.


The documentation for this class was generated from the following files: