Changeset 2442


Ignore:
Timestamp:
Jul 20, 2007, 4:26:50 AM (15 years ago)
Author:
livings124
Message:

get the mac build compiling again

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r2370 r2442  
    6666- (NSArray *) peerSortDescriptors;
    6767
    68 - (int) stateSettingToPopUpIndex: (int) index;
    69 - (int) popUpIndexToStateSetting: (int) index;
    70 
    7168@end
    7269
     
    458455        Torrent * torrent;
    459456       
    460         //set bandwidth limits
     457        //get bandwidth info
    461458        NSEnumerator * enumerator = [fTorrents objectEnumerator];
    462459        torrent = [enumerator nextObject]; //first torrent
    463460       
    464         int checkUpload = [torrent checkUpload],
    465             checkDownload = [torrent checkDownload],
    466             uploadLimit = [torrent uploadLimit],
    467             downloadLimit = [torrent downloadLimit];
    468        
    469         while ((checkUpload != INVALID || uploadLimit != INVALID
    470                 || checkDownload != INVALID || downloadLimit != INVALID)
     461        int uploadSpeedMode = [torrent uploadSpeedMode],
     462            uploadSpeedLimit = [torrent uploadSpeedLimit],
     463            downloadSpeedMode = [torrent downloadSpeedMode],
     464            downloadSpeedLimit = [torrent downloadSpeedLimit];
     465       
     466        while ((uploadSpeedMode != INVALID || uploadSpeedLimit != INVALID
     467                || downloadSpeedMode != INVALID || downloadSpeedLimit != INVALID)
    471468                && (torrent = [enumerator nextObject]))
    472469        {
    473             if (checkUpload != INVALID && checkUpload != [torrent checkUpload])
    474                 checkUpload = INVALID;
     470            if (uploadSpeedMode != INVALID && uploadSpeedMode != [torrent uploadSpeedMode])
     471                uploadSpeedMode = INVALID;
    475472           
    476             if (uploadLimit != INVALID && uploadLimit != [torrent uploadLimit])
    477                 uploadLimit = INVALID;
     473            if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent uploadSpeedLimit])
     474                uploadSpeedLimit = INVALID;
    478475           
    479             if (checkDownload != INVALID && checkDownload != [torrent checkDownload])
    480                 checkDownload = INVALID;
     476            if (downloadSpeedMode != INVALID && downloadSpeedMode != [torrent downloadSpeedMode])
     477                downloadSpeedMode = INVALID;
    481478           
    482             if (downloadLimit != INVALID && downloadLimit != [torrent downloadLimit])
    483                 downloadLimit = INVALID;
    484         }
    485        
     479            if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent downloadSpeedLimit])
     480                downloadSpeedLimit = INVALID;
     481        }
     482       
     483        //set upload view
     484        int index;
     485        if (uploadSpeedMode == TR_SPEEDLIMIT_SINGLE)
     486            index = OPTION_POPUP_LIMIT;
     487        else if (uploadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
     488            index = OPTION_POPUP_NO_LIMIT;
     489        else if (uploadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
     490            index = OPTION_POPUP_GLOBAL;
     491        else
     492            index = -1;
     493        [fUploadLimitPopUp selectItemAtIndex: index];
    486494        [fUploadLimitPopUp setEnabled: YES];
    487         [fUploadLimitPopUp selectItemAtIndex: [self stateSettingToPopUpIndex: checkUpload]];
    488         [fUploadLimitLabel setHidden: checkUpload != NSOnState];
    489         [fUploadLimitField setHidden: checkUpload != NSOnState];
    490         if (uploadLimit != INVALID)
    491             [fUploadLimitField setIntValue: uploadLimit];
     495       
     496        [fUploadLimitLabel setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     497        [fUploadLimitField setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     498        if (uploadSpeedLimit != INVALID)
     499            [fUploadLimitField setIntValue: uploadSpeedLimit];
    492500        else
    493501            [fUploadLimitField setStringValue: @""];
    494502       
     503        //set download view
     504        if (downloadSpeedMode == TR_SPEEDLIMIT_SINGLE)
     505            index = OPTION_POPUP_LIMIT;
     506        else if (downloadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
     507            index = OPTION_POPUP_NO_LIMIT;
     508        else if (downloadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
     509            index = OPTION_POPUP_GLOBAL;
     510        else
     511            index = -1;
     512        [fDownloadLimitPopUp selectItemAtIndex: index];
    495513        [fDownloadLimitPopUp setEnabled: YES];
    496         [fDownloadLimitPopUp selectItemAtIndex: [self stateSettingToPopUpIndex: checkDownload]];
    497         [fDownloadLimitLabel setHidden: checkDownload != NSOnState];
    498         [fDownloadLimitField setHidden: checkDownload != NSOnState];
    499         if (downloadLimit != INVALID)
    500             [fDownloadLimitField setIntValue: downloadLimit];
     514       
     515        [fDownloadLimitLabel setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     516        [fDownloadLimitField setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     517        if (downloadSpeedLimit != INVALID)
     518            [fDownloadLimitField setIntValue: downloadSpeedLimit];
    501519        else
    502520            [fDownloadLimitField setStringValue: @""];
    503521       
    504         //set ratio settings
     522        //get ratio info
    505523        enumerator = [fTorrents objectEnumerator];
    506524        torrent = [enumerator nextObject]; //first torrent
     
    519537        }
    520538       
     539        //set ratio view
     540        if (checkRatio == NSOnState)
     541            index = OPTION_POPUP_LIMIT;
     542        else if (checkRatio == NSOffState)
     543            index = OPTION_POPUP_NO_LIMIT;
     544        else if (checkRatio == NSMixedState)
     545            index = OPTION_POPUP_GLOBAL;
     546        else
     547            index = -1;
     548        [fRatioPopUp selectItemAtIndex: index];
    521549        [fRatioPopUp setEnabled: YES];
    522         [fRatioPopUp selectItemAtIndex: [self stateSettingToPopUpIndex: checkRatio]];
     550       
    523551        [fRatioLimitField setHidden: checkRatio != NSOnState];
    524552        if (ratioLimit != INVALID)
     
    579607}
    580608
    581 - (int) stateSettingToPopUpIndex: (int) index
    582 {
    583     if (index == NSOnState)
    584         return OPTION_POPUP_LIMIT;
    585     else if (index == NSOffState)
    586         return OPTION_POPUP_NO_LIMIT;
    587     else if (index == NSMixedState)
    588         return OPTION_POPUP_GLOBAL;
    589     else
    590         return -1;
    591 }
    592 
    593 - (int) popUpIndexToStateSetting: (int) index
    594 {
    595     if (index == OPTION_POPUP_LIMIT)
    596         return NSOnState;
    597     else if (index == OPTION_POPUP_NO_LIMIT)
    598         return NSOffState;
    599     else if (index == OPTION_POPUP_GLOBAL)
    600         return NSMixedState;
    601     else
    602         return INVALID;
    603 }
    604 
    605609- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
    606610{
     
    10921096}
    10931097
     1098#warning rename to mode
    10941099- (void) setLimitSetting: (id) sender
    10951100{
    10961101    BOOL upload = sender == fUploadLimitPopUp;
    1097     int setting;
    1098     if ((setting = [self popUpIndexToStateSetting: [sender indexOfSelectedItem]]) == INVALID)
    1099         return;
     1102    int index = [sender indexOfSelectedItem], mode;
     1103    if (index == OPTION_POPUP_LIMIT)
     1104        mode = TR_SPEEDLIMIT_SINGLE;
     1105    else if (index == OPTION_POPUP_NO_LIMIT)
     1106        mode = TR_SPEEDLIMIT_UNLIMITED;
     1107    else
     1108        mode = TR_SPEEDLIMIT_GLOBAL;
    11001109   
    11011110    Torrent * torrent;
    11021111    NSEnumerator * enumerator = [fTorrents objectEnumerator];
    11031112    while ((torrent = [enumerator nextObject]))
    1104         upload ? [torrent setCheckUpload: setting] : [torrent setCheckDownload: setting];
     1113        upload ? [torrent setUploadSpeedMode: mode] : [torrent setDownloadSpeedMode: mode];
    11051114   
    11061115    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
    1107     [field setHidden: setting != NSOnState];
    1108     if (setting == NSOnState)
     1116   
     1117    BOOL single = mode == TR_SPEEDLIMIT_SINGLE;
     1118    [field setHidden: !single];
     1119    if (single)
    11091120    {
    11101121        [field selectText: self];
     
    11131124   
    11141125    NSTextField * label = upload ? fUploadLimitLabel : fDownloadLimitLabel;
    1115     [label setHidden: setting != NSOnState];
     1126    [label setHidden: !single];
    11161127}
    11171128
     
    11291140       
    11301141        torrent = [enumerator nextObject]; //use first torrent
    1131         limit = upload ? [torrent uploadLimit] : [torrent downloadLimit];
     1142        limit = upload ? [torrent uploadSpeedLimit] : [torrent downloadSpeedLimit];
    11321143        while ((torrent = [enumerator nextObject]))
    1133             if (limit != (upload ? [torrent uploadLimit] : [torrent downloadLimit]))
     1144            if (limit != (upload ? [torrent uploadSpeedLimit] : [torrent downloadSpeedLimit]))
    11341145            {
    11351146                [sender setStringValue: @""];
     
    11421153    {
    11431154        while ((torrent = [enumerator nextObject]))
    1144             upload ? [torrent setUploadLimit: limit] : [torrent setDownloadLimit: limit];
     1155            upload ? [torrent setUploadSpeedLimit: limit] : [torrent setDownloadSpeedLimit: limit];
    11451156    }
    11461157}
     
    11481159- (void) setRatioSetting: (id) sender
    11491160{
    1150     int setting;
    1151     if ((setting = [self popUpIndexToStateSetting: [sender indexOfSelectedItem]]) == INVALID)
    1152         return;
     1161    int index = [sender indexOfSelectedItem], setting;
     1162    if (index == OPTION_POPUP_LIMIT)
     1163        setting = NSOnState;
     1164    else if (index == OPTION_POPUP_NO_LIMIT)
     1165        setting = NSOffState;
     1166    else
     1167        setting = NSMixedState;
    11531168   
    11541169    Torrent * torrent;
     
    11571172        [torrent setRatioSetting: setting];
    11581173   
    1159     [fRatioLimitField setHidden: setting != NSOnState];
    1160     if (setting == NSOnState)
     1174    BOOL single = setting == NSOnState;
     1175    [fRatioLimitField setHidden: !single];
     1176    if (single)
    11611177    {
    11621178        [fRatioLimitField selectText: self];
  • trunk/macosx/Torrent.h

    r2370 r2442  
    5757    NSArray * fFileList, * fFlatFileList;
    5858   
    59     int     fUploadLimit, fDownloadLimit;
    6059    float   fRatioLimit;
    61     int     fCheckUpload, fCheckDownload, fRatioSetting;
     60    int     fRatioSetting;
    6261    BOOL    fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
    6362   
     
    104103- (float) progressStopRatio;
    105104
    106 - (int) checkUpload;
    107 - (void) setCheckUpload: (int) setting;
    108 - (int) uploadLimit;
    109 - (void) setUploadLimit: (int) limit;
    110 - (int) checkDownload;
    111 - (void) setCheckDownload: (int) setting;
    112 - (int) downloadLimit;
    113 - (void) setDownloadLimit: (int) limit;
    114 
    115 - (void) updateSpeedSetting;
     105#warning merge up and down?
     106- (int) uploadSpeedMode;
     107- (void) setUploadSpeedMode: (int) mode;
     108- (int) uploadSpeedLimit;
     109- (void) setUploadSpeedLimit: (int) limit;
     110- (int) downloadSpeedMode;
     111- (void) setDownloadSpeedMode: (int) mode;
     112- (int) downloadSpeedLimit;
     113- (void) setDownloadSpeedLimit: (int) limit;
    116114
    117115- (void) setWaitToStart: (BOOL) wait;
  • trunk/macosx/Torrent.m

    r2440 r2442  
    4242        dateActivity: (NSDate *) dateActivity
    4343        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    44         limitSpeedCustom: (NSNumber *) limitCustom
    45         checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
    46         checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
    4744                pex: (NSNumber *) pex
    4845        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
     
    8380            dateActivity: nil
    8481            ratioSetting: nil ratioLimit: nil
    85             limitSpeedCustom: nil
    86             checkUpload: nil uploadLimit: nil
    87             checkDownload: nil downloadLimit: nil
    8882                        pex: nil
    8983            waitToStart: nil orderValue: nil];
     
    110104                ratioSetting: [history objectForKey: @"RatioSetting"]
    111105                ratioLimit: [history objectForKey: @"RatioLimit"]
    112                 limitSpeedCustom: [history objectForKey: @"LimitSpeedCustom"]
    113                 checkUpload: [history objectForKey: @"CheckUpload"]
    114                 uploadLimit: [history objectForKey: @"UploadLimit"]
    115                 checkDownload: [history objectForKey: @"CheckDownload"]
    116                 downloadLimit: [history objectForKey: @"DownloadLimit"]
    117106                                pex: [history objectForKey: @"Pex"]
    118107                waitToStart: [history objectForKey: @"WaitToStart"]
     
    143132                    [NSNumber numberWithInt: fRatioSetting], @"RatioSetting",
    144133                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
    145                     [NSNumber numberWithInt: fCheckUpload], @"CheckUpload",
    146                     [NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
    147                     [NSNumber numberWithInt: fCheckDownload], @"CheckDownload",
    148                     [NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
    149134                    [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
    150135                    [self orderValue], @"OrderValue", nil];
     
    268253            && (canMove = [self alertForMoveFolderAvailable]))
    269254        {
     255            #warning pause without actually stopping
    270256            //pause without actually stopping
    271             tr_torrentEnableMaxSpeedUL(fHandle, 1);
    272             tr_torrentSetMaxSpeedUL(fHandle, 0);
    273            
    274             tr_torrentEnableMaxSpeedDL(fHandle, 1);
    275             tr_torrentSetMaxSpeedDL(fHandle, 0);
    276257           
    277258            if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
     
    281262                canMove = NO;
    282263           
    283             [self updateSpeedSetting];
     264            #warning unpause
    284265        }
    285266       
     
    641622}
    642623
    643 - (int) checkUpload
    644 {
    645     return fCheckUpload;
    646 }
    647 
    648 - (void) setCheckUpload: (int) setting
    649 {
    650     fCheckUpload = setting;
    651     [self updateSpeedSetting];
    652 }
    653 
    654 - (int) uploadLimit
    655 {
    656     return fUploadLimit;
    657 }
    658 
    659 - (void) setUploadLimit: (int) limit
    660 {
    661     fUploadLimit = limit;
    662     [self updateSpeedSetting];
    663 }
    664 
    665 - (int) checkDownload
    666 {
    667     return fCheckDownload;
    668 }
    669 
    670 - (void) setCheckDownload: (int) setting
    671 {
    672     fCheckDownload = setting;
    673     [self updateSpeedSetting];
    674 }
    675 
    676 - (int) downloadLimit
    677 {
    678     return fDownloadLimit;
    679 }
    680 
    681 - (void) setDownloadLimit: (int) limit
    682 {
    683     fDownloadLimit = limit;
    684     [self updateSpeedSetting];
    685 }
    686 
    687 - (void) updateSpeedSetting
    688 {
    689     tr_torrentEnableMaxSpeedUL(fHandle, fCheckUpload != NSMixedState);
    690     tr_torrentSetMaxSpeedUL(fHandle, fCheckUpload == NSOnState ? fUploadLimit : -1);
    691    
    692     tr_torrentEnableMaxSpeedDL(fHandle, fCheckDownload != NSMixedState);
    693     tr_torrentSetMaxSpeedDL(fHandle, fCheckDownload == NSOnState ? fDownloadLimit : -1);
     624- (int) uploadSpeedMode
     625{
     626    return tr_torrentGetSpeedMode(fHandle, TR_UP);
     627}
     628
     629- (void) setUploadSpeedMode: (int) mode
     630{
     631    tr_torrentSetSpeedMode(fHandle, TR_UP, mode);
     632}
     633
     634- (int) uploadSpeedLimit
     635{
     636    return tr_torrentGetSpeedLimit(fHandle, TR_UP);
     637}
     638
     639- (void) setUploadSpeedLimit: (int) limit
     640{
     641    tr_torrentSetSpeedLimit(fHandle, TR_UP, limit);
     642}
     643
     644- (int) downloadSpeedMode
     645{
     646    return tr_torrentGetSpeedMode(fHandle, TR_DOWN);
     647}
     648
     649- (void) setDownloadSpeedMode: (int) mode
     650{
     651    tr_torrentSetSpeedMode(fHandle, TR_DOWN, mode);
     652}
     653
     654- (int) downloadSpeedLimit
     655{
     656    return tr_torrentGetSpeedLimit(fHandle, TR_DOWN);
     657}
     658
     659- (void) setDownloadSpeedLimit: (int) limit
     660{
     661    tr_torrentSetSpeedLimit(fHandle, TR_DOWN, limit);
    694662}
    695663
     
    755723        }
    756724       
     725        #warning pause without actually stopping
    757726        //pause without actually stopping
    758         tr_torrentEnableMaxSpeedUL(fHandle, 1);
    759         tr_torrentSetMaxSpeedUL(fHandle, 0);
    760        
    761         tr_torrentEnableMaxSpeedDL(fHandle, 1);
    762         tr_torrentSetMaxSpeedDL(fHandle, 0);
    763727       
    764728        if ([[NSFileManager defaultManager] movePath: [oldFolder stringByAppendingPathComponent: [self name]]
     
    776740            [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateInfoSettings" object: nil];
    777741           
    778             [self updateSpeedSetting];
     742            #warning unpause
    779743        }
    780744        else
    781745        {
    782             [self updateSpeedSetting]; //restart before showing the alert
     746            #warning unpause //restart before showing the alert
    783747       
    784748            NSAlert * alert = [[NSAlert alloc] init];
     
    15241488        dateActivity: (NSDate *) dateActivity
    15251489        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    1526         limitSpeedCustom: (NSNumber *) limitCustom
    1527         checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
    1528         checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
    15291490                pex: (NSNumber *) pex
    15301491        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
     
    15861547   
    15871548    fInfo = tr_torrentInfo(fHandle);
    1588    
    1589     NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
    1590     [nc addObserver: self selector: @selector(updateSpeedSetting:)
    1591                 name: @"UpdateSpeedSetting" object: nil];
    15921549
    15931550    fDateAdded = dateAdded ? [dateAdded retain] : [[NSDate alloc] init];
     
    16001557    fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
    16011558    fFinishedSeeding = NO;
    1602    
    1603     fCheckUpload = checkUpload ? [checkUpload intValue] : NSMixedState;
    1604     fUploadLimit = uploadLimit ? [uploadLimit intValue] : [fDefaults integerForKey: @"UploadLimit"];
    1605     fCheckDownload = checkDownload ? [checkDownload intValue] : NSMixedState;
    1606     fDownloadLimit = downloadLimit ? [downloadLimit intValue] : [fDefaults integerForKey: @"DownloadLimit"];
    1607     [self updateSpeedSetting];
    16081559       
    16091560        if ([self privateTorrent])
Note: See TracChangeset for help on using the changeset viewer.