summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-08 15:55:17 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-08 15:55:17 -0800
commita0e81d1276e0c47f8ff0ed450d823ea3fadba87f (patch)
tree5e36a0cc795df630ba2bbacd7378b7551cf1e410
parente38a5b1234708a23cdf4f58118027e78a7374501 (diff)
ecore: remove use of efl_main_loop_get from efl_io_queue_example.
-rw-r--r--src/examples/ecore/efl_io_queue_example.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/examples/ecore/efl_io_queue_example.c b/src/examples/ecore/efl_io_queue_example.c
index 4f75c47ce7..9a9738859b 100644
--- a/src/examples/ecore/efl_io_queue_example.c
+++ b/src/examples/ecore/efl_io_queue_example.c
@@ -1,10 +1,6 @@
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;
8static Eina_List *waiting = NULL; 4static Eina_List *waiting = NULL;
9static Eina_List *commands = NULL; 5static Eina_List *commands = NULL;
10static Eina_Slice line_delimiter; 6static Eina_Slice line_delimiter;
@@ -87,7 +83,7 @@ _copier_done(void *data EINA_UNUSED, const Efl_Event *event)
87 83
88 waiting = eina_list_remove(waiting, event->object); 84 waiting = eina_list_remove(waiting, event->object);
89 if (!waiting) 85 if (!waiting)
90 ecore_main_loop_quit(); 86 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
91} 87}
92 88
93static void 89static void
@@ -96,8 +92,8 @@ _copier_error(void *data EINA_UNUSED, const Efl_Event *event)
96 const Eina_Error *perr = event->info; 92 const Eina_Error *perr = event->info;
97 fprintf(stderr, "INFO: %s error: #%d '%s'\n", 93 fprintf(stderr, "INFO: %s error: #%d '%s'\n",
98 efl_name_get(event->object), *perr, eina_error_msg_get(*perr)); 94 efl_name_get(event->object), *perr, eina_error_msg_get(*perr));
99 retval = EXIT_FAILURE; 95
100 ecore_main_loop_quit(); 96 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
101} 97}
102 98
103EFL_CALLBACKS_ARRAY_DEFINE(copier_cbs, 99EFL_CALLBACKS_ARRAY_DEFINE(copier_cbs,
@@ -171,8 +167,34 @@ static const Ecore_Getopt options = {
171 } 167 }
172}; 168};
173 169
174int 170EAPI_MAIN void
175main(int argc, char **argv) 171efl_pause(void *data EINA_UNUSED,
172 const Efl_Event *ev EINA_UNUSED)
173{
174}
175
176EAPI_MAIN void
177efl_resume(void *data EINA_UNUSED,
178 const Efl_Event *ev EINA_UNUSED)
179{
180}
181
182EAPI_MAIN void
183efl_terminate(void *data EINA_UNUSED,
184 const Efl_Event *ev EINA_UNUSED)
185{
186 if (waiting)
187 {
188 fprintf(stderr, "ERROR: %d operations were waiting!\n",
189 eina_list_count(waiting));
190 eina_list_free(waiting);
191 waiting = NULL;
192 }
193}
194
195EAPI_MAIN void
196efl_main(void *data EINA_UNUSED,
197 const Efl_Event *ev)
176{ 198{
177 char *address = NULL; 199 char *address = NULL;
178 char *line_delimiter_str = NULL; 200 char *line_delimiter_str = NULL;
@@ -199,24 +221,19 @@ main(int argc, char **argv)
199 int args; 221 int args;
200 Eo *dialer, *sender, *receiver, *loop; 222 Eo *dialer, *sender, *receiver, *loop;
201 223
202 ecore_init(); 224 args = ecore_getopt_parse(&options, values, 0, NULL);
203 ecore_con_init();
204
205 args = ecore_getopt_parse(&options, values, argc, argv);
206 if (args < 0) 225 if (args < 0)
207 { 226 {
208 fputs("ERROR: Could not parse command line options.\n", stderr); 227 fputs("ERROR: Could not parse command line options.\n", stderr);
209 retval = EXIT_FAILURE;
210 goto end; 228 goto end;
211 } 229 }
212 230
213 if (quit_option) goto end; 231 if (quit_option) goto end;
214 232
215 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 233 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
216 if (args < 0) 234 if (args < 0)
217 { 235 {
218 fputs("ERROR: Could not parse positional arguments.\n", stderr); 236 fputs("ERROR: Could not parse positional arguments.\n", stderr);
219 retval = EXIT_FAILURE;
220 goto end; 237 goto end;
221 } 238 }
222 239
@@ -225,7 +242,6 @@ main(int argc, char **argv)
225 if (!commands) 242 if (!commands)
226 { 243 {
227 fputs("ERROR: missing commands to send.\n", stderr); 244 fputs("ERROR: missing commands to send.\n", stderr);
228 retval = EXIT_FAILURE;
229 goto end; 245 goto end;
230 } 246 }
231 247
@@ -248,7 +264,6 @@ main(int argc, char **argv)
248 if (!send_queue) 264 if (!send_queue)
249 { 265 {
250 fprintf(stderr, "ERROR: could not create Efl_Io_Queue (send)\n"); 266 fprintf(stderr, "ERROR: could not create Efl_Io_Queue (send)\n");
251 retval = EXIT_FAILURE;
252 goto end; 267 goto end;
253 } 268 }
254 269
@@ -271,7 +286,6 @@ main(int argc, char **argv)
271 if (!receive_queue) 286 if (!receive_queue)
272 { 287 {
273 fprintf(stderr, "ERROR: could not create Efl_Io_Queue (receive)\n"); 288 fprintf(stderr, "ERROR: could not create Efl_Io_Queue (receive)\n");
274 retval = EXIT_FAILURE;
275 goto error_receive_queue; 289 goto error_receive_queue;
276 } 290 }
277 291
@@ -285,7 +299,7 @@ main(int argc, char **argv)
285 * depend on main loop, thus their parent must be a loop 299 * depend on main loop, thus their parent must be a loop
286 * provider. We use the loop itself. 300 * provider. We use the loop itself.
287 */ 301 */
288 loop = efl_main_loop_get(); 302 loop = ev->object;
289 303
290 /* The TCP client to use to send/receive network data */ 304 /* The TCP client to use to send/receive network data */
291 dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, loop, 305 dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, loop,
@@ -294,7 +308,6 @@ main(int argc, char **argv)
294 if (!dialer) 308 if (!dialer)
295 { 309 {
296 fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n"); 310 fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n");
297 retval = EXIT_FAILURE;
298 goto error_dialer; 311 goto error_dialer;
299 } 312 }
300 313
@@ -308,7 +321,6 @@ main(int argc, char **argv)
308 if (!sender) 321 if (!sender)
309 { 322 {
310 fprintf(stderr, "ERROR: could not create Efl_Io_Copier (sender)\n"); 323 fprintf(stderr, "ERROR: could not create Efl_Io_Copier (sender)\n");
311 retval = EXIT_FAILURE;
312 goto error_sender; 324 goto error_sender;
313 } 325 }
314 326
@@ -322,7 +334,6 @@ main(int argc, char **argv)
322 if (!receiver) 334 if (!receiver)
323 { 335 {
324 fprintf(stderr, "ERROR: could not create Efl_Io_Copier (receiver)\n"); 336 fprintf(stderr, "ERROR: could not create Efl_Io_Copier (receiver)\n");
325 retval = EXIT_FAILURE;
326 goto error_receiver; 337 goto error_receiver;
327 } 338 }
328 339
@@ -337,15 +348,7 @@ main(int argc, char **argv)
337 waiting = eina_list_append(waiting, sender); 348 waiting = eina_list_append(waiting, sender);
338 waiting = eina_list_append(waiting, receiver); 349 waiting = eina_list_append(waiting, receiver);
339 350
340 ecore_main_loop_begin(); 351 return ;
341
342 if (waiting)
343 {
344 fprintf(stderr, "ERROR: %d operations were waiting!\n",
345 eina_list_count(waiting));
346 eina_list_free(waiting);
347 waiting = NULL;
348 }
349 352
350 error_dialing: 353 error_dialing:
351 efl_io_closer_close(receiver); 354 efl_io_closer_close(receiver);
@@ -366,8 +369,7 @@ main(int argc, char **argv)
366 free(cmd); 369 free(cmd);
367 } 370 }
368 371
369 ecore_con_shutdown(); 372 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
370 ecore_shutdown();
371
372 return retval;
373} 373}
374
375EFL_MAIN_EX();