[gnome-panel] [panel] Understand bonobo IID in applet_iid keys



commit 42ac5abaa2c881c4645497e884facc4597fe3ded
Author: Vincent Untz <vuntz gnome org>
Date:   Tue Sep 7 00:01:19 2010 +0200

    [panel] Understand bonobo IID in applet_iid keys
    
    When fetching an applet IID from gconf, we were blindly assuming that
    applet_iid is always a dbus-style IID. This is wrong since there are
    still applets in the wild not migrated to the dbus library, and this
    applet_iid key can contain references to bonobo IID.
    
    So we always need to try to translate the IID we get to a current IID,
    as if it was an old IID before using it.
    
    Concretely, this will help people who added an applet from gnome-applets
    2.31.90 or earlier with gnome-panel 2.31.x, who then use gnome-applets
    2.31.90.1 (where applets were ported to dbus).

 gnome-panel/panel-compatibility.c |   53 ++++++++++++++++++++++++++++++------
 1 files changed, 44 insertions(+), 9 deletions(-)
---
diff --git a/gnome-panel/panel-compatibility.c b/gnome-panel/panel-compatibility.c
index b56db24..128143d 100644
--- a/gnome-panel/panel-compatibility.c
+++ b/gnome-panel/panel-compatibility.c
@@ -1107,26 +1107,61 @@ panel_compatibility_get_applet_iid (const gchar *id)
 	GConfClient *client = panel_gconf_get_client ();
 	PanelAppletInfo *info;
 	const char *key;
-	const char *iid;
 	gchar *applet_iid;
+	gboolean needs_migration;
+	const char *iid;
+
+	/*
+	 * There are two compatibility steps here:
+	 *
+	 * 1) we need to migrate from bonobo_iid to applet_iid if there's no
+	 *    value in the applet_iid key. Always.
+	 *
+	 * 2) we need to try to migrate the iid to a new iid. We can't assume
+	 *    that the fact that the applet_iid key was used mean anything
+	 *    since the value there could well be a bonobo iid.
+	 *    The reason we really have to try to migrate first is this case:
+	 *    if an applet was added with the bonobo iid but gets ported later
+	 *    to dbus, then the reference to the bonobo iid will only be valid
+	 *    as an old reference.
+	 *    And if migration fails, we just use the iid as it is.
+	 */
+
+	needs_migration = FALSE;
 
 	key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
 	applet_iid = gconf_client_get_string (client, key, NULL);
-	if (applet_iid && applet_iid[0])
-		return applet_iid;
 
-	key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
-	applet_iid = gconf_client_get_string (client, key, NULL);
-	if (!applet_iid || !applet_iid[0])
-		return NULL;
+	if (!applet_iid || !applet_iid[0]) {
+		needs_migration = TRUE;
+
+		key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
+		applet_iid = gconf_client_get_string (client, key, NULL);
+
+		if (!applet_iid || !applet_iid[0])
+			return NULL;
+	}
 
 	info = panel_applets_manager_get_applet_info_from_old_id (applet_iid);
 	if (!info)
+		info = panel_applets_manager_get_applet_info (applet_iid);
+
+	if (!info)
 		return NULL;
 
 	iid = panel_applet_info_get_iid (info);
-	key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
-	gconf_client_set_string (client, key, iid, NULL);
+
+	/* migrate if the iid in the configuration is different than the real
+	 * iid that will get used */
+	if (!g_str_equal (iid, applet_iid))
+		needs_migration = TRUE;
+
+	g_free (applet_iid);
+
+	if (needs_migration) {
+		key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
+		gconf_client_set_string (client, key, iid, NULL);
+	}
 
 	return g_strdup (iid);
 }



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