+ /* Keep in queue so that we remember that the opertion has failed */
+ /* and was not just cancelled */
+ if (err->code == TNY_SYSTEM_ERROR_CANCEL) {
+ info->status = MODEST_TNY_SEND_QUEUE_SUSPENDED;
+ } else {
+ if (err->code == TNY_SERVICE_ERROR_CONNECT) {
+ TnyCamelTransportAccount* transport;
+ TnyTransportAccount *conn_specific;
+
+ transport = tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self));
+ if (transport) {
+ gchar *message;
+ ModestTnyAccountStore *acc_store;
+ const gchar *acc_name;
+
+ acc_store = modest_runtime_get_account_store();
+ acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (TNY_ACCOUNT (transport));
+ conn_specific = (TnyTransportAccount *)
+ modest_tny_account_store_get_transport_account_for_open_connection (acc_store, acc_name);
+ if (conn_specific) {
+ message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"),
+ tny_account_get_hostname (TNY_ACCOUNT (conn_specific)));
+ g_object_unref (conn_specific);
+ } else {
+ message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"),
+ tny_account_get_hostname (TNY_ACCOUNT (transport)));
+ }
+ modest_platform_run_alert_dialog (message, FALSE);
+ g_free (message);
+ g_object_unref (transport);
+ }
+ }
+ info->status = MODEST_TNY_SEND_QUEUE_FAILED;
+ }
+ priv->current = NULL;
+
+ /* Notify status has changed */
+ g_signal_emit (self, signals[STATUS_CHANGED_SIGNAL], 0, info->msg_id, info->status);
+
+ /* free */
+ g_free(msg_uid);
+ }
+}
+
+static void
+_on_queue_start (TnySendQueue *self,
+ gpointer data)
+{
+ ModestTnySendQueuePrivate *priv;
+ ModestMailOperation *mail_op;
+
+ mail_op = modest_mail_operation_new (NULL);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
+ mail_op);
+ modest_mail_operation_run_queue (mail_op, MODEST_TNY_SEND_QUEUE (self));
+ g_object_unref (mail_op);
+
+ priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
+ priv->sending = TRUE;
+}
+
+static void
+_on_queue_stop (TnySendQueue *self,
+ gpointer data)
+{
+ ModestTnySendQueuePrivate *priv;
+
+ priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
+ priv->sending = FALSE;
+}
+
+static void
+fill_list_of_caches (gpointer key, gpointer value, gpointer userdata)
+{
+ GSList **send_queues = (GSList **) userdata;
+ *send_queues = g_slist_prepend (*send_queues, value);
+}
+
+/* This function shouldn't be here. Move it to another place. Sergio */
+ModestTnySendQueueStatus
+modest_tny_all_send_queues_get_msg_status (TnyHeader *header)
+{
+ ModestCacheMgr *cache_mgr = NULL;
+ GHashTable *send_queue_cache = NULL;
+ ModestTnyAccountStore *accounts_store = NULL;
+ TnyList *accounts = NULL;
+ TnyIterator *iter = NULL;
+ TnyTransportAccount *account = NULL;
+ GSList *send_queues = NULL, *node;
+ /* get_msg_status returns suspended by default, so we want to detect changes */
+ ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
+ ModestTnySendQueueStatus queue_status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
+ gchar *msg_uid = NULL;
+ ModestTnySendQueue *send_queue = NULL;