aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2007-07-07 03:54:19 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-07-07 03:54:19 +0800
commit2f301d1096f8ed4d869a1d6f2160663307d7605f (patch)
tree7b0e2fb2a44354424df257ceefed24f889262bbc /mail
parent2b89fd32201b191254e589cf405fe986dc7cd59f (diff)
downloadgsoc2013-evolution-2f301d1096f8ed4d869a1d6f2160663307d7605f.tar.gz
gsoc2013-evolution-2f301d1096f8ed4d869a1d6f2160663307d7605f.tar.zst
gsoc2013-evolution-2f301d1096f8ed4d869a1d6f2160663307d7605f.zip
** Fix for bug #312370 from B S Srinidhi
svn path=/trunk/; revision=33764
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/em-format-html.c20
2 files changed, 23 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 7055fc695c..7c51b11110 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-07 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Fix for bug #312370 from B S Srinidhi
+
+ * em-format-html.c: (emfh_gethttp):
+
2007-07-06 Matthew Barnes <mbarnes@redhat.com>
* em-format-html-print.c:
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 4a4b51a10c..80392ebc6b 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -449,8 +449,11 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
{
CamelStream *cistream = NULL, *costream = NULL, *instream = NULL;
CamelURL *url;
- ssize_t n, total = 0;
+ CamelContentType *content_type;
+ CamelHttpStream *tmp_stream;
+ ssize_t n, total = 0, pc_complete = 0, nread = 0;
char buffer[1500];
+ const char *length;
if (cancelled
|| (url = camel_url_new(job->u.uri, NULL)) == NULL)
@@ -481,6 +484,13 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
camel_http_stream_set_proxy((CamelHttpStream *)instream, proxy);
g_free(proxy);
camel_operation_start(NULL, _("Retrieving `%s'"), job->u.uri);
+ tmp_stream = (CamelHttpStream *)instream;
+ content_type = camel_http_stream_get_content_type(tmp_stream);
+ length = camel_header_raw_find(&tmp_stream->headers, "Content-Length", NULL);
+ d(printf(" Content-Length: %s\n", length));
+ if (length != NULL)
+ total = atoi(length);
+ camel_content_type_unref(content_type);
} else
camel_operation_start_transient(NULL, _("Retrieving `%s'"), job->u.uri);
@@ -496,8 +506,12 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
/* FIXME: progress reporting in percentage, can we get the length always? do we care? */
n = camel_stream_read(instream, buffer, sizeof (buffer));
if (n > 0) {
- camel_operation_progress_count(NULL, total);
- total += n;
+ nread += n;
+ /* If we didn't get a valid Content-Length header, do not try to calculate percentage */
+ if (total != 0) {
+ pc_complete = ((nread * 100) / total);
+ camel_operation_progress(NULL, pc_complete);
+ }
d(printf(" read %d bytes\n", n));
if (costream && camel_stream_write(costream, buffer, n) == -1) {
camel_data_cache_remove(emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL);