summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-09 16:28:59 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-09 16:29:30 -0800
commitdda427dc51e81fb2455982832b7c726497776659 (patch)
treeb889a607475b0d17c82f8d8a501a3f28e3a637f7
parent6667a914ac7490004c24ce4158d48f9c3f929703 (diff)
ecore: remove use of efl_main_loop_get from efl_net_dialer_websocket_example.
-rw-r--r--src/examples/ecore/efl_net_dialer_websocket_example.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/src/examples/ecore/efl_net_dialer_websocket_example.c b/src/examples/ecore/efl_net_dialer_websocket_example.c
index d051c3941e..e0b72e4991 100644
--- a/src/examples/ecore/efl_net_dialer_websocket_example.c
+++ b/src/examples/ecore/efl_net_dialer_websocket_example.c
@@ -1,13 +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;
10
11static int lines_text = 0; 6static int lines_text = 0;
12static int lines_binary = 0; 7static int lines_binary = 0;
13 8
@@ -102,7 +97,7 @@ _closed(void *data EINA_UNUSED, const Efl_Event *event)
102{ 97{
103 fprintf(stderr, "INFO: closed %s\n", 98 fprintf(stderr, "INFO: closed %s\n",
104 efl_name_get(event->object)); 99 efl_name_get(event->object));
105 ecore_main_loop_quit(); 100 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
106} 101}
107 102
108static void 103static void
@@ -141,8 +136,7 @@ _error(void *data EINA_UNUSED, const Efl_Event *event)
141{ 136{
142 const Eina_Error *perr = event->info; 137 const Eina_Error *perr = event->info;
143 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr)); 138 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr));
144 retval = EXIT_FAILURE; 139 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
145 ecore_main_loop_quit();
146} 140}
147 141
148EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs, 142EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs,
@@ -226,8 +220,39 @@ static const Ecore_Getopt options = {
226 } 220 }
227}; 221};
228 222
229int 223static Eo *dialer = NULL;
230main(int argc, char **argv) 224
225EAPI_MAIN void
226efl_pause(void *data EINA_UNUSED,
227 const Efl_Event *ev EINA_UNUSED)
228{
229}
230
231EAPI_MAIN void
232efl_resume(void *data EINA_UNUSED,
233 const Efl_Event *ev EINA_UNUSED)
234{
235}
236
237EAPI_MAIN void
238efl_terminate(void *data EINA_UNUSED,
239 const Efl_Event *ev EINA_UNUSED)
240{
241 /* FIXME: For the moment the main loop doesn't get
242 properly destroyed on shutdown which disallow
243 relying on parent destroying their children */
244 if (dialer)
245 {
246 efl_del(dialer);
247 dialer = NULL;
248 }
249
250 fprintf(stderr, "INFO: main loop finished.\n");
251}
252
253EAPI_MAIN void
254efl_main(void *data EINA_UNUSED,
255 const Efl_Event *ev)
231{ 256{
232 char *address = NULL; 257 char *address = NULL;
233 char *username = NULL; 258 char *username = NULL;
@@ -265,34 +290,28 @@ main(int argc, char **argv)
265 ECORE_GETOPT_VALUE_NONE /* sentinel */ 290 ECORE_GETOPT_VALUE_NONE /* sentinel */
266 }; 291 };
267 int args; 292 int args;
268 Eo *dialer, *loop; 293 Eo *loop;
269 Efl_Net_Http_Authentication_Method authentication_method; 294 Efl_Net_Http_Authentication_Method authentication_method;
270 Efl_Net_Http_Header *header; 295 Efl_Net_Http_Header *header;
271 Eina_Iterator *itr; 296 Eina_Iterator *itr;
272 Eina_Error err; 297 Eina_Error err;
273 char *str; 298 char *str;
274 299
275 ecore_init(); 300 args = ecore_getopt_parse(&options, values, 0, NULL);
276 ecore_con_init();
277 ecore_con_url_init();
278
279 args = ecore_getopt_parse(&options, values, argc, argv);
280 if (args < 0) 301 if (args < 0)
281 { 302 {
282 fputs("ERROR: Could not parse command line options.\n", stderr); 303 fputs("ERROR: Could not parse command line options.\n", stderr);
283 retval = EXIT_FAILURE;
284 goto end; 304 goto end;
285 } 305 }
286 306
287 if (quit_option) goto end; 307 if (quit_option) goto end;
288 308
289 loop = efl_main_loop_get(); 309 loop = ev->object;
290 310
291 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 311 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
292 if (args < 0) 312 if (args < 0)
293 { 313 {
294 fputs("ERROR: Could not parse positional arguments.\n", stderr); 314 fputs("ERROR: Could not parse positional arguments.\n", stderr);
295 retval = EXIT_FAILURE;
296 goto end; 315 goto end;
297 } 316 }
298 317
@@ -311,7 +330,6 @@ main(int argc, char **argv)
311 efl_event_callback_array_add(efl_added, dialer_cbs(), NULL)); 330 efl_event_callback_array_add(efl_added, dialer_cbs(), NULL));
312 if (!dialer) 331 if (!dialer)
313 { 332 {
314 retval = EXIT_FAILURE;
315 fprintf(stderr, "ERROR: could not create WebSockets dialer\n"); 333 fprintf(stderr, "ERROR: could not create WebSockets dialer\n");
316 goto end; 334 goto end;
317 } 335 }
@@ -339,7 +357,6 @@ main(int argc, char **argv)
339 err = efl_net_dialer_dial(dialer, address); 357 err = efl_net_dialer_dial(dialer, address);
340 if (err != 0) 358 if (err != 0)
341 { 359 {
342 retval = EXIT_FAILURE;
343 fprintf(stderr, "ERROR: could not dial '%s': %s", 360 fprintf(stderr, "ERROR: could not dial '%s': %s",
344 address, eina_error_msg_get(err)); 361 address, eina_error_msg_get(err));
345 goto no_mainloop; 362 goto no_mainloop;
@@ -368,17 +385,13 @@ main(int argc, char **argv)
368 fprintf(stderr, "INFO: %s\n", str); 385 fprintf(stderr, "INFO: %s\n", str);
369 eina_iterator_free(itr); 386 eina_iterator_free(itr);
370 387
371 ecore_main_loop_begin(); 388 return ;
372
373 fprintf(stderr, "INFO: main loop finished.\n");
374 389
375 no_mainloop: 390 no_mainloop:
376 efl_del(dialer); 391 efl_del(dialer);
377 392
378 end: 393 end:
379 ecore_con_url_shutdown(); 394 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
380 ecore_con_shutdown();
381 ecore_shutdown();
382
383 return retval;
384} 395}
396
397EFL_MAIN_EX();