Changeset - b63c1d0aadda
[Not reviewed]
0 4 0
HanzZ - 14 years ago 2011-06-05 11:58:10
hanzz.k@gmail.com
Store buddies if they change and don't store unchanged buddies on logout
4 files changed with 14 insertions and 7 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -268,7 +268,7 @@ static void buddyListNewNode(PurpleBlistNode *node) {
 
// 	np->handleBuddyChanged(np->m_accounts[account], purple_buddy_get_name(buddy), getAlias(buddy), getGroups(buddy)[0], (int) status.getType(), message, getIconHash(buddy));
 
// }
 

	
 
void buddyListUpdate(PurpleBuddyList *list, PurpleBlistNode *node) {
 
static void buddyListUpdate(PurpleBuddyList *list, PurpleBlistNode *node) {
 
	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
 
		return;
 
	PurpleBuddy *buddy = (PurpleBuddy *) node;
include/transport/buddy.h
Show inline comments
 
@@ -107,6 +107,8 @@ class Buddy {
 

	
 
		void handleVCardReceived(const std::string &id, const Swift::JID &to, Swift::VCard::ref vcard);
 

	
 
		boost::signal<void ()> onBuddyChanged;
 

	
 
		virtual void getVCard(const std::string &id, const Swift::JID &to) = 0;
 

	
 
		/// Returns legacy network username of this buddy. (for example UIN for ICQ,
src/buddy.cpp
Show inline comments
 
@@ -151,6 +151,7 @@ void Buddy::buddyChanged() {
 
	if (presence) {
 
		m_rosterManager->getUser()->getComponent()->getStanzaChannel()->sendPresence(presence);
 
	}
 
	onBuddyChanged();
 
}
 

	
 
void Buddy::handleVCardReceived(const std::string &id, const Swift::JID &to, Swift::VCard::ref vcard) {
src/rostermanager.cpp
Show inline comments
 
@@ -48,10 +48,10 @@ RosterManager::~RosterManager() {
 
	m_setBuddyTimer->stop();
 
	m_RIETimer->stop();
 
	if (m_rosterStorage) {
 
		for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
 
			Buddy *buddy = (*it).second;
 
			m_rosterStorage->storeBuddy(buddy);
 
		}
 
// 		for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
 
// 			Buddy *buddy = (*it).second;
 
// 			m_rosterStorage->storeBuddy(buddy);
 
// 		}
 
		m_rosterStorage->storeBuddies();
 
	}
 

	
 
@@ -86,6 +86,10 @@ void RosterManager::sendBuddyRosterPush(Buddy *buddy) {
 
void RosterManager::setBuddyCallback(Buddy *buddy) {
 
	m_setBuddyTimer->onTick.disconnect(boost::bind(&RosterManager::setBuddyCallback, this, buddy));
 

	
 
	if (m_rosterStorage) {
 
		buddy->onBuddyChanged.connect(boost::bind(&RosterStorage::storeBuddy, m_rosterStorage, buddy));
 
	}
 

	
 
	std::cout << "ADDING " << buddy->getName() << "\n";
 
	m_buddies[buddy->getName()] = buddy;
 
	onBuddySet(buddy);
 
@@ -151,8 +155,7 @@ void RosterManager::handleSubscription(Swift::Presence::ref presence) {
 

	
 
void RosterManager::setStorageBackend(StorageBackend *storageBackend) {
 
	if (m_rosterStorage) {
 
		m_rosterStorage->storeBuddies();
 
		delete m_rosterStorage;
 
		return;
 
	}
 
	m_rosterStorage = new RosterStorage(m_user, storageBackend);
 

	
 
@@ -163,6 +166,7 @@ void RosterManager::setStorageBackend(StorageBackend *storageBackend) {
 
		Buddy *buddy = m_component->getFactory()->createBuddy(this, *it);
 
		std::cout << "CREATING BUDDY FROM DATABASE CACHE " << buddy->getName() << "\n";
 
		m_buddies[buddy->getName()] = buddy;
 
		buddy->onBuddyChanged.connect(boost::bind(&RosterStorage::storeBuddy, m_rosterStorage, buddy));
 
		onBuddySet(buddy);
 
	}
 
}
0 comments (0 inline, 0 general)