summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Presence')
-rw-r--r--Swiften/Presence/PresenceOracle.cpp26
-rw-r--r--Swiften/Presence/PresenceOracle.h4
2 files changed, 29 insertions, 1 deletions
diff --git a/Swiften/Presence/PresenceOracle.cpp b/Swiften/Presence/PresenceOracle.cpp
index d7239df..988fc10 100644
--- a/Swiften/Presence/PresenceOracle.cpp
+++ b/Swiften/Presence/PresenceOracle.cpp
@@ -8,9 +8,33 @@ typedef std::pair<JID, std::map<JID, boost::shared_ptr<Presence> > > JIDMapPair;
typedef std::pair<JID, boost::shared_ptr<Presence> > JIDPresencePair;
PresenceOracle::PresenceOracle(StanzaChannel* stanzaChannel) {
- stanzaChannel->onPresenceReceived.connect(boost::bind(&PresenceOracle::handleIncomingPresence, this, _1));
+ stanzaChannel_ = stanzaChannel;
+ stanzaChannel_->onPresenceReceived.connect(boost::bind(&PresenceOracle::handleIncomingPresence, this, _1));
}
+void PresenceOracle::cancelSubscription(const JID& jid) {
+ boost::shared_ptr<Presence> stanza(new Presence());
+ stanza->setType(Presence::Unsubscribed);
+ stanza->setTo(jid);
+ stanzaChannel_->sendPresence(stanza);
+}
+
+void PresenceOracle::confirmSubscription(const JID& jid) {
+ boost::shared_ptr<Presence> stanza(new Presence());
+ stanza->setType(Presence::Subscribed);
+ stanza->setTo(jid);
+ stanzaChannel_->sendPresence(stanza);
+}
+
+
+void PresenceOracle::requestSubscription(const JID& jid) {
+ boost::shared_ptr<Presence> stanza(new Presence());
+ stanza->setType(Presence::Subscribe);
+ stanza->setTo(jid);
+ stanzaChannel_->sendPresence(stanza);
+}
+
+
void PresenceOracle::handleIncomingPresence(boost::shared_ptr<Presence> presence) {
JID bareJID = JID(presence->getFrom().toBare());
diff --git a/Swiften/Presence/PresenceOracle.h b/Swiften/Presence/PresenceOracle.h
index 320a999..dc6fe5d 100644
--- a/Swiften/Presence/PresenceOracle.h
+++ b/Swiften/Presence/PresenceOracle.h
@@ -14,6 +14,10 @@ class PresenceOracle {
PresenceOracle(StanzaChannel* stanzaChannel);
~PresenceOracle() {};
+ void cancelSubscription(const JID& jid);
+ void confirmSubscription(const JID& jid);
+ void requestSubscription(const JID& jid);
+
boost::signal<void (boost::shared_ptr<Presence>, boost::shared_ptr<Presence>)> onPresenceChange;
boost::signal<void (const JID&, const String&)> onPresenceSubscriptionRequest;