From: Hokwon Song Date: Wed, 10 Apr 2013 09:18:15 +0000 (+0900) Subject: Move Font set/get api to appfw X-Git-Tag: accepted/tizen_2.1/20130425.034849~109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c9f0247e50f79cc970463d312e79eef8eb4830a;p=framework%2Fosp%2Fappfw.git Move Font set/get api to appfw Change-Id: Iaf93d4b5b6a93b027286d700616354a6581a641e Signed-off-by: Hokwon Song --- diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index bd0e247..c31e2da 100755 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-system-power) BuildRequires: pkgconfig(capi-system-runtime-info) +BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(aul) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe5e017..a1bc491 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ pkg_check_modules(pkgs REQUIRED capi-system-runtime-info capi-system-device capi-system-power + capi-system-system-settings ) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/src/system/FSys_SettingInfoImpl.cpp b/src/system/FSys_SettingInfoImpl.cpp index 1f66097..3f3e59b 100644 --- a/src/system/FSys_SettingInfoImpl.cpp +++ b/src/system/FSys_SettingInfoImpl.cpp @@ -19,10 +19,12 @@ * @file FSys_SettingInfoImpl.cpp * @brief This is the implementation file for _SysSettingInfoImpl class. */ - +#include +#include #include #include +#include #include #include #include "FSys_SettingClient.h" @@ -31,6 +33,7 @@ using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Io; +using namespace Tizen::Base::Utility; namespace Tizen { namespace System { @@ -49,6 +52,23 @@ static const wchar_t* _SETTING_SOUND_RINGTONE_VOLUME = L"http://tizen.org/settin static const wchar_t* _SETTING_NOTIFICATION_SOUND_VOLUME = L"NotificationSoundVolume"; static const wchar_t* _SETTING_SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume"; +//Font +static const wchar_t* _FONT_SIZE = L"http://tizen.org/setting/font.size"; +static const wchar_t* _FONT_TYPE = L"http://tizen.org/setting/font.type"; + +static const wchar_t* _FONT_SIZE_GIANT = L"giant"; +static const wchar_t* _FONT_SIZE_HUGE = L"huge"; +static const wchar_t* _FONT_SIZE_LARGE = L"large"; +static const wchar_t* _FONT_SIZE_MEDIUM = L"medium"; +static const wchar_t* _FONT_SIZE_SMALL = L"small"; + +static const int _FONT_SIZE_GIANT_VCONF = 4; +static const int _FONT_SIZE_HUGE_VCONF = 3; +static const int _FONT_SIZE_LARGE_VCONF = 2; +static const int _FONT_SIZE_MEDIUM_VCONF = 1; +static const int _FONT_SIZE_SMALL_VCONF = 0; + + static _SettingClient* pSettingClient = null; void @@ -62,9 +82,19 @@ _SettingInfoImpl::InitSettingClient(void) result _SettingInfoImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value) { - InitSettingClient(); - SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager"); - return pSettingClient->GetValue(key, value); + result r = E_SUCCESS; + + if (key == _FONT_SIZE || key == _FONT_TYPE) + { + r = GetValueForFont(key, value); + } + else + { + InitSettingClient(); + SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager"); + r = pSettingClient->GetValue(key, value); + } + return r; } result @@ -152,9 +182,18 @@ _SettingInfoImpl::SetValue(const String& key, int value) result _SettingInfoImpl::SetValue(const String& key, String value) { - InitSettingClient(); - SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager"); - return pSettingClient->SetValue(key, value); + result r = E_SUCCESS; + if (key == _FONT_SIZE || key == _FONT_TYPE) + { + r = SetValueForFont(key, value); + } + else + { + InitSettingClient(); + SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager"); + r = pSettingClient->SetValue(key, value); + } + return r; } result @@ -312,4 +351,113 @@ _SettingInfoImpl::GetInstance(const SettingInfo& settinginfo) return settinginfo.__pSettingInfoImpl; } +result +_SettingInfoImpl::GetValueForFont(const Tizen::Base::String& key, Tizen::Base::String& value) +{ + 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."); + + r = E_SUCCESS; + switch (fontSize) + { + case _FONT_SIZE_GIANT_VCONF: + value.Append(_FONT_SIZE_GIANT); + break; + case _FONT_SIZE_HUGE_VCONF: + value.Append(_FONT_SIZE_HUGE); + break; + case _FONT_SIZE_LARGE_VCONF: + value.Append(_FONT_SIZE_LARGE); + break; + case _FONT_SIZE_MEDIUM_VCONF: + value.Append(_FONT_SIZE_MEDIUM); + break; + case _FONT_SIZE_SMALL_VCONF: + value.Append(_FONT_SIZE_SMALL); + break; + default: + r = E_SYSTEM; + break; + } + + } + else if (key == _FONT_TYPE) + { + r = E_SUCCESS; + char* pFontType = null; + int res = 0; + res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &pFontType); + SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to get font type"); + r = StringUtil::Utf8ToString(pFontType, value); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r)); + free(pFontType); + } + return r; +} + + +result +_SettingInfoImpl::SetValueForFont(const Tizen::Base::String& key, Tizen::Base::String value) +{ + 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) + { + char* pFontType = null; + int res = 0; + r = E_SUCCESS; + + pFontType = _StringConverter::CopyToCharArrayN(value); + SysTryReturnResult(NID_SYS, pFontType != null, E_SYSTEM, "It is failed to convert String to string."); + SysLog(NID_SYS, "Requested font type is %s.", pFontType); + res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType); + delete [] pFontType; + SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font type."); + } + return r; +} + + } } // Tizen::System diff --git a/src/system/inc/FSys_SettingInfoImpl.h b/src/system/inc/FSys_SettingInfoImpl.h index dfa563c..bce08b3 100644 --- a/src/system/inc/FSys_SettingInfoImpl.h +++ b/src/system/inc/FSys_SettingInfoImpl.h @@ -68,6 +68,8 @@ public: private: static void InitSettingClient(void); + static result GetValueForFont(const Tizen::Base::String& key, Tizen::Base::String& value); + static result SetValueForFont(const Tizen::Base::String& key, Tizen::Base::String value); }; } } // Tizen::Sys