aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/empathy-accounts-common.c56
-rw-r--r--src/empathy-accounts-common.h4
-rw-r--r--src/empathy-accounts-dialog.c6
-rw-r--r--src/empathy-accounts-dialog.h2
-rw-r--r--src/empathy-accounts.c85
-rw-r--r--src/empathy.c5
6 files changed, 55 insertions, 103 deletions
diff --git a/src/empathy-accounts-common.c b/src/empathy-accounts-common.c
index cf730fab2..ff9c8c438 100644
--- a/src/empathy-accounts-common.c
+++ b/src/empathy-accounts-common.c
@@ -111,7 +111,7 @@ do_show_accounts_ui (TpAccountManager *manager,
gtk_window_present (GTK_WINDOW (accounts_window));
}
-static GtkWidget*
+static GtkWidget *
show_account_assistant (EmpathyConnectionManagers *connection_mgrs,
GCallback assistant_destroy_cb)
{
@@ -125,60 +125,6 @@ show_account_assistant (EmpathyConnectionManagers *connection_mgrs,
}
static void
-connection_managers_prepare_cb (
- EmpathyConnectionManagers *cm_mgr,
- GAsyncResult *result,
- gpointer user_data)
-{
- GCallback assistant_destroy_cb = g_object_get_data (G_OBJECT (cm_mgr),
- "assistant-destroy-callback");
- TpAccountManager *account_mgr = g_object_get_data (G_OBJECT (cm_mgr),
- "account-manager");
- gboolean hidden = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cm_mgr),
- "hidden"));
-
- if (!empathy_connection_managers_prepare_finish (cm_mgr, result, NULL))
- goto out;
-
- if (empathy_accounts_import (account_mgr, cm_mgr) &&
- !hidden)
- {
- show_account_assistant (cm_mgr, assistant_destroy_cb);
- }
- else if (!empathy_accounts_has_non_salut_accounts (account_mgr))
- {
- show_account_assistant (cm_mgr, assistant_destroy_cb);
- }
- else
- {
- if (assistant_destroy_cb)
- assistant_destroy_cb ();
- }
-
-out:
- g_object_unref (cm_mgr);
-}
-
-void
-empathy_accounts_manager_ready_for_show_assistant (
- TpAccountManager *account_mgr,
- gboolean hidden)
-{
- EmpathyConnectionManagers *cm_mgr;
-
- cm_mgr = empathy_connection_managers_dup_singleton ();
-
- g_object_set_data (G_OBJECT (cm_mgr), "assistant-destroy-callback",
- g_object_get_data (G_OBJECT (account_mgr), "assistant-destroy-callback"));
- g_object_set_data_full (G_OBJECT (cm_mgr), "account-manager",
- g_object_ref (account_mgr), g_object_unref);
- g_object_set_data (G_OBJECT (cm_mgr), "hidden", GUINT_TO_POINTER (hidden));
-
- empathy_connection_managers_prepare_async (cm_mgr,
- (GAsyncReadyCallback) connection_managers_prepare_cb, NULL);
-}
-
-static void
connection_managers_prepare_for_accounts (GObject *source,
GAsyncResult *result,
gpointer user_data)
diff --git a/src/empathy-accounts-common.h b/src/empathy-accounts-common.h
index 6782d77e2..c8e5c654c 100644
--- a/src/empathy-accounts-common.h
+++ b/src/empathy-accounts-common.h
@@ -28,10 +28,6 @@ void empathy_accounts_show_accounts_ui (TpAccountManager *manager,
TpAccount *account,
GCallback window_destroyed_cb);
-void empathy_accounts_manager_ready_for_show_assistant (
- TpAccountManager *account_mgr,
- gboolean hidden);
-
gboolean empathy_accounts_import (TpAccountManager *account_mgr,
EmpathyConnectionManagers *cm_mgr);
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 1256a1758..c300065f9 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -2229,7 +2229,7 @@ empathy_accounts_dialog_show_application (GdkScreen *screen,
GChildWatchFunc application_exit_cb,
gpointer user_data,
TpAccount *selected_account,
- gboolean try_import,
+ gboolean if_needed,
gboolean hidden)
{
gint command_pid;
@@ -2265,8 +2265,8 @@ empathy_accounts_dialog_show_application (GdkScreen *screen,
argv[i++] = account_option;
}
- if (try_import)
- argv[i++] = "--import";
+ if (if_needed)
+ argv[i++] = "--if-needed";
if (hidden)
argv[i++] = "--hidden";
diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h
index dd9cd7d55..c171e3d24 100644
--- a/src/empathy-accounts-dialog.h
+++ b/src/empathy-accounts-dialog.h
@@ -60,7 +60,7 @@ void empathy_accounts_dialog_show_application (GdkScreen *screen,
GChildWatchFunc application_exit_cb,
gpointer user_data,
TpAccount *selected_account,
- gboolean try_import,
+ gboolean if_needed,
gboolean hidden);
G_END_DECLS
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c
index 942f6a475..f924acc73 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, "
@@ -264,16 +281,8 @@ main (int argc, char *argv[])
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);
diff --git a/src/empathy.c b/src/empathy.c
index ef2f2106e..b0c731a4b 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -254,10 +254,11 @@ accounts_application_exited_cb (GPid pid,
static void
show_accounts_ui (GdkScreen *screen,
- gboolean try_import)
+ gboolean if_needed)
{
+ g_debug ("launching accounts UI");
empathy_accounts_dialog_show_application (screen,
- accounts_application_exited_cb, NULL, NULL, try_import, start_hidden);
+ accounts_application_exited_cb, NULL, NULL, if_needed, start_hidden);
}
static UniqueResponse