mobile-lua: add additional LABELLED_BY relation
[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  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "screen_reader.h"
18 #include "screen_reader_tts.h"
19 #include "screen_reader_vconf.h"
20 #include "screen_reader_spi.h"
21 #include <vconf.h>
22 #include "logger.h"
23
24 #ifdef RUN_IPC_TEST_SUIT
25 #include "test_suite/test_suite.h"
26 #endif
27
28 #define BUF_SIZE 1024
29
30 Service_Data service_data = {
31         //Set by vconf
32         .run_service = 1,
33 #ifdef SCREEN_READER_TV
34         .tracking_signal_name = FOCUS_CHANGED_SIG,
35 #else
36         .tracking_signal_name = HIGHLIGHT_CHANGED_SIG,
37 #endif
38
39         //Set by tts
40         .tts = NULL,
41         .available_languages = NULL,
42
43         //Actions to do when tts state is 'ready'
44         .update_language_list = false,
45         .lua_script_path = SCRIPTDIR "/mobile.lua",
46
47         .text_to_say_info = NULL
48 };
49
50 Service_Data *get_pointer_to_service_data_struct()
51 {
52         return &service_data;
53 }
54
55 int screen_reader_create_service(void *data)
56 {
57         Service_Data *service_data = data;
58
59         vconf_init(service_data);
60         tts_init(service_data);
61
62 #ifdef SCREEN_READER_TV
63         spi_init(service_data);
64 #endif
65         return 0;
66 }
67
68 int screen_reader_terminate_service(void *data)
69 {
70         DEBUG("Service Terminate Callback \n");
71
72         Service_Data *service_data = data;
73
74 #ifdef SCREEN_READER_TV
75         spi_shutdown(service_data);
76 #endif
77
78         tts_stop(service_data->tts);
79         tts_unprepare(service_data->tts);
80         tts_destroy(service_data->tts);
81         service_data->text_from_dbus = NULL;
82         service_data->current_value = NULL;
83
84         return 0;
85 }