From d9e7d5810678c1470808c3de63f7bde412b3d17b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 11 Oct 2012 11:20:02 +0100 Subject: Fix up ripples from urldb change. --- amiga/login.c | 18 +++++---- amiga/sslcert.c | 2 +- amiga/stringview/urlhistory.c | 8 ++-- amiga/thumbnail.c | 2 +- atari/gui.c | 18 ++++----- atari/login.c | 14 ++++--- atari/login.h | 4 +- atari/thumbnail.c | 2 +- beos/gui.cpp | 2 +- beos/thumbnail.cpp | 2 +- cocoa/gui.m | 4 +- cocoa/thumbnail.m | 3 +- content/urldb.c | 2 + desktop/401login.h | 3 +- desktop/browser.c | 3 +- desktop/browser.h | 2 +- desktop/gui.h | 2 +- desktop/history_core.c | 10 ++--- desktop/history_global_core.c | 7 ++-- desktop/hotlist.c | 85 ++++++++++++++++++++++++++----------------- desktop/netsurf.c | 5 +-- desktop/sslcert.c | 11 ++++-- desktop/sslcert.h | 2 +- desktop/thumbnail.h | 3 +- desktop/tree_url_node.c | 59 +++++++++++++++++------------- desktop/tree_url_node.h | 9 +++-- framebuffer/gui.c | 2 +- framebuffer/login.c | 2 +- framebuffer/thumbnail.c | 2 +- gtk/completion.c | 7 ++-- gtk/gui.c | 2 +- gtk/login.c | 29 +++++++-------- gtk/thumbnail.c | 4 +- monkey/401login.c | 6 +-- monkey/cert.c | 4 +- monkey/thumbnail.c | 6 +-- riscos/401login.c | 44 ++++++++++------------ riscos/hotlist.c | 6 ++- riscos/sslcert.c | 2 +- riscos/thumbnail.c | 2 +- riscos/url_complete.c | 41 +++++++++++---------- riscos/url_suggest.c | 12 ++++-- windows/gui.c | 2 +- windows/login.c | 2 +- windows/thumbnail.c | 4 +- 45 files changed, 251 insertions(+), 210 deletions(-) diff --git a/amiga/login.c b/amiga/login.c index 496898113..35115bc2a 100755 --- a/amiga/login.c +++ b/amiga/login.c @@ -48,23 +48,24 @@ struct gui_login_window { Object *objects[GID_LAST]; nserror (*cb)(bool proceed, void *pw); void *cbpw; - char *url; + nsurl *url; char *realm; - char *host; + lwc_string *host; char uname[256]; char pwd[256]; }; -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { const char *auth; struct gui_login_window *lw = AllocVec(sizeof(struct gui_login_window),MEMF_PRIVATE | MEMF_CLEAR); - char *host; + lwc_string *host = nsurl_get_component(url, NSURL_HOST); + + assert(host != NULL); - url_host(url, &host); lw->host = host; - lw->url = (char *)url; + lw->url = nsurl_ref(url); lw->realm = (char *)realm; lw->cb = cb; lw->cbpw = cbpw; @@ -105,7 +106,7 @@ void gui_401login_open(const char *url, const char *realm, WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_ParentGroup, lw->objects[GID_MAIN] = VGroupObject, LAYOUT_AddChild, StringObject, - STRINGA_TextVal,lw->host, + STRINGA_TextVal,lw->lwc_string_data(host), GA_ReadOnly,TRUE, StringEnd, CHILD_Label, LabelObject, @@ -171,7 +172,8 @@ void ami_401login_close(struct gui_login_window *lw) lw->cb(false, lw->cbpw); DisposeObject(lw->objects[OID_MAIN]); - free(lw->host); + lwc_string_unref(lw->host); + nsurl_unref(lw->url); DelObject(lw->node); } diff --git a/amiga/sslcert.c b/amiga/sslcert.c index 8eede70f2..dcf9a6d7d 100644 --- a/amiga/sslcert.c +++ b/amiga/sslcert.c @@ -20,7 +20,7 @@ #include "amiga/tree.h" #include "amiga/sslcert.h" -void gui_cert_verify(const char *url, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { diff --git a/amiga/stringview/urlhistory.c b/amiga/stringview/urlhistory.c index af9c35b13..ec56987f9 100644 --- a/amiga/stringview/urlhistory.c +++ b/amiga/stringview/urlhistory.c @@ -69,7 +69,7 @@ struct List * URLHistory_GetList( void ) return &PageList; } -static bool URLHistoryFound(const char *url, const struct url_data *data) +static bool URLHistoryFound(nsurl *url, const struct url_data *data) { struct Node *node; @@ -77,16 +77,16 @@ static bool URLHistoryFound(const char *url, const struct url_data *data) if(data->visits <= 0) return true; /* skip this URL if it is already in the list */ - if(URLHistory_FindPage(url)) return true; + if(URLHistory_FindPage(nsurl_access(url))) return true; node = AllocVec( sizeof( struct Node ), MEMF_SHARED|MEMF_CLEAR ); if ( node ) { - STRPTR urladd = (STRPTR) AllocVec( strlen ( url ) + 1, MEMF_SHARED|MEMF_CLEAR ); + STRPTR urladd = (STRPTR) AllocVec( strlen ( nsurl_access(url) ) + 1, MEMF_SHARED|MEMF_CLEAR ); if ( urladd ) { - strcpy(urladd, url); + strcpy(urladd, nsurl_access(url)); node->ln_Name = urladd; AddTail( &PageList, node ); } diff --git a/amiga/thumbnail.c b/amiga/thumbnail.c index 08ab90a95..f1738d29d 100755 --- a/amiga/thumbnail.c +++ b/amiga/thumbnail.c @@ -37,7 +37,7 @@ #include bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { struct BitScaleArgs bsa; int plot_width; diff --git a/atari/gui.c b/atari/gui.c index b780985dc..0b76d39ba 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -743,12 +743,12 @@ void gui_launch_url(const char *url) LOG(("launch file: %s\n", url)); } -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { bool bres; char * out = NULL; - bres = login_form_do( (char*)url, (char*)realm, &out ); + bres = login_form_do( url, (char*)realm, &out ); if( bres ) { LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out )); urldb_set_auth_details(url, realm, out ); @@ -760,7 +760,7 @@ void gui_401login_open(const char *url, const char *realm, cb(bres, cbpw); } -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { @@ -951,15 +951,15 @@ static void gui_init(int argc, char** argv) LOG(("Enabling core select menu")); nsoption_set_bool(core_select_menu, true); - + LOG(("Loading url.db from: %s", nsoption_charp(url_file) )); if( strlen(nsoption_charp(url_file)) ){ urldb_load(nsoption_charp(url_file)); - } - - if (nsoption_charp(cookie_file) == NULL ){ - nsoption_set_charp(cookie_file, (char*)"cookies"); - } + } + + if (nsoption_charp(cookie_file) == NULL ){ + nsoption_set_charp(cookie_file, (char*)"cookies"); + } LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) )); if( strlen(nsoption_charp(cookie_file)) ){ urldb_load_cookies(nsoption_charp(cookie_file)); diff --git a/atari/login.c b/atari/login.c index 2dc766f56..ddcfeba43 100755 --- a/atari/login.c +++ b/atari/login.c @@ -42,7 +42,7 @@ extern void * h_gem_rsrc; -bool login_form_do( char * url, char * realm, char ** out ) +bool login_form_do( nsurl * url, char * realm, char ** out ) { OBJECT *tree, *newtree; WINDOW * form; @@ -51,19 +51,21 @@ bool login_form_do( char * url, char * realm, char ** out ) bool bres = false; int res = 0; const char * auth; - char * host; - assert( url_host( url, &host) == URL_FUNC_OK ); + lwc_string * host = nsurl_get_component(url, NSURL_HOST); + assert(host != NULL); if( realm == NULL ){ realm = (char*)"Secure Area"; } - int len = strlen(realm) + strlen(host) + 4; + int len = strlen(realm) + lwc_string_length(host) + 4; char * title = malloc( len ); strncpy(title, realm, len ); strncpy(title, ": ", len-strlen(realm) ); - strncat(title, host, len-strlen(realm)+2 ); - + strncat(title, lwc_string_data(host), len-strlen(realm)+2 ); + + lwc_string_unref(host); + auth = urldb_get_auth_details(url, realm); user[0] = 0; pass[0] = 0; diff --git a/atari/login.h b/atari/login.h index 52a4832c9..345f91df3 100755 --- a/atari/login.h +++ b/atari/login.h @@ -19,6 +19,8 @@ #ifndef NS_LOGIN_H_INCLUDED #define NS_LOGIN_H_INCLUDED -bool login_form_do( char * host, char * realm, char **cbpw ); +#include "utils/nsurl.h" + +bool login_form_do( nsurl * host, char * realm, char **cbpw ); #endif diff --git a/atari/thumbnail.c b/atari/thumbnail.c index ff1c09eed..4783103bd 100755 --- a/atari/thumbnail.c +++ b/atari/thumbnail.c @@ -19,7 +19,7 @@ #include "desktop/thumbnail.h" bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { return false; } diff --git a/beos/gui.cpp b/beos/gui.cpp index 4b16022f0..dc3c33538 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1009,7 +1009,7 @@ void die(const char * const error) exit(EXIT_FAILURE); } -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { diff --git a/beos/thumbnail.cpp b/beos/thumbnail.cpp index ea03d29d8..128462f57 100644 --- a/beos/thumbnail.cpp +++ b/beos/thumbnail.cpp @@ -57,7 +57,7 @@ extern status_t ScaleBitmap(const BBitmap& inBitmap, BBitmap& outBitmap); * \param url the URL the thumnail belongs to, or NULL */ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { BBitmap *thumbnail; BBitmap *small; diff --git a/cocoa/gui.m b/cocoa/gui.m index a76924b5c..94de3753b 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -310,7 +310,7 @@ void gui_launch_url(const char *url) struct ssl_cert_info; -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { @@ -318,7 +318,7 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, } -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { cb( false, cbpw ); diff --git a/cocoa/thumbnail.m b/cocoa/thumbnail.m index fd287a523..7e524b754 100644 --- a/cocoa/thumbnail.m +++ b/cocoa/thumbnail.m @@ -26,8 +26,7 @@ #import "image/bitmap.h" /* In platform specific thumbnail.c. */ -bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, - const char *url) +bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, nsurl *url) { int bwidth = bitmap_get_width( bitmap ); int bheight = bitmap_get_height( bitmap ); diff --git a/content/urldb.c b/content/urldb.c index 975616cfb..7be508bef 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -1905,12 +1905,14 @@ struct path_data *urldb_find_url(nsurl *url) tree = urldb_get_search_tree(host_str); h = urldb_search_find(tree, host_str); if (!h) { + lwc_string_unref(scheme); return NULL; } /* generate plq (path, leaf, query) */ if (nsurl_get(url, NSURL_PATH | NSURL_QUERY, &plq, &len) != NSERROR_OK) { + lwc_string_unref(scheme); return NULL; } diff --git a/desktop/401login.h b/desktop/401login.h index dec3fa5e1..1c8140bae 100644 --- a/desktop/401login.h +++ b/desktop/401login.h @@ -22,9 +22,10 @@ #include #include "utils/config.h" +#include "utils/nsurl.h" #include "utils/errors.h" -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw); #endif diff --git a/desktop/browser.c b/desktop/browser.c index 7647cbb25..46fd14b8d 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1276,8 +1276,7 @@ nserror browser_window_callback(hlcache_handle *c, urldb_set_url_content_type(url, content_get_type(c)); /* This is safe as we've just added the URL */ - global_history_add( - nsurl_access(urldb_get_url(url))); + global_history_add(urldb_get_url(url)); } } diff --git a/desktop/browser.h b/desktop/browser.h index a78735806..f3c68fa09 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -324,7 +324,7 @@ void browser_window_debug_dump(struct browser_window *bw, FILE *f); void hotlist_visited(struct hlcache_handle *c); /* In platform specific global_history.c. */ -void global_history_add(const char *url); +void global_history_add(nsurl *url); /* In platform specific theme_install.c. */ #ifdef WITH_THEME_INSTALL diff --git a/desktop/gui.h b/desktop/gui.h index aa3fc8191..48684c3c5 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -133,7 +133,7 @@ void gui_launch_url(const char *url); struct ssl_cert_info; -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); diff --git a/desktop/history_core.c b/desktop/history_core.c index 21e402f1e..177de6b29 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -227,6 +227,7 @@ void history_add(struct history *history, hlcache_handle *content, const char *frag_id) { struct history_entry *entry; + nsurl *nsurl = hlcache_handle_get_url(content); char *url; char *title; struct bitmap *bitmap; @@ -242,8 +243,7 @@ void history_add(struct history *history, hlcache_handle *content, return; /* TODO: use a nsurl? */ - error = nsurl_get(hlcache_handle_get_url(content), NSURL_WITH_FRAGMENT, - &url, &url_len); + error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &url, &url_len); if (error != NSERROR_OK) { warn_user("NoMemory", 0); free(entry); @@ -281,7 +281,7 @@ void history_add(struct history *history, hlcache_handle *content, /* if we have a thumbnail, don't update until the page has finished * loading */ - bitmap = urldb_get_thumbnail(url); + bitmap = urldb_get_thumbnail(nsurl); if (!bitmap) { bitmap = bitmap_create(WIDTH, HEIGHT, BITMAP_NEW | BITMAP_CLEAR_MEMORY | @@ -290,7 +290,7 @@ void history_add(struct history *history, hlcache_handle *content, warn_user("NoMemory", 0); return; } - if (thumbnail_create(content, bitmap, url) == false) { + if (thumbnail_create(content, bitmap, nsurl) == false) { /* Thumbnailing failed. Ignore it silently */ bitmap_destroy(bitmap); bitmap = NULL; @@ -329,7 +329,7 @@ void history_update(struct history *history, hlcache_handle *content) free(history->current->page.title); history->current->page.title = title; - thumbnail_create(content, history->current->bitmap, 0); + thumbnail_create(content, history->current->bitmap, NULL); } diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c index a73bd7c2b..de67bf869 100644 --- a/desktop/history_global_core.c +++ b/desktop/history_global_core.c @@ -94,8 +94,7 @@ static struct node *history_global_find(const char *url) * \param data URL data associated with URL * \return true (for urldb_iterate_entries) */ -static bool global_history_add_internal(const char *url, - const struct url_data *data) +static bool global_history_add_internal(nsurl *url, const struct url_data *data) { int i, j; struct node *parent = NULL; @@ -143,7 +142,7 @@ static bool global_history_add_internal(const char *url, /* find any previous occurance */ if (global_history_initialised == false) { - node = history_global_find(url); + node = history_global_find(nsurl_access(url)); if (node != NULL) { tree_update_URL_node(global_history_tree, node, url, data); @@ -327,7 +326,7 @@ void history_global_cleanup(void) * * \param url the url to be added */ -void global_history_add(const char *url) +void global_history_add(nsurl *url) { const struct url_data *data; diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 788722d20..b6eac3634 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -58,7 +58,7 @@ static const struct { #define HOTLIST_ENTRIES_COUNT (sizeof(hotlist_default_entries) / sizeof(hotlist_default_entries[0])) static node_callback_resp hotlist_node_callback(void *user_data, - struct node_msg_data *msg_data) + struct node_msg_data *msg_data) { struct node *node = msg_data->node; const char *text; @@ -116,7 +116,8 @@ static node_callback_resp hotlist_node_callback(void *user_data, } /* exported interface documented in hotlist.h */ -bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name) +bool hotlist_initialise(struct tree *tree, const char *hotlist_path, + const char* folder_icon_name) { struct node *node; const struct url_data *url_data; @@ -137,10 +138,8 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* hotlist_tree = tree; hotlist_tree_root = tree_get_root(hotlist_tree); - if (tree_urlfile_load(hotlist_path, - hotlist_tree, - hotlist_node_callback, - NULL)) { + if (tree_urlfile_load(hotlist_path, hotlist_tree, + hotlist_node_callback, NULL)) { return true; } @@ -153,7 +152,7 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* return false; } node = tree_create_folder_node(hotlist_tree, hotlist_tree_root, - name, true, false, false); + name, true, false, false); if (node == NULL) { free(name); return false; @@ -163,24 +162,24 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* tree_set_node_icon(hotlist_tree, node, folder_icon); for (hlst_loop = 0; hlst_loop != HOTLIST_ENTRIES_COUNT; hlst_loop++) { - url_data = urldb_get_url_data(hotlist_default_entries[hlst_loop].url); + nsurl *url; + if (nsurl_create(hotlist_default_entries[hlst_loop].url, + &url) != NSERROR_OK) { + return false; + } + url_data = urldb_get_url_data(url); if (url_data == NULL) { - urldb_add_url(hotlist_default_entries[hlst_loop].url); - urldb_set_url_persistence( - hotlist_default_entries[hlst_loop].url, - true); - url_data = urldb_get_url_data( - hotlist_default_entries[hlst_loop].url); + urldb_add_url(url); + urldb_set_url_persistence(url, true); + url_data = urldb_get_url_data(url); } if (url_data != NULL) { - tree_create_URL_node(hotlist_tree, node, - hotlist_default_entries[hlst_loop].url, + tree_create_URL_node(hotlist_tree, node, url, messages_get(hotlist_default_entries[hlst_loop].msg_key), hotlist_node_callback, NULL); - tree_update_URL_node(hotlist_tree, node, - hotlist_default_entries[hlst_loop].url, - url_data); + tree_update_URL_node(hotlist_tree, node, url, url_data); } + nsurl_unref(url); } return true; @@ -221,21 +220,22 @@ static void hotlist_visited_internal(hlcache_handle *content, struct node *node) struct node *child; const char *text; const char *url; + nsurl *nsurl; if (content == NULL || hlcache_handle_get_url(content) == NULL || hotlist_tree == NULL) return; - /* TODO: do this with a nsurl instead */ - url = nsurl_access(hlcache_handle_get_url(content)); + nsurl = hlcache_handle_get_url(content); + url = nsurl_access(nsurl); for (; node; node = tree_node_get_next(node)) { if (!tree_node_is_folder(node)) { text = tree_url_node_get_url(node); if (strcmp(text, url) == 0) { tree_update_URL_node(hotlist_tree, node, - url, NULL); + nsurl, NULL); } } child = tree_node_get_child(node); @@ -416,6 +416,7 @@ void hotlist_add_entry(bool selected) struct node *node; struct node *parent = NULL; creating_node = true; + nsurl *url; if (selected == true) { parent = tree_get_selected_node(tree_get_root(hotlist_tree)); @@ -428,8 +429,12 @@ void hotlist_add_entry(bool selected) parent = tree_get_default_folder_node(hotlist_tree); } - node = tree_create_URL_node(hotlist_tree, parent, "Address", - "Untitled", hotlist_node_callback, NULL); + if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK) + return; + node = tree_create_URL_node(hotlist_tree, parent, url, "Untitled", + hotlist_node_callback, NULL); + + nsurl_unref(url); if (node == NULL) return; @@ -444,17 +449,23 @@ void hotlist_add_page(const char *url) { const struct url_data *data; struct node *node, *parent; + nsurl *nsurl; if (url == NULL) return; - data = urldb_get_url_data(url); + + if (nsurl_create(url, &nsurl) != NSERROR_OK) + return; + + data = urldb_get_url_data(nsurl); if (data == NULL) return; parent = tree_get_default_folder_node(hotlist_tree); - node = tree_create_URL_node(hotlist_tree, parent, url, NULL, - hotlist_node_callback, NULL); - tree_update_URL_node(hotlist_tree, node, url, data); + node = tree_create_URL_node(hotlist_tree, parent, nsurl, NULL, + hotlist_node_callback, NULL); + tree_update_URL_node(hotlist_tree, node, nsurl, data); + nsurl_unref(nsurl); } /** @@ -468,19 +479,27 @@ void hotlist_add_page_xy(const char *url, int x, int y) const struct url_data *data; struct node *link, *node; bool before; + nsurl *nsurl; + + if (url == NULL) + return; + + if (nsurl_create(url, &nsurl) != NSERROR_OK) + return; - data = urldb_get_url_data(url); + data = urldb_get_url_data(nsurl); if (data == NULL) { - urldb_add_url(url); - urldb_set_url_persistence(url, true); - data = urldb_get_url_data(url); + urldb_add_url(nsurl); + urldb_set_url_persistence(nsurl, true); + data = urldb_get_url_data(nsurl); } if (data != NULL) { link = tree_get_link_details(hotlist_tree, x, y, &before); - node = tree_create_URL_node(NULL, NULL, url, + node = tree_create_URL_node(NULL, NULL, nsurl, NULL, hotlist_node_callback, NULL); tree_link_node(hotlist_tree, link, node, before); } + nsurl_unref(nsurl); } /** diff --git a/desktop/netsurf.c b/desktop/netsurf.c index d2010d80b..65765fae4 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -94,15 +94,14 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, { switch (query->type) { case LLCACHE_QUERY_AUTH: - gui_401login_open(nsurl_access(query->url), - query->data.auth.realm, cb, cbpw); + gui_401login_open(query->url, query->data.auth.realm, cb, cbpw); break; case LLCACHE_QUERY_REDIRECT: /** \todo Need redirect query dialog */ /* For now, do nothing, as this query type isn't emitted yet */ break; case LLCACHE_QUERY_SSL: - gui_cert_verify(nsurl_access(query->url), query->data.ssl.certs, + gui_cert_verify(query->url, query->data.ssl.certs, query->data.ssl.num, cb, cbpw); break; } diff --git a/desktop/sslcert.c b/desktop/sslcert.c index d63d3a2eb..b7a424465 100644 --- a/desktop/sslcert.c +++ b/desktop/sslcert.c @@ -34,6 +34,7 @@ #include "desktop/tree.h" #include "utils/log.h" #include "utils/messages.h" +#include "utils/nsurl.h" #include "utils/utils.h" /** Flags for each type of ssl tree node. */ @@ -49,7 +50,7 @@ enum tree_element_ssl { /** ssl certificate verification context. */ struct sslcert_session_data { unsigned long num; /**< The number of ssl certificates in the chain */ - char *url; /**< The url of the certificate */ + nsurl *url; /**< The url of the certificate */ struct tree *tree; /**< The root of the treeview */ llcache_query_response cb; /**< callback when cert is accepted or rejected */ void *cbpw; /**< context passed to callback */ @@ -84,7 +85,7 @@ void sslcert_cleanup(void) struct sslcert_session_data * sslcert_create_session_data(unsigned long num, - const char *url, + nsurl *url, llcache_query_response cb, void *cbpw) { @@ -95,7 +96,7 @@ sslcert_create_session_data(unsigned long num, warn_user("NoMemory", 0); return NULL; } - data->url = strdup(url); + data->url = nsurl_ref(url); if (data->url == NULL) { free(data); warn_user("NoMemory", 0); @@ -246,7 +247,9 @@ static void sslcert_cleanup_session(struct sslcert_session_data *session) { assert(session != NULL); - free(session->url); + if (session->url) + nsurl_unref(session->url); + free(session); } diff --git a/desktop/sslcert.h b/desktop/sslcert.h index 8fe534846..a9a2587fc 100644 --- a/desktop/sslcert.h +++ b/desktop/sslcert.h @@ -31,7 +31,7 @@ unsigned int sslcert_get_tree_flags(void); void sslcert_cleanup(void); struct sslcert_session_data *sslcert_create_session_data(unsigned long num, - const char *url, llcache_query_response cb, void *cbpw); + nsurl *url, llcache_query_response cb, void *cbpw); bool sslcert_load_tree(struct tree *tree, const struct ssl_cert_info *certs, struct sslcert_session_data *data); diff --git a/desktop/thumbnail.h b/desktop/thumbnail.h index 655c25339..05bae7abc 100644 --- a/desktop/thumbnail.h +++ b/desktop/thumbnail.h @@ -24,6 +24,7 @@ #define _NETSURF_DESKTOP_THUMBNAIL_H_ #include +#include "utils/nsurl.h" #include "utils/types.h" struct hlcache_handle; @@ -52,6 +53,6 @@ bool thumbnail_redraw(struct hlcache_handle *content, /* In platform specific thumbnail.c. */ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, - const char *url); + nsurl *url); #endif diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index d477249c9..a69a1375e 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -126,14 +126,14 @@ void tree_url_node_cleanup() * \return the node created, or NULL for failure */ struct node *tree_create_URL_node(struct tree *tree, struct node *parent, - const char *url, const char *title, + nsurl *url, const char *title, tree_node_user_callback user_callback, void *callback_data) { struct node *node; struct node_element *element; char *text_cp, *squashed; - squashed = squash_whitespace(title ? title : url); + squashed = squash_whitespace(title ? title : nsurl_access(url)); text_cp = strdup(squashed); if (text_cp == NULL) { LOG(("malloc failed")); @@ -161,7 +161,7 @@ struct node *tree_create_URL_node(struct tree *tree, struct node *parent, element = tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_URL, true); if (element != NULL) { - text_cp = strdup(url); + text_cp = strdup(nsurl_access(url)); if (text_cp == NULL) { tree_delete_node(tree, node, false); LOG(("malloc failed")); @@ -184,7 +184,7 @@ struct node *tree_create_URL_node(struct tree *tree, struct node *parent, * \return the node created, or NULL for failure */ struct node *tree_create_URL_node_readonly(struct tree *tree, - struct node *parent, const char *url, + struct node *parent, nsurl *url, const struct url_data *data, tree_node_user_callback user_callback, void *callback_data) { @@ -197,7 +197,7 @@ struct node *tree_create_URL_node_readonly(struct tree *tree, if (data->title != NULL) { title = strdup(data->title); } else { - title = strdup(url); + title = strdup(nsurl_access(url)); } if (title == NULL) @@ -223,7 +223,8 @@ struct node *tree_create_URL_node_readonly(struct tree *tree, element = tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_URL, false); if (element != NULL) { - tree_update_node_element(tree, element, url, NULL); + tree_update_node_element(tree, element, nsurl_access(url), + NULL); } tree_update_URL_node(tree, node, url, data); @@ -238,7 +239,7 @@ struct node *tree_create_URL_node_readonly(struct tree *tree, * \param node the node to update */ void tree_update_URL_node(struct tree *tree, struct node *node, - const char *url, const struct url_data *data) + nsurl *url, const struct url_data *data) { struct node_element *element; struct bitmap *bitmap = NULL; @@ -253,7 +254,7 @@ void tree_update_URL_node(struct tree *tree, struct node *node, if (data != NULL) { if (data->title == NULL) - urldb_set_url_title(url, url); + urldb_set_url_title(url, nsurl_access(url)); if (data->title == NULL) return; @@ -367,8 +368,13 @@ node_callback_resp tree_url_node_callback(void *user_data, */ case TREE_ELEMENT_URL: /* reset URL characteristics */ - urldb_reset_url_visit_data( - msg_data->data.text); + error = nsurl_create(msg_data->data.text, &nsurl); + if (error != NSERROR_OK) { + warn_user("NoMemory", 0); + return NODE_CALLBACK_REJECT; + } + urldb_reset_url_visit_data(nsurl); + nsurl_unref(nsurl); return NODE_CALLBACK_HANDLED; case TREE_ELEMENT_TITLE: return NODE_CALLBACK_HANDLED; @@ -386,7 +392,7 @@ node_callback_resp tree_url_node_callback(void *user_data, text = tree_node_element_get_text(element); if (msg_data->flag == TREE_ELEMENT_LAUNCH_IN_TABS) { msg_data->data.bw = browser_window_create(text, - msg_data->data.bw, 0, true, true); + msg_data->data.bw, 0, true, true); } else { browser_window_create(text, NULL, 0, true, false); @@ -407,7 +413,6 @@ node_callback_resp tree_url_node_callback(void *user_data, } error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &norm_text, &len); - nsurl_unref(nsurl); if (error != NSERROR_OK) { warn_user("NoMemory", 0); return NODE_CALLBACK_REJECT; @@ -415,18 +420,20 @@ node_callback_resp tree_url_node_callback(void *user_data, msg_data->data.text = norm_text; - data = urldb_get_url_data(norm_text); + data = urldb_get_url_data(nsurl); if (data == NULL) { - urldb_add_url(norm_text); - urldb_set_url_persistence(norm_text, - true); - data = urldb_get_url_data(norm_text); - if (data == NULL) + urldb_add_url(nsurl); + urldb_set_url_persistence(nsurl, true); + data = urldb_get_url_data(nsurl); + if (data == NULL) { + nsurl_unref(nsurl); return NODE_CALLBACK_REJECT; + } } tree = user_data; tree_update_URL_node(tree, msg_data->node, - norm_text, NULL); + nsurl, NULL); + nsurl_unref(nsurl); } else if (msg_data->flag == TREE_ELEMENT_TITLE) { while (isspace(*text)) @@ -529,12 +536,12 @@ static void tree_url_load_entry(xmlNode *li, struct tree *tree, /* No longer need this */ xmlFree(url1); - data = urldb_get_url_data(nsurl_access(url)); + data = urldb_get_url_data(url); if (data == NULL) { /* No entry in database, so add one */ - urldb_add_url(nsurl_access(url)); + urldb_add_url(url); /* now attempt to get url data */ - data = urldb_get_url_data(nsurl_access(url)); + data = urldb_get_url_data(url); } if (data == NULL) { xmlFree(title); @@ -544,19 +551,19 @@ static void tree_url_load_entry(xmlNode *li, struct tree *tree, } /* Make this URL persistent */ - urldb_set_url_persistence(nsurl_access(url), true); + urldb_set_url_persistence(url, true); /* Force the title in the hotlist */ - urldb_set_url_title(nsurl_access(url), title); + urldb_set_url_title(url, title); - entry = tree_create_URL_node(tree, directory, nsurl_access(url), title, + entry = tree_create_URL_node(tree, directory, url, title, callback, callback_data); if (entry == NULL) { /** \todo why isn't this fatal? */ warn_user("NoMemory", 0); } else { - tree_update_URL_node(tree, entry, nsurl_access(url), data); + tree_update_URL_node(tree, entry, url, data); } diff --git a/desktop/tree_url_node.h b/desktop/tree_url_node.h index 1fa89cdba..1f0231df1 100644 --- a/desktop/tree_url_node.h +++ b/desktop/tree_url_node.h @@ -26,20 +26,21 @@ #include "desktop/tree.h" +#include "utils/nsurl.h" struct url_data; void tree_url_node_init(const char *folder_icon_name); void tree_url_node_cleanup(void); struct node *tree_create_URL_node(struct tree *tree, - struct node *parent, const char *url, const char *title, + struct node *parent, nsurl *url, const char *title, tree_node_user_callback, void *callback_data); struct node *tree_create_URL_node_readonly(struct tree *tree, - struct node *parent, const char *url, + struct node *parent, nsurl *url, const struct url_data *data, tree_node_user_callback, void *callback_data); -void tree_update_URL_node(struct tree *tree,struct node *node, - const char *url, const struct url_data *data); +void tree_update_URL_node(struct tree *tree, struct node *node, + nsurl *url, const struct url_data *data); const char *tree_url_node_get_title(struct node *node); const char *tree_url_node_get_url(struct node *node); void tree_url_node_edit_title(struct tree *tree, struct node *node); diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 3bcc1be57..b8bb5cede 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1799,7 +1799,7 @@ gui_launch_url(const char *url) } void -gui_cert_verify(const char *url, +gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), diff --git a/framebuffer/login.c b/framebuffer/login.c index c1afab350..7a5e195f4 100644 --- a/framebuffer/login.c +++ b/framebuffer/login.c @@ -18,7 +18,7 @@ #include "desktop/401login.h" -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { cb(false, cbpw); diff --git a/framebuffer/thumbnail.c b/framebuffer/thumbnail.c index 1729d7775..53ff33609 100644 --- a/framebuffer/thumbnail.c +++ b/framebuffer/thumbnail.c @@ -32,7 +32,7 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { nsfb_t *tbm = (nsfb_t *)bitmap; /* target bitmap */ nsfb_t *bm; /* temporary bitmap */ diff --git a/gtk/completion.c b/gtk/completion.c index 8782c876e..d249db160 100644 --- a/gtk/completion.c +++ b/gtk/completion.c @@ -26,7 +26,7 @@ GtkListStore *nsgtk_completion_list; static void nsgtk_completion_empty(void); -static bool nsgtk_completion_udb_callback(const char *url, +static bool nsgtk_completion_udb_callback(nsurl *url, const struct url_data *data); void nsgtk_completion_init(void) @@ -56,13 +56,14 @@ void nsgtk_completion_empty(void) gtk_list_store_clear(nsgtk_completion_list); } -bool nsgtk_completion_udb_callback(const char *url, const struct url_data *data) +bool nsgtk_completion_udb_callback(nsurl *url, const struct url_data *data) { GtkTreeIter iter; if (data->visits != 0) { gtk_list_store_append(nsgtk_completion_list, &iter); - gtk_list_store_set(nsgtk_completion_list, &iter, 0, url, -1); + gtk_list_store_set(nsgtk_completion_list, &iter, 0, + nsurl_access(url), -1); } return true; } diff --git a/gtk/gui.c b/gtk/gui.c index 222c98202..b24fecfb8 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -702,7 +702,7 @@ void die(const char * const error) } -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { diff --git a/gtk/login.c b/gtk/login.c index 41f66de20..3b8d68254 100644 --- a/gtk/login.c +++ b/gtk/login.c @@ -35,8 +35,8 @@ #include "utils/utils.h" struct session_401 { - char *url; /**< URL being fetched */ - char *host; /**< Host for user display */ + nsurl *url; /**< URL being fetched */ + lwc_string *host; /**< Host for user display */ char *realm; /**< Authentication realm */ nserror (*cb)(bool proceed, void *pw); /**< Continuation callback */ void *cbpw; /**< Continuation data */ @@ -46,7 +46,7 @@ struct session_401 { GtkEntry *pass; /**< Widget with password */ }; -static void create_login_window(const char *url, const char *host, +static void create_login_window(nsurl *url, lwc_string *host, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw); static void destroy_login_window(struct session_401 *session); @@ -54,21 +54,20 @@ static void nsgtk_login_next(GtkWidget *w, gpointer data); static void nsgtk_login_ok_clicked(GtkButton *w, gpointer data); static void nsgtk_login_cancel_clicked(GtkButton *w, gpointer data); -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { - char *host; - url_func_result res; + lwc_string *host; - res = url_host(url, &host); - assert(res == URL_FUNC_OK); + host = nsurl_get_component(url, NSURL_HOST); + assert(host != NULL); create_login_window(url, host, realm, cb, cbpw); - free(host); + lwc_string_unref(host); } -void create_login_window(const char *url, const char *host, const char *realm, +void create_login_window(nsurl *url, lwc_string *host, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { struct session_401 *session; @@ -101,8 +100,8 @@ void create_login_window(const char *url, const char *host, const char *realm, /* create and fill in our session structure */ session = calloc(1, sizeof(struct session_401)); - session->url = strdup(url); - session->host = strdup(host); + session->url = nsurl_ref(url); + session->host = lwc_string_ref(host); session->realm = strdup(realm ? realm : "Secure Area"); session->cb = cb; session->cbpw = cbpw; @@ -113,7 +112,7 @@ void create_login_window(const char *url, const char *host, const char *realm, /* fill in our new login window */ - gtk_label_set_text(GTK_LABEL(lhost), host); + gtk_label_set_text(GTK_LABEL(lhost), lwc_string_data(host)); gtk_label_set_text(lrealm, realm); gtk_entry_set_text(euser, ""); gtk_entry_set_text(epass, ""); @@ -145,8 +144,8 @@ void create_login_window(const char *url, const char *host, const char *realm, void destroy_login_window(struct session_401 *session) { - free(session->url); - free(session->host); + nsurl_unref(session->url); + lwc_string_unref(session->host); free(session->realm); gtk_widget_destroy(GTK_WIDGET(session->wnd)); g_object_unref(G_OBJECT(session->x)); diff --git a/gtk/thumbnail.c b/gtk/thumbnail.c index b09b8dd2f..19c5fc193 100644 --- a/gtk/thumbnail.c +++ b/gtk/thumbnail.c @@ -50,7 +50,7 @@ * \param url the URL the thumnail belongs to, or NULL */ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { cairo_surface_t *dsurface = bitmap->surface; cairo_surface_t *surface; @@ -121,7 +121,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, /* register the thumbnail with the URL */ if (url) - urldb_set_thumbnail(url, bitmap); + urldb_set_thumbnail(url, bitmap); return true; } diff --git a/monkey/401login.c b/monkey/401login.c index a079ef30d..b2bff3182 100644 --- a/monkey/401login.c +++ b/monkey/401login.c @@ -25,7 +25,7 @@ typedef struct monkey401 { struct monkey401 *r_next, *r_prev; uint32_t num; - char *host; /* Ignore */ + lwc_string *host; /* Ignore */ nserror (*cb)(bool,void*); void *pw; } monkey401_t; @@ -33,7 +33,7 @@ typedef struct monkey401 { static monkey401_t *m4_ring = NULL; static uint32_t m4_ctr = 0; -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { monkey401_t *m4t = calloc(sizeof(*m4t), 1); @@ -46,7 +46,7 @@ void gui_401login_open(const char *url, const char *realm, RING_INSERT(m4_ring, m4t); fprintf(stdout, "401LOGIN OPEN M4 %u URL %s REALM %s\n", - m4t->num, url, realm); + m4t->num, nsurl_access(url), realm); } diff --git a/monkey/cert.c b/monkey/cert.c index 265a32678..d7f44d11e 100644 --- a/monkey/cert.c +++ b/monkey/cert.c @@ -34,7 +34,7 @@ static monkey_cert_t *cert_ring = NULL; static uint32_t cert_ctr = 0; void -gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { @@ -48,7 +48,7 @@ gui_cert_verify(const char *url, const struct ssl_cert_info *certs, RING_INSERT(cert_ring, m4t); fprintf(stdout, "SSLCERT VERIFY CERT %u URL %s\n", - m4t->num, url); + m4t->num, nsurl_access(url)); } diff --git a/monkey/thumbnail.c b/monkey/thumbnail.c index 7a237bba6..334889510 100644 --- a/monkey/thumbnail.c +++ b/monkey/thumbnail.c @@ -20,12 +20,12 @@ #include "desktop/thumbnail.h" bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { struct gui_window *win = monkey_find_window_by_content(content); if (win == NULL) { - fprintf(stdout, "GENERIC THUMBNAIL URL %s\n", url); + fprintf(stdout, "GENERIC THUMBNAIL URL %s\n", nsurl_access(url)); } - fprintf(stdout, "WINDOW THUMBNAIL WIN %u URL %s\n", win->win_num, url); + fprintf(stdout, "WINDOW THUMBNAIL WIN %u URL %s\n", win->win_num, nsurl_access(url)); return false; } diff --git a/riscos/401login.c b/riscos/401login.c index a81a20e3d..6740f54e5 100644 --- a/riscos/401login.c +++ b/riscos/401login.c @@ -45,17 +45,17 @@ static void ro_gui_401login_close(wimp_w w); static bool ro_gui_401login_apply(wimp_w w); -static void ro_gui_401login_open(const char *url, const char *host, +static void ro_gui_401login_open(nsurl *url, lwc_string *host, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw); static wimp_window *dialog_401_template; struct session_401 { - char *host; /**< Host for user display */ + lwc_string *host; /**< Host for user display */ char *realm; /**< Authentication realm */ char uname[256]; /**< Buffer for username */ - char *url; /**< URL being fetched */ + nsurl *url; /**< URL being fetched */ char pwd[256]; /**< Buffer for password */ nserror (*cb)(bool proceed, void *pw); /**< Continuation callback */ void *cbpw; /**< Continuation callback data */ @@ -75,18 +75,15 @@ void ro_gui_401login_init(void) /** * Open the login dialog */ -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { - char *host; - url_func_result res; - - res = url_host(url, &host); - assert(res == URL_FUNC_OK); + lwc_string *host = nsurl_get_component(url, NSURL_HOST); + assert(host != NULL); ro_gui_401login_open(url, host, realm, cb, cbpw); - free(host); + lwc_string_unref(host); } @@ -94,7 +91,7 @@ void gui_401login_open(const char *url, const char *realm, * Open a 401 login window. */ -void ro_gui_401login_open(const char *url, const char *host, const char *realm, +void ro_gui_401login_open(nsurl *url, lwc_string *host, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { struct session_401 *session; @@ -107,12 +104,7 @@ void ro_gui_401login_open(const char *url, const char *host, const char *realm, return; } - session->url = strdup(url); - if (!session->url) { - free(session); - warn_user("NoMemory", 0); - return; - } + session->url = nsurl_ref(url); if (realm == NULL) realm = "Secure Area"; auth = urldb_get_auth_details(session->url, realm); @@ -133,14 +125,14 @@ void ro_gui_401login_open(const char *url, const char *host, const char *realm, memcpy(session->pwd, pwd, pwd_len); session->pwd[pwd_len] = '\0'; } - session->host = strdup(host); + session->host = lwc_string_ref(host); session->realm = strdup(realm); session->cb = cb; session->cbpw = cbpw; - if ((!session->host) || (!session->realm)) { - free(session->host); - free(session->realm); + if (!session->realm) { + nsurl_unref(session->url); + lwc_string_unref(session->host); free(session); warn_user("NoMemory", 0); return; @@ -148,9 +140,11 @@ void ro_gui_401login_open(const char *url, const char *host, const char *realm, /* fill in download window icons */ dialog_401_template->icons[ICON_401LOGIN_HOST].data. - indirected_text.text = session->host; + indirected_text.text = + (char *)lwc_string_data(session->host); dialog_401_template->icons[ICON_401LOGIN_HOST].data. - indirected_text.size = strlen(session->host) + 1; + indirected_text.size = + lwc_string_length(session->host) + 1; dialog_401_template->icons[ICON_401LOGIN_REALM].data. indirected_text.text = session->realm; dialog_401_template->icons[ICON_401LOGIN_REALM].data. @@ -194,9 +188,9 @@ void ro_gui_401login_close(wimp_w w) if (session->cb != NULL) session->cb(false, session->cbpw); - free(session->host); + nsurl_unref(session->url); + lwc_string_unref(session->host); free(session->realm); - free(session->url); free(session); error = xwimp_delete_window(w); diff --git a/riscos/hotlist.c b/riscos/hotlist.c index a01b9256e..53212c12f 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -468,6 +468,7 @@ bool ro_gui_hotlist_check_menu(wimp_menu *menu) void ro_gui_hotlist_add_page(const char *url) { + nsurl *nsurl; const struct url_data *data; wimp_message message; struct ro_hotlist_message_hotlist_addurl *add_url = @@ -494,9 +495,12 @@ void ro_gui_hotlist_add_page(const char *url) LOG(("Sending Hotlist AddURL to potential hotlist clients.")); - data = urldb_get_url_data(url); + if (nsurl_create(url, &nsurl) != NSERROR_OK) + return; + data = urldb_get_url_data(nsurl); if (data == NULL) return; + nsurl_unref(nsurl); hotlist_url = osmodule_alloc(strlen(url) + 1); hotlist_title = osmodule_alloc(strlen(data->title) + 1); diff --git a/riscos/sslcert.c b/riscos/sslcert.c index 11392c7f9..2490e2e6c 100644 --- a/riscos/sslcert.c +++ b/riscos/sslcert.c @@ -108,7 +108,7 @@ void ro_gui_cert_postinitialise(void) * \param num The number of certificates included. */ -void gui_cert_verify(const char *url, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c index 43100cab1..2a140ce17 100644 --- a/riscos/thumbnail.c +++ b/riscos/thumbnail.c @@ -80,7 +80,7 @@ static void thumbnail_restore_output(struct thumbnail_save_area *save_area); * \param url the URL the thumbnail belongs to, or NULL */ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { struct thumbnail_save_area *save_area; osspriteop_area *sprite_area = NULL; diff --git a/riscos/url_complete.c b/riscos/url_complete.c index d962f195d..4d5f9d213 100644 --- a/riscos/url_complete.c +++ b/riscos/url_complete.c @@ -40,7 +40,7 @@ #define MAXIMUM_VISIBLE_LINES 7 -static const char **url_complete_matches = NULL; +static nsurl **url_complete_matches = NULL; static int url_complete_matches_allocated = 0; static int url_complete_matches_available = 0; static char *url_complete_matched_string = NULL; @@ -51,7 +51,7 @@ static bool url_complete_matches_reset = false; static char *url_complete_original_url = NULL; static bool url_complete_memory_exhausted = false; -static const char *url_complete_redraw[MAXIMUM_VISIBLE_LINES]; +static nsurl *url_complete_redraw[MAXIMUM_VISIBLE_LINES]; static char url_complete_icon_null[] = ""; static char url_complete_icon_sprite[12]; static wimp_icon url_complete_icon; @@ -59,7 +59,7 @@ static wimp_icon url_complete_sprite; static int mouse_x; static int mouse_y; -static bool url_complete_callback(const char *url, +static bool url_complete_callback(nsurl *url, const struct url_data *data); @@ -303,12 +303,13 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) url_complete_original_url, true, false); } else { ro_toolbar_set_url(toolbar, - url_complete_matches[ - url_complete_matches_selection], + nsurl_access(url_complete_matches[ + url_complete_matches_selection]), true, false); free(url_complete_matched_string); - url_complete_matched_string = strdup(url_complete_matches[ - url_complete_matches_selection]); + url_complete_matched_string = strdup(nsurl_access( + url_complete_matches[ + url_complete_matches_selection])); } url_complete_keypress_selection = url_complete_matches_selection; @@ -350,9 +351,9 @@ bool ro_gui_url_complete_keypress(struct toolbar *toolbar, uint32_t key) * \return true to continue iteration, false otherwise */ -bool url_complete_callback(const char *url, const struct url_data *data) +bool url_complete_callback(nsurl *url, const struct url_data *data) { - const char **array_extend; + nsurl **array_extend; /* Ignore unvisited URLs */ if (data->visits == 0) @@ -363,9 +364,9 @@ bool url_complete_callback(const char *url, const struct url_data *data) if (url_complete_matches_available > url_complete_matches_allocated) { - array_extend = (const char **)realloc(url_complete_matches, + array_extend = (nsurl **)realloc(url_complete_matches, (url_complete_matches_allocated + 64) * - sizeof(char *)); + sizeof(nsurl *)); if (!array_extend) { url_complete_memory_exhausted = true; return false; @@ -578,9 +579,11 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) url_complete_icon.extent.y1 = -line * 44; url_complete_icon.extent.y0 = -(line + 1) * 44; url_complete_icon.data.indirected_text.text = - (char *)url_complete_matches[line]; + (char *)nsurl_access( + url_complete_matches[line]); url_complete_icon.data.indirected_text.size = - strlen(url_complete_matches[line]); + nsurl_length( + url_complete_matches[line]); error = xwimp_plot_icon(&url_complete_icon); if (error) { @@ -700,8 +703,8 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) /* Select sets the text and launches */ if (pointer->buttons == wimp_CLICK_SELECT) { ro_toolbar_set_url(g->toolbar, - url_complete_matches[ - url_complete_matches_selection], + nsurl_access(url_complete_matches[ + url_complete_matches_selection]), true, false); /** \todo The interaction of components here is hideous */ @@ -714,16 +717,16 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) */ browser_window_go(g->bw, - url_complete_matches[ - url_complete_matches_selection], + nsurl_access(url_complete_matches[ + url_complete_matches_selection]), 0, true); ro_gui_url_complete_close(); /* Adjust just sets the text */ } else if (pointer->buttons == wimp_CLICK_ADJUST) { ro_toolbar_set_url(g->toolbar, - url_complete_matches[ - url_complete_matches_selection], + nsurl_access(url_complete_matches[ + url_complete_matches_selection]), true, false); ro_gui_url_complete_keypress(g->toolbar, 0); } diff --git a/riscos/url_suggest.c b/riscos/url_suggest.c index be766e1bd..32e772cca 100644 --- a/riscos/url_suggest.c +++ b/riscos/url_suggest.c @@ -34,7 +34,7 @@ struct url_suggest_item { struct url_suggest_item *next; /*< The next URL in the list. */ }; -static bool ro_gui_url_suggest_callback(const char *url, +static bool ro_gui_url_suggest_callback(nsurl *url, const struct url_data *data); static int suggest_entries; @@ -152,7 +152,7 @@ bool ro_gui_url_suggest_prepare_menu(void) * \return true to continue iteration, false otherwise */ -bool ro_gui_url_suggest_callback(const char *url, const struct url_data *data) +bool ro_gui_url_suggest_callback(nsurl *url, const struct url_data *data) { int count; unsigned int weight; @@ -190,7 +190,10 @@ bool ro_gui_url_suggest_callback(const char *url, const struct url_data *data) if (new != NULL) { suggest_entries++; - new->url = url; + /* TODO: keeping pointers to URLdb data is bad. + * should be nsurl_ref(url) or + * take a copy of the string. */ + new->url = nsurl_access(url); new->weight = weight; new->next = *list; @@ -205,6 +208,7 @@ bool ro_gui_url_suggest_callback(const char *url, const struct url_data *data) while (suggest_list != NULL && suggest_entries > URL_SUGGEST_MAX_URLS) { old = suggest_list; suggest_list = suggest_list->next; + free(old); suggest_entries--; } @@ -222,7 +226,7 @@ bool ro_gui_url_suggest_callback(const char *url, const struct url_data *data) const char *ro_gui_url_suggest_get_selection(wimp_selection *selection) { - const char *url = NULL; + const char *url = NULL; if (selection->items[0] >= 0) url = ro_gui_url_suggest_menu->entries[selection->items[0]]. diff --git a/windows/gui.c b/windows/gui.c index f7d8c4ccd..048b50fd5 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -1821,7 +1821,7 @@ void gui_create_form_select_menu(struct browser_window *bw, } -void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { diff --git a/windows/login.c b/windows/login.c index c1afab350..7a5e195f4 100644 --- a/windows/login.c +++ b/windows/login.c @@ -18,7 +18,7 @@ #include "desktop/401login.h" -void gui_401login_open(const char *url, const char *realm, +void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw) { cb(false, cbpw); diff --git a/windows/thumbnail.c b/windows/thumbnail.c index 4ce0aba1c..e87745bae 100644 --- a/windows/thumbnail.c +++ b/windows/thumbnail.c @@ -35,7 +35,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, - const char *url) + nsurl *url) { int width; int height; @@ -53,7 +53,7 @@ thumbnail_create(hlcache_handle *content, bitmap->width; LOG(("bitmap %p for url %s content %p width %d, height %d", - bitmap, url, content, width, height)); + bitmap, nsurl_access(url), content, width, height)); /* create two memory device contexts to put the bitmaps in */ bufferdc = CreateCompatibleDC(NULL); -- cgit v1.2.3