Changeset 1289


Ignore:
Timestamp:
Dec 27, 2006, 2:57:55 AM (15 years ago)
Author:
livings124
Message:

individual download/upload speed caps accessible under options in the inspector

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r1285 r1289  
    11551155    Torrent * torrent = [notification object];
    11561156   
    1157     [fInfoController updateInfoSettings];
     1157    [fInfoController updateInfoStats];
    11581158   
    11591159    [self applyFilter: nil];
     
    16491649    [self applyFilter: nil];
    16501650    [fInfoController updateInfoStats];
    1651     [fInfoController updateInfoSettings];
    16521651   
    16531652    if ([fDefaults boolForKey: @"PlaySeedingSound"])
  • trunk/macosx/English.lproj/InfoWindow.nib/classes.nib

    r1242 r1289  
    1313                revealFile = id;
    1414                revealTorrentFile = id;
     15                setLimitCheck = id;
    1516                setRatioCheck = id;
    1617                setRatioLimit = id;
     18                setSpeedLimit = id;
    1719            };
    1820            CLASS = InfoWindowController;
     
    2628                fDateCreatedField = NSTextField;
    2729                fDateStartedField = NSTextField;
     30                fDownloadLimitCheck = NSButton;
     31                fDownloadLimitField = NSTextField;
    2832                fDownloadedTotalField = NSTextField;
    2933                fDownloadedValidField = NSTextField;
     
    5256                fTorrentLocationField = NSTextField;
    5357                fTrackerField = NSTextField;
     58                fUploadLimitCheck = NSButton;
     59                fUploadLimitField = NSTextField;
    5460                fUploadedTotalField = NSTextField;
    5561                fUploadingToField = NSTextField;
  • trunk/macosx/InfoWindowController.h

    r1256 r1289  
    5757    IBOutlet NSTextField * fFileTableStatusField;
    5858   
     59    IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck;
    5960    IBOutlet NSMatrix * fRatioMatrix;
    60     IBOutlet NSTextField * fRatioLimitField;
     61    IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField;
    6162}
    6263
    6364- (void) updateInfoForTorrents: (NSArray *) torrents;
    6465- (void) updateInfoStats;
    65 - (void) updateInfoSettings;
    6666
    6767- (void) setNextTab;
     
    7272- (void) revealFile: (id) sender;
    7373
     74- (void) setLimitCheck: (id) sender;
     75- (void) setSpeedLimit: (id) sender;
     76
    7477- (void) setRatioCheck: (id) sender;
    7578- (void) setRatioLimit: (id) sender;
  • trunk/macosx/InfoWindowController.m

    r1283 r1289  
    4444#define TAB_PEERS_HEIGHT 268.0
    4545#define TAB_FILES_HEIGHT 268.0
    46 #define TAB_OPTIONS_HEIGHT 83.0
     46#define TAB_OPTIONS_HEIGHT 147.0
    4747
    4848#define INVALID -99
     
    5353- (void) updateInfoActivity;
    5454- (void) updateInfoPeers;
     55- (void) updateInfoSettings;
    5556
    5657- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
     
    294295   
    295296    Torrent * torrent = [fTorrents objectAtIndex: 0];
     297   
    296298    NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]];
    297299    [fTrackerField setStringValue: tracker];
    298300    [fTrackerField setToolTip: tracker];
     301   
     302    NSString * location = [torrent dataLocation];
     303    [fDataLocationField setStringValue: [location stringByAbbreviatingWithTildeInPath]];
     304    [fDataLocationField setToolTip: location];
    299305}
    300306
     
    375381        Torrent * torrent;
    376382       
    377         if (numberSelected == 1)
     383        //set bandwidth limits
     384        NSEnumerator * enumerator = [fTorrents objectEnumerator];
     385        torrent = [enumerator nextObject]; //first torrent
     386       
     387        int checkUpload = [torrent checkUpload] ? 1 : 0,
     388            checkDownload = [torrent checkDownload] ? 1 : 0,
     389            uploadLimit = [torrent uploadLimit],
     390            downloadLimit = [torrent downloadLimit];
     391       
     392        while ((checkUpload != INVALID || uploadLimit != INVALID
     393                || checkDownload != INVALID || downloadLimit != INVALID)
     394                && (torrent = [enumerator nextObject]))
    378395        {
    379             torrent = [fTorrents objectAtIndex: 0];
    380             [fDataLocationField setStringValue: [[torrent dataLocation] stringByAbbreviatingWithTildeInPath]];
    381             [fDataLocationField setToolTip: [torrent dataLocation]];
     396            if (checkUpload != INVALID && checkUpload != ([torrent checkUpload] ? 1 : 0))
     397                checkUpload = INVALID;
     398           
     399            if (uploadLimit != INVALID && uploadLimit != [torrent uploadLimit])
     400                uploadLimit = INVALID;
     401           
     402            if (checkDownload != INVALID && checkDownload != ([torrent checkDownload] ? 1 : 0))
     403                checkDownload = INVALID;
     404           
     405            if (downloadLimit != INVALID && downloadLimit != [torrent downloadLimit])
     406                downloadLimit = INVALID;
    382407        }
    383408       
     409        [fUploadLimitCheck setEnabled: YES];
     410        [fDownloadLimitCheck setEnabled: YES];
     411       
     412        [fUploadLimitField setEnabled: checkUpload != 0];
     413        [fDownloadLimitField setEnabled: checkDownload != 0];
     414       
     415        [fUploadLimitCheck setState: checkUpload == INVALID ? NSMixedState
     416                                : (checkUpload == 1 ? NSOnState : NSOffState)];
     417       
     418        if (uploadLimit != INVALID)
     419            [fUploadLimitField setIntValue: uploadLimit];
     420        else
     421            [fUploadLimitField setStringValue: @""];
     422       
     423        [fDownloadLimitCheck setState: checkDownload == INVALID ? NSMixedState
     424                                : (checkDownload == 1 ? NSOnState : NSOffState)];
     425       
     426        if (downloadLimit != INVALID)
     427            [fDownloadLimitField setIntValue: downloadLimit];
     428        else
     429            [fDownloadLimitField setStringValue: @""];
     430       
    384431        //set ratio settings
    385         NSEnumerator * enumerator = [fTorrents objectEnumerator];
     432        enumerator = [fTorrents objectEnumerator];
    386433        torrent = [enumerator nextObject]; //first torrent
    387434       
     
    430477        [fRatioLimitField setEnabled: NO];
    431478        [fRatioLimitField setStringValue: @""];
     479       
     480        [fUploadLimitCheck setState: NSOffState];
     481        [fUploadLimitCheck setEnabled: NO];
     482        [fUploadLimitField setEnabled: NO];
     483        [fUploadLimitField setStringValue: @""];
     484       
     485        [fDownloadLimitCheck setState: NSOffState];
     486        [fDownloadLimitCheck setEnabled: NO];
     487        [fDownloadLimitField setEnabled: NO];
     488        [fDownloadLimitField setStringValue: @""];
    432489    }
    433490   
     
    471528    }
    472529    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
    473     {
    474530        height = TAB_PEERS_HEIGHT;
    475     }
    476531    else if ([identifier isEqualToString: TAB_FILES_IDENT])
    477532        height = TAB_FILES_HEIGHT;
     
    637692}
    638693
     694- (void) setLimitCheck: (id) sender
     695{
     696    BOOL upload = sender == fUploadLimitCheck,
     697        limit = [sender state] != NSOffState;
     698   
     699    if (limit)
     700        [sender setState: NSOnState];
     701   
     702    Torrent * torrent;
     703    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     704    while ((torrent = [enumerator nextObject]))
     705        upload ? [torrent setLimitUpload: limit] : [torrent setLimitDownload: limit];
     706   
     707    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
     708   
     709    if (![[field stringValue] isEqualToString: @""])
     710        [self setSpeedLimit: field];
     711   
     712    [field setEnabled: limit];
     713}
     714
     715- (void) setSpeedLimit: (id) sender
     716{
     717    BOOL upload = sender == fUploadLimitField;
     718   
     719    Torrent * torrent;
     720    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     721
     722    int limit = [sender intValue];
     723    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%i", limit]] || limit < 0)
     724    {
     725        NSBeep();
     726       
     727        torrent = [enumerator nextObject]; //use first torrent
     728       
     729        limit = upload ? [torrent uploadLimit] : [torrent downloadLimit];
     730        while ((torrent = [enumerator nextObject]))
     731            if (limit != upload ? [torrent uploadLimit] : [torrent downloadLimit])
     732            {
     733                [sender setStringValue: @""];
     734                return;
     735            }
     736       
     737        [sender setIntValue: limit];
     738    }
     739    else
     740    {
     741        while ((torrent = [enumerator nextObject]))
     742            upload ? [torrent setUploadLimit: limit] : [torrent setDownloadLimit: limit];
     743    }
     744}
     745
    639746- (void) setRatioCheck: (id) sender
    640747{
  • trunk/macosx/Torrent.h

    r1285 r1289  
    5151    NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
    5252   
    53     int     fStopRatioSetting;
     53   
     54    int     fUploadLimit, fDownloadLimit, fStopRatioSetting;
    5455    float   fRatioLimit;
    55     BOOL    fFinishedSeeding, fWaitToStart, fError;
     56    BOOL    fCheckUpload, fCheckDownload, fFinishedSeeding, fWaitToStart, fError;
    5657   
    5758    int fOrderValue;
     
    8990- (float)       ratioLimit;
    9091- (void)        setRatioLimit: (float) limit;
     92
     93- (void) setLimitUpload: (BOOL) limit;
     94- (void) setUploadLimit: (int) limit;
     95- (void) setLimitDownload: (BOOL) limit;
     96- (void) setDownloadLimit: (int) limit;
     97- (BOOL) checkUpload;
     98- (int) uploadLimit;
     99- (BOOL) checkDownload;
     100- (int) downloadLimit;
    91101
    92102- (void) setWaitToStart: (BOOL) wait;
  • trunk/macosx/Torrent.m

    r1285 r1289  
    3636        publicTorrent: (NSNumber *) publicTorrent
    3737        date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
    38         ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart
    39         orderValue: (NSNumber *) orderValue;
     38        ratioLimit: (NSNumber *) ratioLimit
     39        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
     40        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
     41        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
    4042
    4143- (NSImage *) advancedBar;
     
    6365    self = [self initWithHash: nil path: path lib: lib
    6466            publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
    65             date: nil stopRatioSetting: nil ratioLimit: nil waitToStart: nil orderValue: nil];
     67            date: nil stopRatioSetting: nil ratioLimit: nil
     68            checkUpload: nil uploadLimit: nil
     69            checkDownload: nil downloadLimit: nil
     70            waitToStart: nil orderValue: nil];
    6671   
    6772    if (self)
     
    8489                stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
    8590                ratioLimit: [history objectForKey: @"RatioLimit"]
     91                checkUpload: [history objectForKey: @"CheckUpload"]
     92                uploadLimit: [history objectForKey: @"UploadLimit"]
     93                checkDownload: [history objectForKey: @"CheckDownload"]
     94                downloadLimit: [history objectForKey: @"DownloadLimit"]
    8695                waitToStart: [history objectForKey: @"WaitToStart"]
    8796                orderValue: [history objectForKey: @"OrderValue"]];
     
    133142                    [NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
    134143                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
     144                    [NSNumber numberWithBool: fCheckUpload], @"CheckUpload",
     145                    [NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
     146                    [NSNumber numberWithBool: fCheckDownload], @"CheckDownload",
     147                    [NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
    135148                    [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
    136149                    [self orderValue], @"OrderValue", nil];
     
    507520}
    508521
     522- (void) setLimitUpload: (BOOL) limit
     523{
     524    fCheckUpload = limit;
     525    tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     526}
     527
     528- (void) setUploadLimit: (int) limit
     529{
     530    fUploadLimit = limit;
     531    tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     532}
     533
     534- (void) setLimitDownload: (BOOL) limit
     535{
     536    fCheckDownload = limit;
     537    tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
     538}
     539
     540- (void) setDownloadLimit: (int) limit
     541{
     542    fDownloadLimit = limit;
     543    tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
     544}
     545
     546- (BOOL) checkUpload
     547{
     548    return fCheckUpload;
     549}
     550
     551- (int) uploadLimit
     552{
     553    return fUploadLimit;
     554}
     555
     556- (BOOL) checkDownload
     557{
     558    return fCheckDownload;
     559}
     560
     561- (int) downloadLimit
     562{
     563    return fDownloadLimit;
     564}
     565
    509566- (void) setWaitToStart: (BOOL) wait
    510567{
     
    10381095        publicTorrent: (NSNumber *) publicTorrent
    10391096        date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
    1040         ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart
    1041         orderValue: (NSNumber *) orderValue
     1097        ratioLimit: (NSNumber *) ratioLimit
     1098        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
     1099        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
     1100        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
    10421101{
    10431102    if (!(self = [super init]))
     
    10711130    fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
    10721131    fFinishedSeeding = NO;
     1132   
     1133    fCheckUpload = checkUpload && [checkUpload boolValue];
     1134    fUploadLimit = uploadLimit ? [uploadLimit intValue] : 10;
     1135    tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     1136   
     1137    fCheckDownload = checkDownload && [checkDownload boolValue];
     1138    fDownloadLimit = downloadLimit ? [downloadLimit intValue] : 10;
     1139    tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
    10731140   
    10741141    fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"];
Note: See TracChangeset for help on using the changeset viewer.