diff options
author | James Bursa <james@netsurf-browser.org> | 2003-02-28 11:49:13 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2003-02-28 11:49:13 +0000 |
commit | 817421cb0f87df2ef21dfbad65b84c21da098071 (patch) | |
tree | 40edbb8e5ce24448a191655e553dd15fdda50c89 /content | |
parent | 05318b210daaa6d68b74f154fef1dae81503eaa8 (diff) | |
download | netsurf-817421cb0f87df2ef21dfbad65b84c21da098071.tar.gz netsurf-817421cb0f87df2ef21dfbad65b84c21da098071.tar.bz2 |
[project @ 2003-02-28 11:49:13 by bursa]
More status messages, bug fixes.
svn path=/import/netsurf/; revision=102
Diffstat (limited to 'content')
-rw-r--r-- | content/content.c | 4 | ||||
-rw-r--r-- | content/fetchcache.c | 25 | ||||
-rw-r--r-- | content/fetchcache.h | 6 |
3 files changed, 23 insertions, 12 deletions
diff --git a/content/content.c b/content/content.c index 1b75f14ae..ecca5c2fd 100644 --- a/content/content.c +++ b/content/content.c @@ -1,5 +1,5 @@ /** - * $Id: content.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ + * $Id: content.c,v 1.3 2003/02/28 11:49:13 bursa Exp $ */ #include <assert.h> @@ -39,7 +39,7 @@ static const struct handler_entry handler_map[] = { {html_create, html_process_data, html_convert, html_revive, html_reformat, html_destroy}, {textplain_create, textplain_process_data, textplain_convert, textplain_revive, textplain_reformat, textplain_destroy}, - {jpeg_create, jpeg_process_data, jpeg_convert, jpeg_revive, jpeg_destroy}, + {jpeg_create, jpeg_process_data, jpeg_convert, jpeg_revive, jpeg_reformat, jpeg_destroy}, /* {css_create, css_process_data, css_convert, css_revive, css_destroy}, {png_create, png_process_data, png_convert, png_revive, png_destroy},*/ }; diff --git a/content/fetchcache.c b/content/fetchcache.c index 96c865b67..b950da093 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -1,8 +1,9 @@ /** - * $Id: fetchcache.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ + * $Id: fetchcache.c,v 1.3 2003/02/28 11:49:13 bursa Exp $ */ #include <assert.h> +#include <string.h> #include "netsurf/content/cache.h" #include "netsurf/content/fetchcache.h" #include "netsurf/content/fetch.h" @@ -12,20 +13,21 @@ struct fetchcache { void *url; - void (*callback)(fetchcache_msg msg, struct content *c, void *p, char *error); + void (*callback)(fetchcache_msg msg, struct content *c, void *p, const char *error); void *p; struct fetch *f; struct content *c; unsigned long width, height; + unsigned long size; }; void fetchcache_free(struct fetchcache *fc); -void fetchcache_callback(fetchcache_msg msg, struct fetchcache *fc, char *data, unsigned long size); +void fetchcache_callback(fetchcache_msg msg, void *p, char *data, unsigned long size); void fetchcache(char *url, char *referer, - void (*callback)(fetchcache_msg msg, struct content *c, void *p, char *error), + void (*callback)(fetchcache_msg msg, struct content *c, void *p, const char *error), void *p, unsigned long width, unsigned long height) { struct content *c; @@ -33,11 +35,13 @@ void fetchcache(char *url, char *referer, c = cache_get(url); if (c != 0) { + callback(FETCHCACHE_STATUS, c, p, "Found in cache"); content_revive(c, width, height); callback(FETCHCACHE_OK, c, p, 0); return; } + callback(FETCHCACHE_STATUS, c, p, "Starting fetch"); fc = xcalloc(1, sizeof(struct fetchcache)); fc->url = xstrdup(url); fc->callback = callback; @@ -45,6 +49,7 @@ void fetchcache(char *url, char *referer, fc->c = 0; fc->width = width; fc->height = height; + fc->size = 0; fc->f = fetch_start(url, referer, fetchcache_callback, fc); } @@ -56,35 +61,41 @@ void fetchcache_free(struct fetchcache *fc) } -void fetchcache_callback(fetch_msg msg, struct fetchcache *fc, char *data, unsigned long size) +void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size) { + struct fetchcache *fc = p; content_type type; char *mime_type; char *semic; + char status[40]; switch (msg) { case FETCH_TYPE: mime_type = strdup(data); if ((semic = strchr(mime_type, ';')) != 0) *semic = 0; /* remove "; charset=..." */ type = content_lookup(mime_type); - free(mime_type); LOG(("FETCH_TYPE, type %u", type)); if (type == CONTENT_OTHER) { fetch_abort(fc->f); - fc->callback(FETCHCACHE_BADTYPE, 0, fc->p, 0); + fc->callback(FETCHCACHE_BADTYPE, 0, fc->p, mime_type); free(fc); } else { fc->c = content_create(type, fc->url); } + free(mime_type); break; case FETCH_DATA: LOG(("FETCH_DATA")); assert(fc->c != 0); + fc->size += size; + sprintf(status, "Received %lu bytes", fc->size); + fc->callback(FETCHCACHE_STATUS, fc->c, fc->p, status); content_process_data(fc->c, data, size); break; case FETCH_FINISHED: LOG(("FETCH_FINISHED")); assert(fc->c != 0); + sprintf(status, "Converting %lu bytes", fc->size); if (content_convert(fc->c, fc->width, fc->height) == 0) { cache_put(fc->c); fc->callback(FETCHCACHE_OK, fc->c, fc->p, 0); diff --git a/content/fetchcache.h b/content/fetchcache.h index d212b56a5..37fa8176b 100644 --- a/content/fetchcache.h +++ b/content/fetchcache.h @@ -1,5 +1,5 @@ /** - * $Id: fetchcache.h,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: fetchcache.h,v 1.2 2003/02/28 11:49:13 bursa Exp $ */ #ifndef _NETSURF_DESKTOP_FETCHCACHE_H_ @@ -7,10 +7,10 @@ #include "netsurf/content/content.h" -typedef enum {FETCHCACHE_OK, FETCHCACHE_BADTYPE, FETCHCACHE_ERROR} fetchcache_msg; +typedef enum {FETCHCACHE_OK, FETCHCACHE_BADTYPE, FETCHCACHE_ERROR, FETCHCACHE_STATUS} fetchcache_msg; void fetchcache(char *url, char *referer, - void (*callback)(fetchcache_msg msg, struct content *c, void *p, char *error), + void (*callback)(fetchcache_msg msg, struct content *c, void *p, const char *error), void *p, unsigned long width, unsigned long height); #endif |