+ /* Apply changes */
+ if (priv->initial_state.auto_update != current_state.auto_update ||
+ priv->initial_state.connect_via != current_state.connect_via ||
+ priv->initial_state.update_interval != current_state.update_interval) {
+
+ TnyAccountStore *account_store;
+ TnyDevice *device;
+
+ if (!current_state.auto_update) {
+ modest_platform_set_update_interval (0);
+ /* To avoid a new indentation level */
+ goto exit;
+ }
+
+ account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
+ device = tny_account_store_get_device (account_store);
+
+ if (tny_device_is_online (device)) {
+ /* If connected via any then set update interval */
+ if (current_state.connect_via == MODEST_CONNECTED_VIA_ANY) {
+ modest_platform_set_update_interval (current_state.update_interval);
+ } else {
+ /* Set update interval only if we
+ selected the same connect_via
+ method than the one already used by
+ the device */
+ ModestConnectedVia connect_via =
+ MODEST_GLOBAL_SETTINGS_DIALOG_GET_CLASS(self)->current_connection_func ();
+
+ if (current_state.connect_via == connect_via)
+ modest_platform_set_update_interval (current_state.update_interval);
+ else
+ modest_platform_set_update_interval (0);
+ }
+ } else {
+ /* Disable autoupdate in offline mode */
+ modest_platform_set_update_interval (0);
+ }
+ g_object_unref (device);
+ }
+
+exit: