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

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