Changeset - 16340590b496
[Not reviewed]
0 5 0
HanzZ - 14 years ago 2011-08-05 09:30:24
hanzz.k@gmail.com
Answer probe presences
5 files changed with 35 insertions and 4 deletions:
0 comments (0 inline, 0 general)
include/transport/rostermanager.h
Show inline comments
 
@@ -88,6 +88,8 @@ class RosterManager {
 

	
 
		void sendCurrentPresences(const Swift::JID &to);
 

	
 
		void sendCurrentPresence(const Swift::JID &from, const Swift::JID &to);
 

	
 
		void sendUnavailablePresences(const Swift::JID &to);
 

	
 
	private:
spectrum/src/sample.cfg
Show inline comments
 
@@ -8,7 +8,7 @@ backend_host=localhost # < this option doesn't work yet
 
backend_port=10001
 
admin_username=admin
 
admin_password=test
 
idle_reconnect_time=10
 
#idle_reconnect_time=10
 
#cert= #patch to PKCS#12 certificate
 
#cert_password= #password to that certificate if any
 
users_per_backend=10
src/rostermanager.cpp
Show inline comments
 
@@ -377,6 +377,24 @@ void RosterManager::sendCurrentPresences(const Swift::JID &to) {
 
	}
 
}
 

	
 
void RosterManager::sendCurrentPresence(const Swift::JID &from, const Swift::JID &to) {
 
	Buddy *buddy = getBuddy(Buddy::JIDToLegacyName(from));
 
	if (buddy) {
 
		Swift::Presence::ref presence = buddy->generatePresenceStanza(255);
 
		if (presence) {
 
			presence->setTo(to);
 
			m_component->getStanzaChannel()->sendPresence(presence);
 
		}
 
	}
 
	else {
 
		Swift::Presence::ref response = Swift::Presence::create();
 
		response->setTo(to);
 
		response->setFrom(from);
 
		response->setType(Swift::Presence::Unavailable);
 
		m_component->getStanzaChannel()->sendPresence(response);
 
	}
 
}
 

	
 
void RosterManager::sendUnavailablePresences(const Swift::JID &to) {
 
	for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
 
		Buddy *buddy = (*it).second;
src/user.cpp
Show inline comments
 
@@ -90,12 +90,12 @@ Swift::JID User::getJIDWithFeature(const std::string &feature) {
 
			continue;
 

	
 
		if (discoInfo->hasFeature(feature)) {
 
			LOG4CXX_INFO(logger, m_jid.toString() << ": Found JID with " << feature << "feature: " << presence->getFrom().toString());
 
			LOG4CXX_INFO(logger, m_jid.toString() << ": Found JID with " << feature << " feature: " << presence->getFrom().toString());
 
			return presence->getFrom();
 
		}
 
	}
 

	
 
	LOG4CXX_INFO(logger, m_jid.toString() << ": No JID with " << feature << "feature");
 
	LOG4CXX_INFO(logger, m_jid.toString() << ": No JID with " << feature << " feature");
 
	return jid;
 
}
 

	
src/usermanager.cpp
Show inline comments
 
@@ -236,7 +236,18 @@ void UserManager::handleGeneralPresenceReceived(Swift::Presence::ref presence) {
 
}
 

	
 
void UserManager::handleProbePresence(Swift::Presence::ref presence) {
 
	
 
	User *user = getUser(presence->getFrom().toBare().toString());
 

	
 
 	if (user) {
 
 		user->getRosterManager()->sendCurrentPresence(presence->getTo(), presence->getFrom());
 
 	}
 
 	else {
 
		Swift::Presence::ref response = Swift::Presence::create();
 
		response->setFrom(presence->getTo());
 
		response->setTo(presence->getFrom());
 
		response->setType(Swift::Presence::Unavailable);
 
		m_component->getStanzaChannel()->sendPresence(response);
 
	}
 
}
 

	
 
void UserManager::handleSubscription(Swift::Presence::ref presence) {
0 comments (0 inline, 0 general)