84b716ea570fbfe99fd9e1c781eed45221d3d36b
[platform/core/uifw/tts.git] / server / ttsd_main_sr.c
1 /*
2 *  Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved 
3 *  Licensed under the Apache License, Version 2.0 (the "License");
4 *  you may not use this file except in compliance with the License.
5 *  You may obtain a copy of the License at
6 *  http://www.apache.org/licenses/LICENSE-2.0
7 *  Unless required by applicable law or agreed to in writing, software
8 *  distributed under the License is distributed on an "AS IS" BASIS,
9 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 *  See the License for the specific language governing permissions and
11 *  limitations under the License.
12 */
13
14 #include "ttsd_main.h"
15 #include "ttsd_server.h"
16 #include "ttsd_dbus.h"
17 #include "ttsd_network.h"
18
19 #include <Ecore.h>
20
21 #define CLIENT_CLEAN_UP_TIME 500
22
23 static Ecore_Timer* g_check_client_timer = NULL;
24
25 const char* get_tag()
26 {
27         return "ttsdsr";
28 }
29
30 const char* tts_tag()
31 {
32         return "ttsdsr";
33 }
34
35 ttsd_mode_e ttsd_get_mode()
36 {
37         return TTSD_MODE_SCREEN_READER;
38 }
39
40 /* Main of TTS Daemon */
41 int main()
42 {
43         SLOG(LOG_DEBUG, get_tag(), "  ");
44         SLOG(LOG_DEBUG, get_tag(), "  ");
45         SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR INITIALIZE");
46
47         if (!ecore_init()) {
48                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail ecore_init()");
49                 return -1;
50         }
51
52         if (0 != ttsd_dbus_open_connection()) {
53                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
54                 return EXIT_FAILURE;
55         }
56
57         if (0 != ttsd_initialize()) {
58                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon-sr"); 
59                 return EXIT_FAILURE;
60         }
61
62         if (0 != ttsd_network_initialize()) {
63                 SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
64         }
65
66         g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
67         if (NULL == g_check_client_timer) {
68                 SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
69         }
70
71         SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon-sr start..."); 
72         SLOG(LOG_DEBUG, get_tag(), "=====");
73         SLOG(LOG_DEBUG, get_tag(), "  ");
74         SLOG(LOG_DEBUG, get_tag(), "  ");
75         
76         ecore_main_loop_begin();
77
78         SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR FINALIZE");
79
80         if (NULL != g_check_client_timer) {
81                 ecore_timer_del(g_check_client_timer);
82         }
83
84         ttsd_dbus_close_connection();
85
86         ttsd_network_finalize();
87
88         ttsd_finalize();
89
90         ecore_shutdown();
91
92         SLOG(LOG_DEBUG, get_tag(), "=====");
93         SLOG(LOG_DEBUG, get_tag(), "  ");
94         SLOG(LOG_DEBUG, get_tag(), "  ");
95
96         return 0;
97 }
98