Use flags for apptransport_client_send()

This commit is contained in:
Pierre Pronchery 2020-11-17 04:59:27 +01:00
parent 946ef7de6f
commit 36ad7752cc
3 changed files with 24 additions and 9 deletions

View File

@ -44,6 +44,9 @@ struct _AppClient
/* prototypes */
static int _appclient_call_message(AppClient * appclient,
AppMessage * appmessage);
/* helpers */
static int _appclient_helper_message(void * data, AppTransport * transport,
AppTransportClient * client, AppMessage * message);
@ -151,8 +154,7 @@ int appclient_callv(AppClient * appclient,
if((message = appinterface_messagev(appclient->interface, method, ap))
== NULL)
return -1;
/* FIXME obtain the answer (AICD_{,IN}OUT) */
ret = apptransport_client_send(appclient->transport, message, 1);
ret = _appclient_call_message(appclient, message);
appmessage_delete(message);
return ret;
}
@ -182,8 +184,7 @@ int appclient_call_variables(AppClient * appclient,
if((message = appinterface_message_variables(appclient->interface,
method, args)) == NULL)
return -1;
/* FIXME obtain the answer (AICD_{,IN}OUT) */
ret = apptransport_client_send(appclient->transport, message, 1);
ret = _appclient_call_message(appclient, message);
appmessage_delete(message);
return ret;
}
@ -199,14 +200,24 @@ int appclient_call_variablev(AppClient * appclient,
if((message = appinterface_message_variablev(appclient->interface,
method, args)) == NULL)
return -1;
/* FIXME obtain the answer (AICD_{,IN}OUT) */
ret = apptransport_client_send(appclient->transport, message, 1);
ret = _appclient_call_message(appclient, message);
appmessage_delete(message);
return ret;
}
/* private */
/* appclient_call_message */
static int _appclient_call_message(AppClient * appclient,
AppMessage * appmessage)
{
/* FIXME obtain the answer (AICD_{,IN}OUT) */
return apptransport_client_send(appclient->transport, appmessage,
ATF_ACKNOWLEDGE);
}
/* helpers */
/* appclient_helper_message */
static int _helper_message_call(AppClient * appclient, AppTransport * transport,
AppMessage * message);

View File

@ -335,11 +335,11 @@ String * apptransport_lookup(char const * app)
/* apptransport_client_send */
int apptransport_client_send(AppTransport * transport, AppMessage * message,
int acknowledge)
AppTransportFlags flags)
{
if(transport->mode == ATM_CLIENT
&& appmessage_get_type(message) == AMT_CALL
&& acknowledge != 0)
&& (flags & ATF_ACKNOWLEDGE) != 0)
/* FIXME will wrap around after 2^32-1 acknowledgements */
appmessage_set_id(message, ++transport->id);
return transport->definition->client_send(transport->tplugin, message);

View File

@ -26,6 +26,10 @@
/* AppTransport */
/* protected */
/* types */
typedef unsigned int AppTransportFlags;
# define ATF_ACKNOWLEDGE 0x1
# define ATF_SYNC 0x2
typedef struct _AppTransportHelper
{
void * data;
@ -57,7 +61,7 @@ String * apptransport_lookup(char const * app);
/* ATM_CLIENT */
int apptransport_client_send(AppTransport * transport, AppMessage * message,
int acknowledge);
AppTransportFlags flags);
/* ATM_SERVER */
int apptransport_server_register(AppTransport * transport, char const * app,