summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2013-03-25 22:53:17 -0500
committerDavid Edmundson <davidedmundson@kde.org>2014-06-14 13:51:54 +0200
commit14c2f25952b3e94d96028b1d806b330faede3bfe (patch)
treec9baefc6fbe878d2d2279e577b778effc97001ad
parent172464d51f36ede3e6e07dd9cc6357eca24aabe0 (diff)
Add BaseConnectionContactListInterface
-rw-r--r--TelepathyQt/base-connection-internal.h33
-rw-r--r--TelepathyQt/base-connection.cpp177
-rw-r--r--TelepathyQt/base-connection.h44
-rw-r--r--TelepathyQt/service-types.h2
4 files changed, 256 insertions, 0 deletions
diff --git a/TelepathyQt/base-connection-internal.h b/TelepathyQt/base-connection-internal.h
index 3aa9e2e2..09254aa7 100644
--- a/TelepathyQt/base-connection-internal.h
+++ b/TelepathyQt/base-connection-internal.h
@@ -159,4 +159,37 @@ public:
BaseConnectionSimplePresenceInterface *mInterface;
};
+class TP_QT_NO_EXPORT BaseConnectionContactListInterface::Adaptee : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(uint contactListState READ contactListState)
+ Q_PROPERTY(bool contactListPersists READ contactListPersists)
+ Q_PROPERTY(bool canChangeContactList READ canChangeContactList)
+ Q_PROPERTY(bool requestUsesMessage READ requestUsesMessage)
+ Q_PROPERTY(bool downloadAtConnection READ downloadAtConnection)
+public:
+ Adaptee(BaseConnectionContactListInterface *interface);
+ ~Adaptee();
+
+ uint contactListState() const;
+ bool contactListPersists() const;
+ bool canChangeContactList() const;
+ bool requestUsesMessage() const;
+ bool downloadAtConnection() const;
+private Q_SLOTS:
+ void getContactListAttributes(const QStringList &interfaces, bool hold, const Tp::Service::ConnectionInterfaceContactListAdaptor::GetContactListAttributesContextPtr &context);
+ void requestSubscription(const Tp::UIntList &contacts, const QString &message, const Tp::Service::ConnectionInterfaceContactListAdaptor::RequestSubscriptionContextPtr &context);
+ //void authorizePublication(const Tp::UIntList &contacts, const Tp::Service::ConnectionInterfaceContactListAdaptor::AuthorizePublicationContextPtr &context);
+ //void removeContacts(const Tp::UIntList &contacts, const Tp::Service::ConnectionInterfaceContactListAdaptor::RemoveContactsContextPtr &context);
+ //void unsubscribe(const Tp::UIntList &contacts, const Tp::Service::ConnectionInterfaceContactListAdaptor::UnsubscribeContextPtr &context);
+ //void unpublish(const Tp::UIntList &contacts, const Tp::Service::ConnectionInterfaceContactListAdaptor::UnpublishContextPtr &context);
+ //void download(const Tp::Service::ConnectionInterfaceContactListAdaptor::DownloadContextPtr &context);
+Q_SIGNALS:
+ void contactListStateChanged(uint contactListState);
+ void contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals);
+ void contactsChanged(const Tp::ContactSubscriptionMap &changes, const Tp::UIntList &removals);
+
+public:
+ BaseConnectionContactListInterface *mInterface;
+};
}
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index a1a863ff..f7909b0f 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -1044,6 +1044,183 @@ void BaseConnectionSimplePresenceInterface::Adaptee::getPresences(const Tp::UInt
context->setFinished(presences);
}
+// Conn.I.ContactList
+BaseConnectionContactListInterface::Adaptee::Adaptee(BaseConnectionContactListInterface *interface)
+ : QObject(interface),
+ mInterface(interface)
+{
+}
+
+BaseConnectionContactListInterface::Adaptee::~Adaptee()
+{
+}
+
+struct TP_QT_NO_EXPORT BaseConnectionContactListInterface::Private {
+ Private(BaseConnectionContactListInterface *parent)
+ : contactListState(ContactListStateNone),
+ contactListPersists(false),
+ canChangeContactList(true),
+ requestUsesMessage(false),
+ downloadAtConnection(false),
+ adaptee(new BaseConnectionContactListInterface::Adaptee(parent)) {
+ }
+ uint contactListState;
+ bool contactListPersists;
+ bool canChangeContactList;
+ bool requestUsesMessage;
+ bool downloadAtConnection;
+ GetContactListAttributesCallback getContactListAttributesCB;
+ RequestSubscriptionCallback requestSubscriptionCB;
+ BaseConnectionContactListInterface::Adaptee *adaptee;
+};
+
+/**
+ * \class BaseConnectionContactListInterface
+ * \ingroup servicecm
+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
+ *
+ * \brief Base class for implementations of Connection.Interface.ContactList
+ */
+
+/**
+ * Class constructor.
+ */
+BaseConnectionContactListInterface::BaseConnectionContactListInterface()
+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST),
+ mPriv(new Private(this))
+{
+}
+
+/**
+ * Class destructor.
+ */
+BaseConnectionContactListInterface::~BaseConnectionContactListInterface()
+{
+ delete mPriv;
+}
+
+/**
+ * Return the immutable properties of this<interface.
+ *
+ * Immutable properties cannot change after the interface has been registered
+ * on a service on the bus with registerInterface().
+ *
+ * \return The immutable properties of this interface.
+ */
+QVariantMap BaseConnectionContactListInterface::immutableProperties() const
+{
+ QVariantMap map;
+ return map;
+}
+
+void BaseConnectionContactListInterface::createAdaptor()
+{
+ (void) new Service::ConnectionInterfaceContactListAdaptor(dbusObject()->dbusConnection(),
+ mPriv->adaptee, dbusObject());
+}
+
+void BaseConnectionContactListInterface::setContactListState(uint contactListState)
+{
+ bool changed = (contactListState != mPriv->contactListState);
+ mPriv->contactListState = contactListState;
+ if (changed)
+ //emit after return
+ QMetaObject::invokeMethod(mPriv->adaptee, "contactListStateChanged",
+ Qt::QueuedConnection,
+ Q_ARG(uint, contactListState));
+
+}
+
+void BaseConnectionContactListInterface::setContactListPersists(bool contactListPersists)
+{
+ mPriv->contactListPersists = contactListPersists;
+}
+
+void BaseConnectionContactListInterface::setCanChangeContactList(bool canChangeContactList)
+{
+ mPriv->canChangeContactList = canChangeContactList;
+}
+
+void BaseConnectionContactListInterface::setRequestUsesMessage(bool requestUsesMessage)
+{
+ mPriv->requestUsesMessage = requestUsesMessage;
+}
+
+void BaseConnectionContactListInterface::setDownloadAtConnection(bool downloadAtConnection)
+{
+ mPriv->downloadAtConnection = downloadAtConnection;
+}
+
+void BaseConnectionContactListInterface::setGetContactListAttributesCallback(const GetContactListAttributesCallback &cb)
+{
+ mPriv->getContactListAttributesCB = cb;
+}
+
+void BaseConnectionContactListInterface::setRequestSubscriptionCallback(const RequestSubscriptionCallback &cb)
+{
+ mPriv->requestSubscriptionCB = cb;
+}
+
+void BaseConnectionContactListInterface::contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals)
+{
+ emit mPriv->adaptee->contactsChangedWithID(changes, identifiers, removals);
+}
+
+uint BaseConnectionContactListInterface::Adaptee::contactListState() const
+{
+ return mInterface->mPriv->contactListState;
+}
+
+bool BaseConnectionContactListInterface::Adaptee::contactListPersists() const
+{
+ return mInterface->mPriv->contactListPersists;
+}
+
+bool BaseConnectionContactListInterface::Adaptee::canChangeContactList() const
+{
+ return mInterface->mPriv->canChangeContactList;
+}
+bool BaseConnectionContactListInterface::Adaptee::requestUsesMessage() const
+{
+ return mInterface->mPriv->requestUsesMessage;
+}
+
+bool BaseConnectionContactListInterface::Adaptee::downloadAtConnection() const
+{
+ return mInterface->mPriv->downloadAtConnection;
+}
+
+void BaseConnectionContactListInterface::Adaptee::getContactListAttributes(const QStringList &interfaces,
+ bool hold, const Tp::Service::ConnectionInterfaceContactListAdaptor::GetContactListAttributesContextPtr &context)
+{
+ if (!mInterface->mPriv->getContactListAttributesCB.isValid()) {
+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+ return;
+ }
+ DBusError error;
+ Tp::ContactAttributesMap contactAttributesMap = mInterface->mPriv->getContactListAttributesCB(interfaces, hold, &error);
+ if (error.isValid()) {
+ context->setFinishedWithError(error.name(), error.message());
+ return;
+ }
+ context->setFinished(contactAttributesMap);
+}
+
+void BaseConnectionContactListInterface::Adaptee::requestSubscription(const Tp::UIntList &contacts,
+ const QString &message, const Tp::Service::ConnectionInterfaceContactListAdaptor::RequestSubscriptionContextPtr &context)
+{
+ if (!mInterface->mPriv->requestSubscriptionCB.isValid()) {
+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+ return;
+ }
+ DBusError error;
+ mInterface->mPriv->requestSubscriptionCB(contacts, message, &error);
+ if (error.isValid()) {
+ context->setFinishedWithError(error.name(), error.message());
+ return;
+ }
+ context->setFinished();
+}
}
diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h
index d8aa8faf..1eadc16a 100644
--- a/TelepathyQt/base-connection.h
+++ b/TelepathyQt/base-connection.h
@@ -273,6 +273,50 @@ private:
Private *mPriv;
};
+class TP_QT_EXPORT BaseConnectionContactListInterface : public AbstractConnectionInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(BaseConnectionContactListInterface)
+
+public:
+ static BaseConnectionContactListInterfacePtr create() {
+ return BaseConnectionContactListInterfacePtr(new BaseConnectionContactListInterface());
+ }
+ template<typename BaseConnectionContactListInterfaceSubclass>
+ static SharedPtr<BaseConnectionContactListInterfaceSubclass> create() {
+ return SharedPtr<BaseConnectionContactListInterfaceSubclass>(
+ new BaseConnectionContactListInterfaceSubclass());
+ }
+
+ virtual ~BaseConnectionContactListInterface();
+
+ QVariantMap immutableProperties() const;
+
+ void setContactListState(uint contactListState);
+ void setContactListPersists(bool);
+ void setCanChangeContactList(bool);
+ void setRequestUsesMessage(bool);
+ void setDownloadAtConnection(bool);
+
+ typedef Callback3<Tp::ContactAttributesMap, const QStringList&, bool, DBusError*> GetContactListAttributesCallback;
+ void setGetContactListAttributesCallback(const GetContactListAttributesCallback &cb);
+
+ typedef Callback3<void, const Tp::UIntList&, const QString&, DBusError*> RequestSubscriptionCallback;
+ void setRequestSubscriptionCallback(const RequestSubscriptionCallback &cb);
+
+ void contactsChangedWithID(const Tp::ContactSubscriptionMap &changes, const Tp::HandleIdentifierMap &identifiers, const Tp::HandleIdentifierMap &removals);
+protected:
+ BaseConnectionContactListInterface();
+
+private:
+ void createAdaptor();
+
+ class Adaptee;
+ friend class Adaptee;
+ struct Private;
+ friend struct Private;
+ Private *mPriv;
+};
}
#endif
diff --git a/TelepathyQt/service-types.h b/TelepathyQt/service-types.h
index ccf9c4cb..4a211565 100644
--- a/TelepathyQt/service-types.h
+++ b/TelepathyQt/service-types.h
@@ -39,6 +39,7 @@ class BaseConnection;
class BaseConnectionRequestsInterface;
class BaseConnectionContactsInterface;
class BaseConnectionSimplePresenceInterface;
+class BaseConnectionContactListInterface;
class BaseConnectionManager;
class BaseProtocol;
class BaseProtocolAddressingInterface;
@@ -58,6 +59,7 @@ typedef SharedPtr<BaseConnection> BaseConnectionPtr;
typedef SharedPtr<BaseConnectionRequestsInterface> BaseConnectionRequestsInterfacePtr;
typedef SharedPtr<BaseConnectionContactsInterface> BaseConnectionContactsInterfacePtr;
typedef SharedPtr<BaseConnectionSimplePresenceInterface> BaseConnectionSimplePresenceInterfacePtr;
+typedef SharedPtr<BaseConnectionContactListInterface> BaseConnectionContactListInterfacePtr;
typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr;
typedef SharedPtr<BaseProtocol> BaseProtocolPtr;
typedef SharedPtr<BaseProtocolAddressingInterface> BaseProtocolAddressingInterfacePtr;