Changeset 2023


Ignore:
Timestamp:
Jun 10, 2007, 4:46:29 AM (15 years ago)
Author:
livings124
Message:

storing and setting (internally) on individual file priorities

Location:
branches/file_selection/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/Torrent.h

    r2021 r2023  
    186186- (int) peersDownloading;
    187187
    188 - (float)       downloadRate;
    189 - (float)       uploadRate;
    190 - (uint64_t)    downloadedValid;
    191 - (uint64_t)    downloadedTotal;
    192 - (uint64_t)    uploadedTotal;
    193 - (float)       swarmSpeed;
     188- (float) downloadRate;
     189- (float) uploadRate;
     190- (uint64_t) downloadedValid;
     191- (uint64_t) downloadedTotal;
     192- (uint64_t) uploadedTotal;
     193- (float) swarmSpeed;
    194194
    195195- (BOOL) pex;
     
    207207- (BOOL) canChangeDownloadCheckForFileFolder: (NSIndexSet *) indexSet;
    208208- (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item;
     209- (void) setFilePriority: (int) priority forFileItem: (NSMutableDictionary *) item;
    209210
    210211- (NSDate *) dateAdded;
  • branches/file_selection/macosx/Torrent.m

    r2022 r2023  
    5050        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue
    5151        filesShouldDownload: (NSArray *) filesShouldDownload filePriorities: (NSArray *) filePriorities;
     52- (void) historyFilePriorities: (NSMutableArray *) history forItems: (NSArray *) items;
    5253
    5354- (void) createFileListShouldDownload: (NSArray *) filesShouldDownload priorities: (NSArray *) filePriorities;
     
    179180                    nil];
    180181   
    181     //set file priorities
     182    //set file should download
    182183    int fileCount = [self fileCount];
    183184    NSMutableArray * filesShouldDownload = [NSMutableArray arrayWithCapacity: fileCount];
     
    190191    [history setObject: filesShouldDownload forKey: @"FilesShouldDownload"];
    191192   
     193    //set file priorities
    192194    NSMutableArray * filePriorities = [NSMutableArray arrayWithCapacity: fileCount];
    193     #warning get priorities
     195    [self historyFilePriorities: filePriorities forItems: fFileList];
    194196    [history setObject: filePriorities forKey: @"FilePriorities"];
    195197   
     
    13791381}
    13801382
     1383- (void) setFilePriority: (int) priority forFileItem: (NSMutableDictionary *) item
     1384{
     1385    if ([[item objectForKey: @"IsFolder"] boolValue])
     1386        return;
     1387   
     1388    [item setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"];
     1389   
     1390    int index = [[item objectForKey: @"Index"] intValue];
     1391    if ([self checkForFile: index] == NSOnState)
     1392    {
     1393        tr_priority_t actualPriority;
     1394        if (priority == PRIORITY_HIGH)
     1395            actualPriority = TR_PRI_HIGH;
     1396        else if (priority == PRIORITY_LOW)
     1397            actualPriority = TR_PRI_LOW;
     1398        else
     1399            actualPriority = TR_PRI_NORMAL;
     1400        tr_torrentSetFilePriority(fHandle, index, actualPriority);
     1401    }
     1402}
     1403
    13811404- (NSDate *) dateAdded
    13821405{
     
    16621685}
    16631686
     1687- (void) historyFilePriorities: (NSMutableArray *) history forItems: (NSArray *) items
     1688{
     1689    NSEnumerator * enumerator = [items objectEnumerator];
     1690    NSDictionary * item;
     1691    while ((item = [enumerator nextObject]))
     1692    {
     1693        if (![[item objectForKey: @"IsFolder"] boolValue])
     1694            [history addObject: [item objectForKey: @"Priority"]];
     1695        else
     1696            [self historyFilePriorities: history forItems: [item objectForKey: @"Children"]];
     1697    }
     1698}
     1699
    16641700- (NSImage *) advancedBar
    16651701{
Note: See TracChangeset for help on using the changeset viewer.