+2007-07-12 Murray Cumming <murrayc@murrayc.com>
+
+ * src/gnome/modest-platform.c: (modest_platform_connect_and_wait):
+ * src/maemo/modest-platform.c:
+ (modest_platform_connect_and_wait):
+ Take a TnyAccount* parameter and try to set it to online
+ (a TnyCamel-only API), because tinymail sets accounts to offline
+ when the user cancels a password dialog, and doesn't ask again until
+ it has been set to online.
+ However, this is commented out because it causes a hang now.
+
+ (modest_platform_connect_and_wait_if_network_account):
+ * src/modest-mail-operation.c:
+ (modest_mail_operation_update_account):
+ * src/modest-platform.h:
+ * src/modest-ui-actions.c: (_modest_ui_actions_open),
+ (download_uncached_messages), (modest_ui_actions_on_send): Adapted.
+
2007-07-12 Armin Burgmeier <armin@openismus.com>
* src/modest-error.h: Added MODEST_MAIL_OPERATION_FOLDER_EXISTS error.
/* TODO: implement a information dialog */
}
-gboolean modest_platform_connect_and_wait (GtkWindow *parent_window)
+gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account)
{
/* TODO: Do something with network-manager?
Otherwise, maybe it is safe to assume that we would already be online if we could be. */
return result;
}
+static void
+set_account_to_online (TnyAccount *account)
+{
+ /* TODO: This is necessary to prevent a cancel of the password dialog
+ * from making a restart necessary to be asked the password again,
+ * but it causes a hang:
+ */
+ #if 0
+ if (account && TNY_IS_CAMEL_STORE_ACCOUNT (account)) {
+ /* Make sure that store accounts are online too,
+ * because tinymail sets accounts to offline if
+ * a password dialog is ever cancelled.
+ * We don't do this for transport accounts because
+ * a) They fundamentally need network access, so they can't really be offline.
+ * b) That might cause a transport connection to happen too early.
+ */
+ GError *error = NULL;
+ tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), TRUE, &error);
+ if (error) {
+ g_warning ("%s: tny_camel_account_set_online() returned a GError:\n %s\n",
+ __FUNCTION__, error->message);
+ g_error_free (error);
+ }
+ }
+ #endif
+}
-gboolean modest_platform_connect_and_wait (GtkWindow *parent_window)
+gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account)
{
if (connect_request_in_progress)
return FALSE;
if (tny_device_is_online (device)) {
printf ("DEBUG: %s: Already online.\n", __FUNCTION__);
+ set_account_to_online (account);
return TRUE;
} else
{
/* g_main_context_unref (context); */
g_slice_free (UtilIdleData, data);
-
- return tny_device_is_online (device);
+
+ gboolean result = tny_device_is_online (device);
+
+ if (result)
+ set_account_to_online (account);
+
+ return result;
}
gboolean modest_platform_connect_and_wait_if_network_account (GtkWindow *parent_window, TnyAccount *account)
}
}
- return modest_platform_connect_and_wait (parent_window);
+ return modest_platform_connect_and_wait (parent_window, account);
}
gboolean modest_platform_connect_and_wait_if_network_folderstore (GtkWindow *parent_window, TnyFolderStore *folder_store)
UpdateAccountCallback callback,
gpointer user_data)
{
- GThread *thread;
- UpdateAccountInfo *info;
- ModestMailOperationPrivate *priv;
- ModestAccountMgr *mgr;
- TnyStoreAccount *modest_account;
- TnyTransportAccount *transport_account;
+ GThread *thread = NULL;
+ UpdateAccountInfo *info = NULL;
+ ModestMailOperationPrivate *priv = NULL;
+ ModestAccountMgr *mgr = NULL;
+ TnyStoreAccount *store_account = NULL;
+ TnyTransportAccount *transport_account = NULL;
g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self), FALSE);
g_return_val_if_fail (account_name, FALSE);
priv->done = 0;
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+ /* Get the Modest account */
+ store_account = (TnyStoreAccount *)
+ modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
+ account_name,
+ TNY_ACCOUNT_TYPE_STORE);
+
/* 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))
+ if (!modest_platform_connect_and_wait (NULL, TNY_ACCOUNT (store_account)))
goto error;
- /* Get the Modest account */
- modest_account = (TnyStoreAccount *)
- modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
- account_name,
- TNY_ACCOUNT_TYPE_STORE);
-
- if (!modest_account) {
+ if (!store_account) {
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
"cannot get tny store account for %s\n", account_name);
/* Create the helper object */
info = g_slice_new (UpdateAccountInfo);
info->mail_op = self;
- info->account = modest_account;
+ info->account = store_account;
info->transport_account = transport_account;
info->callback = callback;
info->user_data = user_data;
/*
* modest_platform_connect_and_wait:
* @parent_window: the parent #GtkWindow for any interactive or progress feedback UI.
+ * @account: The account to be used.
* @return value: Whether a connection was made.
*
* Attempts to make a connection, possibly showing interactive UI to achieve this.
* This will return TRUE immediately if a connection is already open.
* Otherwise, this function blocks until the connection attempt has either succeded or failed.
+ * This also sets the account to online, if it is a store account, in case it has been set to offline mode.
*/
-gboolean modest_platform_connect_and_wait (GtkWindow *parent_window);
+gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account);
/*
* than later in a thread:
*/
if (tny_list_get_length (not_opened_cached_headers) > 0) {
- gboolean connected = modest_platform_connect_and_wait (GTK_WINDOW (win));
+ gboolean connected = modest_platform_connect_and_wait (GTK_WINDOW (win), NULL);
/* Don't go further if a connection would be necessary but none is available: */
if (!connected) {
retval = FALSE;
else {
/* If a download will be necessary, make sure that we have a connection: */
- retval = modest_platform_connect_and_wait(win);
+ retval = modest_platform_connect_and_wait(win, NULL);
}
}
return retval;
return;
/* Offer the connection dialog, if necessary: */
- if (!modest_platform_connect_and_wait (GTK_WINDOW (edit_window)))
+ if (!modest_platform_connect_and_wait (GTK_WINDOW (edit_window), NULL))
return;
/* FIXME: Code added just for testing. The final version will