(#954) rpc: add "torrent-remove" method. rename tr_torrentDelete() as tr_torrentRemove() for consistency with various parts of the code.

This commit is contained in:
Charles Kerr 2008-05-20 23:58:59 +00:00
parent c6229feac9
commit c7b9c8c043
12 changed files with 75 additions and 38 deletions

View File

@ -26,18 +26,18 @@ and
.Op Fl p Ar port
.Op Fl q
.Oo
.Fl r Ar all | Ar torrent-id
.Fl r Ar all | Ar id | Ar hash
.Oc
.Oo
.Fl s Ar all | Ar torrent-id
.Fl s Ar all | Ar id | Ar hash
.Oc
.Oo
.Fl S Ar all | Ar torrent-id
.Fl S Ar all | Ar id | Ar hash
.Oc
.Op Fl u Ar upload-rate
.Op Fl U
.Oo
.Fl V Ar all | Ar torrent-id
.Fl v Ar all | Ar id | Ar hash
.Oc
.Ek
.Sh DESCRIPTION
@ -83,24 +83,40 @@ Disable automatic port mapping.
Attempt to bind to
.Ar port
for use as a listening port to accept incoming peer connections.
.It Fl r Fl -remove Ar all | torrent-id
Remove all torrents, or the torrent with the unique id
.Ar torrent-id .
Neither the downloaded data nor the original torrent metainfo file
will be deleted.
.It Fl S Fl -stop Ar all | torrent-id
Stop all torrents from downloading or seeding, or the torrent with the unique id
.Ar torrent-id .
.It Fl s Fl -start Ar all | torrent-id
Start all torrents downloading or seeding, or the torrent with the unique id
.Ar torrent-id .
.It Fl r Fl -remove Ar all | id | torrent-hash
Remove all torrents, or the torrent matching the specified
.Ar id
or
.Ar hash .
This does not delete the downloaded data.
.It Fl S Fl -stop Ar all | id | torrent-hash
Stop all torrents from downloading or seeding, or the torrent matching the specified
.Ar id
or
.Ar hash .
.It Fl s Fl -start Ar all | id | torrent-hash
Start all torrents downloading or seeding, or the torrent matching the specified
.Ar id
or
.Ar hash .
.It Fl u Fl -upload-limit Ar upload-rate
Set maximum upload rate to
.Ar upload-rate
in kilobytes per second.
.It Fl U Fl -upload-unlimited
Remove the upload limit.
.It Fl v Fl -verify Ar all | id | torrent-hash
Queue all the torrents for verification, or the torrent matching the specified
.Ar id
or
.Ar hash .
.El
.Sh EXAMPLES
Show all torrents, their ID numbers, and their status:

View File

@ -63,8 +63,13 @@
3.1. Torrent Action Requests
Method names: "torrent-start", "torrent-stop",
"torrent-remove", "torrent-verify"
Method name | libtransmission function
--------------------+-------------------------------------------------
"torrent-close" | tr_torrentClose
"torrent-remove" | tr_torrentRemove
"torrent-start" | tr_torrentStart
"torrent-stop" | tr_torrentStop
"torrent-verify" | tr_torrentVerify
Request arguments: "ids", a list of torrent id integers, sha1 hash strings,
or both. These are the torrents that the request will

View File

@ -32,6 +32,7 @@ noinst_HEADERS = \
sexy-icon-entry.h \
torrent-cell-renderer.h \
tr-core.h \
tr-core-dbus.h \
tr-icon.h \
tr-io.h \
tr-prefs.h \

View File

@ -31,13 +31,13 @@ struct AddData
};
static void
deleteOldTorrent( struct AddData * data )
removeOldTorrent( struct AddData * data )
{
if( data->gtor )
{
file_list_set_torrent( data->list, NULL );
tr_torrent_set_delete_flag( data->gtor, TRUE );
tr_torrent_set_remove_flag( data->gtor, TRUE );
g_object_unref( G_OBJECT( data->gtor ) );
data->gtor = NULL;
}
@ -51,7 +51,7 @@ addResponseCB( GtkDialog * dialog, gint response, gpointer gdata )
if( data->gtor )
{
if( response != GTK_RESPONSE_ACCEPT )
deleteOldTorrent( data );
removeOldTorrent( data );
else {
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->run_check ) ) )
tr_torrentStart( tr_torrent_handle( data->gtor ) );
@ -82,7 +82,7 @@ sourceChanged( GtkFileChooserButton * b, gpointer gdata )
{
struct AddData * data = gdata;
deleteOldTorrent( data );
removeOldTorrent( data );
g_free( data->filename );
data->filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );

View File

@ -824,8 +824,8 @@ tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles )
if( deleteFiles )
tr_torrent_delete_files( gtor );
/* delete the torrent */
tr_torrent_set_delete_flag( gtor, TRUE );
/* remove the torrent */
tr_torrent_set_remove_flag( gtor, TRUE );
g_object_unref( G_OBJECT( gtor ) );
}

View File

@ -39,7 +39,7 @@
struct TrTorrentPrivate
{
tr_torrent * handle;
gboolean do_delete;
gboolean do_remove;
gboolean seeding_cap_enabled;
gdouble seeding_cap; /* ratio to stop seeding at */
};
@ -78,8 +78,8 @@ tr_torrent_dispose( GObject * o )
{
if( self->priv->handle )
{
if( self->priv->do_delete )
tr_torrentDelete( self->priv->handle );
if( self->priv->do_remove )
tr_torrentRemove( self->priv->handle );
else
tr_torrentClose( self->priv->handle );
}
@ -318,10 +318,10 @@ tr_torrent_status_str ( TrTorrent * gtor )
}
void
tr_torrent_set_delete_flag( TrTorrent * gtor, gboolean do_delete )
tr_torrent_set_remove_flag( TrTorrent * gtor, gboolean do_remove )
{
if( !isDisposed( gtor ) )
gtor->priv->do_delete = do_delete;
gtor->priv->do_remove = do_remove;
}
void

View File

@ -96,6 +96,6 @@ TrTorrent *
tr_torrent_new_ctor( tr_handle * handle, tr_ctor * ctor, char ** err );
void
tr_torrent_set_delete_flag( TrTorrent *, gboolean );
tr_torrent_set_remove_flag( TrTorrent *, gboolean );
#endif

View File

@ -135,6 +135,21 @@ torrentClose( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
return NULL;
}
static const char*
torrentRemove( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
{
int i, torrentCount;
tr_torrent ** torrents = getTorrents( h, args_in, &torrentCount );
for( i=0; i<torrentCount; ++i )
{
tr_torrent * tor = torrents[i];
notify( h, TR_RPC_TORRENT_REMOVING, tor );
tr_torrentRemove( tor );
}
tr_free( torrents );
return NULL;
}
static const char*
torrentVerify( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
{
@ -673,6 +688,7 @@ struct method {
{ "torrent-get", torrentGet },
{ "torrent-info", torrentInfo },
{ "torrent-list", torrentList },
{ "torrent-remove", torrentRemove },
{ "torrent-set-priorities", torrentSetPriorities },
{ "torrent-set", torrentSet },
{ "torrent-start", torrentStart },

View File

@ -1133,7 +1133,7 @@ tr_torrentClose( tr_torrent * tor )
}
void
tr_torrentDelete( tr_torrent * tor )
tr_torrentRemove( tr_torrent * tor )
{
tor->isDeleting = 1;
tr_torrentClose( tor );

View File

@ -156,6 +156,7 @@ typedef enum
TR_RPC_TORRENT_STARTED,
TR_RPC_TORRENT_STOPPED,
TR_RPC_TORRENT_CLOSING,
TR_RPC_TORRENT_REMOVING,
TR_RPC_TORRENT_CHANGED,
TR_RPC_SESSION_CHANGED
}
@ -468,7 +469,7 @@ void tr_torrentRates( tr_handle *, float *, float * );
* To remedy this, a Torrent Constructor (struct tr_ctor) has been introduced:
* + Simplifies the API down to two (non-deprecated) functions.
* + You can set the fields you want; the system sets defaults for the rest.
* + You can specify whether or not your fields should supercede fastresume's.
* + You can specify whether or not your fields should supercede resume's.
* + We can add new features to tr_ctor without breaking tr_torrentNew()'s API.
*
* All the tr_ctor{Get,Set}*() functions with a return value return
@ -487,10 +488,10 @@ void tr_torrentRates( tr_handle *, float *, float * );
typedef enum
{
TR_FALLBACK, /* indicates the ctor value should be used only
in case of missing fastresume settings */
in case of missing resume settings */
TR_FORCE, /* indicates the ctor value should be used
regardless of what's in the fastresume settings */
regardless of what's in the resume settings */
}
tr_ctorMode;
@ -746,10 +747,10 @@ void tr_torrentClose( tr_torrent * );
/**
* Like tr_torrentClose() but also deletes
* the fastresume file and our copy of the
* the resume file and our copy of the
* torrent file
*/
void tr_torrentDelete( tr_torrent * );
void tr_torrentRemove( tr_torrent * );
/***********************************************************************
* tr_info

View File

@ -56,8 +56,6 @@ EXTRA_DIST = \
InfoTabButtonCell.m \
InfoWindowController.h \
InfoWindowController.m \
IPCController.h \
IPCController.m \
main.m \
MenuLabel.h \
MenuLabel.m \

View File

@ -205,7 +205,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
//allow the file to be index by Time Machine
[self setTimeMachineExclude: NO forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
tr_torrentDelete(fHandle);
tr_torrentRemove(fHandle);
}
- (void) changeIncompleteDownloadFolder: (NSString *) folder