mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
Return response for tagged add message.
Support noop message.
This commit is contained in:
parent
e60a686ce6
commit
c7ff9bdcf1
1 changed files with 39 additions and 9 deletions
48
gtk/ipc.c
48
gtk/ipc.c
|
@ -103,6 +103,8 @@ static void
|
||||||
smsg_quit( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg );
|
smsg_quit( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg );
|
||||||
static void
|
static void
|
||||||
all_default( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg );
|
all_default( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg );
|
||||||
|
static gboolean
|
||||||
|
simpleresp( struct constate * con, enum ipc_msg id, int64_t tag );
|
||||||
|
|
||||||
/* this is only used on the server */
|
/* this is only used on the server */
|
||||||
static char *gl_sockpath = NULL;
|
static char *gl_sockpath = NULL;
|
||||||
|
@ -480,8 +482,7 @@ cli_io_sent(GSource *source SHUTUP, unsigned int id, void *vdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
smsg_add( enum ipc_msg id SHUTUP, benc_val_t * val, int64_t tag SHUTUP,
|
smsg_add( enum ipc_msg id SHUTUP, benc_val_t * val, int64_t tag, void * arg )
|
||||||
void * arg )
|
|
||||||
{
|
{
|
||||||
struct constate * con = arg;
|
struct constate * con = arg;
|
||||||
struct constate_serv * srv = &con->u.serv;
|
struct constate_serv * srv = &con->u.serv;
|
||||||
|
@ -489,11 +490,17 @@ smsg_add( enum ipc_msg id SHUTUP, benc_val_t * val, int64_t tag SHUTUP,
|
||||||
benc_val_t * path;
|
benc_val_t * path;
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
if( NULL == srv->core || TYPE_LIST != val->type )
|
if( NULL == srv->core )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( NULL == val || TYPE_LIST != val->type )
|
||||||
|
{
|
||||||
|
simpleresp( con, tag, IPC_MSG_NOTSUP );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
action = toraddaction( tr_prefs_get( PREF_ID_ADDIPC ) );
|
action = toraddaction( tr_prefs_get( PREF_ID_ADDIPC ) );
|
||||||
for( ii = 0; ii < val->val.l.count; ii++ )
|
for( ii = 0; ii < val->val.l.count; ii++ )
|
||||||
{
|
{
|
||||||
|
@ -506,6 +513,9 @@ smsg_add( enum ipc_msg id SHUTUP, benc_val_t * val, int64_t tag SHUTUP,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tr_core_torrents_added( TR_CORE( srv->core ) );
|
tr_core_torrents_added( TR_CORE( srv->core ) );
|
||||||
|
|
||||||
|
/* XXX should send info response back with torrent ids */
|
||||||
|
simpleresp( con, IPC_MSG_OK, tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -519,16 +529,36 @@ smsg_quit( enum ipc_msg id SHUTUP, benc_val_t * val SHUTUP, int64_t tag SHUTUP,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
all_default( enum ipc_msg id SHUTUP, benc_val_t * val SHUTUP, int64_t tag,
|
all_default( enum ipc_msg id, benc_val_t * val SHUTUP, int64_t tag, void * arg )
|
||||||
void * arg )
|
{
|
||||||
|
switch( id )
|
||||||
|
{
|
||||||
|
case IPC_MSG_FAIL:
|
||||||
|
case IPC_MSG_NOTSUP:
|
||||||
|
case IPC_MSG_OK:
|
||||||
|
break;
|
||||||
|
case IPC_MSG_NOOP:
|
||||||
|
simpleresp( arg, IPC_MSG_OK, tag );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
simpleresp( arg, IPC_MSG_NOTSUP, tag );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
simpleresp( struct constate * con, enum ipc_msg id, int64_t tag )
|
||||||
{
|
{
|
||||||
struct constate * con = arg;
|
|
||||||
uint8_t * buf;
|
uint8_t * buf;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
buf = ipc_mkempty( &con->ipc, &size, IPC_MSG_NOTSUP, tag );
|
buf = ipc_mkempty( &con->ipc, &size, id, tag );
|
||||||
if( NULL != buf )
|
if( NULL == buf )
|
||||||
{
|
{
|
||||||
io_send_keepdata( con->source, buf, size );
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io_send_keepdata( con->source, buf, size );
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue