cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0e91525d25564a33153084462f15101a6a878ea3

commit 0e91525d25564a33153084462f15101a6a878ea3
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Thu Jan 11 10:19:24 2018 -0800

    ecore: remove use of efl_main_loop_get from efl_net_session_example.
---
 src/examples/ecore/efl_net_session_example.c | 64 +++++++++++++++++-----------
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/src/examples/ecore/efl_net_session_example.c 
b/src/examples/ecore/efl_net_session_example.c
index dfc827bcfa..55c8d05d33 100644
--- a/src/examples/ecore/efl_net_session_example.c
+++ b/src/examples/ecore/efl_net_session_example.c
@@ -1,12 +1,6 @@
-#define EFL_BETA_API_SUPPORT 1
-#define EFL_EO_API_SUPPORT 1
-#include <Ecore.h>
-#include <Ecore_Con.h>
+#include <Efl_Net.h>
 #include <Ecore_Getopt.h>
 
-static int retval = EXIT_SUCCESS;
-
-
 static const char *
 _state_str(Efl_Net_Session_State state)
 {
@@ -96,8 +90,39 @@ static const Ecore_Getopt options = {
   }
 };
 
-int
-main(int argc, char **argv)
+static Eo *session = NULL;
+
+EAPI_MAIN void
+efl_pause(void *data EINA_UNUSED,
+          const Efl_Event *ev EINA_UNUSED)
+{
+}
+
+EAPI_MAIN void
+efl_resume(void *data EINA_UNUSED,
+           const Efl_Event *ev EINA_UNUSED)
+{
+}
+
+EAPI_MAIN void
+efl_terminate(void *data EINA_UNUSED,
+              const Efl_Event *ev EINA_UNUSED)
+{
+   /* FIXME: For the moment the main loop doesn't get
+      properly destroyed on shutdown which disallow
+      relying on parent destroying their children */
+   if (session)
+     {
+        efl_del(session);
+        session = NULL;
+     }
+
+   fprintf(stderr, "INFO: main loop finished.\n");
+}
+
+EAPI_MAIN void
+efl_main(void *data EINA_UNUSED,
+         const Efl_Event *ev)
 {
    char *str;
    Eina_List *techs = NULL;
@@ -118,16 +143,11 @@ main(int argc, char **argv)
      ECORE_GETOPT_VALUE_NONE /* sentinel */
    };
    int args;
-   Eo *session;
 
-   ecore_init();
-   ecore_con_init();
-
-   args = ecore_getopt_parse(&options, values, argc, argv);
+   args = ecore_getopt_parse(&options, values, 0, NULL);
    if (args < 0)
      {
         fputs("ERROR: Could not parse command line options.\n", stderr);
-        retval = EXIT_FAILURE;
         goto end;
      }
 
@@ -152,12 +172,11 @@ main(int argc, char **argv)
           }
      }
 
-   session = efl_add(EFL_NET_SESSION_CLASS, efl_main_loop_get(),
+   session = efl_add(EFL_NET_SESSION_CLASS, ev->object,
                      efl_event_callback_array_add(efl_added, 
session_events_cbs(), NULL));
    if (!session)
      {
         fputs("ERROR: Could not create Efl.Net.Session object.\n", stderr);
-        retval = EXIT_FAILURE;
         goto end;
      }
 
@@ -169,13 +188,10 @@ main(int argc, char **argv)
 
    printf("INFO: the session will active while this application runs. Use ^C 
(Control + C) to close it\n");
 
-   ecore_main_loop_begin();
-
-   efl_del(session);
+   return ;
 
  end:
-   ecore_con_shutdown();
-   ecore_shutdown();
-
-   return retval;
+   efl_loop_quit(ev->object, eina_value_int_init(EXIT_FAILURE));
 }
+
+EFL_MAIN_EX();

-- 


Reply via email to