Changeset 107 for trunk/macosx/Controller.m
- Timestamp:
- Feb 8, 2006, 7:05:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r106 r107 224 224 [fBadger release]; 225 225 226 // Save history and stop running torrents 227 NSMutableArray * history = [NSMutableArray arrayWithCapacity: fCount]; 228 BOOL active; 226 // Save history 227 [self updateTorrentHistory]; 228 229 // Stop running torrents 229 230 for( i = 0; i < fCount; i++ ) 230 { 231 active = fStat[i].status & 232 ( TR_STATUS_CHECK | TR_STATUS_DOWNLOAD | TR_STATUS_SEED ); 233 234 [history addObject: [NSDictionary dictionaryWithObjectsAndKeys: 235 [NSString stringWithUTF8String: fStat[i].info.torrent], 236 @"TorrentPath", 237 [NSString stringWithUTF8String: tr_torrentGetFolder( fHandle, i )], 238 @"DownloadFolder", 239 active ? @"NO" : @"YES", 240 @"Paused", 241 NULL]]; 242 243 if( active ) 244 { 231 if( fStat[i].status & ( TR_STATUS_CHECK | TR_STATUS_DOWNLOAD | 232 TR_STATUS_SEED ) ) 245 233 tr_torrentStop( fHandle, i ); 246 }247 }248 [fDefaults setObject: history forKey: @"History"];249 234 250 235 // Wait for torrents to stop (5 seconds timeout) … … 352 337 353 338 [self updateUI: NULL]; 339 [self updateTorrentHistory]; 354 340 } 355 341 … … 431 417 tr_torrentStart( fHandle, idx ); 432 418 [self updateUI: NULL]; 419 [self updateTorrentHistory]; 433 420 } 434 421 … … 455 442 tr_torrentStop( fHandle, idx ); 456 443 [self updateUI: NULL]; 444 [self updateTorrentHistory]; 457 445 } 458 446 … … 528 516 tr_torrentClose( fHandle, idx ); 529 517 [self updateUI: NULL]; 518 [self updateTorrentHistory]; 530 519 } 531 520 … … 617 606 downloadRate: dl >= 0.1 && [defaults boolForKey: @"BadgeDownloadRate"] 618 607 ? [NSString stringForSpeedAbbrev: dl] : nil]; 608 } 609 610 - (void) updateTorrentHistory 611 { 612 if( !fStat ) 613 return; 614 615 NSMutableArray * history = [NSMutableArray arrayWithCapacity: fCount]; 616 617 int i; 618 for (i = 0; i < fCount; i++) 619 [history addObject: [NSDictionary dictionaryWithObjectsAndKeys: 620 [NSString stringWithUTF8String: fStat[i].info.torrent], 621 @"TorrentPath", 622 [NSString stringWithUTF8String: tr_torrentGetFolder( fHandle, i )], 623 @"DownloadFolder", 624 fStat[i].status & (TR_STATUS_CHECK | TR_STATUS_DOWNLOAD | 625 TR_STATUS_SEED) ? @"NO" : @"YES", 626 @"Paused", 627 nil]]; 628 629 [fDefaults setObject: history forKey: @"History"]; 619 630 } 620 631
Note: See TracChangeset
for help on using the changeset viewer.