~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/dlnaexport/extra/hupnp/src/devicemodel/hservices_setupdata.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-09-27 21:41:30 UTC
  • mfrom: (1.2.43)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: package-import@ubuntu.com-20120927214130-i8v3ufr21nesp29i
Tags: 4:3.0.0~beta1a-1
* New upstream release

* Fix "wrongly conflicts phonon-backend-vlc" dropped (Closes: #688142)
* debian/watch include download.kde.org

* digikam 3.0.0 uses features from unreleased kdegraphics >=4.10 & ships 
a private version of the kdegraphics libs - this is not the Debian way :-(
* Unsatisfactory Conflicts: libkipi8, libkexiv2-10, libkdcraw20, libksane0
* Suspend digikam-dbg >130Mb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2010, 2011 Tuomo Penttinen, all rights reserved.
 
3
 *
 
4
 *  Author: Tuomo Penttinen <tp@herqq.org>
 
5
 *
 
6
 *  This file is part of Herqq UPnP (HUPnP) library.
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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/>.
 
20
 */
 
21
 
 
22
#include "hservices_setupdata.h"
 
23
#include "../dataelements/hserviceid.h"
 
24
#include "../dataelements/hresourcetype.h"
 
25
 
 
26
#include <QtCore/QSet>
 
27
 
 
28
namespace Herqq
 
29
{
 
30
 
 
31
namespace Upnp
 
32
{
 
33
 
 
34
/*******************************************************************************
 
35
 * HServiceSetupPrivate
 
36
 ******************************************************************************/
 
37
class HServiceSetupPrivate :
 
38
    public QSharedData
 
39
{
 
40
 
 
41
public:
 
42
 
 
43
    HServiceId m_serviceId;
 
44
    HResourceType m_serviceType;
 
45
    int m_version;
 
46
    HInclusionRequirement m_inclusionReq;
 
47
 
 
48
    HServiceSetupPrivate() :
 
49
        m_serviceId(), m_serviceType(), m_version(0),
 
50
        m_inclusionReq(InclusionRequirementUnknown)
 
51
    {
 
52
    }
 
53
 
 
54
    ~HServiceSetupPrivate()
 
55
    {
 
56
    }
 
57
};
 
58
 
 
59
/*******************************************************************************
 
60
 * HServiceSetup
 
61
 ******************************************************************************/
 
62
HServiceSetup::HServiceSetup() :
 
63
    h_ptr(new HServiceSetupPrivate())
 
64
{
 
65
}
 
66
 
 
67
HServiceSetup::HServiceSetup(
 
68
    const HServiceId& id, const HResourceType& serviceType,
 
69
    HInclusionRequirement ireq) :
 
70
        h_ptr(new HServiceSetupPrivate())
 
71
{
 
72
    h_ptr->m_serviceId = id;
 
73
    h_ptr->m_serviceType = serviceType;
 
74
    h_ptr->m_version = 1;
 
75
    h_ptr->m_inclusionReq = ireq;
 
76
}
 
77
 
 
78
HServiceSetup::HServiceSetup(
 
79
    const HServiceId& id, const HResourceType& serviceType, int version,
 
80
    HInclusionRequirement ireq) :
 
81
        h_ptr(new HServiceSetupPrivate())
 
82
{
 
83
    h_ptr->m_serviceId = id;
 
84
    h_ptr->m_serviceType = serviceType;
 
85
    h_ptr->m_version = version;
 
86
    h_ptr->m_inclusionReq = ireq;
 
87
}
 
88
 
 
89
HServiceSetup::~HServiceSetup()
 
90
{
 
91
}
 
92
 
 
93
HServiceSetup& HServiceSetup::operator=(const HServiceSetup& other)
 
94
{
 
95
    Q_ASSERT(&other != this);
 
96
 
 
97
    h_ptr = other.h_ptr;
 
98
 
 
99
    return *this;
 
100
}
 
101
 
 
102
HServiceSetup::HServiceSetup(const HServiceSetup& other) :
 
103
    h_ptr(other.h_ptr)
 
104
{
 
105
    Q_ASSERT(this != &other);
 
106
}
 
107
 
 
108
bool HServiceSetup::isValid(HValidityCheckLevel checkLevel) const
 
109
{
 
110
    return h_ptr->m_serviceId.isValid(checkLevel) &&
 
111
           h_ptr->m_serviceType.isValid() &&
 
112
           h_ptr->m_version > 0 &&
 
113
           h_ptr->m_inclusionReq != InclusionRequirementUnknown;
 
114
}
 
115
 
 
116
HInclusionRequirement HServiceSetup::inclusionRequirement() const
 
117
{
 
118
    return h_ptr->m_inclusionReq;
 
119
}
 
120
 
 
121
const HServiceId& HServiceSetup::serviceId() const
 
122
{
 
123
    return h_ptr->m_serviceId;
 
124
}
 
125
 
 
126
const HResourceType& HServiceSetup::serviceType() const
 
127
{
 
128
    return h_ptr->m_serviceType;
 
129
}
 
130
 
 
131
int HServiceSetup::version() const
 
132
{
 
133
    return h_ptr->m_version;
 
134
}
 
135
 
 
136
void HServiceSetup::setInclusionRequirement(HInclusionRequirement arg)
 
137
{
 
138
    h_ptr->m_inclusionReq = arg;
 
139
}
 
140
 
 
141
void HServiceSetup::setServiceId(const HServiceId& arg)
 
142
{
 
143
    h_ptr->m_serviceId = arg;
 
144
}
 
145
 
 
146
void HServiceSetup::setServiceType(const HResourceType& arg)
 
147
{
 
148
    h_ptr->m_serviceType = arg;
 
149
}
 
150
 
 
151
void HServiceSetup::setVersion(int version)
 
152
{
 
153
    h_ptr->m_version = version;
 
154
}
 
155
 
 
156
bool operator==(const HServiceSetup& obj1, const HServiceSetup& obj2)
 
157
{
 
158
    return obj1.inclusionRequirement() == obj2.inclusionRequirement() &&
 
159
           obj1.serviceId() == obj2.serviceId() &&
 
160
           obj1.serviceType() == obj2.serviceType() &&
 
161
           obj1.version() == obj2.version();
 
162
}
 
163
 
 
164
/*******************************************************************************
 
165
 * HServicesSetupData
 
166
 ******************************************************************************/
 
167
HServicesSetupData::HServicesSetupData() :
 
168
    m_serviceSetupInfos()
 
169
{
 
170
}
 
171
 
 
172
HServicesSetupData::~HServicesSetupData()
 
173
{
 
174
}
 
175
 
 
176
bool HServicesSetupData::insert(const HServiceSetup& setupInfo, bool overWrite)
 
177
{
 
178
    if (!setupInfo.isValid(StrictChecks))
 
179
    {
 
180
        return false;
 
181
    }
 
182
 
 
183
    const HServiceId& id = setupInfo.serviceId();
 
184
    if (!overWrite && m_serviceSetupInfos.contains(id))
 
185
    {
 
186
        return false;
 
187
    }
 
188
 
 
189
    m_serviceSetupInfos.insert(id, setupInfo);
 
190
    return true;
 
191
}
 
192
 
 
193
bool HServicesSetupData::remove(const HServiceId& serviceId)
 
194
{
 
195
    if (m_serviceSetupInfos.contains(serviceId))
 
196
    {
 
197
        m_serviceSetupInfos.remove(serviceId);
 
198
        return true;
 
199
    }
 
200
 
 
201
    return false;
 
202
}
 
203
 
 
204
HServiceSetup HServicesSetupData::get(const HServiceId& serviceId) const
 
205
{
 
206
    return m_serviceSetupInfos.value(serviceId);
 
207
}
 
208
 
 
209
bool HServicesSetupData::contains(const HServiceId& id) const
 
210
{
 
211
    return m_serviceSetupInfos.contains(id);
 
212
}
 
213
 
 
214
QSet<HServiceId> HServicesSetupData::serviceIds() const
 
215
{
 
216
    return m_serviceSetupInfos.keys().toSet();
 
217
}
 
218
 
 
219
int HServicesSetupData::size() const
 
220
{
 
221
    return m_serviceSetupInfos.size();
 
222
}
 
223
 
 
224
bool HServicesSetupData::isEmpty() const
 
225
{
 
226
    return m_serviceSetupInfos.isEmpty();
 
227
}
 
228
 
 
229
bool operator==(const HServicesSetupData& obj1, const HServicesSetupData& obj2)
 
230
{
 
231
    return obj1.m_serviceSetupInfos == obj2.m_serviceSetupInfos;
 
232
}
 
233
 
 
234
}
 
235
}