summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/Client.cpp15
-rw-r--r--Swiften/Client/Client.h27
2 files changed, 42 insertions, 0 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index e3e8a45..20a0c47 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -9,6 +9,7 @@
#include "Swiften/Queries/Responders/SoftwareVersionResponder.h"
#include "Swiften/Roster/XMPPRoster.h"
#include "Swiften/Roster/XMPPRosterController.h"
+#include "Swiften/Presence/PresenceOracle.h"
namespace Swift {
@@ -18,9 +19,15 @@ Client::Client(const JID& jid, const String& password) : CoreClient(jid, passwor
roster = new XMPPRoster();
rosterController = new XMPPRosterController(getIQRouter(), roster);
+
+ presenceOracle = new PresenceOracle(getStanzaChannel());
+ presenceOracle->onPresenceChange.connect(boost::ref(onPresenceChange));
+ presenceOracle->onPresenceSubscriptionRequest.connect(boost::ref(onPresenceSubscriptionRequest));
}
Client::~Client() {
+ delete presenceOracle;
+
delete rosterController;
delete roster;
@@ -37,4 +44,12 @@ void Client::requestRoster() {
}
+Presence::ref Client::getLastPresence(const JID& jid) const {
+ return presenceOracle->getLastPresence(jid);
+}
+
+Presence::ref Client::getHighestPriorityPresence(const JID& bareJID) const {
+ return presenceOracle->getHighestPriorityPresence(bareJID);
+}
+
}
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 9f3e935..bf19f2f 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -12,6 +12,7 @@ namespace Swift {
class SoftwareVersionResponder;
class XMPPRoster;
class XMPPRosterController;
+ class PresenceOracle;
/**
* Provides the core functionality for writing XMPP client software.
@@ -56,9 +57,35 @@ namespace Swift {
*/
void requestRoster();
+ /**
+ * Returns the last received presence for the given (full) JID.
+ */
+ Presence::ref getLastPresence(const JID& jid) const;
+
+ /**
+ * Returns the presence with the highest priority received for the given JID.
+ */
+ Presence::ref getHighestPriorityPresence(const JID& bareJID) const;
+
+ PresenceOracle* getPresenceOracle() const {
+ return presenceOracle;
+ }
+
+ public:
+ /**
+ * This signal is emitted when a JID changes presence.
+ */
+ boost::signal<void (boost::shared_ptr<Presence>)> onPresenceChange;
+
+ /**
+ * This signal is emitted when a presence subscription request is received.
+ */
+ boost::signal<void (const JID&, const String&)> onPresenceSubscriptionRequest;
+
private:
SoftwareVersionResponder* softwareVersionResponder;
XMPPRoster* roster;
XMPPRosterController* rosterController;
+ PresenceOracle* presenceOracle;
};
}