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

channel-request.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_channel_request_h_HEADER_GUARD_
00023 #define _TelepathyQt4_channel_request_h_HEADER_GUARD_
00024 
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028 
00029 #include <TelepathyQt4/_gen/cli-channel-request.h>
00030 
00031 #include <TelepathyQt4/Constants>
00032 #include <TelepathyQt4/DBus>
00033 #include <TelepathyQt4/DBusProxy>
00034 #include <TelepathyQt4/Feature>
00035 #include <TelepathyQt4/OptionalInterfaceFactory>
00036 #include <TelepathyQt4/ReadinessHelper>
00037 #include <TelepathyQt4/Types>
00038 #include <TelepathyQt4/SharedPtr>
00039 
00040 #include <QSharedDataPointer>
00041 #include <QString>
00042 #include <QStringList>
00043 #include <QVariantMap>
00044 
00045 namespace Tp
00046 {
00047 
00048 class ChannelRequestHints;
00049 class PendingOperation;
00050 
00051 class TELEPATHY_QT4_EXPORT ChannelRequest : public StatefulDBusProxy,
00052                 public OptionalInterfaceFactory<ChannelRequest>
00053 {
00054     Q_OBJECT
00055     Q_DISABLE_COPY(ChannelRequest)
00056 
00057 public:
00058     static const Feature FeatureCore;
00059 
00060     static ChannelRequestPtr create(const QDBusConnection &bus,
00061             const QString &objectPath, const QVariantMap &immutableProperties,
00062             const AccountFactoryConstPtr &accountFactory,
00063             const ConnectionFactoryConstPtr &connectionFactory,
00064             const ChannelFactoryConstPtr &channelFactory,
00065             const ContactFactoryConstPtr &contactFactory);
00066 
00067     static ChannelRequestPtr create(const AccountPtr &account,
00068             const QString &objectPath, const QVariantMap &immutableProperties);
00069 
00070     virtual ~ChannelRequest();
00071 
00072     AccountPtr account() const;
00073     QDateTime userActionTime() const;
00074     QString preferredHandler() const;
00075     QualifiedPropertyValueMapList requests() const;
00076     ChannelRequestHints hints() const;
00077 
00078     QVariantMap immutableProperties() const;
00079 
00080     PendingOperation *cancel();
00081 
00082     ChannelPtr channel() const;
00083 
00084 Q_SIGNALS:
00085     void failed(const QString &errorName, const QString &errorMessage);
00086     void succeeded(); // TODO API/ABI break: remove
00087     void succeeded(const Tp::ChannelPtr &channel);
00088 
00089 protected:
00090     ChannelRequest(const QDBusConnection &bus,
00091             const QString &objectPath, const QVariantMap &immutableProperties,
00092             const AccountFactoryConstPtr &accountFactory,
00093             const ConnectionFactoryConstPtr &connectionFactory,
00094             const ChannelFactoryConstPtr &channelFactory,
00095             const ContactFactoryConstPtr &contactFactory);
00096 
00097     ChannelRequest(const AccountPtr &account,
00098             const QString &objectPath, const QVariantMap &immutableProperties);
00099 
00100     Client::ChannelRequestInterface *baseInterface() const;
00101 
00102 protected:
00103     // TODO: (API/ABI break) Remove connectNotify
00104     void connectNotify(const char *);
00105 
00106 private Q_SLOTS:
00107     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00108     void onAccountReady(Tp::PendingOperation *op);
00109 
00110     void onLegacySucceeded();
00111     void onSucceededWithChannel(const QDBusObjectPath &connPath, const QVariantMap &connProps,
00112             const QDBusObjectPath &chanPath, const QVariantMap &chanProps);
00113     void onChanBuilt(Tp::PendingOperation *op);
00114 
00115 private:
00116     friend class PendingChannelRequest;
00117 
00118     PendingOperation *proceed();
00119 
00120     struct Private;
00121     friend struct Private;
00122     Private *mPriv;
00123 };
00124 
00125 class TELEPATHY_QT4_EXPORT ChannelRequestHints
00126 {
00127 public:
00128 
00129     ChannelRequestHints();
00130     ChannelRequestHints(const QVariantMap &hints);
00131     ChannelRequestHints(const ChannelRequestHints &other);
00132     ~ChannelRequestHints();
00133 
00134     ChannelRequestHints &operator=(const ChannelRequestHints &other);
00135 
00136     bool isValid() const;
00137 
00138     bool hasHint(const QString &reversedDomain, const QString &localName) const;
00139     QVariant hint(const QString &reversedDomain, const QString &localName) const;
00140     void setHint(const QString &reversedDomain, const QString &localName, const QVariant &value);
00141 
00142     QVariantMap allHints() const;
00143 
00144 private:
00145     struct Private;
00146     friend struct Private;
00147     QSharedDataPointer<Private> mPriv;
00148 };
00149 
00150 } // Tp
00151 
00152 Q_DECLARE_METATYPE(Tp::ChannelRequestHints);
00153 
00154 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.5.8