summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'riscos')
-rw-r--r--riscos/about.c80
-rw-r--r--riscos/about.h2
-rw-r--r--riscos/constdata.c1
-rw-r--r--riscos/constdata.h1
-rw-r--r--riscos/gui.c1
-rw-r--r--riscos/window.c46
6 files changed, 101 insertions, 30 deletions
diff --git a/riscos/about.c b/riscos/about.c
index 09e9f7e7b..27b154ca6 100644
--- a/riscos/about.c
+++ b/riscos/about.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <time.h>
#include <unixlib/local.h> /* for __unixify */
#include "netsurf/desktop/netsurf.h"
@@ -28,13 +29,13 @@
#include "oslib/osfind.h"
#include "oslib/osfscontrol.h"
-static const char *pabouthdr = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/transitional.dtd\"><html><head><title>About NetSurf</title></head><body bgcolor=\"#f3f3ff\"><!-- About header --><table border=\"0\" width=\"100%%\" bgcolor=\"#94adff\" cellspacing=\"2\"><tr><td><a href=\"http://netsurf.sf.net\"><img src=\"file:///%%3CNetSurf$Dir%%3E/About/nslogo\" alt=\"Netsurf logo\"></a><td><table bgcolor=\"#94adff\" border=\"0\"><tr><td>&nbsp;<tr><td align=\"center\"><h2>NetSurf %s</h2><tr><td align=\"center\"><h5>Copyright &copy; 2002, 2003 NetSurf Developers.</h5><tr><td>&nbsp;</table></table><hr>"; /**< About page header */
+static const char *pabouthdr = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/transitional.dtd\"><html><head><title>%s</title></head><body bgcolor=\"#f3f3ff\"><!-- About header --><table border=\"0\" width=\"100%%\" bgcolor=\"#94adff\" cellspacing=\"2\"><tr><td><a href=\"http://netsurf.sf.net\"><img src=\"file:///%%3CNetSurf$Dir%%3E/About/nslogo\" alt=\"Netsurf logo\"></a><td><table bgcolor=\"#94adff\" border=\"0\"><tr><td>&nbsp;<tr><td align=\"center\"><h2>NetSurf %s</h2><tr><td align=\"center\"><h5>Copyright &copy; 2002, 2003 NetSurf Developers.</h5><tr><td>&nbsp;</table></table><hr>"; /**< About page header */
static const char *pabtplghd = "<!-- Plugin information --><strong><i>The following plugins are installed on your system:</i></strong><br>&nbsp;<br><table border=\"0\" cellspacing=\"2\" width=\"100%\">"; /**< Plugin table header */
static const char *paboutpl1 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>"; /**< Plugin entry without image */
static const char *paboutpl2 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font><br><img src=\"%s\" alt=\"%s\"></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>";/**< Plugin entry with image (filename=nn) */
static const char *paboutpl3 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font><br><img src=\"%s\" alt=\"%s\" width=\"%d\" height=\"%d\"></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>"; /**< Plugin entry with image (filename=nnwwwwhhhh) */
static const char *pabtplgft = "</table>"; /**< Plugin table footer */
-static const char *paboutftr = "</body></html>"; /**< Page footer */
+static const char *paboutftr = "</div></body></html>"; /**< Page footer */
/** The about page */
struct about_page {
@@ -88,8 +89,9 @@ void about_create(void) {
abt->plugd = 0;
/* Page header */
- buf = xcalloc(strlen(pabouthdr) + 40, sizeof(char));
- snprintf(buf, strlen(pabouthdr) + 40, pabouthdr, netsurf_version);
+ buf = xcalloc(strlen(pabouthdr) + 50, sizeof(char));
+ snprintf(buf, strlen(pabouthdr) + 50, pabouthdr, "About NetSurf",
+ netsurf_version);
abt->header = xstrdup(buf);
xfree(buf);
@@ -252,3 +254,73 @@ void about_create(void) {
return;
}
+/**
+ * Creates the cookie list and stores it in <Wimp$ScrapDir>.WWW.Netsurf
+ */
+void cookie_create(void) {
+
+ FILE *fp;
+ int len, count=0;
+ char *cookies = 0, *pos;
+ char domain[256], flag[10], path[256], secure[10],
+ exp[50], name[256], val[256];
+ unsigned int expiry;
+
+ fp = fopen("Choices:WWW.NetSurf.Cookies", "r");
+ if (!fp) {
+ LOG(("Failed to open cookie jar"));
+ return;
+ }
+
+ /* read file length */
+ fseek(fp, 0, SEEK_END);
+ len = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ cookies = xcalloc((unsigned int)len, sizeof(char));
+ fread(cookies, (unsigned int)len, sizeof(char), fp);
+ fclose(fp);
+
+ xosfile_create_dir("<Wimp$ScrapDir>.WWW", 77);
+ xosfile_create_dir("<Wimp$ScrapDir>.WWW.NetSurf", 77);
+ fp = fopen("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", "w+");
+ if (!fp) {
+ xfree(cookies);
+ LOG(("Failed to create file"));
+ return;
+ }
+ fprintf(fp, pabouthdr, "About NetSurf - Cookies", netsurf_version);
+ fprintf(fp, "<strong><i>The following cookies are stored on your system:</i></strong><div align=\"center\"><table cellspacing=\"2\" cellpadding=\"2\" width=\"100%%\"><strong><thead><td nowrap>Domain:</td><td nowrap>Flag:</td><td nowrap>Path:</td><td nowrap>Secure:</td><td nowrap>Expiration:</td><td nowrap>Name:</td><td nowrap>Value:</td></thead></strong><tbody>");
+ pos = cookies;
+ while (pos != (cookies+len-1)) {
+ if (*pos == '#') {
+ for (; *pos != '\n'; pos++);
+ pos += 1;
+ continue;
+ }
+ sscanf(pos, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", domain, flag, path, secure,
+ exp, name, val);
+ pos += (strlen(domain) + strlen(flag) + strlen(path) + strlen(secure) +
+ strlen(exp) + strlen(name) +strlen(val) + 7);
+ sscanf(exp, "%u", &expiry);
+ fprintf(fp, "<tr%s><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>", (count%2 == 0 ? " bgcolor=\"#ddddee\"" : ""), domain, flag, path, secure,
+ (expiry == 0 ? "Expires on exit" : ctime((time_t*)&expiry)), name, val);
+ count++;
+ }
+
+ fprintf(fp, "</tbody></table></div></body></html>");
+ fclose(fp);
+ xosfile_set_type("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", 0xfaf);
+ xfree(cookies);
+ return;
+}
+
+/**
+ * Clean up created files
+ */
+void about_quit(void) {
+
+ xosfile_delete("<Wimp$ScrapDir>.WWW.NetSurf.About", 0, 0, 0, 0, 0);
+ xosfile_delete("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", 0, 0, 0, 0, 0);
+}
+
diff --git a/riscos/about.h b/riscos/about.h
index cdcdcc885..e3ed66a69 100644
--- a/riscos/about.h
+++ b/riscos/about.h
@@ -9,6 +9,8 @@
#define _NETSURF_RISCOS_ABOUT_H_
void about_create(void);
+void cookie_create(void);
+void about_quit(void);
#endif
diff --git a/riscos/constdata.c b/riscos/constdata.c
index e40ddc0c7..a7f573789 100644
--- a/riscos/constdata.c
+++ b/riscos/constdata.c
@@ -10,6 +10,7 @@
#include "netsurf/riscos/constdata.h"
const char * const ABOUT_URL = "file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/About";
+const char * const COOKIE_URL = "file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/Cookies";
const char * const GESTURES_URL = "file:///%3CNetSurf$Dir%3E/Resources/gestures";
const char * const HOME_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/intro";
const char * const HELP_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/index";
diff --git a/riscos/constdata.h b/riscos/constdata.h
index ff1cf0433..f5a6d47aa 100644
--- a/riscos/constdata.h
+++ b/riscos/constdata.h
@@ -11,6 +11,7 @@
#define _NETSURF_RISCOS_CONSTDATA_H_
extern const char * const ABOUT_URL;
+extern const char * const COOKIE_URL;
extern const char * const GESTURES_URL;
extern const char * const HOME_URL;
extern const char * const HELP_URL;
diff --git a/riscos/gui.c b/riscos/gui.c
index a00857c64..d2b77f0b2 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -162,6 +162,7 @@ void ro_gui_icon_bar_create(void)
void gui_quit(void)
{
+ about_quit();
ro_gui_history_quit();
wimp_close_down(task_handle);
}
diff --git a/riscos/window.c b/riscos/window.c
index e2f6e17ae..8774f31e3 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -16,7 +16,6 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "netsurf/css/css.h"
-#include "netsurf/riscos/about.h"
#include "netsurf/riscos/constdata.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/theme.h"
@@ -309,6 +308,13 @@ void gui_window_set_url(gui_window *g, char *url)
{
strncpy(g->url, url, 255);
wimp_set_icon_state(g->data.browser.toolbar, ICON_TOOLBAR_URL, 0, 0);
+ /* Move the caret to the url bar.
+ * It's ok to do this as this only gets
+ * called when fetching a new page .
+ */
+ wimp_set_caret_position(g->data.browser.toolbar,
+ ICON_TOOLBAR_URL,
+ 0,0,-1, (int) strlen(g->url) - 1);
}
@@ -702,32 +708,20 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
case wimp_KEY_RETURN:
if (!toolbar)
break;
- if (strcasecmp(g->url, "about:") == 0) {
- about_create();
- browser_window_open_location(g->data.browser.bw,
- ABOUT_URL);
- } else if (strcasecmp(g->url, "help:") == 0) {
- browser_window_open_location(g->data.browser.bw,
- HELP_URL);
- } else if (strcasecmp(g->url, "home:") == 0) {
- browser_window_open_location(g->data.browser.bw,
- HOME_URL);
+ 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 {
- 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_open_location(g->data.browser.bw, url2);
- free(url2);
- }
+ strcpy(url, g->url);
+ }
+ url2 = url_join(url, 0);
+ free(url);
+ if (url2) {
+ gui_window_set_url(g, url2);
+ browser_window_open_location(g->data.browser.bw, url2);
+ free(url2);
}
return true;