Ignore:
Timestamp:
Nov 25, 2009, 4:11:52 AM (13 years ago)
Author:
livings124
Message:

start laying a little magnet link groundwork, and remove redundant torrent parse when creating torrent objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r9453 r9561  
    934934}
    935935
     936- (void) openMagnet: (NSString *) address
     937{
     938    Torrent * torrent;
     939    if (!(torrent = [[Torrent alloc] initWithMagnetAddress: address location: nil lib: fLib]))
     940    {
     941        #warning should we do something here?
     942        return;
     943    }
     944   
     945    #warning should we do this?
     946    [torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
     947   
     948    [torrent update];
     949    [fTorrents addObject: torrent];
     950    [torrent release];
     951
     952    [self updateTorrentsInQueue];
     953}
     954
    936955- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
    937956{
     
    11111130   
    11121131    NSString * urlString = [fURLSheetTextField stringValue];
    1113     if ([urlString rangeOfString: @"://"].location == NSNotFound)
    1114     {
    1115         if ([urlString rangeOfString: @"."].location == NSNotFound)
    1116         {
    1117             NSInteger beforeCom;
    1118             if ((beforeCom = [urlString rangeOfString: @"/"].location) != NSNotFound)
    1119                 urlString = [NSString stringWithFormat: @"http://www.%@.com/%@",
    1120                                 [urlString substringToIndex: beforeCom],
    1121                                 [urlString substringFromIndex: beforeCom + 1]];
     1132   
     1133    if ([urlString compare: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)])
     1134        [self openMagnet: urlString];
     1135    else
     1136    {
     1137        if ([urlString rangeOfString: @"://"].location == NSNotFound)
     1138        {
     1139            if ([urlString rangeOfString: @"."].location == NSNotFound)
     1140            {
     1141                NSInteger beforeCom;
     1142                if ((beforeCom = [urlString rangeOfString: @"/"].location) != NSNotFound)
     1143                    urlString = [NSString stringWithFormat: @"http://www.%@.com/%@",
     1144                                    [urlString substringToIndex: beforeCom],
     1145                                    [urlString substringFromIndex: beforeCom + 1]];
     1146                else
     1147                    urlString = [NSString stringWithFormat: @"http://www.%@.com/", urlString];
     1148            }
    11221149            else
    1123                 urlString = [NSString stringWithFormat: @"http://www.%@.com/", urlString];
    1124         }
     1150                urlString = [@"http://" stringByAppendingString: urlString];
     1151        }
     1152       
     1153       
    11251154        else
    1126             urlString = [@"http://" stringByAppendingString: urlString];
    1127     }
    1128    
    1129     NSURL * url = [NSURL URLWithString: urlString];
    1130     [self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
     1155        {
     1156            NSURL * url = [NSURL URLWithString: urlString];
     1157            [self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
     1158        }
     1159    }
    11311160}
    11321161
Note: See TracChangeset for help on using the changeset viewer.