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


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