Changeset 2318


Ignore:
Timestamp:
Jul 10, 2007, 3:30:25 AM (15 years ago)
Author:
livings124
Message:

compile with charles_ last set of changes...currently file selection doesn't apply

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileOutlineView.m

    r2225 r2318  
    104104    {
    105105        NSDictionary * item = [self itemAtRow: row];
     106        Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
     107       
    106108        if ([[item objectForKey: @"IsFolder"] boolValue]
    107                 || ![[(InfoWindowController *)[[self window] windowController] selectedTorrent]
    108                         canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
     109                || ![torrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
    109110            [fNormalColor set];
    110111        else
    111112        {
    112             int priority = [[item objectForKey: @"Priority"] intValue];
    113             if (priority == PRIORITY_HIGH)
     113            NSIndexSet * indexSet = [item objectForKey: @"Indexes"];
     114            if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet])
    114115                [fHighPriorityColor set];
    115             else if (priority == PRIORITY_LOW)
     116            else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet])
    116117                [fLowPriorityColor set];
    117118            else
     
    133134
    134135    NSDictionary * item;
     136    NSIndexSet * indexSet;
    135137    int i, priority;
    136138    Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
     
    140142        {
    141143            item = [self itemAtRow: i];
    142             if (![[item objectForKey: @"IsFolder"] boolValue]
    143                 && [torrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]])
     144            if ([[item objectForKey: @"IsFolder"] boolValue])
     145                continue;
     146           
     147            indexSet = [item objectForKey: @"Indexes"];
     148            if ([torrent canChangeDownloadCheckForFiles: indexSet])
    144149            {
    145                 priority = [[item objectForKey: @"Priority"] intValue];
    146                 if (priority == PRIORITY_HIGH)
     150                if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet])
    147151                    [fHighPriorityColor set];
    148                 else if (priority == PRIORITY_LOW)
     152                else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet])
    149153                    [fLowPriorityColor set];
    150154                else
  • trunk/macosx/FilePriorityCell.m

    r2225 r2318  
    3838        return;
    3939   
    40     int priority = segment, actualPriority;
    41     if (priority == 0)
    42         actualPriority = PRIORITY_LOW;
    43     else if (priority == 2)
    44         actualPriority = PRIORITY_HIGH;
     40    int priority;
     41    if (segment == 0)
     42        priority = TR_PRI_LOW;
     43    else if (segment == 2)
     44        priority = TR_PRI_HIGH;
    4545    else
    46         actualPriority = PRIORITY_NORMAL;
     46        priority = TR_PRI_NORMAL;
    4747   
    48     [torrent setFilePriority: actualPriority forIndexes: indexes];
     48    [torrent setFilePriority: priority forIndexes: indexes];
    4949    [(FileOutlineView *)[self controlView] reloadData];
    5050}
     
    5858        return;
    5959   
    60     BOOL low = [torrent hasFilePriority: PRIORITY_LOW forIndexes: indexSet],
    61         normal = [torrent hasFilePriority: PRIORITY_NORMAL forIndexes: indexSet],
    62         high = [torrent hasFilePriority: PRIORITY_HIGH forIndexes: indexSet];
     60    BOOL low = [torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet],
     61        normal = [torrent hasFilePriority: TR_PRI_NORMAL forIndexes: indexSet],
     62        high = [torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet];
    6363   
    6464    FileOutlineView * view = (FileOutlineView *)[self controlView];
  • trunk/macosx/InfoWindowController.m

    r2285 r2318  
    667667       
    668668        if (menuItem == fFilePriorityHigh)
    669             priority = PRIORITY_HIGH;
     669            priority = TR_PRI_HIGH;
    670670        else if (menuItem == fFilePriorityLow)
    671             priority = PRIORITY_LOW;
    672         else
    673             priority = PRIORITY_NORMAL;
     671            priority = TR_PRI_LOW;
     672        else
     673            priority = TR_PRI_NORMAL;
    674674       
    675675        NSIndexSet * fileIndexSet;
     
    953953            return NSLocalizedString(@"Priority Not Available", "Inspector -> files tab -> tooltip");
    954954       
    955         BOOL low = [torrent hasFilePriority: PRIORITY_LOW forIndexes: indexSet],
    956             normal = [torrent hasFilePriority: PRIORITY_NORMAL forIndexes: indexSet],
    957             high = [torrent hasFilePriority: PRIORITY_HIGH forIndexes: indexSet];
     955        BOOL low = [torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet],
     956            normal = [torrent hasFilePriority: TR_PRI_NORMAL forIndexes: indexSet],
     957            high = [torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet];
    958958       
    959959        if (low && !normal && !high)
     
    10871087    int priority;
    10881088    if (sender == fFilePriorityHigh)
    1089         priority = PRIORITY_HIGH;
     1089        priority = TR_PRI_HIGH;
    10901090    else if (sender == fFilePriorityLow)
    1091         priority = PRIORITY_LOW;
    1092     else
    1093         priority = PRIORITY_NORMAL;
     1091        priority = TR_PRI_LOW;
     1092    else
     1093        priority = TR_PRI_NORMAL;
    10941094   
    10951095    Torrent * torrent = [fTorrents objectAtIndex: 0];
  • trunk/macosx/Torrent.h

    r2262 r2318  
    2626#import <transmission.h>
    2727
    28 #define PRIORITY_LOW -1
    29 #define PRIORITY_NORMAL 0
    30 #define PRIORITY_HIGH 1
    31 
    3228#define INVALID -99
    3329
  • trunk/macosx/Torrent.m

    r2293 r2318  
    4646        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
    4747                pex: (NSNumber *) pex
    48         waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
    49         filesShouldDownload: (NSArray *) filesShouldDownload filePriorities: (NSArray *) filePriorities;
    50 - (void) historyFilePriorities: (NSMutableArray *) history forItems: (NSArray *) items;
     48        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
    5149
    5250- (BOOL) shouldUseIncompleteFolderForName: (NSString *) name;
    5351- (void) updateDownloadFolder;
    5452
    55 - (void) createFileListShouldDownload: (NSArray *) filesShouldDownload priorities: (NSArray *) filePriorities;
     53- (void) createFileList;
    5654- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    5755            withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    58             flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index priority: (int) priority;
     56            flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index;
    5957- (NSImage *) advancedBar;
    6058- (void) trashFile: (NSString *) path;
     
    8987            checkDownload: nil downloadLimit: nil
    9088                        pex: nil
    91             waitToStart: nil orderValue: nil
    92             filesShouldDownload: nil filePriorities: nil];
     89            waitToStart: nil orderValue: nil];
    9390   
    9491    if (self)
     
    120117                                pex: [history objectForKey: @"Pex"]
    121118                waitToStart: [history objectForKey: @"WaitToStart"]
    122                 orderValue: [history objectForKey: @"OrderValue"]
    123                 filesShouldDownload: [history objectForKey: @"FilesShouldDownload"]
    124                 filePriorities: [history objectForKey: @"FilePriorities"]];
     119                orderValue: [history objectForKey: @"OrderValue"]];
    125120   
    126121    if (self)
     
    158153    if (fIncompleteFolder)
    159154        [history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
    160    
    161     //set file should download
    162     int fileCount = [self fileCount];
    163     NSMutableArray * filesShouldDownload = [NSMutableArray arrayWithCapacity: fileCount];
    164    
    165     tr_priority_t * priorities = tr_torrentGetFilePriorities(fHandle);
    166     int i;
    167     for (i = 0; i < fileCount; i++)
    168         [filesShouldDownload addObject: [NSNumber numberWithBool: priorities[i] != TR_PRI_DND]];
    169     free(priorities);
    170     [history setObject: filesShouldDownload forKey: @"FilesShouldDownload"];
    171    
    172     //set file priorities
    173     NSMutableArray * filePriorities = [NSMutableArray arrayWithCapacity: fileCount];
    174     [self historyFilePriorities: filePriorities forItems: fFileList];
    175     [history setObject: filePriorities forKey: @"FilePriorities"];
    176155
    177156    if (fPublicTorrent)
     
    13101289    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    13111290    {
    1312         if (tr_torrentGetFilePriority(fHandle, index) != TR_PRI_DND
    1313                 || ![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
     1291        if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
    13141292            onState = YES;
    13151293        else
     
    13381316    int index;
    13391317    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    1340     {
    1341         tr_priority_t actualPriority;
    1342         if (state == NSOnState)
    1343         {
    1344             int priority = [[[fFlatFileList objectAtIndex: index] objectForKey: @"Priority"] intValue];
    1345             if (priority == PRIORITY_HIGH)
    1346                 actualPriority = TR_PRI_HIGH;
    1347             else if (priority == PRIORITY_LOW)
    1348                 actualPriority = TR_PRI_LOW;
    1349             else
    1350                 actualPriority = TR_PRI_NORMAL;
    1351         }
    1352         else
    1353             actualPriority = TR_PRI_DND;
    1354        
    1355         tr_torrentSetFilePriority(fHandle, index, actualPriority);
    1356     }
     1318        tr_torrentSetFileDL(fHandle, index, state != NSOffState);
    13571319   
    13581320    [self update];
     
    13631325- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet
    13641326{
    1365     NSNumber * priorityValue = [NSNumber numberWithInt: priority];
    1366    
    13671327    int index;
    13681328    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    1369     {
    1370         [[fFlatFileList objectAtIndex: index] setObject: priorityValue forKey: @"Priority"];
    1371        
    1372         if ([self checkForFiles: [NSIndexSet indexSetWithIndex: index]] == NSOnState)
    1373         {
    1374             tr_priority_t actualPriority;
    1375             if (priority == PRIORITY_HIGH)
    1376                 actualPriority = TR_PRI_HIGH;
    1377             else if (priority == PRIORITY_LOW)
    1378                 actualPriority = TR_PRI_LOW;
    1379             else
    1380                 actualPriority = TR_PRI_NORMAL;
    1381             tr_torrentSetFilePriority(fHandle, index, actualPriority);
    1382         }
    1383     }
     1329        tr_torrentSetFilePriority(fHandle, index, priority);
    13841330}
    13851331
     
    13881334    int index;
    13891335    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    1390         if (priority == [[[fFlatFileList objectAtIndex: index] objectForKey: @"Priority"] intValue]
     1336        if (priority == tr_torrentGetFilePriority(fHandle, index)
    13911337                && [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
    13921338            return YES;
     
    14061352- (NSDate *) dateActivity
    14071353{
    1408     uint64_t date = fStat->activityDate / 1000;
    1409     return date != 0 ? [NSDate dateWithTimeIntervalSince1970: date] : fDateActivity;
     1354    uint64_t date = fStat->activityDate;
     1355    return date != 0 ? [NSDate dateWithTimeIntervalSince1970: date / 1000] : fDateActivity;
    14101356}
    14111357
     
    14841430        checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
    14851431                pex: (NSNumber *) pex
    1486         waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
    1487         filesShouldDownload: (NSArray *) filesShouldDownload filePriorities: (NSArray *) filePriorities;
     1432        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
    14881433{
    14891434    if (!(self = [super init]))
     
    15821527    fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30];
    15831528   
    1584     [self createFileListShouldDownload: filesShouldDownload priorities: filePriorities];
     1529    [self createFileList];
    15851530   
    15861531    //set up advanced bar
     
    15981543}
    15991544
    1600 - (void) createFileListShouldDownload: (NSArray *) filesShouldDownload priorities: (NSArray *) filePriorities
     1545- (void) createFileList
    16011546{
    16021547    int count = [self fileCount], i;
     
    16041549    NSMutableArray * pathComponents;
    16051550    NSString * path;
    1606     int priority;
    1607     tr_priority_t actualPriority;
    16081551   
    16091552    NSMutableArray * fileList = [[NSMutableArray alloc] init],
     
    16231566            path = @"";
    16241567       
    1625         priority = filePriorities ? [[filePriorities objectAtIndex: i] intValue] : PRIORITY_NORMAL;
    16261568        [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path
    1627                 flatList: flatFileList fileSize: file->length index: i priority: priority];
     1569                flatList: flatFileList fileSize: file->length index: i];
    16281570        [pathComponents autorelease];
    1629        
    1630         if (!filesShouldDownload || [[filesShouldDownload objectAtIndex: i] boolValue])
    1631         {
    1632             if (priority == PRIORITY_HIGH)
    1633                 actualPriority = TR_PRI_HIGH;
    1634             else if (priority == PRIORITY_LOW)
    1635                 actualPriority = TR_PRI_LOW;
    1636             else
    1637                 actualPriority = TR_PRI_NORMAL;
    1638         }
    1639         else
    1640             actualPriority = TR_PRI_DND;
    1641        
    1642         tr_torrentSetFilePriority(fHandle, i, actualPriority);
    16431571    }
    16441572   
     
    16511579- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    16521580        withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    1653         flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index priority: (int) priority
     1581        flatList: (NSMutableArray *) flatList fileSize: (uint64_t) size index: (int) index
    16541582{
    16551583    NSString * name = [components objectAtIndex: 0];
     
    16841612            [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
    16851613            [dict setObject: [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]] forKey: @"Icon"];
    1686             [dict setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"];
    16871614           
    16881615            [flatList addObject: dict];
     
    16991626        [components removeObjectAtIndex: 0];
    17001627        [self insertPath: components forSiblings: [dict objectForKey: @"Children"]
    1701             withParent: dict previousPath: currentPath flatList: flatList fileSize: size index: index priority: priority];
    1702     }
    1703 }
    1704 
    1705 - (void) historyFilePriorities: (NSMutableArray *) history forItems: (NSArray *) items
    1706 {
    1707     NSEnumerator * enumerator = [items objectEnumerator];
    1708     NSDictionary * item;
    1709     while ((item = [enumerator nextObject]))
    1710     {
    1711         if (![[item objectForKey: @"IsFolder"] boolValue])
    1712             [history addObject: [item objectForKey: @"Priority"]];
    1713         else
    1714             [self historyFilePriorities: history forItems: [item objectForKey: @"Children"]];
     1628            withParent: dict previousPath: currentPath flatList: flatList fileSize: size index: index];
    17151629    }
    17161630}
Note: See TracChangeset for help on using the changeset viewer.