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 ContactManager;
00041 class PendingOperation;
00042 class ReferencedHandles;
00043 
00044 class TELEPATHY_QT4_EXPORT Contact : public QObject
00045 {
00046     Q_OBJECT
00047     Q_DISABLE_COPY(Contact);
00048 
00049 public:
00050     enum Feature {
00051         FeatureAlias,
00052         FeatureAvatarToken,
00053         FeatureSimplePresence,
00054         FeatureCapabilities,
00055         _Padding = 0xFFFFFFFF
00056     };
00057 
00058     enum PresenceState {
00059          PresenceStateNo,
00060          PresenceStateAsk,
00061          PresenceStateYes
00062     };
00063 
00064     ContactManager *manager() const;
00065 
00066     ReferencedHandles handle() const;
00067     QString id() const;
00068 
00069     QSet<Feature> requestedFeatures() const;
00070     QSet<Feature> actualFeatures() const;
00071 
00072     QString alias() const;
00073 
00074     bool isAvatarTokenKnown() const;
00075     QString avatarToken() const;
00076 
00077     QString presenceStatus() const;
00078     uint presenceType() const;
00079     QString presenceMessage() const;
00080 
00081     ContactCapabilities *capabilities() const;
00082 
00083     PresenceState subscriptionState() const;
00084     PresenceState publishState() const;
00085 
00086     PendingOperation *requestPresenceSubscription(const QString &message = QString());
00087     PendingOperation *removePresenceSubscription(const QString &message = QString());
00088     PendingOperation *authorizePresencePublication(const QString &message = QString());
00089     PendingOperation *removePresencePublication(const QString &message = QString());
00090 
00091     bool isBlocked() const;
00092     PendingOperation *block(bool value = true);
00093 
00094     QStringList groups() const;
00095     PendingOperation *addToGroup(const QString &group);
00096     PendingOperation *removeFromGroup(const QString &group);
00097 
00098     ~Contact();
00099 
00100 Q_SIGNALS:
00101     void aliasChanged(const QString &alias);
00102     void avatarTokenChanged(const QString &avatarToken);
00103     void simplePresenceChanged(const QString &status, uint type, const QString &presenceMessage);
00104     void capabilitiesChanged(Tp::ContactCapabilities *caps);
00105 
00106     void subscriptionStateChanged(Tp::Contact::PresenceState state);
00107     void publishStateChanged(Tp::Contact::PresenceState state);
00108     void blockStatusChanged(bool blocked);
00109 
00110     void addedToGroup(const QString &group);
00111     void removedFromGroup(const QString &group);
00112 
00113     // TODO: consider how the Renaming interface should work and map to Contacts
00114     // I guess it would be something like:
00115     // void renamedTo(Tp::ContactPtr)
00116     // with that contact getting the same features requested as the current one. Or would we rather
00117     // want to signal that change right away with a handle?
00118 
00119 private:
00120     Contact(ContactManager *manager, const ReferencedHandles &handle,
00121             const QSet<Feature> &requestedFeatures, const QVariantMap &attributes);
00122 
00123     void augment(const QSet<Feature> &requestedFeatures, const QVariantMap &attributes);
00124 
00125     void receiveAlias(const QString &alias);
00126     void receiveAvatarToken(const QString &avatarToken);
00127     void receiveSimplePresence(const SimplePresence &presence);
00128     void receiveCapabilities(const RequestableChannelClassList &caps);
00129 
00130     void setSubscriptionState(PresenceState state);
00131     void setPublishState(PresenceState state);
00132     void setBlocked(bool value);
00133 
00134     void setAddedToGroup(const QString &group);
00135     void setRemovedFromGroup(const QString &group);
00136 
00137     struct Private;
00138     friend class ContactManager;
00139     friend struct Private;
00140     Private *mPriv;
00141 };
00142 
00143 typedef QSet<ContactPtr> Contacts;
00144 
00145 inline uint qHash(const ContactPtr &contact)
00146 {
00147     return qHash(contact.data());
00148 }
00149 
00150 } // Tp
00151 
00152 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.2.1