TelepathyQt4: client-registrar-internal.h Source File

| 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=\"Capabilities\" type=\"as\" access=\"read\" />\n"
    00160 "    <property name=\"HandledChannels\" type=\"ao\" access=\"read\" />\n"
    00161 "    <method name=\"HandleChannels\" >\n"
    00162 "      <arg name=\"Account\" type=\"o\" direction=\"in\" />\n"
    00163 "      <arg name=\"Connection\" type=\"o\" direction=\"in\" />\n"
    00164 "      <arg name=\"Channels\" type=\"a(oa{sv})\" direction=\"in\" />\n"
    00165 "      <arg name=\"Requests_Satisfied\" type=\"ao\" direction=\"in\" />\n"
    00166 "      <arg name=\"User_Action_Time\" type=\"t\" direction=\"in\" />\n"
    00167 "      <arg name=\"Handler_Info\" type=\"a{sv}\" direction=\"in\" />\n"
    00168 "    </method>\n"
    00169 "  </interface>\n"
    00170         "")
    00171
    00172     Q_PROPERTY(Tp::ChannelClassList HandlerChannelFilter READ HandlerChannelFilter)
    00173     Q_PROPERTY(bool BypassApproval READ BypassApproval)
    00174     Q_PROPERTY(QStringList Capabilities READ Capabilities)
    00175     Q_PROPERTY(Tp::ObjectPathList HandledChannels READ HandledChannels)
    00176
    00177 public:
    00178     ClientHandlerAdaptor(
    00179             const QDBusConnection &bus,
    00180             AbstractClientHandler *client,
    00181             QObject *parent);
    00182     virtual ~ClientHandlerAdaptor();
    00183
    00184 public: // Properties
    00185     inline Tp::ChannelClassList HandlerChannelFilter() const
    00186     {
    00187         return mClient->handlerChannelFilter();
    00188     }
    00189
    00190     inline bool BypassApproval() const
    00191     {
    00192         return mClient->bypassApproval();
    00193     }
    00194
    00195     inline QStringList Capabilities() const
    00196     {
    00197         return mClient->capabilities();
    00198     }
    00199
    00200     inline Tp::ObjectPathList HandledChannels() const
    00201     {
    00202         // mAdaptorsForConnection includes this, so no need to start the set
    00203         // with this->mHandledChannels
    00204         QList<ClientHandlerAdaptor*> adaptors(mAdaptorsForConnection.value(
    00205                     qMakePair(mBus.name(), mBus.baseService())));
    00206         QSet<ChannelPtr> handledChannels;
    00207         foreach (ClientHandlerAdaptor *handlerAdaptor, adaptors) {
    00208             handledChannels.unite(handlerAdaptor->mHandledChannels);
    00209         }
    00210
    00211         Tp::ObjectPathList ret;
    00212         foreach (const ChannelPtr &channel, handledChannels) {
    00213             ret.append(QDBusObjectPath(channel->objectPath()));
    00214         }
    00215         return ret;
    00216     }
    00217
    00218 public Q_SLOTS: // Methods
    00219     void HandleChannels(const QDBusObjectPath &account,
    00220             const QDBusObjectPath &connection,
    00221             const Tp::ChannelDetailsList &channels,
    00222             const Tp::ObjectPathList &requestsSatisfied,
    00223             qulonglong userActionTime,
    00224             const QVariantMap &handlerInfo,
    00225             const QDBusMessage &message);
    00226
    00227 private Q_SLOTS:
    00228     void onChannelInvalidated(Tp::DBusProxy *proxy);
    00229
    00230 private:
    00231     static void onContextFinished(const MethodInvocationContextPtr<> &context,
    00232             const QList<ChannelPtr> &channels, ClientHandlerAdaptor *self);
    00233
    00234     QDBusConnection mBus;
    00235     AbstractClientHandler *mClient;
    00236     QSet<ChannelPtr> mHandledChannels;
    00237
    00238     static QHash<QPair<QString, QString>, QList<ClientHandlerAdaptor *> > mAdaptorsForConnection;
    00239 };
    00240
    00241 class TELEPATHY_QT4_NO_EXPORT ClientHandlerRequestsAdaptor : public QDBusAbstractAdaptor
    00242 {
    00243     Q_OBJECT
    00244     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.Client.Interface.Requests")
    00245     Q_CLASSINFO("D-Bus Introspection", ""
    00246 "  <interface name=\"org.freedesktop.Telepathy.Client.Interface.Requests\" >\n"
    00247 "    <method name=\"AddRequest\" >\n"
    00248 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
    00249 "      <arg name=\"Properties\" type=\"a{sv}\" direction=\"in\" />\n"
    00250 "    </method>\n"
    00251 "    <method name=\"RemoveRequest\" >\n"
    00252 "      <arg name=\"Request\" type=\"o\" direction=\"in\" />\n"
    00253 "      <arg name=\"Error\" type=\"s\" direction=\"in\" />\n"
    00254 "      <arg name=\"Message\" type=\"s\" direction=\"in\" />\n"
    00255 "    </method>\n"
    00256 "  </interface>\n"
    00257         "")
    00258
    00259 public:
    00260     ClientHandlerRequestsAdaptor(const QDBusConnection &bus,
    00261             AbstractClientHandler *client,
    00262             QObject *parent);
    00263     virtual ~ClientHandlerRequestsAdaptor();
    00264
    00265 public Q_SLOTS: // Methods
    00266     void AddRequest(const QDBusObjectPath &request,
    00267             const QVariantMap &requestProperties,
    00268             const QDBusMessage &message);
    00269     void RemoveRequest(const QDBusObjectPath &request,
    00270             const QString &errorName, const QString &errorMessage,
    00271             const QDBusMessage &message);
    00272
    00273 private:
    00274     QDBusConnection mBus;
    00275     AbstractClientHandler *mClient;
    00276 };
    00277
    00278 } // Tp
    00279
    00280 #endif