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


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