From d7c39a05d1ea7368700d2140c7f042cc72cf0d0d Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Mon, 26 Dec 2005 05:04:13 +0000 Subject: [PATCH] Putting stars back in to the hotkey prefs. Fixed a small audioscrobbler bug in MainController. Audioscrobbler keychain item uses a new format (Audioscrobbler: account) Debug logs to figure out why Joe's computer sucks with MenuTunes --- MainController.m | 2 +- PreferencesController.m | 51 ++++++++++++++--------------------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/MainController.m b/MainController.m index 8a6144e..294e52c 100755 --- a/MainController.m +++ b/MainController.m @@ -631,7 +631,7 @@ static MainController *sharedController; { ITDebugLog(@"Audioscrobbler: Attempting to submit current track"); [timer invalidate]; - if ([df boolForKey:@"audioscrobblerEnabled"] && [[AudioscrobblerController sharedController] handshakeCompleted]) { + if ([df boolForKey:@"audioscrobblerEnabled"]) { NS_DURING int elapsed = [[self currentRemote] currentSongPlayed], length = [[self currentRemote] currentSongDuration], requiredInterval = ((length / 2 < 240) ? length / 2 : 240); if ((abs(elapsed - requiredInterval) < 5) && ([[self currentRemote] playerPlayingState] == ITMTRemotePlayerPlaying)) { diff --git a/PreferencesController.m b/PreferencesController.m index f7598cb..612faf9 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -16,25 +16,11 @@ #import #import -#import - -#import -#import -#import -#import -#import - +#import #import -#import -#import -#import -#import -#import -#import - #define SENDER_STATE (([sender state] == NSOnState) ? YES : NO) -#define AUDIOSCROBBLER_KEYCHAIN_SERVICE "MenuTunes: Audioscrobbler" +#define AUDIOSCROBBLER_KEYCHAIN_SERVICE(user) [NSString stringWithFormat:@"Audioscrobbler: %@", user] #define AUDIOSCROBBLER_KEYCHAIN_KIND "application password" /*************************************************************************/ @@ -98,8 +84,8 @@ static PreferencesController *prefs = nil; attributes[1].data = AUDIOSCROBBLER_KEYCHAIN_KIND; attributes[1].length = strlen(AUDIOSCROBBLER_KEYCHAIN_KIND); attributes[2].tag = kSecLabelItemAttr; - attributes[2].data = AUDIOSCROBBLER_KEYCHAIN_SERVICE; - attributes[2].length = strlen(AUDIOSCROBBLER_KEYCHAIN_SERVICE); + attributes[2].data = AUDIOSCROBBLER_KEYCHAIN_SERVICE(user); + attributes[2].length = [AUDIOSCROBBLER_KEYCHAIN_SERVICE(user) length]; list.count = 3; list.attr = attributes; @@ -145,8 +131,8 @@ static PreferencesController *prefs = nil; attributes[1].data = AUDIOSCROBBLER_KEYCHAIN_KIND; attributes[1].length = strlen(AUDIOSCROBBLER_KEYCHAIN_KIND); attributes[2].tag = kSecLabelItemAttr; - attributes[2].data = AUDIOSCROBBLER_KEYCHAIN_SERVICE; - attributes[2].length = strlen(AUDIOSCROBBLER_KEYCHAIN_SERVICE); + attributes[2].data = AUDIOSCROBBLER_KEYCHAIN_SERVICE(user); + attributes[2].length = [AUDIOSCROBBLER_KEYCHAIN_SERVICE(user) length]; list.count = 3; list.attr = attributes; @@ -176,7 +162,7 @@ static PreferencesController *prefs = nil; OSStatus status = errSecNotAvailable; SecKeychainItemRef item = [PreferencesController keychainItemForUser:user]; if (item != nil) { - status = SecKeychainItemModifyContent(item, NULL, [password length], [password cString]); + status = SecKeychainItemModifyContent(item, NULL, [password length], [password UTF8String]); if (status != noErr) { ITDebugLog(@"Audioscrobbler: Error deleting keychain item: %i", status); } @@ -197,18 +183,15 @@ static PreferencesController *prefs = nil; if (status != noErr) { ITDebugLog(@"Audioscrobbler: Error getting keychain item password: %i", status); } else { - if ([NSString respondsToSelector:@selector(stringWithCString:encoding:)]) { - pass = [NSString stringWithCString:buffer encoding:NSASCIIStringEncoding]; - } else { - pass = [NSString stringWithCString:buffer]; - } + NSLog(@"Audioscrobbler: password buffer: \"%s\" \"Length: %i\"", buffer, length); + pass = [NSString stringWithUTF8String:buffer]; } if (status != noErr) { ITDebugLog(@"Audioscrobbler: Error deleting keychain item: %i", status); } CFRelease(item); } - NSLog(@"Audioscrobbler: Retrieved password: %@", pass); + NSLog(@"Audioscrobbler: Retrieved password: \"%@\"", pass); return pass; } @@ -275,12 +258,12 @@ static PreferencesController *prefs = nil; @"Toggle Loop", @"Toggle Song Included In Shuffle", @"Pop-up status menu", - [NSString stringWithUTF8String:"Set Rating: ‚òÜ‚òÜ‚òÜ‚òÜ‚òÜ"], - [NSString stringWithUTF8String:"Set Rating: ‚òÖ‚òÜ‚òÜ‚òÜ‚òÜ"], - [NSString stringWithUTF8String:"Set Rating: ‚òÖ‚òÖ‚òÜ‚òÜ‚òÜ"], - [NSString stringWithUTF8String:"Set Rating: ‚òÖ‚òÖ‚òÖ‚òÜ‚òÜ"], - [NSString stringWithUTF8String:"Set Rating: ‚òÖ‚òÖ‚òÖ‚òÖ‚òÜ"], - [NSString stringWithUTF8String:"Set Rating: ‚òÖ‚òÖ‚òÖ‚òÖ‚òÖ"], + [NSString stringWithUTF8String:"Set Rating: ☆☆☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★☆☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★☆☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★☆☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★★☆"], + [NSString stringWithUTF8String:"Set Rating: ★★★★"], nil]; hotKeysDictionary = [[NSMutableDictionary alloc] init]; controller = nil; @@ -421,7 +404,7 @@ static PreferencesController *prefs = nil; [showScriptsButton setEnabled:NO]; } } else if ( [sender tag] == 1120) { - mkdir([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] cString], 0744); + mkdir([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] UTF8String], 0744); [[NSWorkspace sharedWorkspace] openFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]]; } else if ( [sender tag] == 6010) { //Toggle the other Audioscrobbler options -- 2.20.1