| Home · All Classes · All Namespaces · Modules · Functions · Files

contact.h
1
23 #ifndef _TelepathyQt_contact_h_HEADER_GUARD_
24 #define _TelepathyQt_contact_h_HEADER_GUARD_
25
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29
30 #include <TelepathyQt/Channel>
31 #include <TelepathyQt/Feature>
32 #include <TelepathyQt/Object>
33 #include <TelepathyQt/Types>
34
35 #include <QSet>
36 #include <QVariantMap>
37
38 namespace Tp
39 {
40
41 struct AvatarData;
42 class ContactCapabilities;
43 class LocationInfo;
44 class ContactManager;
45 class PendingContactInfo;
46 class PendingOperation;
47 class PendingStringList;
48 class Presence;
49 class ReferencedHandles;
50
51 class TP_QT_EXPORT Contact : public Object
52 {
53 Q_OBJECT
54 Q_DISABLE_COPY(Contact)
55
56 public:
57 static const Feature FeatureAlias;
58 static const Feature FeatureAvatarData;
59 static const Feature FeatureAvatarToken;
60 static const Feature FeatureCapabilities;
61 static const Feature FeatureInfo;
62 static const Feature FeatureLocation;
63 static const Feature FeatureSimplePresence;
64 static const Feature FeatureAddresses;
65 static const Feature FeatureClientTypes;
66
67 enum PresenceState {
68 PresenceStateNo,
69 PresenceStateAsk,
70 PresenceStateYes
71 };
72
73 class InfoFields
74 {
75 public:
76 InfoFields();
77 InfoFields(const ContactInfoFieldList &fields);
78 InfoFields(const InfoFields &other);
79 ~InfoFields();
80
81 bool isValid() const { return mPriv.constData() != 0; }
82
83 InfoFields &operator=(const InfoFields &other);
84
85 ContactInfoFieldList fields(const QString &name) const;
86
87 ContactInfoFieldList allFields() const;
88
89 private:
90 struct Private;
91 friend struct Private;
92 QSharedDataPointer<Private> mPriv;
93 };
94
95 ~Contact();
96
97 ContactManagerPtr manager() const;
98
99 ReferencedHandles handle() const;
100
101 // TODO filter: exact, prefix, substring match
102 QString id() const;
103
104 Features requestedFeatures() const;
105 Features actualFeatures() const;
106
107 // TODO filter: exact, prefix, substring match
108 QString alias() const;
109
110 QMap<QString, QString> vcardAddresses() const;
111 QStringList uris() const;
112
113 bool isAvatarTokenKnown() const;
114 QString avatarToken() const;
115 AvatarData avatarData() const;
116 void requestAvatarData();
117
118 /*
119 * TODO filter:
120 * - exact match of presence().type(), presence().status()
121 * - ANY 1 of a number of presence types/statuses
122 * - presence().type() greater or less than a set value
123 * - have/don't have presence().message() AND exact/prefix/substring
124 */
125 Presence presence() const;
126
127 // TODO filter: the same as Account filtering by caps
128 ContactCapabilities capabilities() const;
129
130 // TODO filter: is it available, how accurate, are they near me
131 LocationInfo location() const;
132
133 // TODO filter: having a specific field, having ANY field,
134 // (field: exact, contents: exact/prefix/substring)
135 bool isContactInfoKnown() const;
136 InfoFields infoFields() const;
137 PendingOperation *refreshInfo();
138 PendingContactInfo *requestInfo();
139
140 /*
141 * Filters on exact values of these, but also the "in your contact list at all or not" usecase
142 */
143 bool isSubscriptionStateKnown() const;
144 bool isSubscriptionRejected() const;
145 PresenceState subscriptionState() const;
146 bool isPublishStateKnown() const;
147 bool isPublishCancelled() const;
148 PresenceState publishState() const;
149 QString publishStateMessage() const;
150
151 PendingOperation *requestPresenceSubscription(const QString &message = QString());
152 PendingOperation *removePresenceSubscription(const QString &message = QString());
153 PendingOperation *authorizePresencePublication(const QString &message = QString());
154 PendingOperation *removePresencePublication(const QString &message = QString());
155
156 /*
157 * Filter on being blocked or not
158 */
159 bool isBlocked() const;
160 PendingOperation *block();
161 PendingOperation *blockAndReportAbuse();
162 PendingOperation *unblock();
163
164 /*
165 * Filter on the groups they're in - to show a specific group only
166 *
167 * Also prefix/substring match on ANY of the groups of the contact
168 */
169 QStringList groups() const;
170 PendingOperation *addToGroup(const QString &group);
171 PendingOperation *removeFromGroup(const QString &group);
172
173 QStringList clientTypes() const;
174 PendingStringList *requestClientTypes();
175
176 Q_SIGNALS:
177 void aliasChanged(const QString &alias);
178
179 void avatarTokenChanged(const QString &avatarToken);
180 void avatarDataChanged(const Tp::AvatarData &avatarData);
181
182 void presenceChanged(const Tp::Presence &presence);
183
184 void capabilitiesChanged(const Tp::ContactCapabilities &caps);
185
186 void locationUpdated(const Tp::LocationInfo &location);
187
188 void infoFieldsChanged(const Tp::Contact::InfoFields &infoFields);
189
190 void subscriptionStateChanged(Tp::Contact::PresenceState state);
191
192 void publishStateChanged(Tp::Contact::PresenceState state, const QString &message);
193
194 void blockStatusChanged(bool blocked);
195
196 void addedToGroup(const QString &group);
197 void removedFromGroup(const QString &group);
198
199 void clientTypesChanged(const QStringList &clientTypes);
200
201 // TODO: consider how the Renaming interface should work and map to Contacts
202 // I guess it would be something like:
203 // void renamedTo(Tp::ContactPtr)
204 // with that contact getting the same features requested as the current one. Or would we rather
205 // want to signal that change right away with a handle?
206
207 protected:
208 Contact(ContactManager *manager, const ReferencedHandles &handle,
209 const Features &requestedFeatures, const QVariantMap &attributes);
210
211 virtual void augment(const Features &requestedFeatures, const QVariantMap &attributes);
212
213 private:
214 static const Feature FeatureRosterGroups;
215
216 TP_QT_NO_EXPORT void receiveAlias(const QString &alias);
217 TP_QT_NO_EXPORT void receiveAvatarToken(const QString &avatarToken);
218 TP_QT_NO_EXPORT void setAvatarToken(const QString &token);
219 TP_QT_NO_EXPORT void receiveAvatarData(const AvatarData &);
220 TP_QT_NO_EXPORT void receiveSimplePresence(const SimplePresence &presence);
221 TP_QT_NO_EXPORT void receiveCapabilities(const RequestableChannelClassList &caps);
222 TP_QT_NO_EXPORT void receiveLocation(const QVariantMap &location);
223 TP_QT_NO_EXPORT void receiveInfo(const ContactInfoFieldList &info);
224 TP_QT_NO_EXPORT void receiveAddresses(const QMap<QString, QString> &addresses,
225 const QStringList &uris);
226 TP_QT_NO_EXPORT void receiveClientTypes(const QStringList &clientTypes);
227
228 TP_QT_NO_EXPORT static PresenceState subscriptionStateToPresenceState(uint subscriptionState);
229 TP_QT_NO_EXPORT void setSubscriptionState(SubscriptionState state);
230 TP_QT_NO_EXPORT void setPublishState(SubscriptionState state, const QString &message = QString());
231 TP_QT_NO_EXPORT void setBlocked(bool value);
232
233 TP_QT_NO_EXPORT void setAddedToGroup(const QString &group);
234 TP_QT_NO_EXPORT void setRemovedFromGroup(const QString &group);
235
236 struct Private;
237 friend class Connection;
238 friend class ContactFactory;
239 friend class ContactManager;
240 friend struct Private;
241 Private *mPriv;
242 };
243
244 } // Tp
245
246 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
247
248 #endif
Tp::ContactManager
The ContactManager class is responsible for managing contacts.
Definition: contact-manager.h:50
Tp::ContactInfoFieldList
QList< ContactInfoField > ContactInfoFieldList
Definition: build/TelepathyQt/_gen/types.h:1188
Tp::SimplePresence
Definition: build/TelepathyQt/_gen/types.h:2733
Tp::Contact::FeatureAlias
static const Feature FeatureAlias
Definition: contact.h:57
Tp::Object
The Object class provides an object with property notification.
Definition: object.h:39
Tp::ContactCapabilities
The ContactCapabilities class represents the capabilities of a Contact.
Definition: contact-capabilities.h:38
Tp::Contact::FeatureSimplePresence
static const Feature FeatureSimplePresence
Definition: contact.h:63
Tp::Feature
The Feature class represents a feature that can be enabled on demand.
Definition: feature.h:41
Tp::Contact::PresenceStateNo
Definition: contact.h:68
Tp::Contact::FeatureLocation
static const Feature FeatureLocation
Definition: contact.h:62
Tp::Presence
The Presence class represents a Telepathy simple presence.
Definition: presence.h:36
Tp::PendingOperation
The PendingOperation class is a base class for pending asynchronous operations.
Definition: pending-operation.h:45
Tp::RequestableChannelClassList
QList< RequestableChannelClass > RequestableChannelClassList
Definition: build/TelepathyQt/_gen/types.h:2621
Tp::Contact::InfoFields::isValid
bool isValid() const
Definition: contact.h:81
Tp::Connection
The Connection class represents a Telepathy connection.
Definition: connection.h:62
Tp::AvatarData
The AvatarData class represents a Telepathy avatar.
Definition: avatar.h:40
Tp::ReferencedHandles
Helper container for safe management of handle lifetimes. Every handle in a ReferencedHandles contain...
Definition: referenced-handles.h:47
Tp::SubscriptionState
SubscriptionState
Definition: build/TelepathyQt/_gen/constants.h:1789
Tp::Contact::FeatureInfo
static const Feature FeatureInfo
Definition: contact.h:61
Tp::Contact::FeatureAvatarToken
static const Feature FeatureAvatarToken
Definition: contact.h:59
Tp::LocationInfo
The LocationInfo class represents the location of a Telepathy Contact.
Definition: location-info.h:40
Tp::Contact::PresenceStateAsk
Definition: contact.h:69
Tp::ContactFactory
The ContactFactory class is responsible for constructing Contact objects according to application-def...
Definition: contact-factory.h:44
Tp::PendingStringList
The PendingStringList class is a generic subclass of PendingOperation representing a pending D-Bus me...
Definition: pending-string-list.h:37
Tp::Contact::PresenceState
PresenceState
Definition: contact.h:67
Tp::PendingContactInfo
The PendingContactInfo class represents the parameters of and the reply to an asynchronous contact in...
Definition: pending-contact-info.h:39
Tp::Contact::FeatureAvatarData
static const Feature FeatureAvatarData
Definition: contact.h:58
Tp::Contact
The Contact class represents a Telepathy contact.
Definition: contact.h:51
Tp::Contact::InfoFields
The Contact::InfoFields class represents the information of a Telepathy contact.
Definition: contact.h:73
Tp::Contact::FeatureClientTypes
static const Feature FeatureClientTypes
Definition: contact.h:65
Tp::Features
The Features class represents a list of Feature.
Definition: feature.h:61
Tp::Contact::FeatureCapabilities
static const Feature FeatureCapabilities
Definition: contact.h:60
Tp::Contact::FeatureAddresses
static const Feature FeatureAddresses
Definition: contact.h:64