diff --git a/macosx/Controller.m b/macosx/Controller.m index 491808722..98502c771 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1881,15 +1881,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy - (void) torrentFinishedSeeding: (NSNotification *) notification { - Torrent * torrent = [notification object]; - - [self fullUpdateUI]; - - if ([[fTableView selectedTorrents] containsObject: torrent]) - { - [fInfoController updateInfoStats]; - [fInfoController updateOptions]; - } + Torrent * torrent = [[notification object] retain]; if (!fSoundPlaying && [fDefaults boolForKey: @"PlaySeedingSound"]) { @@ -1909,8 +1901,24 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy [clickContext setObject: location forKey: @"Location"]; [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Seeding Complete", "Growl notification title") - description: [torrent name] notificationName: GROWL_SEEDING_COMPLETE - iconData: nil priority: 0 isSticky: NO clickContext: clickContext]; + description: [torrent name] notificationName: GROWL_SEEDING_COMPLETE + iconData: nil priority: 0 isSticky: NO clickContext: clickContext]; + + //removing for the list calls fullUpdateUI + if ([torrent removeWhenFinishSeeding]) + [self confirmRemoveTorrents: [[NSArray arrayWithObject: torrent] retain] deleteData: NO]; + else + { + [self fullUpdateUI]; + + if ([[fTableView selectedTorrents] containsObject: torrent]) + { + [fInfoController updateInfoStats]; + [fInfoController updateOptions]; + } + } + + [torrent release]; } - (void) updateTorrentHistory diff --git a/macosx/Defaults.plist b/macosx/Defaults.plist index 396178673..bb95ad603 100644 --- a/macosx/Defaults.plist +++ b/macosx/Defaults.plist @@ -128,6 +128,8 @@ RatioLimit 2 + RemoveWhenFinishSeeding + RenamePartialFiles RPC diff --git a/macosx/InfoOptionsViewController.h b/macosx/InfoOptionsViewController.h index bfd22c490..7ad51638a 100644 --- a/macosx/InfoOptionsViewController.h +++ b/macosx/InfoOptionsViewController.h @@ -32,7 +32,7 @@ BOOL fSet; IBOutlet NSPopUpButton * fPriorityPopUp, * fRatioPopUp, * fIdlePopUp; - IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck, * fGlobalLimitCheck; + IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck, * fGlobalLimitCheck, * fRemoveSeedingCompleteCheck; IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField, * fIdleLimitField, * fUploadLimitLabel, * fDownloadLimitLabel, * fIdleLimitLabel, * fRatioLimitGlobalLabel, * fIdleLimitGlobalLabel, @@ -45,18 +45,20 @@ - (void) updateInfo; - (void) updateOptions; -- (void) setUseSpeedLimit: (id) sender; -- (void) setSpeedLimit: (id) sender; -- (void) setUseGlobalSpeedLimit: (id) sender; +- (IBAction) setUseSpeedLimit: (id) sender; +- (IBAction) setSpeedLimit: (id) sender; +- (IBAction) setUseGlobalSpeedLimit: (id) sender; -- (void) setRatioSetting: (id) sender; -- (void) setRatioLimit: (id) sender; +- (IBAction) setRatioSetting: (id) sender; +- (IBAction) setRatioLimit: (id) sender; -- (void) setIdleSetting: (id) sender; -- (void) setIdleLimit: (id) sender; +- (IBAction) setIdleSetting: (id) sender; +- (IBAction) setIdleLimit: (id) sender; -- (void) setPriority: (id) sender; +- (IBAction) setRemoveWhenSeedingCompletes: (id) sender; -- (void) setPeersConnectLimit: (id) sender; +- (IBAction) setPriority: (id) sender; + +- (IBAction) setPeersConnectLimit: (id) sender; @end diff --git a/macosx/InfoOptionsViewController.m b/macosx/InfoOptionsViewController.m index f8ec8bd3f..3a7836a68 100644 --- a/macosx/InfoOptionsViewController.m +++ b/macosx/InfoOptionsViewController.m @@ -156,7 +156,8 @@ enumerator = [fTorrents objectEnumerator]; torrent = [enumerator nextObject]; //first torrent - NSInteger checkRatio = [torrent ratioSetting], checkIdle = [torrent idleSetting]; + NSInteger checkRatio = [torrent ratioSetting], checkIdle = [torrent idleSetting], + removeWhenFinishSeeding = [torrent removeWhenFinishSeeding] ? NSOnState : NSOffState; CGFloat ratioLimit = [torrent ratioLimit]; NSUInteger idleLimit = [torrent idleLimitMinutes]; @@ -174,6 +175,9 @@ if (idleLimit != INVALID && idleLimit != [torrent idleLimitMinutes]) idleLimit = INVALID; + + if (removeWhenFinishSeeding != NSMixedState && removeWhenFinishSeeding != ([torrent removeWhenFinishSeeding] ? NSOnState : NSOffState)) + removeWhenFinishSeeding = NSMixedState; } //set ratio view @@ -218,6 +222,10 @@ [fIdleLimitGlobalLabel setHidden: checkIdle != TR_IDLELIMIT_GLOBAL]; + //set remove transfer when seeding finishes + [fRemoveSeedingCompleteCheck setState: removeWhenFinishSeeding]; + [fRemoveSeedingCompleteCheck setEnabled: YES]; + //get priority info enumerator = [fTorrents objectEnumerator]; torrent = [enumerator nextObject]; //first torrent @@ -407,6 +415,18 @@ [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateOptionsNotification" object: self]; } +- (IBAction) setRemoveWhenSeedingCompletes: (id) sender +{ + if ([(NSButton *)sender state] == NSMixedState) + [sender setState: NSOnState]; + const BOOL enable = [(NSButton *)sender state] == NSOnState; + + for (Torrent * torrent in fTorrents) + [torrent setRemoveWhenFinishSeeding: enable]; + + [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateOptionsNotification" object: self]; +} + - (void) setPriority: (id) sender { tr_priority_t priority; @@ -503,6 +523,9 @@ [fIdleLimitLabel setHidden: YES]; [fIdleLimitGlobalLabel setHidden: YES]; + [fRemoveSeedingCompleteCheck setEnabled: NO]; + [fRemoveSeedingCompleteCheck setState: NSOffState]; + [fPeersConnectField setEnabled: NO]; [fPeersConnectField setStringValue: @""]; [fPeersConnectLabel setEnabled: NO]; diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 93567b6d4..8db59584f 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -114,6 +114,8 @@ - (void) setMaxPeerConnect: (uint16_t) count; - (uint16_t) maxPeerConnect; +@property (nonatomic) BOOL removeWhenFinishSeeding; + - (BOOL) waitingToStart; - (tr_priority_t) priority; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 99c1cce87..53b38c4e3 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -38,6 +38,7 @@ - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib groupValue: (NSNumber *) groupValue + removeWhenFinishSeeding: (NSNumber *) removeWhenFinishSeeding timeMachineExcludeLocation: (NSString *) timeMachineExclude downloadFolder: (NSString *) downloadFolder legacyIncompleteFolder: (NSString *) incompleteFolder; @@ -102,11 +103,14 @@ int trashDataFile(const char * filename) @implementation Torrent +@synthesize removeWhenFinishSeeding = fRemoveWhenFinishSeeding; + - (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete lib: (tr_session *) lib { self = [self initWithPath: path hash: nil torrentStruct: NULL magnetAddress: nil lib: lib groupValue: nil + removeWhenFinishSeeding: nil timeMachineExcludeLocation: nil downloadFolder: location legacyIncompleteFolder: nil]; @@ -123,6 +127,7 @@ int trashDataFile(const char * filename) { self = [self initWithPath: nil hash: nil torrentStruct: torrentStruct magnetAddress: nil lib: lib groupValue: nil + removeWhenFinishSeeding: nil timeMachineExcludeLocation: nil downloadFolder: location legacyIncompleteFolder: nil]; @@ -134,6 +139,7 @@ int trashDataFile(const char * filename) { self = [self initWithPath: nil hash: nil torrentStruct: nil magnetAddress: address lib: lib groupValue: nil + removeWhenFinishSeeding: nil timeMachineExcludeLocation: nil downloadFolder: location legacyIncompleteFolder: nil]; @@ -148,6 +154,7 @@ int trashDataFile(const char * filename) magnetAddress: nil lib: lib groupValue: [history objectForKey: @"GroupValue"] + removeWhenFinishSeeding: [history objectForKey: @"RemoveWhenFinishSeeding"] timeMachineExcludeLocation: [history objectForKey: @"TimeMachineExcludeLocation"] downloadFolder: [history objectForKey: @"DownloadFolder"] //upgrading from versions < 1.80 legacyIncompleteFolder: [[history objectForKey: @"UseIncompleteFolder"] boolValue] //upgrading from versions < 1.80 @@ -197,7 +204,8 @@ int trashDataFile(const char * filename) [self hashString], @"TorrentHash", [NSNumber numberWithBool: [self isActive]], @"Active", [NSNumber numberWithBool: [self waitingToStart]], @"WaitToStart", - [NSNumber numberWithInt: fGroupValue], @"GroupValue", nil]; + [NSNumber numberWithInt: fGroupValue], @"GroupValue", + [NSNumber numberWithBool: fRemoveWhenFinishSeeding], @"RemoveWhenFinishSeeding", nil]; if (fTimeMachineExclude) [history setObject: fTimeMachineExclude forKey: @"TimeMachineExcludeLocation"]; @@ -1611,6 +1619,7 @@ int trashDataFile(const char * filename) - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib groupValue: (NSNumber *) groupValue + removeWhenFinishSeeding: (NSNumber *) removeWhenFinishSeeding timeMachineExcludeLocation: (NSString *) timeMachineExclude downloadFolder: (NSString *) downloadFolder legacyIncompleteFolder: (NSString *) incompleteFolder @@ -1674,6 +1683,8 @@ int trashDataFile(const char * filename) fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self]; + fRemoveWhenFinishSeeding = removeWhenFinishSeeding ? [removeWhenFinishSeeding boolValue] : [fDefaults boolForKey: @"RemoveWhenFinishSeeding"]; + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:) name: @"GroupValueRemoved" object: nil]; diff --git a/macosx/en.lproj/InfoOptionsView.xib b/macosx/en.lproj/InfoOptionsView.xib index e5ba0c20f..aa41962f3 100644 --- a/macosx/en.lproj/InfoOptionsView.xib +++ b/macosx/en.lproj/InfoOptionsView.xib @@ -2,13 +2,13 @@ 1060 - 11D50 - 2177 - 1138.32 - 568.00 + 11E53 + 2182 + 1138.47 + 569.00 com.apple.InterfaceBuilder.CocoaPlugin - 2177 + 2182 NSTextField @@ -47,7 +47,7 @@ 268 - {{217, 54}, {45, 20}} + {{217, 71}, {45, 20}} @@ -123,7 +123,7 @@ 268 - {{71, 53}, {138, 22}} + {{71, 70}, {138, 22}} @@ -205,7 +205,7 @@ 268 - {{10, 57}, {56, 14}} + {{10, 74}, {56, 14}} @@ -236,7 +236,7 @@ 268 - {{217, 76}, {45, 20}} + {{217, 93}, {45, 20}} @@ -292,7 +292,7 @@ 268 - {{9, 95}, {88, 17}} + {{9, 112}, {88, 17}} @@ -314,7 +314,7 @@ 268 - {{9, 181}, {117, 14}} + {{9, 198}, {117, 14}} @@ -332,7 +332,7 @@ 268 - {{9, 219}, {46, 17}} + {{9, 236}, {46, 17}} @@ -350,7 +350,7 @@ 268 - {{125, 137}, {45, 20}} + {{125, 154}, {45, 20}} @@ -401,7 +401,7 @@ 268 - {{175, 140}, {29, 14}} + {{175, 157}, {29, 14}} @@ -419,7 +419,7 @@ 268 - {{125, 159}, {45, 20}} + {{125, 176}, {45, 20}} @@ -470,7 +470,7 @@ 266 - {{214, 79}, {90, 14}} + {{214, 96}, {90, 14}} @@ -491,7 +491,7 @@ 266 - {{214, 57}, {90, 14}} + {{214, 74}, {90, 14}} @@ -512,10 +512,10 @@ 268 - {{267, 57}, {47, 14}} + {{267, 74}, {47, 14}} - + YES 67239424 @@ -530,7 +530,7 @@ 268 - {{175, 162}, {29, 14}} + {{175, 179}, {29, 14}} @@ -548,7 +548,7 @@ 268 - {{71, 75}, {138, 22}} + {{71, 92}, {138, 22}} @@ -619,7 +619,7 @@ 268 - {{10, 79}, {35, 14}} + {{10, 96}, {35, 14}} @@ -637,7 +637,7 @@ 268 - {{10, 204}, {94, 14}} + {{10, 221}, {94, 14}} @@ -744,7 +744,6 @@ {{194, 13}, {34, 14}} - YES 67239424 @@ -759,7 +758,7 @@ 268 - {{10, 138}, {93, 18}} + {{10, 155}, {93, 18}} @@ -785,10 +784,34 @@ 25 + + + 268 + {{10, 52}, {248, 18}} + + + + YES + + -2080244224 + 16908288 + Remove from list when seeding completes + + + 1211912703 + 2 + + + + + 200 + 25 + + 268 - {{10, 118}, {230, 18}} + {{10, 135}, {230, 18}} @@ -812,7 +835,7 @@ 268 - {{10, 160}, {109, 18}} + {{10, 177}, {109, 18}} @@ -836,7 +859,7 @@ 268 - {{109, 200}, {98, 22}} + {{109, 217}, {98, 22}} @@ -916,7 +939,7 @@ - {321, 241} + {321, 258} @@ -1160,6 +1183,30 @@ 112 + + + fRemovesSeedingCompleteCheck + + + + 117 + + + + fRemoveSeedingCompleteCheck + + + + 118 + + + + setRemoveWhenSeedingCompletes: + + + + 119 + delegate @@ -1256,6 +1303,7 @@ + Options @@ -1709,6 +1757,19 @@ + + 113 + + + + + + + + 114 + + + @@ -1722,6 +1783,8 @@ ColorTextField com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1797,7 +1860,7 @@ - 112 + 119 @@ -1812,6 +1875,60 @@ InfoOptionsViewController NSViewController + + id + id + id + id + id + id + id + id + id + id + + + + setIdleLimit: + id + + + setIdleSetting: + id + + + setPeersConnectLimit: + id + + + setPriority: + id + + + setRatioLimit: + id + + + setRatioSetting: + id + + + setRemoveWhenSeedingCompletes: + id + + + setSpeedLimit: + id + + + setUseGlobalSpeedLimit: + id + + + setUseSpeedLimit: + id + + NSButton NSTextField @@ -1827,6 +1944,7 @@ NSTextField NSTextField NSPopUpButton + NSButton NSButton NSTextField NSTextField @@ -1888,6 +2006,10 @@ fRatioPopUp NSPopUpButton + + fRemoveSeedingCompleteCheck + NSButton + fUploadLimitCheck NSButton