From: Sergio Villar Senin Date: Wed, 23 Jan 2008 12:41:52 +0000 (+0000) Subject: * Removed modest_tny_send_queue_add, replaced with tny_send_queue_add_async X-Git-Tag: git_migration_finished~1768 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=8c91efe73c60f49290ad30dc3fb039782b98e904 * Removed modest_tny_send_queue_add, replaced with tny_send_queue_add_async * Fixed a crash when sending errors, NOTE: this is a workaround in Modest but must be fixed in tinymail pmo-trunk-r4081 --- diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index f7df1b8..9ae6218 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -652,9 +652,7 @@ modest_mail_operation_send_mail (ModestMailOperation *self, info->error_happened_handler = g_signal_connect (G_OBJECT (send_queue), "error-happened", G_CALLBACK (send_mail_error_happened_handler), info); - modest_tny_send_queue_add (MODEST_TNY_SEND_QUEUE(send_queue), - msg, - &(priv->error)); + tny_send_queue_add_async (send_queue, msg, NULL, NULL, NULL); priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS; } diff --git a/src/modest-tny-send-queue.c b/src/modest-tny-send-queue.c index 1139eba..43b9b7f 100644 --- a/src/modest-tny-send-queue.c +++ b/src/modest-tny-send-queue.c @@ -70,6 +70,11 @@ static void _on_msg_error_happened (TnySendQueue *self, GError *err, gpointer user_data); +static void modest_tny_send_queue_add_async (TnyCamelSendQueue *self, + TnyMsg *msg, + TnySendQueueAddCallback callback, + TnyStatusCallback status_callback, + gpointer user_data); static TnyFolder* modest_tny_send_queue_get_outbox (TnySendQueue *self); static TnyFolder* modest_tny_send_queue_get_sentbox (TnySendQueue *self); @@ -181,7 +186,10 @@ modest_tny_send_queue_to_string (ModestTnySendQueue *self) } static void -_on_added_to_outbox (TnySendQueue *self, gboolean cancelled, TnyMsg *msg, GError *err, +_on_added_to_outbox (TnySendQueue *self, + gboolean cancelled, + TnyMsg *msg, + GError *err, gpointer user_data) { ModestTnySendQueuePrivate *priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE(self); @@ -195,7 +203,6 @@ _on_added_to_outbox (TnySendQueue *self, gboolean cancelled, TnyMsg *msg, GError header = tny_msg_get_header (msg); msg_id = modest_tny_send_queue_get_msg_id (header); -/* msg_id = tny_header_get_message_id (header); */ g_return_if_fail(msg_id != NULL); /* Put newly added message in WAITING state */ @@ -215,20 +222,6 @@ _on_added_to_outbox (TnySendQueue *self, gboolean cancelled, TnyMsg *msg, GError g_object_unref(G_OBJECT(header)); } -void -modest_tny_send_queue_add (ModestTnySendQueue *self, TnyMsg *msg, GError **err) -{ - g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(self)); - g_return_if_fail (TNY_IS_CAMEL_MSG(msg)); - - tny_camel_send_queue_add_async (TNY_CAMEL_SEND_QUEUE(self), - msg, - _on_added_to_outbox, - NULL, - NULL); -} - - static void _add_message (ModestTnySendQueue *self, TnyHeader *header) { @@ -277,6 +270,18 @@ _add_message (ModestTnySendQueue *self, TnyHeader *header) g_free(msg_uid); } +static void +modest_tny_send_queue_add_async (TnyCamelSendQueue *self, + TnyMsg *msg, + TnySendQueueAddCallback callback, + TnyStatusCallback status_callback, + gpointer user_data) +{ + /* Call the superclass passing our own callback */ + TNY_CAMEL_SEND_QUEUE_CLASS(parent_class)->add_async_func (self, msg, _on_added_to_outbox, NULL, NULL); +} + + static TnyFolder* modest_tny_send_queue_get_sentbox (TnySendQueue *self) { @@ -339,6 +344,7 @@ modest_tny_send_queue_class_init (ModestTnySendQueueClass *klass) parent_class = g_type_class_peek_parent (klass); gobject_class->finalize = modest_tny_send_queue_finalize; + TNY_CAMEL_SEND_QUEUE_CLASS(klass)->add_async_func = modest_tny_send_queue_add_async; TNY_CAMEL_SEND_QUEUE_CLASS(klass)->get_outbox_func = modest_tny_send_queue_get_outbox; TNY_CAMEL_SEND_QUEUE_CLASS(klass)->get_sentbox_func = modest_tny_send_queue_get_sentbox; klass->status_changed = NULL; @@ -543,9 +549,6 @@ _on_msg_has_been_sent (TnySendQueue *self, gchar *msg_id = NULL; GList *item; - /* TODO: Sometimes tinymail does not return a header, need to check */ - g_return_if_fail (TNY_IS_HEADER (header)); - priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); /* Get message uid */ @@ -555,13 +558,20 @@ _on_msg_has_been_sent (TnySendQueue *self, /* Get status info */ item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), msg_id); + + + /* TODO: note that item=NULL must not happen, but I found that + tinymail is issuing the message-sent signal twice, because + tny_camel_send_queue_update is called twice for each + message sent. This must be fixed in tinymail. Sergio */ + if (item) { + /* Remove status info */ + modest_tny_send_queue_info_free (item->data); + g_queue_delete_link (priv->queue, item); + priv->current = NULL; - /* Remove status info */ - modest_tny_send_queue_info_free (item->data); - g_queue_delete_link (priv->queue, item); - priv->current = NULL; - - modest_platform_information_banner (NULL, NULL, _("mcen_ib_message_sent")); + modest_platform_information_banner (NULL, NULL, _("mcen_ib_message_sent")); + } /* free */ g_free(msg_id); @@ -585,6 +595,7 @@ _on_msg_error_happened (TnySendQueue *self, msg_uid = modest_tny_send_queue_get_msg_id (header); item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), msg_uid); + info = item->data; /* Keep in queue so that we remember that the opertion has failed */ diff --git a/src/modest-tny-send-queue.h b/src/modest-tny-send-queue.h index 6c23f06..826b778 100644 --- a/src/modest-tny-send-queue.h +++ b/src/modest-tny-send-queue.h @@ -91,17 +91,6 @@ GType modest_tny_send_queue_get_type (void) G_GNUC_CONST; ModestTnySendQueue* modest_tny_send_queue_new (TnyCamelTransportAccount *account); - -/** - * modest_tny_send_queue_ADD: - * @self: a valid #ModestTnySendQueue instance - * @msg: a valid #TnyMsg instance to send - * - * Add @msg to outbox folder waiting to be sent by - * its account send queue. - */ -void modest_tny_send_queue_add (ModestTnySendQueue *self, TnyMsg *msg, GError **err); - /** * modest_tny_send_queue_sending_in_progress: * @self: a valid #ModestTnySendQueue instance