Fix RISC OS build

svn path=/trunk/netsurf/; revision=10405
This commit is contained in:
John Mark Bell 2010-04-15 22:49:22 +00:00
parent a4503a1574
commit b5b280dc96
2 changed files with 47 additions and 24 deletions

View File

@ -45,9 +45,9 @@
static void ro_gui_401login_close(wimp_w w);
static bool ro_gui_401login_apply(wimp_w w);
static void ro_gui_401login_open(struct browser_window *bw, const char *host,
const char *realm, const char *fetchurl);
static void ro_gui_401login_open(const char *url, const char *host,
const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
static wimp_window *dialog_401_template;
@ -57,7 +57,8 @@ struct session_401 {
char uname[256]; /**< Buffer for username */
char *url; /**< URL being fetched */
char pwd[256]; /**< Buffer for password */
struct browser_window *bwin; /**< Browser window handle */
nserror (*cb)(bool proceed, void *pw); /**< Continuation callback */
void *cbpw; /**< Continuation callback data */
};
@ -74,18 +75,16 @@ void ro_gui_401login_init(void)
/**
* Open the login dialog
*/
void gui_401login_open(struct browser_window *bw, hlcache_handle *c,
const char *realm)
void gui_401login_open(const char *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
const char *murl;
char *host;
url_func_result res;
murl = content_get_url(c);
res = url_host(murl, &host);
res = url_host(url, &host);
assert(res == URL_FUNC_OK);
ro_gui_401login_open(bw, host, realm, murl);
ro_gui_401login_open(url, host, realm, cb, cbpw);
free(host);
}
@ -95,8 +94,8 @@ void gui_401login_open(struct browser_window *bw, hlcache_handle *c,
* Open a 401 login window.
*/
void ro_gui_401login_open(struct browser_window *bw, const char *host,
const char *realm, const char *fetchurl)
void ro_gui_401login_open(const char *url, const char *host, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
struct session_401 *session;
wimp_w w;
@ -108,7 +107,7 @@ void ro_gui_401login_open(struct browser_window *bw, const char *host,
return;
}
session->url = strdup(fetchurl);
session->url = strdup(url);
if (!session->url) {
free(session);
warn_user("NoMemory", 0);
@ -136,7 +135,9 @@ void ro_gui_401login_open(struct browser_window *bw, const char *host,
}
session->host = strdup(host);
session->realm = strdup(realm);
session->bwin = bw;
session->cb = cb;
session->cbpw = cbpw;
if ((!session->host) || (!session->realm)) {
free(session->host);
free(session->realm);
@ -174,7 +175,7 @@ void ro_gui_401login_open(struct browser_window *bw, const char *host,
ro_gui_wimp_event_register_close_window(w, ro_gui_401login_close);
ro_gui_wimp_event_set_user_data(w, session);
ro_gui_dialog_open_persistent(bw->window->window, w, false);
ro_gui_dialog_open_persistent(NULL, w, false);
}
/**
@ -189,6 +190,10 @@ void ro_gui_401login_close(wimp_w w)
assert(session);
/* If ok didn't happen, send failure response */
if (session->cb != NULL)
session->cb(false, session->cbpw);
free(session->host);
free(session->realm);
free(session->url);
@ -229,7 +234,12 @@ bool ro_gui_401login_apply(wimp_w w)
free(auth);
browser_window_go(session->bwin, session->url, 0, true);
session->cb(true, session->cbpw);
/* Flag that we sent response by invalidating callback details */
session->cb = NULL;
session->cbpw = NULL;
return true;
}

View File

@ -62,9 +62,11 @@ static wimp_window *dialog_display_template;
struct session_data {
struct session_cert *certs;
unsigned long num;
struct browser_window *bw;
char *url;
struct tree *tree;
nserror (*cb)(bool proceed, void *pw);
void *cbpw;
};
struct session_cert {
char version[16], valid_from[32], valid_to[32], type[8], serial[32];
@ -100,8 +102,9 @@ void ro_gui_cert_init(void)
* Open the certificate verification dialog
*/
void gui_cert_verify(struct browser_window *bw, hlcache_handle *c,
const struct ssl_cert_info *certs, unsigned long num)
void gui_cert_verify(const char *url,
const struct ssl_cert_info *certs, unsigned long num,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
wimp_w w;
wimp_w ssl_w;
@ -115,7 +118,7 @@ void gui_cert_verify(struct browser_window *bw, hlcache_handle *c,
os_error *error;
long i;
assert(bw && c && certs);
assert(certs);
/* copy the certificate information */
data = calloc(1, sizeof(struct session_data));
@ -123,13 +126,14 @@ void gui_cert_verify(struct browser_window *bw, hlcache_handle *c,
warn_user("NoMemory", 0);
return;
}
data->url = strdup(content_get_url(c));
data->url = strdup(url);
if (!data->url) {
free(data);
warn_user("NoMemory", 0);
return;
}
data->bw = bw;
data->cb = cb;
data->cbpw = cbpw;
data->num = num;
data->certs = calloc(num, sizeof(struct session_cert));
if (!data->certs) {
@ -182,7 +186,7 @@ void gui_cert_verify(struct browser_window *bw, hlcache_handle *c,
ro_gui_wimp_event_set_user_data(ssl_w, data);
ro_gui_wimp_event_register_cancel(ssl_w, ICON_SSL_REJECT);
ro_gui_wimp_event_register_ok(ssl_w, ICON_SSL_ACCEPT, ro_gui_cert_apply);
ro_gui_dialog_open_persistent(bw->window->window, ssl_w, false);
ro_gui_dialog_open_persistent(NULL, ssl_w, false);
/* create a tree window (styled as a list) */
error = xwimp_create_window(dialog_tree_template, &w);
@ -391,6 +395,10 @@ void ro_gui_cert_close(wimp_w w)
data = (struct session_data *)ro_gui_wimp_event_get_user_data(w);
assert(data);
/* If we didn't accept the certificate, send failure response */
if (data->cb != NULL)
data->cb(false, data->cbpw);
for (i = 0; i < data->num; i++) {
if (data->certs[i].subject)
ro_textarea_destroy(data->certs[i].subject);
@ -434,7 +442,12 @@ bool ro_gui_cert_apply(wimp_w w)
assert(session);
urldb_set_cert_permissions(session->url, true);
browser_window_go(session->bw, session->url, 0, true);
session->cb(true, session->cbpw);
/* Flag that we sent response by invalidating callback details */
session->cb = NULL;
session->cbpw = NULL;
return true;
}