Profile Configuration.
[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 {
32    //Set by vconf
33    .run_service = 1,
34 #ifdef SCREEN_READER_MOBILE
35    .tracking_signal_name = HIGHLIGHT_CHANGED_SIG,
36 #else
37    .tracking_signal_name = FOCUS_CHANGED_SIG,
38 #endif
39
40    //Set by tts
41    .tts = NULL,
42    .available_languages = NULL,
43
44    //Actions to do when tts state is 'ready'
45    .update_language_list = false,
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_MOBILE
63    spi_init(service_data);
64 #endif
65
66    /* XML TEST */
67 #ifdef RUN_IPC_TEST_SUIT
68    run_xml_tests();
69    test_suite_init();
70 #endif
71
72
73    return 0;
74 }
75
76 int screen_reader_terminate_service(void *data)
77 {
78    DEBUG("Service Terminate Callback \n");
79
80    Service_Data *service_data = data;
81
82    tts_stop(service_data->tts);
83    tts_unprepare(service_data->tts);
84    tts_destroy(service_data->tts);
85    service_data->text_from_dbus = NULL;
86    service_data->current_value = NULL;
87
88    return 0;
89 }