| 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_client_registrar_internal_h_HEADER_GUARD_
    00023 #define _TelepathyQt4_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 TELEPATHY_QT4_NO_EXPORT 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 TELEPATHY_QT4_NO_EXPORT 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.Observer\" >\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 TELEPATHY_QT4_NO_EXPORT ClientApproverAdaptor : public QDBusAbstractAdaptor
    00111 {
    00112     Q_OBJECT
    00113     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Approver")
    00114     Q_CLASSINFO("D-Bus Introspection", ""
    00115 "  <interface name=\"org.freedesktop.Telepathy.Client.Approver\" >\n"
    00116 "    <property name=\"ApproverChannelFilter\" type=\"aa{sv}\" access=\"read\" />\n"
    00117 "    <method name=\"AddDispatchOperation\" >\n"
    00118 "      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
    00119 "      <arg name=\"Dispatch_Operation\" type=\"o\" direction=\"in\" />\n"
    00120 "      <arg name=\"Properties\" type=\"a{sv}\" direction=\"in\" />\n"
    00121 "    </method>\n"
    00122 "  </interface>\n"
    00123         "")
    00124
    00125     Q_PROPERTY(Tp::ChannelClassList ApproverChannelFilter READ ApproverChannelFilter)
    00126
    00127 public:
    00128     ClientApproverAdaptor(
    00129             const QDBusConnection &bus,
    00130             AbstractClientApprover *client,
    00131             QObject *parent);
    00132     virtual ~ClientApproverAdaptor();
    00133
    00134 public: // Properties
    00135     inline Tp::ChannelClassList ApproverChannelFilter() const
    00136     {
    00137         return mClient->approverChannelFilter();
    00138     }
    00139
    00140 public Q_SLOTS: // Methods
    00141     void AddDispatchOperation(const Tp::ChannelDetailsList &channels,
    00142             const QDBusObjectPath &dispatchOperation,
    00143             const QVariantMap &properties,
    00144             const QDBusMessage &message);
    00145
    00146 private:
    00147     QDBusConnection mBus;
    00148     AbstractClientApprover *mClient;
    00149 };
    00150
    00151 class TELEPATHY_QT4_NO_EXPORT ClientHandlerAdaptor : public QDBusAbstractAdaptor
    00152 {
    00153     Q_OBJECT
    00154     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Handler")
    00155     Q_CLASSINFO("D-Bus Introspection", ""
    00156 "  <interface name=\"org.freedesktop.Telepathy.Client.Handler\" >\n"
    00157 "    <property name=\"HandlerChannelFilter\" type=\"aa{sv}\" access=\"read\" />\n"
    00158 "    <property name=\"BypassApproval\" type=\"b\" access=\"read\" />\n"
    00159 "    <property name=\"HandledChannels\" type=\"ao\" access=\"read\" />\n"
    00160 "    <method name=\"HandleChannels\" >\n"
    00161 "      <arg name=\"Account\" type=\"o\" direction=\"in\" />\n"
    00162 "      <arg name=\"Connection\" type=\"o\" direction=\"in\" />\n"
    00163 "      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
    00164 "      <arg name=\"Requests_Satisfied\" type=\"ao\" direction=\"in\" />\n"
    00165 "      <arg name=\"User_Action_Time\" type=\"t\" direction=\"in\" />\n"
    00166 "      <arg name=\"Handler_Info\" type=\"a{sv}\" direction=\"in\" />\n"
    00167 "    </method>\n"
    00168 "  </interface>\n"
    00169         "")
    00170
    00171     Q_PROPERTY(Tp::ChannelClassList HandlerChannelFilter READ HandlerChannelFilter)
    00172     Q_PROPERTY(bool BypassApproval READ BypassApproval)
    00173     Q_PROPERTY(Tp::ObjectPathList HandledChannels READ HandledChannels)
    00174
    00175 public:
    00176     ClientHandlerAdaptor(
    00177             const QDBusConnection &bus,
    00178             AbstractClientHandler *client,
    00179             QObject *parent);
    00180     virtual ~ClientHandlerAdaptor();
    00181
    00182 public: // Properties
    00183     inline Tp::ChannelClassList HandlerChannelFilter() const
    00184     {
    00185         return mClient->handlerChannelFilter();
    00186     }
    00187
    00188     inline bool BypassApproval() const
    00189     {
    00190         return mClient->bypassApproval();
    00191     }
    00192
    00193     inline Tp::ObjectPathList HandledChannels() const
    00194     {
    00195         // mAdaptorsForConnection includes this, so no need to start the set
    00196         // with this->mHandledChannels
    00197         QList<ClientHandlerAdaptor*> adaptors(mAdaptorsForConnection.value(
    00198                     qMakePair(mBus.name(), mBus.baseService())));
    00199         QSet<ChannelPtr> handledChannels;
    00200         foreach (ClientHandlerAdaptor *handlerAdaptor, adaptors) {
    00201             handledChannels.unite(handlerAdaptor->mHandledChannels);
    00202         }
    00203
    00204         Tp::ObjectPathList ret;
    00205         foreach (const ChannelPtr &channel, handledChannels) {
    00206             ret.append(QDBusObjectPath(channel->objectPath()));
    00207         }
    00208         return ret;
    00209     }
    00210
    00211 public Q_SLOTS: // Methods
    00212     void HandleChannels(const QDBusObjectPath &account,
    00213             const QDBusObjectPath &connection,
    00214             const Tp::ChannelDetailsList &channels,
    00215             const Tp::ObjectPathList &requestsSatisfied,
    00216             qulonglong userActionTime,
    00217             const QVariantMap &handlerInfo,
    00218             const QDBusMessage &message);
    00219
    00220 private Q_SLOTS:
    00221     void onChannelInvalidated(Tp::DBusProxy *proxy);
    00222
    00223 private:
    00224     static void onContextFinished(const MethodInvocationContextPtr<> &context,
    00225             const QList<ChannelPtr> &channels, ClientHandlerAdaptor *self);
    00226
    00227     QDBusConnection mBus;
    00228     AbstractClientHandler *mClient;
    00229     QSet<ChannelPtr> mHandledChannels;
    00230
    00231     static QHash<QPair<QString, QString>, QList<ClientHandlerAdaptor *> > mAdaptorsForConnection;
    00232 };
    00233
    00234 class TELEPATHY_QT4_NO_EXPORT ClientHandlerRequestsAdaptor : public QDBusAbstractAdaptor
    00235 {
    00236     Q_OBJECT
    00237     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Interface.Requests")
    00238     Q_CLASSINFO("D-Bus Introspection", ""
    00239 "  <interface name=\"org.freedesktop.Telepathy.Client.Interface.Requests\" >\n"
    00240 "    <method name=\"AddRequest\" >\n"
    00241 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
    00242 "      <arg name=\"Properties\" type=\"a{sv}\" direction=\"in\" />\n"
    00243 "    </method>\n"
    00244 "    <method name=\"RemoveRequest\" >\n"
    00245 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
    00246 "      <arg name=\"Error\" type=\"s\" direction=\"in\" />\n"
    00247 "      <arg name=\"Message\" type=\"s\" direction=\"in\" />\n"
    00248 "    </method>\n"
    00249 "  </interface>\n"
    00250         "")
    00251
    00252 public:
    00253     ClientHandlerRequestsAdaptor(const QDBusConnection &bus,
    00254             AbstractClientHandler *client,
    00255             QObject *parent);
    00256     virtual ~ClientHandlerRequestsAdaptor();
    00257
    00258 public Q_SLOTS: // Methods
    00259     void AddRequest(const QDBusObjectPath &request,
    00260             const QVariantMap &requestProperties,
    00261             const QDBusMessage &message);
    00262     void RemoveRequest(const QDBusObjectPath &request,
    00263             const QString &errorName, const QString &errorMessage,
    00264             const QDBusMessage &message);
    00265
    00266 private:
    00267     QDBusConnection mBus;
    00268     AbstractClientHandler *mClient;
    00269 };
    00270
    00271 } // Tp
    00272
    00273 #endif