Remove a bunch of unused and unnecessary preferences code

Tue, 15 Jul 2025 03:10:33 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 15 Jul 2025 03:10:33 -0500
changeset 43288
2865cd340992
parent 43287
1de854696dfc
child 43289
b39dbed64dc0

Remove a bunch of unused and unnecessary preferences code

Testing Done:
Verified startup and shutdown worked fine, that there were no issues opening the preferences dialog, and called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/4066/

libpurple/prefs.c file | annotate | diff | comparison | revisions
libpurple/prefs.h file | annotate | diff | comparison | revisions
pidgin/prefs/pidginprefs.c file | annotate | diff | comparison | revisions
--- a/libpurple/prefs.c	Tue Jul 15 00:49:09 2025 -0500
+++ b/libpurple/prefs.c	Tue Jul 15 03:10:33 2025 -0500
@@ -772,12 +772,12 @@
 	free_pref(pref);
 }
 
-void
-purple_prefs_remove(const char *name)
+static void
+purple_prefs_destroy(void)
 {
 	struct purple_pref *pref;
 
-	pref = find_pref(name);
+	pref = find_pref("/");
 
 	if(!pref)
 		return;
@@ -785,12 +785,6 @@
 	remove_pref(pref);
 }
 
-void
-purple_prefs_destroy(void)
-{
-	purple_prefs_remove("/");
-}
-
 static void
 do_callbacks(const char* name, struct purple_pref *pref)
 {
@@ -1128,140 +1122,6 @@
 	                        (GCopyFunc)(GCallback)g_strdup, NULL);
 }
 
-static void
-purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpref)
-{
-	struct purple_pref *child, *next;
-	char *oldname, *newname;
-
-	/* if we're a parent, rename the kids first */
-	for(child = oldpref->first_child; child != NULL; child = next)
-	{
-		struct purple_pref *newchild;
-		next = child->sibling;
-		for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling)
-		{
-			if(purple_strequal(child->name, newchild->name))
-			{
-				purple_prefs_rename_node(child, newchild);
-				break;
-			}
-		}
-		if(newchild == NULL) {
-			/* no rename happened, we weren't able to find the new pref */
-			char *tmpname = pref_full_name(child);
-			purple_debug_error("prefs", "Unable to find rename pref for %s\n", tmpname);
-			g_free(tmpname);
-		}
-	}
-
-	oldname = pref_full_name(oldpref);
-	newname = pref_full_name(newpref);
-
-	if (oldpref->type != newpref->type)
-	{
-		purple_debug_error("prefs", "Unable to rename %s to %s: differing types\n", oldname, newname);
-		g_free(oldname);
-		g_free(newname);
-		return;
-	}
-
-	purple_debug_info("prefs", "Renaming %s to %s\n", oldname, newname);
-	g_free(oldname);
-
-	switch(oldpref->type) {
-		case PURPLE_PREF_NONE:
-			break;
-		case PURPLE_PREF_BOOLEAN:
-			purple_prefs_set_bool(newname, oldpref->value.boolean);
-			break;
-		case PURPLE_PREF_INT:
-			purple_prefs_set_int(newname, oldpref->value.integer);
-			break;
-		case PURPLE_PREF_STRING:
-			purple_prefs_set_string(newname, oldpref->value.string);
-			break;
-		case PURPLE_PREF_STRING_LIST:
-			purple_prefs_set_string_list(newname, oldpref->value.stringlist);
-			break;
-		case PURPLE_PREF_PATH:
-			purple_prefs_set_path(newname, oldpref->value.string);
-			break;
-		case PURPLE_PREF_PATH_LIST:
-			purple_prefs_set_path_list(newname, oldpref->value.stringlist);
-			break;
-	}
-	g_free(newname);
-
-	remove_pref(oldpref);
-}
-
-void
-purple_prefs_rename(const char *oldname, const char *newname)
-{
-	struct purple_pref *oldpref, *newpref;
-
-	oldpref = find_pref(oldname);
-
-	/* it's already been renamed, call off the dogs */
-	if(!oldpref)
-		return;
-
-	newpref = find_pref(newname);
-
-	if (newpref == NULL)
-	{
-		purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname);
-		return;
-	}
-
-	purple_prefs_rename_node(oldpref, newpref);
-}
-
-void
-purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname)
-{
-		struct purple_pref *oldpref, *newpref;
-
-		oldpref = find_pref(oldname);
-
-		/* it's already been renamed, call off the cats */
-		if(!oldpref)
-			return;
-
-		if (oldpref->type != PURPLE_PREF_BOOLEAN)
-		{
-			purple_debug_error("prefs", "Unable to rename %s to %s: old pref not a boolean\n", oldname, newname);
-			return;
-		}
-
-		if (oldpref->first_child != NULL) /* can't rename parents */
-		{
-			purple_debug_error("prefs", "Unable to rename %s to %s: can't rename parents\n", oldname, newname);
-			return;
-		}
-
-
-		newpref = find_pref(newname);
-
-		if (newpref == NULL)
-		{
-			purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname);
-			return;
-		}
-
-		if (oldpref->type != newpref->type)
-		{
-			purple_debug_error("prefs", "Unable to rename %s to %s: differing types\n", oldname, newname);
-			return;
-		}
-
-		purple_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname);
-		purple_prefs_set_bool(newname, !(oldpref->value.boolean));
-
-		remove_pref(oldpref);
-}
-
 guint
 purple_prefs_connect_callback(void *handle, const char *name, PurplePrefCallback func, gpointer data)
 {
@@ -1362,64 +1222,7 @@
 	disco_callback_helper_handle(&prefs, handle);
 }
 
-GList *
-purple_prefs_get_children_names(const char *name)
-{
-	GList * list = NULL;
-	struct purple_pref *pref, *child;
-	char sep[2] = "\0\0";;
-
-	pref = find_pref(name);
-
-	if (pref == NULL)
-		return NULL;
-
-	if (name[strlen(name) - 1] != '/')
-		sep[0] = '/';
-	for (child = pref->first_child; child; child = child->sibling) {
-		list = g_list_append(list, g_strdup_printf("%s%s%s", name, sep, child->name));
-	}
-	return list;
-}
-
-static void
-prefs_update_old(void)
-{
-	purple_prefs_rename("/core", "/purple");
-
-	/* Remove some no-longer-used prefs */
-	purple_prefs_remove("/purple/away/auto_response/enabled");
-	purple_prefs_remove("/purple/away/auto_response/idle_only");
-	purple_prefs_remove("/purple/away/auto_response/in_active_conv");
-	purple_prefs_remove("/purple/away/auto_response/sec_before_resend");
-	purple_prefs_remove("/purple/away/auto_response");
-	purple_prefs_remove("/purple/away/default_message");
-	purple_prefs_remove("/purple/buddies/use_server_alias");
-	purple_prefs_remove("/purple/conversations/away_back_on_send");
-	purple_prefs_remove("/purple/conversations/send_urls_as_links");
-	purple_prefs_remove("/purple/conversations/im/show_login");
-	purple_prefs_remove("/purple/conversations/chat/show_join");
-	purple_prefs_remove("/purple/conversations/chat/show_leave");
-	purple_prefs_remove("/purple/conversations/combine_chat_im");
-	purple_prefs_remove("/purple/conversations/use_alias_for_title");
-	purple_prefs_remove("/purple/debug/timestamps");
-	purple_prefs_remove("/purple/logging/log_signon_signoff");
-	purple_prefs_remove("/purple/logging/log_idle_state");
-	purple_prefs_remove("/purple/logging/log_away_state");
-	purple_prefs_remove("/purple/logging/log_own_states");
-	purple_prefs_remove("/purple/sound/while_away");
-	purple_prefs_remove("/purple/sound/while_status");
-	purple_prefs_remove("/purple/sound");
-	purple_prefs_remove("/purple/status/scores/hidden");
-	purple_prefs_remove("/plugins/core/autorecon/hide_connected_error");
-	purple_prefs_remove("/plugins/core/autorecon/hide_connecting_error");
-	purple_prefs_remove("/plugins/core/autorecon/hide_reconnecting_dialog");
-	purple_prefs_remove("/plugins/core/autorecon/restore_state");
-	purple_prefs_remove("/plugins/core/autorecon");
-	purple_prefs_remove("/plugins/lopl");
-}
-
-void *
+static void *
 purple_prefs_get_handle(void)
 {
 	static int handle;
@@ -1453,12 +1256,8 @@
 	/* Contact Priority Settings */
 	purple_prefs_add_none("/purple/contact");
 	purple_prefs_add_bool("/purple/contact/last_match", FALSE);
-	purple_prefs_remove("/purple/contact/offline_score");
-	purple_prefs_remove("/purple/contact/away_score");
-	purple_prefs_remove("/purple/contact/idle_score");
 
 	purple_prefs_load();
-	prefs_update_old();
 }
 
 void
--- a/libpurple/prefs.h	Tue Jul 15 00:49:09 2025 -0500
+++ b/libpurple/prefs.h	Tue Jul 15 03:10:33 2025 -0500
@@ -96,18 +96,6 @@
 /**************************************************************************/
 
 /**
- * purple_prefs_get_handle:
- *
- * Returns the prefs subsystem handle.
- *
- * Returns: The prefs subsystem handle.
- *
- * Since: 2.0
- */
-PURPLE_AVAILABLE_IN_ALL
-void *purple_prefs_get_handle(void);
-
-/**
  * purple_prefs_init:
  *
  * Initialize core prefs
@@ -218,52 +206,6 @@
 PURPLE_AVAILABLE_IN_ALL
 void purple_prefs_add_path_list(const char *name, GList *value);
 
-
-/**
- * purple_prefs_remove:
- * @name: The name of the pref
- *
- * Remove a pref.
- *
- * Since: 2.0
- */
-PURPLE_AVAILABLE_IN_ALL
-void purple_prefs_remove(const char *name);
-
-/**
- * purple_prefs_rename:
- * @oldname: The old name of the pref
- * @newname: The new name for the pref
- *
- * Rename a pref
- *
- * Since: 2.0
- */
-PURPLE_AVAILABLE_IN_ALL
-void purple_prefs_rename(const char *oldname, const char *newname);
-
-/**
- * purple_prefs_rename_boolean_toggle:
- * @oldname: The old name of the pref
- * @newname: The new name for the pref
- *
- * Rename a boolean pref, toggling it's value
- *
- * Since: 2.0
- */
-PURPLE_AVAILABLE_IN_ALL
-void purple_prefs_rename_boolean_toggle(const char *oldname, const char *newname);
-
-/**
- * purple_prefs_destroy:
- *
- * Remove all prefs.
- *
- * Since: 2.0
- */
-PURPLE_AVAILABLE_IN_ALL
-void purple_prefs_destroy(void);
-
 /**
  * purple_prefs_set_bool:
  * @name:  The name of the pref
@@ -442,22 +384,6 @@
 GList *purple_prefs_get_path_list(const char *name);
 
 /**
- * purple_prefs_get_children_names:
- * @name: The parent pref
- *
- * Returns a list of children for a pref
- *
- * Returns: (transfer full) (element-type utf8): A list of newly allocated
- *          strings denoting the names of the children. Returns %NULL if there
- *          are no children or if pref doesn't exist. The caller must free all
- *          the strings and the list.
- *
- * Since: 2.1
- */
-PURPLE_AVAILABLE_IN_2_1
-GList *purple_prefs_get_children_names(const char *name);
-
-/**
  * purple_prefs_connect_callback:
  * @handle:   The handle of the receiver.
  * @name:     The name of the preference
--- a/pidgin/prefs/pidginprefs.c	Tue Jul 15 00:49:09 2025 -0500
+++ b/pidgin/prefs/pidginprefs.c	Tue Jul 15 03:10:33 2025 -0500
@@ -131,144 +131,4 @@
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/vvconfig/video");
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/vvconfig/video/sink");
 	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/vvconfig/video/sink/device", "");
-
-	pidgin_prefs_update_old();
 }
-
-void
-pidgin_prefs_update_old(void)
-{
-	const gchar *video_sink = NULL;
-
-	/* Rename some old prefs */
-	purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise");
-
-	purple_prefs_rename_boolean_toggle(PIDGIN_PREFS_ROOT "/conversations/ignore_colors",
-									 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting");
-
-	/* Remove some no-longer-used prefs */
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/auto_expand_contacts");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/button_style");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/grey_idle_buddies");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/raise_on_events");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_group_count");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/show_warning_level");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/x");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/blist/y");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/browser");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/command");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/place");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/manual_command");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/button_type");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ctrl_enter_sends");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/enter_sends");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/escape_closes");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/html_shortcuts");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/icons_on_tabs");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/send_formatting");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/show_urls_as_links");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_bgcolor");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_fgcolor");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_font");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/use_custom_size");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/old_tab_complete");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/tab_completion");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/hide_on_send");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/color_nicks");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/raise_on_events");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_fonts");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_font_sizes");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/passthrough_unknown_commands");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/debug/timestamps");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/idle");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/signon");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/silent_signon");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/command");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/conv_focus");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/chat_msg_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/first_im_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/im_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/join_chat");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/left_chat");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/login");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/logout");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/send_chat_msg");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/send_im");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/enabled");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/first_im_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/got_attention");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/im_recv");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/join_chat");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/left_chat");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/login");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/logout");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/nick_said");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/pounce_default");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/send_chat_msg");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/send_im");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file/sent_attention");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/file");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/method");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/mute");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/theme");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound");
-
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/away/queue_messages");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/away");
-	purple_prefs_remove("/plugins/gtk/docklet/queue_messages");
-
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_width");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat/default_height");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_width");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im/default_height");
-	purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/x",
-			PIDGIN_PREFS_ROOT "/conversations/im/x");
-	purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/y",
-			PIDGIN_PREFS_ROOT "/conversations/im/y");
-
-	/* Fixup vvconfig plugin prefs */
-	if (purple_prefs_exists("/plugins/core/vvconfig/audio/src/device")) {
-		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/vvconfig/audio/src/device",
-				purple_prefs_get_string("/plugins/core/vvconfig/audio/src/device"));
-	}
-	if (purple_prefs_exists("/plugins/core/vvconfig/audio/sink/device")) {
-		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/vvconfig/audio/sink/device",
-				purple_prefs_get_string("/plugins/core/vvconfig/audio/sink/device"));
-	}
-	if (purple_prefs_exists("/plugins/core/vvconfig/video/src/device")) {
-		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/vvconfig/video/src/device",
-				purple_prefs_get_string("/plugins/core/vvconfig/video/src/device"));
-	}
-	if (purple_prefs_exists("/plugins/gtk/vvconfig/video/sink/device")) {
-		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/vvconfig/video/sink/device",
-				purple_prefs_get_string("/plugins/gtk/vvconfig/video/sink/device"));
-	}
-
-	video_sink = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/vvconfig/video/sink/device");
-	if (purple_strequal(video_sink, "glimagesink") || purple_strequal(video_sink, "directdrawsink")) {
-		/* Accelerated sinks move to GTK GL. */
-		/* video_sink = "gtkglsink"; */
-		/* FIXME: I haven't been able to get gtkglsink to work yet: */
-		video_sink = "gtksink";
-	} else {
-		/* Everything else, including default will be moved to GTK sink. */
-		video_sink = "gtksink";
-	}
-	purple_prefs_set_string(PIDGIN_PREFS_ROOT "/vvconfig/video/sink/device", video_sink);
-
-	purple_prefs_remove("/plugins/core/vvconfig");
-	purple_prefs_remove("/plugins/gtk/vvconfig");
-
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/vvconfig/audio/src/plugin");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/vvconfig/audio/sink/plugin");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/vvconfig/video/src/plugin");
-	purple_prefs_remove(PIDGIN_PREFS_ROOT "/vvconfig/video/sink/plugin");
-}
-

mercurial