NetSurf
con_connect.c
Go to the documentation of this file.
1/*
2 * Copyright 2006 Richard Wilson <info@tinct.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <stdbool.h>
20#include "swis.h"
21#include "oslib/osspriteop.h"
22#include "oslib/wimp.h"
23
24#include "utils/nsoption.h"
25#include "utils/log.h"
26
28#include "riscos/dialog.h"
29#include "riscos/menus.h"
30#include "riscos/tinct.h"
31#include "riscos/wimp.h"
32#include "riscos/wimp_event.h"
33
34
35#define CONNECTION_PROXY_FIELD 3
36#define CONNECTION_PROXY_MENU 4
37#define CONNECTION_PROXY_HOST_LABEL 5
38#define CONNECTION_PROXY_HOST 6
39#define CONNECTION_PROXY_PORT_LABEL 7
40#define CONNECTION_PROXY_PORT 8
41#define CONNECTION_PROXY_USERNAME_LABEL 9
42#define CONNECTION_PROXY_USERNAME 10
43#define CONNECTION_PROXY_PASSWORD_LABEL 11
44#define CONNECTION_PROXY_PASSWORD 12
45#define CONNECTION_MAX_FETCH_FIELD 16
46#define CONNECTION_MAX_FETCH_DEC 17
47#define CONNECTION_MAX_FETCH_INC 18
48#define CONNECTION_HOST_FETCH_FIELD 20
49#define CONNECTION_HOST_FETCH_DEC 21
50#define CONNECTION_HOST_FETCH_INC 22
51#define CONNECTION_CACHE_FETCH_FIELD 24
52#define CONNECTION_CACHE_FETCH_DEC 25
53#define CONNECTION_CACHE_FETCH_INC 26
54#define CONNECTION_DEFAULT_BUTTON 27
55#define CONNECTION_CANCEL_BUTTON 28
56#define CONNECTION_OK_BUTTON 29
57
58#define http_proxy_type (nsoption_bool(http_proxy) ? (nsoption_int(http_proxy_auth) + 1) : 0)
59
60static int ro_gui_options_connection_proxy_type(wimp_w w);
61static void ro_gui_options_connection_default(wimp_pointer *pointer);
62static bool ro_gui_options_connection_ok(wimp_w w);
63static bool ro_gui_options_connection_update(wimp_w w, wimp_i i, wimp_menu *m,
64 wimp_selection *s, menu_action a);
65
67{
68 int proxy_type;
69
70 /* set the current values */
71 proxy_type = (nsoption_bool(http_proxy) ? (nsoption_int(http_proxy_auth) + 1) : 0);
73 proxy_type_menu->entries[proxy_type].
74 data.indirected_text.text, true);
76 nsoption_charp(http_proxy_host) ?
77 nsoption_charp(http_proxy_host) : "", true);
79 nsoption_int(http_proxy_port));
81 nsoption_charp(http_proxy_auth_user) ?
82 nsoption_charp(http_proxy_auth_user) : "", true);
84 nsoption_charp(http_proxy_auth_pass) ?
85 nsoption_charp(http_proxy_auth_pass) : "", true);
87 nsoption_int(max_fetchers));
89 nsoption_int(max_fetchers_per_host));
91 nsoption_int(max_cached_fetch_handles));
93
94 /* register icons */
107 1, 99, 1, 0);
110 1, 99, 1, 0);
113 1, 99, 1, 0);
121
122 ro_gui_wimp_event_set_help_prefix(w, "HelpConnectConfig");
124 return true;
125
126}
127
128bool ro_gui_options_connection_update(wimp_w w, wimp_i i, wimp_menu *m,
129 wimp_selection *s, menu_action a)
130{
131 int proxy_type;
132 bool host, user;
133
134 /* update the shaded state */
136 host = (proxy_type > 0);
137 user = (proxy_type > 1);
138
147
148 return true;
149}
150
152{
153 const char *text;
154 int i;
155
157 for (i = 0; (i < 4); i++)
158 if (!strcmp(text, proxy_type_menu->entries[i].
159 data.indirected_text.text))
160 return i;
161 assert(false);
162}
163
164void ro_gui_options_connection_default(wimp_pointer *pointer)
165{
167 proxy_type_menu->entries[0].
168 data.indirected_text.text, true);
169 ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_HOST, "", true);
176 ro_gui_options_connection_update(pointer->w, -1, NULL, NULL, NO_ACTION);
177}
178
180{
181 int proxy_type;
182
184 if (proxy_type == 0) {
185 nsoption_set_bool(http_proxy, false);
186 } else {
187 nsoption_set_bool(http_proxy, true);
188 nsoption_set_int(http_proxy_auth, proxy_type - 1);
189 }
190
191 nsoption_set_charp(http_proxy_host,
192 strdup(ro_gui_get_icon_string(w,
194
195 nsoption_set_int(http_proxy_port,
197
198 nsoption_set_charp(http_proxy_auth_user,
199 strdup(ro_gui_get_icon_string(w,
201
202 nsoption_set_charp(http_proxy_auth_pass,
203 strdup(ro_gui_get_icon_string(w,
205
206 nsoption_set_int(max_fetchers,
209
210 nsoption_set_int(max_fetchers_per_host,
213
214 nsoption_set_int(max_cached_fetch_handles,
217
219 return true;
220}
menu_action
Definition: scaffolding.h:77
@ NO_ACTION
Definition: scaffolding.h:80
#define CONNECTION_CACHE_FETCH_INC
Definition: con_connect.c:53
#define CONNECTION_PROXY_PASSWORD_LABEL
Definition: con_connect.c:43
#define CONNECTION_PROXY_HOST_LABEL
Definition: con_connect.c:37
#define CONNECTION_HOST_FETCH_FIELD
Definition: con_connect.c:48
#define CONNECTION_HOST_FETCH_INC
Definition: con_connect.c:50
#define CONNECTION_MAX_FETCH_FIELD
Definition: con_connect.c:45
static int ro_gui_options_connection_proxy_type(wimp_w w)
Definition: con_connect.c:151
#define CONNECTION_OK_BUTTON
Definition: con_connect.c:56
#define CONNECTION_PROXY_MENU
Definition: con_connect.c:36
#define CONNECTION_DEFAULT_BUTTON
Definition: con_connect.c:54
#define CONNECTION_PROXY_USERNAME
Definition: con_connect.c:42
#define CONNECTION_CACHE_FETCH_DEC
Definition: con_connect.c:52
#define CONNECTION_CACHE_FETCH_FIELD
Definition: con_connect.c:51
#define CONNECTION_HOST_FETCH_DEC
Definition: con_connect.c:49
#define CONNECTION_PROXY_FIELD
Definition: con_connect.c:35
#define CONNECTION_PROXY_HOST
Definition: con_connect.c:38
#define CONNECTION_PROXY_PORT
Definition: con_connect.c:40
#define CONNECTION_PROXY_PASSWORD
Definition: con_connect.c:44
static void ro_gui_options_connection_default(wimp_pointer *pointer)
Definition: con_connect.c:164
bool ro_gui_options_connection_initialise(wimp_w w)
Definition: con_connect.c:66
#define CONNECTION_PROXY_PORT_LABEL
Definition: con_connect.c:39
#define CONNECTION_PROXY_USERNAME_LABEL
Definition: con_connect.c:41
static bool ro_gui_options_connection_update(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a)
Definition: con_connect.c:128
#define CONNECTION_CANCEL_BUTTON
Definition: con_connect.c:55
#define CONNECTION_MAX_FETCH_INC
Definition: con_connect.c:47
#define CONNECTION_MAX_FETCH_DEC
Definition: con_connect.c:46
static bool ro_gui_options_connection_ok(wimp_w w)
Definition: con_connect.c:179
Automated RISC OS WIMP event handling (interface).
void ro_gui_save_options(void)
Save the current options.
Definition: dialog.c:670
wimp_menu * proxy_type_menu
Definition: menus.c:104
Tinct SWI numbers and flags for version 0.11.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:297
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
Definition: nsoption.h:314
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
Definition: nsoption.h:310
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Definition: nsoption.h:338
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:270
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
Set the contents of a text or sprite icon to a string.
Definition: wimp.c:269
int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places)
Get the contents of an icon as a number.
Definition: wimp.c:423
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
Definition: wimp.c:487
const char * ro_gui_get_icon_string(wimp_w w, wimp_i i)
Read the contents of a text or sprite icon.
Definition: wimp.c:235
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value)
Set the contents of an icon to a number.
Definition: wimp.c:374
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_text_field(wimp_w w, wimp_i i)
Register a text field to be automatically handled.
Definition: wimp_event.c:1318
bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up, wimp_i down, int min, int max, int stepping, int decimal_places)
Register a numeric field to be automatically handled.
Definition: wimp_event.c:1287
bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix)
Set the associated help prefix for a given window.
Definition: wimp_event.c:390
bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu)
Register an icon menu to be automatically handled.
Definition: wimp_event.c:1331
bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i)
Register a function to be called for the Cancel action on a window.
Definition: wimp_event.c:1403
bool ro_gui_wimp_event_memorise(wimp_w w)
Memorises the current state of any registered components in a window.
Definition: wimp_event.c:139
bool ro_gui_wimp_event_register_menu_selection(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_selection *s, menu_action a))
Register a function to be called following a menu selection.
Definition: wimp_event.c:1581
bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, bool(*callback)(wimp_w w))
Register a function to be called for the OK action on a window.
Definition: wimp_event.c:1417
bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i, void(*callback)(wimp_pointer *pointer))
Register a function to be called when a particular button is pressed.
Definition: wimp_event.c:1387
Automated RISC OS WIMP event handling (interface).
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978