From 8dfe22515312a8ecf4da974feb31b0f5e7f317e5 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 14 Jan 2014 16:04:02 +0000 Subject: [PATCH] move download operations to download table --- amiga/download.c | 17 +++++-- amiga/download.h | 2 + amiga/gui.c | 2 + atari/download.c | 20 ++++++--- atari/download.h | 2 + atari/gui.c | 3 ++ beos/download.cpp | 17 +++++-- beos/download.h | 1 + beos/gui.cpp | 5 +++ cocoa/DownloadWindowController.h | 2 + cocoa/DownloadWindowController.m | 17 +++++-- cocoa/NetsurfApp.m | 2 + desktop/download.c | 8 ++-- desktop/gui.h | 35 +++++++++------ desktop/gui_factory.c | 77 +++++++++++++++++++++++++++++--- framebuffer/gui.c | 24 ---------- gtk/download.c | 30 +++++-------- gtk/download.h | 2 + gtk/gui.c | 1 + monkey/browser.h | 1 + monkey/download.c | 17 +++++-- monkey/main.c | 1 + riscos/download.c | 17 +++++-- riscos/gui.c | 1 + riscos/gui.h | 1 + windows/download.c | 18 ++++++-- windows/download.h | 2 + windows/main.c | 3 ++ 28 files changed, 232 insertions(+), 96 deletions(-) diff --git a/amiga/download.c b/amiga/download.c index d33b723d1..60190ce17 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -85,7 +85,7 @@ enum { int downloads_in_progress = 0; -struct gui_download_window *gui_download_window_create(download_context *ctx, +static struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *gui) { const char *url = download_context_get_url(ctx); @@ -193,7 +193,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, return dw; } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { APTR va[3]; @@ -227,7 +227,7 @@ nserror gui_download_window_data(struct gui_download_window *dw, return NSERROR_OK; } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { warn_user("Unwritten",""); @@ -242,7 +242,7 @@ void ami_download_window_abort(struct gui_download_window *dw) gui_download_window_done(dw); } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { struct dlnode *dln,*dln2 = NULL; struct browser_window *bw = dw->bw; @@ -432,3 +432,12 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si if(res == 1) return TRUE; else return FALSE; } + +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *amiga_gui_download_table = &gui_download_table; diff --git a/amiga/download.h b/amiga/download.h index 2febbe908..d9e637ede 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -23,6 +23,8 @@ #include "amiga/gui.h" +extern struct gui_download_table *amiga_gui_download_table; + struct download_context; struct gui_download_window; diff --git a/amiga/gui.c b/amiga/gui.c index 13c32cd8b..708ca09fe 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -5185,6 +5185,8 @@ int main(int argc, char** argv) if (ami_locate_resource(messages, "Messages") == false) die("Cannot open Messages file"); + ami_gui_table.download = amiga_gui_download_table; + ret = netsurf_init(messages, &ami_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); diff --git a/atari/download.c b/atari/download.c index e4a45e82e..4da9ef345 100755 --- a/atari/download.c +++ b/atari/download.c @@ -246,8 +246,8 @@ static char * select_filepath( const char * path, const char * filename ) return(ret); } -struct gui_download_window * gui_download_window_create(download_context *ctx, - struct gui_window *parent) +static struct gui_download_window * +gui_download_window_create(download_context *ctx, struct gui_window *parent) { const char *filename; char *destination; @@ -359,7 +359,7 @@ struct gui_download_window * gui_download_window_create(download_context *ctx, } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { @@ -415,7 +415,7 @@ nserror gui_download_window_data(struct gui_download_window *dw, return NSERROR_OK; } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { LOG(("%s", error_msg)); @@ -426,7 +426,7 @@ void gui_download_window_error(struct gui_download_window *dw, // TODO: change abort to close } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { OBJECT * tree; LOG(("")); @@ -454,3 +454,13 @@ void gui_download_window_done(struct gui_download_window *dw) } gui_window_set_status(input_window, messages_get("Done") ); } + +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *atari_gui_download_table = &gui_download_table; + diff --git a/atari/download.h b/atari/download.h index e25893d4a..a5da60538 100755 --- a/atari/download.h +++ b/atari/download.h @@ -58,4 +58,6 @@ struct gui_download_window { bool close_on_finish; }; +struct gui_download_table *atari_gui_download_table; + #endif diff --git a/atari/gui.c b/atari/gui.c index c2109c985..3128de772 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -1116,6 +1116,9 @@ int main(int argc, char** argv) /* common initialisation */ LOG(("Initialising core...")); + + atari_gui_table.download = nsgtk_gui_download_table; + ret = netsurf_init(messages, atari_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); diff --git a/beos/download.cpp b/beos/download.cpp index e20281c2f..b62ab2ffb 100644 --- a/beos/download.cpp +++ b/beos/download.cpp @@ -178,7 +178,7 @@ NSDownloadWindow::Failure(const char* error) } -struct gui_download_window *gui_download_window_create(download_context *ctx, +static struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *parent) { struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download); @@ -209,7 +209,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { dw->window->Progress(size); @@ -222,7 +222,7 @@ nserror gui_download_window_data(struct gui_download_window *dw, } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { dw->window->Failure(error_msg); @@ -232,7 +232,7 @@ void gui_download_window_error(struct gui_download_window *dw, } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { dw->window->Success(); @@ -248,3 +248,12 @@ void gui_download_window_done(struct gui_download_window *dw) dw->storageLock->Unlock(); } +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *beos_gui_download_table = &gui_download_table; + diff --git a/beos/download.h b/beos/download.h index 9c8d3adcd..962f3b7d9 100644 --- a/beos/download.h +++ b/beos/download.h @@ -16,3 +16,4 @@ * along with this program. If not, see . */ +struct gui_download_table *beos_gui_download_table; diff --git a/beos/gui.cpp b/beos/gui.cpp index efac0bb4c..45a0e6bc7 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1111,6 +1111,7 @@ int main(int argc, char** argv) BPath messages = get_messages_path(); beos_gui_table.window = beos_gui_window_table; + beos_gui_table.download = beos_gui_download_table; ret = netsurf_init(messages.Path(), &beos_gui_table); if (ret != NSERROR_OK) { @@ -1152,6 +1153,10 @@ int gui_init_replicant(int argc, char** argv) /* common initialisation */ BPath messages = get_messages_path(); + + beos_gui_table.window = beos_gui_window_table; + beos_gui_table.download = beos_gui_download_table; + ret = netsurf_init(messages.Path(), &beos_gui_table); if (ret != NSERROR_OK) { // FIXME: must not die when in replicant! diff --git a/cocoa/DownloadWindowController.h b/cocoa/DownloadWindowController.h index b93c24c65..0d049da15 100644 --- a/cocoa/DownloadWindowController.h +++ b/cocoa/DownloadWindowController.h @@ -18,6 +18,7 @@ #import +struct gui_download_table *cocoa_gui_download_table; @interface DownloadWindowController : NSWindowController { struct download_context *context; @@ -50,3 +51,4 @@ - (void) abort; @end + diff --git a/cocoa/DownloadWindowController.m b/cocoa/DownloadWindowController.m index 82be52e51..634257008 100644 --- a/cocoa/DownloadWindowController.m +++ b/cocoa/DownloadWindowController.m @@ -327,7 +327,7 @@ static NSString *cocoa_time_string( unsigned seconds ) #pragma mark - #pragma mark NetSurf interface functions -struct gui_download_window *gui_download_window_create(download_context *ctx, +static struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *parent) { DownloadWindowController * const window = [[DownloadWindowController alloc] initWithContext: ctx]; @@ -338,21 +338,21 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, return (struct gui_download_window *)window; } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { DownloadWindowController * const window = (DownloadWindowController *)dw; return [window receivedData: [NSData dataWithBytes: data length: size]] ? NSERROR_OK : NSERROR_SAVE_FAILED; } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { DownloadWindowController * const window = (DownloadWindowController *)dw; [window showError: [NSString stringWithUTF8String: error_msg]]; } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { DownloadWindowController * const window = (DownloadWindowController *)dw; [window downloadDone]; @@ -376,3 +376,12 @@ static void cocoa_unregister_download( DownloadWindowController *download ) [cocoa_all_downloads removeObject: download]; } + +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *cocoa_gui_download_table = &gui_download_table; diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index 844904f1c..a64c99376 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -203,6 +203,8 @@ int main( int argc, char **argv ) nsoption_commandline(&argc, argv, NULL); /* common initialisation */ + cocoa_gui_table->download = cocoa_gui_download_table; + error = netsurf_init(messages, cocoa_gui_table); if (error != NSERROR_OK) { die("NetSurf failed to initialise"); diff --git a/desktop/download.c b/desktop/download.c index b775eb18e..98c6b6dd0 100644 --- a/desktop/download.c +++ b/desktop/download.c @@ -160,7 +160,7 @@ static nserror download_context_process_headers(download_context *ctx) } /* Create the frontend window */ - ctx->window = gui_download_window_create(ctx, ctx->parent); + ctx->window = guit->download->create(ctx, ctx->parent); if (ctx->window == NULL) { free(ctx->filename); ctx->filename = NULL; @@ -210,7 +210,7 @@ static nserror download_callback(llcache_handle *handle, if (error == NSERROR_OK) { /** \todo Lose ugly cast */ - error = gui_download_window_data(ctx->window, + error = guit->download->data(ctx->window, (char *) event->data.data.buf, event->data.data.len); if (error != NSERROR_OK) @@ -222,7 +222,7 @@ static nserror download_callback(llcache_handle *handle, case LLCACHE_EVENT_DONE: /* There may be no associated window if there was no data or headers */ if (ctx->window != NULL) - gui_download_window_done(ctx->window); + guit->download->done(ctx->window); else download_context_destroy(ctx); @@ -230,7 +230,7 @@ static nserror download_callback(llcache_handle *handle, case LLCACHE_EVENT_ERROR: if (ctx->window != NULL) - gui_download_window_error(ctx->window, event->data.msg); + guit->download->error(ctx->window, event->data.msg); else download_context_destroy(ctx); diff --git a/desktop/gui.h b/desktop/gui.h index 8d65893d0..50e8c67d9 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -244,16 +244,34 @@ struct gui_window_table { void (*start_selection)(struct gui_window *g); }; +/** + * function table for download windows + */ +struct gui_download_table { + struct gui_download_window *(*create)(download_context *ctx, struct gui_window *parent); + + nserror (*data)(struct gui_download_window *dw, const char *data, unsigned int size); + + void (*error)(struct gui_download_window *dw, const char *error_msg); + + void (*done)(struct gui_download_window *dw); +}; + /** Graphical user interface function table * * function table implementing GUI interface to browser core */ struct gui_table { - /* Mandantory entries */ - /* sub tables */ - struct gui_window_table *window; /* window sub table */ + + /** Window sub table */ + struct gui_window_table *window; + + /** Downlaod sub table */ + struct gui_download_table *download; + + /* Mandantory entries */ /** called to let the frontend update its state and run any * I/O operations. @@ -280,17 +298,6 @@ extern struct gui_table *guit; /* the gui vtable */ - -struct gui_download_window *gui_download_window_create(download_context *ctx, - struct gui_window *parent); -nserror gui_download_window_data(struct gui_download_window *dw, - const char *data, unsigned int size); -void gui_download_window_error(struct gui_download_window *dw, - const char *error_msg); -void gui_download_window_done(struct gui_download_window *dw); - - - /** * Callback to translate resource to full url. * diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index 8ebf3515a..7f76eaccb 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -5,13 +5,6 @@ struct gui_table *guit = NULL; -static void gui_default_quit(void) -{ -} - -static void gui_default_set_search_ico(hlcache_handle *ico) -{ -} static void gui_default_window_set_title(struct gui_window *g, const char *title) @@ -201,6 +194,68 @@ static nserror verify_window_register(struct gui_window_table *gwt) return NSERROR_OK; } + +static struct gui_download_window * +gui_default_download_create(download_context *ctx, struct gui_window *parent) +{ + return NULL; +} + +static nserror gui_default_download_data(struct gui_download_window *dw, + const char *data, unsigned int size) +{ + return NSERROR_OK; +} + +static void gui_default_download_error(struct gui_download_window *dw, + const char *error_msg) +{ +} + +static void gui_default_download_done(struct gui_download_window *dw) +{ +} + +static struct gui_download_table default_download_table = { + .create = gui_default_download_create, + .data = gui_default_download_data, + .error = gui_default_download_error, + .done = gui_default_download_done, +}; + +/** verify download window table is valid */ +static nserror verify_download_register(struct gui_download_table *gdt) +{ + /* check table is present */ + if (gdt == NULL) { + return NSERROR_BAD_PARAMETER; + } + + /* all enties are mandantory */ + if (gdt->create == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gdt->data == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gdt->error == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gdt->done == NULL) { + return NSERROR_BAD_PARAMETER; + } + + return NSERROR_OK; +} + +static void gui_default_quit(void) +{ +} + +static void gui_default_set_search_ico(hlcache_handle *ico) +{ +} + nserror gui_factory_register(struct gui_table *gt) { nserror err; @@ -220,6 +275,14 @@ nserror gui_factory_register(struct gui_table *gt) if (err != NSERROR_OK) { return err; } + if (gt->download == NULL) { + /* set default download table */ + gt->download = &default_download_table; + } + err = verify_download_register(gt->download); + if (err != NSERROR_OK) { + return err; + } /* check the mandantory fields are set */ if (gt->poll == NULL) { diff --git a/framebuffer/gui.c b/framebuffer/gui.c index eff0a98e1..c71872067 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1766,30 +1766,6 @@ gui_window_remove_caret(struct gui_window *g) } } -struct gui_download_window * -gui_download_window_create(download_context *ctx, struct gui_window *parent) -{ - return NULL; -} - -nserror -gui_download_window_data(struct gui_download_window *dw, - const char *data, - unsigned int size) -{ - return NSERROR_OK; -} - -void -gui_download_window_error(struct gui_download_window *dw, - const char *error_msg) -{ -} - -void -gui_download_window_done(struct gui_download_window *dw) -{ -} void gui_create_form_select_menu(struct browser_window *bw, diff --git a/gtk/download.c b/gtk/download.c index e882ec798..1eb53403e 100644 --- a/gtk/download.c +++ b/gtk/download.c @@ -712,8 +712,8 @@ static void nsgtk_download_store_create_item (struct gui_download_window *dl) NSGTK_DOWNLOAD, dl, -1); } -struct gui_download_window *gui_download_window_create(download_context *ctx, - struct gui_window *gui) +static struct gui_download_window * +gui_download_window_create(download_context *ctx, struct gui_window *gui) { const char *url = download_context_get_url(ctx); unsigned long total_size = download_context_get_total_length(ctx); @@ -797,7 +797,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, } -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { g_io_channel_write_chars(dw->write, data, size, NULL, &dw->error); @@ -820,13 +820,13 @@ nserror gui_download_window_data(struct gui_download_window *dw, } -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { } -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { g_io_channel_shutdown(dw->write, TRUE, &dw->error); g_io_channel_unref(dw->write); @@ -845,17 +845,11 @@ void gui_download_window_done(struct gui_download_window *dw) } +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; - - - - - - - - - - - - - +struct gui_download_table *nsgtk_gui_download_table = &gui_download_table; diff --git a/gtk/download.h b/gtk/download.h index e85c4126a..393009dc4 100644 --- a/gtk/download.h +++ b/gtk/download.h @@ -27,4 +27,6 @@ bool nsgtk_check_for_downloads(GtkWindow *parent); void nsgtk_download_show(GtkWindow *parent); void nsgtk_download_add(gchar *url, gchar *destination); +struct gui_download_table *nsgtk_gui_download_table; + #endif diff --git a/gtk/gui.c b/gtk/gui.c index 0a89f0ee3..0501ec3f6 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -1172,6 +1172,7 @@ int main(int argc, char** argv) messages = filepath_find(respaths, "Messages"); nsgtk_gui_table.window = nsgtk_gui_window_table; + nsgtk_gui_table.download = nsgtk_gui_download_table; ret = netsurf_init(messages, &nsgtk_gui_table); free(messages); diff --git a/monkey/browser.h b/monkey/browser.h index 892c615ab..6c74a412c 100644 --- a/monkey/browser.h +++ b/monkey/browser.h @@ -37,6 +37,7 @@ struct gui_window { }; extern struct gui_window_table *monkey_gui_window_table; +extern struct gui_download_table *monkey_gui_download_table; struct gui_window *monkey_find_window_by_num(uint32_t win_num); struct gui_window *monkey_find_window_by_content(hlcache_handle *content); diff --git a/monkey/download.c b/monkey/download.c index d706dd6e0..46d54dc0c 100644 --- a/monkey/download.c +++ b/monkey/download.c @@ -34,7 +34,7 @@ struct gui_download_window { static struct gui_download_window *dw_ring = NULL; -struct gui_download_window * +static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *parent) { @@ -52,7 +52,7 @@ gui_download_window_create(download_context *ctx, return ret; } -nserror +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { @@ -61,7 +61,7 @@ gui_download_window_data(struct gui_download_window *dw, return NSERROR_OK; } -void +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { @@ -69,7 +69,7 @@ gui_download_window_error(struct gui_download_window *dw, dw->dwin_num, error_msg); } -void +static void gui_download_window_done(struct gui_download_window *dw) { fprintf(stdout, "DOWNLOAD_WINDOW DONE DWIN %u\n", @@ -77,3 +77,12 @@ gui_download_window_done(struct gui_download_window *dw) RING_REMOVE(dw_ring, dw); free(dw); } + +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *monkey_gui_download_table = &gui_download_table; diff --git a/monkey/main.c b/monkey/main.c index c6aa60f10..ce7906e03 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -153,6 +153,7 @@ main(int argc, char **argv) messages = filepath_find(respaths, "Messages"); monkey_gui_table.window = monkey_gui_window_table; + monkey_gui_table.download = monkey_gui_download_table; ret = netsurf_init(messages, &monkey_gui_table); free(messages); diff --git a/riscos/download.c b/riscos/download.c index ebd981dca..aeeeeffbd 100644 --- a/riscos/download.c +++ b/riscos/download.c @@ -215,7 +215,7 @@ const char *ro_gui_download_temp_name(struct gui_download_window *dw) * reported */ -struct gui_download_window *gui_download_window_create(download_context *ctx, +static struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *gui) { const char *url = download_context_get_url(ctx); @@ -445,7 +445,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, * \return NSERROR_OK on success, appropriate error otherwise */ -nserror gui_download_window_data(struct gui_download_window *dw, +static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size) { while (true) { @@ -714,7 +714,7 @@ void ro_gui_download_window_hide_caret(struct gui_download_window *dw) * \param error_msg error message */ -void gui_download_window_error(struct gui_download_window *dw, +static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { os_error *error; @@ -766,7 +766,7 @@ void gui_download_window_error(struct gui_download_window *dw, * \param dw download window */ -void gui_download_window_done(struct gui_download_window *dw) +static void gui_download_window_done(struct gui_download_window *dw) { os_error *error; @@ -1631,3 +1631,12 @@ bool ro_gui_download_prequit(void) } return true; } + +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *riscos_gui_download_table = &gui_download_table; diff --git a/riscos/gui.c b/riscos/gui.c index f7caf02da..60b14833c 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -898,6 +898,7 @@ int main(int argc, char** argv) /* common initialisation */ riscos_gui_table.window = riscos_gui_window_table; + riscos_gui_table.download = riscos_gui_download_table; ret = netsurf_init(path, &riscos_gui_table); if (ret != NSERROR_OK) { diff --git a/riscos/gui.h b/riscos/gui.h index 1abb40fba..38f3fc60c 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -123,6 +123,7 @@ const char *ro_gui_default_language(void); void ro_gui_download_init(void); void ro_gui_download_datasave_ack(wimp_message *message); bool ro_gui_download_prequit(void); +extern struct gui_download_table *riscos_gui_download_table; /* in 401login.c */ void ro_gui_401login_init(void); diff --git a/windows/download.c b/windows/download.c index 635e3b604..5bf9798aa 100644 --- a/windows/download.c +++ b/windows/download.c @@ -45,7 +45,7 @@ static void nsws_download_update_label(void *p); static void nsws_download_update_progress(void *p); static void nsws_download_clear_data(struct gui_download_window *w); -struct gui_download_window * +static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *gui) { if (downloading) { @@ -259,7 +259,8 @@ void nsws_download_clear_data(struct gui_download_window *w) } -nserror gui_download_window_data(struct gui_download_window *w, const char *data, +static nserror +gui_download_window_data(struct gui_download_window *w, const char *data, unsigned int size) { if ((w == NULL) || (w->file == NULL)) @@ -279,13 +280,13 @@ nserror gui_download_window_data(struct gui_download_window *w, const char *data return NSERROR_OK; } -void gui_download_window_error(struct gui_download_window *w, +static void gui_download_window_error(struct gui_download_window *w, const char *error_msg) { LOG(("error %s", error_msg)); } -void gui_download_window_done(struct gui_download_window *w) +static void gui_download_window_done(struct gui_download_window *w) { if (w == NULL) return; @@ -295,3 +296,12 @@ void gui_download_window_done(struct gui_download_window *w) nsws_download_clear_data(w); } +static struct gui_download_table gui_download_table = { + .create = gui_download_window_create, + .data = gui_download_window_data, + .error = gui_download_window_error, + .done = gui_download_window_done, +}; + +struct gui_download_table *win32_gui_download_table = &gui_download_table; + diff --git a/windows/download.h b/windows/download.h index 777777da5..c1b13bf65 100644 --- a/windows/download.h +++ b/windows/download.h @@ -60,4 +60,6 @@ struct gui_download_window { void nsws_download_window_init(struct gui_window *); +struct gui_download_table *win32_gui_download_table; + #endif diff --git a/windows/main.c b/windows/main.c index 5f20a70d1..eb63357af 100644 --- a/windows/main.c +++ b/windows/main.c @@ -154,6 +154,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* common initialisation */ messages = filepath_find(respaths, "messages"); + + win32_gui_table->download = nsgtk_gui_download_table; + ret = netsurf_init(messages, win32_gui_table); free(messages); if (ret != NSERROR_OK) {