MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9
   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             bool hasServerMessage() const
00120             {
00121                 return allDetails().contains(QLatin1String("server-message"));
00122             }
00123 
00124             QString serverMessage() const
00125             {
00126                 return qdbus_cast<QString>(allDetails().value(QLatin1String("server-message")));
00127             }
00128 
00129             bool hasUserRequested() const
00130             {
00131                 return allDetails().contains(QLatin1String("user-requested"));
00132             }
00133 
00134             bool userRequested() const
00135             {
00136                 return qdbus_cast<bool>(allDetails().value(QLatin1String("user-requested")));
00137             }
00138 
00139             bool hasExpectedHostname() const
00140             {
00141                 return allDetails().contains(QLatin1String("expected-hostname"));
00142             }
00143 
00144             QString expectedHostname() const
00145             {
00146                 return qdbus_cast<QString>(allDetails().value(QLatin1String("expected-hostname")));
00147             }
00148 
00149             bool hasCertificateHostname() const
00150             {
00151                 return allDetails().contains(QLatin1String("certificate-hostname"));
00152             }
00153 
00154             QString certificateHostname() const
00155             {
00156                 return qdbus_cast<QString>(allDetails().value(QLatin1String("certificate-hostname")));
00157             }
00158 
00159             QVariantMap allDetails() const;
00160 
00161         private:
00162             friend class Connection;
00163 
00164             struct Private;
00165             friend struct Private;
00166             QSharedDataPointer<Private> mPriv;
00167     };
00168 
00169     const ErrorDetails &errorDetails() const;
00170 
00171     uint selfHandle() const;
00172     ContactPtr selfContact() const;
00173 
00174     CurrencyAmount accountBalance() const;
00175 
00176     ConnectionCapabilities capabilities() const;
00177 
00178     ContactManagerPtr contactManager() const;
00179 
00180 #if defined(BUILDING_TELEPATHY_QT4) || defined(TP_QT4_ENABLE_LOWLEVEL_API)
00181     ConnectionLowlevelPtr lowlevel();
00182     ConnectionLowlevelConstPtr lowlevel() const;
00183 #endif
00184 
00185 Q_SIGNALS:
00186     void statusChanged(Tp::ConnectionStatus newStatus);
00187 
00188     void selfHandleChanged(uint newHandle);
00189     // FIXME: might not need this when Renaming is fixed and mapped to Contacts
00190     void selfContactChanged();
00191 
00192     void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
00193 
00194 protected:
00195     Connection(const QDBusConnection &bus, const QString &busName,
00196             const QString &objectPath,
00197             const ChannelFactoryConstPtr &channelFactory,
00198             const ContactFactoryConstPtr &contactFactory,
00199             const Feature &coreFeature);
00200 
00201     Client::ConnectionInterface *baseInterface() const;
00202 
00203 private Q_SLOTS:
00204     TELEPATHY_QT4_NO_EXPORT void onStatusReady(uint status);
00205     TELEPATHY_QT4_NO_EXPORT void onStatusChanged(uint status, uint reason);
00206     TELEPATHY_QT4_NO_EXPORT void onConnectionError(const QString &error, const QVariantMap &details);
00207     TELEPATHY_QT4_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *watcher);
00208     TELEPATHY_QT4_NO_EXPORT void gotStatus(QDBusPendingCallWatcher *watcher);
00209     TELEPATHY_QT4_NO_EXPORT void gotInterfaces(QDBusPendingCallWatcher *watcher);
00210     TELEPATHY_QT4_NO_EXPORT void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00211     TELEPATHY_QT4_NO_EXPORT void gotCapabilities(QDBusPendingCallWatcher *watcher);
00212     TELEPATHY_QT4_NO_EXPORT void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00213     TELEPATHY_QT4_NO_EXPORT void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00214     TELEPATHY_QT4_NO_EXPORT void gotSelfContact(Tp::PendingOperation *op);
00215 
00216     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterFinished(Tp::PendingOperation *op);
00217     TELEPATHY_QT4_NO_EXPORT void onIntrospectRosterGroupsFinished(Tp::PendingOperation *op);
00218 
00219     TELEPATHY_QT4_NO_EXPORT void doReleaseSweep(uint handleType);
00220 
00221     TELEPATHY_QT4_NO_EXPORT void onSelfHandleChanged(uint);
00222 
00223     TELEPATHY_QT4_NO_EXPORT void gotBalance(QDBusPendingCallWatcher *watcher);
00224     TELEPATHY_QT4_NO_EXPORT void onBalanceChanged(const Tp::CurrencyAmount &);
00225 
00226 private:
00227     class PendingConnect;
00228     friend class ConnectionLowlevel;
00229     friend class PendingChannel;
00230     friend class PendingConnect;
00231     friend class PendingContactAttributes;
00232     friend class PendingContacts;
00233     friend class PendingHandles;
00234     friend class ReferencedHandles;
00235 
00236     TELEPATHY_QT4_NO_EXPORT void refHandle(HandleType handleType, uint handle);
00237     TELEPATHY_QT4_NO_EXPORT void unrefHandle(HandleType handleType, uint handle);
00238     TELEPATHY_QT4_NO_EXPORT void handleRequestLanded(HandleType handleType);
00239 
00240     struct Private;
00241     friend struct Private;
00242     Private *mPriv;
00243 };
00244 
00245 } // Tp
00246 
00247 Q_DECLARE_METATYPE(Tp::Connection::ErrorDetails);
00248 
00249 #endif

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