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 <QObject>
00030 #include <QSet>
00031 #include <QSharedPointer>
00032 #include <QVariantMap>
00033 
00034 #include <TelepathyQt4/Types>
00035 
00036 namespace Tp
00037 {
00038 
00039 class ContactCapabilities;
00040 class ContactLocation;
00041 class ContactManager;
00042 class PendingContactInfo;
00043 class PendingOperation;
00044 class ReferencedHandles;
00045 
00046 class TELEPATHY_QT4_EXPORT Contact : public QObject
00047 {
00048     Q_OBJECT
00049     Q_DISABLE_COPY(Contact);
00050 
00051 public:
00052     enum Feature {
00053         FeatureAlias,
00054         FeatureAvatarToken,
00055         FeatureSimplePresence,
00056         FeatureCapabilities,
00057         FeatureLocation,
00058         FeatureInfo,
00059         FeatureAvatarData,
00060         _Padding = 0xFFFFFFFF
00061     };
00062 
00063     enum PresenceState {
00064          PresenceStateNo,
00065          PresenceStateAsk,
00066          PresenceStateYes
00067     };
00068 
00069     ContactManager *manager() const;
00070 
00071     ReferencedHandles handle() const;
00072     QString id() const; // TODO filter: exact, prefix, substring match
00073 
00074     QSet<Feature> requestedFeatures() const;
00075     QSet<Feature> actualFeatures() const;
00076 
00077     QString alias() const; // TODO filter: exact, prefix, substring match
00078 
00079     bool isAvatarTokenKnown() const;
00080     QString avatarToken() const;
00081     AvatarData avatarData() const;
00082 
00083     /*
00084      * TODO filter:
00085      *  - exact match of presenceType, presenceStatus
00086      *  - ANY 1 of a number of presenceTypes/Statuses
00087      *  - presenceType greater or less than a set value
00088      */
00089     QString presenceStatus() const;
00090     uint presenceType() const;
00091 
00092     // TODO filter: have/don't have message AND exact/prefix/substring
00093     QString presenceMessage() const; 
00094 
00095     // TODO filter: the same as Account filtering by caps
00096     ContactCapabilities *capabilities() const;
00097 
00098     // TODO filter: is it available, how accurate, are they near me
00099     ContactLocation *location() const;
00100 
00101     // TODO filter: having a specific field, having ANY field,
00102     // (field: exact, contents: exact/prefix/substring)
00103     ContactInfoFieldList info() const;
00104     PendingOperation *refreshInfo();
00105     PendingContactInfo *requestInfo();
00106 
00107     /*
00108      * Filters on exact values of these, but also the "in your contact list at all or not" usecase
00109      */
00110     PresenceState subscriptionState() const;
00111     PresenceState publishState() const;
00112 
00113     PendingOperation *requestPresenceSubscription(const QString &message = QString());
00114     PendingOperation *removePresenceSubscription(const QString &message = QString());
00115     PendingOperation *authorizePresencePublication(const QString &message = QString());
00116     PendingOperation *removePresencePublication(const QString &message = QString());
00117 
00118     /*
00119      * Filter on being blocked or not
00120      */
00121     bool isBlocked() const;
00122     PendingOperation *block(bool value = true);
00123 
00124     /*
00125      * Filter on the groups they're in - to show a specific group only
00126      *
00127      * Also prefix/substring match on ANY of the groups of the contact
00128      */
00129     QStringList groups() const;
00130     PendingOperation *addToGroup(const QString &group);
00131     PendingOperation *removeFromGroup(const QString &group);
00132 
00133     ~Contact();
00134 
00135 Q_SIGNALS:
00136     void aliasChanged(const QString &alias);
00137     void avatarTokenChanged(const QString &avatarToken);
00138     void avatarDataChanged(const Tp::AvatarData &);
00139     void simplePresenceChanged(const QString &status, uint type, const QString &presenceMessage);
00140     void capabilitiesChanged(Tp::ContactCapabilities *caps);
00141     void locationUpdated(Tp::ContactLocation *location);
00142     void infoChanged(const Tp::ContactInfoFieldList &info);
00143 
00144     void subscriptionStateChanged(Tp::Contact::PresenceState state);
00145     void publishStateChanged(Tp::Contact::PresenceState state);
00146     void blockStatusChanged(bool blocked);
00147 
00148     void addedToGroup(const QString &group);
00149     void removedFromGroup(const QString &group);
00150 
00151     // TODO: consider how the Renaming interface should work and map to Contacts
00152     // I guess it would be something like:
00153     // void renamedTo(Tp::ContactPtr)
00154     // with that contact getting the same features requested as the current one. Or would we rather
00155     // want to signal that change right away with a handle?
00156 
00157 private:
00158     Contact(ContactManager *manager, const ReferencedHandles &handle,
00159             const QSet<Feature> &requestedFeatures, const QVariantMap &attributes);
00160 
00161     void augment(const QSet<Feature> &requestedFeatures, const QVariantMap &attributes);
00162 
00163     void receiveAlias(const QString &alias);
00164     void receiveAvatarToken(const QString &avatarToken);
00165     void setAvatarToken(const QString &token);
00166     void receiveAvatarData(const AvatarData &);
00167     void receiveSimplePresence(const SimplePresence &presence);
00168     void receiveCapabilities(const RequestableChannelClassList &caps);
00169     void receiveLocation(const QVariantMap &location);
00170     void receiveInfo(const ContactInfoFieldList &info);
00171 
00172     void setSubscriptionState(PresenceState state);
00173     void setPublishState(PresenceState state);
00174     void setBlocked(bool value);
00175 
00176     void setAddedToGroup(const QString &group);
00177     void setRemovedFromGroup(const QString &group);
00178 
00179     struct Private;
00180     friend class ContactManager;
00181     friend struct Private;
00182     Private *mPriv;
00183 };
00184 
00185 typedef QSet<ContactPtr> Contacts;
00186 
00187 inline uint qHash(const ContactPtr &contact)
00188 {
00189     return qHash(contact.data());
00190 }
00191 
00192 } // Tp
00193 
00194 #endif


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