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

View File

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

View File

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