2
* Copyright (C) 2010, 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP (HUPnP) library.
8
* Herqq UPnP is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser 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 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 Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with Herqq UPnP. If not, see <http://www.gnu.org/licenses/>.
22
#include "hserverdevice.h"
23
#include "hserverdevice_p.h"
24
#include "hserverservice.h"
25
#include "hdefault_serverdevice_p.h"
27
#include "../../dataelements/hserviceid.h"
28
#include "../../dataelements/hdeviceinfo.h"
29
#include "../../dataelements/hserviceinfo.h"
31
#include "../../general/hupnp_global_p.h"
33
#include <QtCore/QString>
41
/*******************************************************************************
42
* HServerDevicePrivate
43
******************************************************************************/
45
/*******************************************************************************
47
******************************************************************************/
48
HServerDevice::HServerDevice() :
50
h_ptr(new HServerDevicePrivate())
54
HServerDevice::HServerDevice(HServerDevicePrivate& dd) :
60
HServerDevice::~HServerDevice()
65
bool HServerDevice::finalizeInit(QString*)
67
// intentionally empty
68
Q_ASSERT(h_ptr->q_ptr);
72
bool HServerDevice::init(const HDeviceInfo& info, HServerDevice* parentDevice)
79
if (parentDevice) { setParent(parentDevice); }
80
h_ptr->m_parentDevice = parentDevice;
81
h_ptr->m_deviceInfo.reset(new HDeviceInfo(info));
87
HServerDevice* HServerDevice::parentDevice() const
89
return h_ptr->m_parentDevice;
92
HServerDevice* HServerDevice::rootDevice() const
94
return h_ptr->rootDevice();
97
HServerService* HServerDevice::serviceById(const HServiceId& serviceId) const
99
return h_ptr->serviceById(serviceId);
102
const HServerServices& HServerDevice::services() const
104
return h_ptr->m_services;
107
HServerServices HServerDevice::servicesByType(
108
const HResourceType& type, HResourceType::VersionMatch versionMatch) const
110
return h_ptr->servicesByType(type, versionMatch);
113
const HServerDevices& HServerDevice::embeddedDevices() const
115
return h_ptr->m_embeddedDevices;
118
HServerDevices HServerDevice::embeddedDevicesByType(
119
const HResourceType& type, HResourceType::VersionMatch versionMatch) const
121
return h_ptr->embeddedDevicesByType(type, versionMatch);
124
const HDeviceInfo& HServerDevice::info() const
126
return *h_ptr->m_deviceInfo;
129
QString HServerDevice::description() const
131
return h_ptr->m_deviceDescription;
134
QList<QUrl> HServerDevice::locations(LocationUrlType urlType) const
136
if (h_ptr->m_parentDevice)
138
// the root device "defines" the locations and they are the same for each
140
return h_ptr->m_parentDevice->locations(urlType);
144
QList<QUrl>::const_iterator ci;
145
for(ci = h_ptr->m_locations.begin(); ci != h_ptr->m_locations.end(); ++ci)
147
retVal.push_back(urlType == AbsoluteUrl ? *ci : extractBaseUrl(*ci));
153
const HDeviceStatus& HServerDevice::deviceStatus() const
155
const HServerDevice* rootDev = rootDevice();
156
return *rootDev->h_ptr->m_deviceStatus;
159
/*******************************************************************************
160
* HDefaultServerDevice
161
******************************************************************************/
162
HDefaultServerDevice::HDefaultServerDevice() :