Changeset 2758


Ignore:
Timestamp:
Aug 14, 2007, 9:11:17 PM (15 years ago)
Author:
livings124
Message:

(0.8x) when automatically opening a newly created torrent file, don't trash it regardless of prefs setting

Location:
branches/0.8x/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.8x/macosx/Controller.h

    r2728 r2758  
    107107- (void) openFiles:             (NSArray *) filenames;
    108108- (void) openFiles:             (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
    109                                             forceDeleteTorrent: (BOOL) delete;
     109                                            deleteTorrentFile: (torrentFileState) deleteTorrent;
    110110- (void) openCreatedFile:       (NSNotification *) notification;
    111111- (void) openFilesWithDict:     (NSDictionary *) dictionary;
    112 - (void) openFilesAsk:          (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete;
     112- (void) openFilesAsk:          (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent;
    113113- (void) openFilesAskWithDict:  (NSDictionary *) dictionary;
    114114- (void) openShowSheet:         (id) sender;
  • branches/0.8x/macosx/Controller.m

    r2728 r2758  
    657657   
    658658    [self openFiles: [NSArray arrayWithObject: path] forcePath: nil ignoreDownloadFolder:
    659         ![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] forceDeleteTorrent: YES];
     659        ![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] deleteTorrentFile: TORRENT_FILE_DELETE];
    660660   
    661661    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     
    670670- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
    671671{
    672     [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     672    [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_DEFAULT];
    673673}
    674674
    675675- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
    676         forceDeleteTorrent: (BOOL) delete
     676        deleteTorrentFile: (torrentFileState) deleteTorrent
    677677{
    678678    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
    679679    if (ignore || (!path && [downloadChoice isEqualToString: @"Ask"]))
    680680    {
    681         [self openFilesAsk: [filenames mutableCopy] forceDeleteTorrent: delete];
     681        [self openFilesAsk: [filenames mutableCopy] deleteTorrentFile: deleteTorrent];
    682682        return;
    683683    }
     
    701701                                        filenames, @"Filenames",
    702702                                        [NSNumber numberWithBool: ignore], @"Ignore",
    703                                         [NSNumber numberWithBool: delete], @"Delete", nil];
     703                                        [NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
    704704       
    705705        [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
     
    724724                                        filenames, @"Filenames",
    725725                                        [NSNumber numberWithBool: ignore], @"Ignore",
    726                                         [NSNumber numberWithBool: delete], @"Delete", nil];
     726                                        [NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
    727727       
    728728        [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
     
    753753        tr_metainfoFree(&info);
    754754       
    755         if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location forceDeleteTorrent: delete lib: fLib]))
     755        if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location deleteTorrentFile: deleteTorrent lib: fLib]))
    756756            continue;
    757757       
     
    771771    NSDictionary * dict = [notification userInfo];
    772772    [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] forcePath: [dict objectForKey: @"Path"]
    773             ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     773            ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_SAVE];
    774774    [dict release];
    775775}
     
    800800    [self openFiles: [dictionary objectForKey: @"Filenames"] forcePath: nil
    801801        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]
    802         forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
     802        deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue]];
    803803   
    804804    [dictionary release];
     
    806806
    807807//called by the main open method to show sheet for choosing download location
    808 - (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
     808- (void) openFilesAsk: (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent
    809809{
    810810    //determine the next file that can be opened
     
    847847   
    848848    NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [torrentPath retain], @"Path",
    849                                     files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
     849                                    files, @"Files", [NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
    850850    tr_metainfoFree(&info);
    851851   
     
    860860        NSString * torrentPath = [dictionary objectForKey: @"Path"];
    861861        Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath location: [[openPanel filenames] objectAtIndex: 0]
    862                             forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue] lib: fLib];
     862                            deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue] lib: fLib];
    863863       
    864864        //add it to the "File > Open Recent" menu
     
    878878{
    879879    [self openFilesAsk: [dictionary objectForKey: @"Files"]
    880             forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
     880            deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue]];
    881881    [dictionary release];
    882882}
     
    890890- (void) openFiles: (NSArray *) filenames
    891891{
    892     [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     892    [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_DEFAULT];
    893893}
    894894
     
    919919{
    920920    [self openFiles: [dictionary objectForKey: @"Files"] forcePath: nil
    921         ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] forceDeleteTorrent: NO];
     921        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] deleteTorrentFile: TORRENT_FILE_DEFAULT];
    922922   
    923923    [dictionary release];
     
    32443244    int oldCount = [fTorrents count];
    32453245   
    3246     [self openFiles: [NSArray arrayWithObject: path] forcePath: directory ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     3246    [self openFiles: [NSArray arrayWithObject: path] forcePath: directory ignoreDownloadFolder: NO deleteTorrentFile: NO];
    32473247   
    32483248    return [fTorrents count] > oldCount;
  • branches/0.8x/macosx/Torrent.h

    r2560 r2758  
    2828#define INVALID -99
    2929
     30typedef enum
     31{
     32        TORRENT_FILE_DELETE,
     33    TORRENT_FILE_SAVE,
     34    TORRENT_FILE_DEFAULT
     35} torrentFileState;
     36
    3037@interface Torrent : NSObject
    3138{
     
    6875}
    6976
    70 - (id) initWithPath: (NSString *) path location: (NSString *) location forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib;
     77- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
     78        lib: (tr_handle_t *) lib;
    7179- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib;
    7280
  • branches/0.8x/macosx/Torrent.m

    r2623 r2758  
    7575                kWhite = BE(0xFFFFFFFF); //255, 255, 255
    7676
    77 - (id) initWithPath: (NSString *) path location: (NSString *) location forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib
     77- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
     78        lib: (tr_handle_t *) lib
    7879{
    7980    self = [self initWithHash: nil path: path lib: lib
    80             publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
     81            publicTorrent: torrentDelete != TORRENT_FILE_DEFAULT
     82                            ? [NSNumber numberWithBool: torrentDelete == TORRENT_FILE_SAVE] : nil
    8183            downloadFolder: location
    8284            useIncompleteFolder: nil incompleteFolder: nil
Note: See TracChangeset for help on using the changeset viewer.