gossip r2781 - in trunk: libgossip src



Author: mr
Date: Sun Mar 30 22:12:01 2008
New Revision: 2781
URL: http://svn.gnome.org/viewvc/gossip?rev=2781&view=rev

Log:
Fixed contact list being empty when online after reconnecting


Modified:
   trunk/libgossip/gossip-contact.c
   trunk/libgossip/gossip-contact.h
   trunk/libgossip/gossip-jabber-ft.c
   trunk/libgossip/gossip-jabber-utils.c
   trunk/libgossip/gossip-jabber.c
   trunk/libgossip/gossip-jabber.h
   trunk/src/gossip-contact-list.c

Modified: trunk/libgossip/gossip-contact.c
==============================================================================
--- trunk/libgossip/gossip-contact.c	(original)
+++ trunk/libgossip/gossip-contact.c	Sun Mar 30 22:12:01 2008
@@ -964,3 +964,19 @@
 	}
 }
 
+const gchar *
+gossip_contact_type_to_string (GossipContactType type)
+{
+	switch (type) {
+	case GOSSIP_CONTACT_TYPE_TEMPORARY:
+		return "GOSSIP_CONTACT_TYPE_TEMPORARY";
+	case GOSSIP_CONTACT_TYPE_CONTACTLIST:
+		return "GOSSIP_CONTACT_TYPE_CONTACTLIST";
+	case GOSSIP_CONTACT_TYPE_CHATROOM:
+		return "GOSSIP_CONTACT_TYPE_CHATROOM";
+	case GOSSIP_CONTACT_TYPE_USER:
+		return "GOSSIP_CONTACT_TYPE_USER";
+	}
+
+	return "";
+}

Modified: trunk/libgossip/gossip-contact.h
==============================================================================
--- trunk/libgossip/gossip-contact.h	(original)
+++ trunk/libgossip/gossip-contact.h	Sun Mar 30 22:12:01 2008
@@ -121,6 +121,7 @@
 gboolean           gossip_contact_is_in_group               (GossipContact      *contact,
 							     const gchar        *group);
 const gchar *      gossip_contact_get_status                (GossipContact      *contact);
+const gchar *      gossip_contact_type_to_string            (GossipContactType   type);
 
 G_END_DECLS
 

Modified: trunk/libgossip/gossip-jabber-ft.c
==============================================================================
--- trunk/libgossip/gossip-jabber-ft.c	(original)
+++ trunk/libgossip/gossip-jabber-ft.c	Sun Mar 30 22:12:01 2008
@@ -696,7 +696,11 @@
 
 	from_str = lm_message_node_get_attribute (m->node, "from");
 	id_str = lm_message_node_get_attribute (m->node, "id");
-	from = gossip_jabber_get_contact_from_jid (jabber, from_str, NULL, TRUE);
+	from = gossip_jabber_get_contact_from_jid (jabber, 
+						   from_str, 
+						   NULL, 
+						   FALSE,
+						   TRUE);
 
 	node = lm_message_node_find_child (m->node, "si");
 	sid = lm_message_node_get_attribute (node, "id");
@@ -765,7 +769,11 @@
 	}
 
 	from_str = lm_message_node_get_attribute (m->node, "from");
-	from = gossip_jabber_get_contact_from_jid (jabber, from_str, NULL, TRUE);
+	from = gossip_jabber_get_contact_from_jid (jabber, 
+						   from_str, 
+						   NULL, 
+						   FALSE, 
+						   TRUE);
 
 	node = lm_message_node_find_child (m->node, "error");
 	error_reason = lm_message_node_get_value (node);

Modified: trunk/libgossip/gossip-jabber-utils.c
==============================================================================
--- trunk/libgossip/gossip-jabber-utils.c	(original)
+++ trunk/libgossip/gossip-jabber-utils.c	Sun Mar 30 22:12:01 2008
@@ -163,6 +163,7 @@
 	contact = gossip_jabber_get_contact_from_jid (jabber,
 						      contact_id,
 						      NULL,
+						      FALSE,
 						      TRUE);
 
 	id = lm_message_node_get_attribute (m->node, "from");

Modified: trunk/libgossip/gossip-jabber.c
==============================================================================
--- trunk/libgossip/gossip-jabber.c	(original)
+++ trunk/libgossip/gossip-jabber.c	Sun Mar 30 22:12:01 2008
@@ -538,6 +538,7 @@
 	contact = gossip_jabber_get_contact_from_jid (jabber,
 						      id,
 						      &new_contact,
+						      FALSE,
 						      FALSE);
 	if (new_contact && !G_STR_EMPTY (name)) {
 		gossip_contact_set_name (contact, name);
@@ -1351,6 +1352,7 @@
 	recipient = gossip_jabber_get_contact_from_jid (jabber,
 							recipient_id,
 							&new_contact,
+							FALSE,
 							TRUE);
 	if (new_contact) {
 		g_object_unref (recipient);
@@ -2172,6 +2174,7 @@
 	from = gossip_jabber_get_contact_from_jid (jabber,
 						   from_str,
 						   NULL,
+						   FALSE,
 						   TRUE);
 
 	if (gossip_jabber_get_message_is_event (m)) {
@@ -2355,7 +2358,11 @@
 		return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
 	}
 
-	contact = gossip_jabber_get_contact_from_jid (jabber, from, &new_item, TRUE);
+	contact = gossip_jabber_get_contact_from_jid (jabber, 
+						      from, 
+						      &new_item, 
+						      FALSE, 
+						      TRUE);
 
 	/* Get the type */
 	type = lm_message_node_get_attribute (m->node, "type");
@@ -2656,6 +2663,7 @@
 		contact = gossip_jabber_get_contact_from_jid (jabber,
 							      jid_str,
 							      &added_item,
+							      TRUE,
 							      FALSE);
 
 		type = gossip_contact_get_type (contact);
@@ -2696,7 +2704,6 @@
 			
 			added_item = TRUE;
 
-			gossip_contact_set_type (contact, GOSSIP_CONTACT_TYPE_CONTACTLIST);
 			gossip_contact_set_subscription (contact, subscription_type);
 		}
 
@@ -3202,12 +3209,14 @@
 gossip_jabber_get_contact_from_jid (GossipJabber *jabber,
 				    const gchar  *jid_str,
 				    gboolean     *new_item,
+				    gboolean      set_permanent,
 				    gboolean      get_vcard)
 {
-	GossipJabberPriv *priv;
-	GossipContact    *contact;
-	GossipJID        *jid;
-	gboolean          tmp_new_item = FALSE;
+	GossipJabberPriv  *priv;
+	GossipContact     *contact;
+	GossipContactType  type;
+	GossipJID         *jid;
+	gboolean           tmp_new_item = FALSE;
 
 	priv = GET_PRIV (jabber);
 
@@ -3217,11 +3226,18 @@
 				       gossip_jid_get_without_resource (jid));
 
 	if (!contact) {
+		if (set_permanent) {
+			type = GOSSIP_CONTACT_TYPE_CONTACTLIST;
+		} else {
+			type = GOSSIP_CONTACT_TYPE_TEMPORARY;
+		}
+
 		gossip_debug (DEBUG_DOMAIN,
-			      "New contact:'%s' (GOSSIP_CONTACT_TYPE_TEMPORARY)",
-			      gossip_jid_get_full (jid));
-		contact = gossip_contact_new (GOSSIP_CONTACT_TYPE_TEMPORARY,
-					      priv->account);
+			      "New contact:'%s' (%s)",
+			      gossip_jid_get_full (jid),
+			      gossip_contact_type_to_string (type));
+
+		contact = gossip_contact_new (type, priv->account);
 		gossip_contact_set_id (contact, gossip_jid_get_full (jid));
 		gossip_contact_set_name (contact, gossip_jid_get_without_resource (jid));
 
@@ -3238,32 +3254,17 @@
 			jabber_contact_vcard (jabber, contact);
 		}
 	} else {
-		GossipContactType  type;
-		const gchar       *type_str;
+		if (set_permanent) {
+			gossip_contact_set_type (contact, GOSSIP_CONTACT_TYPE_CONTACTLIST);
+		}
 
 		type = gossip_contact_get_type (contact);
 
-		switch (type) {
-		case GOSSIP_CONTACT_TYPE_TEMPORARY:
-			type_str = "GOSSIP_CONTACT_TYPE_TEMPORARY";
-			break;
-		case GOSSIP_CONTACT_TYPE_CONTACTLIST:
-			type_str = "GOSSIP_CONTACT_TYPE_CONTACTLIST";
-			break;
-		case GOSSIP_CONTACT_TYPE_CHATROOM:
-			type_str = "GOSSIP_CONTACT_TYPE_CHATROOM";
-			break;
-		case GOSSIP_CONTACT_TYPE_USER:
-			type_str = "GOSSIP_CONTACT_TYPE_USER";
-			break;
-		default:
-			type_str = "unknown";
-			break;
-		}
-
 		gossip_debug (DEBUG_DOMAIN,
 			      "Get contact:'%s', type:%d-->'%s'",
-			      gossip_jid_get_full (jid), type, type_str);
+			      gossip_jid_get_full (jid), 
+			      type, 
+			      gossip_contact_type_to_string (type));
 	}
 
 	gossip_jid_unref (jid);

Modified: trunk/libgossip/gossip-jabber.h
==============================================================================
--- trunk/libgossip/gossip-jabber.h	(original)
+++ trunk/libgossip/gossip-jabber.h	Sun Mar 30 22:12:01 2008
@@ -67,6 +67,7 @@
 GossipContact *gossip_jabber_get_contact_from_jid      (GossipJabber        *jabber,
 							const gchar         *jid,
 							gboolean            *new_item,
+							gboolean             set_permanent,
 							gboolean             get_vcard);
 void           gossip_jabber_send_presence             (GossipJabber        *jabber,
 							GossipPresence      *presence);

Modified: trunk/src/gossip-contact-list.c
==============================================================================
--- trunk/src/gossip-contact-list.c	(original)
+++ trunk/src/gossip-contact-list.c	Sun Mar 30 22:12:01 2008
@@ -71,7 +71,6 @@
 struct _GossipContactListPriv {
 	GossipSession         *session;
 
-	GHashTable            *groups;
 	GHashTable            *flash_table;
 	GHashTable            *active_contacts;
 	GHashTable            *update_contacts;
@@ -972,15 +971,18 @@
 	priv = GET_PRIV (list);
 
 	if (g_hash_table_lookup (priv->update_contacts, contact)) {
-		g_hash_table_remove (priv->update_contacts, contact);
+		gossip_debug (DEBUG_DOMAIN,
+			      "Contact:'%s' updated, checking roster is in sync...",
+			      gossip_contact_get_name (contact));
+		contact_list_contact_update (list, contact);
+	} else {
+		gossip_debug (DEBUG_DOMAIN,
+			      "Contact:'%s' updated, ignoring due to removal",
+			      gossip_contact_get_name (contact));
 	}
 
-	gossip_debug (DEBUG_DOMAIN,
-		      "Contact:'%s' updated, checking roster is in sync...",
-		      gossip_contact_get_name (contact));
-
-	contact_list_contact_update (list, contact);
-
+	g_hash_table_remove (priv->update_contacts, contact);
+		
 	return FALSE;
 }
 
@@ -999,9 +1001,8 @@
 
 	priv = GET_PRIV (list);
 
-	if (g_hash_table_lookup (priv->update_contacts, contact)) {
-		g_hash_table_remove (priv->update_contacts, contact);
-	}
+	/* Always remove the last one as part of the throttling */
+	g_hash_table_remove (priv->update_contacts, contact);
 	
 	data = g_new0 (ActiveContactData, 1);
 	data->list = g_object_ref (list);
@@ -1706,13 +1707,13 @@
 		g_list_free (iters);
 		
 		gossip_debug (DEBUG_DOMAIN, 
-			      " - Now %d top level nodes remaining in the tree\n",
+			      " - Now %d top level nodes remaining in the tree",
 			      gtk_tree_model_iter_n_children (model, NULL));
 	}
 
 	if (refilter) {
 		gossip_debug (DEBUG_DOMAIN, 
-			      "Refiltering model, contact/groups removed at the topmost level");
+			      " - Refiltering model, contact/groups at the topmost level");
 		gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
 	}
 
@@ -1726,8 +1727,10 @@
 					      list);
 
 	if (!shallow_remove) {
-		gossip_debug (DEBUG_DOMAIN, " - Removing flash information");
+		gossip_debug (DEBUG_DOMAIN, " - Removing information (flash/update/active)");
 		g_hash_table_remove (priv->flash_table, contact);
+		g_hash_table_remove (priv->active_contacts, contact);
+		g_hash_table_remove (priv->update_contacts, contact);
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]