+ ITDebugLog(@"Audioscrobbler: Handshake failed, protocol error");
+ key = @"audioscrobbler_protocol_error";
+ comment = @"Internal protocol error";
+ //We have a protocol error
+ }
+ } else if (_currentStatus == AudioscrobblerSubmittingTracksStatus) {
+ if ([responseAction isEqualToString:@"OK"]) {
+ ITDebugLog(@"Audioscrobbler: Submission successful, clearing queue.");
+ /*[_tracks removeObjectsInArray:_submitTracks];
+ [_submitTracks removeAllObjects];*/
+ [_submitTracks removeAllObjects];
+ if ([_tracks count] > 0) {
+ ITDebugLog(@"Audioscrobbler: Tracks remaining in queue, submitting remaining tracks");
+ [self performSelector:@selector(submitTracks) withObject:nil afterDelay:2];
+ }
+ key = @"audioscrobbler_submission_ok";
+ comment = @"Last track submission successful";
+ } else if ([responseAction isEqualToString:@"BADAUTH"]) {
+ ITDebugLog(@"Audioscrobbler: Bad password");
+ key = @"audioscrobbler_bad_password";
+ comment = @"Last track submission failed - invalid password";
+ //Bad auth
+
+ //Add the tracks we were trying to submit back into the submission queue
+ [_tracks addObjectsFromArray:_submitTracks];
+
+ _handshakeCompleted = NO;
+
+ //If we were previously valid with the same login name, try reauthenticating and sending again
+ [self attemptHandshake:YES];
+ } else if (([responseAction length] > 5) && [[responseAction substringToIndex:5] isEqualToString:@"FAILED"]) {
+ ITDebugLog(@"Audioscrobbler: Submission failed (%@)", [responseAction substringFromIndex:6]);
+ key = @"audioscrobbler_submission_failed";
+ comment = @"Last track submission failed - see console for error";
+ //Failed
+
+ //We got an unknown error. To be safe we're going to remove the tracks we tried to submit
+ [_submitTracks removeAllObjects];
+
+ _handshakeCompleted = NO;