Changeset 5960


Ignore:
Timestamp:
May 28, 2008, 11:57:25 PM (14 years ago)
Author:
livings124
Message:

allow creation of torrents with no announce address

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r5920 r5960  
    455455                4DE5CCB80981D27700BE280E /* ResumeAll.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ResumeAll.png; path = macosx/Images/ResumeAll.png; sourceTree = "<group>"; };
    456456                4DE5CCB90981D27700BE280E /* PauseAll.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseAll.png; path = macosx/Images/PauseAll.png; sourceTree = "<group>"; };
    457                 4DE5CCCA0981D9BE00BE280E /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; name = Defaults.plist; path = macosx/Defaults.plist; sourceTree = "<group>"; };
     457                4DE5CCCA0981D9BE00BE280E /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Defaults.plist; path = macosx/Defaults.plist; sourceTree = "<group>"; };
    458458                4DF0C5A90899190500DD8943 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = Controller.m; path = macosx/Controller.m; sourceTree = "<group>"; };
    459459                4DF0C5AA0899190500DD8943 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Controller.h; path = macosx/Controller.h; sourceTree = "<group>"; };
  • trunk/macosx/Controller.m

    r5950 r5960  
    12071207    while ((torrent = [enumerator nextObject]))
    12081208    {
     1209        #warning redo, since now can be removed through rpc
    12091210        //expand the group, since either the whole group is being removed, it is already expanded, or not showing groups
    12101211        [fTableView removeCollapsedGroup: [torrent groupValue]];
  • trunk/macosx/CreatorWindowController.h

    r5710 r5960  
    3232    IBOutlet NSTextField * fNameField, * fStatusField, * fPiecesField, * fTrackerField, * fLocationField;
    3333    IBOutlet NSTextView * fCommentView;
    34     IBOutlet NSButton *fCreateButton, * fPrivateCheck, * fOpenCheck;
     34    IBOutlet NSButton * fPrivateCheck, * fOpenCheck;
    3535   
    3636    IBOutlet NSView * fProgressView;
     
    3838   
    3939    tr_metainfo_builder * fInfo;
    40     NSString * fPath, * fLocation;
     40    NSString * fPath, * fLocation, * fTracker;
    4141    BOOL fOpenTorrent;
    4242   
     
    5252- (id) initWithHandle: (tr_handle *) handle path: (NSString *) path;
    5353
     54- (void) toggleOpenCheck: (id) sender;
     55
    5456- (void) setLocation: (id) sender;
    5557- (void) create: (id) sender;
  • trunk/macosx/CreatorWindowController.m

    r5718 r5960  
    3030
    3131+ (NSString *) chooseFile;
    32 - (void) updateEnableCreateButtonForTrackerField;
     32- (void) updateEnableOpenCheckForTrackerField;
    3333- (void) locationSheetClosed: (NSSavePanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
     34
     35- (void) createReal;
    3436- (void) checkProgress;
    3537- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
     
    151153    if ((tracker = [fDefaults stringForKey: @"CreatorTracker"]))
    152154        [fTrackerField setStringValue: tracker];
    153     [self updateEnableCreateButtonForTrackerField];
    154155   
    155156    if ([fDefaults objectForKey: @"CreatorPrivate"])
    156157        [fPrivateCheck setState: [fDefaults boolForKey: @"CreatorPrivate"] ? NSOnState : NSOffState];
    157158   
    158     if ([fDefaults objectForKey: @"CreatorOpen"])
    159         [fOpenCheck setState: [fDefaults boolForKey: @"CreatorOpen"] ? NSOnState : NSOffState];
     159    fOpenTorrent = [fDefaults boolForKey: @"CreatorOpen"];
     160    [self updateEnableOpenCheckForTrackerField];
    160161}
    161162
     
    165166    [fLocation release];
    166167   
     168    [fTracker release];
     169   
    167170    if (fInfo)
    168171        tr_metaInfoBuilderFree(fInfo);
     
    172175   
    173176    [super dealloc];
     177}
     178
     179- (void) toggleOpenCheck: (id) sender
     180{
     181    fOpenTorrent = [fOpenCheck state] == NSOnState;
     182}
     183
     184- (void) controlTextDidChange: (NSNotification *) notification
     185{
     186    if ([notification object] == fTrackerField)
     187        [self updateEnableOpenCheckForTrackerField];
    174188}
    175189
     
    190204}
    191205
    192 - (void) controlTextDidChange: (NSNotification *) notification
    193 {
    194     if ([notification object] == fTrackerField)
    195         [self updateEnableCreateButtonForTrackerField];
    196 }
    197 
    198206- (void) create: (id) sender
    199207{
    200     NSString * trackerString = [fTrackerField stringValue];
    201     if ([trackerString rangeOfString: @"://"].location == NSNotFound)
    202         trackerString = [@"http://" stringByAppendingString: trackerString];
    203    
    204     //parse tracker string
    205     if (!tr_httpIsValidURL([trackerString UTF8String]))
    206     {
    207         NSAlert * alert = [[[NSAlert alloc] init] autorelease];
    208         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
    209         [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
    210                                                     "Create torrent -> warning -> info")];
    211         [alert setAlertStyle: NSWarningAlertStyle];
    212        
    213         //check common reasons for failure
    214         NSString * prefix = [trackerString substringToIndex: [trackerString rangeOfString: @"://"].location];
    215         if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
    216             [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
    217                                                     "Create torrent -> warning -> message")];
    218         else
    219             [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
    220        
    221         [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
    222         return;
     208    /*if ([[fTrackerField stringValue] isEqualToString: @""] && [fDefaults boolForKey: @"WarningCreatorBlankAddress"])
     209    {
     210    }
     211    else*/
     212        [self createReal];
     213}
     214
     215- (void) cancelCreateWindow: (id) sender
     216{
     217    [[self window] close];
     218}
     219
     220- (void) windowWillClose: (NSNotification *) notification
     221{
     222    [self release];
     223}
     224
     225- (void) cancelCreateProgress: (id) sender
     226{
     227    fInfo->abortFlag = 1;
     228    [fTimer fire];
     229}
     230
     231@end
     232
     233@implementation CreatorWindowController (Private)
     234
     235+ (NSString *) chooseFile
     236{
     237    NSOpenPanel * panel = [NSOpenPanel openPanel];
     238   
     239    [panel setTitle: NSLocalizedString(@"Create Torrent File", "Create torrent -> select file")];
     240    [panel setPrompt: NSLocalizedString(@"Select", "Create torrent -> select file")];
     241    [panel setAllowsMultipleSelection: NO];
     242    [panel setCanChooseFiles: YES];
     243    [panel setCanChooseDirectories: YES];
     244    [panel setCanCreateDirectories: NO];
     245
     246    [panel setMessage: NSLocalizedString(@"Select a file or folder for the torrent file.", "Create torrent -> select file")];
     247   
     248    BOOL success = [panel runModal] == NSOKButton;
     249    return success ? [[panel filenames] objectAtIndex: 0] : nil;
     250}
     251
     252- (void) updateEnableOpenCheckForTrackerField
     253{
     254    BOOL hasTracker = ![[fTrackerField stringValue] isEqualToString: @""];
     255    [fOpenCheck setEnabled: hasTracker];
     256    [fOpenCheck setState: (fOpenTorrent && hasTracker) ? NSOnState : NSOffState];
     257}
     258
     259- (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (void *) info
     260{
     261    if (code == NSOKButton)
     262    {
     263        [fLocation release];
     264        fLocation = [[panel filename] retain];
     265       
     266        [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
     267        [fLocationField setToolTip: fLocation];
     268    }
     269}
     270
     271- (void) createReal
     272{
     273    [fTracker release]; //incase a previous create was aborted
     274    fTracker = [[fTrackerField stringValue] retain];
     275   
     276    //parse non-empty tracker strings
     277    if (![fTracker isEqualToString: @""])
     278    {
     279        if ([fTracker rangeOfString: @"://"].location == NSNotFound)
     280        {
     281            NSString * fullTracker = [@"http://" stringByAppendingString: fTracker];
     282            [fTracker release];
     283            fTracker = [fullTracker retain];
     284        }
     285       
     286        if (!tr_httpIsValidURL([fTracker UTF8String]))
     287        {
     288            NSAlert * alert = [[[NSAlert alloc] init] autorelease];
     289            [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
     290            [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
     291                                                        "Create torrent -> warning -> info")];
     292            [alert setAlertStyle: NSWarningAlertStyle];
     293           
     294            //check common reasons for failure
     295            NSString * prefix = [fTracker substringToIndex: [fTracker rangeOfString: @"://"].location];
     296            if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
     297                [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
     298                                                        "Create torrent -> warning -> message")];
     299            else
     300                [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
     301           
     302            [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
     303            return;
     304        }
    223305    }
    224306   
     
    244326    }
    245327   
    246     fOpenTorrent = [fOpenCheck state] == NSOnState;
    247    
    248328    //store values
    249     [fDefaults setObject: trackerString forKey: @"CreatorTracker"];
     329    [fDefaults setObject: fTracker forKey: @"CreatorTracker"];
    250330    [fDefaults setBool: [fPrivateCheck state] == NSOnState forKey: @"CreatorPrivate"];
    251331    [fDefaults setBool: fOpenTorrent forKey: @"CreatorOpen"];
     
    253333   
    254334    [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
    255     tr_makeMetaInfo(fInfo, [fLocation UTF8String], [trackerString UTF8String], [[fCommentView string] UTF8String],
     335    tr_makeMetaInfo(fInfo, [fLocation UTF8String], [fTracker UTF8String], [[fCommentView string] UTF8String],
    256336                    [fPrivateCheck state] == NSOnState);
    257337   
    258338    fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(checkProgress)
    259                         userInfo: nil repeats: YES];
    260 }
    261 
    262 - (void) cancelCreateWindow: (id) sender
    263 {
    264     [[self window] close];
    265 }
    266 
    267 - (void) windowWillClose: (NSNotification *) notification
    268 {
    269     [self release];
    270 }
    271 
    272 - (void) cancelCreateProgress: (id) sender
    273 {
    274     fInfo->abortFlag = 1;
    275     [fTimer fire];
    276 }
    277 
    278 @end
    279 
    280 @implementation CreatorWindowController (Private)
    281 
    282 + (NSString *) chooseFile
    283 {
    284     NSOpenPanel * panel = [NSOpenPanel openPanel];
    285    
    286     [panel setTitle: NSLocalizedString(@"Create Torrent File", "Create torrent -> select file")];
    287     [panel setPrompt: NSLocalizedString(@"Select", "Create torrent -> select file")];
    288     [panel setAllowsMultipleSelection: NO];
    289     [panel setCanChooseFiles: YES];
    290     [panel setCanChooseDirectories: YES];
    291     [panel setCanCreateDirectories: NO];
    292 
    293     [panel setMessage: NSLocalizedString(@"Select a file or folder for the torrent file.", "Create torrent -> select file")];
    294    
    295     BOOL success = [panel runModal] == NSOKButton;
    296     return success ? [[panel filenames] objectAtIndex: 0] : nil;
    297 }
    298 
    299 - (void) updateEnableCreateButtonForTrackerField
    300 {
    301     NSString * string = [fTrackerField stringValue];
    302     BOOL enable = YES;
    303     if ([string isEqualToString: @""])
    304         enable = NO;
    305     else
    306     {
    307         NSRange prefixRange = [string rangeOfString: @"://"];
    308         if (prefixRange.location != NSNotFound && [string length] == NSMaxRange(prefixRange))
    309             enable = NO;
    310     }
    311    
    312     [fCreateButton setEnabled: enable];
    313 }
    314 
    315 - (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (void *) info
    316 {
    317     if (code == NSOKButton)
    318     {
    319         [fLocation release];
    320         fLocation = [[panel filename] retain];
    321        
    322         [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
    323         [fLocationField setToolTip: fLocation];
    324     }
     339                userInfo: nil repeats: YES];
    325340}
    326341
     
    336351        {
    337352            case TR_MAKEMETA_OK:
    338                 if (fOpenTorrent)
     353                if (fOpenTorrent && ![fTracker isEqualToString: @""])
    339354                {
    340355                    NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: fLocation, @"File",
  • trunk/macosx/Defaults.plist

    r5935 r5960  
    153153        <key>WarningDuplicate</key>
    154154        <true/>
     155        <key>WarningCreatorBlankAddress</key>
     156        <true/>
    155157        <key>WarningFolderDataSameName</key>
    156158        <true/>
  • trunk/macosx/English.lproj/Creator.xib

    r5710 r5960  
    33        <data>
    44                <int key="IBDocument.SystemTarget">1050</int>
    5                 <string key="IBDocument.SystemVersion">9C7010</string>
    6                 <string key="IBDocument.InterfaceBuilderVersion">652</string>
    7                 <string key="IBDocument.AppKitVersion">949.26</string>
     5                <string key="IBDocument.SystemVersion">9D34</string>
     6                <string key="IBDocument.InterfaceBuilderVersion">667</string>
     7                <string key="IBDocument.AppKitVersion">949.33</string>
    88                <string key="IBDocument.HIToolboxVersion">352.00</string>
    99                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
     
    493493                                                        <bool key="NSEnabled">YES</bool>
    494494                                                        <object class="NSButtonCell" key="NSCell" id="671503663">
    495                                                                 <int key="NSCellFlags">604110336</int>
     495                                                                <int key="NSCellFlags">67239424</int>
    496496                                                                <int key="NSCellFlags2">134217728</int>
    497497                                                                <string key="NSContents">Create</string>
     
    783783                                </object>
    784784                                <object class="IBConnectionRecord">
    785                                         <object class="IBOutletConnection" key="connection">
    786                                                 <string key="label">fCreateButton</string>
    787                                                 <reference key="source" ref="578092914"/>
    788                                                 <reference key="destination" ref="697506694"/>
    789                                         </object>
    790                                         <int key="connectionID">87</int>
     785                                        <object class="IBActionConnection" key="connection">
     786                                                <string key="label">toggleOpenCheck:</string>
     787                                                <reference key="source" ref="578092914"/>
     788                                                <reference key="destination" ref="631380462"/>
     789                                        </object>
     790                                        <int key="connectionID">88</int>
    791791                                </object>
    792792                        </object>
     
    13091309                        </object>
    13101310                        <nil key="sourceID"/>
    1311                         <int key="maxID">87</int>
     1311                        <int key="maxID">88</int>
    13121312                </object>
    13131313                <object class="IBClassDescriber" key="IBDocument.Classes">
     
    13251325                                                        <string>create:</string>
    13261326                                                        <string>setLocation:</string>
     1327                                                        <string>toggleOpenCheck:</string>
    13271328                                                </object>
    13281329                                                <object class="NSMutableArray" key="dict.values">
     
    13321333                                                        <string>id</string>
    13331334                                                        <string>id</string>
     1335                                                        <string>id</string>
    13341336                                                </object>
    13351337                                        </object>
     
    13391341                                                        <bool key="EncodedWithXMLCoder">YES</bool>
    13401342                                                        <string>fCommentView</string>
    1341                                                         <string>fCreateButton</string>
    13421343                                                        <string>fIconView</string>
    13431344                                                        <string>fLocationField</string>
     
    13541355                                                        <bool key="EncodedWithXMLCoder">YES</bool>
    13551356                                                        <string>NSTextView</string>
    1356                                                         <string>NSButton</string>
    13571357                                                        <string>NSImageView</string>
    13581358                                                        <string>NSTextField</string>
     
    13821382                                <object class="IBPartialClassDescription">
    13831383                                        <string key="className">FirstResponder</string>
     1384                                        <string key="superclassName">NSObject</string>
    13841385                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
    13851386                                                <string key="majorKey">IBUserSource</string>
     
    13991400                                                <string key="majorKey">IBProjectSource</string>
    14001401                                                <string key="minorKey">macosx/NSMenuAdditions.h</string>
    1401                                         </object>
    1402                                 </object>
    1403                                 <object class="IBPartialClassDescription">
    1404                                         <string key="className">NSObject</string>
    1405                                         <object class="IBClassDescriptionSource" key="sourceIdentifier">
    1406                                                 <string key="majorKey">IBProjectSource</string>
    1407                                                 <string key="minorKey">macosx/IPCController.h</string>
    14081402                                        </object>
    14091403                                </object>
  • trunk/macosx/PrefsController.m

    r5913 r5960  
    507507    [fDefaults setBool: YES forKey: @"WarningFolderDataSameName"];
    508508    [fDefaults setBool: YES forKey: @"WarningResetStats"];
     509    [fDefaults setBool: YES forKey: @"WarningCreatorBlankAddress"];
    509510}
    510511
Note: See TracChangeset for help on using the changeset viewer.