src/system/FSys_DeviceId.cpp
src/system/FSys_RuntimeInfo.cpp
src/system/FSys_PowerManager.cpp
- src/FSys_SettingService.cpp
- src/setting/FSys_SettingApplicationProvider.cpp
- src/setting/FSys_Icu.cpp
- src/setting/FSys_SettingFontProvider.cpp
- src/setting/FSys_SettingGeneralProvider.cpp
- src/setting/FSys_SettingLocaleProvider.cpp
- src/setting/FSys_SettingLocationProvider.cpp
- src/setting/FSys_SettingNetworkProvider.cpp
- src/setting/FSys_SettingScreenProvider.cpp
- src/setting/FSys_SettingSoundProvider.cpp
- src/setting/FSys_SettingStorageProvider.cpp
- src/setting/FSys_SettingVibrationProvider.cpp
- src/setting/FSys_SettingSpeechProvider.cpp
src/FShell_LockManagerService.cpp
src/FShell_LockManagerStub.cpp
)
class _AlarmService;
class _AccessoryManagerService;
class _DeviceManagerService;
-class _SettingService;
class _SystemService;
}}
_TaskHandlerThread __handlerThread;
Tizen::System::_DeviceManagerService* __pDeviceManagerService;
Tizen::System::_SystemService* __pSystemService;
- Tizen::System::_SettingService* __pSettingService;
Tizen::System::_AccessoryManagerService* __pAccessoryManagerService;
Tizen::App::_PackageManagerStub* __pPackageManagerStub;
Tizen::Io::_MmcStorageManagerStub* __pMmcStorageManagerStub;
+++ /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_SettingService.h
- * @brief This is the header file of the _SettingService class.
- *
- * This header file contains the declarations of the _SettingService class.
- */
-#include <FApp.h>
-#include <FBase.h>
-
-#include "FApp_CommunicationDispatcher.h"
-#include "FApp_ICommunicationRequestListener.h"
-#include "FSys_ISettingProvider.h"
-
-#ifndef _FSYS_INTERNAL_SETTING_SERVICE_H_
-#define _FSYS_INTERNAL_SETTING_SERVICE_H_
-
-namespace Tizen { namespace System {
-
-static const wchar_t* _SETTING_PREFIX = L"http://tizen.org/setting/";
-
-/**
- * @class _SettingService
- * @brief This class provides setting information.
- * @since 2.1
- */
-class _SettingService
- : public Tizen::App::_ICommunicationRequestListener
-{
-private:
- _SettingService(void);
- virtual ~_SettingService(void);
-public:
- virtual Tizen::Base::String GetId(void);
- virtual void OnRequestOccured(Tizen::App::AppId appId, int pid, Tizen::Base::Collection::ArrayList* request, Tizen::Base::Collection::ArrayList* response);
- virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid);
-
- result RegisterSettingProvider(_ISettingProvider& settingProvider);
- result UnregisterSettingProvider(_ISettingProvider& settingProvider);
- result SendEvent(Tizen::Base::String key);
- result SendEventForInternal(Tizen::Base::String key);
- result SendResponse(int pid, Tizen::Base::String responseId, Tizen::Base::String key, Tizen::Base::String value);
-
-public:
- static _SettingService* GetInstance(void);
-
-private:
- Tizen::Base::Collection::HashMapT<Tizen::Base::String, _ISettingProvider*> __settingProviderList;
- Tizen::App::_CommunicationDispatcher* __pCommunicationDispatcher;
- Tizen::Base::Collection::ArrayList __eventListenerList;
- Tizen::Base::Collection::ArrayList __eventListenerListForInternal;
-
- Tizen::Base::Runtime::Mutex __eventProtect;
- bool __firstRequest;
-
- static _SettingService* __pSettingService;
-
-private:
-
- 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;
- }
- };
-
-}; //_SettingService
-
-}} //Tizen::System
-#endif /* _FSYS_INTERNAL_SETTING_SERVICE_H_ */
#include "FApp_ConditionManagerStub.h"
#include "FSys_DeviceManagerService.h"
#include "FSys_SystemService.h"
-#include "FSys_SettingService.h"
#include "FSys_AccessoryManagerService.h"
#include "FApp_PackageManagerStub.h"
#include "FAppPkg_PackageManagerImpl.h"
, __handlerThread(*this)
, __pDeviceManagerService(null)
, __pSystemService(null)
-, __pSettingService(null)
, __pAccessoryManagerService(null)
, __pPackageManagerStub(null)
, __pMmcStorageManagerStub(null)
SysAssert( __pSystemService != null);
SysTryReturnVoidResult(NID_APP, __pSystemService != null, E_OUT_OF_MEMORY, "It is failed to _SystemService creation.");
- __pSettingService = _SettingService::GetInstance();
- SysAssert( __pSettingService != null);
- SysTryReturnVoidResult(NID_APP, __pSettingService != null, E_OUT_OF_MEMORY, "It is failed to SettingService creation.");
-
__pAccessoryManagerService = _AccessoryManagerService::GetInstance();
SysAssert( __pAccessoryManagerService != null);
SysTryReturnVoidResult(NID_APP, __pAccessoryManagerService != null, E_OUT_OF_MEMORY, "It is failed to _AccessoryManagerService creation.");
+++ /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_SettingService.cpp
- * @brief This is the implementation file for _SettingService class.
- */
-#include <unique_ptr.h>
-#include <new>
-#include <errno.h>
-#include <sysman.h>
-
-#include <FBaseSysLog.h>
-#include <FBaseColAllElementsDeleter.h>
-#include <FIoFile.h>
-
-#include <FSec_AccessController.h>
-
-#include "FSys_SettingService.h"
-
-#include "FSys_SettingApplicationProvider.h"
-#include "FSys_SettingFontProvider.h"
-#include "FSys_SettingGeneralProvider.h"
-#include "FSys_SettingLocaleProvider.h"
-#include "FSys_SettingLocationProvider.h"
-#include "FSys_SettingNetworkProvider.h"
-#include "FSys_SettingScreenProvider.h"
-#include "FSys_SettingSpeechProvider.h"
-#include "FSys_SettingSoundProvider.h"
-#include "FSys_SettingStorageProvider.h"
-#include "FSys_SettingVibrationProvider.h"
-
-using namespace std;
-
-using namespace Tizen::App;
-using namespace Tizen::Io;
-using namespace Tizen::System;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Utility;
-using namespace Tizen::Security;
-
-namespace {
- static const wchar_t* _SETTING_SERVICE_ID = L"osp.setting.service";
- static const wchar_t* _SETTING_SERVICE_TYPE_EVENT = L"osp.setting.service.type.event";
-
- static const wchar_t* _SETTING_COMMAND_GET_BOOL = L"osp.setting.command.get.bool";
- static const wchar_t* _SETTING_COMMAND_SET_BOOL = L"osp.setting.command.set.bool";
- static const wchar_t* _SETTING_COMMAND_SET_BOOL_ASYNC = L"osp.setting.command.set.bool.async";
- static const wchar_t* _SETTING_COMMAND_GET_BOOL_PRIV = L"osp.setting.command.get.bool.priv";
- static const wchar_t* _SETTING_COMMAND_SET_BOOL_PRIV = L"osp.setting.command.set.bool.priv";
- static const wchar_t* _SETTING_COMMAND_SET_BOOL_ASYNC_PRIV = L"osp.setting.command.set.bool.async.priv";
-
- static const wchar_t* _SETTING_COMMAND_GET_INT = L"osp.setting.command.get.int";
- static const wchar_t* _SETTING_COMMAND_SET_INT = L"osp.setting.command.set.int";
-
- static const wchar_t* _SETTING_COMMAND_GET_STRING = L"osp.setting.command.get.string";
- static const wchar_t* _SETTING_COMMAND_SET_STRING = L"osp.setting.command.set.string";
- static const wchar_t* _SETTING_COMMAND_SET_STRING_PRIV = L"osp.setting.command.set.string.priv";
- static const wchar_t* _SETTING_COMMAND_SET_STRING_ASYNC = L"osp.setting.command.set.string.async";
-
- static const wchar_t* _SETTING_COMMAND_FACTORY_RESET = L"osp.setting.command.factory.reset";
- static const char* _BIN_FACTORY_RESET = "/usr/bin/factory-reset";
-
- static const wchar_t* _SETTING_COMMAND_ADD_EVENT = L"osp.setting.command.add.event";
- static const wchar_t* _SETTING_COMMAND_REMOVE_EVENT = L"osp.setting.command.remove.event";
-
- static const wchar_t* _SETTING_COMMAND_ADD_EVENT_INTERNAL = L"osp.setting.command.add.event.internal";
- static const wchar_t* _SETTING_COMMAND_REMOVE_EVENT_INTERNAL = L"osp.setting.command.remove.event.internal";
- static const wchar_t* _SETTING_SERVICE_TYPE_EVENT_INTERNAL = L"osp.setting.service.type.event.internal";
-
- static const wchar_t* _SETTING_COMMAND_SUPPORTED = L"osp.setting.command.supported";
-
- static const wchar_t* _SETTING_RESULT_SUCCESS = L"osp.system.result.success";
- static const wchar_t* _SETTING_RESULT_SYSTEM = L"osp.system.result.system";
- static const wchar_t* _SETTING_RESULT_INVALID_ARG = L"osp.system.result.invalid_arg";
- static const wchar_t* _SETTING_RESULT_PRIVILEGED_DENIED = L"osp.system.result.privilege_denied";
- static const wchar_t* _SETTING_RESULT_UNSUPPORTED_OPERATION = L"osp.system.result.unsupported_operation";
- static const wchar_t* _SETTING_RESULT_OBJ_NOT_FOUND = L"osp.system.result.obj_not_found";
- static const wchar_t* _SETTING_RESULT_OBJ_ALREADY_EXIST = L"osp.system.result.obj_already_exist";
- static const wchar_t* _SETTING_RESULT_IN_PROGRESS = L"osp.system.result.in_progress";
- static const int _SETTING_COMMAND_ID = 1;
-
- static const int _SETTING_COMMAND_ARG = 2;
-
- //Special Cases (It is not supported by proper provider.)
- static const wchar_t* _SETTING_KEY_FOR_EXCEPT_USB_TETHERING = L"http://tizen.org/setting/usb.tethering"; //It is covered by netowrk provider.
- static const wchar_t* _SETTING_KEY_FOR_EXCEPT_USB_TETHERING_PROVIDER_KEY = L"network";
-
-}
-
-namespace Tizen { namespace System
-{
-
-Tizen::System::_SettingService* Tizen::System::_SettingService::__pSettingService = null;
-
-_SettingService::_SettingService()
- : _ICommunicationRequestListener()
- , __pCommunicationDispatcher(null)
- , __firstRequest(true)
-{
- static _StringHashProvider hashProvider;
- static _StringComparer stringComparer;
-
- result r = E_SUCCESS;
- __pCommunicationDispatcher = _CommunicationDispatcher::GetInstance();
- SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher initiate is failed.");
-
- r = __pCommunicationDispatcher->AddCommunicationEventListener(*this);
- SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to add event listener.");
-
- __settingProviderList.Construct(0, 0, hashProvider, stringComparer);
- __eventListenerList.Construct();
- __eventListenerListForInternal.Construct();
- __eventProtect.Create();
-
-
-CATCH:
- SetLastResult(r);
-}
-
-_SettingService::~_SettingService()
-{
- result r = E_SUCCESS;
- SysTryCatch(NID_SYS, __pCommunicationDispatcher != null, r = E_SYSTEM, E_SYSTEM, "_CommunicationDispatcher is not ready");
-
- r = __pCommunicationDispatcher->RemoveCommunicationEventListener(*this);
- SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "It is failed to remove event listener.");
-
-CATCH:
- SetLastResult(r);
-}
-
-_SettingService*
-_SettingService::GetInstance(void)
-{
- if(__pSettingService == null)
- {
- __pSettingService = new (std::nothrow) _SettingService();
- }
- return __pSettingService;
-}
-
-String
-_SettingService::GetId(void)
-{
- return _SETTING_SERVICE_ID;
-}
-
-result
-_SettingService::RegisterSettingProvider(_ISettingProvider& settingProvider)
-{
- bool registered = false;
- result r = E_SUCCESS;
-
- r = __settingProviderList.ContainsKey(settingProvider.GetId(), registered);
- if(registered == false && r == E_SUCCESS)
- {
- String* providerId = new String(settingProvider.GetId());
- SysLog(NID_SYS, "Provider Id is %ls[%x]", providerId->GetPointer(), &settingProvider);
- return __settingProviderList.Add(*providerId, &settingProvider);
- }
-
- if(r != E_SUCCESS)
- {
- return E_SYSTEM;
- }
-
- return E_OBJ_ALREADY_EXIST;
-}
-
-result
-_SettingService::UnregisterSettingProvider(_ISettingProvider& settingProvider)
-{
- bool registered = false;
- result r = E_SUCCESS;
-
- r = __settingProviderList.ContainsKey(settingProvider.GetId(), registered);
- if(registered == true && r == E_SUCCESS)
- {
- return __settingProviderList.Remove(settingProvider.GetId());
- }
-
- if(r != E_SUCCESS)
- {
- return E_SYSTEM;
- }
-
- return E_OBJ_NOT_FOUND;
-}
-
-void
-_SettingService::OnRequestOccured(AppId appId, int pid, ArrayList* request, ArrayList* response)
-{
- result r = E_SYSTEM;
- int index = 0;
- String* command = (String*) request->GetAt(_SETTING_COMMAND_ID);
- String* key = (String*) request->GetAt(_SETTING_COMMAND_ARG);
- String* value = null;
- String requiredKey;
- String requiredProvider;
- Integer processId(pid);
-
- if(__firstRequest == true)
- {
- static _SettingApplicationProvider applicationProvider;
- static _SettingFontProvider fontProvider;
- static _SettingGeneralProvider generalProvider;
- static _SettingLocaleProvider localeProvider;
- static _SettingLocationProvider locationProvider;
- static _SettingNetworkProvider networkProvider;
- static _SettingScreenProvider screenProvider;
- static _SettingSpeechProvider speechProvider;
- static _SettingSoundProvider soundProvider;
- static _SettingStorageProvider storageProvider;
- static _SettingVibrationProvider vibrationProvider;
- __firstRequest = false;
- }
- _ISettingProvider* pProvider = null;
-
- SysTryCatch(NID_SYS, command != null, r = E_SYSTEM, E_SYSTEM, "Required command is empty.");
-
- if(*command == _SETTING_COMMAND_ADD_EVENT)
- {
- SysLog(NID_SYS, "Setting Event subscription is required.");
-
- if(__eventListenerList.Contains(processId) == false)
- {
- __eventProtect.Acquire();
- r = __eventListenerList.Add(new (std::nothrow) Integer(pid));
- __eventProtect.Release();
- }
- else
- {
- SysLogException(NID_SYS, E_OBJ_ALREADY_EXIST, "Required Application[%ls] is already registered.", appId.GetPointer());
- r = E_OBJ_ALREADY_EXIST;
- }
- }
- else if(*command == _SETTING_COMMAND_REMOVE_EVENT)
- {
- SysLog(NID_SYS, "Setting Event un-subscription is required.");
- if(__eventListenerList.Contains(processId) == true)
- {
- __eventProtect.Acquire();
- r = __eventListenerList.Remove(processId, true);
- __eventProtect.Release();
- }
- else
- {
- SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "Required Application[%ls] is not registered.", appId.GetPointer());
- r = E_OBJ_NOT_FOUND;
- }
- }
- else if(*command == _SETTING_COMMAND_ADD_EVENT_INTERNAL)
- {
- SysLog(NID_SYS, "Setting Event subscription is required. (Internal)");
-
- if(__eventListenerListForInternal.Contains(processId) == false)
- {
- __eventProtect.Acquire();
- r = __eventListenerListForInternal.Add(new (std::nothrow) Integer(pid));
- __eventProtect.Release();
- }
- else
- {
- SysLogException(NID_SYS, E_OBJ_ALREADY_EXIST, "Required Application[%ls] is already registered.", appId.GetPointer());
- r = E_OBJ_ALREADY_EXIST;
- }
- }
- else if(*command == _SETTING_COMMAND_REMOVE_EVENT_INTERNAL)
- {
- SysLog(NID_SYS, "Setting Event un-subscription is required. (Internal)");
- if(__eventListenerListForInternal.Contains(processId) == true)
- {
- __eventProtect.Acquire();
- r = __eventListenerListForInternal.Remove(processId, true);
- __eventProtect.Release();
- }
- else
- {
- SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "Required Application[%ls] is not registered.", appId.GetPointer());
- r = E_OBJ_NOT_FOUND;
- }
- }
- else if(*command == _SETTING_COMMAND_FACTORY_RESET)
- {
- SysLog(NID_SYS, "Warning !!!, Factory reset is required.");
-
- r = _AccessController::CheckSystemPrivilege(appId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE);
-
- if(r == E_SUCCESS)
- {
- if(File::IsFileExist(_BIN_FACTORY_RESET) == false)
- {
- SysLog(NID_SYS, "Current device does not support Factory Reset.");
- r = E_UNSUPPORTED_OPERATION;
- }
- else
- {
- SysLog(NID_SYS, "Warning !!!, Factory reset is started.");
- if(sysman_call_predef_action("launchfr", 0, NULL) == 0)
- {
- SysLog(NID_SYS, "Warning !!!, Factory reset is started.");
- r = E_SUCCESS;
- value = new (std::nothrow) String();
- value->Append(strerror(errno));
- }
- else
- {
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute factory reset.");
- r = E_SYSTEM;
- }
- }
- }
- }
- else
- {
- SysTryCatch(NID_SYS, key != null, r = E_SYSTEM, E_SYSTEM, "Required key is empty.");
-
- String requiredPrefix;
- String settingPrefix(_SETTING_PREFIX);
-
- key->SubString(0, settingPrefix.GetLength(), requiredPrefix);
- SysTryCatch(NID_SYS, settingPrefix == requiredPrefix, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "Required key[%ls] is not valid.", key->GetPointer());
-
- key->SubString(settingPrefix.GetLength(), requiredKey);
- r = requiredKey.IndexOf(".", 0, index);
-
- if(r == E_SUCCESS)
- {
- r = requiredKey.SubString(0, index, requiredProvider);
- }
- else if(r == E_OBJ_NOT_FOUND)
- {
- requiredProvider = requiredKey;
- }
-
- //Special case
- if(*key == _SETTING_KEY_FOR_EXCEPT_USB_TETHERING)
- {
- requiredProvider = _SETTING_KEY_FOR_EXCEPT_USB_TETHERING_PROVIDER_KEY;
- }
-
- r = __settingProviderList.GetValue(requiredProvider, pProvider);
- SysLog(NID_SYS, "Required Provider key is %ls[%x].", requiredProvider.GetPointer(), pProvider);
-
- if(r != E_SUCCESS)
- {
- SysLogException(NID_SYS, E_SYSTEM, "There is no provider[%s] for key[%ls].", GetErrorMessage(r), requiredProvider.GetPointer());
- pProvider = null;
- }
-
- if(pProvider != null)
- {
- SysLog(NID_SYS, "Required command is [%ls / %ls].", command->GetPointer(), requiredKey.GetPointer());
-
- if(*command == _SETTING_COMMAND_GET_BOOL)
- {
- bool tValue = false;
- r = pProvider->GetValue(requiredKey, tValue);
- if(r == E_SUCCESS)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- value = new (std::nothrow) String();
- value->Append(tValue);
- }
- else
- {
- SysLogException(NID_SYS, r, "It is failed to get %ls on provider[%ls].", requiredKey.GetPointer(), pProvider->GetId().GetPointer());
- }
- }
- else if(*command == _SETTING_COMMAND_SET_BOOL)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- bool tValue = Boolean::Parse(*requiredValue, false);
- r = pProvider->SetValue(requiredKey, tValue);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- }
- }
- else if(*command == _SETTING_COMMAND_SET_BOOL_ASYNC)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- bool tValue = Boolean::Parse(*requiredValue, false);
- r = pProvider->SetValueAsync(appId, pid, requiredKey, tValue);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- }
- }
- else if(*command == _SETTING_COMMAND_GET_BOOL_PRIV)
- {
- r = _AccessController::CheckSystemPrivilege(appId, _PRV_SYSTEMSETTING_READ, _PRV_SETTINGMANAGER_READ);
- if(r == E_SUCCESS)
- {
- bool tValue = false;
- r = pProvider->GetValueForPrivilegedKey(requiredKey, tValue);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- value = new (std::nothrow) String(tValue);
- }
- else
- {
- SysLogException(NID_SYS, E_PRIVILEGE_DENIED, "The application[%ls] does not have the privilege to call this method.", appId.GetPointer());
- r = E_PRIVILEGE_DENIED;
- }
- }
- else if(*command == _SETTING_COMMAND_SET_BOOL_PRIV)
- {
- r = _AccessController::CheckSystemPrivilege(appId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE);
- if(r == E_SUCCESS)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- bool tValue = Boolean::Parse(*requiredValue, false);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- r = pProvider->SetValueForPrivilegedKey(requiredKey, tValue);
- }
- }
- else
- {
- SysLogException(NID_SYS, E_PRIVILEGE_DENIED, "The application[%ls] does not have the privilege to call this method.", appId.GetPointer());
- r = E_PRIVILEGE_DENIED;
- }
- }
- else if(*command == _SETTING_COMMAND_SET_BOOL_ASYNC_PRIV)
- {
- r = _AccessController::CheckSystemPrivilege(appId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE);
- if(r == E_SUCCESS)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- bool tValue = Boolean::Parse(*requiredValue, false);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- r = pProvider->SetValueAsyncForPrivilegedKey(appId, pid, requiredKey, tValue);
- }
- }
- else
- {
- SysLogException(NID_SYS, E_PRIVILEGE_DENIED, "The application[%ls] does not have the privilege to call this method.", appId.GetPointer());
- r = E_PRIVILEGE_DENIED;
- }
- }
- else if(*command == _SETTING_COMMAND_GET_INT)
- {
- int tValue = 0;
- r = pProvider->GetValue(requiredKey, tValue);
- if(r == E_SUCCESS)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s.", requiredKey.GetPointer(), tValue, GetErrorMessage(r));
- value = new (std::nothrow) String();
- value->Append(tValue);
- }
- else
- {
- SysLogException(NID_SYS, r, "It is failed to get %ls on provider[%ls].", requiredKey.GetPointer(), pProvider->GetId().GetPointer());
- }
- }
- else if(*command == _SETTING_COMMAND_SET_INT)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- int tValue = 0;
- Integer::Parse(*requiredValue, tValue);
- SysLog(NID_SYS, "RequiredKey[%ls] value is %d and result is %s. %ls", requiredKey.GetPointer(), tValue, GetErrorMessage(r), requiredValue->GetPointer());
- r = pProvider->SetValue(requiredKey, tValue);
- }
- }
- else if(*command == _SETTING_COMMAND_GET_STRING)
- {
- String tValue = 0;
- r = pProvider->GetValue(requiredKey, tValue);
- if(r == E_SUCCESS)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %ls", requiredKey.GetPointer(), tValue.GetPointer());
- value = new (std::nothrow) String();
- value->Append(tValue);
- }
- else
- {
- SysLogException(NID_SYS, r, "It is failed to get %ls on provider[%ls].", requiredKey.GetPointer(), pProvider->GetId().GetPointer());
- }
- }
- else if(*command == _SETTING_COMMAND_SET_STRING)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %ls", requiredKey.GetPointer(), requiredValue->GetPointer());
- r = pProvider->SetValue(requiredKey, *requiredValue);
- }
- }
- else if(*command == _SETTING_COMMAND_SET_STRING_PRIV)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %ls", requiredKey.GetPointer(), requiredValue->GetPointer());
- r = pProvider->SetValueForPrivilegedKey(requiredKey, *requiredValue);
- }
- }
- else if(*command == _SETTING_COMMAND_SET_STRING_ASYNC)
- {
- String* requiredValue = (String*)(request->GetAt(_SETTING_COMMAND_ARG + 1));
- if(requiredValue != null)
- {
- SysLog(NID_SYS, "RequiredKey[%ls] value is %ls", requiredKey.GetPointer(), requiredValue->GetPointer());
- r = pProvider->SetValueAsync(appId, pid, requiredKey, *requiredValue);
- }
- }
- else if(*command == _SETTING_COMMAND_SUPPORTED)
- {
- bool supported = false;
- SysLog(NID_SYS, "RequiredKey[%ls]", requiredKey.GetPointer());
- supported = pProvider->HasKey(requiredKey);
- value = new (std::nothrow) String();
- value->Append(supported);
- }
-
- SysLog(NID_SYS, "result code is %s", GetErrorMessage(r));
- }
- }
-
-CATCH:
- String* serviceId = new (std::nothrow) String(_SETTING_SERVICE_ID);
- String* commandCode = new (std::nothrow) String(*command);
- String* resultCode = new (std::nothrow) String();
-
- SysLog(NID_SYS, "result code is %s", GetErrorMessage(r));
- if(r == E_SUCCESS)
- {
- resultCode->Append(_SETTING_RESULT_SUCCESS);
- }
- else if(r == E_IN_PROGRESS)
- {
- resultCode->Append(_SETTING_RESULT_IN_PROGRESS);
- }
- else if(r == E_INVALID_ARG)
- {
- resultCode->Append(_SETTING_RESULT_INVALID_ARG);
- }
- else if(r == E_UNSUPPORTED_OPERATION)
- {
- resultCode->Append(_SETTING_RESULT_UNSUPPORTED_OPERATION);
- }
- else if(r == E_OBJ_NOT_FOUND)
- {
- resultCode->Append(_SETTING_RESULT_OBJ_NOT_FOUND);
- }
- else if(r == E_OBJ_ALREADY_EXIST)
- {
- resultCode->Append(_SETTING_RESULT_OBJ_ALREADY_EXIST);
- }
- else if(r == E_PRIVILEGE_DENIED)
- {
- resultCode->Append(_SETTING_RESULT_PRIVILEGED_DENIED);
- }
- else
- {
- resultCode->Append(_SETTING_RESULT_SYSTEM);
- }
-
- response->Add(serviceId);
- response->Add(commandCode);
- response->Add(resultCode);
-
- if(value != null)
- {
- response->Add(value);
- }
-}
-
-result
-_SettingService::SendEvent(String key)
-{
- result r = E_SUCCESS;
- unique_ptr<IEnumerator> pEnum(__eventListenerList.GetEnumeratorN());
-
- SysTryReturnResult(NID_SYS, pEnum != null, E_SYSTEM, "There is no listener(s).");
-
- SysTryReturnResult(NID_SYS, __pCommunicationDispatcher != null, E_SYSTEM, "Communication Dispatcher is not ready.");
-
- __eventProtect.Acquire();
- while(pEnum->MoveNext() == E_SUCCESS)
- {
- Integer* pProcessId = (Integer*)pEnum->GetCurrent();
- SysTryReturnResult(NID_SYS, pProcessId != null, E_SYSTEM, "There is no listener id.");
-
- ArrayList* data = new (std::nothrow) ArrayList(SingleObjectDeleter);
- data->Construct();
- data->Add(new (std::nothrow) String(_SETTING_SERVICE_ID));
- data->Add(new (std::nothrow) String(_SETTING_SERVICE_TYPE_EVENT));
- data->Add(new (std::nothrow) String(key));
- r = __pCommunicationDispatcher->SendData(pProcessId->value, data); // Ownership is transfered.
- if(r != E_SUCCESS)
- {
- SysLog(NID_SYS, "Required Key[%ls] is failed to delivered to application[%d]. [%s]", key.GetPointer(), pProcessId->value, GetErrorMessage(r));
- }
- else
- {
- SysLog(NID_SYS, "Required Key[%ls] is delivered to application[%d] successfully.", key.GetPointer(), pProcessId->value);
- }
- }
- __eventProtect.Release();
- return E_SUCCESS;
-}
-
-result
-_SettingService::SendEventForInternal(String key)
-{
- result r = E_SUCCESS;
- unique_ptr<IEnumerator> pEnum(__eventListenerListForInternal.GetEnumeratorN());
-
- SysTryReturnResult(NID_SYS, pEnum != null, E_SYSTEM, "There is no listener(s).");
-
- SysTryReturnResult(NID_SYS, __pCommunicationDispatcher != null, E_SYSTEM, "Communication Dispatcher is not ready.");
-
- __eventProtect.Acquire();
- while(pEnum->MoveNext() == E_SUCCESS)
- {
- Integer* pProcessId = (Integer*)pEnum->GetCurrent();
- SysTryReturnResult(NID_SYS, pProcessId != null, E_SYSTEM, "There is no listener id.");
-
- ArrayList* data = new (std::nothrow) ArrayList(SingleObjectDeleter);
- data->Construct();
- data->Add(new (std::nothrow) String(_SETTING_SERVICE_ID));
- data->Add(new (std::nothrow) String(_SETTING_SERVICE_TYPE_EVENT_INTERNAL));
- data->Add(new (std::nothrow) String(key));
-
- r = __pCommunicationDispatcher->SendData(pProcessId->value, data); // Ownership is transfered.
- if(r != E_SUCCESS)
- {
- SysLog(NID_SYS, "Required Key[%ls] is failed to delivered to application[%d]. [%s]", key.GetPointer(), pProcessId->value, GetErrorMessage(r));
- }
- else
- {
- SysLog(NID_SYS, "Required Key[%ls] is delivered to application[%d] successfully.", key.GetPointer(), pProcessId->value);
- }
- }
- __eventProtect.Release();
- return E_SUCCESS;
-}
-
-result
-_SettingService::SendResponse(int pid, String responseId, String key, String value)
-{
- SysTryReturnResult(NID_SYS, __pCommunicationDispatcher != null, E_SYSTEM, "Communication Dispatcher is not ready.");
-
- String serviceId(_SETTING_SERVICE_ID);
-
- ArrayList* data = new (std::nothrow) ArrayList(SingleObjectDeleter);
- data->Construct();
- data->Add(new (std::nothrow) String(_SETTING_SERVICE_ID));
- data->Add(new (std::nothrow) String(responseId));
- data->Add(new (std::nothrow) String(key));
- data->Add(new (std::nothrow) String(value));
-
- return __pCommunicationDispatcher->SendData(pid, data);
-}
-
-void
-_SettingService::OnApplicationTerminated(const Tizen::App::AppId& appId, int pid)
-{
- result r = E_SUCCESS;
-
- __eventProtect.Acquire();
- if ( __eventListenerList.GetCount() != 0)
- {
- Integer processId(pid);
- r = __eventListenerList.Remove(processId, true);
- r = __eventListenerListForInternal.Remove(processId, true);
- SysLog(NID_SYS, "Application[%ls, %d] is terminated. And remove event listener [%s]", appId.GetPointer(), pid, GetErrorMessage(r));
- }
- __eventProtect.Release();
-}
-
-}}
+++ /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_LISTENER_H_
-#define _FSYS_ISETTING_PROVIDER_LISTENER_H_
-
-#include <FApp.h>
-#include <FBase.h>
-
-namespace Tizen { namespace System
-{
-
-class _ISettingProvider
- : virtual public Tizen::Base::Runtime::IEventListener
-{
-public:
- virtual Tizen::Base::String GetId(void) = 0;
-
- virtual result GetValue(const Tizen::Base::String& key, bool& value) = 0;
- virtual result SetValue(const Tizen::Base::String& key, const bool value) = 0;
- virtual result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value) = 0;
- virtual result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value) = 0;
- virtual result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value) = 0;
- virtual result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value) = 0;
-
- virtual result GetValue(const Tizen::Base::String& key, int& value) = 0;
- virtual result SetValue(const Tizen::Base::String& key, const int value) = 0;
-
- virtual result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value) = 0;
- virtual result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value) = 0;
- virtual result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value) = 0;
- virtual result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value) = 0;
-
- virtual bool HasKey(const Tizen::Base::String& key) = 0;
-}; // _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 <runtime_info.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, };
- char* pRegionPtr = null;
- if (runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pRegionPtr) == RUNTIME_INFO_ERROR_NONE)
- {
- u_uastrncpy(customSkeleton, pIcuFormat, sizeof(customSkeleton));
- pFormatString = GetIcuPatternN(pRegionPtr, customSkeleton);
- free(pRegionPtr);
- }
- 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 <FBase.h>
-#include <FBaseSysLog.h>
-
-#include <FApp_Aul.h>
-#include <FBase_StringConverter.h>
-
-#include "FSys_SettingService.h"
-#include "FSys_SettingApplicationProvider.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* _SETTING_APPLICATION_PROVIDER_ID = L"application";
-
-static const wchar_t* _APPLICATION_HOME = L"application.home";
-static const wchar_t* _APPLICATION_LOCK = L"application.lock";
-
-static const char* _APPLICATION_HOME_VCONFKEY = "db/setting/menuscreen/package_name";
-static const char* _APPLICATION_LOCK_VCONFKEY = "db/setting/3rd_lock_pkg_name";
-
-struct charDeleter
-{
- void operator()(char* pValue)
- {
- if(pValue != null)
- {
- free(pValue);
- pValue = null;
- }
- }
-};
-
-_SettingApplicationProvider::_SettingApplicationProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- int errorCode = vconf_notify_key_changed(_APPLICATION_HOME_VCONFKEY, 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(_APPLICATION_LOCK_VCONFKEY, SettingEventVConf, null);
- if(errorCode != 0)
- {
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to register event listen for lock application change.");
- }
-
-}
-
-_SettingApplicationProvider::~_SettingApplicationProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- int errorCode = vconf_ignore_key_changed(_APPLICATION_HOME_VCONFKEY, 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(_APPLICATION_LOCK_VCONFKEY, SettingEventVConf);
- if(errorCode != 0)
- {
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister event listen for lock application change.");
- }
-}
-
-String
-_SettingApplicationProvider::GetId(void)
-{
- return _SETTING_APPLICATION_PROVIDER_ID;
-}
-
-result
-_SettingApplicationProvider::GetValue(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValue(const String& key, const bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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(_APPLICATION_HOME_VCONFKEY));
- 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(_APPLICATION_LOCK_VCONFKEY));
- 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::SetValue(const String& key, const String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingApplicationProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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 is not installed.");
-
- 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 != 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(_APPLICATION_HOME_VCONFKEY, 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 is not installed.");
-
- 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 != 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(_APPLICATION_LOCK_VCONFKEY, pPackageName.get());
- SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set lock application.");
- }
-
- SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to change package id.");
- return r;
-}
-
-bool
-_SettingApplicationProvider::HasKey(const Tizen::Base::String& key)
-{
- if(key == _APPLICATION_HOME)
- {
- unique_ptr<char, charDeleter> pPackageName(vconf_get_str(_APPLICATION_HOME_VCONFKEY));
-
- if(pPackageName != null)
- return true;
- }
- else if(key == _APPLICATION_LOCK)
- {
- unique_ptr<char, charDeleter> pPackageName(vconf_get_str(_APPLICATION_LOCK_VCONFKEY));
-
- if(pPackageName != null)
- return true;
- }
- return false;
-}
-
-void
-_SettingApplicationProvider::SettingEventVConf(keynode_t* node, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- if(strcmp(_APPLICATION_HOME_VCONFKEY, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_APPLICATION_HOME);
- }
- else if(strcmp(_APPLICATION_LOCK_VCONFKEY, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_APPLICATION_LOCK);
- }
- else
- {
- return;
- }
-
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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_H_
-#define _FSYS_SETTING_APPLICATION_PROVIDER_H_
-
-#include <vconf.h>
-
-#include "FSys_ISettingProvider.h"
-
-namespace Tizen { namespace System
-{
-
-class _SettingApplicationProvider
- : virtual public Tizen::System::_ISettingProvider
-{
-public:
- _SettingApplicationProvider();
- virtual ~_SettingApplicationProvider();
-
-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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
-
- bool HasKey(const Tizen::Base::String& key);
-
-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_SettingService.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* _SETTING_FONT_PROVIDER_ID = L"font";
-
-static const wchar_t* _FONT_SIZE = L"font.size";
-static const wchar_t* _FONT_TYPE = L"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;
- }
- }
-};
-
-_SettingFontProvider::_SettingFontProvider()
-{
- int errorCode = 0;
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingFontProvider::GetId(void)
-{
- return _SETTING_FONT_PROVIDER_ID;
-}
-
-result
-_SettingFontProvider::GetValue(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValue(const String& key, const bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
- unique_ptr<char, charDeleter> pFontType(null);
- char* pTemp = null;
- int res = 0;
- res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &pTemp);
- SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE && pTemp != null, E_SYSTEM, "It is failed to get font type");
- SysLog(NID_SYS, "current font type is %s.", pTemp);
- pFontType.reset(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;
-}
-
-result
-_SettingFontProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingFontProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-bool
-_SettingFontProvider::HasKey(const Tizen::Base::String& key)
-{
- if(key == _FONT_SIZE || key == _FONT_TYPE)
- {
- return true;
- }
-
- return false;
-}
-
-void
-_SettingFontProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
- }
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->SendEventForInternal(settingKey);
- pSettingService->SendEvent(settingKey);
- }
-}
-
-}}
+++ /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_H_
-#define _FSYS_SETTING_FONT_PROVIDER_H_
-
-#include <system/system_settings.h>
-#include "FSys_ISettingProvider.h"
-
-namespace Tizen { namespace System
-{
-
-class _SettingFontProvider
- : virtual public Tizen::System::_ISettingProvider
-{
-public:
- _SettingFontProvider();
- virtual ~_SettingFontProvider();
-
-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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
-
- bool HasKey(const Tizen::Base::String& key);
-
-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_SettingService.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* _SETTING_GENERAL_PROVIDER_ID[6] = {L"device_name", L"motion", L"contacts", L"developer", L"battery", L"graphics"};
-
-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)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- for(currentMode = 0; currentMode < _NUM_OF_GENERAL_PROVIDER; currentMode++)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- for(currentMode = 0; currentMode< _NUM_OF_GENERAL_PROVIDER; currentMode++)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
- }
-
- 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.");
- }
-}
-
-String
-_SettingGeneralProvider::GetId(void)
-{
- String currentId = _SETTING_GENERAL_PROVIDER_ID[currentMode];
- return currentId;
-}
-
-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::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingGeneralProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingGeneralProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingGeneralProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingGeneralProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingGeneralProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
-
- if(key == SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION)
- {
- settingKey.Append(_MOTION_UI);
- }
- else
- {
- return;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-void
-_SettingGeneralProvider::SettingEventVConf(keynode_t* node, void* userData)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
-
- bool HasKey(const Tizen::Base::String& key);
-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_SettingService.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
-{
-
-static const wchar_t* _SETTING_LOCALE_PROVIDER_ID = L"locale";
-
-//Language and Region
-static const wchar_t* _LOCALE_COUNTRY = L"locale.country";
-static const wchar_t* _LOCALE_LANGUAGE = L"locale.language";
-static const char* _LANGUAGE_LIST_FILE_PATH = "/opt/usr/data/setting/langlist.xml";
-
-//Format
-static const wchar_t* _LOCALE_DATE_FORMAT = L"locale.date.format";
-static const wchar_t* _LOCALE_DATETIME_FORMAT = L"locale.date_time.format";
-static const wchar_t* _LOCALE_TIME_FORMAT = L"locale.time.format";
-static const wchar_t* _LOCALE_TIME_FORMAT_24HOUR = L"locale.time.format.24hour";
-
-static const wchar_t* _LOCALE_WEEK_FORMAT_FIRSTDAY = L"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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingLocaleProvider::GetId(void)
-{
- return _SETTING_LOCALE_PROVIDER_ID;
-}
-
-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::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingLocaleProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocaleProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
-{
- String settingKey(_SETTING_PREFIX);
- String deliveredKey;
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- if(key == RUNTIME_INFO_KEY_REGION)
- {
- deliveredKey = settingKey + _LOCALE_DATE_FORMAT;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_DATETIME_FORMAT;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_TIME_FORMAT;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_COUNTRY;
- pSettingService->SendEventForInternal(deliveredKey);
- pSettingService->SendEvent(deliveredKey);
- }
- else if(key == RUNTIME_INFO_KEY_LANGUAGE)
- {
- settingKey.Append(_LOCALE_LANGUAGE);
- pSettingService->SendEventForInternal(settingKey);
- pSettingService->SendEvent(settingKey);
- }
- else if(key == RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED)
- {
- deliveredKey = settingKey + _LOCALE_DATETIME_FORMAT;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_TIME_FORMAT;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_TIME_FORMAT_24HOUR;
- pSettingService->SendEvent(deliveredKey);
- }
-}
-
-void
-_SettingLocaleProvider::SettingEventVConf(keynode_t* node, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
- String deliveredKey;
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- if (strcmp(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, vconf_keynode_get_name(node)) == 0)
- {
- deliveredKey = settingKey + _LOCALE_WEEK_FORMAT_FIRSTDAY;
- pSettingService->SendEvent(deliveredKey);
- }
- else if (strcmp(VCONFKEY_SYSTEM_TIME_CHANGED, vconf_keynode_get_name(node)) == 0)
- {
- deliveredKey = settingKey + _LOCALE_DATETIME;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_DATE;
- pSettingService->SendEvent(deliveredKey);
- deliveredKey = settingKey + _LOCALE_TIME;
- pSettingService->SendEvent(deliveredKey);
- }
- else if (strcmp(VCONFKEY_SETAPPL_TIMEZONE_ID, vconf_keynode_get_name(node)) == 0)
- {
- deliveredKey = settingKey + _LOCALE_TIMEZONE;
- pSettingService->SendEvent(deliveredKey);
- }
- else if (strcmp(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, vconf_keynode_get_name(node)) == 0)
- {
- deliveredKey = settingKey + _LOCALE_UPDATE_AUTO;
- pSettingService->SendEvent(deliveredKey);
- }
-}
-
-
-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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, 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_SettingService.h"
-#include "FSys_SettingLocationProvider.h"
-
-using namespace Tizen::App;
-using namespace Tizen::Base;
-
-namespace Tizen { namespace System
-{
-
-static const wchar_t* _SETTING_LOCATION_PROVIDER_ID = L"location";
-
-static const wchar_t* _LOCATION_GPS = L"location.gps";
-static const wchar_t* _LOCATION_GPS_ADVANCED = L"location.gps.advanced";
-static const wchar_t* _LOCATION_WPS = L"location.wps";
-
-_SettingLocationProvider::_SettingLocationProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingLocationProvider::GetId(void)
-{
- return _SETTING_LOCATION_PROVIDER_ID;
-}
-
-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::SetValue(const String& key, const bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingLocationProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::GetValue(const String& key, String& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::SetValue(const String& key, const String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingLocationProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- if (strcmp(VCONFKEY_LOCATION_ENABLED, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_LOCATION_GPS);
- pSettingService->SendEvent(settingKey);
- }
- else if (strcmp(VCONFKEY_LOCATION_NETWORK_ENABLED, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_LOCATION_WPS);
- pSettingService->SendEvent(settingKey);
- }
- else if (strcmp(VCONFKEY_LOCATION_AGPS_ENABLED, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_LOCATION_GPS_ADVANCED);
- pSettingService->SendEvent(settingKey);
- }
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String 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_SettingService.h"
-#include "FSys_SettingNetworkProvider.h"
-
-using namespace std;
-
-using namespace Tizen::App;
-using namespace Tizen::Base;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Utility;
-
-namespace Tizen { namespace System
-{
-
-static const wchar_t* _SETTING_NETWORK_PROVIDER_ID = L"network";
-
-//Network Telephony
-static const wchar_t* _NETWORK_FLIGHTMODE = L"network.flight_mode";
-static const wchar_t* _NETWORK_TELEPHONY_PACKETSERVICE = L"network.telephony.packet_service";
-static const wchar_t* _NETWORK_TELEPHONY_ROAMING = L"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"network.wifi";
-static const wchar_t* _NETWORK_WIFI_NOTIFICATION = L"network.wifi.notification";
-static const wchar_t* _NETWORK_WIFI_TETHERING = L"network.wifi.tethering";
-static const wchar_t* _NETWORK_WIFI_TETHERING_HIDE = L"network.wifi.tethering.hide";
-static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY = L"network.wifi.tethering.security";
-static const wchar_t* _NETWORK_WIFI_TETHERING_SECURITY_PASSWORD = L"network.wifi.tethering.security.password";
-static const wchar_t* _USB_TETHERING = L"usb.tethering"; //Especially, USB tethering is covered by this provider.
-static const wchar_t* _NETWORK_WIFI_DIRECT = L"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"network.bluetooth";
-static const wchar_t* _NETWORK_BLUETOOTH_TETHERING = L"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)
- , __pidOfFlightMode(0)
- , __pidOfWifi(0)
- , __pidOfWifiDirect(0)
- , __pidOfBluetooth(0)
- , __networkWifiProcessing(false)
- , __networkWifiDirectProcessing(false)
- , __flightModeEnabled(false)
- , __networkBluetoothEnabled(false)
- , __wifiInit(false)
- , __wifiDirectInit(false)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- int errorCode = bt_initialize();
- if(errorCode != 0)
- {
- 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);
- //SysTryReturnResult(NID_SYS, errorCode == WIFI_ERROR_NONE, E_SYSTEM, "It is failed to init wifi direct.");
- __wifiInit = true;
- }
-}
-
-
-_SettingNetworkProvider::~_SettingNetworkProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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.");
-}
-
-String
-_SettingNetworkProvider::GetId(void)
-{
- return _SETTING_NETWORK_PROVIDER_ID;
-}
-
-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;
- }
- return r;
- }
- 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);
- return r;
- }
- 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");
- return r;
- }
- 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;
- }
- return r;
- }
- 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);
- return r;
- }
- 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;
- }
- return r;
- }
- 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;
- }
-
- return r;
- }
- 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;
- }
- 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)
- {
- r = E_SUCCESS;
-
- SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Wi-Fi feature.");
-
- int currentValue = 0;
- 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)
- {
- 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.");
-
- bool state = false;
- 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 Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- int ret = 0;
- result r = E_OBJ_NOT_FOUND;
-
- if(key == _NETWORK_BLUETOOTH)
- {
- SysLog(NID_SYS, "Bluetooth change is required. pid: %d, value: %d", pid, value);
- SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support Bluetooth feature.");
- SysTryReturnResult(NID_SYS, __pidOfBluetooth == 0, E_IN_PROGRESS, "Bluetooth is under changing procedure.");
- r = E_SUCCESS;
-
- __pidOfBluetooth = pid;
-
- 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.");
- __pidOfBluetooth = 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.");
- __pidOfBluetooth = 0;
- r = E_SYSTEM;
- break;
- }
- }
- return r;
-}
-
-result
-_SettingNetworkProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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 Tizen::App::AppId appId, int pid, 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.");
- r = E_SUCCESS;
- SysTryReturnResult(NID_SYS, __pidOfFlightMode == 0, E_IN_PROGRESS, "Flightmode is under changing procedure.");
-
- __pidOfFlightMode = pid;
-
- __flightModeEnabled = value;
- bool telephony_supported = false;
- int ret = system_info_get_platform_bool("http://tizen.org/feature/network.telephony", &telephony_supported);
-
- SysLog(NID_SYS, "It requests flight mode[%d].", value);
- if(ret == 0 && telephony_supported == true)
- {
- if(__tapiHandle == null)
- {
- __tapiHandle = tel_init(null);
- SysTryReturnResult(NID_SYS, __tapiHandle != null, E_SYSTEM, "Tapi is not ready.");
- }
- SysLog(NID_SYS, "tapi handle is %x.", __tapiHandle);
- errorCode = tel_set_flight_mode(__tapiHandle,
- value ? TAPI_POWER_FLIGHT_MODE_ENTER : TAPI_POWER_FLIGHT_MODE_LEAVE,
- SettingEventFlightMode, (void*)this);
- SysLog(NID_SYS, "tapi flightmode result is %d.", errorCode);
- SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on Network Flight mode");
- }
- 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, __networkWifiProcessing == false && __networkWifiDirectProcessing == false, E_IN_PROGRESS, "Wifi is under changing procedure.");
- r = E_SUCCESS;
-
- __pidOfWifi = pid;
- SysLog(NID_SYS, "It creates thread for wifi enable[%d].", value);
-
- __networkWifiProcessing = true;
-
- bool wifiEnabled = false;
- errorCode = wifi_is_activated(&wifiEnabled);
- if(errorCode != WIFI_ERROR_NONE)
- {
- __pidOfWifi = 0;
- __networkWifiProcessing = false;
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to get current status of WIFI.");
- return E_SYSTEM;
- }
-
- if(value == wifiEnabled)
- {
- SysLog(NID_SYS, "It is try to use dummy thread");
- WifiDummy((void*)this);
- return E_SUCCESS;
- }
-
- if(value == true)
- {
- errorCode = wifi_activate(SettingWifiActivateCallBack, (void*) this);
- }
- else
- {
- errorCode = wifi_deactivate(SettingWifiActivateCallBack, (void*) this);
- }
-
- SysLog(NID_SYS, "wifi_direct_activate result is %d, value is %d.", errorCode, value);
-
- if(errorCode != WIFI_ERROR_NONE)
- {
- __networkWifiProcessing = false;
- 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 direct feature.");
- SysTryReturnResult(NID_SYS, __networkWifiProcessing == false && __networkWifiDirectProcessing == false, E_IN_PROGRESS, "Wifi direct is under changing procedure.");
- r = E_SUCCESS;
-
- __pidOfWifiDirect = pid;
- SysLog(NID_SYS, "It creates thread for wifi direct enable[%d].", value);
-
- 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;
- }
-
- __networkWifiDirectProcessing = true;
-
- wifi_direct_state_e wifi_direct_state;
- errorCode = wifi_direct_get_state(&wifi_direct_state);
- if(errorCode != WIFI_DIRECT_ERROR_NONE)
- {
- __pidOfWifiDirect = 0;
- __networkWifiDirectProcessing = false;
- 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, "It is try to use dummy thread");
- 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)
- {
- __networkWifiDirectProcessing = false;
- return E_SYSTEM;
- }
- }
- return r;
-}
-
-result
-_SettingNetworkProvider::WifiDummy(void* data)
-{
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnResult(NID_SYS, (pSettingService != null && pProvider != null), E_SYSTEM, "There is no values of args.");
-
- pProvider->__networkWifiProcessing = false;
- int pid = pProvider->__pidOfWifi;
- pProvider->__pidOfWifi = 0;
- SysTryReturnResult(NID_SYS, pid > 0, E_SYSTEM, "There is invalid pid.");
-
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_WIFI);
- String returnValue = _NETWORK_RESULT_SUCCESS;
-
- result r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Result forward result is %s.", GetErrorMessage(r));
- return r;
-}
-
-result
-_SettingNetworkProvider::WifiDirectDummy(void* data)
-{
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnResult(NID_SYS, (pSettingService != null && pProvider != null), E_SYSTEM, "There is no values of args.");
-
- pProvider->__networkWifiDirectProcessing = false;
- int pid = pProvider->__pidOfWifiDirect;
- pProvider->__pidOfWifiDirect = 0;
- SysTryReturnResult(NID_SYS, pid > 0, E_SYSTEM, "There is invalid pid.");
-
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_WIFI_DIRECT);
- String returnValue = _NETWORK_RESULT_SUCCESS;
-
- result r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Result forward result is %s.", GetErrorMessage(r));
- return r;
-}
-
-void
-_SettingNetworkProvider::SettingWifiActivateCallBack(wifi_error_e errorCode, void* data)
-{
- result r = E_SUCCESS;
- SysLog(NID_SYS, "Wifi activate result callback is called with %d.", errorCode);
-
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_WIFI);
- String returnValue = _NETWORK_RESULT_SUCCESS;
- int pid = 0;
-
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryCatch(NID_SYS, (pSettingService != null && pProvider != null), r = E_SYSTEM, E_SYSTEM, "There is no values of args.");
-
- pid = pProvider->__pidOfWifi;
- pProvider->__pidOfWifi = 0;
- SysTryCatch(NID_SYS, pid > 0 , r = E_SYSTEM, E_SYSTEM, "There is invalid pid[%d].", pid);
-
- if(errorCode != WIFI_ERROR_NONE)
- {
- returnValue = _NETWORK_RESULT_SYSTEM;
- 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;
- }
- }
-
- r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Result forward result is %s.", GetErrorMessage(r));
-
-CATCH:
- pProvider->__networkWifiProcessing = false;
-}
-
-void
-_SettingNetworkProvider::SettingWifiDirectStateChangedCallBack(wifi_direct_error_e errorCode, wifi_direct_device_state_e deviceState, void* data)
-{
- result r = E_SUCCESS;
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_WIFI_DIRECT);
- String returnValue = _NETWORK_RESULT_SUCCESS;
- int pid = 0;
-
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryCatch(NID_SYS, (pSettingService != null && pProvider != null), r = E_SYSTEM, E_SYSTEM, "There is no values of args.");
-
- pid = pProvider->__pidOfWifiDirect;
- pProvider->__pidOfWifiDirect = 0;
- SysTryCatch(NID_SYS, pid > 0 , r = E_SYSTEM, E_SYSTEM, "There is invalid pid[%d].", pid);
- SysTryCatch(NID_SYS, pProvider->__networkWifiDirectProcessing == true, r = E_SYSTEM, E_SYSTEM, "Current state change callback is not my request.");
-
- if(errorCode != WIFI_DIRECT_ERROR_NONE)
- {
- returnValue = _NETWORK_RESULT_SYSTEM;
- }
-
- r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Result forward result is %s.", GetErrorMessage(r));
-
-CATCH:
- pProvider->__networkWifiDirectProcessing = false;
-}
-
-result
-_SettingNetworkProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingNetworkProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingNetworkProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingNetworkProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-bool
-_SettingNetworkProvider::HasKey(const Tizen::Base::String& key)
-{
- int ret = 0;
- bool isSupported = false;
- SysLog(NID_SYS, "requiredKey is %ls.", key.GetPointer());
-
- if(key == _NETWORK_FLIGHTMODE)
- {
- isSupported = true;
- }
- else if(key == _NETWORK_TELEPHONY_PACKETSERVICE || key == _NETWORK_TELEPHONY_ROAMING)
- {
- ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &isSupported);
- SysTryLog(NID_SYS, ret == 0, "It is failed to fetch telephony support information.");
- }
- else if(key == _NETWORK_WIFI || key == _NETWORK_WIFI_NOTIFICATION)
- {
- ret = system_info_get_platform_bool("tizen.org/feature/network.wifi", &isSupported);
- SysTryLog(NID_SYS, ret == 0, "It is failed to fetch wifi support information.");
- }
- else if(key == _NETWORK_WIFI_DIRECT)
- {
- ret = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &isSupported);
- SysTryLog(NID_SYS, ret == 0, "It is failed to fetch wifi-direct support information.");
- }
- 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)
- {
- ret = system_info_get_value_bool(SYSTEM_INFO_KEY_TETHERING_SUPPORTED, &isSupported);
- SysTryLog(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, "It is failed to fetch tethering information.");
- }
- else if(key == _NETWORK_BLUETOOTH)
- {
- ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &isSupported);
- SysTryLog(NID_SYS, ret == 0, "It is failed to fetch bluetooth support information.");
- }
- else if(key == _NETWORK_BLUETOOTH_TETHERING)
- {
- if(__tetheringHandle != null)
- {
- ret = system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &isSupported);
- SysTryLog(NID_SYS, ret == 0, "It is failed to fetch bluetooth support information.");
- }
- }
- return isSupported;
-}
-
-void
-_SettingNetworkProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- if(key == RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED)
- {
- settingKey.Append(_NETWORK_FLIGHTMODE);
- pSettingService->SendEvent(settingKey);
- }
- else if(key == RUNTIME_INFO_KEY_PACKET_DATA_ENABLED)
- {
- settingKey.Append(_NETWORK_TELEPHONY_PACKETSERVICE);
- pSettingService->SendEvent(settingKey);
- }
- else if(key == RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED)
- {
- settingKey.Append(_NETWORK_TELEPHONY_ROAMING);
- pSettingService->SendEvent(settingKey);
- }
-}
-
-void
-_SettingNetworkProvider::SettingEventVConf(keynode_t* node, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService 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);
- pSettingService->SendEvent(settingKey);
- }
- }
- else if (strcmp(VCONFKEY_WIFI_ENABLE_QS, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_NETWORK_WIFI_NOTIFICATION);
- pSettingService->SendEvent(settingKey);
- }
- 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);
- pSettingService->SendEvent(settingKey);
- }
- }
- else if (strcmp(VCONFKEY_BT_STATUS, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_NETWORK_BLUETOOTH);
- pSettingService->SendEvent(settingKey);
- }
- else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_SECURITY, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_NETWORK_WIFI_TETHERING_SECURITY);
- pSettingService->SendEvent(settingKey);
- }
- else if (strcmp(VCONFKEY_MOBILE_HOTSPOT_HIDE, vconf_keynode_get_name(node)) == 0)
- {
- settingKey.Append(_NETWORK_WIFI_TETHERING_HIDE);
- pSettingService->SendEvent(settingKey);
- }
-}
-
-void
-_SettingNetworkProvider::SettingEventTetheringEnabled(tethering_error_e err, tethering_type_e type, bool is_requested, void* data)
-{
- String settingKey(_SETTING_PREFIX);
- SysLog(NID_SYS, "Tethering Endabled Event is occured.");
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-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)
-{
- SysLog(NID_SYS, "Flightmode response is handle:%x, res:%d, date:%x, user_data:%x", handle, res, data, user_data);
- SysLog(NID_SYS, "Flightmode on is %d, off is %d, fail is %d", TAPI_POWER_FLIGHT_MODE_RESP_ON, TAPI_POWER_FLIGHT_MODE_RESP_OFF,TAPI_POWER_FLIGHT_MODE_RESP_FAIL);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
- SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is invalid provider.");
-
- int pid = pProvider->__pidOfFlightMode;
- pProvider->__pidOfFlightMode = 0;
- SysTryReturnVoidResult(NID_SYS, pid > 0, E_SYSTEM, "There is no pid[%d].", pid);
-
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_FLIGHTMODE);
- int errorCode = 0;
- String returnValue;
-
- 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.");
- returnValue = _NETWORK_RESULT_SYSTEM;
- }
- else
- {
- returnValue = _NETWORK_RESULT_SUCCESS;
- }
- 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.");
- returnValue = _NETWORK_RESULT_SYSTEM;
- }
- else
- {
- returnValue = _NETWORK_RESULT_SUCCESS;
- }
- break;
- case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
- default:
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to change flight mode");
- returnValue = _NETWORK_RESULT_SYSTEM;
- }
- pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
-}
-
-result
-_SettingNetworkProvider::FlightModeEnabler(void* data)
-{
- result r = E_SUCCESS;
- String returnValue;
- String settingKey(_SETTING_PREFIX);
- settingKey.Append(_NETWORK_FLIGHTMODE);
-
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)data;
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnResult(NID_SYS, pProvider != null && pSettingService != null, E_SYSTEM, "Provider or SettingService is not ready.");
-
- int pid = pProvider->__pidOfFlightMode;
- pProvider->__pidOfFlightMode = 0;
- SysTryReturnResult(NID_SYS, pid > 0, E_SYSTEM, "There is invalid pid.");
- SysLog(NID_SYS, "Required pid is %d and required value is %d.", pid, pProvider->__flightModeEnabled);
-
- int 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.");
- returnValue = _NETWORK_RESULT_SYSTEM;
- }
-
- SysLog(NID_SYS, "VCONFKEY_TELEPHONY_FLIGHT_MODE result is %d.", errorCode);
- returnValue = _NETWORK_RESULT_SUCCESS;
-
- r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Send result is %s.", GetErrorMessage(r));
- return r;
-}
-
-void
-_SettingNetworkProvider::SettingEventBluetooth(int res, bt_adapter_state_e adapter_state, void* user_data)
-{
- result r = E_SUCCESS;
- SysLog(NID_SYS, "Bluetooth callback is invoked. result:%d, adapter_state:%d, user_data:%x", res, adapter_state, user_data);
-
- String returnValue = _NETWORK_RESULT_SUCCESS;
- _SettingNetworkProvider* pProvider = (_SettingNetworkProvider*)user_data;
- SysTryReturnVoidResult(NID_SYS, pProvider != null, E_SYSTEM, "There is no values of args.");
-
- int pid = pProvider->__pidOfBluetooth;
- pProvider->__pidOfBluetooth = 0;
-
- SysTryReturnVoidResult(NID_SYS, pid > 0, E_SYSTEM, "There is no pid[%d].", pProvider->__pidOfBluetooth);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
- String resultValue;
-
- settingKey.Append(_NETWORK_BLUETOOTH);
-
- if(res == BT_ERROR_NONE)
- {
- resultValue = _NETWORK_RESULT_SUCCESS;
- }
- else
- {
- resultValue = _NETWORK_RESULT_SYSTEM;
- }
-
- SysLog(NID_SYS, "Result is send to %d with %ls.", pid, resultValue.GetPointer());
- r = pSettingService->SendResponse(pid, L"osp.setting.command.set.bool.async.priv", settingKey, returnValue);
- SysLog(NID_SYS, "Send result is %s.", GetErrorMessage(r));
-}
-
-}}
+++ /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 "FSys_ISettingProvider.h"
-
-namespace Tizen { namespace System
-{
-
-class _SettingNetworkProvider
- : virtual public Tizen::System::_ISettingProvider
-{
-public:
- _SettingNetworkProvider();
- virtual ~_SettingNetworkProvider();
-
-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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, 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 __pidOfFlightMode;
- int __pidOfWifi;
- int __pidOfWifiDirect;
- int __pidOfBluetooth;
-
- bool __networkWifiProcessing;
- bool __networkWifiDirectProcessing;
- bool __flightModeEnabled;
- bool __networkBluetoothEnabled;
-
- bool __wifiInit;
- bool __wifiDirectInit;
-}; // _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_SettingService.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* _SETTING_SCREEN_PROVIDER_ID = L"screen";
-
-static const wchar_t* _SCREEN_WALLPAPER = L"screen.wallpaper";
-static const wchar_t* _SCREEN_WALLPAPER_LOCK = L"screen.wallpaper.lock";
-static const wchar_t* _SCREEN_BRIGHTNESS = L"screen.brightness";
-static const wchar_t* _SCREEN_BRIGHTNESS_AUTO = L"screen.brightness.auto";
-static const wchar_t* _SCREEN_BACKLIGHT_TIME = L"screen.backlight.time";
-static const wchar_t* _SCREEN_ROTATION_AUTO = L"screen.rotation.auto";
-static const wchar_t* _SCREEN_MODE = L"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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingScreenProvider::GetId(void)
-{
- return _SETTING_SCREEN_PROVIDER_ID;
-}
-
-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::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingScreenProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingScreenProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingScreenProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingScreenProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingScreenProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-void
-_SettingScreenProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
-{
- String settingKey(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, 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_SettingService.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* _SETTING_SOUND_PROVIDER_ID = L"sound";
-
-static const wchar_t* _SOUND_MEDIA_VOLUME = L"sound.media.volume";
-static const wchar_t* _SOUND_NOTIFICATION = L"sound.notification";
-static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD = L"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"sound.notification.volume";
-static const wchar_t* _SOUND_RINGTONE_VOLUME = L"sound.ringtone.volume";
-static const wchar_t* _SOUND_SYSTEM_VOLUME = L"sound.system.volume";
-
-static const wchar_t* _SOUND_RINGTONE = L"sound.ringtone";
-static const wchar_t* _SOUND_SILENTMODE = L"sound.silent_mode";
-static const wchar_t* _SOUND_TOUCH = L"sound.touch";
-static const wchar_t* _SOUND_LOCK = L"sound.lock";
-
-_SettingSoundProvider::_SettingSoundProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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.");
- }
-}
-
-String
-_SettingSoundProvider::GetId(void)
-{
- return _SETTING_SOUND_PROVIDER_ID;
-}
-
-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::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSoundProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSoundProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSoundProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
- {
- char* pPreloaded = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
- SysTryReturnResult(NID_SYS, pPreloaded != null, E_SYSTEM, "It is failed to get default ringtone.");
-
- String preloaded;
- preloaded.Append(pPreloaded);
-
- if(File::IsFileExist(preloaded) == true)
- {
- value = preloaded;
- errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, pPreloaded);
- if(errorCode != SYSTEM_SETTINGS_ERROR_NONE)
- {
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to set default ringtone.");
- }
-
- if(pPreloaded != null)
- {
- free(pPreloaded);
- }
- }
- else
- {
- if(pPreloaded != null)
- {
- free(pPreloaded);
- }
- 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)
- {
- char* pPreloaded = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
- SysTryReturnResult(NID_SYS, pPreloaded != null, E_SYSTEM, "It is failed to get default noti ringtone.");
-
- String preloaded;
- preloaded.Append(pPreloaded);
- if(File::IsFileExist(preloaded) == true)
- {
- value = preloaded;
- errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, pPreloaded);
- if(errorCode != 0)
- {
- SysLogException(NID_SYS, E_SYSTEM, "It is failed to set default noti ringtone.");
- }
-
- if(pPreloaded != null)
- {
- free(pPreloaded);
- }
- }
- else
- {
- if(pPreloaded != null)
- {
- free(pPreloaded);
- }
- 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;
-}
-
-result
-_SettingSoundProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSoundProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
-
- pSettingService->SendEvent(settingKey);
-}
-
-void
-_SettingSoundProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- if(key == SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE)
- {
- settingKey.Append(_SOUND_RINGTONE);
- }
- else
- {
- return;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-void
-_SettingSoundProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- if(key == RUNTIME_INFO_KEY_SILENT_MODE_ENABLED)
- {
- settingKey.Append(_SOUND_SILENTMODE);
- }
- else
- {
- return;
- }
- pSettingService->SendEvent(settingKey);
-}
-void
-_SettingSoundProvider::SettingEventVConf(keynode_t* node, void* userData)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, 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_SettingService.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* _SETTING_SPEECH_PROVIDER_ID = L"speech";
-
-static const wchar_t* _SPEECH_TTS_SCREEN = L"speech.tts.screen";
-static const wchar_t* _SPEECH_TTS_SCREEN_RATE = L"speech.tts.screen.rate";
-
-struct charDeleter
-{
- void operator()(char* pValue)
- {
- if(pValue != null)
- {
- free(pValue);
- pValue = null;
- }
- }
-};
-
-_SettingSpeechProvider::_SettingSpeechProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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.");
- }
-
-}
-
-String
-_SettingSpeechProvider::GetId(void)
-{
- return _SETTING_SPEECH_PROVIDER_ID;
-}
-
-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::SetValue(const String& key, const bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSpeechProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSpeechProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingSpeechProvider::GetValue(const String& key, String& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSpeechProvider::SetValue(const String& key, const String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSpeechProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingSpeechProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-bool
-_SettingSpeechProvider::HasKey(const Tizen::Base::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(_SETTING_PREFIX);
-
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- 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;
- }
-
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String 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_SettingService.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* _SETTING_STORAGE_PROVIDER_ID = L"storage";
-static const wchar_t* _STORAGE_DIRECTORY_WAP_DOWNLOAD = L"storage.directory.wap.download";
-static const wchar_t* _STORAGE_DIRECTORY_BLUETOOTH_DOWNLOAD = L"storage.directory.bluetooth.download";
-static const wchar_t* _STORAGE_DIRECTORY_CAMERA_RECORD = L"storage.directory.camera.record";
-static const wchar_t* _STORAGE_DIRECTORY_VOICE_RECORD = L"storage.directory.voice.record";
-static const wchar_t* _STORAGE_DIRECTORY_RADIO_BROADCAST = L"storage.directory.radio.broadcast";
-static const wchar_t* _STORAGE_DIRECTORY_VIDEO_BROADCAST = L"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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingStorageProvider::GetId(void)
-{
- return _SETTING_STORAGE_PROVIDER_ID;
-}
-
-result
-_SettingStorageProvider::GetValue(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValue(const String& key, const bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::GetValue(const String& key, int& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValue(const String& key, const int value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingStorageProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingStorageProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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:
- 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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, 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_SettingService.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* _SETTING_VIBRATION_PROVIDER_ID = L"vibrator";
-static const wchar_t* _VIBRATOR = L"vibrator";
-static const wchar_t* _VIBRATOR_LEVEL = L"vibrator.level";
-static const wchar_t* _VIBRATOR_LEVEL_NOTIFICATION = L"vibrator.level.notification";
-
-_SettingVibrationProvider::_SettingVibrationProvider()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->RegisterSettingProvider(*this);
- }
-
- 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()
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- if(pSettingService != null)
- {
- pSettingService->UnregisterSettingProvider(*this);
- }
-
- 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");
- }
-}
-
-String
-_SettingVibrationProvider::GetId(void)
-{
- return _SETTING_VIBRATION_PROVIDER_ID;
-}
-
-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::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::GetValueForPrivilegedKey(const String& key, bool& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::SetValueForPrivilegedKey(const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, const String& key, bool value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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;
-}
-
-result
-_SettingVibrationProvider::GetValue(const String& key, String& value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::SetValue(const String& key, const String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::SetValueAsync(const Tizen::App::AppId appId, int pid, const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-result
-_SettingVibrationProvider::SetValueForPrivilegedKey(const String& key, String value)
-{
- return E_OBJ_NOT_FOUND;
-}
-
-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)
-{
- _SettingService* pSettingService = _SettingService::GetInstance();
- SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_SYSTEM, "SettingService is not ready.");
-
- String settingKey(_SETTING_PREFIX);
-
- 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;
- }
- pSettingService->SendEvent(settingKey);
-}
-
-}}
+++ /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 SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, bool value);
- result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
- result SetValueAsyncForPrivilegedKey(const Tizen::App::AppId appId, int pid, 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);
-
- result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
- result SetValue(const Tizen::Base::String& key, const Tizen::Base::String value);
- result SetValueAsync(const Tizen::App::AppId appId, int pid, const Tizen::Base::String& key, Tizen::Base::String value);
- result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String 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_