Move config applying logic to efl-ext 41/172441/1 accepted/tizen/unified/20180404.141013 submit/tizen/20180326.073708 submit/tizen/20180329.001034 submit/tizen/20180329.043812
authorWonki Kim <wonki_.kim@samsung.com>
Fri, 9 Mar 2018 08:47:32 +0000 (17:47 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Wed, 14 Mar 2018 04:03:57 +0000 (13:03 +0900)
Change-Id: Iac2e629af61dc8c35d9154de36259726a8da1e61
Signed-off-by: Wonki Kim <wonki_.kim@samsung.com>
packaging/capi-system-system-settings.spec
system-settings-util/CMakeLists.txt
system-settings-util/src/system_settings_util.c

index e56a403..dee82ef 100755 (executable)
@@ -26,6 +26,7 @@ BuildRequires:  pkgconfig(uuid)
 BuildRequires:  pkgconfig(capi-media-metadata-extractor)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(libsystemd)
+BuildRequires:  pkgconfig(efl-extension)
 
 BuildRequires:  pkgconfig(json-glib-1.0)
 BuildRequires:  pkgconfig(glib-2.0)
index ce7a6dc..a8ae7b0 100755 (executable)
@@ -6,7 +6,7 @@ PROJECT(${SYSTEM_SETTINGS_UTIL})
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
-SET(requires "elementary ecore dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info libsystemd")
+SET(requires "elementary ecore dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info libsystemd efl-extension")
 
 PKG_CHECK_MODULES(system_settings_util REQUIRED ${requires})
 
index b7b14c5..4dd835f 100644 (file)
@@ -4,17 +4,6 @@
 #include <errno.h>
 #include <time.h>
 
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <sys/socket.h>
-#include <systemd/sd-login.h>
-#include <fcntl.h>
-
-#define EFL_CONFIG_SOCK_PATH "/run/user_ext/%d"
-#define EFL_CONFIG_SOCKET_FILE ".efl-config.sock"
-
 #include <regex.h>
 
 #include <dlog.h>
@@ -39,6 +28,8 @@
 #include <system_settings_util.h>
 #include <system_settings_font.h>
 
+#include <efl_extension_config.h>
+
 #ifdef TIZEN_WEARABLE
 #define SMALL_FONT_DPI                                         (-90)
 #endif
@@ -364,119 +355,13 @@ char *_get_default_font()
        return __get_main_font_family_name_by_alias(SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS);
 }
 
-bool _is_in_system_session()
-{
-       SETTING_TRACE_BEGIN;
-       int ret = 0;
-       char *slice = NULL;
-
-       ret = sd_pid_get_slice(getpid(), &slice);
-       if (0 <= ret && slice) {
-               if (0 == strncmp(slice, "system.slice", strlen("system.slice"))) {
-                       free(slice);
-                       return true;
-               }
-       } else {
-               SETTING_TRACE("sd_pid_get_slice() Fail(%d)", ret);
-       }
-
-       free(slice);
-       return false;
-}
-
-bool _get_active_uid(uid_t *uid)
-{
-       SETTING_TRACE_BEGIN;
-       int active_user_count = 0;
-       uid_t *active_user_list = NULL;
-
-       active_user_count = sd_get_active_uids(&active_user_list);
-       /* the number of active users is 1 in tizen3.0 */
-       if (1 == active_user_count && active_user_list) {
-               *uid = active_user_list[0];
-               SETTING_TRACE("active uid = %d", *uid);
-       } else {
-               SETTING_TRACE("sd_get_active_uids() Fail(%d)", active_user_count);
-               free(active_user_list);
-               return false;
-       }
-
-       return true;
-}
-
-bool
-_efl_config_set(char *msg)
-{
-       SETTING_TRACE_BEGIN;
-       int fd;
-       char sock_file[1024] = {0};
-       uid_t active_uid = getuid();
-       bool ret = false;
-
-       if (_is_in_system_session() == true) {
-               if (_get_active_uid(&active_uid) == false) {
-                       SETTING_TRACE("get active uid fail");
-                       return ret;
-               }
-       }
-
-       snprintf(sock_file, sizeof(sock_file), EFL_CONFIG_SOCK_PATH"/%s",
-                       active_uid,
-                       EFL_CONFIG_SOCKET_FILE);
-
-       do {
-               int r, size, flags;
-               struct sockaddr_un server_addr;
-
-               fd = socket(PF_UNIX, SOCK_STREAM, 0);
-               if (fd < 0) {
-                       SETTING_TRACE("socket[%d] error :%d", fd, errno);
-                       break;
-               }
-
-               flags = fcntl(fd, F_GETFL, 0);
-               if (flags == -1)
-                       flags = 0;
-               r = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-               if (0 != r)
-                       SETTING_TRACE("fcntl fail : %d", errno);
-
-               bzero(&server_addr, sizeof(server_addr));
-               server_addr.sun_family = AF_UNIX;
-               snprintf(server_addr.sun_path, sizeof(server_addr.sun_path), "%s",
-                               sock_file);
-
-               r = connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr));
-               if (r != 0) {
-                       SETTING_TRACE("connect error : %d, %d", r, errno);
-                       close(fd);
-                       break;
-               }
-
-               size = write(fd, msg, strlen(msg));
-               if (size <= 0) {
-                       SETTING_TRACE("write fail : %d", errno);
-               } else {
-                       ret = true;
-               }
-               close(fd);
-       } while (0);
-
-       return ret;
-}
 
 /*  LCOV_EXCL_START */
 bool font_config_set(char *font_name)
 {
        SETTING_TRACE_BEGIN;
-       char buf[255] = { 0 };
        int font_size = __font_size_get();
-       bool ret;
-
-       snprintf(buf, sizeof(buf), "font_name: %s, font_size: %d", font_name, font_size);
-       ret = _efl_config_set(buf);
-
-       return ret;
+       return eext_config_font_set(font_name, font_size);
 }
 /*  LCOV_EXCL_STOP */
 
@@ -484,14 +369,11 @@ bool font_config_set(char *font_name)
 void __font_size_set()
 {
        SETTING_TRACE_BEGIN;
-       char buf[255] = { 0 };
        int font_size = __font_size_get();
        char *font_name = NULL;
-
        font_name = vconf_get_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME);
 
-       snprintf(buf, sizeof(buf), "font_name: %s, font_size: %d", font_name, font_size);
-       _efl_config_set(buf);
+       eext_config_font_set(font_name, font_size);
 
        g_free(font_name);
 }