| 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:
51 AbstractClient();
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:
71 class ObserverInfo
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:
145 class Capabilities
146 {
147 public:
148 Capabilities(const QStringList &tokens = QStringList());
149 Capabilities(const Capabilities &other);
150 ~Capabilities();
151
152 Capabilities &operator=(const Capabilities &other);
153
154 bool hasGTalkP2PNATTraversalToken() const
155 {
156 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
157 QLatin1String("/gtalk-p2p"));
158 }
159
160 void setGTalkP2PNATTraversalToken()
161 {
162 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
163 QLatin1String("/gtalk-p2p"));
164 }
165
166 void unsetGTalkP2PNATTraversalToken()
167 {
168 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
169 QLatin1String("/gtalk-p2p"));
170 }
171
172 bool hasICEUDPNATTraversalToken() const
173 {
174 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
175 QLatin1String("/ice-udp"));
176 }
177
178 void setICEUDPNATTraversalToken()
179 {
180 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
181 QLatin1String("/ice-udp"));
182 }
183
184 void unsetICEUDPNATTraversalToken()
185 {
186 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
187 QLatin1String("/ice-udp"));
188 }
189
190 bool hasWLM85NATTraversalToken() const
191 {
192 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
193 QLatin1String("/wlm-8.5"));
194 }
195
196 void setWLM85NATTraversalToken()
197 {
198 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
199 QLatin1String("/wlm-8.5"));
200 }
201
202 void unsetWLM85NATTraversalToken()
203 {
204 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
205 QLatin1String("/wlm-8.5"));
206 }
207
208 bool hasWLM2009NATTraversalToken() const
209 {
210 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
211 QLatin1String("/wlm-2009"));
212 }
213
214 void setWLM2009NATTraversalToken()
215 {
216 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
217 QLatin1String("/wlm-2009"));
218 }
219
220 void unsetWLM2009NATTraversalToken()
221 {
222 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
223 QLatin1String("/wlm-2009"));
224 }
225
226 bool hasAudioCodecToken(const QString &mimeSubType) const
227 {
228 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
229 QLatin1String("/audio/") + mimeSubType.toLower());
230 }
231
232 void setAudioCodecToken(const QString &mimeSubType)
233 {
234 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
235 QLatin1String("/audio/") + mimeSubType.toLower());
236 }
237
238 void unsetAudioCodecToken(const QString &mimeSubType)
239 {
240 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
241 QLatin1String("/audio/") + mimeSubType.toLower());
242 }
243
244 bool hasVideoCodecToken(const QString &mimeSubType) const
245 {
246 return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
247 QLatin1String("/video/") + mimeSubType.toLower());
248 }
249
250 void setVideoCodecToken(const QString &mimeSubType)
251 {
252 setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
253 QLatin1String("/video/") + mimeSubType.toLower());
254 }
255
256 void unsetVideoCodecToken(const QString &mimeSubType)
257 {
258 unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
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
273 class HandlerInfo
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
Tp::AbstractClientHandler::Capabilities::unsetICEUDPNATTraversalToken
void unsetICEUDPNATTraversalToken()
Definition: abstract-client.h:184
TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING
#define TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING
Definition: build/TelepathyQt/_gen/constants.h:5081
Tp::AbstractClientHandler::Capabilities::unsetAudioCodecToken
void unsetAudioCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:238
Tp::AbstractClientHandler::Capabilities::hasGTalkP2PNATTraversalToken
bool hasGTalkP2PNATTraversalToken() const
Definition: abstract-client.h:154
Tp::AbstractClientHandler::Capabilities::setGTalkP2PNATTraversalToken
void setGTalkP2PNATTraversalToken()
Definition: abstract-client.h:160
Tp::AbstractClientHandler::Capabilities::unsetWLM2009NATTraversalToken
void unsetWLM2009NATTraversalToken()
Definition: abstract-client.h:220
Tp::ChannelClassSpecList
The ChannelClassSpecList class represents a list of ChannelClassSpec.
Definition: channel-class-spec.h:249
Tp::AbstractClientHandler::Capabilities::setVideoCodecToken
void setVideoCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:250
Tp::AbstractClientApprover
The AbstractClientApprover class represents a Telepathy approver.
Definition: abstract-client.h:112
Tp::AbstractClientObserver::ObserverInfo::isRecovering
bool isRecovering() const
Definition: abstract-client.h:80
Tp::AbstractClientHandler::Capabilities::setAudioCodecToken
void setAudioCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:232
Tp::AbstractClientHandler::Capabilities::setICEUDPNATTraversalToken
void setICEUDPNATTraversalToken()
Definition: abstract-client.h:178
Tp::AbstractClientHandler::Capabilities::setWLM2009NATTraversalToken
void setWLM2009NATTraversalToken()
Definition: abstract-client.h:214
Tp::AbstractClientObserver::ObserverInfo
The AbstractClientObserver::ObserverInfo class provides a wrapper around the additional info about th...
Definition: abstract-client.h:71
Tp::AbstractClientHandler::Capabilities::setWLM85NATTraversalToken
void setWLM85NATTraversalToken()
Definition: abstract-client.h:196
Tp::AbstractClient
The AbstractClient class represents a Telepathy client.
Definition: abstract-client.h:46
Tp::AbstractClientHandler::Capabilities
The AbstractClientHandler::Capabilities class provides a wrapper around the capabilities of a handler...
Definition: abstract-client.h:145
Tp::AbstractClientHandler::Capabilities::unsetGTalkP2PNATTraversalToken
void unsetGTalkP2PNATTraversalToken()
Definition: abstract-client.h:166
Tp::AbstractClientHandler::Capabilities::hasWLM85NATTraversalToken
bool hasWLM85NATTraversalToken() const
Definition: abstract-client.h:190
Tp::AbstractClientHandler::Capabilities::unsetVideoCodecToken
void unsetVideoCodecToken(const QString &mimeSubType)
Definition: abstract-client.h:256
Tp::AbstractClientObserver
The AbstractClientObserver class represents a Telepathy observer.
Definition: abstract-client.h:66
Tp::AbstractClientHandler::Capabilities::hasWLM2009NATTraversalToken
bool hasWLM2009NATTraversalToken() const
Definition: abstract-client.h:208
Tp::AbstractClientHandler::Capabilities::hasICEUDPNATTraversalToken
bool hasICEUDPNATTraversalToken() const
Definition: abstract-client.h:172
Tp::AbstractClientHandler::Capabilities::hasAudioCodecToken
bool hasAudioCodecToken(const QString &mimeSubType) const
Definition: abstract-client.h:226
Tp::AbstractClientHandler::HandlerInfo
The AbstractClientHandler::HandlerInfo class provides a wrapper around the additional info about the ...
Definition: abstract-client.h:273
Tp::AbstractClientHandler::Capabilities::hasVideoCodecToken
bool hasVideoCodecToken(const QString &mimeSubType) const
Definition: abstract-client.h:244
Tp::ClientRegistrar
The ClientRegistrar class is responsible for registering Telepathy clients (Observer, Approver, Handler).
Definition: client-registrar.h:43
Tp::RefCounted
The RefCounted class is a base class for shared objects used by SharedPtr.
Definition: shared-ptr.h:42
Tp::AbstractClientHandler::Capabilities::unsetWLM85NATTraversalToken
void unsetWLM85NATTraversalToken()
Definition: abstract-client.h:202
Tp::AbstractClientHandler
The AbstractClientHandler class represents a Telepathy handler.
Definition: abstract-client.h:140