2
* Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP Av (HUPnPAv) library.
8
* Herqq UPnP Av is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* Herqq UPnP Av is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
22
#include "hcdsproperties.h"
24
#include <HUpnpAv/HStateVariableCollection>
25
#include <HUpnpAv/HCdsPropertyInfo>
26
#include <HUpnpAv/HChannelGroupName>
27
#include <HUpnpAv/HForeignMetadata>
28
#include <HUpnpAv/HContentDuration>
29
#include <HUpnpAv/HScheduledTime>
30
#include <HUpnpAv/HDateTimeRange>
31
#include <HUpnpAv/HProgramCode>
32
#include <HUpnpAv/HMatchingId>
33
#include <HUpnpAv/HDeviceUdn>
34
#include <HUpnpAv/HRadioBand>
35
#include <HUpnpAv/HChannelId>
36
#include <HUpnpAv/HObject>
37
#include <HUpnpAv/HPrice>
39
#include <QtCore/QHash>
40
#include <QtCore/QMutex>
41
#include <QtCore/QVector>
42
#include <QtCore/QString>
43
#include <QtCore/QVariant>
44
#include <QtCore/QMutexLocker>
55
HCdsProperties* HCdsProperties::s_instance = 0;
56
QMutex* HCdsProperties::s_instanceLock = new QMutex();
58
class HCdsPropertiesPrivate
60
H_DISABLE_COPY(HCdsPropertiesPrivate)
64
QVector<const HCdsPropertyInfo*> m_propertyInfos;
65
QHash<const QString, const HCdsPropertyInfo*> m_propertyInfosHash;
67
inline HCdsPropertiesPrivate(){}
68
inline ~HCdsPropertiesPrivate()
70
qDeleteAll(m_propertyInfos);
73
inline void insert(HCdsPropertyInfo* obj)
76
m_propertyInfos.append(obj);
77
m_propertyInfosHash.insert(obj->name(), obj);
83
bool lessThan(const HCdsPropertyInfo* obj1, const HCdsPropertyInfo* obj2)
85
return obj1->name() < obj2->name();
89
HCdsProperties::HCdsProperties() :
90
h_ptr(new HCdsPropertiesPrivate())
92
h_ptr->m_propertyInfos.reserve(92);
94
HCdsPropertyInfo* obj = new HCdsPropertyInfo(HCdsPropertyInfo::empty());
97
obj = HCdsPropertyInfo::create(
98
"@id", HCdsProperties::dlite_id, QVariant::String,
99
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::Mandatory) | HCdsPropertyInfo::StandardType);
102
obj = HCdsPropertyInfo::create(
103
"@parentID", HCdsProperties::dlite_id, QVariant::String,
104
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::Mandatory) | HCdsPropertyInfo::StandardType);
107
obj = HCdsPropertyInfo::create(
108
"@restricted", HCdsProperties::dlite_restricted, QVariant::Bool,
109
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::Mandatory) | HCdsPropertyInfo::StandardType);
112
obj = HCdsPropertyInfo::create(
113
"res", HCdsProperties::dlite_res, QVariant::List,
114
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::StandardType) | HCdsPropertyInfo::MultiValued);
117
obj = HCdsPropertyInfo::create(
118
"@refID", HCdsProperties::dlite_refId, QVariant::String, HCdsPropertyInfo::StandardType);
121
obj = HCdsPropertyInfo::create(
122
"@childCount", HCdsProperties::dlite_childCount, QVariant::Int, HCdsPropertyInfo::StandardType);
125
obj = HCdsPropertyInfo::create(
126
"@searchable", HCdsProperties::dlite_searchable, QVariant::Bool, HCdsPropertyInfo::StandardType);
129
obj = HCdsPropertyInfo::create(
130
"@neverPlayable", HCdsProperties::dlite_neverPlayable, QVariant::Bool, HCdsPropertyInfo::StandardType);
133
obj = HCdsPropertyInfo::create(
134
"dc:title", HCdsProperties::dc_title, QVariant::String,
135
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::StandardType) | HCdsPropertyInfo::Mandatory);
138
obj = HCdsPropertyInfo::create(
139
"dc:creator", HCdsProperties::dc_creator, QVariant::String, HCdsPropertyInfo::StandardType);
142
obj = HCdsPropertyInfo::create(
143
"dc:description", HCdsProperties::dc_description, QVariant::String, HCdsPropertyInfo::StandardType);
146
obj = HCdsPropertyInfo::create(
147
"dc:publisher", HCdsProperties::dc_publisher, QVariant::StringList,
148
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::StandardType) | HCdsPropertyInfo::MultiValued);
151
obj = HCdsPropertyInfo::create(
152
"dc:date", HCdsProperties::dc_date, QVariant::DateTime, HCdsPropertyInfo::StandardType);
155
obj = HCdsPropertyInfo::create(
156
"dc:rights", HCdsProperties::dc_rights, QVariant::StringList,
157
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
160
obj = HCdsPropertyInfo::create(
161
"dc:relation", HCdsProperties::dc_relation, QVariant::StringList,
162
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
165
obj = HCdsPropertyInfo::create(
166
"dc:language", HCdsProperties::dc_language, QVariant::StringList,
167
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
170
obj = HCdsPropertyInfo::create(
171
"dc:contributor", HCdsProperties::dc_contributor, QVariant::StringList,
172
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
175
obj = HCdsPropertyInfo::create(
176
"upnp:class", HCdsProperties::upnp_class, QVariant::String,
177
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::Mandatory) | HCdsPropertyInfo::StandardType);
180
obj = HCdsPropertyInfo::create(
181
"upnp:writeStatus", HCdsProperties::upnp_writeStatus, QVariant::fromValue(HObject::UnknownWriteStatus),
182
HCdsPropertyInfo::StandardType);
185
obj = HCdsPropertyInfo::create(
186
"upnp:objectUpdateID", HCdsProperties::upnp_objectUpdateID, QVariant::UInt,
187
HCdsPropertyInfo::StandardType | HCdsPropertyInfo::Disableable);
190
obj = HCdsPropertyInfo::create(
191
"upnp:bookmarkID", HCdsProperties::upnp_bookmarkID, QVariant::StringList, HCdsPropertyInfo::StandardType);
194
obj = HCdsPropertyInfo::create(
195
"upnp:longDescription", HCdsProperties::upnp_longDescription, QVariant::String, HCdsPropertyInfo::StandardType);
198
obj = HCdsPropertyInfo::create(
199
"upnp:rating", HCdsProperties::upnp_rating, QVariant::List,
200
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
203
obj = HCdsPropertyInfo::create(
204
"upnp:album", HCdsProperties::upnp_album, QVariant::StringList,
205
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
208
obj = HCdsPropertyInfo::create(
209
"upnp:genre", HCdsProperties::upnp_genre, QVariant::List,
210
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
213
obj = HCdsPropertyInfo::create(
214
"upnp:artist", HCdsProperties::upnp_artist, QVariant::List,
215
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
218
obj = HCdsPropertyInfo::create(
219
"upnp:originalTrackNumber", HCdsProperties::upnp_originalTrackNumber, QVariant::UInt, HCdsPropertyInfo::StandardType);
222
obj = HCdsPropertyInfo::create(
223
"upnp:producer", HCdsProperties::upnp_producer, QVariant::StringList,
224
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
227
obj = HCdsPropertyInfo::create(
228
"upnp:actor", HCdsProperties::upnp_actor, QVariant::List,
229
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
232
obj = HCdsPropertyInfo::create(
233
"upnp:playList", HCdsProperties::upnp_playList, QVariant::StringList,
234
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
237
obj = HCdsPropertyInfo::create(
238
"upnp:director", HCdsProperties::upnp_director, QVariant::StringList,
239
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
242
obj = HCdsPropertyInfo::create(
243
"upnp:playbackCount", HCdsProperties::upnp_playbackCount, QVariant::UInt, HCdsPropertyInfo::StandardType);
246
obj = HCdsPropertyInfo::create(
247
"upnp:lastPlaybackTime", HCdsProperties::upnp_lastPlaybackTime, QVariant::DateTime, HCdsPropertyInfo::StandardType);
250
obj = HCdsPropertyInfo::create(
251
"upnp:lastPlaybackPosition", HCdsProperties::upnp_lastPlaybackPosition, QVariant::fromValue(HContentDuration()), HCdsPropertyInfo::StandardType);
254
obj = HCdsPropertyInfo::create(
255
"upnp:recordedStartDateTime", HCdsProperties::upnp_recordedStartDateTime, QVariant::DateTime, HCdsPropertyInfo::StandardType);
258
obj = HCdsPropertyInfo::create(
259
"upnp:recordedDuration", HCdsProperties::upnp_recordedDuration, QVariant::fromValue(HContentDuration()), HCdsPropertyInfo::StandardType);
262
obj = HCdsPropertyInfo::create(
263
"upnp:recordedDayOfWeek", HCdsProperties::upnp_recordedDayOfWeek, QVariant::fromValue(Undefined_DayOfWeek),
264
HCdsPropertyInfo::StandardType);
267
obj = HCdsPropertyInfo::create(
268
"upnp:srsRecordScheduleID", HCdsProperties::upnp_srsRecordScheduleID, QVariant::String, HCdsPropertyInfo::StandardType);
271
obj = HCdsPropertyInfo::create(
272
"upnp:srsRecordTaskID", HCdsProperties::upnp_srsRecordTaskID, QVariant::String, HCdsPropertyInfo::StandardType);
275
obj = HCdsPropertyInfo::create(
276
"upnp:author", HCdsProperties::upnp_author, QVariant::List,
277
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
280
obj = HCdsPropertyInfo::create(
281
"upnp:storageMedium", HCdsProperties::upnp_storageMedium, QVariant::String, HCdsPropertyInfo::StandardType);
284
obj = HCdsPropertyInfo::create(
285
"upnp:storageTotal", HCdsProperties::upnp_storageTotal, QVariant::ULongLong, HCdsPropertyInfo::StandardType);
288
obj = HCdsPropertyInfo::create(
289
"upnp:storageUsed", HCdsProperties::upnp_storageUsed, QVariant::ULongLong, HCdsPropertyInfo::StandardType);
292
obj = HCdsPropertyInfo::create(
293
"upnp:storageFree", HCdsProperties::upnp_storageFree, QVariant::ULongLong, HCdsPropertyInfo::StandardType);
296
obj = HCdsPropertyInfo::create(
297
"upnp:storageMaxPartition", HCdsProperties::upnp_storageMaxPartition, QVariant::ULongLong, HCdsPropertyInfo::StandardType);
300
obj = HCdsPropertyInfo::create(
301
"upnp:containerUpdateID", HCdsProperties::upnp_containerUpdateID, QVariant::String,
302
HCdsPropertyInfo::StandardType | HCdsPropertyInfo::Disableable);
305
obj = HCdsPropertyInfo::create(
306
"upnp:totalDeletedChildCount", HCdsProperties::upnp_totalDeletedChildCount, QVariant::UInt,
307
HCdsPropertyInfo::StandardType | HCdsPropertyInfo::Disableable);
310
obj = HCdsPropertyInfo::create(
311
"upnp:createClass", HCdsProperties::upnp_createClass, QVariant::List,
312
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
315
obj = HCdsPropertyInfo::create(
316
"upnp:searchClass", HCdsProperties::upnp_searchClass, QVariant::List,
317
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::MultiValued) | HCdsPropertyInfo::StandardType);
320
obj = HCdsPropertyInfo::create(
321
"upnp:region", HCdsProperties::upnp_region, QVariant::String, HCdsPropertyInfo::StandardType);
324
obj = HCdsPropertyInfo::create(
325
"upnp:radioCallSign", HCdsProperties::upnp_radioCallSign, QVariant::String, HCdsPropertyInfo::StandardType);
328
obj = HCdsPropertyInfo::create(
329
"upnp:radioStationID", HCdsProperties::upnp_radioStationID, QVariant::String, HCdsPropertyInfo::StandardType);
332
obj = HCdsPropertyInfo::create(
333
"upnp:radioBand", HCdsProperties::upnp_radioBand, QVariant::fromValue(HRadioBand()), HCdsPropertyInfo::StandardType);
336
obj = HCdsPropertyInfo::create(
337
"upnp:channelNr", HCdsProperties::upnp_channelNr, QVariant::Int, HCdsPropertyInfo::StandardType);
340
obj = HCdsPropertyInfo::create(
341
"upnp:signalStrength", HCdsProperties::upnp_signalStrength, QVariant::Int, HCdsPropertyInfo::StandardType);
344
obj = HCdsPropertyInfo::create(
345
"upnp:signalLocked", HCdsProperties::upnp_signalLocked, QVariant::Bool, HCdsPropertyInfo::StandardType);
348
obj = HCdsPropertyInfo::create(
349
"upnp:tuned", HCdsProperties::upnp_tuned, QVariant::Bool, HCdsPropertyInfo::StandardType);
352
obj = HCdsPropertyInfo::create(
353
"upnp:recordable", HCdsProperties::upnp_recordable, QVariant::Bool, HCdsPropertyInfo::StandardType);
356
obj = HCdsPropertyInfo::create(
357
"upnp:DVDRegionCode", HCdsProperties::upnp_dvdRegionCode, QVariant::String, HCdsPropertyInfo::StandardType);
360
obj = HCdsPropertyInfo::create(
361
"upnp:channelName", HCdsProperties::upnp_channelName, QVariant::String, HCdsPropertyInfo::StandardType);
364
obj = HCdsPropertyInfo::create(
365
"upnp:scheduledStartTime", HCdsProperties::upnp_scheduledStartTime, QVariant::fromValue(HScheduledTime()), HCdsPropertyInfo::StandardType);
368
obj = HCdsPropertyInfo::create(
369
"upnp:scheduledEndTime", HCdsProperties::upnp_scheduledEndTime, QVariant::fromValue(HScheduledTime()), HCdsPropertyInfo::StandardType);
372
obj = HCdsPropertyInfo::create(
373
"upnp:scheduledDuration", HCdsProperties::upnp_scheduledDuration, QVariant::String, HCdsPropertyInfo::StandardType);
376
obj = HCdsPropertyInfo::create(
377
"upnp:programTitle", HCdsProperties::upnp_programTitle, QVariant::String, HCdsPropertyInfo::StandardType);
380
obj = HCdsPropertyInfo::create(
381
"upnp:seriesTitle", HCdsProperties::upnp_seriesTitle, QVariant::String, HCdsPropertyInfo::StandardType);
384
obj = HCdsPropertyInfo::create(
385
"upnp:episodeCount", HCdsProperties::upnp_episodeCount, QVariant::Int, HCdsPropertyInfo::StandardType);
388
obj = HCdsPropertyInfo::create(
389
"upnp:episodeNumber", HCdsProperties::upnp_episodeNumber, QVariant::Int, HCdsPropertyInfo::StandardType);
392
obj = HCdsPropertyInfo::create(
393
"upnp:icon", HCdsProperties::upnp_icon, QVariant::Url, HCdsPropertyInfo::StandardType);
396
obj = HCdsPropertyInfo::create(
397
"upnp:callSign", HCdsProperties::upnp_callSign, QVariant::String, HCdsPropertyInfo::StandardType);
400
obj = HCdsPropertyInfo::create(
401
"upnp:price", HCdsProperties::upnp_price, QVariant::fromValue(HPrice()), HCdsPropertyInfo::StandardType);
404
obj = HCdsPropertyInfo::create(
405
"upnp:payPerView", HCdsProperties::upnp_payPerView, QVariant::Bool, HCdsPropertyInfo::StandardType);
408
obj = HCdsPropertyInfo::create(
409
"upnp:bookmarkedObjectID", HCdsProperties::upnp_bookmarkedObjectID, QVariant::String, HCdsPropertyInfo::StandardType);
412
obj = HCdsPropertyInfo::create(
413
"upnp:deviceUDN", HCdsProperties::upnp_deviceUdn, QVariant::fromValue(HDeviceUdn()), HCdsPropertyInfo::StandardType);
416
obj = HCdsPropertyInfo::create(
417
"upnp:stateVariableCollection", HCdsProperties::upnp_stateVariableCollection,
418
QVariant::fromValue(HStateVariableCollection()), HCdsPropertyInfo::StandardType);
421
obj = HCdsPropertyInfo::create(
422
"upnp:channelGroupName", HCdsProperties::upnp_channelGroupName, QVariant::fromValue(HChannelGroupName()), HCdsPropertyInfo::StandardType);
425
obj = HCdsPropertyInfo::create(
426
"upnp:epgProviderName", HCdsProperties::upnp_epgProviderName, QVariant::String, HCdsPropertyInfo::StandardType);
429
obj = HCdsPropertyInfo::create(
430
"upnp:dateTimeRange", HCdsProperties::upnp_dateTimeRange, QVariant::fromValue(HDateTimeRange()), HCdsPropertyInfo::StandardType);
433
obj = HCdsPropertyInfo::create(
434
"upnp:serviceProvider", HCdsProperties::upnp_serviceProvider, QVariant::String, HCdsPropertyInfo::StandardType);
437
obj = HCdsPropertyInfo::create(
438
"upnp:programID", HCdsProperties::upnp_programID, QVariant::fromValue(HMatchingId()), HCdsPropertyInfo::StandardType);
441
obj = HCdsPropertyInfo::create(
442
"upnp:seriesID", HCdsProperties::upnp_seriesID, QVariant::fromValue(HMatchingId()), HCdsPropertyInfo::StandardType);
445
obj = HCdsPropertyInfo::create(
446
"upnp:channelID", HCdsProperties::upnp_channelID, QVariant::fromValue(HChannelId()), HCdsPropertyInfo::StandardType);
449
obj = HCdsPropertyInfo::create(
450
"upnp:programCode", HCdsProperties::upnp_programCode, QVariant::fromValue(HProgramCode()), HCdsPropertyInfo::StandardType);
453
obj = HCdsPropertyInfo::create(
454
"upnp:episodeType", HCdsProperties::upnp_episodeType, QVariant::fromValue(HEpisodeType()), HCdsPropertyInfo::StandardType);
457
obj = HCdsPropertyInfo::create(
458
"upnp:networkAffiliation", HCdsProperties::upnp_networkAffiliation, QVariant::String, HCdsPropertyInfo::StandardType);
461
obj = HCdsPropertyInfo::create(
462
"upnp:foreignMetadata", HCdsProperties::upnp_foreignMetadata, QVariant::fromValue(HForeignMetadata()), HCdsPropertyInfo::StandardType);
465
obj = HCdsPropertyInfo::create(
466
"upnp:artistDiscographyURI", HCdsProperties::upnp_artistDiscographyURI, QVariant::Url, HCdsPropertyInfo::StandardType);
469
obj = HCdsPropertyInfo::create(
470
"upnp:lyricsURI", HCdsProperties::upnp_lyricsURI, QVariant::List, HCdsPropertyInfo::StandardType);
473
obj = HCdsPropertyInfo::create(
474
"upnp:albumArtURI", HCdsProperties::upnp_albumArtURI, QVariant::List,
475
HCdsPropertyInfo::PropertyFlags(HCdsPropertyInfo::StandardType) | HCdsPropertyInfo::MultiValued);
478
obj = HCdsPropertyInfo::create(
479
"upnp:toc", HCdsProperties::upnp_toc, QVariant::String, HCdsPropertyInfo::StandardType);
482
obj = HCdsPropertyInfo::create(
483
"upnp:userAnnotation", HCdsProperties::upnp_userAnnotation, QVariant::List, HCdsPropertyInfo::StandardType);
486
obj = HCdsPropertyInfo::create("desc", HCdsProperties::dlite_desc, QVariant::List, HCdsPropertyInfo::StandardType);
490
HCdsProperties::~HCdsProperties()
495
const HCdsProperties& HCdsProperties::instance()
497
QMutexLocker locker(s_instanceLock);
500
s_instance = new HCdsProperties();
505
const HCdsPropertyInfo& HCdsProperties::get(Property property) const
507
return *(*(h_ptr->m_propertyInfos.begin()+property));
510
const HCdsPropertyInfo& HCdsProperties::get(const QString& property) const
512
if (h_ptr->m_propertyInfosHash.contains(property))
514
return *h_ptr->m_propertyInfosHash.value(property);
516
return HCdsPropertyInfo::empty();