Home · All Classes · All Namespaces · Modules · Functions · Files
presence.h
00001 
00023 #ifndef _TelepathyQt_presence_h_HEADER_GUARD_
00024 #define _TelepathyQt_presence_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TP_QT_HEADER
00027 #error IN_TP_QT_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt/Constants>
00031 #include <TelepathyQt/Types>
00032 
00033 namespace Tp
00034 {
00035 
00036 class TP_QT_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     bool operator==(const Presence &other) const;
00057     bool operator!=(const Presence &other) const;
00058 
00059     ConnectionPresenceType type() const;
00060     QString status() const;
00061     QString statusMessage() const;
00062     void setStatus(const SimplePresence &value);
00063     void setStatus(ConnectionPresenceType type, const QString &status,
00064             const QString &statusMessage);
00065     void setStatusMessage(const QString &statusMessage);
00066 
00067     SimplePresence barePresence() const;
00068 
00069 private:
00070     struct Private;
00071     friend struct Private;
00072     QSharedDataPointer<Private> mPriv;
00073 };
00074 
00075 class TP_QT_EXPORT PresenceSpec
00076 {
00077 public:
00078     PresenceSpec();
00079     PresenceSpec(const QString &status, const SimpleStatusSpec &spec);
00080     PresenceSpec(const PresenceSpec &other);
00081     ~PresenceSpec();
00082 
00083     bool isValid() const { return mPriv.constData() != 0; }
00084 
00085     PresenceSpec &operator=(const PresenceSpec &other);
00086     bool operator==(const PresenceSpec &other) const;
00087     bool operator!=(const PresenceSpec &other) const;
00088     bool operator<(const PresenceSpec &other) const;
00089 
00090     Presence presence(const QString &statusMessage = QString()) const;
00091     bool maySetOnSelf() const;
00092     bool canHaveStatusMessage() const;
00093 
00094     SimpleStatusSpec bareSpec() const;
00095 
00096 private:
00097     struct Private;
00098     friend struct Private;
00099     QSharedDataPointer<Private> mPriv;
00100 };
00101 
00102 class TP_QT_EXPORT PresenceSpecList : public QList<PresenceSpec>
00103 {
00104 public:
00105     PresenceSpecList() { }
00106     PresenceSpecList(const SimpleStatusSpecMap &specMap)
00107     {
00108         SimpleStatusSpecMap::const_iterator i = specMap.constBegin();
00109         SimpleStatusSpecMap::const_iterator end = specMap.end();
00110         for (; i != end; ++i) {
00111             QString status = i.key();
00112             SimpleStatusSpec spec = i.value();
00113             append(PresenceSpec(status, spec));
00114         }
00115     }
00116     PresenceSpecList(const QList<PresenceSpec> &other)
00117         : QList<PresenceSpec>(other)
00118     {
00119     }
00120 
00121     QMap<QString, PresenceSpec> toMap() const
00122     {
00123         QMap<QString, PresenceSpec> ret;
00124         Q_FOREACH (const PresenceSpec &spec, *this) {
00125             ret.insert(spec.presence().status(), spec);
00126         }
00127         return ret;
00128     }
00129 };
00130 
00131 } // Tp
00132 
00133 Q_DECLARE_METATYPE(Tp::Presence);
00134 Q_DECLARE_METATYPE(Tp::PresenceSpec);
00135 
00136 #endif


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.1