* Added ending notification to the send_mail operation
authorSergio Villar Senin <svillar@igalia.com>
Wed, 20 Jun 2007 13:36:05 +0000 (13:36 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 20 Jun 2007 13:36:05 +0000 (13:36 +0000)
* Fixed a problem with armin's modest_tny_send_queue code, it was causing a crash due to a g_assert

pmo-trunk-r2334

src/modest-mail-operation.c
src/modest-tny-send-queue.c

index f41bfda..7db713e 100644 (file)
@@ -504,6 +504,8 @@ modest_mail_operation_send_mail (ModestMailOperation *self,
 
        /* Get account and set it into mail_operation */
        priv->account = g_object_ref (transport_account);
+       priv->done = 1;
+       priv->total = 1;
 
        send_queue = TNY_SEND_QUEUE (modest_runtime_get_send_queue (transport_account));
        if (!TNY_IS_SEND_QUEUE(send_queue)) {
@@ -511,10 +513,16 @@ modest_mail_operation_send_mail (ModestMailOperation *self,
                             MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
                             "modest: could not find send queue for account\n");
        } else {
+               /* TODO: connect to the msg-sent in order to know when
+                  the mail operation is finished */
                tny_send_queue_add (send_queue, msg, &(priv->error));
+               /* TODO: we're setting always success, do the check in
+                  the handler */
+               priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
        }
 
-       /* Notify about operation end */
+       /* TODO: do this in the handler of the "msg-sent"
+          signal.Notify about operation end */
        modest_mail_operation_notify_end (self);
 }
 
@@ -539,9 +547,6 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self,
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
 
-       /* Get account and set it into mail_operation */
-       priv->account = g_object_ref (transport_account);
-
        /* Check parametters */
        if (to == NULL) {
                /* Set status failed and set an error */
index 390f7e3..cefdd25 100644 (file)
@@ -426,23 +426,27 @@ static void _on_msg_error_happened (TnySendQueue *self,
        ModestTnySendQueuePrivate *priv;
        SendInfo *info;
        GList *item;
+       TnyHeader *msg_header;
 
        priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
 
        /* TODO: Use this version as soon as the msg-sending
         *  notification works */
-#if 0
-       item = priv->current;
-       g_assert(item != NULL);
-       info = priv->current->data;
-#else
-       /* TODO: Why do we get the msg and its header separately? The docs
-        * don't really tell. */
-       g_assert(header == tny_msg_get_header (msg)); // ????
-       item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), tny_header_get_message_id (header));
+/* #if 0 */
+/*     item = priv->current; */
+/*     g_assert(item != NULL); */
+/*     info = priv->current->data; */
+/* #else */
+/*     /\* TODO: Why do we get the msg and its header separately? The docs */
+/*      * don't really tell. *\/ */
+/*     g_assert(header == tny_msg_get_header (msg)); // ???? */
+       msg_header = tny_msg_get_header (msg);
+       item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), 
+                                                 tny_header_get_message_id (msg_header));
+       g_object_unref (msg_header);
        g_assert(item != NULL);
        info = item->data;
-#endif
+/* #endif */
 
        /* Keep in queue so that we remember that the opertion has failed
         * and was not just cancelled */