#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mc-profile.h>
-#include <libmissioncontrol/mission-control.h>
-#include <libmissioncontrol/mc-account-monitor.h>
#include <telepathy-glib/util.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-account-manager.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-profile-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"
+#include "empathy-import-dialog.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
GtkWidget *alignment_settings;
GtkWidget *vbox_details;
- GtkWidget *frame_no_account;
- GtkWidget *label_no_account;
- GtkWidget *label_no_account_blurb;
+ GtkWidget *frame_no_profile;
GtkWidget *treeview;
GtkWidget *button_add;
GtkWidget *button_remove;
+ GtkWidget *button_import;
GtkWidget *frame_new_account;
GtkWidget *combobox_profile;
GtkWidget *hbox_type;
GtkWidget *button_create;
GtkWidget *button_back;
+ GtkWidget *checkbutton_register;
GtkWidget *image_type;
GtkWidget *label_name;
gboolean connecting_show;
guint connecting_id;
- gboolean account_changed;
- MissionControl *mc;
- McAccountMonitor *monitor;
- gpointer token;
+ EmpathyAccountManager *account_manager;
+ MissionControl *mc;
} EmpathyAccountsDialog;
enum {
COL_COUNT
};
-static void accounts_dialog_setup (EmpathyAccountsDialog *dialog);
static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
McAccount *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,
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_account (EmpathyAccountsDialog *dialog,
+static void accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
McAccount *account);
-static void accounts_dialog_account_added_cb (McAccountMonitor *monitor,
- gchar *unique_name,
+static void accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
+ McAccount *account,
EmpathyAccountsDialog *dialog);
-static void accounts_dialog_account_removed_cb (McAccountMonitor *monitor,
- gchar *unique_name,
+static void accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
+ McAccount *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_status_changed_cb (MissionControl *mc,
- TpConnectionStatus status,
- McPresence presence,
+static void accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
+ McAccount *account,
TpConnectionStatusReason reason,
- const gchar *unique_name,
+ TpConnectionStatus current,
+ TpConnectionStatus previous,
EmpathyAccountsDialog *dialog);
static void accounts_dialog_button_create_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog);
EmpathyAccountsDialog *dialog);
static void accounts_dialog_button_help_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog);
-static void accounts_dialog_remove_response_cb (GtkWidget *dialog,
- gint response,
- McAccount *account);
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);
EmpathyAccountsDialog *dialog);
static void
-accounts_dialog_setup (EmpathyAccountsDialog *dialog)
+accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
+ McAccount *account)
{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeIter iter;
- GList *accounts, *l;
-
- view = GTK_TREE_VIEW (dialog->treeview);
- store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
-
- accounts = mc_accounts_list ();
+ gchar *text;
- for (l = accounts; l; l = l->next) {
- McAccount *account;
- const gchar *name;
- TpConnectionStatus status;
- gboolean enabled;
+ text = g_markup_printf_escaped ("<big><b>%s</b></big>",
+ mc_account_get_display_name (account));
+ gtk_label_set_markup (GTK_LABEL (dialog->label_name), text);
- account = l->data;
-
- name = mc_account_get_display_name (account);
- if (!name) {
- g_object_unref (account);
- continue;
- }
-
- status = mission_control_get_connection_status (dialog->mc, account, NULL);
- enabled = mc_account_is_enabled (account);
-
- gtk_list_store_insert_with_values (store, &iter,
- -1,
- COL_ENABLED, enabled,
- COL_NAME, name,
- COL_STATUS, status,
- COL_ACCOUNT_POINTER, account,
- -1);
-
- accounts_dialog_status_changed_cb (dialog->mc,
- status,
- MC_PRESENCE_UNSET,
- TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
- mc_account_get_unique_name (account),
- dialog);
-
- g_object_unref (account);
- }
-
- g_list_free (accounts);
+ g_free (text);
}
static void
accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
McAccount *account)
{
- if (dialog->settings_widget) {
- gtk_widget_destroy (dialog->settings_widget);
- dialog->settings_widget = NULL;
- }
+ McProfile *profile;
+ const gchar *config_ui;
if (!account) {
GtkTreeView *view;
GtkTreeModel *model;
- GString *string;
- gchar *str;
-
- gtk_widget_show (dialog->frame_no_account);
- gtk_widget_hide (dialog->vbox_details);
-
- gtk_widget_set_sensitive (dialog->button_remove, FALSE);
view = GTK_TREE_VIEW (dialog->treeview);
model = gtk_tree_view_get_model (view);
- if (empathy_profile_chooser_n_profiles (dialog->combobox_profile) > 0) {
- string = g_string_new (_("To add a new account, you can click on the "
- "'Add' button and a new entry will be created "
- "for you to start configuring."));
- } else {
- string = g_string_new (_("To add a new account, you first have to "
- "install a backend for each protocol "
- "you want to use."));
- }
-
if (gtk_tree_model_iter_n_children (model, NULL) > 0) {
- gtk_label_set_markup (GTK_LABEL (dialog->label_no_account),
- _("<b>No Account Selected</b>"));
- g_string_append (string, _("\n\n"
- "If you do not want to add an account, simply "
- "click on the account you want to configure in "
- "the list on the left."));
- } else {
- gtk_label_set_markup (GTK_LABEL (dialog->label_no_account),
- _("<b>No Accounts Configured</b>"));
+ /* We have configured accounts, select the first one */
+ accounts_dialog_model_select_first (dialog);
+ return;
+ }
+ if (empathy_profile_chooser_n_profiles (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;
}
- str = g_string_free (string, FALSE);
- gtk_label_set_markup (GTK_LABEL (dialog->label_no_account_blurb),
- str);
- g_free (str);
- } else {
- McProfile *profile;
- const gchar *config_ui;
-
- gtk_widget_hide (dialog->frame_no_account);
- gtk_widget_show (dialog->vbox_details);
+ /* 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;
+ }
- profile = mc_account_get_profile (account);
- config_ui = mc_profile_get_configuration_ui (profile);
- g_object_unref (profile);
+ /* 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 (!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);
- }
+ if (dialog->settings_widget) {
+ gtk_widget_destroy (dialog->settings_widget);
+ dialog->settings_widget = NULL;
}
- if (dialog->settings_widget) {
- gtk_container_add (GTK_CONTAINER (dialog->alignment_settings),
- dialog->settings_widget);
+ profile = mc_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);
}
- if (account) {
- McProfile *profile;
- gchar *text;
+ gtk_container_add (GTK_CONTAINER (dialog->alignment_settings),
+ dialog->settings_widget);
- profile = mc_account_get_profile (account);
- 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));
-
- text = g_markup_printf_escaped ("<big><b>%s</b></big>",
- mc_account_get_display_name (account));
- gtk_label_set_markup (GTK_LABEL (dialog->label_name), text);
- g_free (text);
- }
+
+ 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);
}
static void
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);
g_object_unref (account);
}
+static void
+accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
+ GtkCellEditable *editable,
+ gchar *path,
+ EmpathyAccountsDialog *dialog)
+{
+ if (dialog->connecting_id) {
+ g_source_remove (dialog->connecting_id);
+ }
+ DEBUG ("Editing account name started; stopping flashing");
+}
+
static void
accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
{
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 void
is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
- gtk_widget_set_sensitive (dialog->button_add, TRUE);
- gtk_widget_set_sensitive (dialog->button_remove, is_selection);
-
account = accounts_dialog_model_get_selected (dialog);
accounts_dialog_update_account (dialog, account);
if (account) {
g_object_unref (account);
}
-
- /* insure new account frame is hidden when a row is selected*/
- gtk_widget_hide (dialog->frame_new_account);
}
static void
-accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
- McAccount *account)
+accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
+ McAccount *account)
{
GtkTreeModel *model;
GtkTreeIter iter;
const gchar *name;
gboolean enabled;
- if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
- return;
- }
-
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
status = mission_control_get_connection_status (dialog->mc, account, NULL);
name = mc_account_get_display_name (account);
enabled = mc_account_is_enabled (account);
- g_return_if_fail (name != NULL);
+ if (!accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ DEBUG ("Adding new account");
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ }
- DEBUG ("Adding new account: %s", name);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, enabled,
+ COL_NAME, name,
+ COL_STATUS, status,
+ COL_ACCOUNT_POINTER, account,
+ -1);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter,
- -1,
- 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);
}
static void
-accounts_dialog_account_added_cb (McAccountMonitor *monitor,
- gchar *unique_name,
+accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
+ McAccount *account,
EmpathyAccountsDialog *dialog)
{
- McAccount *account;
+ 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 McAccount but
+ * it's not set until first connection, so we get the "account"
+ * parameter for CM that have it. */
+ current_name = mc_account_get_display_name (account);
+ mc_account_get_param_string (account, "account", &account_param);
+ if (!EMP_STR_EMPTY (account_param)) {
+ McProfile *profile;
+ const gchar *profile_name;
+ gchar *new_name;
- account = mc_account_lookup (unique_name);
- accounts_dialog_add_account (dialog, account);
- g_object_unref (account);
+ profile = mc_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'",
+ mc_account_get_unique_name (account), new_name);
+
+ mc_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);
}
static void
-accounts_dialog_account_removed_cb (McAccountMonitor *monitor,
- gchar *unique_name,
+accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
+ McAccount *account,
EmpathyAccountsDialog *dialog)
{
- McAccount *account;
-
- account = mc_account_lookup (unique_name);
accounts_dialog_model_set_selected (dialog, account);
accounts_dialog_model_remove_selected (dialog);
-
- g_object_unref (account);
}
static gboolean
}
static void
-accounts_dialog_status_changed_cb (MissionControl *mc,
- TpConnectionStatus status,
- McPresence presence,
- TpConnectionStatusReason reason,
- const gchar *unique_name,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_connection_changed_cb (EmpathyAccountManager *manager,
+ McAccount *account,
+ TpConnectionStatusReason reason,
+ TpConnectionStatus current,
+ TpConnectionStatus previous,
+ EmpathyAccountsDialog *dialog)
{
GtkTreeModel *model;
GtkTreeIter iter;
- McAccount *account;
- GList *accounts, *l;
- gboolean found = FALSE;
+ gboolean found;
/* Update the status in the model */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- account = mc_account_lookup (unique_name);
-
- DEBUG ("Status changed for account %s: status=%d presence=%d",
- unique_name, status, presence);
if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
GtkTreePath *path;
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_STATUS, status,
+ 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);
}
- g_object_unref (account);
- /* Check if there is still accounts in CONNECTING state */
- accounts = mc_accounts_list_by_enabled (TRUE);
- for (l = accounts; l; l = l->next) {
- McAccount *this_account = l->data;
- TpConnectionStatus status;
-
- if (found) {
- g_object_unref (this_account);
- continue;
- }
-
- status = mission_control_get_connection_status (mc, this_account, NULL);
- if (status == TP_CONNECTION_STATUS_CONNECTING) {
- found = TRUE;
- }
-
- g_object_unref (this_account);
- }
- g_list_free (accounts);
+ found = (empathy_account_manager_get_connecting_accounts (manager) > 0);
if (!found && dialog->connecting_id) {
g_source_remove (dialog->connecting_id);
dialog->connecting_id = 0;
}
+
if (found && !dialog->connecting_id) {
dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT,
(GSourceFunc) accounts_dialog_flash_connecting_cb,
}
static void
-accounts_dialog_account_enabled_cb (McAccountMonitor *monitor,
- gchar *unique_name,
- EmpathyAccountsDialog *dialog)
+enable_or_disable_account (EmpathyAccountsDialog *dialog,
+ McAccount *account,
+ gboolean enabled)
{
GtkTreeModel *model;
GtkTreeIter iter;
- McAccount *account;
- gboolean enabled;
/* Update the status in the model */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
- account = mc_account_lookup (unique_name);
- enabled = mc_account_is_enabled (account);
DEBUG ("Account %s is now %s",
mc_account_get_display_name (account),
COL_ENABLED, enabled,
-1);
}
+}
- g_object_unref (account);
+static void
+accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
+ McAccount *account,
+ EmpathyAccountsDialog *dialog)
+{
+ enable_or_disable_account (dialog, account, FALSE);
+}
+
+static void
+accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
+ McAccount *account,
+ EmpathyAccountsDialog *dialog)
+{
+ enable_or_disable_account (dialog, account, TRUE);
+}
+
+static void
+accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
+ McAccount *account,
+ EmpathyAccountsDialog *dialog)
+{
+ McAccount *selected_account;
+
+ 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);
+ }
}
static void
accounts_dialog_button_create_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
- McProfile *profile;
- McAccount *account;
- const gchar *str;
-
- /* Update widgets */
- gtk_widget_show (dialog->vbox_details);
- gtk_widget_hide (dialog->frame_no_account);
- gtk_widget_hide (dialog->frame_new_account);
+ McProfile *profile;
+ McAccount *account;
+ gchar *str;
+ McProfileCapabilityFlags cap;
profile = empathy_profile_chooser_get_selected (dialog->combobox_profile);
/* Create account */
account = mc_account_create (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... */
+ return;
+ }
- str = mc_account_get_unique_name (account);
+ /* To translator: %s is the protocol name */
+ str = g_strdup_printf (_("New %s account"),
+ mc_profile_get_display_name (profile));
mc_account_set_display_name (account, str);
+ g_free (str);
+
+ cap = mc_profile_get_capabilities (profile);
+ if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) {
+ gboolean active;
- accounts_dialog_add_account (dialog, account);
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_register));
+ if (!active) {
+ mc_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);
{
McAccount *account;
- gtk_widget_hide (dialog->vbox_details);
- gtk_widget_hide (dialog->frame_no_account);
- gtk_widget_hide (dialog->frame_new_account);
-
- gtk_widget_set_sensitive (dialog->button_add, TRUE);
-
account = accounts_dialog_model_get_selected (dialog);
accounts_dialog_update_account (dialog, account);
}
+static void
+accounts_dialog_profile_changed_cb (GtkWidget *widget,
+ EmpathyAccountsDialog *dialog)
+{
+ McProfile *profile;
+ McProfileCapabilityFlags cap;
+
+ profile = empathy_profile_chooser_get_selected (dialog->combobox_profile);
+ cap = mc_profile_get_capabilities (profile);
+
+ if (cap & MC_PROFILE_CAPABILITY_REGISTRATION_UI) {
+ gtk_widget_show (dialog->checkbutton_register);
+ } else {
+ gtk_widget_hide (dialog->checkbutton_register);
+ }
+ g_object_unref (profile);
+}
+
static void
accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
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_account);
+ 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->checkbutton_register, dialog);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_register),
+ TRUE);
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_profile), 0);
gtk_widget_grab_focus (dialog->combobox_profile);
}
accounts_dialog_button_help_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
- empathy_url_show ("ghelp:empathy?empathy-create-account");
-}
-
-static void
-accounts_dialog_remove_response_cb (GtkWidget *dialog,
- gint response,
- McAccount *account)
-{
- if (response == GTK_RESPONSE_YES) {
- mc_account_delete (account);
- }
-
- gtk_widget_destroy (dialog);
+ empathy_url_show (button, "ghelp:empathy?empathy-create-account");
}
static void
{
McAccount *account;
GtkWidget *message_dialog;
+ gint res;
account = accounts_dialog_model_get_selected (dialog);
if (!mc_account_is_complete (account)) {
accounts_dialog_model_remove_selected (dialog);
+ accounts_dialog_model_select_first (dialog);
return;
}
message_dialog = gtk_message_dialog_new
GTK_STOCK_REMOVE,
GTK_RESPONSE_YES);
- g_signal_connect (message_dialog, "response",
- G_CALLBACK (accounts_dialog_remove_response_cb),
- account);
-
gtk_widget_show (message_dialog);
+ res = gtk_dialog_run (GTK_DIALOG (message_dialog));
+
+ if (res == GTK_RESPONSE_YES) {
+ mc_account_delete (account);
+ accounts_dialog_model_select_first (dialog);
+ }
+ gtk_widget_destroy (message_dialog);
+}
+
+static void
+accounts_dialog_button_import_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
+{
+ empathy_import_dialog_show (GTK_WINDOW (dialog->window), TRUE);
}
static void
GList *accounts, *l;
/* Disconnect signals */
- g_signal_handlers_disconnect_by_func (dialog->monitor,
+ g_signal_handlers_disconnect_by_func (dialog->account_manager,
accounts_dialog_account_added_cb,
dialog);
- g_signal_handlers_disconnect_by_func (dialog->monitor,
+ g_signal_handlers_disconnect_by_func (dialog->account_manager,
accounts_dialog_account_removed_cb,
dialog);
- g_signal_handlers_disconnect_by_func (dialog->monitor,
+ g_signal_handlers_disconnect_by_func (dialog->account_manager,
accounts_dialog_account_enabled_cb,
dialog);
- empathy_disconnect_account_status_changed (dialog->token);
+ 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 = mc_accounts_list ();
g_source_remove (dialog->connecting_id);
}
+ g_object_unref (dialog->account_manager);
g_object_unref (dialog->mc);
- g_object_unref (dialog->monitor);
g_free (dialog);
}
static EmpathyAccountsDialog *dialog = NULL;
GladeXML *glade;
gchar *filename;
+ GList *accounts, *l;
+ gboolean import_asked;
if (dialog) {
gtk_window_present (GTK_WINDOW (dialog->window));
NULL,
"accounts_dialog", &dialog->window,
"vbox_details", &dialog->vbox_details,
- "frame_no_account", &dialog->frame_no_account,
- "label_no_account", &dialog->label_no_account,
- "label_no_account_blurb", &dialog->label_no_account_blurb,
+ "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,
+ "checkbutton_register", &dialog->checkbutton_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);
"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);
dialog->combobox_profile,
TRUE, TRUE, 0);
gtk_widget_show (dialog->combobox_profile);
- if (empathy_profile_chooser_n_profiles (dialog->combobox_profile) <= 0) {
- gtk_widget_set_sensitive (dialog->button_add, FALSE);
- }
+ g_signal_connect (dialog->combobox_profile, "changed",
+ G_CALLBACK (accounts_dialog_profile_changed_cb),
+ dialog);
/* Set up signalling */
- dialog->mc = empathy_mission_control_new ();
- dialog->monitor = mc_account_monitor_new ();
+ dialog->account_manager = empathy_account_manager_dup_singleton ();
+ dialog->mc = empathy_mission_control_dup_singleton ();
- g_signal_connect (dialog->monitor, "account-created",
+ g_signal_connect (dialog->account_manager, "account-created",
G_CALLBACK (accounts_dialog_account_added_cb),
dialog);
- g_signal_connect (dialog->monitor, "account-deleted",
+ g_signal_connect (dialog->account_manager, "account-deleted",
G_CALLBACK (accounts_dialog_account_removed_cb),
dialog);
- g_signal_connect (dialog->monitor, "account-enabled",
+ g_signal_connect (dialog->account_manager, "account-enabled",
G_CALLBACK (accounts_dialog_account_enabled_cb),
dialog);
- g_signal_connect (dialog->monitor, "account-disabled",
- G_CALLBACK (accounts_dialog_account_enabled_cb),
+ 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);
- dialog->token = empathy_connect_to_account_status_changed (dialog->mc,
- G_CALLBACK (accounts_dialog_status_changed_cb),
- dialog, NULL);
accounts_dialog_model_setup (dialog);
- accounts_dialog_setup (dialog);
+
+ /* Add existing accounts */
+ accounts = mc_accounts_list ();
+ 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);
gtk_widget_show (dialog->window);
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
+
+ if (!import_asked) {
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_IMPORT_ASKED, TRUE);
+ empathy_import_dialog_show (GTK_WINDOW (dialog->window),
+ FALSE);
+ }
+
return dialog->window;
}