6dd2e932eee825a37b6d9c74d361a2d23058a3e8
[platform/core/uifw/tts.git] / server / ttsd_main.c
1 /*
2 *  Copyright (c) 2012, 2013 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
15 #include "ttsd_main.h"
16 #include "ttsd_server.h"
17 #include "ttsd_dbus.h"
18 #include "ttsd_network.h"
19
20 #include <Ecore.h>
21
22 #define CLIENT_CLEAN_UP_TIME 500
23
24 /* Main of TTS Daemon */
25 int main()
26 {
27         SLOG(LOG_DEBUG, TAG_TTSD, "  ");
28         SLOG(LOG_DEBUG, TAG_TTSD, "  ");
29         SLOG(LOG_DEBUG, TAG_TTSD, "===== TTS DAEMON INITIALIZE");
30         if (!ecore_init()) {
31                 SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail ecore_init() \n");
32                 return -1;
33         }
34
35         if (0 != ttsd_initialize()) {
36                 printf("Fail to initialize tts-daemon \n");
37                 SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to initialize tts-daemon \n"); 
38                 return EXIT_FAILURE;
39         }
40         
41         if (0 != ttsd_dbus_open_connection()) {
42                 printf("Fail to initialize IPC connection \n");
43                 SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to open dbus connection \n");
44                 return EXIT_FAILURE;
45         }
46
47         if (0 != ttsd_network_initialize()) {
48                 SLOG(LOG_ERROR, TAG_TTSD, "[Main ERROR] fail to initialize network \n");
49                 return EXIT_FAILURE;
50         }
51
52         ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
53
54         SLOG(LOG_DEBUG, TAG_TTSD, "[Main] tts-daemon start...\n"); 
55         SLOG(LOG_DEBUG, TAG_TTSD, "=====");
56         SLOG(LOG_DEBUG, TAG_TTSD, "  ");
57         SLOG(LOG_DEBUG, TAG_TTSD, "  ");
58
59         printf("TTS-Daemon Start...\n");
60         
61         ecore_main_loop_begin();
62         
63         ecore_shutdown();
64
65         ttsd_dbus_close_connection();
66
67         ttsd_network_finalize();
68
69         return 0;
70 }
71