--- a/libpurple/protocols/jabber/caps.c Sun Oct 02 07:13:45 2016 +0300
+++ b/libpurple/protocols/jabber/caps.c Sun Oct 02 08:13:03 2016 +0300
@@ -209,10 +209,11 @@
PurpleXmlNode *root = purple_xmlnode_new("capabilities");
g_hash_table_foreach(capstable, jabber_caps_store_client, root);
str = purple_xmlnode_to_formatted_str(root, &length);
purple_xmlnode_free(root);
- purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, length);
+ purple_util_write_data_to_cache_file(JABBER_CAPS_FILENAME, str, length); @@ -229,7 +230,7 @@
- PurpleXmlNode *capsdata = purple_util_read_xml_from_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache");
+ PurpleXmlNode *capsdata = purple_util_read_xml_from_cache_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache"); @@ -332,6 +333,7 @@
nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref);
capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, NULL, (GDestroyNotify)jabber_caps_client_info_destroy);
+ purple_move_to_xdg_base_dir(purple_cache_dir(), JABBER_CAPS_FILENAME); --- a/libpurple/util.c Sun Oct 02 07:13:45 2016 +0300
+++ b/libpurple/util.c Sun Oct 02 08:13:03 2016 +0300
@@ -48,47 +48,6 @@
static JsonNode *escape_js_node = NULL;
static JsonGenerator *escape_js_gen = NULL;
-move_to_xdg_base_dir(const char *purple_xdg_dir, char *name)
- gboolean xdg_path_exists;
- /* Check if destination dir exists, otherwise create it */
- xdg_path_exists = g_file_test(purple_xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
- if (!xdg_path_exists) {
- mkdir_res = purple_build_dir(purple_xdg_dir, S_IRWXU);
- purple_debug_error("util", "Error creating xdg directory %s: %s; failed migration\n",
- purple_xdg_dir, g_strerror(errno));
- xdg_path = g_build_filename(purple_xdg_dir, name, NULL);
- xdg_path_exists = g_file_test(xdg_path, G_FILE_TEST_EXISTS);
- if (!xdg_path_exists) {
- gboolean old_path_exists;
- old_path = g_build_filename(purple_user_dir(), name, NULL);
- old_path_exists = g_file_test(old_path, G_FILE_TEST_EXISTS);
- g_rename(old_path, xdg_path);
/* If legacy directory for libpurple exists, move it to location following
* xdg base dir spec. https://developer.pidgin.im/ticket/10029
@@ -101,9 +60,9 @@
legacy_purple_dir = purple_user_dir();
dir_exists = g_file_test(legacy_purple_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
- move_to_xdg_base_dir(purple_data_dir(), "certificates");
- move_to_xdg_base_dir(purple_cache_dir(), "icons");
- move_to_xdg_base_dir(purple_data_dir(), "logs");
+ purple_move_to_xdg_base_dir(purple_data_dir(), "certificates"); + purple_move_to_xdg_base_dir(purple_cache_dir(), "icons"); + purple_move_to_xdg_base_dir(purple_data_dir(), "logs"); @@ -3041,6 +3000,47 @@
+purple_move_to_xdg_base_dir(const char *purple_xdg_dir, char *path) + gboolean xdg_path_exists; + /* Check if destination dir exists, otherwise create it */ + xdg_path_exists = g_file_test(purple_xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); + if (!xdg_path_exists) { + mkdir_res = purple_build_dir(purple_xdg_dir, S_IRWXU); + purple_debug_error("util", "Error creating xdg directory %s: %s; failed migration\n", + purple_xdg_dir, g_strerror(errno)); + xdg_path = g_build_filename(purple_xdg_dir, path, NULL); + xdg_path_exists = g_file_test(xdg_path, G_FILE_TEST_EXISTS); + if (!xdg_path_exists) { + gboolean old_path_exists; + old_path = g_build_filename(purple_user_dir(), path, NULL); + old_path_exists = g_file_test(old_path, G_FILE_TEST_EXISTS); + g_rename(old_path, xdg_path); void purple_util_set_user_dir(const char *dir)
--- a/libpurple/util.h Sun Oct 02 07:13:45 2016 +0300
+++ b/libpurple/util.h Sun Oct 02 08:13:03 2016 +0300
@@ -824,6 +824,18 @@
const char *purple_data_dir(void);
+ * purple_move_to_xdg_base_dir: + * @purple_xdg_dir: The path to cache, config or data dir. + * Use respective function + * @path: File or directory in purple_user_dir + * Moves file or directory from legacy user dir to XDG +purple_move_to_xdg_base_dir(const char *purple_xdg_dir, char *path); * purple_util_set_user_dir:
* @dir: The custom settings directory