a1b865a74a45f143376cc23a8433dce42083ed5c
[platform/core/uifw/voice-control.git] / server / vcd_main.c
1 /*\r
2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved\r
3 *\r
4 * Licensed under the Apache License, Version 2.0 (the License);\r
5 * you may not use this file except in compliance with the License.\r
6 * You may obtain a copy of the License at\r
7 *\r
8 * http://www.apache.org/licenses/LICENSE-2.0\r
9 *\r
10 * Unless required by applicable law or agreed to in writing, software\r
11 * distributed under the License is distributed on an AS IS BASIS,\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 * See the License for the specific language governing permissions and\r
14 * limitations under the License.\r
15 */\r
16 \r
17 \r
18 #include "vcd_dbus.h"\r
19 #include "vcd_main.h"\r
20 #include "vcd_server.h"\r
21 \r
22 #define CLIENT_CLEAN_UP_TIME 500\r
23 \r
24 static Ecore_Timer* g_check_client_timer = NULL;\r
25 \r
26 int main(int argc, char** argv)\r
27 {\r
28         SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Initialize");\r
29 \r
30         if (!ecore_init()) {\r
31                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");\r
32                 return -1;\r
33         }\r
34 \r
35         if (0 != vcd_dbus_open_connection()) {\r
36                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");\r
37                 ecore_shutdown();\r
38                 return EXIT_FAILURE;\r
39         }\r
40 \r
41         if (0 != vcd_initialize()) {\r
42                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize vc-daemon");\r
43                 ecore_shutdown();\r
44                 return EXIT_FAILURE;\r
45         }\r
46 \r
47         g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client_all, NULL);\r
48         if (NULL == g_check_client_timer) {\r
49                 SLOG(LOG_WARN, TAG_VCD, "[Main Warning] Fail to create timer of client check");\r
50         }\r
51 \r
52         SLOG(LOG_DEBUG, TAG_VCD, "[Main] vc-daemon start");\r
53 \r
54         SLOG(LOG_DEBUG, TAG_VCD, "@@@");\r
55 \r
56         ecore_main_loop_begin();\r
57 \r
58         SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Finalize");\r
59 \r
60         if (NULL != g_check_client_timer) {\r
61                 ecore_timer_del(g_check_client_timer);\r
62         }\r
63 \r
64         vcd_finalize();\r
65 \r
66         vcd_dbus_close_connection();\r
67 \r
68         ecore_shutdown();\r
69 \r
70         SLOG(LOG_DEBUG, TAG_VCD, "@@@");\r
71 \r
72         return 0;\r
73 }\r
74 \r
75 \r