[dali_2.0.53] Merge branch 'devel/master'
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / atspi-wrap.cpp
1 /** Copyright (c) 2019 Samsung Electronics Co., Ltd.
2 *
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 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 #include "common.h"
18 #include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
19 #include <dali/integration-api/debug.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 SWIGEXPORT int SWIGSTDCALL csharp_dali_accessibility_GetStatus(void *jarg1)
26 {
27   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
28   if (!arg1)
29   {
30     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
31     return -1;
32   }
33   return Dali::AtspiAccessibility::GetStatus();
34 }
35
36 using callbackFuncType = void(*)(int);
37 callbackFuncType callBack;
38 void sayTestCallback(std::string result)
39 {
40   DALI_LOG_ERROR("sayTestCallback() result=%s ", result.c_str());
41
42   if(callBack)
43   {
44     if(result == "ReadingCancelled")
45     {
46       callBack(1);
47     }
48     else if(result == "ReadingStopped")
49     {
50       callBack(2);
51     }
52     else if(result == "ReadingSkipped")
53     {
54       callBack(3);
55     }
56     else if(result == "ReadingPaused")
57     {
58       callBack(4);
59     }
60     else if(result == "ReadingResumed")
61     {
62       callBack(5);
63     }
64     else
65     {
66       callBack(-1);
67     }
68   }
69 }
70
71 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_say(void *jarg1, char* jarg2, bool jarg3, void *jarg4)
72 {
73   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
74   std::string arg2(jarg2);
75   bool arg3 = jarg3;
76   callBack = (callbackFuncType)jarg4;
77
78   if (!arg1)
79   {
80     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
81     return;
82   }
83
84   Dali::AtspiAccessibility::Say(arg2, jarg3, sayTestCallback);
85
86   DALI_LOG_ERROR("csharp_dali_accessibility_say() arg3=%d", arg3);
87 }
88
89 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_pause_resume(void *jarg1, bool jarg2)
90 {
91   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
92   bool arg2 = jarg2;
93
94   if (!arg1)
95   {
96     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
97     return;
98   }
99
100   if(arg2 == true)
101   {
102     Dali::AtspiAccessibility::Pause();
103   }
104   else
105   {
106     Dali::AtspiAccessibility::Resume();
107   }
108
109   DALI_LOG_ERROR("csharp_dali_accessibility_pause_resume() arg2=%d", arg2);
110 }
111
112 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_stop_reading(void *jarg1, bool jarg2)
113 {
114   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
115   bool arg2 = jarg2;
116
117   if (!arg1)
118   {
119     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
120     return;
121   }
122
123   Dali::AtspiAccessibility::StopReading(arg2);
124
125   DALI_LOG_ERROR("csharp_dali_accessibility_stop_reading() arg2=%d", arg2);
126 }
127
128 SWIGEXPORT bool SWIGSTDCALL csharp_dali_accessibility_suppress_screen_reader(void *jarg1, bool jarg2)
129 {
130   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
131   bool arg2 = jarg2;
132
133   if (!arg1)
134   {
135     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
136     return false;
137   }
138
139   return Dali::AtspiAccessibility::SuppressScreenReader(arg2);
140 }
141
142 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_Enable(void *jarg1, bool jarg2)
143 {
144   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
145
146   if (!arg1)
147   {
148     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
149     return;
150   }
151
152   Dali::AtspiAccessibility::SetForcefully(jarg2);
153
154   DALI_LOG_ERROR("csharp_dali_accessibility_Enable() jarg2=%d \n", jarg2);
155 }
156
157 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_BridgeEnableAutoInit()
158 {
159   Dali::Accessibility::Bridge::EnableAutoInit();
160 }
161
162 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_BridgeDisableAutoInit()
163 {
164   Dali::Accessibility::Bridge::DisableAutoInit();
165 }
166
167 SWIGEXPORT bool SWIGSTDCALL csharp_dali_accessibility_IsEnabled()
168 {
169   return Dali::AtspiAccessibility::IsEnabled();
170 }
171
172 #ifdef __cplusplus
173 }
174 #endif