From: Kent Sutherland Date: Mon, 7 Nov 2005 04:15:33 +0000 (+0000) Subject: Added audioscrobbler to the preferences. Haven't hooked it up to the keychain yet. X-Git-Tag: v1.6.5~27 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/a9dfa3e5705fdde676dce25d2c463d08cdb90a0e Added audioscrobbler to the preferences. Haven't hooked it up to the keychain yet. --- diff --git a/AudioscrobblerController.m b/AudioscrobblerController.m index 62653ba..32cb718 100644 --- a/AudioscrobblerController.m +++ b/AudioscrobblerController.m @@ -121,7 +121,7 @@ static AudioscrobblerController *_sharedController = nil; int i; NSMutableString *requestString; - NSString *authString, *responseHash; + NSString *authString, *responseHash = @""; char *pass = "waffles"; unsigned char *buffer; EVP_MD_CTX ctx; @@ -166,7 +166,7 @@ static AudioscrobblerController *_sharedController = nil; [authString release]; //We can only submit ten tracks at a time - for (i = 0; ([_tracks count] > 0) && (i < 10); i++) { + for (i = 0; (i < [_tracks count]) && (i < 10); i++) { NSDictionary *nextTrack = [_tracks objectAtIndex:i]; NSString *trackString; diff --git a/English.lproj/Preferences.nib/info.nib b/English.lproj/Preferences.nib/info.nib index e50d6ba..33225c9 100755 --- a/English.lproj/Preferences.nib/info.nib +++ b/English.lproj/Preferences.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 34 75 356 240 0 0 1152 746 + 19 60 356 240 0 0 1152 746 IBEditorPositions 634 @@ -17,11 +17,15 @@ 281 + IBLockedTabItems + + 46 + IBOpenObjects 6 IBSystem Version - 8C46 + 8F46 diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index 338c636..1ffd1ec 100755 Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/MenuTunes.xcodeproj/project.pbxproj b/MenuTunes.xcodeproj/project.pbxproj index 42f494a..64d5c64 100755 --- a/MenuTunes.xcodeproj/project.pbxproj +++ b/MenuTunes.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 3740716D05ACE20500CC2142 /* libValidate.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3740716C05ACE20500CC2142 /* libValidate.a */; }; 3798C6B6091874600004C420 /* AudioscrobblerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3798C6B4091874600004C420 /* AudioscrobblerController.h */; }; 3798C6B7091874600004C420 /* AudioscrobblerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3798C6B5091874600004C420 /* AudioscrobblerController.m */; }; + 37A1EBDB091F07F700C2CE55 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37A1EBDA091F07F700C2CE55 /* Security.framework */; }; 37B7EA0406AECF0700A4DE86 /* ChasingArrow.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 37B7EA0306AECF0700A4DE86 /* ChasingArrow.tiff */; }; 37CB20230753EE1E00BB0E46 /* StatusWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7C331FB305A922210088905B /* StatusWindowController.m */; }; 7C331F8F05A921AC0088905B /* MenuTunes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C331F8D05A921AC0088905B /* MenuTunes.h */; }; @@ -216,6 +217,7 @@ 3740716C05ACE20500CC2142 /* libValidate.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libValidate.a; sourceTree = ""; }; 3798C6B4091874600004C420 /* AudioscrobblerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioscrobblerController.h; sourceTree = ""; }; 3798C6B5091874600004C420 /* AudioscrobblerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioscrobblerController.m; sourceTree = ""; }; + 37A1EBDA091F07F700C2CE55 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; 37B7EA0306AECF0700A4DE86 /* ChasingArrow.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ChasingArrow.tiff; sourceTree = ""; }; 7C331F6805A918EC0088905B /* ITMTRemote.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ITMTRemote.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7C331F6905A918EC0088905B /* ITMTRemote-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "ITMTRemote-Info.plist"; sourceTree = SOURCE_ROOT; }; @@ -314,6 +316,7 @@ 7C95A0E905A92B0700B4F576 /* libcrypto.dylib in Frameworks */, 7C95A0F005A92B4800B4F576 /* Carbon.framework in Frameworks */, 3740716D05ACE20500CC2142 /* libValidate.a in Frameworks */, + 37A1EBDB091F07F700C2CE55 /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -366,6 +369,7 @@ children = ( 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, 7C95A0EF05A92B4800B4F576 /* Carbon.framework */, + 37A1EBDA091F07F700C2CE55 /* Security.framework */, 3740716C05ACE20500CC2142 /* libValidate.a */, 7C95A0E805A92B0700B4F576 /* libcrypto.dylib */, ); diff --git a/PreferencesController.h b/PreferencesController.h index aa4c1c6..ca1a1f5 100755 --- a/PreferencesController.h +++ b/PreferencesController.h @@ -24,6 +24,10 @@ IBOutlet NSPopUpButton *appearanceEffectPopup; IBOutlet NSSlider *appearanceSpeedSlider; IBOutlet NSButton *artistCheckbox; + IBOutlet NSButton *audioscrobblerEnabledCheckbox; + IBOutlet NSTextField *audioscrobblerPasswordTextField; + IBOutlet NSButton *audioscrobblerUseCacheCheckbox; + IBOutlet NSTextField *audioscrobblerUserTextField; IBOutlet NSPopUpButton *backgroundStylePopup; IBOutlet NSColorWell *backgroundColorWell; IBOutlet NSPopUpButton *backgroundColorPopup; diff --git a/PreferencesController.m b/PreferencesController.m index 02ba0a0..139872a 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -7,6 +7,8 @@ #import "StatusWindowController.h" #import "CustomMenuTableView.h" +#import + #import #import #import @@ -272,7 +274,31 @@ static PreferencesController *prefs = nil; } else if ( [sender tag] == 1120) { mkdir([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] cString], 0744); [[NSWorkspace sharedWorkspace] openFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]]; - } + } else if ( [sender tag] == 6010) { + //Toggle the other Audioscrobbler options + [df setBool:SENDER_STATE forKey:@"audioscrobblerEnabled"]; + [audioscrobblerUseCacheCheckbox setEnabled:SENDER_STATE]; + [audioscrobblerUserTextField setEnabled:SENDER_STATE]; + [audioscrobblerPasswordTextField setEnabled:SENDER_STATE]; + } else if ( [sender tag ] == 6015) { + [df setString:[sender stringValue] forKey:@"audioscrobblerUser"]; + } else if ( [sender tag ] == 6030) { + //Set the password in the keychain + char *service = "Audioscrobbler"; + NSString *account = [df stringForKey:@"audioscrobblerUser"]; + SecKeychainItemRef item; + OSStatus status = SecKeychainFindGenericPassword(NULL, strlen(service), service, [account length], [account UTF8String], NULL, NULL, &item); + if (status == errSecItemNotFound) { + //Create the keychain + } else if (status == noErr) { + //Modify the current item + //SecKeychainItemFreeContent(NULL, item); + } else { + ITDebugLog(@"Audioscrobbler: Unable to retrieve keychain password."); + } + } else if ( [sender tag] == 6045) { + [df setBool:SENDER_STATE forKey:@"audioscrobblerCacheSubmissions"]; + } [df synchronize]; } @@ -910,6 +936,22 @@ static PreferencesController *prefs = nil; [selectSharedPlayerButton setEnabled:YES]; } + //Setup the Audioscrobbler controls + if ([df boolForKey:@"audioscrobblerEnabled"]) { + [audioscrobblerEnabledCheckbox setState:NSOnState]; + [audioscrobblerUserTextField setEnabled:YES]; + [audioscrobblerPasswordTextField setEnabled:YES]; + [audioscrobblerUseCacheCheckbox setEnabled:YES]; + } else { + [audioscrobblerUserTextField setEnabled:NO]; + [audioscrobblerPasswordTextField setEnabled:NO]; + [audioscrobblerUseCacheCheckbox setEnabled:NO]; + } + [audioscrobblerUserTextField setStringValue:[df stringForKey:@"audioscrobblerUser"]]; + if ([[audioscrobblerUserTextField stringValue] length] > 0) { + [audioscrobblerPasswordTextField setStringValue:@"******"]; + } + [[NSNotificationCenter defaultCenter] addObserver:sharingTableView selector:@selector(reloadData) name:@"ITMTFoundNetService" object:nil]; serverName = [df stringForKey:@"sharedPlayerName"];