change code for config and change init api and add file for sysinfo check
[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 char* get_tag()
25 {
26         return "ttsd";
27 }
28
29 ttsd_mode_e ttsd_get_mode()
30 {
31         return TTSD_MODE_DEFAULT;
32 }
33
34 /* Main of TTS Daemon */
35 int main()
36 {
37         SLOG(LOG_DEBUG, get_tag(), "  ");
38         SLOG(LOG_DEBUG, get_tag(), "  ");
39         SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT INITIALIZE");
40         if (!ecore_init()) {
41                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init() \n");
42                 return -1;
43         }
44
45         if (0 != ttsd_initialize()) {
46                 printf("Fail to initialize tts-daemon \n");
47                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon"); 
48                 return EXIT_FAILURE;
49         }
50         
51         if (0 != ttsd_dbus_open_connection()) {
52                 printf("Fail to initialize IPC connection \n");
53                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection");
54                 return EXIT_FAILURE;
55         }
56
57         if (0 != ttsd_network_initialize()) {
58                 SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network");
59                 return EXIT_FAILURE;
60         }
61
62         ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
63
64         SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon start...\n"); 
65         SLOG(LOG_DEBUG, get_tag(), "=====");
66         SLOG(LOG_DEBUG, get_tag(), "  ");
67         SLOG(LOG_DEBUG, get_tag(), "  ");
68
69         printf("Start tts-daemon ...\n");
70         
71         ecore_main_loop_begin();
72
73         SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT FINALIZE");
74         
75         ttsd_network_finalize();
76
77         ttsd_dbus_close_connection();
78
79         ttsd_finalize();
80
81         ecore_shutdown();
82
83         SLOG(LOG_DEBUG, get_tag(), "=====");
84         SLOG(LOG_DEBUG, get_tag(), "  ");
85         SLOG(LOG_DEBUG, get_tag(), "  ");
86
87         return 0;
88 }
89