Home · All Classes · All Namespaces · Modules · Functions · Files

client-registrar-internal.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2009 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_cli_client_registrar_internal_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_client_registrar_internal_h_HEADER_GUARD_
00024 
00025 #include <QtCore/QObject>
00026 #include <QtDBus/QtDBus>
00027 
00028 #include <TelepathyQt4/AbstractClientHandler>
00029 #include <TelepathyQt4/Channel>
00030 #include <TelepathyQt4/Types>
00031 
00032 namespace Tp
00033 {
00034 
00035 class PendingOperation;
00036 
00037 class ClientAdaptor : public QDBusAbstractAdaptor
00038 {
00039     Q_OBJECT
00040     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client")
00041     Q_CLASSINFO("D-Bus Introspection", ""
00042 "  <interface name=\"org.freedesktop.Telepathy.Client\" >\n"
00043 "    <property name=\"Interfaces\" type=\"as\" access=\"read\" />\n"
00044 "  </interface>\n"
00045         "")
00046 
00047     Q_PROPERTY(QStringList Interfaces READ Interfaces)
00048 
00049 public:
00050     ClientAdaptor(const QStringList &interfaces, QObject *parent);
00051     virtual ~ClientAdaptor();
00052 
00053 public: // Properties
00054     inline QStringList Interfaces() const
00055     {
00056         return mInterfaces;
00057     }
00058 
00059 private:
00060     QStringList mInterfaces;
00061 };
00062 
00063 class ClientObserverAdaptor : public QDBusAbstractAdaptor
00064 {
00065     Q_OBJECT
00066     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Observer")
00067     Q_CLASSINFO("D-Bus Introspection", ""
00068 "  <interface name=\"org.freedesktop.Telepathy.Client.Handler\" >\n"
00069 "    <property name=\"ObserverChannelFilter\" type=\"aa{sv}\" access=\"read\" />\n"
00070 "    <method name=\"ObserveChannels\" >\n"
00071 "      <arg name=\"Account\" type=\"o\" direction=\"in\" />\n"
00072 "      <arg name=\"Connection\" type=\"o\" direction=\"in\" />\n"
00073 "      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
00074 "      <arg name=\"Dispatch_Operation\" type=\"o\" direction=\"in\" />\n"
00075 "      <arg name=\"Requests_Satisfied\" type=\"ao\" direction=\"in\" />\n"
00076 "      <arg name=\"Observer_Info\" type=\"a{sv}\" direction=\"in\" />\n"
00077 "    </method>\n"
00078 "  </interface>\n"
00079         "")
00080 
00081     Q_PROPERTY(Tp::ChannelClassList ObserverChannelFilter READ ObserverChannelFilter)
00082 
00083 public:
00084     ClientObserverAdaptor(
00085             const QDBusConnection &bus,
00086             AbstractClientObserver *client,
00087             QObject *parent);
00088     virtual ~ClientObserverAdaptor();
00089 
00090 public: // Properties
00091     inline Tp::ChannelClassList ObserverChannelFilter() const
00092     {
00093         return mClient->observerChannelFilter();
00094     }
00095 
00096 public Q_SLOTS: // Methods
00097     void ObserveChannels(const QDBusObjectPath &account,
00098             const QDBusObjectPath &connection,
00099             const Tp::ChannelDetailsList &channels,
00100             const QDBusObjectPath &dispatchOperation,
00101             const Tp::ObjectPathList &requestsSatisfied,
00102             const QVariantMap &observerInfo,
00103             const QDBusMessage &message);
00104 
00105 private:
00106     QDBusConnection mBus;
00107     AbstractClientObserver *mClient;
00108 };
00109 
00110 class ClientHandlerAdaptor : public QDBusAbstractAdaptor
00111 {
00112     Q_OBJECT
00113     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Handler")
00114     Q_CLASSINFO("D-Bus Introspection", ""
00115 "  <interface name=\"org.freedesktop.Telepathy.Client.Handler\" >\n"
00116 "    <property name=\"HandlerChannelFilter\" type=\"aa{sv}\" access=\"read\" />\n"
00117 "    <property name=\"BypassApproval\" type=\"b\" access=\"read\" />\n"
00118 "    <property name=\"HandledChannels\" type=\"ao\" access=\"read\" />\n"
00119 "    <method name=\"HandleChannels\" >\n"
00120 "      <arg name=\"Account\" type=\"o\" direction=\"in\" />\n"
00121 "      <arg name=\"Connection\" type=\"o\" direction=\"in\" />\n"
00122 "      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
00123 "      <arg name=\"Requests_Satisfied\" type=\"ao\" direction=\"in\" />\n"
00124 "      <arg name=\"User_Action_Time\" type=\"t\" direction=\"in\" />\n"
00125 "      <arg name=\"Handler_Info\" type=\"a{sv}\" direction=\"in\" />\n"
00126 "    </method>\n"
00127 "  </interface>\n"
00128         "")
00129 
00130     Q_PROPERTY(Tp::ChannelClassList HandlerChannelFilter READ HandlerChannelFilter)
00131     Q_PROPERTY(bool BypassApproval READ BypassApproval)
00132     Q_PROPERTY(Tp::ObjectPathList HandledChannels READ HandledChannels)
00133 
00134 public:
00135     ClientHandlerAdaptor(
00136             const QDBusConnection &bus,
00137             AbstractClientHandler *client,
00138             QObject *parent);
00139     virtual ~ClientHandlerAdaptor();
00140 
00141 public: // Properties
00142     inline Tp::ChannelClassList HandlerChannelFilter() const
00143     {
00144         return mClient->handlerChannelFilter();
00145     }
00146 
00147     inline bool BypassApproval() const
00148     {
00149         return mClient->bypassApproval();
00150     }
00151 
00152     inline Tp::ObjectPathList HandledChannels() const
00153     {
00154         // mAdaptorsForConnection includes this, so no need to start the set
00155         // with this->mHandledChannels
00156         QList<ClientHandlerAdaptor*> adaptors(mAdaptorsForConnection.value(
00157                     qMakePair(mBus.name(), mBus.baseService())));
00158         QSet<ChannelPtr> handledChannels;
00159         foreach (ClientHandlerAdaptor *handlerAdaptor, adaptors) {
00160             handledChannels.unite(handlerAdaptor->mHandledChannels);
00161         }
00162 
00163         Tp::ObjectPathList ret;
00164         foreach (const ChannelPtr &channel, handledChannels) {
00165             ret.append(QDBusObjectPath(channel->objectPath()));
00166         }
00167         return ret;
00168     }
00169 
00170 public Q_SLOTS: // Methods
00171     void HandleChannels(const QDBusObjectPath &account,
00172             const QDBusObjectPath &connection,
00173             const Tp::ChannelDetailsList &channels,
00174             const Tp::ObjectPathList &requestsSatisfied,
00175             qulonglong userActionTime,
00176             const QVariantMap &handlerInfo,
00177             const QDBusMessage &message);
00178 
00179 private Q_SLOTS:
00180     void onChannelInvalidated(Tp::DBusProxy *proxy);
00181 
00182 private:
00183     static void onContextFinished(const MethodInvocationContextPtr<> &context,
00184             const QList<ChannelPtr> &channels, ClientHandlerAdaptor *self);
00185 
00186     QDBusConnection mBus;
00187     AbstractClientHandler *mClient;
00188     QSet<ChannelPtr> mHandledChannels;
00189 
00190     static QHash<QPair<QString, QString>, QList<ClientHandlerAdaptor *> > mAdaptorsForConnection;
00191 };
00192 
00193 class ClientHandlerRequestsAdaptor : public QDBusAbstractAdaptor
00194 {
00195     Q_OBJECT
00196     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Interface.Requests")
00197     Q_CLASSINFO("D-Bus Introspection", ""
00198 "  <interface name=\"org.freedesktop.Telepathy.Client.Interface.Requests\" >\n"
00199 "    <method name=\"AddRequest\" >\n"
00200 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
00201 "      <arg name=\"Properties\" type=\"a{sv}\" direction=\"in\" />\n"
00202 "    </method>\n"
00203 "    <method name=\"RemoveRequest\" >\n"
00204 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
00205 "      <arg name=\"Error\" type=\"s\" direction=\"in\" />\n"
00206 "      <arg name=\"Message\" type=\"s\" direction=\"in\" />\n"
00207 "    </method>\n"
00208 "  </interface>\n"
00209         "")
00210 
00211 public:
00212     ClientHandlerRequestsAdaptor(const QDBusConnection &bus,
00213             AbstractClientHandler *client,
00214             QObject *parent);
00215     virtual ~ClientHandlerRequestsAdaptor();
00216 
00217 public Q_SLOTS: // Methods
00218     void AddRequest(const QDBusObjectPath &request,
00219             const QVariantMap &requestProperties,
00220             const QDBusMessage &message);
00221     void RemoveRequest(const QDBusObjectPath &request,
00222             const QString &errorName, const QString &errorMessage,
00223             const QDBusMessage &message);
00224 
00225 private:
00226     QDBusConnection mBus;
00227     AbstractClientHandler *mClient;
00228 };
00229 
00230 } // Tp
00231 
00232 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.5