aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-08-06 15:05:35 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-09-05 15:39:00 +0200
commit792729700d9589eb1801065b3cf7e4386b5d582b (patch)
treeefc6bc9674ce2b74aeb2f6f2e90c60f21d475a7d
parent100be13c6e0ba5bde9742dfb8010ce1dd4cc17bf (diff)
downloadexternal_libqmi-792729700d9589eb1801065b3cf7e4386b5d582b.zip
external_libqmi-792729700d9589eb1801065b3cf7e4386b5d582b.tar.gz
external_libqmi-792729700d9589eb1801065b3cf7e4386b5d582b.tar.bz2
libqmi-glib,proxy: allow multiple remote 'QmiClientCtl'
Need to share the same underlying 'QmiClientCtl' in the proxy, so interleave messages from different remote 'QmiClientCtl's and sync the transaction IDs properly.
-rw-r--r--src/libqmi-glib/qmi-proxy.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/libqmi-glib/qmi-proxy.c b/src/libqmi-glib/qmi-proxy.c
index bb692c0..ca3e0e0 100644
--- a/src/libqmi-glib/qmi-proxy.c
+++ b/src/libqmi-glib/qmi-proxy.c
@@ -256,10 +256,15 @@ process_internal_proxy_open (Client *client,
return FALSE;
}
+typedef struct {
+ Client *client;
+ guint8 in_trid;
+} Request;
+
static void
device_command_ready (QmiDevice *device,
GAsyncResult *res,
- Client *client)
+ Request *request)
{
QmiMessage *response;
GError *error = NULL;
@@ -271,40 +276,45 @@ device_command_ready (QmiDevice *device,
return;
}
- if (!send_message (client, response, &error)) {
- qmi_message_unref (response);
- connection_close (client);
- return;
- }
+ if (qmi_message_get_service (response) == QMI_SERVICE_CTL)
+ qmi_message_set_transaction_id (response, request->in_trid);
+
+ if (!send_message (request->client, response, &error))
+ connection_close (request->client);
qmi_message_unref (response);
+ g_slice_free (Request, request);
}
static gboolean
process_message (Client *client,
QmiMessage *message)
{
+ Request *request;
+
/* Accept only request messages from the client */
if (!qmi_message_is_request (message)) {
g_debug ("invalid message from client: not a request message");
return FALSE;
}
- if (qmi_message_get_service (message) == QMI_SERVICE_CTL) {
- if (qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_INTERNAL_PROXY_OPEN)
- return process_internal_proxy_open (client, message);
+ if (qmi_message_get_service (message) == QMI_SERVICE_CTL &&
+ qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_INTERNAL_PROXY_OPEN)
+ return process_internal_proxy_open (client, message);
- /* CTL, fixup transaction id and keep on */
+ request = g_slice_new0 (Request);
+ request->client = client;
+ if (qmi_message_get_service (message) == QMI_SERVICE_CTL) {
+ request->in_trid = qmi_message_get_transaction_id (message);
+ qmi_message_set_transaction_id (message, 0);
}
- /* Non-CTL service, just forward to qmi device */
-
qmi_device_command (client->device,
message,
10, /* for now... */
NULL,
(GAsyncReadyCallback)device_command_ready,
- client);
+ request);
return TRUE;
}