diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2010-03-02 19:39:14 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2010-03-02 19:39:14 +0800 |
commit | 41ca7cb4fea39f928976b7b69466a61c78a5f7ed (patch) | |
tree | 6fb60beb6cf57f68bf94ba5b134bdffc04b1c01b /src/empathy-accounts.c | |
parent | 74b2a167ce29bbda607b1b1a0ac8ef96c51a924c (diff) | |
parent | 3c8e671463630b94f8238ea8caaf6a03b2165278 (diff) | |
download | gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar.gz gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar.bz2 gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar.lz gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar.xz gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.tar.zst gsoc2013-empathy-41ca7cb4fea39f928976b7b69466a61c78a5f7ed.zip |
Merge branch 'accounts-wizard'
Diffstat (limited to 'src/empathy-accounts.c')
-rw-r--r-- | src/empathy-accounts.c | 105 |
1 files changed, 47 insertions, 58 deletions
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c index 942f6a475..b97bc4533 100644 --- a/src/empathy-accounts.c +++ b/src/empathy-accounts.c @@ -53,50 +53,58 @@ #define EMPATHY_ACCOUNTS_DBUS_NAME "org.gnome.EmpathyAccounts" -static gboolean try_import = FALSE; +static gboolean only_if_needed = FALSE; static gboolean hidden = FALSE; static gchar *selected_account_name = NULL; static void -account_manager_ready_for_assistant_cb (GObject *source_object, +account_prepare_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { - TpAccountManager *account_mgr = TP_ACCOUNT_MANAGER (source_object); + TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data); + TpAccount *account = TP_ACCOUNT (source_object); GError *error = NULL; - if (!tp_account_manager_prepare_finish (account_mgr, result, &error)) + if (!tp_account_prepare_finish (account, result, &error)) { - DEBUG ("Failed to prepare account manager: %s", error->message); + DEBUG ("Failed to prepare account: %s", error->message); g_error_free (error); - return; + + account = NULL; } - g_object_set_data (G_OBJECT (account_mgr), "assistant-destroy-callback", + empathy_accounts_show_accounts_ui (manager, account, G_CALLBACK (gtk_main_quit)); +} - empathy_accounts_manager_ready_for_show_assistant (account_mgr, hidden); +static void +maybe_show_accounts_ui (TpAccountManager *manager) +{ + if (hidden || + (only_if_needed && empathy_accounts_has_non_salut_accounts (manager))) + gtk_main_quit (); + else + empathy_accounts_show_accounts_ui (manager, NULL, gtk_main_quit); } static void -account_prepare_cb (GObject *source_object, +cm_manager_prepared_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data); - TpAccount *account = TP_ACCOUNT (source_object); - GError *error = NULL; - - if (!tp_account_prepare_finish (account, result, &error)) + if (!empathy_connection_managers_prepare_finish ( + EMPATHY_CONNECTION_MANAGERS (source), result, NULL)) { - DEBUG ("Failed to prepare account: %s", error->message); - g_error_free (error); - - account = NULL; + g_warning ("Failed to prepare connection managers singleton"); + gtk_main_quit (); + return; } - empathy_accounts_show_accounts_ui (manager, account, - G_CALLBACK (gtk_main_quit)); + empathy_accounts_import (TP_ACCOUNT_MANAGER (user_data), + EMPATHY_CONNECTION_MANAGERS (source)); + + maybe_show_accounts_ui (TP_ACCOUNT_MANAGER (user_data)); } static void @@ -115,7 +123,7 @@ account_manager_ready_for_accounts_cb (GObject *source_object, return; } - if (account_id) + if (account_id != NULL) { gchar *account_path; TpAccount *account = NULL; @@ -143,8 +151,18 @@ account_manager_ready_for_accounts_cb (GObject *source_object, } else { - empathy_accounts_show_accounts_ui (manager, NULL, - G_CALLBACK (gtk_main_quit)); + if (empathy_import_mc4_has_imported ()) + { + maybe_show_accounts_ui (manager); + } + else + { + EmpathyConnectionManagers *cm_mgr = + empathy_connection_managers_dup_singleton (); + + empathy_connection_managers_prepare_async ( + cm_mgr, cm_manager_prepared_cb, manager); + } } } @@ -191,15 +209,14 @@ main (int argc, char *argv[]) GOptionContext *optcontext; GOptionEntry options[] = { - { "import", 'i', - G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &try_import, - N_("Try to import any recognized accounts and display an assistant if " - "that fails"), - NULL }, { "hidden", 'h', 0, G_OPTION_ARG_NONE, &hidden, N_("Don't display any dialogs; do any work (eg, importing) and exit"), NULL }, + { "if-needed", 'n', + 0, G_OPTION_ARG_NONE, &only_if_needed, + N_("Don't display any dialogs if there are any non-salut accounts"), + NULL }, { "select-account", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &selected_account_name, N_("Initially select given account (eg, " @@ -242,38 +259,10 @@ main (int argc, char *argv[]) return EXIT_SUCCESS; } - /* Take well-known name */ - dbus_daemon = tp_dbus_daemon_dup (&error); - if (error == NULL) - { - if (!tp_dbus_daemon_request_name (dbus_daemon, - EMPATHY_ACCOUNTS_DBUS_NAME, TRUE, &error)) - { - DEBUG ("Failed to request well-known name: %s", - error ? error->message : "no message"); - g_clear_error (&error); - } - g_object_unref (dbus_daemon); - } - else - { - DEBUG ("Failed to dup dbus daemon: %s", - error ? error->message : "no message"); - g_clear_error (&error); - } - account_manager = tp_account_manager_dup (); - if (try_import) - { - tp_account_manager_prepare_async (account_manager, NULL, - account_manager_ready_for_assistant_cb, NULL); - } - else - { - tp_account_manager_prepare_async (account_manager, NULL, - account_manager_ready_for_accounts_cb, selected_account_name); - } + tp_account_manager_prepare_async (account_manager, NULL, + account_manager_ready_for_accounts_cb, selected_account_name); g_signal_connect (unique_app, "message-received", G_CALLBACK (unique_app_message_cb), NULL); |