1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
/*
* This file is part of TelepathyQt4
*
* Copyright (C) 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/>
* Copyright (C) 2008-2010 Nokia Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _TelepathyQt4_connection_h_HEADER_GUARD_
#define _TelepathyQt4_connection_h_HEADER_GUARD_
#ifndef IN_TELEPATHY_QT4_HEADER
#error IN_TELEPATHY_QT4_HEADER
#endif
#include <TelepathyQt4/_gen/cli-connection.h>
#include <TelepathyQt4/ConnectionCapabilities>
#include <TelepathyQt4/Contact>
#include <TelepathyQt4/DBus>
#include <TelepathyQt4/DBusProxy>
#include <TelepathyQt4/OptionalInterfaceFactory>
#include <TelepathyQt4/ReadinessHelper>
#include <TelepathyQt4/Types>
#include <TelepathyQt4/SharedPtr>
#include <TelepathyQt4/Constants>
#include <TelepathyQt4/Types>
#include <QSet>
#include <QString>
#include <QStringList>
namespace Tp
{
class Channel;
class ConnectionCapabilities;
class ConnectionLowlevel;
class Contact;
class ContactManager;
class PendingChannel;
class PendingContactAttributes;
class PendingHandles;
class PendingOperation;
class PendingReady;
class TELEPATHY_QT4_EXPORT Connection : public StatefulDBusProxy,
public OptionalInterfaceFactory<Connection>
{
Q_OBJECT
Q_DISABLE_COPY(Connection)
public:
static const Feature FeatureCore;
static const Feature FeatureSelfContact;
static const Feature FeatureSimplePresence;
static const Feature FeatureRoster;
static const Feature FeatureRosterGroups;
static const Feature FeatureAccountBalance; // TODO unit tests for this
static ConnectionPtr create(const QString &busName,
const QString &objectPath,
const ChannelFactoryConstPtr &channelFactory,
const ContactFactoryConstPtr &contactFactory);
static ConnectionPtr create(const QDBusConnection &bus,
const QString &busName, const QString &objectPath,
const ChannelFactoryConstPtr &channelFactory,
const ContactFactoryConstPtr &contactFactory);
virtual ~Connection();
ChannelFactoryConstPtr channelFactory() const;
ContactFactoryConstPtr contactFactory() const;
QString cmName() const;
QString protocolName() const;
ConnectionStatus status() const;
ConnectionStatusReason statusReason() const;
class ErrorDetails
{
public:
ErrorDetails();
ErrorDetails(const QVariantMap &details);
ErrorDetails(const ErrorDetails &other);
~ErrorDetails();
ErrorDetails &operator=(const ErrorDetails &other);
bool isValid() const { return mPriv.constData() != 0; }
bool hasDebugMessage() const
{
return allDetails().contains(QLatin1String("debug-message"));
}
QString debugMessage() const
{
return qdbus_cast<QString>(allDetails().value(QLatin1String("debug-message")));
}
#if 0
/*
* TODO: these are actually specified in a draft interface only. Probably shouldn't
* include them yet.
*/
bool hasExpectedHostname() const
{
return allDetails().contains(QLatin1String("expected-hostname"));
}
QString expectedHostname() const
{
return qdbus_cast<QString>(allDetails().value(QLatin1String("expected-hostname")));
}
bool hasCertificateHostname() const
{
return allDetails().contains(QLatin1String("certificate-hostname"));
}
QString certificateHostname() const
{
return qdbus_cast<QString>(allDetails().value(QLatin1String("certificate-hostname")));
}
#endif
QVariantMap allDetails() const;
private:
friend class Connection;
struct Private;
friend struct Private;
QSharedDataPointer<Private> mPriv;
};
const ErrorDetails &errorDetails() const;
uint selfHandle() const;
ContactPtr selfContact() const;
CurrencyAmount accountBalance() const;
ConnectionCapabilities capabilities() const;
ContactManagerPtr contactManager() const;
#if defined(BUILDING_TELEPATHY_QT4) || defined(TP_QT4_ENABLE_LOWLEVEL_API)
ConnectionLowlevelPtr lowlevel();
ConnectionLowlevelConstPtr lowlevel() const;
#endif
Q_SIGNALS:
void statusChanged(Tp::ConnectionStatus newStatus);
void selfHandleChanged(uint newHandle);
// FIXME: might not need this when Renaming is fixed and mapped to Contacts
void selfContactChanged();
void accountBalanceChanged(const Tp::CurrencyAmount &accountBalance);
protected:
Connection(const QDBusConnection &bus, const QString &busName,
const QString &objectPath,
const ChannelFactoryConstPtr &channelFactory,
const ContactFactoryConstPtr &contactFactory,
const Feature &coreFeature);
Client::ConnectionInterface *baseInterface() const;
private Q_SLOTS:
void onStatusReady(uint status);
void onStatusChanged(uint status, uint reason);
void onConnectionError(const QString &error, const QVariantMap &details);
void gotMainProperties(QDBusPendingCallWatcher *watcher);
void gotStatus(QDBusPendingCallWatcher *watcher);
void gotInterfaces(QDBusPendingCallWatcher *watcher);
void gotSelfHandle(QDBusPendingCallWatcher *watcher);
void gotCapabilities(QDBusPendingCallWatcher *watcher);
void gotContactAttributeInterfaces(QDBusPendingCallWatcher *watcher);
void gotSimpleStatuses(QDBusPendingCallWatcher *watcher);
void gotSelfContact(Tp::PendingOperation *op);
void gotContactListProperties(Tp::PendingOperation *op);
void gotContactListContacts(QDBusPendingCallWatcher *watcher);
void gotContactListGroupsProperties(Tp::PendingOperation *op);
void onContactListContactsUpgraded(Tp::PendingOperation *op);
void onContactListStateChanged(uint state);
void onContactListContactsChanged(const Tp::ContactSubscriptionMap &changes,
const Tp::UIntList &removals);
void gotContactListsHandles(Tp::PendingOperation *op);
void gotContactListChannel(Tp::PendingOperation *op);
void contactListChannelReady();
void onNewChannels(const Tp::ChannelDetailsList &channelDetailsList);
void onContactListGroupChannelReady(Tp::PendingOperation *op);
void gotChannels(QDBusPendingCallWatcher *watcher);
void doReleaseSweep(uint handleType);
void onSelfHandleChanged(uint);
void gotBalance(QDBusPendingCallWatcher *watcher);
void onBalanceChanged(const Tp::CurrencyAmount &);
private:
class PendingConnect;
friend class ConnectionLowlevel;
friend class PendingChannel;
friend class PendingConnect;
friend class PendingContactAttributes;
friend class PendingContacts;
friend class PendingHandles;
friend class ReferencedHandles;
void refHandle(HandleType handleType, uint handle);
void unrefHandle(HandleType handleType, uint handle);
void handleRequestLanded(HandleType handleType);
struct Private;
friend struct Private;
Private *mPriv;
};
} // Tp
Q_DECLARE_METATYPE(Tp::Connection::ErrorDetails);
#endif
|