2007-06-29 Murray Cumming <murrayc@murrayc.com
authorMurray Cumming <murrayc@murrayc.com>
Fri, 29 Jun 2007 18:11:21 +0000 (18:11 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Fri, 29 Jun 2007 18:11:21 +0000 (18:11 +0000)
* src/modest-tny-account.c:
(modest_tny_account_new_from_server_account):
Handle the TnyAccount::connection-status-changed signal, which tinymail
now uses to request a connection when it needs one, and which it uses
to tell us that something is wrong with the connection, so we can force
the accounts offline to prevent further problems.

* 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): Do not try to connect explicitly on startup.
This should not be necessary anymore. Do not set the conf key that
determined this (it was always TRUE and not set anywhere else).

* src/modest-ui-actions.h: Remove unused and unimplemented
modest_ui_actions_on_online_toggle_toggled().

pmo-trunk-r2505

ChangeLog
ChangeLog2
src/maemo/modest-maemo-utils.c
src/modest-defs.h
src/modest-init.c
src/modest-mail-operation.c
src/modest-main.c
src/modest-tny-account.c
src/modest-ui-actions.h

index acb6b92..14a901b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1 +1,20 @@
+2007-06-29  Murray Cumming,,,  <set EMAIL_ADDRESS environment variable>
+
+       reviewed by: <delete if not using a buddy>
+
+       * 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
 * please check the svn log instead
index ae22448..53c3574 100644 (file)
@@ -1,4 +1,24 @@
-2007-06-29  Murray Cumming  <murrayc@murrayc-desktop>
+2007-06-29  Murray Cumming  <murrayc@murrayc.com
+
+       * src/modest-tny-account.c: 
+       (modest_tny_account_new_from_server_account):
+       Handle the TnyAccount::"connection-status-changed" signal, which tinymail 
+       now uses to request a connection when it needs one, and which it uses 
+       to tell us that something is wrong with the connection, so we can force 
+       the accounts offline to prevent further problems.
+       
+       * 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): Do not try to connect explicitly on startup.
+       This should not be necessary anymore. Do not set the conf key that 
+       determined this (it was always TRUE and not set anywhere else).
+       
+       * src/modest-ui-actions.h: Remove unused and unimplemented 
+       modest_ui_actions_on_online_toggle_toggled().
+
+2007-06-29  Murray Cumming  <murrayc@murrayc.com
 
        * src/maemo/modest-main-window.c: (connect_signals):
        Don't connect to delete_event twice. Maybe this was harmless.
 
        * src/maemo/modest-main-window.c: (connect_signals):
        Don't connect to delete_event twice. Maybe this was harmless.
index c2f75e8..bb9862c 100644 (file)
@@ -389,6 +389,8 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        default:
                tny_account = NULL;
        }
        default:
                tny_account = NULL;
        }
+
+       /* TODO: Handle connection requests. */
        
        if (!tny_account) {
                g_printerr ("%s could not create tny account.", __FUNCTION__);
        
        if (!tny_account) {
                g_printerr ("%s could not create tny account.", __FUNCTION__);
index 6b162b6..078d7e4 100644 (file)
@@ -72,7 +72,7 @@
 #define MODEST_ACCOUNT_NAMESPACE         MODEST_CONF_NAMESPACE "/accounts"
 #define MODEST_CONF_DEFAULT_ACCOUNT      MODEST_CONF_NAMESPACE "/default_account"
 
 #define MODEST_ACCOUNT_NAMESPACE         MODEST_CONF_NAMESPACE "/accounts"
 #define MODEST_CONF_DEFAULT_ACCOUNT      MODEST_CONF_NAMESPACE "/default_account"
 
-#define MODEST_CONF_CONNECT_AT_STARTUP   MODEST_CONF_NAMESPACE "/connect_at_startup"      
+/* Not used: #define MODEST_CONF_CONNECT_AT_STARTUP   MODEST_CONF_NAMESPACE "/connect_at_startup" */      
 
 #define MODEST_CONF_SHOW_CC              MODEST_CONF_NAMESPACE "/show_cc"           
 #define MODEST_CONF_SHOW_BCC             MODEST_CONF_NAMESPACE "/show_bcc"           
 
 #define MODEST_CONF_SHOW_CC              MODEST_CONF_NAMESPACE "/show_cc"           
 #define MODEST_CONF_SHOW_BCC             MODEST_CONF_NAMESPACE "/show_bcc"           
index b805bff..99e183f 100644 (file)
@@ -669,8 +669,10 @@ init_default_settings (ModestConf *conf)
        if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_BCC, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_SHOW_BCC, FALSE, NULL);
 
        if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_BCC, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_SHOW_BCC, FALSE, NULL);
 
+/* Not used:
        if (!modest_conf_key_exists (conf, MODEST_CONF_CONNECT_AT_STARTUP, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_CONNECT_AT_STARTUP, TRUE, NULL);
        if (!modest_conf_key_exists (conf, MODEST_CONF_CONNECT_AT_STARTUP, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_CONNECT_AT_STARTUP, TRUE, NULL);
+*/
 
        /* Global settings */
        if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_UPDATE, NULL))
 
        /* Global settings */
        if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_UPDATE, NULL))
index 441c6fc..13c8dac 100644 (file)
@@ -1147,13 +1147,6 @@ modest_mail_operation_update_account (ModestMailOperation *self,
        priv->done  = 0;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
        priv->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 (),
        /* Get the Modest account */
        modest_account = (TnyStoreAccount *)
                modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
index 4e860b2..15a51ac 100644 (file)
@@ -80,9 +80,13 @@ static ModestErrorCode  send_mail     (const gchar* account,
 static void 
 on_show (GtkWidget *widget, gpointer user_data)
 {
 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);
        if (modest_conf_get_bool (modest_runtime_get_conf(),
                MODEST_CONF_CONNECT_AT_STARTUP, NULL))
        modest_platform_connect_and_wait(NULL);
+*/
 }
 
 int
 }
 
 int
index 60d6a55..96edb80 100644 (file)
@@ -32,6 +32,7 @@
 #include <modest-tny-account-store.h>
 #include <modest-tny-local-folders-account.h>
 #include <modest-runtime.h>
 #include <modest-tny-account-store.h>
 #include <modest-tny-local-folders-account.h>
 #include <modest-runtime.h>
+#include <modest-platform.h>
 #include <tny-simple-list.h>
 #include <modest-tny-folder.h>
 #include <modest-tny-outbox-account.h>
 #include <tny-simple-list.h>
 #include <modest-tny-folder.h>
 #include <modest-tny-outbox-account.h>
@@ -123,6 +124,34 @@ modest_tny_account_get_special_folder (TnyAccount *account,
        return special_folder;
 }
 
        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 
 /* 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);
 
        }
        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);
        /* Proto */
        const gchar* proto_name =
                modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
index a770e78..a0dcd51 100644 (file)
@@ -128,9 +128,6 @@ void     modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder
                                                         gboolean selected,
                                                         ModestMainWindow *main_window);
 
                                                         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);
 void     modest_ui_actions_on_item_not_found           (ModestHeaderView *header_view,
                                                         ModestItemType type,
                                                         ModestWindow *window);