Home · All Classes · All Namespaces · Modules · Functions · Files

contact.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2008 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_contact_h_HEADER_GUARD_
00023 #define _TelepathyQt4_contact_h_HEADER_GUARD_
00024 
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028 
00029 #include <TelepathyQt4/Channel>
00030 #include <TelepathyQt4/Feature>
00031 #include <TelepathyQt4/Object>
00032 #include <TelepathyQt4/Types>
00033 
00034 #include <QSet>
00035 #include <QVariantMap>
00036 
00037 namespace Tp
00038 {
00039 
00040 struct AvatarData;
00041 class ContactCapabilities;
00042 class LocationInfo;
00043 class ContactManager;
00044 class PendingContactInfo;
00045 class PendingOperation;
00046 class Presence;
00047 class ReferencedHandles;
00048 
00049 class TELEPATHY_QT4_EXPORT Contact : public Object
00050 {
00051     Q_OBJECT
00052     Q_DISABLE_COPY(Contact)
00053 
00054 public:
00055     static const Feature FeatureAlias;
00056     static const Feature FeatureAvatarData;
00057     static const Feature FeatureAvatarToken;
00058     static const Feature FeatureCapabilities;
00059     static const Feature FeatureInfo;
00060     static const Feature FeatureLocation;
00061     static const Feature FeatureSimplePresence;
00062 
00063     enum PresenceState {
00064          PresenceStateNo,
00065          PresenceStateAsk,
00066          PresenceStateYes
00067     };
00068 
00069     class InfoFields
00070     {
00071     public:
00072         InfoFields();
00073         InfoFields(const ContactInfoFieldList &fields);
00074         InfoFields(const InfoFields &other);
00075         ~InfoFields();
00076 
00077         bool isValid() const { return mPriv.constData() != 0; }
00078 
00079         InfoFields &operator=(const InfoFields &other);
00080 
00081         ContactInfoFieldList fields(const QString &name) const;
00082 
00083         ContactInfoFieldList allFields() const;
00084 
00085     private:
00086         struct Private;
00087         friend struct Private;
00088         QSharedDataPointer<Private> mPriv;
00089     };
00090 
00091     ~Contact();
00092 
00093     ContactManagerPtr manager() const;
00094 
00095     ReferencedHandles handle() const;
00096 
00097     // TODO filter: exact, prefix, substring match
00098     QString id() const;
00099 
00100     Features requestedFeatures() const;
00101     Features actualFeatures() const;
00102 
00103     // TODO filter: exact, prefix, substring match
00104     QString alias() const;
00105 
00106     bool isAvatarTokenKnown() const;
00107     QString avatarToken() const;
00108     AvatarData avatarData() const;
00109 
00110     /*
00111      * TODO filter:
00112      *  - exact match of presence().type(), presence().status()
00113      *  - ANY 1 of a number of presence types/statuses
00114      *  - presence().type() greater or less than a set value
00115      *  - have/don't have presence().message() AND exact/prefix/substring
00116      */
00117     Presence presence() const;
00118 
00119     // TODO filter: the same as Account filtering by caps
00120     ContactCapabilities capabilities() const;
00121 
00122     // TODO filter: is it available, how accurate, are they near me
00123     LocationInfo location() const;
00124 
00125     // TODO filter: having a specific field, having ANY field,
00126     // (field: exact, contents: exact/prefix/substring)
00127     InfoFields infoFields() const;
00128     PendingOperation *refreshInfo();
00129     PendingContactInfo *requestInfo();
00130 
00131     /*
00132      * Filters on exact values of these, but also the "in your contact list at all or not" usecase
00133      */
00134     PresenceState subscriptionState() const;
00135     PresenceState publishState() const;
00136 
00137     PendingOperation *requestPresenceSubscription(const QString &message = QString());
00138     PendingOperation *removePresenceSubscription(const QString &message = QString());
00139     PendingOperation *authorizePresencePublication(const QString &message = QString());
00140     PendingOperation *removePresencePublication(const QString &message = QString());
00141 
00142     /*
00143      * Filter on being blocked or not
00144      */
00145     bool isBlocked() const;
00146     PendingOperation *block(bool value = true);
00147 
00148     /*
00149      * Filter on the groups they're in - to show a specific group only
00150      *
00151      * Also prefix/substring match on ANY of the groups of the contact
00152      */
00153     QStringList groups() const;
00154     PendingOperation *addToGroup(const QString &group);
00155     PendingOperation *removeFromGroup(const QString &group);
00156 
00157 Q_SIGNALS:
00158     void aliasChanged(const QString &alias);
00159 
00160     void avatarTokenChanged(const QString &avatarToken);
00161     void avatarDataChanged(const Tp::AvatarData &avatarData);
00162 
00163     void presenceChanged(const Tp::Presence &presence);
00164 
00165     void capabilitiesChanged(const Tp::ContactCapabilities &caps);
00166 
00167     void locationUpdated(const Tp::LocationInfo &location);
00168 
00169     void infoFieldsChanged(const Tp::Contact::InfoFields &infoFields);
00170 
00171     void subscriptionStateChanged(Tp::Contact::PresenceState state,
00172             const Tp::Channel::GroupMemberChangeDetails &details);
00173     void publishStateChanged(Tp::Contact::PresenceState state,
00174             const Tp::Channel::GroupMemberChangeDetails &details);
00175     void blockStatusChanged(bool blocked, const Tp::Channel::GroupMemberChangeDetails &details);
00176 
00177     void addedToGroup(const QString &group);
00178     void removedFromGroup(const QString &group);
00179 
00180     // TODO: consider how the Renaming interface should work and map to Contacts
00181     // I guess it would be something like:
00182     // void renamedTo(Tp::ContactPtr)
00183     // with that contact getting the same features requested as the current one. Or would we rather
00184     // want to signal that change right away with a handle?
00185 
00186 private:
00187     Contact(ContactManager *manager, const ReferencedHandles &handle,
00188             const Features &requestedFeatures, const QVariantMap &attributes);
00189 
00190     void augment(const Features &requestedFeatures, const QVariantMap &attributes);
00191 
00192     void receiveAlias(const QString &alias);
00193     void receiveAvatarToken(const QString &avatarToken);
00194     void setAvatarToken(const QString &token);
00195     void receiveAvatarData(const AvatarData &);
00196     void receiveSimplePresence(const SimplePresence &presence);
00197     void receiveCapabilities(const RequestableChannelClassList &caps);
00198     void receiveLocation(const QVariantMap &location);
00199     void receiveInfo(const ContactInfoFieldList &info);
00200 
00201     void setSubscriptionState(PresenceState state, const Channel::GroupMemberChangeDetails &details =
00202             Channel::GroupMemberChangeDetails());
00203     void setPublishState(PresenceState state, const Channel::GroupMemberChangeDetails &details =
00204             Channel::GroupMemberChangeDetails());
00205     void setBlocked(bool value, const Channel::GroupMemberChangeDetails &details =
00206             Channel::GroupMemberChangeDetails());
00207 
00208     void setAddedToGroup(const QString &group);
00209     void setRemovedFromGroup(const QString &group);
00210 
00211     struct Private;
00212     friend class ContactManager;
00213     friend struct Private;
00214     Private *mPriv;
00215 };
00216 
00217 } // Tp
00218 
00219 Q_DECLARE_METATYPE(Tp::Contact::InfoFields);
00220 
00221 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.5.1