MythTV master
upnpcdsobjects.h
Go to the documentation of this file.
1
2// Program Name: UPnpCDSObjects.h
3// Created : Oct. 24, 2005
4//
5// Purpose : uPnp Content Directory Service Object Definitions
6//
7// Copyright (c) 2005 David Blain <dblain@mythtv.org>
8//
9// Licensed under the GPL v2 or later, see LICENSE for details
10//
12
13#ifndef UPNPCDSOBJECTS_H
14#define UPNPCDSOBJECTS_H
15
16#include <utility>
17
18#include <QDateTime>
19#include <QList>
20#include <QMap>
21#include <QString>
22
24
25#include "upnpexp.h"
26#include "httprequest.h"
27
28class CDSObject;
29class QTextStream;
30
32//
34
35enum ObjectTypes : std::uint8_t
36{
40 OT_Res = 3
41};
42
44//
46
48{
49 public:
50
51 QString m_sName;
52 QString m_sNameSpace;
53 bool m_bRequired {false};
54 bool m_bMultiValue {false};
56
57 public:
58
59 explicit Property( QString sName,
60 QString sNameSpace = "",
61 bool bRequired = false,
62 const QString &sValue = "",
63 bool bMultiValue = false
64 )
65 : m_sName(std::move(sName)),
66 m_sNameSpace(std::move(sNameSpace)),
67 m_bRequired(bRequired),
68 m_bMultiValue(bMultiValue)
69 {
71 }
72
73 void SetValue(const QString &value)
74 {
75 m_sValue = value;
76 }
77
78 QString GetValue(void) const
79 {
80 return m_sValue;
81 }
82
83 QString GetEncodedValue(void) const
84 {
86 }
87
88 void AddAttribute( const QString &sName,
89 const QString &sValue )
90 {
91 m_lstAttributes.push_back(NameValue(sName, HTTPRequest::Encode(sValue)));
92 }
93
94 protected:
95 QString m_sValue;
96};
97
98using Properties = QMultiMap<QString,Property*>;
99using CDSObjects = QList<CDSObject*>;
100
102//
104
106{
107 public:
108
110 QString m_sURI;
111
113
114 public:
115
116 Resource( QString sProtocolInfo,
117 const QString &sURI )
118 : m_sProtocolInfo(std::move(sProtocolInfo))
119 {
121 }
122
123 void AddAttribute( const QString &sName,
124 const QString &sValue )
125 {
126 m_lstAttributes.push_back(NameValue(sName, HTTPRequest::Encode(sValue)));
127 }
128};
129
130using Resources = QList<Resource*>;
131
133//
135
137{
138 public:
139
140 QString m_sClass;
141 QString m_sName;
143
144 public:
145
146 ContainerClass( QString sClass,
147 QString sName,
148 bool bIncludeDerived )
149 : m_sClass(std::move(sClass)),
150 m_sName(std::move(sName)),
151 m_bIncludeDerived(bIncludeDerived)
152 {
153 }
154};
155
156using Classes = QList<ContainerClass*>;
157
182using FilterMap = QStringList;
183
185
187{
188 public:
189 short m_nUpdateId {1};
190
192
193 // Required
194
195 QString m_sId;
196 QString m_sParentId;
197 QString m_sTitle;
198 QString m_sClass;
199 bool m_bRestricted {true};
200 bool m_bSearchable {false};
201
202 // Optional
203
204 QString m_sCreator;
205 QString m_sWriteStatus {"PROTECTED"};
206
207 // Only appropriate for Container Classes
208
211
212 //
213
216 uint32_t m_nChildCount {0};
217 uint32_t m_nChildContainerCount {0};
218
220
221
222 public:
223
224 explicit CDSObject( const QString &sId = "-1",
225 const QString &sTitle = "",
226 const QString &sParentId = "-1" );
227 ~CDSObject() override;
228
229 Property *AddProperty( Property *pProp );
230 QList<Property*> GetProperties( const QString &sName );
231 CDSObject *AddChild ( CDSObject *pChild );
232 CDSObjects GetChildren( void ) const { return m_children; }
233 CDSObject *GetChild ( const QString &sID );
234
237
238 void SetPropValue( const QString &sName, const QString &sValue,
239 const QString &type = "" );
240 QString GetPropValue( const QString &sName ) const;
241 QString toXml ( FilterMap &filter,
242 bool ignoreChildren = false ) const;
243 void toXml ( QTextStream &os, FilterMap &filter,
244 bool ignoreChildren = false ) const;
245
246 uint32_t GetChildCount( void ) const;
247 void SetChildCount( uint32_t nCount );
248
249 uint32_t GetChildContainerCount( void ) const;
250 void SetChildContainerCount( uint32_t nCount );
251
252 Resource *AddResource( const QString& sProtocol, const QString& sURI );
253
254 public:
255
256 static CDSObject *CreateItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
257 static CDSObject *CreateContainer ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
258 static CDSObject *CreateAudioItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
259 static CDSObject *CreateMusicTrack ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
260 static CDSObject *CreateAudioBroadcast ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
261 static CDSObject *CreateAudioBook ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
262 static CDSObject *CreateVideoItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
263 static CDSObject *CreateMovie ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
264 static CDSObject *CreateVideoBroadcast ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
265 static CDSObject *CreateMusicVideoClip ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
266 static CDSObject *CreateImageItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
267 static CDSObject *CreatePhoto ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
268 static CDSObject *CreatePlaylistItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
269 static CDSObject *CreateTextItem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
270 static CDSObject *CreateAlbum ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
271 static CDSObject *CreateMusicAlbum ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
272 static CDSObject *CreatePhotoAlbum ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
273 static CDSObject *CreateGenre ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
274 static CDSObject *CreateMusicGenre ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
275 static CDSObject *CreateMovieGenre ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
276 static CDSObject *CreatePlaylistContainer( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
277 static CDSObject *CreatePerson ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
278 static CDSObject *CreateMusicArtist ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
279 static CDSObject *CreateStorageSystem ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
280 static CDSObject *CreateStorageVolume ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
281 static CDSObject *CreateStorageFolder ( const QString& sId, const QString& sTitle, const QString& sParentId, CDSObject *pObject = nullptr );
282
283 private:
284 static bool FilterContains( const FilterMap &filter, const QString &name ) ;
285
286};
287
288#endif // UPNPCDSOBJECTS_H
QMap< uint, int > FilterMap
Classes m_SearchClass
CDSObjects m_children
ContainerClass * AddCreateClass(ContainerClass *pClass)
QString m_sParentId
Resources m_resources
ContainerClass * AddSearchClass(ContainerClass *pClass)
CDSObjects GetChildren(void) const
QString m_sClass
QString m_sTitle
QString m_sCreator
QString m_sId
Properties m_properties
Classes m_CreateClass
ContainerClass(QString sClass, QString sName, bool bIncludeDerived)
static QString Encode(const QString &sIn)
Property(QString sName, QString sNameSpace="", bool bRequired=false, const QString &sValue="", bool bMultiValue=false)
QString GetEncodedValue(void) const
NameValues m_lstAttributes
void AddAttribute(const QString &sName, const QString &sValue)
bool m_bMultiValue
QString m_sNameSpace
QString m_sName
bool m_bRequired
QString GetValue(void) const
void SetValue(const QString &value)
QString m_sValue
General purpose reference counter.
NameValues m_lstAttributes
QString m_sProtocolInfo
Resource(QString sProtocolInfo, const QString &sURI)
void AddAttribute(const QString &sName, const QString &sValue)
QString m_sURI
STL namespace.
QList< Resource * > Resources
QMultiMap< QString, Property * > Properties
QList< ContainerClass * > Classes
QList< CDSObject * > CDSObjects
ObjectTypes
@ OT_Undefined
@ OT_Item
@ OT_Container
@ OT_Res
#define UPNP_PUBLIC
Definition: upnpexp.h:9