Home · All Classes · All Namespaces · Modules · Functions · Files
presence.h
00001 
00023 #ifndef _TelepathyQt4_presence_h_HEADER_GUARD_
00024 #define _TelepathyQt4_presence_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt4/Constants>
00031 #include <TelepathyQt4/Types>
00032 
00033 namespace Tp
00034 {
00035 
00036 class TELEPATHY_QT4_EXPORT Presence
00037 {
00038 public:
00039     Presence();
00040     Presence(const SimplePresence &sp);
00041     Presence(ConnectionPresenceType type, const QString &status, const QString &statusMessage);
00042     Presence(const Presence &other);
00043     ~Presence();
00044 
00045     static Presence available(const QString &statusMessage = QString());
00046     static Presence away(const QString &statusMessage = QString());
00047     static Presence brb(const QString &statusMessage = QString());
00048     static Presence busy(const QString &statusMessage = QString());
00049     static Presence xa(const QString &statusMessage = QString());
00050     static Presence hidden(const QString &statusMessage = QString());
00051     static Presence offline(const QString &statusMessage = QString());
00052 
00053     bool isValid() const { return mPriv.constData() != 0; }
00054 
00055     Presence &operator=(const Presence &other);
00056 
00057     ConnectionPresenceType type() const;
00058     QString status() const;
00059     QString statusMessage() const;
00060     void setStatus(const SimplePresence &value);
00061     void setStatus(ConnectionPresenceType type, const QString &status,
00062             const QString &statusMessage);
00063 
00064     SimplePresence barePresence() const;
00065 
00066 private:
00067     struct Private;
00068     friend struct Private;
00069     QSharedDataPointer<Private> mPriv;
00070 };
00071 
00072 class TELEPATHY_QT4_EXPORT PresenceSpec
00073 {
00074 public:
00075     PresenceSpec();
00076     PresenceSpec(const QString &status, const SimpleStatusSpec &spec);
00077     PresenceSpec(const PresenceSpec &other);
00078     ~PresenceSpec();
00079 
00080     bool isValid() const { return mPriv.constData() != 0; }
00081 
00082     PresenceSpec &operator=(const PresenceSpec &other);
00083 
00084     Presence presence(const QString &statusMessage = QString()) const;
00085     bool maySetOnSelf() const;
00086     bool canHaveStatusMessage() const;
00087 
00088     SimpleStatusSpec bareSpec() const;
00089 
00090 private:
00091     struct Private;
00092     friend struct Private;
00093     QSharedDataPointer<Private> mPriv;
00094 };
00095 
00096 class TELEPATHY_QT4_EXPORT PresenceSpecList : public QList<PresenceSpec>
00097 {
00098 public:
00099     PresenceSpecList() { }
00100     PresenceSpecList(const SimpleStatusSpecMap &specMap)
00101     {
00102         SimpleStatusSpecMap::const_iterator i = specMap.constBegin();
00103         SimpleStatusSpecMap::const_iterator end = specMap.end();
00104         for (; i != end; ++i) {
00105             QString status = i.key();
00106             SimpleStatusSpec spec = i.value();
00107             append(PresenceSpec(status, spec));
00108         }
00109     }
00110     PresenceSpecList(const QList<PresenceSpec> &other)
00111         : QList<PresenceSpec>(other)
00112     {
00113     }
00114 
00115     QMap<QString, PresenceSpec> toMap() const
00116     {
00117         QMap<QString, PresenceSpec> ret;
00118         Q_FOREACH (const PresenceSpec &spec, *this) {
00119             ret.insert(spec.presence().status(), spec);
00120         }
00121         return ret;
00122     }
00123 };
00124 
00125 } // Tp
00126 
00127 Q_DECLARE_METATYPE(Tp::Presence);
00128 Q_DECLARE_METATYPE(Tp::PresenceSpec);
00129 
00130 #endif


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