Merge commit 'upstream/master' into mc5
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Tue, 28 Jul 2009 09:20:27 +0000 (11:20 +0200)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Tue, 28 Jul 2009 09:20:27 +0000 (11:20 +0200)
Conflicts:
libempathy-gtk/empathy-account-widget.c
src/empathy.c

17 files changed:
1  2 
configure.ac
libempathy-gtk/Makefile.am
libempathy-gtk/empathy-account-chooser.c
libempathy-gtk/empathy-account-widget-irc.c
libempathy-gtk/empathy-contact-dialogs.c
libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-ui-utils.c
libempathy/empathy-chatroom-manager.c
libempathy/empathy-log-store-empathy.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-contact-list.c
megaphone/src/megaphone-applet.c
src/empathy-accounts-dialog.ui
src/empathy-chat-window.c
src/empathy-debug-dialog.c
src/empathy-main-window.c
src/empathy.c

diff --cc configure.ac
Simple merge
Simple merge
@@@ -429,9 -430,9 +429,9 @@@ empathy_account_widget_irc_new (Empathy
    gchar *filename;
  
    settings = g_slice_new0 (EmpathyAccountWidgetIrc);
 -  settings->account = g_object_ref (account);
 +  settings->settings = g_object_ref (account_settings);
  
-   dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+   dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
    g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
    user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL);
    g_free (dir);
Simple merge
Simple merge
Simple merge
  #include <string.h>
  #include <stdio.h>
  #include <stdlib.h>
+ /* FIXME: g_mapped_file_free has been deprecated in GLib 2.22, but the
+  * replacement symbol, g_mapped_file_unref is not available in older Glib
+  * and we're not ready to bump our version requirement just for this. When
+  * we're ready to bump our version requirement, just revert this patch. */
+ #undef G_DISABLE_DEPRECATED
  #include <glib/gstdio.h>
+ #define G_DISABLE_DEPRECATED
  
 +#include <telepathy-glib/util.h>
 +
  #include "empathy-log-store.h"
  #include "empathy-log-store-empathy.h"
  #include "empathy-log-manager.h"
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc src/empathy.c
@@@ -308,40 -321,67 +308,101 @@@ create_salut_account_if_needed (Empathy
        g_object_unref (book);
  }
  
 +static void
 +connection_managers_ready_cb (EmpathyConnectionManagers *managers,
 +      GParamSpec *spec, gpointer user_data)
 +{
 +      if (empathy_connection_managers_is_ready (managers))
 +              {
 +                      create_salut_account_if_needed (managers);
 +                      g_object_unref (managers);
 +                      managers = NULL;
 +              }
 +}
 +
 +static void
 +create_salut_account (void)
 +{
 +      EmpathyConnectionManagers *managers;
 +
 +      if (!should_create_salut_account ())
 +              return;
 +
 +      managers = empathy_connection_managers_dup_singleton ();
 +
 +      if (empathy_connection_managers_is_ready (managers))
 +              {
 +                      create_salut_account_if_needed (managers);
 +                      g_object_unref (managers);
 +              }
 +      else
 +              {
 +                      g_signal_connect (managers, "notify::ready",
 +                              G_CALLBACK (connection_managers_ready_cb), NULL);
 +              }
 +}
 +
+ static void
+ migrate_config_to_xdg_dir (void)
+ {
+       gchar *xdg_dir, *old_dir, *xdg_filename, *old_filename;
+       int i;
+       GFile *xdg_file, *old_file;
+       static const gchar* filenames[] = {
+               "geometry.ini",
+               "irc-networks.xml",
+               "chatrooms.xml",
+               "contact-groups.xml",
+               "status-presets.xml",
+               "accels.txt",
+               NULL
+       };
+       xdg_dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
+       if (g_file_test (xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               /* xdg config dir already exists */
+               g_free (xdg_dir);
+               return;
+       }
+       old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+       if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               /* old config dir didn't exist */
+               g_free (xdg_dir);
+               g_free (old_dir);
+               return;
+       }
+       if (g_mkdir_with_parents (xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) {
+               DEBUG ("Failed to create configuration directory; aborting migration");
+               g_free (xdg_dir);
+               g_free (old_dir);
+               return;
+       }
+       for (i = 0; filenames[i]; i++) {
+               old_filename = g_build_filename (old_dir, filenames[i], NULL);
+               if (!g_file_test (old_filename, G_FILE_TEST_EXISTS)) {
+                       g_free (old_filename);
+                       continue;
+               }
+               xdg_filename = g_build_filename (xdg_dir, filenames[i], NULL);
+               old_file = g_file_new_for_path (old_filename);
+               xdg_file = g_file_new_for_path (xdg_filename);
+               if (!g_file_move (old_file, xdg_file, G_FILE_COPY_NONE,
+                                 NULL, NULL, NULL, NULL)) {
+                       DEBUG ("Failed to migrate %s", filenames[i]);
+               }
+               g_free (old_filename);
+               g_free (xdg_filename);
+               g_object_unref (old_file);
+               g_object_unref (xdg_file);
+       }
+       g_free (xdg_dir);
+       g_free (old_dir);
+ }
  /* The code that handles single-instance and startup notification is
   * copied from gedit.
   *
@@@ -662,14 -695,13 +723,16 @@@ main (int argc, char *argv[]
        if (autoconnect && ! no_connect &&
                tp_connection_presence_type_cmp_availability (empathy_idle_get_state
                        (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) {
 -              empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
 +              empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
        }
  
 +      /* account management */
 +      account_manager = empathy_account_manager_dup_singleton ();
 +      g_signal_connect (account_manager, "notify::ready",
 +              G_CALLBACK (account_manager_ready_cb), NULL);
  
 -      create_salut_account ();
+       migrate_config_to_xdg_dir ();
        /* Setting up UI */
        window = empathy_main_window_show ();
        icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);