From e743ffd43c5e028f33bb47a446ed7e07357c8459 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 26 Nov 2009 00:44:21 +0000 Subject: [PATCH] update the text for when creating a trackerless torrent, add a separate "don't ask again" check for private trackerless torrent creation, and don't disable the "open when created" check when there are no trackers --- macosx/CreatorWindowController.h | 3 -- macosx/CreatorWindowController.m | 50 ++++++++++++++------------------ macosx/Defaults.plist | 2 ++ macosx/PrefsController.m | 1 + 4 files changed, 25 insertions(+), 31 deletions(-) diff --git a/macosx/CreatorWindowController.h b/macosx/CreatorWindowController.h index c3168acc5..ae8eb5f8a 100644 --- a/macosx/CreatorWindowController.h +++ b/macosx/CreatorWindowController.h @@ -41,7 +41,6 @@ tr_metainfo_builder * fInfo; NSString * fPath, * fLocation; NSMutableArray * fTrackers; - BOOL fOpenTorrent; NSTimer * fTimer; BOOL fStarted; @@ -54,8 +53,6 @@ - (id) initWithHandle: (tr_session *) handle path: (NSString *) path; -- (void) toggleOpenCheck: (id) sender; - - (void) setLocation: (id) sender; - (void) create: (id) sender; - (void) cancelCreateWindow: (id) sender; diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index ec1481b80..61d2d2f2c 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -32,7 +32,6 @@ @interface CreatorWindowController (Private) + (NSString *) chooseFile; -- (void) updateEnableOpenCheckForTrackers; - (void) locationSheetClosed: (NSSavePanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) info; - (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo; @@ -178,8 +177,7 @@ if ([fDefaults objectForKey: @"CreatorPrivate"]) [fPrivateCheck setState: [fDefaults boolForKey: @"CreatorPrivate"] ? NSOnState : NSOffState]; - fOpenTorrent = [fDefaults boolForKey: @"CreatorOpen"]; - [self updateEnableOpenCheckForTrackers]; + [fOpenCheck setState: [fDefaults boolForKey: @"CreatorOpen"] ? NSOnState : NSOffState]; } - (void) dealloc @@ -197,11 +195,6 @@ [super dealloc]; } -- (void) toggleOpenCheck: (id) sender -{ - fOpenTorrent = [fOpenCheck state] == NSOnState; -} - - (void) setLocation: (id) sender { NSSavePanel * panel = [NSSavePanel savePanel]; @@ -224,13 +217,22 @@ if ([fTrackerTable editedRow] != -1) [[self window] endEditingFor: fTrackerTable]; - if ([fTrackers count] == 0 && [fDefaults boolForKey: @"WarningCreatorBlankAddress"]) + const BOOL isPrivate = [fPrivateCheck state] == NSOnState; + if ([fTrackers count] == 0 + && [fDefaults boolForKey: isPrivate ? @"WarningCreatorPrivateBlankAddress" : @"WarningCreatorBlankAddress"]) { NSAlert * alert = [[NSAlert alloc] init]; - [alert setMessageText: NSLocalizedString(@"There is no tracker address.", "Create torrent -> blank address -> title")]; - [alert setInformativeText: NSLocalizedString(@"The torrent file will not be able to be opened." - " A torrent file with no tracker address is only useful when you plan to upload the file to a tracker website" - " that will add the address for you.", "Create torrent -> blank address -> message")]; + [alert setMessageText: NSLocalizedString(@"There are no tracker addresses.", "Create torrent -> blank address -> title")]; + + NSString * infoString = isPrivate + ? NSLocalizedString(@"A transfer marked as private with no tracker addresses will be unable to connect to peers." + " The torrent file will only be useful if you plan to upload the file to a tracker website" + " that will add the addresses for you.", "Create torrent -> blank address -> message") + : NSLocalizedString(@"The transfer will not contact trackers for peers," + " and will have to rely solely on DHT and PEX to download and seed.", + "Create torrent -> blank address -> message"); + + [alert setInformativeText: infoString]; [alert addButtonWithTitle: NSLocalizedString(@"Create", "Create torrent -> blank address -> button")]; [alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Create torrent -> blank address -> button")]; [alert setShowsSuppressionButton: YES]; @@ -280,8 +282,6 @@ [fTrackerTable deselectAll: self]; [fTrackerTable reloadData]; - - [self updateEnableOpenCheckForTrackers]; } else { @@ -310,10 +310,7 @@ [fTrackers removeObjectAtIndex: row]; } else - { [fTrackers replaceObjectAtIndex: row withObject: tracker]; - [self updateEnableOpenCheckForTrackers]; - } [fTrackerTable deselectAll: self]; [fTrackerTable reloadData]; @@ -345,13 +342,6 @@ return success ? [[panel filenames] objectAtIndex: 0] : nil; } -- (void) updateEnableOpenCheckForTrackers -{ - BOOL hasTracker = [fTrackers count] > 0; - [fOpenCheck setEnabled: hasTracker]; - [fOpenCheck setState: (fOpenTorrent && hasTracker) ? NSOnState : NSOffState]; -} - - (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (void *) info { if (code == NSOKButton) @@ -367,7 +357,11 @@ - (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo { if ([[alert suppressionButton] state] == NSOnState) - [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorBlankAddress"]; + { + [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorBlankAddress"]; //set regardless of private/public + if ([fPrivateCheck state] == NSOnState) + [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"]; + } [alert release]; @@ -428,7 +422,7 @@ //store values [fDefaults setObject: fTrackers forKey: @"CreatorTrackers"]; [fDefaults setBool: [fPrivateCheck state] == NSOnState forKey: @"CreatorPrivate"]; - [fDefaults setBool: fOpenTorrent forKey: @"CreatorOpen"]; + [fDefaults setBool: [fOpenCheck state] == NSOnState forKey: @"CreatorOpen"]; [fDefaults setObject: [fLocation stringByDeletingLastPathComponent] forKey: @"CreatorLocation"]; [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil]; @@ -451,7 +445,7 @@ switch (fInfo->result) { case TR_MAKEMETA_OK: - if (fOpenTorrent && [fTrackers count] > 0) + if ([fDefaults boolForKey: @"CreatorOpen"]) { NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: fLocation, @"File", [fPath stringByDeletingLastPathComponent], @"Path", nil]; diff --git a/macosx/Defaults.plist b/macosx/Defaults.plist index 98151abd7..5e8c81361 100644 --- a/macosx/Defaults.plist +++ b/macosx/Defaults.plist @@ -182,6 +182,8 @@ WarningCreatorBlankAddress + WarningCreatorPrivateBlankAddress + WarningDonate WarningDuplicate diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 139a4f4e0..c9b671717 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -681,6 +681,7 @@ tr_session * fHandle; [fDefaults removeObjectForKey: @"WarningFolderDataSameName"]; [fDefaults removeObjectForKey: @"WarningResetStats"]; [fDefaults removeObjectForKey: @"WarningCreatorBlankAddress"]; + [fDefaults removeObjectForKey: @"WarningCreatorPrivateBlankAddress"]; [fDefaults removeObjectForKey: @"WarningRemoveTrackers"]; [fDefaults removeObjectForKey: @"WarningInvalidOpen"]; [fDefaults removeObjectForKey: @"WarningDonate"];