summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-09 15:43:09 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-09 16:29:30 -0800
commit1393df02f121f202ae0a9c244bd1cf0f1417856a (patch)
tree726bd915a31b3b890017016c7233ca0505e8cb62
parenta9fb821559c9f857fe25b282db072a447dfa8246 (diff)
ecore: remove use of efl_main_loop_get from efl_net_dialer_simple_example.
-rw-r--r--src/examples/ecore/efl_net_dialer_simple_example.c83
1 files changed, 50 insertions, 33 deletions
diff --git a/src/examples/ecore/efl_net_dialer_simple_example.c b/src/examples/ecore/efl_net_dialer_simple_example.c
index 0c7ac0fead..219da892f1 100644
--- a/src/examples/ecore/efl_net_dialer_simple_example.c
+++ b/src/examples/ecore/efl_net_dialer_simple_example.c
@@ -1,12 +1,8 @@
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_Con.h>
5#include <Ecore_Getopt.h> 2#include <Ecore_Getopt.h>
6#include <fcntl.h> 3#include <fcntl.h>
7#include <ctype.h> 4#include <ctype.h>
8 5
9static int retval = EXIT_SUCCESS;
10static Eina_Bool do_read = EINA_FALSE; 6static Eina_Bool do_read = EINA_FALSE;
11static Eina_Bool do_discard = EINA_FALSE; 7static Eina_Bool do_discard = EINA_FALSE;
12static Eina_Slice line_delm_slice; 8static Eina_Slice line_delm_slice;
@@ -75,8 +71,7 @@ _can_read(void *data EINA_UNUSED, const Efl_Event *event)
75 break; 71 break;
76 } 72 }
77 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err)); 73 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err));
78 retval = EXIT_FAILURE; 74 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
79 ecore_main_loop_quit();
80 return; 75 return;
81 } 76 }
82 77
@@ -153,18 +148,16 @@ _error(void *data EINA_UNUSED, const Efl_Event *event)
153 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr)); 148 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr));
154 if (!efl_io_closer_closed_get(event->object)) 149 if (!efl_io_closer_closed_get(event->object))
155 efl_io_closer_close(event->object); 150 efl_io_closer_close(event->object);
156 retval = EXIT_FAILURE; 151
152 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
157} 153}
158 154
159static void 155static void
160_done_sending(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 156_done_sending(void *data EINA_UNUSED, const Efl_Event *event)
161{ 157{
162 fprintf(stderr, "INFO: done sending\n"); 158 fprintf(stderr, "INFO: done sending\n");
163 if (!do_read) 159 if (!do_read)
164 { 160 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
165 ecore_main_loop_quit();
166 return;
167 }
168} 161}
169 162
170static void 163static void
@@ -174,10 +167,11 @@ _done_receiving(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
174} 167}
175 168
176static void 169static void
177_done(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) 170_done(void *data EINA_UNUSED, const Efl_Event *event)
178{ 171{
179 fprintf(stderr, "INFO: done sending and receiving\n"); 172 fprintf(stderr, "INFO: done sending and receiving\n");
180 ecore_main_loop_quit(); 173
174 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
181} 175}
182 176
183EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs, 177EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs,
@@ -272,8 +266,39 @@ static const Ecore_Getopt options = {
272 } 266 }
273}; 267};
274 268
275int 269static Eo *dialer = NULL;
276main(int argc, char **argv) 270
271EAPI_MAIN void
272efl_pause(void *data EINA_UNUSED,
273 const Efl_Event *ev EINA_UNUSED)
274{
275}
276
277EAPI_MAIN void
278efl_resume(void *data EINA_UNUSED,
279 const Efl_Event *ev EINA_UNUSED)
280{
281}
282
283EAPI_MAIN void
284efl_terminate(void *data EINA_UNUSED,
285 const Efl_Event *ev EINA_UNUSED)
286{
287 /* FIXME: For the moment the main loop doesn't get
288 properly destroyed on shutdown which disallow
289 relying on parent destroying their children */
290 if (dialer)
291 {
292 efl_del(dialer);
293 dialer = NULL;
294 }
295
296 fprintf(stderr, "INFO: main loop finished.\n");
297}
298
299EAPI_MAIN void
300efl_main(void *data EINA_UNUSED,
301 const Efl_Event *ev)
277{ 302{
278 const Efl_Class *cls; 303 const Efl_Class *cls;
279 Eina_List *to_send = NULL; 304 Eina_List *to_send = NULL;
@@ -310,36 +335,30 @@ main(int argc, char **argv)
310 ECORE_GETOPT_VALUE_NONE /* sentinel */ 335 ECORE_GETOPT_VALUE_NONE /* sentinel */
311 }; 336 };
312 int args; 337 int args;
313 Eo *dialer, *loop; 338 Eo *loop;
314 Eina_Error err; 339 Eina_Error err;
315 340
316 ecore_init(); 341 args = ecore_getopt_parse(&options, values, 0, NULL);
317 ecore_con_init();
318
319 args = ecore_getopt_parse(&options, values, argc, argv);
320 if (args < 0) 342 if (args < 0)
321 { 343 {
322 fputs("ERROR: Could not parse command line options.\n", stderr); 344 fputs("ERROR: Could not parse command line options.\n", stderr);
323 retval = EXIT_FAILURE;
324 goto end; 345 goto end;
325 } 346 }
326 347
327 if (quit_option) goto end; 348 if (quit_option) goto end;
328 349
329 loop = efl_main_loop_get(); 350 loop = ev->object;
330 351
331 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 352 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
332 if (args < 0) 353 if (args < 0)
333 { 354 {
334 fputs("ERROR: Could not parse positional arguments.\n", stderr); 355 fputs("ERROR: Could not parse positional arguments.\n", stderr);
335 retval = EXIT_FAILURE;
336 goto end; 356 goto end;
337 } 357 }
338 358
339 if (!protocol) 359 if (!protocol)
340 { 360 {
341 fputs("ERROR: missing protocol.\n", stderr); 361 fputs("ERROR: missing protocol.\n", stderr);
342 retval = EXIT_FAILURE;
343 goto end; 362 goto end;
344 } 363 }
345 364
@@ -433,17 +452,15 @@ main(int argc, char **argv)
433 } 452 }
434 efl_io_buffered_stream_eos_mark(dialer); /* we're done sending */ 453 efl_io_buffered_stream_eos_mark(dialer); /* we're done sending */
435 454
436 ecore_main_loop_begin(); 455 return ;
437
438 fprintf(stderr, "INFO: main loop finished.\n");
439 456
440 no_mainloop: 457 no_mainloop:
441 efl_del(dialer); 458 efl_del(dialer);
442 459
443 end: 460 end:
444 EINA_LIST_FREE(to_send, str) free(str); 461 EINA_LIST_FREE(to_send, str) free(str);
445 ecore_con_shutdown();
446 ecore_shutdown();
447 462
448 return retval; 463 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
449} 464}
465
466EFL_MAIN_EX();