changes for async modal dialogs

git-svn-id: svn://10.0.0.236/trunk@26726 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
spence%netscape.com
1999-04-07 06:54:12 +00:00
parent 778472c1b8
commit d0f3d65e5b
5 changed files with 345 additions and 32 deletions

View File

@@ -520,7 +520,8 @@ NET_AskForAuthString(MWContext *context,
URL_Struct * URL_s,
char * authenticate,
char * prot_template,
Bool already_sent_auth)
Bool already_sent_auth,
void *closure)
{
static PRBool first_time=TRUE;
net_AuthStruct *prev_auth;
@@ -796,6 +797,10 @@ NET_AskForAuthString(MWContext *context,
/* if the password is filled in then the username must
* be filled in already.
*/
/* 4/6/99 -- with the new async dialogs, we will only enter this
statement the first time through; afterward, we will have the
user and pass via NET_ResumeWithAuth()
*/
if(!password || re_authorize)
{
XP_Bool remember_password = FALSE;
@@ -811,6 +816,7 @@ NET_AskForAuthString(MWContext *context,
NET_Progress(context, XP_GetString( XP_CONNECT_PLEASE_ENTER_PASSWORD_FOR_HOST) );
#if 0
#if defined(SingleSignon)
/* prefill prompt with previous username/passwords if any
* this returns 1 if user pressed OK, or 0 if they Canceled
@@ -827,6 +833,16 @@ NET_AskForAuthString(MWContext *context,
(context, buf, &username, &password,
&remember_password, NET_IsURLSecure(URL_s->address));
#endif
#else
{
NET_AuthClosure * authclosure = (NET_AuthClosure *) closure;
/* the new multi-threaded case -- we return asynchronously */
authclosure->msg = PL_strdup (buf);
status = stub_PromptUsernameAndPassword
(context, buf, &username, &password, closure);
}
#endif
PR_Free(buf);
} else {
@@ -836,6 +852,10 @@ NET_AskForAuthString(MWContext *context,
PR_Free(host);
if(!status) {
/* XXX now we have FALSE == WAIT_FOR_AUTH */
return(NET_WAIT_FOR_AUTH);
#ifdef notused /* with async dialogs, we never have a user/pass here */a
TRACEMSG(("User canceled login!!!"));
/* if the paths are exact and the user cancels
@@ -847,6 +867,7 @@ NET_AskForAuthString(MWContext *context,
PR_FREEIF(password);
PR_FREEIF(new_address);
return(NET_AUTH_FAILED_DISPLAY_DOCUMENT);
#endif /* notused */
}
else if(!username || !password)
{
@@ -3663,7 +3684,8 @@ PUBLIC PRBool
NET_AskForProxyAuth(MWContext * context,
char * proxy_addr,
char * pauth_params,
PRBool already_sent_auth)
PRBool already_sent_auth,
void * closure)
{
net_AuthStruct * prev;
PRBool new_entry = FALSE;
@@ -3758,6 +3780,7 @@ NET_AskForProxyAuth(MWContext * context,
PR_snprintf(buf, len*sizeof(char), XP_GetString( XP_PROXY_AUTH_REQUIRED_FOR ), prev->realm, proxy_addr);
NET_Progress(context, XP_GetString( XP_CONNECT_PLEASE_ENTER_PASSWORD_FOR_PROXY ) );
#if 0
#if defined(SingleSignon)
/* prefill prompt with previous username/passwords if any */
len = SI_PromptUsernameAndPassword
@@ -3765,6 +3788,11 @@ NET_AskForProxyAuth(MWContext * context,
#else
len = FE_PromptUsernameAndPassword
(context, buf, &username, &password);
#endif
#else
/* the new multi-thread case -- we return with out user/pass */
len = stub_PromptUsernameAndPassword
(context, buf, &username, &password, closure);
#endif
PR_Free(buf);
}
@@ -3775,8 +3803,12 @@ NET_AskForProxyAuth(MWContext * context,
if (!len)
{
TRACEMSG(("Waiting for user auth"));
return FALSE;
#if notused
TRACEMSG(("User canceled login!!!"));
return FALSE;
#endif /* notused */
}
else if (!username || !password)
{
@@ -5618,6 +5650,7 @@ NET_DisplayCookieInfoAsHTML(MWContext * context)
net_DisplayCookieInfoAsHTML(context, NULL);
}
#if 0
#ifdef XP_MAC
/* pinkerton - reset optimization state (see above) */
#pragma global_optimizer reset
@@ -5625,7 +5658,8 @@ NET_DisplayCookieInfoAsHTML(MWContext * context)
#else
PUBLIC void
NET_DisplayCookieInfoAsHTML(MWContext * context)
NET_DisplayCookieInfoAsHTML(ActiveEntry *cur_entry)
{
}
#endif
#endif /* 0 */

View File

@@ -34,7 +34,8 @@ extern Bool NET_AskForAuthString(MWContext * context,
URL_Struct *URL_s,
char * authenticate,
char * prot_template,
Bool already_sent_auth);
Bool already_sent_auth,
void * closure);
/* returns a authorization string if one is required, otherwise
* returns NULL
@@ -58,7 +59,8 @@ PUBLIC PRBool
NET_AskForProxyAuth(MWContext * context,
char * proxy_addr,
char * pauth_params,
PRBool already_sent_auth);
PRBool already_sent_auth,
void * closure);
MODULE_PRIVATE int PR_CALLBACK
NET_CookieBehaviorPrefChanged(const char * newpref, void * data);

View File

@@ -1,3 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
@@ -128,7 +129,6 @@ PRIVATE XP_List * http_connection_list=0;
PRIVATE IdentifyMeEnum http_identification_method = DoNotIdentifyMe;
PRIVATE Bool sendRefererHeader=TRUE;
PUBLIC const HTTP_Version DEFAULT_VERSION = ONE_POINT_ONE;
PRIVATE const char *VERSION_STRING_ONE_ONE = "HTTP/1.1";
PRIVATE const char *VERSION_STRING_ONE_ZERO = "HTTP/1.0";
@@ -139,6 +139,8 @@ PRIVATE const char *VERSION_STRING_ONE_ZERO = "HTTP/1.0";
typedef enum {
HTTP_START_CONNECT,
HTTP_FINISH_CONNECT,
HTTP_WAIT_FOR_AUTH,
HTTP_RESUME_WITH_AUTH,
HTTP_SEND_PROXY_TUNNEL_REQUEST,
HTTP_BEGIN_UPLOAD_FILE,
HTTP_SEND_REQUEST,
@@ -2409,7 +2411,10 @@ net_revert_post_data(ActiveEntry * ce)
}
}
}
/* forward declaration */
PRIVATE int net_finish_setup_http_stream(ActiveEntry * ce);
/* sets up the stream and performs special actions like redirect and
* retry on authorization
*
@@ -2418,10 +2423,10 @@ net_revert_post_data(ActiveEntry * ce)
PRIVATE int
net_setup_http_stream(ActiveEntry * ce) {
HTTPConData * cd = (HTTPConData *)ce->con_data;
NET_AuthClosure * auth_closure;
XP_Bool need_to_do_again = FALSE;
MWContext * stream_context;
TRACEMSG(("NET_ProcessHTTP: setting up stream"));
TRACEMSG(("NET_ProcessHTTP: setting up stream: %s", ce->URL_s->address));
/* save this since it can be changed in lots
* of places. This will be used for graph progress
@@ -2487,24 +2492,43 @@ net_setup_http_stream(ActiveEntry * ce) {
if(cd->authorization_required) {
/* clear to prevent tight loop */
int status;
NET_ClearReadSelect(ce->window_id, cd->connection->sock);
#if defined(SMOOTH_PROGRESS)
PM_Suspend(ce->window_id, ce->URL_s);
#endif
/* tuck the ce away for the auth callback */
/* set up the auth closure struct for the password dialog */
auth_closure = PR_NEWZAP(NET_AuthClosure);
if (!auth_closure) {
return(MK_INTERRUPTED);
}
auth_closure->_private = (void *) ce;
auth_closure->msg = NULL;
auth_closure->user = NULL;
auth_closure->pass = NULL;
status = NET_AskForAuthString(ce->window_id,
ce->URL_s,
ce->URL_s->authenticate,
ce->URL_s->protection_template,
cd->sent_authorization);
cd->sent_authorization,
(void *) auth_closure);
#if defined(SMOOTH_PROGRESS)
PM_Resume(ce->window_id, ce->URL_s);
#endif
if(status == NET_RETRY_WITH_AUTH)
if (status == NET_RETRY_WITH_AUTH) {
need_to_do_again = TRUE;
} else if (status == NET_WAIT_FOR_AUTH) {
if (!ce->URL_s->password)
cd->next_state = HTTP_WAIT_FOR_AUTH;
return(0);
}
else
ce->URL_s->dont_cache = TRUE;
@@ -2554,12 +2578,26 @@ net_setup_http_stream(ActiveEntry * ce) {
PM_Suspend(ce->window_id, ce->URL_s);
#endif
if(NET_AskForProxyAuth(ce->window_id,
proxyServer,
ce->URL_s->proxy_authenticate,
cd->sent_proxy_auth))
/* tuck the ce away for the auth callback */
/* set up the auth closure struct for the password dialog */
auth_closure = PR_NEWZAP(NET_AuthClosure);
if (!auth_closure) {
return(MK_INTERRUPTED);
}
auth_closure->_private = (void *) ce;
auth_closure->msg = NULL;
auth_closure->user = NULL;
auth_closure->pass = NULL;
if(NET_AskForProxyAuth(ce->window_id,
proxyServer,
ce->URL_s->proxy_authenticate,
cd->sent_proxy_auth,
(void *) auth_closure)) {
need_to_do_again = TRUE;
else
TRACEMSG(("NET_AskForProxyAuth(): need_to_do_again: %s", ce->URL_s->address));
} else
ce->URL_s->dont_cache = TRUE;
#if defined(SMOOTH_PROGRESS)
@@ -2599,7 +2637,35 @@ net_setup_http_stream(ActiveEntry * ce) {
return(0); /* continue */
} else if (cd->doing_redirect && ce->URL_s->redirecting_url &&
}
/* Now finish stream setup. Setup needs to be broken in half
'cuz in the case of modal dialogs, we need to wait for username
and password, then return to finish */
return (ce->status = net_finish_setup_http_stream(ce));
}
PUBLIC void
NET_ResumeHTTP(ActiveEntry * ce, PRBool resume)
{
HTTPConData * cd = (HTTPConData *) ce->con_data;
TRACEMSG (("NET_ResumeHTTP: %s", ce->URL_s->address));
if (resume)
cd->next_state = HTTP_SETUP_STREAM;
else
cd->next_state = HTTP_DONE;
return;
}
PRIVATE int
net_finish_setup_http_stream(ActiveEntry * ce)
{
HTTPConData * cd = (HTTPConData *)ce->con_data;
MWContext * stream_context;
if (cd->doing_redirect && ce->URL_s->redirecting_url &&
/* try and prevent a circular loop. wont work for dual doc loop */
PL_strcmp(ce->URL_s->redirecting_url, ce->URL_s->address))
{
@@ -3438,6 +3504,14 @@ net_ProcessHTTP (ActiveEntry *ce)
switch(cd->next_state) {
case HTTP_WAIT_FOR_AUTH:
TRACEMSG (("HTTP_WAIT_FOR_AUTH: %s", ce->URL_s->address));
cd->pause_for_read = TRUE;
break;
case HTTP_RESUME_WITH_AUTH:
TRACEMSG (("HTTP_RESUME_WITH_AUTH: %s", ce->URL_s->address));
ce->status = net_finish_setup_http_stream(ce);
break;
case HTTP_START_CONNECT:
ce->status = net_start_http_connect(ce);
break;