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 // Disabled Accessibility temporarily in Tizen platform
46 bool GetEnabledVConf()
49 //vconf_get_bool( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, &isEnabled );
53 //vconf_get_bool( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled );
56 return static_cast<bool>(isEnabled);
59 #if defined(DEBUG_ENABLED)
60 Debug::Filter* gAccessibilityAdaptorLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR" );
63 void AccessibilityOnOffNotification(keynode_t* node, void* data)
65 AccessibilityAdaptor* adaptor = static_cast<AccessibilityAdaptor*>( data );
67 bool isEnabled = GetEnabledVConf();
69 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
73 adaptor->EnableAccessibility();
77 adaptor->DisableAccessibility();
81 } // unnamed namespace
83 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
85 Dali::AccessibilityAdaptor adaptor;
87 Dali::SingletonService service( SingletonService::Get() );
90 // Check whether the singleton is already created
91 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
94 // If so, downcast the handle
95 adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
99 adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptor() );
100 AccessibilityAdaptor& adaptorImpl = AccessibilityAdaptor::GetImplementation( adaptor );
102 bool isEnabled = GetEnabledVConf();
106 adaptorImpl.EnableAccessibility();
108 DALI_LOG_INFO( gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled ? "ENABLED" : "DISABLED" );
110 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification, &adaptorImpl );
111 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, &adaptorImpl );
113 service.Register( typeid( adaptor ), adaptor );
120 void AccessibilityAdaptor::OnDestroy()
122 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
123 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_DBUS_TTS, AccessibilityOnOffNotification );
126 } // namespace Adaptor
128 } // namespace Internal