Changeset 2449


Ignore:
Timestamp:
Jul 21, 2007, 3:13:11 AM (15 years ago)
Author:
livings124
Message:

merge upload and download speed methods

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r2448 r2449  
    459459        torrent = [enumerator nextObject]; //first torrent
    460460       
    461         int uploadSpeedMode = [torrent uploadSpeedMode],
    462             uploadSpeedLimit = [torrent uploadSpeedLimit],
    463             downloadSpeedMode = [torrent downloadSpeedMode],
    464             downloadSpeedLimit = [torrent downloadSpeedLimit];
     461        int uploadSpeedMode = [torrent speedMode: YES],
     462            uploadSpeedLimit = [torrent speedLimit: YES],
     463            downloadSpeedMode = [torrent speedMode: NO],
     464            downloadSpeedLimit = [torrent speedLimit: NO];
    465465       
    466466        while ((uploadSpeedMode != INVALID || uploadSpeedLimit != INVALID
     
    468468                && (torrent = [enumerator nextObject]))
    469469        {
    470             if (uploadSpeedMode != INVALID && uploadSpeedMode != [torrent uploadSpeedMode])
     470            if (uploadSpeedMode != INVALID && uploadSpeedMode != [torrent speedMode: YES])
    471471                uploadSpeedMode = INVALID;
    472472           
    473             if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent uploadSpeedLimit])
     473            if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit: YES])
    474474                uploadSpeedLimit = INVALID;
    475475           
    476             if (downloadSpeedMode != INVALID && downloadSpeedMode != [torrent downloadSpeedMode])
     476            if (downloadSpeedMode != INVALID && downloadSpeedMode != [torrent speedMode: NO])
    477477                downloadSpeedMode = INVALID;
    478478           
    479             if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent downloadSpeedLimit])
     479            if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit: NO])
    480480                downloadSpeedLimit = INVALID;
    481481        }
     
    11101110    NSEnumerator * enumerator = [fTorrents objectEnumerator];
    11111111    while ((torrent = [enumerator nextObject]))
    1112         upload ? [torrent setUploadSpeedMode: mode] : [torrent setDownloadSpeedMode: mode];
     1112        [torrent setSpeedMode: mode upload: upload];
    11131113   
    11141114    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
     
    11391139       
    11401140        torrent = [enumerator nextObject]; //use first torrent
    1141         limit = upload ? [torrent uploadSpeedLimit] : [torrent downloadSpeedLimit];
     1141        limit = [torrent speedLimit: upload];
    11421142        while ((torrent = [enumerator nextObject]))
    1143             if (limit != (upload ? [torrent uploadSpeedLimit] : [torrent downloadSpeedLimit]))
     1143            if (limit != [torrent speedLimit: upload])
    11441144            {
    11451145                [sender setStringValue: @""];
     
    11521152    {
    11531153        while ((torrent = [enumerator nextObject]))
    1154             upload ? [torrent setUploadSpeedLimit: limit] : [torrent setDownloadSpeedLimit: limit];
     1154            [torrent setSpeedLimit: limit upload: upload];
    11551155    }
    11561156}
  • trunk/macosx/Torrent.h

    r2447 r2449  
    105105- (float) progressStopRatio;
    106106
    107 #warning merge up and down?
    108 - (int) uploadSpeedMode;
    109 - (void) setUploadSpeedMode: (int) mode;
    110 - (int) uploadSpeedLimit;
    111 - (void) setUploadSpeedLimit: (int) limit;
    112 - (int) downloadSpeedMode;
    113 - (void) setDownloadSpeedMode: (int) mode;
    114 - (int) downloadSpeedLimit;
    115 - (void) setDownloadSpeedLimit: (int) limit;
     107- (int) speedMode: (BOOL) upload;
     108- (void) setSpeedMode: (int) mode upload: (BOOL) upload;
     109- (int) speedLimit: (BOOL) upload;
     110- (void) setSpeedLimit: (int) limit upload: (BOOL) upload;
    116111
    117112- (void) setWaitToStart: (BOOL) wait;
  • trunk/macosx/Torrent.m

    r2447 r2449  
    627627}
    628628
    629 - (int) uploadSpeedMode
    630 {
    631     return tr_torrentGetSpeedMode(fHandle, TR_UP);
    632 }
    633 
    634 - (void) setUploadSpeedMode: (int) mode
    635 {
    636     tr_torrentSetSpeedMode(fHandle, TR_UP, mode);
    637 }
    638 
    639 - (int) uploadSpeedLimit
    640 {
    641     return tr_torrentGetSpeedLimit(fHandle, TR_UP);
    642 }
    643 
    644 - (void) setUploadSpeedLimit: (int) limit
    645 {
    646     tr_torrentSetSpeedLimit(fHandle, TR_UP, limit);
    647 }
    648 
    649 - (int) downloadSpeedMode
    650 {
    651     return tr_torrentGetSpeedMode(fHandle, TR_DOWN);
    652 }
    653 
    654 - (void) setDownloadSpeedMode: (int) mode
    655 {
    656     tr_torrentSetSpeedMode(fHandle, TR_DOWN, mode);
    657 }
    658 
    659 - (int) downloadSpeedLimit
    660 {
    661     return tr_torrentGetSpeedLimit(fHandle, TR_DOWN);
    662 }
    663 
    664 - (void) setDownloadSpeedLimit: (int) limit
    665 {
    666     tr_torrentSetSpeedLimit(fHandle, TR_DOWN, limit);
     629- (int) speedMode: (BOOL) upload
     630{
     631    return tr_torrentGetSpeedMode(fHandle, upload ? TR_UP : TR_DOWN);
     632}
     633
     634- (void) setSpeedMode: (int) mode upload: (BOOL) upload
     635{
     636    tr_torrentSetSpeedMode(fHandle, upload ? TR_UP : TR_DOWN, mode);
     637}
     638
     639- (int) uploadSpeedLimit: (BOOL) upload
     640{
     641    return tr_torrentGetSpeedLimit(fHandle, upload ? TR_UP : TR_DOWN);
     642}
     643
     644- (void) setUploadSpeedLimit: (int) limit upload: (BOOL) upload
     645{
     646    tr_torrentSetSpeedLimit(fHandle, upload ? TR_UP : TR_DOWN, limit);
    667647}
    668648
     
    18301810
    18311811    fQuickPauseDict = [[NSDictionary alloc] initWithObjectsAndKeys:
    1832                     [NSNumber numberWithInt: [self uploadSpeedMode]], @"UploadSpeedMode",
    1833                     [NSNumber numberWithInt: [self uploadSpeedLimit]], @"UploadSpeedLimit",
    1834                     [NSNumber numberWithInt: [self downloadSpeedMode]], @"DownloadSpeedMode",
    1835                     [NSNumber numberWithInt: [self downloadSpeedLimit]], @"DownloadSpeedLimit", nil];
    1836    
    1837     [self setUploadSpeedMode: TR_SPEEDLIMIT_SINGLE];
    1838     [self setUploadSpeedLimit: 0];
    1839     [self setDownloadSpeedMode: TR_SPEEDLIMIT_SINGLE];
    1840     [self setDownloadSpeedLimit: 0];
     1812                    [NSNumber numberWithInt: [self speedMode: YES]], @"UploadSpeedMode",
     1813                    [NSNumber numberWithInt: [self speedLimit: YES]], @"UploadSpeedLimit",
     1814                    [NSNumber numberWithInt: [self speedMode: NO]], @"DownloadSpeedMode",
     1815                    [NSNumber numberWithInt: [self speedLimit: NO]], @"DownloadSpeedLimit", nil];
     1816   
     1817    [self setSpeedMode: TR_SPEEDLIMIT_SINGLE upload: YES];
     1818    [self setSpeedLimit: 0 upload: YES];
     1819    [self setSpeedMode: TR_SPEEDLIMIT_SINGLE upload: NO];
     1820    [self setSpeedLimit: 0 upload: NO];
    18411821}
    18421822
     
    18461826        return
    18471827   
    1848     [self setUploadSpeedMode: [[fQuickPauseDict objectForKey: @"UploadSpeedMode"] intValue]];
    1849     [self setUploadSpeedLimit: [[fQuickPauseDict objectForKey: @"UploadSpeedLimit"] intValue]];
    1850     [self setDownloadSpeedMode: [[fQuickPauseDict objectForKey: @"DownloadSpeedMode"] intValue]];
    1851     [self setDownloadSpeedLimit: [[fQuickPauseDict objectForKey: @"DownloadSpeedLimit"] intValue]];
     1828    [self setSpeedMode: [[fQuickPauseDict objectForKey: @"UploadSpeedMode"] intValue] upload: YES];
     1829    [self setSpeedLimit: [[fQuickPauseDict objectForKey: @"UploadSpeedLimit"] intValue] upload: YES];
     1830    [self setSpeedMode: [[fQuickPauseDict objectForKey: @"DownloadSpeedMode"] intValue] upload: NO];
     1831    [self setSpeedLimit: [[fQuickPauseDict objectForKey: @"DownloadSpeedLimit"] intValue] upload: NO];
    18521832   
    18531833    [fQuickPauseDict release];
Note: See TracChangeset for help on using the changeset viewer.