-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqhtspservicedata.cpp
102 lines (86 loc) · 2.33 KB
/
qhtspservicedata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (C) 2012 Robert Meijers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qhtspservice.h"
QHtspServiceData::QHtspServiceData(QHtspChannel *channel)
: channel(channel)
{
}
QHtspServiceData::QHtspServiceData(const QHtspServiceData &other)
: QObject(0), QSharedData(other), caid(other.caid), caname(other.caname), channel(other.channel), name(other.name), type(other.type)
{
}
void QHtspServiceData::setCaid(qint64 caid)
{
if(this->caid == caid)
return;
this->caid = caid;
emit caidChanged();
}
void QHtspServiceData::setCaname(QString caname)
{
if(this->caname == caname)
return;
this->caname = caname;
emit canameChanged();
}
void QHtspServiceData::setName(QString name)
{
if(this->name == name)
return;
this->name = name;
emit nameChanged();
}
void QHtspServiceData::setType(qint64 type)
{
if(this->type == type)
return;
this->type = type;
emit typeChanged();
}
void QHtspServiceData::parseMessage(QHtspMessage &message)
{
qint64 caid;
QString caname;
QString name;
QString type;
bool ok;
caid = message.getInt64("caid", &ok);
if(ok)
setCaid(caid);
caname = message.getString("caname", &ok);
if(ok)
setCaname(caname);
name = message.getString("name", &ok);
if(ok)
setName(name);
type = message.getString("type", &ok);
if(ok)
{
if(type == "Radio")
{
setType(QHtspService::RadioType);
}
else if(type == "SDTV" || type == "SDTV-AC")
{
setType(QHtspService::SdTvType);
}
else if(type == "HDTV" || type == "HDTV-AC")
{
setType(QHtspService::HdTvType);
}
}
}