Add new source file for main function 49/189749/1
authorchleun.moon <chleun.moon@samsung.com>
Thu, 28 Dec 2017 01:14:13 +0000 (10:14 +0900)
committerYu <jiung.yu@samsung.com>
Thu, 20 Sep 2018 04:39:42 +0000 (13:39 +0900)
Change-Id: I42e86a1ff0558931b063035a1a9299c30332d774
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
include/asp-manager.h
packaging/asp-manager.spec
src/CMakeLists.txt
src/asp-manager-main.c [new file with mode: 0644]
src/asp-manager.c

index 6f2e20a..585a41d 100755 (executable)
@@ -50,6 +50,9 @@ typedef struct {
 
 asp_s *asp_get_manager();
 
+gint32 asp_manager_load();
+void asp_manager_unload();
+
 #ifdef __cplusplus
 }
 #endif
index 59afd24..c3144d5 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       asp-manager
 Summary:    ASP(application service platform) manager
-Version:    0.0.26
+Version:    0.0.27
 Release:    1
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index aebb55c..3f7b423 100755 (executable)
@@ -26,6 +26,7 @@ SET(SRCS
        ${CMAKE_SOURCE_DIR}/src/asp-manager-event.c
        ${CMAKE_SOURCE_DIR}/src/asp-manager-gdbus.c
        ${CMAKE_SOURCE_DIR}/src/asp-manager-util.c
+       ${CMAKE_SOURCE_DIR}/src/asp-manager-main.c
        ${CMAKE_SOURCE_DIR}/interfaces/generated-code.c
        )
 
diff --git a/src/asp-manager-main.c b/src/asp-manager-main.c
new file mode 100644 (file)
index 0000000..de35edc
--- /dev/null
@@ -0,0 +1,37 @@
+#include "asp-manager.h"
+#include "asp-manager-util.h"
+
+gint32 main(gint32 argc, gchar *argv[])
+{
+       GMainLoop *main_loop = NULL;
+       asp_s *manager = NULL;
+
+       /* Initialize required subsystems */
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+
+       if (asp_manager_load() < 0) {
+               ASP_LOGE("Failed to load asp-manager");
+               asp_manager_unload();
+               return -1;
+       }
+
+       manager = asp_get_manager();
+       if (!manager) {
+               ASP_LOGE("Failed to get asp_s");
+               return -1;
+       }
+       /* Crate the GLIB main loop */
+       main_loop = g_main_loop_new(NULL, FALSE);
+       manager->main_loop = main_loop;
+
+       /* Run the main loop */
+       g_main_loop_run(main_loop);
+
+       asp_manager_unload();
+
+       g_main_loop_unref(main_loop);
+
+       return 0;
+}
index eea9f46..30aff54 100755 (executable)
@@ -221,34 +221,23 @@ static asp_s *__asp_manager_init()
        return asp;
 }
 
-gint32 main(gint32 argc, gchar *argv[])
+gint32 asp_manager_load()
 {
-       GMainLoop *main_loop = NULL;
-       gint32 ret = -1;
-
-       /* Initialize required subsystems */
-#if !GLIB_CHECK_VERSION(2, 35, 0)
-       g_type_init();
-#endif
+       __ASP_LOG_FUNC_ENTER__;
 
        g_asp = __asp_manager_init();
-       if (!g_asp)
-               goto fail;
-
-       /* Crate the GLIB main loop */
-       main_loop = g_main_loop_new(NULL, FALSE);
-       g_asp->main_loop = main_loop;
-
-       /* Run the main loop */
-       g_main_loop_run(main_loop);
-
-       ret = 0;
+       if (!g_asp) {
+               ASP_LOGE("Failed to initialize asp-manager");
+               return -1;
+       }
 
-fail:
+       __ASP_LOG_FUNC_EXIT__;
+       return 0;
+}
 
+void asp_manager_unload()
+{
+       __ASP_LOG_FUNC_ENTER__;
        __asp_manager_deinit();
-
-       g_main_loop_unref(main_loop);
-
-       return ret;
+       __ASP_LOG_FUNC_EXIT__;
 }