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
|
PRIVATE void
|
||||||
si_lock_signon_list(void)
|
si_lock_signon_list(void)
|
||||||
{
|
{
|
||||||
if(!signon_lock_monitor)
|
if(!signon_lock_monitor) {
|
||||||
signon_lock_monitor =
|
signon_lock_monitor =
|
||||||
PR_NewNamedMonitor("signon-lock");
|
PR_NewNamedMonitor("signon-lock");
|
||||||
|
}
|
||||||
|
|
||||||
PR_EnterMonitor(signon_lock_monitor);
|
PR_EnterMonitor(signon_lock_monitor);
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ si_lock_signon_list(void)
|
|||||||
PRIVATE void
|
PRIVATE void
|
||||||
si_unlock_signon_list(void)
|
si_unlock_signon_list(void)
|
||||||
{
|
{
|
||||||
PR_EnterMonitor(signon_lock_monitor);
|
PR_EnterMonitor(signon_lock_monitor);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* make sure someone doesn't try to free a lock they don't own */
|
/* make sure someone doesn't try to free a lock they don't own */
|
||||||
@ -183,41 +184,41 @@ si_SaveSignonDataLocked(char * filename);
|
|||||||
PRIVATE void
|
PRIVATE void
|
||||||
si_SetSignonRememberingPref(Bool x)
|
si_SetSignonRememberingPref(Bool x)
|
||||||
{
|
{
|
||||||
/* do nothing if new value of pref is same as current value */
|
/* do nothing if new value of pref is same as current value */
|
||||||
if (x == si_RememberSignons) {
|
if (x == si_RememberSignons) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if pref is being turned off, save the current signons to a file */
|
/* if pref is being turned off, save the current signons to a file */
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
si_lock_signon_list();
|
si_lock_signon_list();
|
||||||
si_SaveSignonDataLocked(NULL);
|
si_SaveSignonDataLocked(NULL);
|
||||||
si_unlock_signon_list();
|
si_unlock_signon_list();
|
||||||
#ifdef APPLE_KEYCHAIN
|
#ifdef APPLE_KEYCHAIN
|
||||||
/* We no longer need the Keychain callback installed */
|
/* We no longer need the Keychain callback installed */
|
||||||
KCRemoveCallback( si_kcUPP );
|
KCRemoveCallback( si_kcUPP );
|
||||||
DisposeRoutineDescriptor( si_kcUPP );
|
DisposeRoutineDescriptor( si_kcUPP );
|
||||||
si_kcUPP = NULL;
|
si_kcUPP = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change the pref */
|
/* change the pref */
|
||||||
si_RememberSignons = x;
|
si_RememberSignons = x;
|
||||||
|
|
||||||
/* if pref is being turned on, load the signon file into memory */
|
/* if pref is being turned on, load the signon file into memory */
|
||||||
if (x == 1) {
|
if (x == 1) {
|
||||||
SI_RemoveAllSignonData();
|
SI_RemoveAllSignonData();
|
||||||
SI_LoadSignonData(NULL);
|
SI_LoadSignonData(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_PRIVATE int PR_CALLBACK
|
MODULE_PRIVATE int PR_CALLBACK
|
||||||
si_SignonRememberingPrefChanged(const char * newpref, void * data)
|
si_SignonRememberingPrefChanged(const char * newpref, void * data)
|
||||||
{
|
{
|
||||||
Bool x;
|
Bool x;
|
||||||
PREF_GetBoolPref(pref_rememberSignons, &x);
|
PREF_GetBoolPref(pref_rememberSignons, &x);
|
||||||
si_SetSignonRememberingPref(x);
|
si_SetSignonRememberingPref(x);
|
||||||
return PREF_NOERROR;
|
return PREF_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -239,20 +240,22 @@ PRIVATE Bool
|
|||||||
si_GetSignonRememberingPref(void)
|
si_GetSignonRememberingPref(void)
|
||||||
{
|
{
|
||||||
#ifdef APPLE_KEYCHAIN
|
#ifdef APPLE_KEYCHAIN
|
||||||
/* If the Keychain has been locked or an item deleted or updated,
|
/* If the Keychain has been locked or an item deleted or updated,
|
||||||
we need to reload the signon data */
|
we need to reload the signon data */
|
||||||
if (si_list_invalid)
|
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
|
||||||
si_list_invalid = FALSE;
|
* calls si_GetSignonRememberingPref
|
||||||
SI_RemoveAllSignonData();
|
*/
|
||||||
SI_LoadSignonData(NULL);
|
si_list_invalid = FALSE;
|
||||||
}
|
SI_RemoveAllSignonData();
|
||||||
|
SI_LoadSignonData(NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
si_RegisterSignonPrefCallbacks();
|
si_RegisterSignonPrefCallbacks();
|
||||||
return si_RememberSignons;
|
return si_RememberSignons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -706,10 +709,10 @@ si_GetURLAndUserForChangeForm(MWContext *context, char* password)
|
|||||||
user_count = 0;
|
user_count = 0;
|
||||||
url_ptr = si_signon_list;
|
url_ptr = si_signon_list;
|
||||||
while((url = (si_SignonURLStruct *) XP_ListNextObject(url_ptr))!=0) {
|
while((url = (si_SignonURLStruct *) XP_ListNextObject(url_ptr))!=0) {
|
||||||
user_ptr = url->signonUser_list;
|
user_ptr = url->signonUser_list;
|
||||||
while((user = (si_SignonUserStruct *) XP_ListNextObject(user_ptr))!=0) {
|
while((user = (si_SignonUserStruct *) XP_ListNextObject(user_ptr))!=0) {
|
||||||
user_count++;
|
user_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate lists for maximumum possible url and user names */
|
/* allocate lists for maximumum possible url and user names */
|
||||||
@ -771,7 +774,7 @@ si_GetURLAndUserForChangeForm(MWContext *context, char* password)
|
|||||||
|
|
||||||
/* free allocated strings */
|
/* free allocated strings */
|
||||||
while (--list2 > list) {
|
while (--list2 > list) {
|
||||||
XP_FREE(*list2);
|
XP_FREE(*list2);
|
||||||
}
|
}
|
||||||
XP_FREE(list);
|
XP_FREE(list);
|
||||||
XP_FREE(users);
|
XP_FREE(users);
|
||||||
@ -1227,9 +1230,8 @@ SI_StartOfForm() {
|
|||||||
#ifdef APPLE_KEYCHAIN
|
#ifdef APPLE_KEYCHAIN
|
||||||
OSStatus PR_CALLBACK
|
OSStatus PR_CALLBACK
|
||||||
si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userContext) {
|
si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userContext) {
|
||||||
Bool *listInvalid = (Bool*)userContext;
|
Bool *listInvalid = (Bool*)userContext;
|
||||||
|
*listInvalid = TRUE;
|
||||||
*listInvalid = TRUE;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1280,172 +1282,169 @@ si_LoadSignonDataFromKeychain() {
|
|||||||
|
|
||||||
status = KCFindFirstItem( &attrList, &searchRef, &itemRef );
|
status = KCFindFirstItem( &attrList, &searchRef, &itemRef );
|
||||||
|
|
||||||
if (status == noErr)
|
if (status == noErr) {
|
||||||
{
|
|
||||||
/* if we found a Netscape item, let's assume notice has been given */
|
/* if we found a Netscape item, let's assume notice has been given */
|
||||||
si_NoticeGiven = TRUE;
|
si_NoticeGiven = TRUE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
si_NoticeGiven = FALSE;
|
si_NoticeGiven = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
si_lock_signon_list();
|
si_lock_signon_list();
|
||||||
while(status == noErr)
|
while(status == noErr) {
|
||||||
{
|
char *value;
|
||||||
char *value;
|
uint16 i = 0;
|
||||||
uint16 i = 0;
|
uint32 actualSize;
|
||||||
uint32 actualSize;
|
KCItemFlags flags;
|
||||||
KCItemFlags flags;
|
Boolean reject = FALSE;
|
||||||
Boolean reject = FALSE;
|
|
||||||
|
|
||||||
submit.value_cnt = 0;
|
submit.value_cnt = 0;
|
||||||
|
|
||||||
/* first find out if it is a reject entry */
|
/* first find out if it is a reject entry */
|
||||||
attr[0].tag = kFlagsKCItemAttr;
|
attr[0].tag = kFlagsKCItemAttr;
|
||||||
attr[0].length = sizeof( KCItemFlags );
|
attr[0].length = sizeof(KCItemFlags);
|
||||||
attr[0].data = &flags;
|
attr[0].data = &flags;
|
||||||
|
|
||||||
status = KCGetAttribute( itemRef, attr, nil );
|
|
||||||
if (status != noErr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (flags & kNegativeKCItemFlag)
|
|
||||||
{
|
|
||||||
reject = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the server name */
|
|
||||||
attr[0].tag = kServerKCItemAttr;
|
|
||||||
attr[0].length = BUFFER_SIZE;
|
|
||||||
attr[0].data = buffer;
|
|
||||||
|
|
||||||
status = KCGetAttribute( itemRef, attr, &actualSize );
|
|
||||||
if (status != noErr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* null terminate */
|
|
||||||
buffer[actualSize] = 0;
|
|
||||||
|
|
||||||
URLName = NULL;
|
|
||||||
StrAllocCopy(URLName, buffer);
|
|
||||||
|
|
||||||
if (!reject)
|
|
||||||
{
|
|
||||||
/* get the password data */
|
|
||||||
status = KCGetData( itemRef, BUFFER_SIZE, buffer, &actualSize );
|
|
||||||
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] == '=')
|
|
||||||
{
|
|
||||||
value = &buffer[i+1];
|
|
||||||
buffer[i] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name_array[submit.value_cnt] = NULL;
|
|
||||||
value_array[submit.value_cnt] = NULL;
|
|
||||||
|
|
||||||
type_array[submit.value_cnt] = FORM_TYPE_PASSWORD;
|
|
||||||
StrAllocCopy(name_array[submit.value_cnt], buffer);
|
|
||||||
StrAllocCopy(value_array[submit.value_cnt], value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the account attribute */
|
|
||||||
attr[0].tag = kAccountKCItemAttr;
|
|
||||||
attr[0].length = BUFFER_SIZE;
|
|
||||||
attr[0].data = buffer;
|
|
||||||
|
|
||||||
status = KCGetAttribute( itemRef, attr, &actualSize );
|
|
||||||
if (status != noErr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* null terminate */
|
|
||||||
buffer[actualSize] = 0;
|
|
||||||
|
|
||||||
if (!reject)
|
|
||||||
{
|
|
||||||
/* parse for '=' which separates the name and value */
|
|
||||||
for (i = 0; i < XP_STRLEN(buffer); i++)
|
|
||||||
{
|
|
||||||
if (buffer[i] == '=')
|
|
||||||
{
|
|
||||||
value = &buffer[i+1];
|
|
||||||
buffer[i] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
submit.value_cnt++;
|
|
||||||
name_array[submit.value_cnt] = NULL;
|
|
||||||
value_array[submit.value_cnt] = NULL;
|
|
||||||
|
|
||||||
type_array[submit.value_cnt] = FORM_TYPE_TEXT;
|
|
||||||
StrAllocCopy(name_array[submit.value_cnt], buffer);
|
|
||||||
StrAllocCopy(value_array[submit.value_cnt], value);
|
|
||||||
|
|
||||||
/* check for overruning of the arrays */
|
|
||||||
if (submit.value_cnt >= MAX_ARRAY_SIZE) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
submit.value_cnt++;
|
|
||||||
/* store the info for this URL into memory-resident data structure */
|
|
||||||
if (!URLName || XP_STRLEN(URLName) == 0) {
|
|
||||||
badInput = TRUE;
|
|
||||||
}
|
|
||||||
if (!badInput) {
|
|
||||||
si_PutData(URLName, &submit, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* free up all the allocations done for processing this URL */
|
|
||||||
for (i = 0; i < submit.value_cnt; i++) {
|
|
||||||
XP_FREE(name_array[i]);
|
|
||||||
XP_FREE(value_array[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* reject */
|
|
||||||
{
|
|
||||||
si_PutReject(URLName, buffer, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
reject = FALSE; /* reset reject flag */
|
|
||||||
XP_FREE(URLName);
|
|
||||||
KCReleaseItemRef( &itemRef );
|
|
||||||
|
|
||||||
status = KCFindNextItem( searchRef, &itemRef );
|
|
||||||
|
|
||||||
|
status = KCGetAttribute( itemRef, attr, nil );
|
||||||
|
if (status != noErr) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & kNegativeKCItemFlag) {
|
||||||
|
reject = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get the server name */
|
||||||
|
attr[0].tag = kServerKCItemAttr;
|
||||||
|
attr[0].length = BUFFER_SIZE;
|
||||||
|
attr[0].data = buffer;
|
||||||
|
|
||||||
|
status = KCGetAttribute( itemRef, attr, &actualSize );
|
||||||
|
if (status != noErr) {
|
||||||
|
break;
|
||||||
|
{
|
||||||
|
|
||||||
|
/* null terminate */
|
||||||
|
buffer[actualSize] = 0;
|
||||||
|
|
||||||
|
URLName = NULL;
|
||||||
|
StrAllocCopy(URLName, buffer);
|
||||||
|
|
||||||
|
if (!reject) {
|
||||||
|
/* get the password data */
|
||||||
|
status = KCGetData(itemRef, BUFFER_SIZE, buffer, &actualSize);
|
||||||
|
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] == '=') {
|
||||||
|
value = &buffer[i+1];
|
||||||
|
buffer[i] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name_array[submit.value_cnt] = NULL;
|
||||||
|
value_array[submit.value_cnt] = NULL;
|
||||||
|
|
||||||
|
type_array[submit.value_cnt] = FORM_TYPE_PASSWORD;
|
||||||
|
StrAllocCopy(name_array[submit.value_cnt], buffer);
|
||||||
|
StrAllocCopy(value_array[submit.value_cnt], value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get the account attribute */
|
||||||
|
attr[0].tag = kAccountKCItemAttr;
|
||||||
|
attr[0].length = BUFFER_SIZE;
|
||||||
|
attr[0].data = buffer;
|
||||||
|
|
||||||
|
status = KCGetAttribute( itemRef, attr, &actualSize );
|
||||||
|
if (status != noErr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* null terminate */
|
||||||
|
buffer[actualSize] = 0;
|
||||||
|
|
||||||
|
if (!reject) {
|
||||||
|
/* parse for '=' which separates the name and value */
|
||||||
|
for (i = 0; i < XP_STRLEN(buffer); i++) {
|
||||||
|
if (buffer[i] == '=') {
|
||||||
|
value = &buffer[i+1];
|
||||||
|
buffer[i] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submit.value_cnt++;
|
||||||
|
name_array[submit.value_cnt] = NULL;
|
||||||
|
value_array[submit.value_cnt] = NULL;
|
||||||
|
|
||||||
|
type_array[submit.value_cnt] = FORM_TYPE_TEXT;
|
||||||
|
StrAllocCopy(name_array[submit.value_cnt], buffer);
|
||||||
|
StrAllocCopy(value_array[submit.value_cnt], value);
|
||||||
|
|
||||||
|
/* check for overruning of the arrays */
|
||||||
|
if (submit.value_cnt >= MAX_ARRAY_SIZE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit.value_cnt++;
|
||||||
|
/* store the info for this URL into memory-resident data structure */
|
||||||
|
if (!URLName || XP_STRLEN(URLName) == 0) {
|
||||||
|
badInput = TRUE;
|
||||||
|
}
|
||||||
|
if (!badInput) {
|
||||||
|
si_PutData(URLName, &submit, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free up all the allocations done for processing this URL */
|
||||||
|
for (i = 0; i < submit.value_cnt; i++) {
|
||||||
|
XP_FREE(name_array[i]);
|
||||||
|
XP_FREE(value_array[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* reject */
|
||||||
|
si_PutReject(URLName, buffer, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
reject = FALSE; /* reset reject flag */
|
||||||
|
XP_FREE(URLName);
|
||||||
|
KCReleaseItemRef( &itemRef );
|
||||||
|
|
||||||
|
status = KCFindNextItem( searchRef, &itemRef );
|
||||||
|
|
||||||
|
}
|
||||||
si_unlock_signon_list();
|
si_unlock_signon_list();
|
||||||
|
|
||||||
if (searchRef)
|
if (searchRef) {
|
||||||
KCReleaseSearchRef( &searchRef );
|
KCReleaseSearchRef( &searchRef );
|
||||||
|
}
|
||||||
|
|
||||||
/* Register a callback with the Keychain if we haven't already done so. */
|
/* Register a callback with the Keychain if we haven't already done so. */
|
||||||
|
|
||||||
if (si_kcUPP == NULL)
|
if (si_kcUPP == NULL)
|
||||||
{
|
{
|
||||||
si_kcUPP = NewKCCallbackProc( si_KeychainCallback );
|
si_kcUPP = NewKCCallbackProc( si_KeychainCallback );
|
||||||
if (!si_kcUPP)
|
if (!si_kcUPP) {
|
||||||
return memFullErr;
|
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 );
|
||||||
status = 0;
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
return (status);
|
if (status == errKCItemNotFound) {
|
||||||
|
status = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (status);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1473,8 +1472,9 @@ SI_LoadSignonData(char * filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APPLE_KEYCHAIN
|
#ifdef APPLE_KEYCHAIN
|
||||||
if (KeychainManagerAvailable())
|
if (KeychainManagerAvailable()) {
|
||||||
return si_LoadSignonDataFromKeychain();
|
return si_LoadSignonDataFromKeychain();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* open the signon file */
|
/* open the signon file */
|
||||||
@ -1618,104 +1618,126 @@ si_SaveSignonDataInKeychain() {
|
|||||||
KCItemFlags flags = kInvisibleKCItemFlag + kNegativeKCItemFlag;
|
KCItemFlags flags = kInvisibleKCItemFlag + kNegativeKCItemFlag;
|
||||||
uint32 actualLength;
|
uint32 actualLength;
|
||||||
|
|
||||||
/* save off the reject list */
|
/* save off the reject list */
|
||||||
if (si_reject_list) {
|
if (si_reject_list) {
|
||||||
list_ptr = si_reject_list;
|
list_ptr = si_reject_list;
|
||||||
while((reject = (si_Reject *) XP_ListNextObject(list_ptr))!=0) {
|
while((reject = (si_Reject *) XP_ListNextObject(list_ptr))!=0) {
|
||||||
status = kcaddinternetpassword( reject->URLName, nil, reject->userName, kAnyPort, kNetscapeProtocolType,
|
status = kcaddinternetpassword
|
||||||
kAnyAuthType, 0, nil, &itemRef );
|
(reject->URLName, nil,
|
||||||
if (status != noErr && status != errKCDuplicateItem)
|
reject->userName,
|
||||||
return(status);
|
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
|
||||||
|
*/
|
||||||
|
attr.tag = kFlagsKCItemAttr;
|
||||||
|
attr.data = &flags;
|
||||||
|
attr.length = sizeof( flags );
|
||||||
|
|
||||||
if (status == noErr)
|
status = KCSetAttribute( itemRef, &attr );
|
||||||
{
|
if (status != noErr) {
|
||||||
/* make the item invisible so the user doesn't see it and negative
|
return(status);
|
||||||
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)
|
|
||||||
return(status);
|
|
||||||
|
|
||||||
status = KCUpdateItem( itemRef );
|
|
||||||
if (status != noErr)
|
|
||||||
return(status);
|
|
||||||
|
|
||||||
KCReleaseItemRef( &itemRef );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
status = KCUpdateItem(itemRef);
|
||||||
|
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) {
|
||||||
|
|
||||||
/* save off the passwords */
|
user_ptr = URL->signonUser_list;
|
||||||
|
|
||||||
if((si_signon_list)) {
|
/* add each user node of the URL node */
|
||||||
list_ptr = si_signon_list;
|
while((user = (si_SignonUserStruct *) XP_ListNextObject(user_ptr)) != NULL) {
|
||||||
while((URL = (si_SignonURLStruct *) XP_ListNextObject(list_ptr)) != NULL) {
|
|
||||||
|
|
||||||
user_ptr = URL->signonUser_list;
|
data_ptr = user->signonData_list;
|
||||||
|
|
||||||
/* add each user node of the URL node */
|
/* write out each data node of the user node */
|
||||||
while((user = (si_SignonUserStruct *) XP_ListNextObject(user_ptr)) != NULL) {
|
while((data=(si_SignonDataStruct *) XP_ListNextObject(data_ptr)) != NULL) {
|
||||||
|
char* attribute = nil;
|
||||||
data_ptr = user->signonData_list;
|
if (data->isPassword) {
|
||||||
|
password = XP_ALLOC(XP_STRLEN(data->value) +
|
||||||
/* write out each data node of the user node */
|
XP_STRLEN(data->name) + 2);
|
||||||
while((data = (si_SignonDataStruct *) XP_ListNextObject(data_ptr)) != NULL) {
|
if (!password) {
|
||||||
char* attribute = nil;
|
return (-1);
|
||||||
if (data->isPassword)
|
}
|
||||||
{
|
attribute = password;
|
||||||
password = XP_ALLOC( XP_STRLEN(data->value) + XP_STRLEN(data->name) + 2);
|
} else {
|
||||||
if (!password)
|
account = XP_ALLOC( XP_STRLEN(data->value) +
|
||||||
return (-1);
|
XP_STRLEN(data->name) + 2);
|
||||||
attribute = password;
|
if (!account) {
|
||||||
}
|
XP_FREE(password);
|
||||||
else
|
return (-1);
|
||||||
{
|
}
|
||||||
account = XP_ALLOC( XP_STRLEN(data->value) + XP_STRLEN(data->name) + 2);
|
attribute = account;
|
||||||
if (!account)
|
|
||||||
{
|
|
||||||
XP_FREE(password);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
attribute = account;
|
|
||||||
}
|
|
||||||
|
|
||||||
XP_STRCPY( attribute, data->name );
|
|
||||||
XP_STRCAT( attribute, "=" );
|
|
||||||
XP_STRCAT( attribute, data->value );
|
|
||||||
|
|
||||||
}
|
|
||||||
/* 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 = KCSetData( itemRef, XP_STRLEN( password ), password );
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
if (account)
|
|
||||||
XP_FREE( account );
|
|
||||||
if (password)
|
|
||||||
XP_FREE( password );
|
|
||||||
account = password = nil;
|
|
||||||
|
|
||||||
if (status != noErr)
|
|
||||||
return(status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XP_STRCPY(attribute, data->name);
|
||||||
|
XP_STRCAT(attribute, "=");
|
||||||
|
XP_STRCAT(attribute, data->value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* 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 = KCSetData(itemRef, XP_STRLEN(password), password);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
if (account) {
|
||||||
|
XP_FREE(account);
|
||||||
|
}
|
||||||
|
if (password) {
|
||||||
|
XP_FREE(password);
|
||||||
|
}
|
||||||
|
account = password = nil;
|
||||||
|
if (status != noErr) {
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
si_signon_list_changed = FALSE;
|
si_signon_list_changed = FALSE;
|
||||||
return (0);
|
return (0);
|
||||||
@ -1753,8 +1775,9 @@ si_SaveSignonDataLocked(char * filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APPLE_KEYCHAIN
|
#ifdef APPLE_KEYCHAIN
|
||||||
if (KeychainManagerAvailable())
|
if (KeychainManagerAvailable()) {
|
||||||
return si_SaveSignonDataInKeychain();
|
return si_SaveSignonDataInKeychain();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* do nothing if we are unable to open file that contains signon list */
|
/* do nothing if we are unable to open file that contains signon list */
|
||||||
|
Loading…
Reference in New Issue
Block a user