tr_freeMessageList( list );
}
+static tr_rpc_callback_status
+on_rpc_callback( tr_session * session UNUSED,
+ tr_rpc_callback_type type,
+ struct tr_torrent * tor UNUSED,
+ void * user_data UNUSED )
+{
+ if( type == TR_RPC_SESSION_CLOSE )
+ closing = TRUE;
+ return TR_RPC_OK;
+}
+
int
main( int argc, char ** argv )
{
tr_formatter_size_init( DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR );
tr_formatter_speed_init( SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR );
mySession = tr_sessionInit( "daemon", configDir, TRUE, &settings );
+ tr_sessionSetRPCCallback( mySession, on_rpc_callback, NULL );
tr_ninf( NULL, "Using settings from \"%s\"", configDir );
tr_sessionSaveSettings( mySession, configDir, &settings );
{ 'e', "cache", "Set the maximum size of the session's memory cache (in " MEM_M_STR ")", "e", 1, "<size>" },
{ 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL },
- { 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
+ { 850, "exit", "Tell the transmission session to shut down", NULL, 0, NULL },
{ 940, "files", "List the current torrent(s)' files", "f", 0, NULL },
{ 'g', "get", "Mark files for download", "g", 1, "<files>" },
{ 'G', "no-get", "Mark files for not downloading", "G", 1, "<files>" },
MODE_SESSION_SET = (1<<9),
MODE_SESSION_GET = (1<<10),
MODE_SESSION_STATS = (1<<11),
- MODE_BLOCKLIST_UPDATE = (1<<12),
- MODE_PORT_TEST = (1<<13)
+ MODE_SESSION_CLOSE = (1<<12),
+ MODE_BLOCKLIST_UPDATE = (1<<13),
+ MODE_PORT_TEST = (1<<14)
};
static int
case 'w': /* download-dir */
return MODE_SESSION_SET | MODE_TORRENT_ADD;
+ case 850: /* session-close */
+ return MODE_SESSION_CLOSE;
+
case 963: /* blocklist-update */
return MODE_BLOCKLIST_UPDATE;
tr_free( path );
break;
}
+ case 850:
+ {
+ tr_benc * top = tr_new0( tr_benc, 1 );
+ tr_bencInitDict( top, 1 );
+ tr_bencDictAddStr( top, "method", "session-close" );
+ status |= flush( rpcurl, &top );
+ break;
+ }
case 963:
{
tr_benc * top = tr_new0( tr_benc, 1 );
.Op Fl d Ar number | Fl D
.Op Fl e Ar size
.Op Fl er | ep | et
+.Op Fl -exit
.Op Fl f
.Op Fl g Ar files
.Op Fl G Ar files
Prefer encrypted peer connections.
.It Fl et Fl -encryption-tolerated
Prefer unencrypted peer connections.
+.It Fl -exit
+Tell the Transmission to initiate a shutdown.
.It Fl f Fl -files
Get a file list for the current torrent(s)
.It Fl g Fl -get Ar all | file-index | files
Request arguments: none
Response arguments: a bool, "port-is-open"
+4.5. Session shutdown
+
+ This method tells the transmission session to shut down.
+
+ Method-name: "session-close"
+ Request arguments: none
+ Response arguments: none
+
5.0. Protocol Versions
The following changes have been made to the RPC interface:
| | yes | session-set | new arg "blocklist-url"
------+---------+-----------+----------------+-------------------------------
12 | 2.20 | yes | session-get | new arg "download-dir-free-space"
+ | | yes | session-close | new method
switch( type )
{
+ case TR_RPC_SESSION_CLOSE:
+ gtr_action_activate( "quit" );
+ break;
+
case TR_RPC_TORRENT_ADDED:
tr_core_add_torrent( cbdata->core, tr_torrent_new_preexisting( tor ), TRUE );
break;
****
***/
+static const char*
+sessionClose( tr_session * session,
+ tr_benc * args_in UNUSED,
+ tr_benc * args_out UNUSED,
+ struct tr_rpc_idle_data * idle_data UNUSED )
+{
+ notify( session, TR_RPC_SESSION_CLOSE, NULL );
+ return NULL;
+}
+
+/***
+****
+***/
+
typedef const char* ( *handler )( tr_session*, tr_benc*, tr_benc*, struct tr_rpc_idle_data * );
static struct method
{
{ "port-test", FALSE, portTest },
{ "blocklist-update", FALSE, blocklistUpdate },
+ { "session-close", TRUE, sessionClose },
{ "session-get", TRUE, sessionGet },
{ "session-set", TRUE, sessionSet },
{ "session-stats", TRUE, sessionStats },
TR_RPC_TORRENT_REMOVING,
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
TR_RPC_TORRENT_MOVED,
- TR_RPC_SESSION_CHANGED
+ TR_RPC_SESSION_CHANGED,
+ TR_RPC_SESSION_CLOSE
}
tr_rpc_callback_type;