Merge lp:~tiagosh/ubuntu/vivid/telepathy-qt5/fix-requested into lp:ubuntu/vivid/telepathy-qt5

Proposed by Tiago Salem Herrmann
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~tiagosh/ubuntu/vivid/telepathy-qt5/fix-requested
Merge into: lp:ubuntu/vivid/telepathy-qt5
Diff against target: 1415 lines (+1367/-1)
6 files modified
.pc/11-fix-requested.patch/TelepathyQt/base-connection.cpp (+1340/-0)
.pc/applied-patches (+1/-0)
TelepathyQt/base-connection.cpp (+1/-1)
debian/changelog (+6/-0)
debian/patches/11-fix-requested.patch (+18/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~tiagosh/ubuntu/vivid/telepathy-qt5/fix-requested
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+250251@code.launchpad.net

Commit message

Don't set "Requested" based on initiatorHandle and selfHandle.

Description of the change

Don't set "Requested" based on initiatorHandle and selfHandle.

To post a comment you must log in.
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

In landing-025

14. By Tiago Salem Herrmann

Update changelog

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

Looks good and works as expected!

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc/11-fix-requested.patch'
2=== added file '.pc/11-fix-requested.patch/.timestamp'
3=== added directory '.pc/11-fix-requested.patch/TelepathyQt'
4=== added file '.pc/11-fix-requested.patch/TelepathyQt/base-connection.cpp'
5--- .pc/11-fix-requested.patch/TelepathyQt/base-connection.cpp 1970-01-01 00:00:00 +0000
6+++ .pc/11-fix-requested.patch/TelepathyQt/base-connection.cpp 2015-02-19 13:15:12 +0000
7@@ -0,0 +1,1340 @@
8+/**
9+ * This file is part of TelepathyQt
10+ *
11+ * @copyright Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
12+ * @copyright Copyright (C) 2012 Nokia Corporation
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/BaseConnection>
31+#include "TelepathyQt/base-connection-internal.h"
32+
33+#include "TelepathyQt/_gen/base-connection.moc.hpp"
34+#include "TelepathyQt/_gen/base-connection-internal.moc.hpp"
35+
36+#include "TelepathyQt/debug-internal.h"
37+
38+#include <TelepathyQt/BaseChannel>
39+#include <TelepathyQt/Constants>
40+#include <TelepathyQt/DBusObject>
41+#include <TelepathyQt/Utils>
42+#include <TelepathyQt/AbstractProtocolInterface>
43+#include <QString>
44+#include <QVariantMap>
45+
46+namespace Tp
47+{
48+
49+struct TP_QT_NO_EXPORT BaseConnection::Private {
50+ Private(BaseConnection *parent, const QDBusConnection &dbusConnection,
51+ const QString &cmName, const QString &protocolName,
52+ const QVariantMap &parameters)
53+ : parent(parent),
54+ cmName(cmName),
55+ protocolName(protocolName),
56+ parameters(parameters),
57+ status(Tp::ConnectionStatusDisconnected),
58+ selfHandle(0),
59+ adaptee(new BaseConnection::Adaptee(dbusConnection, parent)) {
60+ }
61+
62+ BaseConnection *parent;
63+ QString cmName;
64+ QString protocolName;
65+ QVariantMap parameters;
66+ uint status;
67+ QHash<QString, AbstractConnectionInterfacePtr> interfaces;
68+ QSet<BaseChannelPtr> channels;
69+ CreateChannelCallback createChannelCB;
70+ RequestHandlesCallback requestHandlesCB;
71+ ConnectCallback connectCB;
72+ InspectHandlesCallback inspectHandlesCB;
73+ uint selfHandle;
74+ BaseConnection::Adaptee *adaptee;
75+};
76+
77+BaseConnection::Adaptee::Adaptee(const QDBusConnection &dbusConnection,
78+ BaseConnection *connection)
79+ : QObject(connection),
80+ mConnection(connection)
81+{
82+ mAdaptor = new Service::ConnectionAdaptor(dbusConnection, this, connection->dbusObject());
83+}
84+
85+BaseConnection::Adaptee::~Adaptee()
86+{
87+}
88+
89+void BaseConnection::Adaptee::disconnect(const Tp::Service::ConnectionAdaptor::DisconnectContextPtr &context)
90+{
91+ debug() << "BaseConnection::Adaptee::disconnect";
92+ /* This will remove the connection from the connection manager
93+ * and destroy this object. */
94+ emit mConnection->disconnected();
95+ context->setFinished();
96+}
97+
98+void BaseConnection::Adaptee::getSelfHandle(const Tp::Service::ConnectionAdaptor::GetSelfHandleContextPtr &context)
99+{
100+ context->setFinished(mConnection->mPriv->selfHandle);
101+}
102+
103+uint BaseConnection::Adaptee::selfHandle() const
104+{
105+ return mConnection->mPriv->selfHandle;
106+}
107+
108+void BaseConnection::Adaptee::getStatus(const Tp::Service::ConnectionAdaptor::GetStatusContextPtr &context)
109+{
110+ context->setFinished(mConnection->status());
111+}
112+
113+void BaseConnection::Adaptee::connect(const Tp::Service::ConnectionAdaptor::ConnectContextPtr &context)
114+{
115+ if (!mConnection->mPriv->connectCB.isValid()) {
116+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
117+ return;
118+ }
119+ DBusError error;
120+ mConnection->mPriv->connectCB(&error);
121+ if (error.isValid()) {
122+ context->setFinishedWithError(error.name(), error.message());
123+ return;
124+ }
125+ context->setFinished();
126+}
127+
128+void BaseConnection::Adaptee::inspectHandles(uint handleType,
129+ const Tp::UIntList &handles,
130+ const Tp::Service::ConnectionAdaptor::InspectHandlesContextPtr &context)
131+{
132+ if (!mConnection->mPriv->inspectHandlesCB.isValid()) {
133+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
134+ return;
135+ }
136+ DBusError error;
137+ QStringList ret = mConnection->mPriv->inspectHandlesCB(handleType, handles, &error);
138+ if (error.isValid()) {
139+ context->setFinishedWithError(error.name(), error.message());
140+ return;
141+ }
142+ context->setFinished(ret);
143+}
144+QStringList BaseConnection::Adaptee::interfaces() const
145+{
146+ QStringList ret;
147+ foreach(const AbstractConnectionInterfacePtr & iface, mConnection->interfaces()) {
148+ ret << iface->interfaceName();
149+ }
150+ return ret;
151+}
152+
153+void BaseConnection::Adaptee::requestChannel(const QString &type, uint handleType, uint handle, bool suppressHandler,
154+ const Tp::Service::ConnectionAdaptor::RequestChannelContextPtr &context)
155+{
156+ debug() << "BaseConnection::Adaptee::requestChannel (deprecated)";
157+ DBusError error;
158+ bool yours;
159+ BaseChannelPtr channel = mConnection->ensureChannel(type,
160+ handleType,
161+ handle,
162+ yours,
163+ selfHandle(),
164+ suppressHandler,
165+ QVariantMap(),
166+ &error);
167+ if (error.isValid() || !channel) {
168+ context->setFinishedWithError(error.name(), error.message());
169+ return;
170+ }
171+ context->setFinished(QDBusObjectPath(channel->objectPath()));
172+}
173+
174+void BaseConnection::Adaptee::requestHandles(uint handleType, const QStringList &identifiers,
175+ const Tp::Service::ConnectionAdaptor::RequestHandlesContextPtr &context)
176+{
177+ DBusError error;
178+ Tp::UIntList handles = mConnection->requestHandles(handleType, identifiers, &error);
179+ if (error.isValid()) {
180+ context->setFinishedWithError(error.name(), error.message());
181+ return;
182+ }
183+ context->setFinished(handles);
184+}
185+
186+/**
187+ * \class BaseConnection
188+ * \ingroup serviceconn
189+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
190+ *
191+ * \brief Base class for Connection implementations.
192+ */
193+
194+/**
195+ * Construct a BaseConnection.
196+ *
197+ * \param dbusConnection The D-Bus connection that will be used by this object.
198+ * \param cmName The name of the connection manager associated with this connection.
199+ * \param protocolName The name of the protocol associated with this connection.
200+ * \param parameters The parameters of this connection.
201+ */
202+BaseConnection::BaseConnection(const QDBusConnection &dbusConnection,
203+ const QString &cmName, const QString &protocolName,
204+ const QVariantMap &parameters)
205+ : DBusService(dbusConnection),
206+ mPriv(new Private(this, dbusConnection, cmName, protocolName, parameters))
207+{
208+}
209+
210+/**
211+ * Class destructor.
212+ */
213+BaseConnection::~BaseConnection()
214+{
215+ delete mPriv;
216+}
217+
218+/**
219+ * Return the name of the connection manager associated with this connection.
220+ *
221+ * \return The name of the connection manager associated with this connection.
222+ */
223+QString BaseConnection::cmName() const
224+{
225+ return mPriv->cmName;
226+}
227+
228+/**
229+ * Return the name of the protocol associated with this connection.
230+ *
231+ * \return The name of the protocol associated with this connection.
232+ */
233+QString BaseConnection::protocolName() const
234+{
235+ return mPriv->protocolName;
236+}
237+
238+/**
239+ * Return the parameters of this connection.
240+ *
241+ * \return The parameters of this connection.
242+ */
243+QVariantMap BaseConnection::parameters() const
244+{
245+ return mPriv->parameters;
246+}
247+
248+/**
249+ * Return the immutable properties of this connection object.
250+ *
251+ * Immutable properties cannot change after the object has been registered
252+ * on the bus with registerObject().
253+ *
254+ * \return The immutable properties of this connection object.
255+ */
256+QVariantMap BaseConnection::immutableProperties() const
257+{
258+ // FIXME
259+ return QVariantMap();
260+}
261+
262+/**
263+ * Return a unique name for this connection.
264+ *
265+ * \return A unique name for this connection.
266+ */
267+QString BaseConnection::uniqueName() const
268+{
269+ return QString(QLatin1String("_%1")).arg((quintptr) this, 0, 16);
270+}
271+
272+uint BaseConnection::status() const
273+{
274+ debug() << "BaseConnection::status = " << mPriv->status << " " << this;
275+ return mPriv->status;
276+}
277+
278+void BaseConnection::setStatus(uint newStatus, uint reason)
279+{
280+ debug() << "BaseConnection::setStatus " << newStatus << " " << reason << " " << this;
281+ bool changed = (newStatus != mPriv->status);
282+ mPriv->status = newStatus;
283+ if (changed)
284+ emit mPriv->adaptee->statusChanged(newStatus, reason);
285+}
286+
287+void BaseConnection::setCreateChannelCallback(const CreateChannelCallback &cb)
288+{
289+ mPriv->createChannelCB = cb;
290+}
291+
292+Tp::BaseChannelPtr BaseConnection::createChannel(const QString &channelType,
293+ uint targetHandleType,
294+ uint targetHandle,
295+ uint initiatorHandle,
296+ bool suppressHandler,
297+ const QVariantMap &hints,
298+ DBusError *error)
299+{
300+ if (!mPriv->createChannelCB.isValid()) {
301+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
302+ return BaseChannelPtr();
303+ }
304+ if (!mPriv->inspectHandlesCB.isValid()) {
305+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
306+ return BaseChannelPtr();
307+ }
308+
309+ BaseChannelPtr channel = mPriv->createChannelCB(channelType, targetHandleType, targetHandle, hints, error);
310+ if (error->isValid())
311+ return BaseChannelPtr();
312+
313+ QString targetID;
314+ if (targetHandle != 0) {
315+ QStringList list = mPriv->inspectHandlesCB(targetHandleType, UIntList() << targetHandle, error);
316+ if (error->isValid()) {
317+ debug() << "BaseConnection::createChannel: could not resolve handle " << targetHandle;
318+ return BaseChannelPtr();
319+ } else {
320+ debug() << "BaseConnection::createChannel: found targetID " << *list.begin();
321+ targetID = *list.begin();
322+ }
323+ }
324+ QString initiatorID;
325+ if (initiatorHandle != 0) {
326+ QStringList list = mPriv->inspectHandlesCB(HandleTypeContact, UIntList() << initiatorHandle, error);
327+ if (error->isValid()) {
328+ debug() << "BaseConnection::createChannel: could not resolve handle " << initiatorHandle;
329+ return BaseChannelPtr();
330+ } else {
331+ debug() << "BaseConnection::createChannel: found initiatorID " << *list.begin();
332+ initiatorID = *list.begin();
333+ }
334+ }
335+ channel->setInitiatorHandle(initiatorHandle);
336+ channel->setInitiatorID(initiatorID);
337+ channel->setTargetID(targetID);
338+ channel->setRequested(initiatorHandle == mPriv->selfHandle);
339+
340+ channel->registerObject(error);
341+ if (error->isValid())
342+ return BaseChannelPtr();
343+
344+ mPriv->channels.insert(channel);
345+
346+ BaseConnectionRequestsInterfacePtr reqIface =
347+ BaseConnectionRequestsInterfacePtr::dynamicCast(interface(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS));
348+
349+ if (!reqIface.isNull())
350+ //emit after return
351+ QMetaObject::invokeMethod(reqIface.data(), "newChannels",
352+ Qt::QueuedConnection,
353+ Q_ARG(Tp::ChannelDetailsList, ChannelDetailsList() << channel->details()));
354+
355+
356+ //emit after return
357+ QMetaObject::invokeMethod(mPriv->adaptee, "newChannel",
358+ Qt::QueuedConnection,
359+ Q_ARG(QDBusObjectPath, QDBusObjectPath(channel->objectPath())),
360+ Q_ARG(QString, channel->channelType()),
361+ Q_ARG(uint, channel->targetHandleType()),
362+ Q_ARG(uint, channel->targetHandle()),
363+ Q_ARG(bool, suppressHandler));
364+
365+ QObject::connect(channel.data(),
366+ SIGNAL(closed()),
367+ SLOT(removeChannel()));
368+
369+ return channel;
370+}
371+
372+void BaseConnection::setRequestHandlesCallback(const RequestHandlesCallback &cb)
373+{
374+ mPriv->requestHandlesCB = cb;
375+}
376+
377+UIntList BaseConnection::requestHandles(uint handleType, const QStringList &identifiers, DBusError* error)
378+{
379+ if (!mPriv->requestHandlesCB.isValid()) {
380+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
381+ return UIntList();
382+ }
383+ return mPriv->requestHandlesCB(handleType, identifiers, error);
384+}
385+
386+Tp::ChannelInfoList BaseConnection::channelsInfo()
387+{
388+ qDebug() << "BaseConnection::channelsInfo:";
389+ Tp::ChannelInfoList list;
390+ foreach(const BaseChannelPtr & c, mPriv->channels) {
391+ Tp::ChannelInfo info;
392+ info.channel = QDBusObjectPath(c->objectPath());
393+ info.channelType = c->channelType();
394+ info.handle = c->targetHandle();
395+ info.handleType = c->targetHandleType();
396+ qDebug() << "BaseConnection::channelsInfo " << info.channel.path();
397+ list << info;
398+ }
399+ return list;
400+}
401+
402+Tp::ChannelDetailsList BaseConnection::channelsDetails()
403+{
404+ Tp::ChannelDetailsList list;
405+ foreach(const BaseChannelPtr & c, mPriv->channels)
406+ list << c->details();
407+ return list;
408+}
409+
410+BaseChannelPtr BaseConnection::ensureChannel(const QString &channelType, uint targetHandleType,
411+ uint targetHandle, bool &yours, uint initiatorHandle,
412+ bool suppressHandler,
413+ const QVariantMap &hints,
414+ DBusError* error)
415+{
416+ foreach(BaseChannelPtr channel, mPriv->channels) {
417+ if (channel->channelType() == channelType
418+ && channel->targetHandleType() == targetHandleType
419+ && channel->targetHandle() == targetHandle) {
420+ yours = false;
421+ return channel;
422+ }
423+ }
424+ yours = true;
425+ return createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, hints, error);
426+}
427+
428+void BaseConnection::removeChannel()
429+{
430+ BaseChannelPtr channel = BaseChannelPtr(
431+ qobject_cast<BaseChannel*>(sender()));
432+ Q_ASSERT(channel);
433+ Q_ASSERT(mPriv->channels.contains(channel));
434+ mPriv->channels.remove(channel);
435+}
436+
437+/**
438+ * Return a list of interfaces that have been plugged into this Protocol
439+ * D-Bus object with plugInterface().
440+ *
441+ * This property is immutable and cannot change after this Protocol
442+ * object has been registered on the bus with registerObject().
443+ *
444+ * \return A list containing all the Protocol interface implementation objects.
445+ * \sa plugInterface(), interface()
446+ */
447+QList<AbstractConnectionInterfacePtr> BaseConnection::interfaces() const
448+{
449+ return mPriv->interfaces.values();
450+}
451+
452+/**
453+ * Return a pointer to the interface with the given name.
454+ *
455+ * \param interfaceName The D-Bus name of the interface,
456+ * ex. TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING.
457+ * \return A pointer to the AbstractConnectionInterface object that implements
458+ * the D-Bus interface with the given name, or a null pointer if such an interface
459+ * has not been plugged into this object.
460+ * \sa plugInterface(), interfaces()
461+ */
462+AbstractConnectionInterfacePtr BaseConnection::interface(const QString &interfaceName) const
463+{
464+ return mPriv->interfaces.value(interfaceName);
465+}
466+
467+/**
468+ * Plug a new interface into this Connection D-Bus object.
469+ *
470+ * This property is immutable and cannot change after this Protocol
471+ * object has been registered on the bus with registerObject().
472+ *
473+ * \param interface An AbstractConnectionInterface instance that implements
474+ * the interface that is to be plugged.
475+ * \return \c true on success or \c false otherwise
476+ * \sa interfaces(), interface()
477+ */
478+bool BaseConnection::plugInterface(const AbstractConnectionInterfacePtr &interface)
479+{
480+ if (isRegistered()) {
481+ warning() << "Unable to plug protocol interface " << interface->interfaceName() <<
482+ "- protocol already registered";
483+ return false;
484+ }
485+
486+ if (interface->isRegistered()) {
487+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
488+ "- interface already registered";
489+ return false;
490+ }
491+
492+ if (mPriv->interfaces.contains(interface->interfaceName())) {
493+ warning() << "Unable to plug protocol interface" << interface->interfaceName() <<
494+ "- another interface with same name already plugged";
495+ return false;
496+ }
497+
498+ debug() << "Interface" << interface->interfaceName() << "plugged";
499+ mPriv->interfaces.insert(interface->interfaceName(), interface);
500+ return true;
501+}
502+
503+/**
504+ * Register this connection object on the bus.
505+ *
506+ * If \a error is passed, any D-Bus error that may occur will
507+ * be stored there.
508+ *
509+ * \param error A pointer to an empty DBusError where any
510+ * possible D-Bus error will be stored.
511+ * \return \c true on success and \c false if there was an error
512+ * or this connection object is already registered.
513+ * \sa isRegistered()
514+ */
515+bool BaseConnection::registerObject(DBusError *error)
516+{
517+ if (isRegistered()) {
518+ return true;
519+ }
520+
521+ if (!checkValidProtocolName(mPriv->protocolName)) {
522+ if (error) {
523+ error->set(TP_QT_ERROR_INVALID_ARGUMENT,
524+ mPriv->protocolName + QLatin1String("is not a valid protocol name"));
525+ }
526+ debug() << "Unable to register connection - invalid protocol name";
527+ return false;
528+ }
529+
530+ QString escapedProtocolName = mPriv->protocolName;
531+ escapedProtocolName.replace(QLatin1Char('-'), QLatin1Char('_'));
532+ QString name = uniqueName();
533+ debug() << "cmName: " << mPriv->cmName << " escapedProtocolName: " << escapedProtocolName << " name:" << name;
534+ QString busName = QString(QLatin1String("%1%2.%3.%4"))
535+ .arg(TP_QT_CONNECTION_BUS_NAME_BASE, mPriv->cmName, escapedProtocolName, name);
536+ QString objectPath = QString(QLatin1String("%1%2/%3/%4"))
537+ .arg(TP_QT_CONNECTION_OBJECT_PATH_BASE, mPriv->cmName, escapedProtocolName, name);
538+ debug() << "busName: " << busName << " objectName: " << objectPath;
539+ DBusError _error;
540+
541+ debug() << "Connection: registering interfaces at " << dbusObject();
542+ foreach(const AbstractConnectionInterfacePtr & iface, mPriv->interfaces) {
543+ if (!iface->registerInterface(dbusObject())) {
544+ // lets not fail if an optional interface fails registering, lets warn only
545+ warning() << "Unable to register interface" << iface->interfaceName();
546+ }
547+ }
548+
549+ bool ret = registerObject(busName, objectPath, &_error);
550+ if (!ret && error) {
551+ error->set(_error.name(), _error.message());
552+ }
553+ return ret;
554+}
555+
556+/**
557+ * Reimplemented from DBusService.
558+ */
559+bool BaseConnection::registerObject(const QString &busName,
560+ const QString &objectPath, DBusError *error)
561+{
562+ return DBusService::registerObject(busName, objectPath, error);
563+}
564+
565+void BaseConnection::setSelfHandle(uint selfHandle)
566+{
567+ bool changed = (selfHandle != mPriv->selfHandle);
568+ mPriv->selfHandle = selfHandle;
569+ if (changed)
570+ emit mPriv->adaptee->selfHandleChanged(mPriv->selfHandle);
571+}
572+
573+uint BaseConnection::selfHandle() const
574+{
575+ return mPriv->selfHandle;
576+}
577+
578+void BaseConnection::setConnectCallback(const ConnectCallback &cb)
579+{
580+ mPriv->connectCB = cb;
581+}
582+
583+void BaseConnection::setInspectHandlesCallback(const InspectHandlesCallback &cb)
584+{
585+ mPriv->inspectHandlesCB = cb;
586+}
587+
588+/**
589+ * \fn void BaseConnection::disconnected()
590+ *
591+ * Emitted when this connection has been disconnected.
592+ */
593+
594+/**
595+ * \class AbstractConnectionInterface
596+ * \ingroup servicecm
597+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
598+ *
599+ * \brief Base class for all the Connection object interface implementations.
600+ */
601+
602+AbstractConnectionInterface::AbstractConnectionInterface(const QString &interfaceName)
603+ : AbstractDBusServiceInterface(interfaceName)
604+{
605+}
606+
607+AbstractConnectionInterface::~AbstractConnectionInterface()
608+{
609+}
610+
611+// Conn.I.Requests
612+BaseConnectionRequestsInterface::Adaptee::Adaptee(BaseConnectionRequestsInterface *interface)
613+ : QObject(interface),
614+ mInterface(interface)
615+{
616+}
617+
618+BaseConnectionRequestsInterface::Adaptee::~Adaptee()
619+{
620+}
621+
622+void BaseConnectionRequestsInterface::Adaptee::ensureChannel(const QVariantMap &request,
623+ const Tp::Service::ConnectionInterfaceRequestsAdaptor::EnsureChannelContextPtr &context)
624+{
625+ DBusError error;
626+ bool yours;
627+ QDBusObjectPath channel;
628+ QVariantMap details;
629+
630+ mInterface->ensureChannel(request, yours, channel, details, &error);
631+ if (error.isValid()) {
632+ context->setFinishedWithError(error.name(), error.message());
633+ return;
634+ }
635+ context->setFinished(yours, channel, details);
636+}
637+
638+void BaseConnectionRequestsInterface::Adaptee::createChannel(const QVariantMap &request,
639+ const Tp::Service::ConnectionInterfaceRequestsAdaptor::CreateChannelContextPtr &context)
640+{
641+ DBusError error;
642+ QDBusObjectPath channel;
643+ QVariantMap details;
644+
645+ mInterface->createChannel(request, channel, details, &error);
646+ if (error.isValid()) {
647+ context->setFinishedWithError(error.name(), error.message());
648+ return;
649+ }
650+ context->setFinished(channel, details);
651+}
652+
653+struct TP_QT_NO_EXPORT BaseConnectionRequestsInterface::Private {
654+ Private(BaseConnectionRequestsInterface *parent, BaseConnection *connection_)
655+ : connection(connection_), adaptee(new BaseConnectionRequestsInterface::Adaptee(parent)) {
656+ }
657+ BaseConnection *connection;
658+ BaseConnectionRequestsInterface::Adaptee *adaptee;
659+};
660+
661+/**
662+ * \class BaseConnectionRequestsInterface
663+ * \ingroup servicecm
664+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
665+ *
666+ * \brief Base class for implementations of Connection.Interface.Requests
667+ */
668+
669+/**
670+ * Class constructor.
671+ */
672+BaseConnectionRequestsInterface::BaseConnectionRequestsInterface(BaseConnection *connection)
673+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS),
674+ mPriv(new Private(this, connection))
675+{
676+}
677+
678+/**
679+ * Class destructor.
680+ */
681+BaseConnectionRequestsInterface::~BaseConnectionRequestsInterface()
682+{
683+ delete mPriv;
684+}
685+
686+/**
687+ * Return the immutable properties of this interface.
688+ *
689+ * Immutable properties cannot change after the interface has been registered
690+ * on a service on the bus with registerInterface().
691+ *
692+ * \return The immutable properties of this interface.
693+ */
694+QVariantMap BaseConnectionRequestsInterface::immutableProperties() const
695+{
696+ QVariantMap map;
697+ map.insert(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS + QLatin1String(".RequestableChannelClasses"),
698+ QVariant::fromValue(mPriv->adaptee->requestableChannelClasses()));
699+ return map;
700+}
701+
702+void BaseConnectionRequestsInterface::createAdaptor()
703+{
704+ (void) new Service::ConnectionInterfaceRequestsAdaptor(dbusObject()->dbusConnection(),
705+ mPriv->adaptee, dbusObject());
706+}
707+
708+Tp::ChannelDetailsList BaseConnectionRequestsInterface::Adaptee::channels() const
709+{
710+ return mInterface->mPriv->connection->channelsDetails();
711+}
712+
713+void BaseConnectionRequestsInterface::newChannels(const Tp::ChannelDetailsList &channels)
714+{
715+ mPriv->adaptee->newChannels(channels);
716+}
717+
718+void BaseConnectionRequestsInterface::ensureChannel(const QVariantMap &request, bool &yours,
719+ QDBusObjectPath &objectPath, QVariantMap &details, DBusError *error)
720+{
721+ if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))
722+ || !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"))
723+ || (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"))
724+ && !request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")))) {
725+ error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Missing parameters"));
726+ return;
727+ }
728+
729+ QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
730+ uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
731+ uint targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
732+
733+ bool suppressHandler = true;
734+ BaseChannelPtr channel = mPriv->connection->ensureChannel(channelType, targetHandleType,
735+ targetHandle, yours,
736+ mPriv->connection->selfHandle(),
737+ suppressHandler,
738+ request,
739+ error);
740+ if (error->isValid())
741+ return;
742+
743+ objectPath = QDBusObjectPath(channel->objectPath());
744+ details = channel->details().properties;
745+}
746+
747+void BaseConnectionRequestsInterface::createChannel(const QVariantMap &request,
748+ QDBusObjectPath &objectPath,
749+ QVariantMap &details, DBusError *error)
750+{
751+ if (!request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"))) {
752+ error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Missing parameters"));
753+ return;
754+ }
755+
756+ QString channelType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType")].toString();
757+ uint targetHandleType = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType")].toUInt();
758+ uint targetHandle = request[TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")].toUInt();
759+
760+ bool suppressHandler = true;
761+ BaseChannelPtr channel = mPriv->connection->createChannel(channelType, targetHandleType,
762+ targetHandle,
763+ mPriv->connection->selfHandle(),
764+ suppressHandler,
765+ request,
766+ error);
767+ if (error->isValid())
768+ return;
769+
770+ objectPath = QDBusObjectPath(channel->objectPath());
771+ details = channel->details().properties;
772+}
773+
774+
775+// Conn.I.Contacts
776+BaseConnectionContactsInterface::Adaptee::Adaptee(BaseConnectionContactsInterface *interface)
777+ : QObject(interface),
778+ mInterface(interface)
779+{
780+}
781+
782+BaseConnectionContactsInterface::Adaptee::~Adaptee()
783+{
784+}
785+
786+void BaseConnectionContactsInterface::Adaptee::getContactAttributes(const Tp::UIntList &handles,
787+ const QStringList &interfaces, bool /*hold*/,
788+ const Tp::Service::ConnectionInterfaceContactsAdaptor::GetContactAttributesContextPtr &context)
789+{
790+ DBusError error;
791+ ContactAttributesMap contactAttributes = mInterface->getContactAttributes(handles, interfaces, &error);
792+ if (error.isValid()) {
793+ context->setFinishedWithError(error.name(), error.message());
794+ return;
795+ }
796+ context->setFinished(contactAttributes);
797+}
798+
799+struct TP_QT_NO_EXPORT BaseConnectionContactsInterface::Private {
800+ Private(BaseConnectionContactsInterface *parent)
801+ : adaptee(new BaseConnectionContactsInterface::Adaptee(parent)) {
802+ }
803+ QStringList contactAttributeInterfaces;
804+ GetContactAttributesCallback getContactAttributesCallback;
805+ BaseConnectionContactsInterface::Adaptee *adaptee;
806+};
807+
808+QStringList BaseConnectionContactsInterface::Adaptee::contactAttributeInterfaces() const
809+{
810+ return mInterface->mPriv->contactAttributeInterfaces;
811+}
812+
813+/**
814+ * \class BaseConnectionContactsInterface
815+ * \ingroup servicecm
816+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
817+ *
818+ * \brief Base class for implementations of Connection.Interface.Contacts
819+ */
820+
821+/**
822+ * Class constructor.
823+ */
824+BaseConnectionContactsInterface::BaseConnectionContactsInterface()
825+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACTS),
826+ mPriv(new Private(this))
827+{
828+}
829+
830+/**
831+ * Class destructor.
832+ */
833+BaseConnectionContactsInterface::~BaseConnectionContactsInterface()
834+{
835+ delete mPriv;
836+}
837+
838+/**
839+ * Return the immutable properties of this<interface.
840+ *
841+ * Immutable properties cannot change after the interface has been registered
842+ * on a service on the bus with registerInterface().
843+ *
844+ * \return The immutable properties of this interface.
845+ */
846+QVariantMap BaseConnectionContactsInterface::immutableProperties() const
847+{
848+ QVariantMap map;
849+ map.insert(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACTS + QLatin1String(".ContactAttributeInterfaces"),
850+ QVariant::fromValue(mPriv->adaptee->contactAttributeInterfaces()));
851+ return map;
852+}
853+
854+void BaseConnectionContactsInterface::createAdaptor()
855+{
856+ (void) new Service::ConnectionInterfaceContactsAdaptor(dbusObject()->dbusConnection(),
857+ mPriv->adaptee, dbusObject());
858+}
859+
860+void BaseConnectionContactsInterface::setContactAttributeInterfaces(const QStringList &contactAttributeInterfaces)
861+{
862+ mPriv->contactAttributeInterfaces = contactAttributeInterfaces;
863+}
864+
865+void BaseConnectionContactsInterface::setGetContactAttributesCallback(const GetContactAttributesCallback &cb)
866+{
867+ mPriv->getContactAttributesCallback = cb;
868+}
869+
870+ContactAttributesMap BaseConnectionContactsInterface::getContactAttributes(const Tp::UIntList &handles,
871+ const QStringList &interfaces,
872+ DBusError *error)
873+{
874+ if (!mPriv->getContactAttributesCallback.isValid()) {
875+ error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
876+ return ContactAttributesMap();
877+ }
878+ return mPriv->getContactAttributesCallback(handles, interfaces, error);
879+}
880+
881+// Conn.I.SimplePresence
882+BaseConnectionSimplePresenceInterface::Adaptee::Adaptee(BaseConnectionSimplePresenceInterface *interface)
883+ : QObject(interface),
884+ mInterface(interface)
885+{
886+}
887+
888+BaseConnectionSimplePresenceInterface::Adaptee::~Adaptee()
889+{
890+}
891+
892+struct TP_QT_NO_EXPORT BaseConnectionSimplePresenceInterface::Private {
893+ Private(BaseConnectionSimplePresenceInterface *parent)
894+ : maxmimumStatusMessageLength(0),
895+ adaptee(new BaseConnectionSimplePresenceInterface::Adaptee(parent)) {
896+ }
897+ SetPresenceCallback setPresenceCB;
898+ SimpleStatusSpecMap statuses;
899+ uint maxmimumStatusMessageLength;
900+ /* The current presences */
901+ SimpleContactPresences presences;
902+ BaseConnectionSimplePresenceInterface::Adaptee *adaptee;
903+};
904+
905+/**
906+ * \class BaseConnectionSimplePresenceInterface
907+ * \ingroup servicecm
908+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
909+ *
910+ * \brief Base class for implementations of Connection.Interface.SimplePresence
911+ */
912+
913+/**
914+ * Class constructor.
915+ */
916+BaseConnectionSimplePresenceInterface::BaseConnectionSimplePresenceInterface()
917+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE),
918+ mPriv(new Private(this))
919+{
920+}
921+
922+/**
923+ * Class destructor.
924+ */
925+BaseConnectionSimplePresenceInterface::~BaseConnectionSimplePresenceInterface()
926+{
927+ delete mPriv;
928+}
929+
930+/**
931+ * Return the immutable properties of this<interface.
932+ *
933+ * Immutable properties cannot change after the interface has been registered
934+ * on a service on the bus with registerInterface().
935+ *
936+ * \return The immutable properties of this interface.
937+ */
938+QVariantMap BaseConnectionSimplePresenceInterface::immutableProperties() const
939+{
940+ QVariantMap map;
941+ //FIXME
942+ return map;
943+}
944+
945+void BaseConnectionSimplePresenceInterface::createAdaptor()
946+{
947+ (void) new Service::ConnectionInterfaceSimplePresenceAdaptor(dbusObject()->dbusConnection(),
948+ mPriv->adaptee, dbusObject());
949+}
950+
951+
952+
953+void BaseConnectionSimplePresenceInterface::setPresences(const Tp::SimpleContactPresences &presences)
954+{
955+ foreach(uint handle, presences.keys()) {
956+ mPriv->presences[handle] = presences[handle];
957+ }
958+ emit mPriv->adaptee->presencesChanged(presences);
959+}
960+
961+void BaseConnectionSimplePresenceInterface::setSetPresenceCallback(const SetPresenceCallback &cb)
962+{
963+ mPriv->setPresenceCB = cb;
964+}
965+
966+void BaseConnectionSimplePresenceInterface::setStatuses(const SimpleStatusSpecMap &statuses)
967+{
968+ mPriv->statuses = statuses;
969+}
970+
971+void BaseConnectionSimplePresenceInterface::setMaxmimumStatusMessageLength(uint maxmimumStatusMessageLength)
972+{
973+ mPriv->maxmimumStatusMessageLength = maxmimumStatusMessageLength;
974+}
975+
976+
977+Tp::SimpleStatusSpecMap BaseConnectionSimplePresenceInterface::Adaptee::statuses() const
978+{
979+ return mInterface->mPriv->statuses;
980+}
981+
982+int BaseConnectionSimplePresenceInterface::Adaptee::maximumStatusMessageLength() const
983+{
984+ return mInterface->mPriv->maxmimumStatusMessageLength;
985+}
986+
987+void BaseConnectionSimplePresenceInterface::Adaptee::setPresence(const QString &status, const QString &statusMessage_,
988+ const Tp::Service::ConnectionInterfaceSimplePresenceAdaptor::SetPresenceContextPtr &context)
989+{
990+ if (!mInterface->mPriv->setPresenceCB.isValid()) {
991+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
992+ return;
993+ }
994+
995+ SimpleStatusSpecMap::Iterator i = mInterface->mPriv->statuses.find(status);
996+ if (i == mInterface->mPriv->statuses.end()) {
997+ warning() << "BaseConnectionSimplePresenceInterface::Adaptee::setPresence: status is not in statuses";
998+ context->setFinishedWithError(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("status not in statuses"));
999+ return;
1000+ }
1001+
1002+ QString statusMessage = statusMessage_;
1003+ if ((uint)statusMessage.length() > mInterface->mPriv->maxmimumStatusMessageLength) {
1004+ debug() << "BaseConnectionSimplePresenceInterface::Adaptee::setPresence: "
1005+ << "truncating status to " << mInterface->mPriv->maxmimumStatusMessageLength;
1006+ statusMessage = statusMessage.left(mInterface->mPriv->maxmimumStatusMessageLength);
1007+ }
1008+
1009+ DBusError error;
1010+ uint selfHandle = mInterface->mPriv->setPresenceCB(status, statusMessage, &error);
1011+ if (error.isValid()) {
1012+ context->setFinishedWithError(error.name(), error.message());
1013+ return;
1014+ }
1015+ Tp::SimplePresence presence;
1016+ presence.type = i->type;
1017+ presence.status = status;
1018+ presence.statusMessage = statusMessage;
1019+ mInterface->mPriv->presences[selfHandle] = presence;
1020+
1021+ /* Emit PresencesChanged */
1022+ SimpleContactPresences presences;
1023+ presences[selfHandle] = presence;
1024+ //emit after return
1025+ QMetaObject::invokeMethod(mInterface->mPriv->adaptee, "presencesChanged",
1026+ Qt::QueuedConnection,
1027+ Q_ARG(Tp::SimpleContactPresences, presences));
1028+ context->setFinished();
1029+}
1030+
1031+void BaseConnectionSimplePresenceInterface::Adaptee::getPresences(const Tp::UIntList &contacts,
1032+ const Tp::Service::ConnectionInterfaceSimplePresenceAdaptor::GetPresencesContextPtr &context)
1033+{
1034+ Tp::SimpleContactPresences presences;
1035+ foreach(uint handle, contacts) {
1036+ SimpleContactPresences::iterator i = mInterface->mPriv->presences.find(handle);
1037+ if (i == mInterface->mPriv->presences.end()) {
1038+ Tp::SimplePresence presence;
1039+ presence.type = ConnectionPresenceTypeUnknown;
1040+ presence.status = QLatin1String("unknown");
1041+ presences[handle] = presence;
1042+ } else
1043+ presences[handle] = *i;
1044+ }
1045+ context->setFinished(presences);
1046+}
1047+
1048+// Conn.I.ContactList
1049+BaseConnectionContactListInterface::Adaptee::Adaptee(BaseConnectionContactListInterface *interface)
1050+ : QObject(interface),
1051+ mInterface(interface)
1052+{
1053+}
1054+
1055+BaseConnectionContactListInterface::Adaptee::~Adaptee()
1056+{
1057+}
1058+
1059+struct TP_QT_NO_EXPORT BaseConnectionContactListInterface::Private {
1060+ Private(BaseConnectionContactListInterface *parent)
1061+ : contactListState(ContactListStateNone),
1062+ contactListPersists(false),
1063+ canChangeContactList(true),
1064+ requestUsesMessage(false),
1065+ downloadAtConnection(false),
1066+ adaptee(new BaseConnectionContactListInterface::Adaptee(parent)) {
1067+ }
1068+ uint contactListState;
1069+ bool contactListPersists;
1070+ bool canChangeContactList;
1071+ bool requestUsesMessage;
1072+ bool downloadAtConnection;
1073+ GetContactListAttributesCallback getContactListAttributesCB;
1074+ RequestSubscriptionCallback requestSubscriptionCB;
1075+ BaseConnectionContactListInterface::Adaptee *adaptee;
1076+};
1077+
1078+/**
1079+ * \class BaseConnectionContactListInterface
1080+ * \ingroup servicecm
1081+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
1082+ *
1083+ * \brief Base class for implementations of Connection.Interface.ContactList
1084+ */
1085+
1086+/**
1087+ * Class constructor.
1088+ */
1089+BaseConnectionContactListInterface::BaseConnectionContactListInterface()
1090+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST),
1091+ mPriv(new Private(this))
1092+{
1093+}
1094+
1095+/**
1096+ * Class destructor.
1097+ */
1098+BaseConnectionContactListInterface::~BaseConnectionContactListInterface()
1099+{
1100+ delete mPriv;
1101+}
1102+
1103+/**
1104+ * Return the immutable properties of this<interface.
1105+ *
1106+ * Immutable properties cannot change after the interface has been registered
1107+ * on a service on the bus with registerInterface().
1108+ *
1109+ * \return The immutable properties of this interface.
1110+ */
1111+QVariantMap BaseConnectionContactListInterface::immutableProperties() const
1112+{
1113+ QVariantMap map;
1114+ return map;
1115+}
1116+
1117+void BaseConnectionContactListInterface::createAdaptor()
1118+{
1119+ (void) new Service::ConnectionInterfaceContactListAdaptor(dbusObject()->dbusConnection(),
1120+ mPriv->adaptee, dbusObject());
1121+}
1122+
1123+void BaseConnectionContactListInterface::setContactListState(uint contactListState)
1124+{
1125+ bool changed = (contactListState != mPriv->contactListState);
1126+ mPriv->contactListState = contactListState;
1127+ if (changed)
1128+ //emit after return
1129+ QMetaObject::invokeMethod(mPriv->adaptee, "contactListStateChanged",
1130+ Qt::QueuedConnection,
1131+ Q_ARG(uint, contactListState));
1132+
1133+}
1134+
1135+void BaseConnectionContactListInterface::setContactListPersists(bool contactListPersists)
1136+{
1137+ mPriv->contactListPersists = contactListPersists;
1138+}
1139+
1140+void BaseConnectionContactListInterface::setCanChangeContactList(bool canChangeContactList)
1141+{
1142+ mPriv->canChangeContactList = canChangeContactList;
1143+}
1144+
1145+void BaseConnectionContactListInterface::setRequestUsesMessage(bool requestUsesMessage)
1146+{
1147+ mPriv->requestUsesMessage = requestUsesMessage;
1148+}
1149+
1150+void BaseConnectionContactListInterface::setDownloadAtConnection(bool downloadAtConnection)
1151+{
1152+ mPriv->downloadAtConnection = downloadAtConnection;
1153+}
1154+
1155+void BaseConnectionContactListInterface::setGetContactListAttributesCallback(const GetContactListAttributesCallback &cb)
1156+{
1157+ mPriv->getContactListAttributesCB = cb;
1158+}
1159+
1160+void BaseConnectionContactListInterface::setRequestSubscriptionCallback(const RequestSubscriptionCallback &cb)
1161+{
1162+ mPriv->requestSubscriptionCB = cb;
1163+}
1164+
1165+void BaseConnectionContactListInterface::contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals)
1166+{
1167+ emit mPriv->adaptee->contactsChangedWithID(changes, identifiers, removals);
1168+}
1169+
1170+uint BaseConnectionContactListInterface::Adaptee::contactListState() const
1171+{
1172+ return mInterface->mPriv->contactListState;
1173+}
1174+
1175+bool BaseConnectionContactListInterface::Adaptee::contactListPersists() const
1176+{
1177+ return mInterface->mPriv->contactListPersists;
1178+}
1179+
1180+bool BaseConnectionContactListInterface::Adaptee::canChangeContactList() const
1181+{
1182+ return mInterface->mPriv->canChangeContactList;
1183+}
1184+
1185+bool BaseConnectionContactListInterface::Adaptee::requestUsesMessage() const
1186+{
1187+ return mInterface->mPriv->requestUsesMessage;
1188+}
1189+
1190+bool BaseConnectionContactListInterface::Adaptee::downloadAtConnection() const
1191+{
1192+ return mInterface->mPriv->downloadAtConnection;
1193+}
1194+
1195+void BaseConnectionContactListInterface::Adaptee::getContactListAttributes(const QStringList &interfaces,
1196+ bool hold, const Tp::Service::ConnectionInterfaceContactListAdaptor::GetContactListAttributesContextPtr &context)
1197+{
1198+ if (!mInterface->mPriv->getContactListAttributesCB.isValid()) {
1199+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1200+ return;
1201+ }
1202+ DBusError error;
1203+ Tp::ContactAttributesMap contactAttributesMap = mInterface->mPriv->getContactListAttributesCB(interfaces, hold, &error);
1204+ if (error.isValid()) {
1205+ context->setFinishedWithError(error.name(), error.message());
1206+ return;
1207+ }
1208+ context->setFinished(contactAttributesMap);
1209+}
1210+
1211+void BaseConnectionContactListInterface::Adaptee::requestSubscription(const Tp::UIntList &contacts,
1212+ const QString &message, const Tp::Service::ConnectionInterfaceContactListAdaptor::RequestSubscriptionContextPtr &context)
1213+{
1214+ if (!mInterface->mPriv->requestSubscriptionCB.isValid()) {
1215+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1216+ return;
1217+ }
1218+ DBusError error;
1219+ mInterface->mPriv->requestSubscriptionCB(contacts, message, &error);
1220+ if (error.isValid()) {
1221+ context->setFinishedWithError(error.name(), error.message());
1222+ return;
1223+ }
1224+ context->setFinished();
1225+}
1226+
1227+// Conn.I.Addressing
1228+BaseConnectionAddressingInterface::Adaptee::Adaptee(BaseConnectionAddressingInterface *interface)
1229+ : QObject(interface),
1230+ mInterface(interface)
1231+{
1232+}
1233+
1234+BaseConnectionAddressingInterface::Adaptee::~Adaptee()
1235+{
1236+}
1237+
1238+struct TP_QT_NO_EXPORT BaseConnectionAddressingInterface::Private {
1239+ Private(BaseConnectionAddressingInterface *parent)
1240+ : adaptee(new BaseConnectionAddressingInterface::Adaptee(parent)) {
1241+ }
1242+ GetContactsByVCardFieldCallback getContactsByVCardFieldCB;
1243+ GetContactsByURICallback getContactsByURICB;
1244+ BaseConnectionAddressingInterface::Adaptee *adaptee;
1245+};
1246+
1247+/**
1248+ * \class BaseProtocolPresenceInterface
1249+ * \ingroup servicecm
1250+ * \headerfile TelepathyQt/base-protocol.h <TelepathyQt/BaseProtocolPresenceInterface>
1251+ *
1252+ * \brief Base class for implementations of Protocol.Interface.Presence
1253+ */
1254+
1255+/**
1256+ * Class constructor.
1257+ */
1258+BaseConnectionAddressingInterface::BaseConnectionAddressingInterface()
1259+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING),
1260+ mPriv(new Private(this))
1261+{
1262+}
1263+
1264+/**
1265+ * Class destructor.
1266+ */
1267+BaseConnectionAddressingInterface::~BaseConnectionAddressingInterface()
1268+{
1269+ delete mPriv;
1270+}
1271+
1272+/**
1273+ * Return the immutable properties of this<interface.
1274+ *
1275+ * Immutable properties cannot change after the interface has been registered
1276+ * on a service on the bus with registerInterface().
1277+ *
1278+ * \return The immutable properties of this interface.
1279+ */
1280+QVariantMap BaseConnectionAddressingInterface::immutableProperties() const
1281+{
1282+ QVariantMap map;
1283+ return map;
1284+}
1285+
1286+void BaseConnectionAddressingInterface::createAdaptor()
1287+{
1288+ (void) new Service::ConnectionInterfaceAddressingAdaptor(dbusObject()->dbusConnection(),
1289+ mPriv->adaptee, dbusObject());
1290+}
1291+
1292+void BaseConnectionAddressingInterface::setGetContactsByVCardFieldCallback(const GetContactsByVCardFieldCallback &cb)
1293+{
1294+ mPriv->getContactsByVCardFieldCB = cb;
1295+}
1296+
1297+void BaseConnectionAddressingInterface::setGetContactsByURICallback(const GetContactsByURICallback &cb)
1298+{
1299+ mPriv->getContactsByURICB = cb;
1300+}
1301+
1302+void BaseConnectionAddressingInterface::Adaptee::getContactsByVCardField(const QString &field,
1303+ const QStringList &addresses,
1304+ const QStringList &interfaces,
1305+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByVCardFieldContextPtr &context)
1306+{
1307+ if (!mInterface->mPriv->getContactsByVCardFieldCB.isValid()) {
1308+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1309+ return;
1310+ }
1311+ Tp::AddressingNormalizationMap addressingNormalizationMap;
1312+ Tp::ContactAttributesMap contactAttributesMap;
1313+
1314+ DBusError error;
1315+ mInterface->mPriv->getContactsByVCardFieldCB(field, addresses, interfaces,
1316+ addressingNormalizationMap, contactAttributesMap,
1317+ &error);
1318+ if (error.isValid()) {
1319+ context->setFinishedWithError(error.name(), error.message());
1320+ return;
1321+ }
1322+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
1323+}
1324+
1325+void BaseConnectionAddressingInterface::Adaptee::getContactsByURI(const QStringList &URIs,
1326+ const QStringList &interfaces,
1327+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByURIContextPtr &context)
1328+{
1329+ if (!mInterface->mPriv->getContactsByURICB.isValid()) {
1330+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
1331+ return;
1332+ }
1333+ Tp::AddressingNormalizationMap addressingNormalizationMap;
1334+ Tp::ContactAttributesMap contactAttributesMap;
1335+
1336+ DBusError error;
1337+ mInterface->mPriv->getContactsByURICB(URIs, interfaces,
1338+ addressingNormalizationMap, contactAttributesMap,
1339+ &error);
1340+ if (error.isValid()) {
1341+ context->setFinishedWithError(error.name(), error.message());
1342+ return;
1343+ }
1344+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
1345+}
1346+
1347+}
1348
1349=== modified file '.pc/applied-patches'
1350--- .pc/applied-patches 2014-12-01 19:58:52 +0000
1351+++ .pc/applied-patches 2015-02-19 13:15:12 +0000
1352@@ -8,3 +8,4 @@
1353 08-add_conference_call_client_side.patch
1354 09-add_sms_iface_service_side.patch
1355 10-emit_selfHandleChanged.patch
1356+11-fix-requested.patch
1357
1358=== modified file 'TelepathyQt/base-connection.cpp'
1359--- TelepathyQt/base-connection.cpp 2014-12-01 19:58:52 +0000
1360+++ TelepathyQt/base-connection.cpp 2015-02-19 13:15:12 +0000
1361@@ -328,7 +328,7 @@
1362 channel->setInitiatorHandle(initiatorHandle);
1363 channel->setInitiatorID(initiatorID);
1364 channel->setTargetID(targetID);
1365- channel->setRequested(initiatorHandle == mPriv->selfHandle);
1366+ channel->setRequested(suppressHandler);
1367
1368 channel->registerObject(error);
1369 if (error->isValid())
1370
1371=== modified file 'debian/changelog'
1372--- debian/changelog 2015-01-28 14:17:09 +0000
1373+++ debian/changelog 2015-02-19 13:15:12 +0000
1374@@ -1,3 +1,9 @@
1375+telepathy-qt5 (0.9.3-0ubuntu15) vivid; urgency=medium
1376+
1377+ * Don't set "Requested" based on initiatorHandler and selfHandle.
1378+
1379+ -- Tiago Salem Herrmann <tiago.herrmann@canonical.com> Thu, 19 Feb 2015 10:51:37 -0200
1380+
1381 telepathy-qt5 (0.9.3-0ubuntu14) vivid; urgency=medium
1382
1383 [ Tiago Salem Herrmann ]
1384
1385=== added file 'debian/patches/11-fix-requested.patch'
1386--- debian/patches/11-fix-requested.patch 1970-01-01 00:00:00 +0000
1387+++ debian/patches/11-fix-requested.patch 2015-02-19 13:15:12 +0000
1388@@ -0,0 +1,18 @@
1389+Description: Don't set "Requested" based on initiatorHandle and selfHandle
1390+Author: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
1391+Forwarded: no
1392+
1393+diff:
1394+Index: telepathy-qt5/TelepathyQt/base-connection.cpp
1395+===================================================================
1396+--- telepathy-qt5.orig/TelepathyQt/base-connection.cpp
1397++++ telepathy-qt5/TelepathyQt/base-connection.cpp
1398+@@ -328,7 +328,7 @@ Tp::BaseChannelPtr BaseConnection::creat
1399+ channel->setInitiatorHandle(initiatorHandle);
1400+ channel->setInitiatorID(initiatorID);
1401+ channel->setTargetID(targetID);
1402+- channel->setRequested(initiatorHandle == mPriv->selfHandle);
1403++ channel->setRequested(suppressHandler);
1404+
1405+ channel->registerObject(error);
1406+ if (error->isValid())
1407
1408=== modified file 'debian/patches/series'
1409--- debian/patches/series 2014-12-01 19:58:52 +0000
1410+++ debian/patches/series 2015-02-19 13:15:12 +0000
1411@@ -8,3 +8,4 @@
1412 08-add_conference_call_client_side.patch
1413 09-add_sms_iface_service_side.patch
1414 10-emit_selfHandleChanged.patch
1415+11-fix-requested.patch

Subscribers

People subscribed via source and target branches