diff -r e0a388ced476 libpurple/buddyicon.c
--- a/libpurple/buddyicon.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/buddyicon.c	Sun May 19 16:27:54 2013 -0400
@@ -1048,13 +1048,13 @@
 	g_return_if_fail(dir != NULL);
 
 	g_free(cache_dir);
-	cache_dir = g_strdup(dir);
+	cache_dir = g_build_filename(g_get_user_cache_dir(), "purple", "icons", NULL);
 }
 
 const char *
 purple_buddy_icons_get_cache_dir(void)
 {
-	return cache_dir;
+	return g_build_filename(g_get_user_cache_dir(), "purple", "icons", NULL);
 }
 
 void *
diff -r e0a388ced476 libpurple/certificate.c
--- a/libpurple/certificate.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/certificate.c	Sun May 19 16:27:54 2013 -0400
@@ -508,7 +508,7 @@
 	esc_name = g_strdup(purple_escape_filename(pool->name));
 	esc_id = id ? g_strdup(purple_escape_filename(id)) : NULL;
 
-	path = g_build_filename(purple_user_dir(),
+	path = g_build_filename(g_get_user_cache_dir(), "purple",
 				"certificates", /* TODO: constantize this? */
 				esc_scheme_name,
 				esc_name,
diff -r e0a388ced476 libpurple/plugins/autoaccept.c
--- a/libpurple/plugins/autoaccept.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/plugins/autoaccept.c	Sun May 19 16:27:54 2013 -0400
@@ -346,7 +346,7 @@
 init_plugin(PurplePlugin *plugin) {
 	char *dirname;
 
-	dirname = g_build_filename(purple_user_dir(), "autoaccept", NULL);
+	dirname = g_build_filename(g_get_user_data_dir(), "pidgin", "autoaccept", NULL);
 	purple_prefs_add_none(PREF_PREFIX);
 	purple_prefs_add_string(PREF_PATH, dirname);
 	purple_prefs_add_bool(PREF_NOTIFY, TRUE);
diff -r e0a388ced476 libpurple/prefs.c
--- a/libpurple/prefs.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/prefs.c	Sun May 19 16:27:54 2013 -0400
@@ -375,7 +375,7 @@
 gboolean
 purple_prefs_load()
 {
-	gchar *filename = g_build_filename(purple_user_dir(), "prefs.xml", NULL);
+	gchar *filename=g_build_filename(g_get_user_config_dir(), "purple", "prefs.xml", NULL);
 	gchar *contents = NULL;
 	gsize length;
 	GMarkupParseContext *context;
@@ -401,7 +401,7 @@
 		filename = g_build_filename(common_appdata ? common_appdata : "", "purple", "prefs.xml", NULL);
 		g_free(common_appdata);
 #else
-		filename = g_build_filename(SYSCONFDIR, "purple", "prefs.xml", NULL);
+		filename = g_build_filename(g_get_user_config_dir(), "purple", "prefs.xml", NULL);
 #endif
 
 		purple_debug_info("prefs", "Reading %s\n", filename);
diff -r e0a388ced476 libpurple/theme-manager.c
--- a/libpurple/theme-manager.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/theme-manager.c	Sun May 19 16:27:54 2013 -0400
@@ -154,17 +154,8 @@
 	g_hash_table_foreach_remove(theme_table, (GHRFunc)check_if_theme_or_loader,
 	                            &loaders);
 
-	/* Add themes from ~/.purple */
-	path = g_build_filename(purple_user_dir(), "themes", NULL);
-	purple_theme_manager_build_dir(loaders, path);
-	g_free(path);
-
-	/* look for XDG_DATA_HOME.  If we don't have it use ~/.local, and add it */
-	if ((xdg = g_getenv("XDG_DATA_HOME")) != NULL)
-		path = g_build_filename(xdg, "themes", NULL);
-	else
-		path = g_build_filename(purple_home_dir(), ".local", "themes", NULL);
-
+	/* Add themes from xdg config base dir */
+	path = g_build_filename(g_get_user_config_dir(),"purple","themes", NULL);
 	purple_theme_manager_build_dir(loaders, path);
 	g_free(path);
 
diff -r e0a388ced476 libpurple/util.c
--- a/libpurple/util.c	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/util.c	Sun May 19 16:27:54 2013 -0400
@@ -48,6 +48,57 @@
 static JsonNode *escape_js_node = NULL;
 static JsonGenerator *escape_js_gen = NULL;
 
+/* If legacy directory for libpurple exists, move it to location following 
+* xdg base dir spec. https://developer.pidgin.im/ticket/10029 */
+void
+move_to_xdg_base_dir()
+{     
+	char *legacydir;
+	char *purpledatadir;
+	char *legacycertsdir;
+	char *certsdir;
+	char *legacyiconsdir;
+	char *iconsdir;
+	char *legacyprefs;
+	char *prefs;
+	
+	legacydir=g_build_filename(g_get_home_dir (), ".purple", NULL);
+	purpledatadir= g_build_filename(g_get_user_data_dir (), "purple", NULL);
+	legacycertsdir=g_build_filename(legacydir, "certificates", NULL);
+	certsdir= g_build_filename(g_get_user_cache_dir (), "purple","certificates", NULL);
+	legacyiconsdir=g_build_filename(legacydir, "icons", NULL);
+	iconsdir= g_build_filename(g_get_user_cache_dir (), "purple","icons", NULL);
+	legacyprefs=g_build_filename(g_get_home_dir (), ".purple", "prefs.xml", NULL);
+	prefs=g_build_filename(g_get_user_config_dir(), "purple", "prefs.xml", NULL);
+	
+    	g_rename(legacycertsdir, certsdir);
+    	g_rename(legacyiconsdir, iconsdir);
+
+	g_print("%s \n", legacyprefs);
+        g_print("%s \n", prefs);
+        g_rename(legacyprefs, prefs);	
+	
+	g_print("%s \n", legacydir);
+        g_print("%s \n", purpledatadir);
+	g_rename(legacydir, purpledatadir);
+    
+    	g_free(legacycertsdir);
+	legacycertsdir=NULL;
+	g_free(certsdir);
+	certsdir=NULL;
+	
+	g_free(legacyiconsdir);
+	legacyiconsdir=NULL;
+	g_free(iconsdir);
+	iconsdir=NULL;
+    
+    	g_free(legacydir);
+	legacydir=NULL;
+	g_free(purpledatadir);
+	purpledatadir=NULL;
+ 	
+}
+
 PurpleMenuAction *
 purple_menu_action_new(const char *label, PurpleCallback callback, gpointer data,
                      GList *children)
@@ -128,9 +179,15 @@
 void
 purple_util_init(void)
 {
+	char *legacypurpledir;
+	legacypurpledir=g_build_filename(g_get_home_dir (), ".purple", NULL);
 	escape_js_node = json_node_new(JSON_NODE_VALUE);
 	escape_js_gen = json_generator_new();
 	json_node_set_boolean(escape_js_node, FALSE);
+	if(g_file_test(legacypurpledir, G_FILE_TEST_IS_DIR))
+			move_to_xdg_base_dir();
+	g_free(legacypurpledir);
+	legacypurpledir=NULL;
 }
 
 void
@@ -149,6 +206,7 @@
 
 	g_object_unref(escape_js_gen);
 	escape_js_gen = NULL;
+	
 }
 
 /**************************************************************************
@@ -2891,8 +2949,9 @@
 const char *
 purple_home_dir(void)
 {
+/* In Linux, this returns the data directory instead. Not been renamed to preserve D-Bus binding semantics*/
 #ifndef _WIN32
-	return g_get_home_dir();
+	return g_get_user_data_dir();
 #else
 	return wpurple_data_dir();
 #endif
@@ -2905,7 +2964,7 @@
 	if (custom_user_dir != NULL)
 		return custom_user_dir;
 	else if (!user_dir)
-		user_dir = g_build_filename(purple_home_dir(), ".purple", NULL);
+		user_dir = g_build_filename(purple_home_dir(), "purple", NULL);
 
 	return user_dir;
 }
@@ -2933,27 +2992,28 @@
 gboolean
 purple_util_write_data_to_file(const char *filename, const char *data, gssize size)
 {
-	const char *user_dir = purple_user_dir();
+	const char *dirname;
 	gchar *filename_full;
 	gboolean ret = FALSE;
-
+	dirname = purple_user_dir();
+	
 	g_return_val_if_fail(user_dir != NULL, FALSE);
 
 	purple_debug_info("util", "Writing file %s to directory %s\n",
 					filename, user_dir);
 
 	/* Ensure the user directory exists */
-	if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR))
+	if (!g_file_test(dirname, G_FILE_TEST_IS_DIR))
 	{
-		if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
+		if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
 		{
 			purple_debug_error("util", "Error creating directory %s: %s\n",
-							 user_dir, g_strerror(errno));
+							 dirname, g_strerror(errno));
 			return FALSE;
 		}
 	}
 
-	filename_full = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", user_dir, filename);
+	filename_full = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, filename);
 
 	ret = purple_util_write_data_to_file_absolute(filename_full, data, size);
 
diff -r e0a388ced476 libpurple/util.h
--- a/libpurple/util.h	Sat May 18 20:49:29 2013 +0200
+++ b/libpurple/util.h	Sun May 19 16:27:54 2013 -0400
@@ -64,6 +64,12 @@
 
 G_BEGIN_DECLS
 
+/** Move files to xdg base dir
+*
+* 
+*/
+void move_to_xdg_base_dir(void);
+
 /**
  * Creates a new PurpleMenuAction.
  *
