From 0075eab1949e4de071b3649c68ba402b8ffce6fb Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 14 Jan 2014 23:31:54 +0000 Subject: move remaining gui operations to table --- desktop/browser.c | 4 +-- desktop/gui.h | 85 ++++++++++++++++++++++++++------------------------- desktop/gui_factory.c | 52 +++++++++++++++++++++++++++++++ desktop/netsurf.c | 2 +- desktop/textarea.c | 4 +-- 5 files changed, 101 insertions(+), 46 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 3ae613d08..55cb779bf 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -814,7 +814,7 @@ browser_window_download(struct browser_window *bw, NULL, NULL, &l); if (error == NSERROR_NO_FETCH_HANDLER) { /* no internal handler for this type, call out to frontend */ - gui_launch_url(nsurl_access(url)); + guit->launch_url(nsurl_access(url)); } else if (error != NSERROR_OK) { LOG(("Failed to fetch download: %d", error)); } else { @@ -1873,7 +1873,7 @@ nserror browser_window_navigate(struct browser_window *bw, case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */ /** @todo does this always try and download even unverifiable content? */ - gui_launch_url(nsurl_access(url)); + guit->launch_url(nsurl_access(url)); break; default: /* report error to user */ diff --git a/desktop/gui.h b/desktop/gui.h index 2780325f5..12cf91a50 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -280,7 +280,8 @@ struct gui_table { /* Mandantory entries */ - /** called to let the frontend update its state and run any + /** + * called to let the frontend update its state and run any * I/O operations. */ void (*poll)(bool active); @@ -299,56 +300,58 @@ struct gui_table { * cache from search_web_ico() */ void (*set_search_ico)(hlcache_handle *ico); -}; - - - - -/** - * Callback to translate resource to full url. - * - * Transforms a resource: path into a full URL. The returned URL - * is used as the target for a redirect. The caller takes ownership of - * the returned nsurl including unrefing it when finished with it. - * - * \param path The path of the resource to locate. - * \return A string containing the full URL of the target object or - * NULL if no suitable resource can be found. - */ -nsurl* gui_get_resource_url(const char *path); + /** + * Callback to translate resource to full url. + * + * Transforms a resource: path into a full URL. The returned URL + * is used as the target for a redirect. The caller takes ownership of + * the returned nsurl including unrefing it when finished with it. + * + * \param path The path of the resource to locate. + * \return A string containing the full URL of the target object or + * NULL if no suitable resource can be found. + */ + nsurl* (*get_resource_url)(const char *path); -void gui_launch_url(const char *url); + /** + * core has no fetcher for url + */ + void (*launch_url)(const char *url); + + /** + * create a form select menu + */ + void (*create_form_select_menu)(struct browser_window *bw, struct form_control *control); -void gui_create_form_select_menu(struct browser_window *bw, - struct form_control *control); + /** + * Core asks front end for clipboard contents. + * + * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core + * \param length Byte length of UTF-8 text in buffer + */ + void (*get_clipboard)(char **buffer, size_t *length); -/** - * Core asks front end for clipboard contents. - * - * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core - * \param length Byte length of UTF-8 text in buffer - */ -void gui_get_clipboard(char **buffer, size_t *length); + /** + * Core tells front end to put given text in clipboard + * + * \param buffer UTF-8 text, owned by core + * \param length Byte length of UTF-8 text in buffer + * \param styles Array of styles given to text runs, owned by core, or NULL + * \param n_styles Number of text run styles in array + */ + void (*set_clipboard)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles); + /** + * verify certificate + */ + void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); -/** - * Core tells front end to put given text in clipboard - * - * \param buffer UTF-8 text, owned by core - * \param length Byte length of UTF-8 text in buffer - * \param styles Array of styles given to text runs, owned by core, or NULL - * \param n_styles Number of text run styles in array - */ -void gui_set_clipboard(const char *buffer, size_t length, - nsclipboard_styles styles[], int n_styles); +}; -void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, - unsigned long num, nserror (*cb)(bool proceed, void *pw), - void *cbpw); #endif diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index 7f76eaccb..cb01fc45e 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -256,6 +256,40 @@ static void gui_default_set_search_ico(hlcache_handle *ico) { } +static nsurl *gui_default_get_resource_url(const char *path) +{ + return NULL; +} + +static void gui_default_launch_url(const char *url) +{ +} + +static void gui_default_create_form_select_menu(struct browser_window *bw, + struct form_control *control) +{ +} + +static void gui_default_get_clipboard(char **buffer, size_t *length) +{ + *buffer = NULL; + *length = 0; +} + +static void gui_default_set_clipboard(const char *buffer, size_t length, + nsclipboard_styles styles[], int n_styles) +{ +} + +static void gui_default_cert_verify(nsurl *url, + const struct ssl_cert_info *certs, + unsigned long num, + nserror (*cb)(bool proceed, void *pw), + void *cbpw) +{ + cb(false, cbpw); +} + nserror gui_factory_register(struct gui_table *gt) { nserror err; @@ -296,6 +330,24 @@ nserror gui_factory_register(struct gui_table *gt) if (gt->set_search_ico == NULL) { gt->set_search_ico = gui_default_set_search_ico; } + if (gt->get_resource_url == NULL) { + gt->get_resource_url = gui_default_get_resource_url; + } + if (gt->launch_url == NULL) { + gt->launch_url = gui_default_launch_url; + } + if (gt->create_form_select_menu == NULL) { + gt->create_form_select_menu = gui_default_create_form_select_menu; + } + if (gt->get_clipboard == NULL) { + gt->get_clipboard = gui_default_get_clipboard; + } + if (gt->set_clipboard == NULL) { + gt->set_clipboard = gui_default_set_clipboard; + } + if (gt->cert_verify == NULL) { + gt->cert_verify = gui_default_cert_verify; + } guit = gt; diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 10dc7ba68..1c36a3fe7 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -103,7 +103,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, /* For now, do nothing, as this query type isn't emitted yet */ break; case LLCACHE_QUERY_SSL: - gui_cert_verify(query->url, query->data.ssl.certs, + guit->cert_verify(query->url, query->data.ssl.certs, query->data.ssl.num, cb, cbpw); break; } diff --git a/desktop/textarea.c b/desktop/textarea.c index f9712ac84..423767274 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1417,7 +1417,7 @@ static bool textarea_replace_text_internal(struct textarea *ta, size_t b_start, /* Place CUTs on clipboard */ if (add_to_clipboard) { - gui_set_clipboard(ta->show->data + b_start, b_end - b_start, + guit->set_clipboard(ta->show->data + b_start, b_end - b_start, NULL, 0); } @@ -2484,7 +2484,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) if (readonly) break; - gui_get_clipboard(&clipboard, &clipboard_length); + guit->get_clipboard(&clipboard, &clipboard_length); if (clipboard == NULL) return false; -- cgit v1.2.3