From bbdb3cc988c580001964f69ef57ab31032df49e0 Mon Sep 17 00:00:00 2001 From: "morse%netscape.com" Date: Wed, 12 Aug 1998 04:03:33 +0000 Subject: [PATCH] improved signon viewer git-svn-id: svn://10.0.0.236/trunk@7807 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/main/singsign.c | 623 +++++++++++++++++++++----------- 1 file changed, 406 insertions(+), 217 deletions(-) diff --git a/mozilla/network/main/singsign.c b/mozilla/network/main/singsign.c index da2716e8bfd..5b1815ce7b8 100644 --- a/mozilla/network/main/singsign.c +++ b/mozilla/network/main/singsign.c @@ -1849,17 +1849,19 @@ SI_UnanonymizeSignons() si_anonymous = FALSE; } } -#include "mkgeturl.h" + #include "htmldlgs.h" -extern int XP_EMPTY_STRINGS; -extern int SA_VIEW_BUTTON_LABEL; +extern int XP_CERT_PAGE_STRINGS; extern int SA_REMOVE_BUTTON_LABEL; +extern int MK_SIGNON_VIEW_SIGNONS; +extern int MK_SIGNON_VIEW_REJECTS; #define BUFLEN 5000 #define FLUSH_BUFFER \ if (buffer) { \ StrAllocCat(buffer2, buffer); \ + buffer[0] = '\0'; \ g = 0; \ } @@ -1879,105 +1881,43 @@ Bool si_InSequence(char* sequence, int number) { for (ptr = sequence ; ptr ; ptr = endptr) { /* get to next comma */ - endptr = XP_STRCHR(ptr, ','); + endptr = PL_strchr(ptr, ','); - /* if comma found, set it to null */ + /* if comma found, process it */ if (endptr) { /* restore last comma-to-null back to comma */ if (undo) { *undo = ','; } + + /* set the comma to a null */ undo = endptr; *endptr++ = '\0'; - } - /* if there is a number before the comma, compare it with "number" */ - if (*ptr) { - i = atoi(ptr); - if (i == number) { + /* compare the number before the comma with "number" */ + if (*ptr) { + i = atoi(ptr); + if (i == number) { - /* "number" was in the sequence so return TRUE */ - retval = TRUE; - break; + /* "number" was in the sequence so return TRUE */ + retval = TRUE; + break; + } } } } + /* restore last comma-to-null back to comma */ if (undo) { *undo = ','; } return retval; } -MODULE_PRIVATE void -si_DisplayUserInfoAsHTML - (MWContext *context, si_SignonUserStruct* user, char* URLName) -{ - char *buffer = (char*)XP_ALLOC(BUFLEN); - char *buffer2 = 0; - int g = 0; - XP_List *data_ptr = user->signonData_list; - si_SignonDataStruct* data; - int dataNum; - - static XPDialogInfo dialogInfo = { - XP_DIALOG_OK_BUTTON, - NULL, - 250, - 200 - }; - - XPDialogStrings* strings; - StrAllocCopy(buffer2, ""); - - g += PR_snprintf(buffer+g, BUFLEN-g, -"
\n" -"
%s
\n" - ); - FLUSH_BUFFER - - /* free buffer since it is no longer needed */ - if (buffer) { - XP_FREE(buffer); - } - - /* do html dialog */ - strings = XP_GetDialogStrings(XP_EMPTY_STRINGS); - if (!strings) { - if (buffer2) { - XP_FREE(buffer2); - } - return; - } - if (buffer2) { - XP_CopyDialogString(strings, 0, buffer2); - XP_FREE(buffer2); - buffer2 = NULL; - } - XP_MakeHTMLDialog(context, &dialogInfo, MK_SIGNON_YOUR_SIGNONS, - strings, context, PR_FALSE); - - return; -} - PR_STATIC_CALLBACK(PRBool) -si_SignonInfoDialogDone - (XPDialogState* state, char** argv, int argc, unsigned int button) +si_SignonInfoDialogDone(XPDialogState* state, char** argv, int argc, + unsigned int button) { XP_List *URL_ptr; XP_List *user_ptr; @@ -1991,48 +1931,15 @@ si_SignonInfoDialogDone si_Reject* reject; si_Reject* rejectToDelete = 0; - char *buttonName, *userNumberAsString; + char *buttonName; int userNumber; int rejectNumber; char* gone; - /* test for cancel */ - if (button == XP_DIALOG_CANCEL_BUTTON) { - /* CANCEL button was pressed */ - return PR_FALSE; - } - - /* get button name */ buttonName = XP_FindValueInArgs("button", argv, argc); - if (buttonName && - !XP_STRCASECMP(buttonName, XP_GetString(SA_VIEW_BUTTON_LABEL))) { - - /* view button was pressed */ - - /* get "selname" value in argv list */ - if (!(userNumberAsString = XP_FindValueInArgs("selname", argv, argc))) { - /* no selname in argv list */ - return(PR_TRUE); - } - - /* convert "selname" value from string to an integer */ - userNumber = atoi(userNumberAsString); - - /* step to the user corresponding to that integer */ - si_lock_signon_list(); - URL_ptr = si_signon_list; - while ((URL = (si_SignonURLStruct *) XP_ListNextObject(URL_ptr))) { - user_ptr = URL->signonUser_list; - while ((user = (si_SignonUserStruct *) - XP_ListNextObject(user_ptr))) { - if (--userNumber < 0) { - si_DisplayUserInfoAsHTML - ((MWContext *)(state->arg), user, URL->URLName); - return(PR_TRUE); - } - } - } - si_unlock_signon_list(); + if (button != XP_DIALOG_OK_BUTTON) { + /* OK button not pressed (must be cancel button that was pressed) */ + return PR_FALSE; } /* OK was pressed, do the deletions */ @@ -2044,7 +1951,8 @@ si_SignonInfoDialogDone return PR_FALSE; } - /* step through all users and delete those that are in the sequence + /* + * step through all users and delete those that are in the sequence * Note: we can't delete user while "user_ptr" is pointing to it because * that would destroy "user_ptr". So we do a lazy deletion */ @@ -2080,7 +1988,7 @@ si_SignonInfoDialogDone si_SaveSignonDataLocked(NULL); } - /* get the comma-separated sequence of rejects to be deleted */ + /* get the comma-separated sequence of rejections to be deleted */ gone = XP_FindValueInArgs("goneR", argv, argc); XP_ASSERT(gone); if (!gone) { @@ -2109,16 +2017,24 @@ si_SignonInfoDialogDone si_SaveSignonDataLocked(NULL); } si_unlock_signon_list(); - return PR_FALSE; } +typedef struct _SignonViewerDialog SignonViewerDialog; + +struct _SignonViewerDialog { + void *window; + void *parent_window; + PRBool dialogUp; + XPDialogState *state; +}; + PUBLIC void SI_DisplaySignonInfoAsHTML(MWContext *context) { char *buffer = (char*)XP_ALLOC(BUFLEN); char *buffer2 = 0; - int g = 0, userNumber; + int g = 0, signonNum, count; XP_List *URL_ptr; XP_List *user_ptr; XP_List *data_ptr; @@ -2126,67 +2042,180 @@ SI_DisplaySignonInfoAsHTML(MWContext *context) si_SignonURLStruct *URL; si_SignonUserStruct * user; si_SignonDataStruct* data; - si_Reject* reject; + si_Reject *reject; + SignonViewerDialog *dlg; + int i; static XPDialogInfo dialogInfo = { - XP_DIALOG_OK_BUTTON | XP_DIALOG_CANCEL_BUTTON, + 0, si_SignonInfoDialogDone, - 600, - 420 + 350, + 400 }; XPDialogStrings* strings; + strings = XP_GetDialogStrings(XP_CERT_PAGE_STRINGS); + if (!strings) { + return; + } StrAllocCopy(buffer2, ""); - /* Write out the javascript */ + /* generate initial section of html file */ g += PR_snprintf(buffer+g, BUFLEN-g, -"\n" +"\n" +"\n" +" Cookies\n" +" \n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" <BODY> <P> </BODY>\n" +"\n" +"\n" + ); FLUSH_BUFFER si_unlock_signon_list(); /* free buffer since it is no longer needed */ if (buffer) { - XP_FREE(buffer); + PR_Free(buffer); } - /* do html dialog */ - strings = XP_GetDialogStrings(XP_EMPTY_STRINGS); - if (!strings) { - if (buffer2) { - XP_FREE(buffer2); - } + /* put html just generated into strings->arg[2] and invoke HTML dialog */ + if (buffer2) { + XP_SetDialogString(strings, 2, buffer2); + buffer2 = NULL; + } + dlg = PORT_ZAlloc(sizeof(SignonViewerDialog)); + if ( dlg == NULL ) { return; } - if (buffer2) { - XP_CopyDialogString(strings, 0, buffer2); - XP_FREE(buffer2); - buffer2 = NULL; - } - XP_MakeHTMLDialog(context, &dialogInfo, MK_SIGNON_YOUR_SIGNONS, - strings, context, PR_FALSE); + dlg->parent_window = (void *)context; + dlg->dialogUp = PR_TRUE; + dlg->state =XP_MakeRawHTMLDialog(context, &dialogInfo, MK_SIGNON_YOUR_SIGNONS, + strings, 1, (void *)dlg); return; } - #endif