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 "htransportinfo.h"
33
/*******************************************************************************
35
******************************************************************************/
36
HTransportStatus::HTransportStatus() :
37
m_type(Undefined), m_typeAsString()
41
HTransportStatus::HTransportStatus(Type type) :
42
m_type(type), m_typeAsString(toString(type))
46
HTransportStatus::HTransportStatus(const QString& arg) :
47
m_type(), m_typeAsString()
49
QString trimmed = arg.trimmed();
50
m_type = fromString(trimmed);
51
m_typeAsString = trimmed;
54
QString HTransportStatus::toString(HTransportStatus::Type type)
59
case HTransportStatus::OK:
62
case HTransportStatus::ErrorOccurred:
63
retVal = "ERROR_OCCURRED";
71
HTransportStatus::Type HTransportStatus::fromString(const QString& type)
73
Type retVal = Undefined;
74
if (type.compare("OK", Qt::CaseInsensitive) == 0)
78
else if (type.compare("ERROR_OCCURRED", Qt::CaseInsensitive) == 0)
80
retVal = ErrorOccurred;
82
else if (!type.isEmpty())
84
retVal = VendorDefined;
89
bool operator==(const HTransportStatus& obj1, const HTransportStatus& obj2)
91
return obj1.toString() == obj2.toString();
94
/*******************************************************************************
95
* HTransportInfoPrivate
96
******************************************************************************/
97
class HTransportInfoPrivate :
100
H_DISABLE_ASSIGN(HTransportInfoPrivate)
104
HTransportState m_transportState;
105
HTransportStatus m_transportStatus;
106
QString m_transportPlaySpeed;
108
HTransportInfoPrivate() :
109
m_transportState(), m_transportStatus(), m_transportPlaySpeed()
114
/*******************************************************************************
116
******************************************************************************/
117
HTransportInfo::HTransportInfo() :
118
h_ptr(new HTransportInfoPrivate())
122
HTransportInfo::HTransportInfo(
123
const HTransportState& state, const HTransportStatus& status,
124
const QString& speed) :
125
h_ptr(new HTransportInfoPrivate())
127
h_ptr->m_transportState = state;
128
h_ptr->m_transportStatus = status;
129
h_ptr->m_transportPlaySpeed = speed;
132
HTransportInfo::HTransportInfo(const HTransportInfo& other) :
135
Q_ASSERT(&other != this);
138
HTransportInfo& HTransportInfo::operator =(const HTransportInfo& other)
140
Q_ASSERT(&other != this);
145
HTransportInfo::~HTransportInfo()
149
const HTransportState& HTransportInfo::state() const
151
return h_ptr->m_transportState;
154
const HTransportStatus& HTransportInfo::status() const
156
return h_ptr->m_transportStatus;
159
QString HTransportInfo::speed() const
161
return h_ptr->m_transportPlaySpeed;
164
bool HTransportInfo::isValid()
166
return h_ptr->m_transportState.isValid() && h_ptr->m_transportStatus.isValid();
169
void HTransportInfo::setState(const HTransportState& arg)
171
h_ptr->m_transportState = arg;
174
void HTransportInfo::setStatus(const HTransportStatus& arg)
176
h_ptr->m_transportStatus = arg;
179
void HTransportInfo::setSpeed(const QString& arg)
181
h_ptr->m_transportPlaySpeed = arg;
184
bool operator==(const HTransportInfo& obj1, const HTransportInfo& obj2)
186
return obj1.speed() == obj2.speed() &&
187
obj1.state() == obj2.state() &&
188
obj1.status() == obj2.status();