aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile.am8
-rw-r--r--src/cc-empathy-accounts-page.c35
-rw-r--r--src/cc-empathy-accounts-page.h1
-rw-r--r--src/cc-empathy-accounts-panel.c26
-rw-r--r--src/empathy-account-assistant.c5
-rw-r--r--src/empathy-accounts-dialog.c2
-rw-r--r--src/empathy-accounts.c2
-rw-r--r--src/empathy-call-window.c13
-rw-r--r--src/empathy-chat-window.c6
-rw-r--r--src/empathy-debugger.c50
-rw-r--r--src/empathy-invite-participant-dialog.c7
-rw-r--r--src/empathy-invite-participant-dialog.h3
-rw-r--r--src/empathy-main-window.c53
-rw-r--r--src/empathy-map-view.c4
-rw-r--r--src/empathy-migrate-butterfly-logs.c213
-rw-r--r--src/empathy-migrate-butterfly-logs.h32
-rw-r--r--src/empathy-status-icon.c2
18 files changed, 438 insertions, 25 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 082f7cdd4..cf52a9c68 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -2,3 +2,4 @@ empathy
empathy-accounts
empathy-chat-chandler
empathy-call-chandler
+empathy-debugger
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f8d15733..a01b759a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,6 +81,7 @@ endif
bin_PROGRAMS = \
empathy \
empathy-accounts \
+ empathy-debugger \
$(NULL)
BUILT_SOURCES=
@@ -94,17 +95,22 @@ empathy_accounts_LDADD = \
libempathy-accounts-common.la \
$(NULL)
+empathy_debugger_SOURCES = \
+ empathy-debug-window.c empathy-debug-window.h \
+ empathy-debugger.c \
+ $(NULL)
+
empathy_handwritten_source = \
empathy-about-dialog.c empathy-about-dialog.h \
empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \
empathy-call-window.c empathy-call-window.h \
empathy-chat-window.c empathy-chat-window.h \
empathy-chatrooms-window.c empathy-chatrooms-window.h \
- empathy-debug-window.c empathy-debug-window.h \
empathy-event-manager.c empathy-event-manager.h \
empathy-ft-manager.c empathy-ft-manager.h \
empathy-invite-participant-dialog.c empathy-invite-participant-dialog.h \
empathy-main-window.c empathy-main-window.h \
+ empathy-migrate-butterfly-logs.c empathy-migrate-butterfly-logs.h \
empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \
empathy-preferences.c empathy-preferences.h \
empathy-sidebar.c empathy-sidebar.h \
diff --git a/src/cc-empathy-accounts-page.c b/src/cc-empathy-accounts-page.c
index 383e20d41..48330f6f0 100644
--- a/src/cc-empathy-accounts-page.c
+++ b/src/cc-empathy-accounts-page.c
@@ -32,6 +32,9 @@
#include <libempathy/empathy-connection-managers.h>
#include <libempathy-gtk/empathy-ui-utils.h>
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
#include "cc-empathy-accounts-page.h"
#include "empathy-accounts-common.h"
#include "empathy-account-assistant.h"
@@ -45,6 +48,8 @@ struct CcEmpathyAccountsPagePrivate
* destroyed in our finalize(), since it invalidates its children (even if
* they've already been reparented by the time it is destroyed) */
GtkWidget *accounts_window;
+
+ GtkWidget *assistant;
};
G_DEFINE_TYPE (CcEmpathyAccountsPage, cc_empathy_accounts_page, CC_TYPE_PAGE)
@@ -87,6 +92,9 @@ account_assistant_closed_cb (GtkWidget *widget,
empathy_account_dialog_cancel (
EMPATHY_ACCOUNTS_DIALOG (page->priv->accounts_window));
}
+
+ gtk_widget_set_sensitive (GTK_WIDGET (page), TRUE);
+ page->priv->assistant = NULL;
}
static void
@@ -112,10 +120,14 @@ connection_managers_prepare (GObject *source,
if (!empathy_accounts_has_non_salut_accounts (account_mgr))
{
- GtkWidget *w;
- w = empathy_account_assistant_show (NULL, cm_mgr);
+ GtkWindow *parent;
- empathy_signal_connect_weak (w, "hide",
+ parent = empathy_get_toplevel_window (GTK_WIDGET (page));
+ page->priv->assistant = empathy_account_assistant_show (parent, cm_mgr);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (page), FALSE);
+
+ empathy_signal_connect_weak (page->priv->assistant, "hide",
G_CALLBACK (account_assistant_closed_cb),
G_OBJECT (page));
}
@@ -172,6 +184,8 @@ active_changed (CcPage *base_page,
CcEmpathyAccountsPage *page = CC_EMPATHY_ACCOUNTS_PAGE (base_page);
TpAccountManager *account_manager;
+ DEBUG ("%s: active = %i", G_STRLOC, is_active);
+
if (is_active)
{
/* unref'd in final endpoint callbacks */
@@ -232,3 +246,18 @@ cc_empathy_accounts_page_new (void)
return CC_PAGE (object);
}
+
+void
+cc_empathy_accounts_page_destroy_dialogs (CcEmpathyAccountsPage *self)
+{
+ /* This function is really kludgey, it is called by the AccountPanel to
+ * remove any child dialogs (i.e. this assistant). I personally feel this
+ * would be better in active_changed, but the Page doesn't seem to receive
+ * that signal when the panel does. */
+
+ if (self->priv->assistant != NULL)
+ {
+ DEBUG ("Destroying assistant");
+ gtk_widget_destroy (self->priv->assistant);
+ }
+}
diff --git a/src/cc-empathy-accounts-page.h b/src/cc-empathy-accounts-page.h
index 7c360874e..4139a33f8 100644
--- a/src/cc-empathy-accounts-page.h
+++ b/src/cc-empathy-accounts-page.h
@@ -48,6 +48,7 @@ typedef struct
GType cc_empathy_accounts_page_get_type (void);
CcPage* cc_empathy_accounts_page_new (void);
+void cc_empathy_accounts_page_destroy_dialogs (CcEmpathyAccountsPage *self);
G_END_DECLS
diff --git a/src/cc-empathy-accounts-panel.c b/src/cc-empathy-accounts-panel.c
index 63500e66c..d69325b7b 100644
--- a/src/cc-empathy-accounts-panel.c
+++ b/src/cc-empathy-accounts-panel.c
@@ -28,6 +28,9 @@
#include <gconf/gconf-client.h>
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
#include "cc-empathy-accounts-panel.h"
#include "cc-empathy-accounts-page.h"
@@ -55,6 +58,24 @@ setup_panel (CcEmpathyAccountsPanel *panel)
NULL);
}
+static void
+cc_empathy_accounts_panel_active_changed (CcPanel *self,
+ gboolean is_active)
+{
+ DEBUG ("%s: active = %i", G_STRLOC, is_active);
+
+ if (!is_active)
+ {
+ /* why doesn't control-center call active-changed on the Page? */
+ cc_empathy_accounts_page_destroy_dialogs (
+ CC_EMPATHY_ACCOUNTS_PAGE (
+ CC_EMPATHY_ACCOUNTS_PANEL (self)->priv->empathy_accounts_page));
+ }
+
+ CC_PANEL_CLASS (cc_empathy_accounts_panel_parent_class)->active_changed (
+ self, is_active);
+}
+
static GObject *
cc_empathy_accounts_panel_constructor (GType type,
guint n_construct_properties,
@@ -96,7 +117,10 @@ cc_empathy_accounts_panel_finalize (GObject *object)
static void
cc_empathy_accounts_panel_class_init (CcEmpathyAccountsPanelClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ panel_class->active_changed = cc_empathy_accounts_panel_active_changed;
object_class->constructor = cc_empathy_accounts_panel_constructor;
object_class->finalize = cc_empathy_accounts_panel_finalize;
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index e5c5e80c2..9860259fa 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -1223,6 +1223,9 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self)
EmpathyAccountAssistantPriv);
self->priv = priv;
+ gtk_window_set_title (GTK_WINDOW (self),
+ _("Messaging and VoIP Accounts Assistant"));
+
priv->account_mgr = tp_account_manager_dup ();
}
@@ -1320,7 +1323,7 @@ empathy_account_assistant_show (GtkWindow *window,
if (dialog == NULL)
{
- dialog = g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
+ dialog = g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
"parent-window", window,
"connection-managers", connection_mgrs,
NULL);
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 5162e0b8e..8e85a3653 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -2063,7 +2063,7 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
gtk_box_pack_start (GTK_BOX (hbox), priv->label_status, TRUE, TRUE, 0);
/* Tweak the dialog */
- gtk_window_set_title (GTK_WINDOW (dialog), _("Accounts"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Messaging and VoIP Accounts"));
gtk_window_set_role (GTK_WINDOW (dialog), "accounts");
gtk_window_set_default_size (GTK_WINDOW (dialog), 640, -1);
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c
index 187bdf56b..0eaa8553e 100644
--- a/src/empathy-accounts.c
+++ b/src/empathy-accounts.c
@@ -244,7 +244,7 @@ main (int argc, char *argv[])
empathy_gtk_init ();
- g_set_application_name (_(PACKAGE_NAME " Accounts"));
+ g_set_application_name (_("Empathy Accounts"));
gtk_window_set_default_icon_name ("empathy");
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 8b7af2dcf..d67fc3770 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -1037,12 +1037,6 @@ empathy_call_window_init (EmpathyCallWindow *self)
"show", G_CALLBACK (empathy_call_window_sidebar_shown_cb), self);
gtk_paned_pack2 (GTK_PANED (priv->pane), priv->sidebar, FALSE, FALSE);
- priv->dtmf_panel = empathy_call_window_create_dtmf (self);
- empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
- priv->dtmf_panel);
-
- gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
-
page = empathy_call_window_create_audio_input (self);
empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Audio input"),
page);
@@ -1051,6 +1045,13 @@ empathy_call_window_init (EmpathyCallWindow *self)
empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Video input"),
page);
+ priv->dtmf_panel = empathy_call_window_create_dtmf (self);
+ empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
+ priv->dtmf_panel);
+
+ gtk_widget_set_sensitive (priv->dtmf_panel, FALSE);
+
+
gtk_widget_show_all (top_vbox);
gtk_widget_hide (priv->sidebar);
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 7419a720b..29d574a3e 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -879,6 +879,7 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
EmpathyTpChat *tp_chat;
TpChannel *channel;
int response;
+ TpAccount *account;
priv = GET_PRIV (window);
@@ -886,9 +887,10 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
tp_chat = empathy_chat_get_tp_chat (priv->current_chat);
channel = empathy_tp_chat_get_channel (tp_chat);
+ account = empathy_chat_get_account (priv->current_chat);
dialog = empathy_invite_participant_dialog_new (
- GTK_WINDOW (priv->dialog));
+ GTK_WINDOW (priv->dialog), account);
gtk_widget_show (dialog);
response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -2244,7 +2246,7 @@ empathy_chat_window_present_chat (EmpathyChat *chat)
priv = GET_PRIV (window);
empathy_chat_window_switch_to_chat (window, chat);
- empathy_window_present (GTK_WINDOW (priv->dialog), TRUE);
+ empathy_window_present (GTK_WINDOW (priv->dialog));
gtk_widget_grab_focus (chat->input_text_view);
}
diff --git a/src/empathy-debugger.c b/src/empathy-debugger.c
new file mode 100644
index 000000000..a4e6a9ca2
--- /dev/null
+++ b/src/empathy-debugger.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005-2007 Imendio AB
+ * Copyright (C) 2007-2010 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
+
+#include "empathy-debug-window.h"
+
+int
+main (int argc,
+ char **argv)
+{
+ GtkWidget *window;
+
+ g_thread_init (NULL);
+ gtk_init (&argc, &argv);
+ empathy_gtk_init ();
+
+ g_set_application_name (_("Empathy Debugger"));
+
+ gtk_window_set_default_icon_name ("empathy");
+
+ window = empathy_debug_window_new (NULL);
+ g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+
+ gtk_main ();
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c
index 70332d1ff..77fb93738 100644
--- a/src/empathy-invite-participant-dialog.c
+++ b/src/empathy-invite-participant-dialog.c
@@ -52,9 +52,12 @@ empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self)
}
GtkWidget *
-empathy_invite_participant_dialog_new (GtkWindow *parent)
+empathy_invite_participant_dialog_new (GtkWindow *parent,
+ TpAccount *account)
{
- GtkWidget *self = g_object_new (EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, NULL);
+ GtkWidget *self = g_object_new (EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG,
+ "filter-account", account,
+ NULL);
if (parent != NULL)
{
diff --git a/src/empathy-invite-participant-dialog.h b/src/empathy-invite-participant-dialog.h
index 561e10738..daacf5192 100644
--- a/src/empathy-invite-participant-dialog.h
+++ b/src/empathy-invite-participant-dialog.h
@@ -39,7 +39,8 @@ struct _EmpathyInviteParticipantDialogClass
};
GType empathy_invite_participant_dialog_get_type (void);
-GtkWidget *empathy_invite_participant_dialog_new (GtkWindow *parent);
+GtkWidget *empathy_invite_participant_dialog_new (GtkWindow *parent,
+ TpAccount *account);
G_END_DECLS
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 240f4b18b..fe9af9c4d 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2002-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
+ * Copyright (C) 2007-2010 Collabora Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -63,6 +63,7 @@
#include "empathy-chatrooms-window.h"
#include "empathy-event-manager.h"
#include "empathy-ft-manager.h"
+#include "empathy-migrate-butterfly-logs.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
@@ -119,6 +120,9 @@ typedef struct {
/* Actions that are enabled when there are connected accounts */
GList *actions_connected;
+
+ /* The idle event source to migrate butterfly's logs */
+ guint butterfly_log_migration_contact_added_id;
} EmpathyMainWindow;
static EmpathyMainWindow *main_window = NULL;
@@ -652,6 +656,7 @@ main_window_destroy_cb (GtkWidget *widget,
window);
g_object_unref (window->event_manager);
g_object_unref (window->ui_manager);
+ g_object_unref (window->chatroom_manager);
g_free (window);
}
@@ -1091,7 +1096,35 @@ static void
main_window_help_debug_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_debug_window_new (NULL);
+ GdkScreen *screen = gdk_screen_get_default ();
+ GError *error = NULL;
+ gchar *argv[2] = { NULL, };
+ gint i = 0;
+ gchar *path;
+
+ g_return_if_fail (GDK_IS_SCREEN (screen));
+
+ /* Try to run from source directory if possible */
+ path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
+ "empathy-debugger", NULL);
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+ g_free (path);
+ path = g_build_filename (BIN_DIR, "empathy-debugger", NULL);
+ }
+
+ argv[i++] = path;
+
+ gdk_spawn_on_screen (screen, NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, NULL, NULL, &error);
+
+ if (error) {
+ g_warning ("Failed to open debug window: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_free (path);
}
static void
@@ -1243,6 +1276,18 @@ account_manager_prepared_cb (GObject *source_object,
g_list_free (accounts);
}
+static void
+main_window_contact_added_cb (EmpathyContactMonitor *monitor,
+ EmpathyContact *contact,
+ EmpathyMainWindow *window)
+{
+ if (!empathy_migrate_butterfly_logs (contact)) {
+ g_signal_handler_disconnect (monitor,
+ window->butterfly_log_migration_contact_added_id);
+ window->butterfly_log_migration_contact_added_id = 0;
+ }
+}
+
GtkWidget *
empathy_main_window_show (void)
{
@@ -1261,7 +1306,7 @@ empathy_main_window_show (void)
GSList *l;
if (main_window) {
- empathy_window_present (GTK_WINDOW (main_window->window), TRUE);
+ empathy_window_present (GTK_WINDOW (main_window->window));
return main_window->window;
}
@@ -1391,6 +1436,8 @@ empathy_main_window_show (void)
EMPATHY_CONTACT_FEATURE_ALL);
g_signal_connect (monitor, "contact-presence-changed",
G_CALLBACK (main_window_contact_presence_changed_cb), window);
+ window->butterfly_log_migration_contact_added_id = g_signal_connect (monitor, "contact-added",
+ G_CALLBACK (main_window_contact_added_cb), window);
g_object_unref (list_iface);
gtk_widget_show (GTK_WIDGET (window->list_view));
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c
index fd6106c95..287d9b6ff 100644
--- a/src/empathy-map-view.c
+++ b/src/empathy-map-view.c
@@ -351,7 +351,7 @@ empathy_map_view_show (void)
if (window)
{
- empathy_window_present (GTK_WINDOW (window->window), TRUE);
+ empathy_window_present (GTK_WINDOW (window->window));
return window->window;
}
@@ -415,7 +415,7 @@ empathy_map_view_show (void)
model = GTK_TREE_MODEL (window->list_store);
gtk_tree_model_foreach (model, map_view_contacts_foreach, window);
- empathy_window_present (GTK_WINDOW (window->window), TRUE);
+ empathy_window_present (GTK_WINDOW (window->window));
/* Set up time updating loop */
window->timeout_id = g_timeout_add_seconds (5,
diff --git a/src/empathy-migrate-butterfly-logs.c b/src/empathy-migrate-butterfly-logs.c
new file mode 100644
index 000000000..50d7b8e7b
--- /dev/null
+++ b/src/empathy-migrate-butterfly-logs.c
@@ -0,0 +1,213 @@
+/*
+* Copyright (C) 2010 Collabora Ltd.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <string.h>
+
+#include <gio/gio.h>
+
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-log-store-empathy.h>
+
+#include <libempathy-gtk/empathy-conf.h>
+
+#include <telepathy-glib/account-manager.h>
+#include <telepathy-glib/util.h>
+
+#include "empathy-migrate-butterfly-logs.h"
+
+static guint butterfly_log_migration_id = 0;
+
+static void
+migrate_log_files_in_dir (const gchar *dirname)
+{
+ GDir *dir;
+ const gchar *subdir;
+ gchar *new_name;
+ gchar *full_path;
+ GError *error = NULL;
+
+ dir = g_dir_open (dirname, 0, &error);
+
+ if (dir == NULL)
+ {
+ DEBUG ("Failed to open dir: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ while ((subdir = g_dir_read_name (dir)) != NULL)
+ {
+ GFile *old_gfile, *new_gfile;
+
+ if (!tp_strdiff (subdir, "chatrooms"))
+ continue;
+
+ if (g_str_has_suffix (subdir, "#1"))
+ {
+ new_name = g_strndup (subdir, (strlen (subdir) - 2));
+ }
+ else if (g_str_has_suffix (subdir, "#32"))
+ {
+ gchar *tmp;
+ tmp = g_strndup (subdir, (strlen (subdir) - 3));
+ new_name = g_strdup_printf ("%s#yahoo", tmp);
+ g_free (tmp);
+ }
+ else
+ {
+ continue;
+ }
+
+ full_path = g_build_filename (dirname, subdir, NULL);
+ old_gfile = g_file_new_for_path (full_path);
+ g_free (full_path);
+
+ full_path = g_build_filename (dirname, new_name, NULL);
+ new_gfile = g_file_new_for_path (full_path);
+ g_free (full_path);
+
+ if (!g_file_move (old_gfile, new_gfile, G_FILE_COPY_NONE,
+ NULL, NULL, NULL, &error))
+ {
+ DEBUG ("Failed to move file: %s", error->message);
+ g_clear_error (&error);
+ }
+ else
+ {
+ DEBUG ("Successfully migrated logs for %s", new_name);
+ }
+
+ g_free (new_name);
+ g_object_unref (old_gfile);
+ g_object_unref (new_gfile);
+ }
+
+ g_dir_close (dir);
+}
+
+static void
+migration_account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccountManager *am = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
+ GList *accounts, *l;
+ EmpathyLogStoreEmpathy *log_store;
+ EmpathyConf *conf;
+
+ if (!tp_account_manager_prepare_finish (am, result, &error))
+ {
+ DEBUG ("Failed to prepare the account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ log_store = g_object_new (EMPATHY_TYPE_LOG_STORE_EMPATHY, NULL);
+ accounts = tp_account_manager_get_valid_accounts (am);
+
+ for (l = accounts; l != NULL; l = l->next)
+ {
+ TpAccount *account = TP_ACCOUNT (l->data);
+ gchar *dir, *cm;
+
+ tp_account_parse_object_path (tp_proxy_get_object_path (account),
+ &cm, NULL, NULL, NULL);
+
+ if (tp_strdiff (cm, "butterfly"))
+ {
+ g_free (cm);
+ continue;
+ }
+
+ dir = empathy_log_store_empathy_get_dir (log_store, account);
+ DEBUG ("Migrating all logs from dir: %s", dir);
+
+ migrate_log_files_in_dir (dir);
+
+ g_free (cm);
+ g_free (dir);
+ }
+
+ DEBUG ("Finished all migrating");
+
+ conf = empathy_conf_get ();
+ empathy_conf_set_bool (conf, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED, TRUE);
+
+ g_list_free (accounts);
+ g_object_unref (log_store);
+}
+
+static gboolean
+migrate_logs (gpointer data)
+{
+ TpAccountManager *account_manager;
+
+ account_manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (account_manager, NULL,
+ migration_account_manager_prepared_cb, NULL);
+
+ g_object_unref (account_manager);
+
+ return FALSE;
+}
+
+gboolean
+empathy_migrate_butterfly_logs (EmpathyContact *contact)
+{
+ EmpathyConf *conf;
+ gboolean logs_migrated;
+ gchar *cm;
+
+ conf = empathy_conf_get ();
+
+ /* Already in progress. */
+ if (butterfly_log_migration_id != 0)
+ return FALSE;
+
+ /* Already done. */
+ if (!empathy_conf_get_bool (conf, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED,
+ &logs_migrated))
+ return FALSE;
+
+ if (logs_migrated)
+ return FALSE;
+
+ tp_account_parse_object_path (
+ tp_proxy_get_object_path (empathy_contact_get_account (contact)),
+ &cm, NULL, NULL, NULL);
+
+ if (tp_strdiff (cm, "butterfly"))
+ {
+ g_free (cm);
+ return TRUE;
+ }
+ g_free (cm);
+
+ if (g_str_has_suffix (empathy_contact_get_id (contact), "#32")
+ || g_str_has_suffix (empathy_contact_get_id (contact), "#1"))
+ return TRUE;
+
+ /* Okay, we know a new butterfly is being used, so we should migrate its logs */
+ butterfly_log_migration_id = g_idle_add_full (G_PRIORITY_LOW,
+ migrate_logs, NULL, NULL);
+
+ return FALSE;
+}
diff --git a/src/empathy-migrate-butterfly-logs.h b/src/empathy-migrate-butterfly-logs.h
new file mode 100644
index 000000000..a06c1b488
--- /dev/null
+++ b/src/empathy-migrate-butterfly-logs.h
@@ -0,0 +1,32 @@
+/*
+* Copyright (C) 2010 Collabora Ltd.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include <glib.h>
+
+#include <libempathy/empathy-contact.h>
+
+#ifndef __EMPATHY_MIGRATE_BUTTERFLY_LOGS_H__
+#define __EMPATHY_MIGRATE_BUTTERFLY_LOGS_H__
+
+G_BEGIN_DECLS
+
+gboolean empathy_migrate_butterfly_logs (EmpathyContact *contact);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_MIGRATE_BUTTERFLY_LOGS_H__ */
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index d0cdac314..d1ea96c98 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -362,7 +362,7 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
if (!visible) {
empathy_window_iconify (priv->window, priv->icon);
} else {
- empathy_window_present (GTK_WINDOW (priv->window), TRUE);
+ empathy_window_present (GTK_WINDOW (priv->window));
}
}