77 const char *fmt =
"The site %s is requesting your username and password. The realm is \"%s\"";
86 strlen = snprintf(str, 0, fmt, url_s, realm) + 1;
91 snprintf(str, strlen, fmt, url_s, realm);
108 RECT rc, rcDlg, rcOwner;
112 SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
120 if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
121 hwndOwner = GetDesktopWindow();
124 GetWindowRect(hwndOwner, &rcOwner);
125 GetWindowRect(hwndDlg, &rcDlg);
126 CopyRect(&rc, &rcOwner);
134 OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
135 OffsetRect(&rc, -rc.left, -rc.top);
136 OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
141 SetWindowPos(hwndDlg,
143 rcOwner.left + (rc.right / 2),
144 rcOwner.top + (rc.bottom / 2),
167 if (GetDlgItemText(hwndDlg,
170 sizeof(username)) == 0) {
174 if (GetDlgItemText(hwndDlg,
177 sizeof(password)) == 0) {
181 NSLOG(netsurf, DEBUG,
182 "context %p, user:\"%s\" pw:\"%s\"", ctx, username, password);
184 ctx->
cb(username, password, ctx->
cbctx);
186 DestroyWindow(hwndDlg);
202 NSLOG(netsurf, DEBUG,
"context %p", ctx);
204 ctx->
cb(NULL, NULL, ctx->
cbctx);
206 DestroyWindow(hwndDlg);
227 ctx = (
struct login_ctx *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
234 switch (LOWORD(wParam)) {
255 const char *password,
271 nctx = calloc(1,
sizeof(
struct login_ctx));
288 hwndDlg = CreateDialogParam(NULL,
Localised message support (interface).
static nserror get_login_description(struct nsurl *url, const char *realm, char **out_str)
generate the description of the login request
static nserror free_loginctx(struct login_ctx *ctx)
free login dialog context
static BOOL login_dialog_init(HWND hwndDlg, WPARAM wParam, LPARAM lParam)
win32 login dialog initialisation handler
nserror nsurl_get(const nsurl *url, nsurl_component parts, char **url_s, size_t *url_l)
Get URL (section) as a string, from a NetSurf URL object.
Basic authentication login interfaces.
nserror nsw32_add_dialog(HWND hwndDlg)
add a modeless dialog to the special handling list
static BOOL login_dialog_cancel(HWND hwndDlg, struct login_ctx *ctx)
win32 login dialog cancel handler
#define IDC_LOGIN_PASSWORD
nserror
Enumeration of error codes.
struct gui_window * nsws_get_gui_window(HWND hwnd)
Obtain gui window structure from window handle.
nserror nsw32_del_dialog(HWND hwndDlg)
remove a modeless dialog from the special handling list
first entry in window list
#define NSLOG(catname, level, logmsg, args...)
nserror(* cb)(const char *username, const char *password, void *cbctx)
Version information interface.
#define IDC_LOGIN_USERNAME
#define LOG_WIN_MSG(h, m, w, l)
log windows message
static BOOL CALLBACK login_dialog_callback(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
win32 API callback for login dialog
HWND main
handle to the actual window
#define IDC_LOGIN_DESCRIPTION
nserror nsw32_401login(nsurl *url, const char *realm, const char *username, const char *password, nserror(*cb)(const char *username, const char *password, void *cbctx), void *cbctx)
Request credentials for http login.
static BOOL login_dialog_ok(HWND hwndDlg, struct login_ctx *ctx)
win32 login dialog ok handler
NetSurf URL handling (interface).
struct nsurl nsurl
NetSurf URL object.