2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*****************************************************************************
19 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
33 /*****************************************************************************
34 * Application Service Platform manager headers
35 *****************************************************************************/
36 #include "asp-manager.h"
37 #include "asp-service.h"
38 #include "asp-session.h"
40 #include "asp-manager-gdbus.h"
41 #include "asp-manager-util.h"
43 /*****************************************************************************
45 *****************************************************************************/
47 /*****************************************************************************
49 *****************************************************************************/
50 static asp_s *g_asp = NULL;
52 /*****************************************************************************
53 * Local Functions Definition
54 *****************************************************************************/
56 asp_s *asp_get_manager()
61 static void __asp_manager_deinit()
63 __ASP_LOG_FUNC_ENTER__;
67 printf("Memory for manager structure is not allocated");
73 res = asp_service_deinit();
75 ASP_LOGE("Failed to deinitialize service");
77 asp_manager_gdbus_deinit((void *)g_asp);
81 __ASP_LOG_FUNC_EXIT__;
84 static asp_s *__asp_manager_init()
86 __ASP_LOG_FUNC_ENTER__;
90 asp = (asp_s*) g_try_malloc0(sizeof(asp_s));
92 ASP_LOGE("Failed to allocate memory for manager structure");
95 ASP_LOGD("ASP: manager alloc");
99 /* TODO : Handle tech failure */
101 res = asp_service_init();
103 ASP_LOGE("Failed to initialize service");
108 asp_manager_gdbus_init((void *)asp);
110 ASP_LOGD("asp manager initialized");
111 __ASP_LOG_FUNC_EXIT__;
115 int main(int argc, char *argv[])
117 GMainLoop *main_loop = NULL;
120 /* Initialize required subsystems */
121 #if !GLIB_CHECK_VERSION(2, 35, 0)
125 g_asp = __asp_manager_init();
129 /* Crate the GLIB main loop */
130 main_loop = g_main_loop_new(NULL, FALSE);
131 g_asp->main_loop = main_loop;
133 /* Run the main loop */
134 g_main_loop_run(main_loop);
140 __asp_manager_deinit();
142 g_main_loop_unref(main_loop);