Working subscriptions with swiften_raw backend

This commit is contained in:
HanzZ 2013-02-22 13:13:05 +01:00
parent 5c60ead75c
commit ba9a34731c

View file

@ -296,6 +296,8 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
client->getPresenceOracle()->onPresenceChange.connect(boost::bind(&SwiftenPlugin::handleSwiftPresenceChanged, this, user, _1));
client->onDataRead.connect(boost::bind(&SwiftenPlugin::handleSwiftenDataRead, this, _1));
client->onDataWritten.connect(boost::bind(&SwiftenPlugin::handleSwiftenDataWritten, this, _1));
client->getSubscriptionManager()->onPresenceSubscriptionRequest.connect(boost::bind(&SwiftenPlugin::handleSubscriptionRequest, this, user, _1, _2, _3));
client->getSubscriptionManager()->onPresenceSubscriptionRevoked.connect(boost::bind(&SwiftenPlugin::handleSubscriptionRevoked, this, user, _1, _2));
Swift::ClientOptions opt;
opt.allowPLAINWithoutTLS = true;
client->connect(opt);
@ -305,6 +307,18 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
m_handlers[user] = handler;
}
void handleSubscriptionRequest(const std::string &user, const Swift::JID& jid, const std::string& message, Swift::Presence::ref presence) {
handleSwiftPresenceChanged(user, presence);
}
void handleSubscriptionRevoked(const std::string &user, const Swift::JID& jid, const std::string& message) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setTo(user);
presence->setFrom(jid);
presence->setType(Swift::Presence::Unsubscribe);
handleSwiftPresenceChanged(user, presence);
}
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
boost::shared_ptr<Swift::Client> client = m_users[user];
if (client) {