00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TelepathyQt4_cli_connection_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_connection_h_HEADER_GUARD_
00024
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028
00029 #include <TelepathyQt4/_gen/cli-connection.h>
00030
00031 #include <TelepathyQt4/Client/Contact>
00032 #include <TelepathyQt4/Client/DBus>
00033 #include <TelepathyQt4/Client/DBusProxy>
00034 #include <TelepathyQt4/Client/OptionalInterfaceFactory>
00035 #include <TelepathyQt4/Client/ReadinessHelper>
00036 #include <TelepathyQt4/Client/ReadyObject>
00037
00038 #include <TelepathyQt4/Constants>
00039 #include <TelepathyQt4/Types>
00040
00041 #include <QExplicitlySharedDataPointer>
00042 #include <QSet>
00043 #include <QSharedData>
00044 #include <QString>
00045 #include <QStringList>
00046
00047 namespace Telepathy
00048 {
00049 namespace Client
00050 {
00051
00052 class Channel;
00053 class Contact;
00054 class ContactManager;
00055 class PendingChannel;
00056 class PendingContactAttributes;
00057 class PendingHandles;
00058 class PendingOperation;
00059 class PendingReady;
00060
00061 class Connection : public StatefulDBusProxy,
00062 private OptionalInterfaceFactory<Connection>,
00063 public ReadyObject,
00064 public QSharedData
00065 {
00066 Q_OBJECT
00067 Q_DISABLE_COPY(Connection)
00068 Q_ENUMS(Status)
00069
00070 public:
00071 static const Feature FeatureCore;
00072 static const Feature FeatureSelfContact;
00073 static const Feature FeatureSimplePresence;
00074 static const Feature FeatureRoster;
00075
00076 enum Status {
00077 StatusDisconnected = Telepathy::ConnectionStatusDisconnected,
00078 StatusConnecting = Telepathy::ConnectionStatusConnecting,
00079 StatusConnected = Telepathy::ConnectionStatusConnected,
00080 StatusUnknown = 0xFFFFFFFF
00081 };
00082
00083 Connection(const QString &busName,
00084 const QString &objectPath,
00085 QObject *parent = 0);
00086
00087 Connection(const QDBusConnection &bus,
00088 const QString &busName,
00089 const QString &objectPath,
00090 QObject *parent = 0);
00091
00092 ~Connection();
00093
00094 uint status() const;
00095 uint statusReason() const;
00096
00097 QStringList interfaces() const;
00098
00099 uint selfHandle() const;
00100
00101 SimpleStatusSpecMap allowedPresenceStatuses() const;
00102 PendingOperation *setSelfPresence(const QString &status, const QString &statusMessage);
00103
00104 ContactPtr selfContact() const;
00105
00106 template <class Interface>
00107 inline Interface *optionalInterface(
00108 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00109 {
00110
00111 QString name(Interface::staticInterfaceName());
00112 if (check == CheckInterfaceSupported && !interfaces().contains(name)) {
00113 return 0;
00114 }
00115
00116
00117 return OptionalInterfaceFactory<Connection>::interface<Interface>();
00118 }
00119
00120 inline ConnectionInterfaceAliasingInterface *aliasingInterface(
00121 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00122 {
00123 return optionalInterface<ConnectionInterfaceAliasingInterface>(check);
00124 }
00125
00126 inline ConnectionInterfaceAvatarsInterface *avatarsInterface(
00127 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00128 {
00129 return optionalInterface<ConnectionInterfaceAvatarsInterface>(check);
00130 }
00131
00132 inline ConnectionInterfaceCapabilitiesInterface *capabilitiesInterface(
00133 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00134 {
00135 return optionalInterface<ConnectionInterfaceCapabilitiesInterface>(check);
00136 }
00137
00138 inline ConnectionInterfacePresenceInterface *presenceInterface(
00139 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00140 {
00141 return optionalInterface<ConnectionInterfacePresenceInterface>(check);
00142 }
00143
00144 inline ConnectionInterfaceSimplePresenceInterface *simplePresenceInterface(
00145 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00146 {
00147 return optionalInterface<ConnectionInterfaceSimplePresenceInterface>(check);
00148 }
00149
00150 inline ConnectionInterfaceRequestsInterface *requestsInterface(
00151 InterfaceSupportedChecking check = CheckInterfaceSupported) const
00152 {
00153 return optionalInterface<ConnectionInterfaceRequestsInterface>(check);
00154 }
00155
00156 inline DBus::PropertiesInterface *propertiesInterface() const
00157 {
00158 return optionalInterface<DBus::PropertiesInterface>(BypassInterfaceCheck);
00159 }
00160
00161 PendingChannel *createChannel(const QVariantMap &request);
00162
00163 PendingChannel *ensureChannel(const QVariantMap &request);
00164
00165 PendingReady *requestConnect(const Features &requestedFeatures = Features());
00166
00167 PendingOperation *requestDisconnect();
00168
00169 PendingHandles *requestHandles(uint handleType, const QStringList &names);
00170
00171 PendingHandles *referenceHandles(uint handleType, const UIntList &handles);
00172
00173 PendingContactAttributes *getContactAttributes(const UIntList &handles,
00174 const QStringList &interfaces, bool reference = true);
00175 QStringList contactAttributeInterfaces() const;
00176 ContactManager *contactManager() const;
00177
00178 Q_SIGNALS:
00179 void statusChanged(uint newStatus, uint newStatusReason);
00180 void selfHandleChanged(uint newHandle);
00181
00182 void selfContactChanged();
00183
00184 protected:
00185 ConnectionInterface *baseInterface() const;
00186
00187 private Q_SLOTS:
00188 void onStatusReady(uint);
00189 void onStatusChanged(uint, uint);
00190 void gotStatus(QDBusPendingCallWatcher *watcher);
00191 void gotInterfaces(QDBusPendingCallWatcher *watcher);
00192 void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
00193 void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
00194 void gotSelfContact(Telepathy::Client::PendingOperation *);
00195 void gotSelfHandle(QDBusPendingCallWatcher *watcher);
00196 void gotContactListsHandles(Telepathy::Client::PendingOperation *);
00197 void gotContactListChannel(Telepathy::Client::PendingOperation *);
00198 void contactListChannelReady();
00199
00200 void doReleaseSweep(uint type);
00201
00202 void onSelfHandleChanged(uint);
00203
00204 private:
00205 void refHandle(uint type, uint handle);
00206 void unrefHandle(uint type, uint handle);
00207 void handleRequestLanded(uint type);
00208
00209 struct Private;
00210 class PendingConnect;
00211 friend struct Private;
00212 friend class PendingChannel;
00213 friend class PendingConnect;
00214 friend class PendingContactAttributes;
00215 friend class PendingHandles;
00216 friend class ReferencedHandles;
00217 Private *mPriv;
00218 };
00219
00220 typedef QExplicitlySharedDataPointer<Connection> ConnectionPtr;
00221
00222 }
00223 }
00224
00225 #endif