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/devel-api/common/singleton-service.h>
33 #include <dali/integration-api/debug.h>
36 #include <dali/internal/system/common/system-settings.h>
39 #define MSG_DOMAIN_CONTROL_ACCESS static_cast< int >( ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL )
51 namespace // unnamed namespace
54 #if defined(DEBUG_ENABLED)
55 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
58 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS = "db/setting/accessibility/atspi";
60 bool GetEnabledVConf()
63 vconf_get_bool( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, &isEnabled );
67 vconf_get_bool( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled );
70 return bool( isEnabled );
74 void AccessibilityOnOffNotification(keynode_t* node, void* data)
76 AccessibilityAdaptor* adaptor = static_cast<AccessibilityAdaptor*>( data );
78 bool isEnabled = GetEnabledVConf();
80 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
84 adaptor->EnableAccessibility();
88 adaptor->DisableAccessibility();
92 } // unnamed namespace
94 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
96 Dali::AccessibilityAdaptor adaptor;
98 Dali::SingletonService service( SingletonService::Get() );
101 // Check whether the singleton is already created
102 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
105 // If so, downcast the handle
106 adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
110 adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptorMobile() );
111 AccessibilityAdaptorMobile& adaptorImpl = AccessibilityAdaptorMobile::GetImplementation( adaptor );
113 bool isEnabled = GetEnabledVConf();
117 adaptorImpl.EnableAccessibility();
119 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
121 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification, &adaptorImpl );
122 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, &adaptorImpl );
124 service.Register( typeid( adaptor ), adaptor );
131 void AccessibilityAdaptor::OnDestroy()
133 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
134 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification );
137 AccessibilityAdaptorMobile::AccessibilityAdaptorMobile()
141 bool AccessibilityAdaptorMobile::HandleActionNextEvent(bool allowEndFeedback)
147 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
150 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
155 bool AccessibilityAdaptorMobile::HandleActionPreviousEvent(bool allowEndFeedback)
161 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
164 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
169 bool AccessibilityAdaptorMobile::HandleActionActivateEvent()
175 ret = mActionHandler->AccessibilityActionActivate();
178 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
183 bool AccessibilityAdaptorMobile::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
187 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
194 // The accessibility actions should be handled by the registered accessibility action handler (e.g. focus manager)
195 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
196 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
202 bool AccessibilityAdaptorMobile::HandleActionReadNextEvent(bool allowEndFeedback)
208 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
211 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
216 bool AccessibilityAdaptorMobile::HandleActionReadPreviousEvent(bool allowEndFeedback)
222 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
225 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
230 bool AccessibilityAdaptorMobile::HandleActionUpEvent()
236 ret = mActionHandler->AccessibilityActionUp();
239 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
244 bool AccessibilityAdaptorMobile::HandleActionDownEvent()
250 ret = mActionHandler->AccessibilityActionDown();
253 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
258 AccessibilityAdaptorMobile::~AccessibilityAdaptorMobile()
262 } // namespace Adaptor
264 } // namespace Internal