Home · All Classes · All Namespaces · Modules · Functions · Files
connection.h
1 
23 #ifndef _TelepathyQt_connection_h_HEADER_GUARD_
24 #define _TelepathyQt_connection_h_HEADER_GUARD_
25 
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29 
30 #include <TelepathyQt/_gen/cli-connection.h>
31 
32 #include <TelepathyQt/ConnectionCapabilities>
33 #include <TelepathyQt/Contact>
34 #include <TelepathyQt/DBus>
35 #include <TelepathyQt/DBusProxy>
36 #include <TelepathyQt/OptionalInterfaceFactory>
37 #include <TelepathyQt/ReadinessHelper>
38 #include <TelepathyQt/Types>
39 #include <TelepathyQt/SharedPtr>
40 
41 #include <TelepathyQt/Constants>
42 #include <TelepathyQt/Types>
43 
44 #include <QSet>
45 #include <QString>
46 #include <QStringList>
47 
48 namespace Tp
49 {
50 
51 class Channel;
52 class ConnectionCapabilities;
53 class ConnectionLowlevel;
54 class ContactManager;
55 class PendingChannel;
56 class PendingContactAttributes;
57 class PendingHandles;
58 class PendingOperation;
59 class PendingReady;
60 
61 class TP_QT_EXPORT Connection : public StatefulDBusProxy,
62  public OptionalInterfaceFactory<Connection>
63 {
64  Q_OBJECT
65  Q_DISABLE_COPY(Connection)
66 
67 public:
68  static const Feature FeatureCore;
71  static const Feature FeatureRoster;
73  static const Feature FeatureAccountBalance; // TODO unit tests for this
74  static const Feature FeatureConnected;
75 
76  static ConnectionPtr create(const QString &busName,
77  const QString &objectPath,
78  const ChannelFactoryConstPtr &channelFactory,
79  const ContactFactoryConstPtr &contactFactory);
80  static ConnectionPtr create(const QDBusConnection &bus,
81  const QString &busName, const QString &objectPath,
82  const ChannelFactoryConstPtr &channelFactory,
83  const ContactFactoryConstPtr &contactFactory);
84 
85  virtual ~Connection();
86 
87  ChannelFactoryConstPtr channelFactory() const;
88  ContactFactoryConstPtr contactFactory() const;
89 
90  QString cmName() const;
91  QString protocolName() const;
92 
93  ConnectionStatus status() const;
94  ConnectionStatusReason statusReason() const;
95 
97  {
98  public:
99  ErrorDetails();
100  ErrorDetails(const QVariantMap &details);
101  ErrorDetails(const ErrorDetails &other);
102  ~ErrorDetails();
103 
104  ErrorDetails &operator=(const ErrorDetails &other);
105 
106  bool isValid() const { return mPriv.constData() != 0; }
107 
108  bool hasDebugMessage() const
109  {
110  return allDetails().contains(QLatin1String("debug-message"));
111  }
112 
113  QString debugMessage() const
114  {
115  return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message")));
116  }
117 
118  bool hasServerMessage() const
119  {
120  return allDetails().contains(QLatin1String("server-message"));
121  }
122 
123  QString serverMessage() const
124  {
125  return qdbus_cast<QString>(allDetails().value(QLatin1String("server-message")));
126  }
127 
128  bool hasUserRequested() const
129  {
130  return allDetails().contains(QLatin1String("user-requested"));
131  }
132 
133  bool userRequested() const
134  {
135  return qdbus_cast<bool>(allDetails().value(QLatin1String("user-requested")));
136  }
137 
138  bool hasExpectedHostname() const
139  {
140  return allDetails().contains(QLatin1String("expected-hostname"));
141  }
142 
143  QString expectedHostname() const
144  {
145  return qdbus_cast<QString>(allDetails().value(QLatin1String("expected-hostname")));
146  }
147 
149  {
150  return allDetails().contains(QLatin1String("certificate-hostname"));
151  }
152 
153  QString certificateHostname() const
154  {
155  return qdbus_cast<QString>(allDetails().value(QLatin1String("certificate-hostname")));
156  }
157 
158  QVariantMap allDetails() const;
159 
160  private:
161  friend class Connection;
162 
163  struct Private;
164  friend struct Private;
165  QSharedDataPointer<Private> mPriv;
166  };
167 
168  const ErrorDetails &errorDetails() const;
169 
170  uint selfHandle() const;
171  ContactPtr selfContact() const;
172 
173  CurrencyAmount accountBalance() const;
174 
175  ConnectionCapabilities capabilities() const;
176 
177  ContactManagerPtr contactManager() const;
178 
179 #if defined(BUILDING_TP_QT) || defined(TP_QT_ENABLE_LOWLEVEL_API)
180  ConnectionLowlevelPtr lowlevel();
181  ConnectionLowlevelConstPtr lowlevel() const;
182 #endif
183 
184 Q_SIGNALS:
185  void statusChanged(Tp::ConnectionStatus newStatus);
186 
187  void selfHandleChanged(uint newHandle);
188  // FIXME: might not need this when Renaming is fixed and mapped to Contacts
189  void selfContactChanged();
190 
191  void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
192 
193 protected:
194  Connection(const QDBusConnection &bus, const QString &busName,
195  const QString &objectPath,
196  const ChannelFactoryConstPtr &channelFactory,
197  const ContactFactoryConstPtr &contactFactory,
198  const Feature &coreFeature);
199 
200  Client::ConnectionInterface *baseInterface() const;
201 
202 private Q_SLOTS:
203  TP_QT_NO_EXPORT void onStatusReady(uint status);
204  TP_QT_NO_EXPORT void onStatusChanged(uint status, uint reason);
205  TP_QT_NO_EXPORT void onConnectionError(const QString &error, const QVariantMap &details);
206  TP_QT_NO_EXPORT void gotMainProperties(QDBusPendingCallWatcher *watcher);
207  TP_QT_NO_EXPORT void gotStatus(QDBusPendingCallWatcher *watcher);
208  TP_QT_NO_EXPORT void gotInterfaces(QDBusPendingCallWatcher *watcher);
209  TP_QT_NO_EXPORT void gotSelfHandle(QDBusPendingCallWatcher *watcher);
210  TP_QT_NO_EXPORT void gotCapabilities(QDBusPendingCallWatcher *watcher);
211  TP_QT_NO_EXPORT void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
212  TP_QT_NO_EXPORT void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
213  TP_QT_NO_EXPORT void gotSelfContact(Tp::PendingOperation *op);
214 
215  TP_QT_NO_EXPORT void onIntrospectRosterFinished(Tp::PendingOperation *op);
216  TP_QT_NO_EXPORT void onIntrospectRosterGroupsFinished(Tp::PendingOperation *op);
217 
218  TP_QT_NO_EXPORT void doReleaseSweep(uint handleType);
219 
220  TP_QT_NO_EXPORT void onSelfHandleChanged(uint);
221 
222  TP_QT_NO_EXPORT void gotBalance(QDBusPendingCallWatcher *watcher);
223  TP_QT_NO_EXPORT void onBalanceChanged(const Tp::CurrencyAmount &);
224 
225 private:
226  class PendingConnect;
227  friend class ConnectionLowlevel;
228  friend class PendingChannel;
229  friend class PendingConnect;
231  friend class PendingContacts;
232  friend class PendingHandles;
233  friend class ReferencedHandles;
234 
235  TP_QT_NO_EXPORT void refHandle(HandleType handleType, uint handle);
236  TP_QT_NO_EXPORT void unrefHandle(HandleType handleType, uint handle);
237  TP_QT_NO_EXPORT void handleRequestLanded(HandleType handleType);
238 
239  struct Private;
240  friend struct Private;
241  Private *mPriv;
242 };
243 
244 } // Tp
245 
246 Q_DECLARE_METATYPE(Tp::Connection::ErrorDetails);
247 
248 #endif
ConnectionStatusReason
Definition: build/TelepathyQt/_gen/constants.h:1465
The PendingOperation class is a base class for pending asynchronous operations.
Definition: pending-operation.h:45
QString expectedHostname() const
Definition: connection.h:143
The Connection::ErrorDetails class represents the details of a connection error.
Definition: connection.h:96
bool hasDebugMessage() const
Definition: connection.h:108
The PendingContactAttributes class represents the parameters of and the reply to an asynchronous requ...
Definition: pending-contact-attributes.h:40
Definition: cli-connection.h:44
The ConnectionCapabilities class represents the capabilities of a Connection.
Definition: connection-capabilities.h:38
bool hasServerMessage() const
Definition: connection.h:118
static const Feature FeatureSelfContact
Definition: connection.h:69
The PendingHandles class represents the parameters of and the reply to an asynchronous handle request...
Definition: pending-handles.h:46
static const Feature FeatureSimplePresence
Definition: connection.h:70
bool hasCertificateHostname() const
Definition: connection.h:148
bool hasExpectedHostname() const
Definition: connection.h:138
static const Feature FeatureRosterGroups
Definition: connection.h:72
bool userRequested() const
Definition: connection.h:133
Definition: build/TelepathyQt/_gen/types.h:1361
static const Feature FeatureCore
Definition: connection.h:68
The StatefulDBusProxy class is a base class representing a remote object whose API is stateful...
Definition: dbus-proxy.h:96
ConnectionStatus
Definition: build/TelepathyQt/_gen/constants.h:1420
The PendingContacts class is used by ContactManager when creating/updating Contact objects...
Definition: pending-contacts.h:46
static const Feature FeatureAccountBalance
Definition: connection.h:73
QString certificateHostname() const
Definition: connection.h:153
The PendingChannel class represents the parameters of and the reply to an asynchronous channel reques...
Definition: pending-channel.h:44
The Connection class represents a Telepathy connection.
Definition: connection.h:61
bool isValid() const
Definition: connection.h:106
The OptionalInterfaceFactory class is a helper class for high-level D-Bus proxy classes willing to of...
Definition: optional-interface-factory.h:65
Helper container for safe management of handle lifetimes. Every handle in a ReferencedHandles contain...
Definition: referenced-handles.h:47
HandleType
Definition: build/TelepathyQt/_gen/constants.h:1375
Definition: abstract-adaptor.cpp:31
bool hasUserRequested() const
Definition: connection.h:128
QString serverMessage() const
Definition: connection.h:123
The Feature class represents a feature that can be enabled on demand.
Definition: feature.h:41
static const Feature FeatureConnected
Definition: connection.h:74
static const Feature FeatureRoster
Definition: connection.h:71
The ConnectionLowlevel class extends Connection with support to low-level features.
Definition: connection-lowlevel.h:43
QString debugMessage() const
Definition: connection.h:113


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.7