Home · All Classes · All Namespaces · Modules · Functions · Files
abstract-client.h
1 
23 #ifndef _TelepathyQt_abstract_client_h_HEADER_GUARD_
24 #define _TelepathyQt_abstract_client_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/SharedPtr>
32 #include <TelepathyQt/Types>
33 
34 #include <QList>
35 #include <QObject>
36 #include <QSharedDataPointer>
37 #include <QString>
38 #include <QVariantMap>
39 
40 namespace Tp
41 {
42 
43 class ClientRegistrar;
44 class ChannelClassSpecList;
45 
46 class TP_QT_EXPORT AbstractClient : public RefCounted
47 {
48  Q_DISABLE_COPY(AbstractClient)
49 
50 public:
52  virtual ~AbstractClient();
53 
54  bool isRegistered() const;
55 
56 private:
57  friend class ClientRegistrar;
58 
59  void setRegistered(bool registered);
60 
61  struct Private;
62  friend struct Private;
63  Private *mPriv;
64 };
65 
66 class TP_QT_EXPORT AbstractClientObserver : public virtual AbstractClient
67 {
68  Q_DISABLE_COPY(AbstractClientObserver)
69 
70 public:
72  {
73  public:
74  ObserverInfo(const QVariantMap &info = QVariantMap());
75  ObserverInfo(const ObserverInfo &other);
76  ~ObserverInfo();
77 
78  ObserverInfo &operator=(const ObserverInfo &other);
79 
80  bool isRecovering() const { return qdbus_cast<bool>(allInfo().value(QLatin1String("recovering"))); }
81 
82  QVariantMap allInfo() const;
83 
84  private:
85  struct Private;
86  QSharedDataPointer<Private> mPriv;
87  };
88 
89  virtual ~AbstractClientObserver();
90 
91  ChannelClassSpecList observerFilter() const;
92 
93  bool shouldRecover() const;
94 
95  virtual void observeChannels(const MethodInvocationContextPtr<> &context,
96  const AccountPtr &account,
97  const ConnectionPtr &connection,
98  const QList<ChannelPtr> &channels,
99  const ChannelDispatchOperationPtr &dispatchOperation,
100  const QList<ChannelRequestPtr> &requestsSatisfied,
101  const ObserverInfo &observerInfo) = 0;
102 
103 protected:
104  AbstractClientObserver(const ChannelClassSpecList &channelFilter, bool shouldRecover = false);
105 
106 private:
107  struct Private;
108  friend struct Private;
109  Private *mPriv;
110 };
111 
112 class TP_QT_EXPORT AbstractClientApprover : public virtual AbstractClient
113 {
114  Q_DISABLE_COPY(AbstractClientApprover)
115 
116 public:
117  virtual ~AbstractClientApprover();
118 
119  ChannelClassSpecList approverFilter() const;
120 
121  virtual void addDispatchOperation(const MethodInvocationContextPtr<> &context,
122  const ChannelDispatchOperationPtr &dispatchOperation) = 0;
123 
124 protected:
125  AbstractClientApprover(const ChannelClassSpecList &channelFilter);
126 
127 private:
128  struct Private;
129  friend struct Private;
130  Private *mPriv;
131 };
132 
133 /*
134  * TODO: use case specific subclasses:
135  * - StreamTubeHandler(QString(List) protocol(s))
136  * - handleTube(DBusTubeChannelPtr, userActionTime)
137  * - DBusTubeHandler(QString(List) serviceName(s))
138  * - handleTube(DBusTubeChannelPtr, userActionTime)
139  */
140 class TP_QT_EXPORT AbstractClientHandler : public virtual AbstractClient
141 {
142  Q_DISABLE_COPY(AbstractClientHandler)
143 
144 public:
146  {
147  public:
148  Capabilities(const QStringList &tokens = QStringList());
149  Capabilities(const Capabilities &other);
150  ~Capabilities();
151 
152  Capabilities &operator=(const Capabilities &other);
153 
155  {
157  QLatin1String("/gtalk-p2p"));
158  }
159 
161  {
163  QLatin1String("/gtalk-p2p"));
164  }
165 
167  {
169  QLatin1String("/gtalk-p2p"));
170  }
171 
173  {
175  QLatin1String("/ice-udp"));
176  }
177 
179  {
181  QLatin1String("/ice-udp"));
182  }
183 
185  {
187  QLatin1String("/ice-udp"));
188  }
189 
191  {
193  QLatin1String("/wlm-8.5"));
194  }
195 
197  {
199  QLatin1String("/wlm-8.5"));
200  }
201 
203  {
205  QLatin1String("/wlm-8.5"));
206  }
207 
209  {
211  QLatin1String("/wlm-2009"));
212  }
213 
215  {
217  QLatin1String("/wlm-2009"));
218  }
219 
221  {
223  QLatin1String("/wlm-2009"));
224  }
225 
226  bool hasAudioCodecToken(const QString &mimeSubType) const
227  {
229  QLatin1String("/audio/") + mimeSubType.toLower());
230  }
231 
232  void setAudioCodecToken(const QString &mimeSubType)
233  {
235  QLatin1String("/audio/") + mimeSubType.toLower());
236  }
237 
238  void unsetAudioCodecToken(const QString &mimeSubType)
239  {
241  QLatin1String("/audio/") + mimeSubType.toLower());
242  }
243 
244  bool hasVideoCodecToken(const QString &mimeSubType) const
245  {
247  QLatin1String("/video/") + mimeSubType.toLower());
248  }
249 
250  void setVideoCodecToken(const QString &mimeSubType)
251  {
253  QLatin1String("/video/") + mimeSubType.toLower());
254  }
255 
256  void unsetVideoCodecToken(const QString &mimeSubType)
257  {
259  QLatin1String("/video/") + mimeSubType.toLower());
260  }
261 
262  bool hasToken(const QString &token) const;
263  void setToken(const QString &token);
264  void unsetToken(const QString &token);
265 
266  QStringList allTokens() const;
267 
268  private:
269  struct Private;
270  QSharedDataPointer<Private> mPriv;
271  };
272 
274  {
275  public:
276  HandlerInfo(const QVariantMap &info = QVariantMap());
277  HandlerInfo(const HandlerInfo &other);
278  ~HandlerInfo();
279 
280  HandlerInfo &operator=(const HandlerInfo &other);
281 
282  QVariantMap allInfo() const;
283 
284  private:
285  struct Private;
286  QSharedDataPointer<Private> mPriv;
287  };
288 
289  virtual ~AbstractClientHandler();
290 
291  ChannelClassSpecList handlerFilter() const;
292 
293  Capabilities handlerCapabilities() const;
294 
295  virtual bool bypassApproval() const = 0;
296 
297  virtual void handleChannels(const MethodInvocationContextPtr<> &context,
298  const AccountPtr &account,
299  const ConnectionPtr &connection,
300  const QList<ChannelPtr> &channels,
301  const QList<ChannelRequestPtr> &requestsSatisfied,
302  const QDateTime &userActionTime,
303  const HandlerInfo &handlerInfo) = 0;
304 
305  bool wantsRequestNotification() const;
306  virtual void addRequest(const ChannelRequestPtr &request);
307  virtual void removeRequest(const ChannelRequestPtr &request,
308  const QString &errorName, const QString &errorMessage);
309 
310 protected:
311  AbstractClientHandler(const ChannelClassSpecList &channelFilter,
312  const Capabilities &capabilities = Capabilities(),
313  bool wantsRequestNotification = false);
314 
315 private:
316  struct Private;
317  friend struct Private;
318  Private *mPriv;
319 };
320 
321 } // Tp
322 
323 Q_DECLARE_METATYPE(Tp::AbstractClientObserver::ObserverInfo);
324 Q_DECLARE_METATYPE(Tp::AbstractClientHandler::Capabilities);
325 Q_DECLARE_METATYPE(Tp::AbstractClientHandler::HandlerInfo);
326 
327 #endif
void unsetICEUDPNATTraversalToken()
Definition: abstract-client.h:184
#define TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING
Definition: build/TelepathyQt/_gen/constants.h:5081
void unsetAudioCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:238
bool hasGTalkP2PNATTraversalToken() const
Definition: abstract-client.h:154
void setGTalkP2PNATTraversalToken()
Definition: abstract-client.h:160
void unsetWLM2009NATTraversalToken()
Definition: abstract-client.h:220
The ChannelClassSpecList class represents a list of ChannelClassSpec.
Definition: channel-class-spec.h:249
void setVideoCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:250
The AbstractClientApprover class represents a Telepathy approver.
Definition: abstract-client.h:112
bool isRecovering() const
Definition: abstract-client.h:80
void setAudioCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:232
void setICEUDPNATTraversalToken()
Definition: abstract-client.h:178
void setWLM2009NATTraversalToken()
Definition: abstract-client.h:214
The AbstractClientObserver::ObserverInfo class provides a wrapper around the additional info about th...
Definition: abstract-client.h:71
void setWLM85NATTraversalToken()
Definition: abstract-client.h:196
The AbstractClient class represents a Telepathy client.
Definition: abstract-client.h:46
The AbstractClientHandler::Capabilities class provides a wrapper around the capabilities of a handler...
Definition: abstract-client.h:145
void unsetGTalkP2PNATTraversalToken()
Definition: abstract-client.h:166
bool hasWLM85NATTraversalToken() const
Definition: abstract-client.h:190
void unsetVideoCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:256
The AbstractClientObserver class represents a Telepathy observer.
Definition: abstract-client.h:66
bool hasWLM2009NATTraversalToken() const
Definition: abstract-client.h:208
bool hasICEUDPNATTraversalToken() const
Definition: abstract-client.h:172
bool hasAudioCodecToken(const QString &mimeSubType) const
Definition: abstract-client.h:226
The AbstractClientHandler::HandlerInfo class provides a wrapper around the additional info about the ...
Definition: abstract-client.h:273
bool hasVideoCodecToken(const QString &mimeSubType) const
Definition: abstract-client.h:244
The ClientRegistrar class is responsible for registering Telepathy clients (Observer, Approver, Handler).
Definition: client-registrar.h:43
The RefCounted class is a base class for shared objects used by SharedPtr.
Definition: shared-ptr.h:42
void unsetWLM85NATTraversalToken()
Definition: abstract-client.h:202
The AbstractClientHandler class represents a Telepathy handler.
Definition: abstract-client.h:140


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