mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 20:46:50 +03:00
[project @ 2006-04-06 22:42:22 by rjw]
Add connection option tool. svn path=/import/netsurf/; revision=2498
This commit is contained in:
parent
04147f020e
commit
1bb74deace
4
makefile
4
makefile
@ -42,8 +42,8 @@ OBJECTS_RISCOS += 401login.o artworks.o assert.o awrender.o bitmap.o \
|
||||
schedule.o search.o sprite.o sslcert.o textselection.o theme.o \
|
||||
theme_install.o thumbnail.o treeview.o ucstables.o uri.o \
|
||||
url_complete.o url_protocol.o wimp.o wimp_event.o window.o # riscos/
|
||||
OBJECTS_RISCOS += con_cache.o con_content.o con_fonts.o con_home.o \
|
||||
con_image.o con_inter.o con_language.o con_memory.o \
|
||||
OBJECTS_RISCOS += con_cache.o con_connect.o con_content.o con_fonts.o \
|
||||
con_home.o con_image.o con_inter.o con_language.o con_memory.o \
|
||||
con_secure.o con_theme.o # riscos/configure/
|
||||
# OBJECTS_RISCOS += memdebug.o
|
||||
|
||||
|
@ -65,6 +65,9 @@ void ro_gui_configure_initialise(void) {
|
||||
ro_gui_configure_register("con_cache",
|
||||
ro_gui_options_cache_initialise,
|
||||
ro_gui_wimp_event_finalise);
|
||||
ro_gui_configure_register("con_connect",
|
||||
ro_gui_options_connection_initialise,
|
||||
ro_gui_wimp_event_finalise);
|
||||
ro_gui_configure_register("con_content",
|
||||
ro_gui_options_content_initialise,
|
||||
ro_gui_wimp_event_finalise);
|
||||
|
190
riscos/configure/con_connect.c
Normal file
190
riscos/configure/con_connect.c
Normal file
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* 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 2006 Richard Wilson <info@tinct.net>
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <swis.h>
|
||||
#include "oslib/osspriteop.h"
|
||||
#include "oslib/wimp.h"
|
||||
#include "netsurf/desktop/options.h"
|
||||
#include "netsurf/riscos/configure/configure.h"
|
||||
#include "netsurf/riscos/dialog.h"
|
||||
#include "netsurf/riscos/menus.h"
|
||||
#include "netsurf/riscos/options.h"
|
||||
#include "netsurf/riscos/tinct.h"
|
||||
#include "netsurf/riscos/wimp.h"
|
||||
#include "netsurf/riscos/wimp_event.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
|
||||
#define CONNECTION_PROXY_FIELD 3
|
||||
#define CONNECTION_PROXY_MENU 4
|
||||
#define CONNECTION_PROXY_HOST_LABEL 5
|
||||
#define CONNECTION_PROXY_HOST 6
|
||||
#define CONNECTION_PROXY_PORT_LABEL 7
|
||||
#define CONNECTION_PROXY_PORT 8
|
||||
#define CONNECTION_PROXY_USERNAME_LABEL 9
|
||||
#define CONNECTION_PROXY_USERNAME 10
|
||||
#define CONNECTION_PROXY_PASSWORD_LABEL 11
|
||||
#define CONNECTION_PROXY_PASSWORD 12
|
||||
#define CONNECTION_MAX_FETCH_FIELD 16
|
||||
#define CONNECTION_MAX_FETCH_DEC 17
|
||||
#define CONNECTION_MAX_FETCH_INC 18
|
||||
#define CONNECTION_HOST_FETCH_FIELD 20
|
||||
#define CONNECTION_HOST_FETCH_DEC 21
|
||||
#define CONNECTION_HOST_FETCH_INC 22
|
||||
#define CONNECTION_CACHE_FETCH_FIELD 24
|
||||
#define CONNECTION_CACHE_FETCH_DEC 25
|
||||
#define CONNECTION_CACHE_FETCH_INC 26
|
||||
#define CONNECTION_DEFAULT_BUTTON 27
|
||||
#define CONNECTION_CANCEL_BUTTON 28
|
||||
#define CONNECTION_OK_BUTTON 29
|
||||
|
||||
#define http_proxy_type (option_http_proxy ? (option_http_proxy_auth + 1) : 0)
|
||||
|
||||
static int ro_gui_options_connection_proxy_type(wimp_w w);
|
||||
static void ro_gui_options_connection_default(wimp_pointer *pointer);
|
||||
static bool ro_gui_options_connection_ok(wimp_w w);
|
||||
static void ro_gui_options_connection_update(wimp_w w, wimp_i i);
|
||||
|
||||
bool ro_gui_options_connection_initialise(wimp_w w) {
|
||||
int proxy_type;
|
||||
|
||||
/* set the current values */
|
||||
proxy_type = (option_http_proxy ? (option_http_proxy_auth + 1) : 0);
|
||||
ro_gui_set_icon_string(w, CONNECTION_PROXY_FIELD,
|
||||
proxy_type_menu->entries[proxy_type].
|
||||
data.indirected_text.text);
|
||||
ro_gui_set_icon_string(w, CONNECTION_PROXY_HOST,
|
||||
option_http_proxy_host);
|
||||
ro_gui_set_icon_integer(w, CONNECTION_PROXY_PORT,
|
||||
option_http_proxy_port);
|
||||
ro_gui_set_icon_string(w, CONNECTION_PROXY_USERNAME,
|
||||
option_http_proxy_auth_user);
|
||||
ro_gui_set_icon_string(w, CONNECTION_PROXY_PASSWORD,
|
||||
option_http_proxy_auth_pass);
|
||||
ro_gui_set_icon_integer(w, CONNECTION_MAX_FETCH_FIELD,
|
||||
option_max_fetchers);
|
||||
ro_gui_set_icon_integer(w, CONNECTION_HOST_FETCH_FIELD,
|
||||
option_max_fetchers_per_host);
|
||||
ro_gui_set_icon_integer(w, CONNECTION_CACHE_FETCH_FIELD,
|
||||
option_max_cached_fetch_handles);
|
||||
ro_gui_options_connection_update(w, -1);
|
||||
|
||||
/* register icons */
|
||||
ro_gui_wimp_event_register_menu_gright(w, CONNECTION_PROXY_FIELD,
|
||||
CONNECTION_PROXY_MENU, proxy_type_menu);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_HOST_LABEL);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_HOST);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PORT_LABEL);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PORT);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_USERNAME_LABEL);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_USERNAME);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PASSWORD_LABEL);
|
||||
ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PASSWORD);
|
||||
ro_gui_wimp_event_register_numeric_field(w, CONNECTION_MAX_FETCH_FIELD,
|
||||
CONNECTION_MAX_FETCH_INC, CONNECTION_MAX_FETCH_DEC,
|
||||
1, 99, 1, 0);
|
||||
ro_gui_wimp_event_register_numeric_field(w, CONNECTION_HOST_FETCH_FIELD,
|
||||
CONNECTION_HOST_FETCH_INC, CONNECTION_HOST_FETCH_DEC,
|
||||
1, 99, 1, 0);
|
||||
ro_gui_wimp_event_register_numeric_field(w, CONNECTION_CACHE_FETCH_FIELD,
|
||||
CONNECTION_CACHE_FETCH_INC, CONNECTION_CACHE_FETCH_DEC,
|
||||
1, 99, 1, 0);
|
||||
ro_gui_wimp_event_register_menu_selection(w,
|
||||
ro_gui_options_connection_update);
|
||||
ro_gui_wimp_event_register_button(w, CONNECTION_DEFAULT_BUTTON,
|
||||
ro_gui_options_connection_default);
|
||||
ro_gui_wimp_event_register_cancel(w, CONNECTION_CANCEL_BUTTON);
|
||||
ro_gui_wimp_event_register_ok(w, CONNECTION_OK_BUTTON,
|
||||
ro_gui_options_connection_ok);
|
||||
|
||||
ro_gui_wimp_event_set_help_prefix(w, "HelpConnectConfig");
|
||||
ro_gui_wimp_event_memorise(w);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void ro_gui_options_connection_update(wimp_w w, wimp_i i) {
|
||||
int proxy_type;
|
||||
bool host, user;
|
||||
|
||||
/* update the shaded state */
|
||||
proxy_type = ro_gui_options_connection_proxy_type(w);
|
||||
host = (proxy_type > 0);
|
||||
user = (proxy_type > 1);
|
||||
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_HOST_LABEL, !host);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_HOST, !host);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PORT_LABEL, !host);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PORT, !host);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_USERNAME_LABEL, !user);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_USERNAME, !user);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PASSWORD_LABEL, !user);
|
||||
ro_gui_set_icon_shaded_state(w, CONNECTION_PROXY_PASSWORD, !user);
|
||||
}
|
||||
|
||||
int ro_gui_options_connection_proxy_type(wimp_w w) {
|
||||
char *text;
|
||||
int i;
|
||||
|
||||
text = ro_gui_get_icon_string(w, CONNECTION_PROXY_FIELD);
|
||||
for (i = 0; (i < 4); i++)
|
||||
if (!strcmp(text, proxy_type_menu->entries[i].
|
||||
data.indirected_text.text))
|
||||
return i;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void ro_gui_options_connection_default(wimp_pointer *pointer) {
|
||||
ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_FIELD,
|
||||
proxy_type_menu->entries[0].
|
||||
data.indirected_text.text);
|
||||
ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_HOST, "");
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_PROXY_PORT, 8080);
|
||||
ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_USERNAME, "");
|
||||
ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_PASSWORD, "");
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_MAX_FETCH_FIELD, 24);
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_HOST_FETCH_FIELD, 5);
|
||||
ro_gui_set_icon_integer(pointer->w, CONNECTION_CACHE_FETCH_FIELD, 6);
|
||||
ro_gui_options_connection_update(pointer->w, -1);
|
||||
}
|
||||
|
||||
bool ro_gui_options_connection_ok(wimp_w w) {
|
||||
int proxy_type;
|
||||
|
||||
proxy_type = ro_gui_options_connection_proxy_type(w);
|
||||
if (proxy_type == 0)
|
||||
option_http_proxy = false;
|
||||
else {
|
||||
option_http_proxy = true;
|
||||
option_http_proxy_auth = proxy_type - 1;
|
||||
}
|
||||
if (option_http_proxy_host)
|
||||
free(option_http_proxy_host);
|
||||
option_http_proxy_host = strdup(ro_gui_get_icon_string(w,
|
||||
CONNECTION_PROXY_HOST));
|
||||
option_http_proxy_port = ro_gui_get_icon_decimal(w,
|
||||
CONNECTION_PROXY_PORT, 0);
|
||||
if (option_http_proxy_auth_user)
|
||||
free(option_http_proxy_auth_user);
|
||||
option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(w,
|
||||
CONNECTION_PROXY_USERNAME));
|
||||
if (option_http_proxy_auth_pass)
|
||||
free(option_http_proxy_auth_pass);
|
||||
option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(w,
|
||||
CONNECTION_PROXY_PASSWORD));
|
||||
option_max_fetchers = ro_gui_get_icon_decimal(w,
|
||||
CONNECTION_MAX_FETCH_FIELD, 0);
|
||||
option_max_fetchers_per_host = ro_gui_get_icon_decimal(w,
|
||||
CONNECTION_HOST_FETCH_FIELD, 0);
|
||||
option_max_cached_fetch_handles = ro_gui_get_icon_decimal(w,
|
||||
CONNECTION_CACHE_FETCH_FIELD, 0);
|
||||
|
||||
ro_gui_save_options();
|
||||
return true;
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
bool ro_gui_options_cache_initialise(wimp_w w);
|
||||
bool ro_gui_options_connection_initialise(wimp_w w);
|
||||
bool ro_gui_options_content_initialise(wimp_w w);
|
||||
bool ro_gui_options_fonts_initialise(wimp_w w);
|
||||
bool ro_gui_options_home_initialise(wimp_w w);
|
||||
|
@ -129,7 +129,7 @@ int iconbar_menu_height = 5 * 44;
|
||||
/** The available menus */
|
||||
wimp_menu *iconbar_menu, *browser_menu, *hotlist_menu, *global_history_menu,
|
||||
*image_quality_menu, *browser_toolbar_menu,
|
||||
*tree_toolbar_menu, *proxy_auth_menu, *languages_menu;
|
||||
*tree_toolbar_menu, *proxy_type_menu, *languages_menu;
|
||||
/** URL suggestion menu */
|
||||
static wimp_MENU(GLOBAL_HISTORY_RECENT_URLS) url_suggest;
|
||||
wimp_menu *url_suggest_menu = (wimp_menu *)&url_suggest;
|
||||
@ -334,16 +334,17 @@ void ro_gui_menu_init(void)
|
||||
(struct ns_menu *)&tree_toolbar_definition);
|
||||
|
||||
/* proxy menu */
|
||||
NS_MENU(4) proxy_auth_definition = {
|
||||
"ProxyAuth", {
|
||||
NS_MENU(5) proxy_type_definition = {
|
||||
"ProxyType", {
|
||||
{ "ProxyNone", NO_ACTION, 0 },
|
||||
{ "ProxyNoAuth", NO_ACTION, 0 },
|
||||
{ "ProxyBasic", NO_ACTION, 0 },
|
||||
{ "ProxyNTLM", NO_ACTION, 0 },
|
||||
{NULL, 0, 0}
|
||||
}
|
||||
};
|
||||
proxy_auth_menu = ro_gui_menu_define_menu(
|
||||
(struct ns_menu *)&proxy_auth_definition);
|
||||
proxy_type_menu = ro_gui_menu_define_menu(
|
||||
(struct ns_menu *)&proxy_type_definition);
|
||||
|
||||
/* special case menus */
|
||||
url_suggest_menu->title_data.indirected_text.text =
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
extern wimp_menu *iconbar_menu, *browser_menu, *hotlist_menu,
|
||||
*global_history_menu, *image_quality_menu,
|
||||
*browser_toolbar_menu, *tree_toolbar_menu, *proxy_auth_menu;
|
||||
*browser_toolbar_menu, *tree_toolbar_menu, *proxy_type_menu;
|
||||
extern wimp_menu *languages_menu, *url_suggest_menu;
|
||||
|
||||
extern wimp_menu *current_menu;
|
||||
|
Loading…
Reference in New Issue
Block a user