channel-class-spec.h Source File

| Home · All Classes · All Namespaces · Modules · Functions · Files

channel-class-spec.h
1
23 #ifndef _TelepathyQt_channel_class_spec_h_HEADER_GUARD_
24 #define _TelepathyQt_channel_class_spec_h_HEADER_GUARD_
25
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29
30 #include <TelepathyQt/Constants>
31 #include <TelepathyQt/Global>
32 #include <TelepathyQt/Types>
33
34 #include <QSharedDataPointer>
35 #include <QVariant>
36 #include <QVariantMap>
37 #include <QPair>
38
39 namespace Tp
40 {
41
42 class TP_QT_EXPORT ChannelClassSpec
43 {
44 public:
45 ChannelClassSpec();
46 ChannelClassSpec(const ChannelClass &cc);
47 ChannelClassSpec(const QVariantMap &props);
48 ChannelClassSpec(const QString &channelType, HandleType targetHandleType,
49 const QVariantMap &otherProperties = QVariantMap());
50 ChannelClassSpec(const QString &channelType, HandleType targetHandleType, bool requested,
51 const QVariantMap &otherProperties = QVariantMap());
52 ChannelClassSpec(const ChannelClassSpec &other,
53 const QVariantMap &additionalProperties = QVariantMap());
54 ~ChannelClassSpec();
55
56 bool isValid() const;
57
58 ChannelClassSpec &operator=(const ChannelClassSpec &other);
59
60 bool operator==(const ChannelClassSpec &other) const
61 {
62 return this->allProperties() == other.allProperties();
63 }
64
65 bool isSubsetOf(const ChannelClassSpec &other) const;
66 bool matches(const QVariantMap &immutableProperties) const;
67
68 QString channelType() const
69 {
70 return qdbus_cast<QString>(
71 property(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")));
72 }
73
74 void setChannelType(const QString &type)
75 {
76 setProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
77 QVariant::fromValue(type));
78 }
79
80 HandleType targetHandleType() const
81 {
82 return (HandleType) qdbus_cast<uint>(
83 property(
84 TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")));
85 }
86
87 void setTargetHandleType(HandleType type)
88 {
89 setProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
90 QVariant::fromValue((uint) type));
91 }
92
93 bool hasRequested() const
94 {
95 return hasProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested"));
96 }
97
98 bool isRequested() const
99 {
100 return qdbus_cast<bool>(
101 property(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested")));
102 }
103
104 void setRequested(bool requested)
105 {
106 setProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested"),
107 QVariant::fromValue(requested));
108 }
109
110 void unsetRequested()
111 {
112 unsetProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested"));
113 }
114
115 bool hasCallInitialAudioFlag() const
116 {
117 return qdbus_cast<bool>(
118 property(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio")));
119 }
120
121 void setCallInitialAudioFlag()
122 {
123 setProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"),
124 QVariant::fromValue(true));
125 }
126
127 void unsetCallInitialAudioFlag()
128 {
129 unsetProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"));
130 }
131
132 bool hasCallInitialVideoFlag() const
133 {
134 return qdbus_cast<bool>(
135 property(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo")));
136 }
137
138 void setCallInitialVideoFlag()
139 {
140 setProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"),
141 QVariant::fromValue(true));
142 }
143
144 void unsetCallInitialVideoFlag()
145 {
146 unsetProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"));
147 }
148
149 TP_QT_DEPRECATED bool hasStreamedMediaInitialAudioFlag() const
150 {
151 return qdbus_cast<bool>(
152 property(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialAudio")));
153 }
154
155 TP_QT_DEPRECATED void setStreamedMediaInitialAudioFlag()
156 {
157 setProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialAudio"),
158 QVariant::fromValue(true));
159 }
160
161 TP_QT_DEPRECATED void unsetStreamedMediaInitialAudioFlag()
162 {
163 unsetProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialAudio"));
164 }
165
166 TP_QT_DEPRECATED bool hasStreamedMediaInitialVideoFlag() const
167 {
168 return qdbus_cast<bool>(
169 property(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialVideo")));
170 }
171
172 TP_QT_DEPRECATED void setStreamedMediaInitialVideoFlag()
173 {
174 setProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialVideo"),
175 QVariant::fromValue(true));
176 }
177
178 TP_QT_DEPRECATED void unsetStreamedMediaInitialVideoFlag()
179 {
180 unsetProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA + QLatin1String(".InitialVideo"));
181 }
182
183 bool hasProperty(const QString &qualifiedName) const;
184 QVariant property(const QString &qualifiedName) const;
185
186 void setProperty(const QString &qualifiedName, const QVariant &value);
187 void unsetProperty(const QString &qualifiedName);
188
189 QVariantMap allProperties() const;
190 ChannelClass bareClass() const;
191
192 static ChannelClassSpec textChat(const QVariantMap &additionalProperties = QVariantMap());
193 static ChannelClassSpec textChatroom(const QVariantMap &additionalProperties = QVariantMap());
194 static ChannelClassSpec unnamedTextChat(const QVariantMap &additionalProperties = QVariantMap());
195
196 static ChannelClassSpec mediaCall(const QVariantMap &additionalProperties = QVariantMap());
197 static ChannelClassSpec audioCall(const QVariantMap &additionalProperties = QVariantMap());
198 static ChannelClassSpec videoCall(const QVariantMap &additionalProperties = QVariantMap());
199 static ChannelClassSpec videoCallWithAudio(const QVariantMap &additionalProperties =
200 QVariantMap());
201
202 TP_QT_DEPRECATED static ChannelClassSpec streamedMediaCall(const QVariantMap &additionalProperties = QVariantMap());
203 TP_QT_DEPRECATED static ChannelClassSpec streamedMediaAudioCall(const QVariantMap &additionalProperties =
204 QVariantMap());
205 TP_QT_DEPRECATED static ChannelClassSpec streamedMediaVideoCall(const QVariantMap &additionalProperties =
206 QVariantMap());
207 TP_QT_DEPRECATED static ChannelClassSpec streamedMediaVideoCallWithAudio(const QVariantMap &additionalProperties =
208 QVariantMap());
209
210 TP_QT_DEPRECATED static ChannelClassSpec unnamedStreamedMediaCall(const QVariantMap &additionalProperties =
211 QVariantMap());
212 TP_QT_DEPRECATED static ChannelClassSpec unnamedStreamedMediaAudioCall(const QVariantMap &additionalProperties =
213 QVariantMap());
214 TP_QT_DEPRECATED static ChannelClassSpec unnamedStreamedMediaVideoCall(const QVariantMap &additionalProperties =
215 QVariantMap());
216 TP_QT_DEPRECATED static ChannelClassSpec unnamedStreamedMediaVideoCallWithAudio(const QVariantMap &additionalProperties =
217 QVariantMap());
218
219 static ChannelClassSpec serverAuthentication(const QVariantMap &additionalProperties =
220 QVariantMap());
221
222 static ChannelClassSpec roomList(const QVariantMap &additionalProperties = QVariantMap());
223 static ChannelClassSpec outgoingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
224 static ChannelClassSpec incomingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
225 static ChannelClassSpec outgoingStreamTube(const QString &service = QString(),
226 const QVariantMap &additionalProperties = QVariantMap());
227 static ChannelClassSpec incomingStreamTube(const QString &service = QString(),
228 const QVariantMap &additionalProperties = QVariantMap());
229 static ChannelClassSpec outgoingRoomStreamTube(const QString &service = QString(),
230 const QVariantMap &additionalProperties = QVariantMap());
231 static ChannelClassSpec incomingRoomStreamTube(const QString &service = QString(),
232 const QVariantMap &additionalProperties = QVariantMap());
233 static ChannelClassSpec outgoingDBusTube(const QString &serviceName = QString(),
234 const QVariantMap &additionalProperties = QVariantMap());
235 static ChannelClassSpec incomingDBusTube(const QString &serviceName = QString(),
236 const QVariantMap &additionalProperties = QVariantMap());
237 static ChannelClassSpec outgoingRoomDBusTube(const QString &serviceName = QString(),
238 const QVariantMap &additionalProperties = QVariantMap());
239 static ChannelClassSpec incomingRoomDBusTube(const QString &serviceName = QString(),
240 const QVariantMap &additionalProperties = QVariantMap());
241 static ChannelClassSpec contactSearch(const QVariantMap &additionalProperties = QVariantMap());
242
243 private:
244 struct Private;
245 friend struct Private;
246 QSharedDataPointer<Private> mPriv;
247 };
248
249 class TP_QT_EXPORT ChannelClassSpecList :
250 public QList<ChannelClassSpec>
251 {
252 public:
253 ChannelClassSpecList() { }
254
255 ChannelClassSpecList(const ChannelClassSpec &spec)
256 {
257 append(spec);
258 }
259
260 ChannelClassSpecList(const QList<ChannelClassSpec> &other)
261 : QList<ChannelClassSpec>(other)
262 {
263 }
264
265 ChannelClassSpecList(const ChannelClassList &classes)
266 {
267 // Why doesn't Qt have range constructors like STL... stupid, so stupid.
268 Q_FOREACH (const ChannelClass &cc, classes) {
269 append(cc);
270 }
271 }
272
273 ChannelClassList bareClasses() const
274 {
275 ChannelClassList list;
276 Q_FOREACH (const ChannelClassSpec &spec, *this) {
277 list.append(spec.bareClass());
278 }
279 return list;
280 }
281 };
282
283 inline uint qHash(const ChannelClassSpec &spec)
284 {
285 uint ret = 0;
286 QVariantMap::const_iterator it = spec.allProperties().constBegin();
287 QVariantMap::const_iterator end = spec.allProperties().constEnd();
288 int i = spec.allProperties().size() + 1;
289 for (; it != end; ++it) {
290 // all D-Bus types should be convertible to QString
291 QPair<QString, QString> p(it.key(), it.value().toString());
292 int h = qHash(p);
293 ret ^= ((h << (2 << i)) | (h >> (2 >> i)));
294 i--;
295 }
296 return ret;
297 }
298
299 inline uint qHash(const QSet<ChannelClassSpec> &specSet)
300 {
301 int ret = 0;
302 Q_FOREACH (const ChannelClassSpec &spec, specSet) {
303 int h = qHash(spec);
304 ret ^= h;
305 }
306 return ret;
307 }
308
309 inline uint qHash(const ChannelClassSpecList &specList)
310 {
311 // Make it unique by converting to QSet
312 QSet<ChannelClassSpec> uniqueSet = specList.toSet();
313 return qHash(uniqueSet);
314 }
315
316 } // Tp
317
318 Q_DECLARE_METATYPE(Tp::ChannelClassSpec);
319 Q_DECLARE_METATYPE(Tp::ChannelClassSpecList);
320
321 #endif
Tp::ChannelClassSpec::unsetCallInitialVideoFlag
void unsetCallInitialVideoFlag()
Definition: channel-class-spec.h:144
Tp::ChannelClassSpec::unsetStreamedMediaInitialVideoFlag
void unsetStreamedMediaInitialVideoFlag()
Definition: channel-class-spec.h:178
Tp::ChannelClassSpec::hasRequested
bool hasRequested() const
Definition: channel-class-spec.h:93
Tp::ChannelClassSpec::hasCallInitialAudioFlag
bool hasCallInitialAudioFlag() const
Definition: channel-class-spec.h:115
Tp::ChannelClassSpec::channelType
QString channelType() const
Definition: channel-class-spec.h:68
Tp::HandleType
HandleType
Definition: build/TelepathyQt/_gen/constants.h:1375
Tp::ChannelClassSpecList::bareClasses
ChannelClassList bareClasses() const
Definition: channel-class-spec.h:273
Tp::ChannelClassSpecList
The ChannelClassSpecList class represents a list of ChannelClassSpec.
Definition: channel-class-spec.h:249
Tp::ChannelClassSpec::setRequested
void setRequested(bool requested)
Definition: channel-class-spec.h:104
Tp::ChannelClassSpec::targetHandleType
HandleType targetHandleType() const
Definition: channel-class-spec.h:80
Tp::ChannelClassSpec::bareClass
ChannelClass bareClass() const
Definition: channel-class-spec.cpp:188
Tp::ChannelClassSpec::unsetCallInitialAudioFlag
void unsetCallInitialAudioFlag()
Definition: channel-class-spec.h:127
Tp::ChannelClassSpec::allProperties
QVariantMap allProperties() const
Definition: channel-class-spec.cpp:183
Tp::ChannelClassSpec
The ChannelClassSpec class represents a Telepathy channel class.
Definition: channel-class-spec.h:42
Tp::ChannelClassSpec::setCallInitialVideoFlag
void setCallInitialVideoFlag()
Definition: channel-class-spec.h:138
Tp::ChannelClassSpec::setStreamedMediaInitialVideoFlag
void setStreamedMediaInitialVideoFlag()
Definition: channel-class-spec.h:172
Tp::ChannelClassSpecList::ChannelClassSpecList
ChannelClassSpecList(const ChannelClassList &classes)
Definition: channel-class-spec.h:265
TP_QT_IFACE_CHANNEL
#define TP_QT_IFACE_CHANNEL
Definition: build/TelepathyQt/_gen/constants.h:4897
Tp::ChannelClassList
QList< ChannelClass > ChannelClassList
Definition: build/TelepathyQt/_gen/types.h:740
TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA
#define TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA
Definition: build/TelepathyQt/_gen/constants.h:4969
Tp::ChannelClassSpec::operator==
bool operator==(const ChannelClassSpec &other) const
Definition: channel-class-spec.h:60
Tp::ChannelClassSpecList::ChannelClassSpecList
ChannelClassSpecList()
Definition: channel-class-spec.h:253
Tp::ChannelClass
Definition: build/TelepathyQt/_gen/types.h:722
Tp::ChannelClassSpec::unsetStreamedMediaInitialAudioFlag
void unsetStreamedMediaInitialAudioFlag()
Definition: channel-class-spec.h:161
Tp::qHash
uint qHash(const ChannelClassSpec &spec)
Definition: channel-class-spec.h:283
Tp::ChannelClassSpec::isRequested
bool isRequested() const
Definition: channel-class-spec.h:98
Tp::ChannelClassSpec::hasCallInitialVideoFlag
bool hasCallInitialVideoFlag() const
Definition: channel-class-spec.h:132
Tp::ChannelClassSpecList::ChannelClassSpecList
ChannelClassSpecList(const ChannelClassSpec &spec)
Definition: channel-class-spec.h:255
Tp::ChannelClassSpec::hasStreamedMediaInitialAudioFlag
bool hasStreamedMediaInitialAudioFlag() const
Definition: channel-class-spec.h:149
Tp::ChannelClassSpec::setChannelType
void setChannelType(const QString &type)
Definition: channel-class-spec.h:74
Tp::ChannelClassSpec::setTargetHandleType
void setTargetHandleType(HandleType type)
Definition: channel-class-spec.h:87
Tp::ChannelClassSpec::setCallInitialAudioFlag
void setCallInitialAudioFlag()
Definition: channel-class-spec.h:121
TP_QT_IFACE_CHANNEL_TYPE_CALL
#define TP_QT_IFACE_CHANNEL_TYPE_CALL
Definition: build/TelepathyQt/_gen/constants.h:4905
Tp::ChannelClassSpecList::ChannelClassSpecList
ChannelClassSpecList(const QList< ChannelClassSpec > &other)
Definition: channel-class-spec.h:260
Tp::ChannelClassSpec::unsetRequested
void unsetRequested()
Definition: channel-class-spec.h:110
Tp::ChannelClassSpec::setStreamedMediaInitialAudioFlag
void setStreamedMediaInitialAudioFlag()
Definition: channel-class-spec.h:155
Tp::ChannelClassSpec::hasStreamedMediaInitialVideoFlag
bool hasStreamedMediaInitialVideoFlag() const
Definition: channel-class-spec.h:166