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

connection.h

00001 
00023 #ifndef _TelepathyQt4_connection_h_HEADER_GUARD_
00024 #define _TelepathyQt4_connection_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt4/_gen/cli-connection.h>
00031 
00032 #include <TelepathyQt4/ConnectionCapabilities>
00033 #include <TelepathyQt4/Contact>
00034 #include <TelepathyQt4/DBus>
00035 #include <TelepathyQt4/DBusProxy>
00036 #include <TelepathyQt4/OptionalInterfaceFactory>
00037 #include <TelepathyQt4/ReadinessHelper>
00038 #include <TelepathyQt4/Types>
00039 #include <TelepathyQt4/SharedPtr>
00040 
00041 #include <TelepathyQt4/Constants>
00042 #include <TelepathyQt4/Types>
00043 
00044 #include <QSet>
00045 #include <QString>
00046 #include <QStringList>
00047 
00048 namespace Tp
00049 {
00050 
00051 class Channel;
00052 class ConnectionCapabilities;
00053 class ConnectionLowlevel;
00054 class Contact;
00055 class ContactManager;
00056 class PendingChannel;
00057 class PendingContactAttributes;
00058 class PendingHandles;
00059 class PendingOperation;
00060 class PendingReady;
00061 
00062 class TELEPATHY_QT4_EXPORT Connection : public StatefulDBusProxy,
00063                    public OptionalInterfaceFactory<Connection>
00064 {
00065     Q_OBJECT
00066     Q_DISABLE_COPY(Connection)
00067 
00068 public:
00069     static const Feature FeatureCore;
00070     static const Feature FeatureSelfContact;
00071     static const Feature FeatureSimplePresence;
00072     static const Feature FeatureRoster;
00073     static const Feature FeatureRosterGroups;
00074     static const Feature FeatureAccountBalance; // TODO unit tests for this
00075     static const Feature FeatureConnected;
00076 
00077     static ConnectionPtr create(const QString &busName,
00078             const QString &objectPath,
00079             const ChannelFactoryConstPtr &channelFactory,
00080             const ContactFactoryConstPtr &contactFactory);
00081     static ConnectionPtr create(const QDBusConnection &bus,
00082             const QString &busName, const QString &objectPath,
00083             const ChannelFactoryConstPtr &channelFactory,
00084             const ContactFactoryConstPtr &contactFactory);
00085 
00086     virtual ~Connection();
00087 
00088     ChannelFactoryConstPtr channelFactory() const;
00089     ContactFactoryConstPtr contactFactory() const;
00090 
00091     QString cmName() const;
00092     QString protocolName() const;
00093 
00094     ConnectionStatus status() const;
00095     ConnectionStatusReason statusReason() const;
00096 
00097     class ErrorDetails
00098     {
00099         public:
00100             ErrorDetails();
00101             ErrorDetails(const QVariantMap &details);
00102             ErrorDetails(const ErrorDetails &other);
00103             ~ErrorDetails();
00104 
00105             ErrorDetails &operator=(const ErrorDetails &other);
00106 
00107             bool isValid() const { return mPriv.constData() != 0; }
00108 
00109             bool hasDebugMessage() const
00110             {
00111                 return allDetails().contains(QLatin1String("debug-message"));
00112             }
00113 
00114             QString debugMessage() const
00115             {
00116                 return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message")));
00117             }
00118 
00119 #if 0
00120             /*
00121              * TODO: these are actually specified in a draft interface only. Probably shouldn't
00122              * include them yet.
00123              */
00124             bool hasExpectedHostname() const
00125             {
00126                 return allDetails().contains(QLatin1String("expected-hostname"));
00127             }
00128 
00129             QString expectedHostname() const
00130             {
00131                 return qdbus_cast<QString>(allDetails().value(QLatin1String("expected-hostname")));
00132             }
00133 
00134             bool hasCertificateHostname() const
00135             {
00136                 return allDetails().contains(QLatin1String("certificate-hostname"));
00137             }
00138 
00139             QString certificateHostname() const
00140             {
00141                 return qdbus_cast<QString>(allDetails().value(QLatin1String("certificate-hostname")));
00142             }
00143 #endif
00144 
00145             QVariantMap allDetails() const;
00146 
00147         private:
00148             friend class Connection;
00149 
00150             struct Private;
00151             friend struct Private;
00152             QSharedDataPointer<Private> mPriv;
00153     };
00154 
00155     const ErrorDetails &errorDetails() const;
00156 
00157     uint selfHandle() const;
00158     ContactPtr selfContact() const;
00159 
00160     CurrencyAmount accountBalance() const;
00161 
00162     ConnectionCapabilities capabilities() const;
00163 
00164     ContactManagerPtr contactManager() const;
00165 
00166 #if defined(BUILDING_TELEPATHY_QT4) || defined(TP_QT4_ENABLE_LOWLEVEL_API)
00167     ConnectionLowlevelPtr lowlevel();
00168     ConnectionLowlevelConstPtr lowlevel() const;
00169 #endif
00170 
00171 Q_SIGNALS:
00172     void statusChanged(Tp::ConnectionStatus newStatus);
00173 
00174     void selfHandleChanged(uint newHandle);
00175     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00176     void selfContactChanged();
00177 
00178     void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
00179 
00180 protected:
00181     Connection(const QDBusConnection &bus, const QString &busName,
00182             const QString &objectPath,
00183             const ChannelFactoryConstPtr &channelFactory,
00184             const ContactFactoryConstPtr &contactFactory,
00185             const Feature &coreFeature);
00186 
00187     Client::ConnectionInterface *baseInterface() const;
00188 
00189 private Q_SLOTS:
00190     TELEPATHY_QT4_NO_EXPORT void onStatusReady(uint status);
00191     TELEPATHY_QT4_NO_EXPORT void onStatusChanged(uint status, uint reason);
00192     TELEPATHY_QT4_NO_EXPORT void onConnectionError(const QString &error, const QVariantMap &details);
00193     TELEPATHY_QT4_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *watcher);
00194     TELEPATHY_QT4_NO_EXPORT void gotStatus(QDBusPendingCallWatcher *watcher);
00195     TELEPATHY_QT4_NO_EXPORT void gotInterfaces(QDBusPendingCallWatcher *watcher);
00196     TELEPATHY_QT4_NO_EXPORT void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00197     TELEPATHY_QT4_NO_EXPORT void gotCapabilities(QDBusPendingCallWatcher *watcher);
00198     TELEPATHY_QT4_NO_EXPORT void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00199     TELEPATHY_QT4_NO_EXPORT void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00200     TELEPATHY_QT4_NO_EXPORT void gotSelfContact(Tp::PendingOperation *op);
00201 
00202     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterFinished(Tp::PendingOperation *op);
00203     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterGroupsFinished(Tp::PendingOperation *op);
00204 
00205     TELEPATHY_QT4_NO_EXPORT void doReleaseSweep(uint handleType);
00206 
00207     TELEPATHY_QT4_NO_EXPORT void onSelfHandleChanged(uint);
00208 
00209     TELEPATHY_QT4_NO_EXPORT void gotBalance(QDBusPendingCallWatcher *watcher);
00210     TELEPATHY_QT4_NO_EXPORT void onBalanceChanged(const Tp::CurrencyAmount &);
00211 
00212 private:
00213     class PendingConnect;
00214     friend class ConnectionLowlevel;
00215     friend class PendingChannel;
00216     friend class PendingConnect;
00217     friend class PendingContactAttributes;
00218     friend class PendingContacts;
00219     friend class PendingHandles;
00220     friend class ReferencedHandles;
00221 
00222     TELEPATHY_QT4_NO_EXPORT void refHandle(HandleType handleType, uint handle);
00223     TELEPATHY_QT4_NO_EXPORT void unrefHandle(HandleType handleType, uint handle);
00224     TELEPATHY_QT4_NO_EXPORT void handleRequestLanded(HandleType handleType);
00225 
00226     struct Private;
00227     friend struct Private;
00228     Private *mPriv;
00229 };
00230 
00231 } // Tp
00232 
00233 Q_DECLARE_METATYPE(Tp::Connection::ErrorDetails);
00234 
00235 #endif


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.5.14