summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-01-13 22:42:39 +0000
committerJames Bursa <james@netsurf-browser.org>2005-01-13 22:42:39 +0000
commitf0b264670e57d1eefd6f7e297b87cedf38d8be9a (patch)
treea9f2680f01e5cb9dab890b83ce05954a87bc8793
parenta76404dfd076925eebeb8166f588e0d5e7a9fdd3 (diff)
downloadnetsurf-f0b264670e57d1eefd6f7e297b87cedf38d8be9a.tar.gz
netsurf-f0b264670e57d1eefd6f7e297b87cedf38d8be9a.tar.bz2
[project @ 2005-01-13 22:42:38 by bursa]
Start on theme auto-install. Fix content_add_user() not to broadcast error on memory exhaustion. svn path=/import/netsurf/; revision=1448
-rw-r--r--!NetSurf/Resources/de/Messages3
-rwxr-xr-x!NetSurf/Resources/de/Templates,fecbin11223 -> 11525 bytes
-rw-r--r--!NetSurf/Resources/en/Messages3
-rw-r--r--!NetSurf/Resources/en/Templates,fecbin11206 -> 11508 bytes
-rw-r--r--!NetSurf/Resources/fr/Messages3
-rw-r--r--!NetSurf/Resources/fr/Templates,fecbin11506 -> 11808 bytes
-rw-r--r--content/content.c30
-rw-r--r--content/content_type.h3
-rw-r--r--desktop/browser.c12
-rw-r--r--desktop/browser.h5
-rw-r--r--makefile4
-rw-r--r--riscos/gui.c1
-rw-r--r--riscos/gui.h9
-rw-r--r--riscos/theme_install.c111
-rw-r--r--utils/config.h4
15 files changed, 168 insertions, 20 deletions
diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages
index 701b2cd82..d50ef9412 100644
--- a/!NetSurf/Resources/de/Messages
+++ b/!NetSurf/Resources/de/Messages
@@ -264,6 +264,9 @@ Encoding1:detected
Encoding2:from <meta>
EncodingUnk:Unknown
+ThemeInstActive:A theme is currently being downloaded or installed. Please wait for it to finish or cancel it before installing more themes.
+ThemeInstDown:Please wait for the theme to download.
+
# Interactive help
HelpToolbar0:Schaltet zurück auf die zuvor dargestellte Seite.|MDer Inhalt wird dabei nicht aktualisiert.
HelpToolbar1:Schaltet vorwärts auf die nächste Seite.|MDer Inhalt wird dabei nicht aktualisiert.
diff --git a/!NetSurf/Resources/de/Templates,fec b/!NetSurf/Resources/de/Templates,fec
index 5173f4b8d..4ef3330f5 100755
--- a/!NetSurf/Resources/de/Templates,fec
+++ b/!NetSurf/Resources/de/Templates,fec
Binary files differ
diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages
index d375b633e..60e1c4257 100644
--- a/!NetSurf/Resources/en/Messages
+++ b/!NetSurf/Resources/en/Messages
@@ -264,6 +264,9 @@ Encoding1:detected
Encoding2:from <meta>
EncodingUnk:Unknown
+ThemeInstActive:A theme is currently being downloaded or installed. Please wait for it to finish or cancel it before installing more themes.
+ThemeInstDown:Please wait for the theme to download.
+
# Interactive help
HelpToolbar0:\Tback button.|M\Straverse back one page in the history tree.|MDoes not resubmit form information.
HelpToolbar1:\Tforward button.|M\Straverse forward one page in the history tree.|MDoes not resubmit form information.
diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec
index 71a1b96b3..d41b4f849 100644
--- a/!NetSurf/Resources/en/Templates,fec
+++ b/!NetSurf/Resources/en/Templates,fec
Binary files differ
diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages
index df4899f33..c426d645e 100644
--- a/!NetSurf/Resources/fr/Messages
+++ b/!NetSurf/Resources/fr/Messages
@@ -264,6 +264,9 @@ Encoding1:detected
Encoding2:from <meta>
EncodingUnk:Unknown
+ThemeInstActive:A theme is currently being downloaded or installed. Please wait for it to finish or cancel it before installing more themes.
+ThemeInstDown:Please wait for the theme to download.
+
# Interactive help
HelpToolbar0:\Tle bouton de retour.|M\Srevenir d'une page en arrière dans l'historique.|MNe renvoie pas l'information de formulaire.
HelpToolbar1:\Tle bouton d'avance.|M\Savancer d'une page dans l'historique.|MNe renvoie pas l'information de formulaire.
diff --git a/!NetSurf/Resources/fr/Templates,fec b/!NetSurf/Resources/fr/Templates,fec
index 243cf6038..47d2bb79e 100644
--- a/!NetSurf/Resources/fr/Templates,fec
+++ b/!NetSurf/Resources/fr/Templates,fec
Binary files differ
diff --git a/content/content.c b/content/content.c
index 9dac5fa85..c9ad560a5 100644
--- a/content/content.c
+++ b/content/content.c
@@ -61,9 +61,12 @@ struct mime_entry {
/** A map from MIME type to ::content_type. Must be sorted by mime_type. */
static const struct mime_entry mime_map[] = {
#ifdef WITH_DRAW
- {"application/drawfile", CONTENT_DRAW},
- {"application/x-drawfile", CONTENT_DRAW},
- {"image/drawfile", CONTENT_DRAW},
+ {"application/drawfile", CONTENT_DRAW},
+ {"application/x-drawfile", CONTENT_DRAW},
+#ifdef WITH_THEME_INSTALL
+ {"application/x-netsurf-theme", CONTENT_THEME},
+#endif
+ {"image/drawfile", CONTENT_DRAW},
#endif
#ifdef WITH_GIF
{"image/gif", CONTENT_GIF},
@@ -127,6 +130,9 @@ const char *content_type_name[] = {
#ifdef WITH_PLUGIN
"PLUGIN",
#endif
+#ifdef WITH_THEME_INSTALL
+ "THEME",
+#endif
"OTHER",
"UNKNOWN"
};
@@ -198,6 +204,9 @@ static const struct handler_entry handler_map[] = {
plugin_open, plugin_close,
true},
#endif
+#ifdef WITH_THEME_INSTALL
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, false},
+#endif
{0, 0, 0, 0, 0, 0, 0, 0, 0, false}
};
#define HANDLER_MAP_COUNT (sizeof(handler_map) / sizeof(handler_map[0]))
@@ -716,10 +725,10 @@ bool content_redraw(struct content *c, int x, int y,
/**
* Register a user for callbacks.
*
- * \param c The content to register
- * \param callback The callback function
- * \param p1, p2 Callback private data
- * \return true on success, false otherwise and error broadcast to users
+ * \param c the content to register
+ * \param callback the callback function
+ * \param p1, p2 callback private data
+ * \return true on success, false otherwise on memory exhaustion
*
* The callback will be called with p1 and p2 when content_broadcast() is
* called with the content.
@@ -731,16 +740,11 @@ bool content_add_user(struct content *c,
void *p1, void *p2)
{
struct content_user *user;
- union content_msg_data msg_data;
LOG(("content %s, user %p %p %p", c->url, callback, p1, p2));
user = calloc(1, sizeof(*user));
- if (!user) {
- c->status = CONTENT_STATUS_ERROR;
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ if (!user)
return false;
- }
user->callback = callback;
user->p1 = p1;
user->p2 = p2;
diff --git a/content/content_type.h b/content/content_type.h
index 484a877a6..4cbb49550 100644
--- a/content/content_type.h
+++ b/content/content_type.h
@@ -42,6 +42,9 @@ typedef enum {
#ifdef WITH_PLUGIN
CONTENT_PLUGIN,
#endif
+#ifdef WITH_THEME_INSTALL
+ CONTENT_THEME,
+#endif
/* these must be the last two */
CONTENT_OTHER,
CONTENT_UNKNOWN /**< content-type not received yet */
diff --git a/desktop/browser.c b/desktop/browser.c
index 734fde5ae..fc96df12f 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -241,6 +241,15 @@ void browser_window_callback(content_msg msg, struct content *c,
if (c->type == CONTENT_OTHER)
browser_window_convert_to_download(bw);
+#ifdef WITH_THEME_INSTALL
+ else if (c->type == CONTENT_THEME) {
+ theme_install_start(c);
+ bw->loading_content = 0;
+ content_remove_user(c, browser_window_callback,
+ bw, 0);
+ browser_window_stop_throbber(bw);
+ }
+#endif
else
gui_window_set_url(bw->window, c->url);
break;
@@ -297,7 +306,7 @@ void browser_window_callback(content_msg msg, struct content *c,
bw->scrolling_box = NULL;
}
browser_window_stop_throbber(bw);
- free (bw->referer);
+ free(bw->referer);
bw->referer = 0;
break;
@@ -1087,7 +1096,6 @@ void browser_redraw_box(struct content *c, struct box *box)
data.redraw.object_height = c->height;
content_broadcast(c, CONTENT_MSG_REDRAW, data);
-
}
diff --git a/desktop/browser.h b/desktop/browser.h
index 2a2776411..a39f78461 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -123,4 +123,9 @@ void schedule(int t, void (*callback)(void *p), void *p);
void schedule_remove(void (*callback)(void *p), void *p);
void schedule_run(void);
+/* In platform specific theme_install.c. */
+#ifdef WITH_THEME_INSTALL
+void theme_install_start(struct content *c);
+#endif
+
#endif
diff --git a/makefile b/makefile
index 54b49e402..a2260a557 100644
--- a/makefile
+++ b/makefile
@@ -34,8 +34,8 @@ OBJECTS_RISCOS += 401login.o bitmap.o buffer.o debugwin.o \
menus.o mouseactions.o plotters.o plugin.o print.o \
save.o save_complete.o save_draw.o save_text.o \
schedule.o search.o sprite.o textselection.o theme.o \
- thumbnail.o treeview.o ufont.o uri.o url_protocol.o \
- wimp.o window.o # riscos/
+ theme_install.o thumbnail.o treeview.o ufont.o uri.o \
+ url_protocol.o wimp.o window.o # riscos/
# OBJECTS_RISCOS += memdebug.o
OBJECTS_NCOS = $(OBJECTS_RISCOS)
diff --git a/riscos/gui.c b/riscos/gui.c
index 8ef2d561f..f7e8fa12c 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -258,6 +258,7 @@ void gui_init(int argc, char** argv)
ro_gui_401login_init();
#endif
ro_gui_history_init();
+ ro_gui_theme_install_init();
wimp_close_template();
ro_gui_sprites_init();
ro_gui_tree_initialise(); /* must be done after sprite loading */
diff --git a/riscos/gui.h b/riscos/gui.h
index bf5db9b85..0d25890bc 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -30,7 +30,7 @@ extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip, dialog_warning,
dialog_config_th_pane, dialog_debug, dialog_folder, dialog_entry,
- dialog_search, dialog_print, dialog_config_font;
+ dialog_search, dialog_print, dialog_config_font, dialog_theme_install;
extern wimp_w history_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu,
*proxyauth_menu, *languages_menu, *toolbar_menu,
@@ -251,6 +251,9 @@ extern int ro_plot_origin_x;
extern int ro_plot_origin_y;
void ro_plot_set_scale(float scale);
+/* in theme_install.c */
+void ro_gui_theme_install_init(void);
+
/* toolbar types */
#define TOOLBAR_BROWSER 0
#define TOOLBAR_HOTLIST 1
@@ -414,4 +417,8 @@ void ro_plot_set_scale(float scale);
#define ICON_PRINT_PRINT 16
#define ICON_PRINT_TEXT_BLACK 20
+#define ICON_THEME_INSTALL_MESSAGE 0
+#define ICON_THEME_INSTALL_INSTALL 1
+#define ICON_THEME_INSTALL_CANCEL 2
+
#endif
diff --git a/riscos/theme_install.c b/riscos/theme_install.c
new file mode 100644
index 000000000..cdf9c0c6a
--- /dev/null
+++ b/riscos/theme_install.c
@@ -0,0 +1,111 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
+ */
+
+/** \file
+ * Theme auto-installing.
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include "netsurf/content/content.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/wimp.h"
+#include "netsurf/utils/messages.h"
+#include "netsurf/utils/utils.h"
+
+
+static bool theme_install_active = false;
+wimp_w dialog_theme_install;
+
+
+void theme_install_callback(content_msg msg, struct content *c,
+ void *p1, void *p2, union content_msg_data data);
+
+
+/**
+ * Handle a CONTENT_THEME that has started loading.
+ */
+
+void theme_install_start(struct content *c)
+{
+ assert(c);
+ assert(c->type == CONTENT_THEME);
+
+ if (theme_install_active) {
+ warn_user("ThemeInstActive", 0);
+ /* raise & centre dialog */
+ return;
+ }
+
+ if (!content_add_user(c, theme_install_callback, 0, 0)) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ theme_install_active = true;
+
+ ro_gui_set_icon_string(dialog_theme_install, ICON_THEME_INSTALL_MESSAGE,
+ messages_get("ThemeInstDown"));
+ ro_gui_set_icon_shaded_state(dialog_theme_install,
+ ICON_THEME_INSTALL_INSTALL, true);
+ ro_gui_dialog_open(dialog_theme_install);
+}
+
+
+/**
+ * Callback for fetchcache() for theme install fetches.
+ */
+
+void theme_install_callback(content_msg msg, struct content *c,
+ void *p1, void *p2, union content_msg_data data)
+{
+ switch (msg) {
+ case CONTENT_MSG_READY:
+ break;
+
+ case CONTENT_MSG_DONE:
+ /** \todo: parse the theme data, extract name & author,
+ * and ask the user if they want to install */
+ ro_gui_set_icon_string(dialog_theme_install,
+ ICON_THEME_INSTALL_MESSAGE,
+ "Would you like to install the theme "
+ "\"x\" by y?");
+ ro_gui_set_icon_shaded_state(dialog_theme_install,
+ ICON_THEME_INSTALL_INSTALL, false);
+ break;
+
+ case CONTENT_MSG_ERROR:
+ ro_gui_dialog_close(dialog_theme_install);
+ warn_user(data.error, 0);
+ theme_install_active = false;
+ break;
+
+ case CONTENT_MSG_STATUS:
+ break;
+
+ case CONTENT_MSG_LOADING:
+ case CONTENT_MSG_REDIRECT:
+ case CONTENT_MSG_REFORMAT:
+ case CONTENT_MSG_REDRAW:
+ case CONTENT_MSG_NEWPTR:
+ case CONTENT_MSG_AUTH:
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+/**
+ * Create theme install window.
+ */
+
+void ro_gui_theme_install_init(void)
+{
+ dialog_theme_install = ro_gui_dialog_create("themeinstall");
+}
diff --git a/utils/config.h b/utils/config.h
index 281dd26f8..580185714 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -46,12 +46,12 @@
#define WITH_SEARCH
/* Printing support */
#define WITH_PRINT
+ /* Theme auto-install */
+ #define WITH_THEME_INSTALL
#endif
#ifdef ncos
/* Kiosk style browsing support */
#define WITH_KIOSK_BROWSING
- /* Kiosk style browsing themes support */
- #define WITH_KIOSK_THEMES
#endif
#if defined(riscos) || defined(ncos) || defined(debug)