tr_sessionSetRPCCallback(fLib, rpcCallback, self);
+ //register for dock icon drags
+ [[NSAppleEventManager sharedAppleEventManager] setEventHandler: self andSelector: @selector(handleOpenContentsEvent:replyEvent:)
+ forEventClass: kCoreEventClass andEventID: kAEOpenContents];
+
+ //register for magnet URLs
+ [[NSAppleEventManager sharedAppleEventManager] setEventHandler: self andSelector: @selector(handleOpenContentsEvent:replyEvent:)
+ forEventClass: kInternetEventClass andEventID: kAEGetURL];
+
[GrowlApplicationBridge setGrowlDelegate: self];
[[UKKQueue sharedFileWatcher] setDelegate: self];
{
[NSApp setServicesProvider: self];
- //register for dock icon drags
- [[NSAppleEventManager sharedAppleEventManager] setEventHandler: self andSelector: @selector(handleOpenContentsEvent:replyEvent:)
- forEventClass: kCoreEventClass andEventID: kAEOpenContents];
-
//auto importing
[self checkAutoImportDirectory];
urlString = [directObject stringValue];
if (urlString)
- [self openURL: [NSURL URLWithString: urlString]];
+ [self openURL: urlString];
}
- (void) download: (NSURLDownload *) download decideDestinationWithSuggestedFilename: (NSString *) suggestedName
[alert release];
}
-- (void) openURL: (NSURL *) url
+- (void) openURL: (NSString *) urlString
{
- [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url] delegate: self];
+ if ([urlString rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
+ [self openMagnet: urlString];
+ else
+ {
+ if ([urlString rangeOfString: @"://"].location == NSNotFound)
+ {
+ if ([urlString rangeOfString: @"."].location == NSNotFound)
+ {
+ NSInteger beforeCom;
+ if ((beforeCom = [urlString rangeOfString: @"/"].location) != NSNotFound)
+ urlString = [NSString stringWithFormat: @"http://www.%@.com/%@",
+ [urlString substringToIndex: beforeCom],
+ [urlString substringFromIndex: beforeCom + 1]];
+ else
+ urlString = [NSString stringWithFormat: @"http://www.%@.com/", urlString];
+ }
+ else
+ urlString = [@"http://" stringByAppendingString: urlString];
+ }
+
+ NSURL * url = [NSURL URLWithString: urlString];
+ [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url] delegate: self];
+ }
}
- (void) openURLShowSheet: (id) sender
return;
NSString * urlString = [fURLSheetTextField stringValue];
-
- if ([urlString rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
- [self openMagnet: urlString];
- else
- {
- if ([urlString rangeOfString: @"://"].location == NSNotFound)
- {
- if ([urlString rangeOfString: @"."].location == NSNotFound)
- {
- NSInteger beforeCom;
- if ((beforeCom = [urlString rangeOfString: @"/"].location) != NSNotFound)
- urlString = [NSString stringWithFormat: @"http://www.%@.com/%@",
- [urlString substringToIndex: beforeCom],
- [urlString substringFromIndex: beforeCom + 1]];
- else
- urlString = [NSString stringWithFormat: @"http://www.%@.com/", urlString];
- }
- else
- urlString = [@"http://" stringByAppendingString: urlString];
- }
-
- NSURL * url = [NSURL URLWithString: urlString];
- [self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
- }
+ [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
}
- (void) createFile: (id) sender
NSURL * url;
if ((url = [NSURL URLFromPasteboard: pasteboard]))
{
- [self openURL: url];
+ [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url] delegate: self];
return YES;
}
}