]> git.0d.be Git - empathy.git/commitdiff
all: remove butterfly workarounds (bgo#612555)
authorJonny Lamb <jonnylamb@gnome.org>
Tue, 21 Sep 2010 23:14:16 +0000 (00:14 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 26 Sep 2011 10:25:02 +0000 (12:25 +0200)
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
libempathy/empathy-tp-chat.c
src/Makefile.am
src/empathy-chat-window.c
src/empathy-main-window.c
src/empathy-migrate-butterfly-logs.c [deleted file]
src/empathy-migrate-butterfly-logs.h [deleted file]

index 9eaff95924fa34b6397fde09298119958fe3a805..11a6e7de509b2597080bdeafd0207acbd19785d5 100644 (file)
@@ -889,66 +889,6 @@ check_almost_ready (EmpathyTpChat *self)
        check_ready (self);
 }
 
-static void
-tp_chat_update_remote_contact (EmpathyTpChat *self)
-{
-       TpChannel *channel = (TpChannel *) self;
-       EmpathyContact *contact = NULL;
-       TpHandle self_handle;
-       TpHandleType handle_type;
-       GList *l;
-
-       /* If this is a named chatroom, never pretend it is a private chat */
-       tp_channel_get_handle (channel, &handle_type);
-       if (handle_type == TP_HANDLE_TYPE_ROOM) {
-               return;
-       }
-
-       /* This is an MSN chat, but it's the new style where 1-1 chats don't
-        * have the group interface. If it has the conference interface, then
-        * it is indeed a MUC. */
-       if (tp_proxy_has_interface_by_id (self,
-                                         TP_IFACE_QUARK_CHANNEL_INTERFACE_CONFERENCE)) {
-               return;
-       }
-
-       /* This is an MSN-like chat where anyone can join the chat at anytime.
-        * If there is only one non-self contact member, we are in a private
-        * chat and we set the "remote-contact" property to that contact. If
-        * there are more, set the "remote-contact" property to NULL and the
-        * UI will display a contact list. */
-       self_handle = tp_channel_group_get_self_handle (channel);
-       for (l = self->priv->members; l; l = l->next) {
-               /* Skip self contact if member */
-               if (empathy_contact_get_handle (l->data) == self_handle) {
-                       continue;
-               }
-
-               /* We have more than one remote contact, break */
-               if (contact != NULL) {
-                       contact = NULL;
-                       break;
-               }
-
-               /* If we didn't find yet a remote contact, keep this one */
-               contact = l->data;
-       }
-
-       if (self->priv->remote_contact == contact) {
-               return;
-       }
-
-       DEBUG ("Changing remote contact from %p to %p",
-               self->priv->remote_contact, contact);
-
-       if (self->priv->remote_contact) {
-               g_object_unref (self->priv->remote_contact);
-       }
-
-       self->priv->remote_contact = contact ? g_object_ref (contact) : NULL;
-       g_object_notify (G_OBJECT (self), "remote-contact");
-}
-
 static void
 tp_chat_got_added_contacts_cb (TpConnection            *connection,
                               guint                    n_contacts,
@@ -984,7 +924,6 @@ tp_chat_got_added_contacts_cb (TpConnection            *connection,
                }
        }
 
-       tp_chat_update_remote_contact (EMPATHY_TP_CHAT (chat));
        check_almost_ready (EMPATHY_TP_CHAT (chat));
 }
 
@@ -1092,7 +1031,6 @@ tp_chat_got_renamed_contacts_cb (TpConnection            *connection,
                self->priv->user = g_object_ref (new);
        }
 
-       tp_chat_update_remote_contact (self);
        check_almost_ready (self);
 }
 
@@ -1168,8 +1106,6 @@ tp_chat_group_members_changed_cb (TpChannel     *channel,
                        G_OBJECT (self));
        }
 
-       tp_chat_update_remote_contact (self);
-
        if (actor_contact != NULL) {
                g_object_unref (actor_contact);
        }
index 40be88c1274314ed1dce56c1e66705ab51eb736b..ef4e8d964066f6fd73c8026bbf91049695be3b28 100644 (file)
@@ -176,7 +176,6 @@ empathy_handwritten_source = \
        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-notifications-approver.c empathy-notifications-approver.h \
        empathy-call-observer.c empathy-call-observer.h                 \
index 97ed1b9de51c7696308f5015037b261338f31358..44f3dcce39d761ef9177a3ed130168ce83d792d1 100644 (file)
@@ -1482,8 +1482,7 @@ chat_window_new_message_cb (EmpathyChat       *chat,
         *   a) the chatroom's always_urgent property is TRUE
         *   b) the message contains our alias
         */
-       if (empathy_chat_is_room (chat) ||
-           empathy_chat_get_remote_contact (chat) == NULL) {
+       if (empathy_chat_is_room (chat)) {
                TpAccount             *account;
                const gchar           *room;
                EmpathyChatroom       *chatroom;
index 3f87c4f7afb7f7123049b593efeabc33d9645e47..cb135c4fc4df4fe9559d5f0b90803cc718605376 100644 (file)
@@ -76,7 +76,6 @@
 #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>
@@ -169,9 +168,6 @@ struct _EmpathyMainWindowPriv {
        /* 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_members_changed_id;
-
        gboolean               shell_running;
 };
 
@@ -2051,27 +2047,6 @@ account_manager_prepared_cb (GObject      *source_object,
        g_list_free (accounts);
 }
 
-static void
-main_window_members_changed_cb (EmpathyContactList *list,
-                               EmpathyContact     *contact,
-                               EmpathyContact     *actor,
-                               guint               reason,
-                               gchar              *message,
-                               gboolean            is_member,
-                               EmpathyMainWindow  *window)
-{
-       EmpathyMainWindowPriv *priv = GET_PRIV (window);
-
-       if (!is_member)
-               return;
-
-       if (!empathy_migrate_butterfly_logs (contact)) {
-               g_signal_handler_disconnect (list,
-                       priv->butterfly_log_migration_members_changed_id);
-               priv->butterfly_log_migration_members_changed_id = 0;
-       }
-}
-
 void
 empathy_main_window_set_shell_running (EmpathyMainWindow *window,
                                        gboolean          shell_running)
@@ -2358,10 +2333,6 @@ empathy_main_window_init (EmpathyMainWindow *window)
                        EMPATHY_INDIVIDUAL_VIEW_FEATURE_ALL ^ EMPATHY_INDIVIDUAL_VIEW_FEATURE_PERSONA_DROP,
                        EMPATHY_INDIVIDUAL_FEATURE_ALL);
 
-       priv->butterfly_log_migration_members_changed_id = g_signal_connect (
-                       priv->contact_manager, "members-changed",
-                       G_CALLBACK (main_window_members_changed_cb), window);
-
        gtk_widget_show (GTK_WIDGET (priv->individual_view));
        gtk_container_add (GTK_CONTAINER (sw),
                           GTK_WIDGET (priv->individual_view));
diff --git a/src/empathy-migrate-butterfly-logs.c b/src/empathy-migrate-butterfly-logs.c
deleted file mode 100644 (file)
index c673a2f..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-*  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-gsettings.h>
-
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/defs.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);
-}
-
-/* This is copied from empathy-log-store-empathy.c (see #613437) */
-static gchar *
-log_store_account_to_dirname (TpAccount *account)
-{
-  const gchar *name;
-
-  name = tp_proxy_get_object_path (account);
-  if (g_str_has_prefix (name, TP_ACCOUNT_OBJECT_PATH_BASE))
-    name += strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
-
-  return g_strdelimit (g_strdup (name), "/", '_');
-}
-
-static gchar *
-get_log_dir_for_account (TpAccount *account)
-{
-  gchar *basedir;
-  gchar *escaped;
-
-  escaped = log_store_account_to_dirname (account);
-
-  basedir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
-    PACKAGE_NAME, "logs", escaped, NULL);
-
-  g_free (escaped);
-
-  return basedir;
-}
-
-
-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;
-  GSettings *gsettings;
-
-  if (!tp_proxy_prepare_finish (am, result, &error))
-    {
-      DEBUG ("Failed to prepare the account manager: %s", error->message);
-      g_error_free (error);
-      return;
-    }
-
-  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 = get_log_dir_for_account (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");
-
-  gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
-  g_settings_set_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED,
-      TRUE);
-  g_object_unref (gsettings);
-
-  g_list_free (accounts);
-}
-
-static gboolean
-migrate_logs (gpointer data)
-{
-  TpAccountManager *account_manager;
-
-  account_manager = tp_account_manager_dup ();
-
-  tp_proxy_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)
-{
-  GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
-  gchar *cm;
-
-  /* Already in progress. */
-  if (butterfly_log_migration_id != 0)
-    return FALSE;
-
-  /* Already done. */
-  if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_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
deleted file mode 100644 (file)
index a06c1b4..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-*  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__ */