MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9
   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     // FIXME: split block in block()/unblock() and deprecate this method
00155     PendingOperation *block(bool value = true);
00156 
00157     /*
00158      * Filter on the groups they're in - to show a specific group only
00159      *
00160      * Also prefix/substring match on ANY of the groups of the contact
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     // deprecated
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     // deprecated
00187     void publishStateChanged(Tp::Contact::PresenceState state,
00188             const Tp::Channel::GroupMemberChangeDetails &details);
00189 
00190     void blockStatusChanged(bool blocked);
00191     // deprecated
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     // TODO: consider how the Renaming interface should work and map to Contacts
00198     // I guess it would be something like:
00199     // void renamedTo(Tp::ContactPtr)
00200     // with that contact getting the same features requested as the current one. Or would we rather
00201     // want to signal that change right away with a handle?
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     // FIXME: (API/ABI break) Remove connectNotify
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 } // Tp
00241 
00242 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
00243 
00244 #endif

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