soc.2009.transport: b4ebb11a: Rewrited subscribeCache in user.cpp

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Tue May 19 05:20:34 EDT 2009


-----------------------------------------------------------------
Revision: b4ebb11afbb4c318af78b169b492e05458a9618d
Ancestor: c2ad93896402feb01bd8fa638a6cdc8b4febd8ca
Author: hanzz at soc.pidgin.im
Date: 2009-05-02T13:27:17
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/b4ebb11afbb4c318af78b169b492e05458a9618d

Modified files:
        autoconnectloop.cpp user.cpp user.h usermanager.cpp

ChangeLog: 

Rewrited subscribeCache in user.cpp

-------------- next part --------------
============================================================
--- autoconnectloop.cpp	12e5f22934db95c46fa69620a00f8378cb1dc684
+++ autoconnectloop.cpp	10c31ab28140a30d201953b05b43106edb8ee9f9
@@ -62,13 +62,14 @@ bool AutoConnectLoop::restoreNextConnect
 
 bool AutoConnectLoop::restoreNextConnection() {
 	Stanza * stanza;
+	User *user;
 	PurpleAccount *account;
-	GList *l;
-	User *user;
 	Log().Get("connection restorer") << "Restoring new connection";
 	if (m_account == NULL)
 		return false;
 
+	account = (PurpleAccount *) m_account->data;
+
 	Log().Get("connection restorer") << "Checking next account";
 	if (purple_presence_is_online(account->presence)) {
 		user = main->userManager()->getUserByAccount(account);
============================================================
--- user.cpp	4eec7b778e0a37c321d088c86d8c3b15f089fb0a
+++ user.cpp	6f47369aa163dd691bbd460701382e7d3b9a6666
@@ -153,26 +153,29 @@ void User::sendRosterX()
 	Tag *item;
 
 	// adding these users to roster db with subscription=ask
-	std::map<std::string,subscribeContact>::iterator it = m_subscribeCache.begin();
+	std::map<std::string,PurpleBuddy*>::iterator it = m_subscribeCache.begin();
 	while(it != m_subscribeCache.end()) {
-		if (!(*it).second.uin.empty()){
+// 		if (!(*it).second.uin.empty()){
 			RosterRow user;
+			PurpleBuddy *buddy = (*it).second;
+			std::string alias(purple_buddy_get_alias(buddy));
+			std::string name(purple_buddy_get_name(buddy));
 			user.id = -1;
 			user.jid = m_jid;
-			user.uin = (*it).second.uin;
+			user.uin = name;
 			user.subscription = "ask";
 			user.online = false;
 			user.lastPresence = "";
-			m_roster[(*it).second.uin] = user;
-			p->sql()->addUserToRoster(m_jid,(*it).second.uin,"ask");
+			m_roster[name] = user;
+			p->sql()->addUserToRoster(m_jid,name,"ask");
 
 			item = new Tag("item");
 			item->addAttribute("action","add");
-			item->addAttribute("jid",(*it).second.uin+"@"+p->jid());
-			item->addAttribute("name",(*it).second.alias);
-			item->addChild(new Tag("group",(*it).second.group));
+			item->addAttribute("jid",name+"@"+p->jid());
+			item->addAttribute("name",alias);
+			item->addChild(new Tag("group",(std::string) purple_group_get_name(purple_buddy_get_group(buddy))));
 			x->addChild(item);
-		}
+// 		}
 		it++;
 	}
 	tag->addChild(x);
@@ -270,6 +273,7 @@ Tag *User::generatePresenceStanza(Purple
 	PurpleBuddyIcon *icon = purple_buddy_get_icon(buddy);
 	if (icon != NULL) {
 		avatarHash = purple_buddy_icon_get_full_path(icon);
+		Log().Get(m_jid) << "avatarHash";
 	}
 
 	Tag *x = new Tag("x");
@@ -371,11 +375,11 @@ void User::purpleBuddyChanged(PurpleBudd
 
 	if (!inRoster) {
 		if (!m_rosterXCalled && hasFeature(GLOOX_FEATURE_ROSTERX)){
-			subscribeContact c;
-			c.uin = name;
-			c.alias = alias;
-			c.group = (std::string) purple_group_get_name(purple_buddy_get_group(buddy));
-			m_subscribeCache[name] = c;
+// 			subscribeContact c;
+// 			c.uin = name;
+// 			c.alias = alias;
+// 			c.group = (std::string) purple_group_get_name(purple_buddy_get_group(buddy));
+			m_subscribeCache[name] = buddy;
 			Log().Get(m_jid) << "Not in roster => adding to rosterX cache";
 		}
 		else {
@@ -384,11 +388,11 @@ void User::purpleBuddyChanged(PurpleBudd
 				if (m_syncTimer==0){
 					m_syncTimer = purple_timeout_add_seconds(4, sync_cb, this);
 				}
-				subscribeContact c;
-				c.uin = name;
-				c.alias = alias;
-				c.group = (std::string) purple_group_get_name(purple_buddy_get_group(buddy));
-				m_subscribeCache[name] = c;
+// 				subscribeContact c;
+// 				c.uin = name;
+// 				c.alias = alias;
+// 				c.group = (std::string) purple_group_get_name(purple_buddy_get_group(buddy));
+				m_subscribeCache[name] = buddy;
 			}
 			else {
 				Log().Get(m_jid) << "Not in roster => sending subscribe";
============================================================
--- user.h	bc9a40b41bf1f77c0b111973a6e1e3e88fadd27e
+++ user.h	11ce62f3078fecb587aa9cc63b7f821ae544105a
@@ -142,7 +142,7 @@ class User {
 		std::map<std::string,int> m_resources;	// list of all resources which are connected to the transport
 		std::map<std::string,authRequest> m_authRequests;	// list of authorization requests (holds callbacks and user data)
 		std::map<std::string,PurpleConversation *> m_conversations; // list of opened conversations
-		std::map<std::string,subscribeContact> m_subscribeCache;	// cache for contacts for roster X
+		std::map<std::string,PurpleBuddy *> m_subscribeCache;	// cache for contacts for roster X
 };
 
 #endif
============================================================
--- usermanager.cpp	1a915481e3d45033dfe54075cdbd368da74308a0
+++ usermanager.cpp	2827384bdcc8da87746de013a569e0ab857ae3c6
@@ -40,7 +40,7 @@ User *UserManager::getUserByJID(std::str
 }
 
 User *UserManager::getUserByJID(std::string barejid){
-	User *user = (User*) g_hash_table_lookup(m_users, user->jid().c_str());
+	User *user = (User*) g_hash_table_lookup(m_users, barejid.c_str());
 	return user;
 }
 


More information about the Commits mailing list