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