BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(capi-system-media-key)
BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires: pkgconfig(capi-telephony-sim)
+BuildRequires: pkgconfig(capi-network-tethering)
+BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires: pkgconfig(capi-network-wifi-direct)
+BuildRequires: pkgconfig(capi-media-sound-manager)
+BuildRequires: pkgconfig(sysman)
BuildRequires: pkgconfig(tapi)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(eet)
+BuildRequires: pkgconfig(edbus)
+BuildRequires: pkgconfig(efreet)
+BuildRequires: pkgconfig(ethumb)
BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(libpcre)
SET (this_target osp-system-server)
INCLUDE_DIRECTORIES (
+ /usr/include/sysman
+ /usr/include/elementary-1
+ /usr/include/eet-1
+ /usr/include/ecore-1
+ /usr/include/evas-1
+ /usr/include/edje-1
+ /usr/include/e_dbus-1
+ /usr/include/efreet-1
+ /usr/include/ethumb-1
+ /usr/include/libxml
+ /usr/include/telephony
${SLP_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/inc
+ ${CMAKE_SOURCE_DIR}/src/app/inc
+ ${CMAKE_SOURCE_DIR}/src/base/inc
${CMAKE_SOURCE_DIR}/src/system-server/inc
${CMAKE_SOURCE_DIR}/src/io/inc
${CMAKE_SOURCE_DIR}/src/server/inc
SET (${this_target}_SOURCE_FILES
system/FSys_SystemInfo.cpp
- dev/FSys_DeviceManager.cpp
+ setting/FSys_SettingInfo.cpp
+ setting/providers/FSys_SettingApplicationProvider.cpp
+ setting/providers/FSys_SettingFontProvider.cpp
+ setting/providers/FSys_SettingGeneralProvider.cpp
+ setting/providers/FSys_SettingLocaleProvider.cpp
+ setting/providers/FSys_SettingLocationProvider.cpp
+ setting/providers/FSys_SettingNetworkProvider.cpp
+ setting/providers/FSys_SettingScreenProvider.cpp
+ setting/providers/FSys_SettingSoundProvider.cpp
+ setting/providers/FSys_SettingSpeechProvider.cpp
+ setting/providers/FSys_SettingStorageProvider.cpp
+ setting/providers/FSys_SettingVibrationProvider.cpp
)
INCLUDE(FindPkgConfig)
SOVERSION ${MAJORVER}
CLEAN_DIRECT_OUTPUT 1
)
+
ADD_CUSTOM_COMMAND(TARGET ${this_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER}
--- /dev/null
+#ifndef _FSYS_SETTING_INFO_INTERNAL_H_
+#define _FSYS_SETTING_INFO_INTERNAL_H_
+
+#include <pthread.h>
+
+#include <FBaseColArrayListT.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseSysLog.h>
+#include <FBaseString.h>
+#include <FSysISettingEventListener.h>
+#include <FSysISettingInfoSetValueAsyncResultListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _ISettingProvider;
+
+class _OSP_EXPORT_ _SettingInfo
+{
+private:
+ _SettingInfo();
+ ~_SettingInfo();
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+public:
+ static _SettingInfo* GetInstance(void);
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result GetValue(const Tizen::Base::String& key, int& value);
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ bool HasKey(const Tizen::Base::String& key);
+ result SetValue(const Tizen::Base::String& key, bool value);
+ result SetValue(const Tizen::Base::String& key, int value);
+ result SetValue(const Tizen::Base::String& key, Tizen::Base::String value);
+ result AddSettingEventListener(ISettingEventListener& listener);
+ result RemoveSettingEventListener(ISettingEventListener& listener);
+ result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+ result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+ result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
+ result ResetToFactoryDefault(void);
+
+ result AnnounceSettingEvent(const Tizen::Base::String& key);
+
+private:
+ result RegisterProvider(const Tizen::Base::String& key, _ISettingProvider* provider);
+ result UnregisterProvider(const Tizen::Base::String& key);
+ _ISettingProvider* GetProvider(const Tizen::Base::String& key);
+ result RemoveProvider(const Tizen::Base::String key);
+
+private:
+ static _SettingInfo* __pSettingInfo;
+
+private:
+ Tizen::Base::Collection::HashMapT<Tizen::Base::String, _ISettingProvider*> __settingProviderList;
+ Tizen::Base::Collection::ArrayListT< ISettingEventListener* > __settingEventList;
+
+ class _StringHashProvider
+ : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
+ {
+ public:
+ virtual int GetHashCode(const Tizen::Base::String& value) const
+ {
+ return value.GetHashCode();
+ }
+ };
+
+ class _StringComparer
+ : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
+ {
+ public:
+ virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
+ {
+ cmp = string1.CompareTo(string2);
+ return E_SUCCESS;
+ }
+ };
+};
+
+}}
+#endif
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingInfo.cpp
+ * @brief This is the implementation file for _SettingInfo class.
+ */
+
+#include <new>
+#include <stdlib.h>
+#include <unistd.h>
+#include <unique_ptr.h>
+#include <sysman.h>
+
+#include <FBaseColIEnumeratorT.h>
+#include <FIoFile.h>
+
+#include "providers/FSys_ISettingProvider.h"
+#include "FSys_SettingInfo.h"
+
+//providers
+#include "providers/FSys_SettingApplicationProvider.h"
+#include "providers/FSys_SettingFontProvider.h"
+#include "providers/FSys_SettingGeneralProvider.h"
+#include "providers/FSys_SettingLocaleProvider.h"
+#include "providers/FSys_SettingLocationProvider.h"
+#include "providers/FSys_SettingNetworkProvider.h"
+#include "providers/FSys_SettingScreenProvider.h"
+#include "providers/FSys_SettingSoundProvider.h"
+#include "providers/FSys_SettingSpeechProvider.h"
+#include "providers/FSys_SettingStorageProvider.h"
+#include "providers/FSys_SettingVibrationProvider.h"
+
+using namespace std;
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const String _SETTING_APPLICATION_PROVIDER(L"application");
+static const String _SETTING_FONT_PROVIDER(L"font");
+static const String _SETTING_DEVICE_NAME_PROVIDER(L"device_name");
+static const String _SETTING_MOTION_PROVIDER(L"motion");
+static const String _SETTING_CONTACTS_PROVIDER(L"contacts");
+static const String _SETTING_DEVELOPER_PROVIDER(L"developer");
+static const String _SETTING_BATTERY_PROVIDER(L"battery");
+static const String _SETTING_GRAPHICS_PROVIDER(L"graphics");
+static const String _SETTING_LOCALE_PROVIDER(L"locale");
+static const String _SETTING_LOCATION_PROVIDER(L"location");
+static const String _SETTING_NETWORK_PROVIDER(L"network");
+static const String _SETTING_SCREEN_PROVIDER(L"screen");
+static const String _SETTING_SOUND_PROVIDER(L"sound");
+static const String _SETTING_SPEECH_PROVIDER(L"speech");
+static const String _SETTING_STORAGE_PROVIDER(L"storage");
+static const String _SETTING_VIBRATION_PROVIDER(L"vibration");
+
+static const wchar_t* _SETTING_PREFIX = L"http://tizen.org/setting/";
+
+_SettingInfo* _SettingInfo::__pSettingInfo = null;
+static const char* _BIN_FACTORY_RESET = "/usr/bin/factory-reset";
+
+_SettingInfo::_SettingInfo()
+{
+ static _StringHashProvider hashProvider;
+ static _StringComparer stringComparer;
+ __settingProviderList.Construct(0, 0, hashProvider, stringComparer);
+
+ _SettingApplicationProvider* applicationProvider = new (std::nothrow) _SettingApplicationProvider();
+ RegisterProvider(_SETTING_APPLICATION_PROVIDER, (_ISettingProvider*)applicationProvider);
+
+ _SettingFontProvider* fontProvider = new (std::nothrow) _SettingFontProvider();
+ RegisterProvider(_SETTING_FONT_PROVIDER, (_ISettingProvider*)fontProvider);
+
+ _SettingGeneralProvider* generalProvider = new (std::nothrow) _SettingGeneralProvider();
+ RegisterProvider(_SETTING_DEVICE_NAME_PROVIDER, (_ISettingProvider*)generalProvider);
+ RegisterProvider(_SETTING_MOTION_PROVIDER, (_ISettingProvider*)generalProvider);
+ RegisterProvider(_SETTING_CONTACTS_PROVIDER, (_ISettingProvider*)generalProvider);
+ RegisterProvider(_SETTING_DEVELOPER_PROVIDER, (_ISettingProvider*)generalProvider);
+ RegisterProvider(_SETTING_BATTERY_PROVIDER, (_ISettingProvider*)generalProvider);
+ RegisterProvider(_SETTING_GRAPHICS_PROVIDER, (_ISettingProvider*)generalProvider);
+
+ _SettingLocaleProvider* localeProvider = new (std::nothrow) _SettingLocaleProvider();
+ RegisterProvider(_SETTING_LOCALE_PROVIDER, (_ISettingProvider*)localeProvider);
+
+ _SettingLocationProvider* locationProvider = new (std::nothrow) _SettingLocationProvider();
+ RegisterProvider(_SETTING_LOCATION_PROVIDER, (_ISettingProvider*)locationProvider);
+
+ _SettingNetworkProvider* networkProvider = new (std::nothrow) _SettingNetworkProvider();
+ RegisterProvider(_SETTING_NETWORK_PROVIDER, (_ISettingProvider*)networkProvider);
+
+ _SettingScreenProvider* screenProvider = new (std::nothrow) _SettingScreenProvider();
+ RegisterProvider(_SETTING_SCREEN_PROVIDER, (_ISettingProvider*)screenProvider);
+
+ _SettingSoundProvider* soundProvider = new (std::nothrow) _SettingSoundProvider();
+ RegisterProvider(_SETTING_SOUND_PROVIDER, (_ISettingProvider*)soundProvider);
+
+ _SettingSpeechProvider* speechProvider = new (std::nothrow) _SettingSpeechProvider();
+ RegisterProvider(_SETTING_SPEECH_PROVIDER, (_ISettingProvider*)speechProvider);
+
+ _SettingStorageProvider* storageProvider = new (std::nothrow) _SettingStorageProvider();
+ RegisterProvider(_SETTING_STORAGE_PROVIDER, (_ISettingProvider*)storageProvider);
+
+ _SettingVibrationProvider* vibrationProvider = new (std::nothrow) _SettingVibrationProvider();
+ RegisterProvider(_SETTING_VIBRATION_PROVIDER, (_ISettingProvider*)vibrationProvider);
+
+ __settingEventList.Construct();
+}
+
+_SettingInfo::~_SettingInfo()
+{
+ RemoveProvider(_SETTING_APPLICATION_PROVIDER);
+ RemoveProvider(_SETTING_FONT_PROVIDER);
+ UnregisterProvider(_SETTING_MOTION_PROVIDER);
+ UnregisterProvider(_SETTING_CONTACTS_PROVIDER);
+ UnregisterProvider(_SETTING_DEVELOPER_PROVIDER);
+ UnregisterProvider(_SETTING_BATTERY_PROVIDER);
+ UnregisterProvider(_SETTING_GRAPHICS_PROVIDER);
+ RemoveProvider(_SETTING_LOCALE_PROVIDER);
+ RemoveProvider(_SETTING_LOCATION_PROVIDER);
+ RemoveProvider(_SETTING_NETWORK_PROVIDER);
+ RemoveProvider(_SETTING_SCREEN_PROVIDER);
+ RemoveProvider(_SETTING_SOUND_PROVIDER);
+ RemoveProvider(_SETTING_SPEECH_PROVIDER);
+ RemoveProvider(_SETTING_STORAGE_PROVIDER);
+ RemoveProvider(_SETTING_VIBRATION_PROVIDER);
+ __settingProviderList.RemoveAll();
+}
+
+result
+_SettingInfo::RemoveProvider(const String key)
+{
+ _ISettingProvider* pProvider = null;
+
+ pProvider = GetProvider(key);
+ if(pProvider != null)
+ {
+ UnregisterProvider(key);
+ delete pProvider;
+ return E_SUCCESS;
+ }
+ return E_SYSTEM;
+}
+
+_SettingInfo*
+_SettingInfo::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+ if(__pSettingInfo == null)
+ {
+ pthread_once(&onceBlock, InitSingleton);
+ }
+ return __pSettingInfo;
+}
+
+void
+_SettingInfo::InitSingleton(void)
+{
+ _SettingInfo* pSettingInfo = new (std::nothrow) _SettingInfo();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
+ GetErrorMessage(E_OUT_OF_MEMORY));
+
+ __pSettingInfo = pSettingInfo;
+ atexit(DestroySingleton);
+}
+
+void
+_SettingInfo::DestroySingleton(void)
+{
+ delete __pSettingInfo;
+}
+
+_ISettingProvider*
+_SettingInfo::GetProvider(const String& key)
+{
+ int index = 0;
+ String requiredKey;
+ String prefix(_SETTING_PREFIX);
+ _ISettingProvider* provider = null;
+
+ key.SubString(prefix.GetLength(), requiredKey);
+ key.IndexOf(L".", 0, index);
+ requiredKey.SubString(index, requiredKey);
+ result r = __settingProviderList.GetValue(requiredKey, provider);
+
+ if(r != E_SUCCESS || provider == null)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to find proper provider for required key(%ls).", key.GetPointer());
+ return null;
+ }
+
+ return provider;
+}
+
+result
+_SettingInfo::GetValue(const String& key, String& value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->GetValue(key, value);
+}
+
+result
+_SettingInfo::GetValue(const String& key, int& value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->GetValue(key, value);
+}
+
+result
+_SettingInfo::GetValue(const String& key, bool& value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->GetValue(key, value);
+}
+
+bool HasKey(const String& key)
+{
+ return false;
+}
+
+result
+_SettingInfo::SetValue(const String& key, bool value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValue(key, value);
+}
+
+result
+_SettingInfo::SetValue(const String& key, int value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValue(key, value);
+}
+
+result
+_SettingInfo::SetValue(const String& key, String value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValue(key, value);
+}
+
+result
+_SettingInfo::AddSettingEventListener(ISettingEventListener& listener)
+{
+ return __settingEventList.Add(&listener);
+}
+
+result
+_SettingInfo::RemoveSettingEventListener(ISettingEventListener& listener)
+{
+ return __settingEventList.Remove(&listener);
+}
+
+result
+_SettingInfo::AnnounceSettingEvent(const String& key)
+{
+ IEnumeratorT< ISettingEventListener*>* pEnum = __settingEventList.GetEnumeratorN();
+ SysTryReturnResult(NID_SYS, pEnum != null, E_SYSTEM, "It is failed to get event listener list.");
+
+ while(pEnum->MoveNext() == E_SUCCESS)
+ {
+ ISettingEventListener* pEventListener = null;
+ pEnum->GetCurrent(pEventListener);
+
+ if(pEventListener != null)
+ {
+ String eventKey = key;
+ pEventListener->OnSettingChanged(eventKey);
+ }
+ }
+
+ delete pEnum;
+ return E_SUCCESS;
+}
+
+result
+_SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->GetValueForPrivilegedKey(key, value);
+}
+
+result
+_SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValueForPrivilegedKey(key, value);
+}
+
+result
+_SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValueAsyncForPrivilegedKey(key, value, listener);
+}
+
+result
+_SettingInfo::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValueAsyncForPrivilegedKey(key, value, listener);
+}
+
+result
+_SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
+{
+ _ISettingProvider* provider = GetProvider(key);
+ SysTryReturnResult(NID_SYS, provider != null, E_SYSTEM, "It is failed to find provider.");
+ return provider->SetValueForPrivilegedKey(key, value);
+}
+
+result
+_SettingInfo::ResetToFactoryDefault(void)
+{
+ SysTryReturnResult(NID_SYS, File::IsFileExist(_BIN_FACTORY_RESET) == true, E_UNSUPPORTED_OPERATION, "Current device does not support factory reset.");
+ SysTryReturnResult(NID_SYS, sysman_call_predef_action("launchfr", 0, NULL) == 0, E_SYSTEM, "It is failed to execute factory reset.");
+ return E_SUCCESS;
+}
+
+result
+_SettingInfo::RegisterProvider(const String& key, _ISettingProvider* provider)
+{
+ bool exist = false;
+ result r = __settingProviderList.ContainsKey(key, exist);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to check required key(%ls).", key.GetPointer());
+ SysTryReturnResult(NID_SYS, exist == false, E_OBJ_ALREADY_EXIST, "It is already registered key(%ls).", key.GetPointer());
+
+ r = __settingProviderList.Add(key, provider);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to add required key(%ls).", key.GetPointer());
+ return E_SUCCESS;
+}
+
+result
+_SettingInfo::UnregisterProvider(const String& key)
+{
+ bool exist = false;
+ result r = __settingProviderList.ContainsKey(key, exist);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to check required key(%ls).", key.GetPointer());
+ SysTryReturnResult(NID_SYS, exist == true, E_OBJ_NOT_FOUND, "It is already registered key(%ls).", key.GetPointer());
+
+ r = __settingProviderList.Remove(key);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to remove required key(%ls).", key.GetPointer());
+ return E_SUCCESS;
+}
+
+} }
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_ISettingProvider.h
+ * @brief This is the header file for the %_ISettingProvider class.
+ *
+ * This header file contains the declarations of the %_ISettingProvider class.
+ */
+
+#ifndef _FSYS_ISETTING_PROVIDER_INTERNAL_H_
+#define _FSYS_ISETTING_PROVIDER_INTERNAL_H_
+
+#include <FBaseString.h>
+#include <FSysISettingInfoSetValueAsyncResultListener.h>
+#include <FSysISettingEventListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _ISettingProvider
+{
+public:
+ virtual bool HasKey(const Tizen::Base::String& key)
+ {
+ return false;
+ }
+
+ virtual result GetValue(const Tizen::Base::String& key, int& value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result GetValue(const Tizen::Base::String& key, bool& value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValue(const Tizen::Base::String& key, int value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValue(const Tizen::Base::String& key, bool value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValue(const Tizen::Base::String& key, Tizen::Base::String value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ virtual result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value)
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+}; // _ISettingProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_PROVIDER_LISTENER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_Icu.cpp
+ * @brief This is the implementation file for _Icu class.
+ */
+
+#include <stdlib.h>
+#include <memory.h>
+
+#include <FBaseSysLog.h>
+#include <FBase_NativeError.h>
+#include "FSys_Icu.h"
+
+namespace Tizen { namespace System
+{
+
+static const int _MAX_COUNTRY_LENTH = 2;
+static const int _LANGUAGE_START_INDEX = 0;
+static const int _MAX_LANGUAGE_LENTH = 2;
+
+_Icu::_Icu()
+{
+}
+
+_Icu::~_Icu()
+{
+}
+
+char*
+_Icu::GetIcuPatternN(const char* pLocale, UChar* pCustomSkeleton)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UDateTimePatternGenerator* pGenerator = null;
+ UChar bestPattern[64] = {0,};
+
+ if(pLocale == null || pCustomSkeleton == null)
+ {
+ return null;
+ }
+
+ char* pBestPatternString = null;
+ int32_t bestPatternCapacity = 0;
+ int32_t bestPatternLength = 0;
+
+ pGenerator = udatpg_open(pLocale, &status);
+
+ if (U_FAILURE(status) == true)
+ {
+ return null;
+ }
+
+ status = U_ZERO_ERROR;
+
+ bestPatternCapacity = (int32_t)(sizeof(bestPattern)/sizeof((bestPattern)[0]));
+ bestPatternLength = udatpg_getBestPattern(pGenerator, pCustomSkeleton, u_strlen(pCustomSkeleton), bestPattern, bestPatternCapacity, &status);
+ if (U_FAILURE(status) == true)
+ {
+ return null;
+ }
+
+ status = U_ZERO_ERROR;
+ pBestPatternString = (char*)malloc(128);
+ if (pBestPatternString == null)
+ {
+ return null;
+ }
+ memset(pBestPatternString, 0, 128);
+ u_austrncpy(pBestPatternString, bestPattern, 128);
+ udatpg_close(pGenerator);
+ SysLog(NID_SYS, "Format is [%s] \n", pBestPatternString);
+ return pBestPatternString;
+}
+
+char*
+_Icu::GetDateTimeFormatN(const char* pIcuFormat)
+{
+ char* pFormatString = null;
+ char* pDateTimeFormat = null;
+
+ if (pIcuFormat == null)
+ {
+ return null;
+ }
+
+ UChar customSkeleton[256] = {0, };
+ const char* pLocaleDefault = uloc_getDefault();
+
+ pDateTimeFormat = const_cast< char* > (pLocaleDefault);
+
+ u_uastrncpy(customSkeleton, pIcuFormat, sizeof(customSkeleton));
+ pFormatString = GetIcuPatternN(pDateTimeFormat, customSkeleton);
+
+ return pFormatString;
+}
+
+} } // Tizen::System
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_Icu.h
+ * @brief This is the header file for _Icu class.
+ */
+
+
+#include <unicode/ustring.h>
+#include <unicode/uloc.h>
+#include <unicode/utypes.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/locid.h>
+
+namespace Tizen { namespace System
+{
+// ICU
+static const char* _ICU_DATE_FORMAT = "yMMMMEEEEd";
+static const char* _ICU_TIME_24_FORMAT = "Hms";
+static const char* _ICU_TIME_12_FORMAT = "hms";
+
+class _Icu
+{
+public:
+ _Icu();
+ virtual ~_Icu();
+ char* GetIcuPatternN(const char* pLocale, UChar* pCustomSkeleton);
+ char* GetDateTimeFormatN(const char* pIcuFormat);
+};
+} } // Tizen::System
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingApplicationProvider.cpp
+ * @brief This is the implementation for the _SettingApplicationProvider class.
+ */
+#include <unique_ptr.h>
+
+#include <FApp.h>
+#include <FApp_Aul.h>
+#include <FBase_StringConverter.h>
+
+#include <FBaseString.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingApplicationProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _APPLICATION_HOME = L"http://tizen.org/setting/application.home";
+static const wchar_t* _APPLICATION_LOCK = L"http://tizen.org/setting/application.lock";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingApplicationProvider::_SettingApplicationProvider()
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for home application change.");
+ }
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for lock application change.");
+ }
+}
+
+_SettingApplicationProvider::~_SettingApplicationProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister event listen for home application change.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister event listen for lock application change.");
+ }
+}
+
+bool
+_SettingApplicationProvider::HasKey(const String& key)
+{
+ if(key == _APPLICATION_HOME)
+ {
+ unique_ptr<char, charDeleter> pPackageName(vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME));
+
+ if(pPackageName.get() != null)
+ {
+ return true;
+ }
+ }
+ else if(key == _APPLICATION_LOCK)
+ {
+ unique_ptr<char, charDeleter> pPackageName(vconf_get_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR));
+
+ if(pPackageName.get() != null)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+result
+_SettingApplicationProvider::GetValue(const String& key, String& value)
+{
+ result r = E_OBJ_NOT_FOUND;
+
+ SysLog(NID_SYS, "Key[%ls] is required.", key.GetPointer());
+ if(key == _APPLICATION_HOME)
+ {
+ unique_ptr<char, charDeleter> pPackageName(vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME));
+ SysLog(NID_SYS, "Value for Key[%ls] is %s.", key.GetPointer(), pPackageName.get());
+ SysTryReturnResult(NID_SYS, pPackageName != null, E_UNSUPPORTED_OPERATION, "It is failed to get package name of home application.");
+ value.Clear();
+ value.Append(pPackageName.get());
+ r = E_SUCCESS;
+ }
+ else if(key == _APPLICATION_LOCK)
+ {
+ unique_ptr<char, charDeleter> pPackageName(vconf_get_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR));
+ SysLog(NID_SYS, "Value for Key[%ls] is %s.", key.GetPointer(), pPackageName.get());
+ SysTryReturnResult(NID_SYS, pPackageName != null, E_UNSUPPORTED_OPERATION, "It is failed to get package name of lock application.");
+ value.Clear();
+ value.Append(pPackageName.get());
+ r = E_SUCCESS;
+ }
+
+ return r;
+}
+
+result
+_SettingApplicationProvider::SetValueForPrivilegedKey(const String& key, String value)
+{
+ result r = E_OBJ_NOT_FOUND;
+
+ int errorCode = 0;
+
+ if(key == _APPLICATION_HOME)
+ {
+ bool installed = _Aul::IsInstalled(value);
+ SysTryReturnResult(NID_SYS, installed == true, E_INVALID_ARG, "Specified application[%ls] is not installed.", value.GetPointer());
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support home application.");
+ r = E_SUCCESS;
+
+ unique_ptr<char []> pPackageName(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, pPackageName.get() != null, E_SYSTEM, "It is failed to get string of specified value[%ls].", value.GetPointer());
+ SysLog(NID_SYS, "Value for Key[%ls] is %s.", key.GetPointer(), pPackageName.get());
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, pPackageName.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set home application.");
+ }
+ else if(key == _APPLICATION_LOCK)
+ {
+ bool installed = _Aul::IsInstalled(value);
+ SysTryReturnResult(NID_SYS, installed == true, E_INVALID_ARG, "Specified application[%ls] is not installed.", value.GetPointer());
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support lock application.");
+ r = E_SUCCESS;
+
+ unique_ptr<char []> pPackageName(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, pPackageName.get() != null, E_SYSTEM, "It is failed to get string of specified value[%ls].", value.GetPointer());
+ SysLog(NID_SYS, "Value for Key[%ls] is %s.", key.GetPointer(), pPackageName.get());
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, pPackageName.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set lock application.");
+ }
+ return r;
+}
+
+void
+_SettingApplicationProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ if(strcmp(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_APPLICATION_HOME);
+ }
+ else if(strcmp(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_APPLICATION_LOCK);
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "There is no reserved key [%s].", vconf_keynode_get_name(node));
+ return;
+ }
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingApplicationProvider.h
+ * @brief This is the header file for the %_SettingApplicationProvider class.
+ *
+ * This header file contains the declarations of the %_SettingApplicationProvider class.
+ */
+
+#ifndef _FSYS_SETTING_APPLICATION_PROVIDER_INTERNAL_H_
+#define _FSYS_SETTING_APPLICATION_PROVIDER_INTERNAL_H_
+
+#include <vconf.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingApplicationProvider
+ : _ISettingProvider
+{
+public:
+ _SettingApplicationProvider();
+ virtual ~_SettingApplicationProvider();
+
+public:
+ bool HasKey(const Tizen::Base::String& key);
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
+
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+
+}; // _SettingApplicationProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_APPLICATION_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingFontProvider.cpp
+ * @brief This is the implementation for the _SettingFontProvider class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include <FBase_StringConverter.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingFontProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _FONT_SIZE = L"http://tizen.org/setting/font.size";
+static const wchar_t* _FONT_TYPE = L"http://tizen.org/setting/font.type";
+
+static const wchar_t* _FONT_SIZE_GIANT = L"giant";
+static const wchar_t* _FONT_SIZE_HUGE = L"huge";
+static const wchar_t* _FONT_SIZE_LARGE = L"large";
+static const wchar_t* _FONT_SIZE_MEDIUM = L"medium";
+static const wchar_t* _FONT_SIZE_SMALL = L"small";
+
+static const int _FONT_SIZE_GIANT_VCONF = 4;
+static const int _FONT_SIZE_HUGE_VCONF = 3;
+static const int _FONT_SIZE_LARGE_VCONF = 2;
+static const int _FONT_SIZE_MEDIUM_VCONF = 1;
+static const int _FONT_SIZE_SMALL_VCONF = 0;
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+bool
+_SettingFontProvider::HasKey(const Tizen::Base::String& key)
+{
+ if(key == _FONT_SIZE || key == _FONT_TYPE)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+_SettingFontProvider::_SettingFontProvider()
+{
+ int errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register font type event listener");
+ }
+
+ errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register font size event listener");
+ }
+}
+
+
+_SettingFontProvider::~_SettingFontProvider()
+{
+ int errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister font size event listener");
+ }
+
+ errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister font type event listener");
+ }
+}
+
+result
+_SettingFontProvider::GetValue(const String& key, String& value)
+{
+ SysTryReturnResult(NID_SYS, 0, E_SYSTEM, "[E_SYSTEM] It is not working.");
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _FONT_SIZE)
+ {
+ int fontSize = 0;
+ int res = 0;
+ res = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &fontSize);
+ SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to get font size.");
+ SysLog(NID_SYS, "current font size is %d.", fontSize);
+
+ r = E_SUCCESS;
+ switch (fontSize)
+ {
+ case _FONT_SIZE_GIANT_VCONF:
+ value.Append(_FONT_SIZE_GIANT);
+ break;
+ case _FONT_SIZE_HUGE_VCONF:
+ value.Append(_FONT_SIZE_HUGE);
+ break;
+ case _FONT_SIZE_LARGE_VCONF:
+ value.Append(_FONT_SIZE_LARGE);
+ break;
+ case _FONT_SIZE_MEDIUM_VCONF:
+ value.Append(_FONT_SIZE_MEDIUM);
+ break;
+ case _FONT_SIZE_SMALL_VCONF:
+ value.Append(_FONT_SIZE_SMALL);
+ break;
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ }
+ else if(key == _FONT_TYPE)
+ {
+ r = E_SUCCESS;
+ char* pTemp = null;
+ int res = 0;
+ res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &pTemp);
+ SysTryReturnResult(NID_SYS, pTemp != null, E_SYSTEM, "It is failed to get font type.");
+
+ unique_ptr<char, charDeleter> pFontType(pTemp);
+ SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to get font type.");
+ SysLog(NID_SYS, "current font type is %s.", pTemp);
+ r = StringUtil::Utf8ToString(pFontType.get(), value);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to convert font type to Utf8.");
+ }
+
+ return r;
+}
+
+result
+_SettingFontProvider::SetValue(const String& key, const String value)
+{
+ SysTryReturnResult(NID_SYS, 0, E_SYSTEM, "[E_SYSTEM] It is not working.");
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _FONT_SIZE)
+ {
+ int fontSize = 0;
+ int res = 0;
+ String lowerValue = value;
+ lowerValue.ToLowerCase();
+ r = E_SUCCESS;
+
+ if (lowerValue == _FONT_SIZE_GIANT)
+ {
+ fontSize = _FONT_SIZE_GIANT_VCONF;
+ }
+ else if (lowerValue == _FONT_SIZE_HUGE)
+ {
+ fontSize = _FONT_SIZE_HUGE_VCONF;
+ }
+ else if (lowerValue == _FONT_SIZE_LARGE)
+ {
+ fontSize = _FONT_SIZE_LARGE_VCONF;
+ }
+ else if (lowerValue == _FONT_SIZE_MEDIUM)
+ {
+ fontSize = _FONT_SIZE_MEDIUM_VCONF;
+ }
+ else if (lowerValue == _FONT_SIZE_SMALL)
+ {
+ fontSize = _FONT_SIZE_SMALL_VCONF;
+ }
+ else
+ {
+ return E_INVALID_ARG;
+ }
+ res = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, fontSize);
+ SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font size.");
+ }
+ else if(key == _FONT_TYPE)
+ {
+ int res = 0;
+ r = E_SUCCESS;
+
+ unique_ptr<char []> pFontType(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, pFontType.get() != null, E_SYSTEM, "It is failed to convert String to string.");
+ SysLog(NID_SYS, "Requested font type is %s.", pFontType.get());
+ res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType.get());
+ if(res == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
+ {
+ return E_INVALID_ARG;
+ }
+ SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font type.");
+ }
+ return r;
+}
+
+void
+_SettingFontProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
+{
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ String settingKey;
+
+ switch (key)
+ {
+ case SYSTEM_SETTINGS_KEY_FONT_SIZE:
+ {
+ settingKey.Append(_FONT_SIZE);
+ break;
+ }
+ case SYSTEM_SETTINGS_KEY_FONT_TYPE:
+ {
+ settingKey.Append(_FONT_TYPE);
+ break;
+ }
+ default:
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "No required key[%d] is delivered", key);
+ return;
+ }
+ }
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingFontProvider.h
+ * @brief This is the header file for the %_SettingFontProvider class.
+ *
+ * This header file contains the declarations of the %_SettingFontProvider class.
+ */
+
+#ifndef _FSYS_SETTING_FONT_PROVIDER_INTERNAL_H_
+#define _FSYS_SETTING_FONT_PROVIDER_INTERNAL_H_
+
+#include <system/system_settings.h>
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingFontProvider
+ : _ISettingProvider
+{
+public:
+ _SettingFontProvider();
+ ~_SettingFontProvider();
+
+public:
+ bool HasKey(const Tizen::Base::String& key);
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, Tizen::Base::String value);
+
+private:
+ static void SettingEventSettingInfo(system_settings_key_e key, void* userData);
+}; // _SettingFontProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_FONT_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingGeneralProvider.cpp
+ * @brief This is the implementation for the _SettingGeneralProvider class.
+ */
+#include <unique_ptr.h>
+
+#include <Eina.h>
+#include <Elementary.h>
+
+#include <runtime_info.h>
+
+#include <FBase_StringConverter.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingGeneralProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace System
+{
+
+static const int _NUM_OF_GENERAL_PROVIDER = 6;
+
+static const wchar_t* _DEVICE_NAME = L"device_name";
+
+static const wchar_t* _MOTION_UI = L"motion.ui";
+
+static const wchar_t* _CONTACT_ORDER_FIRSTNAME = L"contacts.order.firstname";
+static const int _CONTACT_ORDER_FIRSTNAME_FIRSTLAST = 0;
+static const int _CONTACT_ORDER_FIRSTNAME_LASTFIRST = 1;
+
+static const wchar_t* _DEVELOPER_USBDEBUGGING = L"developer.usb_debugging";
+
+static const wchar_t* _BATTERY_FORMAT_PERCENTAGE = L"battery.format.percentage";
+
+static const wchar_t* _GRAPHICS_GPU_RENDERING = L"graphics.gpu.rendering";
+static const char* _GRAPHICS_GPU_RENDERING_HW = "opengl_x11";
+static const char* _GRAPHICS_GPU_RENDERING_SW = "software_x11";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingGeneralProvider::_SettingGeneralProvider()
+ : currentMode(0)
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEVICE_NAME_STR event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL event listener.");
+ }
+
+ errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION event listener.");
+ }
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT event listener.");
+ }
+}
+
+
+_SettingGeneralProvider::~_SettingGeneralProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEVICE_NAME_STR event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL event listener.");
+ }
+
+ errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION event listener.");
+ }
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT event listener.");
+ }
+}
+
+result
+_SettingGeneralProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ SysLog(NID_SYS, "Key: %ls", key.GetPointer());
+ if (key == _MOTION_UI)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ int motion = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &motion);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_SETAPPL_MOTION_ACTIVATION.");
+ value = motion;
+ return r;
+ }
+ else if (key == _CONTACT_ORDER_FIRSTNAME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Contact ordering feature.");
+ r = E_SUCCESS;
+
+ int contactOrder = 0;
+ errorCode = vconf_get_int(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, &contactOrder);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER.");
+
+ if (contactOrder == _CONTACT_ORDER_FIRSTNAME_FIRSTLAST)
+ {
+ value = true;
+ }
+ else if (contactOrder == _CONTACT_ORDER_FIRSTNAME_LASTFIRST)
+ {
+ value = false;
+ }
+ else
+ {
+ return E_SYSTEM;
+ }
+ }
+ else if (key == _DEVELOPER_USBDEBUGGING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB debugging feature.");
+ r = E_SUCCESS;
+
+ int usbMode = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &usbMode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL.");
+ value = usbMode;
+ }
+ else if(key == _BATTERY_FORMAT_PERCENTAGE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support battery format feature.");
+ r = E_SUCCESS;
+
+ int batteryFormat = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &batteryFormat);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL.");
+ value = batteryFormat;
+ }
+ else if(key == _GRAPHICS_GPU_RENDERING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support GPU rendering feature.");
+ r = E_SUCCESS;
+
+ int gpu_rendering = 0;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, &gpu_rendering);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT.");
+ value = (gpu_rendering == SETTING_RENDERING_ENGINE_HW);
+ }
+ return r;
+}
+
+result
+_SettingGeneralProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ SysLog(NID_SYS, "Key: %ls, %d", key.GetPointer(), value);
+ if(key == _MOTION_UI)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set the VCONFKEY_SETAPPL_MOTION_ACTIVATION.");
+ }
+ else if (key == _CONTACT_ORDER_FIRSTNAME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ int contactOrder = 0;
+
+ if (value)
+ {
+ contactOrder = _CONTACT_ORDER_FIRSTNAME_FIRSTLAST;
+ }
+ else
+ {
+ contactOrder = _CONTACT_ORDER_FIRSTNAME_LASTFIRST;
+ }
+ errorCode = vconf_set_int(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, contactOrder);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER vconf");
+ }
+ else if(key == _BATTERY_FORMAT_PERCENTAGE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support battery format feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set the VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL.");
+ }
+ else if(key == _GRAPHICS_GPU_RENDERING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support GPU rendering feature.");
+ r = E_SUCCESS;
+
+ if(value == true)
+ {
+ elm_config_preferred_engine_set(_GRAPHICS_GPU_RENDERING_HW);
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, SETTING_RENDERING_ENGINE_HW);
+ }
+ else
+ {
+ elm_config_preferred_engine_set(_GRAPHICS_GPU_RENDERING_SW);
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, SETTING_RENDERING_ENGINE_SW);
+ }
+
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT.");
+ }
+ return r;
+}
+
+result
+_SettingGeneralProvider::SetValueForPrivilegedKey(const String& key, bool value)
+{
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _DEVELOPER_USBDEBUGGING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ int errorCode = vconf_set_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL vconf");
+ }
+ return r;
+}
+
+result
+_SettingGeneralProvider::GetValue(const String& key, String& value)
+{
+ result r = E_OBJ_NOT_FOUND;
+ if (key == _DEVICE_NAME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ unique_ptr<char, charDeleter> pDeviceName(vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR));
+ SysTryReturnResult(NID_SYS, pDeviceName.get() != null, E_SYSTEM, "It is failed to get device name.");
+
+ r = StringUtil::Utf8ToString(pDeviceName.get(), value);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "[%s] StringUtil::Utf8ToString is failed", GetErrorMessage(r));
+ }
+ return r;
+}
+
+result
+_SettingGeneralProvider::SetValue(const String& key, const String value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _DEVICE_NAME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ SysTryReturnResult(NID_SYS, value.GetLength() > 0 && value.GetLength() <= 128, E_INVALID_ARG, "Device name is too long")
+ unique_ptr<char []> deviceName(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, deviceName.get() != null, E_SYSTEM, "It is failed to convert String to string");
+
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, deviceName.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEVICE_NAME_STR vconf");
+ }
+ return r;
+}
+
+bool
+_SettingGeneralProvider::HasKey(const Tizen::Base::String& key)
+{
+ if(key == _DEVICE_NAME)
+ {
+ return true;
+ }
+ else if(key == _MOTION_UI)
+ {
+ return true;
+ }
+ else if(key == _CONTACT_ORDER_FIRSTNAME)
+ {
+ return true;
+ }
+ else if(key == _DEVELOPER_USBDEBUGGING)
+ {
+#ifndef _OSP_EMUL_
+ return true;
+#else
+ return false;
+#endif
+ }
+ else if(key == _GRAPHICS_GPU_RENDERING)
+ {
+ return true;
+ }
+ else if(key == _BATTERY_FORMAT_PERCENTAGE)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingGeneralProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
+{
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+ String settingKey;
+
+ if(key == SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION)
+ {
+ settingKey.Append(_MOTION_UI);
+ }
+ else
+ {
+ return;
+ }
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingGeneralProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+ String settingKey;
+
+ if (strcmp(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_DEVICE_NAME);
+ }
+ else if (strcmp(VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_CONTACT_ORDER_FIRSTNAME);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_DEVELOPER_USBDEBUGGING);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_BATTERY_FORMAT_PERCENTAGE);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_RENDERING_ENGINE_TYPE_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_GRAPHICS_GPU_RENDERING);
+ }
+ else
+ {
+ return;
+ }
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingGeneralProvider.h
+ * @brief This is the header file for the %_SettingGeneralProvider class.
+ *
+ * This header file contains the declarations of the %_SettingGeneralProvider class.
+ */
+
+#ifndef _FSYS_SETTING_GENERAL_PROVIDER_H_
+#define _FSYS_SETTING_GENERAL_PROVIDER_H_
+
+#include <vconf.h>
+#include <system/system_settings.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingGeneralProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingGeneralProvider();
+ virtual ~_SettingGeneralProvider();
+
+public:
+ bool HasKey(const Tizen::Base::String& key);
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+private:
+ int currentMode;
+
+private:
+ static void SettingEventSettingInfo(system_settings_key_e key, void* userData);
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingGeneralProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_GENERAL_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingLocaleProvider.cpp
+ * @brief This is the implementation for the _SettingLocaleProvider class.
+ */
+
+#include <unique_ptr.h>
+#include <sysman.h>
+#include <libxml/xpath.h>
+#include <libxml/tree.h>
+#include <locale.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FLocales.h>
+
+#include <FBase_StringConverter.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingLocaleProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Locales;
+
+namespace Tizen { namespace System
+{
+
+//Language and Region
+static const wchar_t* _LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country";
+static const wchar_t* _LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
+static const char* _LANGUAGE_LIST_FILE_PATH = "/opt/usr/data/setting/langlist.xml";
+
+//Format
+static const wchar_t* _LOCALE_DATE_FORMAT = L"http://tizen.org/setting/locale.date.format";
+static const wchar_t* _LOCALE_DATETIME_FORMAT = L"http://tizen.org/setting/locale.date_time.format";
+static const wchar_t* _LOCALE_TIME_FORMAT = L"http://tizen.org/setting/locale.time.format";
+static const wchar_t* _LOCALE_TIME_FORMAT_24HOUR = L"http://tizen.org/setting/locale.time.format.24hour";
+
+static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY = L"http://tizen.org/setting/locale.week.format.firstday";
+static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY = L"Monday";
+static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY = L"Sunday";
+
+static const int _LOCALE_WEEK_FORMAT_VCONF_SUNDAY = 0;
+static const int _LOCALE_WEEK_FORMAT_VCONF_MONDAY = 1;
+
+//Timezone
+static const wchar_t* _LOCALE_TIMEZONE = L"locale.time_zone";
+static const wchar_t* _LOCALE_UPDATE_AUTO= L"locale.update.auto";
+
+static const char* _LOCALE_TIMEZONE_ROOT_PATH = "/usr/share/zoneinfo/";
+static const char* _LOCALE_TIMEZONE_LINK = "/opt/etc/localtime";
+static const int _LOCALE_TIMEZONE_ROOT_PATH_LENGTH = 20;
+
+//Date time
+static const wchar_t* _LOCALE_DATE = L"locale.date";
+static const wchar_t* _LOCALE_TIME = L"locale.time";
+static const wchar_t* _LOCALE_DATETIME = L"locale.date_time";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingLocaleProvider::_SettingLocaleProvider()
+{
+ int errorCode = 0;
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_REGION, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register region event listener");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register language event listener");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register 24hour format event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_TIMEZONE_ID, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL event listener");
+ }
+}
+
+_SettingLocaleProvider::~_SettingLocaleProvider()
+{
+ int errorCode = 0;
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_REGION);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister region event listener");
+ }
+
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LANGUAGE);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register language event listener");
+ }
+
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register 24hour format event listener");
+ }
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TIMEZONE_ID, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_TIMEZONE_ID event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL event listener");
+ }
+}
+
+result
+_SettingLocaleProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _LOCALE_TIME_FORMAT_24HOUR)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support 24hour format feature.");
+ r = E_SUCCESS;
+ bool is24HoueEnabled = false;
+ errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, &is24HoueEnabled);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the SYSTEM_INFO_KEY__WIFI_SUPPORTED");
+ value = is24HoueEnabled;
+ }
+ else if (key == _LOCALE_UPDATE_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support locale auto update feature.");
+ r = E_SUCCESS;
+ int isAutomaticUpdate = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &isAutomaticUpdate);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL vconf");
+ if(isAutomaticUpdate == 1)
+ {
+ value = true;
+ }
+ else
+ {
+ value = false;
+ }
+ }
+ return r;
+}
+
+result
+_SettingLocaleProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _LOCALE_TIME_FORMAT_24HOUR)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support 24hour format feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_int(VCONFKEY_REGIONFORMAT_TIME1224, value ? VCONFKEY_TIME_FORMAT_24 : VCONFKEY_TIME_FORMAT_12);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_REGIONFORMAT_TIME1224 vconf");
+ }
+ else if(key == _LOCALE_UPDATE_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support locale auto update feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL vconf");
+ }
+ return r;
+}
+
+result
+_SettingLocaleProvider::GetValue(const String& key, String& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if (key == _LOCALE_COUNTRY || key == _LOCALE_LANGUAGE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support %ls feature.", key.GetPointer());
+ r = E_SUCCESS;
+
+ unique_ptr<char, charDeleter> pLocale(null);
+ char* pTemp = null;
+ runtime_info_key_e vconfKey = (key == _LOCALE_COUNTRY)
+ ? RUNTIME_INFO_KEY_REGION // Region locale
+ : RUNTIME_INFO_KEY_LANGUAGE; // Display language locale
+
+ errorCode = runtime_info_get_value_string(vconfKey, &pTemp);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE && pTemp != null, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_string [%ls] failed", key.GetPointer());
+ pLocale.reset(pTemp);
+ icu::Locale icuLocale(pLocale.get());
+ String localeString(icuLocale.getISO3Language());
+ String languageScriptTmp(icuLocale.getScript());
+
+ if (!languageScriptTmp.IsEmpty())
+ {
+ String languageScript;
+ languageScriptTmp.ToLowerCase(languageScript);
+ localeString.Append(L"-");
+ localeString.Append(languageScript);
+ }
+ localeString.Append("_");
+
+ localeString.Append(icuLocale.getCountry());
+
+ value = localeString;
+ }
+ else if ( key == _LOCALE_TIME_FORMAT)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support date format feature.");
+ r = E_SUCCESS;
+
+ unique_ptr<char, charDeleter> pTimeFormat(null);
+ char* pTemp = null;
+ bool selected24Format = false;
+
+ r = GetValue(_LOCALE_TIME_FORMAT_24HOUR, selected24Format);
+
+ if (selected24Format == true)
+ {
+ pTemp = __icu.GetDateTimeFormatN(_ICU_TIME_24_FORMAT);
+ }
+ else
+ {
+ pTemp = __icu.GetDateTimeFormatN(_ICU_TIME_12_FORMAT);
+ }
+ SysTryReturnResult(NID_SYS, pTemp != null, E_SYSTEM, "Failed to get time format");
+ pTimeFormat.reset(pTemp);
+ r = StringUtil::Utf8ToString(pTimeFormat.get(), value);
+ }
+ else if ( key == _LOCALE_DATE_FORMAT)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support date format feature.");
+ r = E_SUCCESS;
+
+ unique_ptr<char, charDeleter> pDateFormat(__icu.GetDateTimeFormatN(_ICU_DATE_FORMAT));
+ SysTryReturnResult(NID_SYS, pDateFormat.get() != null, E_SYSTEM, "It is failed to get date format");
+
+ r = StringUtil::Utf8ToString(pDateFormat.get(), value);
+ }
+ else if (key == _LOCALE_DATETIME_FORMAT)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support date time format feature.");
+ r = E_SUCCESS;
+
+ unique_ptr<char, charDeleter> pDateFormat(__icu.GetDateTimeFormatN(_ICU_DATE_FORMAT));
+ unique_ptr<char, charDeleter> pTimeFormat(null);
+ char* pTemp = null;
+ String timeFormat;
+ bool selected24Format = false;
+
+ SysLog(NID_SYS, "Date Time format is %s.", pDateFormat.get());
+ SysTryReturnResult(NID_SYS, pDateFormat.get() != null, E_SYSTEM, "It is failed to get date format.");
+
+ r = GetValue(_LOCALE_TIME_FORMAT_24HOUR, selected24Format);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get time format.");
+
+ SysLog(NID_SYS, "24hour format, %d", selected24Format);
+
+ if (selected24Format == true)
+ {
+ pTemp = __icu.GetDateTimeFormatN(_ICU_TIME_24_FORMAT);
+ }
+ else
+ {
+ pTemp = __icu.GetDateTimeFormatN(_ICU_TIME_12_FORMAT);
+ }
+
+ SysTryReturnResult(NID_SYS, pTemp != null, E_SYSTEM, "It is failed to get time format.");
+ pTimeFormat.reset(pTemp);
+ r = StringUtil::Utf8ToString(pDateFormat.get(), value);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to convert string to UTF8.");
+ r = StringUtil::Utf8ToString(pTimeFormat.get(), timeFormat);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to convert string to UTF8.");
+
+ value.Append(" ");
+ value.Append(timeFormat);
+ }
+ else if (key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support week format feature.");
+ r = E_SUCCESS;
+
+ int firstDay = 0;
+ int errorCode = 0;
+
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, &firstDay);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT vconf");
+
+ if (firstDay == _LOCALE_WEEK_FORMAT_VCONF_SUNDAY)
+ {
+ value = _LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY;
+ }
+ else if (firstDay == _LOCALE_WEEK_FORMAT_VCONF_MONDAY)
+ {
+ value = _LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY;
+ }
+ else
+ {
+ r = E_SYSTEM;
+ }
+ }
+ else if (key == _LOCALE_TIMEZONE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support time zone feature.");
+ r = E_SUCCESS;
+
+ char pTZPath[256] = {0,};
+ ssize_t nLen = readlink(_LOCALE_TIMEZONE_LINK, pTZPath, sizeof(pTZPath)-1);
+ if (nLen != -1)
+ {
+ pTZPath[nLen] = '\0';
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to get timezone");
+ }
+ value.Clear();
+ value.Append(&pTZPath[_LOCALE_TIMEZONE_ROOT_PATH_LENGTH]);
+ }
+ else if (key == _LOCALE_DATE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support date feature.");
+ r = E_SUCCESS;
+
+ DateTime currentTime;
+ SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
+ String currentFormat;
+ GetValue(_LOCALE_DATE_FORMAT, currentFormat);
+
+ unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
+ SysTryReturnResult(NID_SYS, pFormatter != null, E_OUT_OF_MEMORY, "It is failed to create DateTimeFomatter");
+ pFormatter->ApplyPattern(currentFormat);
+ value.Clear();
+ pFormatter->Format(currentTime, value);
+ }
+ else if (key == _LOCALE_DATETIME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support date time feature.");
+ r = E_SUCCESS;
+
+ DateTime currentTime;
+ SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
+ String currentFormat;
+ GetValue(_LOCALE_DATETIME_FORMAT, currentFormat);
+
+ unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
+ pFormatter->ApplyPattern(currentFormat);
+ value.Clear();
+ pFormatter->Format(currentTime, value);
+ }
+ else if (key == _LOCALE_TIME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support time feature.");
+ r = E_SUCCESS;
+
+ DateTime currentTime;
+ SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
+ String currentFormat;
+ GetValue(_LOCALE_TIME_FORMAT, currentFormat);
+
+ unique_ptr<DateTimeFormatter> pFormatter(DateTimeFormatter::CreateTimeFormatterN());
+ pFormatter->ApplyPattern(currentFormat);
+ value.Clear();
+ pFormatter->Format(currentTime, value);
+ }
+ return r;
+}
+
+result
+_SettingLocaleProvider::SetValue(const String& key, const String value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _LOCALE_COUNTRY || key == _LOCALE_LANGUAGE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support locale country selection feature.");
+
+ r = E_SUCCESS;
+
+ unique_ptr<char []> lang (_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, lang != null, E_SYSTEM, "It is failed to convert String to string");
+
+ icu::Locale locale(lang.get());
+ errorCode = locale.isBogus();
+ SysTryReturnResult(NID_SYS, errorCode == 0 && IsValidLocaleString(value, locale) == true, E_INVALID_ARG, "Unknown language format");
+
+ std::string localeCode(locale.getLanguage());
+ localeCode.append("_");
+ localeCode.append(locale.getCountry());
+
+ const char* vconfKey = null;
+
+ if (key == _LOCALE_LANGUAGE)
+ {
+ SysTryReturnResult(NID_SYS, IsSupportedDisplayLanguageLocale(localeCode.c_str()),
+ E_INVALID_ARG, "It is not the supported display language locale [%s].", localeCode.c_str());
+ vconfKey = VCONFKEY_LANGSET;
+ localeCode.append(".utf8");
+ }
+ else if (key == _LOCALE_COUNTRY)
+ {
+ localeCode.append(".utf8");
+ SysTryReturnResult(NID_SYS, IsSupportedRegionLocale(localeCode.c_str()),
+ E_INVALID_ARG, "It is not the supported region locale [%s].", localeCode.c_str());
+ vconfKey = VCONFKEY_REGIONFORMAT;
+ }
+ errorCode = vconf_set_str(vconfKey, localeCode.c_str());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on %ls vconf",key.GetPointer());
+ r = E_SUCCESS;
+ }
+ else if(key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support week format selection feature.");
+ r = E_SUCCESS;
+
+ int firstDay = 0;
+
+ String sunday(_LOCALE_WEEK_FORMAT_FIRSTDAY_SUNDAY);
+ String monday(_LOCALE_WEEK_FORMAT_FIRSTDAY_MONDAY);
+
+ String requiredValue(value);
+ requiredValue.ToLowerCase();
+ sunday.ToLowerCase();
+ monday.ToLowerCase();
+
+ if (requiredValue == sunday)
+ {
+ firstDay = _LOCALE_WEEK_FORMAT_VCONF_SUNDAY;
+ }
+ else if (requiredValue == monday)
+ {
+ firstDay = _LOCALE_WEEK_FORMAT_VCONF_MONDAY;
+ }
+ else
+ {
+ return E_INVALID_ARG;
+ }
+
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, firstDay);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT vconf");
+ }
+ else if(key == _LOCALE_TIMEZONE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support time zone feature.");
+ r = E_SUCCESS;
+
+ LocaleManager localeManager;
+ localeManager.Construct();
+ unique_ptr<IList, AllElementsDeleter> pSupportedTimeZoneList(localeManager.GetAvailableTimeZonesN());
+
+ SysTryReturnResult(NID_SYS, pSupportedTimeZoneList != null, E_SYSTEM, "It is failed to get supported timezone list.");
+ SysTryReturnResult(NID_SYS, pSupportedTimeZoneList->Contains(value) == true, E_INVALID_ARG, "Specified timezone id[%S] is not valid", value.GetPointer());
+
+ unique_ptr<char []> tzpath (_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, tzpath != null, E_SYSTEM, "It is failed to convert String to string");
+ std::string tzStr(_LOCALE_TIMEZONE_ROOT_PATH);
+ tzStr.append(tzpath.get());
+ unique_ptr<char, charDeleter> cstrTzpath (strdup(tzStr.c_str()));
+ int errorCode = sysman_set_timezone(cstrTzpath.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set timezone");
+
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, cstrTzpath.get()+_LOCALE_TIMEZONE_ROOT_PATH_LENGTH);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set VCONFKEY_SETAPPL_TIMEZONE_ID vconf");
+
+ errorCode = vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, -1);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to notify to system about time changing");
+ }
+ return r;
+}
+
+bool
+_SettingLocaleProvider::HasKey(const Tizen::Base::String& key)
+{
+ if(key == _LOCALE_COUNTRY || key == _LOCALE_LANGUAGE)
+ {
+ return true;
+ }
+ else if(key == _LOCALE_DATE_FORMAT || key == _LOCALE_DATETIME_FORMAT || key == _LOCALE_TIME_FORMAT || key == _LOCALE_TIME_FORMAT_24HOUR || key == _LOCALE_WEEK_FORMAT_FIRSTDAY)
+ {
+ return true;
+ }
+ else if(key == _LOCALE_TIMEZONE || key == _LOCALE_UPDATE_AUTO)
+ {
+ return true;
+ }
+ else if(key == _LOCALE_DATE || key == _LOCALE_TIME || _LOCALE_DATETIME)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingLocaleProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
+{
+ result r = E_SUCCESS;
+ String settingKey;
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ if(key == RUNTIME_INFO_KEY_REGION)
+ {
+ settingKey = _LOCALE_DATE_FORMAT;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_DATETIME_FORMAT;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_TIME_FORMAT;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_COUNTRY;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ }
+ else if(key == RUNTIME_INFO_KEY_LANGUAGE)
+ {
+ settingKey.Append(_LOCALE_LANGUAGE);
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ }
+ else if(key == RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED)
+ {
+ settingKey = _LOCALE_DATETIME_FORMAT;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_TIME_FORMAT;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_TIME_FORMAT_24HOUR;
+ }
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingLocaleProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ result r = E_SUCCESS;
+ String settingKey;
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ if (strcmp(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCALE_WEEK_FORMAT_FIRSTDAY);
+ }
+ else if (strcmp(VCONFKEY_SYSTEM_TIME_CHANGED, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey = _LOCALE_DATETIME;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_DATE;
+ pSettingInfo->AnnounceSettingEvent(settingKey);
+ settingKey = _LOCALE_TIME;
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_TIMEZONE_ID, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCALE_TIMEZONE);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCALE_UPDATE_AUTO);
+ }
+ else
+ {
+ return;
+ }
+
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+bool
+_SettingLocaleProvider::IsValidLocaleString(const Tizen::Base::String& localeString, const icu::Locale& icuLocale)
+{
+ int indexOfScript = -1;
+ int indexOfCountryCode = -1;
+
+ localeString.IndexOf(L"-", 0, indexOfScript);
+ localeString.IndexOf(L"_", 0, indexOfCountryCode);
+
+ SysTryReturnResult(NID_SYS, indexOfCountryCode == 3 || (indexOfScript == 3 && indexOfCountryCode == 8)
+ , E_INVALID_ARG, "localeString %ls is invalid.", localeString.GetPointer());
+
+ // Tizen locale format languageCode-scriptCode_countryCode (ex: aze-latn_AZ)
+ String languageCode;
+ String scriptCode;
+ String countryCode;
+
+ localeString.SubString(0, 3, languageCode);
+
+ if (indexOfScript == 3)
+ {
+ localeString.SubString(4, 4, scriptCode);
+ }
+
+ int countryCodeLength = (localeString.Contains(L"419") == true) ? 3 : 2;
+ int countryCodeIndex = (indexOfCountryCode == 3) ? 4 : 9;
+
+ localeString.SubString(countryCodeIndex, countryCodeLength, countryCode);
+
+ // icu locale format languageCode_ScriptCode_countryCode (ex: az_Latn_AZ)
+ String icuLanguageCode(icuLocale.getISO3Language());
+ String icuScriptCode(icuLocale.getScript());
+ String icuCountryCode(icuLocale.getCountry());
+
+ if (!icuScriptCode.IsEmpty())
+ {
+ icuScriptCode.ToLowerCase();
+ }
+
+ if (languageCode == icuLanguageCode && scriptCode == icuScriptCode && countryCode == icuCountryCode)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool
+_SettingLocaleProvider::IsSupportedDisplayLanguageLocale(const char* localeId)
+{
+ xmlDocPtr doc = null;
+ xmlNodePtr cur = null;
+
+ doc = xmlParseFile(_LANGUAGE_LIST_FILE_PATH);
+ SysTryCatch(NID_SYS, doc != null, , E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the langlist from the resource.");
+
+ cur = xmlDocGetRootElement(doc);
+ SysTryCatch(NID_SYS, cur != null, , E_EMPTY_BODY, "[E_EMPTY_BODY] It is empty document.");
+ SysTryCatch(NID_SYS, xmlStrcmp(cur->name, (const xmlChar *) "langlist") == 0, , E_INVALID_CONTENT, "[E_INVALID_CONTENT] The document is wrong type");
+
+ cur = cur->xmlChildrenNode;
+
+ for (xmlNodePtr cur_node = cur; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE)
+ {
+ char* pLocId = (char*)xmlGetProp(cur_node, (const xmlChar *)"id");
+ if (!strcmp(localeId, pLocId))
+ {
+ xmlFreeDoc(doc);
+ return true;
+ }
+ }
+ }
+
+CATCH:
+ if (doc)
+ {
+ xmlFreeDoc(doc);
+ }
+ return false;
+}
+
+bool
+_SettingLocaleProvider::IsSupportedRegionLocale(const char* localeId)
+{
+ locale_t cLoc = newlocale(LC_ALL_MASK, localeId, null);
+ if (cLoc == (locale_t)null)
+ {
+ return false;
+ }
+ freelocale(cLoc);
+ return true;
+}
+
+} }
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingLocaleProvider.h
+ * @brief This is the header file for the %_SettingLocaleProvider class.
+ *
+ * This header file contains the declarations of the %_SettingLocaleProvider class.
+ */
+
+#ifndef _FSYS_SETTING_LOCALE_PROVIDER_H_
+#define _FSYS_SETTING_LOCALE_PROVIDER_H_
+
+#include <vconf.h>
+#include <runtime_info.h>
+
+#include "FSys_ISettingProvider.h"
+#include "FSys_Icu.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingLocaleProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingLocaleProvider();
+ virtual ~_SettingLocaleProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+ bool IsValidLocaleString(const Tizen::Base::String& localeString, const icu::Locale& icuLocale);
+ bool IsSupportedDisplayLanguageLocale(const char* localeId);
+ bool IsSupportedRegionLocale(const char* localeId);
+private:
+ _Icu __icu;
+private:
+ static void SettingEventRuntimeInfo(runtime_info_key_e key, void* userData);
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingLocaleProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_LOCALE_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingLocationProvider.cpp
+ * @brief This is the implementation for the _SettingLocationProvider class.
+ */
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingLocationProvider.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _LOCATION_GPS = L"http://tizen.org/setting/location.gps";
+static const wchar_t* _LOCATION_GPS_ADVANCED = L"http://tizen.org/setting/location.gps.advanced";
+static const wchar_t* _LOCATION_WPS = L"http://tizen.org/setting/location.wps";
+
+_SettingLocationProvider::_SettingLocationProvider()
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_LOCATION_ENABLED, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_LOCATION_ENABLED event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_LOCATION_NETWORK_ENABLED event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_LOCATION_AGPS_ENABLED, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_LOCATION_AGPS_ENABLED event listener");
+ }
+}
+
+
+_SettingLocationProvider::~_SettingLocationProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_LOCATION_ENABLED, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_LOCATION_ENABLED event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_LOCATION_NETWORK_ENABLED event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_LOCATION_AGPS_ENABLED, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_LOCATION_AGPS_ENABLED event listener");
+ }
+}
+
+result
+_SettingLocationProvider::GetValue(const String& key, bool& value)
+{
+ result r = E_OBJ_NOT_FOUND;
+ int errorCode = 0;
+
+ if (key == _LOCATION_GPS)
+ {
+ int gps_value = 0;
+ errorCode = vconf_get_int(VCONFKEY_LOCATION_ENABLED, &gps_value);
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_LOCATION_ENABLED vconf.");
+ if(gps_value == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ else if (key == _LOCATION_GPS_ADVANCED)
+ {
+ int agps = 0;
+ errorCode = vconf_get_int(VCONFKEY_LOCATION_AGPS_ENABLED, &agps);
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL vconf.");
+
+ if(agps == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+
+ return r;
+ }
+ else if (key == _LOCATION_WPS)
+ {
+ int wps_value = 0;
+ errorCode = vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_value);
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get the VCONFKEY_LOCATION_NETWORK_ENABLED");
+ if(wps_value == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+
+ }
+ return r;
+}
+
+result
+_SettingLocationProvider::SetValueForPrivilegedKey(const String& key, bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _LOCATION_GPS)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support GPS feature.");
+ r = E_SUCCESS;
+ if(value == true)
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
+ }
+ else
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_LOCATION_ENABLED vconf");
+ }
+ else if(key == _LOCATION_WPS)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support WPS feature.");
+ r = E_SUCCESS;
+ if(value == true)
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
+ }
+ else
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_LOCATION_NETWORK_ENABLED vconf");
+ }
+ else if(key == _LOCATION_GPS_ADVANCED)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Advanced GPS feature.");
+ r = E_SUCCESS;
+ if(value == true)
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_AGPS_ENABLED, 1);
+ }
+ else
+ {
+ errorCode = vconf_set_int(VCONFKEY_LOCATION_AGPS_ENABLED, 0);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_LOCATION_AGPS_ENABLED vconf");
+ }
+ return r;
+}
+
+bool
+_SettingLocationProvider::HasKey(const Tizen::Base::String& key)
+{
+ if(key == _LOCATION_GPS || key == _LOCATION_WPS || key == _LOCATION_GPS_ADVANCED)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingLocationProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if (strcmp(VCONFKEY_LOCATION_ENABLED, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCATION_GPS);
+ }
+ else if (strcmp(VCONFKEY_LOCATION_NETWORK_ENABLED, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCATION_WPS);
+ }
+ else if (strcmp(VCONFKEY_LOCATION_AGPS_ENABLED, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_LOCATION_GPS_ADVANCED);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+} }
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingLocationProvider.h
+ * @brief This is the header file for the %_SettingLocationProvider class.
+ *
+ * This header file contains the declarations of the %_SettingLocationProvider class.
+ */
+
+#ifndef _FSYS_SETTING_LOCATION_PROVIDER_H_
+#define _FSYS_SETTING_LOCATION_PROVIDER_H_
+
+#include <vconf.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingLocationProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingLocationProvider();
+ virtual ~_SettingLocationProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingLocationProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_LOCATION_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingNetworkProvider.cpp
+ * @brief This is the implementation for the _SettingNetworkProvider class.
+ */
+
+#include <unistd.h>
+#include <unique_ptr.h>
+#include <dlfcn.h>
+#include <sim.h>
+#include <system_info.h>
+#include <bluetooth.h>
+
+#include <FBase_StringConverter.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include "FSys_SystemInfo.h"
+#include "FSys_SettingNetworkProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base;
+using namespace Utility;
+
+namespace Tizen { namespace System
+{
+//Network Telephony
+static const wchar_t* _NETWORK_FLIGHTMODE = L"http://tizen.org/setting/network.flight_mode";
+static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"http://tizen.org/setting/network.telephony.packet_service";
+static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"http://tizen.org/setting/network.telephony.roaming";
+static const wchar_t* _SYSTEM_TELEPHONY = L"http://tizen.org/feature/network.telephony";
+
+//Network Wi-Fi
+static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/setting/network.wifi";
+static const wchar_t* _NETWORK_WIFI_NOTIFICATION = L"http://tizen.org/setting/network.wifi.notification";
+static const wchar_t* _NETWORK_WIFI_TETHERING = L"http://tizen.org/setting/network.wifi.tethering";
+static const wchar_t* _NETWORK_WIFI_TETHERING_HIDE = L"http://tizen.org/setting/network.wifi.tethering.hide";
+static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"http://tizen.org/setting/network.wifi.tethering.security";
+static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD = L"http://tizen.org/setting/network.wifi.tethering.security.password";
+static const wchar_t* _USB_TETHERING = L"http://tizen.org/setting/usb.tethering"; //Especially, USB tethering is covered by this provider.
+static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/setting/network.wifi.direct";
+
+static const wchar_t* _SYSTEM_NETWORK_WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
+static const wchar_t* _SYSTEM_NETWORK_WIFI = L"http://tizen.org/feature/network.wifi";
+
+//Network Bluetooth
+static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/setting/network.bluetooth";
+static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"http://tizen.org/setting/network.bluetooth.tethering";
+
+static const wchar_t* _SYSTEM_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
+
+static const wchar_t* _NETWORK_RESULT_SUCCESS = L"osp.system.result.success";
+static const wchar_t* _NETWORK_RESULT_SYSTEM = L"osp.system.result.system";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingNetworkProvider::_SettingNetworkProvider()
+ : __tapiHandle(null)
+ , __pWifiDllHandle(null)
+ , __pBluetoothDllHandle(null)
+ , __stateOfFlightMode(0)
+ , __stateOfWifi(0)
+ , __stateOfWifiDirect(0)
+ , __stateOfBluetooth(0)
+ , __flightModeEnabled(false)
+ , __networkBluetoothEnabled(false)
+ , __wifiInit(false)
+ , __wifiDirectInit(false)
+ , __pWifiListener(null)
+ , __pWifiDirectListener(null)
+ , __pFlightModeListener(null)
+ , __pBluetoothListener(null)
+{
+ int errorCode = bt_initialize();
+ if(errorCode != 0)
+ {
+ //For multiple usage, deinitialize should not be called when it terminated.
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to initialize bluetooth.");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register flight mode event listener");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register packet data event listener");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register roaming event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_STATE listener");
+ }
+
+ errorCode = tethering_create(&__tetheringHandle);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to create tethering handle");
+ }
+
+ errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringEnabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
+ }
+
+ errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringEnabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
+ }
+
+ errorCode = tethering_set_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringEnabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
+ }
+
+ errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB, SettingEventTetheringDisabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_USB listener");
+ }
+
+ errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI, SettingEventTetheringDisabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_WIFI listener");
+ }
+
+ errorCode = tethering_set_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT, SettingEventTetheringDisabled, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register TETHERING_TYPE_BT listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_DIRECT_STATE listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_BT_STATUS listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_WIFI_ENABLE_QS listener");
+ }
+
+ errorCode = bt_adapter_set_state_changed_cb(SettingEventBluetooth, (void*)this);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register bluetooth listener");
+ }
+
+ if(__wifiInit == false)
+ {
+ SysLog(NID_SYS, "wifi init is started");
+ errorCode = wifi_initialize();
+ SysLog(NID_SYS, "wifi init result is %d", errorCode);
+ __wifiInit = true;
+ }
+}
+
+
+_SettingNetworkProvider::~_SettingNetworkProvider()
+{
+ int errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister flight mode event listener");
+ }
+
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister packet data event listener");
+ }
+
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister roaming event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_STATE listener");
+ }
+
+ errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
+ }
+
+ errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
+ }
+
+ errorCode = tethering_unset_enabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
+ }
+
+ errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_USB);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_USB listener");
+ }
+
+ errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_WIFI);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_WIFI listener");
+ }
+
+ errorCode = tethering_unset_disabled_cb(__tetheringHandle, TETHERING_TYPE_BT);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister TETHERING_TYPE_BT listener");
+ }
+
+ tethering_destroy(__tetheringHandle);
+ __tetheringHandle = null;
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_DIRECT_STATE listener");
+ }
+ errorCode = vconf_ignore_key_changed(VCONFKEY_BT_STATUS, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_BT_STATUS listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_SECURITY, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_SECURITY listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_HIDE, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_MOBILE_HOTSPOT_HIDE listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_WIFI_ENABLE_QS, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_WIFI_ENABLE_QS listener");
+ }
+
+ errorCode = bt_adapter_unset_state_changed_cb();
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister bluetooth listener");
+ }
+
+ errorCode = bt_deinitialize();
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize bluetooth.");
+ }
+
+ if(__wifiDirectInit == true)
+ {
+ errorCode = wifi_direct_unset_device_state_changed_cb();
+ if(errorCode == WIFI_DIRECT_ERROR_NONE)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister Wi-Fi direct callback.");
+ }
+
+ errorCode = wifi_direct_deinitialize();
+ if(errorCode == WIFI_DIRECT_ERROR_NONE)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi direct.");
+ }
+ SysLog(NID_SYS, "Wifi direct de-init result is %d.", errorCode);
+ __wifiDirectInit = false;
+ }
+
+ if(__wifiInit == true)
+ {
+ errorCode = wifi_deinitialize();
+ if(errorCode == WIFI_ERROR_NONE)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to deinitialize Wi-Fi.");
+ }
+ SysLog(NID_SYS, "Wifi de-init result is %d.", errorCode);
+ __wifiInit = false;
+ }
+ SysLog(NID_SYS, "Network Provider is terminated properly.");
+}
+
+result
+_SettingNetworkProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _NETWORK_FLIGHTMODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
+ bool flightModeEnabled = false;
+ r = E_SUCCESS;
+ errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, &flightModeEnabled);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED");
+ value = flightModeEnabled;
+ }
+ else if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony packet service feature.");
+ bool packetServiceAllowed = false;
+ r = E_SUCCESS;
+ errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, &packetServiceAllowed);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_PACKET_DATA_ENABLED");
+ value = packetServiceAllowed;
+ }
+ else if(key == _NETWORK_TELEPHONY_ROAMING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Telephony roaming feature.");
+ bool dataRoamingEnabled = false;
+ r = E_SUCCESS;
+ errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &dataRoamingEnabled);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED");
+ value = dataRoamingEnabled;
+ }
+ else if (key == _NETWORK_WIFI)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+
+ bool wifiState = false;
+ errorCode = wifi_is_activated(&wifiState);
+ SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to get from wifi_is_activated.");
+ value = wifiState;
+ }
+ else if (key == _NETWORK_WIFI_NOTIFICATION)
+ {
+ int wifiQSState = 0;
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+
+ errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, &wifiQSState);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
+
+ if(wifiQSState == VCONFKEY_WIFI_QS_DISABLE)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ else if (key == _NETWORK_WIFI_TETHERING)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
+ value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_WIFI);
+ }
+ else if (key == _NETWORK_WIFI_TETHERING_HIDE)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
+ errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, &value);
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering visibility state");
+ }
+ else if (key == _NETWORK_WIFI_TETHERING_SECURITY)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
+ r = E_SUCCESS;
+ tethering_wifi_security_type_e securityType;
+ errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
+ if(securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ else if (key == _USB_TETHERING)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support USB tethering feature.");
+ value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_USB);
+ }
+ else if (key == _NETWORK_WIFI_DIRECT)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi direct feature.");
+ r = E_SUCCESS;
+
+ int isActivated = 0;
+ errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &isActivated);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_WIFI_ENABLE_QS vconf.");
+
+ if(isActivated == 1)
+ {
+ value = true;
+ }
+ else
+ {
+ value = false;
+ }
+ }
+ else if (key == _NETWORK_BLUETOOTH)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
+ r = E_SUCCESS;
+ int bluetoothStatus = VCONFKEY_BT_STATUS_OFF;
+ errorCode = vconf_get_int(VCONFKEY_BT_STATUS, &bluetoothStatus);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to read bluetooth status.");
+
+ if(bluetoothStatus == VCONFKEY_BT_STATUS_OFF)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ else if (key == _NETWORK_BLUETOOTH_TETHERING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth tethering feature.");
+ r = E_SUCCESS;
+ value = tethering_is_enabled(__tetheringHandle, TETHERING_TYPE_BT);
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _NETWORK_WIFI_NOTIFICATION)
+ {
+ int currentValue = 0;
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+ errorCode = vconf_get_int(VCONFKEY_WIFI_ENABLE_QS, ¤tValue);
+ SysTryReturnResult(NID_SYS, errorCode != -1, E_UNSUPPORTED_OPERATION, "This device does not support %ls key.", key.GetPointer());
+
+ if(value == true)
+ {
+ errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_ENABLE);
+ }
+ else
+ {
+ errorCode = vconf_set_int(VCONFKEY_WIFI_ENABLE_QS, VCONFKEY_WIFI_QS_DISABLE);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_WIFI_ENABLE_QS vconf.");
+ }
+ else if(key == _NETWORK_WIFI_TETHERING)
+ {
+ bool state = false;
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+ SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+ r = GetValue(_NETWORK_WIFI, state);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the WIFI state");
+ SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "WIFI is not activated");
+
+ if(value == true)
+ {
+ errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_WIFI);
+ }
+ else
+ {
+ errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_WIFI);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option.");
+ }
+ else if(key == _NETWORK_WIFI_TETHERING_HIDE)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+
+ bool currentState = false;
+ SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+ errorCode = tethering_wifi_get_ssid_visibility(__tetheringHandle, ¤tState);
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to current wifi tethering visibility setting");
+
+ if(value == true && currentState == false)
+ {
+ errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, true);
+ }
+ else if(value == false && currentState == true)
+ {
+ errorCode = tethering_wifi_set_ssid_visibility(__tetheringHandle, false);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
+ }
+ else if(key == _NETWORK_WIFI_TETHERING_SECURITY)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+
+ tethering_wifi_security_type_e securityType;
+ SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+
+ errorCode = tethering_wifi_get_security_type(__tetheringHandle, &securityType);
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to get wifi tethering securiy state");
+
+ if(value == true && securityType == TETHERING_WIFI_SECURITY_TYPE_NONE)
+ {
+ errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK);
+ }
+ else if(value == false && securityType == TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK)
+ {
+ errorCode = tethering_wifi_set_security_type(__tetheringHandle, TETHERING_WIFI_SECURITY_TYPE_NONE);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change wifi tethering visibility setting");
+ }
+ else if(key == _USB_TETHERING)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+
+ if(value == true)
+ {
+ errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_USB);
+ }
+ else
+ {
+ errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_USB);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
+ }
+ else if(key == _NETWORK_BLUETOOTH_TETHERING)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+
+ bool state = false;
+ r = GetValue(_NETWORK_BLUETOOTH, state);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the Bluetooth state");
+ SysTryReturnResult(NID_SYS, state == true, E_INVALID_STATE, "Bluetooth is not activated");
+
+ if(value == true)
+ {
+ errorCode = tethering_enable(__tetheringHandle, TETHERING_TYPE_BT);
+ }
+ else
+ {
+ errorCode = tethering_disable(__tetheringHandle, TETHERING_TYPE_BT);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to change tethering option");
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+ int ret = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _NETWORK_BLUETOOTH)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
+ SysTryReturnResult(NID_SYS, __stateOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
+ r = E_SUCCESS;
+ __stateOfBluetooth = 1;
+ __pBluetoothListener = listener;
+
+ if(value == true)
+ {
+ ret = bt_adapter_enable();
+ }
+ else
+ {
+ ret = bt_adapter_disable();
+ }
+
+ SysLog(NID_SYS, "bt_adapter returns %d.", ret);
+
+ switch(ret)
+ {
+ case BT_ERROR_NONE:
+ SysLog(NID_SYS, "It is OK to change the bluetooth mode.");
+ break;
+
+ case BT_ERROR_ALREADY_DONE:
+ case BT_ERROR_NOT_ENABLED:
+ SysLog(NID_SYS, "Bluetooth is already enabled.");
+ SettingEventBluetooth(BT_ERROR_NONE, BT_ADAPTER_ENABLED, (void*)this);
+ break;
+
+ case BT_ERROR_NOW_IN_PROGRESS:
+ SysLog(NID_SYS, "Currently, Bluetooth change is in progress.");
+ __stateOfBluetooth = 0;
+ r = E_IN_PROGRESS;
+ break;
+
+ case BT_ERROR_NOT_INITIALIZED:
+ default:
+ SysLog(NID_SYS, "There is an unknown error when changing the bluetooth mode.");
+ __stateOfBluetooth = 0;
+ r = E_SYSTEM;
+ break;
+ }
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _NETWORK_TELEPHONY_PACKETSERVICE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony packet service feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_3G_ENABLE, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_3G_ENABLE vconf.");
+ }
+ else if(key == _NETWORK_TELEPHONY_ROAMING)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support telephony roaming feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL vconf.");
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _NETWORK_FLIGHTMODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support flightmode feature.");
+ r = E_SUCCESS;
+
+ SysTryReturnResult(NID_SYS, __stateOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
+ __stateOfFlightMode = 1;
+
+ bool supported = false;
+ int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
+ SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+
+ __pFlightModeListener = listener;
+ if(supported == true)
+ {
+ if(__tapiHandle == null)
+ {
+ __tapiHandle = tel_init(null);
+ if(__tapiHandle == null)
+ {
+ __stateOfFlightMode = 0;
+ }
+ SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
+ }
+ errorCode = tel_set_flight_mode(__tapiHandle,
+ value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
+ SettingEventFlightMode, (void*)this);
+
+ if(errorCode != 0)
+ {
+ __stateOfFlightMode = 0;
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode(%d).", errorCode);
+ }
+ else
+ {
+ FlightModeEnabler((void*)this);
+ }
+ }
+ else if(key == _NETWORK_WIFI)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+ SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
+ r = E_SUCCESS;
+
+ __stateOfWifi = 1;
+ SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
+
+ bool wifiEnabled = false;
+ __pWifiListener = listener;
+ errorCode = wifi_is_activated(&wifiEnabled);
+ if(errorCode != WIFI_ERROR_NONE)
+ {
+ __stateOfWifi = 0;
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
+ return E_SYSTEM;
+ }
+
+ if(value == wifiEnabled) //Wi-Fi is already changed.
+ {
+ SysLog(NID_SYS, "It is try to use dummy thread");
+ r = WifiDummy((void*)this);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to set Wi-Fi state.");
+ return r;
+ }
+
+ if(value == true)
+ {
+ errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
+ }
+ else
+ {
+ errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
+ }
+
+ if(errorCode != WIFI_ERROR_NONE)
+ {
+ __stateOfWifi = 0;
+ return E_SYSTEM;
+ }
+ }
+ else if(key == _NETWORK_WIFI_DIRECT)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
+ SysTryReturnResult(NID_SYS, __stateOfWifi == 0 && __stateOfWifiDirect == 0, E_IN_PROGRESS, "Wifi processing is under way.");
+ r = E_SUCCESS;
+
+ __stateOfWifiDirect = 1;
+ SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
+
+
+ __pWifiDirectListener = listener;
+ if(__wifiDirectInit == false)
+ {
+ SysLog(NID_SYS, "wifi direct init is started");
+ errorCode = wifi_direct_initialize();
+ SysLog(NID_SYS, "wifi direct init result is %d", errorCode);
+ SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
+ errorCode = wifi_direct_set_device_state_changed_cb(SettingWifiDirectStateChangedCallBack, (void*) this);
+ SysTryReturnResult(NID_SYS, errorCode == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "It is failed to register wifi direct result callback.");
+ __wifiDirectInit = true;
+ }
+
+
+ wifi_direct_state_e wifi_direct_state;
+ errorCode = wifi_direct_get_state(&wifi_direct_state);
+ if(errorCode != WIFI_DIRECT_ERROR_NONE)
+ {
+ __stateOfWifiDirect = 0;
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI direct.");
+ return E_SYSTEM;
+ }
+
+ if((value == false && wifi_direct_state == WIFI_DIRECT_STATE_DEACTIVATED)
+ || (value == true && wifi_direct_state != WIFI_DIRECT_STATE_DEACTIVATED))
+ {
+ SysLog(NID_SYS, "Required state is already applied.");
+ WifiDirectDummy((void*)this);
+ return E_SUCCESS;
+ }
+
+ if(value == true)
+ {
+ errorCode = wifi_direct_activate();
+ }
+ else
+ {
+ errorCode = wifi_direct_deactivate();
+ }
+ SysLog(NID_SYS, "wifi_direct_activate result is %d. value is %d.", errorCode, value);
+
+ if(errorCode < 0)
+ {
+ return E_SYSTEM;
+ }
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::WifiDummy(void* data)
+{
+ result r = E_SUCCESS;
+ String settingKey(_NETWORK_WIFI);
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
+
+ SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, r = E_SYSTEM, E_SYSTEM, "There is invalid state.");
+
+ if(pProvider->__pWifiListener != null)
+ {
+ pProvider->__pWifiListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
+ }
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+
+CATCH:
+ pProvider->__stateOfWifi = 0;
+ return r;
+}
+
+result
+_SettingNetworkProvider::WifiDirectDummy(void* data)
+{
+ result r = E_SUCCESS;
+ String settingKey(_NETWORK_WIFI_DIRECT);
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
+ SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1, E_SYSTEM, E_SYSTEM, "There is invalid state.");
+
+ if(pProvider->__pWifiDirectListener != null)
+ {
+ pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
+ }
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+
+CATCH:
+ pProvider->__stateOfWifiDirect = 0;
+ return r;
+}
+
+void
+_SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
+{
+ String settingKey(_NETWORK_WIFI);
+
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
+ SysTryCatch(NID_SYS, pProvider->__stateOfWifi == 1, E_SYSTEM, E_SYSTEM, "Wi-Fi processing is under way.");
+
+ if(errorCode != WIFI_ERROR_NONE)
+ {
+ switch(errorCode)
+ {
+ case WIFI_ERROR_INVALID_PARAMETER:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid param.");
+ break;
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by out of memory.");
+ break;
+ case WIFI_ERROR_INVALID_OPERATION:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid operation.");
+ break;
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by family not supported.");
+ break;
+ case WIFI_ERROR_OPERATION_FAILED:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation failed.");
+ break;
+ case WIFI_ERROR_NO_CONNECTION:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no connection.");
+ break;
+ case WIFI_ERROR_ALREADY_EXISTS:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by already exist.");
+ break;
+ case WIFI_ERROR_OPERATION_ABORTED:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by operation aborted.");
+ break;
+ case WIFI_ERROR_DHCP_FAILED:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by DHCP fail.");
+ break;
+ case WIFI_ERROR_INVALID_KEY:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by invalid key.");
+ break;
+ case WIFI_ERROR_NO_REPLY:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by no reply.");
+ break;
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is failed by security restricted.");
+ break;
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ SysLogException(NID_SYS, E_SYSTEM, "Wifi change request is under way.");
+ break;
+ }
+ }
+
+ if(pProvider->__pWifiDirectListener != null)
+ {
+ pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, E_SUCCESS);
+ }
+CATCH:
+ pProvider->__stateOfWifi = 0;
+}
+
+void
+_SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
+{
+ result r = E_SUCCESS;
+ String settingKey(_NETWORK_WIFI_DIRECT);
+ String returnValue = _NETWORK_RESULT_SUCCESS;
+
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, (pSettingInfo != null && pProvider != null), E_SYSTEM, "There is no values of args.");
+
+ SysTryCatch(NID_SYS, pProvider->__stateOfWifiDirect == 1 , E_SYSTEM, E_SYSTEM, "There is invalid state.");
+
+ if(errorCode != WIFI_DIRECT_ERROR_NONE)
+ {
+ r = E_SYSTEM;
+ }
+
+ if(pProvider->__pWifiDirectListener != null)
+ {
+ pProvider->__pWifiDirectListener->OnResultReceivedForSetValueAsync(settingKey, r);
+ }
+
+CATCH:
+ pProvider->__stateOfWifiDirect = 0;
+}
+
+result
+_SettingNetworkProvider::GetValue(const String& key, String& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if (key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
+ {
+ r = E_SUCCESS;
+ unique_ptr<char> password(null);
+ char* pTemp = null;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
+
+ SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+ errorCode = tethering_wifi_get_passphrase(__tetheringHandle, &pTemp);
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get password");
+
+ password.reset(pTemp);
+
+ value.Clear();
+ value.Append(password.get());
+ }
+ return r;
+}
+
+result
+_SettingNetworkProvider::SetValue(const String& key, const String value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key ==_NETWORK_WIFI_TETHERING_SECURITY_PASSWORD)
+ {
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi tethering feature.");
+
+ SysTryReturnResult(NID_SYS, __tetheringHandle != null, E_UNSUPPORTED_OPERATION, "Current device does not support tethering feature.");
+ unique_ptr<char []> password(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, password != null, E_SYSTEM, "It is failed to convert String to string");
+ errorCode = tethering_wifi_set_passphrase(__tetheringHandle, password.get());
+ SysTryReturnResult(NID_SYS, errorCode == TETHERING_ERROR_NONE, E_SYSTEM, "It is failed to set password");
+ }
+ return r;
+}
+
+bool
+_SettingNetworkProvider::HasKey(const String& key)
+{
+ bool wifi_supported = false;
+ bool wifi_direct_supported = false;
+ bool bluetooth_supported = false;
+ bool telephony_supported = false;
+
+ int ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi_supported);
+ SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+
+ ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_supported);
+ SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+
+ ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth_supported);
+ SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+
+ ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony_supported);
+ SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+
+ if(key == _NETWORK_FLIGHTMODE)
+ {
+ return true;
+ }
+ else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
+ {
+ if(telephony_supported == true)
+ {
+ return true;
+ }
+ }
+ else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
+ {
+ if(wifi_supported == true)
+ {
+ return true;
+ }
+ }
+ else if(key == _NETWORK_WIFI_DIRECT)
+ {
+ if(wifi_direct_supported == true)
+ {
+ return true;
+ }
+ }
+ else if(key == _NETWORK_WIFI_TETHERING || key == _NETWORK_WIFI_TETHERING_HIDE
+ || key == _NETWORK_WIFI_TETHERING_SECURITY || key == _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD || key == _USB_TETHERING)
+ {
+ bool isSupported = false;
+ int errorCode = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
+ if(errorCode == SYSTEM_INFO_ERROR_NONE && isSupported == true)
+ {
+ return true;
+ }
+ }
+ else if(key == _NETWORK_BLUETOOTH)
+ {
+ if(bluetooth_supported == true)
+ {
+ return true;
+ }
+ }
+ else if(key == _NETWORK_BLUETOOTH_TETHERING)
+ {
+ if(__tetheringHandle != null && bluetooth_supported == true)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+void
+_SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
+{
+ String settingKey;
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
+
+ if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
+ {
+ settingKey.Append(_NETWORK_FLIGHTMODE);
+ }
+ else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
+ {
+ settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
+ }
+ else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
+ {
+ settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
+ return;
+ }
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ result r = E_SUCCESS;
+ String settingKey;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ if (strcmp(VCONFKEY_WIFI_STATE, vconf_keynode_get_name(node)) == 0)
+ {
+ int state = VCONFKEY_WIFI_OFF;
+ int errorCode = 0;
+ errorCode = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
+
+ if(errorCode == 0 && (state == VCONFKEY_WIFI_OFF || state == VCONFKEY_WIFI_UNCONNECTED))
+ {
+ settingKey.Append(_NETWORK_WIFI);
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+ }
+ return;
+ }
+ else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
+ }
+ else if (strcmp(VCONFKEY_WIFI_DIRECT_STATE, vconf_keynode_get_name(node)) == 0)
+ {
+ int state = VCONFKEY_WIFI_DIRECT_DEACTIVATED;
+ int errorCode = 0;
+ errorCode = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
+ SysLog(NID_SYS, "Wi-Fi Direct state is changed. %d", state);
+ if(errorCode == 0 && (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED || state == VCONFKEY_WIFI_DIRECT_ACTIVATED))
+ {
+ settingKey.Append(_NETWORK_WIFI_DIRECT);
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+ }
+ return;
+ }
+ else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_NETWORK_BLUETOOTH);
+ }
+ else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
+ }
+ else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is not supported key.");
+ return;
+ }
+
+ r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
+{
+ String settingKey;
+ SysLog(NID_SYS, "Tethering Endabled Event is occured.");
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ switch(type)
+ {
+ case TETHERING_TYPE_USB:
+ settingKey.Append(_USB_TETHERING);
+ break;
+ case TETHERING_TYPE_WIFI:
+ settingKey.Append(_NETWORK_WIFI_TETHERING);
+ break;
+ case TETHERING_TYPE_BT:
+ settingKey.Append(_NETWORK_BLUETOOTH_TETHERING);
+ break;
+ default:
+ return;
+ }
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingNetworkProvider::SettingEventTetheringDisabled(tethering_error_e err, tethering_type_e type, tethering_disabled_cause_e cause,void* data)
+{
+ SysLog(NID_SYS, "Tethering Disabled Event is occured.");
+ SettingEventTetheringEnabled(err, type, false, null);
+}
+
+void
+_SettingNetworkProvider::SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data)
+{
+ String settingKey(_NETWORK_FLIGHTMODE);
+ int errorCode = 0;
+ result r = E_SUCCESS;
+ SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "SettingInfo is not ready.");
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
+ SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
+ SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
+
+ switch (res)
+ {
+ case TAPI_POWER_FLIGHT_MODE_RESP_ON:
+ SysLog(NID_SYS, "It successes to change flight mode on");
+
+ errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
+ if (errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
+ r = E_SYSTEM;
+ }
+ break;
+ case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
+ SysLog(NID_SYS, "It successes to change flight mode off");
+
+ errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
+ if (errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
+ r = E_SYSTEM;
+ }
+ break;
+ case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
+ default:
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
+ r = E_SYSTEM;
+ }
+
+ if(pProvider->__pFlightModeListener != null)
+ {
+ pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
+ }
+
+CATCH:
+ pProvider->__stateOfFlightMode = 0;
+}
+
+result
+_SettingNetworkProvider::FlightModeEnabler(void* data)
+{
+ result r = E_SUCCESS;
+ int errorCode = 0;
+ String settingKey(_NETWORK_FLIGHTMODE);
+
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnResult(NID_SYS, pProvider != null && pSettingInfo != null, E_SYSTEM, "Provider or SettingInfo is not ready.");
+ SysTryCatch(NID_SYS, pProvider->__stateOfFlightMode == 1, E_SYSTEM, E_SYSTEM, "Current state of flight mode is not valid.");
+
+ errorCode = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, pProvider->__flightModeEnabled);
+ if (errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to set on VCONFKEY_TELEPHONY_FLIGHT_MODE vconf.");
+ r = E_SYSTEM;
+ }
+
+
+ if(pProvider->__pFlightModeListener != null)
+ {
+ pProvider->__pFlightModeListener->OnResultReceivedForSetValueAsync(settingKey, r);
+ }
+
+CATCH:
+ pProvider->__stateOfFlightMode = 0;
+ return r;
+}
+
+void
+_SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
+{
+ String settingKey(_NETWORK_BLUETOOTH);
+ result r = E_SUCCESS;
+ SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
+
+ _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
+ SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
+ SysTryCatch(NID_SYS, pProvider->__stateOfBluetooth == 1, E_SYSTEM, E_SYSTEM, "Bluetooth processing is under way.");
+
+ if(res == BT_ERROR_NONE)
+ {
+ r = E_SUCCESS;
+ }
+ else
+ {
+ r = E_SYSTEM;
+ }
+
+ if(pProvider->__pBluetoothListener != null && pProvider->__stateOfBluetooth == 1)
+ {
+ pProvider->__pBluetoothListener->OnResultReceivedForSetValueAsync(settingKey, r);
+ }
+
+ if(r == E_SUCCESS)
+ {
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryCatch(NID_SYS, pSettingInfo != null, E_SYSTEM, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+ }
+
+CATCH:
+ pProvider->__stateOfBluetooth = 0;
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingNetworkProvider.h
+ * @brief This is the header file for the %_SettingNetworkProvider class.
+ *
+ * This header file contains the declarations of the %_SettingNetworkProvider class.
+ */
+
+#ifndef _FSYS_SETTING_NETWORK_PROVIDER_H_
+#define _FSYS_SETTING_NETWORK_PROVIDER_H_
+
+#include <pthread.h>
+
+#include <vconf.h>
+#include <tethering.h>
+#include <tapi_common.h>
+#include <ITapiModem.h>
+#include <runtime_info.h>
+#include <bluetooth.h>
+#include <wifi.h>
+#include <wifi-direct.h>
+
+#include <FBase.h>
+#include <FSysISettingInfoSetValueAsyncResultListener.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingNetworkProvider
+ : _ISettingProvider
+{
+public:
+ _SettingNetworkProvider();
+ virtual ~_SettingNetworkProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+ result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+ result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+private:
+ result FlightModeEnabler(void* data);
+ result WifiDummy(void* data);
+ result WifiDirectDummy(void* data);
+
+ static void SettingEventFlightMode(TapiHandle* handle, int res, void* data, void* user_data);
+ static void SettingEventRuntimeInfo(runtime_info_key_e key, void* userData);
+ static void SettingEventVConf(keynode_t* node, void* userData);
+ static void SettingEventTetheringEnabled(tethering_error_e tetheringErr, tethering_type_e deviceType, bool isRequested, void* data);
+ static void SettingEventTetheringDisabled(tethering_error_e tetheringErr, tethering_type_e deviceType, tethering_disabled_cause_e tetheringCause, void* data);
+ static void SettingEventBluetooth(int result, bt_adapter_state_e adapter_state, void* user_data);
+
+ static void SettingWifiActivateCallBack(wifi_error_e errorCode, void* data);
+ static void SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data);
+
+private:
+ TapiHandle* __tapiHandle;
+ void* __pWifiDllHandle;
+ void* __pBluetoothDllHandle;
+ tethering_h __tetheringHandle;
+
+ int __stateOfFlightMode;
+ int __stateOfWifi;
+ int __stateOfWifiDirect;
+ int __stateOfBluetooth;
+
+ bool __flightModeEnabled;
+ bool __networkBluetoothEnabled;
+
+ bool __wifiInit;
+ bool __wifiDirectInit;
+
+ ISettingInfoSetValueAsyncResultListener* __pWifiListener;
+ ISettingInfoSetValueAsyncResultListener* __pWifiDirectListener;
+ ISettingInfoSetValueAsyncResultListener* __pFlightModeListener;
+ ISettingInfoSetValueAsyncResultListener* __pBluetoothListener;
+}; // _SettingNetworkProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_NETWORK_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingScreenProvider.cpp
+ * @brief This is the implementation for the _SettingScreenProvider class.
+ */
+
+#include <unique_ptr.h>
+#include <device.h>
+
+#include <FApp.h>
+#include <FIo.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include <FBase_StringConverter.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingScreenProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _SCREEN_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper";
+static const wchar_t* _SCREEN_WALLPAPER_LOCK = L"http://tizen.org/setting/screen.wallpaper.lock";
+static const wchar_t* _SCREEN_BRIGHTNESS = L"http://tizen.org/setting/screen.brightness";
+static const wchar_t* _SCREEN_BRIGHTNESS_AUTO = L"http://tizen.org/setting/screen.brightness.auto";
+static const wchar_t* _SCREEN_BACKLIGHT_TIME = L"http://tizen.org/setting/screen.backlight.time";
+static const wchar_t* _SCREEN_ROTATION_AUTO = L"http://tizen.org/setting/screen.rotation.auto";
+static const wchar_t* _SCREEN_MODE = L"http://tizen.org/setting/screen.mode";
+
+static const wchar_t* _SCREEN_MODE_DYNAMIC = L"Dynamic";
+static const wchar_t* _SCREEN_MODE_STANDARD = L"Standard";
+static const wchar_t* _SCREEN_MODE_NATURAL = L"Natural";
+static const wchar_t* _SCREEN_MODE_MOVIE = L"Movie";
+static const char* _SCREEN_MODE_VCONFKEY = VCONFKEY_SETAPPL_PREFIX"/screenmode/selected_name";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingScreenProvider::_SettingScreenProvider()
+{
+ int errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register wallpaper event listener");
+ }
+
+ errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register lock wallpaper event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_LCD_BRIGHTNESS event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(_SCREEN_MODE_VCONFKEY, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register _SCREEN_MODE_VCONFKEY event listener");
+ }
+}
+
+
+_SettingScreenProvider::~_SettingScreenProvider()
+{
+ int errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister wallpaper event listener");
+ }
+
+ errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister lock wallpaper event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_LCD_BRIGHTNESS event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(_SCREEN_MODE_VCONFKEY, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister _SCREEN_MODE_VCONFKEY event listener");
+ }
+}
+
+result
+_SettingScreenProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if (key == _SCREEN_BRIGHTNESS_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support brightness auto control feature.");
+ r = E_SUCCESS;
+ int brightnessAuto = 0;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &brightnessAuto);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on SETAPPL_BRIGHTNESS_AUTOMATIC_INT vconf");
+
+ if(brightnessAuto == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ else if (key == _SCREEN_ROTATION_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support auto ratation feature.");
+ r = E_SUCCESS;
+ int autoRotate = false;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &autoRotate);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL vconf");
+ if(autoRotate == 1)
+ {
+ value = true;
+ }
+ else
+ {
+ value = false;
+ }
+ }
+ return r;
+}
+
+result
+_SettingScreenProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _SCREEN_BRIGHTNESS_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support brightness auto control feature.");
+ r = E_SUCCESS;
+ if(value == true)
+ {
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
+ }
+ else
+ {
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
+ }
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on SETAPPL_BRIGHTNESS_AUTOMATIC_INT vconf");
+ }
+ else if(key == _SCREEN_ROTATION_AUTO)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support auto ratation feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL vconf");
+ }
+ return r;
+}
+
+result
+_SettingScreenProvider::GetValue(const String& key, int& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if (key == _SCREEN_BRIGHTNESS)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support brightness feature.");
+ r = E_SUCCESS;
+ int brightness = 0;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_LCD_BRIGHTNESS vconf");
+ value = brightness;
+ }
+ else if (key == _SCREEN_BACKLIGHT_TIME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen backlight time feature.");
+ r = E_SUCCESS;
+ int timeout = 0;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &timeout);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TIMEOUT_NORMAL vconf");
+ value = timeout;
+ }
+ return r;
+}
+
+result
+_SettingScreenProvider::SetValue(const String& key, const int value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _SCREEN_BRIGHTNESS)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support brightness feature.");
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, value > 0 && value <= 100, E_INVALID_ARG, "Out of range");
+
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_LCD_BRIGHTNESS vconf");
+
+ errorCode = device_set_brightness_from_settings(0);
+ if(errorCode != 0)
+ {
+ SysLog(NID_SYS, "It is failed to update screen brightness.");
+ }
+ }
+ else if(key == _SCREEN_BACKLIGHT_TIME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen backlight time feature.");
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, value == 15 || value == 30 || value == 60 || value == 120 || value == 300 || value == 600, E_INVALID_ARG, "Out of range");
+
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL vconf");
+ }
+ return r;
+}
+
+result
+_SettingScreenProvider::GetValue(const String& key, String& value)
+{
+ int errorCode = 0;
+ result r = E_SUCCESS;
+
+ if(key == _SCREEN_WALLPAPER)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support wallpaper feature.");
+ r = E_SUCCESS;
+ char* pWallpaper = null;
+ errorCode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &pWallpaper);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get wallpaper of home screen");
+
+ r = StringUtil::Utf8ToString(pWallpaper, value);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
+
+ free(pWallpaper);
+ }
+ else if (key == _SCREEN_WALLPAPER_LOCK)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support wallpaper feature.");
+ r = E_SUCCESS;
+ unique_ptr<char, charDeleter> pWallpaper(null);
+ char* pTemp = null;
+
+ errorCode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &pTemp);
+ SysTryReturnResult(NID_SYS, errorCode == 0 && pTemp != null, E_SYSTEM, "It is failed to get wallpaper of lock screen");
+
+ pWallpaper.reset(pTemp);
+
+ r = StringUtil::Utf8ToString(pWallpaper.get(), value);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
+ }
+ else if (key == _SCREEN_MODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen mode feature.");
+ r = E_SUCCESS;
+ unique_ptr<char, charDeleter> curmode(vconf_get_str(_SCREEN_MODE_VCONFKEY));
+ value.Clear();
+ value.Append(curmode.get());
+ }
+ return r;
+}
+
+result
+_SettingScreenProvider::SetValue(const String& key, const String value)
+{
+ int errorCode = 0;
+ result r = E_SUCCESS;
+
+ if(key == _SCREEN_WALLPAPER)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support wallpaper feature.");
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, "The entry for the specified wallpaper file or the file path cannot be found");
+ unique_ptr<char []> pFilePath(_StringConverter::CopyToCharArrayN(value));
+
+ SysTryReturnResult(NID_SYS, pFilePath.get() != null, E_SYSTEM, "It is failed to convert type of filePath");
+
+ errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, pFilePath.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set wallpaper of home screen");
+ }
+ else if(key == _SCREEN_WALLPAPER_LOCK)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support wallpaper feature.");
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, "The entry for the specified wallpaper lock file or the file path cannot be found");
+ unique_ptr<char []> pFilePath(_StringConverter::CopyToCharArrayN(value));
+ SysTryReturnResult(NID_SYS, pFilePath.get() != null, E_SYSTEM, "It is failed to convert type of filePath");
+
+ errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, pFilePath.get());
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set wallpaper of home screen");
+ }
+ else if(key == _SCREEN_MODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen mode feature.");
+ r = E_SUCCESS;
+ SysTryReturnResult(NID_SYS, value == _SCREEN_MODE_DYNAMIC || value == _SCREEN_MODE_STANDARD || value == _SCREEN_MODE_NATURAL || value == _SCREEN_MODE_MOVIE, E_INVALID_ARG, "designated value(%ls) is invalid", value.GetPointer());
+ unique_ptr<char []> screenMode(_StringConverter::CopyToCharArrayN(value));
+ errorCode = vconf_set_str(_SCREEN_MODE_VCONFKEY, screenMode.get());
+
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to change screen mode.");
+ }
+ return r;
+}
+
+bool
+_SettingScreenProvider::HasKey(const Tizen::Base::String& key)
+{
+
+ if(key == _SCREEN_WALLPAPER || key == _SCREEN_WALLPAPER_LOCK)
+ {
+ return true;
+ }
+ else if(key == _SCREEN_BRIGHTNESS || key ==_SCREEN_BRIGHTNESS_AUTO)
+ {
+ return true;
+ }
+ else if(key == _SCREEN_BACKLIGHT_TIME)
+ {
+ return true;
+ }
+ else if(key == _SCREEN_ROTATION_AUTO)
+ {
+ return true;
+ }
+ else if(key == _SCREEN_MODE)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingScreenProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if (strcmp(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SCREEN_BRIGHTNESS);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SCREEN_BRIGHTNESS_AUTO);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SCREEN_BACKLIGHT_TIME);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SCREEN_ROTATION_AUTO);
+ }
+ else if (strcmp(_SCREEN_MODE_VCONFKEY, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SCREEN_MODE);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingScreenProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
+{
+ String settingKey;
+
+ if(key == SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN)
+ {
+ settingKey.Append(_SCREEN_WALLPAPER);
+ }
+ else if(key == SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN)
+ {
+ settingKey.Append(_SCREEN_WALLPAPER_LOCK);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingScreenProvider.h
+ * @brief This is the header file for the %_SettingScreenProvider class.
+ *
+ * This header file contains the declarations of the %_SettingScreenProvider class.
+ */
+
+#ifndef _FSYS_SETTING_SCREEN_PROVIDER_H_
+#define _FSYS_SETTING_SCREEN_PROVIDER_H_
+
+#include <vconf.h>
+#include <system/system_settings.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingScreenProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingScreenProvider();
+ virtual ~_SettingScreenProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+
+ result GetValue(const Tizen::Base::String& key, int& value);
+ result SetValue(const Tizen::Base::String& key, const int value);
+
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+
+ bool HasKey(const Tizen::Base::String& key);
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+ static void SettingEventSettingInfo(system_settings_key_e key, void* userData);
+}; // _SettingScreenProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_SCREEN_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingSoundProvider.cpp
+ * @brief This is the implementation for the _SettingSoundProvider class.
+ */
+
+#include <FBase_StringConverter.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FIo.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingSoundProvider.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+static const wchar_t* _SOUND_MEDIA_VOLUME = L"http://tizen.org/setting/sound.media.volume";
+static const wchar_t* _SOUND_NOTIFICATION = L"http://tizen.org/setting/sound.notification";
+static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD = L"http://tizen.org/setting/sound.notification.repetition_period";
+static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE = L"once";
+static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN = L"2min";
+static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN = L"5min";
+static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN = L"10min";
+static const wchar_t* _SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
+static const wchar_t* _SOUND_RINGTONE_VOLUME = L"http://tizen.org/setting/sound.ringtone.volume";
+static const wchar_t* _SOUND_SYSTEM_VOLUME = L"http://tizen.org/setting/sound.system.volume";
+
+static const wchar_t* _SOUND_RINGTONE = L"http://tizen.org/setting/sound.ringtone";
+static const wchar_t* _SOUND_SILENTMODE = L"http://tizen.org/setting/sound.silent_mode";
+static const wchar_t* _SOUND_TOUCH = L"http://tizen.org/setting/sound.touch";
+static const wchar_t* _SOUND_LOCK = L"http://tizen.org/setting/sound.lock";
+
+_SettingSoundProvider::_SettingSoundProvider()
+{
+ int errorCode = sound_manager_set_volume_changed_cb(SettingEventSoundManager, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register volume event listener.");
+ }
+
+ errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, SettingEventSettingInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register ringtone event listener.");
+ }
+
+ errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, SettingEventRuntimeInfo, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register silent mode event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT event listener.");
+ }
+}
+
+
+_SettingSoundProvider::~_SettingSoundProvider()
+{
+ sound_manager_unset_volume_changed_cb();
+
+ int errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister ringtone event listener.");
+ }
+
+ errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister silent mode event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
+ }
+}
+
+result
+_SettingSoundProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if (key == _SOUND_SILENTMODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+ bool silentModeEnabled = false;
+ errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, &silentModeEnabled);
+ SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_SILENT_MODE_ENABLED");
+ value = !silentModeEnabled;
+ }
+ else if (key == _SOUND_TOUCH)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
+ r = E_SUCCESS;
+ int soundTouch = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &soundTouch);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
+ if(soundTouch == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ return r;
+ }
+ else if (key == _SOUND_LOCK)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
+ r = E_SUCCESS;
+
+ int soundLock = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &soundLock);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOO vconf");
+ if(soundLock == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ return r;
+ }
+ return r;
+}
+
+result
+_SettingSoundProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _SOUND_SILENTMODE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+ bool silentMode = !value;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, silentMode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_SOUND_STATUS_BOOL vconf");
+ }
+ else if(key == _SOUND_TOUCH)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
+ }
+ else if(key == _SOUND_LOCK)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound lock effect feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOOL vconf");
+ }
+ return r;
+}
+
+result
+_SettingSoundProvider::GetValue(const String& key, int& value)
+{
+ int volume = 0;
+ int maxVolume = 0;
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if (key == _SOUND_MEDIA_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+
+ errorCode = sound_manager_get_max_volume(SOUND_TYPE_MEDIA, &maxVolume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
+
+ errorCode = sound_manager_get_volume(SOUND_TYPE_MEDIA, &volume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
+
+ value = volume;
+ }
+ else if (key == _SOUND_NOTIFICATION_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+
+ errorCode = sound_manager_get_max_volume(SOUND_TYPE_NOTIFICATION, &maxVolume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
+
+ errorCode = sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
+
+ value = volume;
+ }
+ else if (key == _SOUND_RINGTONE_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+
+ errorCode = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &maxVolume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
+
+ errorCode = sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
+
+ value = volume;
+ }
+ else if (key == _SOUND_SYSTEM_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ r = E_SUCCESS;
+
+ errorCode = sound_manager_get_max_volume(SOUND_TYPE_SYSTEM, &maxVolume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
+
+ errorCode = sound_manager_get_volume(SOUND_TYPE_SYSTEM, &volume);
+ SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
+
+ value = volume;
+ }
+ return r;
+}
+
+result
+_SettingSoundProvider::SetValue(const String& key, const int value)
+{
+ int errorCode = 0;
+ int maxVolume = 0;
+ result r = E_SUCCESS;
+ sound_type_e soundType;
+
+ if (key == _SOUND_MEDIA_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ soundType = SOUND_TYPE_MEDIA;
+ }
+ else if (key == _SOUND_NOTIFICATION_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ soundType = SOUND_TYPE_NOTIFICATION;
+ }
+ else if (key == _SOUND_RINGTONE_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ soundType = SOUND_TYPE_RINGTONE;
+ }
+ else if (key == _SOUND_SYSTEM_VOLUME)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
+ soundType = SOUND_TYPE_SYSTEM;
+ }
+ else
+ {
+ return E_OBJ_NOT_FOUND;
+ }
+
+ errorCode = sound_manager_get_max_volume(soundType, &maxVolume);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get max volume.");
+ SysTryReturnResult(NID_SYS, maxVolume >= value && value >= 0, E_INVALID_ARG, "The specified value[%d] is outside the bounds of soundCategory.", value);
+
+ SysLog(NID_SYS, "Required Volume is %d, Value is %d", soundType, value);
+ errorCode = sound_manager_set_volume(soundType, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "A system error has occured.");
+
+ return r;
+}
+
+result
+_SettingSoundProvider::GetValue(const String& key, String& value)
+{
+ int errorCode = 0;
+ result r =E_OBJ_NOT_FOUND;
+
+ if(key == _SOUND_RINGTONE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone feature.");
+ r = E_SUCCESS;
+ char* pRingtone = null;
+ errorCode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &pRingtone);
+ SysTryReturnResult(NID_SYS, errorCode == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to get ringtone");
+
+ value.Clear();
+ value.Append(pRingtone);
+ free(pRingtone);
+ if(File::IsFileExist(value) == false)
+ {
+ if(File::IsFileExist(L"/opt/share/settings/Ringtones/ringtone_sdk.mp3") == true)
+ {
+ value = L"/opt/share/settings/Ringtones/ringtone_sdk.mp3";
+ system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "/opt/share/settings/Ringtones/ringtone_sdk.mp3");
+ }
+ else
+ {
+ return E_SYSTEM;
+ }
+ }
+ }
+ if(key == _SOUND_NOTIFICATION)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone feature.");
+ r = E_SUCCESS;
+ char* pNotification = null;
+ pNotification = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
+ SysTryReturnResult(NID_SYS, pNotification != null, E_SYSTEM, "It is failed to get ringtone");
+ value.Clear();
+ value.Append(pNotification);
+ free(pNotification);
+
+ if(File::IsFileExist(value) == false)
+ {
+ if(File::IsFileExist( L"/opt/share/settings/Alerts/General notification_sdk.wav") == true)
+ {
+ value = L"/opt/share/settings/Alerts/General notification_sdk.wav";
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, "/opt/share/settings/Alerts/General notification_sdk.wav");
+ }
+ else
+ {
+ return E_SYSTEM;
+ }
+ }
+ }
+ else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
+ r = E_SUCCESS;
+
+ int current_value = 0;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, ¤t_value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
+
+ switch (current_value)
+ {
+ case SETTING_SOUND_REP_ONCE:
+ value = _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE;
+ break;
+ case SETTING_SOUND_REP_EVERY_2_MIN:
+ value = _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN;
+ break;
+ case SETTING_SOUND_REP_EVERY_5_MIN:
+ value = _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN;
+ break;
+ case SETTING_SOUND_REP_EVERY_10_MIN:
+ value = _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN;
+ break;
+ default:
+ SysLogException(NID_SYS, E_SYSTEM, "Unsupported value[%d] is provided.", current_value);
+ return E_SYSTEM;
+ }
+ }
+
+ return r;
+}
+
+result
+_SettingSoundProvider::SetValue(const String& key, const String value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _SOUND_RINGTONE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone sound feature.");
+ r = E_SUCCESS;
+
+ char* pFilePath = null;
+ SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, E_INVALID_ARG, "The entry for the specified ringtone file or the file path cannot be found");
+ pFilePath = _StringConverter::CopyToCharArrayN(value);
+
+ SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
+
+ errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, const_cast<char*>(pFilePath));
+ SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
+
+ delete [] pFilePath;
+ }
+ else if(key == _SOUND_NOTIFICATION)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notification sound feature.");
+ r = E_SUCCESS;
+
+ char* pFilePath = null;
+ SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, E_INVALID_ARG, "The entry for the specified notification file or the file path cannot be found");
+ pFilePath = _StringConverter::CopyToCharArrayN(value);
+
+ SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
+
+ errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, const_cast<char*>(pFilePath));
+ SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
+
+ delete [] pFilePath;
+ }
+ else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
+ r = E_SUCCESS;
+
+ String requestValue(value);
+
+ requestValue.ToLowerCase();
+
+ int current_value = 0;
+
+ if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE)
+ {
+ current_value = (int) SETTING_SOUND_REP_ONCE;
+ }
+ else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN)
+ {
+ current_value = (int) SETTING_SOUND_REP_EVERY_2_MIN;
+ }
+ else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN)
+ {
+ current_value = (int) SETTING_SOUND_REP_EVERY_5_MIN;
+ }
+ else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN)
+ {
+ current_value = (int) SETTING_SOUND_REP_EVERY_10_MIN;
+ }
+ else
+ {
+ SysLogException(NID_SYS, E_INVALID_ARG, "Requested value[%ls] is not supported.", value.GetPointer());
+ return E_INVALID_ARG;
+ }
+
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, current_value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
+ }
+
+
+ return r;
+}
+
+bool
+_SettingSoundProvider::HasKey(const Tizen::Base::String& key)
+{
+
+ if(key == _SOUND_MEDIA_VOLUME || key == _SOUND_NOTIFICATION_VOLUME
+ || key == _SOUND_RINGTONE_VOLUME || key == _SOUND_SYSTEM_VOLUME)
+ {
+ return true;
+ }
+ else if(key == _SOUND_RINGTONE)
+ {
+ return true;
+ }
+ else if(key == _SOUND_SILENTMODE)
+ {
+ return true;
+ }
+ else if(key == _SOUND_TOUCH || key == _SOUND_LOCK)
+ {
+ return true;
+ }
+ else if(key == _SOUND_NOTIFICATION || key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+void
+_SettingSoundProvider::SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData)
+{
+ String settingKey;
+
+ switch (type)
+ {
+ case SOUND_TYPE_SYSTEM:
+ settingKey.Append(_SOUND_SYSTEM_VOLUME);
+ break;
+ case SOUND_TYPE_MEDIA:
+ settingKey.Append(_SOUND_MEDIA_VOLUME);
+ break;
+ case SOUND_TYPE_RINGTONE:
+ settingKey.Append(_SOUND_RINGTONE_VOLUME);
+ break;
+ case SOUND_TYPE_NOTIFICATION:
+ settingKey.Append(_SOUND_NOTIFICATION_VOLUME);
+ break;
+ default:
+ SysLog(NID_SYS, "NOT IMPLEMENTED");
+ return;
+ }
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingSoundProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
+{
+ String settingKey;
+
+ if(key == SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE)
+ {
+ settingKey.Append(_SOUND_RINGTONE);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+void
+_SettingSoundProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
+{
+ String settingKey;
+
+ if(key == RUNTIME_INFO_KEY_SILENT_MODE_ENABLED)
+ {
+ settingKey.Append(_SOUND_SILENTMODE);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+void
+_SettingSoundProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if (strcmp(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SOUND_TOUCH);
+ }
+ else if(strcmp(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SOUND_LOCK);
+ }
+ else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SOUND_NOTIFICATION_REPEAT_PERIOD);
+ }
+ else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SOUND_NOTIFICATION);
+ }
+ else
+ {
+ return;
+ }
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingSoundProvider.h
+ * @brief This is the header file for the %_SettingSoundProvider class.
+ *
+ * This header file contains the declarations of the %_SettingSoundProvider class.
+ */
+
+#ifndef _FSYS_SETTING_SOUND_PROVIDER_H_
+#define _FSYS_SETTING_SOUND_PROVIDER_H_
+
+#include <media/sound_manager.h>
+#include <vconf.h>
+#include <runtime_info.h>
+#include <system/system_settings.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingSoundProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingSoundProvider();
+ virtual ~_SettingSoundProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+
+ result GetValue(const Tizen::Base::String& key, int& value);
+ result SetValue(const Tizen::Base::String& key, const int value);
+
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+private:
+ static void SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData);
+ static void SettingEventSettingInfo(system_settings_key_e key, void* userData);
+ static void SettingEventRuntimeInfo(runtime_info_key_e key, void* userData);
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingSoundProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_SOUND_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingSpeechProvider.cpp
+ * @brief This is the implementation for the _SettingSpeechProvider class.
+ */
+#include <unique_ptr.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+
+#include <FBase_StringConverter.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingSpeechProvider.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::App::Package;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _SPEECH_TTS_SCREEN = L"http://tizen.org/setting/speech.tts.screen";
+static const wchar_t* _SPEECH_TTS_SCREEN_RATE = L"http://tizen.org/setting/speech.tts.screen.rate";
+
+struct charDeleter
+{
+ void operator()(char* pValue)
+ {
+ if(pValue != null)
+ {
+ free(pValue);
+ pValue = null;
+ }
+ }
+};
+
+_SettingSpeechProvider::_SettingSpeechProvider()
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for screen reader speech rate change.");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for screen reader change.");
+ }
+}
+
+_SettingSpeechProvider::~_SettingSpeechProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for screen reader speech rate change.");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for screen reader change.");
+ }
+
+}
+
+result
+_SettingSpeechProvider::GetValue(const String& key, bool& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _SPEECH_TTS_SCREEN)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen reader.");
+ r = E_SUCCESS;
+ int current_value = 0;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, ¤t_value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_TTS key.");
+ if(current_value == 0)
+ {
+ value = false;
+ }
+ else
+ {
+ value = true;
+ }
+ }
+ return r;
+}
+
+result
+_SettingSpeechProvider::SetValueForPrivilegedKey(const String& key, bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _SPEECH_TTS_SCREEN)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen reader.");
+ r = E_SUCCESS;
+
+ int current_value = (int)value;
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, current_value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_TTS key.");
+ }
+ return r;
+}
+
+result
+_SettingSpeechProvider::GetValue(const String& key, int& value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _SPEECH_TTS_SCREEN_RATE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen reader.");
+ r = E_SUCCESS;
+
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, &value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE key.");
+ }
+ return r;
+}
+
+result
+_SettingSpeechProvider::SetValue(const String& key, const int value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _SPEECH_TTS_SCREEN_RATE)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support screen reader.");
+ r = E_SUCCESS;
+
+ SysTryReturnResult(NID_SYS, value > -1 && value < 5, E_INVALID_ARG, "Required value[%d] is not valid.", value);
+
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE key.");
+ }
+ return r;
+}
+
+bool
+_SettingSpeechProvider::HasKey(const String& key)
+{
+ if(key == _SPEECH_TTS_SCREEN_RATE || key == _SPEECH_TTS_SCREEN)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingSpeechProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if(strcmp(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SPEECH_TTS_SCREEN_RATE);
+ }
+ else if(strcmp(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_SPEECH_TTS_SCREEN);
+ }
+ else
+ {
+ return;
+ }
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingSpeechProvider.h
+ * @brief This is the header file for the %_SettingSpeechProvider class.
+ *
+ * This header file contains the declarations of the %_SettingSpeechProvider class.
+ */
+
+#ifndef _FSYS_SETTING_SPEECH_PROVIDER_H_
+#define _FSYS_SETTING_SPEECH_PROVIDER_H_
+
+#include <vconf.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingSpeechProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingSpeechProvider();
+ virtual ~_SettingSpeechProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+ result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+
+ result GetValue(const Tizen::Base::String& key, int& value);
+ result SetValue(const Tizen::Base::String& key, const int value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingSpeechProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_SPEECH_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingStorageProvider.cpp
+ * @brief This is the implementation for the _SettingStorageProvider class.
+ */
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FIo.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingStorageProvider.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _STORAGE_DIRECTORY_WAP_DOWNLOAD = L"http://tizen.org/setting/storage.directory.wap.download";
+static const wchar_t* _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD = L"http://tizen.org/setting/storage.directory.bluetooth.download";
+static const wchar_t* _STORAGE_DIRECTORY_CAMERA_RECORD = L"http://tizen.org/setting/storage.directory.camera.record";
+static const wchar_t* _STORAGE_DIRECTORY_VOICE_RECORD = L"http://tizen.org/setting/storage.directory.voice.record";
+static const wchar_t* _STORAGE_DIRECTORY_RADIO_BROADCAST = L"http://tizen.org/setting/storage.directory.radio.broadcast";
+static const wchar_t* _STORAGE_DIRECTORY_VIDEO_BROADCAST = L"http://tizen.org/setting/storage.directory.video.broadcast";
+static const wchar_t* _STORAGE_DIRECTORY_INTERNAL_MODE = L"internal";
+static const wchar_t* _STORAGE_DIRECTORY_EXTERNAL_MODE = L"external";
+
+_SettingStorageProvider::_SettingStorageProvider()
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT event listener");
+ }
+}
+
+
+_SettingStorageProvider::~_SettingStorageProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT event listener");
+ }
+}
+
+result
+_SettingStorageProvider::GetValue(const String& key, String& value)
+{
+ result r = E_OBJ_NOT_FOUND;
+ int errorCode = 0;
+ int storage_mode = 0;
+
+ if (key == _STORAGE_DIRECTORY_WAP_DOWNLOAD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT vconf");
+ SysLog(NID_SYS, "storage wap download -> %d", storage_mode);
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ SysLog(NID_SYS, "storage wap download -> %s", value.GetPointer());
+ }
+ else if (key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT vconf");
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ }
+ else if (key == _STORAGE_DIRECTORY_CAMERA_RECORD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT vconf");
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ }
+ else if (key == _STORAGE_DIRECTORY_VOICE_RECORD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT vconf");
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ }
+ else if (key == _STORAGE_DIRECTORY_RADIO_BROADCAST)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT vconf");
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ }
+ else if (key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, &storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT vconf");
+
+ switch(storage_mode)
+ {
+ case 0:
+ value = _STORAGE_DIRECTORY_INTERNAL_MODE;
+ break;
+ case 1:
+ value = _STORAGE_DIRECTORY_EXTERNAL_MODE;
+ break;
+ default:
+ r = E_SYSTEM;
+ }
+ }
+ return r;
+}
+
+result
+_SettingStorageProvider::SetValue(const String& key, const String value)
+{
+ result r = E_OBJ_NOT_FOUND;
+ int storage_mode = 0;
+ int errorCode = 0;
+ if(key == _STORAGE_DIRECTORY_WAP_DOWNLOAD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT vconf");
+ }
+ else if(key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT vconf");
+ }
+ else if(key == _STORAGE_DIRECTORY_CAMERA_RECORD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT vconf");
+ }
+ else if(key == _STORAGE_DIRECTORY_VOICE_RECORD)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT vconf");
+ }
+ else if(key == _STORAGE_DIRECTORY_RADIO_BROADCAST)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT vconf");
+ }
+ else if(key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support storage feature.");
+ r = E_SUCCESS;
+
+ String lowerValue;
+ value.ToLowerCase(lowerValue);
+
+ if(lowerValue == _STORAGE_DIRECTORY_INTERNAL_MODE)
+ {
+ storage_mode = 0;
+ }
+ else if(lowerValue == _STORAGE_DIRECTORY_EXTERNAL_MODE)
+ {
+ storage_mode = 1;
+ }
+ else
+ {
+ return E_UNSUPPORTED_OPERATION;
+ }
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, storage_mode);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT vconf");
+ }
+ return r;
+}
+
+bool
+_SettingStorageProvider::HasKey(const Tizen::Base::String& key)
+{
+ if(key == _STORAGE_DIRECTORY_WAP_DOWNLOAD
+ || key == _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD
+ || key == _STORAGE_DIRECTORY_CAMERA_RECORD
+ || key == _STORAGE_DIRECTORY_VOICE_RECORD
+ || key == _STORAGE_DIRECTORY_RADIO_BROADCAST
+ || key == _STORAGE_DIRECTORY_VIDEO_BROADCAST)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingStorageProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_WAP_DOWNLOAD);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_CAMERA_RECORD);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_VOICE_RECORD);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_RADIO_BROADCAST);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_STORAGE_DIRECTORY_VIDEO_BROADCAST);
+ }
+ else
+ {
+ return;
+ }
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingStorageProvider.h
+ * @brief This is the header file for the %_SettingStorageProvider class.
+ *
+ * This header file contains the declarations of the %_SettingStorageProvider class.
+ */
+
+#ifndef _FSYS_SETTING_STORAGE_PROVIDER_H_
+#define _FSYS_SETTING_STORAGE_PROVIDER_H_
+
+#include <media/sound_manager.h>
+#include <vconf.h>
+
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingStorageProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingStorageProvider();
+ virtual ~_SettingStorageProvider();
+
+public:
+ result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
+ result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
+
+ bool HasKey(const Tizen::Base::String& key);
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingStorageProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_STORAGE_PROVIDER_H_
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingVibrationProvider.cpp
+ * @brief This is the implementation for the _SettingVibrationProvider class.
+ */
+
+#include <runtime_info.h>
+#include <haptic/haptic.h>
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FBaseSysLog.h>
+#include <FIo.h>
+
+#include "FSys_SettingInfo.h"
+#include "FSys_SettingVibrationProvider.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+static const wchar_t* _VIBRATOR = L"http://tizen.org/setting/vibrator";
+static const wchar_t* _VIBRATOR_LEVEL = L"http://tizen.org/setting/vibrator.level";
+static const wchar_t* _VIBRATOR_LEVEL_NOTIFICATION = L"http://tizen.org/setting/vibrator.level.notification";
+
+_SettingVibrationProvider::_SettingVibrationProvider()
+{
+ int errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT event listener");
+ }
+
+ errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, SettingEventVConf, null);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT event listener");
+ }
+}
+
+
+_SettingVibrationProvider::~_SettingVibrationProvider()
+{
+ int errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT event listener");
+ }
+
+ errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, SettingEventVConf);
+ if(errorCode != 0)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT event listener");
+ }
+}
+
+result
+_SettingVibrationProvider::GetValue(const String& key, bool& value)
+{
+ int enabled = false;
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _VIBRATOR)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+ errorCode = vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &enabled);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL vconf.");
+ value = enabled ? true : false;
+ }
+ return r;
+}
+
+result
+_SettingVibrationProvider::SetValue(const String& key, const bool value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ haptic_device_h __hapticHandle;
+
+ if(key == _VIBRATOR)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+ if(!value)
+ {
+ errorCode = haptic_open(HAPTIC_DEVICE_0, &__hapticHandle);
+ SysTryReturnResult(NID_SYS, errorCode == HAPTIC_ERROR_NONE, E_SYSTEM, "It is failed to open haptic library.");
+ haptic_stop_all_effects(__hapticHandle);
+ errorCode = haptic_close(__hapticHandle);
+ SysTryReturnResult(NID_SYS, errorCode == HAPTIC_ERROR_NONE, E_SYSTEM, "It is failed to close haptic library.");
+ __hapticHandle = null;
+ }
+ errorCode = vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL vconf.");
+ }
+ return r;
+}
+
+result
+_SettingVibrationProvider::GetValue(const String& key, int& value)
+{
+ int level = 0;
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+
+ if(key == _VIBRATOR_LEVEL)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ errorCode = vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &level);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT vconf");
+ value = level;
+ }
+ else if (key == _VIBRATOR_LEVEL_NOTIFICATION)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ int errorCode = vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT vconf");
+ value = level;
+ }
+ return r;
+}
+
+result
+_SettingVibrationProvider::SetValue(const String& key, const int value)
+{
+ int errorCode = 0;
+ result r = E_OBJ_NOT_FOUND;
+ if(key == _VIBRATOR_LEVEL)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ SysTryReturnResult(NID_SYS, value >= 0 && value <= 5, E_INVALID_ARG, "Speicified value is not valid");
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT vconf");
+ }
+ else if(key == _VIBRATOR_LEVEL_NOTIFICATION)
+ {
+ SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support vibrator feature.");
+ r = E_SUCCESS;
+
+ SysTryReturnResult(NID_SYS, value >= 0 && value <= 5, E_INVALID_ARG, "Speicified value is not valid");
+ errorCode = vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, value);
+ SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT vconf");
+ }
+ return r;
+}
+
+bool
+_SettingVibrationProvider::HasKey(const Tizen::Base::String& key)
+{
+
+ if(key == _VIBRATOR_LEVEL_NOTIFICATION
+ || key == _VIBRATOR_LEVEL
+ || key == _VIBRATOR)
+ {
+ return true;
+ }
+ return false;
+}
+
+void
+_SettingVibrationProvider::SettingEventVConf(keynode_t* node, void* userData)
+{
+ String settingKey;
+
+ if (strcmp(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_VIBRATOR);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_VIBRATOR_LEVEL);
+ }
+ else if (strcmp(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, vconf_keynode_get_name(node)) == 0)
+ {
+ settingKey.Append(_VIBRATOR_LEVEL_NOTIFICATION);
+ }
+ else
+ {
+ return;
+ }
+
+ _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
+ SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
+
+ result r = pSettingInfo->AnnounceSettingEvent(settingKey);
+ SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
+}
+
+}}
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_SettingVibrationProvider.h
+ * @brief This is the header file for the %_SettingVibrationProvider class.
+ *
+ * This header file contains the declarations of the %_SettingVibrationProvider class.
+ */
+
+#ifndef _FSYS_SETTING_VIBRATION_PROVIDER_H_
+#define _FSYS_SETTING_VIBRATION_PROVIDER_H_
+
+#include <vconf.h>
+#include "FSys_ISettingProvider.h"
+
+namespace Tizen { namespace System
+{
+
+class _SettingVibrationProvider
+ : virtual public Tizen::System::_ISettingProvider
+{
+public:
+ _SettingVibrationProvider();
+ virtual ~_SettingVibrationProvider();
+
+public:
+ Tizen::Base::String GetId(void);
+
+ result GetValue(const Tizen::Base::String& key, bool& value);
+ result SetValue(const Tizen::Base::String& key, const bool value);
+
+ result GetValue(const Tizen::Base::String& key, int& value);
+ result SetValue(const Tizen::Base::String& key, const int value);
+
+ bool HasKey(const Tizen::Base::String& key);
+
+private:
+ static void SettingEventVConf(keynode_t* node, void* userData);
+}; // _SettingVibrationProvider
+
+}} // Tizen::System
+
+#endif // _FSYS_ISETTING_VIBRATION_PROVIDER_H_