Send RIE to all resources

This commit is contained in:
HanzZ 2012-12-26 09:59:09 +01:00
parent f7dc91ccb4
commit 984a075019
3 changed files with 16 additions and 13 deletions

View file

@ -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<Swift::JID> getJIDWithFeature(const std::string &feature);
Swift::DiscoInfo::ref getCaps(const Swift::JID &jid) const;

View file

@ -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<Swift::JID> 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<Swift::JID> jidWithRIE = m_user->getJIDWithFeature("http://jabber.org/protocol/rosterx");
// fallback to normal subscribe
if (!jidWithRIE.isValid()) {
if (jidWithRIE.empty()) {
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::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<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::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<Swift::GenericRequest<Swift::RosterItemExchangePayload> > request(new Swift::GenericRequest<Swift::RosterItemExchangePayload>(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<Swift::GenericRequest<Swift::RosterItemExchangePayload> > request(new Swift::GenericRequest<Swift::RosterItemExchangePayload>(Swift::IQ::Set, jid, payload, m_component->getIQRouter()));
request->send();
}
}
void RosterManager::handleSubscription(Swift::Presence::ref presence) {

View file

@ -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<Swift::JID> User::getJIDWithFeature(const std::string &feature) {
std::vector<Swift::JID> jid;
std::vector<Swift::Presence::ref> 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;
}