[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
This commit is contained in:
James Bursa 2005-01-13 22:42:39 +00:00
parent a76404dfd0
commit f0b264670e
15 changed files with 168 additions and 20 deletions

View File

@ -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.

Binary file not shown.

View File

@ -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.

Binary file not shown.

View File

@ -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.

Binary file not shown.

View File

@ -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},
@ -126,6 +129,9 @@ const char *content_type_name[] = {
#endif
#ifdef WITH_PLUGIN
"PLUGIN",
#endif
#ifdef WITH_THEME_INSTALL
"THEME",
#endif
"OTHER",
"UNKNOWN"
@ -197,6 +203,9 @@ static const struct handler_entry handler_map[] = {
plugin_reformat, plugin_destroy, 0, plugin_redraw,
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}
};
@ -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;

View File

@ -41,6 +41,9 @@ typedef enum {
#endif
#ifdef WITH_PLUGIN
CONTENT_PLUGIN,
#endif
#ifdef WITH_THEME_INSTALL
CONTENT_THEME,
#endif
/* these must be the last two */
CONTENT_OTHER,

View File

@ -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);
}

View File

@ -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

View File

@ -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)

View File

@ -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 */

View File

@ -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

111
riscos/theme_install.c Normal file
View File

@ -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");
}

View File

@ -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)