Changeset - afe5ac506dd1
[Not reviewed]
0 3 0
HanzZ - 13 years ago 2012-03-30 15:28:49
hanzz.k@gmail.com
Store buddy changes only when there's a real change
3 files changed with 12 insertions and 6 deletions:
0 comments (0 inline, 0 general)
include/transport/localbuddy.h
Show inline comments
 
@@ -48,16 +48,26 @@ class LocalBuddy : public Buddy {
 
		void setStatus(const Swift::StatusShow &status, const std::string &statusMessage) {
 
			m_status = status;
 
			m_statusMessage = statusMessage;
 
		}
 

	
 
		std::string getIconHash() { return m_iconHash; }
 
		void setIconHash(const std::string &iconHash) { m_iconHash = iconHash; }
 
		void setIconHash(const std::string &iconHash) {
 
			bool changed = m_iconHash != iconHash;
 
			m_iconHash = iconHash;
 
			if (changed)
 
				getRosterManager()->storeBuddy(this);
 
		}
 

	
 
		std::vector<std::string> getGroups() { return m_groups; }
 
		void setGroups(const std::vector<std::string> &groups) { m_groups = groups; }
 
		void setGroups(const std::vector<std::string> &groups) {
 
			bool changed = m_groups.size() != groups.size();
 
			m_groups = groups;
 
			if (changed)
 
				getRosterManager()->storeBuddy(this);
 
		}
 

	
 
	private:
 
		std::string m_name;
 
		std::string m_alias;
 
		std::vector<std::string> m_groups;
 
		std::string m_statusMessage;
src/buddy.cpp
Show inline comments
 
@@ -145,13 +145,12 @@ std::string Buddy::getSafeName() {
 

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

	
 
void Buddy::handleVCardReceived(const std::string &id, Swift::VCard::ref vcard) {
 
	boost::shared_ptr<Swift::GenericRequest<Swift::VCard> > request(new Swift::GenericRequest<Swift::VCard>(Swift::IQ::Result, m_rosterManager->getUser()->getJID(), vcard, m_rosterManager->getUser()->getComponent()->getIQRouter()));
 
	request->send();
 
}
src/rostermanager.cpp
Show inline comments
 
@@ -149,15 +149,12 @@ void RosterManager::sendBuddySubscribePresence(Buddy *buddy) {
 
	response->setType(Swift::Presence::Subscribe);
 
// 	TODO: NICKNAME
 
	m_component->getStanzaChannel()->sendPresence(response);
 
}
 

	
 
void RosterManager::handleBuddyChanged(Buddy *buddy) {
 
	if (m_rosterStorage) {
 
		m_rosterStorage->storeBuddy(buddy);
 
	}
 
}
 

	
 
void RosterManager::setBuddyCallback(Buddy *buddy) {
 
	LOG4CXX_INFO(logger, "Associating buddy " << buddy->getName() << " with " << m_user->getJID().toString());
 
	m_buddies[buddy->getName()] = buddy;
 
	onBuddySet(buddy);
0 comments (0 inline, 0 general)