Attempting to get the MobileMe password in MailMe. If successful, fixes #105. maintenance-1.2
authorPeter Hosey <hg@boredzo.org>
Thu Mar 10 22:01:03 2011 -0800 (2011-03-10)
branchmaintenance-1.2
changeset 46778da49fce81c3
parent 4676 0af179d7ec7a
child 4678 18c0b5b4a8d5
Attempting to get the MobileMe password in MailMe. If successful, fixes #105.
Plugins/Displays/MailMe/GrowlMailMeDisplay.m
     1.1 --- a/Plugins/Displays/MailMe/GrowlMailMeDisplay.m	Thu Mar 10 20:38:12 2011 -0800
     1.2 +++ b/Plugins/Displays/MailMe/GrowlMailMeDisplay.m	Thu Mar 10 22:01:03 2011 -0800
     1.3 @@ -105,8 +105,24 @@
     1.4  				kSecProtocolTypeSMTP, kSecAuthenticationTypeAny,
     1.5  				&passwordLength, &passwordBytes,
     1.6  				/*itemRef*/ NULL);
     1.7 +
     1.8  			if (err != noErr) {
     1.9 -				NSLog(@"MailMe: Could not get password for SMTP account %@: %i/%s", userAtHostPort, (int)err, GetMacOSStatusCommentString(err));
    1.10 +				//Try looking it up as a MobileMe account.
    1.11 +				NSMutableArray *usernameComponents = [[[username componentsSeparatedByString:@"@"] mutableCopy] autorelease];
    1.12 +				[usernameComponents removeLastObject];
    1.13 +				username = [usernameComponents componentsJoinedByString:@"@"];
    1.14 +
    1.15 +				NSString *serviceName = @"iTools";
    1.16 +
    1.17 +				err = SecKeychainFindGenericPassword(/*keychainOrArray*/ NULL,
    1.18 +					(UInt32)[serviceName length], [serviceName UTF8String],
    1.19 +					(UInt32)[username length],    [username UTF8String],
    1.20 +					&passwordLength,              &passwordBytes,
    1.21 +					/*itemRef*/ NULL);
    1.22 +
    1.23 +				if (err != noErr) {
    1.24 +					NSLog(@"MailMe: Could not get password for SMTP account %@: %i/%s", userAtHostPort, (int)err, GetMacOSStatusCommentString(err));
    1.25 +				}
    1.26  			} else {
    1.27  				NSData *passwordData = [NSData dataWithBytesNoCopy:passwordBytes length:passwordLength freeWhenDone:NO];
    1.28