#import "ImportABCController.h"
#import "ImportProgressController.h"
#import "AppDelegate.h"
#import "Tune.h"

@implementation ImportABCController

-(void)viewDidLoad {
  [urlField setText:@"http://"];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return YES;
}

- (void)didReceiveMemoryWarning
{
	[super didReceiveMemoryWarning];
}

-(void)dealloc
{
	[super dealloc];
}

- (IBAction) onImport:(id)sender
{
  [urlField resignFirstResponder];

  ImportProgressController *controller = [[ImportProgressController alloc] initWithNibName:@"ImportProgress" bundle:nil];
  [self presentModalViewController:controller animated:YES];
  NSURL *url = [NSURL URLWithString:urlField.text];
  [controller import:url];
}

#pragma mark UIViewController delegate methods

- (void)viewWillAppear:(BOOL)animated
{
}

#pragma mark UITextField delegate methods

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
  [theTextField resignFirstResponder];
  if ( theTextField == urlField )
    [self onImport:self];
  return YES;
}

@end
