empathy r952 - trunk/libempathy



Author: xclaesse
Date: Wed Apr 16 11:43:42 2008
New Revision: 952
URL: http://svn.gnome.org/viewvc/empathy?rev=952&view=rev

Log:
If the RequestAliases fails, make sure the name property on all contacts becomes ready to avoid waiting infinitely.


Modified:
   trunk/libempathy/empathy-contact.c
   trunk/libempathy/empathy-tp-contact-factory.c

Modified: trunk/libempathy/empathy-contact.c
==============================================================================
--- trunk/libempathy/empathy-contact.c	(original)
+++ trunk/libempathy/empathy-contact.c	Wed Apr 16 11:43:42 2008
@@ -315,19 +315,12 @@
 
 static void
 contact_set_ready_flag (EmpathyContact      *contact,
-			EmpathyContactReady  flag,
-			gboolean             set)
+			EmpathyContactReady  flag)
 {
 	EmpathyContactPriv *priv = GET_PRIV (contact);
-	EmpathyContactReady ready_old = priv->ready;
 
-	if (set) {
+	if (!(priv->ready & flag)) {
 		priv->ready |= flag;
-	} else {
-		priv->ready &= ~flag;
-	}
-
-	if (priv->ready != ready_old) {
 		g_object_notify (G_OBJECT (contact), "ready");
 	}
 }
@@ -375,19 +368,20 @@
 
 	priv = GET_PRIV (contact);
 
-	if (!tp_strdiff (id, priv->id)) {
-		return;
-	}
-
-	g_free (priv->id);
-	priv->id = g_strdup (id);
+	/* We temporally ref the contact because it could be destroyed
+	 * during the signal emition */
 	g_object_ref (contact);
-	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID,
-				!G_STR_EMPTY (id));
-	g_object_notify (G_OBJECT (contact), "id");
-	if (G_STR_EMPTY (priv->name)) {
-		g_object_notify (G_OBJECT (contact), "name");
+	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_ID);
+	if (tp_strdiff (id, priv->id)) {
+		g_free (priv->id);
+		priv->id = g_strdup (id);
+
+		g_object_notify (G_OBJECT (contact), "id");
+		if (G_STR_EMPTY (priv->name)) {
+			g_object_notify (G_OBJECT (contact), "name");
+		}
 	}
+
 	g_object_unref (contact);
 }
 
@@ -417,17 +411,13 @@
 
 	priv = GET_PRIV (contact);
 
-	if (!tp_strdiff (name, priv->name)) {
-		return;
-	}
-
-	g_free (priv->name);
-	priv->name = g_strdup (name);
-
 	g_object_ref (contact);
-	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME,
-				name != NULL);
-	g_object_notify (G_OBJECT (contact), "name");
+	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_NAME);
+	if (tp_strdiff (name, priv->name)) {
+		g_free (priv->name);
+		priv->name = g_strdup (name);
+		g_object_notify (G_OBJECT (contact), "name");
+	}
 	g_object_unref (contact);
 }
 
@@ -587,16 +577,12 @@
 
 	priv = GET_PRIV (contact);
 
-	if (priv->handle == handle) {
-		return;
-	}
-
-	priv->handle = handle;
-
 	g_object_ref (contact);
-	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE,
-				handle != 0);
-	g_object_notify (G_OBJECT (contact), "handle");
+	contact_set_ready_flag (contact, EMPATHY_CONTACT_READY_HANDLE);
+	if (handle != priv->handle) {
+		priv->handle = handle;
+		g_object_notify (G_OBJECT (contact), "handle");
+	}
 	g_object_unref (contact);
 }
 

Modified: trunk/libempathy/empathy-tp-contact-factory.c
==============================================================================
--- trunk/libempathy/empathy-tp-contact-factory.c	(original)
+++ trunk/libempathy/empathy-tp-contact-factory.c	Wed Apr 16 11:43:42 2008
@@ -223,6 +223,22 @@
 	if (error) {
 		empathy_debug (DEBUG_DOMAIN, "Error requesting aliases: %s",
 			      error->message);
+
+		/* If we failed to get alias set it to NULL, like that if
+		 * someone is waiting for the name to be ready it won't wait
+		 * infinitely */
+		while (*handles != 0) {
+			EmpathyContact *contact;
+
+			contact = tp_contact_factory_find_by_handle (
+				(EmpathyTpContactFactory*) tp_factory,
+				*handles);
+			if (contact) {
+				empathy_contact_set_name (contact, NULL);
+			}
+
+			handles++;
+		}
 		return;
 	}
 
@@ -601,7 +617,8 @@
 	/* FIXME: Sometimes the dbus call timesout because CM takes
 	 * too much time to request all aliases from the server,
 	 * that's why we increase the timeout here. See fd.o bug #14795 */
-	dup_handles = g_memdup (handles->data, handles->len * sizeof (guint));
+	dup_handles = g_malloc0 ((handles->len + 1) * sizeof (guint));
+	g_memmove (dup_handles, handles->data, handles->len * sizeof (guint));
 	tp_cli_connection_interface_aliasing_call_request_aliases (priv->connection,
 								   5*60*1000,
 								   handles,



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