2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/accessibility/tizen-wayland/tizen-mobile/accessibility-adaptor-impl-mobile.h>
25 #include <dali/internal/system/linux/dali-ecore-x.h>
26 #include <dali/internal/system/linux/dali-elementary.h>
31 #include <dali/public-api/object/type-registry.h>
32 #include <dali/integration-api/debug.h>
33 #include <dali/integration-api/debug.h>
36 #include <dali/internal/system/common/singleton-service-impl.h>
37 #include <dali/internal/system/common/system-settings.h>
40 #define MSG_DOMAIN_CONTROL_ACCESS static_cast< int >( ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL )
52 namespace // unnamed namespace
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
59 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS = "db/setting/accessibility/atspi";
61 bool GetEnabledVConf()
64 vconf_get_bool( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, &isEnabled );
68 vconf_get_bool( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled );
71 return bool( isEnabled );
75 void AccessibilityOnOffNotification(keynode_t* node, void* data)
77 AccessibilityAdaptor* adaptor = static_cast<AccessibilityAdaptor*>( data );
79 bool isEnabled = GetEnabledVConf();
81 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
85 adaptor->EnableAccessibility();
89 adaptor->DisableAccessibility();
93 } // unnamed namespace
95 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
97 Dali::AccessibilityAdaptor adaptor;
99 Dali::SingletonService service( SingletonService::Get() );
102 // Check whether the singleton is already created
103 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
106 // If so, downcast the handle
107 adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
111 adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptorMobile() );
112 AccessibilityAdaptorMobile& adaptorImpl = AccessibilityAdaptorMobile::GetImplementation( adaptor );
114 bool isEnabled = GetEnabledVConf();
118 adaptorImpl.EnableAccessibility();
120 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
122 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification, &adaptorImpl );
123 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, &adaptorImpl );
125 service.Register( typeid( adaptor ), adaptor );
132 void AccessibilityAdaptor::OnDestroy()
134 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
135 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification );
138 AccessibilityAdaptorMobile::AccessibilityAdaptorMobile()
142 bool AccessibilityAdaptorMobile::HandleActionNextEvent(bool allowEndFeedback)
148 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
151 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
156 bool AccessibilityAdaptorMobile::HandleActionPreviousEvent(bool allowEndFeedback)
162 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
165 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
170 bool AccessibilityAdaptorMobile::HandleActionActivateEvent()
176 ret = mActionHandler->AccessibilityActionActivate();
179 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
184 bool AccessibilityAdaptorMobile::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
188 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
195 // The accessibility actions should be handled by the registered accessibility action handler (e.g. focus manager)
196 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
197 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
203 bool AccessibilityAdaptorMobile::HandleActionReadNextEvent(bool allowEndFeedback)
209 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
212 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
217 bool AccessibilityAdaptorMobile::HandleActionReadPreviousEvent(bool allowEndFeedback)
223 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
226 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
231 bool AccessibilityAdaptorMobile::HandleActionUpEvent()
237 ret = mActionHandler->AccessibilityActionUp();
240 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
245 bool AccessibilityAdaptorMobile::HandleActionDownEvent()
251 ret = mActionHandler->AccessibilityActionDown();
254 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
259 AccessibilityAdaptorMobile::~AccessibilityAdaptorMobile()
263 } // namespace Adaptor
265 } // namespace Internal