support adding torrent from data with ipc

This commit is contained in:
Mitchell Livingston 2008-01-21 06:23:10 +00:00
parent 1b7706e101
commit 0a2720339f
6 changed files with 64 additions and 23 deletions

12
NEWS
View File

@ -5,6 +5,18 @@ NEWS file for Transmission <http://www.transmissionbt.com/>
+ Window when adding torrents to select files and other settings
+ Use the file icon as the per-torrent action button
1.02 (2008/01/xx)
- All Platforms:
+ Fix 1.00 bug that caused some routers to lag
+ Fix 1.00 crash in peer handshake
+ Fix 1.01 bug that sometimes froze the app for a long time
- GTK+
+ Fix crash when removing a torrent while its details window is open
+ Better compliance with the Gnome interface guidelines
+ I18N fixes
+ Updated Dutch translation
+ Various other interface additions and improvements
1.01 (2008/01/11)
- All Platforms:
+ Fix 1.00 freezing issue

View File

@ -651,9 +651,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
{
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
@"Torrent download error -> title"), [NSString stringWithFormat:
NSLocalizedString(@"The torrent could not be downloaded from %@ because an error occurred (%@).",
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", @"Torrent download error -> title"),
[NSString stringWithFormat: NSLocalizedString(@"The torrent could not be downloaded from %@ because an error occurred (%@).",
@"Torrent download failed -> message"),
[[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding],
[error localizedDescription]], NSLocalizedString(@"OK", @"Torrent download failed -> button"), nil, nil);
@ -3854,20 +3853,23 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (BOOL) ipcAddTorrentData: (NSData *) data directory: (NSString *) directory
{
/* 'data' is the contents of a torrent file, 'directory' is the
directory it should download it's files to and may be nil,
should return NO if torrent fails to load */
return NO;
return [self ipcAddTorrentDataAutostart: data directory: directory autostart: [fDefaults boolForKey: @"AutoStartDownload"]];
}
- (BOOL) ipcAddTorrentDataAutostart: (NSData *) path directory: (NSString *) directory autostart: (BOOL) autostart
- (BOOL) ipcAddTorrentDataAutostart: (NSData *) data directory: (NSString *) directory autostart: (BOOL) autostart
{
/* 'data' is the contents of a torrent file, 'directory' is the
directory it should download it's files to and may be nil,
'autostart' is a boolean indicating if the torrent should be
automatically started (or queued to start, I guess), should
return NO if torrent fails to load */
return NO;
Torrent * torrent;
if ((torrent = [[Torrent alloc] initWithData: data location: directory lib: fLib]))
{
[torrent update];
[fTorrents addObject: torrent];
[torrent release];
[self updateTorrentsInQueue];
return YES;
}
else
return NO;
}
- (BOOL) ipcStartTorrents: (NSArray *) torrents

View File

@ -26,7 +26,6 @@
@implementation InfoTabButtonCell
#warning store images in image/alternateImage?
- (void) awakeFromNib
{
[(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self];

View File

@ -75,6 +75,7 @@ typedef enum
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
lib: (tr_handle *) lib;
- (id) initWithData: (NSData *) data location: (NSString *) location lib: (tr_handle *) lib;
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle *) lib;
- (NSDictionary *) history;

View File

@ -31,7 +31,7 @@ static int static_lastid = 0;
@interface Torrent (Private)
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle *) lib
- (id) initWithHash: (NSString *) hashString path: (NSString *) path data: (NSData *) data lib: (tr_handle *) lib
publicTorrent: (NSNumber *) publicTorrent
downloadFolder: (NSString *) downloadFolder
useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
@ -71,7 +71,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
lib: (tr_handle *) lib
{
self = [self initWithHash: nil path: path lib: lib
self = [self initWithHash: nil path: path data: nil lib: lib
publicTorrent: torrentDelete != TORRENT_FILE_DEFAULT
? [NSNumber numberWithBool: torrentDelete == TORRENT_FILE_SAVE] : nil
downloadFolder: location
@ -89,10 +89,24 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
return self;
}
- (id) initWithData: (NSData *) data location: (NSString *) location lib: (tr_handle *) lib
{
self = [self initWithHash: nil path: nil data: data lib: lib
publicTorrent: nil
downloadFolder: location
useIncompleteFolder: nil incompleteFolder: nil
dateAdded: nil dateCompleted: nil
dateActivity: nil
ratioSetting: nil ratioLimit: nil
waitToStart: nil orderValue: nil groupValue: nil];
return self;
}
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle *) lib
{
self = [self initWithHash: [history objectForKey: @"TorrentHash"]
path: [history objectForKey: @"TorrentPath"] lib: lib
path: [history objectForKey: @"TorrentPath"] data: nil lib: lib
publicTorrent: [history objectForKey: @"PublicCopy"]
downloadFolder: [history objectForKey: @"DownloadFolder"]
useIncompleteFolder: [history objectForKey: @"UseIncompleteFolder"]
@ -1465,7 +1479,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
@implementation Torrent (Private)
//if a hash is given, attempt to load that; otherwise, attempt to open file at path
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle *) lib
- (id) initWithHash: (NSString *) hashString path: (NSString *) path data: (NSData *) data lib: (tr_handle *) lib
publicTorrent: (NSNumber *) publicTorrent
downloadFolder: (NSString *) downloadFolder
useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
@ -1532,6 +1546,20 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
}
tr_metainfoFree(&info);
}
if (!fHandle && data)
{
tr_ctorSetMetainfo(ctor, [data bytes], [data length]);
if (tr_torrentParse(fLib, ctor, &info) == TR_OK)
{
NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]]
? fIncompleteFolder : fDownloadFolder;
tr_ctorSetDestination(ctor, TR_FORCE, [currentDownloadFolder UTF8String]);
fHandle = tr_torrentNew(fLib, ctor, &error);
}
tr_metainfoFree(&info);
}
tr_ctorFree(ctor);
if (!fHandle)

View File

@ -238,14 +238,12 @@
fActionPushedRow = -1;
[self setNeedsDisplayInRect: [self rectOfRow: row]];
}
if ([self pointInMinimalStatusRect: point])
else if ([self pointInMinimalStatusRect: point])
{
[fDefaults setBool: ![fDefaults boolForKey: @"DisplaySmallStatusRegular"] forKey: @"DisplaySmallStatusRegular"];
[self reloadData];
}
if ([event clickCount] == 2) //double click
else if ([event clickCount] == 2) //double click
{
if ([self pointInProgressRect: point])
{
@ -255,6 +253,7 @@
else
[fController showInfo: nil];
}
else;
}
- (void) selectTorrents: (NSArray *) torrents