diff options
author | James Bursa <james@netsurf-browser.org> | 2004-03-02 18:02:41 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2004-03-02 18:02:41 +0000 |
commit | 1c85bf04293cfba663c5170bbe762825b7e72af1 (patch) | |
tree | 6db0b94b8e875ae20514b334c9f9acb3b380f362 /riscos | |
parent | 2d816dda237a80f413a9d90031c7f5aff01e7a83 (diff) | |
download | netsurf-1c85bf04293cfba663c5170bbe762825b7e72af1.tar.gz netsurf-1c85bf04293cfba663c5170bbe762825b7e72af1.tar.bz2 |
[project @ 2004-03-02 18:02:17 by bursa]
Add new url functions and modify to use them.
svn path=/import/netsurf/; revision=578
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/401login.c | 3 | ||||
-rw-r--r-- | riscos/about.c | 128 | ||||
-rw-r--r-- | riscos/gui.c | 8 | ||||
-rw-r--r-- | riscos/save_complete.c | 50 | ||||
-rw-r--r-- | riscos/url_protocol.c (renamed from riscos/url.c) | 2 | ||||
-rw-r--r-- | riscos/url_protocol.h (renamed from riscos/url.h) | 0 | ||||
-rw-r--r-- | riscos/window.c | 23 |
7 files changed, 54 insertions, 160 deletions
diff --git a/riscos/401login.c b/riscos/401login.c index b46d115d0..c96fcd2c1 100644 --- a/riscos/401login.c +++ b/riscos/401login.c @@ -17,6 +17,7 @@ #include "netsurf/riscos/gui.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" +#include "netsurf/utils/url.h" #include "netsurf/utils/utils.h" #ifdef WITH_AUTH @@ -65,7 +66,7 @@ void gui_401login_open(struct browser_window *bw, struct content *c, char *realm char *murl, *host; murl = c->url; - host = get_host_from_url(murl); + host = url_host(murl); assert(host); bwin = bw; diff --git a/riscos/about.c b/riscos/about.c index cfec2733a..89f39506c 100644 --- a/riscos/about.c +++ b/riscos/about.c @@ -16,20 +16,18 @@ #include <stdio.h> #include <time.h> #include <unixlib/local.h> /* for __unixify */ - -#include "netsurf/utils/config.h" -#include "netsurf/desktop/netsurf.h" -#include "netsurf/riscos/about.h" -#include "netsurf/utils/log.h" -#include "netsurf/utils/messages.h" -#include "netsurf/utils/utils.h" - #include "oslib/fileswitch.h" #include "oslib/osargs.h" #include "oslib/osfile.h" #include "oslib/osfind.h" #include "oslib/osfscontrol.h" #include "oslib/osgbpb.h" +#include "netsurf/utils/config.h" +#include "netsurf/desktop/browser.h" +#include "netsurf/desktop/netsurf.h" +#include "netsurf/utils/log.h" +#include "netsurf/utils/messages.h" +#include "netsurf/utils/utils.h" #ifdef WITH_ABOUT @@ -41,81 +39,53 @@ static const char *paboutpl3 = "<tr valign=\"top\"><td width=\"30%%\"><font size static const char *pabtplgft = "</table>"; /**< Plugin table footer */ static const char *paboutftr = "</div></body></html>"; /**< Page footer */ -/** The about page */ -struct about_page { - - char *header; /**< page header */ - char *browser; /**< browser details */ - char *plghead; /**< plugin header */ - struct plugd *plugd; /**< plugin details list */ - char *plgfoot; /**< plugin footer */ - char *footer; /**< page footer */ -}; - -/** A set of plugin details */ -struct plugd { - char *details; /**< plugin details */ - struct plugd *next; /**< next plugin details */ -}; - -struct plugd *new_plugin(struct plugd *pd, char* details); /** - * Adds a plugin's details to the head of the linked list of plugin details - * Returns the new head of the list + * Create the browser about page. + * + * \param url requested url (about:...) + * \param callback content callback function, for content_add_user() + * \param p1 user parameter for callback + * \param p2 user parameter for callback + * \param width available width + * \param height available height + * \return a new content containing the about page */ -struct plugd *new_plugin(struct plugd *pd, char* details) { - - struct plugd *np = xcalloc(1, sizeof(*np)); - np->details = 0; - np->details = details; - - np->next = pd; - return np; -} - -/** - * Creates the about page and stores it in <Wimp$ScrapDir>.WWW.Netsurf - */ -void about_create(void) { - - struct about_page *abt; - struct plugd *temp; +struct content *about_create(const char *url, + void (*callback)(content_msg msg, struct content *c, void *p1, + void *p2, const char *error), + void *p1, void *p2, unsigned long width, unsigned long height) +{ + struct content *c = 0; FILE *fp; char *buf, *val, var[20], *ptype, *pdetails, *fname, *furl; int i, nofiles, j, w, h, size; fileswitch_object_type fot; os_error *e; + const char *params[] = { 0 }; - abt = (struct about_page*)xcalloc(1, sizeof(*abt)); - abt->plugd = 0; + c = content_create(url); + c->width = width; + c->height = height; + content_add_user(c, callback, p1, p2); + content_set_type(c, CONTENT_HTML, "text/html", params); /* Page header */ buf = xcalloc(strlen(pabouthdr) + 50, sizeof(char)); snprintf(buf, strlen(pabouthdr) + 50, pabouthdr, "About NetSurf", netsurf_version); - abt->header = xstrdup(buf); - xfree(buf); + content_process_data(c, buf, strlen(buf)); + free(buf); /* browser details */ - xosfile_read_stamped_no_path("<NetSurf$Dir>.About.About",0,0,0,&i,0,0); - fp = fopen("<NetSurf$Dir>.About.About", "r"); - buf = xcalloc((unsigned int)i + 10, sizeof(char)); - fread(buf, sizeof(char), (unsigned int)i, fp); - fclose(fp); - abt->browser = xstrdup(buf); - xfree(buf); + buf = load("<NetSurf$Dir>.About.About"); + content_process_data(c, buf, strlen(buf)); + free(buf); /* plugin header */ - abt->plghead = xstrdup(pabtplghd); - - /* plugin footer */ - abt->plgfoot = xstrdup(pabtplgft); - - /* Page footer */ - abt->footer = xstrdup(paboutftr); + content_process_data(c, pabtplghd, strlen(pabtplghd)); /* plugins registered */ for (i=0; i!=4096; i++) { @@ -172,7 +142,7 @@ void about_create(void) { furl = xcalloc(strlen(paboutpl1) + strlen(ptype) + strlen(pdetails) + 10, sizeof(char)); sprintf(furl, paboutpl1, ptype, pdetails); LOG(("furl: %s", furl)); - abt->plugd = new_plugin(abt->plugd, furl); + content_process_data(c, furl, strlen(furl)); xfree(pdetails); continue; } @@ -214,7 +184,7 @@ void about_create(void) { furl = xcalloc(strlen(paboutpl3) + strlen(ptype) + strlen(buf) + strlen(pdetails) + 10, sizeof(char)); sprintf(furl, paboutpl3, ptype, buf, ptype, w, h, pdetails); - abt->plugd = new_plugin(abt->plugd, furl); + content_process_data(c, furl, strlen(furl)); xfree(pdetails); continue; } @@ -230,7 +200,7 @@ void about_create(void) { furl = xcalloc(strlen(paboutpl2) + strlen(ptype) + strlen(fname) + strlen(pdetails) + 10, sizeof(char)); sprintf(furl, paboutpl2, ptype, fname, ptype, pdetails); - abt->plugd = new_plugin(abt->plugd, furl); + content_process_data(c, furl, strlen(furl)); xfree(fname); xfree(pdetails); } @@ -241,29 +211,15 @@ void about_create(void) { } } - /* write file */ - xosfile_create_dir("<Wimp$ScrapDir>.WWW", 77); - xosfile_create_dir("<Wimp$ScrapDir>.WWW.NetSurf", 77); - - fp = fopen("<Wimp$ScrapDir>.WWW.Netsurf.About", "w+"); - fprintf(fp, "%s", abt->header); - fprintf(fp, "%s", abt->browser); - fprintf(fp, "%s", abt->plghead); - while (abt->plugd != 0) { - fprintf(fp, "%s", abt->plugd->details); - temp = abt->plugd; - abt->plugd = abt->plugd->next; - xfree(temp); - } - fprintf(fp, "%s", abt->plgfoot); - fprintf(fp, "%s", abt->footer); - fclose(fp); + /* plugin footer */ + content_process_data(c, pabtplgft, strlen(pabtplgft)); - xosfile_set_type("<Wimp$ScrapDir>.WWW.NetSurf.About", 0xfaf); + /* Page footer */ + content_process_data(c, paboutftr, strlen(paboutftr)); - xfree(abt); + content_convert(c, c->width, c->height); - return; + return c; } #ifdef WITH_COOKIES diff --git a/riscos/gui.c b/riscos/gui.c index dd976ee4e..a325aebf2 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -29,9 +29,6 @@ #include "netsurf/render/font.h" #include "netsurf/render/form.h" #include "netsurf/render/html.h" -#ifdef WITH_ABOUT -#include "netsurf/riscos/about.h" -#endif #include "netsurf/riscos/constdata.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/options.h" @@ -43,7 +40,7 @@ #include "netsurf/riscos/uri.h" #endif #ifdef WITH_URL -#include "netsurf/riscos/url.h" +#include "netsurf/riscos/url_protocol.h" #endif #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" @@ -257,9 +254,6 @@ void ro_gui_icon_bar_create(void) void gui_quit(void) { -#ifdef WITH_ABOUT - about_quit(); -#endif ro_gui_history_quit(); wimp_close_down(task_handle); xhourglass_off(); diff --git a/riscos/save_complete.c b/riscos/save_complete.c index a97465679..08baffbd8 100644 --- a/riscos/save_complete.c +++ b/riscos/save_complete.c @@ -6,13 +6,8 @@ */ #include <string.h> - #include <unixlib/local.h> /* for __riscosify */ - -#include <uri.h> /* possibly just have accessor methods in utils.c */ - #include "oslib/osfile.h" - #include "netsurf/utils/config.h" #include "netsurf/content/content.h" #include "netsurf/css/css.h" @@ -30,7 +25,6 @@ */ void save_imported_sheets(struct content *c, int parent, int level, char *p, char* fn); -char* get_filename(char * url); /* this is temporary. */ const char * const SAVE_PATH = "<NetSurf$Dir>.savetest."; @@ -46,7 +40,7 @@ void save_complete(struct content *c) { return; } - fname = get_filename(c->data.html.base_url); + fname = "test"; /*get_filename(c->data.html.base_url);*/ if (!fname) { /* no path -> exit */ return; @@ -135,46 +129,4 @@ void save_imported_sheets(struct content *c, int parent, int level, char *p, cha } } -char* get_filename(char * url) { - - char *ret = 0, *offs; - uri_t *uri; - - uri = uri_alloc(url, (int)strlen(url)); - - if (!uri) { - return 0; - } - - if (uri->path) { - /* Two possible cases here: - * a) no page name given (eg http://www.blah.com/) -> index.html - * b) page name given - */ - /* case a */ - if (strlen(uri->path) == 0) { - ret = xstrdup("index.html"); - } - /* case b */ - else { - offs = strrchr(uri->path, '/'); - if (!offs) { - ret = xstrdup(uri->path); - } - else { - ret = xstrdup(offs+1); - } - } - } - - uri_free(uri); - - offs = xcalloc(strlen(ret)+1, sizeof(char)); - - __riscosify(ret, 0, 0, offs, strlen(ret)+1, 0); - - xfree(ret); - - return offs; -} #endif diff --git a/riscos/url.c b/riscos/url_protocol.c index e1ee94d47..1553d17ac 100644 --- a/riscos/url.c +++ b/riscos/url_protocol.c @@ -15,7 +15,7 @@ #include "netsurf/riscos/theme.h" #include "netsurf/desktop/gui.h" #include "netsurf/riscos/gui.h" -#include "netsurf/riscos/url.h" +#include "netsurf/riscos/url_protocol.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" diff --git a/riscos/url.h b/riscos/url_protocol.h index 01b99b7c1..01b99b7c1 100644 --- a/riscos/url.h +++ b/riscos/url_protocol.h diff --git a/riscos/window.c b/riscos/window.c index 80cd80b02..fa8b2e1d7 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -27,6 +27,7 @@ #include "netsurf/riscos/theme.h" #include "netsurf/riscos/thumbnail.h" #include "netsurf/utils/log.h" +#include "netsurf/utils/url.h" #include "netsurf/utils/utils.h" gui_window *window_list = 0; @@ -676,6 +677,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar) struct content *content = g->data.browser.bw->current_content; wimp_window_state state; int y; + char *url; assert(g->type == GUI_BROWSER_WINDOW); @@ -744,22 +746,11 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar) case wimp_KEY_RETURN: if (!toolbar) break; - else { - char *url = xcalloc(1, 10 + strlen(g->url)); - char *url2; - if (g->url[strspn(g->url, "abcdefghijklmnopqrstuvwxyz")] != ':') { - strcpy(url, "http://"); - strcpy(url + 7, g->url); - } else { - strcpy(url, g->url); - } - url2 = url_join(url, 0); - free(url); - if (url2) { - gui_window_set_url(g, url2); - browser_window_go(g->data.browser.bw, url2); - free(url2); - } + url = url_normalize(g->url); + if (url) { + gui_window_set_url(g, url); + browser_window_go(g->data.browser.bw, url); + free(url); } return true; |