Setup progress reporting for message sending.
authorJeffrey Stedfast <fejj@novell.com>
Sat, 21 Jun 2008 02:45:02 +0000 (02:45 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Sat, 21 Jun 2008 02:45:02 +0000 (02:45 +0000)
2008-06-20  Jeffrey Stedfast  <fejj@novell.com>

* camel-smtp-transport.c (smtp_data): Setup progress reporting for
message sending.

svn path=/trunk/; revision=9013

camel/providers/smtp/ChangeLog
camel/providers/smtp/camel-smtp-transport.c

index 85e3c23..a2a071e 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-20  Jeffrey Stedfast  <fejj@novell.com>
+
+       * camel-smtp-transport.c (smtp_data): Setup progress reporting for
+       message sending.
+
 2008-06-18  Matthew Barnes  <mbarnes@redhat.com>
 
        ** Fixes part of bug #532472
index 71604e8..43826fb 100644 (file)
@@ -41,6 +41,7 @@
 #undef MAX
 
 #include "camel-exception.h"
+#include "camel-mime-filter-progress.h"
 #include "camel-mime-filter-crlf.h"
 #include "camel-mime-message.h"
 #include "camel-mime-part.h"
@@ -52,6 +53,7 @@
 #include "camel-smtp-transport.h"
 #include "camel-stream-buffer.h"
 #include "camel-stream-filter.h"
+#include "camel-stream-null.h"
 #include "camel-tcp-stream-raw.h"
 #include "camel-tcp-stream.h"
 
@@ -1297,11 +1299,12 @@ smtp_rcpt (CamelSmtpTransport *transport, const char *recipient, CamelException
 static gboolean
 smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelException *ex)
 {
-       CamelBestencEncoding enctype = CAMEL_BESTENC_8BIT;
        struct _camel_header_raw *header, *savedbcc, *n, *tail;
-       char *cmdbuf, *respbuf = NULL;
+       CamelBestencEncoding enctype = CAMEL_BESTENC_8BIT;
        CamelStreamFilter *filtered_stream;
-       CamelMimeFilter *crlffilter;
+       char *cmdbuf, *respbuf = NULL;
+       CamelMimeFilter *filter;
+       CamelStreamNull *null;
        int ret;
        
        /* If the server doesn't support 8BITMIME, set our required encoding to be 7bit */
@@ -1346,12 +1349,6 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
        g_free (respbuf);
        respbuf = NULL;
        
-       /* setup stream filtering */
-       crlffilter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
-       filtered_stream = camel_stream_filter_new_with_stream (transport->ostream);
-       camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlffilter));
-       camel_object_unref (crlffilter);
-       
        /* unlink the bcc headers */
        savedbcc = NULL;
        tail = (struct _camel_header_raw *) &savedbcc;
@@ -1371,6 +1368,23 @@ smtp_data (CamelSmtpTransport *transport, CamelMimeMessage *message, CamelExcept
                n = header->next;
        }
        
+       /* find out how large the message is... */
+       null = camel_stream_null_new ();
+       camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (null));
+       
+       filtered_stream = camel_stream_filter_new_with_stream (transport->ostream);
+       
+       /* setup progress reporting for message sending... */
+       filter = camel_mime_filter_progress_new (NULL, null->written);
+       camel_stream_filter_add (filtered_stream, filter);
+       camel_object_unref (filter);
+       camel_object_unref (null);
+       
+       /* setup LF->CRLF conversion */
+       filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
+       camel_stream_filter_add (filtered_stream, filter);
+       camel_object_unref (filter);
+       
        /* write the message */
        ret = camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (filtered_stream));