Changeset 159


Ignore:
Timestamp:
Mar 15, 2006, 9:46:33 PM (16 years ago)
Author:
titer
Message:

Fixed removal of torrents

Location:
branches/new_api/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/new_api/macosx/Controller.h

    r151 r159  
    127127- (void) notifyGrowl:       (NSString *) file;
    128128- (void) revealFromMenu:    (id) sender;
    129 - (void) finderTrash:       (NSString *) path;
    130129- (void) growlRegister:     (id) sender;
    131130
  • branches/new_api/macosx/Controller.m

    r156 r159  
    503503            deleteData: (BOOL) deleteData
    504504{
     505    Torrent * torrent = [fTorrents objectAtIndex: idx];
     506
    505507    /* Pause if not paused already */
    506     [self stopTorrentWithIndex:idx];
    507 
    508 #if 0
     508    [torrent stop];
     509
    509510    if( deleteData )
    510511    {
    511         [self finderTrash: [NSString stringWithFormat: @"%@/%@",
    512             [NSString stringWithUTF8String: fStat[idx].folder],
    513             [NSString stringWithUTF8String: fStat[idx].info.name]]];
     512        [torrent trashData];
    514513    }
    515514    if( deleteTorrent )
    516515    {
    517         [self finderTrash: [NSString stringWithUTF8String:
    518             fStat[idx].info.torrent]];
    519     }
    520 
    521     tr_torrentClose( fHandle, idx );
    522     [self updateUI: NULL];
     516        [torrent trashTorrent];
     517    }
     518
     519    [fTorrents removeObject: torrent];
     520    [torrent release];
     521
     522    [self updateUI: nil];
    523523    [self updateTorrentHistory];
    524 #endif
    525524}
    526525
     
    10981097}
    10991098
    1100 - (void) finderTrash: (NSString *) path
    1101 {
    1102     NSString * string;
    1103     NSAppleScript * appleScript;
    1104     NSDictionary * error;
    1105 
    1106     string = [NSString stringWithFormat:
    1107         @"tell application \"Finder\"\n"
    1108          "  move (POSIX file \"%@\") to trash\n"
    1109          "end tell", path];
    1110 
    1111     appleScript = [[NSAppleScript alloc] initWithSource: string];
    1112     if( ![appleScript executeAndReturnError: &error] )
    1113     {
    1114         printf( "finderTrash failed\n" );
    1115     }
    1116     [appleScript release];
    1117 }
    1118 
    11191099- (void) checkForUpdate: (id) sender
    11201100{
  • branches/new_api/macosx/Torrent.h

    r151 r159  
    5050- (void)       wakeUp;
    5151- (void)       reveal;
     52- (void)       trashTorrent;
     53- (void)       trashData;
    5254
    5355- (NSImage *)  icon;
  • branches/new_api/macosx/Torrent.m

    r151 r159  
    2424#import "StringAdditions.h"
    2525
     26@interface Torrent (Private)
     27
     28- (void) trashPath: (NSString *) path;
     29
     30@end
     31
     32
    2633@implementation Torrent
    2734
     
    210217}
    211218
     219- (void) trashTorrent
     220{
     221    [self trashPath: [self path]];
     222}
     223
     224- (void) trashData
     225{
     226    [self trashPath: [NSString stringWithFormat: @"%@/%@",
     227        [self getFolder], [self name]]];
     228}
     229
    212230- (NSImage *) icon
    213231{
     
    276294
    277295@end
     296
     297
     298@implementation Torrent (Private)
     299
     300- (void) trashPath: (NSString *) path
     301{
     302    NSString * string;
     303    NSAppleScript * appleScript;
     304    NSDictionary * error;
     305
     306    string = [NSString stringWithFormat:
     307        @"tell application \"Finder\"\n"
     308         "  move (POSIX file \"%@\") to trash\n"
     309         "end tell", path];
     310   
     311    appleScript = [[NSAppleScript alloc] initWithSource: string];
     312    if( ![appleScript executeAndReturnError: &error] )
     313    {
     314        printf( "trashPath failed\n" );
     315    }
     316    [appleScript release];
     317}
     318
     319@end
Note: See TracChangeset for help on using the changeset viewer.