Revert "Revert "(ATSPI) Add ATSPI for Say(), Pause(), Resume(), SetForcefully(),...
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / atspi.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 #ifndef CSHARP_ATSPI
18 #define CSHARP_ATSPI
19 #endif
20
21 #include "common.h"
22 #include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
23 #include <dali/integration-api/debug.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 SWIGEXPORT int SWIGSTDCALL csharp_dali_accessibility_GetStatus(void *jarg1)
30 {
31   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
32   if (!arg1)
33   {
34     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
35     return -1;
36   }
37   return Dali::AtspiAccessibility::GetStatus();
38 }
39
40 using callbackFuncType = void(*)(int);
41 callbackFuncType callBack;
42 void sayTestCallback(std::string result)
43 {
44   DALI_LOG_ERROR("sayTestCallback() result=%s ", result.c_str());
45
46   if(callBack)
47   {
48     if(result == "ReadingCancelled")
49     {
50       callBack(1);
51     }
52     else if(result == "ReadingStopped")
53     {
54       callBack(2);
55     }
56     else if(result == "ReadingSkipped")
57     {
58       callBack(3);
59     }
60     else
61     {
62       callBack(-1);
63     }
64   }
65 }
66
67 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_say(void *jarg1, char* jarg2, bool jarg3, void *jarg4)
68 {
69   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
70   std::string arg2(jarg2);
71   bool arg3 = jarg3;
72   callBack = (callbackFuncType)jarg4;
73
74   if (!arg1)
75   {
76     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
77     return;
78   }
79
80   Dali::AtspiAccessibility::Say(arg2, jarg3, sayTestCallback);
81
82   DALI_LOG_ERROR("csharp_dali_accessibility_say() arg3=%d", arg3);
83 }
84
85 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_pause_resume(void *jarg1, bool jarg2)
86 {
87   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
88   bool arg2 = jarg2;
89
90   if (!arg1)
91   {
92     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
93     return;
94   }
95
96   if(arg2 == true)
97   {
98     Dali::AtspiAccessibility::Pause();
99   }
100   else
101   {
102     Dali::AtspiAccessibility::Resume();
103   }
104
105   DALI_LOG_ERROR("csharp_dali_accessibility_pause_resume() arg2=%d", arg2);
106 }
107
108 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_Enable(void *jarg1, bool jarg2)
109 {
110   Dali::Toolkit::Control *arg1 = (Dali::Toolkit::Control *)jarg1;
111
112   if (!arg1)
113   {
114     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Control is null", 0);
115     return;
116   }
117
118   Dali::AtspiAccessibility::SetForcefully(jarg2);
119
120   DALI_LOG_ERROR("csharp_dali_accessibility_Enable() jarg2=%d \n", jarg2);
121 }
122
123 #ifdef __cplusplus
124 }
125 #endif