Home · All Classes · All Namespaces · Modules · Functions · Files
contact.h
00001 
00023 #ifndef _TelepathyQt_contact_h_HEADER_GUARD_
00024 #define _TelepathyQt_contact_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TP_QT_HEADER
00027 #error IN_TP_QT_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt/Channel>
00031 #include <TelepathyQt/Feature>
00032 #include <TelepathyQt/Object>
00033 #include <TelepathyQt/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 PendingStringList;
00048 class Presence;
00049 class ReferencedHandles;
00050 
00051 class TP_QT_EXPORT Contact : public Object
00052 {
00053     Q_OBJECT
00054     Q_DISABLE_COPY(Contact)
00055 
00056 public:
00057     static const Feature FeatureAlias;
00058     static const Feature FeatureAvatarData;
00059     static const Feature FeatureAvatarToken;
00060     static const Feature FeatureCapabilities;
00061     static const Feature FeatureInfo;
00062     static const Feature FeatureLocation;
00063     static const Feature FeatureSimplePresence;
00064     static const Feature FeatureAddresses;
00065     static const Feature FeatureClientTypes;
00066 
00067     enum PresenceState {
00068          PresenceStateNo,
00069          PresenceStateAsk,
00070          PresenceStateYes
00071     };
00072 
00073     class InfoFields
00074     {
00075     public:
00076         InfoFields();
00077         InfoFields(const ContactInfoFieldList &fields);
00078         InfoFields(const InfoFields &other);
00079         ~InfoFields();
00080 
00081         bool isValid() const { return mPriv.constData() != 0; }
00082 
00083         InfoFields &operator=(const InfoFields &other);
00084 
00085         ContactInfoFieldList fields(const QString &name) const;
00086 
00087         ContactInfoFieldList allFields() const;
00088 
00089     private:
00090         struct Private;
00091         friend struct Private;
00092         QSharedDataPointer<Private> mPriv;
00093     };
00094 
00095     ~Contact();
00096 
00097     ContactManagerPtr manager() const;
00098 
00099     ReferencedHandles handle() const;
00100 
00101     // TODO filter: exact, prefix, substring match
00102     QString id() const;
00103 
00104     Features requestedFeatures() const;
00105     Features actualFeatures() const;
00106 
00107     // TODO filter: exact, prefix, substring match
00108     QString alias() const;
00109 
00110     QMap<QString, QString> vcardAddresses() const;
00111     QStringList uris() const;
00112 
00113     bool isAvatarTokenKnown() const;
00114     QString avatarToken() const;
00115     AvatarData avatarData() const;
00116     void requestAvatarData();
00117 
00118     /*
00119      * TODO filter:
00120      *  - exact match of presence().type(), presence().status()
00121      *  - ANY 1 of a number of presence types/statuses
00122      *  - presence().type() greater or less than a set value
00123      *  - have/don't have presence().message() AND exact/prefix/substring
00124      */
00125     Presence presence() const;
00126 
00127     // TODO filter: the same as Account filtering by caps
00128     ContactCapabilities capabilities() const;
00129 
00130     // TODO filter: is it available, how accurate, are they near me
00131     LocationInfo location() const;
00132 
00133     // TODO filter: having a specific field, having ANY field,
00134     // (field: exact, contents: exact/prefix/substring)
00135     bool isContactInfoKnown() const;
00136     InfoFields infoFields() const;
00137     PendingOperation *refreshInfo();
00138     PendingContactInfo *requestInfo();
00139 
00140     /*
00141      * Filters on exact values of these, but also the "in your contact list at all or not" usecase
00142      */
00143     bool isSubscriptionStateKnown() const;
00144     bool isSubscriptionRejected() const;
00145     PresenceState subscriptionState() const;
00146     bool isPublishStateKnown() const;
00147     bool isPublishCancelled() const;
00148     PresenceState publishState() const;
00149     QString publishStateMessage() const;
00150 
00151     PendingOperation *requestPresenceSubscription(const QString &message = QString());
00152     PendingOperation *removePresenceSubscription(const QString &message = QString());
00153     PendingOperation *authorizePresencePublication(const QString &message = QString());
00154     PendingOperation *removePresencePublication(const QString &message = QString());
00155 
00156     /*
00157      * Filter on being blocked or not
00158      */
00159     bool isBlocked() const;
00160     PendingOperation *block();
00161     PendingOperation *blockAndReportAbuse();
00162     PendingOperation *unblock();
00163 
00164     /*
00165      * Filter on the groups they're in - to show a specific group only
00166      *
00167      * Also prefix/substring match on ANY of the groups of the contact
00168      */
00169     QStringList groups() const;
00170     PendingOperation *addToGroup(const QString &group);
00171     PendingOperation *removeFromGroup(const QString &group);
00172 
00173     QStringList clientTypes() const;
00174     PendingStringList *requestClientTypes();
00175 
00176 Q_SIGNALS:
00177     void aliasChanged(const QString &alias);
00178 
00179     void avatarTokenChanged(const QString &avatarToken);
00180     void avatarDataChanged(const Tp::AvatarData &avatarData);
00181 
00182     void presenceChanged(const Tp::Presence &presence);
00183 
00184     void capabilitiesChanged(const Tp::ContactCapabilities &caps);
00185 
00186     void locationUpdated(const Tp::LocationInfo &location);
00187 
00188     void infoFieldsChanged(const Tp::Contact::InfoFields &infoFields);
00189 
00190     void subscriptionStateChanged(Tp::Contact::PresenceState state);
00191 
00192     void publishStateChanged(Tp::Contact::PresenceState state, const QString &message);
00193 
00194     void blockStatusChanged(bool blocked);
00195 
00196     void addedToGroup(const QString &group);
00197     void removedFromGroup(const QString &group);
00198 
00199     void clientTypesChanged(const QStringList &clientTypes);
00200 
00201     // TODO: consider how the Renaming interface should work and map to Contacts
00202     // I guess it would be something like:
00203     // void renamedTo(Tp::ContactPtr)
00204     // with that contact getting the same features requested as the current one. Or would we rather
00205     // want to signal that change right away with a handle?
00206 
00207 protected:
00208     Contact(ContactManager *manager, const ReferencedHandles &handle,
00209             const Features &requestedFeatures, const QVariantMap &attributes);
00210 
00211     virtual void augment(const Features &requestedFeatures, const QVariantMap &attributes);
00212 
00213 private:
00214     static const Feature FeatureRosterGroups;
00215 
00216     TP_QT_NO_EXPORT void receiveAlias(const QString &alias);
00217     TP_QT_NO_EXPORT void receiveAvatarToken(const QString &avatarToken);
00218     TP_QT_NO_EXPORT void setAvatarToken(const QString &token);
00219     TP_QT_NO_EXPORT void receiveAvatarData(const AvatarData &);
00220     TP_QT_NO_EXPORT void receiveSimplePresence(const SimplePresence &presence);
00221     TP_QT_NO_EXPORT void receiveCapabilities(const RequestableChannelClassList &caps);
00222     TP_QT_NO_EXPORT void receiveLocation(const QVariantMap &location);
00223     TP_QT_NO_EXPORT void receiveInfo(const ContactInfoFieldList &info);
00224     TP_QT_NO_EXPORT void receiveAddresses(const QMap<QString, QString> &addresses,
00225             const QStringList &uris);
00226     TP_QT_NO_EXPORT void receiveClientTypes(const QStringList &clientTypes);
00227 
00228     TP_QT_NO_EXPORT static PresenceState subscriptionStateToPresenceState(uint subscriptionState);
00229     TP_QT_NO_EXPORT void setSubscriptionState(SubscriptionState state);
00230     TP_QT_NO_EXPORT void setPublishState(SubscriptionState state, const QString &message = QString());
00231     TP_QT_NO_EXPORT void setBlocked(bool value);
00232 
00233     TP_QT_NO_EXPORT void setAddedToGroup(const QString &group);
00234     TP_QT_NO_EXPORT void setRemovedFromGroup(const QString &group);
00235 
00236     struct Private;
00237     friend class Connection;
00238     friend class ContactFactory;
00239     friend class ContactManager;
00240     friend struct Private;
00241     Private *mPriv;
00242 };
00243 
00244 } // Tp
00245 
00246 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
00247 
00248 #endif


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