From: Murray Cumming Date: Fri, 29 Jun 2007 18:11:21 +0000 (+0000) Subject: 2007-06-29 Murray Cumming + + reviewed by: + + * src/maemo/modest-maemo-utils.c: + (modest_maemo_utils_get_supported_secure_authentication_methods): + * src/maemo/modest-main-window.c: + (on_zoom_minus_plus_not_implemented), + (modest_main_window_set_offline): + * src/modest-defs.h: + * src/modest-init.c: (init_default_settings): + * src/modest-mail-operation.c: + (modest_mail_operation_update_account): + * src/modest-main.c: (on_show): + * src/modest-tny-account.c: (on_connection_status_changed), + (modest_tny_account_new_from_server_account): + * src/modest-ui-actions.h: + * src/widgets/modest-main-window.h: + * please check the svn log instead diff --git a/ChangeLog2 b/ChangeLog2 index ae22448..53c3574 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,4 +1,24 @@ -2007-06-29 Murray Cumming +2007-06-29 Murray Cumming done = 0; priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS; - /* Make sure that we have a connection, and request one - * if necessary: - * TODO: Is there some way to trigger this for every attempt to - * use the network? */ - if (!modest_platform_connect_and_wait(NULL)) - goto error; - /* Get the Modest account */ modest_account = (TnyStoreAccount *) modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), diff --git a/src/modest-main.c b/src/modest-main.c index 4e860b2..15a51ac 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -80,9 +80,13 @@ static ModestErrorCode send_mail (const gchar* account, static void on_show (GtkWidget *widget, gpointer user_data) { + /* This key is not used by any preferences UI and + * I don't think this behavior is specified in the UI specification. murrayc: */ +/* if (modest_conf_get_bool (modest_runtime_get_conf(), MODEST_CONF_CONNECT_AT_STARTUP, NULL)) modest_platform_connect_and_wait(NULL); +*/ } int diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 60d6a55..96edb80 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,34 @@ modest_tny_account_get_special_folder (TnyAccount *account, return special_folder; } +static void +on_connection_status_changed (TnyAccount *account, TnyConnectionStatus status, gpointer user_data) +{ + printf ("DEBUG: %s: status=%d\n", __FUNCTION__, status); + + if (status == TNY_CONNECTION_STATUS_DISCONNECTED) { + /* We are trying to use the network with an account, + * but the accounts are set as offline, because our TnyDevice is offline, + * because libconic says we are offline. + * So ask the user to go online: + */ + modest_platform_connect_and_wait(NULL); + } else if (status == TNY_CONNECTION_STATUS_CONNECTED_BROKEN) { + printf ("DEBUG: %s: Connection broken. Forcing TnyDevice offline.\n", + __FUNCTION__); + + /* Something went wrong during some network operation. + * Stop trying to use the network now, + * by forcing accounts into offline mode: + * + * When libconic reconnects, it will set the device back online again, + * regardless of it being forced offline before. + */ + TnyDevice *device = modest_runtime_get_device (); + tny_device_force_offline (device); + } +} + /* Camel options: */ /* These seem to be listed in @@ -216,6 +245,11 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr, } tny_account_set_id (tny_account, account_data->account_name); + /* Handle connection requests: + * This (badly-named) signal will be called when we try to use an offline account. */ + g_signal_connect (G_OBJECT (tny_account), "connection-status-changed", + G_CALLBACK (on_connection_status_changed), NULL); + /* Proto */ const gchar* proto_name = modest_protocol_info_get_transport_store_protocol_name(account_data->proto); diff --git a/src/modest-ui-actions.h b/src/modest-ui-actions.h index a770e78..a0dcd51 100644 --- a/src/modest-ui-actions.h +++ b/src/modest-ui-actions.h @@ -128,9 +128,6 @@ void modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder gboolean selected, ModestMainWindow *main_window); -void modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, - ModestMainWindow *main_window); - void modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, ModestItemType type, ModestWindow *window);