Changeset 452
- Timestamp:
- Jun 23, 2006, 10:32:01 PM (16 years ago)
- Location:
- trunk/macosx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.h
r450 r452 133 133 - (void) ratioGlobalChange: (NSNotification *) notification; 134 134 135 - (void) checkWaitingForFinished: (NSNotification *) notification; 136 - (void) startSettingChange: (NSNotification *) notification; 135 - (void) checkWaitingForStopped: (NSNotification *) notification; 136 - (void) checkWaitingForFinished: (Torrent *) finishedTorrent; 137 - (void) torrentStartSettingChange: (NSNotification *) notification; 138 - (void) globalStartSettingChange: (NSNotification *) notification; 139 140 - (void) attemptToStartAuto: (Torrent *) torrent; 137 141 138 142 - (void) reloadInspector: (NSNotification *) notification; -
trunk/macosx/Controller.m
r450 r452 210 210 name: @"RatioGlobalChange" object: nil]; 211 211 212 [nc addObserver: self selector: @selector(checkWaitingForFinished:) 213 name: @"TorrentFinishedDownloading" object: nil]; 214 215 [nc addObserver: self selector: @selector(startSettingChange:) 216 name: @"StartSettingChange" object: nil]; 217 212 //check to start another because of stopped torrent 213 [nc addObserver: self selector: @selector(checkWaitingForStopped:) 214 name: @"StoppedDownloading" object: nil]; 215 216 //check all torrents for starting 217 [nc addObserver: self selector: @selector(globalStartSettingChange:) 218 name: @"GlobalStartSettingChange" object: nil]; 219 220 //check if torrent should now start 221 [nc addObserver: self selector: @selector(torrentStartSettingChange:) 222 name: @"TorrentStartSettingChange" object: nil]; 223 224 //change that just impacts the inspector 218 225 [nc addObserver: self selector: @selector(reloadInspector:) 219 226 name: @"TorrentSettingChange" object: nil]; … … 324 331 if (code == NSOKButton) 325 332 { 326 //setup for autostart327 NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];328 BOOL waitToStart = [startSetting isEqualToString: @"Wait"];329 int desiredActive, active = 0;330 if (waitToStart)331 {332 desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];333 Torrent * tempTorrent;334 NSEnumerator * enumerator = [fTorrents objectEnumerator];335 while ((tempTorrent = [enumerator nextObject]))336 if ([tempTorrent isActive] && ![tempTorrent isSeeding])337 active++;338 }339 340 333 [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]]; 341 if ((waitToStart && active < desiredActive) || [startSetting isEqualToString: @"Start"]) 342 [torrent startTransfer]; 334 [self attemptToStartAuto: torrent]; 343 335 [fTorrents addObject: torrent]; 336 [torrent update]; 344 337 345 338 [self torrentNumberChanged]; … … 352 345 { 353 346 NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath; 354 355 //setup for autostart356 NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];357 BOOL waitToStart = [startSetting isEqualToString: @"Wait"];358 int desiredActive, active = 0;359 if (waitToStart && ![downloadChoice isEqualToString: @"Ask"])360 {361 desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];362 Torrent * tempTorrent;363 NSEnumerator * enumerator = [fTorrents objectEnumerator];364 while ((tempTorrent = [enumerator nextObject]))365 if ([tempTorrent isActive] && ![tempTorrent isSeeding])366 active++;367 }368 369 347 Torrent * torrent; 370 348 NSEnumerator * enumerator = [filenames objectEnumerator]; … … 403 381 404 382 [torrent setDownloadFolder: folder]; 405 #warning should check if transfer was already done 406 if ((waitToStart && active < desiredActive) || [startSetting isEqualToString: @"Start"]) 407 { 408 [torrent startTransfer]; 409 active++; 410 } 383 [self attemptToStartAuto: torrent]; 411 384 [fTorrents addObject: torrent]; 385 [torrent update]; 412 386 } 413 387 … … 745 719 if ([torrent justFinished]) 746 720 { 721 [self checkWaitingForFinished: torrent]; 722 747 723 //notifications 748 724 [self notifyGrowl: [torrent name]]; … … 939 915 } 940 916 941 - (void) checkWaitingForFinished: (NSNotification *) notification 917 - (void) checkWaitingForStopped: (NSNotification *) notification 918 { 919 [self checkWaitingForFinished: [notification object]]; 920 } 921 922 - (void) checkWaitingForFinished: (Torrent *) finishedTorrent 942 923 { 943 924 //don't try to start a transfer if there should be none waiting … … 952 933 { 953 934 //ignore the torrent just stopped; for some reason it is not marked instantly as not active 954 if (torrent == [notification object])935 if (torrent == finishedTorrent) 955 936 continue; 956 937 … … 981 962 } 982 963 983 - (void) startSettingChange: (NSNotification *) notification964 - (void) globalStartSettingChange: (NSNotification *) notification 984 965 { 985 966 NSString * startSetting = [fDefaults stringForKey: @"StartSetting"]; … … 1049 1030 } 1050 1031 1032 - (void) torrentStartSettingChange: (NSNotification *) notification 1033 { 1034 [self attemptToStartAuto: [notification object]]; 1035 1036 [self updateUI: nil]; 1037 [self updateTorrentHistory]; 1038 } 1039 1040 //will try to start, taking into consideration the start preference 1041 - (void) attemptToStartAuto: (Torrent *) torrent 1042 { 1043 #warning should check if transfer was already done 1044 if (![torrent waitingToStart]) 1045 return; 1046 1047 NSString * startSetting = [fDefaults stringForKey: @"StartSetting"]; 1048 if ([startSetting isEqualToString: @"Wait"]) 1049 { 1050 int desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"]; 1051 1052 Torrent * tempTorrent; 1053 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 1054 while ((tempTorrent = [enumerator nextObject])) 1055 if ([tempTorrent isActive] && ![tempTorrent isSeeding]) 1056 { 1057 desiredActive--; 1058 if (desiredActive <= 0) 1059 return; 1060 } 1061 1062 [torrent startTransfer]; 1063 } 1064 else if ([startSetting isEqualToString: @"Start"]) 1065 [torrent startTransfer]; 1066 else; 1067 } 1068 1051 1069 - (void) reloadInspector: (NSNotification *) notification 1052 1070 { -
trunk/macosx/InfoWindowController.m
r451 r452 198 198 [fWaitToStartButton setState: [torrent waitingToStart]]; 199 199 200 [fWaitToStartButton setEnabled: ![torrent isActive] && [torrent progress] < 1.0 201 && [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"] isEqualToString: @"Wait"]]; 200 #warning disable if actively downloading or finished 201 [fWaitToStartButton setEnabled: 202 [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"] isEqualToString: @"Wait"]]; 202 203 } 203 204 else … … 471 472 - (void) setWaitToStart: (id) sender 472 473 { 473 BOOL wait = [sender state];474 475 474 Torrent * torrent; 476 475 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 477 476 while ((torrent = [enumerator nextObject])) 478 [torrent setWaitToStart: wait];479 480 [[NSNotificationCenter defaultCenter] postNotificationName: @" StartSettingChange" object: self];477 [torrent setWaitToStart: [sender state]]; 478 479 [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentStartSettingChange" object: torrent]; 481 480 } 482 481 -
trunk/macosx/PrefsController.m
r448 r452 453 453 [fDefaults setInteger: waitNumber forKey: @"WaitToStartNumber"]; 454 454 455 [[NSNotificationCenter defaultCenter] postNotificationName: @" StartSettingChange" object: self];455 [[NSNotificationCenter defaultCenter] postNotificationName: @"GlobalStartSettingChange" object: self]; 456 456 } 457 457 -
trunk/macosx/Torrent.m
r450 r452 244 244 245 245 tr_torrentStop(fHandle); 246 246 247 247 if (!wasSeeding) 248 [[NSNotificationCenter defaultCenter] postNotificationName: @" TorrentFinishedDownloading" object: self];248 [[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self]; 249 249 } 250 250 } … … 453 453 - (BOOL) justFinished 454 454 { 455 BOOL finished = tr_getFinished(fHandle); 456 if (finished) 457 [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self]; 458 459 return finished; 455 return tr_getFinished(fHandle); 460 456 } 461 457 … … 598 594 599 595 fWaitToStart = waitToStart ? [waitToStart boolValue] 600 : [[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"];596 : ![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Manual"]; 601 597 602 598 NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
Note: See TracChangeset
for help on using the changeset viewer.