libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
cdirectory.hxx
1/* Copyright (C) 2006-2016 J.F.Dockes
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18#ifndef _UPNPDIR_HXX_INCLUDED_
19#define _UPNPDIR_HXX_INCLUDED_
20
21#include <unordered_map>
22#include <set>
23#include <string>
24#include <vector>
25
26#include "libupnpp/control/service.hxx"
27
28namespace UPnPClient {
29
30class ContentDirectory;
31class UPnPDeviceDesc;
32class UPnPDirContent;
33class UPnPServiceDesc;
34
35typedef std::shared_ptr<ContentDirectory> CDSH;
36
53class UPNPP_API ContentDirectory : public Service {
54public:
55
57 ContentDirectory(const UPnPDeviceDesc& dev, const UPnPServiceDesc& srv);
58
59 enum ServiceKind {CDSKIND_UNKNOWN, CDSKIND_BUBBLE, CDSKIND_MEDIATOMB,
60 CDSKIND_MINIDLNA, CDSKIND_MINIM, CDSKIND_TWONKY
61 };
62
63 ServiceKind getKind() {
64 return m_serviceKind;
65 }
66
68 static bool isCDService(const std::string& st);
69 bool serviceTypeMatch(const std::string& tp) override;
70
72 static bool getServices(std::vector<CDSH>&);
73
75 static bool getServerByName(const std::string& friendlyName,
76 CDSH& server);
77
84 int readDir(const std::string& objectId, UPnPDirContent& dirbuf);
85
99 int readDirSlice(const std::string& objectId, int offset,
100 int count, UPnPDirContent& dirbuf,
101 int *didread, int *total);
102
103 int goodSliceSize()
104 {
105 return m_rdreqcnt;
106 }
107
119 int search(const std::string& objectId, const std::string& searchstring,
120 UPnPDirContent& dirbuf);
122 int searchSlice(const std::string& objectId,
123 const std::string& searchstring,
124 int offset, int count, UPnPDirContent& dirbuf,
125 int *didread, int *total);
126
134 int getMetadata(const std::string& objectId, UPnPDirContent& dirbuf);
135
142 int getSearchCapabilities(std::set<std::string>& result);
143
144protected:
145 bool serviceInit(const UPnPDeviceDesc& device,
146 const UPnPServiceDesc& service) override;
147 /* My service type string */
148 static const std::string SType;
149
150private:
151 int m_rdreqcnt{200}; // Slice size to use when reading
152 ServiceKind m_serviceKind{CDSKIND_UNKNOWN};
153
154 void UPNPP_LOCAL
155 evtCallback(const std::unordered_map<std::string, std::string>&);
156 void UPNPP_LOCAL registerCallback() override;
157};
158
159}
160
161#endif /* _UPNPDIR_HXX_INCLUDED_ */
Content Directory Service client class.
Definition cdirectory.hxx:53
Definition service.hxx:88
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition description.hxx:139
Image of a MediaServer Directory Service container (directory), possibly containing items and subordi...
Definition cdircontent.hxx:239
Data holder for a UPnP service, parsed from the device XML description.
Definition description.hxx:46
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition avlastchg.cxx:28