diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2009-11-09 17:38:32 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2009-11-09 17:38:32 +0800 |
commit | 4a2917a052f26751f18df7865a444c001555826b (patch) | |
tree | 1feda4b958f516d3713ba43021bc8e16a1aed6e2 | |
parent | a74847a856efacde2142507fde3f7278e04a2f7c (diff) | |
download | gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar.gz gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar.bz2 gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar.lz gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar.xz gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.tar.zst gsoc2013-empathy-4a2917a052f26751f18df7865a444c001555826b.zip |
Move the call to empathy_idle_get_state() to once the AM is ready
Removes a race where the presence gets wiped because we check whether to go
online before our connection to the AccountManager is ready.
-rw-r--r-- | src/empathy.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/empathy.c b/src/empathy.c index 72b691c16..5fef07072 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -83,6 +83,7 @@ static gboolean account_dialog_only = FALSE; static gboolean start_hidden = FALSE; +static gboolean no_connect = FALSE; static void dispatch_cb (EmpathyDispatcher *dispatcher, @@ -642,6 +643,9 @@ account_manager_ready_cb (GObject *source_object, { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); GError *error = NULL; + EmpathyIdle *idle; + EmpathyConnectivity *connectivity; + gboolean autoconnect = TRUE; if (!tp_account_manager_prepare_finish (manager, result, &error)) { @@ -650,6 +654,19 @@ account_manager_ready_cb (GObject *source_object, return; } + /* Autoconnect */ + idle = empathy_idle_dup_singleton (); + connectivity = empathy_connectivity_dup_singleton (); + + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_AUTOCONNECT, &autoconnect); + if (autoconnect && !no_connect && + tp_connection_presence_type_cmp_availability + (empathy_idle_get_state (idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) + <= 0) + /* if current state is Offline, then put it online */ + empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); + if (should_create_salut_account (manager) || !empathy_import_mc4_has_imported ()) { @@ -857,8 +874,6 @@ main (int argc, char *argv[]) GtkWidget *window; EmpathyIdle *idle; EmpathyConnectivity *connectivity; - gboolean autoconnect = TRUE; - gboolean no_connect = FALSE; GError *error = NULL; TpDBusDaemon *dbus_daemon; UniqueApp *unique_app; @@ -974,15 +989,6 @@ main (int argc, char *argv[]) empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN, use_conn_notify_cb, connectivity); - /* Autoconnect */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_AUTOCONNECT, &autoconnect); - 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, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE); - /* account management */ account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (account_manager, NULL, |