diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2014-01-14 16:04:02 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2014-01-14 16:04:02 +0000 |
commit | 8dfe22515312a8ecf4da974feb31b0f5e7f317e5 (patch) | |
tree | 163091cfeda5c4cb644e08e7649f70788070a560 /desktop/gui_factory.c | |
parent | d18c8ed4521714c3fff3cca64685b8192ca0e075 (diff) | |
download | netsurf-8dfe22515312a8ecf4da974feb31b0f5e7f317e5.tar.gz netsurf-8dfe22515312a8ecf4da974feb31b0f5e7f317e5.tar.bz2 |
move download operations to download table
Diffstat (limited to 'desktop/gui_factory.c')
-rw-r--r-- | desktop/gui_factory.c | 77 |
1 files changed, 70 insertions, 7 deletions
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) { |