common: change implementations of apis using enum 42/40642/3 submit/tizen/20150609.090025
authorTaeyoung Kim <ty317.kim@samsung.com>
Sat, 6 Jun 2015 13:49:21 +0000 (22:49 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 9 Jun 2015 08:53:04 +0000 (17:53 +0900)
- The apis using enum values will be deprecated.
- The implementations of the apis are changed to use key string
  declared on Tizen.org developer guide

Change-Id: Iab978500aad94c257acf7bf207bfc38b9496dab3
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
CMakeLists.txt
include/system_info_private.h
packaging/capi-system-info.spec
src/system_info_device.c
src/system_info_platform.c
src/system_info_screen.c

index ebf03a7a2e1222ec2ae035dbe7532f1abb973f31..be10b51ff769a55f360007c34cb620927bb3fc39 100644 (file)
@@ -10,12 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-IF(ENABLE_WAYLAND)
-    ADD_DEFINITIONS("-DWAYLAND_PLATFORM")
 SET(requires "dlog capi-base-common iniparser libxml-2.0")
-ELSE(ENABLE_WAYLAND)
-SET(requires "dlog capi-base-common xi xrandr iniparser libxml-2.0")
-ENDIF(ENABLE_WAYLAND)
 SET(pc_requires "capi-base-common")
 
 INCLUDE(FindPkgConfig)
@@ -37,7 +32,6 @@ ADD_DEFINITIONS("-DINFO_FILE_PATH=\"${INFO_FILE_PATH}\"")
 ADD_DEFINITIONS("-DOS_RELEASE_FILE_PATH=\"${OS_RELEASE_FILE_PATH}\"")
 ADD_DEFINITIONS("-DSERIAL_PATH=\"${SERIAL_PATH}\"")
 ADD_DEFINITIONS("-DTIZEN_ID_PATH=\"${TIZEN_ID_PATH}\"")
-ADD_DEFINITIONS("-DSLP_DEBUG")
 ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"")
 
 aux_source_directory(src SOURCES)
index 00b671b8761e07c2e4828cd5cf3f8119b13c3337..8ddef261b13a2b13141d71927e109be24520e988 100644 (file)
@@ -33,7 +33,6 @@ extern "C"
 
 #define PLATFORM_TAG   "platform"
 #define CUSTOM_TAG             "custom"
-#define INTERNAL_TAG   "internal"
 
 #define BOOL_TYPE      "bool"
 #define INT_TYPE       "int"
index 9d21cc796df3be504f640e67c25eae09596e249f..90d7cdbcaf8a13e568b3c2cc4caa64de4fd0ff65 100644 (file)
@@ -1,5 +1,3 @@
-%bcond_with x
-%bcond_with wayland
 Name:           capi-system-info
 Version:        0.2.0
 Release:        0
@@ -16,14 +14,6 @@ BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(glib-2.0)
-%if %{with wayland}
-BuildRequires:  pkgconfig(ecore-wayland)
-%endif
-%if %{with x}
-BuildRequires:  pkgconfig(x11)
-BuildRequires:  pkgconfig(xi)
-BuildRequires:  pkgconfig(xrandr)
-%endif
 
 %description
 
@@ -47,15 +37,11 @@ cp %{SOURCE1001} .
 %define tizen_id_path /opt/home/root/tizenid
 
 %build
-%cmake . \
-%if !%{with x} && %{with wayland}
-               -DENABLE_WAYLAND=TRUE \
-%endif
-               -DCONFIG_FILE_PATH=%{config_file_path} \
-               -DINFO_FILE_PATH=%{info_file_path} \
-               -DOS_RELEASE_FILE_PATH=%{os_release_file_path} \
-               -DSERIAL_PATH=%{serial_path} \
-               -DTIZEN_ID_PATH=%{tizen_id_path}
+%cmake . -DCONFIG_FILE_PATH=%{config_file_path} \
+                -DINFO_FILE_PATH=%{info_file_path} \
+                -DOS_RELEASE_FILE_PATH=%{os_release_file_path} \
+                -DSERIAL_PATH=%{serial_path} \
+                -DTIZEN_ID_PATH=%{tizen_id_path}
 
 %__make %{?_smp_mflags}
 
index cc077245dea6aa26b64731e5987bb53054e68c70..26f310803787810c53294370e56916525e676127 100644 (file)
 
 int system_info_get_manufacturer(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       char *manufacturer = NULL;
+       int ret;
+       char *manufacturer;
 
-       manufacturer = strdup("samsung");
-       if (manufacturer == NULL) {
-               LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
-               return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
-       }
+       ret = system_info_get_platform_string(
+                       "tizen.org/system/manufacturer",
+                       &manufacturer);
+       if (ret == SYSTEM_INFO_ERROR_NONE)
+               *value = manufacturer;
 
-       *value = manufacturer;
-
-       return SYSTEM_INFO_ERROR_NONE;
+       return ret;
 }
 
 int system_info_get_tethering_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
        bool *supported;
-       char *string = NULL;
-       char *model = "default";
+       bool tethering;
+       int ret;
 
        supported = (bool *)value;
 
-       if (access(TETHERING_INFO_FILE_PATH, R_OK)) {
-                       *supported = false;
-                       return SYSTEM_INFO_ERROR_NONE;
-       }
-
-       if (system_info_get_value_from_xml(TETHERING_INFO_FILE_PATH, model, "tethering-support", &string)) {
-                       LOGE("cannot get tethering-support info from %s!!!", TETHERING_INFO_FILE_PATH);
-                       return SYSTEM_INFO_ERROR_IO_ERROR;
-       }
-
-       if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
-               *supported = true;
-       else
-               *supported = false;
-
-       free(string);
+       ret = system_info_get_platform_bool(
+                       "tizen.org/feature/network.tethering",
+                       &tethering);
+       if (ret == SYSTEM_INFO_ERROR_NONE)
+               *supported = tethering;
 
-       return SYSTEM_INFO_ERROR_NONE;
+       return ret;
 }
index 49fac2701153855900d14b8b4a706b4ac3039728..d89e3ab070397c9f46a76241e079a8163974abc0 100644 (file)
 
 int system_info_get_model(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       return system_info_ini_get_string(INFO_FILE_PATH, "version:model", (char **)value);
+       return system_info_get_platform_string("tizen.org/system/model_name", (char **)value);
 }
 
 int system_info_get_build_string(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       return system_info_ini_get_string(INFO_FILE_PATH, "version:build", (char **)value);
+       return system_info_get_platform_string("tizen.org/system/build.string", (char **)value);
 }
 
 int system_info_get_build_date(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       return system_info_ini_get_string(INFO_FILE_PATH, "build:date", (char **)value);
+       return system_info_get_platform_string("tizen.org/system/build.date", (char **)value);
 }
 
 int system_info_get_build_time(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       return system_info_ini_get_string(INFO_FILE_PATH, "build:time", (char **)value);
+       return system_info_get_platform_string("tizen.org/system/build.time", (char **)value);
 }
 
 int system_info_get_tizen_version(system_info_key_e key, system_info_data_type_e data_type, void **value)
index 9af9f8159c060d6d0257102d5315b363266898d2..c17cf9fb96fd5de1bedcdf248a0b4f30f1d07eb9 100644 (file)
 
 #include <dlog.h>
 
-#ifndef WAYLAND_PLATFORM
-#include <X11/Xlib.h>
-#include <X11/extensions/Xrandr.h>
-#endif
-
 #include <system_info.h>
 #include <system_info_private.h>
 
 
 #define LOG_TAG "CAPI_SYSTEM_INFO"
 
-typedef struct _progInfo ProgInfo;
-
-/* globals */
-ProgInfo g_pinfo;
-#ifdef WAYLAND_PLATFORM
-struct _progInfo {
-        int *dpy;
-        int root;
-        int screen;
-        int event_base, error_base;
-        int major, minor;
-        int *res;
-};
-#else
-struct _progInfo {
-       Display *dpy;
-       Window root;
-       int screen;
-       int event_base, error_base;
-       int major, minor;
-       XRRScreenResources *res;
-};
-#endif
-static int PHYSICAL_SCREEN_WIDTH;
-static int PHYSICAL_SCREEN_HEIGHT;
-int system_info_screen_initialized;
-
-int system_info_screen_init()
-{
-
-       memset(&g_pinfo, 0x0, sizeof(ProgInfo));
-       #ifdef WAYLAND_PLATFORM
-       //In wayland environment, noting to do in this function, FIXME if necessary.
-       LOGE("In wayland environment, system_info_screen_init Failed");
-       system_info_screen_initialized = 1;
-               return -1;
-       #else
-       int i;
-       g_pinfo.dpy = XOpenDisplay(NULL);
-       if (NULL == g_pinfo.dpy) {
-               LOGE("XOpenDisplay Failed");
-               return -1;
-       }
-
-       if (0 > g_pinfo.screen)
-               g_pinfo.screen = DefaultScreen(g_pinfo.dpy);
-       g_pinfo.root = RootWindow(g_pinfo.dpy, g_pinfo.screen);
-
-       if (!XRRQueryExtension(g_pinfo.dpy, &g_pinfo.event_base, &g_pinfo.error_base) ||
-               !XRRQueryVersion(g_pinfo.dpy, &g_pinfo.major, &g_pinfo.minor)) {
-               LOGE("XRRQuery Failed");
-               XCloseDisplay(g_pinfo.dpy);
-               return -1;
-       }
-
-       g_pinfo.res = XRRGetScreenResources(g_pinfo.dpy, g_pinfo.root);
-
-       if (!g_pinfo.res) {
-               LOGE("XRRGetScreenResources Failed");
-               XCloseDisplay(g_pinfo.dpy);
-               return -1;
-       }
-
-       for (i = 0; i < g_pinfo.res->noutput; i++) {
-               XRROutputInfo *output_info = XRRGetOutputInfo(g_pinfo.dpy, g_pinfo.res, g_pinfo.res->outputs[i]);
-               if (!output_info) {
-                       LOGE("XRRGetOutputInfo Failed");
-                       XCloseDisplay(g_pinfo.dpy);
-                       return -1;
-               }
-
-               /* find target lcd */
-               if (!strcmp(output_info->name, "LVDS1")) {
-                       /* XRRCrtcInfo information */
-                       XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(g_pinfo.dpy, g_pinfo.res, output_info->crtc);
-                       if (!crtc_info)
-                               break;
-
-                       PHYSICAL_SCREEN_WIDTH = output_info->mm_width;
-                       PHYSICAL_SCREEN_HEIGHT = output_info->mm_height;
-
-                       XRRFreeCrtcInfo(crtc_info);
-               }
-               XRRFreeOutputInfo(output_info);
-       }
-
-       XCloseDisplay(g_pinfo.dpy);
-
-       system_info_screen_initialized = 1;
-
-       return 0;
-       #endif
-}
+#define MM_PER_INCH (25.4)
 
 int system_info_get_screen_width(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
@@ -141,36 +44,50 @@ int system_info_get_screen_height(system_info_key_e key, system_info_data_type_e
 
 int system_info_get_physical_screen_height(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       int *height;
-       int ret_val;
+       int ret;
+       int height, dpi;
+       int *physical;
+
+       physical = (int *)value;
 
-       height = (int *)value;
+       ret = system_info_get_platform_int("tizen.org/feature/screen.dpi", &dpi);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               LOGE("Failed to get dpi information(%d)", ret);
+               return ret;
+       }
 
-       if (0 == system_info_screen_initialized) {
-               ret_val = system_info_screen_init();
-               if (ret_val)
-                       return ret_val;
+       ret = system_info_get_platform_int("tizen.org/feature/screen.height", &height);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               LOGE("Failed to get height information(%d)", ret);
+               return ret;
        }
 
-       *height = PHYSICAL_SCREEN_HEIGHT;
+       *physical = (int)((height / dpi) * MM_PER_INCH);
 
        return SYSTEM_INFO_ERROR_NONE;
 }
 
 int system_info_get_physical_screen_width(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
-       int *width;
-       int ret_val;
+       int ret;
+       int width, dpi;
+       int *physical;
 
-       width = (int *)value;
+       physical = (int *)value;
+
+       ret = system_info_get_platform_int("tizen.org/feature/screen.dpi", &dpi);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               LOGE("Failed to get dpi information(%d)", ret);
+               return ret;
+       }
 
-       if (0 == system_info_screen_initialized) {
-               ret_val = system_info_screen_init();
-               if (ret_val)
-                       return ret_val;
+       ret = system_info_get_platform_int("tizen.org/feature/screen.width", &width);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               LOGE("Failed to get height information(%d)", ret);
+               return ret;
        }
 
-       *width = PHYSICAL_SCREEN_WIDTH;
+       *physical = (int)((width / dpi) * MM_PER_INCH);
 
        return SYSTEM_INFO_ERROR_NONE;
 }