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:
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());
53  const QVariantMap &additionalProperties = QVariantMap());
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 
81  {
82  return (HandleType) qdbus_cast<uint>(
83  property(
84  TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")));
85  }
86 
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 
111  {
112  unsetProperty(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested"));
113  }
114 
116  {
117  return qdbus_cast<bool>(
118  property(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio")));
119  }
120 
122  {
123  setProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"),
124  QVariant::fromValue(true));
125  }
126 
128  {
129  unsetProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"));
130  }
131 
133  {
134  return qdbus_cast<bool>(
135  property(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo")));
136  }
137 
139  {
140  setProperty(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"),
141  QVariant::fromValue(true));
142  }
143 
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:
254 
256  {
257  append(spec);
258  }
259 
260  ChannelClassSpecList(const QList<ChannelClassSpec> &other)
261  : QList<ChannelClassSpec>(other)
262  {
263  }
264 
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 
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
ChannelClassSpecList(const ChannelClassSpec &spec)
Definition: channel-class-spec.h:255
The ChannelClassSpecList class represents a list of ChannelClassSpec.
Definition: channel-class-spec.h:249
void setChannelType(const QString &type)
Definition: channel-class-spec.h:74
bool hasStreamedMediaInitialVideoFlag() const
Definition: channel-class-spec.h:166
bool hasCallInitialVideoFlag() const
Definition: channel-class-spec.h:132
QList< ChannelClass > ChannelClassList
Definition: buildqt4/TelepathyQt/_gen/types.h:740
bool hasCallInitialAudioFlag() const
Definition: channel-class-spec.h:115
bool hasStreamedMediaInitialAudioFlag() const
Definition: channel-class-spec.h:149
void setStreamedMediaInitialVideoFlag()
Definition: channel-class-spec.h:172
void setCallInitialAudioFlag()
Definition: channel-class-spec.h:121
ChannelClassSpecList(const ChannelClassList &classes)
Definition: channel-class-spec.h:265
bool isRequested() const
Definition: channel-class-spec.h:98
QString channelType() const
Definition: channel-class-spec.h:68
The ChannelClassSpec class represents a Telepathy channel class.
Definition: channel-class-spec.h:42
void setRequested(bool requested)
Definition: channel-class-spec.h:104
void setTargetHandleType(HandleType type)
Definition: channel-class-spec.h:87
ChannelClassSpecList()
Definition: channel-class-spec.h:253
#define TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA
Definition: buildqt4/TelepathyQt/_gen/constants.h:4913
void setStreamedMediaInitialAudioFlag()
Definition: channel-class-spec.h:155
void unsetCallInitialVideoFlag()
Definition: channel-class-spec.h:144
HandleType targetHandleType() const
Definition: channel-class-spec.h:80
bool hasRequested() const
Definition: channel-class-spec.h:93
#define TP_QT_IFACE_CHANNEL_TYPE_CALL
Definition: buildqt4/TelepathyQt/_gen/constants.h:4849
Definition: buildqt4/TelepathyQt/_gen/types.h:722
ChannelClass bareClass() const
Definition: channel-class-spec.cpp:188
void unsetRequested()
Definition: channel-class-spec.h:110
ChannelClassList bareClasses() const
Definition: channel-class-spec.h:273
uint qHash(const ChannelClassSpec &spec)
Definition: channel-class-spec.h:283
void unsetStreamedMediaInitialVideoFlag()
Definition: channel-class-spec.h:178
void setCallInitialVideoFlag()
Definition: channel-class-spec.h:138
ChannelClassSpecList(const QList< ChannelClassSpec > &other)
Definition: channel-class-spec.h:260
bool operator==(const ChannelClassSpec &other) const
Definition: channel-class-spec.h:60
void unsetCallInitialAudioFlag()
Definition: channel-class-spec.h:127
#define TP_QT_IFACE_CHANNEL
Definition: buildqt4/TelepathyQt/_gen/constants.h:4841
QVariantMap allProperties() const
Definition: channel-class-spec.cpp:183
void unsetStreamedMediaInitialAudioFlag()
Definition: channel-class-spec.h:161
HandleType
Definition: buildqt4/TelepathyQt/_gen/constants.h:1375


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.4