Switch to unified view

a/libupnpp/cdirectory.hxx b/libupnpp/cdirectory.hxx
1
/* Copyright (C) 2013 J.F.Dockes
1
/* Copyright (C) 2013 J.F.Dockes
2
 *     This program is free software; you can redistribute it and/or modify
2
 *       This program is free software; you can redistribute it and/or modify
3
 *     it under the terms of the GNU General Public License as published by
3
 *       it under the terms of the GNU General Public License as published by
4
 *     the Free Software Foundation; either version 2 of the License, or
4
 *       the Free Software Foundation; either version 2 of the License, or
5
 *     (at your option) any later version.
5
 *       (at your option) any later version.
6
 *
6
 *
7
 *     This program is distributed in the hope that it will be useful,
7
 *       This program is distributed in the hope that it will be useful,
8
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
8
 *       but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9
 *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *     GNU General Public License for more details.
10
 *       GNU General Public License for more details.
11
 *
11
 *
12
 *     You should have received a copy of the GNU General Public License
12
 *       You should have received a copy of the GNU General Public License
13
 *     along with this program; if not, write to the
13
 *       along with this program; if not, write to the
14
 *     Free Software Foundation, Inc.,
14
 *       Free Software Foundation, Inc.,
15
 *     59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *       59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#ifndef _UPNPDIR_HXX_INCLUDED_
17
#ifndef _UPNPDIR_HXX_INCLUDED_
18
#define _UPNPDIR_HXX_INCLUDED_
18
#define _UPNPDIR_HXX_INCLUDED_
19
19
20
#include <string>
20
#include <string>
...
...
22
22
23
#include "description.hxx"
23
#include "description.hxx"
24
#include "cdircontent.hxx"
24
#include "cdircontent.hxx"
25
25
26
/**
26
/**
27
 * Content Directory Service class.
27
 * Content Directory Service client class.
28
 *
28
 *
29
 * This stores identity data from a directory service
29
 * This stores identity data from a directory service
30
 * and the device it belongs to, and has methods to query
30
 * and the device it belongs to, and has methods to query
31
 * the directory, using libupnp for handling the UPnP protocols.
31
 * the directory, using libupnp for handling the UPnP protocols.
32
 *
32
 *
...
...
39
 * The value chosen may affect by the UpnpSetMaxContentLength
39
 * The value chosen may affect by the UpnpSetMaxContentLength
40
 * (2000*1024) done during initialization, but this should be ample
40
 * (2000*1024) done during initialization, but this should be ample
41
 */
41
 */
42
class ContentDirectoryService {
42
class ContentDirectoryService {
43
public:
43
public:
44
  /** Construct by copying data from device and service objects.
44
    /** Construct by copying data from device and service objects.
45
   *
45
     *
46
   * To be used by the discovery service. 
46
     * To be used by the discovery service. 
47
   * External users must call getDirServices() instead
47
     * External users must call getDirServices() instead
48
   */
48
     */
49
  ContentDirectoryService(const UPnPDevice& device,
49
    ContentDirectoryService(const UPnPDeviceDesc& device,
50
              const UPnPService& service)
50
                            const UPnPServiceDesc& service)
51
      : m_actionURL(caturl(device.URLBase, service.controlURL)),
51
        : m_actionURL(caturl(device.URLBase, service.controlURL)),
52
        m_serviceType(service.serviceType),
52
          m_serviceType(service.serviceType),
53
        m_deviceId(device.UDN),
53
          m_deviceId(device.UDN),
54
        m_friendlyName(device.friendlyName),
54
          m_friendlyName(device.friendlyName),
55
        m_manufacturer(device.manufacturer),
55
          m_manufacturer(device.manufacturer),
56
        m_modelName(device.modelName),
56
          m_modelName(device.modelName),
57
        m_rdreqcnt(200)
57
          m_rdreqcnt(200)
58
  {
58
        {
59
      if (!m_modelName.compare("MediaTomb")) {
59
            if (!m_modelName.compare("MediaTomb")) {
60
          // Readdir by 200 entries is good for most, but MediaTomb likes
60
                // Readdir by 200 entries is good for most, but MediaTomb likes
61
          // them really big. Actually 1000 is better but I don't dare
61
                // them really big. Actually 1000 is better but I don't dare
62
          m_rdreqcnt = 500;
62
                m_rdreqcnt = 500;
63
      }
63
            }
64
  }
64
        }
65
65
66
  /** An empty one */
66
    /** An empty one */
67
  ContentDirectoryService() {}
67
    ContentDirectoryService() {}
68
68
69
  /** Read a container's children list into dirbuf.
69
    /** Read a container's children list into dirbuf.
70
   *
70
     *
71
   * @param objectId the UPnP object Id for the container. Root has Id "0"
71
     * @param objectId the UPnP object Id for the container. Root has Id "0"
72
   * @param[out] dirbuf stores the entries we read.
72
     * @param[out] dirbuf stores the entries we read.
73
   * @return UPNP_E_SUCCESS for success, else libupnp error code.
73
     * @return UPNP_E_SUCCESS for success, else libupnp error code.
74
   */
74
     */
75
  int readDir(const std::string& objectId, UPnPDirContent& dirbuf);
75
    int readDir(const std::string& objectId, UPnPDirContent& dirbuf);
76
76
77
  int readDirSlice(const string& objectId, int offset,
77
    int readDirSlice(const string& objectId, int offset,
78
                   int count, UPnPDirContent& dirbuf,
78
                     int count, UPnPDirContent& dirbuf,
79
                   int *didread, int *total);
79
                     int *didread, int *total);
80
80
81
  /** Search the content directory service.
81
    /** Search the content directory service.
82
   *
82
     *
83
   * @param objectId the UPnP object Id under which the search
83
     * @param objectId the UPnP object Id under which the search
84
   * should be done. Not all servers actually support this below
84
     * should be done. Not all servers actually support this below
85
   * root. Root has Id "0"
85
     * root. Root has Id "0"
86
   * @param searchstring an UPnP searchcriteria string. Check the
86
     * @param searchstring an UPnP searchcriteria string. Check the
87
   * UPnP document: UPnP-av-ContentDirectory-v1-Service-20020625.pdf
87
     * UPnP document: UPnP-av-ContentDirectory-v1-Service-20020625.pdf
88
   * section 2.5.5. Maybe we'll provide an easier way some day...
88
     * section 2.5.5. Maybe we'll provide an easier way some day...
89
   * @param[out] dirbuf stores the entries we read.
89
     * @param[out] dirbuf stores the entries we read.
90
   * @return UPNP_E_SUCCESS for success, else libupnp error code.
90
     * @return UPNP_E_SUCCESS for success, else libupnp error code.
91
   */
91
     */
92
  int search(const std::string& objectId, const std::string& searchstring,
92
    int search(const std::string& objectId, const std::string& searchstring,
93
         UPnPDirContent& dirbuf);
93
               UPnPDirContent& dirbuf);
94
94
95
  /** Read metadata for a given node.
95
    /** Read metadata for a given node.
96
   *
96
     *
97
   * @param objectId the UPnP object Id. Root has Id "0"
97
     * @param objectId the UPnP object Id. Root has Id "0"
98
   * @param[out] dirbuf stores the entries we read. At most one entry will be
98
     * @param[out] dirbuf stores the entries we read. At most one entry will be
99
   *    returned.
99
     *   returned.
100
   * @return UPNP_E_SUCCESS for success, else libupnp error code.
100
     * @return UPNP_E_SUCCESS for success, else libupnp error code.
101
   */
101
     */
102
  int getMetadata(const std::string& objectId, UPnPDirContent& dirbuf);
102
    int getMetadata(const std::string& objectId, UPnPDirContent& dirbuf);
103
103
104
  /** Retrieve search capabilities
104
    /** Retrieve search capabilities
105
   *
105
     *
106
   * @param[out] result an empty vector: no search, or a single '*' element:
106
     * @param[out] result an empty vector: no search, or a single '*' element:
107
   *      any tag can be used in a search, or a list of usable tag names.
107
     *     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.
108
     * @return UPNP_E_SUCCESS for success, else libupnp error code.
109
   */
109
     */
110
  int getSearchCapabilities(std::set<std::string>& result);
110
    int getSearchCapabilities(std::set<std::string>& result);
111
111
112
  /** Retrieve the "friendly name" for this server, useful for display. */
112
    /** Retrieve the "friendly name" for this server, useful for display. */
113
  std::string getFriendlyName() const {return m_friendlyName;}
113
    std::string getFriendlyName() const {return m_friendlyName;}
114
114
115
private:
115
private:
116
  std::string m_actionURL;
116
    std::string m_actionURL;
117
  std::string m_serviceType;
117
    std::string m_serviceType;
118
  std::string m_deviceId;
118
    std::string m_deviceId;
119
  std::string m_friendlyName;
119
    std::string m_friendlyName;
120
  std::string m_manufacturer;
120
    std::string m_manufacturer;
121
  std::string m_modelName;
121
    std::string m_modelName;
122
122
123
  int m_rdreqcnt; // Slice size to use when reading
123
    int m_rdreqcnt; // Slice size to use when reading
124
};
124
};
125
125
126
#endif /* _UPNPDIR_HXX_INCLUDED_ */
126
#endif /* _UPNPDIR_HXX_INCLUDED_ */
127
/* Local Variables: */
128
/* mode: c++ */
129
/* c-basic-offset: 4 */
130
/* tab-width: 4 */
131
/* indent-tabs-mode: t */
132
/* End: */