| 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
    00066     SimplePresence barePresence() const;
    00067
    00068 private:
    00069     struct Private;
    00070     friend struct Private;
    00071     QSharedDataPointer<Private> mPriv;
    00072 };
    00073
    00074 class TP_QT_EXPORT PresenceSpec
    00075 {
    00076 public:
    00077     PresenceSpec();
    00078     PresenceSpec(const QString &status, const SimpleStatusSpec &spec);
    00079     PresenceSpec(const PresenceSpec &other);
    00080     ~PresenceSpec();
    00081
    00082     bool isValid() const { return mPriv.constData() != 0; }
    00083
    00084     PresenceSpec &operator=(const PresenceSpec &other);
    00085     bool operator==(const PresenceSpec &other) const;
    00086     bool operator!=(const PresenceSpec &other) const;
    00087     bool operator<(const PresenceSpec &other) const;
    00088
    00089     Presence presence(const QString &statusMessage = QString()) const;
    00090     bool maySetOnSelf() const;
    00091     bool canHaveStatusMessage() const;
    00092
    00093     SimpleStatusSpec bareSpec() const;
    00094
    00095 private:
    00096     struct Private;
    00097     friend struct Private;
    00098     QSharedDataPointer<Private> mPriv;
    00099 };
    00100
    00101 class TP_QT_EXPORT PresenceSpecList : public QList<PresenceSpec>
    00102 {
    00103 public:
    00104     PresenceSpecList() { }
    00105     PresenceSpecList(const SimpleStatusSpecMap &specMap)
    00106     {
    00107         SimpleStatusSpecMap::const_iterator i = specMap.constBegin();
    00108         SimpleStatusSpecMap::const_iterator end = specMap.end();
    00109         for (; i != end; ++i) {
    00110             QString status = i.key();
    00111             SimpleStatusSpec spec = i.value();
    00112             append(PresenceSpec(status, spec));
    00113         }
    00114     }
    00115     PresenceSpecList(const QList<PresenceSpec> &other)
    00116         : QList<PresenceSpec>(other)
    00117     {
    00118     }
    00119
    00120     QMap<QString, PresenceSpec> toMap() const
    00121     {
    00122         QMap<QString, PresenceSpec> ret;
    00123         Q_FOREACH (const PresenceSpec &spec, *this) {
    00124             ret.insert(spec.presence().status(), spec);
    00125         }
    00126         return ret;
    00127     }
    00128 };
    00129
    00130 } // Tp
    00131
    00132 Q_DECLARE_METATYPE(Tp::Presence);
    00133 Q_DECLARE_METATYPE(Tp::PresenceSpec);
    00134
    00135 #endif