Added audioscrobbler to the preferences. Haven't hooked it up to the keychain yet.
authorKent Sutherland <ksuther@ithinksw.com>
Mon, 7 Nov 2005 04:15:33 +0000 (04:15 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Mon, 7 Nov 2005 04:15:33 +0000 (04:15 +0000)
AudioscrobblerController.m
English.lproj/Preferences.nib/info.nib
English.lproj/Preferences.nib/keyedobjects.nib
MenuTunes.xcodeproj/project.pbxproj
PreferencesController.h
PreferencesController.m

index 62653ba..32cb718 100644 (file)
@@ -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;
                
index e50d6ba..33225c9 100755 (executable)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>34 75 356 240 0 0 1152 746 </string>
+       <string>19 60 356 240 0 0 1152 746 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>634</key>
        <array>
                <integer>281</integer>
        </array>
+       <key>IBLockedTabItems</key>
+       <array>
+               <integer>46</integer>
+       </array>
        <key>IBOpenObjects</key>
        <array>
                <integer>6</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8C46</string>
+       <string>8F46</string>
 </dict>
 </plist>
index 338c636..1ffd1ec 100755 (executable)
Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ
index 42f494a..64d5c64 100755 (executable)
@@ -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 */; };
                3740716C05ACE20500CC2142 /* libValidate.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libValidate.a; sourceTree = "<group>"; };
                3798C6B4091874600004C420 /* AudioscrobblerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioscrobblerController.h; sourceTree = "<group>"; };
                3798C6B5091874600004C420 /* AudioscrobblerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioscrobblerController.m; sourceTree = "<group>"; };
+               37A1EBDA091F07F700C2CE55 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
                37B7EA0306AECF0700A4DE86 /* ChasingArrow.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ChasingArrow.tiff; sourceTree = "<group>"; };
                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; };
                                7C95A0E905A92B0700B4F576 /* libcrypto.dylib in Frameworks */,
                                7C95A0F005A92B4800B4F576 /* Carbon.framework in Frameworks */,
                                3740716D05ACE20500CC2142 /* libValidate.a in Frameworks */,
+                               37A1EBDB091F07F700C2CE55 /* Security.framework in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        children = (
                                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
                                7C95A0EF05A92B4800B4F576 /* Carbon.framework */,
+                               37A1EBDA091F07F700C2CE55 /* Security.framework */,
                                3740716C05ACE20500CC2142 /* libValidate.a */,
                                7C95A0E805A92B0700B4F576 /* libcrypto.dylib */,
                        );
index aa4c1c6..ca1a1f5 100755 (executable)
     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;
index 02ba0a0..139872a 100755 (executable)
@@ -7,6 +7,8 @@
 #import "StatusWindowController.h"
 #import "CustomMenuTableView.h"
 
+#import <Security/Security.h>
+
 #import <netinet/in.h>
 #import <arpa/inet.h>
 #import <openssl/sha.h>
@@ -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"];