Changeset - 984a07501942
[Not reviewed]
0 3 0
HanzZ - 13 years ago 2012-12-26 09:59:09
hanzz.k@gmail.com
Send RIE to all resources
3 files changed with 14 insertions and 11 deletions:
0 comments (0 inline, 0 general)
include/transport/user.h
Show inline comments
 
@@ -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;
 

	
src/rostermanager.cpp
Show inline comments
 
@@ -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,9 +346,12 @@ 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()));
 
	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) {
 
	std::string legacyName = Buddy::JIDToLegacyName(presence->getTo());
src/user.cpp
Show inline comments
 
@@ -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());
 
		}
 
	}
 

	
 
	if (jid.empty()) {
 
		LOG4CXX_INFO(logger, m_jid.toString() << ": No JID with " << feature << " feature " << m_legacyCaps.size());
 
	}
 
	return jid;
 
}
 

	
0 comments (0 inline, 0 general)