From f39eb233f8e1f1c95ef4b39c54ed8a62a40c7bd2 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 27 Jun 2007 00:42:06 +0000 Subject: [PATCH] reflect some of the changes in libT (some, which means it still doesn't compile ;)) --- macosx/Controller.m | 23 ++++++----------------- macosx/Torrent.m | 12 +++--------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 29c0a4650..25500ff46 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -544,7 +544,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //save history and stop running torrents [self updateTorrentHistory]; - [fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)]; + #warning check if all torrents are fully released + [fDisplayedTorrents removeAllObjects]; + [fTorrents removeAllObjects]; //disable NAT traversal tr_natTraversalEnable(fLib, 0); @@ -558,22 +560,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //clear badge [fBadger clearBadge]; - //wait for running transfers to stop (5 second timeout) + //wait for running transfers to stop and for NAT to be disabled (5 second timeout) NSDate * start = [NSDate date]; - BOOL timeUp = NO; - - enumerator = [fTorrents objectEnumerator]; - Torrent * torrent; - while (!timeUp && (torrent = [enumerator nextObject])) - while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0)) - { - usleep(100000); - [torrent update]; - } - - //wait for NAT to be disabled (same 5 second timeout) - while (!([start timeIntervalSinceNow] < -5.0) - && tr_handleStatus(fLib)->natTraversalStatus != TR_NAT_TRAVERSAL_DISABLED) + while ([start timeIntervalSinceNow] >= -5.0 + && (tr_torrentCount(fLib) > 0 || tr_handleStatus(fLib)->natTraversalStatus != TR_NAT_TRAVERSAL_DISABLED)) usleep(100000); } @@ -1207,7 +1197,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy { if (code == NSOKButton) { - //move torrent data file to new location NSEnumerator * enumerator = [torrents objectEnumerator]; Torrent * torrent; while ((torrent = [enumerator nextObject])) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index c76b7f899..8fe0dfaa6 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -387,7 +387,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 { NSString * tempString; - case TR_STATUS_PAUSE: + case TR_STATUS_STOPPED: if (fWaitToStart) { tempString = ![self allDownloaded] @@ -602,12 +602,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 } } -- (void) stopTransferForQuit -{ - if ([self isActive]) - tr_torrentStop(fHandle); -} - - (void) sleep { if ((fResumeOnWake = [self isActive])) @@ -1061,7 +1055,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 { switch( fStat->status ) { - case TR_STATUS_PAUSE: + case TR_STATUS_STOPPED: return NSLocalizedString(@"Paused", "Torrent -> status string"); break; @@ -1114,7 +1108,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (BOOL) isPaused { - return fStat->status == TR_STATUS_PAUSE; + return fStat->status == TR_STATUS_STOPPED; } - (BOOL) isWaitingToChecking