Changeset 294


Ignore:
Timestamp:
Jun 8, 2006, 5:01:42 AM (16 years ago)
Author:
joshe
Message:

Re-commit rev 291, in the right place this time.

Location:
branches/save_torrent_files/macosx
Files:
13 edited

Legend:

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

    r272 r294  
    9797
    9898- (void) removeTorrent:                 (id) sender;
    99 - (void) removeTorrentDeleteTorrent:    (id) sender;
    10099- (void) removeTorrentDeleteData:       (id) sender;
    101 - (void) removeTorrentDeleteBoth:       (id) sender;
    102100- (void) removeTorrentWithIndex:        (NSIndexSet *) indexSet
    103                 deleteTorrent:          (BOOL) deleteTorrent
    104101                deleteData:             (BOOL) deleteData;
    105102               
     
    107104                        contextInfo: (NSDictionary *) dict;
    108105- (void) confirmRemoveTorrents: (NSArray *) torrents
    109             deleteTorrent: (BOOL) deleteTorrent
    110106            deleteData: (BOOL) deleteData;
    111107
  • branches/save_torrent_files/macosx/Controller.m

    r275 r294  
    525525
    526526- (void) removeTorrentWithIndex: (NSIndexSet *) indexSet
    527                   deleteTorrent: (BOOL) deleteTorrent
    528527                     deleteData: (BOOL) deleteData
    529528{
     
    541540        NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
    542541            torrents, @"Torrents",
    543             [NSNumber numberWithBool: deleteTorrent], @"DeleteTorrent",
    544542            [NSNumber numberWithBool: deleteData], @"DeleteData",
    545543            nil];
     
    573571    {
    574572        [self confirmRemoveTorrents: torrents
    575                 deleteTorrent: deleteTorrent
    576573                deleteData: deleteData];
    577574    }
     
    584581
    585582    NSArray * torrents = [dict objectForKey: @"Torrents"];
    586     BOOL deleteTorrent = [[dict objectForKey: @"DeleteTorrent"] boolValue];
    587583    BOOL deleteData = [[dict objectForKey: @"DeleteData"] boolValue];
    588584    [dict release];
     
    591587    {
    592588        [self confirmRemoveTorrents: torrents
    593             deleteTorrent: deleteTorrent
    594589            deleteData: deleteData];
    595590    }
     
    599594
    600595- (void) confirmRemoveTorrents: (NSArray *) torrents
    601             deleteTorrent: (BOOL) deleteTorrent
    602596            deleteData: (BOOL) deleteData
    603597{
     
    610604        if( deleteData )
    611605            [torrent trashData];
    612            
    613         if( deleteTorrent )
    614             [torrent trashTorrent];
    615 
     606
     607        [torrent removeForever];
    616608        [fTorrents removeObject: torrent];
    617609    }
     
    626618- (void) removeTorrent: (id) sender
    627619{
    628     [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteTorrent: NO deleteData: NO];
    629 }
    630 
    631 - (void) removeTorrentDeleteTorrent: (id) sender
    632 {
    633     [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteTorrent: YES deleteData: NO];
     620    [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteData: NO];
    634621}
    635622
    636623- (void) removeTorrentDeleteData: (id) sender
    637624{
    638     [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteTorrent: NO deleteData: YES];
    639 }
    640 
    641 - (void) removeTorrentDeleteBoth: (id) sender
    642 {
    643     [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteTorrent: YES deleteData: YES];
     625    [self removeTorrentWithIndex: [fTableView selectedRowIndexes] deleteData: YES];
    644626}
    645627
     
    12101192
    12111193    //enable remove items
    1212     if (action == @selector(removeTorrent:)
    1213         || action == @selector(removeTorrentDeleteTorrent:)
    1214         || action == @selector(removeTorrentDeleteData:)
    1215         || action == @selector(removeTorrentDeleteBoth:))
     1194    if (action == @selector(removeTorrent:) || action == @selector(removeTorrentDeleteData:))
    12161195    {
    12171196        BOOL active = NO;
  • branches/save_torrent_files/macosx/Defaults.plist

    r272 r294  
    1919        <key>CheckUpload</key>
    2020        <true/>
     21        <key>DeleteOriginalTorrent</key>
     22        <false/>
    2123        <key>DownloadChoice</key>
    2224        <string>Constant</string>
     
    4143        <key>SUScheduledCheckInterval</key>
    4244        <integer>86400</integer>
     45        <key>SavePrivateTorrent</key>
     46        <true/>
    4347        <key>ShowInspector</key>
    4448        <false/>
  • branches/save_torrent_files/macosx/English.lproj/MainMenu.nib/classes.nib

    r272 r294  
    1010                openShowSheet = id;
    1111                removeTorrent = id;
    12                 removeTorrentDeleteBoth = id;
    1312                removeTorrentDeleteData = id;
    14                 removeTorrentDeleteTorrent = id;
    1513                resumeAllTorrents = id;
    1614                resumeTorrent = id;
  • branches/save_torrent_files/macosx/English.lproj/MainMenu.nib/info.nib

    r276 r294  
    3030        <key>IBOpenObjects</key>
    3131        <array>
     32                <integer>29</integer>
     33                <integer>1480</integer>
    3234                <integer>21</integer>
    33                 <integer>1480</integer>
    3435        </array>
    3536        <key>IBSystem Version</key>
  • branches/save_torrent_files/macosx/English.lproj/PrefsWindow.nib/classes.nib

    r272 r294  
    1111                setLimit = id;
    1212                setLimitCheck = id;
     13                setMoveTorrent = id;
    1314                setPort = id;
    1415                setRatio = id;
     
    2324                fBadgeDownloadRateCheck = NSButton;
    2425                fBadgeUploadRateCheck = NSButton;
     26                fCopyTorrentCheck = NSButton;
     27                fDeleteOriginalTorrentCheck = NSButton;
    2528                fDownloadCheck = NSButton;
    2629                fDownloadField = NSTextField;
  • branches/save_torrent_files/macosx/English.lproj/PrefsWindow.nib/info.nib

    r272 r294  
    88        <dict>
    99                <key>28</key>
    10                 <string>347 472 462 212 0 0 1152 842 </string>
     10                <string>345 472 462 212 0 0 1152 842 </string>
    1111                <key>41</key>
    12                 <string>345 461 462 234 0 0 1152 842 </string>
     12                <string>262 506 462 274 0 0 1152 842 </string>
    1313                <key>66</key>
    1414                <string>347 526 462 104 0 0 1152 842 </string>
  • branches/save_torrent_files/macosx/PrefsController.h

    r272 r294  
    3737    IBOutlet NSButton       * fQuitCheck, * fRemoveCheck,
    3838                            * fBadgeDownloadRateCheck, * fBadgeUploadRateCheck,
    39                             * fAutoStartCheck;                           
     39                            * fAutoStartCheck, * fCopyTorrentCheck, * fDeleteOriginalTorrentCheck;
    4040    IBOutlet NSPopUpButton  * fUpdatePopUp;
    4141
     
    5959- (void) checkUpdate;
    6060- (void) setAutoStart:          (id) sender;
     61- (void) setMoveTorrent:        (id) sender;
    6162- (void) setDownloadLocation:   (id) sender;
    6263- (void) folderSheetShow:       (id) sender;
  • branches/save_torrent_files/macosx/PrefsController.m

    r272 r294  
    117117    int uploadLimit = [fDefaults integerForKey: @"UploadLimit"];
    118118   
    119     [fUploadCheck setState: checkUpload ? NSOnState : NSOffState];
     119    [fUploadCheck setState: checkUpload];
    120120    [fUploadField setIntValue: uploadLimit];
    121121    [fUploadField setEnabled: checkUpload];
     
    127127    int downloadLimit = [fDefaults integerForKey: @"DownloadLimit"];
    128128   
    129     [fDownloadCheck setState: checkDownload ? NSOnState : NSOffState];
     129    [fDownloadCheck setState: checkDownload];
    130130    [fDownloadField setIntValue: downloadLimit];
    131131    [fDownloadField setEnabled: checkDownload];
     
    135135    //set ratio limit
    136136    BOOL ratioCheck = [fDefaults boolForKey: @"RatioCheck"];
    137     [fRatioCheck setState: ratioCheck ? NSOnState : NSOffState];
     137    [fRatioCheck setState: ratioCheck];
    138138    [fRatioField setEnabled: ratioCheck];
    139139    [fRatioField setFloatValue: [fDefaults floatForKey: @"RatioLimit"]];
    140140   
    141141    //set remove and quit prompts
    142     [fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"] ?
    143         NSOnState : NSOffState];
    144     [fRemoveCheck setState: [fDefaults boolForKey: @"CheckRemove"] ?
    145         NSOnState : NSOffState];
     142    [fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"]];
     143    [fRemoveCheck setState: [fDefaults boolForKey: @"CheckRemove"]];
    146144
    147145    //set dock badging
     
    151149    //set auto start
    152150    [fAutoStartCheck setState: [fDefaults boolForKey: @"AutoStartDownload"]];
     151   
     152    //set private torrents
     153    BOOL copyTorrents = [fDefaults boolForKey: @"SavePrivateTorrent"];
     154    [fCopyTorrentCheck setState: copyTorrents];
     155   
     156    [fDeleteOriginalTorrentCheck setEnabled: copyTorrents];
     157    [fDeleteOriginalTorrentCheck setState: [fDefaults boolForKey: @"DeleteOriginalTorrent"]];
    153158
    154159    //set update check
     
    418423{
    419424    [fDefaults setBool: [sender state] forKey: @"AutoStartDownload"];
     425}
     426
     427- (void) setMoveTorrent: (id) sender
     428{
     429    int state = [sender state];
     430    if (sender == fCopyTorrentCheck)
     431    {
     432        [fDefaults setBool: state forKey: @"SavePrivateTorrent"];
     433       
     434        [fDeleteOriginalTorrentCheck setEnabled: state];
     435        if (state == NSOffState)
     436        {
     437            [fDeleteOriginalTorrentCheck setState: NSOffState];
     438            [fDefaults setBool: NO forKey: @"DeleteOriginalTorrent"];
     439        }
     440    }
     441    else
     442        [fDefaults setBool: state forKey: @"DeleteOriginalTorrent"];
    420443}
    421444
  • branches/save_torrent_files/macosx/Torrent.h

    r272 r294  
    3636    tr_info_t    * fInfo;
    3737    tr_stat_t    * fStat;
     38   
    3839    BOOL         fResumeOnWake;
    3940    NSDate       * fDate;
     41   
     42    BOOL        fPrivateSaved;
    4043
    4144    NSUserDefaults  * fDefaults;
     
    5659- (void)       getAvailability: (int8_t *) tab size: (int) size;
    5760
    58 - (void)       update;
    59 - (void)       start;
    60 - (void)       stop;
    61 - (void)       sleep;
    62 - (void)       wakeUp;
     61- (void)        update;
     62- (void)        start;
     63- (void)        stop;
     64- (void)        removeForever;
     65- (void)        sleep;
     66- (void)        wakeUp;
    6367
    6468- (float)       ratio;
     
    6973
    7074- (void)        reveal;
    71 - (void)        trashTorrent;
    7275- (void)        trashData;
    7376
  • branches/save_torrent_files/macosx/Torrent.m

    r282 r294  
    2929@interface Torrent (Private)
    3030
    31 - (void) trashPath: (NSString *) path;
    3231- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib date: (NSDate *) date
    3332        stopRatioSetting: (NSNumber *) stopRatioSetting ratioLimit: (NSNumber *) ratioLimit;
     33- (id) initWithHash: (NSString *) hashString lib: (tr_handle_t *) lib date: (NSDate *) date
     34        stopRatioSetting: (NSNumber *) stopRatioSetting ratioLimit: (NSNumber *) ratioLimit;
     35- (id) initForSuccessWithDate: (NSDate *) date stopRatioSetting: (NSNumber *)
     36            stopRatioSetting ratioLimit: (NSNumber *) ratioLimit;
     37
     38- (void) trashPath: (NSString *) path;
    3439
    3540@end
     
    4045- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
    4146{
    42     return [self initWithPath: path lib: lib
    43             date: nil stopRatioSetting: nil
    44             ratioLimit: nil];
     47    id torrent = [self initWithPath: path lib: lib
     48                    date: nil stopRatioSetting: nil
     49                    ratioLimit: nil];
     50    NSLog(path);
     51    if (fPrivateSaved && [fDefaults boolForKey: @"DeleteOriginalTorrent"])
     52        [self trashPath: path];
     53   
     54    return torrent;
    4555}
    4656
    4757- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib
    4858{
    49     self = [self initWithPath: [history objectForKey: @"TorrentPath"]
     59    NSNumber * privateCopy;
     60    if ((privateCopy = [history objectForKey: @"PrivateCopy"]) && [privateCopy boolValue])
     61        self = [self initWithHash: [history objectForKey: @"TorrentHash"]
     62            lib: lib date: [history objectForKey: @"Date"]
     63            stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
     64            ratioLimit: [history objectForKey: @"RatioLimit"]];
     65    else
     66        self = [self initWithPath: [history objectForKey: @"TorrentPath"]
    5067            lib: lib date: [history objectForKey: @"Date"]
    5168            stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
     
    6986- (NSDictionary *) history
    7087{
    71     return [NSDictionary dictionaryWithObjectsAndKeys:
    72             [self torrentLocation], @"TorrentPath",
    73             [self downloadFolder], @"DownloadFolder",
    74             [self isActive] ? @"NO" : @"YES", @"Paused",
    75             [self date], @"Date",
    76             [NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
    77             [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit", nil];
     88    NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
     89                    [NSNumber numberWithBool: fPrivateSaved], @"PrivateCopy",
     90                    [self downloadFolder], @"DownloadFolder",
     91                    [self isActive] ? @"NO" : @"YES", @"Paused",
     92                    [self date], @"Date",
     93                    [NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
     94                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit", nil];
     95           
     96    if (fPrivateSaved)
     97        [history setObject: [self torrentLocation] forKey: @"TorrentPath"];
     98    else
     99        [history setObject: [self hashString] forKey: @"TorrentHash"];
     100   
     101    return history;
    78102}
    79103
     
    212236}
    213237
     238- (void) removeForever
     239{
     240    tr_torrentRemoveSaved(fHandle);
     241}
     242
    214243- (void) sleep
    215244{
     
    261290}
    262291
    263 - (void) trashTorrent
    264 {
    265     [self trashPath: [self torrentLocation]];
    266 }
    267 
    268292- (void) trashData
    269293{
     
    314338- (NSString *) hashString
    315339{
    316     NSMutableString * string = [NSMutableString
     340    /*NSMutableString * string = [NSMutableString
    317341        stringWithCapacity: SHA_DIGEST_LENGTH];
    318342    int i;
     
    321345        [string appendFormat: @"%02x", fInfo->hash[i]];
    322346    }
    323     return string;
     347    return string;*/
     348   
     349    return [NSString stringWithUTF8String: fInfo->hashString];
    324350}
    325351
    326352- (NSString *) torrentLocation
    327353{
    328     return [NSString stringWithUTF8String: fInfo->torrent];;
     354    return [NSString stringWithUTF8String: fInfo->torrent];
    329355}
    330356
     
    487513
    488514    fLib = lib;
     515    fDefaults = [NSUserDefaults standardUserDefaults];
     516
     517    fPrivateSaved = [fDefaults boolForKey: @"SavePrivateTorrent"];
    489518
    490519    int error;
    491     if (!path || !(fHandle = tr_torrentInit(fLib, [path UTF8String], 0, &error)))
     520    if (!path || !(fHandle = tr_torrentInit(fLib, [path UTF8String],
     521                    fPrivateSaved ? TR_FSAVEPRIVATE : 0, &error)))
    492522    {
    493523        [self release];
     
    495525    }
    496526   
     527    return [self initForSuccessWithDate: date stopRatioSetting: stopRatioSetting ratioLimit: ratioLimit];
     528}
     529
     530- (id) initWithHash: (NSString *) hashString lib: (tr_handle_t *) lib date: (NSDate *) date
     531        stopRatioSetting: (NSNumber *) stopRatioSetting ratioLimit: (NSNumber *) ratioLimit
     532{
     533    if (!(self = [super init]))
     534        return nil;
     535
     536    fLib = lib;
     537    fDefaults = [NSUserDefaults standardUserDefaults];
     538   
     539    fPrivateSaved = YES;
     540
     541    int error;
     542    if (!hashString || !(fHandle = tr_torrentInitSaved(fLib, [hashString UTF8String], TR_FSAVEPRIVATE, &error)))
     543    {
     544        [self release];
     545        return nil;
     546    }
     547   
     548    return [self initForSuccessWithDate: date stopRatioSetting: stopRatioSetting ratioLimit: ratioLimit];
     549}
     550
     551- (id) initForSuccessWithDate: (NSDate *) date stopRatioSetting: (NSNumber *)
     552            stopRatioSetting ratioLimit: (NSNumber *) ratioLimit
     553{
    497554    fInfo = tr_torrentInfo( fHandle );
    498    
    499     fDefaults = [NSUserDefaults standardUserDefaults];
    500555
    501556    fDate = date ? [date retain] : [[NSDate alloc] init];
     
    517572    return self;
    518573}
     574
    519575
    520576- (void) trashPath: (NSString *) path
Note: See TracChangeset for help on using the changeset viewer.