| Home · All Classes · All Namespaces · Modules · Functions · Files

presence.h
1
23 #ifndef _TelepathyQt_presence_h_HEADER_GUARD_
24 #define _TelepathyQt_presence_h_HEADER_GUARD_
25
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29
30 #include <TelepathyQt/Constants>
31 #include <TelepathyQt/Types>
32
33 namespace Tp
34 {
35
36 class TP_QT_EXPORT Presence
37 {
38 public:
39 Presence();
40 Presence(const SimplePresence &sp);
41 Presence(ConnectionPresenceType type, const QString &status, const QString &statusMessage);
42 Presence(const Presence &other);
43 ~Presence();
44
45 static Presence available(const QString &statusMessage = QString());
46 static Presence chat(const QString &statusMessage = QString());
47 static Presence away(const QString &statusMessage = QString());
48 static Presence brb(const QString &statusMessage = QString());
49 static Presence busy(const QString &statusMessage = QString());
50 static Presence dnd(const QString &statusMessage = QString());
51 static Presence xa(const QString &statusMessage = QString());
52 static Presence hidden(const QString &statusMessage = QString());
53 static Presence offline(const QString &statusMessage = QString());
54
55 bool isValid() const { return mPriv.constData() != 0; }
56
57 Presence &operator=(const Presence &other);
58 bool operator==(const Presence &other) const;
59 bool operator!=(const Presence &other) const;
60
61 ConnectionPresenceType type() const;
62 QString status() const;
63 QString statusMessage() const;
64 void setStatus(const SimplePresence &value);
65 void setStatus(ConnectionPresenceType type, const QString &status,
66 const QString &statusMessage);
67 void setStatusMessage(const QString &statusMessage);
68
69 SimplePresence barePresence() const;
70
71 private:
72 struct Private;
73 friend struct Private;
74 QSharedDataPointer<Private> mPriv;
75 };
76
77 class TP_QT_EXPORT PresenceSpec
78 {
79 public:
80 enum SimpleStatusFlag {
81 NoFlags = 0,
82 MaySetOnSelf = 0x1,
83 CanHaveStatusMessage = 0x2,
84 AllFlags = MaySetOnSelf | CanHaveStatusMessage
85 };
86 Q_DECLARE_FLAGS(SimpleStatusFlags, SimpleStatusFlag);
87
88 PresenceSpec();
89 PresenceSpec(const QString &status, const SimpleStatusSpec &spec);
90 PresenceSpec(const PresenceSpec &other);
91 ~PresenceSpec();
92
93 static PresenceSpec available(SimpleStatusFlags flags = AllFlags);
94 static PresenceSpec chat(SimpleStatusFlags flags = AllFlags);
95 static PresenceSpec pstn(SimpleStatusFlags flags = CanHaveStatusMessage);
96 static PresenceSpec away(SimpleStatusFlags flags = AllFlags);
97 static PresenceSpec brb(SimpleStatusFlags flags = AllFlags);
98 static PresenceSpec dnd(SimpleStatusFlags flags = AllFlags);
99 static PresenceSpec busy(SimpleStatusFlags flags = AllFlags);
100 static PresenceSpec xa(SimpleStatusFlags flags = AllFlags);
101 static PresenceSpec hidden(SimpleStatusFlags flags = AllFlags);
102 static PresenceSpec offline(SimpleStatusFlags flags = CanHaveStatusMessage);
103 static PresenceSpec unknown(SimpleStatusFlags flags = CanHaveStatusMessage);
104 static PresenceSpec error(SimpleStatusFlags flags = CanHaveStatusMessage);
105
106 bool isValid() const { return mPriv.constData() != 0; }
107
108 PresenceSpec &operator=(const PresenceSpec &other);
109 bool operator==(const PresenceSpec &other) const;
110 bool operator!=(const PresenceSpec &other) const;
111 bool operator<(const PresenceSpec &other) const;
112
113 Presence presence(const QString &statusMessage = QString()) const;
114 bool maySetOnSelf() const;
115 bool canHaveStatusMessage() const;
116
117 SimpleStatusSpec bareSpec() const;
118
119 private:
120 struct Private;
121 friend struct Private;
122 QSharedDataPointer<Private> mPriv;
123 };
124
125 class TP_QT_EXPORT PresenceSpecList : public QList<PresenceSpec>
126 {
127 public:
128 PresenceSpecList() { }
129 PresenceSpecList(const SimpleStatusSpecMap &specMap)
130 {
131 SimpleStatusSpecMap::const_iterator i = specMap.constBegin();
132 SimpleStatusSpecMap::const_iterator end = specMap.end();
133 for (; i != end; ++i) {
134 QString status = i.key();
135 SimpleStatusSpec spec = i.value();
136 append(PresenceSpec(status, spec));
137 }
138 }
139 PresenceSpecList(const QList<PresenceSpec> &other)
140 : QList<PresenceSpec>(other)
141 {
142 }
143
144 QMap<QString, PresenceSpec> toMap() const
145 {
146 QMap<QString, PresenceSpec> ret;
147 Q_FOREACH (const PresenceSpec &spec, *this) {
148 ret.insert(spec.presence().status(), spec);
149 }
150 return ret;
151 }
152
153 SimpleStatusSpecMap bareSpecs() const
154 {
155 SimpleStatusSpecMap ret;
156 Q_FOREACH (const PresenceSpec &spec, *this) {
157 ret.insert(spec.presence().status(), spec.bareSpec());
158 }
159 return ret;
160 }
161 };
162
163 Q_DECLARE_OPERATORS_FOR_FLAGS(PresenceSpec::SimpleStatusFlags)
164
165 } // Tp
166
167 Q_DECLARE_METATYPE(Tp::Presence);
168 Q_DECLARE_METATYPE(Tp::PresenceSpec);
169 Q_DECLARE_METATYPE(Tp::PresenceSpecList);
170
171 #endif
Tp::SimpleStatusSpec
Definition: obj-x86_64-linux-gnu/TelepathyQt/_gen/types.h:2787
Tp::Presence::status
QString status() const
Definition: presence.cpp:162
Tp
Definition: abstract-adaptor.cpp:31
Tp::PresenceSpec::SimpleStatusFlag
SimpleStatusFlag
Definition: presence.h:80
Tp::operator!=
bool operator!=(const AccessControl &v1, const AccessControl &v2)
Definition: obj-x86_64-linux-gnu/TelepathyQt/_gen/types.h:144
QMap::constBegin
const_iterator constBegin() const
QMap
Tp::PresenceSpecList::PresenceSpecList
PresenceSpecList(const SimpleStatusSpecMap &specMap)
Definition: presence.h:129
Tp::PresenceSpecList::toMap
QMap< QString, PresenceSpec > toMap() const
Definition: presence.h:144
Tp::PresenceSpecList::PresenceSpecList
PresenceSpecList(const QList< PresenceSpec > &other)
Definition: presence.h:139
Tp::ConnectionPresenceType
ConnectionPresenceType
Definition: obj-x86_64-linux-gnu/TelepathyQt/_gen/constants.h:2026
Tp::SimplePresence
Definition: obj-x86_64-linux-gnu/TelepathyQt/_gen/types.h:2733
Tp::Presence::isValid
bool isValid() const
Definition: presence.h:55
Tp::PresenceSpecList::bareSpecs
SimpleStatusSpecMap bareSpecs() const
Definition: presence.h:153
QString
QList
QMap::end
iterator end()
Tp::PresenceSpecList
The PresenceSpecList class represents a list of PresenceSpec.
Definition: presence.h:125
Tp::operator==
bool operator==(const SUSocketAddress &v1, const SUSocketAddress &v2)
Definition: types.cpp:50
Tp::PresenceSpec::isValid
bool isValid() const
Definition: presence.h:106
Tp::SimpleStatusSpecMap
Definition: obj-x86_64-linux-gnu/TelepathyQt/_gen/types.h:3849
Tp::PresenceSpec::presence
Presence presence(const QString &statusMessage=QString()) const
Definition: presence.cpp:419
QMap::insert
iterator insert(const Key &key, const T &value)
Tp::PresenceSpec
The PresenceSpec class represents a Telepathy presence information supported by a protocol...
Definition: presence.h:77
Tp::Presence
The Presence class represents a Telepathy simple presence.
Definition: presence.h:36
QSharedDataPointer< Private >
Tp::PresenceSpecList::PresenceSpecList
PresenceSpecList()
Definition: presence.h:128
Tp::PresenceSpec::bareSpec
SimpleStatusSpec bareSpec() const
Definition: presence.cpp:451