Changeset - 62f3fbf99c88
[Not reviewed]
0 3 0
Jan Kaluza - 14 years ago 2011-04-06 14:32:03
hanzz.k@gmail.com
Buddy::JIDToLegacyName
3 files changed with 18 insertions and 2 deletions:
0 comments (0 inline, 0 general)
include/transport/buddy.h
Show inline comments
 
@@ -120,24 +120,26 @@ class Buddy {
 

	
 
		/// Returns current legacy network status and statuMessage of this buddy.
 
		/// \param status current status/show is stored here
 
		/// \param statusMessage current status message is stored here
 
		/// \return true if status was stored successfully
 
		virtual bool getStatus(Swift::StatusShow &status, std::string &statusMessage) = 0;
 

	
 
		/// Returns SHA-1 hash of buddy icon (avatar) or empty string if there is no avatar
 
		/// for this buddy.
 
		/// \return avatar hash or empty string.
 
		virtual std::string getIconHash() = 0;
 

	
 
		static std::string JIDToLegacyName(const Swift::JID &jid);
 

	
 
	private:
 
		void generateJID();
 

	
 
		long m_id;
 
		bool m_online;
 
		std::string m_subscription;
 
		Swift::Presence::ref m_lastPresence;
 
		Swift::JID m_jid;
 
		BuddyFlag m_flags;
 
		RosterManager *m_rosterManager;
 
};
 

	
src/buddy.cpp
Show inline comments
 
@@ -144,13 +144,27 @@ std::string Buddy::getSafeName() {
 
// 		Log("SpectrumBuddy::getSafeName", "Name is EMPTY! Previous was " << getName() << ".");
 
// 	}
 
	return name;
 
}
 

	
 
void Buddy::buddyChanged() {
 
	Swift::Presence::ref presence = generatePresenceStanza(255);
 
	if (presence) {
 
		m_rosterManager->getUser()->getComponent()->getStanzaChannel()->sendPresence(presence);
 
	}
 
}
 

	
 
std::string Buddy::JIDToLegacyName(const Swift::JID &jid) {
 
	std::string name;
 
	if (jid.getUnescapedNode() == jid.getNode()) {
 
		name = jid.getNode();
 
		if (name.find_last_of("%") != std::string::npos) {
 
			name.replace(name.find_last_of("%"), 1, "@");
 
		}
 
	}
 
	else {
 
		name = jid.getUnescapedNode();
 
	}
 
	return name;
 
}
 

	
 
}
src/rostermanager.cpp
Show inline comments
 
@@ -111,16 +111,16 @@ void RosterManager::sendRIE() {
 
		item.name = buddy->getAlias();
 
		item.action = Swift::RosterItemExchangePayload::Add;
 
		item.groups = buddy->getGroups();
 

	
 
		payload->addItem(item);
 
	}
 

	
 
	boost::shared_ptr<Swift::GenericRequest<Swift::RosterItemExchangePayload> > request(new Swift::GenericRequest<Swift::RosterItemExchangePayload>(Swift::IQ::Set, m_user->getJID(), payload, m_component->getIQRouter()));
 
	request->send();
 
}
 

	
 
void RosterManager::handleSubscription(Swift::Presence::ref presence) {
 
	></i>
 
	std::string legacyName = Buddy::JIDToLegacyName(presence->getTo());
 
}
 

	
 
}
 
\ No newline at end of file
 
}
0 comments (0 inline, 0 general)