Ignore:
Timestamp:
Jun 27, 2007, 10:12:10 PM (15 years ago)
Author:
livings124
Message:

commit my current work...still doesn't compile (calls some non-existent functions :))

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r2205 r2209  
    708708    while ((torrentPath = [enumerator nextObject]))
    709709    {
    710         if (!(torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib]))
     710        NSString * location;
     711        if (path)
     712            location = path;
     713        else if ([downloadChoice isEqualToString: @"Constant"])
     714            location = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
     715        else
     716            location = [torrentPath stringByDeletingLastPathComponent];
     717       
     718        if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location forceDeleteTorrent: delete lib: fLib]))
    711719            continue;
    712720       
     
    714722        [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
    715723       
    716         NSString * folder;
    717         if (path)
    718             folder = path;
    719         else if ([downloadChoice isEqualToString: @"Constant"])
    720             folder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
    721         else
    722             folder = [torrentPath stringByDeletingLastPathComponent];
    723        
    724         [torrent setDownloadFolder: folder];
    725724        [torrent update];
    726        
    727725        [fTorrents addObject: torrent];
    728726        [torrent release];
     
    773771- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
    774772{
     773    //determine the next file that can be opened
    775774    NSString * torrentPath;
    776     tr_torrent_t * tempTor;
    777     int error;
    778    
    779     //determine next file that can be opened
     775    int canAdd;
    780776    do
    781777    {
     
    789785   
    790786        torrentPath = [[files objectAtIndex: 0] retain];
    791         tempTor = tr_torrentInit(fLib, [torrentPath UTF8String], NULL, 0, &error);
    792        
    793787        [files removeObjectAtIndex: 0];
    794     } while (!tempTor);
     788    } while (tr_torrentCouldBeAdded(fLib, [torrentPath UTF8String]) != TR_OK);
    795789
    796790    NSOpenPanel * panel = [NSOpenPanel openPanel];
     
    802796    [panel setCanCreateDirectories: YES];
    803797
    804     [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
     798    #warning fix!!!
     799    /*[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
    805800                        "Open torrent -> select destination folder"),
    806                         [NSString stringWithUTF8String: tr_torrentInfo(tempTor)->name]]];
     801                        [NSString stringWithUTF8String: tr_torrentInfo(tempTor)->name]]];*/
     802    [panel setMessage: @"Select the download folder "];
    807803   
    808804    NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrentPath, @"Path",
    809805                                    files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
    810806    [torrentPath release];
    811 
    812     tr_torrentClose(tempTor);
     807   
    813808    [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
    814809            didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
     
    820815    {
    821816        NSString * torrentPath = [dictionary objectForKey: @"Path"];
    822         Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent:
    823                                 [[dictionary objectForKey: @"Delete"] boolValue] lib: fLib];
     817        Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath
     818                            location: [[openPanel filenames] objectAtIndex: 0]
     819                            forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue] lib: fLib];
    824820       
    825821        //add it to the "File > Open Recent" menu
    826822        [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
    827823       
    828         [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
    829824        [torrent update];
    830        
    831825        [fTorrents addObject: torrent];
    832826        [torrent release];
     
    20242018        [self openFiles: newNames];
    20252019   
    2026     //create temporary torrents to check if an import fails because of an error
     2020    //check if an import fails because of an error so it can be tried again
    20272021    enumerator = [newNames objectEnumerator];
    2028     int error;
     2022    int canAdd;
    20292023    while ((file = [enumerator nextObject]))
    20302024    {
    2031         tr_torrent_t * tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error);
    2032        
    2033         if (tempTor)
    2034             tr_torrentClose(tempTor);
    2035         else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
    2036             [fAutoImportedNames removeObject: [file lastPathComponent]]; //can try to import later
    2037         else;
     2025        canAdd = tr_torrentCouldBeAdded(fLib, [file UTF8String]);
     2026        if (canAdd == TR_EINVALID || canAdd == TR_EOTHER)
     2027            [fAutoImportedNames removeObject: [file lastPathComponent]];
    20382028    }
    20392029   
     
    21562146        NSEnumerator * enumerator = [files objectEnumerator];
    21572147        NSString * file;
    2158         tr_torrent_t * tempTor;
    21592148        BOOL torrent = NO;
     2149        int canAdd;
    21602150        while ((file = [enumerator nextObject]))
    21612151        {
    2162             int error;
    2163             if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error)))
     2152            canAdd = tr_torrentCouldBeAdded(fLib, [file UTF8String]);
     2153            if (canAdd == TR_OK)
    21642154            {
    2165                 tr_torrentClose(tempTor);
    2166                
    21672155                if (!fOverlayWindow)
    21682156                    fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
     
    21712159                return NSDragOperationCopy;
    21722160            }
    2173             else
    2174             {
    2175                 if (error == TR_EUNSUPPORTED || error == TR_EDUPLICATE)
    2176                     torrent = YES;
    2177             }
     2161            else if (canAdd == TR_EUNSUPPORTED || canAdd == TR_EDUPLICATE)
     2162                torrent = YES;
     2163            else;
    21782164        }
    21792165       
     
    22232209        NSString * file;
    22242210        tr_torrent_t * tempTor;
     2211        int canAdd;
    22252212        while ((file = [enumerator nextObject]))
    22262213        {
    2227             int error;
    2228             if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error)))
     2214            canAdd = tr_torrentCouldBeAdded(fLib, [file UTF8String]);
     2215            if (canAdd == TR_OK)
    22292216            {
    22302217                tr_torrentClose(tempTor);
     
    22332220                torrent = YES;
    22342221            }
    2235             else
    2236             {
    2237                 if (error == TR_EUNSUPPORTED || error == TR_EDUPLICATE)
    2238                     torrent = YES;
    2239             }
     2222            else if (canAdd == TR_EUNSUPPORTED || canAdd == TR_EDUPLICATE)
     2223                torrent = YES;
     2224            else;
    22402225        }
    22412226       
Note: See TracChangeset for help on using the changeset viewer.