aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/empathy-accounts-dialog.c2194
-rw-r--r--src/empathy-accounts-dialog.h27
-rw-r--r--src/empathy-accounts-dialog.ui2
-rw-r--r--src/empathy-chat-window.c7
-rw-r--r--src/empathy-chatrooms-window.c2
-rw-r--r--src/empathy-debug-dialog.c4
-rw-r--r--src/empathy-event-manager.c1
-rw-r--r--src/empathy-import-dialog.c4
-rw-r--r--src/empathy-main-window.c9
-rw-r--r--src/empathy-new-chatroom-dialog.c12
-rw-r--r--src/empathy-status-icon.c17
-rw-r--r--src/empathy-tube-dispatch.c1
-rw-r--r--src/empathy.c288
14 files changed, 1460 insertions, 1110 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 42485b7d1..50d317fbb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,8 +39,6 @@ empathy_handwritten_source = \
empathy-chat-window.c empathy-chat-window.h \
empathy-event-manager.c empathy-event-manager.h \
empathy-ft-manager.c empathy-ft-manager.h \
- empathy-import-dialog.c empathy-import-dialog.h \
- empathy-import-pidgin.c empathy-import-pidgin.h \
empathy-main-window.c empathy-main-window.h \
empathy-misc.c empathy-misc.h \
empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 98e848566..974b6dcc4 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -1,7 +1,6 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2005-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
+ * Copyright (C) 2007-2009 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
@@ -20,6 +19,7 @@
*
* Authors: Martyn Russell <martyn@imendio.com>
* Xavier Claessens <xclaesse@gmail.com>
+ * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
*/
#include <config.h>
@@ -31,20 +31,24 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#include <libmissioncontrol/mc-profile.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-account-manager.h>
+#include <libempathy/empathy-connection-managers.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-profile-chooser.h>
+
+#include <libempathy-gtk/empathy-protocol-chooser.h>
#include <libempathy-gtk/empathy-account-widget.h>
#include <libempathy-gtk/empathy-account-widget-irc.h>
#include <libempathy-gtk/empathy-account-widget-sip.h>
#include <libempathy-gtk/empathy-conf.h>
#include "empathy-accounts-dialog.h"
+#if 0
+/* FIXME MC-5 */
#include "empathy-import-dialog.h"
+#endif
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
@@ -52,1125 +56,1447 @@
/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
+G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT);
+
+static EmpathyAccountsDialog *dialog_singleton = NULL;
+
typedef struct {
- GtkWidget *window;
+ GtkWidget *window;
+
+ GtkWidget *alignment_settings;
+
+ GtkWidget *vbox_details;
+ GtkWidget *frame_no_protocol;
- GtkWidget *alignment_settings;
+ GtkWidget *treeview;
- GtkWidget *vbox_details;
- GtkWidget *frame_no_profile;
+ GtkWidget *button_add;
+ GtkWidget *button_remove;
+ GtkWidget *button_import;
- GtkWidget *treeview;
+ GtkWidget *frame_new_account;
+ GtkWidget *combobox_protocol;
+ GtkWidget *hbox_type;
+ GtkWidget *button_create;
+ GtkWidget *button_back;
+ GtkWidget *radiobutton_reuse;
+ GtkWidget *radiobutton_register;
- GtkWidget *button_add;
- GtkWidget *button_remove;
- GtkWidget *button_import;
+ GtkWidget *image_type;
+ GtkWidget *label_name;
+ GtkWidget *label_type;
+ GtkWidget *settings_widget;
- GtkWidget *frame_new_account;
- GtkWidget *combobox_profile;
- GtkWidget *hbox_type;
- GtkWidget *button_create;
- GtkWidget *button_back;
- GtkWidget *radiobutton_reuse;
- GtkWidget *radiobutton_register;
+ gboolean connecting_show;
+ guint connecting_id;
- GtkWidget *image_type;
- GtkWidget *label_name;
- GtkWidget *label_type;
- GtkWidget *settings_widget;
+ gulong settings_ready_id;
+ EmpathyAccountSettings *settings_ready;
- gboolean connecting_show;
- guint connecting_id;
+ EmpathyAccountManager *account_manager;
+ EmpathyConnectionManagers *cms;
- EmpathyAccountManager *account_manager;
- MissionControl *mc;
-} EmpathyAccountsDialog;
+ GtkWindow *parent_window;
+ EmpathyAccount *initial_selection;
+} EmpathyAccountsDialogPriv;
enum {
- COL_ENABLED,
- COL_NAME,
- COL_STATUS,
- COL_ACCOUNT_POINTER,
- COL_COUNT
+ COL_ENABLED,
+ COL_NAME,
+ COL_STATUS,
+ COL_ACCOUNT_POINTER,
+ COL_ACCOUNT_SETTINGS_POINTER,
+ COL_COUNT
};
-static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account);
-static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
- GtkCellEditable *editable,
- gchar *path,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EmpathyAccountsDialog *dialog);
-static EmpathyAccount *accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account);
-static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account);
-static void accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog);
-static gboolean accounts_dialog_row_changed_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data);
-static gboolean accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_create_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_back_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_add_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_help_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_import_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_destroy_cb (GtkWidget *widget,
- EmpathyAccountsDialog *dialog);
+enum {
+ PROP_PARENT = 1
+};
+
+static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings);
+
+#if 0
+/* FIXME MC-5 */
+static void accounts_dialog_button_import_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+#endif
static void
accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+ EmpathyAccountSettings *settings)
{
- gchar *text;
+ gchar *text;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- text = g_markup_printf_escaped ("<big><b>%s</b></big>",
- empathy_account_get_display_name (account));
- gtk_label_set_markup (GTK_LABEL (dialog->label_name), text);
+ text = g_markup_printf_escaped ("<big><b>%s</b></big>",
+ empathy_account_settings_get_display_name (settings));
+ gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
- g_free (text);
+ g_free (text);
+}
+
+static GtkWidget *
+get_account_setup_widget (EmpathyAccountSettings *settings)
+{
+ const gchar *cm = empathy_account_settings_get_cm (settings);
+ const gchar *proto = empathy_account_settings_get_protocol (settings);
+
+ struct {
+ const gchar *cm;
+ const gchar *proto;
+ } dialogs[] = {
+ { "gabble", "jabber" },
+ { "butterfly", "msn" },
+ { "salut", "local-xmpp" },
+ { "idle", "irc" },
+ { "haze", "icq" },
+ { "haze", "aim" },
+ { "haze", "yahoo" },
+ { "haze", "groupwise" },
+ { "sofiasip", "sip" },
+ { NULL, NULL }
+ };
+ int i;
+
+ for (i = 0; dialogs[i].cm != NULL; i++)
+ {
+ if (!tp_strdiff (cm, dialogs[i].cm)
+ && !tp_strdiff (proto, dialogs[i].proto))
+ return empathy_account_widget_new_for_protocol (dialogs[i].proto, settings);
+ }
+
+ return empathy_account_widget_new_for_protocol ("generic", settings);
}
static void
-accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings)
{
- McProfile *profile;
- const gchar *config_ui;
-
- if (!account) {
- GtkTreeView *view;
- GtkTreeModel *model;
-
- view = GTK_TREE_VIEW (dialog->treeview);
- model = gtk_tree_view_get_model (view);
-
- if (gtk_tree_model_iter_n_children (model, NULL) > 0) {
- /* We have configured accounts, select the first one */
- accounts_dialog_model_select_first (dialog);
- return;
- }
- if (empathy_profile_chooser_n_profiles (
- EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile)) > 0) {
- /* We have no account configured but we have some
- * profiles instsalled. The user obviously wants to add
- * an account. Click on the Add button for him. */
- accounts_dialog_button_add_clicked_cb (dialog->button_add,
- dialog);
- return;
- }
-
- /* No account and no profile, warn the user */
- gtk_widget_hide (dialog->vbox_details);
- gtk_widget_hide (dialog->frame_new_account);
- gtk_widget_show (dialog->frame_no_profile);
- gtk_widget_set_sensitive (dialog->button_add, FALSE);
- gtk_widget_set_sensitive (dialog->button_remove, FALSE);
- return;
- }
-
- /* We have an account selected, destroy old settings and create a new
- * one for the account selected */
- gtk_widget_hide (dialog->frame_new_account);
- gtk_widget_hide (dialog->frame_no_profile);
- gtk_widget_show (dialog->vbox_details);
- gtk_widget_set_sensitive (dialog->button_add, TRUE);
- gtk_widget_set_sensitive (dialog->button_remove, TRUE);
-
- if (dialog->settings_widget) {
- gtk_widget_destroy (dialog->settings_widget);
- dialog->settings_widget = NULL;
- }
-
- profile = empathy_account_get_profile (account);
- config_ui = mc_profile_get_configuration_ui (profile);
- if (!tp_strdiff (config_ui, "jabber")) {
- dialog->settings_widget =
- empathy_account_widget_jabber_new (account);
- }
- else if (!tp_strdiff (config_ui, "msn")) {
- dialog ->settings_widget =
- empathy_account_widget_msn_new (account);
- }
- else if (!tp_strdiff (config_ui, "local-xmpp")) {
- dialog->settings_widget =
- empathy_account_widget_salut_new (account);
- }
- else if (!tp_strdiff (config_ui, "irc")) {
- dialog->settings_widget =
- empathy_account_widget_irc_new (account);
- }
- else if (!tp_strdiff (config_ui, "icq")) {
- dialog->settings_widget =
- empathy_account_widget_icq_new (account);
- }
- else if (!tp_strdiff (config_ui, "aim")) {
- dialog->settings_widget =
- empathy_account_widget_aim_new (account);
- }
- else if (!tp_strdiff (config_ui, "yahoo")) {
- dialog->settings_widget =
- empathy_account_widget_yahoo_new (account);
- }
- else if (!tp_strdiff (config_ui, "sofiasip")) {
- dialog->settings_widget =
- empathy_account_widget_sip_new (account);
- }
- else if (!tp_strdiff (config_ui, "groupwise")) {
- dialog->settings_widget =
- empathy_account_widget_groupwise_new (account);
- }
- else {
- dialog->settings_widget =
- empathy_account_widget_generic_new (account);
- }
-
- gtk_container_add (GTK_CONTAINER (dialog->alignment_settings),
- dialog->settings_widget);
- gtk_widget_show (dialog->settings_widget);
-
-
- gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type),
- mc_profile_get_icon_name (profile),
- GTK_ICON_SIZE_DIALOG);
- gtk_widget_set_tooltip_text (dialog->image_type,
- mc_profile_get_display_name (profile));
-
- accounts_dialog_update_name_label (dialog, account);
-
- g_object_unref (profile);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ gchar *icon_name;
+
+ priv->settings_widget = get_account_setup_widget (settings);
+
+ gtk_container_add (GTK_CONTAINER (priv->alignment_settings),
+ priv->settings_widget);
+ gtk_widget_show (priv->settings_widget);
+
+ icon_name = empathy_account_settings_get_icon_name (settings);
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type),
+ icon_name, GTK_ICON_SIZE_DIALOG);
+ gtk_widget_set_tooltip_text (priv->image_type,
+ empathy_account_settings_get_protocol (settings));
+
+ accounts_dialog_update_name_label (dialog, settings);
+
+ g_free (icon_name);
}
static void
-accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
+account_dialog_settings_ready_cb (EmpathyAccountSettings *settings,
+ GParamSpec *spec,
+ EmpathyAccountsDialog *dialog)
{
- GtkListStore *store;
- GtkTreeSelection *selection;
+ if (empathy_account_settings_is_ready (settings))
+ account_dialog_create_settings_widget (dialog, settings);
+}
- store = gtk_list_store_new (COL_COUNT,
- G_TYPE_BOOLEAN, /* enabled */
- G_TYPE_STRING, /* name */
- G_TYPE_UINT, /* status */
- EMPATHY_TYPE_ACCOUNT); /* account */
+static void
+accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* select first */
+ view = GTK_TREE_VIEW (priv->treeview);
+ model = gtk_tree_view_get_model (view);
+
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ {
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
+ else
+ {
+ accounts_dialog_update_settings (dialog, NULL);
+ }
+}
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview),
- GTK_TREE_MODEL (store));
+static void
+accounts_dialog_protocol_changed_cb (GtkWidget *widget,
+ EmpathyAccountsDialog *dialog)
+{
+ TpConnectionManager *cm;
+ TpConnectionManagerProtocol *proto;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ cm = empathy_protocol_chooser_dup_selected (
+ EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto);
+
+ if (tp_connection_manager_protocol_can_register (proto))
+ {
+ gtk_widget_show (priv->radiobutton_register);
+ gtk_widget_show (priv->radiobutton_reuse);
+ }
+ else
+ {
+ gtk_widget_hide (priv->radiobutton_register);
+ gtk_widget_hide (priv->radiobutton_reuse);
+ }
+ g_object_unref (cm);
+}
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+static void
+accounts_dialog_button_add_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ model = gtk_tree_view_get_model (view);
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_selection_unselect_all (selection);
+
+ gtk_widget_set_sensitive (priv->button_add, FALSE);
+ gtk_widget_set_sensitive (priv->button_remove, FALSE);
+ gtk_widget_hide (priv->vbox_details);
+ gtk_widget_hide (priv->frame_no_protocol);
+ gtk_widget_show (priv->frame_new_account);
+
+ /* If we have no account, no need of a back button */
+ if (gtk_tree_model_iter_n_children (model, NULL) > 0)
+ gtk_widget_show (priv->button_back);
+ else
+ gtk_widget_hide (priv->button_back);
+
+ accounts_dialog_protocol_changed_cb (priv->radiobutton_register, dialog);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->radiobutton_reuse),
+ TRUE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox_protocol), 0);
+ gtk_widget_grab_focus (priv->combobox_protocol);
+}
- g_signal_connect (selection, "changed",
- G_CALLBACK (accounts_dialog_model_selection_changed),
- dialog);
+static void
+accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ if (priv->settings_ready != NULL)
+ {
+ g_signal_handler_disconnect (priv->settings_ready,
+ priv->settings_ready_id);
+ priv->settings_ready = NULL;
+ priv->settings_ready_id = 0;
+ }
+
+ if (!settings)
+ {
+ GtkTreeView *view;
+ GtkTreeModel *model;
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ model = gtk_tree_view_get_model (view);
+
+ if (gtk_tree_model_iter_n_children (model, NULL) > 0)
+ {
+ /* We have configured accounts, select the first one */
+ accounts_dialog_model_select_first (dialog);
+ return;
+ }
+ if (empathy_connection_managers_get_cms_num (priv->cms) > 0)
+ {
+ /* We have no account configured but we have some
+ * profiles instsalled. The user obviously wants to add
+ * an account. Click on the Add button for him. */
+ accounts_dialog_button_add_clicked_cb (priv->button_add,
+ dialog);
+ return;
+ }
+
+ /* No account and no profile, warn the user */
+ gtk_widget_hide (priv->vbox_details);
+ gtk_widget_hide (priv->frame_new_account);
+ gtk_widget_show (priv->frame_no_protocol);
+ gtk_widget_set_sensitive (priv->button_add, FALSE);
+ gtk_widget_set_sensitive (priv->button_remove, FALSE);
+ return;
+ }
+
+ /* We have an account selected, destroy old settings and create a new
+ * one for the account selected */
+ gtk_widget_hide (priv->frame_new_account);
+ gtk_widget_hide (priv->frame_no_protocol);
+ gtk_widget_show (priv->vbox_details);
+ gtk_widget_set_sensitive (priv->button_add, TRUE);
+ gtk_widget_set_sensitive (priv->button_remove, TRUE);
+
+ if (priv->settings_widget)
+ {
+ gtk_widget_destroy (priv->settings_widget);
+ priv->settings_widget = NULL;
+ }
+
+ if (empathy_account_settings_is_ready (settings))
+ {
+ account_dialog_create_settings_widget (dialog, settings);
+ }
+ else
+ {
+ priv->settings_ready = settings;
+ priv->settings_ready_id =
+ g_signal_connect (settings, "notify::ready",
+ G_CALLBACK (account_dialog_settings_ready_cb), dialog);
+ }
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
- COL_NAME, GTK_SORT_ASCENDING);
+}
- accounts_dialog_model_add_columns (dialog);
+static void
+accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
+ GtkCellEditable *editable,
+ gchar *path,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- g_object_unref (store);
+ if (priv->connecting_id)
+ g_source_remove (priv->connecting_id);
+
+ DEBUG ("Editing account name started; stopping flashing");
}
static void
-accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
- gchar *path,
- gchar *new_text,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account;
- GtkTreeModel *model;
- GtkTreePath *treepath;
- GtkTreeIter iter;
-
- if (empathy_account_manager_get_connecting_accounts (dialog->account_manager) > 0) {
- dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT,
- (GSourceFunc) accounts_dialog_flash_connecting_cb,
- dialog);
- }
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- treepath = gtk_tree_path_new_from_string (path);
- gtk_tree_model_get_iter (model, &iter, treepath);
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &account,
- -1);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_NAME, new_text,
- -1);
- gtk_tree_path_free (treepath);
-
- empathy_account_set_display_name (account, new_text);
- g_object_unref (account);
+ EmpathyAccountSettings *settings;
+ gchar *icon_name;
+ GdkPixbuf *pixbuf;
+ TpConnectionStatus status;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ gtk_tree_model_get (model, iter,
+ COL_STATUS, &status,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings,
+ -1);
+
+ icon_name = empathy_account_settings_get_icon_name (settings);
+ pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
+
+ g_free (icon_name);
+
+ if (pixbuf)
+ {
+ if (status == TP_CONNECTION_STATUS_DISCONNECTED ||
+ (status == TP_CONNECTION_STATUS_CONNECTING &&
+ !priv->connecting_show))
+ {
+ GdkPixbuf *modded_pixbuf;
+
+ modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+
+ gdk_pixbuf_saturate_and_pixelate (pixbuf,
+ modded_pixbuf,
+ 1.0,
+ TRUE);
+ g_object_unref (pixbuf);
+ pixbuf = modded_pixbuf;
+ }
+ }
+
+ g_object_set (cell,
+ "visible", TRUE,
+ "pixbuf", pixbuf,
+ NULL);
+
+ g_object_unref (settings);
+
+ if (pixbuf)
+ g_object_unref (pixbuf);
}
static void
accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- EmpathyAccountsDialog *dialog)
+ gchar *path,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccount *account;
+ GtkTreeModel *model;
+ GtkTreePath *treepath;
+ GtkTreeIter iter;
+ gboolean enabled;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ treepath = gtk_tree_path_new_from_string (path);
+ gtk_tree_model_get_iter (model, &iter, treepath);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_POINTER, &account,
+ -1);
+ gtk_tree_path_free (treepath);
+
+ if (account == NULL)
+ return;
+
+ enabled = empathy_account_is_enabled (account);
+ empathy_account_set_enabled (account, !enabled);
+
+ DEBUG ("%s account %s", enabled ? "Disabled" : "Enable",
+ empathy_account_get_display_name (account));
+
+ g_object_unref (account);
+}
+
+static gboolean
+accounts_dialog_row_changed_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- EmpathyAccount *account;
- GtkTreeModel *model;
- GtkTreePath *treepath;
- GtkTreeIter iter;
- gboolean enabled;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- treepath = gtk_tree_path_new_from_string (path);
- gtk_tree_model_get_iter (model, &iter, treepath);
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &account,
- -1);
- gtk_tree_path_free (treepath);
-
- enabled = empathy_account_is_enabled (account);
- empathy_account_set_enabled (account, !enabled);
-
- DEBUG ("%s account %s", enabled ? "Disabled" : "Enable",
- empathy_account_get_display_name (account));
-
- g_object_unref (account);
+ gtk_tree_model_row_changed (model, path, iter);
+
+ return FALSE;
+}
+
+static gboolean
+accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ priv->connecting_show = !priv->connecting_show;
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ model = gtk_tree_view_get_model (view);
+
+ gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL);
+
+ return TRUE;
}
static void
-accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
- GtkCellEditable *editable,
- gchar *path,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ EmpathyAccountsDialog *dialog)
{
- if (dialog->connecting_id) {
- g_source_remove (dialog->connecting_id);
- }
- DEBUG ("Editing account name started; stopping flashing");
+ EmpathyAccountSettings *settings;
+ GtkTreeModel *model;
+ GtkTreePath *treepath;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ if (empathy_account_manager_get_connecting_accounts
+ (priv->account_manager) > 0)
+ {
+ priv->connecting_id = g_timeout_add (FLASH_TIMEOUT,
+ (GSourceFunc) accounts_dialog_flash_connecting_cb,
+ dialog);
+ }
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ treepath = gtk_tree_path_new_from_string (path);
+ gtk_tree_model_get_iter (model, &iter, treepath);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings,
+ -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_NAME, new_text,
+ -1);
+ gtk_tree_path_free (treepath);
+
+ empathy_account_settings_set_display_name_async (settings, new_text,
+ NULL, NULL);
+ g_object_unref (settings);
}
static void
accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeViewColumn *column;
- GtkCellRenderer *cell;
-
- view = GTK_TREE_VIEW (dialog->treeview);
- gtk_tree_view_set_headers_visible (view, TRUE);
-
- /* Enabled column */
- cell = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_insert_column_with_attributes (view, -1,
- _("Enabled"),
- cell,
- "active", COL_ENABLED,
- NULL);
- g_signal_connect (cell, "toggled",
- G_CALLBACK (accounts_dialog_enable_toggled_cb),
- dialog);
-
- /* Account column */
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Accounts"));
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_append_column (view, column);
-
- /* Icon renderer */
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, cell, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- (GtkTreeCellDataFunc)
- accounts_dialog_model_pixbuf_data_func,
- dialog,
- NULL);
-
- /* Name renderer */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 25,
- "editable", TRUE,
- NULL);
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME);
- g_signal_connect (cell, "edited",
- G_CALLBACK (accounts_dialog_name_edited_cb),
- dialog);
- g_signal_connect (cell, "editing-started",
- G_CALLBACK (accounts_dialog_name_editing_started_cb),
- dialog);
+ GtkTreeView *view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *cell;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ gtk_tree_view_set_headers_visible (view, TRUE);
+
+ /* Enabled column */
+ cell = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_insert_column_with_attributes (view, -1,
+ _("Enabled"),
+ cell,
+ "active", COL_ENABLED,
+ NULL);
+ g_signal_connect (cell, "toggled",
+ G_CALLBACK (accounts_dialog_enable_toggled_cb),
+ dialog);
+
+ /* Account column */
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_title (column, _("Accounts"));
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_append_column (view, column);
+
+ /* Icon renderer */
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, cell, FALSE);
+ gtk_tree_view_column_set_cell_data_func (column, cell,
+ (GtkTreeCellDataFunc)
+ accounts_dialog_model_pixbuf_data_func,
+ dialog,
+ NULL);
+
+ /* Name renderer */
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "width-chars", 25,
+ "editable", TRUE,
+ NULL);
+ gtk_tree_view_column_pack_start (column, cell, TRUE);
+ gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME);
+ g_signal_connect (cell, "edited",
+ G_CALLBACK (accounts_dialog_name_edited_cb),
+ dialog);
+ g_signal_connect (cell, "editing-started",
+ G_CALLBACK (accounts_dialog_name_editing_started_cb),
+ dialog);
+}
+
+static EmpathyAccountSettings *
+accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountSettings *settings;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return NULL;
+
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings, -1);
+
+ return settings;
}
static void
-accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog)
+accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
+ EmpathyAccountsDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- /* select first */
- view = GTK_TREE_VIEW (dialog->treeview);
- model = gtk_tree_view_get_model (view);
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_selection_select_iter (selection, &iter);
- } else {
- accounts_dialog_update_account (dialog, NULL);
- }
+ EmpathyAccountSettings *settings;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean is_selection;
+
+ is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
+
+ settings = accounts_dialog_model_get_selected_settings (dialog);
+ accounts_dialog_update_settings (dialog, settings);
+
+ if (settings)
+ g_object_unref (settings);
}
static void
-accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
+{
+ GtkListStore *store;
+ GtkTreeSelection *selection;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ store = gtk_list_store_new (COL_COUNT,
+ G_TYPE_BOOLEAN, /* enabled */
+ G_TYPE_STRING, /* name */
+ G_TYPE_UINT, /* status */
+ EMPATHY_TYPE_ACCOUNT, /* account */
+ EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
+ GTK_TREE_MODEL (store));
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (accounts_dialog_model_selection_changed),
+ dialog);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ COL_NAME, GTK_SORT_ASCENDING);
+
+ accounts_dialog_model_add_columns (dialog);
+
+ g_object_unref (store);
+}
+
+static gboolean
+accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings,
+ GtkTreeIter *iter)
{
- EmpathyAccount *account;
- const gchar *icon_name;
- GdkPixbuf *pixbuf;
- TpConnectionStatus status;
-
- gtk_tree_model_get (model, iter,
- COL_STATUS, &status,
- COL_ACCOUNT_POINTER, &account,
- -1);
-
- icon_name = empathy_icon_name_from_account (account);
- pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
-
- if (pixbuf) {
- if (status == TP_CONNECTION_STATUS_DISCONNECTED ||
- (status == TP_CONNECTION_STATUS_CONNECTING &&
- !dialog->connecting_show)) {
- GdkPixbuf *modded_pixbuf;
-
- modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- gdk_pixbuf_get_width (pixbuf),
- gdk_pixbuf_get_height (pixbuf));
-
- gdk_pixbuf_saturate_and_pixelate (pixbuf,
- modded_pixbuf,
- 1.0,
- TRUE);
- g_object_unref (pixbuf);
- pixbuf = modded_pixbuf;
- }
- }
-
- g_object_set (cell,
- "visible", TRUE,
- "pixbuf", pixbuf,
- NULL);
-
- g_object_unref (account);
- if (pixbuf) {
- g_object_unref (pixbuf);
- }
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ gboolean ok;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* Update the status in the model */
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
+
+ for (ok = gtk_tree_model_get_iter_first (model, iter);
+ ok;
+ ok = gtk_tree_model_iter_next (model, iter))
+ {
+ EmpathyAccountSettings *this_settings;
+ gboolean equal;
+
+ gtk_tree_model_get (model, iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &this_settings,
+ -1);
+
+ equal = (this_settings == settings);
+ g_object_unref (this_settings);
+
+ if (equal)
+ return TRUE;
+ }
+
+ return FALSE;
}
static gboolean
accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account,
- GtkTreeIter *iter)
+ EmpathyAccount *account,
+ GtkTreeIter *iter)
{
- GtkTreeView *view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- gboolean ok;
-
- /* Update the status in the model */
- view = GTK_TREE_VIEW (dialog->treeview);
- selection = gtk_tree_view_get_selection (view);
- model = gtk_tree_view_get_model (view);
-
- for (ok = gtk_tree_model_get_iter_first (model, iter);
- ok;
- ok = gtk_tree_model_iter_next (model, iter)) {
- EmpathyAccount *this_account;
- gboolean equal;
-
- gtk_tree_model_get (model, iter,
- COL_ACCOUNT_POINTER, &this_account,
- -1);
-
- equal = empathy_account_equal (this_account, account);
- g_object_unref (this_account);
-
- if (equal) {
- return TRUE;
- }
- }
-
- return FALSE;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ gboolean ok;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* Update the status in the model */
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
+
+ for (ok = gtk_tree_model_get_iter_first (model, iter);
+ ok;
+ ok = gtk_tree_model_iter_next (model, iter))
+ {
+ EmpathyAccountSettings *settings;
+ gboolean equal;
+
+ gtk_tree_model_get (model, iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings,
+ -1);
+
+ equal = empathy_account_settings_has_account
+ (settings, account);
+ g_object_unref (settings);
+
+ if (equal)
+ return TRUE;
+ }
+
+ return FALSE;
}
static EmpathyAccount *
-accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog)
+accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- EmpathyAccount *account;
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccount *account;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- view = GTK_TREE_VIEW (dialog->treeview);
- selection = gtk_tree_view_get_selection (view);
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
- if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
- return NULL;
- }
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return NULL;
- gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
+ gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
- return account;
+ return account;
}
static void
accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+ EmpathyAccountSettings *settings)
{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview));
- if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
- gtk_tree_selection_select_iter (selection, &iter);
- }
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ if (accounts_dialog_get_settings_iter (dialog, settings, &iter))
+ gtk_tree_selection_select_iter (selection, &iter);
}
static gboolean
accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccount *account;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- view = GTK_TREE_VIEW (dialog->treeview);
- selection = gtk_tree_view_get_selection (view);
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
- if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
- return FALSE;
- }
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return FALSE;
- return gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_POINTER, &account,
+ -1);
+
+ if (account != NULL)
+ empathy_account_remove_async (account, NULL, NULL);
+
+ return gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
static void
-accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_add (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings)
{
- EmpathyAccount *account;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean is_selection;
-
- is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ const gchar *name;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ name = empathy_account_settings_get_display_name (settings);
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, FALSE,
+ COL_NAME, name,
+ COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED,
+ COL_ACCOUNT_SETTINGS_POINTER, settings,
+ -1);
+}
- account = accounts_dialog_model_get_selected (dialog);
- accounts_dialog_update_account (dialog, account);
+static void
+accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
+ EmpathyAccount *account,
+ TpConnectionStatusReason reason,
+ TpConnectionStatus current,
+ TpConnectionStatus previous,
+ EmpathyAccountsDialog *dialog)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean found;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* Update the status in the model */
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+
+ if (accounts_dialog_get_account_iter (dialog, account, &iter))
+ {
+ GtkTreePath *path;
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_STATUS, current,
+ -1);
+
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
+ }
+
+ found = (empathy_account_manager_get_connecting_accounts (manager) > 0);
+
+ if (!found && priv->connecting_id)
+ {
+ g_source_remove (priv->connecting_id);
+ priv->connecting_id = 0;
+ }
+
+ if (found && !priv->connecting_id)
+ priv->connecting_id = g_timeout_add (FLASH_TIMEOUT,
+ (GSourceFunc) accounts_dialog_flash_connecting_cb,
+ dialog);
+}
- if (account) {
- g_object_unref (account);
- }
+static void
+accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
+ EmpathyAccount *account)
+{
+ EmpathyAccountSettings *settings;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ TpConnectionStatus status;
+ const gchar *name;
+ gboolean enabled;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ g_object_get (account, "connection-status", &status, NULL);
+ name = empathy_account_get_display_name (account);
+ enabled = empathy_account_is_enabled (account);
+
+ if (!accounts_dialog_get_account_iter (dialog, account, &iter))
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ settings = empathy_account_settings_new_for_account (account);
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, enabled,
+ COL_NAME, name,
+ COL_STATUS, status,
+ COL_ACCOUNT_POINTER, account,
+ COL_ACCOUNT_SETTINGS_POINTER, settings,
+ -1);
+
+ accounts_dialog_connection_changed_cb (priv->account_manager,
+ account,
+ TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
+ status,
+ TP_CONNECTION_STATUS_DISCONNECTED,
+ dialog);
+
+ g_object_unref (settings);
}
static void
-accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account)
+accounts_dialog_update (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- TpConnectionStatus status;
- const gchar *name;
- gboolean enabled;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- g_object_get (account, "status", &status, NULL);
- name = empathy_account_get_display_name (account);
- enabled = empathy_account_is_enabled (account);
-
- if (!accounts_dialog_get_account_iter (dialog, account, &iter)) {
- DEBUG ("Adding new account");
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- }
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, enabled,
- COL_NAME, name,
- COL_STATUS, status,
- COL_ACCOUNT_POINTER, account,
- -1);
-
- accounts_dialog_connection_changed_cb (dialog->account_manager,
- account,
- TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
- status,
- TP_CONNECTION_STATUS_DISCONNECTED,
- dialog);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ TpConnectionStatus status = TP_CONNECTION_STATUS_DISCONNECTED;
+ const gchar *name;
+ gboolean enabled = FALSE;
+ EmpathyAccount *account;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ name = empathy_account_settings_get_display_name (settings);
+
+ account = empathy_account_settings_get_account (settings);
+ if (account != NULL)
+ {
+ enabled = empathy_account_is_enabled (account);
+ g_object_get (account, "connection-status", &status, NULL);
+ }
+
+ accounts_dialog_get_settings_iter (dialog, settings, &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, enabled,
+ COL_NAME, name,
+ COL_STATUS, status,
+ COL_ACCOUNT_POINTER, account,
+ COL_ACCOUNT_SETTINGS_POINTER, settings,
+ -1);
}
static void
accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
+ EmpathyAccount *account,
+ EmpathyAccountsDialog *dialog)
{
- const gchar *current_name;
- gchar *account_param = NULL;
-
- accounts_dialog_add_or_update_account (dialog, account);
-
- /* Change the display name to "%s (%s)" % (protocol, account).
- * - The protocol is the display name of the profile.
- * - The account should be the normalized name of the EmpathyAccount but
- * it's not set until first connection, so we get the "account"
- * parameter for CM that have it. */
- current_name = empathy_account_get_display_name (account);
- account_param = empathy_account_get_param_string (account, "account");
- if (!EMP_STR_EMPTY (account_param)) {
- McProfile *profile;
- const gchar *profile_name;
- gchar *new_name;
-
- profile = empathy_account_get_profile (account);
- profile_name = mc_profile_get_display_name (profile);
- new_name = g_strdup_printf ("%s (%s)", profile_name,
- account_param);
-
- DEBUG ("Setting new display name for account %s: '%s'",
- empathy_account_get_unique_name (account), new_name);
-
- empathy_account_set_display_name (account, new_name);
- g_free (new_name);
- g_object_unref (profile);
- } else {
- /* FIXME: This CM has no account parameter, what can be done? */
- }
- g_free (account_param);
+ accounts_dialog_add_account (dialog, account);
}
+
static void
accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
+ EmpathyAccount *account,
+ EmpathyAccountsDialog *dialog)
{
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- accounts_dialog_model_set_selected (dialog, account);
- accounts_dialog_model_remove_selected (dialog);
+ if (accounts_dialog_get_account_iter (dialog, account, &iter))
+ gtk_list_store_remove (GTK_LIST_STORE (
+ gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter);
}
-static gboolean
-accounts_dialog_row_changed_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
+static void
+enable_or_disable_account (EmpathyAccountsDialog *dialog,
+ EmpathyAccount *account,
+ gboolean enabled)
{
- gtk_tree_model_row_changed (model, path, iter);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* Update the status in the model */
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+
+ DEBUG ("Account %s is now %s",
+ empathy_account_get_display_name (account),
+ enabled ? "enabled" : "disabled");
- return FALSE;
+ if (accounts_dialog_get_account_iter (dialog, account, &iter))
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, enabled,
+ -1);
}
-static gboolean
-accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog)
+static void
+accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
+ EmpathyAccount *account,
+ EmpathyAccountsDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeModel *model;
+ enable_or_disable_account (dialog, account, FALSE);
+}
- dialog->connecting_show = !dialog->connecting_show;
+static void
+accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
+ EmpathyAccount *account,
+ EmpathyAccountsDialog *dialog)
+{
+ enable_or_disable_account (dialog, account, TRUE);
+}
+
+static void
+accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
+ EmpathyAccount *account,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccountSettings *settings, *selected_settings;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
- view = GTK_TREE_VIEW (dialog->treeview);
- model = gtk_tree_view_get_model (view);
+ if (!accounts_dialog_get_account_iter (dialog, account, &iter))
+ return;
- gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings,
+ -1);
- return TRUE;
+ accounts_dialog_update (dialog, settings);
+ selected_settings = accounts_dialog_model_get_selected_settings (dialog);
+
+ if (settings == selected_settings)
+ accounts_dialog_update_name_label (dialog, settings);
}
static void
-accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- TpConnectionStatusReason reason,
- TpConnectionStatus current,
- TpConnectionStatus previous,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_button_create_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean found;
+ EmpathyAccountSettings *settings;
+ gchar *str;
+ TpConnectionManager *cm;
+ TpConnectionManagerProtocol *proto;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ cm = empathy_protocol_chooser_dup_selected (
+ EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto);
- /* Update the status in the model */
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ /* Create account */
+ /* To translator: %s is the protocol name */
+ str = g_strdup_printf (_("New %s account"), proto->name);
- if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
- GtkTreePath *path;
+ settings = empathy_account_settings_new (cm->name, proto->name, str);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_STATUS, current,
- -1);
+ g_free (str);
- path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_model_row_changed (model, path, &iter);
- gtk_tree_path_free (path);
- }
+ if (tp_connection_manager_protocol_can_register (proto))
+ {
+ gboolean active;
- found = (empathy_account_manager_get_connecting_accounts (manager) > 0);
+ active = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (priv->radiobutton_register));
+ if (active)
+ empathy_account_settings_set_boolean (settings, "register", TRUE);
+ }
- if (!found && dialog->connecting_id) {
- g_source_remove (dialog->connecting_id);
- dialog->connecting_id = 0;
- }
+ accounts_dialog_add (dialog, settings);
+ accounts_dialog_model_set_selected (dialog, settings);
- if (found && !dialog->connecting_id) {
- dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT,
- (GSourceFunc) accounts_dialog_flash_connecting_cb,
- dialog);
- }
+ g_object_unref (settings);
+ g_object_unref (cm);
}
static void
-enable_or_disable_account (EmpathyAccountsDialog *dialog,
- EmpathyAccount *account,
- gboolean enabled)
+accounts_dialog_button_back_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
+ EmpathyAccountSettings *settings;
- /* Update the status in the model */
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ settings = accounts_dialog_model_get_selected_settings (dialog);
+ accounts_dialog_update (dialog, settings);
+}
- DEBUG ("Account %s is now %s",
- empathy_account_get_display_name (account),
- enabled ? "enabled" : "disabled");
+static void
+accounts_dialog_button_help_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
+{
+ empathy_url_show (button, "ghelp:empathy?empathy-create-account");
+}
- if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, enabled,
- -1);
- }
+static void
+accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccount *account;
+ GtkWidget *message_dialog;
+ gint res;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ account = accounts_dialog_model_get_selected_account (dialog);
+
+ if (account == NULL || !empathy_account_is_valid (account))
+ {
+ accounts_dialog_model_remove_selected (dialog);
+ accounts_dialog_model_select_first (dialog);
+ return;
+ }
+ message_dialog = gtk_message_dialog_new
+ (GTK_WINDOW (priv->window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("You are about to remove your %s account!\n"
+ "Are you sure you want to proceed?"),
+ empathy_account_get_display_name (account));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (message_dialog),
+ _("Any associated conversations and chat rooms will NOT be "
+ "removed if you decide to proceed.\n"
+ "\n"
+ "Should you decide to add the account back at a later time, "
+ "they will still be available."));
+
+ gtk_dialog_add_button (GTK_DIALOG (message_dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_NO);
+ gtk_dialog_add_button (GTK_DIALOG (message_dialog),
+ GTK_STOCK_REMOVE,
+ GTK_RESPONSE_YES);
+
+ gtk_widget_show (message_dialog);
+ res = gtk_dialog_run (GTK_DIALOG (message_dialog));
+
+ if (res == GTK_RESPONSE_YES)
+ {
+ accounts_dialog_model_remove_selected (dialog);
+ accounts_dialog_model_select_first (dialog);
+ }
+ gtk_widget_destroy (message_dialog);
}
+#if 0
+/* FIXME MC-5 */
static void
-accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_button_import_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
{
- enable_or_disable_account (dialog, account, FALSE);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ empathy_import_dialog_show (GTK_WINDOW (priv->window), TRUE);
}
+#endif
static void
-accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_response_cb (GtkWidget *widget,
+ gint response,
+ EmpathyAccountsDialog *dialog)
{
- enable_or_disable_account (dialog, account, TRUE);
+ GList *accounts, *l;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ if (response == GTK_RESPONSE_CLOSE)
+ {
+ /* Delete incomplete accounts */
+ accounts = empathy_account_manager_dup_accounts
+ (priv->account_manager);
+ for (l = accounts; l; l = l->next)
+ {
+ EmpathyAccount *account;
+
+ account = l->data;
+ if (!empathy_account_is_valid (account))
+ /* FIXME: Warn the user the account is not
+ * complete and is going to be removed.
+ */
+ empathy_account_manager_remove
+ (priv->account_manager, account);
+
+ g_object_unref (account);
+ }
+ g_list_free (accounts);
+
+ gtk_widget_destroy (widget);
+ }
}
static void
-accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
- EmpathyAccount *account,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_destroy_cb (GtkObject *obj,
+ EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *selected_account;
+ DEBUG ("%p", obj);
- accounts_dialog_add_or_update_account (dialog, account);
- selected_account = accounts_dialog_model_get_selected (dialog);
- if (empathy_account_equal (account, selected_account)) {
- accounts_dialog_update_name_label (dialog, account);
- }
+ g_object_unref (dialog);
}
static void
-accounts_dialog_button_create_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
+ EmpathyAccount *account)
{
- McProfile *profile;
- EmpathyAccount *account;
- gchar *str;
- McProfileCapabilityFlags cap;
-
- profile = empathy_profile_chooser_dup_selected (
- EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile));
-
- /* Create account */
- account = empathy_account_manager_create (dialog->account_manager, profile);
- if (account == NULL) {
- /* We can't display an error to the user as MC doesn't give us
- * any clue about the reason of the failure... */
- g_object_unref (profile);
- return;
- }
-
- /* To translator: %s is the protocol name */
- str = g_strdup_printf (_("New %s account"),
- mc_profile_get_display_name (profile));
- empathy_account_set_display_name (account, str);
- g_free (str);
-
- cap = mc_profile_get_capabilities (profile);
- if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) {
- gboolean active;
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_register));
- if (active) {
- empathy_account_set_param_boolean (account, "register", TRUE);
- }
- }
-
- accounts_dialog_add_or_update_account (dialog, account);
- accounts_dialog_model_set_selected (dialog, account);
-
- g_object_unref (account);
- g_object_unref (profile);
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ if (accounts_dialog_get_account_iter (dialog, account, &iter))
+ gtk_tree_selection_select_iter (selection, &iter);
}
static void
-accounts_dialog_button_back_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms,
+ GParamSpec *pspec,
+ EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account;
-
- account = accounts_dialog_model_get_selected (dialog);
- accounts_dialog_update_account (dialog, account);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ if (empathy_connection_managers_is_ready (cms))
+ {
+ accounts_dialog_update_settings (dialog, NULL);
+
+ if (priv->initial_selection != NULL)
+ {
+ accounts_dialog_set_selected_account
+ (dialog, priv->initial_selection);
+ priv->initial_selection = NULL;
+ }
+ }
}
static void
-accounts_dialog_profile_changed_cb (GtkWidget *widget,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
{
- McProfile *profile;
- McProfileCapabilityFlags cap;
-
- profile = empathy_profile_chooser_dup_selected (
- EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile));
- cap = mc_profile_get_capabilities (profile);
-
- if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) {
- gtk_widget_show (dialog->radiobutton_register);
- gtk_widget_show (dialog->radiobutton_reuse);
- } else {
- gtk_widget_hide (dialog->radiobutton_register);
- gtk_widget_hide (dialog->radiobutton_reuse);
- }
- g_object_unref (profile);
+ GtkBuilder *gui;
+ gchar *filename;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src");
+
+ gui = empathy_builder_get_file (filename,
+ "accounts_dialog", &priv->window,
+ "vbox_details", &priv->vbox_details,
+ "frame_no_protocol", &priv->frame_no_protocol,
+ "alignment_settings", &priv->alignment_settings,
+ "treeview", &priv->treeview,
+ "frame_new_account", &priv->frame_new_account,
+ "hbox_type", &priv->hbox_type,
+ "button_create", &priv->button_create,
+ "button_back", &priv->button_back,
+ "radiobutton_reuse", &priv->radiobutton_reuse,
+ "radiobutton_register", &priv->radiobutton_register,
+ "image_type", &priv->image_type,
+ "label_name", &priv->label_name,
+ "button_add", &priv->button_add,
+ "button_remove", &priv->button_remove,
+ "button_import", &priv->button_import,
+ NULL);
+ g_free (filename);
+
+ empathy_builder_connect (gui, dialog,
+ "accounts_dialog", "response", accounts_dialog_response_cb,
+ "accounts_dialog", "destroy", accounts_dialog_destroy_cb,
+ "button_create", "clicked", accounts_dialog_button_create_clicked_cb,
+ "button_back", "clicked", accounts_dialog_button_back_clicked_cb,
+ "button_add", "clicked", accounts_dialog_button_add_clicked_cb,
+ "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
+#if 0
+ /* FIXME MC-5 */
+ "button_import", "clicked", accounts_dialog_button_import_clicked_cb,
+#endif
+ "button_help", "clicked", accounts_dialog_button_help_clicked_cb,
+ NULL);
+
+ g_object_unref (gui);
+
+ priv->combobox_protocol = empathy_protocol_chooser_new ();
+ gtk_box_pack_end (GTK_BOX (priv->hbox_type),
+ priv->combobox_protocol,
+ TRUE, TRUE, 0);
+ gtk_widget_show (priv->combobox_protocol);
+ g_signal_connect (priv->combobox_protocol, "changed",
+ G_CALLBACK (accounts_dialog_protocol_changed_cb),
+ dialog);
+
+ if (priv->parent_window)
+ gtk_window_set_transient_for (GTK_WINDOW (priv->window),
+ priv->parent_window);
}
static void
-accounts_dialog_button_add_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+do_dispose (GObject *obj)
+{
+ EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ /* Disconnect signals */
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_account_added_cb,
+ dialog);
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_account_removed_cb,
+ dialog);
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_account_enabled_cb,
+ dialog);
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_account_disabled_cb,
+ dialog);
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_account_changed_cb,
+ dialog);
+ g_signal_handlers_disconnect_by_func (priv->account_manager,
+ accounts_dialog_connection_changed_cb,
+ dialog);
+
+ if (priv->connecting_id)
+ g_source_remove (priv->connecting_id);
+
+ if (priv->account_manager != NULL)
+ {
+ g_object_unref (priv->account_manager);
+ priv->account_manager = NULL;
+ }
+
+ if (priv->cms != NULL)
+ {
+ g_object_unref (priv->cms);
+ priv->cms = NULL;
+ }
+
+ G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj);
+}
+
+static GObject *
+do_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
{
- GtkTreeView *view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
-
- view = GTK_TREE_VIEW (dialog->treeview);
- model = gtk_tree_view_get_model (view);
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_selection_unselect_all (selection);
-
- gtk_widget_set_sensitive (dialog->button_add, FALSE);
- gtk_widget_set_sensitive (dialog->button_remove, FALSE);
- gtk_widget_hide (dialog->vbox_details);
- gtk_widget_hide (dialog->frame_no_profile);
- gtk_widget_show (dialog->frame_new_account);
-
- /* If we have no account, no need of a back button */
- if (gtk_tree_model_iter_n_children (model, NULL) > 0) {
- gtk_widget_show (dialog->button_back);
- } else {
- gtk_widget_hide (dialog->button_back);
- }
-
- accounts_dialog_profile_changed_cb (dialog->radiobutton_register, dialog);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_reuse),
- TRUE);
- gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_profile), 0);
- gtk_widget_grab_focus (dialog->combobox_profile);
+ GObject *retval;
+
+ if (dialog_singleton)
+ {
+ retval = G_OBJECT (dialog_singleton);
+ }
+ else
+ {
+ retval =
+ G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor
+ (type, n_props, props);
+
+ dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval);
+ g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton);
+ }
+
+ return retval;
}
static void
-accounts_dialog_button_help_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+do_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- empathy_url_show (button, "ghelp:empathy?empathy-create-account");
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (object);
+
+ switch (property_id)
+ {
+ case PROP_PARENT:
+ g_value_set_object (value, priv->parent_window);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
-accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+do_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EmpathyAccount *account;
- GtkWidget *message_dialog;
- gint res;
-
- account = accounts_dialog_model_get_selected (dialog);
-
- if (!empathy_account_is_valid (account)) {
- accounts_dialog_model_remove_selected (dialog);
- accounts_dialog_model_select_first (dialog);
- return;
- }
- message_dialog = gtk_message_dialog_new
- (GTK_WINDOW (dialog->window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("You are about to remove your %s account!\n"
- "Are you sure you want to proceed?"),
- empathy_account_get_display_name (account));
-
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (message_dialog),
- _("Any associated conversations and chat rooms will NOT be "
- "removed if you decide to proceed.\n"
- "\n"
- "Should you decide to add the account back at a later time, "
- "they will still be available."));
-
- gtk_dialog_add_button (GTK_DIALOG (message_dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_NO);
- gtk_dialog_add_button (GTK_DIALOG (message_dialog),
- GTK_STOCK_REMOVE,
- GTK_RESPONSE_YES);
-
- gtk_widget_show (message_dialog);
- res = gtk_dialog_run (GTK_DIALOG (message_dialog));
-
- if (res == GTK_RESPONSE_YES) {
- empathy_account_manager_remove (dialog->account_manager, account);
- accounts_dialog_model_select_first (dialog);
- }
- gtk_widget_destroy (message_dialog);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (object);
+
+ switch (property_id)
+ {
+ case PROP_PARENT:
+ priv->parent_window = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
-accounts_dialog_button_import_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+do_constructed (GObject *object)
{
- empathy_import_dialog_show (GTK_WINDOW (dialog->window), TRUE);
+ EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ GList *accounts, *l;
+ gboolean import_asked;
+
+ accounts_dialog_build_ui (dialog);
+
+ /* Set up signalling */
+ priv->account_manager = empathy_account_manager_dup_singleton ();
+
+ g_signal_connect (priv->account_manager, "account-created",
+ G_CALLBACK (accounts_dialog_account_added_cb),
+ dialog);
+ g_signal_connect (priv->account_manager, "account-deleted",
+ G_CALLBACK (accounts_dialog_account_removed_cb),
+ dialog);
+ g_signal_connect (priv->account_manager, "account-enabled",
+ G_CALLBACK (accounts_dialog_account_enabled_cb),
+ dialog);
+ g_signal_connect (priv->account_manager, "account-disabled",
+ G_CALLBACK (accounts_dialog_account_disabled_cb),
+ dialog);
+ g_signal_connect (priv->account_manager, "account-changed",
+ G_CALLBACK (accounts_dialog_account_changed_cb),
+ dialog);
+ g_signal_connect (priv->account_manager, "account-connection-changed",
+ G_CALLBACK (accounts_dialog_connection_changed_cb),
+ dialog);
+
+ accounts_dialog_model_setup (dialog);
+
+ /* Add existing accounts */
+ accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+ for (l = accounts; l; l = l->next)
+ {
+ accounts_dialog_add_account (dialog, l->data);
+ g_object_unref (l->data);
+ }
+ g_list_free (accounts);
+
+ priv->cms = empathy_connection_managers_dup_singleton ();
+ if (!empathy_connection_managers_is_ready (priv->cms))
+ g_signal_connect (priv->cms, "notify::ready",
+ G_CALLBACK (accounts_dialog_cms_ready_cb), dialog);
+
+ accounts_dialog_model_select_first (dialog);
+
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
+
+
+#if 0
+ /* FIXME MC-5 */
+ if (empathy_import_dialog_accounts_to_import ())
+ {
+
+ if (!import_asked)
+ {
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_IMPORT_ASKED, TRUE);
+ empathy_import_dialog_show (GTK_WINDOW (priv->window),
+ FALSE);
+ }
+ }
+ else
+ {
+ gtk_widget_set_sensitive (priv->button_import, FALSE);
+ }
+#endif
}
static void
-accounts_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathyAccountsDialog *dialog)
+empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass)
{
- if (response == GTK_RESPONSE_CLOSE) {
- gtk_widget_destroy (widget);
- }
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GParamSpec *param_spec;
+
+ oclass->constructor = do_constructor;
+ oclass->dispose = do_dispose;
+ oclass->constructed = do_constructed;
+ oclass->set_property = do_set_property;
+ oclass->get_property = do_get_property;
+
+ param_spec = g_param_spec_object ("parent",
+ "parent", "The parent window",
+ GTK_TYPE_WINDOW,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (oclass, PROP_PARENT, param_spec);
+
+ g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv));
}
static void
-accounts_dialog_destroy_cb (GtkWidget *widget,
- EmpathyAccountsDialog *dialog)
+empathy_accounts_dialog_init (EmpathyAccountsDialog *dialog)
{
- GList *accounts, *l;
-
- /* Disconnect signals */
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_account_added_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_account_removed_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_account_enabled_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_account_disabled_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_account_changed_cb,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->account_manager,
- accounts_dialog_connection_changed_cb,
- dialog);
-
- /* Delete incomplete accounts */
- accounts = empathy_account_manager_dup_accounts (dialog->account_manager);
- for (l = accounts; l; l = l->next) {
- EmpathyAccount *account;
-
- account = l->data;
- if (!empathy_account_is_valid (account)) {
- /* FIXME: Warn the user the account is not complete
- * and is going to be removed. */
- empathy_account_manager_remove (dialog->account_manager, account);
- }
-
- g_object_unref (account);
- }
- g_list_free (accounts);
-
- if (dialog->connecting_id) {
- g_source_remove (dialog->connecting_id);
- }
-
- g_object_unref (dialog->account_manager);
- g_object_unref (dialog->mc);
-
- g_free (dialog);
+ EmpathyAccountsDialogPriv *priv;
+
+ priv = G_TYPE_INSTANCE_GET_PRIVATE ((dialog),
+ EMPATHY_TYPE_ACCOUNTS_DIALOG,
+ EmpathyAccountsDialogPriv);
+ dialog->priv = priv;
}
+/* public methods */
+
GtkWidget *
empathy_accounts_dialog_show (GtkWindow *parent,
- EmpathyAccount *selected_account)
+ EmpathyAccount *selected_account)
{
- static EmpathyAccountsDialog *dialog = NULL;
- GtkBuilder *gui;
- gchar *filename;
- GList *accounts, *l;
- gboolean import_asked;
-
- if (dialog) {
- gtk_window_present (GTK_WINDOW (dialog->window));
- return dialog->window;
- }
-
- dialog = g_new0 (EmpathyAccountsDialog, 1);
-
- filename = empathy_file_lookup ("empathy-accounts-dialog.ui",
- "src");
- gui = empathy_builder_get_file (filename,
- "accounts_dialog", &dialog->window,
- "vbox_details", &dialog->vbox_details,
- "frame_no_profile", &dialog->frame_no_profile,
- "alignment_settings", &dialog->alignment_settings,
- "treeview", &dialog->treeview,
- "frame_new_account", &dialog->frame_new_account,
- "hbox_type", &dialog->hbox_type,
- "button_create", &dialog->button_create,
- "button_back", &dialog->button_back,
- "radiobutton_reuse", &dialog->radiobutton_reuse,
- "radiobutton_register", &dialog->radiobutton_register,
- "image_type", &dialog->image_type,
- "label_name", &dialog->label_name,
- "button_add", &dialog->button_add,
- "button_remove", &dialog->button_remove,
- "button_import", &dialog->button_import,
- NULL);
- g_free (filename);
-
- empathy_builder_connect (gui, dialog,
- "accounts_dialog", "destroy", accounts_dialog_destroy_cb,
- "accounts_dialog", "response", accounts_dialog_response_cb,
- "button_create", "clicked", accounts_dialog_button_create_clicked_cb,
- "button_back", "clicked", accounts_dialog_button_back_clicked_cb,
- "button_add", "clicked", accounts_dialog_button_add_clicked_cb,
- "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
- "button_import", "clicked", accounts_dialog_button_import_clicked_cb,
- "button_help", "clicked", accounts_dialog_button_help_clicked_cb,
- NULL);
-
- g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog);
-
- g_object_unref (gui);
-
- /* Create profile chooser */
- dialog->combobox_profile = empathy_profile_chooser_new ();
- gtk_box_pack_end (GTK_BOX (dialog->hbox_type),
- dialog->combobox_profile,
- TRUE, TRUE, 0);
- gtk_widget_show (dialog->combobox_profile);
- g_signal_connect (dialog->combobox_profile, "changed",
- G_CALLBACK (accounts_dialog_profile_changed_cb),
- dialog);
-
- /* Set up signalling */
- dialog->account_manager = empathy_account_manager_dup_singleton ();
- dialog->mc = empathy_mission_control_dup_singleton ();
-
- g_signal_connect (dialog->account_manager, "account-created",
- G_CALLBACK (accounts_dialog_account_added_cb),
- dialog);
- g_signal_connect (dialog->account_manager, "account-deleted",
- G_CALLBACK (accounts_dialog_account_removed_cb),
- dialog);
- g_signal_connect (dialog->account_manager, "account-enabled",
- G_CALLBACK (accounts_dialog_account_enabled_cb),
- dialog);
- g_signal_connect (dialog->account_manager, "account-disabled",
- G_CALLBACK (accounts_dialog_account_disabled_cb),
- dialog);
- g_signal_connect (dialog->account_manager, "account-changed",
- G_CALLBACK (accounts_dialog_account_changed_cb),
- dialog);
- g_signal_connect (dialog->account_manager, "account-connection-changed",
- G_CALLBACK (accounts_dialog_connection_changed_cb),
- dialog);
-
- accounts_dialog_model_setup (dialog);
-
- /* Add existing accounts */
- accounts = empathy_account_manager_dup_accounts (dialog->account_manager);
- for (l = accounts; l; l = l->next) {
- accounts_dialog_add_or_update_account (dialog, l->data);
- g_object_unref (l->data);
- }
- g_list_free (accounts);
-
- if (selected_account) {
- accounts_dialog_model_set_selected (dialog, selected_account);
- } else {
- accounts_dialog_model_select_first (dialog);
- }
-
- if (parent) {
- gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
- GTK_WINDOW (parent));
- }
-
- gtk_widget_show (dialog->window);
-
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
-
-
- if (empathy_import_dialog_accounts_to_import ()) {
-
- if (!import_asked) {
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_IMPORT_ASKED, TRUE);
- empathy_import_dialog_show (GTK_WINDOW (dialog->window),
- FALSE);
- }
- } else {
- gtk_widget_set_sensitive (dialog->button_import, FALSE);
- }
-
- return dialog->window;
-}
+ EmpathyAccountsDialog *dialog;
+ EmpathyAccountsDialogPriv *priv;
+
+ dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG,
+ "parent", parent, NULL);
+ priv = GET_PRIV (dialog);
+
+ if (selected_account && empathy_connection_managers_is_ready (priv->cms))
+ accounts_dialog_set_selected_account (dialog, selected_account);
+ else
+ /* save the selection to set it later when the cms
+ * becomes ready.
+ */
+ priv->initial_selection = selected_account;
+
+ gtk_window_present (GTK_WINDOW (priv->window));
+
+ return priv->window;
+}
diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h
index 11e237c8f..aa8f7c06b 100644
--- a/src/empathy-accounts-dialog.h
+++ b/src/empathy-accounts-dialog.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2005-2007 Imendio AB
* Copyright (C) 2007-2008 Collabora Ltd.
@@ -31,8 +30,32 @@
G_BEGIN_DECLS
+#define EMPATHY_TYPE_ACCOUNTS_DIALOG empathy_accounts_dialog_get_type()
+#define EMPATHY_ACCOUNTS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialog))
+#define EMPATHY_ACCOUNTS_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialogClass))
+#define EMPATHY_IS_ACCOUNTS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG))
+#define EMPATHY_IS_ACCOUNTS_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNTS_DIALOG))
+#define EMPATHY_ACCOUNTS_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialogClass))
+
+typedef struct {
+ GObject parent;
+
+ /* private */
+ gpointer priv;
+} EmpathyAccountsDialog;
+
+typedef struct {
+ GObjectClass parent_class;
+} EmpathyAccountsDialogClass;
+
+GType empathy_accounts_dialog_get_type (void);
GtkWidget *empathy_accounts_dialog_show (GtkWindow *parent,
- EmpathyAccount *selected_account);
+ EmpathyAccount *selected_account);
G_END_DECLS
diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui
index da00f45d7..7c899a3cb 100644
--- a/src/empathy-accounts-dialog.ui
+++ b/src/empathy-accounts-dialog.ui
@@ -362,7 +362,7 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame_no_profile">
+ <object class="GtkFrame" id="frame_no_protocol">
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 3e77553b3..822f22826 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -35,7 +35,6 @@
#include <libnotify/notification.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mission-control.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
@@ -1269,7 +1268,7 @@ chat_window_drag_data_received (GtkWidget *widget,
strv = g_strsplit (id, "/", 2);
account_id = strv[0];
contact_id = strv[1];
- account = empathy_account_manager_lookup (account_manager, account_id);
+ account = empathy_account_manager_get_account (account_manager, account_id);
chat = empathy_chat_window_find_chat (account, contact_id);
if (!chat) {
@@ -1282,11 +1281,9 @@ chat_window_drag_data_received (GtkWidget *widget,
connection, contact_id, NULL, NULL);
}
- g_object_unref (account);
g_strfreev (strv);
return;
}
- g_object_unref (account);
g_object_unref (account_manager);
g_strfreev (strv);
@@ -1778,7 +1775,7 @@ empathy_chat_window_find_chat (EmpathyAccount *account,
chat = ll->data;
- if (empathy_account_equal (account, empathy_chat_get_account (chat)) &&
+ if (account == empathy_chat_get_account (chat) &&
!tp_strdiff (id, empathy_chat_get_id (chat))) {
return chat;
}
diff --git a/src/empathy-chatrooms-window.c b/src/empathy-chatrooms-window.c
index 3b5dd1f77..4ec71ec49 100644
--- a/src/empathy-chatrooms-window.c
+++ b/src/empathy-chatrooms-window.c
@@ -514,7 +514,7 @@ chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager,
if (!account) {
chatrooms_window_model_add (window, chatroom, FALSE);
} else {
- if (empathy_account_equal (account, empathy_chatroom_get_account (chatroom))) {
+ if (account == empathy_chatroom_get_account (chatroom)) {
chatrooms_window_model_add (window, chatroom, FALSE);
}
diff --git a/src/empathy-debug-dialog.c b/src/empathy-debug-dialog.c
index 9d047bab1..d71542db0 100644
--- a/src/empathy-debug-dialog.c
+++ b/src/empathy-debug-dialog.c
@@ -284,7 +284,6 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser,
EmpathyDebugDialog *debug_dialog)
{
EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
- MissionControl *mc;
TpDBusDaemon *dbus;
GError *error = NULL;
gchar *bus_name;
@@ -302,13 +301,11 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser,
return;
}
- mc = empathy_mission_control_dup_singleton ();
dbus = tp_dbus_daemon_dup (&error);
if (error != NULL)
{
DEBUG ("Failed at duping the dbus daemon: %s", error->message);
- g_object_unref (mc);
}
gtk_tree_model_get (GTK_TREE_MODEL (priv->cms), &iter,
@@ -344,7 +341,6 @@ debug_dialog_cm_chooser_changed_cb (GtkComboBox *cm_chooser,
debug_dialog_get_messages_cb, debug_dialog, NULL, NULL);
g_object_unref (dbus);
- g_object_unref (mc);
}
typedef struct
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 1a7ec09cb..1be3ff7ce 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -25,6 +25,7 @@
#include <glib/gi18n.h>
#include <telepathy-glib/util.h>
+#include <telepathy-glib/interfaces.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-dispatcher.h>
diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c
index 1e135892d..1d0854dd0 100644
--- a/src/empathy-import-dialog.c
+++ b/src/empathy-import-dialog.c
@@ -99,7 +99,9 @@ import_dialog_add_account (EmpathyImportAccountData *data)
GValue *username;
account_manager = empathy_account_manager_dup_singleton ();
- account = empathy_account_manager_create (account_manager, data->profile);
+ account = empathy_account_manager_create_by_profile (account_manager,
+ data->profile);
+
g_object_unref (account_manager);
if (account == NULL)
{
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index a600fd429..f8e22d91d 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -49,8 +49,6 @@
#include <libempathy-gtk/empathy-sound.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libmissioncontrol/mission-control.h>
-
#include "empathy-accounts-dialog.h"
#include "empathy-main-window.h"
#include "ephy-spinner.h"
@@ -81,7 +79,6 @@
typedef struct {
EmpathyContactListView *list_view;
EmpathyContactListStore *list_store;
- MissionControl *mc;
EmpathyAccountManager *account_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyEventManager *event_manager;
@@ -654,7 +651,6 @@ main_window_destroy_cb (GtkWidget *widget,
g_list_free (window->actions_connected);
- g_object_unref (window->mc);
g_object_unref (window->account_manager);
g_object_unref (window->list_store);
g_hash_table_destroy (window->errors);
@@ -1252,15 +1248,14 @@ empathy_main_window_show (void)
gtk_action_set_visible (show_map_widget, FALSE);
#endif
- window->mc = empathy_mission_control_dup_singleton ();
window->account_manager = empathy_account_manager_dup_singleton ();
g_signal_connect (window->account_manager,
"account-connection-changed",
G_CALLBACK (main_window_connection_changed_cb), window);
- window->errors = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal,
+ window->errors = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
g_object_unref,
NULL);
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index e16da91a7..219be371d 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -32,9 +32,6 @@
#include <glib/gi18n.h>
#include <glib/gprintf.h>
-#include <libmissioncontrol/mission-control.h>
-#include <libmissioncontrol/mc-profile.h>
-
#include <libempathy/empathy-tp-roomlist.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-utils.h>
@@ -358,14 +355,16 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
{
EmpathyAccountChooser *account_chooser;
EmpathyAccount *account;
- McProfile *profile;
const gchar *protocol;
const gchar *room;
account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
account = empathy_account_chooser_dup_account (account_chooser);
- profile = empathy_account_get_profile (account);
- protocol = mc_profile_get_protocol_name (profile);
+
+ if (account == NULL)
+ return;
+
+ protocol = empathy_account_get_protocol (account);
gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), "");
@@ -390,7 +389,6 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
gtk_widget_grab_focus (dialog->entry_room);
g_object_unref (account);
- g_object_unref (profile);
}
static void
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index f6c63c537..aca2d85c2 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -305,24 +305,7 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
if (!visible) {
empathy_window_iconify (priv->window, priv->icon);
} else {
- GList *accounts;
- GList *l;
- gboolean one_enabled = FALSE;
-
empathy_window_present (GTK_WINDOW (priv->window), TRUE);
-
- /* Show the accounts dialog if there is no enabled accounts */
- accounts = empathy_account_manager_dup_accounts (priv->account_manager);
- for (l = accounts ; l != NULL ; l = g_list_next (l)) {
- one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data))
- || one_enabled;
- g_object_unref (l->data);
- }
- g_list_free (accounts);
- if (!one_enabled) {
- DEBUG ("No enabled account, Showing account dialog");
- empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL);
- }
}
}
diff --git a/src/empathy-tube-dispatch.c b/src/empathy-tube-dispatch.c
index 67db5a3a3..66efa217d 100644
--- a/src/empathy-tube-dispatch.c
+++ b/src/empathy-tube-dispatch.c
@@ -25,6 +25,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/proxy-subclass.h>
+#include <telepathy-glib/interfaces.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
diff --git a/src/empathy.c b/src/empathy.c
index 4ff0918fd..637470773 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -40,13 +40,16 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mission-control.h>
+#include <telepathy-glib/connection-manager.h>
+#include <telepathy-glib/interfaces.h>
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-account-settings.h>
#include <libempathy/empathy-account-manager.h>
+#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-debugger.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-dispatch-operation.h>
@@ -110,7 +113,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
manager = empathy_account_manager_dup_singleton ();
connection = empathy_tp_chat_get_connection (tp_chat);
- account = empathy_account_manager_get_account (manager,
+ account = empathy_account_manager_get_account_for_connection (manager,
connection);
chat = empathy_chat_window_find_chat (account, id);
g_object_unref (manager);
@@ -146,89 +149,91 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
}
static void
-service_ended_cb (MissionControl *mc,
- gpointer user_data)
+use_nm_notify_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
{
- DEBUG ("Mission Control stopped");
+ EmpathyIdle *idle = user_data;
+ gboolean use_nm;
+
+ if (empathy_conf_get_bool (conf, key, &use_nm)) {
+ empathy_idle_set_use_nm (idle, use_nm);
+ }
}
-static void
-operation_error_cb (MissionControl *mc,
- guint operation_id,
- guint error_code,
- gpointer user_data)
+/* Salut account creation */
+static gboolean
+should_create_salut_account (void)
{
- const gchar *message;
-
- switch (error_code) {
- case MC_DISCONNECTED_ERROR:
- message = "Disconnected";
- break;
- case MC_INVALID_HANDLE_ERROR:
- message = "Invalid handle";
- break;
- case MC_NO_MATCHING_CONNECTION_ERROR:
- message = "No matching connection";
- break;
- case MC_INVALID_ACCOUNT_ERROR:
- message = "Invalid account";
- break;
- case MC_PRESENCE_FAILURE_ERROR:
- message = "Presence failure";
- break;
- case MC_NO_ACCOUNTS_ERROR:
- message = "No accounts";
- break;
- case MC_NETWORK_ERROR:
- message = "Network error";
- break;
- case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR:
- message = "Contact does not support voice";
- break;
- case MC_LOWMEM_ERROR:
- message = "Lowmem";
- break;
- case MC_CHANNEL_REQUEST_GENERIC_ERROR:
- message = "Channel request generic error";
- break;
- case MC_CHANNEL_BANNED_ERROR:
- message = "Channel banned";
- break;
- case MC_CHANNEL_FULL_ERROR:
- message = "Channel full";
- break;
- case MC_CHANNEL_INVITE_ONLY_ERROR:
- message = "Channel invite only";
- break;
- default:
- message = "Unknown error code";
+ EmpathyAccountManager *manager;
+ gboolean salut_created = FALSE;
+ GList *accounts, *l;
+
+ /* Check if we already created a salut account */
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ &salut_created);
+
+ if (salut_created)
+ {
+ DEBUG ("Gconf says we already created a salut account once");
+ return FALSE;
+ }
+
+ manager = empathy_account_manager_dup_singleton ();
+ accounts = empathy_account_manager_dup_accounts (manager);
+
+ for (l = accounts; l != NULL; l = g_list_next (l)) {
+ EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+
+ if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
+ salut_created = TRUE;
+
+ g_object_unref (account);
}
- DEBUG ("Error during operation %d: %s", operation_id, message);
+ g_object_unref (manager);
+
+ if (salut_created)
+ {
+ DEBUG ("Existing salut account already exists, flagging so in gconf");
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ TRUE);
+ }
+
+ return !salut_created;
}
static void
-use_nm_notify_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
+salut_account_created (GObject *source,
+ GAsyncResult *result, gpointer user_data)
{
- EmpathyIdle *idle = user_data;
- gboolean use_nm;
+ EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
+ EmpathyAccount *account;
+ GError *error = NULL;
+
+ if (!empathy_account_settings_apply_finish (settings, result, &error))
+ {
+ DEBUG ("Failed to create salut account: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- if (empathy_conf_get_bool (conf, key, &use_nm)) {
- empathy_idle_set_use_nm (idle, use_nm);
- }
+ account = empathy_account_settings_get_account (settings);
+
+ empathy_account_set_enabled (account, TRUE);
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ TRUE);
}
static void
-create_salut_account (void)
+create_salut_account_if_needed (EmpathyConnectionManagers *managers)
{
- McProfile *profile;
- McProtocol *protocol;
- gboolean salut_created = FALSE;
- EmpathyAccount *account;
- EmpathyAccountManager *account_manager;
- GList *accounts;
+ EmpathyAccountSettings *settings;
+ TpConnectionManager *manager;
+ const TpConnectionManagerProtocol *protocol;
EBook *book;
EContact *contact;
gchar *nickname = NULL;
@@ -238,56 +243,36 @@ create_salut_account (void)
gchar *jid = NULL;
GError *error = NULL;
- /* Check if we already created a salut account */
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
- &salut_created);
- if (salut_created) {
+
+ if (!should_create_salut_account ())
return;
- }
- DEBUG ("Try to add a salut account...");
+ manager = empathy_connection_managers_get_cm (managers, "salut");
+ if (manager == NULL)
+ {
+ DEBUG ("Salut not installed, not making a salut account");
+ return;
+ }
- /* Check if the salut CM is installed */
- profile = mc_profile_lookup ("salut");
- if (!profile) {
- DEBUG ("No salut profile");
- return;
- }
- protocol = mc_profile_get_protocol (profile);
- if (!protocol) {
- DEBUG ("Salut not installed");
- g_object_unref (profile);
- return;
- }
- g_object_unref (protocol);
+ protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
+ if (protocol == NULL)
+ {
+ DEBUG ("Salut doesn't support local-xmpp!!");
+ return;
+ }
+
+ DEBUG ("Trying to add a salut account...");
/* Get self EContact from EDS */
if (!e_book_get_self (&contact, &book, &error)) {
DEBUG ("Failed to get self econtact: %s",
error ? error->message : "No error given");
g_clear_error (&error);
- g_object_unref (profile);
return;
}
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
- TRUE);
-
- /* Check if there is already a salut account */
- accounts = mc_accounts_list_by_profile (profile);
- if (accounts) {
- DEBUG ("There is already a salut account");
- mc_accounts_list_free (accounts);
- g_object_unref (profile);
- return;
- }
-
- account_manager = empathy_account_manager_dup_singleton ();
- account = empathy_account_manager_create (account_manager, profile);
- empathy_account_set_display_name (account, _("People nearby"));
- g_object_unref (account_manager);
+ settings = empathy_account_settings_new ("salut", "local-xmpp",
+ _("People nearby"));
nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
@@ -304,24 +289,60 @@ create_salut_account (void)
"last-name=%s\nemail=%s\njid=%s\n",
nickname, first_name, last_name, email, jid);
- empathy_account_set_param_string (account, "nickname", nickname ? nickname : "");
- empathy_account_set_param_string (account, "first-name", first_name ? first_name : "");
- empathy_account_set_param_string (account, "last-name", last_name ? last_name : "");
- empathy_account_set_param_string (account, "email", email ? email : "");
- empathy_account_set_param_string (account, "jid", jid ? jid : "");
+ empathy_account_settings_set_string (settings, "nickname", nickname ? nickname : "");
+ empathy_account_settings_set_string (settings, "first-name", first_name ? first_name : "");
+ empathy_account_settings_set_string (settings, "last-name", last_name ? last_name : "");
+ empathy_account_settings_set_string (settings, "email", email ? email : "");
+ empathy_account_settings_set_string (settings, "jid", jid ? jid : "");
+
+ empathy_account_settings_apply_async (settings,
+ salut_account_created, NULL);
g_free (nickname);
g_free (first_name);
g_free (last_name);
g_free (email);
g_free (jid);
- g_object_unref (account);
- g_object_unref (profile);
+ g_object_unref (settings);
g_object_unref (contact);
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;
@@ -539,6 +560,22 @@ default_log_handler (const gchar *log_domain,
}
#endif /* ENABLE_DEBUG */
+static void
+account_manager_ready_cb (EmpathyAccountManager *manager,
+ GParamSpec *spec,
+ gpointer user_data)
+{
+ if (!empathy_account_manager_is_ready (manager))
+ return;
+
+ if (empathy_account_manager_get_count (manager) == 0)
+ {
+ empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()),
+ NULL);
+ }
+ create_salut_account ();
+}
+
int
main (int argc, char *argv[])
{
@@ -548,12 +585,12 @@ main (int argc, char *argv[])
#endif
EmpathyStatusIcon *icon;
EmpathyDispatcher *dispatcher;
+ EmpathyAccountManager *account_manager;
EmpathyLogManager *log_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyCallFactory *call_factory;
EmpathyFTFactory *ft_factory;
GtkWidget *window;
- MissionControl *mc;
EmpathyIdle *idle;
gboolean autoconnect = TRUE;
gboolean no_connect = FALSE;
@@ -660,15 +697,6 @@ main (int argc, char *argv[])
g_clear_error (&error);
}
- /* Setting up MC */
- mc = empathy_mission_control_dup_singleton ();
- g_signal_connect (mc, "ServiceEnded",
- G_CALLBACK (service_ended_cb),
- NULL);
- g_signal_connect (mc, "Error",
- G_CALLBACK (operation_error_cb),
- NULL);
-
if (accounts_dialog) {
GtkWidget *dialog;
@@ -695,12 +723,15 @@ 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);
migrate_config_to_xdg_dir ();
- create_salut_account ();
/* Setting up UI */
window = empathy_main_window_show ();
@@ -745,9 +776,9 @@ main (int argc, char *argv[])
empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
- g_object_unref (mc);
g_object_unref (idle);
g_object_unref (icon);
+ g_object_unref (account_manager);
g_object_unref (log_manager);
g_object_unref (dispatcher);
g_object_unref (chatroom_manager);
@@ -760,4 +791,3 @@ main (int argc, char *argv[])
return EXIT_SUCCESS;
}
-