Changeset 1084


Ignore:
Timestamp:
Nov 13, 2006, 4:05:24 AM (15 years ago)
Author:
livings124
Message:

No choice but to delete the torrent file when adding when adding with url.

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r1081 r1084  
    9595}
    9696
    97 - (void) openFiles:     (NSArray *) filenames;
    98 - (void) openFiles:     (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
    99 - (void) openFilesAsk:  (NSMutableArray *) files;
    100 - (void) openShowSheet: (id) sender;
    101 - (void) openURL:               (NSURL *) torrentURL;
     97- (void) openFiles:             (NSArray *) filenames;
     98- (void) openFiles:             (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete;
     99- (void) openFilesAsk:          (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete;
     100- (void) openFilesAskWithDict:  (NSDictionary *) dictionary;
     101- (void) openShowSheet:         (id) sender;
     102- (void) openURL:               (NSURL *) torrentURL;
    102103
    103104- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
  • trunk/macosx/Controller.m

    r1083 r1084  
    354354- (void) applicationDidFinishLaunching: (NSNotification *) notification
    355355{
    356     [NSApp setServicesProvider:self];
     356    [NSApp setServicesProvider: self];
    357357   
    358358    //register for dock icon drags
     
    412412    //remove all torrent downloads
    413413    NSEnumerator * enumerator = [[fPendingTorrentDownloads allValues] objectEnumerator];
     414    NSDictionary * downloadDict;
    414415    NSURLDownload * download;
    415     while ((download = [enumerator nextObject]))
    416     {
     416    while ((downloadDict = [enumerator nextObject]))
     417    {
     418        download = [downloadDict objectForKey: @"Download"];
    417419        [download cancel];
    418420        [download release];
     
    458460}
    459461
    460 - (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
    461 {
    462     [self openFiles: filenames ignoreDownloadFolder: NO];
    463 }
    464 
    465462- (void) handleOpenContentsEvent: (NSAppleEventDescriptor *) event replyEvent: (NSAppleEventDescriptor *) replyEvent
    466463{
     
    484481- (void) openURL: (NSURL *) url
    485482{
    486     #warning remove when quitting
    487483    NSURLDownload * torrentDownload = [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url]
    488484                                        delegate: self];
     
    507503        NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
    508504        [download setDestination: path allowOverwrite: NO];
    509         [fPendingTorrentDownloads setObject: download forKey: [[download request] URL]];
     505        [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
     506                    path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
    510507    }
    511508}
     
    526523{
    527524    #warning try to open, if not delete
    528     [self openFiles: [NSArray arrayWithObject: [fPendingTorrentDownloads objectForKey: [[download request] URL]]]
    529             ignoreDownloadFolder: NO];
     525    [self openFiles: [NSArray arrayWithObject: [[fPendingTorrentDownloads objectForKey:
     526            [[download request] URL]] objectForKey: @"Path"]] ignoreDownloadFolder: NO forceDeleteTorrent: YES];
    530527   
    531528    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     
    533530}
    534531
    535 - (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
     532- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
     533{
     534    [self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     535}
     536
     537- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete
    536538{
    537539    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
    538540    if (ignore || [downloadChoice isEqualToString: @"Ask"])
    539541    {
    540         [self openFilesAsk: [filenames mutableCopy]];
     542        [self openFilesAsk: [filenames mutableCopy] forceDeleteTorrent: delete];
    541543        return;
    542544    }
     
    547549    while ((torrentPath = [enumerator nextObject]))
    548550    {
    549         if (!(torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib]))
     551        if (!(torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib]))
    550552            continue;
    551553
     
    572574
    573575//called by the main open method to show sheet for choosing download location
    574 - (void) openFilesAsk: (NSMutableArray *) files
     576- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
    575577{
    576578    NSString * torrentPath;
     
    589591   
    590592        torrentPath = [files objectAtIndex: 0];
    591         torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib];
     593        torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib];
    592594       
    593595        [files removeObjectAtIndex: 0];
     
    607609                        "Open torrent -> select destination folder"), [torrent name]]];
    608610   
    609     NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files", nil];
     611    NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files",
     612                                            [NSNumber numberWithBool: delete], @"Delete", nil];
    610613
    611614    [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
    612615            didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
    613 }
    614 
    615 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
    616     contextInfo: (NSDictionary *) dictionary
     616    [torrent release];
     617}
     618
     619- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) dictionary
    617620{
    618621    Torrent * torrent = [dictionary objectForKey: @"Torrent"];
     
    630633    }
    631634   
    632     [self performSelectorOnMainThread: @selector(openFilesAsk:) withObject: [dictionary objectForKey: @"Files"]
    633                         waitUntilDone: NO];
    634    
    635     [torrent release];
     635    [self performSelectorOnMainThread: @selector(openFilesAskWithDict:) withObject: dictionary waitUntilDone: NO];
     636}
     637
     638- (void) openFilesAskWithDict: (NSDictionary *) dictionary
     639{
     640    [self openFilesAsk: [dictionary objectForKey: @"Files"]
     641            forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
    636642    [dictionary release];
    637643}
     
    645651- (void) openFiles: (NSArray *) filenames
    646652{
    647     [self openFiles: filenames ignoreDownloadFolder: NO];
     653    [self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
    648654}
    649655
     
    674680{
    675681    [self openFiles: [dictionary objectForKey: @"Files"]
    676         ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]];
     682        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] forceDeleteTorrent: NO];
    677683   
    678684    [dictionary release];
  • trunk/macosx/Torrent.h

    r1054 r1084  
    6161}
    6262
    63 - (id)  initWithPath: (NSString *) path lib: (tr_handle_t *) lib;
     63- (id)  initWithPath: (NSString *) path forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib;
    6464- (id)  initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib;
    6565
  • trunk/macosx/Torrent.m

    r1065 r1084  
    5959                kWhite = BE(0xFFFFFFFF); //255, 255, 255
    6060
    61 - (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
    62 {
    63     self = [self initWithHash: nil path: path lib: lib publicTorrent: nil
     61- (id) initWithPath: (NSString *) path forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib
     62{
     63    self = [self initWithHash: nil path: path lib: lib
     64            publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
    6465            date: nil stopRatioSetting: nil ratioLimit: nil waitToStart: nil orderValue: nil];
    6566   
Note: See TracChangeset for help on using the changeset viewer.