]> granicus.if.org Git - transmission/commitdiff
allow creation of torrents with no announce address
authorMitchell Livingston <livings124@transmissionbt.com>
Wed, 28 May 2008 23:57:25 +0000 (23:57 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Wed, 28 May 2008 23:57:25 +0000 (23:57 +0000)
Transmission.xcodeproj/project.pbxproj
macosx/Controller.m
macosx/CreatorWindowController.h
macosx/CreatorWindowController.m
macosx/Defaults.plist
macosx/English.lproj/Creator.xib
macosx/PrefsController.m

index 768f72d60bc07a3d93acd6bfc91f6644a870f54b..273cbcfef86a4292c62adce103870f2179382737 100644 (file)
                4DE5CCA80980739100BE280E /* Badge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Badge.png; path = macosx/Images/Badge.png; sourceTree = "<group>"; };
                4DE5CCB80981D27700BE280E /* ResumeAll.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ResumeAll.png; path = macosx/Images/ResumeAll.png; sourceTree = "<group>"; };
                4DE5CCB90981D27700BE280E /* PauseAll.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseAll.png; path = macosx/Images/PauseAll.png; sourceTree = "<group>"; };
-               4DE5CCCA0981D9BE00BE280E /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; name = Defaults.plist; path = macosx/Defaults.plist; sourceTree = "<group>"; };
+               4DE5CCCA0981D9BE00BE280E /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Defaults.plist; path = macosx/Defaults.plist; sourceTree = "<group>"; };
                4DF0C5A90899190500DD8943 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = Controller.m; path = macosx/Controller.m; sourceTree = "<group>"; };
                4DF0C5AA0899190500DD8943 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Controller.h; path = macosx/Controller.h; sourceTree = "<group>"; };
                4DF7500708A103AD007B0D70 /* Open.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Open.png; path = macosx/Images/Open.png; sourceTree = "<group>"; };
index 02c79c51d4150810d50ca84e9142d6ebccdadb99..4953db71cde6bbd7aacce320cfe91cde867b8fc0 100644 (file)
@@ -1206,6 +1206,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     enumerator = [torrents objectEnumerator];
     while ((torrent = [enumerator nextObject]))
     {
+        #warning redo, since now can be removed through rpc
         //expand the group, since either the whole group is being removed, it is already expanded, or not showing groups
         [fTableView removeCollapsedGroup: [torrent groupValue]];
         
index e617c9171825fe4b368cc1328822b0c6f6dda503..cead2078275b5cee294007c37f3f98161e585051 100644 (file)
     IBOutlet NSImageView * fIconView;
     IBOutlet NSTextField * fNameField, * fStatusField, * fPiecesField, * fTrackerField, * fLocationField;
     IBOutlet NSTextView * fCommentView;
-    IBOutlet NSButton *fCreateButton, * fPrivateCheck, * fOpenCheck;
+    IBOutlet NSButton * fPrivateCheck, * fOpenCheck;
     
     IBOutlet NSView * fProgressView;
     IBOutlet NSProgressIndicator * fProgressIndicator;
     
     tr_metainfo_builder * fInfo;
-    NSString * fPath, * fLocation;
+    NSString * fPath, * fLocation, * fTracker;
     BOOL fOpenTorrent;
     
     NSTimer * fTimer;
@@ -51,6 +51,8 @@
 
 - (id) initWithHandle: (tr_handle *) handle path: (NSString *) path;
 
+- (void) toggleOpenCheck: (id) sender;
+
 - (void) setLocation: (id) sender;
 - (void) create: (id) sender;
 - (void) cancelCreateWindow: (id) sender;
index b621fe8fa9d90c7b353f4e0f3cdfbbfc5a277f51..5ce10bfcb96791d77768be4852aa4d4741f4fb8b 100644 (file)
 @interface CreatorWindowController (Private)
 
 + (NSString *) chooseFile;
-- (void) updateEnableCreateButtonForTrackerField;
+- (void) updateEnableOpenCheckForTrackerField;
 - (void) locationSheetClosed: (NSSavePanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
+
+- (void) createReal;
 - (void) checkProgress;
 - (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
 
     NSString * tracker;
     if ((tracker = [fDefaults stringForKey: @"CreatorTracker"]))
         [fTrackerField setStringValue: tracker];
-    [self updateEnableCreateButtonForTrackerField];
     
     if ([fDefaults objectForKey: @"CreatorPrivate"])
         [fPrivateCheck setState: [fDefaults boolForKey: @"CreatorPrivate"] ? NSOnState : NSOffState];
     
-    if ([fDefaults objectForKey: @"CreatorOpen"])
-        [fOpenCheck setState: [fDefaults boolForKey: @"CreatorOpen"] ? NSOnState : NSOffState];
+    fOpenTorrent = [fDefaults boolForKey: @"CreatorOpen"];
+    [self updateEnableOpenCheckForTrackerField];
 }
 
 - (void) dealloc
     [fPath release];
     [fLocation release];
     
+    [fTracker release];
+    
     if (fInfo)
         tr_metaInfoBuilderFree(fInfo);
     
     [super dealloc];
 }
 
+- (void) toggleOpenCheck: (id) sender
+{
+    fOpenTorrent = [fOpenCheck state] == NSOnState;
+}
+
+- (void) controlTextDidChange: (NSNotification *) notification
+{
+    if ([notification object] == fTrackerField)
+        [self updateEnableOpenCheckForTrackerField];
+}
+
 - (void) setLocation: (id) sender
 {
     NSSavePanel * panel = [NSSavePanel savePanel];
             contextInfo: nil];
 }
 
-- (void) controlTextDidChange: (NSNotification *) notification
-{
-    if ([notification object] == fTrackerField)
-        [self updateEnableCreateButtonForTrackerField];
-}
-
 - (void) create: (id) sender
 {
-    NSString * trackerString = [fTrackerField stringValue];
-    if ([trackerString rangeOfString: @"://"].location == NSNotFound)
-        trackerString = [@"http://" stringByAppendingString: trackerString];
-    
-    //parse tracker string
-    if (!tr_httpIsValidURL([trackerString UTF8String]))
+    /*if ([[fTrackerField stringValue] isEqualToString: @""] && [fDefaults boolForKey: @"WarningCreatorBlankAddress"])
     {
-        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
-        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
-        [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
-                                                    "Create torrent -> warning -> info")];
-        [alert setAlertStyle: NSWarningAlertStyle];
-        
-        //check common reasons for failure
-        NSString * prefix = [trackerString substringToIndex: [trackerString rangeOfString: @"://"].location];
-        if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
-            [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
-                                                    "Create torrent -> warning -> message")];
-        else
-            [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
-        
-        [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
-        return;
     }
-    
-    //check if a file with the same name and location already exists
-    if ([[NSFileManager defaultManager] fileExistsAtPath: fLocation])
-    {
-        NSArray * pathComponents = [fLocation pathComponents];
-        int count = [pathComponents count];
-        
-        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
-        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> file already exists warning -> button")];
-        [alert setMessageText: NSLocalizedString(@"A torrent file with this name and directory cannot be created.",
-                                                "Create torrent -> file already exists warning -> title")];
-        [alert setInformativeText: [NSString stringWithFormat:
-                NSLocalizedString(@"A file with the name \"%@\" already exists in the directory \"%@\". "
-                    "Choose a new name or directory to create the torrent file.",
-                    "Create torrent -> file already exists warning -> warning"),
-                    [pathComponents objectAtIndex: count-1], [pathComponents objectAtIndex: count-2]]];
-        [alert setAlertStyle: NSWarningAlertStyle];
-        
-        [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
-        return;
-    }
-    
-    fOpenTorrent = [fOpenCheck state] == NSOnState;
-    
-    //store values
-    [fDefaults setObject: trackerString forKey: @"CreatorTracker"];
-    [fDefaults setBool: [fPrivateCheck state] == NSOnState forKey: @"CreatorPrivate"];
-    [fDefaults setBool: fOpenTorrent forKey: @"CreatorOpen"];
-    [fDefaults setObject: [fLocation stringByDeletingLastPathComponent] forKey: @"CreatorLocation"];
-    
-    [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
-    tr_makeMetaInfo(fInfo, [fLocation UTF8String], [trackerString UTF8String], [[fCommentView string] UTF8String],
-                    [fPrivateCheck state] == NSOnState);
-    
-    fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(checkProgress)
-                        userInfo: nil repeats: YES];
+    else*/
+        [self createReal];
 }
 
 - (void) cancelCreateWindow: (id) sender
     return success ? [[panel filenames] objectAtIndex: 0] : nil;
 }
 
-- (void) updateEnableCreateButtonForTrackerField
+- (void) updateEnableOpenCheckForTrackerField
 {
-    NSString * string = [fTrackerField stringValue];
-    BOOL enable = YES;
-    if ([string isEqualToString: @""])
-        enable = NO;
-    else
-    {
-        NSRange prefixRange = [string rangeOfString: @"://"];
-        if (prefixRange.location != NSNotFound && [string length] == NSMaxRange(prefixRange))
-            enable = NO;
-    }
-    
-    [fCreateButton setEnabled: enable];
+    BOOL hasTracker = ![[fTrackerField stringValue] isEqualToString: @""];
+    [fOpenCheck setEnabled: hasTracker];
+    [fOpenCheck setState: (fOpenTorrent && hasTracker) ? NSOnState : NSOffState];
 }
 
 - (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (void *) info
     }
 }
 
+- (void) createReal
+{
+    [fTracker release]; //incase a previous create was aborted
+    fTracker = [[fTrackerField stringValue] retain];
+    
+    //parse non-empty tracker strings
+    if (![fTracker isEqualToString: @""])
+    {
+        if ([fTracker rangeOfString: @"://"].location == NSNotFound)
+        {
+            NSString * fullTracker = [@"http://" stringByAppendingString: fTracker];
+            [fTracker release];
+            fTracker = [fullTracker retain];
+        }
+        
+        if (!tr_httpIsValidURL([fTracker UTF8String]))
+        {
+            NSAlert * alert = [[[NSAlert alloc] init] autorelease];
+            [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> warning -> button")];
+            [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent file.",
+                                                        "Create torrent -> warning -> info")];
+            [alert setAlertStyle: NSWarningAlertStyle];
+            
+            //check common reasons for failure
+            NSString * prefix = [fTracker substringToIndex: [fTracker rangeOfString: @"://"].location];
+            if ([prefix caseInsensitiveCompare: @"http"] != NSOrderedSame && [prefix caseInsensitiveCompare: @"https"] != NSOrderedSame)
+                [alert setMessageText: NSLocalizedString(@"The tracker address must begin with \"http://\" or \"https://\".",
+                                                        "Create torrent -> warning -> message")];
+            else
+                [alert setMessageText: NSLocalizedString(@"The tracker address is invalid.", "Create torrent -> warning -> message")];
+            
+            [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
+            return;
+        }
+    }
+    
+    //check if a file with the same name and location already exists
+    if ([[NSFileManager defaultManager] fileExistsAtPath: fLocation])
+    {
+        NSArray * pathComponents = [fLocation pathComponents];
+        int count = [pathComponents count];
+        
+        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
+        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> file already exists warning -> button")];
+        [alert setMessageText: NSLocalizedString(@"A torrent file with this name and directory cannot be created.",
+                                                "Create torrent -> file already exists warning -> title")];
+        [alert setInformativeText: [NSString stringWithFormat:
+                NSLocalizedString(@"A file with the name \"%@\" already exists in the directory \"%@\". "
+                    "Choose a new name or directory to create the torrent file.",
+                    "Create torrent -> file already exists warning -> warning"),
+                    [pathComponents objectAtIndex: count-1], [pathComponents objectAtIndex: count-2]]];
+        [alert setAlertStyle: NSWarningAlertStyle];
+        
+        [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
+        return;
+    }
+    
+    //store values
+    [fDefaults setObject: fTracker forKey: @"CreatorTracker"];
+    [fDefaults setBool: [fPrivateCheck state] == NSOnState forKey: @"CreatorPrivate"];
+    [fDefaults setBool: fOpenTorrent forKey: @"CreatorOpen"];
+    [fDefaults setObject: [fLocation stringByDeletingLastPathComponent] forKey: @"CreatorLocation"];
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
+    tr_makeMetaInfo(fInfo, [fLocation UTF8String], [fTracker UTF8String], [[fCommentView string] UTF8String],
+                    [fPrivateCheck state] == NSOnState);
+    
+    fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(checkProgress)
+                userInfo: nil repeats: YES];
+}
+
 - (void) checkProgress
 {
     if (fInfo->isDone)
         switch (fInfo->result)
         {
             case TR_MAKEMETA_OK:
-                if (fOpenTorrent)
+                if (fOpenTorrent && ![fTracker isEqualToString: @""])
                 {
                     NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: fLocation, @"File",
                                             [fPath stringByDeletingLastPathComponent], @"Path", nil];
index 82b90eeb467a81bdf9e76926acb788c4622bc847..4992be74178aa818248296bcb25523b2ca3dda2f 100644 (file)
        <false/>
        <key>WarningDuplicate</key>
        <true/>
+       <key>WarningCreatorBlankAddress</key>
+       <true/>
        <key>WarningFolderDataSameName</key>
        <true/>
        <key>WarningRemainingSpace</key>
index 3ddbaf059aaec2245375246f95ec156a2af373dc..5a9d2a8ea12391d5607a73031c950b0782cb9107 100644 (file)
@@ -2,9 +2,9 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9C7010</string>
-               <string key="IBDocument.InterfaceBuilderVersion">652</string>
-               <string key="IBDocument.AppKitVersion">949.26</string>
+               <string key="IBDocument.SystemVersion">9D34</string>
+               <string key="IBDocument.InterfaceBuilderVersion">667</string>
+               <string key="IBDocument.AppKitVersion">949.33</string>
                <string key="IBDocument.HIToolboxVersion">352.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference key="NSSuperview" ref="755547124"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSButtonCell" key="NSCell" id="671503663">
-                                                               <int key="NSCellFlags">604110336</int>
+                                                               <int key="NSCellFlags">67239424</int>
                                                                <int key="NSCellFlags2">134217728</int>
                                                                <string key="NSContents">Create</string>
                                                                <reference key="NSSupport" ref="364179855"/>
                                        <int key="connectionID">86</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fCreateButton</string>
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">toggleOpenCheck:</string>
                                                <reference key="source" ref="578092914"/>
-                                               <reference key="destination" ref="697506694"/>
+                                               <reference key="destination" ref="631380462"/>
                                        </object>
-                                       <int key="connectionID">87</int>
+                                       <int key="connectionID">88</int>
                                </object>
                        </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                </object>
                        </object>
                        <nil key="sourceID"/>
-                       <int key="maxID">87</int>
+                       <int key="maxID">88</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <object class="NSMutableArray" key="referencedPartialClassDescriptions">
                                                        <string>cancelCreateWindow:</string>
                                                        <string>create:</string>
                                                        <string>setLocation:</string>
+                                                       <string>toggleOpenCheck:</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <string>id</string>
                                                        <string>id</string>
                                                        <string>id</string>
+                                                       <string>id</string>
                                                </object>
                                        </object>
                                        <object class="NSMutableDictionary" key="outlets">
                                                <object class="NSMutableArray" key="dict.sortedKeys">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <string>fCommentView</string>
-                                                       <string>fCreateButton</string>
                                                        <string>fIconView</string>
                                                        <string>fLocationField</string>
                                                        <string>fNameField</string>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <string>NSTextView</string>
-                                                       <string>NSButton</string>
                                                        <string>NSImageView</string>
                                                        <string>NSTextField</string>
                                                        <string>NSTextField</string>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">FirstResponder</string>
+                                       <string key="superclassName">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
                                                <string key="minorKey">macosx/NSMenuAdditions.h</string>
                                        </object>
                                </object>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">NSObject</string>
-                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">macosx/IPCController.h</string>
-                                       </object>
-                               </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
index ff0a3e80075f864344cf0539accc7b1a02a22fb5..16c5b1baa2c41360ae08cb57c64132d8c63501da 100644 (file)
     [fDefaults setBool: YES forKey: @"WarningRemainingSpace"];
     [fDefaults setBool: YES forKey: @"WarningFolderDataSameName"];
     [fDefaults setBool: YES forKey: @"WarningResetStats"];
+    [fDefaults setBool: YES forKey: @"WarningCreatorBlankAddress"];
 }
 
 - (void) setCheckForUpdate: (id) sender