00001
00023 #ifndef _TelepathyQt4_contact_h_HEADER_GUARD_
00024 #define _TelepathyQt4_contact_h_HEADER_GUARD_
00025
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029
00030 #include <TelepathyQt4/Channel>
00031 #include <TelepathyQt4/Feature>
00032 #include <TelepathyQt4/Object>
00033 #include <TelepathyQt4/Types>
00034
00035 #include <QSet>
00036 #include <QVariantMap>
00037
00038 namespace Tp
00039 {
00040
00041 struct AvatarData;
00042 class ContactCapabilities;
00043 class LocationInfo;
00044 class ContactManager;
00045 class PendingContactInfo;
00046 class PendingOperation;
00047 class Presence;
00048 class ReferencedHandles;
00049
00050 class TELEPATHY_QT4_EXPORT Contact : public Object
00051 {
00052 Q_OBJECT
00053 Q_DISABLE_COPY(Contact)
00054
00055 public:
00056 static const Feature FeatureAlias;
00057 static const Feature FeatureAvatarData;
00058 static const Feature FeatureAvatarToken;
00059 static const Feature FeatureCapabilities;
00060 static const Feature FeatureInfo;
00061 static const Feature FeatureLocation;
00062 static const Feature FeatureSimplePresence;
00063
00064 enum PresenceState {
00065 PresenceStateNo,
00066 PresenceStateAsk,
00067 PresenceStateYes
00068 };
00069
00070 class InfoFields
00071 {
00072 public:
00073 InfoFields();
00074 InfoFields(const ContactInfoFieldList &fields);
00075 InfoFields(const InfoFields &other);
00076 ~InfoFields();
00077
00078 bool isValid() const { return mPriv.constData() != 0; }
00079
00080 InfoFields &operator=(const InfoFields &other);
00081
00082 ContactInfoFieldList fields(const QString &name) const;
00083
00084 ContactInfoFieldList allFields() const;
00085
00086 private:
00087 struct Private;
00088 friend struct Private;
00089 QSharedDataPointer<Private> mPriv;
00090 };
00091
00092 ~Contact();
00093
00094 ContactManagerPtr manager() const;
00095
00096 ReferencedHandles handle() const;
00097
00098
00099 QString id() const;
00100
00101 Features requestedFeatures() const;
00102 Features actualFeatures() const;
00103
00104
00105 QString alias() const;
00106
00107 bool isAvatarTokenKnown() const;
00108 QString avatarToken() const;
00109 AvatarData avatarData() const;
00110 void requestAvatarData();
00111
00112
00113
00114
00115
00116
00117
00118
00119 Presence presence() const;
00120
00121
00122 ContactCapabilities capabilities() const;
00123
00124
00125 LocationInfo location() const;
00126
00127
00128
00129 bool isContactInfoKnown() const;
00130 InfoFields infoFields() const;
00131 PendingOperation *refreshInfo();
00132 PendingContactInfo *requestInfo();
00133
00134
00135
00136
00137 bool isSubscriptionStateKnown() const;
00138 bool isSubscriptionRejected() const;
00139 PresenceState subscriptionState() const;
00140 bool isPublishStateKnown() const;
00141 bool isPublishCancelled() const;
00142 PresenceState publishState() const;
00143 QString publishStateMessage() const;
00144
00145 PendingOperation *requestPresenceSubscription(const QString &message = QString());
00146 PendingOperation *removePresenceSubscription(const QString &message = QString());
00147 PendingOperation *authorizePresencePublication(const QString &message = QString());
00148 PendingOperation *removePresencePublication(const QString &message = QString());
00149
00150
00151
00152
00153 bool isBlocked() const;
00154
00155 PendingOperation *block(bool value = true);
00156
00157
00158
00159
00160
00161
00162 QStringList groups() const;
00163 PendingOperation *addToGroup(const QString &group);
00164 PendingOperation *removeFromGroup(const QString &group);
00165
00166 Q_SIGNALS:
00167 void aliasChanged(const QString &alias);
00168
00169 void avatarTokenChanged(const QString &avatarToken);
00170 void avatarDataChanged(const Tp::AvatarData &avatarData);
00171
00172 void presenceChanged(const Tp::Presence &presence);
00173
00174 void capabilitiesChanged(const Tp::ContactCapabilities &caps);
00175
00176 void locationUpdated(const Tp::LocationInfo &location);
00177
00178 void infoFieldsChanged(const Tp::Contact::InfoFields &infoFields);
00179
00180 void subscriptionStateChanged(Tp::Contact::PresenceState state);
00181
00182 void subscriptionStateChanged(Tp::Contact::PresenceState state,
00183 const Tp::Channel::GroupMemberChangeDetails &details);
00184
00185 void publishStateChanged(Tp::Contact::PresenceState state, const QString &message);
00186
00187 void publishStateChanged(Tp::Contact::PresenceState state,
00188 const Tp::Channel::GroupMemberChangeDetails &details);
00189
00190 void blockStatusChanged(bool blocked);
00191
00192 void blockStatusChanged(bool blocked, const Tp::Channel::GroupMemberChangeDetails &details);
00193
00194 void addedToGroup(const QString &group);
00195 void removedFromGroup(const QString &group);
00196
00197
00198
00199
00200
00201
00202
00203 protected:
00204 Contact(ContactManager *manager, const ReferencedHandles &handle,
00205 const Features &requestedFeatures, const QVariantMap &attributes);
00206
00207 virtual void augment(const Features &requestedFeatures, const QVariantMap &attributes);
00208
00209
00210 void connectNotify(const char *);
00211
00212 private:
00213 static const Feature FeatureRosterGroups;
00214
00215 TELEPATHY_QT4_NO_EXPORT void receiveAlias(const QString &alias);
00216 TELEPATHY_QT4_NO_EXPORT void receiveAvatarToken(const QString &avatarToken);
00217 TELEPATHY_QT4_NO_EXPORT void setAvatarToken(const QString &token);
00218 TELEPATHY_QT4_NO_EXPORT void receiveAvatarData(const AvatarData &);
00219 TELEPATHY_QT4_NO_EXPORT void receiveSimplePresence(const SimplePresence &presence);
00220 TELEPATHY_QT4_NO_EXPORT void receiveCapabilities(const RequestableChannelClassList &caps);
00221 TELEPATHY_QT4_NO_EXPORT void receiveLocation(const QVariantMap &location);
00222 TELEPATHY_QT4_NO_EXPORT void receiveInfo(const ContactInfoFieldList &info);
00223
00224 TELEPATHY_QT4_NO_EXPORT static PresenceState subscriptionStateToPresenceState(uint subscriptionState);
00225 TELEPATHY_QT4_NO_EXPORT void setSubscriptionState(SubscriptionState state);
00226 TELEPATHY_QT4_NO_EXPORT void setPublishState(SubscriptionState state, const QString &message = QString());
00227 TELEPATHY_QT4_NO_EXPORT void setBlocked(bool value);
00228
00229 TELEPATHY_QT4_NO_EXPORT void setAddedToGroup(const QString &group);
00230 TELEPATHY_QT4_NO_EXPORT void setRemovedFromGroup(const QString &group);
00231
00232 struct Private;
00233 friend class Connection;
00234 friend class ContactFactory;
00235 friend class ContactManager;
00236 friend struct Private;
00237 Private *mPriv;
00238 };
00239
00240 }
00241
00242 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
00243
00244 #endif