Changeset 2021


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

add storing of priorities, although they can't be saved, viewed, or changed (fun :))

Location:
branches/file_selection/macosx
Files:
2 edited

Legend:

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

    r2016 r2021  
    165165- (BOOL) isError;
    166166- (NSString *) errorMessage;
    167 - (BOOL) justFinished;
    168167
    169168- (NSArray *) peers;
  • branches/file_selection/macosx/Torrent.m

    r2020 r2021  
    3131#define BLANK_PIECE -99
    3232
     33#define PRIORITY_LOW -1
     34#define PRIORITY_NORMAL 0
     35#define PRIORITY_HIGH 1
     36
    3337static int static_lastid = 0;
    3438
     
    5054- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    5155            withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    52             fileSize: (uint64_t) size index: (int) index;
     56            fileSize: (uint64_t) size index: (int) index priority: (int) priority;
    5357- (NSImage *) advancedBar;
    5458- (void) trashFile: (NSString *) path;
     
    186190    [history setObject: filesShouldDownload forKey: @"FilesShouldDownload"];
    187191   
    188     #warning add priorities
     192    NSMutableArray * filePriorities = [NSMutableArray arrayWithCapacity: fileCount];
     193    #warning get priorities
     194    [history setObject: filePriorities forKey: @"FilePriorities"];
     195   
    189196    if (fUseIncompleteFolder)
    190197        [history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
     
    301308   
    302309    //notification when downloading finished
    303     if ([self justFinished])
     310    if (tr_getFinished(fHandle))
    304311    {
    305312        BOOL canMove = YES;
     
    11241131}
    11251132
    1126 - (BOOL) justFinished
    1127 {
    1128     return tr_getFinished(fHandle);
    1129 }
    1130 
    11311133- (NSArray *) peers
    11321134{
     
    13501352- (void) setFileCheckState: (int) state forFileItem: (NSDictionary *) item
    13511353{
     1354    #warning use index set
    13521355    if (![[item objectForKey: @"IsFolder"] boolValue])
    13531356        tr_torrentSetFilePriority(fHandle, [[item objectForKey: @"Index"] intValue],
     
    15481551    NSMutableArray * pathComponents;
    15491552    NSString * path;
    1550     BOOL shouldDownload;
     1553    int priority;
     1554    tr_priority_t actualPriority;
    15511555   
    15521556    NSMutableArray * fileList = [[NSMutableArray alloc] init];
     
    15651569            path = @"";
    15661570       
     1571        priority = filePriorities ? [[filesShouldDownload objectAtIndex: i] intValue] : PRIORITY_NORMAL;
    15671572        [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path
    1568                 fileSize: file->length index: i];
     1573                fileSize: file->length index: i priority: priority];
    15691574        [pathComponents autorelease];
    15701575       
    1571         shouldDownload = filesShouldDownload ? [[filesShouldDownload objectAtIndex: i] boolValue] : YES;
    1572         #warning add priorities
    1573         tr_torrentSetFilePriority(fHandle, i, YES ? TR_PRI_NORMAL : TR_PRI_DND);
     1576        if (!filesShouldDownload || [[filesShouldDownload objectAtIndex: i] boolValue])
     1577        {
     1578            if (priority == PRIORITY_HIGH)
     1579                actualPriority = TR_PRI_HIGH;
     1580            else if (priority == PRIORITY_LOW)
     1581                actualPriority = TR_PRI_LOW;
     1582            else
     1583                actualPriority = TR_PRI_NORMAL;
     1584        }
     1585        else
     1586            actualPriority = TR_PRI_DND;
     1587       
     1588        tr_torrentSetFilePriority(fHandle, i, actualPriority);
    15741589    }
    15751590   
     
    15801595- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    15811596        withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    1582         fileSize: (uint64_t) size index: (int) index
     1597        fileSize: (uint64_t) size index: (int) index priority: (int) priority
    15831598{
    15841599    NSString * name = [components objectAtIndex: 0];
     
    16131628            [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
    16141629            [dict setObject: [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]] forKey: @"Icon"];
     1630            [dict setObject: [NSNumber numberWithInt: priority] forKey: @"Priority"];
    16151631        }
    16161632       
     
    16281644        [components removeObjectAtIndex: 0];
    16291645        [self insertPath: components forSiblings: [dict objectForKey: @"Children"]
    1630             withParent: dict previousPath: currentPath fileSize: size index: index];
     1646            withParent: dict previousPath: currentPath fileSize: size index: index priority: priority];
    16311647    }
    16321648}
Note: See TracChangeset for help on using the changeset viewer.