2 * Copyright (c) 2018 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>
26 #include <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>
34 #include <dali/integration-api/events/gesture-requests.h>
37 #include <dali/internal/system/common/singleton-service-impl.h>
38 #include <dali/internal/system/common/system-settings.h>
41 #define MSG_DOMAIN_CONTROL_ACCESS static_cast< int >( ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL )
53 namespace // unnamed namespace
56 #if defined(DEBUG_ENABLED)
57 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
60 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS = "db/setting/accessibility/atspi";
62 bool GetEnabledVConf()
65 vconf_get_bool( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, &isEnabled );
69 vconf_get_bool( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled );
72 return bool( isEnabled );
76 void AccessibilityOnOffNotification(keynode_t* node, void* data)
78 AccessibilityAdaptor* adaptor = static_cast<AccessibilityAdaptor*>( data );
80 bool isEnabled = GetEnabledVConf();
82 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
86 adaptor->EnableAccessibility();
90 adaptor->DisableAccessibility();
94 } // unnamed namespace
96 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
98 Dali::AccessibilityAdaptor adaptor;
100 Dali::SingletonService service( SingletonService::Get() );
103 // Check whether the singleton is already created
104 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
107 // If so, downcast the handle
108 adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
112 adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptorMobile() );
113 AccessibilityAdaptorMobile& adaptorImpl = AccessibilityAdaptorMobile::GetImplementation( adaptor );
115 bool isEnabled = GetEnabledVConf();
119 adaptorImpl.EnableAccessibility();
121 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
123 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification, &adaptorImpl );
124 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, &adaptorImpl );
126 service.Register( typeid( adaptor ), adaptor );
133 void AccessibilityAdaptor::OnDestroy()
135 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
136 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification );
139 AccessibilityAdaptorMobile::AccessibilityAdaptorMobile()
143 bool AccessibilityAdaptorMobile::HandleActionNextEvent(bool allowEndFeedback)
149 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
152 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
157 bool AccessibilityAdaptorMobile::HandleActionPreviousEvent(bool allowEndFeedback)
163 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
166 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
171 bool AccessibilityAdaptorMobile::HandleActionActivateEvent()
177 ret = mActionHandler->AccessibilityActionActivate();
180 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
185 bool AccessibilityAdaptorMobile::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
189 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
196 // The accessibility actions should be handled by the registered accessibility action handler (e.g. focus manager)
197 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
198 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
204 bool AccessibilityAdaptorMobile::HandleActionReadNextEvent(bool allowEndFeedback)
210 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
213 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
218 bool AccessibilityAdaptorMobile::HandleActionReadPreviousEvent(bool allowEndFeedback)
224 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
227 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
232 bool AccessibilityAdaptorMobile::HandleActionUpEvent()
238 ret = mActionHandler->AccessibilityActionUp();
241 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
246 bool AccessibilityAdaptorMobile::HandleActionDownEvent()
252 ret = mActionHandler->AccessibilityActionDown();
255 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
260 AccessibilityAdaptorMobile::~AccessibilityAdaptorMobile()
264 } // namespace Adaptor
266 } // namespace Internal