diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-02-17 15:52:25 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2016-02-17 15:52:25 +0100 |
commit | e8b3babd44971d1d4b25186f88bdbea23f7bf394 (patch) | |
tree | 6f59998cbd157df14dc444f66f302f66b85c6ec0 /uca-net-camera.c | |
parent | 9da4e6a2c7ad73a0eb4f377533179eb606a14285 (diff) | |
download | uca-net-e8b3babd44971d1d4b25186f88bdbea23f7bf394.tar.gz uca-net-e8b3babd44971d1d4b25186f88bdbea23f7bf394.tar.bz2 uca-net-e8b3babd44971d1d4b25186f88bdbea23f7bf394.tar.xz uca-net-e8b3babd44971d1d4b25186f88bdbea23f7bf394.zip |
Implement outstanding write request
Diffstat (limited to 'uca-net-camera.c')
-rw-r--r-- | uca-net-camera.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/uca-net-camera.c b/uca-net-camera.c index ad3606d..f2d5638 100644 --- a/uca-net-camera.c +++ b/uca-net-camera.c @@ -157,7 +157,37 @@ uca_net_camera_write (UcaCamera *camera, gsize size, GError **error) { + UcaNetCameraPrivate *priv; + GOutputStream *output; + gssize bytes_left; + gchar *buffer; + UcaNetMessageWriteRequest request = { .type = UCA_NET_MESSAGE_WRITE }; + g_return_if_fail (UCA_IS_NET_CAMERA (camera)); + + priv = UCA_NET_CAMERA_GET_PRIVATE (camera); + output = g_io_stream_get_output_stream (G_IO_STREAM (priv->connection)); + request.size = size; + strncpy (request.name, name, sizeof (request.name)); + + if (!g_output_stream_write_all (output, &request, sizeof (request), NULL, NULL, error)) + return; + + bytes_left = size; + buffer = (gchar *) data; + + while (bytes_left > 0) { + gssize written; + + written = g_output_stream_write (output, &buffer[size - bytes_left], bytes_left, NULL, error); + + if (written < 0) + return; + + bytes_left -= written; + } + + handle_default_reply (priv->connection, UCA_NET_MESSAGE_WRITE, error); } static gboolean |