f31ed91e47ed17d7b4e041b06b4438e9b1dc1c84
[platform/core/uifw/voice-control.git] / server / vcd_main.c
1 /*
2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 #include "vcd_dbus.h"
19 #include "vcd_main.h"
20 #include "vcd_server.h"
21
22 #define CLIENT_CLEAN_UP_TIME 500
23
24 static Ecore_Timer* g_check_client_timer = NULL;
25
26 int main(int argc, char** argv)
27 {
28         SLOG(LOG_DEBUG, TAG_VCD, "  ");
29         SLOG(LOG_DEBUG, TAG_VCD, "  ");
30         SLOG(LOG_DEBUG, TAG_VCD, "===== VC Daemon Initialize");
31
32         if (!ecore_init()) {
33                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");
34                 return -1;
35         }
36
37         if (0 != vcd_dbus_open_connection()) {
38                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");
39                 return EXIT_FAILURE;
40         }
41
42         if (0 != vcd_initialize()) {
43                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize vc-daemon");
44                 return EXIT_FAILURE;
45         }
46
47         g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client_all, NULL);
48         if (NULL == g_check_client_timer) {
49                 SLOG(LOG_WARN, TAG_VCD, "[Main Warning] Fail to create timer of client check");
50         }
51
52         SLOG(LOG_DEBUG, TAG_VCD, "[Main] vc-daemon start...");
53
54         SLOG(LOG_DEBUG, TAG_VCD, "=====");
55         SLOG(LOG_DEBUG, TAG_VCD, "  ");
56         SLOG(LOG_DEBUG, TAG_VCD, "  ");
57
58         ecore_main_loop_begin();
59
60         SLOG(LOG_DEBUG, TAG_VCD, "===== VC Daemon Finalize");
61
62         if (NULL != g_check_client_timer) {
63                 ecore_timer_del(g_check_client_timer);
64         }
65
66         vcd_finalize();
67
68         vcd_dbus_close_connection();
69
70         ecore_shutdown();
71
72         SLOG(LOG_DEBUG, TAG_VCD, "=====");
73         SLOG(LOG_DEBUG, TAG_VCD, "  ");
74         SLOG(LOG_DEBUG, TAG_VCD, "  ");
75
76         return 0;
77 }
78
79