telepathy-qt: BaseConnectionContactsInterface: Implemented getContactByID( ).
Alexandr Akulich
kaffeine at kemper.freedesktop.org
Sat Aug 29 05:49:54 PDT 2015
Module: telepathy-qt
Branch: master
Commit: c88ce6b6f9ebd529f662b5f01ef5752e6a879ec8
URL: http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=c88ce6b6f9ebd529f662b5f01ef5752e6a879ec8
Author: Alexandr Akulich <akulichalexander at gmail.com>
Date: Wed Jun 3 18:29:36 2015 +0600
BaseConnectionContactsInterface: Implemented getContactByID().
Reviewed-by: David Edmundson
---
TelepathyQt/base-connection-internal.h | 2 ++
TelepathyQt/base-connection.cpp | 35 ++++++++++++++++++++++++++++++++
TelepathyQt/base-connection.h | 2 ++
3 files changed, 39 insertions(+)
diff --git a/TelepathyQt/base-connection-internal.h b/TelepathyQt/base-connection-internal.h
index 8e4c02c..525e4ae 100644
--- a/TelepathyQt/base-connection-internal.h
+++ b/TelepathyQt/base-connection-internal.h
@@ -131,6 +131,8 @@ public:
private Q_SLOTS:
void getContactAttributes(const Tp::UIntList &handles, const QStringList &interfaces, bool hold,
const Tp::Service::ConnectionInterfaceContactsAdaptor::GetContactAttributesContextPtr &context);
+ void getContactByID(const QString &identifier, const QStringList &interfaces,
+ const Tp::Service::ConnectionInterfaceContactsAdaptor::GetContactByIDContextPtr &context);
public:
BaseConnectionContactsInterface *mInterface;
};
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index a8dc7f0..f681926 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -974,6 +974,22 @@ void BaseConnectionContactsInterface::Adaptee::getContactAttributes(const Tp::UI
context->setFinished(attributes);
}
+void BaseConnectionContactsInterface::Adaptee::getContactByID(const QString &identifier, const QStringList &interfaces,
+ const Tp::Service::ConnectionInterfaceContactsAdaptor::GetContactByIDContextPtr &context)
+{
+ debug() << "BaseConnectionContactsInterface::Adaptee::getContactByID";
+ DBusError error;
+ uint handle;
+ QVariantMap attributes;
+
+ mInterface->getContactByID(identifier, interfaces, handle, attributes, &error);
+ if (error.isValid()) {
+ context->setFinishedWithError(error.name(), error.message());
+ return;
+ }
+ context->setFinished(handle, attributes);
+}
+
/**
* \class BaseConnectionContactsInterface
* \ingroup serviceconn
@@ -1045,6 +1061,25 @@ Tp::ContactAttributesMap BaseConnectionContactsInterface::getContactAttributes(c
return mPriv->getContactAttributesCB(handles, interfaces, error);
}
+void BaseConnectionContactsInterface::getContactByID(const QString &identifier, const QStringList &interfaces, uint &handle, QVariantMap &attributes, DBusError *error)
+{
+ const Tp::UIntList handles = mPriv->connection->requestHandles(Tp::HandleTypeContact, QStringList() << identifier, error);
+ if (error->isValid() || handles.isEmpty()) {
+ // The check for empty handles is paranoid, because the error must be set in such case.
+ error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Could not process ID"));
+ return;
+ }
+
+ const Tp::ContactAttributesMap result = getContactAttributes(handles, interfaces, error);
+
+ if (error->isValid()) {
+ return;
+ }
+
+ handle = handles.first();
+ attributes = result.value(handle);
+}
+
// Conn.I.SimplePresence
BaseConnectionSimplePresenceInterface::Adaptee::Adaptee(BaseConnectionSimplePresenceInterface *interface)
: QObject(interface),
diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h
index e2b1c65..76eef59 100644
--- a/TelepathyQt/base-connection.h
+++ b/TelepathyQt/base-connection.h
@@ -221,6 +221,8 @@ public:
void setGetContactAttributesCallback(const GetContactAttributesCallback &cb);
Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &interfaces, DBusError *error);
+ void getContactByID(const QString &identifier, const QStringList &interfaces, uint &handle, QVariantMap &attributes, DBusError *error);
+
protected:
BaseConnectionContactsInterface(BaseConnection *connection);
More information about the telepathy-commits
mailing list