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 
00076     static ConnectionPtr create(const QString &busName,
00077             const QString &objectPath,
00078             const ChannelFactoryConstPtr &channelFactory,
00079             const ContactFactoryConstPtr &contactFactory);
00080     static ConnectionPtr create(const QDBusConnection &bus,
00081             const QString &busName, const QString &objectPath,
00082             const ChannelFactoryConstPtr &channelFactory,
00083             const ContactFactoryConstPtr &contactFactory);
00084 
00085     virtual ~Connection();
00086 
00087     ChannelFactoryConstPtr channelFactory() const;
00088     ContactFactoryConstPtr contactFactory() const;
00089 
00090     QString cmName() const;
00091     QString protocolName() const;
00092 
00093     ConnectionStatus status() const;
00094     ConnectionStatusReason statusReason() const;
00095 
00096     class ErrorDetails
00097     {
00098         public:
00099             ErrorDetails();
00100             ErrorDetails(const QVariantMap &details);
00101             ErrorDetails(const ErrorDetails &other);
00102             ~ErrorDetails();
00103 
00104             ErrorDetails &operator=(const ErrorDetails &other);
00105 
00106             bool isValid() const { return mPriv.constData() != 0; }
00107 
00108             bool hasDebugMessage() const
00109             {
00110                 return allDetails().contains(QLatin1String("debug-message"));
00111             }
00112 
00113             QString debugMessage() const
00114             {
00115                 return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message")));
00116             }
00117 
00118 #if 0
00119             /*
00120              * TODO: these are actually specified in a draft interface only. Probably shouldn't
00121              * include them yet.
00122              */
00123             bool hasExpectedHostname() const
00124             {
00125                 return allDetails().contains(QLatin1String("expected-hostname"));
00126             }
00127 
00128             QString expectedHostname() const
00129             {
00130                 return qdbus_cast<QString>(allDetails().value(QLatin1String("expected-hostname")));
00131             }
00132 
00133             bool hasCertificateHostname() const
00134             {
00135                 return allDetails().contains(QLatin1String("certificate-hostname"));
00136             }
00137 
00138             QString certificateHostname() const
00139             {
00140                 return qdbus_cast<QString>(allDetails().value(QLatin1String("certificate-hostname")));
00141             }
00142 #endif
00143 
00144             QVariantMap allDetails() const;
00145 
00146         private:
00147             friend class Connection;
00148 
00149             struct Private;
00150             friend struct Private;
00151             QSharedDataPointer<Private> mPriv;
00152     };
00153 
00154     const ErrorDetails &errorDetails() const;
00155 
00156     uint selfHandle() const;
00157     ContactPtr selfContact() const;
00158 
00159     CurrencyAmount accountBalance() const;
00160 
00161     ConnectionCapabilities capabilities() const;
00162 
00163     ContactManagerPtr contactManager() const;
00164 
00165 #if defined(BUILDING_TELEPATHY_QT4) || defined(TP_QT4_ENABLE_LOWLEVEL_API)
00166     ConnectionLowlevelPtr lowlevel();
00167     ConnectionLowlevelConstPtr lowlevel() const;
00168 #endif
00169 
00170 Q_SIGNALS:
00171     void statusChanged(Tp::ConnectionStatus newStatus);
00172 
00173     void selfHandleChanged(uint newHandle);
00174     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00175     void selfContactChanged();
00176 
00177     void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
00178 
00179 protected:
00180     Connection(const QDBusConnection &bus, const QString &busName,
00181             const QString &objectPath,
00182             const ChannelFactoryConstPtr &channelFactory,
00183             const ContactFactoryConstPtr &contactFactory,
00184             const Feature &coreFeature);
00185 
00186     Client::ConnectionInterface *baseInterface() const;
00187 
00188 private Q_SLOTS:
00189     TELEPATHY_QT4_NO_EXPORT void onStatusReady(uint status);
00190     TELEPATHY_QT4_NO_EXPORT void onStatusChanged(uint status, uint reason);
00191     TELEPATHY_QT4_NO_EXPORT void onConnectionError(const QString &error, const QVariantMap &details);
00192     TELEPATHY_QT4_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *watcher);
00193     TELEPATHY_QT4_NO_EXPORT void gotStatus(QDBusPendingCallWatcher *watcher);
00194     TELEPATHY_QT4_NO_EXPORT void gotInterfaces(QDBusPendingCallWatcher *watcher);
00195     TELEPATHY_QT4_NO_EXPORT void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00196     TELEPATHY_QT4_NO_EXPORT void gotCapabilities(QDBusPendingCallWatcher *watcher);
00197     TELEPATHY_QT4_NO_EXPORT void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00198     TELEPATHY_QT4_NO_EXPORT void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00199     TELEPATHY_QT4_NO_EXPORT void gotSelfContact(Tp::PendingOperation *op);
00200 
00201     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterFinished(Tp::PendingOperation *op);
00202     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterGroupsFinished(Tp::PendingOperation *op);
00203 
00204     TELEPATHY_QT4_NO_EXPORT void doReleaseSweep(uint handleType);
00205 
00206     TELEPATHY_QT4_NO_EXPORT void onSelfHandleChanged(uint);
00207 
00208     TELEPATHY_QT4_NO_EXPORT void gotBalance(QDBusPendingCallWatcher *watcher);
00209     TELEPATHY_QT4_NO_EXPORT void onBalanceChanged(const Tp::CurrencyAmount &);
00210 
00211 private:
00212     class PendingConnect;
00213     friend class ConnectionLowlevel;
00214     friend class PendingChannel;
00215     friend class PendingConnect;
00216     friend class PendingContactAttributes;
00217     friend class PendingContacts;
00218     friend class PendingHandles;
00219     friend class ReferencedHandles;
00220 
00221     TELEPATHY_QT4_NO_EXPORT void refHandle(HandleType handleType, uint handle);
00222     TELEPATHY_QT4_NO_EXPORT void unrefHandle(HandleType handleType, uint handle);
00223     TELEPATHY_QT4_NO_EXPORT void handleRequestLanded(HandleType handleType);
00224 
00225     struct Private;
00226     friend struct Private;
00227     Private *mPriv;
00228 };
00229 
00230 } // Tp
00231 
00232 Q_DECLARE_METATYPE(Tp::Connection::ErrorDetails);
00233 
00234 #endif


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