CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-ADD_SUBDIRECTORY(utils)
+ADD_SUBDIRECTORY(libutil)
ADD_SUBDIRECTORY(tests)
--- /dev/null
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+SET(LIB_UTILS system-settings-util)
+
+FILE(GLOB UTILS_SRCS *.c)
+
+PKG_CHECK_MODULES(utils_pkgs REQUIRED dlog vconf fontconfig ecore-evas
+ efl-extension elementary)
+INCLUDE_DIRECTORIES(${utils_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${utils_pkgs_LIBRARY_DIRS})
+
+ADD_LIBRARY(${LIB_UTILS} SHARED ${UTILS_SRCS})
+TARGET_LINK_LIBRARIES(${LIB_UTILS} ${utils_pkgs_LIBRARIES})
+INSTALL(TARGETS ${LIB_UTILS} DESTINATION ${LIB_INSTALL_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2011-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#include "sst_utils_wrapper.h"
+
+#include <string.h>
+#include <vconf.h>
+#include <fontconfig/fontconfig.h>
+#include <Ecore_Evas.h>
+#include <efl_extension.h>
+#include "system_settings.h"
+#include "sst.h"
+#include "sst_core.h"
+
+#ifdef TIZEN_WEARABLE
+#define SMALL_FONT_DPI (-90)
+#else
+#define SMALL_FONT_DPI (-80)
+#endif
+
+#define MIDDLE_FONT_DPI (-100)
+
+#ifdef TIZEN_WEARABLE
+#define LARGE_FONT_DPI (-110)
+#else
+#define LARGE_FONT_DPI (-150)
+#endif
+
+#define HUGE_FONT_DPI (-190)
+#define GIANT_FONT_DPI (-250)
+
+#define SETTING_FONT_PRELOAD_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
+#define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_SHARE"/fonts"
+
+#define SETTING_FONT_TIZEN_FONT_ALIAS "Tizen"
+#define SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS "TizenDefaultFont"
+
+static char* _get_main_font_family(char *alias)
+{
+ FcFontSet *set;
+ FcPattern *pat;
+ FcConfig *font_config = NULL;
+ FcChar8 *family = NULL;
+ char *ret = NULL;
+ FcResult res = 0;
+
+ font_config = FcInitLoadConfigAndFonts();
+ if (NULL == font_config) {
+ ERR("FcInitLoadConfigAndFonts() Fail");
+ return NULL;
+ }
+
+ pat = FcPatternBuild(0, FC_FAMILY, FcTypeString, alias, NULL);
+ if (NULL == pat) {
+ ERR("FcPatternBuild() Fail");
+ FcConfigDestroy(font_config);
+ return NULL;
+ }
+
+ FcConfigSubstitute(font_config, pat, FcMatchPattern);
+ FcDefaultSubstitute(pat);
+
+ /* do matching */
+ set = FcFontSort(font_config, pat, FcTrue, NULL, &res);
+ if (set) {
+ if (0 < set->nfont) {
+ FcPatternGetString(set->fonts[0], FC_FAMILY, 0, &family);
+ if (family)
+ ret = strdup((char*)family);
+ }
+ FcFontSetDestroy(set);
+ }
+
+ FcPatternDestroy(pat);
+ FcConfigDestroy(font_config);
+
+ return ret;
+}
+
+API bool sstu_is_valid_image(char *path)
+{
+ void *ee;
+ void *evas;
+
+ if (ecore_evas_init()) {
+ ERR("ecore_evas_init() Fail");
+ return false;
+ }
+
+ ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
+ evas = ecore_evas_get(ee);
+
+ void *img = evas_object_image_add(evas);
+ evas_object_image_file_set(img, path, NULL);
+ int ret = evas_object_image_load_error_get(img);
+
+ bool result = false;
+ if (ret == 0) {
+ result = true;
+ } else {
+ ERR("Invalid(%s)", path);
+ result = false;
+ }
+ ecore_evas_free(ee);
+ ecore_evas_shutdown();
+ return result;
+}
+
+API void sstu_font_config_set_notification()
+{
+}
+
+API int sstu_is_available_font(char *font_name)
+{
+ FcObjectSet *os;
+ FcFontSet *fs;
+ FcPattern *pat;
+ FcConfig *font_config;
+ int ret = 0;
+
+ RETV_IF(NULL == font_name, -1);
+
+ font_config = FcInitLoadConfigAndFonts();
+ if (NULL == font_config)
+ ERR("FcInitLoadConfigAndFonts() Fail");
+
+ char *locale = setlocale(0, NULL);
+ os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, NULL);
+ if (NULL == os) {
+ ERR("FcObjectSetBuild() Fail");
+ FcConfigDestroy(font_config);
+ return 0;
+ }
+
+ pat = FcPatternCreate();
+ if (NULL == pat) {
+ ERR("FcPatternCreate() Fail");
+ FcObjectSetDestroy(os);
+ FcConfigDestroy(font_config);
+ return 0;
+ }
+
+ fs = FcFontList(font_config, pat, os);
+ FcPatternDestroy(pat);
+ FcObjectSetDestroy(os);
+ if (NULL == fs) {
+ ERR("FcFontList() Fail");
+ FcConfigDestroy(font_config);
+ return 0;
+ }
+
+ INFO("fs->nfont = %d", fs->nfont);
+
+ int i;
+ for (i = 0; i < fs->nfont; i++) {
+ FcChar8 *file = NULL;
+ FcChar8 *family = NULL;
+
+ FcResult result;
+ result = FcPatternGetString(fs->fonts[i], FC_FILE, 0, &file);
+ if (FcResultMatch != result || NULL == file) {
+ ERR("FcPatternGetString() Fail(%d)", result);
+ FcFontSetDestroy(fs);
+ FcConfigDestroy(font_config);
+ return 0;
+ }
+ const char *preloaded = SETTING_FONT_PRELOAD_FONT_PATH;
+ const char *downloaded = SETTING_FONT_DOWNLOADED_FONT_PATH;
+ int preload_len = sizeof(SETTING_FONT_PRELOAD_FONT_PATH) - 1;
+ int download_len = sizeof(SETTING_FONT_DOWNLOADED_FONT_PATH) - 1;
+
+ if (SST_EQUAL == strncmp((char*)file, preloaded, preload_len)
+ || SST_EQUAL == strncmp((char*)file, downloaded, download_len)) {
+ char *family_result = NULL;
+ FcChar8 *lang = NULL;
+ int id = 0;
+ if (FcPatternGetString(fs->fonts[i], FC_FAMILY, id, &family) != FcResultMatch)
+ break;
+ if (FcPatternGetString(fs->fonts[i], FC_FAMILYLANG, id, &lang) != FcResultMatch)
+ break;
+ family_result = (char*)family;
+
+ /* Find proper family name for current locale. */
+ while (locale && family && lang) {
+ if (SST_EQUAL == strncmp(locale, (char*)lang, strlen((char*)lang))) {
+ family_result = (char*)family;
+ break;
+ }
+
+ /* I will set english as default family language. */
+ /* If there is no proper family language for current locale, */
+ /* we have to show the english family name. */
+ if (SST_EQUAL == strcmp((char*)lang, "en"))
+ family_result = (char*)family;
+
+ id++;
+ if (FcPatternGetString(fs->fonts[i], FC_FAMILY, id, &family) != FcResultMatch)
+ break;
+ if (FcPatternGetString(fs->fonts[i], FC_FAMILYLANG, id, &lang) != FcResultMatch)
+ break;
+ }
+
+ if (family_result) {
+ DBG("family = %s", family_result);
+ if (strcmp(family_result, font_name) == 0) {
+ ret = 1;
+ break;
+ }
+ }
+ }
+ }
+ FcFontSetDestroy(fs);
+ FcConfigDestroy(font_config);
+ return ret;
+}
+
+API char* sstu_get_default_font()
+{
+ return _get_main_font_family(SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS);
+}
+
+static int _get_font_size()
+{
+ int font_size = -1;
+
+ int vconf_value = -1;
+ if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
+ ERR("vconf_get_int() Fail");
+ return -1;
+ }
+
+ switch (vconf_value) {
+ case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
+ font_size = SMALL_FONT_DPI;
+ break;
+ case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
+ font_size = MIDDLE_FONT_DPI;
+ break;
+ case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
+ font_size = LARGE_FONT_DPI;
+ break;
+ case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
+ font_size = HUGE_FONT_DPI;
+ break;
+ case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
+ font_size = GIANT_FONT_DPI;
+ break;
+ default:
+ font_size = MIDDLE_FONT_DPI;
+ break;
+ }
+ return font_size;
+}
+
+API bool sstu_set_font_config(char *font_name)
+{
+ int font_size = _get_font_size();
+ return eext_config_font_set(font_name, font_size);
+}
+
+API void sstu_set_font_size()
+{
+ int font_size = _get_font_size();
+ char *font_name = NULL;
+ font_name = vconf_get_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME);
+ eext_config_font_set(font_name, font_size);
+ free(font_name);
+}
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-appfw-package-manager)
+BuildRequires: pkgconfig(ecore-evas)
+BuildRequires: pkgconfig(efl-extension)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
-
BuildRequires: pkgconfig(sqlite3)
-BuildRequires: efl
BuildRequires: capi-system-info-test
BuildRequires: default-fonts-sdk
-# BuildRequires: model-config-tm1
%if 0%{?gcov:1}
BuildRequires: lcov
%endif
%description
System setting api for get,set configuration
+%package util-lib
+Summary: Utility library for %{name}
+Group: System/System Info
+Requires: %{name} = %{version}
+
+%description util-lib
+The %{name}-utils pacakge contains an utility library for handling font and image
+
%package devel
Summary: A System Settings library in Tizen Native API (Development)
Group: System/System Info
-Requires: %{name} = %{version}-%{release}
+Requires: %{name} = %{version}
Requires: pkgconfig(capi-base-common)
%description devel
%check
bash tests/scripts/vconf_golden_master.sh
-LD_LIBRARY_PATH=.:tests:utils LD_PRELOAD=tests/libsys-settings-mock.so tests/sys-settings-test
+LD_LIBRARY_PATH=.:tests:libutil LD_PRELOAD=tests/libsys-settings-mock.so tests/sys-settings-test
+%if 0%{?gcov:1}
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
+%endif
+%post -p /sbin/ldconfig
+%post util-lib -p /sbin/ldconfig
%post unittests
XDG_RUNTIME_DIR=/run %{sys_setting_test_dir}/sys-settings-test
-%post -p /sbin/ldconfig
-
%postun -p /sbin/ldconfig
+%postun util-lib -p /sbin/ldconfig
%files
%manifest %{name}.manifest
%{_libdir}/lib*settings.so.*
+%license LICENSE.APLv2
+
+%files util-lib
+%manifest %{name}.manifest
%{_libdir}/lib*settings-util.so
%license LICENSE.APLv2
#include "sst.h"
#include "sst_core.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_vconf.h"
#include "sst_interface.h"
INFO("key = %d, %s", key, iface->vconf_key);
- ret = sst_utils_add_multi_cb(&iface->changed_cb_list, callback, user_data);
+ ret = sst_misc_add_multi_cb(&iface->changed_cb_list, callback, user_data);
if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
- ERR("sst_utils_add_multi_cb() Fail(%d)", ret);
+ ERR("sst_misc_add_multi_cb() Fail(%d)", ret);
return ret;
}
return ret;
}
- ret = sst_utils_del_multi_cb(&iface->changed_cb_list, callback);
+ ret = sst_misc_del_multi_cb(&iface->changed_cb_list, callback);
if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
- ERR("sst_utils_del_multi_cb() Fail(%d)", ret);
+ ERR("sst_misc_del_multi_cb() Fail(%d)", ret);
return ret;
}
#include <package_manager.h>
#include <vconf.h>
#include "sst.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_vconf.h"
#include "sst_interface.h"
{
char *vconf_value = value;
- bool is_valid = sst_utils_exist(vconf_value);
+ bool is_valid = sst_misc_exist(vconf_value);
if (true == is_valid) {
if (vconf_set_str(iface->vconf_key, vconf_value)) {
ERR("vconf_set_str(%s, %s) Fail", iface->vconf_key, vconf_value);
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
} else {
- ERR("sst_utils_exist(%s) Fail", vconf_value);
+ ERR("sst_misc_exist(%s) Fail", vconf_value);
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
int sst_del_value(system_settings_key_e key, sst_interface_data_type data_type, void *value);
int sst_list_value(system_settings_key_e key, sst_interface_data_type data_type, bool(*system_setting_data_iterator)(int, const char*, void *), void *user_data);
-
int sst_get_network_wifi_notification(sst_interface *iface, void **value);
int sst_set_sound_notification(sst_interface *iface, void *value);
int sst_get_ads_id(sst_interface *iface, void **value);
int sst_set_ads_id(sst_interface *iface, void *value);
-int sst_get_uds_state(sst_interface *iface, void **value);
\ No newline at end of file
+int sst_get_uds_state(sst_interface *iface, void **value);
*/
#pragma once
-
-int sst_excl_set_wallpaper(const char *key, const char *val);
\ No newline at end of file
+int sst_excl_set_wallpaper(const char *key, const char *val);
int sst_feature_check_font(void *value);
int sst_feature_check_accessibility_grayscale(void *value);
int sst_feature_check_accessibility_negative(void *value);
-int sst_feature_check_rotary(void *value);
\ No newline at end of file
+int sst_feature_check_rotary(void *value);
*/
#include "sst_font.h"
-#include <dlfcn.h>
#include <libxml/tree.h>
#include <vconf.h>
#include "sst.h"
-
-static const char* const sst_utils_library = SETTING_UTILS_SO_FILE_PATH;
-
-static int dl_is_available_font(char *str)
-{
- void *handle = NULL;
- char *error;
- int ret = 0;
- int (*check_available_font)(char *font_name);
-
- handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail", sst_utils_library);
- return 0;
- }
-
- check_available_font = dlsym(handle, "sstu_is_available_font");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_is_available_font) Fail(%s)", error);
- dlclose(handle);
- return 0;
- }
- ret = check_available_font(str);
- dlclose(handle);
- return ret;
-}
-
-static void dl_font_size_set()
-{
- void *handle = NULL;
- char *error;
- void(*set_font_size)();
-
- handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail", sst_utils_library);
- return;
- }
-
- set_font_size = dlsym(handle, "sstu_set_font_size");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_set_font_size) Fail(%s)", error);
- dlclose(handle);
- return;
- }
- set_font_size();
- dlclose(handle);
- return;
-}
-
-static void dl_font_config_set_notification()
-{
- void *handle = NULL;
- char *error;
- void (*set_font_nodification)();
-
- handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail", sst_utils_library);
- return;
- }
-
- set_font_nodification = dlsym(handle, "sstu_font_config_set_notification");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_font_config_set_notification) Fail(%s)", error);
- dlclose(handle);
- return;
- }
- set_font_nodification();
- dlclose(handle);
- return;
-}
-
-static bool dl_font_config_set(char *font_name)
-{
- void *handle = NULL;
- char *error;
- bool ret = false;
- bool (*check_font_type)(char *font_name);
-
- handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail", sst_utils_library);
- return false;
- }
-
- check_font_type = dlsym(handle, "sstu_set_font_config");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_set_font_config) Fail(%s)", error);
- dlclose(handle);
- return false;
- }
- ret = check_font_type(font_name);
- dlclose(handle);
- return ret;
-}
-
-static char *dl_get_default_font_info()
-{
- void *handle = NULL;
- char *error;
- char *ret = NULL;
- char *(*get_font_info)();
-
- handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail", sst_utils_library);
- return NULL;
- }
-
- get_font_info = dlsym(handle, "sstu_get_default_font");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_get_default_font) Fail(%s)", error);
- dlclose(handle);
- return NULL;
- }
- ret = get_font_info();
- dlclose(handle);
- return ret;
-}
+#include "sst_utils_wrapper.h"
int sst_font_set_size(sst_interface *iface, void *value)
{
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
- dl_font_size_set();
+ sstu_set_font_size();
return SYSTEM_SETTINGS_ERROR_NONE;
}
font_name = (char*)value;
/* get current font list */
- int is_found = dl_is_available_font(font_name);
+ int is_found = sstu_is_available_font(font_name);
if (is_found == 1) {
DBG("found font : %s ", font_name);
} else {
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
- bool bsave = dl_font_config_set(font_name);
+ bool bsave = sstu_set_font_config(font_name);
if (!bsave) {
- ERR("dl_font_config_set() Fail");
+ ERR("sstu_set_font_config() Fail");
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
doc = NULL;
}
- dl_font_config_set_notification();
+ sstu_font_config_set_notification();
char *vconf_value;
vconf_value = (char*)value;
int sst_font_get_default_type(sst_interface *iface, void **value)
{
- char *font_name = dl_get_default_font_info();
+ char *font_name = sstu_get_default_font();
if (NULL == font_name) {
- ERR("dl_get_default_font_info() Fail");
+ ERR("sstu_get_default_font() Fail");
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
#include "sst.h"
#include "sst_core.h"
#include "sst_font.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_vconf.h"
#include "sst_screen.h"
#include "sst_feature.h"
void *user_data;
};
-int sst_get_interface(system_settings_key_e key, sst_interface **iface);
\ No newline at end of file
+int sst_get_interface(system_settings_key_e key, sst_interface **iface);
}
return false;
-}
\ No newline at end of file
+}
void sst_json_get_ringtones(sst_json_h *handle, system_settings_iter_cb cb, void *user_data);
void sst_json_add_ringtone(sst_json_h *handle, char *nameval, char *pathval);
void sst_json_remove_ringtone(sst_json_h *handle, char *path_to_del);
-bool sst_json_contain_ringtone(sst_json_h *handle, char *newfile);
\ No newline at end of file
+bool sst_json_contain_ringtone(sst_json_h *handle, char *newfile);
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "sst_utils.h"
+#include "sst_misc.h"
#include <unistd.h>
#include <errno.h>
return 1;
}
-int sst_utils_add_multi_cb(callback_list *handle, system_settings_changed_cb cb, void *user_data)
+int sst_misc_add_multi_cb(callback_list *handle, system_settings_changed_cb cb, void *user_data)
{
RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
return SYSTEM_SETTINGS_ERROR_NONE;
}
-int sst_utils_del_multi_cb(callback_list *handle, system_settings_changed_cb cb)
+int sst_misc_del_multi_cb(callback_list *handle, system_settings_changed_cb cb)
{
RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
return SYSTEM_SETTINGS_ERROR_NONE;
}
-int sst_utils_invoke_cb_list(callback_list *handle, system_settings_key_e key)
+int sst_misc_invoke_cb_list(callback_list *handle, system_settings_key_e key)
{
RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
return SYSTEM_SETTINGS_ERROR_NONE;
}
-bool sst_utils_exist(const char *path)
+bool sst_misc_exist(const char *path)
{
if (0 != access(path, R_OK)) {
/* error code : 13 */
}
return true;
}
+
#include <stdbool.h>
#include "sst_interface.h"
-int sst_utils_add_multi_cb(callback_list *handle, system_settings_changed_cb ptr, void *user_data);
-int sst_utils_del_multi_cb(callback_list *handle, system_settings_changed_cb ptr);
-int sst_utils_invoke_cb_list(callback_list *handle, system_settings_key_e key);
+int sst_misc_add_multi_cb(callback_list *handle, system_settings_changed_cb ptr, void *user_data);
+int sst_misc_del_multi_cb(callback_list *handle, system_settings_changed_cb ptr);
+int sst_misc_invoke_cb_list(callback_list *handle, system_settings_key_e key);
-bool sst_utils_exist(const char *path);
+bool sst_misc_exist(const char *path);
#include "sst.h"
#include "sst_json.h"
#include "sst_vconf.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_interface.h"
typedef struct _file_Info {
{
char *vconf_value = value;
- bool is_valid = sst_utils_exist(vconf_value);
+ bool is_valid = sst_misc_exist(vconf_value);
if (false == is_valid) {
- ERR("sst_utils_exist(%s) Fail", vconf_value);
+ ERR("sst_misc_exist(%s) Fail", vconf_value);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
{
char *vconf_value = value;
- bool is_valid = sst_utils_exist(vconf_value);
+ bool is_valid = sst_misc_exist(vconf_value);
if (false == is_valid) {
- ERR("sst_utils_exist(%s) Fail", vconf_value);
+ ERR("sst_misc_exist(%s) Fail", vconf_value);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
/* check to see if it's accessable -> OK */
/* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
- bool is_valid = sst_utils_exist(vconf_value);
+ bool is_valid = sst_misc_exist(vconf_value);
if (true == is_valid) {
*value = vconf_value;
} else {
/* check to see if it's accessable -> OK */
/* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
- bool is_valid = sst_utils_exist(vconf_value);
+ bool is_valid = sst_misc_exist(vconf_value);
if (true == is_valid) {
*value = vconf_value;
} else {
#include <vconf.h>
#include "sst.h"
#include "sst_vconf.h"
-#include "sst_utils.h"
#include "sst_exclusive.h"
+#include "sst_utils_wrapper.h"
int sst_screen_set_backlight_time(sst_interface *iface, void *value)
{
return SYSTEM_SETTINGS_ERROR_NONE;
}
-static bool _screen_is_valid_img(char *path)
-{
- void *handle = NULL;
- char *error;
- bool ret = false;
- bool (*image_type_check)(char *path);
-
- handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY | RTLD_GLOBAL);
- if (NULL == handle) {
- ERR("dlopen(%s) Fail(%d)", SETTING_UTILS_SO_FILE_PATH, errno);
- return false;
- }
-
- image_type_check = dlsym(handle, "sstu_is_valid_image");
- if ((error = dlerror()) != NULL) {
- ERR("dlsym(sstu_is_valid_image) Fail(%s)", error);
- dlclose(handle);
- return false;
- }
-
- ret = image_type_check(path);
- dlclose(handle);
- return ret;
-}
-
int sst_screen_set_home_wallpaper(sst_interface *iface, void *value)
{
char *vconf_value = value;
- bool valid = _screen_is_valid_img(vconf_value);
+ bool valid = sstu_is_valid_image(vconf_value);
if (false == valid) {
ERR("Invalid image file(%s)", vconf_value);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
{
char *vconf_value = value;
- bool valid = _screen_is_valid_img(vconf_value);
+ bool valid = sstu_is_valid_image(vconf_value);
if (false == valid) {
ERR("Invalid image file(%s)", vconf_value);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
#include <vconf.h>
#include "sst.h"
#include "sst_vconf.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_interface.h"
int sst_locale_get_country(sst_interface *iface, void **value)
char tzpath[PATH_MAX];
snprintf(tzpath, sizeof(tzpath), SETTING_TIME_ZONEINFO_PATH"/%s", timezone);
- if (false == sst_utils_exist(tzpath)) {
- ERR("sst_utils_exist(%s) Fail", tzpath);
+ if (false == sst_misc_exist(tzpath)) {
+ ERR("sst_misc_exist(%s) Fail", tzpath);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#include "sst_utils_wrapper.h"
+
+#include <dlfcn.h>
+#include "sst.h"
+
+static void *sst_utils_handle;
+static const char* const sst_utils_library = SETTING_UTILS_SO_FILE_PATH;
+
+static void* _utils_load_lib()
+{
+ if (sst_utils_handle)
+ return sst_utils_handle;
+
+ sst_utils_handle = dlopen(sst_utils_library, RTLD_LAZY | RTLD_GLOBAL);
+ if (NULL == sst_utils_handle) {
+ ERR("dlopen(%s) Fail", sst_utils_library);
+ }
+
+ return sst_utils_handle;
+}
+
+bool sstu_set_font_config(char *font_name)
+{
+ static bool (*fn_impl)(char*);
+ if (fn_impl)
+ return fn_impl(font_name);
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return false;
+ }
+
+ fn_impl = dlsym(handle, "sstu_set_font_config");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_set_font_config) Fail(%s)", error);
+ return false;
+ }
+
+ return fn_impl(font_name);
+}
+
+int sstu_is_available_font(char *font_name)
+{
+ static int (*fn_impl)(char*) = NULL;
+ if (fn_impl)
+ return fn_impl(font_name);
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return 0;
+ }
+
+ fn_impl = dlsym(handle, "sstu_is_available_font");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_is_available_font) Fail(%s)", error);
+ return 0;
+ }
+
+ return fn_impl(font_name);
+}
+
+char* sstu_get_default_font()
+{
+ static char* (*fn_impl)(void) = NULL;
+ if (fn_impl)
+ return fn_impl();
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return NULL;
+ }
+
+ fn_impl = dlsym(handle, "sstu_get_default_font");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_get_default_font) Fail(%s)", error);
+ return NULL;
+ }
+
+ return fn_impl();
+}
+
+bool sstu_is_valid_image(char *path)
+{
+ static bool (*fn_impl)(char*) = NULL;
+ if (fn_impl)
+ return fn_impl(path);
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return false;
+ }
+
+ fn_impl = dlsym(handle, "sstu_is_valid_image");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_is_valid_image) Fail(%s)", error);
+ return false;
+ }
+
+ return fn_impl(path);
+}
+void sstu_set_font_size()
+{
+ static void (*fn_impl)() = NULL;
+ if (fn_impl)
+ return fn_impl();
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return;
+ }
+
+ fn_impl = dlsym(handle, "sstu_set_font_size");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_set_font_size) Fail(%s)", error);
+ return;
+ }
+
+ return fn_impl();
+}
+
+void sstu_font_config_set_notification()
+{
+ static void (*fn_impl)() = NULL;
+ if (fn_impl)
+ return fn_impl();
+
+ void *handle = _utils_load_lib();
+ if (NULL == handle) {
+ ERR("No Utils Library Handle");
+ return;
+ }
+
+ fn_impl = dlsym(handle, "sstu_font_config_set_notification");
+ char *error = dlerror();
+ if (error) {
+ ERR("dlsym(sstu_font_config_set_notification) Fail(%s)", error);
+ return;
+ }
+
+ return fn_impl();
+}
+
+//It is called after releasing the global variable(sst_utils_handle)
+//Therefore, It is better to leave as it is.
+/*
+__attribute__((destructor)) static void _utils_unload_lib()
+{
+ dlclose(sst_utils_handle);
+ sst_utils_handle = NULL;
+}
+*/
\ No newline at end of file
-/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
*
- * Licensed under the Apache License, Version 2.0 (the License);
+ * 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,
+ * 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.
*/
#pragma once
+#include <stdbool.h>
+
+//It is same with util Library
bool sstu_set_font_config(char *font_name);
int sstu_is_available_font(char *font_name);
char* sstu_get_default_font();
#include <vconf.h>
#include "sst.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
#include "sst_interface.h"
typedef enum {
return;
}
- ret = sst_utils_invoke_cb_list(&iface->changed_cb_list, pkey);
+ ret = sst_misc_invoke_cb_list(&iface->changed_cb_list, pkey);
if (SYSTEM_SETTINGS_ERROR_NONE != ret)
- ERR("sst_utils_invoke_cb_list(%d) Fail(%d)", pkey, ret);
+ ERR("sst_misc_invoke_cb_list(%d) Fail(%d)", pkey, ret);
}
static void _vconf_event_multi_cb_slot_0(keynode_t *node, void *event_data)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
ADD_DEFINITIONS("-DSST_TEST")
-FILE(GLOB MOCK_SRCS mocks/*.c mocks/*.cpp)
SET(MOCK_LIB "sys-settings-mock")
+FILE(GLOB MOCK_SRCS mocks/*.c mocks/*.cpp)
ADD_LIBRARY(${MOCK_LIB} SHARED ${MOCK_SRCS})
-SET(EFL_EXTENSION_MOCK "efl-extension")
-ADD_LIBRARY(${EFL_EXTENSION_MOCK} SHARED mocks/efl-extension.c)
-SET_TARGET_PROPERTIES(${EFL_EXTENSION_MOCK} PROPERTIES SOVERSION 0)
-
FILE(GLOB TEST_SRCS *.c)
ADD_DEFINITIONS("-DN_THREADS=${N_THREADS}")
ADD_DEFINITIONS(-DSYS_SETTINGS_TEST_DIR=\"${TEST_INSTALL_DIR}\")
API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
{
return PMINFO_R_OK;
-}
\ No newline at end of file
+}
+++ /dev/null
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
-
-SET(LIB_UTILS system-settings-util)
-
-FILE(GLOB UTILS_SRCS *.c)
-
-PKG_CHECK_MODULES(utils_pkgs REQUIRED dlog vconf fontconfig libxml-2.0 pkgmgr
- pkgmgr-info libsystemd)
-INCLUDE_DIRECTORIES(${client_pkgs_INCLUDE_DIRS})
-LINK_DIRECTORIES(${client_pkgs_LIBRARY_DIRS})
-
-ADD_LIBRARY(${LIB_UTILS} SHARED ${UTILS_SRCS})
-TARGET_LINK_LIBRARIES(${LIB_UTILS} ${utils_LIBRARIES})
-INSTALL(TARGETS ${LIB_UTILS} DESTINATION ${LIB_INSTALL_DIR})
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <time.h>
-#include <locale.h>
-#include <regex.h>
-#include <vconf.h>
-#include <glib.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-
-#include <fontconfig/fontconfig.h>
-
-#include <pkgmgr-info.h>
-#include <tzplatform_config.h>
-
-#include "system_settings.h"
-#include "sst.h"
-#include "sst_core.h"
-#include "sstu.h"
-#include "sstu_font.h"
-
-#ifdef TIZEN_WEARABLE
-#define SMALL_FONT_DPI (-90)
-#else
-#define SMALL_FONT_DPI (-80)
-#endif
-
-#define MIDDLE_FONT_DPI (-100)
-
-#ifdef TIZEN_WEARABLE
-#define LARGE_FONT_DPI (-110)
-#else
-#define LARGE_FONT_DPI (-150)
-#endif
-
-#define HUGE_FONT_DPI (-190)
-#define GIANT_FONT_DPI (-250)
-
-#define SETTING_FONT_PRELOAD_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
-#define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_SHARE"/fonts"
-
-#define SETTING_FONT_TIZEN_FONT_ALIAS "Tizen"
-#define SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS "TizenDefaultFont"
-
-#define SETTING_FONT_CONFIG_SO_PATH "libfontconfig.so.1"
-#define SETTING_ECORE_EVAS_SO_PATH "libecore_evas.so.1"
-#define SETTING_EFL_EXTENSION_SO_PATH "libefl-extension.so.0"
-#define SETTING_EVAS_SO_PATH "libevas.so.1"
-
-static void *sstu_font_handle = NULL;
-static void *sstu_efl_handle = NULL;
-static void *sstu_evas_handle = NULL;
-static void *sstu_efl_ext_handle = NULL;
-
-#define DYM_FUNC_LOADING(error, handle, pfunc, func_name) do { \
- pfunc = dlsym(handle, func_name); \
- if ((error = dlerror()) != NULL) { \
- SECURE_ERR("ERROR!! canNOT find %s function at %s", func_name, #handle); \
- if (handle) \
- dlclose(handle); \
- return false; \
- } \
-} while (0)
-
-#define DYM_CLOSE_HANDLE(handle) do { \
- if (handle) { \
- dlclose(handle); \
- handle = NULL; \
- } \
-} while (0)
-
-static int _load_font_symbol(f_libs *font_lib)
-{
- char *error = NULL;
-
- if (!font_lib)
- return false;
-
- if (!sstu_font_handle) {
- sstu_font_handle = dlopen(SETTING_FONT_CONFIG_SO_PATH, RTLD_LAZY | RTLD_GLOBAL);
- if (!sstu_font_handle) {
- SECURE_ERR("ERROR!! canNOT find "SETTING_FONT_CONFIG_SO_PATH);
- return false;
- }
- }
-
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcInitLoadConfigAndFonts, "FcInitLoadConfigAndFonts");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcPatternBuild, "FcPatternBuild");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcConfigDestroy, "FcConfigDestroy");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcConfigSubstitute, "FcConfigSubstitute");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcDefaultSubstitute, "FcDefaultSubstitute");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcFontSort, "FcFontSort");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcPatternGetString, "FcPatternGetString");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcFontSetDestroy, "FcFontSetDestroy");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcPatternDestroy, "FcPatternDestroy");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcPatternCreate, "FcPatternCreate");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcObjectSetBuild, "FcObjectSetBuild");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcFontList, "FcFontList");
- DYM_FUNC_LOADING(error, sstu_font_handle, font_lib->d_FcObjectSetDestroy, "FcObjectSetDestroy");
-
- return true;
-}
-
-static int _load_efl(e_libs *efl_libs)
-{
- char *error = NULL;
-
- if (!efl_libs)
- return false;
-
- if (!sstu_efl_handle) {
- sstu_efl_handle = dlopen(SETTING_ECORE_EVAS_SO_PATH, RTLD_LAZY | RTLD_GLOBAL);
- if (!sstu_efl_handle) {
- SECURE_ERR("ERROR!! canNOT find "SETTING_ECORE_EVAS_SO_PATH" %s", dlerror());
-
- return false;
- }
- }
-
- if (!sstu_evas_handle) {
- sstu_evas_handle = dlopen(SETTING_EVAS_SO_PATH, RTLD_LAZY | RTLD_GLOBAL);
- if (!sstu_evas_handle) {
- SECURE_ERR("ERROR!! canNOT find "SETTING_EVAS_SO_PATH" %s", dlerror());
- return false;
- }
- }
-
- DYM_FUNC_LOADING(error, sstu_evas_handle, efl_libs->d_evas_init, "evas_init");
- DYM_FUNC_LOADING(error, sstu_evas_handle, efl_libs->d_evas_object_image_add, "evas_object_image_add");
- DYM_FUNC_LOADING(error, sstu_evas_handle, efl_libs->d_evas_object_image_file_set, "evas_object_image_file_set");
- DYM_FUNC_LOADING(error, sstu_evas_handle, efl_libs->d_evas_object_image_load_error_get, "evas_object_image_load_error_get");
- DYM_FUNC_LOADING(error, sstu_evas_handle, efl_libs->d_evas_shutdown, "evas_shutdown");
-
- DYM_FUNC_LOADING(error, sstu_efl_handle, efl_libs->d_ecore_evas_init, "ecore_evas_init");
- DYM_FUNC_LOADING(error, sstu_efl_handle, efl_libs->d_ecore_evas_shutdown, "ecore_evas_shutdown");
- DYM_FUNC_LOADING(error, sstu_efl_handle, efl_libs->d_ecore_evas_new, "ecore_evas_new");
- DYM_FUNC_LOADING(error, sstu_efl_handle, efl_libs->d_ecore_evas_get, "ecore_evas_get");
- DYM_FUNC_LOADING(error, sstu_efl_handle, efl_libs->d_ecore_evas_free, "ecore_evas_free");
-
- return true;
-}
-
-static void _close_efl()
-{
- DYM_CLOSE_HANDLE(sstu_evas_handle);
- DYM_CLOSE_HANDLE(sstu_efl_handle);
-}
-
-static int _load_efl_extension(ex_libs *eext_libs)
-{
- char *error = NULL;
-
- if (!eext_libs)
- return false;
-
- if (!sstu_efl_ext_handle) {
- sstu_efl_ext_handle = dlopen(SETTING_EFL_EXTENSION_SO_PATH, RTLD_LAZY | RTLD_GLOBAL);
- if (!sstu_efl_ext_handle) {
- SECURE_ERR("ERROR!! canNOT find "SETTING_EFL_EXTENSION_SO_PATH" %s", dlerror());
- return false;
- }
- }
-
- DYM_FUNC_LOADING(error, sstu_efl_ext_handle, eext_libs->d_eext_config_font_set, "eext_config_font_set");
-
- return true;
-}
-
-static char* _get_main_font_family(char *alias)
-{
- FcFontSet *set = NULL;
- FcPattern *pat = NULL;
- FcConfig *font_config = NULL;
- FcChar8 *family = NULL;
- char *ret = NULL;
- FcResult res = 0;
- f_libs font_libs;
-
- if (!_load_font_symbol(&font_libs))
- return NULL;
-
- font_config = font_libs.d_FcInitLoadConfigAndFonts();
- if (font_config == NULL) {
- DYM_CLOSE_HANDLE(sstu_font_handle);
- return ret;
- }
-
- pat = font_libs.d_FcPatternBuild(0, FC_FAMILY, FcTypeString, alias, (char*)0);
-
- if (pat == NULL) {
- if (font_config != NULL) {
- font_libs.d_FcConfigDestroy(font_config);
- font_config = NULL;
- }
- DYM_CLOSE_HANDLE(sstu_font_handle);
- return ret;
- }
-
- font_libs.d_FcConfigSubstitute(font_config, pat, FcMatchPattern);
- font_libs.d_FcDefaultSubstitute(pat);
-
- /* do matching */
- set = font_libs.d_FcFontSort(font_config, pat, FcTrue, NULL, &res);
-
- if (set != NULL && (set->nfont > 0)) {
- font_libs.d_FcPatternGetString(set->fonts[0], FC_FAMILY, 0, &family);
- ret = g_strdup((char*)family);
-
- font_libs.d_FcFontSetDestroy(set);
- set = NULL;
- }
-
- if (set != NULL) {
- font_libs.d_FcFontSetDestroy(set);
- set = NULL;
- }
-
- if (pat != NULL) {
- font_libs.d_FcPatternDestroy(pat);
- pat = NULL;
- }
-
- if (font_config != NULL) {
- font_libs.d_FcConfigDestroy(font_config);
- font_config = NULL;
- }
- DYM_CLOSE_HANDLE(sstu_font_handle);
- return ret;
-}
-
-API bool sstu_is_valid_image(char *path)
-{
- e_libs efl_libs;
- if (!_load_efl(&efl_libs)) {
- SECURE_ERR("ERROR!! canNOT loading efl!!");
- return false;
- }
-
- void *ee;
- void *evas;
-
- if (!efl_libs.d_ecore_evas_init()) {
- _close_efl();
- return false;
- }
-
- ee = efl_libs.d_ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
- evas = efl_libs.d_ecore_evas_get(ee);
-
- void *img = efl_libs.d_evas_object_image_add(evas);
- efl_libs.d_evas_object_image_file_set(img, path, NULL);
- int ret = efl_libs.d_evas_object_image_load_error_get(img);
-
- bool result = false;
- if (ret == 0) {
- SECURE_ERR("%s - OK", path);
- result = true;
- } else {
- SECURE_ERR("%s - NO", path);
- result = false;
- }
- efl_libs.d_ecore_evas_free(ee);
- efl_libs.d_ecore_evas_shutdown();
- _close_efl();
- return result;
-}
-
-API void sstu_font_config_set_notification()
-{
-}
-
-API int sstu_is_available_font(char *font_name)
-{
- FcObjectSet *os = NULL;
- FcFontSet *fs = NULL;
- FcPattern *pat = NULL;
- FcConfig *font_config = NULL;
- int ret = 0;
- f_libs font_libs = {0};
-
- if (!_load_font_symbol(&font_libs))
- return -1;
-
- if (font_name == NULL) {
- DYM_CLOSE_HANDLE(sstu_font_handle);
- return -1;
- }
-
- font_config = font_libs.d_FcInitLoadConfigAndFonts();
-
- /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
-
- char *locale = setlocale(0, NULL);
-
- pat = font_libs.d_FcPatternCreate();
-
- os = font_libs.d_FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char*)0);
-
- if (os) {
- fs = font_libs.d_FcFontList(font_config, pat, os);
- font_libs.d_FcObjectSetDestroy(os);
- os = NULL;
- }
-
- if (pat) {
- font_libs.d_FcPatternDestroy(pat);
- pat = NULL;
- }
-
- if (fs) {
- int j;
- SECURE_ERR("fs->nfont = %d", fs->nfont);
-
- for (j = 0; j < fs->nfont; j++) {
- FcChar8 *family = NULL;
- FcChar8 *file = NULL;
-
- if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
- int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
- int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
-
- if (file && (!strncmp((const char*)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
- || !strncmp((const char*)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
- char *family_result = NULL;
- FcChar8 *lang = NULL;
- int id = 0;
- if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch)
- break;
- if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch)
- break;
- family_result = (char*)family;
-
- /* Find proper family name for current locale. */
- while (locale && family && lang) {
- if (!strncmp(locale, (char*)lang, strlen((char*)lang))) {
- family_result = (char*)family;
- break;
- }
-
- /* I will set english as default family language. */
- /* If there is no proper family language for current locale, */
- /* we have to show the english family name. */
- if (!strcmp((char*)lang, (char*)"en"))
- family_result = (char*)family;
-
- id++;
- if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch)
- break;
- if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch)
- break;
- }
-
- if (family_result) {
- SECURE_ERR("-------- FONT - family_result = %s", (char*)family_result);
- if (strcmp(family_result, font_name) == 0) {
- ret = 1;
- break;
- }
- }
- }
- }
- }
- font_libs.d_FcFontSetDestroy(fs);
- fs = NULL;
- }
- font_libs.d_FcConfigDestroy(font_config);
- font_config = NULL;
- DYM_CLOSE_HANDLE(sstu_font_handle);
- return ret;
-}
-
-API char* sstu_get_default_font()
-{
- return _get_main_font_family(SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS);
-}
-
-static int _get_font_size()
-{
- int font_size = -1;
-
- int vconf_value = -1;
- if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value))
- return -1;
-
- switch (vconf_value) {
- case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
- font_size = SMALL_FONT_DPI;
- break;
- case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
- font_size = MIDDLE_FONT_DPI;
- break;
- case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
- font_size = LARGE_FONT_DPI;
- break;
- case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
- font_size = HUGE_FONT_DPI;
- break;
- case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
- font_size = GIANT_FONT_DPI;
- break;
- default:
- font_size = MIDDLE_FONT_DPI;
- break;
- }
- return font_size;
-}
-
-API bool sstu_set_font_config(char *font_name)
-{
- ex_libs eext_libs;
- if (!_load_efl_extension(&eext_libs))
- return false;
- int font_size = _get_font_size();
- bool ret = eext_libs.d_eext_config_font_set(font_name, font_size);
- DYM_CLOSE_HANDLE(sstu_efl_ext_handle);
- return ret;
-}
-
-API void sstu_set_font_size()
-{
- ex_libs eext_libs;
- if (!_load_efl_extension(&eext_libs))
- return;
- int font_size = _get_font_size();
- char *font_name = NULL;
- font_name = vconf_get_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME);
-
- eext_libs.d_eext_config_font_set(font_name, font_size);
-
- DYM_CLOSE_HANDLE(sstu_efl_ext_handle);
- free(font_name);
-}
+++ /dev/null
-/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#include <fontconfig/fontconfig.h>
-#include <dlfcn.h>
-
-typedef struct _f_libs {
- FcConfig* (*d_FcInitLoadConfigAndFonts) (void);
- FcPattern* (*d_FcPatternBuild) (FcPattern *p, ...);
- void(*d_FcConfigDestroy) (FcConfig *config);
- FcBool(*d_FcConfigSubstitute) (FcConfig *config, FcPattern *p, FcMatchKind kind);
- void(*d_FcDefaultSubstitute) (FcPattern *pattern);
- FcFontSet* (*d_FcFontSort) (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result);
- FcResult(*d_FcPatternGetString) (const FcPattern *p, const char *object, int n, FcChar8 ** s);
- void(*d_FcFontSetDestroy) (FcFontSet *s);
- void(*d_FcPatternDestroy) (FcPattern *p);
- FcPattern* (*d_FcPatternCreate) (void);
- FcObjectSet* (*d_FcObjectSetBuild) (const char *first, ...);
- FcFontSet* (*d_FcFontList) (FcConfig *config, FcPattern *p, FcObjectSet *os);
- void(*d_FcObjectSetDestroy) (FcObjectSet *os);
-} f_libs;
-
-typedef struct _e_libs {
- int (*d_evas_init) (void);
- void* (*d_ecore_evas_new) (const char *engine_name, int x, int y, int w, int h, const char *extra_options);
- void* (*d_ecore_evas_get) (const void *ee);
- void* (*d_evas_object_image_add) (void *eo_e);
- void (*d_evas_object_image_file_set) (void *obj, const char *file, const char *key);
- int (*d_evas_object_image_load_error_get) (const void *obj);
- void (*d_ecore_evas_free) (void *ee);
- int (*d_evas_shutdown) (void);
- int (*d_ecore_evas_init) (void);
- int (*d_ecore_evas_shutdown) (void);
-} e_libs;
-
-typedef struct _eext_libs {
- bool (*d_eext_config_font_set)(char *name, int size);
-} ex_libs;
-