--- a/libpurple/prefs.c Tue Sep 20 02:44:44 2022 -0500
+++ b/libpurple/prefs.c Tue Sep 20 02:55:07 2022 -0500
@@ -37,8 +37,6 @@
-static PurplePrefsUiOps *prefs_ui_ops = NULL;
struct _PurplePrefCallbackData {
@@ -93,25 +91,6 @@
static GHashTable *prefs_hash = NULL;
static guint save_timer = 0;
static gboolean prefs_loaded = FALSE;
-static GSList *ui_callbacks = NULL;
-#define PURPLE_PREFS_UI_OP_CALL(member, ...) \
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops(); \
- if (uiop && uiop->member) { \
- uiop->member(__VA_ARGS__); \
-#define PURPLE_PREFS_UI_OP_CALL_RETURN(member, ...) \
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops(); \
- if (uiop && uiop->member) { \
- return uiop->member(__VA_ARGS__); \
/*********************************************************************
* Private utility functions *
@@ -240,8 +219,6 @@
- PURPLE_PREFS_UI_OP_CALL(save);
node = prefs_to_xmlnode();
data = purple_xmlnode_to_formatted_str(node, NULL);
purple_util_write_data_to_config_file("prefs.xml", data, -1);
@@ -260,8 +237,6 @@
schedule_prefs_save(void)
- PURPLE_PREFS_UI_OP_CALL(schedule_save);
save_timer = g_timeout_add_seconds(5, save_cb, NULL);
@@ -419,13 +394,6 @@
GMarkupParseContext *context;
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- if (uiop && uiop->load) {
filename = g_build_filename(purple_config_dir(), "prefs.xml", NULL);
@@ -644,8 +612,6 @@
purple_prefs_add_none(const char *name)
- PURPLE_PREFS_UI_OP_CALL(add_none, name);
add_pref(PURPLE_PREF_NONE, name);
@@ -654,8 +620,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(add_bool, name, value);
pref = add_pref(PURPLE_PREF_BOOLEAN, name);
@@ -669,8 +633,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(add_int, name, value);
pref = add_pref(PURPLE_PREF_INT, name);
@@ -689,8 +651,6 @@
- PURPLE_PREFS_UI_OP_CALL(add_string, name, value);
pref = add_pref(PURPLE_PREF_STRING, name);
@@ -705,8 +665,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(add_string_list, name, value);
pref = add_pref(PURPLE_PREF_STRING_LIST, name);
@@ -727,9 +685,6 @@
struct purple_pref *pref;
- /* re-use the string UI OP */
- PURPLE_PREFS_UI_OP_CALL(add_string, name, value);
pref = add_pref(PURPLE_PREF_PATH, name);
@@ -743,9 +698,6 @@
struct purple_pref *pref;
- /* re-use the string list UI OP */
- PURPLE_PREFS_UI_OP_CALL(add_string_list, name, value);
pref = add_pref(PURPLE_PREF_PATH_LIST, name);
@@ -831,8 +783,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(remove, name);
@@ -860,43 +810,10 @@
-do_ui_callbacks(const char *name)
- purple_debug_misc("prefs", "trigger callback %s\n", name);
- for (cbs = ui_callbacks; cbs; cbs = cbs->next) {
- PurplePrefCallbackData *cb = cbs->data;
- const char *cb_name = cb->name;
- size_t len = strlen(cb_name);
- if (!strncmp(cb_name, name, len) &&
- (name[len] == 0 || name[len] == '/' ||
- (len && name[len - 1] == '/'))) {
- /* This test should behave like this:
- * cb_name = /toto/tata --> true
- * cb_name = /toto/tatatiti --> false
- * cb_name = /toto --> true
- * cb_name = /toto/ --> true
- purple_prefs_trigger_callback_object(cbs->data);
purple_prefs_trigger_callback(const char *name)
struct purple_pref *pref;
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- if (uiop && uiop->connect_callback) {
@@ -915,8 +832,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(set_bool, name, value);
@@ -940,8 +855,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(set_int, name, value);
@@ -970,8 +883,6 @@
- PURPLE_PREFS_UI_OP_CALL(set_string, name, value);
@@ -996,8 +907,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(set_string_list, name, value);
@@ -1035,8 +944,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(set_string, name, value);
@@ -1061,8 +968,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL(set_string_list, name, value);
@@ -1089,8 +994,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(exists, name);
@@ -1104,8 +1007,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_type, name);
@@ -1119,8 +1020,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_bool, name);
@@ -1141,8 +1040,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_int, name);
@@ -1163,8 +1060,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_string, name);
@@ -1185,8 +1080,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name);
@@ -1207,8 +1100,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_string, name);
@@ -1229,8 +1120,6 @@
struct purple_pref *pref;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name);
@@ -1319,8 +1208,6 @@
struct purple_pref *oldpref, *newpref;
- PURPLE_PREFS_UI_OP_CALL(rename, oldname, newname);
oldpref = find_pref(oldname);
/* it's already been renamed, call off the dogs */
@@ -1343,8 +1230,6 @@
struct purple_pref *oldpref, *newpref;
- PURPLE_PREFS_UI_OP_CALL(rename_boolean_toggle, oldname, newname);
oldpref = find_pref(oldname);
/* it's already been renamed, call off the cats */
@@ -1390,19 +1275,13 @@
struct purple_pref *pref = NULL;
PurplePrefCallbackData *cb;
- PurplePrefsUiOps *uiop = NULL;
g_return_val_if_fail(name != NULL, 0);
g_return_val_if_fail(func != NULL, 0);
- uiop = purple_prefs_get_ui_ops();
- if (!(uiop && uiop->connect_callback)) {
- pref = find_pref(name);
- purple_debug_error("prefs", "purple_prefs_connect_callback: Unknown pref %s\n", name);
+ pref = find_pref(name); + purple_debug_error("prefs", "purple_prefs_connect_callback: Unknown pref %s\n", name); cb = g_new0(PurplePrefCallbackData, 1);
@@ -1413,75 +1292,15 @@
cb->name = g_strdup(name);
- if (uiop && uiop->connect_callback) {
- cb->ui_data = uiop->connect_callback(name, cb);
- if (cb->ui_data == NULL) {
- purple_debug_error("prefs", "purple_prefs_connect_callback: connect failed for %s\n", name);
- ui_callbacks = g_slist_append(ui_callbacks, cb);
- pref->callbacks = g_slist_append(pref->callbacks, cb);
+ pref->callbacks = g_slist_append(pref->callbacks, cb);
-purple_prefs_trigger_ui_callback_object(PurplePrefCallbackData *cb)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- gconstpointer value = NULL;
- PurplePrefType type = PURPLE_PREF_NONE;
- type = uiop->get_type(cb->name);
- value = GINT_TO_POINTER(uiop->get_int(cb->name));
- case PURPLE_PREF_BOOLEAN:
- value = GINT_TO_POINTER(uiop->get_bool(cb->name));
- case PURPLE_PREF_STRING:
- if (uiop->get_string) {
- value = uiop->get_string(cb->name);
- case PURPLE_PREF_STRING_LIST:
- case PURPLE_PREF_PATH_LIST:
- if (uiop->get_string_list) {
- value = uiop->get_string_list(cb->name);
- purple_debug_error("prefs", "Unexpected type = %i\n", type);
- cb->func(cb->name, type, value, cb->data);
purple_prefs_trigger_callback_object(PurplePrefCallbackData *cb)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- if (uiop && uiop->connect_callback && uiop->get_type) {
- purple_prefs_trigger_ui_callback_object(cb);
- purple_prefs_trigger_callback(cb->name);
+ purple_prefs_trigger_callback(cb->name); @@ -1511,35 +1330,10 @@
-disco_ui_callback_helper(guint callback_id)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- for (cbs = ui_callbacks; cbs; cbs = cbs->next) {
- PurplePrefCallbackData *cb = cbs->data;
- if (cb->id == callback_id) {
- uiop->disconnect_callback(cb->name, cb->ui_data);
- ui_callbacks = g_slist_delete_link(ui_callbacks, cbs);
purple_prefs_disconnect_callback(guint callback_id)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- if (uiop && uiop->disconnect_callback) {
- disco_ui_callback_helper(callback_id);
- disco_callback_helper(&prefs, callback_id);
+ disco_callback_helper(&prefs, callback_id); @@ -1567,40 +1361,12 @@
disco_callback_helper_handle(child, handle);
-disco_ui_callback_helper_handle(void *handle)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
- for (cbs = ui_callbacks; cbs; cbs = cbs->next) {
- PurplePrefCallbackData *cb = cbs->data;
- if (cb->handle != handle) {
- uiop->disconnect_callback(cb->name, cb->ui_data);
- ui_callbacks = g_slist_delete_link(ui_callbacks, cbs);
purple_prefs_disconnect_by_handle(void *handle)
- PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops();
g_return_if_fail(handle != NULL);
- if (uiop && uiop->disconnect_callback) {
- disco_ui_callback_helper_handle(handle);
- disco_callback_helper_handle(&prefs, handle);
+ disco_callback_helper_handle(&prefs, handle); @@ -1610,8 +1376,6 @@
struct purple_pref *pref, *child;
- PURPLE_PREFS_UI_OP_CALL_RETURN(get_children_names, name);
@@ -1745,15 +1509,3 @@
g_hash_table_destroy(prefs_hash);
-purple_prefs_set_ui_ops(PurplePrefsUiOps *ops)
-purple_prefs_get_ui_ops(void)