dd5cb7c6cb25734dfdc17ba7094a8ed390ce3362
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / tizen-wayland / atspi / atspi-accessibility-tizen.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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
18 #include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
19 #include <dali/internal/accessibility/tizen-wayland/atspi/accessibility-impl.h>
20 #include <dali/internal/accessibility/tizen-wayland/atspi/accessibility-common.h>
21
22 #include <mutex>
23 #include <Eldbus.h>
24 #include <Ecore_Input.h>
25 #include <dali/integration-api/debug.h>
26
27 void Dali::AtspiAccessibility::Pause()
28 {
29   if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
30   {
31     bridge->Pause();
32   }
33 }
34
35 void Dali::AtspiAccessibility::Resume()
36 {
37   if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
38   {
39     bridge->Resume();
40   }
41 }
42
43 void Dali::AtspiAccessibility::Say( const std::string& text, bool discardable, std::function<void( std::string )> callback )
44 {
45   if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
46   {
47     bridge->Say(text, discardable, callback);
48   }
49 }
50
51 int Dali::AtspiAccessibility::SetForcefully( bool turnOn )
52 {
53   if( turnOn )
54   {
55     if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
56     {
57       bridge->Initialize();
58       auto ret = bridge->ForceUp();
59       return (int)ret;
60     }
61   }
62   else
63   {
64     if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
65     {
66       bridge->ForceDown();
67       return 0;
68     }
69   }
70   return -1;
71 }
72
73 int Dali::AtspiAccessibility::GetStatus()
74 {
75   //0(ATSPI OFF, ScreenReader OFF), 1(ATSPI ON, ScreenReader OFF), 2 (ATSPI OFF, ScreenReader ON), 3(ATSPI ON, ScreenReader ON)
76   if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
77   {
78     if( bridge->GetScreenReaderEnabled() )
79     {
80       if( bridge->GetIsEnabled() )
81       {
82         return 3;
83       }
84       else
85       {
86         return 2;
87       }
88     }
89     else
90     {
91       if( bridge->GetIsEnabled() )
92       {
93         return 1;
94       }
95       else
96       {
97         return 0;
98       }
99     }
100   }
101   return -1;
102 }