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