[telepathy-qt4/master] ClientRegistrar: Added AbstractClient/AbstractClientHandler and ClientHandlerAdaptor classes.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue May 19 06:49:06 PDT 2009


---
 TelepathyQt4/AbstractClient              |   13 ++++
 TelepathyQt4/AbstractClientHandler       |   13 ++++
 TelepathyQt4/Makefile.am                 |    7 ++
 TelepathyQt4/abstract-client.cpp         |   61 ++++++++++++++++++++
 TelepathyQt4/abstract-client.h           |   82 ++++++++++++++++++++++++++
 TelepathyQt4/client-registrar-internal.h |   92 ++++++++++++++++++++++++++++++
 TelepathyQt4/client-registrar.cpp        |   24 ++++++++
 7 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 TelepathyQt4/AbstractClient
 create mode 100644 TelepathyQt4/AbstractClientHandler
 create mode 100644 TelepathyQt4/abstract-client.cpp
 create mode 100644 TelepathyQt4/abstract-client.h
 create mode 100644 TelepathyQt4/client-registrar-internal.h

diff --git a/TelepathyQt4/AbstractClient b/TelepathyQt4/AbstractClient
new file mode 100644
index 0000000..c06bc99
--- /dev/null
+++ b/TelepathyQt4/AbstractClient
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_Client_AbstractClient_HEADER_GUARD_
+#define _TelepathyQt4_Client_AbstractClient_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/abstract-client.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/AbstractClientHandler b/TelepathyQt4/AbstractClientHandler
new file mode 100644
index 0000000..b5d7108
--- /dev/null
+++ b/TelepathyQt4/AbstractClientHandler
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_Client_AbstractClientHandler_HEADER_GUARD_
+#define _TelepathyQt4_Client_AbstractClientHandler_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/abstract-client.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index 711997b..2262a7c 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -44,11 +44,13 @@ libtelepathy_qt4_la_LIBADD = $(ALL_LIBS)
 libtelepathy_qt4_la_DEPENDENCIES = Makefile.am
 
 libtelepathy_qt4_la_SOURCES = \
+    abstract-client.cpp \
     abstract-interface.cpp \
     account.cpp \
     account-manager.cpp \
     channel.cpp \
     client-registrar.cpp \
+    client-registrar-internal.h \
     connection.cpp \
     connection-manager.cpp \
     connection-internal.h \
@@ -105,10 +107,12 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     _gen/cli-properties-body.hpp \
     _gen/cli-properties.moc.hpp \
     _gen/types-body.hpp \
+    _gen/abstract-client.moc.hpp \
     _gen/abstract-interface.moc.hpp \
     _gen/account.moc.hpp \
     _gen/account-manager.moc.hpp \
     _gen/channel.moc.hpp \
+    _gen/client-registrar-internal.moc.hpp \
     _gen/connection.moc.hpp \
     _gen/connection-manager.moc.hpp \
     _gen/connection-internal.moc.hpp \
@@ -133,6 +137,8 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     _gen/text-channel.moc.hpp
 
 tpqt4include_HEADERS = \
+    AbstractClient \
+    AbstractClientHandler \
     AbstractInterface \
     Account \
     AccountManager \
@@ -212,6 +218,7 @@ tpqt4include_HEADERS = \
     PeerInterface \
     PropertiesInterface \
     PropertiesInterfaceInterface \
+    abstract-client.h \
     abstract-interface.h \
     account.h \
     account-manager.h \
diff --git a/TelepathyQt4/abstract-client.cpp b/TelepathyQt4/abstract-client.cpp
new file mode 100644
index 0000000..cdec8a2
--- /dev/null
+++ b/TelepathyQt4/abstract-client.cpp
@@ -0,0 +1,61 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <TelepathyQt4/AbstractClient>
+
+#include "TelepathyQt4/_gen/abstract-client.moc.hpp"
+
+#include <QObject>
+#include <QString>
+
+namespace Tp
+{
+
+AbstractClient::AbstractClient()
+{
+}
+
+AbstractClient::~AbstractClient()
+{
+}
+
+struct AbstractClientHandler::Private
+{
+    ChannelClassList channelFilter;
+};
+
+AbstractClientHandler::AbstractClientHandler(const ChannelClassList &channelFilter)
+    : mPriv(new Private)
+{
+    mPriv->channelFilter = channelFilter;
+}
+
+AbstractClientHandler::~AbstractClientHandler()
+{
+    delete mPriv;
+}
+
+ChannelClassList AbstractClientHandler::channelFilter() const
+{
+    return mPriv->channelFilter;
+}
+
+} // Tp
diff --git a/TelepathyQt4/abstract-client.h b/TelepathyQt4/abstract-client.h
new file mode 100644
index 0000000..3c0744b
--- /dev/null
+++ b/TelepathyQt4/abstract-client.h
@@ -0,0 +1,82 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TelepathyQt4_cli_abstract_client_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_abstract_client_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/SharedPtr>
+#include <TelepathyQt4/Types>
+
+#include <QObject>
+
+namespace Tp
+{
+
+class AbstractClient : public QObject, public RefCounted
+{
+    Q_OBJECT
+
+public:
+    virtual ~AbstractClient();
+
+protected:
+    AbstractClient();
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+class AbstractClientHandler : public AbstractClient
+{
+    Q_OBJECT
+
+public:
+    virtual ~AbstractClientHandler();
+
+    ChannelClassList channelFilter() const;
+    virtual bool bypassApproval() const = 0;
+    virtual ObjectPathList handledChannels() const = 0;
+
+    virtual void handleChannels(const QDBusObjectPath &account,
+            const QDBusObjectPath &connection,
+            const ChannelDetailsList &channels,
+            const ObjectPathList &requestsSatisfied,
+            qulonglong userActionTime,
+            const QVariantMap &handlerInfo) = 0;
+
+protected:
+    AbstractClientHandler(const ChannelClassList &channelFilter);
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+} // Tp
+
+#endif
diff --git a/TelepathyQt4/client-registrar-internal.h b/TelepathyQt4/client-registrar-internal.h
new file mode 100644
index 0000000..f8653a0
--- /dev/null
+++ b/TelepathyQt4/client-registrar-internal.h
@@ -0,0 +1,92 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TelepathyQt4_cli_client_registrar_internal_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_client_registrar_internal_h_HEADER_GUARD_
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+
+#include <TelepathyQt4/AbstractClientHandler>
+#include <TelepathyQt4/Types>
+
+namespace Tp
+{
+
+class ClientHandlerAdaptor : public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Handler")
+    Q_CLASSINFO("D-Bus Introspection", ""
+"  <interface name=\"org.freedesktop.Telepathy.Client.Handler\" >\n"
+"    <property name=\"HandlerChannelFilter\" type=\"aa{sv}\" access=\"read\" />\n"
+"    <property name=\"BypassApproval\" type=\"b\" access=\"read\" />\n"
+"    <property name=\"HandledChannels\" type=\"ao\" access=\"read\" />\n"
+"    <method name=\"HandleChannels\" >\n"
+"      <arg name=\"Account\" type=\"o\" direction=\"in\" />\n"
+"      <arg name=\"Connection\" type=\"o\" direction=\"in\" />\n"
+"      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
+"      <arg name=\"Requests_Satisfied\" type=\"ao\" direction=\"in\" />\n"
+"      <arg name=\"User_Action_Time\" type=\"t\" direction=\"in\" />\n"
+"      <arg name=\"Handler_Info\" type=\"a{sv}\" direction=\"in\" />\n"
+"    </method>\n"
+"  </interface>\n"
+        "")
+
+    Q_PROPERTY(Tp::ChannelClassList HandlerChannelFilter READ HandlerChannelFilter)
+    Q_PROPERTY(bool BypassApproval READ BypassApproval)
+    Q_PROPERTY(Tp::ObjectPathList HandledChannels READ HandledChannels)
+
+public:
+    ClientHandlerAdaptor(AbstractClientHandler *client);
+    virtual ~ClientHandlerAdaptor();
+
+public: // Properties
+    inline Tp::ChannelClassList HandlerChannelFilter() const
+    {
+        return mClient->channelFilter();
+    }
+
+    inline bool BypassApproval() const
+    {
+        return mClient->bypassApproval();
+    }
+
+    inline Tp::ObjectPathList HandledChannels() const
+    {
+        return mClient->handledChannels();
+    }
+
+public Q_SLOTS: // Methods
+    void HandleChannels(const QDBusObjectPath &account,
+            const QDBusObjectPath &connection,
+            const Tp::ChannelDetailsList &channels,
+            const Tp::ObjectPathList &requestsSatisfied,
+            qulonglong userActionTime,
+            const QVariantMap &handlerInfo);
+
+private:
+    AbstractClientHandler *mClient;
+};
+
+} // Tp
+
+#endif
diff --git a/TelepathyQt4/client-registrar.cpp b/TelepathyQt4/client-registrar.cpp
index d49fae2..c7bfee5 100644
--- a/TelepathyQt4/client-registrar.cpp
+++ b/TelepathyQt4/client-registrar.cpp
@@ -23,12 +23,36 @@
 #include "TelepathyQt4/client-registrar-internal.h"
 
 #include "TelepathyQt4/_gen/client-registrar.moc.hpp"
+#include "TelepathyQt4/_gen/client-registrar-internal.moc.hpp"
 
 #include "TelepathyQt4/debug-internal.h"
 
 namespace Tp
 {
 
+ClientHandlerAdaptor::ClientHandlerAdaptor(AbstractClientHandler *client)
+    : QDBusAbstractAdaptor(client),
+      mClient(client)
+{
+    setAutoRelaySignals(true);
+}
+
+ClientHandlerAdaptor::~ClientHandlerAdaptor()
+{
+}
+
+void ClientHandlerAdaptor::HandleChannels(const QDBusObjectPath &account,
+        const QDBusObjectPath &connection,
+        const Tp::ChannelDetailsList &channels,
+        const Tp::ObjectPathList &requestsSatisfied,
+        qulonglong userActionTime,
+        const QVariantMap &handlerInfo)
+{
+    mClient->handleChannels(account, connection, channels,
+            requestsSatisfied, userActionTime, handlerInfo);
+}
+
+
 struct ClientRegistrar::Private
 {
 };
-- 
1.5.6.5




More information about the telepathy-commits mailing list