From: Kent Sutherland Date: Wed, 9 Nov 2005 16:56:55 +0000 (+0000) Subject: Now removing items from the submission queue after success. X-Git-Tag: v1.6.5~20 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/d33e9b61891ddd4d4e70422f3f20c693d0ee030c Now removing items from the submission queue after success. Keychain update warning will now run at applictaion launch, instead of mid-execution. --- diff --git a/AudioscrobblerController.h b/AudioscrobblerController.h index 7daddea..ae0a20e 100644 --- a/AudioscrobblerController.h +++ b/AudioscrobblerController.h @@ -24,7 +24,7 @@ typedef enum { @interface AudioscrobblerController : NSObject { BOOL _handshakeCompleted; AudioscrobblerStatus _currentStatus; - NSMutableArray *_tracks; + NSMutableArray *_tracks, *_submitTracks; NSDate *_delayDate; NSString *_md5Challenge; diff --git a/AudioscrobblerController.m b/AudioscrobblerController.m index 6206ad8..552d949 100644 --- a/AudioscrobblerController.m +++ b/AudioscrobblerController.m @@ -54,6 +54,7 @@ static AudioscrobblerController *_sharedController = nil; _delayDate = nil; _responseData = nil; _tracks = [[NSMutableArray alloc] init]; + _submitTracks = [[NSMutableArray alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioscrobblerNotification:) name:nil object:self]; } return self; @@ -64,6 +65,7 @@ static AudioscrobblerController *_sharedController = nil; [_md5Challenge release]; [_postURL release]; [_responseData release]; + [_submitTracks release]; [_tracks release]; [super dealloc]; } @@ -185,6 +187,7 @@ static AudioscrobblerController *_sharedController = nil; trackString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[NSString stringWithFormat:@"&a[%i]=%@&t[%i]=%@&b[%i]=%@&m[%i]=&l[%i]=%@&i[%i]=%@", i, [nextTrack objectForKey:@"artist"], i, [nextTrack objectForKey:@"title"], i, [nextTrack objectForKey:@"album"], i, i, [nextTrack objectForKey:@"length"], i, [nextTrack objectForKey:@"time"]], NULL, NULL, kCFStringEncodingUTF8); [requestString appendString:trackString]; [trackString release]; + [_submitTracks addObject:nextTrack]; } //Create and send the request @@ -253,6 +256,8 @@ static AudioscrobblerController *_sharedController = nil; } } else if (_currentStatus == AudioscrobblerSubmittingTracksStatus) { if ([responseAction isEqualToString:@"OK"]) { + [_tracks removeObjectsInArray:_submitTracks]; + [_submitTracks removeAllObjects]; } else if ([responseAction isEqualToString:@"BADAUTH"]) { //Bad auth } else if (([responseAction length] > 5) && [[responseAction substringToIndex:5] isEqualToString:@"FAILED"]) { diff --git a/MainController.m b/MainController.m index 7a8c874..4994a7d 100755 --- a/MainController.m +++ b/MainController.m @@ -199,7 +199,9 @@ static MainController *sharedController; [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]]; if ([df boolForKey:@"audioscrobblerEnabled"]) { - [[AudioscrobblerController sharedController] attemptHandshake:NO]; + if ([PreferencesController getKeychainItemPasswordForUser:[df stringForKey:@"audioscrobblerUser"]] != nil) { + [[AudioscrobblerController sharedController] attemptHandshake:NO]; + } } [networkController startRemoteServerSearch]; diff --git a/PreferencesController.m b/PreferencesController.m index 6f8abfd..638be40 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -86,6 +86,10 @@ static PreferencesController *prefs = nil; SecKeychainAttribute attributes[3]; SecKeychainAttributeList list; + if ((user == nil) || ([user length] == 0)) { + return nil; + } + ITDebugLog(@"Audioscrobbler: Searching for keychain item for %@.", user); attributes[0].tag = kSecAccountItemAttr; attributes[0].data = (char *)[user UTF8String];