[LICENSE] change to Flora-1.1 license
[profile/tv/apps/native/screen-reader.git] / src / screen_reader.c
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * This file is a modified version of BSD licensed file and
5  * licensed under the Flora License, Version 1.1 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * Please, see the LICENSE file for the original copyright owner and
18  * license.
19  */
20
21 #include "screen_reader.h"
22 #include "screen_reader_tts.h"
23 #include "screen_reader_vconf.h"
24 #include "screen_reader_spi.h"
25 #include <vconf.h>
26 #include "logger.h"
27
28 #ifdef RUN_IPC_TEST_SUIT
29 #include "test_suite/test_suite.h"
30 #endif
31
32 #define BUF_SIZE 1024
33
34 Service_Data service_data =
35 {
36    //Set by vconf
37    .run_service = 1,
38 #ifdef SCREEN_READER_TV
39    .tracking_signal_name = FOCUS_CHANGED_SIG,
40 #else
41    .tracking_signal_name = HIGHLIGHT_CHANGED_SIG,
42 #endif
43
44    //Set by tts
45    .tts = NULL,
46    .available_languages = NULL,
47
48    //Actions to do when tts state is 'ready'
49    .update_language_list = false,
50
51    .text_to_say_info = NULL
52 };
53
54 Service_Data *get_pointer_to_service_data_struct()
55 {
56    return &service_data;
57 }
58
59 int screen_reader_create_service(void *data)
60 {
61    Service_Data *service_data = data;
62
63    vconf_init(service_data);
64    tts_init(service_data);
65
66 #ifdef SCREEN_READER_TV
67    spi_init(service_data);
68 #endif
69
70    /* XML TEST */
71 #ifdef RUN_IPC_TEST_SUIT
72    run_xml_tests();
73    test_suite_init();
74 #endif
75
76
77    return 0;
78 }
79
80 int screen_reader_terminate_service(void *data)
81 {
82    DEBUG("Service Terminate Callback \n");
83
84    Service_Data *service_data = data;
85
86    tts_stop(service_data->tts);
87    tts_unprepare(service_data->tts);
88    tts_destroy(service_data->tts);
89    service_data->text_from_dbus = NULL;
90    service_data->current_value = NULL;
91
92    return 0;
93 }