mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
fix up indentation
This commit is contained in:
parent
4893fa0a92
commit
c5c850dbb6
@ -124,9 +124,10 @@ FE_SelectDialog
|
||||
PRIVATE void
|
||||
si_lock_signon_list(void)
|
||||
{
|
||||
if(!signon_lock_monitor)
|
||||
if(!signon_lock_monitor) {
|
||||
signon_lock_monitor =
|
||||
PR_NewNamedMonitor("signon-lock");
|
||||
}
|
||||
|
||||
PR_EnterMonitor(signon_lock_monitor);
|
||||
|
||||
@ -243,8 +244,10 @@ si_GetSignonRememberingPref(void)
|
||||
we need to reload the signon data */
|
||||
if (si_list_invalid)
|
||||
{
|
||||
/* set si_list_invalid to FALSE first because SI_RemoveAllSignonData
|
||||
calls si_GetSignonRememberingPref */
|
||||
/*
|
||||
* set si_list_invalid to FALSE first because SI_RemoveAllSignonData
|
||||
* calls si_GetSignonRememberingPref
|
||||
*/
|
||||
si_list_invalid = FALSE;
|
||||
SI_RemoveAllSignonData();
|
||||
SI_LoadSignonData(NULL);
|
||||
@ -1228,7 +1231,6 @@ SI_StartOfForm() {
|
||||
OSStatus PR_CALLBACK
|
||||
si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userContext) {
|
||||
Bool *listInvalid = (Bool*)userContext;
|
||||
|
||||
*listInvalid = TRUE;
|
||||
}
|
||||
#endif
|
||||
@ -1280,19 +1282,15 @@ si_LoadSignonDataFromKeychain() {
|
||||
|
||||
status = KCFindFirstItem( &attrList, &searchRef, &itemRef );
|
||||
|
||||
if (status == noErr)
|
||||
{
|
||||
if (status == noErr) {
|
||||
/* if we found a Netscape item, let's assume notice has been given */
|
||||
si_NoticeGiven = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
si_NoticeGiven = FALSE;
|
||||
}
|
||||
|
||||
si_lock_signon_list();
|
||||
while(status == noErr)
|
||||
{
|
||||
while(status == noErr) {
|
||||
char *value;
|
||||
uint16 i = 0;
|
||||
uint32 actualSize;
|
||||
@ -1307,11 +1305,11 @@ si_LoadSignonDataFromKeychain() {
|
||||
attr[0].data = &flags;
|
||||
|
||||
status = KCGetAttribute( itemRef, attr, nil );
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & kNegativeKCItemFlag)
|
||||
{
|
||||
if (flags & kNegativeKCItemFlag) {
|
||||
reject = TRUE;
|
||||
}
|
||||
|
||||
@ -1321,8 +1319,9 @@ si_LoadSignonDataFromKeychain() {
|
||||
attr[0].data = buffer;
|
||||
|
||||
status = KCGetAttribute( itemRef, attr, &actualSize );
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
break;
|
||||
{
|
||||
|
||||
/* null terminate */
|
||||
buffer[actualSize] = 0;
|
||||
@ -1330,21 +1329,19 @@ si_LoadSignonDataFromKeychain() {
|
||||
URLName = NULL;
|
||||
StrAllocCopy(URLName, buffer);
|
||||
|
||||
if (!reject)
|
||||
{
|
||||
if (!reject) {
|
||||
/* get the password data */
|
||||
status = KCGetData(itemRef, BUFFER_SIZE, buffer, &actualSize);
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* null terminate */
|
||||
buffer[actualSize] = 0;
|
||||
|
||||
/* parse for '=' which separates the name and value */
|
||||
for (i = 0; i < XP_STRLEN(buffer); i++)
|
||||
{
|
||||
if (buffer[i] == '=')
|
||||
{
|
||||
for (i = 0; i < XP_STRLEN(buffer); i++) {
|
||||
if (buffer[i] == '=') {
|
||||
value = &buffer[i+1];
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
@ -1364,19 +1361,17 @@ si_LoadSignonDataFromKeychain() {
|
||||
attr[0].data = buffer;
|
||||
|
||||
status = KCGetAttribute( itemRef, attr, &actualSize );
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* null terminate */
|
||||
buffer[actualSize] = 0;
|
||||
|
||||
if (!reject)
|
||||
{
|
||||
if (!reject) {
|
||||
/* parse for '=' which separates the name and value */
|
||||
for (i = 0; i < XP_STRLEN(buffer); i++)
|
||||
{
|
||||
if (buffer[i] == '=')
|
||||
{
|
||||
for (i = 0; i < XP_STRLEN(buffer); i++) {
|
||||
if (buffer[i] == '=') {
|
||||
value = &buffer[i+1];
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
@ -1410,9 +1405,8 @@ si_LoadSignonDataFromKeychain() {
|
||||
XP_FREE(name_array[i]);
|
||||
XP_FREE(value_array[i]);
|
||||
}
|
||||
}
|
||||
else /* reject */
|
||||
{
|
||||
} else {
|
||||
/* reject */
|
||||
si_PutReject(URLName, buffer, FALSE);
|
||||
}
|
||||
|
||||
@ -1425,25 +1419,30 @@ si_LoadSignonDataFromKeychain() {
|
||||
}
|
||||
si_unlock_signon_list();
|
||||
|
||||
if (searchRef)
|
||||
if (searchRef) {
|
||||
KCReleaseSearchRef( &searchRef );
|
||||
}
|
||||
|
||||
/* Register a callback with the Keychain if we haven't already done so. */
|
||||
|
||||
if (si_kcUPP == NULL)
|
||||
{
|
||||
si_kcUPP = NewKCCallbackProc( si_KeychainCallback );
|
||||
if (!si_kcUPP)
|
||||
if (!si_kcUPP) {
|
||||
return memFullErr;
|
||||
|
||||
KCAddCallback( si_kcUPP, kLockKCEventMask + kDeleteKCEventMask + kUpdateKCEventMask, &si_list_invalid );
|
||||
/* Note that the callback is not necessarily removed. We take advantage of the fact that the
|
||||
Keychain will clean up the callback when the app goes away. It is explicitly removed when
|
||||
the signon preference is turned off. */
|
||||
}
|
||||
|
||||
if (status == errKCItemNotFound)
|
||||
KCAddCallback( si_kcUPP, kLockKCEventMask + kDeleteKCEventMask + kUpdateKCEventMask, &si_list_invalid );
|
||||
/*
|
||||
* Note that the callback is not necessarily removed. We take advantage
|
||||
* of the fact that the Keychain will clean up the callback when the app
|
||||
* goes away. It is explicitly removed when the signon preference is turned off.
|
||||
*/
|
||||
}
|
||||
|
||||
if (status == errKCItemNotFound) {
|
||||
status = 0;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
@ -1473,8 +1472,9 @@ SI_LoadSignonData(char * filename) {
|
||||
}
|
||||
|
||||
#ifdef APPLE_KEYCHAIN
|
||||
if (KeychainManagerAvailable())
|
||||
if (KeychainManagerAvailable()) {
|
||||
return si_LoadSignonDataFromKeychain();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* open the signon file */
|
||||
@ -1622,35 +1622,41 @@ si_SaveSignonDataInKeychain() {
|
||||
if (si_reject_list) {
|
||||
list_ptr = si_reject_list;
|
||||
while((reject = (si_Reject *) XP_ListNextObject(list_ptr))!=0) {
|
||||
status = kcaddinternetpassword( reject->URLName, nil, reject->userName, kAnyPort, kNetscapeProtocolType,
|
||||
kAnyAuthType, 0, nil, &itemRef );
|
||||
if (status != noErr && status != errKCDuplicateItem)
|
||||
status = kcaddinternetpassword
|
||||
(reject->URLName, nil,
|
||||
reject->userName,
|
||||
kAnyPort,
|
||||
kNetscapeProtocolType,
|
||||
kAnyAuthType,
|
||||
0,
|
||||
nil,
|
||||
&itemRef);
|
||||
if (status != noErr && status != errKCDuplicateItem) {
|
||||
return(status);
|
||||
|
||||
if (status == noErr)
|
||||
{
|
||||
/* make the item invisible so the user doesn't see it and negative
|
||||
so we know that it is a reject entry */
|
||||
}
|
||||
if (status == noErr) {
|
||||
/*
|
||||
* make the item invisible so the user doesn't see it and
|
||||
* negative so we know that it is a reject entry
|
||||
*/
|
||||
attr.tag = kFlagsKCItemAttr;
|
||||
attr.data = &flags;
|
||||
attr.length = sizeof( flags );
|
||||
|
||||
status = KCSetAttribute( itemRef, &attr );
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
return(status);
|
||||
|
||||
}
|
||||
status = KCUpdateItem(itemRef);
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
return(status);
|
||||
|
||||
}
|
||||
KCReleaseItemRef(&itemRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* save off the passwords */
|
||||
|
||||
if((si_signon_list)) {
|
||||
list_ptr = si_signon_list;
|
||||
while((URL = (si_SignonURLStruct *) XP_ListNextObject(list_ptr)) != NULL) {
|
||||
@ -1665,18 +1671,17 @@ si_SaveSignonDataInKeychain() {
|
||||
/* write out each data node of the user node */
|
||||
while((data=(si_SignonDataStruct *) XP_ListNextObject(data_ptr)) != NULL) {
|
||||
char* attribute = nil;
|
||||
if (data->isPassword)
|
||||
{
|
||||
password = XP_ALLOC( XP_STRLEN(data->value) + XP_STRLEN(data->name) + 2);
|
||||
if (!password)
|
||||
if (data->isPassword) {
|
||||
password = XP_ALLOC(XP_STRLEN(data->value) +
|
||||
XP_STRLEN(data->name) + 2);
|
||||
if (!password) {
|
||||
return (-1);
|
||||
attribute = password;
|
||||
}
|
||||
else
|
||||
{
|
||||
account = XP_ALLOC( XP_STRLEN(data->value) + XP_STRLEN(data->name) + 2);
|
||||
if (!account)
|
||||
{
|
||||
attribute = password;
|
||||
} else {
|
||||
account = XP_ALLOC( XP_STRLEN(data->value) +
|
||||
XP_STRLEN(data->name) + 2);
|
||||
if (!account) {
|
||||
XP_FREE(password);
|
||||
return (-1);
|
||||
}
|
||||
@ -1689,33 +1694,50 @@ si_SaveSignonDataInKeychain() {
|
||||
|
||||
}
|
||||
/* if it's already there, we just want to change the password */
|
||||
status = kcfindinternetpassword( URL->URLName, nil, account, kAnyPort, kNetscapeProtocolType, kAnyAuthType,
|
||||
0, nil, &actualLength, &itemRef );
|
||||
if (status == noErr)
|
||||
{
|
||||
status = kcfindinternetpassword
|
||||
(URL->URLName,
|
||||
nil,
|
||||
account,
|
||||
kAnyPort,
|
||||
kNetscapeProtocolType,
|
||||
kAnyAuthType,
|
||||
0,
|
||||
nil,
|
||||
&actualLength,
|
||||
&itemRef);
|
||||
if (status == noErr) {
|
||||
status = KCSetData(itemRef, XP_STRLEN(password), password);
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
return(status);
|
||||
|
||||
}
|
||||
status = KCUpdateItem(itemRef);
|
||||
KCReleaseItemRef(&itemRef);
|
||||
} else {
|
||||
/* wasn't there, let's add it */
|
||||
status = kcaddinternetpassword
|
||||
(URL->URLName,
|
||||
nil,
|
||||
account,
|
||||
kAnyPort,
|
||||
kNetscapeProtocolType,
|
||||
kAnyAuthType,
|
||||
XP_STRLEN(password),
|
||||
password,
|
||||
nil);
|
||||
}
|
||||
else /* wasn't there, let's add it */
|
||||
{
|
||||
status = kcaddinternetpassword( URL->URLName, nil, account, kAnyPort, kNetscapeProtocolType, kAnyAuthType,
|
||||
XP_STRLEN( password ), password, nil );
|
||||
}
|
||||
if (account)
|
||||
if (account) {
|
||||
XP_FREE(account);
|
||||
if (password)
|
||||
}
|
||||
if (password) {
|
||||
XP_FREE(password);
|
||||
}
|
||||
account = password = nil;
|
||||
|
||||
if (status != noErr)
|
||||
if (status != noErr) {
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
si_signon_list_changed = FALSE;
|
||||
return (0);
|
||||
@ -1753,8 +1775,9 @@ si_SaveSignonDataLocked(char * filename) {
|
||||
}
|
||||
|
||||
#ifdef APPLE_KEYCHAIN
|
||||
if (KeychainManagerAvailable())
|
||||
if (KeychainManagerAvailable()) {
|
||||
return si_SaveSignonDataInKeychain();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* do nothing if we are unable to open file that contains signon list */
|
||||
|
Loading…
Reference in New Issue
Block a user