Make the keychain interface in MacOSX compile and work.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19182 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Mike Alexander 2010-05-19 20:27:12 +00:00
parent f796e05b2f
commit 3bcf2f9264
2 changed files with 28 additions and 27 deletions

View File

@ -230,9 +230,9 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
*/
g_return_val_if_fail( hostname != 0, NULL );
if ( username != NULL )
if ( username != NULL && *username )
{
if ( password != NULL )
if ( password != NULL && *password )
userpass = g_strdup_printf ( "%s:%s@", username, password );
else
userpass = g_strdup_printf ( "%s@", username );

View File

@ -147,6 +147,8 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent,
* So we use the security domain parameter to allow us to
* distinguish between these two.
*/
if (*user != NULL)
{
status = SecKeychainFindInternetPassword( NULL,
strlen(server), server,
strlen(access_method), access_method,
@ -160,9 +162,7 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent,
if ( status == noErr )
{
*password = (gchar*)xmalloc(( password_length + 1 ) * sizeof(char));
strncpy(*password, password_data, (size_t)password_length);
(*password)[password_length] = '\0';
*password = g_strndup(password_data, password_length);
password_found = TRUE;
SecKeychainItemFreeContent(NULL, password_data);
}
@ -174,6 +174,7 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent,
PWARN ( "OS X keychain error: %s", resultstring );
CFRelease ( osx_resultstring );
}
}
#endif /* HAVE_OSX_KEYCHAIN */
if ( !password_found )