ECredentials *used_credentials;
gboolean open_finished;
GError *opened_cb_error;
+ guint retry_open_id;
+ gboolean only_if_exists;
} EClientUtilsAsyncOpData;
static void
g_return_if_fail (async_data->cancellable != NULL);
g_return_if_fail (async_data->client != NULL);
+ if (async_data->retry_open_id)
+ g_source_remove (async_data->retry_open_id);
+
g_signal_handlers_disconnect_matched (async_data->cancellable, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, async_data);
g_signal_handlers_disconnect_matched (async_data->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, async_data);
g_error_free (error);
}
+static gboolean client_utils_retry_open_timeout_cb (gpointer user_data);
+
static void
finish_or_retry_open (EClientUtilsAsyncOpData *async_data, const GError *error)
{
}
e_client_process_authentication (async_data->client, async_data->used_credentials);
+ } else if (error && g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY)) {
+ /* postpone for few 1/4 of a second, backend is busy now */
+ async_data->retry_open_id = g_timeout_add (500, client_utils_retry_open_timeout_cb, async_data);
} else if (error) {
return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, async_data->source, e_client_utils_open_new);
free_client_utils_async_op_data (async_data);
}
static gboolean
+client_utils_retry_open_timeout_cb (gpointer user_data)
+{
+ EClientUtilsAsyncOpData *async_data = user_data;
+
+ g_return_val_if_fail (async_data != NULL, FALSE);
+
+ async_data->open_finished = FALSE;
+ g_signal_handlers_disconnect_matched (async_data->cancellable, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, async_data);
+
+ e_client_open (async_data->client, async_data->only_if_exists, async_data->cancellable, client_utils_open_new_async_cb, async_data);
+
+ async_data->retry_open_id = 0;
+
+ return FALSE;
+}
+
+static gboolean
client_utils_open_new_auth_cb (EClient *client, ECredentials *credentials, gpointer user_data)
{
EClientUtilsAsyncOpData *async_data = user_data;
async_data->source = g_object_ref (source);
async_data->client = client;
async_data->open_finished = FALSE;
+ async_data->only_if_exists = only_if_exists;
+ async_data->retry_open_id = 0;
+
if (cancellable)
async_data->cancellable = g_object_ref (cancellable);
else
/* wait till backend notifies about its opened state */
g_signal_connect (client, "opened", G_CALLBACK (client_utils_opened_cb), async_data);
- e_client_open (client, only_if_exists, async_data->cancellable, client_utils_open_new_async_cb, async_data);
+ e_client_open (async_data->client, async_data->only_if_exists, async_data->cancellable, client_utils_open_new_async_cb, async_data);
}
/**