X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-send-queue.c;h=bb103ab95a9794c9f5833f74bb0f05973696444d;hp=526dd76942baef650170980ce9ec8c279ae589e0;hb=f541209a85cb6c71c79da1df81afbe10c448690a;hpb=19e4ee9927196eed183d94f5e9d2a33d288db92a diff --git a/src/modest-tny-send-queue.c b/src/modest-tny-send-queue.c index 526dd76..bb103ab 100644 --- a/src/modest-tny-send-queue.c +++ b/src/modest-tny-send-queue.c @@ -192,6 +192,11 @@ modest_tny_send_queue_to_string (ModestTnySendQueue *self) return str; } +typedef struct { + TnySendQueueAddCallback callback; + gpointer user_data; +} AddAsyncHelper; + static void _on_added_to_outbox (TnySendQueue *self, gboolean cancelled, @@ -204,6 +209,7 @@ _on_added_to_outbox (TnySendQueue *self, SendInfo *info = NULL; GList* existing = NULL; gchar* msg_id = NULL; + AddAsyncHelper *helper; g_return_if_fail (TNY_IS_SEND_QUEUE(self)); g_return_if_fail (TNY_IS_CAMEL_MSG(msg)); @@ -231,6 +237,12 @@ _on_added_to_outbox (TnySendQueue *self, end: g_object_unref (G_OBJECT(header)); + + /* Call the user callback */ + helper = (AddAsyncHelper *) user_data; + if (helper->callback) + helper->callback (self, cancelled, msg, err, helper->user_data); + g_slice_free (AddAsyncHelper, helper); } static void @@ -288,8 +300,15 @@ modest_tny_send_queue_add_async (TnySendQueue *self, TnyStatusCallback status_callback, gpointer user_data) { + AddAsyncHelper *helper = g_slice_new0 (AddAsyncHelper); + helper->callback = callback; + helper->user_data = user_data; + /* Call the superclass passing our own callback */ - TNY_CAMEL_SEND_QUEUE_CLASS(parent_class)->add_async (self, msg, _on_added_to_outbox, NULL, NULL); + TNY_CAMEL_SEND_QUEUE_CLASS(parent_class)->add_async (self, msg, + _on_added_to_outbox, + status_callback, + helper); } @@ -461,7 +480,21 @@ modest_tny_send_queue_new (TnyCamelTransportAccount *account) g_return_val_if_fail (TNY_IS_CAMEL_TRANSPORT_ACCOUNT(account), NULL); self = MODEST_TNY_SEND_QUEUE(g_object_new(MODEST_TYPE_TNY_SEND_QUEUE, NULL)); - + + /* Set outbox and sentbox */ + priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); + priv->outbox = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), + TNY_FOLDER_TYPE_OUTBOX); + priv->sentbox = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), + TNY_FOLDER_TYPE_SENT); + + /* NOTE that this could happen if there was not enough disk + space when the account was created */ + if (!priv->outbox || !priv->sentbox) { + g_object_unref (self); + return NULL; + } + /* Connect signals to control when a msg is being or has been sent */ g_signal_connect (G_OBJECT(self), "msg-sending", G_CALLBACK(_on_msg_start_sending), @@ -476,12 +509,7 @@ modest_tny_send_queue_new (TnyCamelTransportAccount *account) G_CALLBACK (_on_queue_start), NULL); - /* Set outbox and sentbox */ - priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); - priv->outbox = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), - TNY_FOLDER_TYPE_OUTBOX); - priv->sentbox = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), - TNY_FOLDER_TYPE_SENT); + priv->requested_send_receive = FALSE; headers = tny_simple_list_new (); @@ -665,10 +693,24 @@ _on_msg_error_happened (TnySendQueue *self, /* Keep in queue so that we remember that the opertion has failed */ /* and was not just cancelled */ - if (err->code == TNY_SYSTEM_ERROR_CANCEL) + if (err->code == TNY_SYSTEM_ERROR_CANCEL) { info->status = MODEST_TNY_SEND_QUEUE_SUSPENDED; - else + } else { + if (err->code == TNY_SERVICE_ERROR_CONNECT) { + TnyCamelTransportAccount* transport; + + transport = tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self)); + if (transport) { + gchar *message; + 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 */ @@ -736,11 +778,12 @@ modest_tny_all_send_queues_get_msg_status (TnyHeader *header) account = TNY_TRANSPORT_ACCOUNT(tny_iterator_get_current (iter)); send_queue = modest_runtime_get_send_queue(TNY_TRANSPORT_ACCOUNT(account), TRUE); g_object_unref(account); - - queue_status = modest_tny_send_queue_get_msg_status (send_queue, msg_uid); - if (queue_status != MODEST_TNY_SEND_QUEUE_UNKNOWN) { - status = queue_status; - break; + if (TNY_IS_SEND_QUEUE (send_queue)) { + queue_status = modest_tny_send_queue_get_msg_status (send_queue, msg_uid); + if (queue_status != MODEST_TNY_SEND_QUEUE_UNKNOWN) { + status = queue_status; + break; + } } tny_iterator_next (iter); }