Changeset 5938


Ignore:
Timestamp:
May 27, 2008, 12:52:18 AM (14 years ago)
Author:
livings124
Message:

support for adding a transfer through rpc

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r5935 r5938  
    4141typedef enum
    4242{
    43     ADD_NORMAL,
     43    ADD_MANUAL,
    4444    ADD_AUTO,
    4545    ADD_SHOW_OPTIONS,
  • trunk/macosx/Controller.m

    r5935 r5938  
    694694- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
    695695{
    696     [self openFiles: filenames addType: ADD_NORMAL forcePath: nil];
     696    [self openFiles: filenames addType: ADD_MANUAL forcePath: nil];
    697697}
    698698
     
    885885{
    886886    NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: files, @"Filenames",
    887                                 [NSNumber numberWithInt: ADD_NORMAL], @"AddType", nil];
     887                                [NSNumber numberWithInt: ADD_MANUAL], @"AddType", nil];
    888888    [self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dict waitUntilDone: NO];
    889889}
     
    907907    {
    908908        NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [panel filenames], @"Filenames",
    909             [NSNumber numberWithInt: [useOptions boolValue] ? ADD_SHOW_OPTIONS : ADD_NORMAL], @"AddType", nil];
     909            [NSNumber numberWithInt: [useOptions boolValue] ? ADD_SHOW_OPTIONS : ADD_MANUAL], @"AddType", nil];
    910910        [self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
    911911    }
     
    41524152   
    41534153    //get the torrent
    4154     if (torrentStruct != NULL && type != TR_RPC_TORRENT_ADDED)
     4154    if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED))
    41554155    {
    41564156        NSEnumerator * enumerator = [fTorrents objectEnumerator];
     
    41704170    {
    41714171        case TR_RPC_TORRENT_ADDED:
     4172            [self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
     4173                [[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
    41724174            break;
    41734175        case TR_RPC_TORRENT_STARTED:
     
    41864188}
    41874189
     4190- (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr
     4191{
     4192    tr_torrent * torrentStruct = (tr_torrent *)[torrentStructPtr pointerValue];
     4193    [torrentStructPtr release];
     4194   
     4195    NSString * location = nil;
     4196    if (tr_torrentGetDownloadDir(torrentStruct) != NULL)
     4197        location = [NSString stringWithUTF8String: tr_torrentGetDownloadDir(torrentStruct)];
     4198   
     4199    Torrent * torrent = [[Torrent alloc] initWithTorrentStruct: torrentStruct location: location lib: fLib];
     4200   
     4201    [torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
     4202   
     4203    [torrent update];
     4204    [fTorrents addObject: torrent];
     4205    [torrent release];
     4206   
     4207    [self updateTorrentsInQueue];
     4208}
     4209
    41884210/*- (void) ipcQuit
    41894211{
  • trunk/macosx/Torrent.m

    r5937 r5938  
    15591559    {
    15601560        fHandle = torrentStruct;
    1561        
    1562         const tr_info * info = tr_torrentInfo(fHandle);
    1563         NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info->name]]
     1561        fInfo = tr_torrentInfo(fHandle);
     1562       
     1563        NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: fInfo->name]]
    15641564                                                ? fIncompleteFolder : fDownloadFolder;
    15651565        tr_torrentSetDownloadDir(fHandle, [currentDownloadFolder UTF8String]);
    1566         tr_metainfoFree(info);
    15671566    }
    15681567    else
     
    16081607            return nil;
    16091608        }
     1609       
     1610        fInfo = tr_torrentInfo(fHandle);
    16101611    }
    16111612   
    16121613    tr_torrentSetStatusCallback(fHandle, completenessChangeCallback, self);
    1613    
    1614     fInfo = tr_torrentInfo(fHandle);
    16151614   
    16161615    fNameString = [[NSString alloc] initWithUTF8String: fInfo->name];
Note: See TracChangeset for help on using the changeset viewer.