зеркало из https://github.com/mozilla/pjs.git
updates for single signon
This commit is contained in:
Родитель
e579ba153c
Коммит
b9bbbccca0
|
@ -265,8 +265,10 @@ extern Bool LO_GridCanGoForward(MWContext *context);
|
|||
extern Bool LO_GridCanGoBackward(MWContext *context);
|
||||
|
||||
#if defined(SingleSignon)
|
||||
extern void SI_RestoreSignonData
|
||||
(char* URLName, char* name, char** value);
|
||||
extern void SI_RememberSignonData
|
||||
(MWContext *context, LO_FormSubmitData *submit);
|
||||
(char* URLName, LO_FormSubmitData *submit);
|
||||
extern void SI_RememberSignonDataFromBrowser
|
||||
(MWContext *context,char* URLName, char* username, char* password);
|
||||
extern void SI_RestoreOldSignonData
|
||||
|
|
|
@ -68,6 +68,31 @@ si_SaveSignonDataInKeychain();
|
|||
|
||||
#endif
|
||||
|
||||
/* temporary */
|
||||
/*
|
||||
* Need this for now because the normal call to FE_Confirm goes through
|
||||
* a pointer in the context (context->func->confirm) and the context
|
||||
* doesn't exist when we get control from layout, namely when SI_RememberSignonData
|
||||
* is called
|
||||
*/
|
||||
#undef FE_Confirm
|
||||
Bool
|
||||
FE_Confirm(MWContext* context, const char* szMessage)
|
||||
{
|
||||
char c;
|
||||
fprintf(stdout, "%c%s (y/n)? ", '\007', szMessage); /* \007 is BELL */
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of temporary */
|
||||
|
||||
PRIVATE void
|
||||
si_lock_signon_list(void)
|
||||
{
|
||||
|
@ -170,7 +195,7 @@ si_SignonRememberingPrefChanged(const char * newpref, void * data)
|
|||
void
|
||||
si_RegisterSignonPrefCallbacks(void)
|
||||
{
|
||||
Bool x;
|
||||
Bool x = TRUE; /* initialize to default value in case PREF_GetBoolPref fails */
|
||||
static Bool first_time = TRUE;
|
||||
|
||||
if(first_time)
|
||||
|
@ -1064,7 +1089,7 @@ SI_StartOfForm() {
|
|||
*/
|
||||
#ifdef APPLE_KEYCHAIN
|
||||
OSStatus PR_CALLBACK
|
||||
si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userContext ) {
|
||||
si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userContext) {
|
||||
Bool *listInvalid = (Bool*)userContext;
|
||||
|
||||
*listInvalid = TRUE;
|
||||
|
@ -1730,11 +1755,12 @@ SI_RemoveAllSignonData() {
|
|||
* Check for a signon submission and remember the data if so
|
||||
*/
|
||||
PUBLIC void
|
||||
SI_RememberSignonData(MWContext *context, LO_FormSubmitData * submit)
|
||||
SI_RememberSignonData(char* URLName, LO_FormSubmitData * submit)
|
||||
{
|
||||
int i, j;
|
||||
int passwordCount = 0;
|
||||
int pswd[3];
|
||||
MWContext *context; /* not used -- just a hold-over from the old world order */
|
||||
|
||||
/* do nothing if signon preference is not enabled */
|
||||
if (!si_GetSignonRememberingPref()){
|
||||
|
@ -1763,9 +1789,9 @@ SI_RememberSignonData(MWContext *context, LO_FormSubmitData * submit)
|
|||
}
|
||||
|
||||
if (si_OkToSave(context,
|
||||
context->hist.cur_doc_ptr->address, /* urlname */
|
||||
URLName, /* urlname */
|
||||
((char **)submit->value_array)[j] /* username */)) {
|
||||
si_PutData(context->hist.cur_doc_ptr->address, submit, TRUE);
|
||||
si_PutData(URLName, submit, TRUE);
|
||||
}
|
||||
} else if (passwordCount == 2) {
|
||||
/* two-password form is a registration */
|
||||
|
@ -1787,10 +1813,8 @@ SI_RememberSignonData(MWContext *context, LO_FormSubmitData * submit)
|
|||
|
||||
/* ask user if this is a password change */
|
||||
si_lock_signon_list();
|
||||
user = si_GetUserForChangeForm(
|
||||
context,
|
||||
context->hist.cur_doc_ptr->address,
|
||||
MK_SIGNON_PASSWORDS_REMEMBER);
|
||||
user = si_GetUserForChangeForm
|
||||
(context, URLName, MK_SIGNON_PASSWORDS_REMEMBER);
|
||||
|
||||
/* return if user said no */
|
||||
if (!user) {
|
||||
|
@ -1825,6 +1849,40 @@ SI_RememberSignonData(MWContext *context, LO_FormSubmitData * submit)
|
|||
}
|
||||
}
|
||||
|
||||
PUBLIC void
|
||||
SI_RestoreSignonData
|
||||
(char* URLName, char* name, char** value)
|
||||
{
|
||||
MWContext *context; /* not used -- just a hold-over from the old world order */
|
||||
// si_SignonURLStruct* url;
|
||||
si_SignonUserStruct* user;
|
||||
si_SignonDataStruct* data;
|
||||
XP_List * data_ptr=0;
|
||||
|
||||
/* do nothing if signon preference is not enabled */
|
||||
if (!si_GetSignonRememberingPref()){
|
||||
return;
|
||||
}
|
||||
|
||||
/* get first user for this url */
|
||||
si_lock_signon_list();
|
||||
// url = si_GetURL(URLName);
|
||||
user = si_GetUser(context, URLName, TRUE, NULL);
|
||||
|
||||
/* restore the data from previous time this URL was visited */
|
||||
if (user) {
|
||||
data_ptr = user->signonData_list;
|
||||
while((data = (si_SignonDataStruct *) XP_ListNextObject(data_ptr))!=0) {
|
||||
if(name && XP_STRCMP(data->name, name)==0) {
|
||||
StrAllocCopy(*value, data->value);
|
||||
si_unlock_signon_list();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
si_unlock_signon_list();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for remembered data from a previous signon submission and
|
||||
* restore it if so
|
||||
|
@ -1964,7 +2022,7 @@ si_RememberSignonDataFromBrowser(char* URLName, char* username, char* password)
|
|||
|
||||
PUBLIC void
|
||||
SI_RememberSignonDataFromBrowser
|
||||
(MWContext *context,char* URLName, char* username, char* password)
|
||||
(MWContext *context, char* URLName, char* username, char* password)
|
||||
{
|
||||
if (si_OkToSave(context, URLName, username)) {
|
||||
si_RememberSignonDataFromBrowser (URLName, username, password);
|
||||
|
@ -2223,7 +2281,55 @@ SI_UnanonymizeSignons()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HTMLDialogs
|
||||
#include "htmldlgs.h"
|
||||
#else
|
||||
#define XP_DIALOG_CANCEL_BUTTON (1<<0)
|
||||
#define XP_DIALOG_OK_BUTTON (1<<2)
|
||||
#define XP_STRINGS_CHUNKSIZE 512
|
||||
typedef struct _XPDialogState XPDialogState;
|
||||
typedef struct _XPDialogInfo XPDialogInfo;
|
||||
typedef struct _XPDialogStrings XPDialogStrings;
|
||||
typedef PRBool (* XP_HTMLDialogHandler)(XPDialogState *state, char **argv,
|
||||
int argc, unsigned int button);
|
||||
struct _XPDialogState {
|
||||
PRArenaPool *arena;
|
||||
void *window;
|
||||
void *proto_win;
|
||||
XPDialogInfo *dialogInfo;
|
||||
void *arg;
|
||||
void (* deleteCallback)(void *arg);
|
||||
void *cbarg;
|
||||
PRBool deleted;
|
||||
};
|
||||
struct _XPDialogInfo {
|
||||
unsigned int buttonFlags;
|
||||
XP_HTMLDialogHandler handler;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
struct _XPDialogStrings
|
||||
{
|
||||
PRArenaPool *arena;
|
||||
int basestringnum;
|
||||
int nargs;
|
||||
char **args;
|
||||
char *contents;
|
||||
};
|
||||
|
||||
extern time_t CookieTime();
|
||||
extern XPDialogState *
|
||||
XP_MakeRawHTMLDialog(void *proto_win, XPDialogInfo *dialogInfo,
|
||||
int titlenum, XPDialogStrings *strings,
|
||||
int handlestring, void *arg);
|
||||
extern XPDialogStrings *XP_GetDialogStrings(int stringnum);
|
||||
extern void
|
||||
XP_SetDialogString(XPDialogStrings *strings, int argNum, char *string);
|
||||
extern char *
|
||||
XP_FindValueInArgs(const char *name, char **av, int ac);
|
||||
|
||||
#endif
|
||||
|
||||
extern int XP_CERT_PAGE_STRINGS;
|
||||
extern int SA_REMOVE_BUTTON_LABEL;
|
||||
extern int MK_SIGNON_VIEW_SIGNONS;
|
||||
|
@ -2765,6 +2871,15 @@ SI_DisplaySignonInfoAsHTML(MWContext *context)
|
|||
" }\n"
|
||||
"\n"
|
||||
" function clicker(but,win){\n"
|
||||
#ifndef HTMLDialogs
|
||||
" var goneS = top.frames[button_frame].document.buttons.goneS;\n"
|
||||
" var goneR = top.frames[button_frame].document.buttons.goneR;\n"
|
||||
" var expires = new Date();\n"
|
||||
" expires.setTime(expires.getTime() + 1000*60*60*24*365);\n"
|
||||
" document.cookie = \"htmldlgs=|\" + but.value +\n"
|
||||
" \"|goneS|\" + goneS.value + \"|goneR|\" + goneR.value + \"|\" +\n"
|
||||
" \"; expires=\" + expires.toGMTString();\n"
|
||||
#endif
|
||||
" top.frames[button_frame].document.buttons.xxxbuttonxxx.value = but.value;\n"
|
||||
" top.frames[button_frame].document.buttons.xxxbuttonxxx.name = 'button';\n"
|
||||
" top.frames[button_frame].document.buttons.submit();\n"
|
||||
|
|
|
@ -33,12 +33,23 @@
|
|||
#define COOKIE_FILE "cookies"
|
||||
#endif
|
||||
|
||||
#ifdef CookieManagement
|
||||
#define COOKIE_PERMISSION_FILE_TOK "%COOKIE_PERMISSION_F%"
|
||||
#ifdef XP_PC
|
||||
#define COOKIE_PERMISSION_FILE "cookperm.txt"
|
||||
#else
|
||||
#define COOKIE_PERMISSION_FILE "cookperm"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SingleSignon
|
||||
#define SIGNON_FILE_TOK "%SIGNON_F%"
|
||||
#ifdef XP_PC
|
||||
#define SIGNON_FILE "signons.txt"
|
||||
#else
|
||||
#define SIGNON_FILE "signons"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CACHE_DB_F_TOK "%CACHE_DB_F%"
|
||||
#define CACHE_DB_FILE "fat.db"
|
||||
|
|
|
@ -523,6 +523,17 @@ size_t XP_StrfTime(MWContext* context, char *result, size_t maxsize, int format,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
* From ns/lib/layout/edtutil.cpp
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void EDT_SavePublishUsername(MWContext *pContext, char *pAddress, char *pUsername)
|
||||
{
|
||||
MOZ_FUNCTION_STUB;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------------------
|
||||
* From ns/lib/layout/layutil.c
|
||||
|
@ -882,7 +893,8 @@ xpJSCookieFilters
|
|||
xpFileToPost
|
||||
xpMimeTypes
|
||||
xpHTTPCookie
|
||||
xpHTTPCookiePermission*/
|
||||
xpHTTPCookiePermission
|
||||
xpHTTPSingleSignon*/
|
||||
|
||||
// Caller is repsonsible for freeing string.
|
||||
|
||||
|
@ -914,6 +926,8 @@ char *xpFileTypeToName(XP_FileType type) {
|
|||
return PL_strdup("%USER%%COOKIE_F%");
|
||||
case (xpHTTPCookiePermission):
|
||||
return PL_strdup("%USER%%COOKIE_PERMISSION_F%");
|
||||
case (xpHTTPSingleSignon):
|
||||
return PL_strdup("%USER%%SIGNON_F%");
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -1061,6 +1075,8 @@ NET_InitFilesAndDirs(void) {
|
|||
|
||||
// Setup files.
|
||||
fileMgr->SetFileAssoc(COOKIE_FILE_TOK, COOKIE_FILE, USER_DIR_TOK);
|
||||
fileMgr->SetFileAssoc(COOKIE_PERMISSION_FILE_TOK, COOKIE_PERMISSION_FILE, USER_DIR_TOK);
|
||||
fileMgr->SetFileAssoc(SIGNON_FILE_TOK, SIGNON_FILE, USER_DIR_TOK);
|
||||
fileMgr->SetFileAssoc(CACHE_DB_F_TOK, CACHE_DB_FILE, CACHE_DIR_TOK);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1378,6 +1394,12 @@ WH_FileName (const char *NetName, XP_FileType type)
|
|||
return PL_strdup("cookperm.txt");
|
||||
#else
|
||||
return PL_strdup("cookperm");
|
||||
#endif
|
||||
} else if (type == xpHTTPSingleSignon) {
|
||||
#ifdef XP_PC
|
||||
return PL_strdup("signons.txt");
|
||||
#else
|
||||
return PL_strdup("signons");
|
||||
#endif
|
||||
} else if (type == xpCacheFAT) {
|
||||
;// sprintf(newName, "%s\\fat.db", (const char *)theApp.m_pCacheDir);
|
||||
|
@ -1438,6 +1460,7 @@ XP_FileOpen(const char * name, XP_FileType type, const XP_FilePerm perm)
|
|||
case xpFileToPost:
|
||||
case xpHTTPCookie:
|
||||
case xpHTTPCookiePermission:
|
||||
case xpHTTPSingleSignon:
|
||||
{
|
||||
XP_File fp;
|
||||
char* newName = WH_FileName(name, type);
|
||||
|
@ -1768,7 +1791,17 @@ JSBool
|
|||
ET_PostMessageBox(MWContext* context, char* szMessage, JSBool bConfirm)
|
||||
{
|
||||
MOZ_FUNCTION_STUB;
|
||||
return JS_FALSE;
|
||||
fprintf(stdout, "%c%s (y/n)? ", '\007', szMessage); /* \007 is BELL */
|
||||
char c;
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -1778,7 +1811,7 @@ ET_PostCheckConfirmBox(MWContext* context,
|
|||
XP_Bool *bChecked)
|
||||
{
|
||||
MOZ_FUNCTION_STUB;
|
||||
fprintf(stdout, "%c%s y/n? ", '\007', szMainMessage); /* \007 is BELL */
|
||||
fprintf(stdout, "%c%s (y/n)? ", '\007', szMainMessage); /* \007 is BELL */
|
||||
char c;
|
||||
XP_Bool result;
|
||||
for (;;) {
|
||||
|
|
|
@ -105,7 +105,7 @@ void stub_Alert(MWContext *context,
|
|||
}
|
||||
/* No nsINetSupport interface... */
|
||||
else {
|
||||
printf("Alert: %s", msg);
|
||||
printf("%cAlert: %s", '\007', msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,17 @@ XP_Bool stub_Confirm(MWContext *context,
|
|||
}
|
||||
/* No nsINetSupport interface... */
|
||||
else {
|
||||
printf("Confirm: %s", msg);
|
||||
printf("%cConfirm: %s (y/n)? ", '\007', msg);
|
||||
char c;
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
bResult = TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
bResult = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
@ -171,7 +181,7 @@ char *stub_Prompt(MWContext *context,
|
|||
char buf[256];
|
||||
|
||||
printf("%s\n", msg);
|
||||
printf("Prompt: ");
|
||||
printf("%cPrompt: ", '\007');
|
||||
scanf("%s", buf);
|
||||
if (PL_strlen(buf)) {
|
||||
result = PL_strdup(buf);
|
||||
|
@ -208,11 +218,11 @@ stub_PromptUsernameAndPassword(MWContext *context,
|
|||
char buf[256];
|
||||
|
||||
printf("%s\n", msg);
|
||||
printf("Username: ");
|
||||
printf("%cUsername: ", '\007');
|
||||
scanf("%s", buf);
|
||||
*username = PL_strdup(buf);
|
||||
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
*password = PL_strdup(buf);
|
||||
if (**username) {
|
||||
|
@ -247,7 +257,7 @@ char *stub_PromptPassword(MWContext *context,
|
|||
char buf[256];
|
||||
|
||||
printf("%s\n", msg);
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
if (PL_strlen(buf)) {
|
||||
result = PL_strdup(buf);
|
||||
|
|
|
@ -3853,6 +3853,7 @@ XP_MakeRawHTMLDialog(void *proto_win, XPDialogInfo *dialogInfo,
|
|||
char* button = NULL;
|
||||
char* cookie;
|
||||
char* separator;
|
||||
int i, j;
|
||||
|
||||
/* read in the cookies file */
|
||||
stat(COOKIE_FILE, &stats);
|
||||
|
@ -3861,43 +3862,38 @@ XP_MakeRawHTMLDialog(void *proto_win, XPDialogInfo *dialogInfo,
|
|||
f = fopen(COOKIE_FILE, "r");
|
||||
fread(readBuf, sizeof(char), fileLength, f);
|
||||
|
||||
/* find the htmldlgs cookie (it is preceded by "htmldlgs" tab "|" ) */
|
||||
cookie = PL_strstr(readBuf, "htmldlgs\t|"); /* get to htmldlgs tab | */
|
||||
cookie = cookie + PL_strlen("htmldlgs\t|"); /* get passed htmldlgs tab | */
|
||||
/* find the htmldlgs cookie (it is preceded by "htmldlgs" tab verical-bar ) */
|
||||
cookie = PL_strstr(readBuf, "htmldlgs\t|"); /* get to htmldlgs tab vert-bar */
|
||||
cookie = cookie + PL_strlen("htmldlgs\t|"); /* get passed htmldlgs tab vert-bar */
|
||||
|
||||
/* button name is first item in cookie (up to next |) */
|
||||
/* button name is first item in cookie (up to next verical bar) */
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
StrAllocCopy(button, cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
|
||||
/* goneC value is next item in cookie (up to next |) */
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
StrAllocCopy(argv[0], "goneC");
|
||||
StrAllocCopy(argv[1], cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
|
||||
/* goneP value is next item in cookie (up to next |) */
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
StrAllocCopy(argv[2], "goneP");
|
||||
StrAllocCopy(argv[3], cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
/* remainder of cookie string are the args, separated by vertical bars */
|
||||
for (i=0; (*cookie != '\n') && (*cookie != '\r'); i++) {
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
StrAllocCopy(argv[i], cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
}
|
||||
|
||||
/* invoke the dialog callback routine */
|
||||
if (!PORT_Strcmp(button,"OK")) {
|
||||
(dialogInfo->handler)(NULL, argv, 4, XP_DIALOG_OK_BUTTON);
|
||||
} else {
|
||||
(dialogInfo->handler)(NULL, argv, 4, XP_DIALOG_CANCEL_BUTTON);
|
||||
}
|
||||
|
||||
/* free up the allocated strings */
|
||||
XP_FREE(button);
|
||||
XP_FREE(argv[0]);
|
||||
XP_FREE(argv[1]);
|
||||
XP_FREE(argv[2]);
|
||||
XP_FREE(argv[3]);
|
||||
for (j=0; j<1; j++) {
|
||||
XP_FREE(argv[j]);
|
||||
}
|
||||
XP_FREE(readBuf);
|
||||
}
|
||||
|
||||
|
@ -5436,7 +5432,7 @@ net_DisplayCookieInfoAsHTML(MWContext *context, char* host)
|
|||
" var expires = new Date();\n"
|
||||
" expires.setTime(expires.getTime() + 1000*60*60*24*365);\n"
|
||||
" document.cookie = \"htmldlgs=|\" + but.value +\n"
|
||||
" \"|\" + goneC.value + \"|\" + goneP.value + \"|\" +\n"
|
||||
" \"|goneC|\" + goneC.value + \"|goneP|\" + goneP.value + \"|\" +\n"
|
||||
" \"; expires=\" + expires.toGMTString();\n"
|
||||
#endif
|
||||
" top.frames[button_frame].document.buttons.xxxbuttonxxx.value = but.value;\n"
|
||||
|
|
|
@ -1606,7 +1606,7 @@ nsBrowserWindow::Alert(const nsString &aText)
|
|||
|
||||
msg = aText.ToNewCString();
|
||||
if (nsnull != msg) {
|
||||
printf("Browser Window Alert: %s\n", msg);
|
||||
printf("%cBrowser Window Alert: %s\n", '\007', msg);
|
||||
PR_Free(msg);
|
||||
}
|
||||
}
|
||||
|
@ -1618,10 +1618,19 @@ nsBrowserWindow::Confirm(const nsString &aText)
|
|||
|
||||
msg = aText.ToNewCString();
|
||||
if (nsnull != msg) {
|
||||
printf("Browser Window Confirm: %s (returning false)\n", msg);
|
||||
printf("%cBrowser Window Confirm: %s (y/n)? ", msg);
|
||||
PR_Free(msg);
|
||||
char c;
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1638,7 +1647,7 @@ nsBrowserWindow::Prompt(const nsString &aText,
|
|||
printf("Browser Window: %s\n", msg);
|
||||
PR_Free(msg);
|
||||
|
||||
printf("Prompt: ");
|
||||
printf("%cPrompt: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aResult = buf;
|
||||
}
|
||||
|
@ -1659,11 +1668,11 @@ nsBrowserWindow::PromptUserAndPassword(const nsString &aText,
|
|||
printf("Browser Window: %s\n", msg);
|
||||
PR_Free(msg);
|
||||
|
||||
printf("User: ");
|
||||
printf("%cUser: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aUser = buf;
|
||||
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aPassword = buf;
|
||||
}
|
||||
|
@ -1680,7 +1689,7 @@ nsBrowserWindow::PromptPassword(const nsString &aText,
|
|||
msg = aText.ToNewCString();
|
||||
if (nsnull != msg) {
|
||||
printf("Browser Window: %s\n", msg);
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aPassword = buf;
|
||||
}
|
||||
|
|
|
@ -2494,7 +2494,7 @@ nsBrowserWindow::Alert(const nsString &aText)
|
|||
char *str;
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window Alert: %s\n", str);
|
||||
printf("Browser Window Alert: %c%s\n", '\007', str);
|
||||
PR_Free(str);
|
||||
}
|
||||
|
||||
|
@ -2505,10 +2505,18 @@ nsBrowserWindow::Confirm(const nsString &aText)
|
|||
char *str;
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window Confirm: %s (returning false)\n", str);
|
||||
printf("%cBrowser Window Confirm: %s (y/n)? ", '\007', str);
|
||||
PR_Free(str);
|
||||
|
||||
return PR_FALSE;
|
||||
char c;
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
@ -2521,7 +2529,7 @@ nsBrowserWindow::Prompt(const nsString &aText,
|
|||
char buf[256];
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window: %s\n", str);
|
||||
printf("%cBrowser Window: %s\n", '\007', str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("Prompt: ");
|
||||
|
@ -2544,10 +2552,10 @@ nsBrowserWindow::PromptUserAndPassword(const nsString &aText,
|
|||
printf("Browser Window: %s\n", str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("User: ");
|
||||
printf("%cUser: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aUser = buf;
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aPassword = buf;
|
||||
|
||||
|
@ -2563,7 +2571,7 @@ nsBrowserWindow::PromptPassword(const nsString &aText,
|
|||
char buf[256];
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window: %s\n", str);
|
||||
printf("%cBrowser Window: %s\n", '\007', str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("Password: ");
|
||||
|
|
|
@ -582,7 +582,7 @@ NS_IMETHODIMP_(void) nsXPBaseWindow::Alert(const nsString &aText)
|
|||
char *str;
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window Alert: %s\n", str);
|
||||
printf("%cBrowser Window Alert: %s\n", '\007', str);
|
||||
PR_Free(str);
|
||||
}
|
||||
|
||||
|
@ -592,10 +592,18 @@ NS_IMETHODIMP_(PRBool) nsXPBaseWindow::Confirm(const nsString &aText)
|
|||
char *str;
|
||||
|
||||
str = aText.ToNewCString();
|
||||
printf("Browser Window Confirm: %s (returning false)\n", str);
|
||||
printf("%cBrowser Window Confirm: %s (y/n)? \n", '\007', str);
|
||||
PR_Free(str);
|
||||
|
||||
return PR_FALSE;
|
||||
char c;
|
||||
for (;;) {
|
||||
c = getchar();
|
||||
if (tolower(c) == 'y') {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (tolower(c) == 'n') {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
@ -610,7 +618,7 @@ NS_IMETHODIMP_(PRBool) nsXPBaseWindow::Prompt(const nsString &aText,
|
|||
printf("Browser Window: %s\n", str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("Prompt: ");
|
||||
printf("%cPrompt: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aResult = buf;
|
||||
|
||||
|
@ -629,10 +637,10 @@ NS_IMETHODIMP_(PRBool) nsXPBaseWindow::PromptUserAndPassword(const nsString &aTe
|
|||
printf("Browser Window: %s\n", str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("User: ");
|
||||
printf("%cUser: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aUser = buf;
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aPassword = buf;
|
||||
|
||||
|
@ -650,7 +658,7 @@ NS_IMETHODIMP_(PRBool) nsXPBaseWindow::PromptPassword(const nsString &aText,
|
|||
printf("Browser Window: %s\n", str);
|
||||
PR_Free(str);
|
||||
|
||||
printf("Password: ");
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
aPassword = buf;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче