support for getting platform system information 54/10754/1
authorkh5325.kim <kh5325.kim@samsung.com>
Thu, 10 Oct 2013 04:49:02 +0000 (13:49 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Thu, 10 Oct 2013 04:49:02 +0000 (13:49 +0900)
Change-Id: Ie93809dbc52b3c636a28a771fd06eb4463ee6865
Signed-off-by: kh5325.kim <kh5325.kim@samsung.com>
Makefile
packaging/sdbd.spec
src/services.c

index 02c3437..240e1be 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -89,8 +89,8 @@ SDBD_SRC_FILES := \
 SDBD_CFLAGS := -O2 -g -DSDB_HOST=0 -Wall -Wno-unused-parameter
 SDBD_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
 SDBD_CFLAGS += -DHAVE_FORKEXEC -fPIE -D_DROP_PRIVILEGE -D_FILE_OFFSET_BITS=64
-
-IFLAGS := -Iinclude -Isrc
+SDBD_LFLAGS := -lcapi-system-info
+IFLAGS := -Iinclude -Isrc -I/usr/include/system
 OBJDIR := bin
 INSTALLDIR := usr/sbin
 INITSCRIPTDIR := etc/init.d
@@ -126,7 +126,7 @@ sdb : $(SDB_SRC_FILES)
 
 sdbd : $(SDBD_SRC_FILES)
        mkdir -p $(OBJDIR)
-       $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDBD_CFLAGS) $(IFLAGS) $(SDBD_SRC_FILES)
+       $(CC) -pthread -o $(OBJDIR)/$(MODULE) $(SDBD_CFLAGS) $(IFLAGS) $(SDBD_SRC_FILES) $(SDBD_LFLAGS)
 
 install :
        mkdir -p $(DESTDIR)/$(INSTALLDIR)
index ce73689..44b3fe4 100644 (file)
@@ -5,6 +5,8 @@ Release:    1
 Group:      TO_BE/FILLED_IN
 License:    TO BE FILLED IN
 Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires: capi-system-info-devel
 Requires(post): pkgmgr
 Requires(post): pkgmgr-server
 Requires(post): wrt
@@ -38,7 +40,7 @@ chsmack -t /home/developer
 
 %files
 %manifest sdbd.manifest
-%defattr(-,root,root,-) 
+%defattr(-,root,root,-)
 %{_prefix}/sbin/sdbd
 %{_prefix}/sbin/sdk_launch
 %{_sysconfdir}/init.d/sdbd
index dfc2735..4af9982 100644 (file)
@@ -38,6 +38,9 @@
 #   include "sdktools.h"
 #endif
 
+#include "strutils.h"
+#include <system_info.h>
+
 typedef struct stinfo stinfo;
 
 struct stinfo {
@@ -577,6 +580,79 @@ static int create_syncproc_thread()
 
 #endif
 
+#define UNKNOWN "unknown"
+#define INFOBUF_MAXLEN 64
+#define INFO_VERSION "2.2.0"
+typedef struct platform_info {
+    
+    char platform_info_version[INFOBUF_MAXLEN];
+    char model_name[INFOBUF_MAXLEN]; // Emulator
+    char platform_name[INFOBUF_MAXLEN]; // Tizen
+    char platform_version[INFOBUF_MAXLEN]; // 2.2.1
+    char profile_name[INFOBUF_MAXLEN]; // 2.2.1
+} pinfo;
+
+static void get_platforminfo(int fd, void *cookie) {
+    pinfo sysinfo;
+
+    char *value = NULL;
+    s_strncpy(sysinfo.platform_info_version, INFO_VERSION, strlen(INFO_VERSION));
+
+    int r = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &value);
+    if (r != SYSTEM_INFO_ERROR_NONE) {
+        s_strncpy(sysinfo.model_name, UNKNOWN, strlen(UNKNOWN));
+        D("fail to get system model:%d\n", errno);
+    } else {
+        s_strncpy(sysinfo.model_name, value, sizeof(sysinfo.model_name));
+        D("returns model_name:%s\n", value);
+        if (value != NULL) {
+            free(value);
+        }
+    }
+
+    r = system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &value);
+    if (r != SYSTEM_INFO_ERROR_NONE) {
+        s_strncpy(sysinfo.platform_name, UNKNOWN, strlen(UNKNOWN));
+        D("fail to get platform name:%d\n", errno);
+    } else {
+        s_strncpy(sysinfo.platform_name, value, sizeof(sysinfo.platform_name));
+        D("returns platform_name:%s\n", value);
+        if (value != NULL) {
+            free(value);
+        }
+
+    }
+
+    // FIXME: the result is different when using SYSTEM_INFO_KEY_TIZEN_VERSION_NAME
+    r = system_info_get_platform_string("tizen.org/feature/platform.version", &value);
+    if (r != SYSTEM_INFO_ERROR_NONE) {
+        s_strncpy(sysinfo.platform_version, UNKNOWN, strlen(UNKNOWN));
+        D("fail to get platform version:%d\n", errno);
+    } else {
+        s_strncpy(sysinfo.platform_version, value, sizeof(sysinfo.platform_version));
+        D("returns platform_version:%s\n", value);
+        if (value != NULL) {
+            free(value);
+        }
+    }
+
+    r = system_info_get_platform_string("tizen.org/feature/profile", &value);
+    if (r != SYSTEM_INFO_ERROR_NONE) {
+        s_strncpy(sysinfo.profile_name, UNKNOWN, strlen(UNKNOWN));
+        D("fail to get profile name:%d\n", errno);
+    } else {
+        s_strncpy(sysinfo.profile_name, value, sizeof(sysinfo.profile_name));
+        D("returns profile name:%s\n", value);
+        if (value != NULL) {
+            free(value);
+        }
+    }
+
+    writex(fd, &sysinfo, sizeof(pinfo));
+
+    sdb_close(fd);
+}
+
 int service_to_fd(const char *name)
 {
     int ret = -1;
@@ -664,10 +740,8 @@ int service_to_fd(const char *name)
     } else if(!strncmp(name, "cs:", 5)) {
         ret = create_service_thread(inoti_service, NULL);
 #endif
-#if 0
-    } else if(!strncmp(name, "echo:", 5)){
-        ret = create_service_thread(echo_service, 0);
-#endif
+    } else if(!strncmp(name, "sysinfo:", 8)){
+        ret = create_service_thread(get_platforminfo, 0);
     }
     if (ret >= 0) {
         if (close_on_exec(ret) < 0) {