Changeset 10878


Ignore:
Timestamp:
Jun 26, 2010, 6:52:05 PM (13 years ago)
Author:
livings124
Message:

(2.0x) #3320 When a download completes at the same time seeding completes, still show a Growl notification and play a sound

Location:
branches/2.0x
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0x/libtransmission/peer-mgr.c

    r10876 r10878  
    31323132    }
    31333133
    3134     /* possibly stop torrents that have an error */
     3134    /* stop torrents that are ready to stop, but couldn't be stopped earlier
     3135    * during the peer-io callback call chain */
    31353136    tor = NULL;
    31363137    while(( tor = tr_torrentNext( mgr->session, tor )))
    3137         if( tor->isRunning && ( tor->error == TR_STAT_LOCAL_ERROR ))
     3138        if( tor->isStopping )
    31383139            tr_torrentStop( tor );
    31393140
  • branches/2.0x/libtransmission/rpcimpl.c

    r10638 r10878  
    222222    {
    223223        tr_torrent * tor = torrents[i];
     224
    224225        if( tor->isRunning )
    225226        {
    226             tr_torrentStop( tor );
     227            tor->isStopping = TRUE;
    227228            notify( session, TR_RPC_TORRENT_STOPPED, tor );
    228229        }
  • branches/2.0x/libtransmission/torrent.c

    r10862 r10878  
    322322        tr_torinf( tor, "Seed ratio reached; pausing torrent" );
    323323
    324         tr_torrentStop( tor );
     324        tor->isStopping = TRUE;
    325325
    326326        /* maybe notify the client */
     
    347347    evutil_vsnprintf( tor->errorString, sizeof( tor->errorString ), fmt, ap );
    348348    va_end( ap );
     349
     350    if( tor->isRunning )
     351        tor->isStopping = TRUE;
    349352}
    350353
     
    13611364    {
    13621365        tr_torrentSetLocalError( tor, _( "No data found!  Reconnect any disconnected drives, use \"Set Location\", or restart the torrent to re-download." ) );
    1363         tr_torrentStop( tor );
    13641366    }
    13651367    else
     
    14441446    {
    14451447        tr_torrentSetLocalError( tor, _( "Can't find local data.  Try \"Set Location\" to find it, or restart the torrent to re-download." ) );
    1446         tr_torrentStop( tor );
    14471448    }
    14481449    else if( tor->startAfterVerify )
     
    15341535
    15351536        tor->isRunning = 0;
     1537        tor->isStopping = 0;
    15361538        tr_torrentSetDirty( tor );
    15371539        tr_runInEventThread( tor->session, stopTorrent, tor );
     
    16191621static void
    16201622fireCompletenessChange( tr_torrent       * tor,
    1621                         tr_completeness    status )
     1623                        tr_completeness    status,
     1624                        tr_bool            wasRunning )
    16221625{
    16231626    assert( tr_isTorrent( tor ) );
     
    16271630
    16281631    if( tor->completeness_func )
    1629         tor->completeness_func( tor, status, tor->completeness_func_user_data );
     1632        tor->completeness_func( tor, status, wasRunning,
     1633                                tor->completeness_func_user_data );
    16301634}
    16311635
     
    16971701tr_torrentRecheckCompleteness( tr_torrent * tor )
    16981702{
     1703    tr_bool wasRunning;
    16991704    tr_completeness completeness;
    17001705
     
    17041709
    17051710    completeness = tr_cpGetStatus( &tor->completion );
     1711    wasRunning = tor->isRunning;
    17061712
    17071713    if( completeness != tor->completeness )
     
    17361742        }
    17371743
    1738         fireCompletenessChange( tor, completeness );
     1744        fireCompletenessChange( tor, wasRunning, completeness );
    17391745
    17401746        tr_torrentSetDirty( tor );
  • branches/2.0x/libtransmission/torrent.h

    r10843 r10878  
    232232
    233233    tr_bool                    isRunning;
     234    tr_bool                    isStopping;
    234235    tr_bool                    isDeleting;
    235236    tr_bool                    startAfterVerify;
  • branches/2.0x/libtransmission/transmission.h

    r10697 r10878  
    12771277tr_completeness;
    12781278
     1279/**
     1280* @param wasRunning whether or not the torrent was running when
     1281*                   it changed its completeness state
     1282*/
    12791283typedef void ( tr_torrent_completeness_func )( tr_torrent       * torrent,
    12801284                                               tr_completeness    completeness,
     1285                                               tr_bool            wasRunning,
    12811286                                               void             * user_data );
    12821287
  • branches/2.0x/macosx/Controller.m

    r10559 r10878  
    18891889    Torrent * torrent = [notification object];
    18901890   
    1891     if ([torrent isActive])
     1891    if ([[[notification userInfo] objectForKey: @"WasRunning"] boolValue])
    18921892    {
    18931893        if (!fSoundPlaying && [fDefaults boolForKey: @"PlayDownloadSound"])
     
    19191919            object: [torrent dataLocation]];
    19201920       
    1921         if ([fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] == 0)
     1921        if ([torrent isActive] && [fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] == 0)
    19221922        {
    19231923            [torrent stopTransfer];
     
    19321932{
    19331933    Torrent * torrent = [notification object];
    1934     if ([torrent isActive])
    1935     {
    1936         if ([fDefaults boolForKey: @"Queue"] && [self numToStartFromQueue: YES] == 0)
    1937         {
    1938             [torrent stopTransfer];
    1939             [torrent setWaitToStart: YES];
    1940         }
     1934    if ([torrent isActive] && [fDefaults boolForKey: @"Queue"] && [self numToStartFromQueue: YES] == 0)
     1935    {
     1936        [torrent stopTransfer];
     1937        [torrent setWaitToStart: YES];
    19411938    }
    19421939   
  • branches/2.0x/macosx/Torrent.m

    r10712 r10878  
    4444    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList;
    4545
    46 - (void) completenessChange: (NSNumber *) status;
     46- (void) completenessChange: (NSDictionary *) statusInfo;
    4747- (void) ratioLimitHit;
    4848- (void) metadataRetrieved;
     
    5454@end
    5555
    56 void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, void * torrentData)
    57 {
    58     [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:)
    59         withObject: [[NSNumber alloc] initWithInt: status] waitUntilDone: NO];
     56void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, tr_bool wasRunning, void * torrentData)
     57{
     58    NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: status], @"Status",
     59                            [NSNumber numberWithBool: wasRunning], @"WasRunning", nil];
     60    [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
    6061}
    6162
     
    17481749
    17491750//status has been retained
    1750 - (void) completenessChange: (NSNumber *) status
     1751- (void) completenessChange: (NSDictionary *) statusInfo
    17511752{
    17521753    fStat = tr_torrentStat(fHandle); //don't call update yet to avoid auto-stop
    17531754   
    1754     switch ([status intValue])
     1755    switch ([[statusInfo objectForKey: @"Status"] intValue])
    17551756    {
    17561757        case TR_SEED:
    17571758        case TR_PARTIAL_SEED:
    1758             [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
     1759            //simpler to create a new dictionary than to use statusInfo - avoids retention chicanery
     1760            [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self
     1761                userInfo: [NSDictionary dictionaryWithObject: [statusInfo objectForKey: @"WasRunning"] forKey: @"WasRunning"]];
    17591762            break;
    17601763       
     
    17631766            break;
    17641767    }
    1765     [status release];
     1768    [statusInfo release];
    17661769   
    17671770    [self update];
Note: See TracChangeset for help on using the changeset viewer.