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