--- a/libpurple/prefs.c Wed Jun 15 21:59:51 2016 -0500
+++ b/libpurple/prefs.c Wed Jun 15 04:59:21 2016 -0300
@@ -40,6 +40,8 @@
+static PurplePrefsUiOps *prefs_ui_ops = NULL; @@ -79,6 +81,23 @@
static guint save_timer = 0;
static gboolean prefs_loaded = FALSE;
+#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 *
@@ -207,6 +226,8 @@
+ PURPLE_PREFS_UI_OP_CALL(save); node = prefs_to_xmlnode();
data = xmlnode_to_formatted_str(node, NULL);
purple_util_write_data_to_file("prefs.xml", data, -1);
@@ -225,6 +246,8 @@
schedule_prefs_save(void)
+ PURPLE_PREFS_UI_OP_CALL(schedule_save); save_timer = purple_timeout_add_seconds(5, save_cb, NULL);
@@ -376,12 +399,21 @@
- gchar *filename = g_build_filename(purple_user_dir(), "prefs.xml", NULL);
GMarkupParseContext *context;
+ PurplePrefsUiOps *uiop = purple_prefs_get_ui_ops(); + if (uiop && uiop->load) { + filename = g_build_filename(purple_user_dir(), "prefs.xml", NULL); @@ -605,13 +637,19 @@
purple_prefs_add_none(const char *name)
+ PURPLE_PREFS_UI_OP_CALL(add_none, name); add_pref(PURPLE_PREF_NONE, name);
purple_prefs_add_bool(const char *name, gboolean value)
- struct purple_pref *pref = add_pref(PURPLE_PREF_BOOLEAN, name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(add_bool, name, value); + pref = add_pref(PURPLE_PREF_BOOLEAN, name); @@ -622,7 +660,11 @@
purple_prefs_add_int(const char *name, int value)
- struct purple_pref *pref = add_pref(PURPLE_PREF_INT, name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(add_int, name, value); + pref = add_pref(PURPLE_PREF_INT, name); @@ -640,6 +682,8 @@
+ PURPLE_PREFS_UI_OP_CALL(add_string, name, value); pref = add_pref(PURPLE_PREF_STRING, name);
@@ -651,9 +695,13 @@
purple_prefs_add_string_list(const char *name, GList *value)
- struct purple_pref *pref = add_pref(PURPLE_PREF_STRING_LIST, name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(add_string_list, name, value); + pref = add_pref(PURPLE_PREF_STRING_LIST, name); @@ -670,7 +718,12 @@
purple_prefs_add_path(const char *name, const char *value)
- struct purple_pref *pref = add_pref(PURPLE_PREF_PATH, name);
+ 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); @@ -681,9 +734,14 @@
purple_prefs_add_path_list(const char *name, GList *value)
- struct purple_pref *pref = add_pref(PURPLE_PREF_PATH_LIST, name);
+ 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); @@ -740,7 +798,11 @@
purple_prefs_remove(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(remove, name); + pref = find_pref(name); @@ -781,6 +843,7 @@
do_callbacks(name, pref);
+/* this function is deprecated, so it doesn't get the new UI ops */ purple_prefs_set_generic(const char *name, gpointer value)
@@ -799,7 +862,11 @@
purple_prefs_set_bool(const char *name, gboolean value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(set_bool, name, value); + pref = find_pref(name); if(pref->type != PURPLE_PREF_BOOLEAN) {
@@ -820,7 +887,11 @@
purple_prefs_set_int(const char *name, int value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(set_int, name, value); + pref = find_pref(name); if(pref->type != PURPLE_PREF_INT) {
@@ -841,13 +912,17 @@
purple_prefs_set_string(const char *name, const char *value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; if(value != NULL && !g_utf8_validate(value, -1, NULL)) {
purple_debug_error("prefs", "purple_prefs_set_string: Cannot store invalid UTF8 for string pref %s\n", name);
+ PURPLE_PREFS_UI_OP_CALL(set_string, name, value); + pref = find_pref(name); if(pref->type != PURPLE_PREF_STRING && pref->type != PURPLE_PREF_PATH) {
purple_debug_error("prefs",
@@ -868,7 +943,12 @@
purple_prefs_set_string_list(const char *name, GList *value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(set_string_list, name, value); + pref = find_pref(name); @@ -903,7 +983,11 @@
purple_prefs_set_path(const char *name, const char *value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(set_string, name, value); + pref = find_pref(name); if(pref->type != PURPLE_PREF_PATH) {
@@ -925,7 +1009,12 @@
purple_prefs_set_path_list(const char *name, GList *value)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL(set_string_list, name, value); + pref = find_pref(name); @@ -956,7 +1045,11 @@
purple_prefs_exists(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(exists, name); + pref = find_pref(name); @@ -967,7 +1060,11 @@
purple_prefs_get_type(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_type, name); + pref = find_pref(name); @@ -978,7 +1075,11 @@
purple_prefs_get_bool(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_bool, name); + pref = find_pref(name); purple_debug_error("prefs",
@@ -996,7 +1097,11 @@
purple_prefs_get_int(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_int, name); + pref = find_pref(name); purple_debug_error("prefs",
@@ -1014,7 +1119,11 @@
purple_prefs_get_string(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_string, name); + pref = find_pref(name); purple_debug_error("prefs",
@@ -1032,9 +1141,13 @@
purple_prefs_get_string_list(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name); + pref = find_pref(name); purple_debug_error("prefs",
"purple_prefs_get_string_list: Unknown pref %s\n", name);
@@ -1055,7 +1168,11 @@
purple_prefs_get_path(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_string, name); + pref = find_pref(name); purple_debug_error("prefs",
@@ -1073,9 +1190,13 @@
purple_prefs_get_path_list(const char *name)
- struct purple_pref *pref = find_pref(name);
+ struct purple_pref *pref; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name); + pref = find_pref(name); purple_debug_error("prefs",
"purple_prefs_get_path_list: Unknown pref %s\n", name);
@@ -1166,6 +1287,8 @@
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 */
@@ -1188,6 +1311,8 @@
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 */
@@ -1323,9 +1448,13 @@
purple_prefs_get_children_names(const char *name)
- struct purple_pref *pref = find_pref(name), *child;
+ struct purple_pref *pref, *child; + PURPLE_PREFS_UI_OP_CALL_RETURN(get_children_names, name); + pref = find_pref(name); @@ -1451,8 +1580,7 @@
purple_timeout_remove(save_timer);
purple_prefs_disconnect_by_handle(purple_prefs_get_handle());
@@ -1463,3 +1591,15 @@
+purple_prefs_set_ui_ops(PurplePrefsUiOps *ops) +purple_prefs_get_ui_ops(void)