[project @ 2003-02-28 11:49:13 by bursa]

More status messages, bug fixes.

svn path=/import/netsurf/; revision=102
This commit is contained in:
James Bursa 2003-02-28 11:49:13 +00:00
parent 05318b210d
commit 817421cb0f
6 changed files with 45 additions and 29 deletions

View File

@ -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},*/
};

View File

@ -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);

View File

@ -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

View File

@ -1,5 +1,5 @@
/**
* $Id: browser.c,v 1.27 2003/02/26 18:22:24 bursa Exp $
* $Id: browser.c,v 1.28 2003/02/28 11:49:13 bursa Exp $
*/
#include "netsurf/content/cache.h"
@ -28,7 +28,7 @@ void browser_window_redraw_boxes(struct browser_window* bw, struct box_position*
void browser_window_follow_link(struct browser_window* bw,
int click_x, int click_y, int click_type);
void browser_window_callback(fetchcache_msg msg, struct content *c,
struct browser_window* bw, char *error);
struct browser_window* bw, const char *error);
void box_under_area(struct box* box, int x, int y, int ox, int oy, struct box_selection** found, int* count, int* plot_index);
@ -48,9 +48,6 @@ void browser_window_stop_throbber(struct browser_window* bw)
void browser_window_reformat(struct browser_window* bw)
{
char status[100];
clock_t time0, time1;
LOG(("Entering..."));
assert(bw != 0);
if (bw->current_content == NULL)
@ -60,26 +57,23 @@ void browser_window_reformat(struct browser_window* bw)
{
case CONTENT_HTML:
LOG(("HTML content."));
time0 = clock();
if (bw->current_content->title == 0)
gui_window_set_title(bw->window, bw->url);
else
gui_window_set_title(bw->window, bw->current_content->title);
time1 = clock();
LOG(("Setting extent"));
gui_window_set_extent(bw->window, bw->current_content->width, bw->current_content->height);
LOG(("Setting scroll"));
gui_window_set_scroll(bw->window, 0, 0);
LOG(("Redraw window"));
gui_window_redraw_window(bw->window);
LOG(("Complete"));
sprintf(status, "Format complete (%gs).", ((float) time1 - time0) / CLOCKS_PER_SEC);
browser_window_set_status(bw, status);
break;
default:
LOG(("Unknown content type"));
LOG(("Unknown content type"));
break;
}
LOG(("Redraw window"));
gui_window_redraw_window(bw->window);
}
/* create a new history item */
@ -225,6 +219,7 @@ void browser_window_open_location_historical(struct browser_window* bw, char* ur
assert(bw != 0 && url != 0);
browser_window_set_status(bw, "Opening page...");
bw->time0 = clock();
fetchcache(url, 0, browser_window_callback, bw, gui_window_get_width(bw->window), 0);
LOG(("end"));
@ -248,14 +243,14 @@ void browser_window_open_location(struct browser_window* bw, char* url)
}
void browser_window_callback(fetchcache_msg msg, struct content *c,
struct browser_window* bw, char *error)
struct browser_window* bw, const char *error)
{
gui_safety previous_safety;
char status[40];
switch (msg)
{
case FETCHCACHE_OK:
browser_window_set_status(bw, "Request complete.");
{
struct gui_message gmsg;
if (bw->url != 0)
@ -279,6 +274,8 @@ void browser_window_callback(fetchcache_msg msg, struct content *c,
bw->current_content = c;
browser_window_reformat(bw);
gui_window_set_redraw_safety(bw->window, previous_safety);
sprintf(status, "Page complete (%gs)", ((float) clock() - bw->time0) / CLOCKS_PER_SEC);
browser_window_set_status(bw, status);
browser_window_stop_throbber(bw);
}
break;
@ -289,10 +286,15 @@ void browser_window_callback(fetchcache_msg msg, struct content *c,
break;
case FETCHCACHE_BADTYPE:
browser_window_set_status(bw, "Unknown type");
fprintf(status, "Unknown type '%s'", error);
browser_window_set_status(bw, status);
browser_window_stop_throbber(bw);
break;
case FETCHCACHE_STATUS:
browser_window_set_status(bw, error);
break;
default:
assert(0);
}

View File

@ -1,10 +1,11 @@
/**
* $Id: browser.h,v 1.8 2003/02/09 19:33:19 bursa Exp $
* $Id: browser.h,v 1.9 2003/02/28 11:49:13 bursa Exp $
*/
#ifndef _NETSURF_DESKTOP_BROWSER_H_
#define _NETSURF_DESKTOP_BROWSER_H_
#include <time.h>
#include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/render/box.h"
@ -48,6 +49,7 @@ struct browser_window
struct content* current_content;
struct history* history;
clock_t time0;
char* url;

View File

@ -1,5 +1,5 @@
/**
* $Id: jpeg.c,v 1.1 2003/02/25 21:00:27 bursa Exp $
* $Id: jpeg.c,v 1.2 2003/02/28 11:49:13 bursa Exp $
*
* This is just a temporary implementation using the JPEG renderer
* available in some versions of RISC OS.
@ -26,6 +26,7 @@ void jpeg_process_data(struct content *c, char *data, unsigned long size)
c->data.jpeg.data = xrealloc(c->data.jpeg.data, c->data.jpeg.length + size);
memcpy(c->data.jpeg.data + c->data.jpeg.length, data, size);
c->data.jpeg.length += size;
c->size += size;
}