From: Sergio Villar Senin Date: Thu, 25 Oct 2007 17:50:27 +0000 (+0000) Subject: * Fixed a very stupid mistake by myself in the connect_and_wait function. It could... X-Git-Tag: git_migration_finished~2211 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=1c4231d3e067c7c17ce6675a4685e58c152f17a7;p=modest * Fixed a very stupid mistake by myself in the connect_and_wait function. It could cause a SIGSEV and was not taking into account the case where the device was online and the account was not and was not reconnecting as well. pmo-trunk-r3581 --- diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index 2bdd043..f80687f 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -936,12 +936,11 @@ typedef struct _UtilIdleData { gulong handler; } UtilIdleData; + static void -on_connection_status_changed (TnyAccount *account, - TnyConnectionStatus status, - gpointer user_data) +check_connection_status_and_quit (TnyAccount *account, + UtilIdleData *data) { - UtilIdleData *data = (UtilIdleData *) user_data; TnyConnectionStatus conn_status; conn_status = tny_account_get_connection_status (account); @@ -962,6 +961,25 @@ on_connection_status_changed (TnyAccount *account, g_mutex_unlock (data->mutex); } +static void +on_connection_status_changed (TnyAccount *account, + TnyConnectionStatus status, + gpointer user_data) +{ + check_connection_status_and_quit (account, + (UtilIdleData *) user_data); +} + +static void +on_tny_camel_account_set_online_cb (TnyCamelAccount *account, + gboolean canceled, + GError *err, + gpointer user_data) +{ + check_connection_status_and_quit (TNY_ACCOUNT (account), + (UtilIdleData *) user_data); +} + gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account) @@ -987,12 +1005,13 @@ modest_platform_connect_and_wait (GtkWindow *parent_window, if (device_online && conn_status == TNY_CONNECTION_STATUS_CONNECTED) return TRUE; + /* Create the helper */ + data = g_slice_new0 (UtilIdleData); + data->mutex = g_mutex_new (); + data->has_callback = FALSE; + /* Connect the device */ if (!device_online) { - data = g_slice_new0 (UtilIdleData); - data->mutex = g_mutex_new (); - data->has_callback = FALSE; - /* Track account connection status changes */ data->handler = g_signal_connect (account, "connection-status-changed", G_CALLBACK (on_connection_status_changed), @@ -1003,6 +1022,10 @@ modest_platform_connect_and_wait (GtkWindow *parent_window, /* If the device connection failed then exit */ if (!device_online && data->handler) goto frees; + } else { + /* Force a reconnection of the account */ + tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), TRUE, + on_tny_camel_account_set_online_cb, data); } /* Wait until the callback is executed */