mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
support for adding a transfer through rpc
This commit is contained in:
parent
c939cc4b98
commit
ff929b1f6a
3 changed files with 31 additions and 10 deletions
|
@ -40,7 +40,7 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
ADD_NORMAL,
|
||||
ADD_MANUAL,
|
||||
ADD_AUTO,
|
||||
ADD_SHOW_OPTIONS,
|
||||
ADD_URL,
|
||||
|
|
|
@ -693,7 +693,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames addType: ADD_NORMAL forcePath: nil];
|
||||
[self openFiles: filenames addType: ADD_MANUAL forcePath: nil];
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames addType: (addType) type forcePath: (NSString *) path
|
||||
|
@ -884,7 +884,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) open: (NSArray *) files
|
||||
{
|
||||
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: files, @"Filenames",
|
||||
[NSNumber numberWithInt: ADD_NORMAL], @"AddType", nil];
|
||||
[NSNumber numberWithInt: ADD_MANUAL], @"AddType", nil];
|
||||
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dict waitUntilDone: NO];
|
||||
}
|
||||
|
||||
|
@ -906,7 +906,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
if (code == NSOKButton)
|
||||
{
|
||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [panel filenames], @"Filenames",
|
||||
[NSNumber numberWithInt: [useOptions boolValue] ? ADD_SHOW_OPTIONS : ADD_NORMAL], @"AddType", nil];
|
||||
[NSNumber numberWithInt: [useOptions boolValue] ? ADD_SHOW_OPTIONS : ADD_MANUAL], @"AddType", nil];
|
||||
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
|
@ -4151,7 +4151,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
//get the torrent
|
||||
if (torrentStruct != NULL && type != TR_RPC_TORRENT_ADDED)
|
||||
if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED))
|
||||
{
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
|
@ -4169,6 +4169,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
switch (type)
|
||||
{
|
||||
case TR_RPC_TORRENT_ADDED:
|
||||
[self performSelectorOnMainThread: @selector(rpcAddTorrentStruct:) withObject:
|
||||
[[NSValue valueWithPointer: torrentStruct] retain] waitUntilDone: NO];
|
||||
break;
|
||||
case TR_RPC_TORRENT_STARTED:
|
||||
break;
|
||||
|
@ -4185,6 +4187,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[pool release];
|
||||
}
|
||||
|
||||
- (void) rpcAddTorrentStruct: (NSValue *) torrentStructPtr
|
||||
{
|
||||
tr_torrent * torrentStruct = (tr_torrent *)[torrentStructPtr pointerValue];
|
||||
[torrentStructPtr release];
|
||||
|
||||
NSString * location = nil;
|
||||
if (tr_torrentGetDownloadDir(torrentStruct) != NULL)
|
||||
location = [NSString stringWithUTF8String: tr_torrentGetDownloadDir(torrentStruct)];
|
||||
|
||||
Torrent * torrent = [[Torrent alloc] initWithTorrentStruct: torrentStruct location: location lib: fLib];
|
||||
|
||||
[torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
/*- (void) ipcQuit
|
||||
{
|
||||
fRemoteQuit = YES;
|
||||
|
|
|
@ -1558,12 +1558,11 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
if (torrentStruct)
|
||||
{
|
||||
fHandle = torrentStruct;
|
||||
fInfo = tr_torrentInfo(fHandle);
|
||||
|
||||
const tr_info * info = tr_torrentInfo(fHandle);
|
||||
NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info->name]]
|
||||
NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: fInfo->name]]
|
||||
? fIncompleteFolder : fDownloadFolder;
|
||||
tr_torrentSetDownloadDir(fHandle, [currentDownloadFolder UTF8String]);
|
||||
tr_metainfoFree(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1607,12 +1606,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
fInfo = tr_torrentInfo(fHandle);
|
||||
}
|
||||
|
||||
tr_torrentSetStatusCallback(fHandle, completenessChangeCallback, self);
|
||||
|
||||
fInfo = tr_torrentInfo(fHandle);
|
||||
|
||||
fNameString = [[NSString alloc] initWithUTF8String: fInfo->name];
|
||||
fHashString = [[NSString alloc] initWithUTF8String: fInfo->hashString];
|
||||
|
||||
|
|
Loading…
Reference in a new issue