mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-03 17:54:33 +03:00
Atari: Move to new HTTP auth API.
This commit is contained in:
parent
c55a31aa11
commit
66a97b863c
@ -767,23 +767,30 @@ static void gui_set_clipboard(const char *buffer, size_t length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void gui_401login_open(nsurl *url, const char *realm,
|
static void gui_401login_open(nsurl *url, const char *realm,
|
||||||
nserror (*cb)(bool proceed, void *pw), void *cbpw)
|
const char *username, const char *password,
|
||||||
|
nserror (*cb)(const char *username,
|
||||||
|
const char *password,
|
||||||
|
void *pw),
|
||||||
|
void *cbpw)
|
||||||
{
|
{
|
||||||
bool bres;
|
bool bres;
|
||||||
char * out = NULL;
|
char * u_out = NULL;
|
||||||
bres = login_form_do( url, (char*)realm, &out);
|
char * p_out = NULL;
|
||||||
if (bres) {
|
|
||||||
NSLOG(netsurf, INFO, "url: %s, realm: %s, auth: %s\n",
|
|
||||||
nsurl_access(url), realm, out);
|
|
||||||
urldb_set_auth_details(url, realm, out);
|
|
||||||
}
|
|
||||||
if (out != NULL) {
|
|
||||||
free( out );
|
|
||||||
}
|
|
||||||
if (cb != NULL) {
|
|
||||||
cb(bres, cbpw);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bres = login_form_do(url, (char*)realm, &u_out, &p_out);
|
||||||
|
if (bres) {
|
||||||
|
NSLOG(netsurf, INFO, "url: %s, realm: %s, auth: %s\n",
|
||||||
|
nsurl_access(url), realm, out);
|
||||||
|
}
|
||||||
|
if (cb != NULL) {
|
||||||
|
cb(u_out, p_out, cbpw);
|
||||||
|
}
|
||||||
|
if (u_out != NULL) {
|
||||||
|
free(u_out);
|
||||||
|
}
|
||||||
|
if (p_out != NULL) {
|
||||||
|
free(p_out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static nserror
|
static nserror
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "atari/res/netsurf.rsh"
|
#include "atari/res/netsurf.rsh"
|
||||||
|
|
||||||
|
|
||||||
bool login_form_do(nsurl * url, char * realm, char ** out)
|
bool login_form_do(nsurl * url, char * realm, char ** u_out char ** p_out)
|
||||||
{
|
{
|
||||||
char user[255];
|
char user[255];
|
||||||
char pass[255];
|
char pass[255];
|
||||||
@ -45,8 +45,6 @@ bool login_form_do(nsurl * url, char * realm, char ** out)
|
|||||||
user[0] = 0;
|
user[0] = 0;
|
||||||
pass[0] = 0;
|
pass[0] = 0;
|
||||||
|
|
||||||
// TODO: use auth details for predefined login data
|
|
||||||
// auth = urldb_get_auth_details(url, realm);
|
|
||||||
tree = gemtk_obj_get_tree(LOGIN);
|
tree = gemtk_obj_get_tree(LOGIN);
|
||||||
|
|
||||||
assert(tree != NULL);
|
assert(tree != NULL);
|
||||||
@ -57,10 +55,18 @@ bool login_form_do(nsurl * url, char * realm, char ** out)
|
|||||||
get_string(tree, LOGIN_TB_USER, user);
|
get_string(tree, LOGIN_TB_USER, user);
|
||||||
get_string(tree, LOGIN_TB_PASSWORD, pass);
|
get_string(tree, LOGIN_TB_PASSWORD, pass);
|
||||||
int size = strlen((char*)&user) + strlen((char*)&pass) + 2 ;
|
int size = strlen((char*)&user) + strlen((char*)&pass) + 2 ;
|
||||||
*out = malloc(size);
|
*u_out = malloc(strlen((char*)&user) + 1);
|
||||||
snprintf(*out, size, "%s:%s", user, pass);
|
*p_out = malloc(strlen((char*)&pass) + 1);
|
||||||
|
if (u_out == NULL || p_out == NULL) {
|
||||||
|
free(*u_out);
|
||||||
|
free(*p_out);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(*u_out, (char*)&user, strlen((char*)&user) + 1);
|
||||||
|
memcpy(*p_out, (char*)&pass, strlen((char*)&pass) + 1);
|
||||||
} else {
|
} else {
|
||||||
*out = NULL;
|
*u_out = NULL;
|
||||||
|
*p_out = NULL;
|
||||||
}
|
}
|
||||||
return((exit_obj == LOGIN_BT_LOGIN));
|
return((exit_obj == LOGIN_BT_LOGIN));
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,6 @@
|
|||||||
|
|
||||||
#include "utils/nsurl.h"
|
#include "utils/nsurl.h"
|
||||||
|
|
||||||
bool login_form_do( nsurl * host, char * realm, char **cbpw );
|
bool login_form_do(nsurl * url, char * realm, char ** u_out char ** p_out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user