/* Fetches a bunch of links from any web page. Use the delegate methods to receive feedback.
   Written by Håkan Waara (hakan@konstochvanligasaker.se), June 2007. 
   
   You may only use LinkScraper under the terms of the GPLv2 license. 
   See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
   
   Get the latest version (using Subversion or your favorite web browser) at 
   http://svn.konstochvanligasaker.se/general
   
   TODO: Make it support authentication
         More advanced filtering (regexps?)
*/

#import <Cocoa/Cocoa.h>

@interface LinkScraper : NSObject
{
  id delegate;

  // NSURLDownload objects
  NSMutableArray *downloadObjects;
  
  // NSValue(NSURLDownload) => paths to where they're saved
  NSMutableDictionary *downloadPointersToSavePaths;
  
  // for example, ".html", for only HTML-links.
  NSString *suffixFilter;
}

- (id)init;
- (id)initWithURL:(NSString *)url delegate:(id)delegate;

- (void)scrapeURL:(NSString *)url;
- (void)setSuffixFilter:(NSString *)filter;

- (void)setDelegate:(id)delegate;

@end

/* LinkScraper delegate methods */
@interface NSObject(LinkScraperDelegate)

// Something went wrong.
- (void)linkScraperDidFail:(LinkScraper *)scraper;

// The link scraping is done!
- (void)linkScraperDidFinish:(LinkScraper *)scraper links:(NSDictionary *)links;

@end
