Changeset 1295


Ignore:
Timestamp:
Dec 28, 2006, 12:29:05 AM (16 years ago)
Author:
livings124
Message:

redone options tab of inspector...current settings for "stop at ratio" won't carry over

Location:
trunk/macosx
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Defaults.plist

    r1054 r1295  
    1919        <key>CheckDownload</key>
    2020        <false/>
     21        <key>CheckDownloadTorrent</key>
     22        <false/>
    2123        <key>CheckQuit</key>
    2224        <true/>
     
    2931        <key>CheckUpload</key>
    3032        <true/>
     33        <key>CheckUploadTorrent</key>
     34        <false/>
    3135        <key>DeleteOriginalTorrent</key>
    3236        <false/>
     
    3741        <key>DownloadLimit</key>
    3842        <integer>100</integer>
     43        <key>DownloadLimitTorrent</key>
     44        <integer>50</integer>
    3945        <key>DownloadSound</key>
    4046        <string>Glass</string>
     
    103109        <key>UploadLimit</key>
    104110        <integer>20</integer>
     111        <key>UploadLimitTorrent</key>
     112        <integer>20</integer>
    105113        <key>UseAdvancedBar</key>
    106114        <false/>
  • trunk/macosx/English.lproj/InfoWindow.nib/classes.nib

    r1289 r1295  
    1414                revealTorrentFile = id;
    1515                setLimitCheck = id;
    16                 setRatioCheck = id;
     16                setLimitCustom = id;
     17                setRatioCustom = id;
    1718                setRatioLimit = id;
     19                setRatioSetting = id;
    1820                setSpeedLimit = id;
    1921            };
     
    3941                fImageView = NSImageView;
    4042                fLeechersField = NSTextField;
     43                fLimitCustomCheck = NSButton;
    4144                fNameField = NSTextField;
    4245                fPeerTable = NSTableView;
    4346                fPiecesField = NSTextField;
    4447                fPiecesView = PiecesView;
     48                fRatioCustomCheck = NSButton;
    4549                fRatioField = NSTextField;
    4650                fRatioLimitField = NSTextField;
    47                 fRatioMatrix = NSMatrix;
     51                fRatioStopCheck = NSButton;
    4852                fRevealDataButton = NSButton;
    4953                fRevealTorrentButton = NSButton;
  • trunk/macosx/English.lproj/InfoWindow.nib/info.nib

    r1216 r1295  
    44<dict>
    55        <key>IBDocumentLocation</key>
    6         <string>69 61 356 240 0 0 1152 842 </string>
     6        <string>34 67 356 240 0 0 1152 842 </string>
    77        <key>IBEditorPositions</key>
    88        <dict>
  • trunk/macosx/English.lproj/PrefsWindow.nib/classes.nib

    r1054 r1295  
    77            ACTIONS = {
    88                applySpeedSettings = id;
     9                applyTorrentSpeedSetting = id;
    910                folderSheetShow = id;
    1011                helpForNetwork = id;
  • trunk/macosx/English.lproj/PrefsWindow.nib/info.nib

    r1058 r1295  
    44<dict>
    55        <key>IBDocumentLocation</key>
    6         <string>19 87 356 240 0 0 1152 842 </string>
     6        <string>19 79 356 240 0 0 1152 842 </string>
    77        <key>IBEditorPositions</key>
    88        <dict>
    99                <key>153</key>
    10                 <string>235 384 563 267 0 0 1152 842 </string>
     10                <string>180 392 571 335 0 0 1152 842 </string>
    1111                <key>28</key>
    12                 <string>294 434 563 290 0 0 1152 842 </string>
     12                <string>99 386 571 290 0 0 1152 842 </string>
    1313                <key>41</key>
    14                 <string>161 288 563 305 0 0 1152 842 </string>
     14                <string>290 426 571 305 0 0 1152 842 </string>
    1515                <key>66</key>
    16                 <string>294 507 563 144 0 0 1152 842 </string>
     16                <string>139 501 571 144 0 0 1152 842 </string>
    1717        </dict>
    1818        <key>IBFramework Version</key>
     
    2525        <array>
    2626                <integer>153</integer>
    27                 <integer>41</integer>
    2827        </array>
    2928        <key>IBSystem Version</key>
  • trunk/macosx/InfoWindowController.h

    r1289 r1295  
    5757    IBOutlet NSTextField * fFileTableStatusField;
    5858   
    59     IBOutlet NSButton * fUploadLimitCheck, * fDownloadLimitCheck;
    60     IBOutlet NSMatrix * fRatioMatrix;
     59    IBOutlet NSButton * fRatioCustomCheck, * fRatioStopCheck,
     60                    * fLimitCustomCheck, * fUploadLimitCheck, * fDownloadLimitCheck;
    6161    IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField;
    6262}
     
    7272- (void) revealFile: (id) sender;
    7373
     74- (void) setLimitCustom: (id) sender;
    7475- (void) setLimitCheck: (id) sender;
    7576- (void) setSpeedLimit: (id) sender;
    7677
    77 - (void) setRatioCheck: (id) sender;
     78- (void) setRatioCustom: (id) sender;
     79- (void) setRatioSetting: (id) sender;
    7880- (void) setRatioLimit: (id) sender;
    7981
  • trunk/macosx/InfoWindowController.m

    r1289 r1295  
    2626#import "StringAdditions.h"
    2727
    28 #define RATIO_GLOBAL_TAG 0
    29 #define RATIO_NO_CHECK_TAG 1
    30 #define RATIO_CHECK_TAG 2
    31 
    3228#define MIN_WINDOW_WIDTH 300
    3329#define MAX_WINDOW_WIDTH 5000
     
    4440#define TAB_PEERS_HEIGHT 268.0
    4541#define TAB_FILES_HEIGHT 268.0
    46 #define TAB_OPTIONS_HEIGHT 147.0
     42#define TAB_OPTIONS_HEIGHT 157.0
    4743
    4844#define INVALID -99
     
    385381        torrent = [enumerator nextObject]; //first torrent
    386382       
    387         int checkUpload = [torrent checkUpload] ? 1 : 0,
     383        int limitCustom = [torrent customLimitSetting] ? 1 : 0,
     384            checkUpload = [torrent checkUpload] ? 1 : 0,
    388385            checkDownload = [torrent checkDownload] ? 1 : 0,
    389386            uploadLimit = [torrent uploadLimit],
    390387            downloadLimit = [torrent downloadLimit];
    391388       
    392         while ((checkUpload != INVALID || uploadLimit != INVALID
     389        while ((limitCustom != INVALID
     390                || checkUpload != INVALID || uploadLimit != INVALID
    393391                || checkDownload != INVALID || downloadLimit != INVALID)
    394392                && (torrent = [enumerator nextObject]))
    395393        {
     394            if (limitCustom != INVALID && limitCustom != ([torrent customLimitSetting] ? 1 : 0))
     395                limitCustom = INVALID;
     396           
    396397            if (checkUpload != INVALID && checkUpload != ([torrent checkUpload] ? 1 : 0))
    397398                checkUpload = INVALID;
     
    407408        }
    408409       
    409         [fUploadLimitCheck setEnabled: YES];
    410         [fDownloadLimitCheck setEnabled: YES];
    411        
    412         [fUploadLimitField setEnabled: checkUpload != 0];
    413         [fDownloadLimitField setEnabled: checkDownload != 0];
    414        
     410        [fLimitCustomCheck setEnabled: YES];
     411        [fLimitCustomCheck setState: limitCustom == INVALID ? NSMixedState
     412                                : (limitCustom == 1 ? NSOnState : NSOffState)];
     413       
     414        [fUploadLimitCheck setEnabled: limitCustom == 1];
    415415        [fUploadLimitCheck setState: checkUpload == INVALID ? NSMixedState
    416416                                : (checkUpload == 1 ? NSOnState : NSOffState)];
    417417       
     418        [fDownloadLimitCheck setEnabled: limitCustom == 1];
     419        [fDownloadLimitCheck setState: checkDownload == INVALID ? NSMixedState
     420                                : (checkDownload == 1 ? NSOnState : NSOffState)];
     421       
     422        [fUploadLimitField setEnabled: limitCustom == 1 && checkUpload == 1];
    418423        if (uploadLimit != INVALID)
    419424            [fUploadLimitField setIntValue: uploadLimit];
    420425        else
    421426            [fUploadLimitField setStringValue: @""];
    422        
    423         [fDownloadLimitCheck setState: checkDownload == INVALID ? NSMixedState
    424                                 : (checkDownload == 1 ? NSOnState : NSOffState)];
    425        
     427
     428        [fDownloadLimitField setEnabled: limitCustom == 1 && checkDownload == 1];
    426429        if (downloadLimit != INVALID)
    427430            [fDownloadLimitField setIntValue: downloadLimit];
     
    433436        torrent = [enumerator nextObject]; //first torrent
    434437       
    435         int ratioSetting = [torrent stopRatioSetting];
     438        int ratioCustom = [torrent customRatioSetting] ? 1 : 0,
     439            ratioStop = [torrent shouldStopAtRatio];
    436440        float ratioLimit = [torrent ratioLimit];
    437441       
    438         while ((ratioSetting != INVALID || ratioLimit != INVALID)
     442        while ((ratioCustom != INVALID || ratioStop != INVALID || ratioLimit != INVALID)
    439443                && (torrent = [enumerator nextObject]))
    440444        {
    441             if (ratioSetting != INVALID && ratioSetting != [torrent stopRatioSetting])
    442                 ratioSetting = INVALID;
     445            if (ratioCustom != INVALID && ratioCustom != ([torrent customRatioSetting] ? 1 : 0))
     446                ratioCustom = INVALID;
     447           
     448            if (ratioStop != INVALID && ratioStop != ([torrent shouldStopAtRatio] ? 1 : 0))
     449                ratioStop = INVALID;
    443450           
    444451            if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
     
    446453        }
    447454       
    448         [fRatioMatrix setEnabled: YES];
    449        
    450         if (ratioSetting == RATIO_CHECK)
    451         {
    452             [fRatioMatrix selectCellWithTag: RATIO_CHECK_TAG];
    453             [fRatioLimitField setEnabled: YES];
    454         }
    455         else
    456         {
    457             if (ratioSetting == RATIO_NO_CHECK)
    458                 [fRatioMatrix selectCellWithTag: RATIO_NO_CHECK_TAG];
    459             else if (ratioSetting == RATIO_GLOBAL)
    460                 [fRatioMatrix selectCellWithTag: RATIO_GLOBAL_TAG];
    461             else
    462                 [fRatioMatrix deselectAllCells];
    463            
    464             [fRatioLimitField setEnabled: NO];
    465         }
    466        
     455        [fRatioCustomCheck setEnabled: YES];
     456        [fRatioCustomCheck setState: ratioCustom == INVALID ? NSMixedState
     457                                : (ratioCustom == 1 ? NSOnState : NSOffState)];
     458       
     459        [fRatioStopCheck setEnabled: ratioCustom == 1];
     460        [fRatioStopCheck setState: ratioStop == INVALID ? NSMixedState
     461                                : (ratioStop == 1 ? NSOnState : NSOffState)];
     462       
     463        [fRatioLimitField setEnabled: ratioCustom == 1 && ratioStop == 1];
    467464        if (ratioLimit != INVALID)
    468465            [fRatioLimitField setFloatValue: ratioLimit];
     
    472469    else
    473470    {
    474         [fRatioMatrix deselectAllCells];
    475         [fRatioMatrix setEnabled: NO];
    476        
     471        [fLimitCustomCheck setEnabled: NO];
     472        [fLimitCustomCheck setState: NSOffState];
     473       
     474        [fUploadLimitCheck setEnabled: NO];
     475        [fUploadLimitCheck setState: NSOffState];
     476        [fUploadLimitField setEnabled: NO];
     477        [fUploadLimitField setStringValue: @""];
     478       
     479        [fDownloadLimitCheck setEnabled: NO];
     480        [fDownloadLimitCheck setState: NSOffState];
     481        [fDownloadLimitField setEnabled: NO];
     482        [fDownloadLimitField setStringValue: @""];
     483       
     484        [fRatioCustomCheck setEnabled: NO];
     485        [fRatioCustomCheck setState: NSOffState];
     486        [fRatioStopCheck setEnabled: NO];
     487        [fRatioStopCheck setState: NSOffState];
    477488        [fRatioLimitField setEnabled: NO];
    478489        [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: @""];
    489490    }
    490491   
     
    692693}
    693694
     695- (void) setLimitCustom: (id) sender
     696{
     697    BOOL custom = [sender state] != NSOffState;
     698    if (custom)
     699        [sender setState: NSOnState];
     700
     701    Torrent * torrent;
     702    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     703    while ((torrent = [enumerator nextObject]))
     704        [torrent setCustomLimitSetting: custom];
     705   
     706    [fUploadLimitCheck setEnabled: custom];
     707    [fUploadLimitField setEnabled: custom && [fUploadLimitCheck state] == NSOnState];
     708   
     709    [fDownloadLimitCheck setEnabled: custom];
     710    [fDownloadLimitField setEnabled: custom && [fDownloadLimitCheck state] == NSOnState];
     711}
     712
    694713- (void) setLimitCheck: (id) sender
    695714{
     
    706725   
    707726    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
    708    
    709     if (![[field stringValue] isEqualToString: @""])
    710         [self setSpeedLimit: field];
    711727   
    712728    [field setEnabled: limit];
     
    744760}
    745761
    746 - (void) setRatioCheck: (id) sender
    747 {
    748     int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];
    749     if (tag == RATIO_CHECK_TAG)
    750         ratioSetting = RATIO_CHECK;
    751     else if (tag == RATIO_NO_CHECK_TAG)
    752         ratioSetting = RATIO_NO_CHECK;
    753     else
    754         ratioSetting = RATIO_GLOBAL;
     762- (void) setRatioCustom: (id) sender
     763{
     764    BOOL custom = [sender state] != NSOffState;
     765    if (custom)
     766        [sender setState: NSOnState];
    755767
    756768    Torrent * torrent;
    757769    NSEnumerator * enumerator = [fTorrents objectEnumerator];
    758770    while ((torrent = [enumerator nextObject]))
    759         [torrent setStopRatioSetting: ratioSetting];
    760    
    761     [self setRatioLimit: fRatioLimitField];
    762     [fRatioLimitField setEnabled: tag == RATIO_CHECK_TAG];
     771        [torrent setCustomRatioSetting: custom];
     772   
     773    [fRatioStopCheck setEnabled: custom];
     774    [fRatioLimitField setEnabled: custom && [fRatioStopCheck state] == NSOnState];
     775}
     776
     777- (void) setRatioSetting: (id) sender
     778{
     779    BOOL enabled = [sender state] != NSOffState;
     780    if (enabled)
     781        [sender setState: NSOnState];
     782
     783    Torrent * torrent;
     784    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     785    while ((torrent = [enumerator nextObject]))
     786        [torrent setShouldStopAtRatio: enabled];
     787   
     788    [fRatioLimitField setEnabled: enabled && [fRatioCustomCheck state] == NSOnState];
    763789}
    764790
  • trunk/macosx/PrefsController.h

    r1054 r1295  
    8080
    8181- (void) applySpeedSettings: (id) sender;
     82- (void) applyTorrentSpeedSetting: (id) sender;
    8283
    8384- (void) setAutoImport: (id) sender;
  • trunk/macosx/PrefsController.m

    r1286 r1295  
    314314}
    315315
     316- (void) applyTorrentSpeedSetting: (id) sender
     317{
     318    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateSpeedSetting" object: self];
     319}
     320
    316321- (void) setAutoSpeedLimit: (id) sender
    317322{
  • trunk/macosx/Torrent.h

    r1289 r1295  
    2626#import <transmission.h>
    2727
    28 #define RATIO_CHECK 1
    29 #define RATIO_GLOBAL -1
    30 #define RATIO_NO_CHECK 0
    31 
    3228@interface Torrent : NSObject
    3329{
     
    5248   
    5349   
    54     int     fUploadLimit, fDownloadLimit, fStopRatioSetting;
     50    int     fUploadLimit, fDownloadLimit;
    5551    float   fRatioLimit;
    56     BOOL    fCheckUpload, fCheckDownload, fFinishedSeeding, fWaitToStart, fError;
     52    BOOL    fLimitCustom, fCheckUpload, fCheckDownload,
     53            fRatioCustom, fShouldStopAtRatio,
     54            fFinishedSeeding, fWaitToStart, fError;
    5755   
    5856    int fOrderValue;
     
    8684
    8785- (float)       ratio;
    88 - (int)         stopRatioSetting;
    89 - (void)        setStopRatioSetting: (int) setting;
     86- (BOOL)        customRatioSetting;
     87- (void)        setCustomRatioSetting: (BOOL) setting;
     88- (BOOL)        shouldStopAtRatio;
     89- (void)        setShouldStopAtRatio: (BOOL) setting;
    9090- (float)       ratioLimit;
    9191- (void)        setRatioLimit: (float) limit;
    9292
    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;
     93- (BOOL)    checkUpload;
     94- (void)    setLimitUpload: (BOOL) limit;
     95- (int)     uploadLimit;
     96- (void)    setUploadLimit: (int) limit;
     97- (BOOL)    checkDownload;
     98- (void)    setLimitDownload: (BOOL) limit;
     99- (int)     downloadLimit;
     100- (void)    setDownloadLimit: (int) limit;
     101
     102- (BOOL)    customLimitSetting;
     103- (void)    setCustomLimitSetting: (BOOL) setting;
     104- (void)    updateSpeedSetting: (NSNotification *) notification;
    101105
    102106- (void) setWaitToStart: (BOOL) wait;
  • trunk/macosx/Torrent.m

    r1289 r1295  
    3535- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
    3636        publicTorrent: (NSNumber *) publicTorrent
    37         date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
     37        date: (NSDate *) date
     38        stopRatioCustom: (NSNumber *) ratioCustom
     39        shouldStopAtRatio: (NSNumber *) shouldStopAtRatio
    3840        ratioLimit: (NSNumber *) ratioLimit
     41        limitSpeedCustom: (NSNumber *) limitCustom
    3942        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
    4043        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
     
    6568    self = [self initWithHash: nil path: path lib: lib
    6669            publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
    67             date: nil stopRatioSetting: nil ratioLimit: nil
     70            date: nil
     71            stopRatioCustom: nil shouldStopAtRatio: nil ratioLimit: nil
     72            limitSpeedCustom: nil
    6873            checkUpload: nil uploadLimit: nil
    6974            checkDownload: nil downloadLimit: nil
     
    8792                publicTorrent: [history objectForKey: @"PublicCopy"]
    8893                date: [history objectForKey: @"Date"]
    89                 stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
     94                stopRatioCustom: [history objectForKey: @"StopRatioCustom"]
     95                shouldStopAtRatio: [history objectForKey: @"ShouldStopAtRatio"]
    9096                ratioLimit: [history objectForKey: @"RatioLimit"]
     97                limitSpeedCustom: [history objectForKey: @"LimitSpeedCustom"]
    9198                checkUpload: [history objectForKey: @"CheckUpload"]
    9299                uploadLimit: [history objectForKey: @"UploadLimit"]
     
    140147                    [self isActive] ? @"NO" : @"YES", @"Paused",
    141148                    [self date], @"Date",
    142                     [NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
     149                    [NSNumber numberWithBool: fRatioCustom], @"StopRatioCustom",
     150                    [NSNumber numberWithBool: fShouldStopAtRatio], @"ShouldStopAtRatio",
    143151                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
     152                    [NSNumber numberWithBool: fLimitCustom], @"LimitSpeedCustom",
    144153                    [NSNumber numberWithBool: fCheckUpload], @"CheckUpload",
    145154                    [NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
     
    163172    {
    164173        tr_torrentClose(fLib, fHandle);
     174       
     175        [[NSNotificationCenter defaultCenter] removeObserver: self];
    165176       
    166177        if (fDownloadFolder)
     
    254265   
    255266    //check to stop for ratio
    256     if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
    257             || (fStopRatioSetting == RATIO_GLOBAL && [fDefaults boolForKey: @"RatioCheck"]
    258             && [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
     267    if ([self isSeeding] && ((fRatioCustom && fShouldStopAtRatio && [self ratio] >= fRatioLimit)
     268            || (!fRatioCustom && [fDefaults boolForKey: @"RatioCheck"]
     269                && [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
    259270    {
    260271        [self stopTransfer];
    261         [self setStopRatioSetting: RATIO_NO_CHECK];
     272       
    262273        fFinishedSeeding = YES;
    263274       
     
    499510}
    500511
    501 - (int) stopRatioSetting
    502 {
    503         return fStopRatioSetting;
    504 }
    505 
    506 - (void) setStopRatioSetting: (int) setting
    507 {
    508     fStopRatioSetting = setting;
     512- (BOOL) customRatioSetting
     513{
     514        return fRatioCustom;
     515}
     516
     517- (void) setCustomRatioSetting: (BOOL) setting
     518{
     519    fRatioCustom = setting;
     520}
     521
     522- (BOOL) shouldStopAtRatio
     523{
     524        return fShouldStopAtRatio;
     525}
     526
     527- (void) setShouldStopAtRatio: (BOOL) setting
     528{
     529    fShouldStopAtRatio = setting;
    509530}
    510531
     
    520541}
    521542
     543- (BOOL) checkUpload
     544{
     545    return fCheckUpload;
     546}
     547
    522548- (void) setLimitUpload: (BOOL) limit
    523549{
    524550    fCheckUpload = limit;
    525     tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     551    [self updateSpeedSetting: nil];
     552}
     553
     554- (int) uploadLimit
     555{
     556    return fUploadLimit;
    526557}
    527558
     
    529560{
    530561    fUploadLimit = limit;
    531     tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     562    [self updateSpeedSetting: nil];
     563}
     564
     565- (BOOL) checkDownload
     566{
     567    return fCheckDownload;
    532568}
    533569
     
    535571{
    536572    fCheckDownload = limit;
    537     tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
     573    [self updateSpeedSetting: nil];
     574}
     575
     576- (int) downloadLimit
     577{
     578    return fDownloadLimit;
    538579}
    539580
     
    541582{
    542583    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;
     584    [self updateSpeedSetting: nil];
     585}
     586
     587- (BOOL) customLimitSetting
     588{
     589    return fLimitCustom;
     590}
     591
     592- (void) setCustomLimitSetting: (BOOL) setting
     593{
     594    fLimitCustom = setting;
     595    [self updateSpeedSetting: nil];
     596}
     597
     598- (void) updateSpeedSetting: (NSNotification *) notification
     599{
     600    if (fLimitCustom)
     601    {
     602        tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     603        tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
     604    }
     605    else
     606    {
     607        tr_setUploadLimit(fHandle, [fDefaults boolForKey: @"CheckUploadTorrent"]
     608                                        ? [fDefaults integerForKey: @"UploadLimitTorrent"] : -1);
     609        tr_setDownloadLimit(fHandle, [fDefaults boolForKey: @"CheckDownloadTorrent"]
     610                                        ? [fDefaults integerForKey: @"DownloadLimitTorrent"] : -1);
     611    }
    564612}
    565613
     
    10941142- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
    10951143        publicTorrent: (NSNumber *) publicTorrent
    1096         date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
     1144        date: (NSDate *) date
     1145        stopRatioCustom: (NSNumber *) ratioCustom
     1146        shouldStopAtRatio: (NSNumber *) shouldStopAtRatio
    10971147        ratioLimit: (NSNumber *) ratioLimit
     1148        limitSpeedCustom: (NSNumber *) limitCustom
    10981149        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
    10991150        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
     
    11231174    }
    11241175   
     1176    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
     1177    [nc addObserver: self selector: @selector(updateSpeedSetting:)
     1178                name: @"UpdateSpeedSetting" object: nil];
     1179   
    11251180    fInfo = tr_torrentInfo( fHandle );
    11261181
    11271182    fDate = date ? [date retain] : [[NSDate alloc] init];
    11281183   
    1129     fStopRatioSetting = stopRatioSetting ? [stopRatioSetting intValue] : -1;
     1184    fRatioCustom = ratioCustom ? [ratioCustom boolValue] : NO;
     1185    fShouldStopAtRatio = shouldStopAtRatio ? [shouldStopAtRatio boolValue] : [fDefaults boolForKey: @"RatioCheck"];
    11301186    fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
    11311187    fFinishedSeeding = NO;
    11321188   
    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);
     1189    fLimitCustom = limitCustom ? [limitCustom boolValue] : NO;
     1190    fCheckUpload = checkUpload ? [checkUpload boolValue] : [fDefaults boolForKey: @"CheckUploadTorrent"];
     1191    fUploadLimit = uploadLimit ? [uploadLimit intValue] : [fDefaults integerForKey: @"UploadLimitTorrent"];
     1192    fCheckDownload = checkDownload ? [checkDownload boolValue] : [fDefaults boolForKey: @"CheckDownloadTorrent"];
     1193    fDownloadLimit = downloadLimit ? [downloadLimit intValue] : [fDefaults integerForKey: @"DownloadLimitTorrent"];
     1194    [self updateSpeedSetting: nil];
    11401195   
    11411196    fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"];
Note: See TracChangeset for help on using the changeset viewer.