summaryrefslogtreecommitdiff
path: root/src/lib/ecore/efl_io_buffered_stream.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-07 16:55:42 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-08 11:40:45 -0200
commitbb5f91273c68e350fbe4aeeb282942c1bd017178 (patch)
tree4099a89d587cb7ad9e74b57a869353bc29ba8921 /src/lib/ecore/efl_io_buffered_stream.c
parent5242c3b1d4120133a7d428760f5cbc27f7d5e067 (diff)
efl_io_buffered_stream: property and event 'progress'
useful to get feedback on when data was actually sent/received, and how much.
Diffstat (limited to '')
-rw-r--r--src/lib/ecore/efl_io_buffered_stream.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/ecore/efl_io_buffered_stream.c b/src/lib/ecore/efl_io_buffered_stream.c
index f75c033aea..69ea69c35e 100644
--- a/src/lib/ecore/efl_io_buffered_stream.c
+++ b/src/lib/ecore/efl_io_buffered_stream.c
@@ -35,6 +35,13 @@ _efl_io_buffered_stream_error(void *data, const Efl_Event *event)
35} 35}
36 36
37static void 37static void
38_efl_io_buffered_stream_copier_progress(void *data, const Efl_Event *event EINA_UNUSED)
39{
40 Eo *o = data;
41 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
42}
43
44static void
38_efl_io_buffered_stream_incoming_can_read_changed(void *data, const Efl_Event *event) 45_efl_io_buffered_stream_incoming_can_read_changed(void *data, const Efl_Event *event)
39{ 46{
40 Eo *o = data; 47 Eo *o = data;
@@ -69,6 +76,7 @@ _efl_io_buffered_stream_receiver_done(void *data, const Efl_Event *event EINA_UN
69} 76}
70 77
71EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_receiver_cbs, 78EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_receiver_cbs,
79 { EFL_IO_COPIER_EVENT_PROGRESS, _efl_io_buffered_stream_copier_progress },
72 { EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_receiver_done }, 80 { EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_receiver_done },
73 { EFL_IO_COPIER_EVENT_LINE, _efl_io_buffered_stream_receiver_line }, 81 { EFL_IO_COPIER_EVENT_LINE, _efl_io_buffered_stream_receiver_line },
74 { EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error }); 82 { EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error });
@@ -90,12 +98,16 @@ _efl_io_buffered_stream_sender_done(void *data, const Efl_Event *event EINA_UNUS
90{ 98{
91 Eo *o = data; 99 Eo *o = data;
92 Efl_Io_Buffered_Stream_Data *pd = efl_data_scope_get(o, MY_CLASS); 100 Efl_Io_Buffered_Stream_Data *pd = efl_data_scope_get(o, MY_CLASS);
101 efl_ref(o);
102 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
93 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_WRITE_FINISHED, NULL); 103 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_WRITE_FINISHED, NULL);
94 if (efl_io_copier_done_get(pd->receiver)) 104 if (efl_io_copier_done_get(pd->receiver))
95 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL); 105 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL);
106 efl_unref(o);
96} 107}
97 108
98EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_sender_cbs, 109EFL_CALLBACKS_ARRAY_DEFINE(_efl_io_buffered_stream_sender_cbs,
110 { EFL_IO_COPIER_EVENT_PROGRESS, _efl_io_buffered_stream_copier_progress },
99 { EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_sender_done }, 111 { EFL_IO_COPIER_EVENT_DONE, _efl_io_buffered_stream_sender_done },
100 { EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error }); 112 { EFL_IO_COPIER_EVENT_ERROR, _efl_io_buffered_stream_error });
101 113
@@ -262,10 +274,13 @@ _efl_io_buffered_stream_efl_io_reader_eos_set(Eo *o, Efl_Io_Buffered_Stream_Data
262 pd->eos = is_eos; 274 pd->eos = is_eos;
263 if (!is_eos) return; 275 if (!is_eos) return;
264 276
277 efl_ref(o);
278 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, NULL);
265 efl_event_callback_call(o, EFL_IO_READER_EVENT_EOS, NULL); 279 efl_event_callback_call(o, EFL_IO_READER_EVENT_EOS, NULL);
266 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED, NULL); 280 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED, NULL);
267 if (efl_io_copier_done_get(pd->sender)) 281 if (efl_io_copier_done_get(pd->sender))
268 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL); 282 efl_event_callback_call(o, EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, NULL);
283 efl_unref(o);
269} 284}
270 285
271EOLIAN static Eina_Error 286EOLIAN static Eina_Error
@@ -482,6 +497,18 @@ _efl_io_buffered_stream_pending_read_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stre
482 return efl_io_queue_usage_get(pd->incoming); 497 return efl_io_queue_usage_get(pd->incoming);
483} 498}
484 499
500EOLIAN static void
501_efl_io_buffered_stream_progress_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, size_t *pr, size_t *pw)
502{
503 size_t r = 0, w = 0;
504
505 if (pd->sender) efl_io_copier_progress_get(pd->sender, NULL, &w, NULL);
506 if (pd->receiver) efl_io_copier_progress_get(pd->receiver, &r, NULL, NULL);
507
508 if (pr) *pr = r;
509 if (pw) *pw = w;
510}
511
485EOLIAN static Eina_Bool 512EOLIAN static Eina_Bool
486_efl_io_buffered_stream_slice_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, Eina_Slice *slice) 513_efl_io_buffered_stream_slice_get(Eo *o EINA_UNUSED, Efl_Io_Buffered_Stream_Data *pd, Eina_Slice *slice)
487{ 514{