#import <UIKit/UIKit.h>
#import "TuneParser.h"

@class Tune;

@interface ImportProgressController : UIViewController <TuneParserDelegate>
{
  NSURL *_url;
  NSURLConnection *urlConnection;
  long bytesRead;
  long bytesProcessed;
  long bytesToRead;
  BOOL lastWasCR;
  int numTunes;
  BOOL cancelled;
  BOOL finished;
  BOOL animateDismiss;
  NSInteger statusCode;
  TuneParser *parser;
  NSMutableArray *parsedTunes;
  NSMutableString *fragment;
  NSURLRequest *_request;

  IBOutlet UIButton *cancelButton;
  IBOutlet UIProgressView *progressView;
  IBOutlet UILabel *activityLabel;
  IBOutlet UILabel *statusLabel;
  IBOutlet UILabel *titleLabel;
}

- (void) viewDidLoad;

- (void) import:(NSURL *)url;
- (void) import:(NSURL *)url animateDismiss:(BOOL)animate;
- (void) importRequest:(NSURLRequest *)request;

- (IBAction) onCancel:(id)sender;

- (void) threadRun:(id)sender;
- (void) updateProgress:(id)sender;

- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
- (NSCachedURLResponse *) connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse;
- (void) connectionDidFinishLoading:(NSURLConnection *)connection;

- (void) parsedTune:(TuneParser *)parser tune:(Tune *)tune;
- (void) finishedImport:(id)sender;

@end
