diff --git a/src/rostermanager.cpp b/src/rostermanager.cpp index 0967fe567a8c8208b1f1805cebcd07f2c8a036b6..f9c47e77eed88ada8ac5273dac078c6830cddf06 100644 --- a/src/rostermanager.cpp +++ b/src/rostermanager.cpp @@ -30,7 +30,10 @@ #include "Swiften/Elements/RosterPayload.h" #include "Swiften/Elements/RosterItemPayload.h" #include "Swiften/Elements/RosterItemExchangePayload.h" +#include "Swiften/Elements/Nickname.h" +#include "Swiften/Queries/IQRouter.h" #include +#include #include #include @@ -151,12 +154,7 @@ void RosterManager::sendBuddyRosterPush(Buddy *buddy) { Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload()); Swift::RosterItemPayload item; item.setJID(buddy->getJID().toBare()); - if (buddy->getAlias().empty()) { - item.setName(buddy->getJID().toBare().toString()); - } - else { - item.setName(buddy->getAlias()); - } + item.setName(buddy->getAlias()); item.setGroups(buddy->getGroups()); item.setSubscription(Swift::RosterItemPayload::Both); @@ -280,6 +278,15 @@ void RosterManager::handleRemoteRosterResponse(boost::shared_ptrgetJID().toString() << ": This server supports remote roster protoXEP"); m_supportRemoteRoster = true; + + //If we receive empty RosterPayload on login (not register) initiate full RosterPush + if(!m_buddies.empty() && payload->getItems().empty()){ + LOG4CXX_INFO(logger, "Received empty Roster upon login. Pushing full Roster."); + for(std::map, boost::pool_allocator< std::pair > >::const_iterator c_it = m_buddies.begin(); + c_it != m_buddies.end(); c_it++) { + sendBuddyRosterPush(c_it->second); + } + } return; BOOST_FOREACH(const Swift::RosterItemPayload &item, payload->getItems()) { @@ -490,6 +497,7 @@ void RosterManager::handleSubscription(Swift::Presence::ref presence) { buddy = m_component->getFactory()->createBuddy(this, buddyInfo); setBuddy(buddy); onBuddyAdded(buddy); + LOG4CXX_INFO(logger, m_user->getJID().toString() << ": Subscription received for new buddy " << buddyInfo.legacyName << " => adding to legacy network"); response->setType(Swift::Presence::Subscribed); break; case Swift::Presence::Unsubscribe: