summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-08 16:18:52 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-08 16:18:52 -0800
commitbb5f9d156ca9fad76a695f78d767a0c27273360d (patch)
treed2182c0ac4cd335b85f5ed79c14682ca985e6cb6
parent419145a298d1297a1d5008c3c76bc3d7ea143d0f (diff)
ecore: remove use of efl_main_loop_get from efl_net_dialer_http_example.
-rw-r--r--src/examples/ecore/efl_net_dialer_http_example.c89
1 files changed, 54 insertions, 35 deletions
diff --git a/src/examples/ecore/efl_net_dialer_http_example.c b/src/examples/ecore/efl_net_dialer_http_example.c
index 2eae870a7e..5c83fda53c 100644
--- a/src/examples/ecore/efl_net_dialer_http_example.c
+++ b/src/examples/ecore/efl_net_dialer_http_example.c
@@ -6,7 +6,6 @@
6#include <fcntl.h> 6#include <fcntl.h>
7#include <ctype.h> 7#include <ctype.h>
8 8
9static int retval = EXIT_SUCCESS;
10static int waiting; 9static int waiting;
11 10
12static void 11static void
@@ -43,7 +42,7 @@ _error(void *data EINA_UNUSED, const Efl_Event *event)
43{ 42{
44 const Eina_Error *perr = event->info; 43 const Eina_Error *perr = event->info;
45 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr)); 44 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr));
46 retval = EXIT_FAILURE; 45 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
47} 46}
48 47
49static void 48static void
@@ -87,7 +86,7 @@ _done(void *data EINA_UNUSED, const Efl_Event *event)
87 fprintf(stderr, "INFO: done %s, waiting=%d\n", 86 fprintf(stderr, "INFO: done %s, waiting=%d\n",
88 efl_name_get(event->object), waiting); 87 efl_name_get(event->object), waiting);
89 if (waiting == 0) 88 if (waiting == 0)
90 ecore_main_loop_quit(); 89 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
91} 90}
92 91
93EFL_CALLBACKS_ARRAY_DEFINE(copier_cbs, 92EFL_CALLBACKS_ARRAY_DEFINE(copier_cbs,
@@ -199,8 +198,49 @@ static const Ecore_Getopt options = {
199 } 198 }
200}; 199};
201 200
202int 201static Eo *dialer = NULL;
203main(int argc, char **argv) 202static Eo *sender = NULL;
203static Eo *receiver = NULL;
204
205EAPI_MAIN void
206efl_pause(void *data EINA_UNUSED,
207 const Efl_Event *ev EINA_UNUSED)
208{
209}
210
211EAPI_MAIN void
212efl_resume(void *data EINA_UNUSED,
213 const Efl_Event *ev EINA_UNUSED)
214{
215}
216
217EAPI_MAIN void
218efl_terminate(void *data EINA_UNUSED,
219 const Efl_Event *ev EINA_UNUSED)
220{
221 /* FIXME: For the moment the main loop doesn't get
222 properly destroyed on shutdown which disallow
223 relying on parent destroying their children */
224 if (sender ||
225 receiver ||
226 dialer)
227 {
228 efl_io_closer_close(sender);
229 efl_del(sender);
230 sender = NULL;
231
232 efl_io_closer_close(receiver);
233 efl_del(receiver);
234 receiver = NULL;
235
236 efl_del(dialer);
237 dialer = NULL;
238 }
239}
240
241EAPI_MAIN void
242efl_main(void *data EINA_UNUSED,
243 const Efl_Event *ev)
204{ 244{
205 char *method = "GET"; 245 char *method = "GET";
206 char *primary_mode_str = "auto"; 246 char *primary_mode_str = "auto";
@@ -246,7 +286,7 @@ main(int argc, char **argv)
246 ECORE_GETOPT_VALUE_NONE /* sentinel */ 286 ECORE_GETOPT_VALUE_NONE /* sentinel */
247 }; 287 };
248 int args; 288 int args;
249 Eo *input, *dialer, *output, *sender, *receiver, *loop; 289 Eo *input, *output, *loop;
250 Efl_Net_Dialer_Http_Primary_Mode primary_mode; 290 Efl_Net_Dialer_Http_Primary_Mode primary_mode;
251 Efl_Net_Http_Version http_version; 291 Efl_Net_Http_Version http_version;
252 Efl_Net_Http_Authentication_Method authentication_method; 292 Efl_Net_Http_Authentication_Method authentication_method;
@@ -255,27 +295,21 @@ main(int argc, char **argv)
255 Eina_Error err; 295 Eina_Error err;
256 char *str; 296 char *str;
257 297
258 ecore_init(); 298 args = ecore_getopt_parse(&options, values, 0, NULL);
259 ecore_con_init();
260 ecore_con_url_init();
261
262 args = ecore_getopt_parse(&options, values, argc, argv);
263 if (args < 0) 299 if (args < 0)
264 { 300 {
265 fputs("ERROR: Could not parse command line options.\n", stderr); 301 fputs("ERROR: Could not parse command line options.\n", stderr);
266 retval = EXIT_FAILURE;
267 goto end; 302 goto end;
268 } 303 }
269 304
270 if (quit_option) goto end; 305 if (quit_option) goto end;
271 306
272 loop = efl_main_loop_get(); 307 loop = ev->object;
273 308
274 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 309 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
275 if (args < 0) 310 if (args < 0)
276 { 311 {
277 fputs("ERROR: Could not parse positional arguments.\n", stderr); 312 fputs("ERROR: Could not parse positional arguments.\n", stderr);
278 retval = EXIT_FAILURE;
279 goto end; 313 goto end;
280 } 314 }
281 315
@@ -371,7 +405,7 @@ main(int argc, char **argv)
371 { 405 {
372 fprintf(stderr, "ERROR: could not dial '%s': %s", 406 fprintf(stderr, "ERROR: could not dial '%s': %s",
373 address, eina_error_msg_get(err)); 407 address, eina_error_msg_get(err));
374 goto no_mainloop; 408 goto end;
375 } 409 }
376 410
377 fprintf(stderr, 411 fprintf(stderr,
@@ -398,25 +432,10 @@ main(int argc, char **argv)
398 fprintf(stderr, "INFO: %s: %s\n", header->key, header->value); 432 fprintf(stderr, "INFO: %s: %s\n", header->key, header->value);
399 eina_iterator_free(itr); 433 eina_iterator_free(itr);
400 434
401 ecore_main_loop_begin(); 435 return ;
402
403 fprintf(stderr, "INFO: main loop finished.\n");
404
405 no_mainloop:
406 efl_io_closer_close(sender);
407 efl_del(sender);
408
409 efl_io_closer_close(receiver);
410 efl_del(receiver);
411
412 efl_del(dialer);
413 efl_del(output);
414 efl_del(input);
415 436
416 end: 437 end:
417 ecore_con_url_shutdown(); 438 efl_loop_quit(ev->object, eina_value_int_init(EXIT_FAILURE));
418 ecore_con_shutdown();
419 ecore_shutdown();
420
421 return retval;
422} 439}
440
441EFL_MAIN_EX();