summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-22 20:37:30 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-22 20:37:30 (GMT)
commit0c377fa93ffd8538da9e71ddc71d4e8c07600a22 (patch)
treefa655b09f94cdb9018bfad4aa1de3dba2d345969 /Swiften/Presence
parent1ebd045cadb3585c846ea38c63d508e5aa6ec1e7 (diff)
downloadswift-contrib-0c377fa93ffd8538da9e71ddc71d4e8c07600a22.zip
swift-contrib-0c377fa93ffd8538da9e71ddc71d4e8c07600a22.tar.bz2
Can now accept roster subscriptions.
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;