summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-09 15:51:44 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-09 16:29:30 -0800
commit76d91121f850e77dda00de36af23664267a3f42b (patch)
tree3804cf53bf3768a41c68581fae780bd66cef213c
parent1393df02f121f202ae0a9c244bd1cf0f1417856a (diff)
ecore: remove use of efl_main_loop_get from efl_net_dialer_udp_example.
-rw-r--r--src/examples/ecore/efl_net_dialer_udp_example.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/src/examples/ecore/efl_net_dialer_udp_example.c b/src/examples/ecore/efl_net_dialer_udp_example.c
index 35336235aa..3b13a60ca7 100644
--- a/src/examples/ecore/efl_net_dialer_udp_example.c
+++ b/src/examples/ecore/efl_net_dialer_udp_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 int needed_reads = 0; 6static int needed_reads = 0;
11 7
12static void 8static void
@@ -69,8 +65,7 @@ _can_read(void *data EINA_UNUSED, const Efl_Event *event)
69 if (err == EAGAIN) /* EAGAIN for spurious packets */ 65 if (err == EAGAIN) /* EAGAIN for spurious packets */
70 return; 66 return;
71 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err)); 67 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err));
72 retval = EXIT_FAILURE; 68 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
73 ecore_main_loop_quit();
74 return; 69 return;
75 } 70 }
76 71
@@ -78,10 +73,7 @@ _can_read(void *data EINA_UNUSED, const Efl_Event *event)
78 73
79 needed_reads--; 74 needed_reads--;
80 if (!needed_reads) 75 if (!needed_reads)
81 { 76 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
82 retval = EXIT_SUCCESS;
83 ecore_main_loop_quit();
84 }
85 free(rw_slice.mem); 77 free(rw_slice.mem);
86} 78}
87 79
@@ -108,8 +100,7 @@ _can_write(void *data EINA_UNUSED, const Efl_Event *event)
108 if (err) 100 if (err)
109 { 101 {
110 fprintf(stderr, "ERROR: could not write: %s\n", eina_error_msg_get(err)); 102 fprintf(stderr, "ERROR: could not write: %s\n", eina_error_msg_get(err));
111 retval = EXIT_FAILURE; 103 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
112 ecore_main_loop_quit();
113 return; 104 return;
114 } 105 }
115 106
@@ -122,8 +113,7 @@ _can_write(void *data EINA_UNUSED, const Efl_Event *event)
122 if (err) 113 if (err)
123 { 114 {
124 fprintf(stderr, "ERROR: could not write: %s\n", eina_error_msg_get(err)); 115 fprintf(stderr, "ERROR: could not write: %s\n", eina_error_msg_get(err));
125 retval = EXIT_FAILURE; 116 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
126 ecore_main_loop_quit();
127 return; 117 return;
128 } 118 }
129 119
@@ -139,8 +129,7 @@ _can_write(void *data EINA_UNUSED, const Efl_Event *event)
139 else 129 else
140 { 130 {
141 fprintf(stderr, "INFO: we're done\n"); 131 fprintf(stderr, "INFO: we're done\n");
142 retval = EXIT_SUCCESS; 132 efl_loop_quit(efl_loop_get(event->object), EINA_VALUE_EMPTY);
143 ecore_main_loop_quit();
144 } 133 }
145 return; 134 return;
146 } 135 }
@@ -161,7 +150,8 @@ _error(void *data EINA_UNUSED, const Efl_Event *event)
161{ 150{
162 const Eina_Error *perr = event->info; 151 const Eina_Error *perr = event->info;
163 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr)); 152 fprintf(stderr, "INFO: error: %d '%s'\n", *perr, eina_error_msg_get(*perr));
164 retval = EXIT_FAILURE; 153
154 efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
165} 155}
166 156
167EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs, 157EFL_CALLBACKS_ARRAY_DEFINE(dialer_cbs,
@@ -202,8 +192,39 @@ static const Ecore_Getopt options = {
202 } 192 }
203}; 193};
204 194
205int 195static Eo *dialer = NULL;
206main(int argc, char **argv) 196
197EAPI_MAIN void
198efl_pause(void *data EINA_UNUSED,
199 const Efl_Event *ev EINA_UNUSED)
200{
201}
202
203EAPI_MAIN void
204efl_resume(void *data EINA_UNUSED,
205 const Efl_Event *ev EINA_UNUSED)
206{
207}
208
209EAPI_MAIN void
210efl_terminate(void *data EINA_UNUSED,
211 const Efl_Event *ev EINA_UNUSED)
212{
213 /* FIXME: For the moment the main loop doesn't get
214 properly destroyed on shutdown which disallow
215 relying on parent destroying their children */
216 if (dialer)
217 {
218 efl_del(dialer);
219 dialer = NULL;
220 }
221
222 fprintf(stderr, "INFO: main loop finished.\n");
223}
224
225EAPI_MAIN void
226efl_main(void *data EINA_UNUSED,
227 const Efl_Event *ev)
207{ 228{
208 char *address = NULL; 229 char *address = NULL;
209 char *bind_address = NULL; 230 char *bind_address = NULL;
@@ -238,29 +259,24 @@ main(int argc, char **argv)
238 ECORE_GETOPT_VALUE_NONE /* sentinel */ 259 ECORE_GETOPT_VALUE_NONE /* sentinel */
239 }; 260 };
240 int args; 261 int args;
241 Eo *dialer, *loop; 262 Eo *loop;
242 Eina_Error err; 263 Eina_Error err;
243 264
244 ecore_init(); 265 args = ecore_getopt_parse(&options, values, 0, NULL);
245 ecore_con_init();
246
247 args = ecore_getopt_parse(&options, values, argc, argv);
248 if (args < 0) 266 if (args < 0)
249 { 267 {
250 fputs("ERROR: Could not parse command line options.\n", stderr); 268 fputs("ERROR: Could not parse command line options.\n", stderr);
251 retval = EXIT_FAILURE;
252 goto end; 269 goto end;
253 } 270 }
254 271
255 if (quit_option) goto end; 272 if (quit_option) goto end;
256 273
257 loop = efl_main_loop_get(); 274 loop = ev->object;
258 275
259 args = ecore_getopt_parse_positional(&options, values, argc, argv, args); 276 args = ecore_getopt_parse_positional(&options, values, 0, NULL, args);
260 if (args < 0) 277 if (args < 0)
261 { 278 {
262 fputs("ERROR: Could not parse positional arguments.\n", stderr); 279 fputs("ERROR: Could not parse positional arguments.\n", stderr);
263 retval = EXIT_FAILURE;
264 goto end; 280 goto end;
265 } 281 }
266 282
@@ -289,9 +305,7 @@ main(int argc, char **argv)
289 305
290 if (do_read) needed_reads = cork ? 1 : 2; 306 if (do_read) needed_reads = cork ? 1 : 2;
291 307
292 ecore_main_loop_begin(); 308 return ;
293
294 fprintf(stderr, "INFO: main loop finished.\n");
295 309
296 no_mainloop: 310 no_mainloop:
297 efl_del(dialer); 311 efl_del(dialer);
@@ -299,8 +313,8 @@ main(int argc, char **argv)
299 end: 313 end:
300 EINA_LIST_FREE(mcast_groups, str) 314 EINA_LIST_FREE(mcast_groups, str)
301 free(str); 315 free(str);
302 ecore_con_shutdown();
303 ecore_shutdown();
304 316
305 return retval; 317 efl_loop_quit(efl_loop_get(ev->object), eina_value_int_init(EXIT_FAILURE));
306} 318}
319
320EFL_MAIN_EX();