diff --git a/include/transport/user.h b/include/transport/user.h index d164852f..f7752f07 100644 --- a/include/transport/user.h +++ b/include/transport/user.h @@ -57,7 +57,7 @@ class User : public Swift::EntityCapsProvider { /// Returns full JID which supports particular feature or invalid JID. /// \param feature disco#info feature. /// \return full JID which supports particular feature or invalid JID. - Swift::JID getJIDWithFeature(const std::string &feature); + std::vector getJIDWithFeature(const std::string &feature); Swift::DiscoInfo::ref getCaps(const Swift::JID &jid) const; diff --git a/src/rostermanager.cpp b/src/rostermanager.cpp index 34a2d690..ebb7c456 100644 --- a/src/rostermanager.cpp +++ b/src/rostermanager.cpp @@ -232,8 +232,8 @@ void RosterManager::setBuddyCallback(Buddy *buddy) { } else { // Send RIE only if there's resource which supports it. - Swift::JID jidWithRIE = m_user->getJIDWithFeature("http://jabber.org/protocol/rosterx"); - if (jidWithRIE.isValid()) { + std::vector jidWithRIE = m_user->getJIDWithFeature("http://jabber.org/protocol/rosterx"); + if (!jidWithRIE.empty()) { m_RIETimer->start(); } else { @@ -317,10 +317,10 @@ void RosterManager::sendRIE() { m_RIETimer->stop(); // Check the feature, because proper resource could logout during RIETimer. - Swift::JID jidWithRIE = m_user->getJIDWithFeature("http://jabber.org/protocol/rosterx"); + std::vector jidWithRIE = m_user->getJIDWithFeature("http://jabber.org/protocol/rosterx"); // fallback to normal subscribe - if (!jidWithRIE.isValid()) { + if (jidWithRIE.empty()) { for (std::map, boost::pool_allocator< std::pair > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) { Buddy *buddy = (*it).second; if (!buddy) { @@ -331,8 +331,6 @@ void RosterManager::sendRIE() { return; } - LOG4CXX_INFO(logger, "Sending RIE stanza to " << jidWithRIE.toString()); - Swift::RosterItemExchangePayload::ref payload = Swift::RosterItemExchangePayload::ref(new Swift::RosterItemExchangePayload()); for (std::map, boost::pool_allocator< std::pair > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) { Buddy *buddy = (*it).second; @@ -348,8 +346,11 @@ void RosterManager::sendRIE() { payload->addItem(item); } - boost::shared_ptr > request(new Swift::GenericRequest(Swift::IQ::Set, jidWithRIE, payload, m_component->getIQRouter())); - request->send(); + BOOST_FOREACH(Swift::JID &jid, jidWithRIE) { + LOG4CXX_INFO(logger, "Sending RIE stanza to " << jid.toString()); + boost::shared_ptr > request(new Swift::GenericRequest(Swift::IQ::Set, jid, payload, m_component->getIQRouter())); + request->send(); + } } void RosterManager::handleSubscription(Swift::Presence::ref presence) { diff --git a/src/user.cpp b/src/user.cpp index 86f908bd..82a45bdd 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -83,8 +83,8 @@ const Swift::JID &User::getJID() { return m_jid; } -Swift::JID User::getJIDWithFeature(const std::string &feature) { - Swift::JID jid; +std::vector User::getJIDWithFeature(const std::string &feature) { + std::vector jid; std::vector presences = m_presenceOracle->getAllPresence(m_jid); foreach(Swift::Presence::ref presence, presences) { @@ -111,11 +111,13 @@ Swift::JID User::getJIDWithFeature(const std::string &feature) { if (discoInfo->hasFeature(feature)) { LOG4CXX_INFO(logger, m_jid.toString() << ": Found JID with " << feature << " feature: " << presence->getFrom().toString()); - return presence->getFrom(); + jid.push_back(presence->getFrom()); } } - LOG4CXX_INFO(logger, m_jid.toString() << ": No JID with " << feature << " feature " << m_legacyCaps.size()); + if (jid.empty()) { + LOG4CXX_INFO(logger, m_jid.toString() << ": No JID with " << feature << " feature " << m_legacyCaps.size()); + } return jid; }