Merge lp:~tiagosh/ubuntu/trusty/telepathy-qt5/group-chat into lp:ubuntu/trusty/telepathy-qt5

Proposed by Tiago Salem Herrmann
Status: Merged
Merged at revision: 6
Proposed branch: lp:~tiagosh/ubuntu/trusty/telepathy-qt5/group-chat
Merge into: lp:ubuntu/trusty/telepathy-qt5
Diff against target: 5775 lines (+5535/-31)
19 files modified
.pc/06-conference_interfaces.patch/TelepathyQt/base-channel-internal.h (+351/-0)
.pc/06-conference_interfaces.patch/TelepathyQt/base-channel.cpp (+1688/-0)
.pc/06-conference_interfaces.patch/TelepathyQt/base-channel.h (+479/-0)
.pc/06-conference_interfaces.patch/TelepathyQt/service-types.h (+97/-0)
.pc/06-conference_interfaces.patch/TelepathyQt/svc-channel.xml (+38/-0)
.pc/07-fix_createChannel.patch/TelepathyQt/base-connection.cpp (+1356/-0)
.pc/07-fix_createChannel.patch/TelepathyQt/base-connection.h (+364/-0)
.pc/applied-patches (+2/-0)
TelepathyQt/base-channel-internal.h (+67/-0)
TelepathyQt/base-channel.cpp (+294/-0)
TelepathyQt/base-channel.h (+113/-0)
TelepathyQt/base-connection.cpp (+7/-29)
TelepathyQt/base-connection.h (+2/-2)
TelepathyQt/service-types.h (+6/-0)
TelepathyQt/svc-channel.xml (+2/-0)
debian/changelog (+9/-0)
debian/patches/06-conference_interfaces.patch (+554/-0)
debian/patches/07-fix_createChannel.patch (+104/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~tiagosh/ubuntu/trusty/telepathy-qt5/group-chat
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+204310@code.launchpad.net

Commit message

* debian/patches/06-conference_interfaces.patch: add conference related interfaces
* debian/patches/07-fix_ensureChannel.patch: pass request details on ensureChannel()
  and do not check for TargetHandle and TargetHandleType as managers will take care of
  them.

Description of the change

* debian/patches/06-conference_interfaces.patch: add conference related interfaces
* debian/patches/07-fix_ensureChannel.patch: pass request details on ensureChannel()
  and do not check for TargetHandle and TargetHandleType as managers will take care of
  them.

To post a comment you must log in.
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

It seems 07-fix_ensureChannel.patch is missing the code to actually forward the request details to the manager implementing it.

review: Needs Fixing
7. By Tiago Salem Herrmann

apply patch 06 to the code

8. By Tiago Salem Herrmann

update patches

9. By Tiago Salem Herrmann

fix callback signature

10. By Tiago Salem Herrmann

pass the request hints to createChannel()

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.
No.

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes.

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telepathy-qt) on device or emulator?
Yes.

If you changed the UI, was the change specified/approved by design?
No UI changes.

If you changed the packaging (debian), did you subscribe a core-dev to this MP?
No packaging changes.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telepathy-qt5) on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No CI.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes.

The change looks good and works as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc/06-conference_interfaces.patch'
2=== added file '.pc/06-conference_interfaces.patch/.timestamp'
3=== added directory '.pc/06-conference_interfaces.patch/TelepathyQt'
4=== added file '.pc/06-conference_interfaces.patch/TelepathyQt/base-channel-internal.h'
5--- .pc/06-conference_interfaces.patch/TelepathyQt/base-channel-internal.h 1970-01-01 00:00:00 +0000
6+++ .pc/06-conference_interfaces.patch/TelepathyQt/base-channel-internal.h 2014-02-05 14:09:56 +0000
7@@ -0,0 +1,351 @@
8+/**
9+ * This file is part of TelepathyQt
10+ *
11+ * @copyright Copyright (C) 2013 Matthias Gehre <gehre.matthias@gmail.com>
12+ * @copyright Copyright 2013 Canonical Ltd.
13+ * @license LGPL 2.1
14+ *
15+ * This library is free software; you can redistribute it and/or
16+ * modify it under the terms of the GNU Lesser General Public
17+ * License as published by the Free Software Foundation; either
18+ * version 2.1 of the License, or (at your option) any later version.
19+ *
20+ * This library is distributed in the hope that it will be useful,
21+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23+ * Lesser General Public License for more details.
24+ *
25+ * You should have received a copy of the GNU Lesser General Public
26+ * License along with this library; if not, write to the Free Software
27+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+ */
29+
30+#include "TelepathyQt/_gen/svc-channel.h"
31+
32+#include <TelepathyQt/Global>
33+#include <TelepathyQt/MethodInvocationContext>
34+#include <TelepathyQt/Constants>
35+#include <TelepathyQt/Types>
36+#include "TelepathyQt/debug-internal.h"
37+
38+
39+namespace Tp
40+{
41+
42+class TP_QT_NO_EXPORT BaseChannel::Adaptee : public QObject
43+{
44+ Q_OBJECT
45+
46+ Q_PROPERTY(QString channelType READ channelType)
47+ Q_PROPERTY(QStringList interfaces READ interfaces)
48+ Q_PROPERTY(uint targetHandle READ targetHandle)
49+ Q_PROPERTY(QString targetID READ targetID)
50+ Q_PROPERTY(uint targetHandleType READ targetHandleType)
51+ Q_PROPERTY(bool requested READ requested)
52+ Q_PROPERTY(uint initiatorHandle READ initiatorHandle)
53+ Q_PROPERTY(QString initiatorID READ initiatorID)
54+public:
55+ Adaptee(const QDBusConnection &dbusConnection, BaseChannel *cm);
56+ ~Adaptee();
57+
58+ QString channelType() const {
59+ return mChannel->channelType();
60+ }
61+ QStringList interfaces() const;
62+ uint targetHandle() const {
63+ return mChannel->targetHandle();
64+ }
65+ QString targetID() const {
66+ return mChannel->targetID();
67+ }
68+ uint targetHandleType() const {
69+ return mChannel->targetHandleType();
70+ }
71+ bool requested() const {
72+ return mChannel->requested();
73+ }
74+ uint initiatorHandle() const {
75+ return mChannel->initiatorHandle();
76+ }
77+ QString initiatorID() const {
78+ return mChannel->initiatorID();
79+ }
80+
81+private Q_SLOTS:
82+ void close(const Tp::Service::ChannelAdaptor::CloseContextPtr &context);
83+ void getChannelType(const Tp::Service::ChannelAdaptor::GetChannelTypeContextPtr &context) {
84+ context->setFinished(channelType());
85+ }
86+
87+ void getHandle(const Tp::Service::ChannelAdaptor::GetHandleContextPtr &context) {
88+ context->setFinished(targetHandleType(), targetHandle());
89+ }
90+
91+ void getInterfaces(const Tp::Service::ChannelAdaptor::GetInterfacesContextPtr &context) {
92+ context->setFinished(interfaces());
93+ }
94+
95+
96+public:
97+ BaseChannel *mChannel;
98+ Service::ChannelAdaptor *mAdaptor;
99+
100+signals:
101+ void closed();
102+};
103+
104+class TP_QT_NO_EXPORT BaseChannelTextType::Adaptee : public QObject
105+{
106+ Q_OBJECT
107+public:
108+ Adaptee(BaseChannelTextType *interface);
109+ ~Adaptee();
110+
111+public slots:
112+ void acknowledgePendingMessages(const Tp::UIntList &IDs, const Tp::Service::ChannelTypeTextAdaptor::AcknowledgePendingMessagesContextPtr &context);
113+//deprecated:
114+ //void getMessageTypes(const Tp::Service::ChannelTypeTextAdaptor::GetMessageTypesContextPtr &context);
115+ //void listPendingMessages(bool clear, const Tp::Service::ChannelTypeTextAdaptor::ListPendingMessagesContextPtr &context);
116+ //void send(uint type, const QString &text, const Tp::Service::ChannelTypeTextAdaptor::SendContextPtr &context);
117+signals:
118+ void lostMessage();
119+ void received(uint ID, uint timestamp, uint sender, uint type, uint flags, const QString &text);
120+ void sendError(uint error, uint timestamp, uint type, const QString &text);
121+ void sent(uint timestamp, uint type, const QString &text);
122+
123+public:
124+ BaseChannelTextType *mInterface;
125+};
126+
127+class TP_QT_NO_EXPORT BaseChannelMessagesInterface::Adaptee : public QObject
128+{
129+ Q_OBJECT
130+ Q_PROPERTY(QStringList supportedContentTypes READ supportedContentTypes)
131+ Q_PROPERTY(Tp::UIntList messageTypes READ messageTypes)
132+ Q_PROPERTY(uint messagePartSupportFlags READ messagePartSupportFlags)
133+ Q_PROPERTY(Tp::MessagePartListList pendingMessages READ pendingMessages)
134+ Q_PROPERTY(uint deliveryReportingSupport READ deliveryReportingSupport)
135+public:
136+ Adaptee(BaseChannelMessagesInterface *interface);
137+ ~Adaptee();
138+
139+ QStringList supportedContentTypes() {
140+ return mInterface->supportedContentTypes();
141+ }
142+ Tp::UIntList messageTypes() {
143+ return mInterface->messageTypes();
144+ }
145+ uint messagePartSupportFlags() {
146+ return mInterface->messagePartSupportFlags();
147+ }
148+ uint deliveryReportingSupport() {
149+ return mInterface->deliveryReportingSupport();
150+ }
151+ Tp::MessagePartListList pendingMessages() {
152+ return mInterface->pendingMessages();
153+ }
154+
155+public slots:
156+ void sendMessage(const Tp::MessagePartList &message, uint flags, const Tp::Service::ChannelInterfaceMessagesAdaptor::SendMessageContextPtr &context);
157+//deprecated, never implemented:
158+ //void getPendingMessageContent(uint messageID, const Tp::UIntList &parts, const Tp::Service::ChannelInterfaceMessagesAdaptor::GetPendingMessageContentContextPtr &context);
159+signals:
160+ void messageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken);
161+ void pendingMessagesRemoved(const Tp::UIntList &messageIDs);
162+ void messageReceived(const Tp::MessagePartList &message);
163+
164+public:
165+ BaseChannelMessagesInterface *mInterface;
166+};
167+
168+class TP_QT_NO_EXPORT BaseChannelServerAuthenticationType::Adaptee : public QObject
169+{
170+ Q_OBJECT
171+ Q_PROPERTY(QString authenticationMethod READ authenticationMethod)
172+public:
173+ Adaptee(BaseChannelServerAuthenticationType *interface);
174+ ~Adaptee();
175+ QString authenticationMethod() const;
176+public:
177+ BaseChannelServerAuthenticationType *mInterface;
178+};
179+
180+class TP_QT_NO_EXPORT BaseChannelCaptchaAuthenticationInterface::Adaptee : public QObject
181+{
182+ Q_OBJECT
183+ Q_PROPERTY(bool canRetryCaptcha READ canRetryCaptcha)
184+ Q_PROPERTY(uint captchaStatus READ captchaStatus)
185+ Q_PROPERTY(QString captchaError READ captchaError)
186+ Q_PROPERTY(QVariantMap captchaErrorDetails READ captchaErrorDetails)
187+public:
188+ Adaptee(BaseChannelCaptchaAuthenticationInterface *interface);
189+ ~Adaptee();
190+ bool canRetryCaptcha() const;
191+ uint captchaStatus() const;
192+ QString captchaError() const;
193+ QVariantMap captchaErrorDetails() const;
194+public slots:
195+ void getCaptchas(const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::GetCaptchasContextPtr &context);
196+ void getCaptchaData(uint ID, const QString &mimeType, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::GetCaptchaDataContextPtr &context);
197+ void answerCaptchas(const Tp::CaptchaAnswers &answers, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::AnswerCaptchasContextPtr &context);
198+ void cancelCaptcha(uint reason, const QString &debugMessage, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::CancelCaptchaContextPtr &context);
199+public:
200+ BaseChannelCaptchaAuthenticationInterface *mInterface;
201+};
202+
203+class TP_QT_NO_EXPORT BaseChannelHoldInterface::Adaptee : public QObject
204+{
205+ Q_OBJECT
206+public:
207+ Adaptee(BaseChannelHoldInterface *interface);
208+ ~Adaptee();
209+
210+public slots:
211+ void getHoldState(const Tp::Service::ChannelInterfaceHoldAdaptor::GetHoldStateContextPtr &context);
212+ void requestHold(bool hold, const Tp::Service::ChannelInterfaceHoldAdaptor::RequestHoldContextPtr &context);
213+signals:
214+ void holdStateChanged(uint holdState, uint reason);
215+
216+public:
217+ BaseChannelHoldInterface *mInterface;
218+};
219+
220+class TP_QT_NO_EXPORT BaseChannelGroupInterface::Adaptee : public QObject
221+{
222+ Q_OBJECT
223+ Q_PROPERTY(uint groupFlags READ groupFlags)
224+ Q_PROPERTY(Tp::HandleOwnerMap handleOwners READ handleOwners)
225+ Q_PROPERTY(Tp::LocalPendingInfoList localPendingMembers READ localPendingMembers)
226+ Q_PROPERTY(Tp::UIntList members READ members)
227+ Q_PROPERTY(Tp::UIntList remotePendingMembers READ remotePendingMembers)
228+ Q_PROPERTY(uint selfHandle READ selfHandle)
229+ Q_PROPERTY(Tp::HandleIdentifierMap memberIdentifiers READ memberIdentifiers)
230+public:
231+ Adaptee(BaseChannelGroupInterface *interface);
232+ ~Adaptee();
233+ uint groupFlags() const;
234+ Tp::HandleOwnerMap handleOwners() const;
235+ Tp::LocalPendingInfoList localPendingMembers() const;
236+ Tp::UIntList members() const;
237+ Tp::UIntList remotePendingMembers() const;
238+ uint selfHandle() const;
239+ Tp::HandleIdentifierMap memberIdentifiers() const;
240+public slots:
241+ void addMembers(const Tp::UIntList &contacts, const QString &message, const Tp::Service::ChannelInterfaceGroupAdaptor::AddMembersContextPtr &context);
242+ void getAllMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetAllMembersContextPtr &context);
243+ void getGroupFlags(const Tp::Service::ChannelInterfaceGroupAdaptor::GetGroupFlagsContextPtr &context);
244+ void getHandleOwners(const Tp::UIntList &handles, const Tp::Service::ChannelInterfaceGroupAdaptor::GetHandleOwnersContextPtr &context);
245+ void getLocalPendingMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetLocalPendingMembersContextPtr &context);
246+ void getLocalPendingMembersWithInfo(const Tp::Service::ChannelInterfaceGroupAdaptor::GetLocalPendingMembersWithInfoContextPtr &context);
247+ void getMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetMembersContextPtr &context);
248+ void getRemotePendingMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetRemotePendingMembersContextPtr &context);
249+ void getSelfHandle(const Tp::Service::ChannelInterfaceGroupAdaptor::GetSelfHandleContextPtr &context);
250+ void removeMembers(const Tp::UIntList &contacts, const QString &message, const Tp::Service::ChannelInterfaceGroupAdaptor::RemoveMembersContextPtr &context);
251+ void removeMembersWithReason(const Tp::UIntList &contacts, const QString &message, uint reason, const Tp::Service::ChannelInterfaceGroupAdaptor::RemoveMembersWithReasonContextPtr &context);
252+signals:
253+ void handleOwnersChangedDetailed(const Tp::HandleOwnerMap &added, const Tp::UIntList &removed, const Tp::HandleIdentifierMap &identifiers);
254+ void selfContactChanged(uint selfHandle, const QString &selfID);
255+ void groupFlagsChanged(uint added, uint removed);
256+ void membersChanged(const QString &message, const Tp::UIntList &added, const Tp::UIntList &removed, const Tp::UIntList &localPending, const Tp::UIntList &remotePending, uint actor, uint reason);
257+ void membersChangedDetailed(const Tp::UIntList &added, const Tp::UIntList &removed, const Tp::UIntList &localPending, const Tp::UIntList &remotePending, const QVariantMap &details);
258+ //All other signals are deprecated
259+public:
260+ BaseChannelGroupInterface *mInterface;
261+};
262+
263+class TP_QT_NO_EXPORT BaseChannelCallType::Adaptee : public QObject
264+{
265+ Q_OBJECT
266+ Q_PROPERTY(Tp::ObjectPathList contents READ contents)
267+ Q_PROPERTY(QVariantMap callStateDetails READ callStateDetails)
268+ Q_PROPERTY(uint callState READ callState)
269+ Q_PROPERTY(uint callFlags READ callFlags)
270+ Q_PROPERTY(Tp::CallStateReason callStateReason READ callStateReason)
271+ Q_PROPERTY(bool hardwareStreaming READ hardwareStreaming)
272+ Q_PROPERTY(Tp::CallMemberMap callMembers READ callMembers)
273+ Q_PROPERTY(Tp::HandleIdentifierMap memberIdentifiers READ memberIdentifiers)
274+ Q_PROPERTY(uint initialTransport READ initialTransport)
275+ Q_PROPERTY(bool initialAudio READ initialAudio)
276+ Q_PROPERTY(bool initialVideo READ initialVideo)
277+ Q_PROPERTY(QString initialVideoName READ initialVideoName)
278+ Q_PROPERTY(QString initialAudioName READ initialAudioName)
279+ Q_PROPERTY(bool mutableContents READ mutableContents)
280+
281+public:
282+ Adaptee(BaseChannelCallType *interface);
283+ ~Adaptee();
284+
285+ Tp::ObjectPathList contents() {
286+ return mInterface->contents();
287+ }
288+
289+ QVariantMap callStateDetails() {
290+ return mInterface->callStateDetails();
291+ }
292+
293+ uint callState() {
294+ return mInterface->callState();
295+ }
296+
297+ uint callFlags() {
298+ return mInterface->callFlags();
299+ }
300+
301+ Tp::CallStateReason callStateReason() {
302+ return mInterface->callStateReason();
303+ }
304+
305+ bool hardwareStreaming() {
306+ return mInterface->hardwareStreaming();
307+ }
308+
309+ Tp::CallMemberMap callMembers() {
310+ return mInterface->callMembers();
311+ }
312+
313+ Tp::HandleIdentifierMap memberIdentifiers() {
314+ return mInterface->memberIdentifiers();
315+ }
316+
317+ uint initialTransport() {
318+ return mInterface->initialTransport();
319+ }
320+
321+ bool initialAudio() {
322+ return mInterface->initialAudio();
323+ }
324+
325+ bool initialVideo() {
326+ return mInterface->initialVideo();
327+ }
328+
329+ QString initialVideoName() {
330+ return mInterface->initialVideoName();
331+ }
332+
333+ QString initialAudioName() {
334+ return mInterface->initialAudioName();
335+ }
336+
337+ bool mutableContents() {
338+ return mInterface->mutableContents();
339+ }
340+
341+public slots:
342+ void setRinging(const Tp::Service::ChannelTypeCallAdaptor::SetRingingContextPtr &context);
343+ void setQueued(const Tp::Service::ChannelTypeCallAdaptor::SetQueuedContextPtr &context);
344+ void accept(const Tp::Service::ChannelTypeCallAdaptor::AcceptContextPtr &context);
345+ void hangup(uint reason, const QString &detailedHangupReason, const QString &message, const Tp::Service::ChannelTypeCallAdaptor::HangupContextPtr &context);
346+ void addContent(const QString &contentName, const Tp::MediaStreamType &contentType, const Tp::MediaStreamDirection &initialDirection, const Tp::Service::ChannelTypeCallAdaptor::AddContentContextPtr &context);
347+
348+signals:
349+ void contentAdded(const QDBusObjectPath &content);
350+ void contentRemoved(const QDBusObjectPath &content, const Tp::CallStateReason &reason);
351+ void callStateChanged(uint callState, uint callFlags, const Tp::CallStateReason &stateReason, const QVariantMap &callStateDetails);
352+ void callMembersChanged(const Tp::CallMemberMap &flagsChanged, const Tp::HandleIdentifierMap &identifiers, const Tp::UIntList &removed, const Tp::CallStateReason &reason);
353+
354+public:
355+ BaseChannelCallType *mInterface;
356+};
357+
358+}
359
360=== added file '.pc/06-conference_interfaces.patch/TelepathyQt/base-channel.cpp'
361--- .pc/06-conference_interfaces.patch/TelepathyQt/base-channel.cpp 1970-01-01 00:00:00 +0000
362+++ .pc/06-conference_interfaces.patch/TelepathyQt/base-channel.cpp 2014-02-05 14:09:56 +0000
363@@ -0,0 +1,1688 @@
364+/**
365+ * This file is part of TelepathyQt
366+ *
367+ * @copyright Copyright (C) 2013 Matthias Gehre <gehre.matthias@gmail.com>
368+ * @copyright Copyright 2013 Canonical Ltd.
369+ * @license LGPL 2.1
370+ *
371+ * This library is free software; you can redistribute it and/or
372+ * modify it under the terms of the GNU Lesser General Public
373+ * License as published by the Free Software Foundation; either
374+ * version 2.1 of the License, or (at your option) any later version.
375+ *
376+ * This library is distributed in the hope that it will be useful,
377+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
378+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
379+ * Lesser General Public License for more details.
380+ *
381+ * You should have received a copy of the GNU Lesser General Public
382+ * License along with this library; if not, write to the Free Software
383+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
384+ */
385+
386+#include <TelepathyQt/BaseChannel>
387+#include <TelepathyQt/BaseCall>
388+#include "TelepathyQt/base-channel-internal.h"
389+
390+#include "TelepathyQt/_gen/base-channel.moc.hpp"
391+#include "TelepathyQt/_gen/base-channel-internal.moc.hpp"
392+
393+#include "TelepathyQt/debug-internal.h"
394+
395+#include <TelepathyQt/BaseConnection>
396+#include <TelepathyQt/Constants>
397+#include <TelepathyQt/DBusObject>
398+#include <TelepathyQt/Utils>
399+#include <TelepathyQt/AbstractProtocolInterface>
400+#include <QString>
401+#include <QVariantMap>
402+
403+namespace Tp
404+{
405+
406+struct TP_QT_NO_EXPORT BaseChannel::Private {
407+ Private(BaseChannel *parent, const QDBusConnection &dbusConnection, BaseConnection* connection,
408+ const QString &channelType, uint targetHandle, uint targetHandleType)
409+ : parent(parent),
410+ connection(connection),
411+ channelType(channelType),
412+ targetHandle(targetHandle),
413+ targetHandleType(targetHandleType),
414+ adaptee(new BaseChannel::Adaptee(dbusConnection, parent)) {
415+ }
416+
417+ BaseChannel *parent;
418+ BaseConnection* connection;
419+ QString channelType;
420+ QHash<QString, AbstractChannelInterfacePtr> interfaces;
421+ uint targetHandle;
422+ QString targetID;
423+ uint targetHandleType;
424+ bool requested;
425+ uint initiatorHandle;
426+ QString initiatorID;
427+ BaseChannel::Adaptee *adaptee;
428+};
429+
430+
431+BaseChannel::Adaptee::Adaptee(const QDBusConnection &dbusConnection,
432+ BaseChannel *channel)
433+ : QObject(channel),
434+ mChannel(channel)
435+{
436+ debug() << "Creating service::channelAdaptor for " << channel->dbusObject();
437+ mAdaptor = new Service::ChannelAdaptor(dbusConnection, this, channel->dbusObject());
438+}
439+
440+BaseChannel::Adaptee::~Adaptee()
441+{
442+}
443+
444+QStringList BaseChannel::Adaptee::interfaces() const
445+{
446+ QStringList ret;
447+ foreach(const AbstractChannelInterfacePtr & iface, mChannel->interfaces()) {
448+ if (iface->interfaceName().contains(QLatin1String(".Type.")))
449+ continue; //Do not include "Type"
450+ ret << iface->interfaceName();
451+ }
452+ ret << TP_QT_IFACE_PROPERTIES;
453+ return ret;
454+}
455+
456+void BaseChannel::Adaptee::close(const Tp::Service::ChannelAdaptor::CloseContextPtr &context)
457+{
458+ mChannel->close();
459+ context->setFinished();
460+}
461+
462+/**
463+ * \class BaseChannel
464+ * \ingroup servicecm
465+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
466+ *
467+ * \brief Base class for channel implementations.
468+ *
469+ */
470+
471+BaseChannel::BaseChannel(const QDBusConnection &dbusConnection,
472+ BaseConnection* connection,
473+ const QString &channelType, uint targetHandle,
474+ uint targetHandleType)
475+ : DBusService(dbusConnection),
476+ mPriv(new Private(this, dbusConnection, connection,
477+ channelType, targetHandle, targetHandleType))
478+{
479+}
480+
481+/**
482+ * Class destructor.
483+ */
484+BaseChannel::~BaseChannel()
485+{
486+ delete mPriv;
487+}
488+
489+void BaseChannel::close()
490+{
491+ //emit after return
492+ QMetaObject::invokeMethod(mPriv->adaptee, "closed",
493+ Qt::QueuedConnection);
494+ //emit after return
495+ QMetaObject::invokeMethod(this, "closed",
496+ Qt::QueuedConnection);
497+}
498+
499+/**
500+ * Return a unique name for this channel.
501+ *
502+ * \return A unique name for this channel.
503+ */
504+QString BaseChannel::uniqueName() const
505+{
506+ return QString(QLatin1String("_%1")).arg((quintptr) this, 0, 16);
507+}
508+
509+bool BaseChannel::registerObject(DBusError *error)
510+{
511+ if (isRegistered()) {
512+ return true;
513+ }
514+
515+ QString name = uniqueName();
516+ QString busName = mPriv->connection->busName();
517+ //QString busName = QString(QLatin1String("%1.%2"))
518+ // .arg(mPriv->connection->busName(),name);
519+ QString objectPath = QString(QLatin1String("%1/%2"))
520+ .arg(mPriv->connection->objectPath(), name);
521+ debug() << "Registering channel: busName: " << busName << " objectName: " << objectPath;
522+ DBusError _error;
523+
524+ debug() << "Channel: registering interfaces at " << dbusObject();
525+ foreach(const AbstractChannelInterfacePtr & iface, mPriv->interfaces) {
526+ if (!iface->registerInterface(dbusObject())) {
527+ // lets not fail if an optional interface fails registering, lets warn only
528+ warning() << "Unable to register interface" << iface->interfaceName();
529+ }
530+ }
531+
532+ bool ret = registerObject(busName, objectPath, &_error);
533+ if (!ret && error) {
534+ error->set(_error.name(), _error.message());
535+ }
536+ return ret;
537+}
538+
539+/**
540+ * Reimplemented from DBusService.
541+ */
542+bool BaseChannel::registerObject(const QString &busName,
543+ const QString &objectPath, DBusError *error)
544+{
545+ return DBusService::registerObject(busName, objectPath, error);
546+}
547+
548+QString BaseChannel::channelType() const
549+{
550+ return mPriv->channelType;
551+}
552+QList<AbstractChannelInterfacePtr> BaseChannel::interfaces() const
553+{
554+ return mPriv->interfaces.values();
555+}
556+uint BaseChannel::targetHandle() const
557+{
558+ return mPriv->targetHandle;
559+}
560+QString BaseChannel::targetID() const
561+{
562+ return mPriv->targetID;
563+}
564+uint BaseChannel::targetHandleType() const
565+{
566+ return mPriv->targetHandleType;
567+}
568+bool BaseChannel::requested() const
569+{
570+ return mPriv->requested;
571+}
572+uint BaseChannel::initiatorHandle() const
573+{
574+ return mPriv->initiatorHandle;
575+}
576+QString BaseChannel::initiatorID() const
577+{
578+ return mPriv->initiatorID;
579+}
580+
581+void BaseChannel::setInitiatorHandle(uint initiatorHandle)
582+{
583+ mPriv->initiatorHandle = initiatorHandle;
584+}
585+
586+void BaseChannel::setInitiatorID(const QString &initiatorID)
587+{
588+ mPriv->initiatorID = initiatorID;
589+}
590+
591+void BaseChannel::setTargetID(const QString &targetID)
592+{
593+ mPriv->targetID = targetID;
594+}
595+
596+void BaseChannel::setRequested(bool requested)
597+{
598+ mPriv->requested = requested;
599+}
600+
601+BaseConnection* BaseChannel::baseConnection() const
602+{
603+ return mPriv->connection;
604+}
605+
606+/**
607+ * Return the immutable properties of this channel object.
608+ *
609+ * Immutable properties cannot change after the object has been registered
610+ * on the bus with registerObject().
611+ *
612+ * \return The immutable properties of this channel object.
613+ */
614+QVariantMap BaseChannel::immutableProperties() const
615+{
616+ QVariantMap map;
617+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
618+ QVariant::fromValue(mPriv->adaptee->channelType()));
619+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"),
620+ QVariant::fromValue(mPriv->adaptee->targetHandle()));
621+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".Interfaces"),
622+ QVariant::fromValue(mPriv->adaptee->interfaces()));
623+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"),
624+ QVariant::fromValue(mPriv->adaptee->targetID()));
625+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
626+ QVariant::fromValue(mPriv->adaptee->targetHandleType()));
627+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".Requested"),
628+ QVariant::fromValue(mPriv->adaptee->requested()));
629+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle"),
630+ QVariant::fromValue(mPriv->adaptee->initiatorHandle()));
631+ map.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorID"),
632+ QVariant::fromValue(mPriv->adaptee->initiatorID()));
633+ return map;
634+}
635+
636+Tp::ChannelDetails BaseChannel::details() const
637+{
638+ Tp::ChannelDetails details;
639+ details.channel = QDBusObjectPath(objectPath());
640+ details.properties.unite(immutableProperties());
641+
642+ foreach(const AbstractChannelInterfacePtr & iface, mPriv->interfaces) {
643+ details.properties.unite(iface->immutableProperties());
644+ }
645+
646+ return details;
647+}
648+
649+/**
650+ * Return a pointer to the interface with the given name.
651+ *
652+ * \param interfaceName The D-Bus name of the interface,
653+ * ex. TP_QT_IFACE_PROTOCOL_INTERFACE_ADDRESSING.
654+ * \return A pointer to the AbstractProtocolInterface object that implements
655+ * the D-Bus interface with the given name, or a null pointer if such an interface
656+ * has not been plugged into this object.
657+ * \sa plugInterface(), interfaces()
658+ */
659+AbstractChannelInterfacePtr BaseChannel::interface(const QString &interfaceName) const
660+{
661+ return mPriv->interfaces.value(interfaceName);
662+}
663+
664+/**
665+ * Plug a new interface into this Protocol D-Bus object.
666+ *
667+ * This property is immutable and cannot change after this Protocol
668+ * object has been registered on the bus with registerObject().
669+ *
670+ * \param interface An AbstractProtocolInterface instance that implements
671+ * the interface that is to be plugged.
672+ * \return \c true on success or \c false otherwise
673+ * \sa interfaces(), interface()
674+ */
675+bool BaseChannel::plugInterface(const AbstractChannelInterfacePtr &interface)
676+{
677+ if (isRegistered()) {
678+ warning() << "Unable to plug protocol interface " << interface->interfaceName() <<
679+ "- protocol already registered";
680+ return false;
681+ }
682+
683+ if (interface->isRegistered()) {
684+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
685+ "- interface already registered";
686+ return false;
687+ }
688+
689+ if (mPriv->interfaces.contains(interface->interfaceName())) {
690+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
691+ "- another interface with same name already plugged";
692+ return false;
693+ }
694+
695+ debug() << "Interface" << interface->interfaceName() << "plugged";
696+ mPriv->interfaces.insert(interface->interfaceName(), interface);
697+ return true;
698+}
699+
700+/**
701+ * \class AbstractChannelInterface
702+ * \ingroup servicecm
703+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
704+ *
705+ * \brief Base class for all the Channel object interface implementations.
706+ */
707+
708+AbstractChannelInterface::AbstractChannelInterface(const QString &interfaceName)
709+ : AbstractDBusServiceInterface(interfaceName)
710+{
711+}
712+
713+AbstractChannelInterface::~AbstractChannelInterface()
714+{
715+}
716+
717+// Chan.T.Text
718+BaseChannelTextType::Adaptee::Adaptee(BaseChannelTextType *interface)
719+ : QObject(interface),
720+ mInterface(interface)
721+{
722+}
723+
724+BaseChannelTextType::Adaptee::~Adaptee()
725+{
726+}
727+
728+void BaseChannelTextType::Adaptee::acknowledgePendingMessages(const Tp::UIntList &IDs,
729+ const Tp::Service::ChannelTypeTextAdaptor::AcknowledgePendingMessagesContextPtr &context)
730+{
731+ qDebug() << "BaseConnectionContactsInterface::acknowledgePendingMessages " << IDs;
732+ DBusError error;
733+ mInterface->acknowledgePendingMessages(IDs, &error);
734+ if (error.isValid()) {
735+ context->setFinishedWithError(error.name(), error.message());
736+ return;
737+ }
738+ context->setFinished();
739+}
740+
741+struct TP_QT_NO_EXPORT BaseChannelTextType::Private {
742+ Private(BaseChannelTextType *parent, BaseChannel* channel)
743+ : channel(channel),
744+ pendingMessagesId(0),
745+ adaptee(new BaseChannelTextType::Adaptee(parent)) {
746+ }
747+
748+ BaseChannel* channel;
749+ /* maps pending-message-id to message part list */
750+ QMap<uint, Tp::MessagePartList> pendingMessages;
751+ /* increasing unique id of pending messages */
752+ uint pendingMessagesId;
753+ MessageAcknowledgedCallback messageAcknowledgedCB;
754+ BaseChannelTextType::Adaptee *adaptee;
755+};
756+
757+/**
758+ * \class BaseChannelTextType
759+ * \ingroup servicecm
760+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
761+ *
762+ * \brief Base class for implementations of Channel.Type.Text
763+ *
764+ */
765+
766+/**
767+ * Class constructor.
768+ */
769+BaseChannelTextType::BaseChannelTextType(BaseChannel* channel)
770+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_TYPE_TEXT),
771+ mPriv(new Private(this, channel))
772+{
773+}
774+
775+/**
776+ * Class destructor.
777+ */
778+BaseChannelTextType::~BaseChannelTextType()
779+{
780+ delete mPriv;
781+}
782+
783+/**
784+ * Return the immutable properties of this interface.
785+ *
786+ * Immutable properties cannot change after the interface has been registered
787+ * on a service on the bus with registerInterface().
788+ *
789+ * \return The immutable properties of this interface.
790+ */
791+QVariantMap BaseChannelTextType::immutableProperties() const
792+{
793+ return QVariantMap();
794+}
795+
796+void BaseChannelTextType::createAdaptor()
797+{
798+ (void) new Service::ChannelTypeTextAdaptor(dbusObject()->dbusConnection(),
799+ mPriv->adaptee, dbusObject());
800+}
801+
802+void BaseChannelTextType::addReceivedMessage(const Tp::MessagePartList &msg)
803+{
804+ MessagePartList message = msg;
805+ if (msg.empty()) {
806+ warning() << "empty message: not sent";
807+ return;
808+ }
809+ MessagePart &header = message.front();
810+
811+ if (header.count(QLatin1String("pending-message-id")))
812+ warning() << "pending-message-id will be overwritten";
813+
814+ /* Add pending-message-id to header */
815+ uint pendingMessageId = mPriv->pendingMessagesId++;
816+ header[QLatin1String("pending-message-id")] = QDBusVariant(pendingMessageId);
817+ mPriv->pendingMessages[pendingMessageId] = message;
818+
819+ uint timestamp = 0;
820+ if (header.count(QLatin1String("message-received")))
821+ timestamp = header[QLatin1String("message-received")].variant().toUInt();
822+
823+ uint handle = 0;
824+ if (header.count(QLatin1String("message-sender")))
825+ handle = header[QLatin1String("message-sender")].variant().toUInt();
826+
827+ uint type = ChannelTextMessageTypeNormal;
828+ if (header.count(QLatin1String("message-type")))
829+ type = header[QLatin1String("message-type")].variant().toUInt();
830+
831+ //FIXME: flags are not parsed
832+ uint flags = 0;
833+
834+ QString content;
835+ for (MessagePartList::Iterator i = message.begin() + 1; i != message.end(); ++i)
836+ if (i->count(QLatin1String("content-type"))
837+ && i->value(QLatin1String("content-type")).variant().toString() == QLatin1String("text/plain")
838+ && i->count(QLatin1String("content"))) {
839+ content = i->value(QLatin1String("content")).variant().toString();
840+ break;
841+ }
842+ if (content.length() > 0)
843+ QMetaObject::invokeMethod(mPriv->adaptee, "received",
844+ Qt::QueuedConnection,
845+ Q_ARG(uint, pendingMessageId),
846+ Q_ARG(uint, timestamp),
847+ Q_ARG(uint, handle),
848+ Q_ARG(uint, type),
849+ Q_ARG(uint, flags),
850+ Q_ARG(QString, content));
851+
852+ /* Signal on ChannelMessagesInterface */
853+ BaseChannelMessagesInterfacePtr messagesIface = BaseChannelMessagesInterfacePtr::dynamicCast(
854+ mPriv->channel->interface(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES));
855+ if (messagesIface)
856+ QMetaObject::invokeMethod(messagesIface.data(), "messageReceived",
857+ Qt::QueuedConnection,
858+ Q_ARG(Tp::MessagePartList, message));
859+}
860+
861+Tp::MessagePartListList BaseChannelTextType::pendingMessages()
862+{
863+ return mPriv->pendingMessages.values();
864+}
865+
866+/*
867+ * Will be called with the value of the message-token field after a received message has been acknowledged,
868+ * if the message-token field existed in the header.
869+ */
870+void BaseChannelTextType::setMessageAcknowledgedCallback(const MessageAcknowledgedCallback &cb)
871+{
872+ mPriv->messageAcknowledgedCB = cb;
873+}
874+
875+void BaseChannelTextType::acknowledgePendingMessages(const Tp::UIntList &IDs, DBusError* error)
876+{
877+ foreach(uint id, IDs) {
878+ QMap<uint, Tp::MessagePartList>::Iterator i = mPriv->pendingMessages.find(id);
879+ if (i == mPriv->pendingMessages.end()) {
880+ error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("id not found"));
881+ return;
882+ }
883+
884+ MessagePart &header = i->front();
885+ if (header.count(QLatin1String("message-token")) && mPriv->messageAcknowledgedCB.isValid())
886+ mPriv->messageAcknowledgedCB(header[QLatin1String("message-token")].variant().toString());
887+
888+ mPriv->pendingMessages.erase(i);
889+ }
890+
891+ /* Signal on ChannelMessagesInterface */
892+ BaseChannelMessagesInterfacePtr messagesIface = BaseChannelMessagesInterfacePtr::dynamicCast(
893+ mPriv->channel->interface(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES));
894+ if (messagesIface) //emit after return
895+ QMetaObject::invokeMethod(messagesIface.data(), "pendingMessagesRemoved",
896+ Qt::QueuedConnection,
897+ Q_ARG(Tp::UIntList, IDs));
898+}
899+
900+
901+
902+void BaseChannelTextType::sent(uint timestamp, uint type, QString text)
903+{
904+ emit mPriv->adaptee->sent(timestamp, type, text);
905+}
906+
907+
908+// Chan.I.Messages
909+BaseChannelMessagesInterface::Adaptee::Adaptee(BaseChannelMessagesInterface *interface)
910+ : QObject(interface),
911+ mInterface(interface)
912+{
913+}
914+
915+BaseChannelMessagesInterface::Adaptee::~Adaptee()
916+{
917+}
918+
919+void BaseChannelMessagesInterface::Adaptee::sendMessage(const Tp::MessagePartList &message, uint flags,
920+ const Tp::Service::ChannelInterfaceMessagesAdaptor::SendMessageContextPtr &context)
921+{
922+ DBusError error;
923+ QString token = mInterface->sendMessage(message, flags, &error);
924+ if (error.isValid()) {
925+ context->setFinishedWithError(error.name(), error.message());
926+ return;
927+ }
928+ context->setFinished(token);
929+}
930+
931+struct TP_QT_NO_EXPORT BaseChannelMessagesInterface::Private {
932+ Private(BaseChannelMessagesInterface *parent,
933+ BaseChannelTextType* textTypeInterface,
934+ QStringList supportedContentTypes,
935+ Tp::UIntList messageTypes,
936+ uint messagePartSupportFlags,
937+ uint deliveryReportingSupport)
938+ : textTypeInterface(textTypeInterface),
939+ supportedContentTypes(supportedContentTypes),
940+ messageTypes(messageTypes),
941+ messagePartSupportFlags(messagePartSupportFlags),
942+ deliveryReportingSupport(deliveryReportingSupport),
943+ adaptee(new BaseChannelMessagesInterface::Adaptee(parent)) {
944+ }
945+
946+ BaseChannelTextType* textTypeInterface;
947+ QStringList supportedContentTypes;
948+ Tp::UIntList messageTypes;
949+ uint messagePartSupportFlags;
950+ uint deliveryReportingSupport;
951+ SendMessageCallback sendMessageCB;
952+ BaseChannelMessagesInterface::Adaptee *adaptee;
953+};
954+
955+/**
956+ * \class BaseChannelMessagesInterface
957+ * \ingroup servicecm
958+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
959+ *
960+ * \brief Base class for implementations of Channel.Interface.Messages
961+ *
962+ */
963+
964+/**
965+ * Class constructor.
966+ */
967+BaseChannelMessagesInterface::BaseChannelMessagesInterface(BaseChannelTextType *textType,
968+ QStringList supportedContentTypes,
969+ UIntList messageTypes,
970+ uint messagePartSupportFlags,
971+ uint deliveryReportingSupport)
972+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES),
973+ mPriv(new Private(this, textType, supportedContentTypes, messageTypes,
974+ messagePartSupportFlags, deliveryReportingSupport))
975+{
976+}
977+
978+/**
979+ * Class destructor.
980+ */
981+BaseChannelMessagesInterface::~BaseChannelMessagesInterface()
982+{
983+ delete mPriv;
984+}
985+
986+/**
987+ * Return the immutable properties of this interface.
988+ *
989+ * Immutable properties cannot change after the interface has been registered
990+ * on a service on the bus with registerInterface().
991+ *
992+ * \return The immutable properties of this interface.
993+ */
994+QVariantMap BaseChannelMessagesInterface::immutableProperties() const
995+{
996+ QVariantMap map;
997+
998+ map.insert(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES + QLatin1String(".SupportedContentTypes"),
999+ QVariant::fromValue(mPriv->adaptee->supportedContentTypes()));
1000+ map.insert(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES + QLatin1String(".MessageTypes"),
1001+ QVariant::fromValue(mPriv->adaptee->messageTypes()));
1002+ map.insert(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES + QLatin1String(".MessagePartSupportFlags"),
1003+ QVariant::fromValue(mPriv->adaptee->messagePartSupportFlags()));
1004+ map.insert(TP_QT_IFACE_CHANNEL_INTERFACE_MESSAGES + QLatin1String(".DeliveryReportingSupport"),
1005+ QVariant::fromValue(mPriv->adaptee->deliveryReportingSupport()));
1006+ return map;
1007+}
1008+
1009+void BaseChannelMessagesInterface::createAdaptor()
1010+{
1011+ (void) new Service::ChannelInterfaceMessagesAdaptor(dbusObject()->dbusConnection(),
1012+ mPriv->adaptee, dbusObject());
1013+}
1014+
1015+QStringList BaseChannelMessagesInterface::supportedContentTypes()
1016+{
1017+ return mPriv->supportedContentTypes;
1018+}
1019+
1020+Tp::UIntList BaseChannelMessagesInterface::messageTypes()
1021+{
1022+ return mPriv->messageTypes;
1023+}
1024+
1025+uint BaseChannelMessagesInterface::messagePartSupportFlags()
1026+{
1027+ return mPriv->messagePartSupportFlags;
1028+}
1029+
1030+uint BaseChannelMessagesInterface::deliveryReportingSupport()
1031+{
1032+ return mPriv->deliveryReportingSupport;
1033+}
1034+
1035+Tp::MessagePartListList BaseChannelMessagesInterface::pendingMessages()
1036+{
1037+ return mPriv->textTypeInterface->pendingMessages();
1038+}
1039+
1040+void BaseChannelMessagesInterface::messageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken)
1041+{
1042+ emit mPriv->adaptee->messageSent(content, flags, messageToken);
1043+}
1044+
1045+void BaseChannelMessagesInterface::pendingMessagesRemoved(const Tp::UIntList &messageIDs)
1046+{
1047+ emit mPriv->adaptee->pendingMessagesRemoved(messageIDs);
1048+}
1049+
1050+void BaseChannelMessagesInterface::messageReceived(const Tp::MessagePartList &message)
1051+{
1052+ emit mPriv->adaptee->messageReceived(message);
1053+}
1054+
1055+void BaseChannelMessagesInterface::setSendMessageCallback(const SendMessageCallback &cb)
1056+{
1057+ mPriv->sendMessageCB = cb;
1058+}
1059+
1060+QString BaseChannelMessagesInterface::sendMessage(const Tp::MessagePartList &message, uint flags, DBusError* error)
1061+{
1062+ if (!mPriv->sendMessageCB.isValid()) {
1063+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1064+ return QString();
1065+ }
1066+ QString token = mPriv->sendMessageCB(message, flags, error);
1067+
1068+ //emit after return
1069+ QMetaObject::invokeMethod(mPriv->adaptee, "messageSent",
1070+ Qt::QueuedConnection,
1071+ Q_ARG(Tp::MessagePartList, message),
1072+ Q_ARG(uint, flags),
1073+ Q_ARG(QString, token));
1074+
1075+ if (message.empty()) {
1076+ warning() << "Sending empty message";
1077+ return token;
1078+ }
1079+ const MessagePart &header = message.front();
1080+
1081+ uint timestamp = 0;
1082+ if (header.count(QLatin1String("message-received")))
1083+ timestamp = header[QLatin1String("message-received")].variant().toUInt();
1084+
1085+ uint type = ChannelTextMessageTypeNormal;
1086+ if (header.count(QLatin1String("message-type")))
1087+ type = header[QLatin1String("message-type")].variant().toUInt();
1088+
1089+ QString content;
1090+ for (MessagePartList::const_iterator i = message.begin() + 1; i != message.end(); ++i)
1091+ if (i->count(QLatin1String("content-type"))
1092+ && i->value(QLatin1String("content-type")).variant().toString() == QLatin1String("text/plain")
1093+ && i->count(QLatin1String("content"))) {
1094+ content = i->value(QLatin1String("content")).variant().toString();
1095+ break;
1096+ }
1097+ //emit after return
1098+ QMetaObject::invokeMethod(mPriv->textTypeInterface, "sent",
1099+ Qt::QueuedConnection,
1100+ Q_ARG(uint, timestamp),
1101+ Q_ARG(uint, type),
1102+ Q_ARG(QString, content));
1103+ return token;
1104+}
1105+
1106+
1107+//Chan.T.ServerAuthentication
1108+BaseChannelServerAuthenticationType::Adaptee::Adaptee(BaseChannelServerAuthenticationType *interface)
1109+ : QObject(interface),
1110+ mInterface(interface)
1111+{
1112+}
1113+
1114+BaseChannelServerAuthenticationType::Adaptee::~Adaptee()
1115+{
1116+}
1117+
1118+struct TP_QT_NO_EXPORT BaseChannelServerAuthenticationType::Private {
1119+ Private(BaseChannelServerAuthenticationType *parent, const QString& authenticationMethod)
1120+ : authenticationMethod(authenticationMethod),
1121+ adaptee(new BaseChannelServerAuthenticationType::Adaptee(parent)) {
1122+ }
1123+ QString authenticationMethod;
1124+ BaseChannelServerAuthenticationType::Adaptee *adaptee;
1125+};
1126+
1127+QString BaseChannelServerAuthenticationType::Adaptee::authenticationMethod() const
1128+{
1129+ return mInterface->mPriv->authenticationMethod;
1130+}
1131+
1132+/**
1133+ * \class BaseChannelServerAuthenticationType
1134+ * \ingroup servicecm
1135+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
1136+ *
1137+ * \brief Base class for implementations of Channel.Type.ServerAuthentifcation
1138+ *
1139+ */
1140+
1141+/**
1142+ * Class constructor.
1143+ */
1144+BaseChannelServerAuthenticationType::BaseChannelServerAuthenticationType(const QString& authenticationMethod)
1145+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION),
1146+ mPriv(new Private(this, authenticationMethod))
1147+{
1148+}
1149+
1150+/**
1151+ * Class destructor.
1152+ */
1153+BaseChannelServerAuthenticationType::~BaseChannelServerAuthenticationType()
1154+{
1155+ delete mPriv;
1156+}
1157+
1158+/**
1159+ * Return the immutable properties of this interface.
1160+ *
1161+ * Immutable properties cannot change after the interface has been registered
1162+ * on a service on the bus with registerInterface().
1163+ *
1164+ * \return The immutable properties of this interface.
1165+ */
1166+QVariantMap BaseChannelServerAuthenticationType::immutableProperties() const
1167+{
1168+ QVariantMap map;
1169+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION + QLatin1String(".AuthenticationMethod"),
1170+ QVariant::fromValue(mPriv->adaptee->authenticationMethod()));
1171+ return map;
1172+}
1173+
1174+void BaseChannelServerAuthenticationType::createAdaptor()
1175+{
1176+ (void) new Service::ChannelTypeServerAuthenticationAdaptor(dbusObject()->dbusConnection(),
1177+ mPriv->adaptee, dbusObject());
1178+}
1179+
1180+//Chan.I.CaptchaAuthentication
1181+BaseChannelCaptchaAuthenticationInterface::Adaptee::Adaptee(BaseChannelCaptchaAuthenticationInterface *interface)
1182+ : QObject(interface),
1183+ mInterface(interface)
1184+{
1185+}
1186+
1187+BaseChannelCaptchaAuthenticationInterface::Adaptee::~Adaptee()
1188+{
1189+}
1190+
1191+struct TP_QT_NO_EXPORT BaseChannelCaptchaAuthenticationInterface::Private {
1192+ Private(BaseChannelCaptchaAuthenticationInterface *parent, bool canRetryCaptcha)
1193+ : canRetryCaptcha(canRetryCaptcha),
1194+ captchaStatus(CaptchaStatusLocalPending),
1195+ adaptee(new BaseChannelCaptchaAuthenticationInterface::Adaptee(parent)) {
1196+ }
1197+ bool canRetryCaptcha;
1198+ bool captchaStatus;
1199+ QString captchaError;
1200+ QVariantMap captchaErrorDetails;
1201+ GetCaptchasCallback getCaptchasCB;
1202+ GetCaptchaDataCallback getCaptchaDataCB;
1203+ AnswerCaptchasCallback answerCaptchasCB;
1204+ CancelCaptchaCallback cancelCaptchaCB;
1205+ BaseChannelCaptchaAuthenticationInterface::Adaptee *adaptee;
1206+};
1207+
1208+bool BaseChannelCaptchaAuthenticationInterface::Adaptee::canRetryCaptcha() const
1209+{
1210+ return mInterface->mPriv->canRetryCaptcha;
1211+}
1212+
1213+uint BaseChannelCaptchaAuthenticationInterface::Adaptee::captchaStatus() const
1214+{
1215+ return mInterface->mPriv->captchaStatus;
1216+}
1217+
1218+QString BaseChannelCaptchaAuthenticationInterface::Adaptee::captchaError() const
1219+{
1220+ return mInterface->mPriv->captchaError;
1221+}
1222+
1223+QVariantMap BaseChannelCaptchaAuthenticationInterface::Adaptee::captchaErrorDetails() const
1224+{
1225+ return mInterface->mPriv->captchaErrorDetails;
1226+}
1227+
1228+void BaseChannelCaptchaAuthenticationInterface::Adaptee::getCaptchas(const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::GetCaptchasContextPtr &context)
1229+{
1230+ qDebug() << "BaseChannelCaptchaAuthenticationInterface::Adaptee::getCaptchas";
1231+ DBusError error;
1232+ Tp::CaptchaInfoList captchaInfo;
1233+ uint numberRequired;
1234+ QString language;
1235+ mInterface->mPriv->getCaptchasCB(captchaInfo, numberRequired, language, &error);
1236+ if (error.isValid()) {
1237+ context->setFinishedWithError(error.name(), error.message());
1238+ return;
1239+ }
1240+ context->setFinished(captchaInfo, numberRequired, language);
1241+}
1242+
1243+void BaseChannelCaptchaAuthenticationInterface::Adaptee::getCaptchaData(uint ID, const QString& mimeType, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::GetCaptchaDataContextPtr &context)
1244+{
1245+ qDebug() << "BaseChannelCaptchaAuthenticationInterface::Adaptee::getCaptchaData " << ID << mimeType;
1246+ DBusError error;
1247+ QByteArray captchaData = mInterface->mPriv->getCaptchaDataCB(ID, mimeType, &error);
1248+ if (error.isValid()) {
1249+ context->setFinishedWithError(error.name(), error.message());
1250+ return;
1251+ }
1252+ context->setFinished(captchaData);
1253+}
1254+
1255+void BaseChannelCaptchaAuthenticationInterface::Adaptee::answerCaptchas(const Tp::CaptchaAnswers& answers, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::AnswerCaptchasContextPtr &context)
1256+{
1257+ qDebug() << "BaseChannelCaptchaAuthenticationInterface::Adaptee::answerCaptchas";
1258+ DBusError error;
1259+ mInterface->mPriv->answerCaptchasCB(answers, &error);
1260+ if (error.isValid()) {
1261+ context->setFinishedWithError(error.name(), error.message());
1262+ return;
1263+ }
1264+ context->setFinished();
1265+}
1266+
1267+void BaseChannelCaptchaAuthenticationInterface::Adaptee::cancelCaptcha(uint reason, const QString& debugMessage, const Tp::Service::ChannelInterfaceCaptchaAuthenticationAdaptor::CancelCaptchaContextPtr &context)
1268+{
1269+ qDebug() << "BaseChannelCaptchaAuthenticationInterface::Adaptee::cancelCaptcha "
1270+ << reason << " " << debugMessage;
1271+ DBusError error;
1272+ mInterface->mPriv->cancelCaptchaCB(reason, debugMessage, &error);
1273+ if (error.isValid()) {
1274+ context->setFinishedWithError(error.name(), error.message());
1275+ return;
1276+ }
1277+ context->setFinished();
1278+}
1279+
1280+/**
1281+ * \class BaseChannelCaptchaAuthenticationInterface
1282+ * \ingroup servicecm
1283+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
1284+ *
1285+ * \brief Base class for implementations of Channel.Interface.CaptchaAuthentication
1286+ *
1287+ */
1288+
1289+/**
1290+ * Class constructor.
1291+ */
1292+BaseChannelCaptchaAuthenticationInterface::BaseChannelCaptchaAuthenticationInterface(bool canRetryCaptcha)
1293+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_CAPTCHA_AUTHENTICATION),
1294+ mPriv(new Private(this, canRetryCaptcha))
1295+{
1296+}
1297+
1298+/**
1299+ * Class destructor.
1300+ */
1301+BaseChannelCaptchaAuthenticationInterface::~BaseChannelCaptchaAuthenticationInterface()
1302+{
1303+ delete mPriv;
1304+}
1305+
1306+/**
1307+ * Return the immutable properties of this interface.
1308+ *
1309+ * Immutable properties cannot change after the interface has been registered
1310+ * on a service on the bus with registerInterface().
1311+ *
1312+ * \return The immutable properties of this interface.
1313+ */
1314+QVariantMap BaseChannelCaptchaAuthenticationInterface::immutableProperties() const
1315+{
1316+ QVariantMap map;
1317+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION + QLatin1String(".CanRetryCaptcha"),
1318+ QVariant::fromValue(mPriv->adaptee->canRetryCaptcha()));
1319+ return map;
1320+}
1321+
1322+void BaseChannelCaptchaAuthenticationInterface::createAdaptor()
1323+{
1324+ (void) new Service::ChannelInterfaceCaptchaAuthenticationAdaptor(dbusObject()->dbusConnection(),
1325+ mPriv->adaptee, dbusObject());
1326+}
1327+
1328+void BaseChannelCaptchaAuthenticationInterface::setGetCaptchasCallback(const GetCaptchasCallback &cb)
1329+{
1330+ mPriv->getCaptchasCB = cb;
1331+}
1332+
1333+void BaseChannelCaptchaAuthenticationInterface::setGetCaptchaDataCallback(const GetCaptchaDataCallback &cb)
1334+{
1335+ mPriv->getCaptchaDataCB = cb;
1336+}
1337+
1338+void BaseChannelCaptchaAuthenticationInterface::setAnswerCaptchasCallback(const AnswerCaptchasCallback &cb)
1339+{
1340+ mPriv->answerCaptchasCB = cb;
1341+}
1342+
1343+void BaseChannelCaptchaAuthenticationInterface::setCancelCaptchaCallback(const CancelCaptchaCallback &cb)
1344+{
1345+ mPriv->cancelCaptchaCB = cb;
1346+}
1347+
1348+void BaseChannelCaptchaAuthenticationInterface::setCaptchaStatus(uint status)
1349+{
1350+ mPriv->captchaStatus = status;
1351+}
1352+
1353+void BaseChannelCaptchaAuthenticationInterface::setCaptchaError(const QString& busName)
1354+{
1355+ mPriv->captchaError = busName;
1356+}
1357+
1358+void BaseChannelCaptchaAuthenticationInterface::setCaptchaErrorDetails(const QVariantMap& error)
1359+{
1360+ mPriv->captchaErrorDetails = error;
1361+}
1362+
1363+//Chan.I.Group
1364+BaseChannelGroupInterface::Adaptee::Adaptee(BaseChannelGroupInterface *interface)
1365+ : QObject(interface),
1366+ mInterface(interface)
1367+{
1368+}
1369+
1370+BaseChannelGroupInterface::Adaptee::~Adaptee()
1371+{
1372+}
1373+
1374+struct TP_QT_NO_EXPORT BaseChannelGroupInterface::Private {
1375+ Private(BaseChannelGroupInterface *parent, ChannelGroupFlags initialFlags, uint selfHandle)
1376+ : flags(initialFlags),
1377+ selfHandle(selfHandle),
1378+ adaptee(new BaseChannelGroupInterface::Adaptee(parent)) {
1379+ }
1380+ ChannelGroupFlags flags;
1381+ Tp::HandleOwnerMap handleOwners;
1382+ Tp::LocalPendingInfoList localPendingMembers;
1383+ Tp::UIntList members;
1384+ Tp::UIntList remotePendingMembers;
1385+ uint selfHandle;
1386+ Tp::HandleIdentifierMap memberIdentifiers;
1387+ RemoveMembersCallback removeMembersCB;
1388+ AddMembersCallback addMembersCB;
1389+ Tp::UIntList getLocalPendingMembers() const {
1390+ Tp::UIntList ret;
1391+ foreach(const LocalPendingInfo & info, localPendingMembers)
1392+ ret << info.toBeAdded;
1393+ return ret;
1394+ }
1395+ BaseChannelGroupInterface::Adaptee *adaptee;
1396+};
1397+
1398+uint BaseChannelGroupInterface::Adaptee::groupFlags() const
1399+{
1400+ return mInterface->mPriv->flags;
1401+}
1402+
1403+Tp::HandleOwnerMap BaseChannelGroupInterface::Adaptee::handleOwners() const
1404+{
1405+ return mInterface->mPriv->handleOwners;
1406+}
1407+
1408+Tp::LocalPendingInfoList BaseChannelGroupInterface::Adaptee::localPendingMembers() const
1409+{
1410+ return mInterface->mPriv->localPendingMembers;
1411+}
1412+
1413+Tp::UIntList BaseChannelGroupInterface::Adaptee::members() const
1414+{
1415+ return mInterface->mPriv->members;
1416+}
1417+
1418+Tp::UIntList BaseChannelGroupInterface::Adaptee::remotePendingMembers() const
1419+{
1420+ return mInterface->mPriv->remotePendingMembers;
1421+}
1422+
1423+uint BaseChannelGroupInterface::Adaptee::selfHandle() const
1424+{
1425+ return mInterface->mPriv->selfHandle;
1426+}
1427+
1428+Tp::HandleIdentifierMap BaseChannelGroupInterface::Adaptee::memberIdentifiers() const
1429+{
1430+ return mInterface->mPriv->memberIdentifiers;
1431+}
1432+
1433+void BaseChannelGroupInterface::Adaptee::addMembers(const Tp::UIntList& contacts,
1434+ const QString& message,
1435+ const Tp::Service::ChannelInterfaceGroupAdaptor::AddMembersContextPtr &context)
1436+{
1437+ debug() << "BaseChannelGroupInterface::Adaptee::addMembers";
1438+ if (!mInterface->mPriv->addMembersCB.isValid()) {
1439+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1440+ return;
1441+ }
1442+ DBusError error;
1443+ mInterface->mPriv->addMembersCB(contacts, message, &error);
1444+ if (error.isValid()) {
1445+ context->setFinishedWithError(error.name(), error.message());
1446+ return;
1447+ }
1448+ context->setFinished();
1449+}
1450+
1451+void BaseChannelGroupInterface::Adaptee::removeMembers(const Tp::UIntList& contacts, const QString& message,
1452+ const Tp::Service::ChannelInterfaceGroupAdaptor::RemoveMembersContextPtr &context)
1453+{
1454+ debug() << "BaseChannelGroupInterface::Adaptee::removeMembers";
1455+ if (!mInterface->mPriv->removeMembersCB.isValid()) {
1456+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1457+ return;
1458+ }
1459+ DBusError error;
1460+ mInterface->mPriv->removeMembersCB(contacts, message, &error);
1461+ if (error.isValid()) {
1462+ context->setFinishedWithError(error.name(), error.message());
1463+ return;
1464+ }
1465+ context->setFinished();
1466+}
1467+
1468+void BaseChannelGroupInterface::Adaptee::removeMembersWithReason(const Tp::UIntList& contacts,
1469+ const QString& message,
1470+ uint reason,
1471+ const Tp::Service::ChannelInterfaceGroupAdaptor::RemoveMembersWithReasonContextPtr &context)
1472+{
1473+ debug() << "BaseChannelGroupInterface::Adaptee::removeMembersWithReason";
1474+ removeMembers(contacts, message, context);
1475+}
1476+
1477+void BaseChannelGroupInterface::Adaptee::getAllMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetAllMembersContextPtr &context)
1478+{
1479+ context->setFinished(mInterface->mPriv->members, mInterface->mPriv->getLocalPendingMembers(), mInterface->mPriv->remotePendingMembers);
1480+}
1481+
1482+void BaseChannelGroupInterface::Adaptee::getGroupFlags(const Tp::Service::ChannelInterfaceGroupAdaptor::GetGroupFlagsContextPtr &context)
1483+{
1484+ context->setFinished(mInterface->mPriv->flags);
1485+}
1486+
1487+void BaseChannelGroupInterface::Adaptee::getHandleOwners(const Tp::UIntList& handles, const Tp::Service::ChannelInterfaceGroupAdaptor::GetHandleOwnersContextPtr &context)
1488+{
1489+ Tp::UIntList ret;
1490+ foreach(uint handle, handles)
1491+ ret.append(mInterface->mPriv->handleOwners.contains(handle) ? mInterface->mPriv->handleOwners[handle] : 0);
1492+ context->setFinished(ret);
1493+}
1494+
1495+void BaseChannelGroupInterface::Adaptee::getLocalPendingMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetLocalPendingMembersContextPtr &context)
1496+{
1497+ context->setFinished(mInterface->mPriv->getLocalPendingMembers());
1498+}
1499+
1500+void BaseChannelGroupInterface::Adaptee::getLocalPendingMembersWithInfo(const Tp::Service::ChannelInterfaceGroupAdaptor::GetLocalPendingMembersWithInfoContextPtr &context)
1501+{
1502+ context->setFinished(mInterface->mPriv->localPendingMembers);
1503+}
1504+
1505+void BaseChannelGroupInterface::Adaptee::getMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetMembersContextPtr &context)
1506+{
1507+ context->setFinished(mInterface->mPriv->members);
1508+}
1509+
1510+void BaseChannelGroupInterface::Adaptee::getRemotePendingMembers(const Tp::Service::ChannelInterfaceGroupAdaptor::GetRemotePendingMembersContextPtr &context)
1511+{
1512+ context->setFinished(mInterface->mPriv->remotePendingMembers);
1513+}
1514+
1515+void BaseChannelGroupInterface::Adaptee::getSelfHandle(const Tp::Service::ChannelInterfaceGroupAdaptor::GetSelfHandleContextPtr &context)
1516+{
1517+ context->setFinished(mInterface->mPriv->selfHandle);
1518+}
1519+
1520+/**
1521+ * \class BaseChannelGroupInterface
1522+ * \ingroup servicecm
1523+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
1524+ *
1525+ * \brief Base class for implementations of Channel.Interface.Group
1526+ *
1527+ */
1528+
1529+/**
1530+ * Class constructor.
1531+ */
1532+BaseChannelGroupInterface::BaseChannelGroupInterface(ChannelGroupFlags initialFlags, uint selfHandle)
1533+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_GROUP),
1534+ mPriv(new Private(this, initialFlags, selfHandle))
1535+{
1536+}
1537+
1538+/**
1539+ * Class destructor.
1540+ */
1541+BaseChannelGroupInterface::~BaseChannelGroupInterface()
1542+{
1543+ delete mPriv;
1544+}
1545+
1546+/**
1547+ * Return the immutable properties of this interface.
1548+ *
1549+ * Immutable properties cannot change after the interface has been registered
1550+ * on a service on the bus with registerInterface().
1551+ *
1552+ * \return The immutable properties of this interface.
1553+ */
1554+QVariantMap BaseChannelGroupInterface::immutableProperties() const
1555+{
1556+ QVariantMap map;
1557+ return map;
1558+}
1559+
1560+void BaseChannelGroupInterface::createAdaptor()
1561+{
1562+ (void) new Service::ChannelInterfaceGroupAdaptor(dbusObject()->dbusConnection(),
1563+ mPriv->adaptee, dbusObject());
1564+}
1565+
1566+void BaseChannelGroupInterface::setRemoveMembersCallback(const RemoveMembersCallback &cb)
1567+{
1568+ mPriv->removeMembersCB = cb;
1569+}
1570+
1571+void BaseChannelGroupInterface::setAddMembersCallback(const AddMembersCallback &cb)
1572+{
1573+ mPriv->addMembersCB = cb;
1574+}
1575+
1576+void BaseChannelGroupInterface::addMembers(const Tp::UIntList& handles, const QStringList& identifiers)
1577+{
1578+ if (handles.size() != identifiers.size()) {
1579+ debug() << "BaseChannelGroupInterface::addMembers: handles.size() != identifiers.size()";
1580+ return;
1581+ }
1582+ Tp::UIntList added;
1583+ for (int i = 0; i < handles.size(); ++i) {
1584+ uint handle = handles[i];
1585+ if (mPriv->members.contains(handle))
1586+ continue;
1587+
1588+ mPriv->memberIdentifiers[handle] = identifiers[i];
1589+ mPriv->members.append(handle);
1590+ added.append(handle);
1591+ }
1592+ if (!added.isEmpty())
1593+ emit mPriv->adaptee->membersChanged(QString(), added, Tp::UIntList(), Tp::UIntList(), Tp::UIntList(), 0, ChannelGroupChangeReasonNone);
1594+}
1595+
1596+void BaseChannelGroupInterface::removeMembers(const Tp::UIntList& handles)
1597+{
1598+ Tp::UIntList removed;
1599+ foreach(uint handle, handles) {
1600+ if (mPriv->members.contains(handle))
1601+ continue;
1602+
1603+ mPriv->memberIdentifiers.remove(handle);
1604+ mPriv->members.removeAll(handle);
1605+ removed.append(handle);
1606+ }
1607+ if (!removed.isEmpty())
1608+ emit mPriv->adaptee->membersChanged(QString(), Tp::UIntList(), removed, Tp::UIntList(), Tp::UIntList(), 0, ChannelGroupChangeReasonNone);
1609+}
1610+
1611+// Chan.T.Call
1612+BaseChannelCallType::Adaptee::Adaptee(BaseChannelCallType *interface)
1613+ : QObject(interface),
1614+ mInterface(interface)
1615+{
1616+}
1617+
1618+BaseChannelCallType::Adaptee::~Adaptee()
1619+{
1620+}
1621+
1622+
1623+struct TP_QT_NO_EXPORT BaseChannelCallType::Private {
1624+ Private(BaseChannelCallType *parent, BaseChannel* channel, bool hardwareStreaming,
1625+ uint initialTransport,
1626+ bool initialAudio,
1627+ bool initialVideo,
1628+ QString initialAudioName,
1629+ QString initialVideoName,
1630+ bool mutableContents)
1631+ : hardwareStreaming(hardwareStreaming),
1632+ initialTransport(initialTransport),
1633+ initialAudio(initialAudio),
1634+ initialVideo(initialVideo),
1635+ initialAudioName(initialAudioName),
1636+ initialVideoName(initialVideoName),
1637+ mutableContents(mutableContents),
1638+ channel(channel),
1639+ adaptee(new BaseChannelCallType::Adaptee(parent)) {
1640+ }
1641+
1642+ Tp::ObjectPathList contents;
1643+ QVariantMap callStateDetails;
1644+ uint callState;
1645+ uint callFlags;
1646+ Tp::CallStateReason callStateReason;
1647+ bool hardwareStreaming;
1648+ Tp::CallMemberMap callMembers;
1649+ Tp::HandleIdentifierMap memberIdentifiers;
1650+ uint initialTransport;
1651+ bool initialAudio;
1652+ bool initialVideo;
1653+ QString initialAudioName;
1654+ QString initialVideoName;
1655+ bool mutableContents;
1656+
1657+ QList<Tp::BaseCallContentPtr> mCallContents;
1658+ AcceptCallback acceptCB;
1659+ HangupCallback hangupCB;
1660+ SetQueuedCallback setQueuedCB;
1661+ SetRingingCallback setRingingCB;
1662+ AddContentCallback addContentCB;
1663+
1664+ BaseChannel *channel;
1665+ BaseChannelCallType::Adaptee *adaptee;
1666+};
1667+
1668+void BaseChannelCallType::Adaptee::setRinging(const Tp::Service::ChannelTypeCallAdaptor::SetRingingContextPtr &context)
1669+{
1670+ if (!mInterface->mPriv->setRingingCB.isValid()) {
1671+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1672+ return;
1673+ }
1674+ DBusError error;
1675+ mInterface->mPriv->setRingingCB(&error);
1676+ if (error.isValid()) {
1677+ context->setFinishedWithError(error.name(), error.message());
1678+ return;
1679+ }
1680+ context->setFinished();
1681+}
1682+
1683+void BaseChannelCallType::Adaptee::setQueued(const Tp::Service::ChannelTypeCallAdaptor::SetQueuedContextPtr &context)
1684+{
1685+ if (!mInterface->mPriv->setQueuedCB.isValid()) {
1686+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1687+ return;
1688+ }
1689+ DBusError error;
1690+ mInterface->mPriv->setQueuedCB(&error);
1691+ if (error.isValid()) {
1692+ context->setFinishedWithError(error.name(), error.message());
1693+ return;
1694+ }
1695+ context->setFinished();
1696+}
1697+
1698+void BaseChannelCallType::Adaptee::accept(const Tp::Service::ChannelTypeCallAdaptor::AcceptContextPtr &context)
1699+{
1700+ if (!mInterface->mPriv->acceptCB.isValid()) {
1701+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1702+ return;
1703+ }
1704+ DBusError error;
1705+ mInterface->mPriv->acceptCB(&error);
1706+ if (error.isValid()) {
1707+ context->setFinishedWithError(error.name(), error.message());
1708+ return;
1709+ }
1710+ context->setFinished();
1711+}
1712+
1713+void BaseChannelCallType::Adaptee::hangup(uint reason, const QString &detailedHangupReason, const QString &message, const Tp::Service::ChannelTypeCallAdaptor::HangupContextPtr &context)
1714+{
1715+ if (!mInterface->mPriv->hangupCB.isValid()) {
1716+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1717+ return;
1718+ }
1719+ DBusError error;
1720+ mInterface->mPriv->hangupCB(reason, detailedHangupReason, message, &error);
1721+ if (error.isValid()) {
1722+ context->setFinishedWithError(error.name(), error.message());
1723+ return;
1724+ }
1725+ context->setFinished();
1726+}
1727+
1728+void BaseChannelCallType::Adaptee::addContent(const QString &contentName, const Tp::MediaStreamType &contentType, const Tp::MediaStreamDirection &initialDirection, const Tp::Service::ChannelTypeCallAdaptor::AddContentContextPtr &context)
1729+{
1730+ if (!mInterface->mPriv->addContentCB.isValid()) {
1731+ Tp::BaseCallContentPtr ptr = mInterface->addContent(contentName, contentType, initialDirection);
1732+ QDBusObjectPath objPath;
1733+ objPath.setPath(ptr->objectPath());
1734+ context->setFinished(objPath);
1735+ return;
1736+ }
1737+
1738+ DBusError error;
1739+ QDBusObjectPath objPath = mInterface->mPriv->addContentCB(contentName, contentType, initialDirection, &error);
1740+ if (error.isValid()) {
1741+ context->setFinishedWithError(error.name(), error.message());
1742+ return;
1743+ }
1744+ context->setFinished(objPath);
1745+}
1746+
1747+/**
1748+ * \class BaseChannelCallType
1749+ * \ingroup servicecm
1750+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
1751+ *
1752+ * \brief Base class for implementations of Channel.Type.Call
1753+ *
1754+ */
1755+
1756+/**
1757+ * Class constructor.
1758+ */
1759+BaseChannelCallType::BaseChannelCallType(BaseChannel* channel, bool hardwareStreaming,
1760+ uint initialTransport,
1761+ bool initialAudio,
1762+ bool initialVideo,
1763+ QString initialAudioName,
1764+ QString initialVideoName,
1765+ bool mutableContents)
1766+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_TYPE_CALL),
1767+ mPriv(new Private(this, channel,
1768+ hardwareStreaming,
1769+ initialTransport,
1770+ initialAudio,
1771+ initialVideo,
1772+ initialAudioName,
1773+ initialVideoName,
1774+ mutableContents))
1775+{
1776+}
1777+
1778+Tp::ObjectPathList BaseChannelCallType::contents() {
1779+ return mPriv->contents;
1780+}
1781+
1782+QVariantMap BaseChannelCallType::callStateDetails() {
1783+ return mPriv->callStateDetails;
1784+}
1785+
1786+uint BaseChannelCallType::callState() {
1787+ return mPriv->callState;
1788+}
1789+
1790+uint BaseChannelCallType::callFlags() {
1791+ return mPriv->callFlags;
1792+}
1793+
1794+Tp::CallStateReason BaseChannelCallType::callStateReason() {
1795+ return mPriv->callStateReason;
1796+}
1797+
1798+bool BaseChannelCallType::hardwareStreaming() {
1799+ return mPriv->hardwareStreaming;
1800+}
1801+
1802+Tp::CallMemberMap BaseChannelCallType::callMembers() {
1803+ return mPriv->callMembers;
1804+}
1805+
1806+Tp::HandleIdentifierMap BaseChannelCallType::memberIdentifiers() {
1807+ return mPriv->memberIdentifiers;
1808+}
1809+
1810+uint BaseChannelCallType::initialTransport() {
1811+ return mPriv->initialTransport;
1812+}
1813+
1814+bool BaseChannelCallType::initialAudio() {
1815+ return mPriv->initialAudio;
1816+}
1817+
1818+bool BaseChannelCallType::initialVideo() {
1819+ return mPriv->initialVideo;
1820+}
1821+
1822+QString BaseChannelCallType::initialVideoName() {
1823+ return mPriv->initialVideoName;
1824+}
1825+
1826+QString BaseChannelCallType::initialAudioName() {
1827+ return mPriv->initialAudioName;
1828+}
1829+
1830+bool BaseChannelCallType::mutableContents() {
1831+ return mPriv->mutableContents;
1832+}
1833+
1834+/**
1835+ * Class destructor.
1836+ */
1837+BaseChannelCallType::~BaseChannelCallType()
1838+{
1839+ delete mPriv;
1840+}
1841+
1842+QVariantMap BaseChannelCallType::immutableProperties() const
1843+{
1844+ QVariantMap map;
1845+
1846+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".HardwareStreaming"),
1847+ QVariant::fromValue(mPriv->adaptee->hardwareStreaming()));
1848+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialTransport"),
1849+ QVariant::fromValue(mPriv->adaptee->initialTransport()));
1850+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"),
1851+ QVariant::fromValue(mPriv->adaptee->initialAudio()));
1852+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"),
1853+ QVariant::fromValue(mPriv->adaptee->initialVideo()));
1854+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudioName"),
1855+ QVariant::fromValue(mPriv->adaptee->initialAudioName()));
1856+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideoName"),
1857+ QVariant::fromValue(mPriv->adaptee->initialVideoName()));
1858+ map.insert(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".MutableContents"),
1859+ QVariant::fromValue(mPriv->adaptee->mutableContents()));
1860+ return map;
1861+}
1862+
1863+void BaseChannelCallType::createAdaptor()
1864+{
1865+ (void) new Service::ChannelTypeCallAdaptor(dbusObject()->dbusConnection(),
1866+ mPriv->adaptee, dbusObject());
1867+}
1868+
1869+void BaseChannelCallType::setCallState(const Tp::CallState &state, uint flags, const Tp::CallStateReason &stateReason, const QVariantMap &callStateDetails)
1870+{
1871+ mPriv->callState = state;
1872+ mPriv->callFlags = flags;
1873+ mPriv->callStateReason = stateReason;
1874+ mPriv->callStateDetails = callStateDetails;
1875+ emit mPriv->adaptee->callStateChanged(state, flags, stateReason, callStateDetails);
1876+}
1877+
1878+void BaseChannelCallType::setAcceptCallback(const AcceptCallback &cb)
1879+{
1880+ mPriv->acceptCB = cb;
1881+}
1882+
1883+void BaseChannelCallType::setHangupCallback(const HangupCallback &cb)
1884+{
1885+ mPriv->hangupCB = cb;
1886+}
1887+
1888+void BaseChannelCallType::setSetRingingCallback(const SetRingingCallback &cb)
1889+{
1890+ mPriv->setRingingCB = cb;
1891+}
1892+
1893+void BaseChannelCallType::setSetQueuedCallback(const SetQueuedCallback &cb)
1894+{
1895+ mPriv->setQueuedCB = cb;
1896+}
1897+
1898+void BaseChannelCallType::setAddContentCallback(const AddContentCallback &cb)
1899+{
1900+ mPriv->addContentCB = cb;
1901+}
1902+
1903+void BaseChannelCallType::setMembersFlags(const Tp::CallMemberMap &flagsChanged, const Tp::HandleIdentifierMap &identifiers, const Tp::UIntList &removed, const Tp::CallStateReason &reason)
1904+{
1905+ mPriv->callMembers = flagsChanged;
1906+ mPriv->memberIdentifiers = identifiers;
1907+ emit mPriv->adaptee->callMembersChanged(flagsChanged, identifiers, removed, reason);
1908+}
1909+
1910+BaseCallContentPtr BaseChannelCallType::addContent(const QString &name, const Tp::MediaStreamType &type, const Tp::MediaStreamDirection &direction)
1911+{
1912+ BaseCallContentPtr ptr = BaseCallContent::create(mPriv->channel->dbusConnection(), mPriv->channel, name, type, direction);
1913+ DBusError error;
1914+ ptr->registerObject(&error);
1915+ QDBusObjectPath objpath;
1916+ objpath.setPath(ptr->objectPath());
1917+ mPriv->contents.append(objpath);
1918+ emit mPriv->adaptee->contentAdded(objpath);
1919+
1920+ return ptr;
1921+}
1922+
1923+void BaseChannelCallType::addContent(BaseCallContentPtr content)
1924+{
1925+ DBusError error;
1926+ content->registerObject(&error);
1927+ QDBusObjectPath objpath;
1928+ objpath.setPath(content->objectPath());
1929+ mPriv->contents.append(objpath);
1930+ emit mPriv->adaptee->contentAdded(objpath);
1931+}
1932+
1933+// Chan.I.Hold
1934+BaseChannelHoldInterface::Adaptee::Adaptee(BaseChannelHoldInterface *interface)
1935+ : QObject(interface),
1936+ mInterface(interface)
1937+{
1938+}
1939+
1940+BaseChannelHoldInterface::Adaptee::~Adaptee()
1941+{
1942+}
1943+
1944+struct TP_QT_NO_EXPORT BaseChannelHoldInterface::Private {
1945+ Private(BaseChannelHoldInterface *parent, Tp::LocalHoldState state)
1946+ : state(state),
1947+ reason(Tp::LocalHoldStateReasonNone),
1948+ adaptee(new BaseChannelHoldInterface::Adaptee(parent)) {
1949+ }
1950+
1951+ SetHoldStateCallback setHoldStateCB;
1952+ Tp::LocalHoldState state;
1953+ Tp::LocalHoldStateReason reason;
1954+ BaseChannelHoldInterface::Adaptee *adaptee;
1955+};
1956+
1957+void BaseChannelHoldInterface::Adaptee::getHoldState(const Tp::Service::ChannelInterfaceHoldAdaptor::GetHoldStateContextPtr &context)
1958+{
1959+ context->setFinished(mInterface->getHoldState(), mInterface->getHoldReason());
1960+}
1961+
1962+void BaseChannelHoldInterface::Adaptee::requestHold(bool hold, const Tp::Service::ChannelInterfaceHoldAdaptor::RequestHoldContextPtr &context)
1963+{
1964+ if (!mInterface->mPriv->setHoldStateCB.isValid()) {
1965+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1966+ return;
1967+ }
1968+
1969+ Tp::LocalHoldState state = hold ? Tp::LocalHoldStateHeld : Tp::LocalHoldStateUnheld;
1970+
1971+ DBusError error;
1972+ mInterface->mPriv->setHoldStateCB(state, Tp::LocalHoldStateReasonRequested, &error);
1973+ if (error.isValid()) {
1974+ context->setFinishedWithError(error.name(), error.message());
1975+ return;
1976+ }
1977+ context->setFinished();
1978+}
1979+
1980+/**
1981+ * \class BaseChannelHoldInterface
1982+ * \ingroup servicecm
1983+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
1984+ *
1985+ * \brief Base class for implementations of Channel.Interface.Hold
1986+ *
1987+ */
1988+
1989+/**
1990+ * Class constructor.
1991+ */
1992+BaseChannelHoldInterface::BaseChannelHoldInterface()
1993+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_HOLD),
1994+ mPriv(new Private(this, Tp::LocalHoldStateUnheld))
1995+{
1996+}
1997+
1998+Tp::LocalHoldState BaseChannelHoldInterface::getHoldState() const
1999+{
2000+ return mPriv->state;
2001+}
2002+
2003+Tp::LocalHoldStateReason BaseChannelHoldInterface::getHoldReason() const
2004+{
2005+ return mPriv->reason;
2006+}
2007+
2008+void BaseChannelHoldInterface::setSetHoldStateCallback(const SetHoldStateCallback &cb)
2009+{
2010+ mPriv->setHoldStateCB = cb;
2011+}
2012+
2013+void BaseChannelHoldInterface::setHoldState(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason)
2014+{
2015+ if (mPriv->state != state) {
2016+ mPriv->state = state;
2017+ mPriv->reason = reason;
2018+ emit mPriv->adaptee->holdStateChanged(state, reason);
2019+ }
2020+}
2021+
2022+/**
2023+ * Class destructor.
2024+ */
2025+BaseChannelHoldInterface::~BaseChannelHoldInterface()
2026+{
2027+ delete mPriv;
2028+}
2029+
2030+/**
2031+ * Return the immutable properties of this interface.
2032+ *
2033+ * Immutable properties cannot change after the interface has been registered
2034+ * on a service on the bus with registerInterface().
2035+ *
2036+ * \return The immutable properties of this interface.
2037+ */
2038+QVariantMap BaseChannelHoldInterface::immutableProperties() const
2039+{
2040+ QVariantMap map;
2041+ return map;
2042+}
2043+
2044+void BaseChannelHoldInterface::createAdaptor()
2045+{
2046+ (void) new Service::ChannelInterfaceHoldAdaptor(dbusObject()->dbusConnection(),
2047+ mPriv->adaptee, dbusObject());
2048+}
2049+
2050+}
2051+
2052
2053=== added file '.pc/06-conference_interfaces.patch/TelepathyQt/base-channel.h'
2054--- .pc/06-conference_interfaces.patch/TelepathyQt/base-channel.h 1970-01-01 00:00:00 +0000
2055+++ .pc/06-conference_interfaces.patch/TelepathyQt/base-channel.h 2014-02-05 14:09:56 +0000
2056@@ -0,0 +1,479 @@
2057+/**
2058+ * This file is part of TelepathyQt
2059+ *
2060+ * @copyright Copyright (C) 2013 Matthias Gehre <gehre.matthias@gmail.com>
2061+ * @copyright Copyright 2013 Canonical Ltd.
2062+ * @license LGPL 2.1
2063+ *
2064+ * This library is free software; you can redistribute it and/or
2065+ * modify it under the terms of the GNU Lesser General Public
2066+ * License as published by the Free Software Foundation; either
2067+ * version 2.1 of the License, or (at your option) any later version.
2068+ *
2069+ * This library is distributed in the hope that it will be useful,
2070+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2071+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2072+ * Lesser General Public License for more details.
2073+ *
2074+ * You should have received a copy of the GNU Lesser General Public
2075+ * License along with this library; if not, write to the Free Software
2076+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2077+ */
2078+
2079+#ifndef _TelepathyQt_base_channel_h_HEADER_GUARD_
2080+#define _TelepathyQt_base_channel_h_HEADER_GUARD_
2081+
2082+#ifndef IN_TP_QT_HEADER
2083+#error IN_TP_QT_HEADER
2084+#endif
2085+
2086+#include <TelepathyQt/DBusService>
2087+#include <TelepathyQt/Global>
2088+#include <TelepathyQt/Types>
2089+#include <TelepathyQt/Callbacks>
2090+#include <TelepathyQt/Constants>
2091+
2092+#include <QDBusConnection>
2093+
2094+class QString;
2095+
2096+namespace Tp
2097+{
2098+
2099+class TP_QT_EXPORT BaseChannel : public DBusService
2100+{
2101+ Q_OBJECT
2102+ Q_DISABLE_COPY(BaseChannel)
2103+
2104+public:
2105+ static BaseChannelPtr create(BaseConnection* connection, const QString &channelType,
2106+ uint targetHandle, uint targetHandleType) {
2107+ return BaseChannelPtr(new BaseChannel(QDBusConnection::sessionBus(), connection,
2108+ channelType, targetHandle, targetHandleType));
2109+ }
2110+
2111+ virtual ~BaseChannel();
2112+
2113+ QVariantMap immutableProperties() const;
2114+ bool registerObject(DBusError *error = NULL);
2115+ virtual QString uniqueName() const;
2116+
2117+ QString channelType() const;
2118+ QList<AbstractChannelInterfacePtr> interfaces() const;
2119+ AbstractChannelInterfacePtr interface(const QString &interfaceName) const;
2120+ uint targetHandle() const;
2121+ QString targetID() const;
2122+ uint targetHandleType() const;
2123+ bool requested() const;
2124+ uint initiatorHandle() const;
2125+ QString initiatorID() const;
2126+ Tp::ChannelDetails details() const;
2127+
2128+ void setInitiatorHandle(uint initiatorHandle);
2129+ void setInitiatorID(const QString &initiatorID);
2130+ void setTargetID(const QString &targetID);
2131+ void setRequested(bool requested);
2132+
2133+ bool plugInterface(const AbstractChannelInterfacePtr &interface);
2134+ BaseConnection * baseConnection() const;
2135+ void close();
2136+
2137+Q_SIGNALS:
2138+ void closed();
2139+protected:
2140+ BaseChannel(const QDBusConnection &dbusConnection, BaseConnection* connection,
2141+ const QString &channelType, uint targetHandle, uint targetHandleType);
2142+ virtual bool registerObject(const QString &busName, const QString &objectPath,
2143+ DBusError *error);
2144+private:
2145+ class Adaptee;
2146+ friend class Adaptee;
2147+ class Private;
2148+ friend class Private;
2149+ Private *mPriv;
2150+};
2151+
2152+class TP_QT_EXPORT AbstractChannelInterface : public AbstractDBusServiceInterface
2153+{
2154+ Q_OBJECT
2155+ Q_DISABLE_COPY(AbstractChannelInterface)
2156+
2157+public:
2158+ AbstractChannelInterface(const QString &interfaceName);
2159+ virtual ~AbstractChannelInterface();
2160+
2161+private:
2162+ friend class BaseChannel;
2163+
2164+ class Private;
2165+ friend class Private;
2166+ Private *mPriv;
2167+};
2168+
2169+class TP_QT_EXPORT BaseChannelTextType : public AbstractChannelInterface
2170+{
2171+ Q_OBJECT
2172+ Q_DISABLE_COPY(BaseChannelTextType)
2173+
2174+public:
2175+ static BaseChannelTextTypePtr create(BaseChannel* channel) {
2176+ return BaseChannelTextTypePtr(new BaseChannelTextType(channel));
2177+ }
2178+ template<typename BaseChannelTextTypeSubclass>
2179+ static SharedPtr<BaseChannelTextTypeSubclass> create(BaseChannel* channel) {
2180+ return SharedPtr<BaseChannelTextTypeSubclass>(
2181+ new BaseChannelTextTypeSubclass(channel));
2182+ }
2183+
2184+ typedef Callback2<QDBusObjectPath, const QVariantMap&, DBusError*> CreateChannelCallback;
2185+ CreateChannelCallback createChannel;
2186+
2187+ typedef Callback2<bool, const QVariantMap&, DBusError*> EnsureChannelCallback;
2188+ EnsureChannelCallback ensureChannel;
2189+
2190+ virtual ~BaseChannelTextType();
2191+
2192+ QVariantMap immutableProperties() const;
2193+
2194+ Tp::RequestableChannelClassList requestableChannelClasses;
2195+
2196+ typedef Callback1<void, QString> MessageAcknowledgedCallback;
2197+ void setMessageAcknowledgedCallback(const MessageAcknowledgedCallback &cb);
2198+
2199+ Tp::MessagePartListList pendingMessages();
2200+
2201+ /* Convenience function */
2202+ void addReceivedMessage(const Tp::MessagePartList &message);
2203+private Q_SLOTS:
2204+ void sent(uint timestamp, uint type, QString text);
2205+protected:
2206+ BaseChannelTextType(BaseChannel* channel);
2207+ void acknowledgePendingMessages(const Tp::UIntList &IDs, DBusError* error);
2208+
2209+private:
2210+ void createAdaptor();
2211+
2212+ class Adaptee;
2213+ friend class Adaptee;
2214+ struct Private;
2215+ friend struct Private;
2216+ Private *mPriv;
2217+};
2218+
2219+class TP_QT_EXPORT BaseChannelMessagesInterface : public AbstractChannelInterface
2220+{
2221+ Q_OBJECT
2222+ Q_DISABLE_COPY(BaseChannelMessagesInterface)
2223+
2224+public:
2225+ static BaseChannelMessagesInterfacePtr create(BaseChannelTextType* textTypeInterface,
2226+ QStringList supportedContentTypes,
2227+ UIntList messageTypes,
2228+ uint messagePartSupportFlags,
2229+ uint deliveryReportingSupport) {
2230+ return BaseChannelMessagesInterfacePtr(new BaseChannelMessagesInterface(textTypeInterface,
2231+ supportedContentTypes,
2232+ messageTypes,
2233+ messagePartSupportFlags,
2234+ deliveryReportingSupport));
2235+ }
2236+ template<typename BaseChannelMessagesInterfaceSubclass>
2237+ static SharedPtr<BaseChannelMessagesInterfaceSubclass> create() {
2238+ return SharedPtr<BaseChannelMessagesInterfaceSubclass>(
2239+ new BaseChannelMessagesInterfaceSubclass());
2240+ }
2241+ virtual ~BaseChannelMessagesInterface();
2242+
2243+ QVariantMap immutableProperties() const;
2244+
2245+ QStringList supportedContentTypes();
2246+ Tp::UIntList messageTypes();
2247+ uint messagePartSupportFlags();
2248+ uint deliveryReportingSupport();
2249+ Tp::MessagePartListList pendingMessages();
2250+
2251+ void messageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken);
2252+
2253+ typedef Callback3<QString, const Tp::MessagePartList&, uint, DBusError*> SendMessageCallback;
2254+ void setSendMessageCallback(const SendMessageCallback &cb);
2255+protected:
2256+ QString sendMessage(const Tp::MessagePartList &message, uint flags, DBusError* error);
2257+private Q_SLOTS:
2258+ void pendingMessagesRemoved(const Tp::UIntList &messageIDs);
2259+ void messageReceived(const Tp::MessagePartList &message);
2260+private:
2261+ BaseChannelMessagesInterface(BaseChannelTextType* textType,
2262+ QStringList supportedContentTypes,
2263+ Tp::UIntList messageTypes,
2264+ uint messagePartSupportFlags,
2265+ uint deliveryReportingSupport);
2266+ void createAdaptor();
2267+
2268+ class Adaptee;
2269+ friend class Adaptee;
2270+ struct Private;
2271+ friend struct Private;
2272+ Private *mPriv;
2273+};
2274+
2275+class TP_QT_EXPORT BaseChannelServerAuthenticationType : public AbstractChannelInterface
2276+{
2277+ Q_OBJECT
2278+ Q_DISABLE_COPY(BaseChannelServerAuthenticationType)
2279+
2280+public:
2281+ static BaseChannelServerAuthenticationTypePtr create(const QString &authenticationMethod) {
2282+ return BaseChannelServerAuthenticationTypePtr(new BaseChannelServerAuthenticationType(authenticationMethod));
2283+ }
2284+ template<typename BaseChannelServerAuthenticationTypeSubclass>
2285+ static SharedPtr<BaseChannelServerAuthenticationTypeSubclass> create(const QString &authenticationMethod) {
2286+ return SharedPtr<BaseChannelServerAuthenticationTypeSubclass>(
2287+ new BaseChannelServerAuthenticationTypeSubclass(authenticationMethod));
2288+ }
2289+ virtual ~BaseChannelServerAuthenticationType();
2290+
2291+ QVariantMap immutableProperties() const;
2292+private Q_SLOTS:
2293+private:
2294+ BaseChannelServerAuthenticationType(const QString &authenticationMethod);
2295+ void createAdaptor();
2296+
2297+ class Adaptee;
2298+ friend class Adaptee;
2299+ struct Private;
2300+ friend struct Private;
2301+ Private *mPriv;
2302+};
2303+
2304+class TP_QT_EXPORT BaseChannelCaptchaAuthenticationInterface : public AbstractChannelInterface
2305+{
2306+ Q_OBJECT
2307+ Q_DISABLE_COPY(BaseChannelCaptchaAuthenticationInterface)
2308+
2309+public:
2310+ static BaseChannelCaptchaAuthenticationInterfacePtr create(bool canRetryCaptcha) {
2311+ return BaseChannelCaptchaAuthenticationInterfacePtr(new BaseChannelCaptchaAuthenticationInterface(canRetryCaptcha));
2312+ }
2313+ template<typename BaseChannelCaptchaAuthenticationInterfaceSubclass>
2314+ static SharedPtr<BaseChannelCaptchaAuthenticationInterfaceSubclass> create(bool canRetryCaptcha) {
2315+ return SharedPtr<BaseChannelCaptchaAuthenticationInterfaceSubclass>(
2316+ new BaseChannelCaptchaAuthenticationInterfaceSubclass(canRetryCaptcha));
2317+ }
2318+ virtual ~BaseChannelCaptchaAuthenticationInterface();
2319+
2320+ QVariantMap immutableProperties() const;
2321+
2322+ typedef Callback4<void, Tp::CaptchaInfoList&, uint&, QString&, DBusError*> GetCaptchasCallback;
2323+ void setGetCaptchasCallback(const GetCaptchasCallback &cb);
2324+
2325+ typedef Callback3<QByteArray, uint, const QString&, DBusError*> GetCaptchaDataCallback;
2326+ void setGetCaptchaDataCallback(const GetCaptchaDataCallback &cb);
2327+
2328+ typedef Callback2<void, const Tp::CaptchaAnswers&, DBusError*> AnswerCaptchasCallback;
2329+ void setAnswerCaptchasCallback(const AnswerCaptchasCallback &cb);
2330+
2331+ typedef Callback3<void, uint, const QString&, DBusError*> CancelCaptchaCallback;
2332+ void setCancelCaptchaCallback(const CancelCaptchaCallback &cb);
2333+
2334+ void setCaptchaStatus(uint status);
2335+ void setCaptchaError(const QString &busName);
2336+ void setCaptchaErrorDetails(const QVariantMap &error);
2337+private Q_SLOTS:
2338+private:
2339+ BaseChannelCaptchaAuthenticationInterface(bool canRetryCaptcha);
2340+ void createAdaptor();
2341+
2342+ class Adaptee;
2343+ friend class Adaptee;
2344+ struct Private;
2345+ friend struct Private;
2346+ Private *mPriv;
2347+};
2348+
2349+class TP_QT_EXPORT BaseChannelGroupInterface : public AbstractChannelInterface
2350+{
2351+ Q_OBJECT
2352+ Q_DISABLE_COPY(BaseChannelGroupInterface)
2353+
2354+public:
2355+ static BaseChannelGroupInterfacePtr create(ChannelGroupFlags initialFlags, uint selfHandle) {
2356+ return BaseChannelGroupInterfacePtr(new BaseChannelGroupInterface(initialFlags, selfHandle));
2357+ }
2358+ template<typename BaseChannelGroupInterfaceSubclass>
2359+ static SharedPtr<BaseChannelGroupInterfaceSubclass> create(ChannelGroupFlags initialFlags, uint selfHandle) {
2360+ return SharedPtr<BaseChannelGroupInterfaceSubclass>(
2361+ new BaseChannelGroupInterfaceSubclass(initialFlags, selfHandle));
2362+ }
2363+ virtual ~BaseChannelGroupInterface();
2364+
2365+ QVariantMap immutableProperties() const;
2366+
2367+ typedef Callback3<void, const Tp::UIntList&, const QString&, DBusError*> RemoveMembersCallback;
2368+ void setRemoveMembersCallback(const RemoveMembersCallback &cb);
2369+
2370+ typedef Callback3<void, const Tp::UIntList&, const QString&, DBusError*> AddMembersCallback;
2371+ void setAddMembersCallback(const AddMembersCallback &cb);
2372+
2373+ /* Adds a contact to this group. No-op if already in this group */
2374+ void addMembers(const Tp::UIntList &handles, const QStringList &identifiers);
2375+ void removeMembers(const Tp::UIntList &handles);
2376+
2377+private Q_SLOTS:
2378+private:
2379+ BaseChannelGroupInterface(ChannelGroupFlags initialFlags, uint selfHandle);
2380+ void createAdaptor();
2381+
2382+ class Adaptee;
2383+ friend class Adaptee;
2384+ struct Private;
2385+ friend struct Private;
2386+ Private *mPriv;
2387+};
2388+
2389+class TP_QT_EXPORT BaseChannelCallType : public AbstractChannelInterface
2390+{
2391+ Q_OBJECT
2392+ Q_DISABLE_COPY(BaseChannelCallType)
2393+
2394+public:
2395+ static BaseChannelCallTypePtr create(BaseChannel* channel, bool hardwareStreaming,
2396+ uint initialTransport,
2397+ bool initialAudio,
2398+ bool initialVideo,
2399+ QString initialAudioName,
2400+ QString initialVideoName,
2401+ bool mutableContents = false) {
2402+ return BaseChannelCallTypePtr(new BaseChannelCallType(channel,
2403+ hardwareStreaming,
2404+ initialTransport,
2405+ initialAudio,
2406+ initialVideo,
2407+ initialAudioName,
2408+ initialVideoName,
2409+ mutableContents));
2410+ }
2411+ template<typename BaseChannelCallTypeSubclass>
2412+ static SharedPtr<BaseChannelCallTypeSubclass> create(BaseChannel* channel, bool hardwareStreaming,
2413+ uint initialTransport,
2414+ bool initialAudio,
2415+ bool initialVideo,
2416+ QString initialAudioName,
2417+ QString initialVideoName,
2418+ bool mutableContents = false) {
2419+ return SharedPtr<BaseChannelCallTypeSubclass>(
2420+ new BaseChannelCallTypeSubclass(channel,
2421+ hardwareStreaming,
2422+ initialTransport,
2423+ initialAudio,
2424+ initialVideo,
2425+ initialAudioName,
2426+ initialVideoName,
2427+ mutableContents));
2428+ }
2429+
2430+ typedef Callback2<QDBusObjectPath, const QVariantMap&, DBusError*> CreateChannelCallback;
2431+ CreateChannelCallback createChannel;
2432+
2433+ typedef Callback2<bool, const QVariantMap&, DBusError*> EnsureChannelCallback;
2434+ EnsureChannelCallback ensureChannel;
2435+
2436+ virtual ~BaseChannelCallType();
2437+
2438+ QVariantMap immutableProperties() const;
2439+
2440+ Tp::ObjectPathList contents();
2441+ QVariantMap callStateDetails();
2442+ uint callState();
2443+ uint callFlags();
2444+ Tp::CallStateReason callStateReason();
2445+ bool hardwareStreaming();
2446+ Tp::CallMemberMap callMembers();
2447+ Tp::HandleIdentifierMap memberIdentifiers();
2448+ uint initialTransport();
2449+ bool initialAudio();
2450+ bool initialVideo();
2451+ QString initialAudioName();
2452+ QString initialVideoName();
2453+ bool mutableContents();
2454+
2455+ typedef Callback1<void, DBusError*> AcceptCallback;
2456+ void setAcceptCallback(const AcceptCallback &cb);
2457+
2458+ typedef Callback4<void, uint, const QString &, const QString &, DBusError*> HangupCallback;
2459+ void setHangupCallback(const HangupCallback &cb);
2460+
2461+ typedef Callback1<void, DBusError*> SetRingingCallback;
2462+ void setSetRingingCallback(const SetRingingCallback &cb);
2463+
2464+ typedef Callback1<void, DBusError*> SetQueuedCallback;
2465+ void setSetQueuedCallback(const SetQueuedCallback &cb);
2466+
2467+ typedef Callback4<QDBusObjectPath, const QString&, const Tp::MediaStreamType&, const Tp::MediaStreamDirection&, DBusError*> AddContentCallback;
2468+ void setAddContentCallback(const AddContentCallback &cb);
2469+
2470+ void setCallState(const Tp::CallState &state, uint flags, const Tp::CallStateReason &stateReason, const QVariantMap &callStateDetails);
2471+ void setMembersFlags(const Tp::CallMemberMap &flagsChanged, const Tp::HandleIdentifierMap &identifiers, const Tp::UIntList &removed, const Tp::CallStateReason &reason);
2472+ BaseCallContentPtr addContent(const QString &name, const Tp::MediaStreamType &type, const Tp::MediaStreamDirection &direction);
2473+ void addContent(BaseCallContentPtr content);
2474+
2475+ Tp::RequestableChannelClassList requestableChannelClasses;
2476+
2477+protected:
2478+ BaseChannelCallType(BaseChannel* channel,
2479+ bool hardwareStreaming,
2480+ uint initialTransport,
2481+ bool initialAudio,
2482+ bool initialVideo,
2483+ QString initialAudioName,
2484+ QString initialVideoName,
2485+ bool mutableContents = false);
2486+
2487+private:
2488+ void createAdaptor();
2489+
2490+ class Adaptee;
2491+ friend class Adaptee;
2492+ struct Private;
2493+ friend struct Private;
2494+ Private *mPriv;
2495+};
2496+
2497+class TP_QT_EXPORT BaseChannelHoldInterface : public AbstractChannelInterface
2498+{
2499+ Q_OBJECT
2500+ Q_DISABLE_COPY(BaseChannelHoldInterface)
2501+
2502+public:
2503+ static BaseChannelHoldInterfacePtr create() {
2504+ return BaseChannelHoldInterfacePtr(new BaseChannelHoldInterface());
2505+ }
2506+ template<typename BaseChannelHoldInterfaceSubclass>
2507+ static SharedPtr<BaseChannelHoldInterfaceSubclass> create() {
2508+ return SharedPtr<BaseChannelHoldInterfaceSubclass>(
2509+ new BaseChannelHoldInterfaceSubclass());
2510+ }
2511+ virtual ~BaseChannelHoldInterface();
2512+
2513+ QVariantMap immutableProperties() const;
2514+
2515+ Tp::LocalHoldState getHoldState() const;
2516+ Tp::LocalHoldStateReason getHoldReason() const;
2517+ void setHoldState(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason);
2518+
2519+ typedef Callback3<void, const Tp::LocalHoldState&, const Tp::LocalHoldStateReason &, DBusError*> SetHoldStateCallback;
2520+ void setSetHoldStateCallback(const SetHoldStateCallback &cb);
2521+Q_SIGNALS:
2522+ void holdStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason);
2523+private:
2524+ BaseChannelHoldInterface();
2525+ void createAdaptor();
2526+
2527+ class Adaptee;
2528+ friend class Adaptee;
2529+ struct Private;
2530+ friend struct Private;
2531+ Private *mPriv;
2532+};
2533+
2534+}
2535+#endif
2536
2537=== added file '.pc/06-conference_interfaces.patch/TelepathyQt/service-types.h'
2538--- .pc/06-conference_interfaces.patch/TelepathyQt/service-types.h 1970-01-01 00:00:00 +0000
2539+++ .pc/06-conference_interfaces.patch/TelepathyQt/service-types.h 2014-02-05 14:09:56 +0000
2540@@ -0,0 +1,97 @@
2541+/**
2542+ * This file is part of TelepathyQt
2543+ *
2544+ * @copyright Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
2545+ * @copyright Copyright (C) 2012 Nokia Corporation
2546+ * @license LGPL 2.1
2547+ *
2548+ * This library is free software; you can redistribute it and/or
2549+ * modify it under the terms of the GNU Lesser General Public
2550+ * License as published by the Free Software Foundation; either
2551+ * version 2.1 of the License, or (at your option) any later version.
2552+ *
2553+ * This library is distributed in the hope that it will be useful,
2554+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2555+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2556+ * Lesser General Public License for more details.
2557+ *
2558+ * You should have received a copy of the GNU Lesser General Public
2559+ * License along with this library; if not, write to the Free Software
2560+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2561+ */
2562+
2563+#ifndef _TelepathyQt_service_types_h_HEADER_GUARD_
2564+#define _TelepathyQt_service_types_h_HEADER_GUARD_
2565+
2566+#ifndef IN_TP_QT_HEADER
2567+#error IN_TP_QT_HEADER
2568+#endif
2569+
2570+#include <TelepathyQt/Types>
2571+
2572+namespace Tp
2573+{
2574+
2575+class AbstractProtocolInterface;
2576+class AbstractConnectionInterface;
2577+class AbstractChannelInterface;
2578+class AbstractCallContentInterface;
2579+class BaseConnection;
2580+class BaseConnectionRequestsInterface;
2581+class BaseConnectionContactsInterface;
2582+class BaseConnectionSimplePresenceInterface;
2583+class BaseConnectionContactListInterface;
2584+class BaseConnectionAddressingInterface;
2585+class BaseConnectionManager;
2586+class BaseProtocol;
2587+class BaseProtocolAddressingInterface;
2588+class BaseProtocolAvatarsInterface;
2589+class BaseProtocolPresenceInterface;
2590+class BaseChannel;
2591+class BaseChannelTextType;
2592+class BaseChannelCallType;
2593+class BaseCallContent;
2594+class BaseCallMuteInterface;
2595+class BaseCallContentDTMFInterface;
2596+class BaseChannelMessagesInterface;
2597+class BaseChannelServerAuthenticationType;
2598+class BaseChannelCaptchaAuthenticationInterface;
2599+class BaseChannelGroupInterface;
2600+class BaseChannelHoldInterface;
2601+class DBusService;
2602+
2603+#ifndef DOXYGEN_SHOULD_SKIP_THIS
2604+
2605+typedef SharedPtr<AbstractProtocolInterface> AbstractProtocolInterfacePtr;
2606+typedef SharedPtr<AbstractConnectionInterface> AbstractConnectionInterfacePtr;
2607+typedef SharedPtr<AbstractChannelInterface> AbstractChannelInterfacePtr;
2608+typedef SharedPtr<AbstractCallContentInterface> AbstractCallContentInterfacePtr;
2609+typedef SharedPtr<BaseConnection> BaseConnectionPtr;
2610+typedef SharedPtr<BaseConnectionRequestsInterface> BaseConnectionRequestsInterfacePtr;
2611+typedef SharedPtr<BaseConnectionContactsInterface> BaseConnectionContactsInterfacePtr;
2612+typedef SharedPtr<BaseConnectionSimplePresenceInterface> BaseConnectionSimplePresenceInterfacePtr;
2613+typedef SharedPtr<BaseConnectionContactListInterface> BaseConnectionContactListInterfacePtr;
2614+typedef SharedPtr<BaseConnectionAddressingInterface> BaseConnectionAddressingInterfacePtr;
2615+typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr;
2616+typedef SharedPtr<BaseProtocol> BaseProtocolPtr;
2617+typedef SharedPtr<BaseProtocolAddressingInterface> BaseProtocolAddressingInterfacePtr;
2618+typedef SharedPtr<BaseProtocolAvatarsInterface> BaseProtocolAvatarsInterfacePtr;
2619+typedef SharedPtr<BaseProtocolPresenceInterface> BaseProtocolPresenceInterfacePtr;
2620+typedef SharedPtr<BaseChannel> BaseChannelPtr;
2621+typedef SharedPtr<BaseChannelTextType> BaseChannelTextTypePtr;
2622+typedef SharedPtr<BaseChannelCallType> BaseChannelCallTypePtr;
2623+typedef SharedPtr<BaseCallContent> BaseCallContentPtr;
2624+typedef SharedPtr<BaseCallContentDTMFInterface> BaseCallContentDTMFInterfacePtr;
2625+typedef SharedPtr<BaseCallMuteInterface> BaseCallMuteInterfacePtr;
2626+typedef SharedPtr<BaseChannelMessagesInterface> BaseChannelMessagesInterfacePtr;
2627+typedef SharedPtr<BaseChannelServerAuthenticationType> BaseChannelServerAuthenticationTypePtr;
2628+typedef SharedPtr<BaseChannelCaptchaAuthenticationInterface> BaseChannelCaptchaAuthenticationInterfacePtr;
2629+typedef SharedPtr<BaseChannelGroupInterface> BaseChannelGroupInterfacePtr;
2630+typedef SharedPtr<BaseChannelHoldInterface> BaseChannelHoldInterfacePtr;
2631+typedef SharedPtr<DBusService> DBusServicePtr;
2632+
2633+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
2634+
2635+} // Tp
2636+
2637+#endif
2638
2639=== added file '.pc/06-conference_interfaces.patch/TelepathyQt/svc-channel.xml'
2640--- .pc/06-conference_interfaces.patch/TelepathyQt/svc-channel.xml 1970-01-01 00:00:00 +0000
2641+++ .pc/06-conference_interfaces.patch/TelepathyQt/svc-channel.xml 2014-02-05 14:09:56 +0000
2642@@ -0,0 +1,38 @@
2643+<tp:spec
2644+ xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
2645+ xmlns:xi="http://www.w3.org/2001/XInclude">
2646+
2647+<tp:title>Channel interfaces</tp:title>
2648+
2649+<xi:include href="../spec/Channel.xml"/>
2650+
2651+<xi:include href="../spec/Channel_Type_Call.xml"/>
2652+<xi:include href="../spec/Channel_Type_Contact_Search.xml"/>
2653+<xi:include href="../spec/Channel_Type_DBus_Tube.xml"/>
2654+<xi:include href="../spec/Channel_Type_File_Transfer.xml"/>
2655+<xi:include href="../spec/Channel_Type_Room_List.xml"/>
2656+<xi:include href="../spec/Channel_Type_Server_Authentication.xml"/>
2657+<xi:include href="../spec/Channel_Type_Server_TLS_Connection.xml"/>
2658+<xi:include href="../spec/Channel_Type_Streamed_Media.xml"/>
2659+<xi:include href="../spec/Channel_Type_Stream_Tube.xml"/>
2660+<xi:include href="../spec/Channel_Type_Text.xml"/>
2661+
2662+<xi:include href="../spec/Channel_Interface_Anonymity.xml"/>
2663+<xi:include href="../spec/Channel_Interface_Captcha_Authentication.xml"/>
2664+<xi:include href="../spec/Channel_Interface_Call_State.xml"/>
2665+<xi:include href="../spec/Channel_Interface_Chat_State.xml"/>
2666+<xi:include href="../spec/Channel_Interface_Conference.xml"/>
2667+<xi:include href="../spec/Channel_Interface_Destroyable.xml"/>
2668+<xi:include href="../spec/Channel_Interface_DTMF.xml"/>
2669+<xi:include href="../spec/Channel_Interface_File_Transfer_Metadata.xml"/>
2670+<xi:include href="../spec/Channel_Interface_Group.xml"/>
2671+<xi:include href="../spec/Channel_Interface_Hold.xml"/>
2672+<xi:include href="../spec/Channel_Interface_Media_Signalling.xml"/>
2673+<xi:include href="../spec/Channel_Interface_Messages.xml"/>
2674+<xi:include href="../spec/Channel_Interface_Password.xml"/>
2675+<xi:include href="../spec/Channel_Interface_SASL_Authentication.xml"/>
2676+<xi:include href="../spec/Channel_Interface_Securable.xml"/>
2677+<xi:include href="../spec/Channel_Interface_Service_Point.xml"/>
2678+<xi:include href="../spec/Channel_Interface_SMS.xml"/>
2679+
2680+</tp:spec>
2681
2682=== added directory '.pc/07-fix_createChannel.patch'
2683=== added file '.pc/07-fix_createChannel.patch/.timestamp'
2684=== added directory '.pc/07-fix_createChannel.patch/TelepathyQt'
2685=== added file '.pc/07-fix_createChannel.patch/TelepathyQt/base-connection.cpp'
2686--- .pc/07-fix_createChannel.patch/TelepathyQt/base-connection.cpp 1970-01-01 00:00:00 +0000
2687+++ .pc/07-fix_createChannel.patch/TelepathyQt/base-connection.cpp 2014-02-05 14:09:56 +0000
2688@@ -0,0 +1,1356 @@
2689+/**
2690+ * This file is part of TelepathyQt
2691+ *
2692+ * @copyright Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
2693+ * @copyright Copyright (C) 2012 Nokia Corporation
2694+ * @license LGPL 2.1
2695+ *
2696+ * This library is free software; you can redistribute it and/or
2697+ * modify it under the terms of the GNU Lesser General Public
2698+ * License as published by the Free Software Foundation; either
2699+ * version 2.1 of the License, or (at your option) any later version.
2700+ *
2701+ * This library is distributed in the hope that it will be useful,
2702+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2703+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2704+ * Lesser General Public License for more details.
2705+ *
2706+ * You should have received a copy of the GNU Lesser General Public
2707+ * License along with this library; if not, write to the Free Software
2708+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2709+ */
2710+
2711+#include <TelepathyQt/BaseConnection>
2712+#include "TelepathyQt/base-connection-internal.h"
2713+
2714+#include "TelepathyQt/_gen/base-connection.moc.hpp"
2715+#include "TelepathyQt/_gen/base-connection-internal.moc.hpp"
2716+
2717+#include "TelepathyQt/debug-internal.h"
2718+
2719+#include <TelepathyQt/BaseChannel>
2720+#include <TelepathyQt/Constants>
2721+#include <TelepathyQt/DBusObject>
2722+#include <TelepathyQt/Utils>
2723+#include <TelepathyQt/AbstractProtocolInterface>
2724+#include <QString>
2725+#include <QVariantMap>
2726+
2727+namespace Tp
2728+{
2729+
2730+struct TP_QT_NO_EXPORT BaseConnection::Private {
2731+ Private(BaseConnection *parent, const QDBusConnection &dbusConnection,
2732+ const QString &cmName, const QString &protocolName,
2733+ const QVariantMap &parameters)
2734+ : parent(parent),
2735+ cmName(cmName),
2736+ protocolName(protocolName),
2737+ parameters(parameters),
2738+ status(Tp::ConnectionStatusDisconnected),
2739+ selfHandle(0),
2740+ adaptee(new BaseConnection::Adaptee(dbusConnection, parent)) {
2741+ }
2742+
2743+ BaseConnection *parent;
2744+ QString cmName;
2745+ QString protocolName;
2746+ QVariantMap parameters;
2747+ uint status;
2748+ QHash<QString, AbstractConnectionInterfacePtr> interfaces;
2749+ QSet<BaseChannelPtr> channels;
2750+ CreateChannelCallback createChannelCB;
2751+ RequestHandlesCallback requestHandlesCB;
2752+ ConnectCallback connectCB;
2753+ InspectHandlesCallback inspectHandlesCB;
2754+ uint selfHandle;
2755+ BaseConnection::Adaptee *adaptee;
2756+};
2757+
2758+BaseConnection::Adaptee::Adaptee(const QDBusConnection &dbusConnection,
2759+ BaseConnection *connection)
2760+ : QObject(connection),
2761+ mConnection(connection)
2762+{
2763+ mAdaptor = new Service::ConnectionAdaptor(dbusConnection, this, connection->dbusObject());
2764+}
2765+
2766+BaseConnection::Adaptee::~Adaptee()
2767+{
2768+}
2769+
2770+void BaseConnection::Adaptee::disconnect(const Tp::Service::ConnectionAdaptor::DisconnectContextPtr &context)
2771+{
2772+ debug() << "BaseConnection::Adaptee::disconnect";
2773+ /* This will remove the connection from the connection manager
2774+ * and destroy this object. */
2775+ emit mConnection->disconnected();
2776+ context->setFinished();
2777+}
2778+
2779+void BaseConnection::Adaptee::getSelfHandle(const Tp::Service::ConnectionAdaptor::GetSelfHandleContextPtr &context)
2780+{
2781+ context->setFinished(mConnection->mPriv->selfHandle);
2782+}
2783+
2784+uint BaseConnection::Adaptee::selfHandle() const
2785+{
2786+ return mConnection->mPriv->selfHandle;
2787+}
2788+
2789+void BaseConnection::Adaptee::getStatus(const Tp::Service::ConnectionAdaptor::GetStatusContextPtr &context)
2790+{
2791+ context->setFinished(mConnection->status());
2792+}
2793+
2794+void BaseConnection::Adaptee::connect(const Tp::Service::ConnectionAdaptor::ConnectContextPtr &context)
2795+{
2796+ if (!mConnection->mPriv->connectCB.isValid()) {
2797+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
2798+ return;
2799+ }
2800+ DBusError error;
2801+ mConnection->mPriv->connectCB(&error);
2802+ if (error.isValid()) {
2803+ context->setFinishedWithError(error.name(), error.message());
2804+ return;
2805+ }
2806+ context->setFinished();
2807+}
2808+
2809+void BaseConnection::Adaptee::inspectHandles(uint handleType,
2810+ const Tp::UIntList &handles,
2811+ const Tp::Service::ConnectionAdaptor::InspectHandlesContextPtr &context)
2812+{
2813+ if (!mConnection->mPriv->inspectHandlesCB.isValid()) {
2814+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
2815+ return;
2816+ }
2817+ DBusError error;
2818+ QStringList ret = mConnection->mPriv->inspectHandlesCB(handleType, handles, &error);
2819+ if (error.isValid()) {
2820+ context->setFinishedWithError(error.name(), error.message());
2821+ return;
2822+ }
2823+ context->setFinished(ret);
2824+}
2825+QStringList BaseConnection::Adaptee::interfaces() const
2826+{
2827+ QStringList ret;
2828+ foreach(const AbstractConnectionInterfacePtr & iface, mConnection->interfaces()) {
2829+ ret << iface->interfaceName();
2830+ }
2831+ return ret;
2832+}
2833+
2834+void BaseConnection::Adaptee::requestChannel(const QString &type, uint handleType, uint handle, bool suppressHandler,
2835+ const Tp::Service::ConnectionAdaptor::RequestChannelContextPtr &context)
2836+{
2837+ debug() << "BaseConnection::Adaptee::requestChannel (deprecated)";
2838+ DBusError error;
2839+ bool yours;
2840+ BaseChannelPtr channel = mConnection->ensureChannel(type,
2841+ handleType,
2842+ handle,
2843+ yours,
2844+ selfHandle(),
2845+ suppressHandler,
2846+ &error);
2847+ if (error.isValid() || !channel) {
2848+ context->setFinishedWithError(error.name(), error.message());
2849+ return;
2850+ }
2851+ context->setFinished(QDBusObjectPath(channel->objectPath()));
2852+}
2853+
2854+void BaseConnection::Adaptee::requestHandles(uint handleType, const QStringList &identifiers,
2855+ const Tp::Service::ConnectionAdaptor::RequestHandlesContextPtr &context)
2856+{
2857+ DBusError error;
2858+ Tp::UIntList handles = mConnection->requestHandles(handleType, identifiers, &error);
2859+ if (error.isValid()) {
2860+ context->setFinishedWithError(error.name(), error.message());
2861+ return;
2862+ }
2863+ context->setFinished(handles);
2864+}
2865+
2866+/**
2867+ * \class BaseConnection
2868+ * \ingroup serviceconn
2869+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
2870+ *
2871+ * \brief Base class for Connection implementations.
2872+ */
2873+
2874+/**
2875+ * Construct a BaseConnection.
2876+ *
2877+ * \param dbusConnection The D-Bus connection that will be used by this object.
2878+ * \param cmName The name of the connection manager associated with this connection.
2879+ * \param protocolName The name of the protocol associated with this connection.
2880+ * \param parameters The parameters of this connection.
2881+ */
2882+BaseConnection::BaseConnection(const QDBusConnection &dbusConnection,
2883+ const QString &cmName, const QString &protocolName,
2884+ const QVariantMap &parameters)
2885+ : DBusService(dbusConnection),
2886+ mPriv(new Private(this, dbusConnection, cmName, protocolName, parameters))
2887+{
2888+}
2889+
2890+/**
2891+ * Class destructor.
2892+ */
2893+BaseConnection::~BaseConnection()
2894+{
2895+ delete mPriv;
2896+}
2897+
2898+/**
2899+ * Return the name of the connection manager associated with this connection.
2900+ *
2901+ * \return The name of the connection manager associated with this connection.
2902+ */
2903+QString BaseConnection::cmName() const
2904+{
2905+ return mPriv->cmName;
2906+}
2907+
2908+/**
2909+ * Return the name of the protocol associated with this connection.
2910+ *
2911+ * \return The name of the protocol associated with this connection.
2912+ */
2913+QString BaseConnection::protocolName() const
2914+{
2915+ return mPriv->protocolName;
2916+}
2917+
2918+/**
2919+ * Return the parameters of this connection.
2920+ *
2921+ * \return The parameters of this connection.
2922+ */
2923+QVariantMap BaseConnection::parameters() const
2924+{
2925+ return mPriv->parameters;
2926+}
2927+
2928+/**
2929+ * Return the immutable properties of this connection object.
2930+ *
2931+ * Immutable properties cannot change after the object has been registered
2932+ * on the bus with registerObject().
2933+ *
2934+ * \return The immutable properties of this connection object.
2935+ */
2936+QVariantMap BaseConnection::immutableProperties() const
2937+{
2938+ // FIXME
2939+ return QVariantMap();
2940+}
2941+
2942+/**
2943+ * Return a unique name for this connection.
2944+ *
2945+ * \return A unique name for this connection.
2946+ */
2947+QString BaseConnection::uniqueName() const
2948+{
2949+ return QString(QLatin1String("_%1")).arg((quintptr) this, 0, 16);
2950+}
2951+
2952+uint BaseConnection::status() const
2953+{
2954+ debug() << "BaseConnection::status = " << mPriv->status << " " << this;
2955+ return mPriv->status;
2956+}
2957+
2958+void BaseConnection::setStatus(uint newStatus, uint reason)
2959+{
2960+ debug() << "BaseConnection::setStatus " << newStatus << " " << reason << " " << this;
2961+ bool changed = (newStatus != mPriv->status);
2962+ mPriv->status = newStatus;
2963+ if (changed)
2964+ emit mPriv->adaptee->statusChanged(newStatus, reason);
2965+}
2966+
2967+void BaseConnection::setCreateChannelCallback(const CreateChannelCallback &cb)
2968+{
2969+ mPriv->createChannelCB = cb;
2970+}
2971+
2972+Tp::BaseChannelPtr BaseConnection::createChannel(const QString &channelType,
2973+ uint targetHandleType,
2974+ uint targetHandle,
2975+ uint initiatorHandle,
2976+ bool suppressHandler,
2977+ DBusError *error)
2978+{
2979+ if (!mPriv->createChannelCB.isValid()) {
2980+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
2981+ return BaseChannelPtr();
2982+ }
2983+ if (!mPriv->inspectHandlesCB.isValid()) {
2984+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
2985+ return BaseChannelPtr();
2986+ }
2987+
2988+ BaseChannelPtr channel = mPriv->createChannelCB(channelType, targetHandleType, targetHandle, error);
2989+ if (error->isValid())
2990+ return BaseChannelPtr();
2991+
2992+ QString targetID;
2993+ if (targetHandle != 0) {
2994+ QStringList list = mPriv->inspectHandlesCB(targetHandleType, UIntList() << targetHandle, error);
2995+ if (error->isValid()) {
2996+ debug() << "BaseConnection::createChannel: could not resolve handle " << targetHandle;
2997+ return BaseChannelPtr();
2998+ } else {
2999+ debug() << "BaseConnection::createChannel: found targetID " << *list.begin();
3000+ targetID = *list.begin();
3001+ }
3002+ }
3003+ QString initiatorID;
3004+ if (initiatorHandle != 0) {
3005+ QStringList list = mPriv->inspectHandlesCB(HandleTypeContact, UIntList() << initiatorHandle, error);
3006+ if (error->isValid()) {
3007+ debug() << "BaseConnection::createChannel: could not resolve handle " << initiatorHandle;
3008+ return BaseChannelPtr();
3009+ } else {
3010+ debug() << "BaseConnection::createChannel: found initiatorID " << *list.begin();
3011+ initiatorID = *list.begin();
3012+ }
3013+ }
3014+ channel->setInitiatorHandle(initiatorHandle);
3015+ channel->setInitiatorID(initiatorID);
3016+ channel->setTargetID(targetID);
3017+ channel->setRequested(initiatorHandle == mPriv->selfHandle);
3018+
3019+ channel->registerObject(error);
3020+ if (error->isValid())
3021+ return BaseChannelPtr();
3022+
3023+ mPriv->channels.insert(channel);
3024+
3025+ BaseConnectionRequestsInterfacePtr reqIface =
3026+ BaseConnectionRequestsInterfacePtr::dynamicCast(interface(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS));
3027+
3028+ if (!reqIface.isNull())
3029+ //emit after return
3030+ QMetaObject::invokeMethod(reqIface.data(), "newChannels",
3031+ Qt::QueuedConnection,
3032+ Q_ARG(Tp::ChannelDetailsList, ChannelDetailsList() << channel->details()));
3033+
3034+
3035+ //emit after return
3036+ QMetaObject::invokeMethod(mPriv->adaptee, "newChannel",
3037+ Qt::QueuedConnection,
3038+ Q_ARG(QDBusObjectPath, QDBusObjectPath(channel->objectPath())),
3039+ Q_ARG(QString, channel->channelType()),
3040+ Q_ARG(uint, channel->targetHandleType()),
3041+ Q_ARG(uint, channel->targetHandle()),
3042+ Q_ARG(bool, suppressHandler));
3043+
3044+ QObject::connect(channel.data(),
3045+ SIGNAL(closed()),
3046+ SLOT(removeChannel()));
3047+
3048+ return channel;
3049+}
3050+
3051+void BaseConnection::setRequestHandlesCallback(const RequestHandlesCallback &cb)
3052+{
3053+ mPriv->requestHandlesCB = cb;
3054+}
3055+
3056+UIntList BaseConnection::requestHandles(uint handleType, const QStringList &identifiers, DBusError* error)
3057+{
3058+ if (!mPriv->requestHandlesCB.isValid()) {
3059+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
3060+ return UIntList();
3061+ }
3062+ return mPriv->requestHandlesCB(handleType, identifiers, error);
3063+}
3064+
3065+Tp::ChannelInfoList BaseConnection::channelsInfo()
3066+{
3067+ qDebug() << "BaseConnection::channelsInfo:";
3068+ Tp::ChannelInfoList list;
3069+ foreach(const BaseChannelPtr & c, mPriv->channels) {
3070+ Tp::ChannelInfo info;
3071+ info.channel = QDBusObjectPath(c->objectPath());
3072+ info.channelType = c->channelType();
3073+ info.handle = c->targetHandle();
3074+ info.handleType = c->targetHandleType();
3075+ qDebug() << "BaseConnection::channelsInfo " << info.channel.path();
3076+ list << info;
3077+ }
3078+ return list;
3079+}
3080+
3081+Tp::ChannelDetailsList BaseConnection::channelsDetails()
3082+{
3083+ Tp::ChannelDetailsList list;
3084+ foreach(const BaseChannelPtr & c, mPriv->channels)
3085+ list << c->details();
3086+ return list;
3087+}
3088+
3089+BaseChannelPtr BaseConnection::ensureChannel(const QString &channelType, uint targetHandleType,
3090+ uint targetHandle, bool &yours, uint initiatorHandle,
3091+ bool suppressHandler,
3092+ DBusError* error)
3093+{
3094+ foreach(BaseChannelPtr channel, mPriv->channels) {
3095+ if (channel->channelType() == channelType
3096+ && channel->targetHandleType() == targetHandleType
3097+ && channel->targetHandle() == targetHandle) {
3098+ yours = false;
3099+ return channel;
3100+ }
3101+ }
3102+ yours = true;
3103+ return createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, error);
3104+}
3105+
3106+void BaseConnection::removeChannel()
3107+{
3108+ BaseChannelPtr channel = BaseChannelPtr(
3109+ qobject_cast<BaseChannel*>(sender()));
3110+ Q_ASSERT(channel);
3111+ Q_ASSERT(mPriv->channels.contains(channel));
3112+ mPriv->channels.remove(channel);
3113+}
3114+
3115+/**
3116+ * Return a list of interfaces that have been plugged into this Protocol
3117+ * D-Bus object with plugInterface().
3118+ *
3119+ * This property is immutable and cannot change after this Protocol
3120+ * object has been registered on the bus with registerObject().
3121+ *
3122+ * \return A list containing all the Protocol interface implementation objects.
3123+ * \sa plugInterface(), interface()
3124+ */
3125+QList<AbstractConnectionInterfacePtr> BaseConnection::interfaces() const
3126+{
3127+ return mPriv->interfaces.values();
3128+}
3129+
3130+/**
3131+ * Return a pointer to the interface with the given name.
3132+ *
3133+ * \param interfaceName The D-Bus name of the interface,
3134+ * ex. TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING.
3135+ * \return A pointer to the AbstractConnectionInterface object that implements
3136+ * the D-Bus interface with the given name, or a null pointer if such an interface
3137+ * has not been plugged into this object.
3138+ * \sa plugInterface(), interfaces()
3139+ */
3140+AbstractConnectionInterfacePtr BaseConnection::interface(const QString &interfaceName) const
3141+{
3142+ return mPriv->interfaces.value(interfaceName);
3143+}
3144+
3145+/**
3146+ * Plug a new interface into this Connection D-Bus object.
3147+ *
3148+ * This property is immutable and cannot change after this Protocol
3149+ * object has been registered on the bus with registerObject().
3150+ *
3151+ * \param interface An AbstractConnectionInterface instance that implements
3152+ * the interface that is to be plugged.
3153+ * \return \c true on success or \c false otherwise
3154+ * \sa interfaces(), interface()
3155+ */
3156+bool BaseConnection::plugInterface(const AbstractConnectionInterfacePtr &interface)
3157+{
3158+ if (isRegistered()) {
3159+ warning() << "Unable to plug protocol interface " << interface->interfaceName() <<
3160+ "- protocol already registered";
3161+ return false;
3162+ }
3163+
3164+ if (interface->isRegistered()) {
3165+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
3166+ "- interface already registered";
3167+ return false;
3168+ }
3169+
3170+ if (mPriv->interfaces.contains(interface->interfaceName())) {
3171+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
3172+ "- another interface with same name already plugged";
3173+ return false;
3174+ }
3175+
3176+ debug() << "Interface" << interface->interfaceName() << "plugged";
3177+ mPriv->interfaces.insert(interface->interfaceName(), interface);
3178+ return true;
3179+}
3180+
3181+/**
3182+ * Register this connection object on the bus.
3183+ *
3184+ * If \a error is passed, any D-Bus error that may occur will
3185+ * be stored there.
3186+ *
3187+ * \param error A pointer to an empty DBusError where any
3188+ * possible D-Bus error will be stored.
3189+ * \return \c true on success and \c false if there was an error
3190+ * or this connection object is already registered.
3191+ * \sa isRegistered()
3192+ */
3193+bool BaseConnection::registerObject(DBusError *error)
3194+{
3195+ if (isRegistered()) {
3196+ return true;
3197+ }
3198+
3199+ if (!checkValidProtocolName(mPriv->protocolName)) {
3200+ if (error) {
3201+ error->set(TP_QT_ERROR_INVALID_ARGUMENT,
3202+ mPriv->protocolName + QLatin1String("is not a valid protocol name"));
3203+ }
3204+ debug() << "Unable to register connection - invalid protocol name";
3205+ return false;
3206+ }
3207+
3208+ QString escapedProtocolName = mPriv->protocolName;
3209+ escapedProtocolName.replace(QLatin1Char('-'), QLatin1Char('_'));
3210+ QString name = uniqueName();
3211+ debug() << "cmName: " << mPriv->cmName << " escapedProtocolName: " << escapedProtocolName << " name:" << name;
3212+ QString busName = QString(QLatin1String("%1%2.%3.%4"))
3213+ .arg(TP_QT_CONNECTION_BUS_NAME_BASE, mPriv->cmName, escapedProtocolName, name);
3214+ QString objectPath = QString(QLatin1String("%1%2/%3/%4"))
3215+ .arg(TP_QT_CONNECTION_OBJECT_PATH_BASE, mPriv->cmName, escapedProtocolName, name);
3216+ debug() << "busName: " << busName << " objectName: " << objectPath;
3217+ DBusError _error;
3218+
3219+ debug() << "Connection: registering interfaces at " << dbusObject();
3220+ foreach(const AbstractConnectionInterfacePtr & iface, mPriv->interfaces) {
3221+ if (!iface->registerInterface(dbusObject())) {
3222+ // lets not fail if an optional interface fails registering, lets warn only
3223+ warning() << "Unable to register interface" << iface->interfaceName();
3224+ }
3225+ }
3226+
3227+ bool ret = registerObject(busName, objectPath, &_error);
3228+ if (!ret && error) {
3229+ error->set(_error.name(), _error.message());
3230+ }
3231+ return ret;
3232+}
3233+
3234+/**
3235+ * Reimplemented from DBusService.
3236+ */
3237+bool BaseConnection::registerObject(const QString &busName,
3238+ const QString &objectPath, DBusError *error)
3239+{
3240+ return DBusService::registerObject(busName, objectPath, error);
3241+}
3242+
3243+void BaseConnection::setSelfHandle(uint selfHandle)
3244+{
3245+ mPriv->selfHandle = selfHandle;
3246+}
3247+
3248+uint BaseConnection::selfHandle() const
3249+{
3250+ return mPriv->selfHandle;
3251+}
3252+
3253+void BaseConnection::setConnectCallback(const ConnectCallback &cb)
3254+{
3255+ mPriv->connectCB = cb;
3256+}
3257+
3258+void BaseConnection::setInspectHandlesCallback(const InspectHandlesCallback &cb)
3259+{
3260+ mPriv->inspectHandlesCB = cb;
3261+}
3262+
3263+/**
3264+ * \fn void BaseConnection::disconnected()
3265+ *
3266+ * Emitted when this connection has been disconnected.
3267+ */
3268+
3269+/**
3270+ * \class AbstractConnectionInterface
3271+ * \ingroup servicecm
3272+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
3273+ *
3274+ * \brief Base class for all the Connection object interface implementations.
3275+ */
3276+
3277+AbstractConnectionInterface::AbstractConnectionInterface(const QString &interfaceName)
3278+ : AbstractDBusServiceInterface(interfaceName)
3279+{
3280+}
3281+
3282+AbstractConnectionInterface::~AbstractConnectionInterface()
3283+{
3284+}
3285+
3286+// Conn.I.Requests
3287+BaseConnectionRequestsInterface::Adaptee::Adaptee(BaseConnectionRequestsInterface *interface)
3288+ : QObject(interface),
3289+ mInterface(interface)
3290+{
3291+}
3292+
3293+BaseConnectionRequestsInterface::Adaptee::~Adaptee()
3294+{
3295+}
3296+
3297+void BaseConnectionRequestsInterface::Adaptee::ensureChannel(const QVariantMap &request,
3298+ const Tp::Service::ConnectionInterfaceRequestsAdaptor::EnsureChannelContextPtr &context)
3299+{
3300+ DBusError error;
3301+ bool yours;
3302+ QDBusObjectPath channel;
3303+ QVariantMap details;
3304+
3305+ mInterface->ensureChannel(request, yours, channel, details, &error);
3306+ if (error.isValid()) {
3307+ context->setFinishedWithError(error.name(), error.message());
3308+ return;
3309+ }
3310+ context->setFinished(yours, channel, details);
3311+}
3312+
3313+void BaseConnectionRequestsInterface::Adaptee::createChannel(const QVariantMap &request,
3314+ const Tp::Service::ConnectionInterfaceRequestsAdaptor::CreateChannelContextPtr &context)
3315+{
3316+ DBusError error;
3317+ QDBusObjectPath channel;
3318+ QVariantMap details;
3319+
3320+ mInterface->createChannel(request, channel, details, &error);
3321+ if (error.isValid()) {
3322+ context->setFinishedWithError(error.name(), error.message());
3323+ return;
3324+ }
3325+ context->setFinished(channel, details);
3326+}
3327+
3328+struct TP_QT_NO_EXPORT BaseConnectionRequestsInterface::Private {
3329+ Private(BaseConnectionRequestsInterface *parent, BaseConnection *connection_)
3330+ : connection(connection_), adaptee(new BaseConnectionRequestsInterface::Adaptee(parent)) {
3331+ }
3332+ BaseConnection *connection;
3333+ BaseConnectionRequestsInterface::Adaptee *adaptee;
3334+};
3335+
3336+/**
3337+ * \class BaseConnectionRequestsInterface
3338+ * \ingroup servicecm
3339+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
3340+ *
3341+ * \brief Base class for implementations of Connection.Interface.Requests
3342+ */
3343+
3344+/**
3345+ * Class constructor.
3346+ */
3347+BaseConnectionRequestsInterface::BaseConnectionRequestsInterface(BaseConnection *connection)
3348+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS),
3349+ mPriv(new Private(this, connection))
3350+{
3351+}
3352+
3353+/**
3354+ * Class destructor.
3355+ */
3356+BaseConnectionRequestsInterface::~BaseConnectionRequestsInterface()
3357+{
3358+ delete mPriv;
3359+}
3360+
3361+/**
3362+ * Return the immutable properties of this interface.
3363+ *
3364+ * Immutable properties cannot change after the interface has been registered
3365+ * on a service on the bus with registerInterface().
3366+ *
3367+ * \return The immutable properties of this interface.
3368+ */
3369+QVariantMap BaseConnectionRequestsInterface::immutableProperties() const
3370+{
3371+ QVariantMap map;
3372+ map.insert(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS + QLatin1String(".RequestableChannelClasses"),
3373+ QVariant::fromValue(mPriv->adaptee->requestableChannelClasses()));
3374+ return map;
3375+}
3376+
3377+void BaseConnectionRequestsInterface::createAdaptor()
3378+{
3379+ (void) new Service::ConnectionInterfaceRequestsAdaptor(dbusObject()->dbusConnection(),
3380+ mPriv->adaptee, dbusObject());
3381+}
3382+
3383+Tp::ChannelDetailsList BaseConnectionRequestsInterface::Adaptee::channels() const
3384+{
3385+ return mInterface->mPriv->connection->channelsDetails();
3386+}
3387+
3388+void BaseConnectionRequestsInterface::newChannels(const Tp::ChannelDetailsList &channels)
3389+{
3390+ mPriv->adaptee->newChannels(channels);
3391+}
3392+
3393+void BaseConnectionRequestsInterface::ensureChannel(const QVariantMap &request, bool &yours,
3394+ QDBusObjectPath &objectPath, QVariantMap &details, DBusError *error)
3395+{
3396+ if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
3397+ || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"))
3398+ || (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"))
3399+ && !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")))) {
3400+ error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Missing parameters"));
3401+ return;
3402+ }
3403+
3404+ QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
3405+ uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
3406+ uint targetHandle;
3407+ if (request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")))
3408+ targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
3409+ else {
3410+ QString targetID = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")].toString();
3411+ Tp::UIntList list = mPriv->connection->requestHandles(targetHandleType, QStringList() << targetID, error);
3412+ if (error->isValid()) {
3413+ warning() << "BBaseConnectionRequestsInterface::ensureChannel: could not resolve ID " << targetID;
3414+ return;
3415+ }
3416+ targetHandle = *list.begin();
3417+ }
3418+
3419+ bool suppressHandler = true;
3420+ BaseChannelPtr channel = mPriv->connection->ensureChannel(channelType, targetHandleType,
3421+ targetHandle, yours,
3422+ mPriv->connection->selfHandle(),
3423+ suppressHandler,
3424+ error);
3425+ if (error->isValid())
3426+ return;
3427+
3428+ objectPath = QDBusObjectPath(channel->objectPath());
3429+ details = channel->details().properties;
3430+}
3431+
3432+void BaseConnectionRequestsInterface::createChannel(const QVariantMap &request,
3433+ QDBusObjectPath &objectPath,
3434+ QVariantMap &details, DBusError *error)
3435+{
3436+ if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
3437+ || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
3438+ || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))) {
3439+ error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Missing parameters"));
3440+ return;
3441+ }
3442+
3443+ QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
3444+ uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
3445+ uint targetHandle;
3446+ if (request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")))
3447+ targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
3448+ else {
3449+ QString targetID = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")].toString();
3450+ Tp::UIntList list = mPriv->connection->requestHandles(targetHandleType, QStringList() << targetID, error);
3451+ if (error->isValid()) {
3452+ warning() << "BBaseConnectionRequestsInterface::ensureChannel: could not resolve ID " << targetID;
3453+ return;
3454+ }
3455+ targetHandle = *list.begin();
3456+ }
3457+
3458+ bool suppressHandler = true;
3459+ BaseChannelPtr channel = mPriv->connection->createChannel(channelType, targetHandleType,
3460+ targetHandle,
3461+ mPriv->connection->selfHandle(),
3462+ suppressHandler,
3463+ error);
3464+ if (error->isValid())
3465+ return;
3466+
3467+ objectPath = QDBusObjectPath(channel->objectPath());
3468+ details = channel->details().properties;
3469+}
3470+
3471+
3472+// Conn.I.Contacts
3473+BaseConnectionContactsInterface::Adaptee::Adaptee(BaseConnectionContactsInterface *interface)
3474+ : QObject(interface),
3475+ mInterface(interface)
3476+{
3477+}
3478+
3479+BaseConnectionContactsInterface::Adaptee::~Adaptee()
3480+{
3481+}
3482+
3483+void BaseConnectionContactsInterface::Adaptee::getContactAttributes(const Tp::UIntList &handles,
3484+ const QStringList &interfaces, bool /*hold*/,
3485+ const Tp::Service::ConnectionInterfaceContactsAdaptor::GetContactAttributesContextPtr &context)
3486+{
3487+ DBusError error;
3488+ ContactAttributesMap contactAttributes = mInterface->getContactAttributes(handles, interfaces, &error);
3489+ if (error.isValid()) {
3490+ context->setFinishedWithError(error.name(), error.message());
3491+ return;
3492+ }
3493+ context->setFinished(contactAttributes);
3494+}
3495+
3496+struct TP_QT_NO_EXPORT BaseConnectionContactsInterface::Private {
3497+ Private(BaseConnectionContactsInterface *parent)
3498+ : adaptee(new BaseConnectionContactsInterface::Adaptee(parent)) {
3499+ }
3500+ QStringList contactAttributeInterfaces;
3501+ GetContactAttributesCallback getContactAttributesCallback;
3502+ BaseConnectionContactsInterface::Adaptee *adaptee;
3503+};
3504+
3505+QStringList BaseConnectionContactsInterface::Adaptee::contactAttributeInterfaces() const
3506+{
3507+ return mInterface->mPriv->contactAttributeInterfaces;
3508+}
3509+
3510+/**
3511+ * \class BaseConnectionContactsInterface
3512+ * \ingroup servicecm
3513+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
3514+ *
3515+ * \brief Base class for implementations of Connection.Interface.Contacts
3516+ */
3517+
3518+/**
3519+ * Class constructor.
3520+ */
3521+BaseConnectionContactsInterface::BaseConnectionContactsInterface()
3522+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACTS),
3523+ mPriv(new Private(this))
3524+{
3525+}
3526+
3527+/**
3528+ * Class destructor.
3529+ */
3530+BaseConnectionContactsInterface::~BaseConnectionContactsInterface()
3531+{
3532+ delete mPriv;
3533+}
3534+
3535+/**
3536+ * Return the immutable properties of this<interface.
3537+ *
3538+ * Immutable properties cannot change after the interface has been registered
3539+ * on a service on the bus with registerInterface().
3540+ *
3541+ * \return The immutable properties of this interface.
3542+ */
3543+QVariantMap BaseConnectionContactsInterface::immutableProperties() const
3544+{
3545+ QVariantMap map;
3546+ map.insert(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACTS + QLatin1String(".ContactAttributeInterfaces"),
3547+ QVariant::fromValue(mPriv->adaptee->contactAttributeInterfaces()));
3548+ return map;
3549+}
3550+
3551+void BaseConnectionContactsInterface::createAdaptor()
3552+{
3553+ (void) new Service::ConnectionInterfaceContactsAdaptor(dbusObject()->dbusConnection(),
3554+ mPriv->adaptee, dbusObject());
3555+}
3556+
3557+void BaseConnectionContactsInterface::setContactAttributeInterfaces(const QStringList &contactAttributeInterfaces)
3558+{
3559+ mPriv->contactAttributeInterfaces = contactAttributeInterfaces;
3560+}
3561+
3562+void BaseConnectionContactsInterface::setGetContactAttributesCallback(const GetContactAttributesCallback &cb)
3563+{
3564+ mPriv->getContactAttributesCallback = cb;
3565+}
3566+
3567+ContactAttributesMap BaseConnectionContactsInterface::getContactAttributes(const Tp::UIntList &handles,
3568+ const QStringList &interfaces,
3569+ DBusError *error)
3570+{
3571+ if (!mPriv->getContactAttributesCallback.isValid()) {
3572+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
3573+ return ContactAttributesMap();
3574+ }
3575+ return mPriv->getContactAttributesCallback(handles, interfaces, error);
3576+}
3577+
3578+// Conn.I.SimplePresence
3579+BaseConnectionSimplePresenceInterface::Adaptee::Adaptee(BaseConnectionSimplePresenceInterface *interface)
3580+ : QObject(interface),
3581+ mInterface(interface)
3582+{
3583+}
3584+
3585+BaseConnectionSimplePresenceInterface::Adaptee::~Adaptee()
3586+{
3587+}
3588+
3589+struct TP_QT_NO_EXPORT BaseConnectionSimplePresenceInterface::Private {
3590+ Private(BaseConnectionSimplePresenceInterface *parent)
3591+ : maxmimumStatusMessageLength(0),
3592+ adaptee(new BaseConnectionSimplePresenceInterface::Adaptee(parent)) {
3593+ }
3594+ SetPresenceCallback setPresenceCB;
3595+ SimpleStatusSpecMap statuses;
3596+ uint maxmimumStatusMessageLength;
3597+ /* The current presences */
3598+ SimpleContactPresences presences;
3599+ BaseConnectionSimplePresenceInterface::Adaptee *adaptee;
3600+};
3601+
3602+/**
3603+ * \class BaseConnectionSimplePresenceInterface
3604+ * \ingroup servicecm
3605+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
3606+ *
3607+ * \brief Base class for implementations of Connection.Interface.SimplePresence
3608+ */
3609+
3610+/**
3611+ * Class constructor.
3612+ */
3613+BaseConnectionSimplePresenceInterface::BaseConnectionSimplePresenceInterface()
3614+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE),
3615+ mPriv(new Private(this))
3616+{
3617+}
3618+
3619+/**
3620+ * Class destructor.
3621+ */
3622+BaseConnectionSimplePresenceInterface::~BaseConnectionSimplePresenceInterface()
3623+{
3624+ delete mPriv;
3625+}
3626+
3627+/**
3628+ * Return the immutable properties of this<interface.
3629+ *
3630+ * Immutable properties cannot change after the interface has been registered
3631+ * on a service on the bus with registerInterface().
3632+ *
3633+ * \return The immutable properties of this interface.
3634+ */
3635+QVariantMap BaseConnectionSimplePresenceInterface::immutableProperties() const
3636+{
3637+ QVariantMap map;
3638+ //FIXME
3639+ return map;
3640+}
3641+
3642+void BaseConnectionSimplePresenceInterface::createAdaptor()
3643+{
3644+ (void) new Service::ConnectionInterfaceSimplePresenceAdaptor(dbusObject()->dbusConnection(),
3645+ mPriv->adaptee, dbusObject());
3646+}
3647+
3648+
3649+
3650+void BaseConnectionSimplePresenceInterface::setPresences(const Tp::SimpleContactPresences &presences)
3651+{
3652+ foreach(uint handle, presences.keys()) {
3653+ mPriv->presences[handle] = presences[handle];
3654+ }
3655+ emit mPriv->adaptee->presencesChanged(presences);
3656+}
3657+
3658+void BaseConnectionSimplePresenceInterface::setSetPresenceCallback(const SetPresenceCallback &cb)
3659+{
3660+ mPriv->setPresenceCB = cb;
3661+}
3662+
3663+void BaseConnectionSimplePresenceInterface::setStatuses(const SimpleStatusSpecMap &statuses)
3664+{
3665+ mPriv->statuses = statuses;
3666+}
3667+
3668+void BaseConnectionSimplePresenceInterface::setMaxmimumStatusMessageLength(uint maxmimumStatusMessageLength)
3669+{
3670+ mPriv->maxmimumStatusMessageLength = maxmimumStatusMessageLength;
3671+}
3672+
3673+
3674+Tp::SimpleStatusSpecMap BaseConnectionSimplePresenceInterface::Adaptee::statuses() const
3675+{
3676+ return mInterface->mPriv->statuses;
3677+}
3678+
3679+int BaseConnectionSimplePresenceInterface::Adaptee::maximumStatusMessageLength() const
3680+{
3681+ return mInterface->mPriv->maxmimumStatusMessageLength;
3682+}
3683+
3684+void BaseConnectionSimplePresenceInterface::Adaptee::setPresence(const QString &status, const QString &statusMessage_,
3685+ const Tp::Service::ConnectionInterfaceSimplePresenceAdaptor::SetPresenceContextPtr &context)
3686+{
3687+ if (!mInterface->mPriv->setPresenceCB.isValid()) {
3688+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
3689+ return;
3690+ }
3691+
3692+ SimpleStatusSpecMap::Iterator i = mInterface->mPriv->statuses.find(status);
3693+ if (i == mInterface->mPriv->statuses.end()) {
3694+ warning() << "BaseConnectionSimplePresenceInterface::Adaptee::setPresence: status is not in statuses";
3695+ context->setFinishedWithError(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("status not in statuses"));
3696+ return;
3697+ }
3698+
3699+ QString statusMessage = statusMessage_;
3700+ if ((uint)statusMessage.length() > mInterface->mPriv->maxmimumStatusMessageLength) {
3701+ debug() << "BaseConnectionSimplePresenceInterface::Adaptee::setPresence: "
3702+ << "truncating status to " << mInterface->mPriv->maxmimumStatusMessageLength;
3703+ statusMessage = statusMessage.left(mInterface->mPriv->maxmimumStatusMessageLength);
3704+ }
3705+
3706+ DBusError error;
3707+ uint selfHandle = mInterface->mPriv->setPresenceCB(status, statusMessage, &error);
3708+ if (error.isValid()) {
3709+ context->setFinishedWithError(error.name(), error.message());
3710+ return;
3711+ }
3712+ Tp::SimplePresence presence;
3713+ presence.type = i->type;
3714+ presence.status = status;
3715+ presence.statusMessage = statusMessage;
3716+ mInterface->mPriv->presences[selfHandle] = presence;
3717+
3718+ /* Emit PresencesChanged */
3719+ SimpleContactPresences presences;
3720+ presences[selfHandle] = presence;
3721+ //emit after return
3722+ QMetaObject::invokeMethod(mInterface->mPriv->adaptee, "presencesChanged",
3723+ Qt::QueuedConnection,
3724+ Q_ARG(Tp::SimpleContactPresences, presences));
3725+ context->setFinished();
3726+}
3727+
3728+void BaseConnectionSimplePresenceInterface::Adaptee::getPresences(const Tp::UIntList &contacts,
3729+ const Tp::Service::ConnectionInterfaceSimplePresenceAdaptor::GetPresencesContextPtr &context)
3730+{
3731+ Tp::SimpleContactPresences presences;
3732+ foreach(uint handle, contacts) {
3733+ SimpleContactPresences::iterator i = mInterface->mPriv->presences.find(handle);
3734+ if (i == mInterface->mPriv->presences.end()) {
3735+ Tp::SimplePresence presence;
3736+ presence.type = ConnectionPresenceTypeUnknown;
3737+ presence.status = QLatin1String("unknown");
3738+ presences[handle] = presence;
3739+ } else
3740+ presences[handle] = *i;
3741+ }
3742+ context->setFinished(presences);
3743+}
3744+
3745+// Conn.I.ContactList
3746+BaseConnectionContactListInterface::Adaptee::Adaptee(BaseConnectionContactListInterface *interface)
3747+ : QObject(interface),
3748+ mInterface(interface)
3749+{
3750+}
3751+
3752+BaseConnectionContactListInterface::Adaptee::~Adaptee()
3753+{
3754+}
3755+
3756+struct TP_QT_NO_EXPORT BaseConnectionContactListInterface::Private {
3757+ Private(BaseConnectionContactListInterface *parent)
3758+ : contactListState(ContactListStateNone),
3759+ contactListPersists(false),
3760+ canChangeContactList(true),
3761+ requestUsesMessage(false),
3762+ downloadAtConnection(false),
3763+ adaptee(new BaseConnectionContactListInterface::Adaptee(parent)) {
3764+ }
3765+ uint contactListState;
3766+ bool contactListPersists;
3767+ bool canChangeContactList;
3768+ bool requestUsesMessage;
3769+ bool downloadAtConnection;
3770+ GetContactListAttributesCallback getContactListAttributesCB;
3771+ RequestSubscriptionCallback requestSubscriptionCB;
3772+ BaseConnectionContactListInterface::Adaptee *adaptee;
3773+};
3774+
3775+/**
3776+ * \class BaseConnectionContactListInterface
3777+ * \ingroup servicecm
3778+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
3779+ *
3780+ * \brief Base class for implementations of Connection.Interface.ContactList
3781+ */
3782+
3783+/**
3784+ * Class constructor.
3785+ */
3786+BaseConnectionContactListInterface::BaseConnectionContactListInterface()
3787+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST),
3788+ mPriv(new Private(this))
3789+{
3790+}
3791+
3792+/**
3793+ * Class destructor.
3794+ */
3795+BaseConnectionContactListInterface::~BaseConnectionContactListInterface()
3796+{
3797+ delete mPriv;
3798+}
3799+
3800+/**
3801+ * Return the immutable properties of this<interface.
3802+ *
3803+ * Immutable properties cannot change after the interface has been registered
3804+ * on a service on the bus with registerInterface().
3805+ *
3806+ * \return The immutable properties of this interface.
3807+ */
3808+QVariantMap BaseConnectionContactListInterface::immutableProperties() const
3809+{
3810+ QVariantMap map;
3811+ return map;
3812+}
3813+
3814+void BaseConnectionContactListInterface::createAdaptor()
3815+{
3816+ (void) new Service::ConnectionInterfaceContactListAdaptor(dbusObject()->dbusConnection(),
3817+ mPriv->adaptee, dbusObject());
3818+}
3819+
3820+void BaseConnectionContactListInterface::setContactListState(uint contactListState)
3821+{
3822+ bool changed = (contactListState != mPriv->contactListState);
3823+ mPriv->contactListState = contactListState;
3824+ if (changed)
3825+ //emit after return
3826+ QMetaObject::invokeMethod(mPriv->adaptee, "contactListStateChanged",
3827+ Qt::QueuedConnection,
3828+ Q_ARG(uint, contactListState));
3829+
3830+}
3831+
3832+void BaseConnectionContactListInterface::setContactListPersists(bool contactListPersists)
3833+{
3834+ mPriv->contactListPersists = contactListPersists;
3835+}
3836+
3837+void BaseConnectionContactListInterface::setCanChangeContactList(bool canChangeContactList)
3838+{
3839+ mPriv->canChangeContactList = canChangeContactList;
3840+}
3841+
3842+void BaseConnectionContactListInterface::setRequestUsesMessage(bool requestUsesMessage)
3843+{
3844+ mPriv->requestUsesMessage = requestUsesMessage;
3845+}
3846+
3847+void BaseConnectionContactListInterface::setDownloadAtConnection(bool downloadAtConnection)
3848+{
3849+ mPriv->downloadAtConnection = downloadAtConnection;
3850+}
3851+
3852+void BaseConnectionContactListInterface::setGetContactListAttributesCallback(const GetContactListAttributesCallback &cb)
3853+{
3854+ mPriv->getContactListAttributesCB = cb;
3855+}
3856+
3857+void BaseConnectionContactListInterface::setRequestSubscriptionCallback(const RequestSubscriptionCallback &cb)
3858+{
3859+ mPriv->requestSubscriptionCB = cb;
3860+}
3861+
3862+void BaseConnectionContactListInterface::contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals)
3863+{
3864+ emit mPriv->adaptee->contactsChangedWithID(changes, identifiers, removals);
3865+}
3866+
3867+uint BaseConnectionContactListInterface::Adaptee::contactListState() const
3868+{
3869+ return mInterface->mPriv->contactListState;
3870+}
3871+
3872+bool BaseConnectionContactListInterface::Adaptee::contactListPersists() const
3873+{
3874+ return mInterface->mPriv->contactListPersists;
3875+}
3876+
3877+bool BaseConnectionContactListInterface::Adaptee::canChangeContactList() const
3878+{
3879+ return mInterface->mPriv->canChangeContactList;
3880+}
3881+
3882+bool BaseConnectionContactListInterface::Adaptee::requestUsesMessage() const
3883+{
3884+ return mInterface->mPriv->requestUsesMessage;
3885+}
3886+
3887+bool BaseConnectionContactListInterface::Adaptee::downloadAtConnection() const
3888+{
3889+ return mInterface->mPriv->downloadAtConnection;
3890+}
3891+
3892+void BaseConnectionContactListInterface::Adaptee::getContactListAttributes(const QStringList &interfaces,
3893+ bool hold, const Tp::Service::ConnectionInterfaceContactListAdaptor::GetContactListAttributesContextPtr &context)
3894+{
3895+ if (!mInterface->mPriv->getContactListAttributesCB.isValid()) {
3896+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
3897+ return;
3898+ }
3899+ DBusError error;
3900+ Tp::ContactAttributesMap contactAttributesMap = mInterface->mPriv->getContactListAttributesCB(interfaces, hold, &error);
3901+ if (error.isValid()) {
3902+ context->setFinishedWithError(error.name(), error.message());
3903+ return;
3904+ }
3905+ context->setFinished(contactAttributesMap);
3906+}
3907+
3908+void BaseConnectionContactListInterface::Adaptee::requestSubscription(const Tp::UIntList &contacts,
3909+ const QString &message, const Tp::Service::ConnectionInterfaceContactListAdaptor::RequestSubscriptionContextPtr &context)
3910+{
3911+ if (!mInterface->mPriv->requestSubscriptionCB.isValid()) {
3912+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
3913+ return;
3914+ }
3915+ DBusError error;
3916+ mInterface->mPriv->requestSubscriptionCB(contacts, message, &error);
3917+ if (error.isValid()) {
3918+ context->setFinishedWithError(error.name(), error.message());
3919+ return;
3920+ }
3921+ context->setFinished();
3922+}
3923+
3924+// Conn.I.Addressing
3925+BaseConnectionAddressingInterface::Adaptee::Adaptee(BaseConnectionAddressingInterface *interface)
3926+ : QObject(interface),
3927+ mInterface(interface)
3928+{
3929+}
3930+
3931+BaseConnectionAddressingInterface::Adaptee::~Adaptee()
3932+{
3933+}
3934+
3935+struct TP_QT_NO_EXPORT BaseConnectionAddressingInterface::Private {
3936+ Private(BaseConnectionAddressingInterface *parent)
3937+ : adaptee(new BaseConnectionAddressingInterface::Adaptee(parent)) {
3938+ }
3939+ GetContactsByVCardFieldCallback getContactsByVCardFieldCB;
3940+ GetContactsByURICallback getContactsByURICB;
3941+ BaseConnectionAddressingInterface::Adaptee *adaptee;
3942+};
3943+
3944+/**
3945+ * \class BaseProtocolPresenceInterface
3946+ * \ingroup servicecm
3947+ * \headerfile TelepathyQt/base-protocol.h <TelepathyQt/BaseProtocolPresenceInterface>
3948+ *
3949+ * \brief Base class for implementations of Protocol.Interface.Presence
3950+ */
3951+
3952+/**
3953+ * Class constructor.
3954+ */
3955+BaseConnectionAddressingInterface::BaseConnectionAddressingInterface()
3956+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING),
3957+ mPriv(new Private(this))
3958+{
3959+}
3960+
3961+/**
3962+ * Class destructor.
3963+ */
3964+BaseConnectionAddressingInterface::~BaseConnectionAddressingInterface()
3965+{
3966+ delete mPriv;
3967+}
3968+
3969+/**
3970+ * Return the immutable properties of this<interface.
3971+ *
3972+ * Immutable properties cannot change after the interface has been registered
3973+ * on a service on the bus with registerInterface().
3974+ *
3975+ * \return The immutable properties of this interface.
3976+ */
3977+QVariantMap BaseConnectionAddressingInterface::immutableProperties() const
3978+{
3979+ QVariantMap map;
3980+ return map;
3981+}
3982+
3983+void BaseConnectionAddressingInterface::createAdaptor()
3984+{
3985+ (void) new Service::ConnectionInterfaceAddressingAdaptor(dbusObject()->dbusConnection(),
3986+ mPriv->adaptee, dbusObject());
3987+}
3988+
3989+void BaseConnectionAddressingInterface::setGetContactsByVCardFieldCallback(const GetContactsByVCardFieldCallback &cb)
3990+{
3991+ mPriv->getContactsByVCardFieldCB = cb;
3992+}
3993+
3994+void BaseConnectionAddressingInterface::setGetContactsByURICallback(const GetContactsByURICallback &cb)
3995+{
3996+ mPriv->getContactsByURICB = cb;
3997+}
3998+
3999+void BaseConnectionAddressingInterface::Adaptee::getContactsByVCardField(const QString &field,
4000+ const QStringList &addresses,
4001+ const QStringList &interfaces,
4002+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByVCardFieldContextPtr &context)
4003+{
4004+ if (!mInterface->mPriv->getContactsByVCardFieldCB.isValid()) {
4005+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
4006+ return;
4007+ }
4008+ Tp::AddressingNormalizationMap addressingNormalizationMap;
4009+ Tp::ContactAttributesMap contactAttributesMap;
4010+
4011+ DBusError error;
4012+ mInterface->mPriv->getContactsByVCardFieldCB(field, addresses, interfaces,
4013+ addressingNormalizationMap, contactAttributesMap,
4014+ &error);
4015+ if (error.isValid()) {
4016+ context->setFinishedWithError(error.name(), error.message());
4017+ return;
4018+ }
4019+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
4020+}
4021+
4022+void BaseConnectionAddressingInterface::Adaptee::getContactsByURI(const QStringList &URIs,
4023+ const QStringList &interfaces,
4024+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByURIContextPtr &context)
4025+{
4026+ if (!mInterface->mPriv->getContactsByURICB.isValid()) {
4027+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
4028+ return;
4029+ }
4030+ Tp::AddressingNormalizationMap addressingNormalizationMap;
4031+ Tp::ContactAttributesMap contactAttributesMap;
4032+
4033+ DBusError error;
4034+ mInterface->mPriv->getContactsByURICB(URIs, interfaces,
4035+ addressingNormalizationMap, contactAttributesMap,
4036+ &error);
4037+ if (error.isValid()) {
4038+ context->setFinishedWithError(error.name(), error.message());
4039+ return;
4040+ }
4041+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
4042+}
4043+
4044+}
4045
4046=== added file '.pc/07-fix_createChannel.patch/TelepathyQt/base-connection.h'
4047--- .pc/07-fix_createChannel.patch/TelepathyQt/base-connection.h 1970-01-01 00:00:00 +0000
4048+++ .pc/07-fix_createChannel.patch/TelepathyQt/base-connection.h 2014-02-05 14:09:56 +0000
4049@@ -0,0 +1,364 @@
4050+/**
4051+ * This file is part of TelepathyQt
4052+ *
4053+ * @copyright Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
4054+ * @copyright Copyright (C) 2012 Nokia Corporation
4055+ * @license LGPL 2.1
4056+ *
4057+ * This library is free software; you can redistribute it and/or
4058+ * modify it under the terms of the GNU Lesser General Public
4059+ * License as published by the Free Software Foundation; either
4060+ * version 2.1 of the License, or (at your option) any later version.
4061+ *
4062+ * This library is distributed in the hope that it will be useful,
4063+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4064+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4065+ * Lesser General Public License for more details.
4066+ *
4067+ * You should have received a copy of the GNU Lesser General Public
4068+ * License along with this library; if not, write to the Free Software
4069+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4070+ */
4071+
4072+#ifndef _TelepathyQt_base_connection_h_HEADER_GUARD_
4073+#define _TelepathyQt_base_connection_h_HEADER_GUARD_
4074+
4075+#ifndef IN_TP_QT_HEADER
4076+#error IN_TP_QT_HEADER
4077+#endif
4078+
4079+#include <TelepathyQt/DBusService>
4080+#include <TelepathyQt/Global>
4081+#include <TelepathyQt/Types>
4082+#include <TelepathyQt/Callbacks>
4083+
4084+#include <QDBusConnection>
4085+
4086+class QString;
4087+
4088+namespace Tp
4089+{
4090+
4091+class TP_QT_EXPORT BaseConnection : public DBusService
4092+{
4093+ Q_OBJECT
4094+ Q_DISABLE_COPY(BaseConnection)
4095+
4096+public:
4097+ static BaseConnectionPtr create(const QString &cmName, const QString &protocolName,
4098+ const QVariantMap &parameters) {
4099+ return BaseConnectionPtr(new BaseConnection(
4100+ QDBusConnection::sessionBus(), cmName, protocolName, parameters));
4101+ }
4102+ template<typename BaseConnectionSubclass>
4103+ static SharedPtr<BaseConnectionSubclass> create(const QString &cmName,
4104+ const QString &protocolName, const QVariantMap &parameters) {
4105+ return SharedPtr<BaseConnectionSubclass>(new BaseConnectionSubclass(
4106+ QDBusConnection::sessionBus(), cmName, protocolName, parameters));
4107+ }
4108+ static BaseConnectionPtr create(const QDBusConnection &dbusConnection,
4109+ const QString &cmName, const QString &protocolName,
4110+ const QVariantMap &parameters) {
4111+ return BaseConnectionPtr(new BaseConnection(
4112+ dbusConnection, cmName, protocolName, parameters));
4113+ }
4114+ template<typename BaseConnectionSubclass>
4115+ static SharedPtr<BaseConnectionSubclass> create(const QDBusConnection &dbusConnection,
4116+ const QString &cmName, const QString &protocolName,
4117+ const QVariantMap &parameters) {
4118+ return SharedPtr<BaseConnectionSubclass>(new BaseConnectionSubclass(
4119+ dbusConnection, cmName, protocolName, parameters));
4120+ }
4121+
4122+ virtual ~BaseConnection();
4123+
4124+ QString cmName() const;
4125+ QString protocolName() const;
4126+ QVariantMap parameters() const;
4127+ uint status() const;
4128+ QVariantMap immutableProperties() const;
4129+
4130+ void setStatus(uint newStatus, uint reason);
4131+
4132+ typedef Callback4<BaseChannelPtr, const QString&, uint, uint, DBusError*> CreateChannelCallback;
4133+ void setCreateChannelCallback(const CreateChannelCallback &cb);
4134+ Tp::BaseChannelPtr createChannel(const QString &channelType, uint targetHandleType, uint targetHandle, uint initiatorHandle, bool suppressHandler, DBusError *error);
4135+
4136+ typedef Callback3<UIntList, uint, const QStringList&, DBusError*> RequestHandlesCallback;
4137+ void setRequestHandlesCallback(const RequestHandlesCallback &cb);
4138+ UIntList requestHandles(uint handleType, const QStringList &identifiers, DBusError* error);
4139+
4140+ //typedef Callback3<uint, const QString&, const QString&, DBusError*> SetPresenceCallback;
4141+ //void setSetPresenceCallback(const SetPresenceCallback &cb);
4142+
4143+ void setSelfHandle(uint selfHandle);
4144+ uint selfHandle() const;
4145+
4146+ typedef Callback1<void, DBusError*> ConnectCallback;
4147+ void setConnectCallback(const ConnectCallback &cb);
4148+
4149+ typedef Callback3<QStringList, uint, const Tp::UIntList&, DBusError*> InspectHandlesCallback;
4150+ void setInspectHandlesCallback(const InspectHandlesCallback &cb);
4151+
4152+ Tp::ChannelInfoList channelsInfo();
4153+ Tp::ChannelDetailsList channelsDetails();
4154+
4155+ BaseChannelPtr ensureChannel(const QString &channelType, uint targetHandleType,
4156+ uint targetHandle, bool &yours, uint initiatorHandle, bool suppressHandler, DBusError *error);
4157+ void addChannel(BaseChannelPtr channel);
4158+
4159+ QList<AbstractConnectionInterfacePtr> interfaces() const;
4160+ AbstractConnectionInterfacePtr interface(const QString &interfaceName) const;
4161+ bool plugInterface(const AbstractConnectionInterfacePtr &interface);
4162+
4163+ virtual QString uniqueName() const;
4164+ bool registerObject(DBusError *error = NULL);
4165+
4166+Q_SIGNALS:
4167+ void disconnected();
4168+
4169+private Q_SLOTS:
4170+ TP_QT_NO_EXPORT void removeChannel();
4171+
4172+protected:
4173+ BaseConnection(const QDBusConnection &dbusConnection,
4174+ const QString &cmName, const QString &protocolName,
4175+ const QVariantMap &parameters);
4176+
4177+ virtual bool registerObject(const QString &busName, const QString &objectPath,
4178+ DBusError *error);
4179+
4180+private:
4181+ class Adaptee;
4182+ friend class Adaptee;
4183+ class Private;
4184+ friend class Private;
4185+ Private *mPriv;
4186+};
4187+
4188+class TP_QT_EXPORT AbstractConnectionInterface : public AbstractDBusServiceInterface
4189+{
4190+ Q_OBJECT
4191+ Q_DISABLE_COPY(AbstractConnectionInterface)
4192+
4193+public:
4194+ AbstractConnectionInterface(const QString &interfaceName);
4195+ virtual ~AbstractConnectionInterface();
4196+
4197+private:
4198+ friend class BaseConnection;
4199+
4200+ class Private;
4201+ friend class Private;
4202+ Private *mPriv;
4203+};
4204+
4205+class TP_QT_EXPORT BaseConnectionRequestsInterface : public AbstractConnectionInterface
4206+{
4207+ Q_OBJECT
4208+ Q_DISABLE_COPY(BaseConnectionRequestsInterface)
4209+
4210+public:
4211+ static BaseConnectionRequestsInterfacePtr create(BaseConnection* connection) {
4212+ return BaseConnectionRequestsInterfacePtr(new BaseConnectionRequestsInterface(connection));
4213+ }
4214+ template<typename BaseConnectionRequestsInterfaceSubclass>
4215+ static SharedPtr<BaseConnectionRequestsInterfaceSubclass> create(BaseConnection* connection) {
4216+ return SharedPtr<BaseConnectionRequestsInterfaceSubclass>(
4217+ new BaseConnectionRequestsInterfaceSubclass(connection));
4218+ }
4219+
4220+ virtual ~BaseConnectionRequestsInterface();
4221+
4222+ QVariantMap immutableProperties() const;
4223+
4224+ Tp::RequestableChannelClassList requestableChannelClasses;
4225+ void ensureChannel(const QVariantMap &request, bool &yours,
4226+ QDBusObjectPath &channel, QVariantMap &details, DBusError* error);
4227+ void createChannel(const QVariantMap &request, QDBusObjectPath &channel,
4228+ QVariantMap &details, DBusError* error);
4229+public Q_SLOTS:
4230+ void newChannels(const Tp::ChannelDetailsList &channels);
4231+
4232+protected:
4233+ BaseConnectionRequestsInterface(BaseConnection* connection);
4234+
4235+private:
4236+ void createAdaptor();
4237+
4238+ class Adaptee;
4239+ friend class Adaptee;
4240+ struct Private;
4241+ friend struct Private;
4242+ Private *mPriv;
4243+};
4244+
4245+
4246+class TP_QT_EXPORT BaseConnectionContactsInterface : public AbstractConnectionInterface
4247+{
4248+ Q_OBJECT
4249+ Q_DISABLE_COPY(BaseConnectionContactsInterface)
4250+
4251+
4252+public:
4253+ static BaseConnectionContactsInterfacePtr create() {
4254+ return BaseConnectionContactsInterfacePtr(new BaseConnectionContactsInterface());
4255+ }
4256+ template<typename BaseConnectionContactsInterfaceSubclass>
4257+ static SharedPtr<BaseConnectionContactsInterfaceSubclass> create() {
4258+ return SharedPtr<BaseConnectionContactsInterfaceSubclass>(
4259+ new BaseConnectionContactsInterfaceSubclass());
4260+ }
4261+
4262+ virtual ~BaseConnectionContactsInterface();
4263+
4264+ QVariantMap immutableProperties() const;
4265+
4266+ typedef Callback3<ContactAttributesMap, const Tp::UIntList&, const QStringList&, DBusError*> GetContactAttributesCallback;
4267+ void setGetContactAttributesCallback(const GetContactAttributesCallback &cb);
4268+ ContactAttributesMap getContactAttributes(const Tp::UIntList &handles,
4269+ const QStringList &interfaces,
4270+ DBusError *error);
4271+ void setContactAttributeInterfaces(const QStringList &contactAttributeInterfaces);
4272+protected:
4273+ BaseConnectionContactsInterface();
4274+
4275+private:
4276+ void createAdaptor();
4277+
4278+ class Adaptee;
4279+ friend class Adaptee;
4280+ struct Private;
4281+ friend struct Private;
4282+ Private *mPriv;
4283+};
4284+
4285+class TP_QT_EXPORT BaseConnectionSimplePresenceInterface : public AbstractConnectionInterface
4286+{
4287+ Q_OBJECT
4288+ Q_DISABLE_COPY(BaseConnectionSimplePresenceInterface)
4289+
4290+public:
4291+ static BaseConnectionSimplePresenceInterfacePtr create() {
4292+ return BaseConnectionSimplePresenceInterfacePtr(new BaseConnectionSimplePresenceInterface());
4293+ }
4294+ template<typename BaseConnectionSimplePresenceInterfaceSublclass>
4295+ static SharedPtr<BaseConnectionSimplePresenceInterfaceSublclass> create() {
4296+ return SharedPtr<BaseConnectionSimplePresenceInterfaceSublclass>(
4297+ new BaseConnectionSimplePresenceInterfaceSublclass());
4298+ }
4299+
4300+ virtual ~BaseConnectionSimplePresenceInterface();
4301+
4302+ QVariantMap immutableProperties() const;
4303+
4304+ typedef Callback3<uint, const QString&, const QString&, DBusError*> SetPresenceCallback;
4305+ void setSetPresenceCallback(const SetPresenceCallback &cb);
4306+
4307+ void setPresences(const Tp::SimpleContactPresences &presences);
4308+ void setStatuses(const SimpleStatusSpecMap &statuses);
4309+ void setMaxmimumStatusMessageLength(uint maxmimumStatusMessageLength);
4310+protected:
4311+ BaseConnectionSimplePresenceInterface();
4312+ Tp::SimpleStatusSpecMap statuses() const;
4313+ int maximumStatusMessageLength() const;
4314+
4315+private:
4316+ void createAdaptor();
4317+
4318+ class Adaptee;
4319+ friend class Adaptee;
4320+ struct Private;
4321+ friend struct Private;
4322+ Private *mPriv;
4323+};
4324+
4325+class TP_QT_EXPORT BaseConnectionContactListInterface : public AbstractConnectionInterface
4326+{
4327+ Q_OBJECT
4328+ Q_DISABLE_COPY(BaseConnectionContactListInterface)
4329+
4330+public:
4331+ static BaseConnectionContactListInterfacePtr create() {
4332+ return BaseConnectionContactListInterfacePtr(new BaseConnectionContactListInterface());
4333+ }
4334+ template<typename BaseConnectionContactListInterfaceSubclass>
4335+ static SharedPtr<BaseConnectionContactListInterfaceSubclass> create() {
4336+ return SharedPtr<BaseConnectionContactListInterfaceSubclass>(
4337+ new BaseConnectionContactListInterfaceSubclass());
4338+ }
4339+
4340+ virtual ~BaseConnectionContactListInterface();
4341+
4342+ QVariantMap immutableProperties() const;
4343+
4344+ void setContactListState(uint contactListState);
4345+ void setContactListPersists(bool);
4346+ void setCanChangeContactList(bool);
4347+ void setRequestUsesMessage(bool);
4348+ void setDownloadAtConnection(bool);
4349+
4350+ typedef Callback3<Tp::ContactAttributesMap, const QStringList&, bool, DBusError*> GetContactListAttributesCallback;
4351+ void setGetContactListAttributesCallback(const GetContactListAttributesCallback &cb);
4352+
4353+ typedef Callback3<void, const Tp::UIntList&, const QString&, DBusError*> RequestSubscriptionCallback;
4354+ void setRequestSubscriptionCallback(const RequestSubscriptionCallback &cb);
4355+
4356+ void contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals);
4357+protected:
4358+ BaseConnectionContactListInterface();
4359+
4360+private:
4361+ void createAdaptor();
4362+
4363+ class Adaptee;
4364+ friend class Adaptee;
4365+ struct Private;
4366+ friend struct Private;
4367+ Private *mPriv;
4368+};
4369+
4370+class TP_QT_EXPORT BaseConnectionAddressingInterface : public AbstractConnectionInterface
4371+{
4372+ Q_OBJECT
4373+ Q_DISABLE_COPY(BaseConnectionAddressingInterface)
4374+
4375+public:
4376+ static BaseConnectionAddressingInterfacePtr create() {
4377+ return BaseConnectionAddressingInterfacePtr(new BaseConnectionAddressingInterface());
4378+ }
4379+ template<typename BaseConnectionAddressingInterfaceSubclass>
4380+ static SharedPtr<BaseConnectionAddressingInterfaceSubclass> create() {
4381+ return SharedPtr<BaseConnectionAddressingInterfaceSubclass>(
4382+ new BaseConnectionAddressingInterfaceSubclass());
4383+ }
4384+
4385+ virtual ~BaseConnectionAddressingInterface();
4386+
4387+ QVariantMap immutableProperties() const;
4388+
4389+
4390+
4391+ typedef Callback6 < void, const QString&, const QStringList&, const QStringList&,
4392+ Tp::AddressingNormalizationMap&, Tp::ContactAttributesMap&, DBusError* > GetContactsByVCardFieldCallback;
4393+ void setGetContactsByVCardFieldCallback(const GetContactsByVCardFieldCallback &cb);
4394+
4395+ typedef Callback5 < void, const QStringList&, const QStringList&,
4396+ Tp::AddressingNormalizationMap&, Tp::ContactAttributesMap&, DBusError* > GetContactsByURICallback;
4397+ void setGetContactsByURICallback(const GetContactsByURICallback &cb);
4398+
4399+protected:
4400+ BaseConnectionAddressingInterface();
4401+
4402+private:
4403+ void createAdaptor();
4404+
4405+ class Adaptee;
4406+ friend class Adaptee;
4407+ struct Private;
4408+ friend struct Private;
4409+ Private *mPriv;
4410+};
4411+}
4412+
4413+#endif
4414
4415=== modified file '.pc/applied-patches'
4416--- .pc/applied-patches 2014-01-17 10:22:42 +0000
4417+++ .pc/applied-patches 2014-02-05 14:09:56 +0000
4418@@ -3,3 +3,5 @@
4419 03-add_service_side_classes.patch
4420 04-force_PIC_QT5.patch
4421 05-fix-qt52-build.patch
4422+06-conference_interfaces.patch
4423+07-fix_createChannel.patch
4424
4425=== modified file 'TelepathyQt/base-channel-internal.h'
4426--- TelepathyQt/base-channel-internal.h 2013-06-06 04:56:14 +0000
4427+++ TelepathyQt/base-channel-internal.h 2014-02-05 14:09:56 +0000
4428@@ -210,6 +210,73 @@
4429 BaseChannelHoldInterface *mInterface;
4430 };
4431
4432+class TP_QT_NO_EXPORT BaseChannelConferenceInterface::Adaptee : public QObject
4433+{
4434+ Q_OBJECT
4435+ Q_PROPERTY(Tp::ObjectPathList channels READ channels)
4436+ Q_PROPERTY(Tp::ObjectPathList initialChannels READ initialChannels)
4437+ Q_PROPERTY(Tp::UIntList initialInviteeHandles READ initialInviteeHandles)
4438+ Q_PROPERTY(QStringList initialInviteeIDs READ initialInviteeIDs)
4439+ Q_PROPERTY(QString invitationMessage READ invitationMessage)
4440+ Q_PROPERTY(ChannelOriginatorMap originalChannels READ originalChannels)
4441+public:
4442+ Adaptee(BaseChannelConferenceInterface *interface);
4443+ ~Adaptee();
4444+ Tp::ObjectPathList channels() const {
4445+ return mInterface->channels();
4446+ }
4447+ Tp::ObjectPathList initialChannels() const {
4448+ return mInterface->initialChannels();
4449+ }
4450+ Tp::UIntList initialInviteeHandles() const {
4451+ return mInterface->initialInviteeHandles();
4452+ }
4453+ QStringList initialInviteeIDs() const {
4454+ return mInterface->initialInviteeIDs();
4455+ }
4456+ QString invitationMessage() const {
4457+ return mInterface->invitationMessage();
4458+ }
4459+ ChannelOriginatorMap originalChannels() const {
4460+ return mInterface->originalChannels();
4461+ }
4462+
4463+signals:
4464+ void channelMerged(const QDBusObjectPath &channel, uint channelHandlent, Tp::QualifiedPropertyValueMap &properties);
4465+ void channelRemoved(const QDBusObjectPath &channel, const QVariantMap& details);
4466+
4467+public:
4468+ BaseChannelConferenceInterface *mInterface;
4469+};
4470+
4471+class TP_QT_NO_EXPORT BaseChannelMergeableConferenceInterface::Adaptee : public QObject
4472+{
4473+ Q_OBJECT
4474+public:
4475+ Adaptee(BaseChannelMergeableConferenceInterface *interface);
4476+ ~Adaptee();
4477+
4478+public slots:
4479+ void merge(const QDBusObjectPath &channel, const Tp::Service::ChannelInterfaceMergeableConferenceAdaptor::MergeContextPtr &context);
4480+
4481+public:
4482+ BaseChannelMergeableConferenceInterface *mInterface;
4483+};
4484+
4485+class TP_QT_NO_EXPORT BaseChannelSplittableInterface::Adaptee : public QObject
4486+{
4487+ Q_OBJECT
4488+public:
4489+ Adaptee(BaseChannelSplittableInterface *interface);
4490+ ~Adaptee();
4491+
4492+public slots:
4493+ void split(const Tp::Service::ChannelInterfaceSplittableAdaptor::SplitContextPtr &context);
4494+
4495+public:
4496+ BaseChannelSplittableInterface *mInterface;
4497+};
4498+
4499 class TP_QT_NO_EXPORT BaseChannelGroupInterface::Adaptee : public QObject
4500 {
4501 Q_OBJECT
4502
4503=== modified file 'TelepathyQt/base-channel.cpp'
4504--- TelepathyQt/base-channel.cpp 2013-06-06 04:56:14 +0000
4505+++ TelepathyQt/base-channel.cpp 2014-02-05 14:09:56 +0000
4506@@ -26,6 +26,7 @@
4507
4508 #include "TelepathyQt/_gen/base-channel.moc.hpp"
4509 #include "TelepathyQt/_gen/base-channel-internal.moc.hpp"
4510+#include "TelepathyQt/future-internal.h"
4511
4512 #include "TelepathyQt/debug-internal.h"
4513
4514@@ -1684,5 +1685,298 @@
4515 mPriv->adaptee, dbusObject());
4516 }
4517
4518+
4519+// Chan.I.MergeableConference
4520+BaseChannelMergeableConferenceInterface::Adaptee::Adaptee(BaseChannelMergeableConferenceInterface *interface)
4521+ : QObject(interface),
4522+ mInterface(interface)
4523+{
4524+}
4525+
4526+BaseChannelMergeableConferenceInterface::Adaptee::~Adaptee()
4527+{
4528+}
4529+
4530+struct TP_QT_NO_EXPORT BaseChannelMergeableConferenceInterface::Private {
4531+ Private(BaseChannelMergeableConferenceInterface *parent)
4532+ :adaptee(new BaseChannelMergeableConferenceInterface::Adaptee(parent)) {
4533+ }
4534+
4535+ MergeCallback mergeCB;
4536+ BaseChannelMergeableConferenceInterface::Adaptee *adaptee;
4537+};
4538+
4539+void BaseChannelMergeableConferenceInterface::Adaptee::merge(const QDBusObjectPath &channelPath, const Tp::Service::ChannelInterfaceMergeableConferenceAdaptor::MergeContextPtr &context)
4540+{
4541+ if (!mInterface->mPriv->mergeCB.isValid()) {
4542+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
4543+ return;
4544+ }
4545+
4546+ DBusError error;
4547+ mInterface->mPriv->mergeCB(channelPath, &error);
4548+ if (error.isValid()) {
4549+ context->setFinishedWithError(error.name(), error.message());
4550+ return;
4551+ }
4552+ context->setFinished();
4553+}
4554+
4555+/**
4556+ * \class BaseChannelMergeableConferenceInterface
4557+ * \ingroup servicecm
4558+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
4559+ *
4560+ * \brief Base class for implementations of Channel.Interface.MergeableConference
4561+ *
4562+ */
4563+
4564+/**
4565+ * Class constructor.
4566+ */
4567+BaseChannelMergeableConferenceInterface::BaseChannelMergeableConferenceInterface()
4568+ : AbstractChannelInterface(TP_QT_FUTURE_IFACE_CHANNEL_INTERFACE_MERGEABLE_CONFERENCE),
4569+ mPriv(new Private(this))
4570+{
4571+}
4572+
4573+void BaseChannelMergeableConferenceInterface::setMergeCallback(const MergeCallback &cb)
4574+{
4575+ mPriv->mergeCB = cb;
4576+}
4577+
4578+/**
4579+ * Class destructor.
4580+ */
4581+BaseChannelMergeableConferenceInterface::~BaseChannelMergeableConferenceInterface()
4582+{
4583+ delete mPriv;
4584+}
4585+
4586+/**
4587+ * Return the immutable properties of this interface.
4588+ *
4589+ * Immutable properties cannot change after the interface has been registered
4590+ * on a service on the bus with registerInterface().
4591+ *
4592+ * \return The immutable properties of this interface.
4593+ */
4594+QVariantMap BaseChannelMergeableConferenceInterface::immutableProperties() const
4595+{
4596+ QVariantMap map;
4597+ return map;
4598+}
4599+
4600+void BaseChannelMergeableConferenceInterface::createAdaptor()
4601+{
4602+ (void) new Service::ChannelInterfaceMergeableConferenceAdaptor(dbusObject()->dbusConnection(),
4603+ mPriv->adaptee, dbusObject());
4604+}
4605+
4606+
4607+// Chan.I.Splittable
4608+BaseChannelSplittableInterface::Adaptee::Adaptee(BaseChannelSplittableInterface *interface)
4609+ : QObject(interface),
4610+ mInterface(interface)
4611+{
4612+}
4613+
4614+BaseChannelSplittableInterface::Adaptee::~Adaptee()
4615+{
4616+}
4617+
4618+struct TP_QT_NO_EXPORT BaseChannelSplittableInterface::Private {
4619+ Private(BaseChannelSplittableInterface *parent)
4620+ :adaptee(new BaseChannelSplittableInterface::Adaptee(parent)) {
4621+ }
4622+
4623+ SplitCallback splitCB;
4624+ BaseChannelSplittableInterface::Adaptee *adaptee;
4625+};
4626+
4627+void BaseChannelSplittableInterface::Adaptee::split(const Tp::Service::ChannelInterfaceSplittableAdaptor::SplitContextPtr &context)
4628+{
4629+ if (!mInterface->mPriv->splitCB.isValid()) {
4630+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
4631+ return;
4632+ }
4633+
4634+ DBusError error;
4635+ mInterface->mPriv->splitCB(&error);
4636+ if (error.isValid()) {
4637+ context->setFinishedWithError(error.name(), error.message());
4638+ return;
4639+ }
4640+ context->setFinished();
4641+}
4642+
4643+/**
4644+ * \class BaseChannelSplittableInterface
4645+ * \ingroup servicecm
4646+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
4647+ *
4648+ * \brief Base class for implementations of Channel.Interface.Splittable
4649+ *
4650+ */
4651+
4652+/**
4653+ * Class constructor.
4654+ */
4655+BaseChannelSplittableInterface::BaseChannelSplittableInterface()
4656+ : AbstractChannelInterface(TP_QT_FUTURE_IFACE_CHANNEL_INTERFACE_SPLITTABLE),
4657+ mPriv(new Private(this))
4658+{
4659+}
4660+
4661+void BaseChannelSplittableInterface::setSplitCallback(const SplitCallback &cb)
4662+{
4663+ mPriv->splitCB = cb;
4664+}
4665+
4666+/**
4667+ * Class destructor.
4668+ */
4669+BaseChannelSplittableInterface::~BaseChannelSplittableInterface()
4670+{
4671+ delete mPriv;
4672+}
4673+
4674+/**
4675+ * Return the immutable properties of this interface.
4676+ *
4677+ * Immutable properties cannot change after the interface has been registered
4678+ * on a service on the bus with registerInterface().
4679+ *
4680+ * \return The immutable properties of this interface.
4681+ */
4682+QVariantMap BaseChannelSplittableInterface::immutableProperties() const
4683+{
4684+ QVariantMap map;
4685+ return map;
4686+}
4687+
4688+void BaseChannelSplittableInterface::createAdaptor()
4689+{
4690+ (void) new Service::ChannelInterfaceSplittableAdaptor(dbusObject()->dbusConnection(),
4691+ mPriv->adaptee, dbusObject());
4692+}
4693+
4694+
4695+// Chan.I.Conference
4696+BaseChannelConferenceInterface::Adaptee::Adaptee(BaseChannelConferenceInterface *interface)
4697+ : QObject(interface),
4698+ mInterface(interface)
4699+{
4700+}
4701+
4702+BaseChannelConferenceInterface::Adaptee::~Adaptee()
4703+{
4704+}
4705+
4706+struct TP_QT_NO_EXPORT BaseChannelConferenceInterface::Private {
4707+ Private(BaseChannelConferenceInterface *parent,
4708+ Tp::ObjectPathList initialChannels,
4709+ Tp::UIntList initialInviteeHandles,
4710+ QStringList initialInviteeIDs,
4711+ QString invitationMessage,
4712+ ChannelOriginatorMap originalChannels) :
4713+ channels(initialChannels),
4714+ initialChannels(initialChannels),
4715+ initialInviteeHandles(initialInviteeHandles),
4716+ initialInviteeIDs(initialInviteeIDs),
4717+ invitationMessage(invitationMessage),
4718+ originalChannels(originalChannels),
4719+ adaptee(new BaseChannelConferenceInterface::Adaptee(parent)) {
4720+ }
4721+ Tp::ObjectPathList channels;
4722+ Tp::ObjectPathList initialChannels;
4723+ Tp::UIntList initialInviteeHandles;
4724+ QStringList initialInviteeIDs;
4725+ QString invitationMessage;
4726+ ChannelOriginatorMap originalChannels;
4727+
4728+ BaseChannelConferenceInterface::Adaptee *adaptee;
4729+};
4730+
4731+/**
4732+ * \class BaseChannelConferenceInterface
4733+ * \ingroup servicecm
4734+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
4735+ *
4736+ * \brief Base class for implementations of Channel.Interface.Conference
4737+ *
4738+ */
4739+
4740+/**
4741+ * Class constructor.
4742+ */
4743+BaseChannelConferenceInterface::BaseChannelConferenceInterface(Tp::ObjectPathList initialChannels,
4744+ Tp::UIntList initialInviteeHandles,
4745+ QStringList initialInviteeIDs,
4746+ QString invitationMessage,
4747+ ChannelOriginatorMap originalChannels)
4748+ : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE),
4749+ mPriv(new Private(this, initialChannels, initialInviteeHandles, initialInviteeIDs, invitationMessage, originalChannels))
4750+{
4751+}
4752+
4753+Tp::ObjectPathList BaseChannelConferenceInterface::channels() const
4754+{
4755+ return mPriv->channels;
4756+}
4757+
4758+Tp::ObjectPathList BaseChannelConferenceInterface::initialChannels() const
4759+{
4760+ return mPriv->initialChannels;
4761+}
4762+
4763+Tp::UIntList BaseChannelConferenceInterface::initialInviteeHandles() const
4764+{
4765+ return mPriv->initialInviteeHandles;
4766+}
4767+
4768+QStringList BaseChannelConferenceInterface::initialInviteeIDs() const
4769+{
4770+ return mPriv->initialInviteeIDs;
4771+}
4772+
4773+QString BaseChannelConferenceInterface::invitationMessage() const
4774+{
4775+ return mPriv->invitationMessage;
4776+}
4777+
4778+ChannelOriginatorMap BaseChannelConferenceInterface::originalChannels() const
4779+{
4780+ return mPriv->originalChannels;
4781+}
4782+
4783+/**
4784+ * Class destructor.
4785+ */
4786+BaseChannelConferenceInterface::~BaseChannelConferenceInterface()
4787+{
4788+ delete mPriv;
4789+}
4790+
4791+/**
4792+ * Return the immutable properties of this interface.
4793+ *
4794+ * Immutable properties cannot change after the interface has been registered
4795+ * on a service on the bus with registerInterface().
4796+ *
4797+ * \return The immutable properties of this interface.
4798+ */
4799+QVariantMap BaseChannelConferenceInterface::immutableProperties() const
4800+{
4801+ QVariantMap map;
4802+ return map;
4803+}
4804+
4805+void BaseChannelConferenceInterface::createAdaptor()
4806+{
4807+ (void) new Service::ChannelInterfaceConferenceAdaptor(dbusObject()->dbusConnection(),
4808+ mPriv->adaptee, dbusObject());
4809+}
4810+
4811 }
4812
4813
4814=== modified file 'TelepathyQt/base-channel.h'
4815--- TelepathyQt/base-channel.h 2013-06-06 04:56:14 +0000
4816+++ TelepathyQt/base-channel.h 2014-02-05 14:09:56 +0000
4817@@ -475,5 +475,118 @@
4818 Private *mPriv;
4819 };
4820
4821+class TP_QT_EXPORT BaseChannelMergeableConferenceInterface : public AbstractChannelInterface
4822+{
4823+ Q_OBJECT
4824+ Q_DISABLE_COPY(BaseChannelMergeableConferenceInterface)
4825+
4826+public:
4827+ static BaseChannelMergeableConferenceInterfacePtr create() {
4828+ return BaseChannelMergeableConferenceInterfacePtr(new BaseChannelMergeableConferenceInterface());
4829+ }
4830+ template<typename BaseChannelMergeableConferenceInterfaceSubclass>
4831+ static SharedPtr<BaseChannelMergeableConferenceInterfaceSubclass> create() {
4832+ return SharedPtr<BaseChannelMergeableConferenceInterfaceSubclass>(
4833+ new BaseChannelMergeableConferenceInterfaceSubclass());
4834+ }
4835+ virtual ~BaseChannelMergeableConferenceInterface();
4836+
4837+ QVariantMap immutableProperties() const;
4838+
4839+ void merge(const QDBusObjectPath &channel);
4840+
4841+ typedef Callback2<void, const QDBusObjectPath&, DBusError*> MergeCallback;
4842+ void setMergeCallback(const MergeCallback &cb);
4843+private:
4844+ BaseChannelMergeableConferenceInterface();
4845+ void createAdaptor();
4846+
4847+ class Adaptee;
4848+ friend class Adaptee;
4849+ struct Private;
4850+ friend struct Private;
4851+ Private *mPriv;
4852+};
4853+
4854+class TP_QT_EXPORT BaseChannelSplittableInterface : public AbstractChannelInterface
4855+{
4856+ Q_OBJECT
4857+ Q_DISABLE_COPY(BaseChannelSplittableInterface)
4858+
4859+public:
4860+ static BaseChannelSplittableInterfacePtr create() {
4861+ return BaseChannelSplittableInterfacePtr(new BaseChannelSplittableInterface());
4862+ }
4863+ template<typename BaseChannelSplittableInterfaceSubclass>
4864+ static SharedPtr<BaseChannelSplittableInterfaceSubclass> create() {
4865+ return SharedPtr<BaseChannelSplittableInterfaceSubclass>(
4866+ new BaseChannelSplittableInterfaceSubclass());
4867+ }
4868+ virtual ~BaseChannelSplittableInterface();
4869+
4870+ QVariantMap immutableProperties() const;
4871+
4872+ void split();
4873+
4874+ typedef Callback1<void, DBusError*> SplitCallback;
4875+ void setSplitCallback(const SplitCallback &cb);
4876+private:
4877+ BaseChannelSplittableInterface();
4878+ void createAdaptor();
4879+
4880+ class Adaptee;
4881+ friend class Adaptee;
4882+ struct Private;
4883+ friend struct Private;
4884+ Private *mPriv;
4885+};
4886+
4887+class TP_QT_EXPORT BaseChannelConferenceInterface : public AbstractChannelInterface
4888+{
4889+ Q_OBJECT
4890+ Q_DISABLE_COPY(BaseChannelConferenceInterface)
4891+
4892+public:
4893+ static BaseChannelConferenceInterfacePtr create(Tp::ObjectPathList initialChannels = Tp::ObjectPathList(),
4894+ Tp::UIntList initialInviteeHandles = Tp::UIntList(),
4895+ QStringList initialInviteeIDs = QStringList(),
4896+ QString invitationMessage = QString(),
4897+ ChannelOriginatorMap originalChannels = ChannelOriginatorMap()) {
4898+ return BaseChannelConferenceInterfacePtr(new BaseChannelConferenceInterface(initialChannels, initialInviteeHandles, initialInviteeIDs, invitationMessage, originalChannels));
4899+ }
4900+ template<typename BaseChannelConferenceInterfaceSubclass>
4901+ static SharedPtr<BaseChannelConferenceInterfaceSubclass> create(Tp::ObjectPathList initialChannels = Tp::ObjectPathList(),
4902+ Tp::UIntList initialInviteeHandles = Tp::UIntList(),
4903+ QStringList initialInviteeIDs = QStringList(),
4904+ QString invitationMessage = QString(),
4905+ ChannelOriginatorMap originalChannels = ChannelOriginatorMap()) {
4906+ return SharedPtr<BaseChannelConferenceInterfaceSubclass>(
4907+ new BaseChannelConferenceInterfaceSubclass(initialChannels, initialInviteeHandles, initialInviteeIDs, invitationMessage, originalChannels));
4908+ }
4909+ virtual ~BaseChannelConferenceInterface();
4910+
4911+ QVariantMap immutableProperties() const;
4912+ Tp::ObjectPathList channels() const;
4913+ Tp::ObjectPathList initialChannels() const;
4914+ Tp::UIntList initialInviteeHandles() const;
4915+ QStringList initialInviteeIDs() const;
4916+ QString invitationMessage() const;
4917+ ChannelOriginatorMap originalChannels() const;
4918+
4919+Q_SIGNALS:
4920+ void channelMerged(const QDBusObjectPath &channel, uint channelHandle, const Tp::QualifiedPropertyValueMap &properties);
4921+ void channelRemoved(const QDBusObjectPath &channel, const QVariantMap &properties);
4922+
4923+private:
4924+ BaseChannelConferenceInterface(Tp::ObjectPathList initialChannels, Tp::UIntList initialInviteeHandles, QStringList initialInviteeIDs, QString invitationMessage, ChannelOriginatorMap originalChannels);
4925+ void createAdaptor();
4926+
4927+ class Adaptee;
4928+ friend class Adaptee;
4929+ struct Private;
4930+ friend struct Private;
4931+ Private *mPriv;
4932+};
4933+
4934 }
4935 #endif
4936
4937=== modified file 'TelepathyQt/base-connection.cpp'
4938--- TelepathyQt/base-connection.cpp 2013-06-06 04:56:14 +0000
4939+++ TelepathyQt/base-connection.cpp 2014-02-05 14:09:56 +0000
4940@@ -286,6 +286,7 @@
4941 uint targetHandle,
4942 uint initiatorHandle,
4943 bool suppressHandler,
4944+ const QVariantMap &hints,
4945 DBusError *error)
4946 {
4947 if (!mPriv->createChannelCB.isValid()) {
4948@@ -297,7 +298,7 @@
4949 return BaseChannelPtr();
4950 }
4951
4952- BaseChannelPtr channel = mPriv->createChannelCB(channelType, targetHandleType, targetHandle, error);
4953+ BaseChannelPtr channel = mPriv->createChannelCB(channelType, targetHandleType, targetHandle, hints, error);
4954 if (error->isValid())
4955 return BaseChannelPtr();
4956
4957@@ -412,7 +413,7 @@
4958 }
4959 }
4960 yours = true;
4961- return createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, error);
4962+ return createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, QVariantMap(), error);
4963 }
4964
4965 void BaseConnection::removeChannel()
4966@@ -715,18 +716,7 @@
4967
4968 QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
4969 uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
4970- uint targetHandle;
4971- if (request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")))
4972- targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
4973- else {
4974- QString targetID = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")].toString();
4975- Tp::UIntList list = mPriv->connection->requestHandles(targetHandleType, QStringList() << targetID, error);
4976- if (error->isValid()) {
4977- warning() << "BBaseConnectionRequestsInterface::ensureChannel: could not resolve ID " << targetID;
4978- return;
4979- }
4980- targetHandle = *list.begin();
4981- }
4982+ uint targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
4983
4984 bool suppressHandler = true;
4985 BaseChannelPtr channel = mPriv->connection->ensureChannel(channelType, targetHandleType,
4986@@ -745,33 +735,21 @@
4987 QDBusObjectPath &objectPath,
4988 QVariantMap &details, DBusError *error)
4989 {
4990- if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
4991- || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
4992- || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))) {
4993+ if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))) {
4994 error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Missing parameters"));
4995 return;
4996 }
4997
4998 QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
4999 uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
5000- uint targetHandle;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches