summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-04 16:54:45 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-08 10:08:43 -0800
commit8428289c9489c5146d7e6d1eebde380a0d0ce19d (patch)
tree59bc78f512fdd9a7c31396d5a1ad91f44a2ebe9c
parent44d3227beb8b2064aa98ddedc90b29b8e9580278 (diff)
ecore: remove use of efl_main_loop_get from example.
-rw-r--r--src/examples/ecore/efl_io_buffered_stream_example.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/examples/ecore/efl_io_buffered_stream_example.c b/src/examples/ecore/efl_io_buffered_stream_example.c
index aaf1a997bf..3338bae396 100644
--- a/src/examples/ecore/efl_io_buffered_stream_example.c
+++ b/src/examples/ecore/efl_io_buffered_stream_example.c
@@ -1,8 +1,5 @@
1#define EFL_BETA_API_SUPPORT 1 1#include <Efl_Net.h>
2#define EFL_EO_API_SUPPORT 1
3#include <Ecore.h>
4#include <Ecore_Getopt.h> 2#include <Ecore_Getopt.h>
5#include <Ecore_Con.h>
6 3
7static int retval = EXIT_SUCCESS; 4static int retval = EXIT_SUCCESS;
8static Eina_List *commands = NULL; 5static Eina_List *commands = NULL;
@@ -92,14 +89,14 @@ _stream_error(void *data EINA_UNUSED, const Efl_Event *event)
92 fprintf(stderr, "INFO: %s error: #%d '%s'\n", 89 fprintf(stderr, "INFO: %s error: #%d '%s'\n",
93 efl_name_get(event->object), *perr, eina_error_msg_get(*perr)); 90 efl_name_get(event->object), *perr, eina_error_msg_get(*perr));
94 retval = EXIT_FAILURE; 91 retval = EXIT_FAILURE;
95 ecore_main_loop_quit(); 92 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
96} 93}
97 94
98static void 95static void
99_stream_eos(void *data EINA_UNUSED, const Efl_Event *event) 96_stream_eos(void *data EINA_UNUSED, const Efl_Event *event)
100{ 97{
101 fprintf(stderr, "INFO: %s eos, quit\n", efl_name_get(event->object)); 98 fprintf(stderr, "INFO: %s eos, quit\n", efl_name_get(event->object));
102 ecore_main_loop_quit(); 99 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
103} 100}
104 101
105EFL_CALLBACKS_ARRAY_DEFINE(stream_cbs, 102EFL_CALLBACKS_ARRAY_DEFINE(stream_cbs,
@@ -174,8 +171,9 @@ static const Ecore_Getopt options = {
174 } 171 }
175}; 172};
176 173
177int 174EAPI_MAIN void
178main(int argc, char **argv) 175efl_main(void *data EINA_UNUSED,
176 const Efl_Event *ev)
179{ 177{
180 char *address = NULL; 178 char *address = NULL;
181 char *line_delimiter_str = NULL; 179 char *line_delimiter_str = NULL;
@@ -200,12 +198,9 @@ main(int argc, char **argv)
200 }; 198 };
201 Eina_Error err; 199 Eina_Error err;
202 int args; 200 int args;
203 Eo *dialer, *loop; 201 Eo *dialer;
204 202
205 ecore_init(); 203 args = ecore_getopt_parse(&options, values, 0, NULL);
206 ecore_con_init();
207
208 args = ecore_getopt_parse(&options, values, argc, argv);
209 if (args < 0) 204 if (args < 0)
210 { 205 {
211 fputs("ERROR: Could not parse command line options.\n", stderr); 206 fputs("ERROR: Could not parse command line options.\n", stderr);
@@ -215,7 +210,7 @@ main(int argc, char **argv)
215 210
216 if (quit_option) goto end; 211 if (quit_option) goto end;
217 212
218 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 213 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
219 if (args < 0) 214 if (args < 0)
220 { 215 {
221 fputs("ERROR: Could not parse positional arguments.\n", stderr); 216 fputs("ERROR: Could not parse positional arguments.\n", stderr);
@@ -235,12 +230,10 @@ main(int argc, char **argv)
235 /* 230 /*
236 * some objects such as the Efl.Io.Buffered_Stream and 231 * some objects such as the Efl.Io.Buffered_Stream and
237 * Efl.Net.Dialer.Tcp depend on main loop, thus their parent must 232 * Efl.Net.Dialer.Tcp depend on main loop, thus their parent must
238 * be a loop provider. We use the loop itself. 233 * be a loop provider. We use the loop itself that come from event.
239 */ 234 */
240 loop = efl_main_loop_get();
241
242 /* The TCP client to use to send/receive network data */ 235 /* The TCP client to use to send/receive network data */
243 dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, loop, 236 dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, ev->object,
244 efl_name_set(efl_added, "dialer"), 237 efl_name_set(efl_added, "dialer"),
245 efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL)); 238 efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL));
246 if (!dialer) 239 if (!dialer)
@@ -263,7 +256,7 @@ main(int argc, char **argv)
263 * 256 *
264 * On incoming data we peek at it with slice_get() and then clear(). 257 * On incoming data we peek at it with slice_get() and then clear().
265 */ 258 */
266 stream = efl_add(EFL_IO_BUFFERED_STREAM_CLASS, loop, 259 stream = efl_add(EFL_IO_BUFFERED_STREAM_CLASS, ev->object,
267 efl_name_set(efl_added, "stream"), 260 efl_name_set(efl_added, "stream"),
268 efl_io_buffered_stream_inner_io_set(efl_added, dialer), /* mandatory! */ 261 efl_io_buffered_stream_inner_io_set(efl_added, dialer), /* mandatory! */
269 efl_io_buffered_stream_line_delimiter_set(efl_added, line_delimiter), 262 efl_io_buffered_stream_line_delimiter_set(efl_added, line_delimiter),
@@ -289,7 +282,7 @@ main(int argc, char **argv)
289 goto error_dialing; 282 goto error_dialing;
290 } 283 }
291 284
292 ecore_main_loop_begin(); 285 return ;
293 286
294 error_dialing: 287 error_dialing:
295 efl_io_closer_close(stream); 288 efl_io_closer_close(stream);
@@ -303,8 +296,7 @@ main(int argc, char **argv)
303 free(cmd); 296 free(cmd);
304 } 297 }
305 298
306 ecore_con_shutdown(); 299 efl_loop_quit(ev->object, eina_value_int_init(retval));
307 ecore_shutdown();
308
309 return retval;
310} 300}
301
302EFL_MAIN();