2 * Copyright (c) 2014 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 "accessibility-adaptor-impl.h"
24 #include <dali/public-api/object/type-registry.h>
25 #include <dali/integration-api/debug.h>
28 #include <singleton-service-impl.h>
29 #include <system-settings.h>
43 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS = "db/setting/accessibility/atspi";
45 bool GetEnabledVConf()
48 vconf_get_bool( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, &isEnabled );
52 vconf_get_bool( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled );
55 return (bool)isEnabled;
58 #if defined(DEBUG_ENABLED)
59 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR" );
62 void AccessibilityOnOffNotification(keynode_t* node, void* data)
64 AccessibilityAdaptor* adaptor = static_cast<AccessibilityAdaptor*>( data );
66 bool isEnabled = GetEnabledVConf();
68 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
72 adaptor->EnableAccessibility();
76 adaptor->DisableAccessibility();
80 } // unnamed namespace
82 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
84 Dali::AccessibilityAdaptor adaptor;
86 Dali::SingletonService service( SingletonService::Get() );
89 // Check whether the singleton is already created
90 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
93 // If so, downcast the handle
94 adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
98 adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptor() );
99 AccessibilityAdaptor& adaptorImpl = AccessibilityAdaptor::GetImplementation( adaptor );
101 bool isEnabled = GetEnabledVConf();
105 adaptorImpl.EnableAccessibility();
107 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
109 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification, &adaptorImpl );
110 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, &adaptorImpl );
112 service.Register( typeid( adaptor ), adaptor );
119 void AccessibilityAdaptor::OnDestroy()
121 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
122 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification );
125 } // namespace Adaptor
127 } // namespace Internal