summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-10-27 16:20:09 (GMT)
committerTobias Markmann <tm@ayena.de>2015-10-30 12:34:52 (GMT)
commit0f5ef716a50c8d9761cafda12aacf818cdfd6353 (patch)
tree4ed80dedc2fa8b04036eb7567282094ea8fe07f1 /Swiften/Presence/PresenceOracle.h
parent4320235bef1b601856b295a8d6411d1898048802 (diff)
downloadswift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.zip
swift-0f5ef716a50c8d9761cafda12aacf818cdfd6353.tar.bz2
Change bare JID presence lookup code to ignore priorities
Before presence handling code was handled by both, the ContactRosterItem in Swift and the PresenceOracle in Swiften. The ContactRosterItem also considered the presence priority for deciding what presence to show for a bare JID. With this code all full or bare JID presence requests are finally handled by the PresenceOracle. For bare JIDs it is looked up to a presence of one of the available resources of that JID regardless of the priorities. Test-Information: Adjusted tests according to above description and documentation in PresenceOracle. Change-Id: I972a4574f476cdf4d4b5593a035eb1c25ef2f8ba
Diffstat (limited to 'Swiften/Presence/PresenceOracle.h')
-rw-r--r--Swiften/Presence/PresenceOracle.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/Swiften/Presence/PresenceOracle.h b/Swiften/Presence/PresenceOracle.h
index f312506..a010e8e 100644
--- a/Swiften/Presence/PresenceOracle.h
+++ b/Swiften/Presence/PresenceOracle.h
@@ -17,6 +17,11 @@ namespace Swift {
class StanzaChannel;
class XMPPRoster;
+ /**
+ * The PresenceOracle class observes all received presence stanzas for
+ * the \ref StanzaChannel class passed in the constructor and maintains a
+ * cache.
+ */
class SWIFTEN_API PresenceOracle {
public:
PresenceOracle(StanzaChannel* stanzaChannel, XMPPRoster* roster);
@@ -26,6 +31,34 @@ namespace Swift {
Presence::ref getHighestPriorityPresence(const JID& bareJID) const;
std::vector<Presence::ref> getAllPresence(const JID& bareJID) const;
+ /**
+ * \brief Returns the relevant presence for a list of resource presences.
+ *
+ * It only takes the presence show type into account. Priorities are
+ * ignored as various clients set them to arbitrary values unrelated
+ * to actual end point availability.
+ *
+ * The presences of the resources are group by availablilty and sorted
+ * by show type in the following order:
+ *
+ * -# Online
+ * -# Free for Chat
+ * -# Available
+ * -# Away
+ * -# DND
+ * -# Extended Away
+ * -# Away
+ * -# Offline
+ * -# Unavailable
+ */
+ static Presence::ref getActivePresence(const std::vector<Presence::ref> presences);
+
+ /**
+ * \brief This considers all online resources of a bare JID and returns
+ * the value returned by \ref getActivePresence when passing this list.
+ */
+ Presence::ref getAccountPresence(const JID& jid) const;
+
public:
boost::signal<void (Presence::ref)> onPresenceChange;