Changeset 5993


Ignore:
Timestamp:
Jun 2, 2008, 1:55:15 AM (14 years ago)
Author:
livings124
Message:

allow torrents with no announce address to be created again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/CreatorWindowController.m

    r5992 r5993  
    299299- (void) createReal
    300300{
    301     [fTracker release]; //incase a previous create was aborted
    302     fTracker = [[fTrackerField stringValue] retain];
    303    
    304     //parse non-empty tracker strings
    305     if (![fTracker isEqualToString: @""])
    306     {
    307         if ([fTracker rangeOfString: @"://"].location == NSNotFound)
    308         {
    309             NSString * fullTracker = [@"http://" stringByAppendingString: fTracker];
    310             [fTracker release];
    311             fTracker = [fullTracker retain];
    312         }
    313        
    314         if (!tr_httpIsValidURL([fTracker UTF8String]))
    315         {
    316             NSAlert * alert = [[[NSAlert alloc] init] autorelease];
    317             [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
    318             [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
    319                                                         "Create torrent -> warning -> info")];
    320             [alert setAlertStyle: NSWarningAlertStyle];
    321            
    322             //check common reasons for failure
    323             NSString * prefix = [fTracker substringToIndex: [fTracker rangeOfString: @"://"].location];
    324             if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
    325                 [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
    326                                                         "Create torrent -> warning -> message")];
    327             else
    328                 [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
    329            
    330             [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
    331             return;
    332         }
    333     }
    334    
    335301    //check if a file with the same name and location already exists
    336302    if ([[NSFileManager defaultManager] fileExistsAtPath: fLocation])
     
    354320    }
    355321   
     322    [fTracker release]; //incase a previous create was aborted
     323    fTracker = [[fTrackerField stringValue] retain];
     324   
     325    //parse non-empty tracker strings
     326    tr_tracker_info trackerInfo;
     327    BOOL isTracker = NO;
     328    if (![fTracker isEqualToString: @""])
     329    {
     330        isTracker = YES;
     331        if ([fTracker rangeOfString: @"://"].location == NSNotFound)
     332        {
     333            NSString * fullTracker = [@"http://" stringByAppendingString: fTracker];
     334            [fTracker release];
     335            fTracker = [fullTracker retain];
     336        }
     337       
     338        if (!tr_httpIsValidURL([fTracker UTF8String]))
     339        {
     340            NSAlert * alert = [[[NSAlert alloc] init] autorelease];
     341            [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
     342            [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
     343                                                        "Create torrent -> warning -> info")];
     344            [alert setAlertStyle: NSWarningAlertStyle];
     345           
     346            //check common reasons for failure
     347            NSString * prefix = [fTracker substringToIndex: [fTracker rangeOfString: @"://"].location];
     348            if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
     349                [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
     350                                                        "Create torrent -> warning -> message")];
     351            else
     352                [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
     353           
     354            [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
     355            return;
     356        }
     357       
     358        trackerInfo.tier = 0;
     359        trackerInfo.announce = (char *)[fTracker UTF8String];
     360    }
     361   
    356362    //store values
    357363    [fDefaults setObject: fTracker forKey: @"CreatorTracker"];
     
    360366    [fDefaults setObject: [fLocation stringByDeletingLastPathComponent] forKey: @"CreatorLocation"];
    361367   
    362     #warning perhaps don't create at all if no trackers
    363     //create tracker
    364     tr_tracker_info trackerInfo;
    365     trackerInfo.tier = 0;
    366     trackerInfo.announce = (char *)[fTracker UTF8String];
    367    
    368368    [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
    369     tr_makeMetaInfo(fInfo, [fLocation UTF8String], &trackerInfo, 1, [[fCommentView string] UTF8String],
     369    tr_makeMetaInfo(fInfo, [fLocation UTF8String], &trackerInfo, isTracker ? 1 : 0, [[fCommentView string] UTF8String],
    370370                    [fPrivateCheck state] == NSOnState);
    371371   
Note: See TracChangeset for help on using the changeset viewer.