Home · All Classes · All Namespaces · Modules · Functions · Files
contact.h
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     // TODO filter: exact, prefix, substring match
00099     QString id() const;
00100 
00101     Features requestedFeatures() const;
00102     Features actualFeatures() const;
00103 
00104     // TODO filter: exact, prefix, substring match
00105     QString alias() const;
00106 
00107     bool isAvatarTokenKnown() const;
00108     QString avatarToken() const;
00109     AvatarData avatarData() const;
00110     void requestAvatarData();
00111 
00112     /*
00113      * TODO filter:
00114      *  - exact match of presence().type(), presence().status()
00115      *  - ANY 1 of a number of presence types/statuses
00116      *  - presence().type() greater or less than a set value
00117      *  - have/don't have presence().message() AND exact/prefix/substring
00118      */
00119     Presence presence() const;
00120 
00121     // TODO filter: the same as Account filtering by caps
00122     ContactCapabilities capabilities() const;
00123 
00124     // TODO filter: is it available, how accurate, are they near me
00125     LocationInfo location() const;
00126 
00127     // TODO filter: having a specific field, having ANY field,
00128     // (field: exact, contents: exact/prefix/substring)
00129     bool isContactInfoKnown() const;
00130     InfoFields infoFields() const;
00131     PendingOperation *refreshInfo();
00132     PendingContactInfo *requestInfo();
00133 
00134     /*
00135      * Filters on exact values of these, but also the "in your contact list at all or not" usecase
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      * Filter on being blocked or not
00152      */
00153     bool isBlocked() const;
00154     TELEPATHY_QT4_DEPRECATED PendingOperation *block(bool value);
00155     PendingOperation *block();
00156     PendingOperation *blockAndReportAbuse();
00157     PendingOperation *unblock();
00158 
00159     /*
00160      * Filter on the groups they're in - to show a specific group only
00161      *
00162      * Also prefix/substring match on ANY of the groups of the contact
00163      */
00164     QStringList groups() const;
00165     PendingOperation *addToGroup(const QString &group);
00166     PendingOperation *removeFromGroup(const QString &group);
00167 
00168 Q_SIGNALS:
00169     void aliasChanged(const QString &alias);
00170 
00171     void avatarTokenChanged(const QString &avatarToken);
00172     void avatarDataChanged(const Tp::AvatarData &avatarData);
00173 
00174     void presenceChanged(const Tp::Presence &presence);
00175 
00176     void capabilitiesChanged(const Tp::ContactCapabilities &caps);
00177 
00178     void locationUpdated(const Tp::LocationInfo &location);
00179 
00180     void infoFieldsChanged(const Tp::Contact::InfoFields &infoFields);
00181 
00182     void subscriptionStateChanged(Tp::Contact::PresenceState state);
00183     // deprecated
00184     void subscriptionStateChanged(Tp::Contact::PresenceState state,
00185             const Tp::Channel::GroupMemberChangeDetails &details);
00186 
00187     void publishStateChanged(Tp::Contact::PresenceState state, const QString &message);
00188     // deprecated
00189     void publishStateChanged(Tp::Contact::PresenceState state,
00190             const Tp::Channel::GroupMemberChangeDetails &details);
00191 
00192     void blockStatusChanged(bool blocked);
00193     // deprecated
00194     void blockStatusChanged(bool blocked, const Tp::Channel::GroupMemberChangeDetails &details);
00195 
00196     void addedToGroup(const QString &group);
00197     void removedFromGroup(const QString &group);
00198 
00199     // TODO: consider how the Renaming interface should work and map to Contacts
00200     // I guess it would be something like:
00201     // void renamedTo(Tp::ContactPtr)
00202     // with that contact getting the same features requested as the current one. Or would we rather
00203     // want to signal that change right away with a handle?
00204 
00205 protected:
00206     Contact(ContactManager *manager, const ReferencedHandles &handle,
00207             const Features &requestedFeatures, const QVariantMap &attributes);
00208 
00209     virtual void augment(const Features &requestedFeatures, const QVariantMap &attributes);
00210 
00211     // FIXME: (API/ABI break) Remove connectNotify
00212     void connectNotify(const char *);
00213 
00214 private:
00215     static const Feature FeatureRosterGroups;
00216 
00217     TELEPATHY_QT4_NO_EXPORT void receiveAlias(const QString &alias);
00218     TELEPATHY_QT4_NO_EXPORT void receiveAvatarToken(const QString &avatarToken);
00219     TELEPATHY_QT4_NO_EXPORT void setAvatarToken(const QString &token);
00220     TELEPATHY_QT4_NO_EXPORT void receiveAvatarData(const AvatarData &);
00221     TELEPATHY_QT4_NO_EXPORT void receiveSimplePresence(const SimplePresence &presence);
00222     TELEPATHY_QT4_NO_EXPORT void receiveCapabilities(const RequestableChannelClassList &caps);
00223     TELEPATHY_QT4_NO_EXPORT void receiveLocation(const QVariantMap &location);
00224     TELEPATHY_QT4_NO_EXPORT void receiveInfo(const ContactInfoFieldList &info);
00225 
00226     TELEPATHY_QT4_NO_EXPORT static PresenceState subscriptionStateToPresenceState(uint subscriptionState);
00227     TELEPATHY_QT4_NO_EXPORT void setSubscriptionState(SubscriptionState state);
00228     TELEPATHY_QT4_NO_EXPORT void setPublishState(SubscriptionState state, const QString &message = QString());
00229     TELEPATHY_QT4_NO_EXPORT void setBlocked(bool value);
00230 
00231     TELEPATHY_QT4_NO_EXPORT void setAddedToGroup(const QString &group);
00232     TELEPATHY_QT4_NO_EXPORT void setRemovedFromGroup(const QString &group);
00233 
00234     struct Private;
00235     friend class Connection;
00236     friend class ContactFactory;
00237     friend class ContactManager;
00238     friend struct Private;
00239     Private *mPriv;
00240 };
00241 
00242 } // Tp
00243 
00244 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
00245 
00246 #endif


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.8.0