00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifndef __UPNPCDSOBJECTS_H_
00014 #define __UPNPCDSOBJECTS_H_
00015
00016 #include <QDateTime>
00017 #include <QString>
00018 #include <QList>
00019 #include <QMap>
00020
00021 #include "upnpexp.h"
00022
00023 class CDSObject;
00024 class QTextStream;
00025
00027
00029
00030 typedef enum
00031 {
00032 OT_Undefined = 0,
00033 OT_Container = 1,
00034 OT_Item = 2,
00035 OT_Res = 3
00036
00037 } ObjectTypes;
00038
00040
00042
00043 class Property
00044 {
00045 public:
00046
00047 QString m_sName;
00048 QString m_sNameSpace;
00049 bool m_bRequired;
00050 QString m_sValue;
00051 NameValues m_lstAttributes;
00052
00053 public:
00054
00055 explicit Property( const QString &sName,
00056 const QString &sNameSpace = "",
00057 bool bRequired = false,
00058 const QString &sValue = "" )
00059 {
00060 m_sName = sName;
00061 m_sNameSpace = sNameSpace;
00062 m_bRequired = bRequired;
00063 m_sValue = sValue;
00064 }
00065
00066 void AddAttribute( const QString &sName,
00067 const QString &sValue )
00068 {
00069 m_lstAttributes.push_back(NameValue(sName, sValue));
00070 }
00071 };
00072
00073 typedef QMap<QString,Property*> Properties;
00074 typedef QList<CDSObject*> CDSObjects;
00075
00077
00079
00080 class Resource
00081 {
00082 public:
00083
00084 QString m_sProtocolInfo;
00085 QString m_sURI;
00086
00087 NameValues m_lstAttributes;
00088
00089 public:
00090
00091 Resource( const QString &sProtocolInfo,
00092 const QString &sURI )
00093 {
00094 m_sProtocolInfo = sProtocolInfo;
00095 m_sURI = sURI;
00096 }
00097
00098 void AddAttribute( const QString &sName,
00099 const QString &sValue )
00100 {
00101 m_lstAttributes.push_back(NameValue(sName, sValue));
00102 }
00103 };
00104
00105 typedef QList<Resource*> Resources;
00106
00108
00110
00111 class ContainerClass
00112 {
00113 public:
00114
00115 QString m_sClass;
00116 QString m_sName;
00117 bool m_bIncludeDerived;
00118
00119 public:
00120
00121 ContainerClass( const QString &sClass,
00122 const QString &sName,
00123 bool bIncludeDerived )
00124 {
00125 m_sClass = sClass;
00126 m_sName = sName;
00127 m_bIncludeDerived = bIncludeDerived;
00128 }
00129 };
00130
00131 typedef QList<ContainerClass*> Classes;
00132
00133 typedef QStringList FilterMap;
00134
00136
00137 class UPNP_PUBLIC CDSObject
00138 {
00139 public:
00140 short m_nUpdateId;
00141
00142 ObjectTypes m_eType;
00143
00144
00145
00146 QString m_sId;
00147 QString m_sParentId;
00148 QString m_sTitle;
00149 QString m_sClass;
00150 bool m_bRestricted;
00151 bool m_bSearchable;
00152
00153
00154
00155 QString m_sCreator;
00156 QString m_sWriteStatus;
00157
00158
00159
00160 Classes m_SearchClass;
00161 Classes m_CreateClass;
00162
00163
00164
00165 Properties m_properties;
00166 CDSObjects m_children;
00167 long m_nChildCount;
00168
00169 Resources m_resources;
00170
00171
00172 public:
00173
00174 explicit CDSObject( const QString sId = "-1",
00175 const QString sTitle = "",
00176 const QString sParentId = "-1" );
00177 virtual ~CDSObject();
00178
00179 Property *AddProperty( Property *pProp );
00180 Property *GetProperty( QString sName );
00181 CDSObject *AddChild ( CDSObject *pChild );
00182
00183 ContainerClass *AddSearchClass( ContainerClass *pClass );
00184 ContainerClass *AddCreateClass( ContainerClass *pClass );
00185
00186 void SetPropValue( QString sName, QString sValue );
00187 QString GetPropValue( const QString &sName ) const;
00188 QString toXml ( FilterMap &filter ) const;
00189 void toXml ( QTextStream &os, FilterMap &filter ) const;
00190
00191 long GetChildCount( void ) const;
00192 void SetChildCount( long nCount );
00193
00194 Resource *AddResource( QString sProtocol, QString sURI );
00195
00196 public:
00197
00198 static CDSObject *CreateItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00199 static CDSObject *CreateContainer ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00200 static CDSObject *CreateAudioItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00201 static CDSObject *CreateMusicTrack ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00202 static CDSObject *CreateAudioBroadcast ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00203 static CDSObject *CreateAudioBook ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00204 static CDSObject *CreateVideoItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00205 static CDSObject *CreateMovie ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00206 static CDSObject *CreateVideoBroadcast ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00207 static CDSObject *CreateMusicVideoClip ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00208 static CDSObject *CreateImageItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00209 static CDSObject *CreatePhoto ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00210 static CDSObject *CreatePlaylistItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00211 static CDSObject *CreateTextItem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00212 static CDSObject *CreateAlbum ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00213 static CDSObject *CreateMusicAlbum ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00214 static CDSObject *CreatePhotoAlbum ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00215 static CDSObject *CreateGenre ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00216 static CDSObject *CreateMusicGenre ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00217 static CDSObject *CreateMovieGenre ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00218 static CDSObject *CreatePlaylistContainer( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00219 static CDSObject *CreatePerson ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00220 static CDSObject *CreateMusicArtist ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00221 static CDSObject *CreateStorageSystem ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00222 static CDSObject *CreateStorageVolume ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00223 static CDSObject *CreateStorageFolder ( QString sId, QString sTitle, QString sParentId, CDSObject *pObject = NULL );
00224
00225 };
00226
00227 #endif