add new keys(MMS, SMS, CBS, NFC_RESERVED_PUSH)
authorNam KwanWoo <kw46.nam@samsung.com>
Mon, 25 Mar 2013 02:56:47 +0000 (11:56 +0900)
committerNam KwanWoo <kw46.nam@samsung.com>
Mon, 25 Mar 2013 02:56:47 +0000 (11:56 +0900)
Change-Id: I9d7fba7841bd4396a8ac97ac568c6fded1955ef0

include/system_info.h [changed mode: 0755->0644]
include/system_info_private.h
packaging/capi-system-info.spec
src/system_info.c
src/system_info_device.c
src/system_info_platform.c

old mode 100755 (executable)
new mode 100644 (file)
index d335f17..dd155b2
@@ -94,7 +94,11 @@ typedef enum {
        SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED, /**< Indicates whether the device supports stt */
        SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED, /**< Indicates whether the device supports barometer sensor */
        SYSTEM_INFO_KEY_MANUFACTURER, /**< The manufacturer of the device */
-       SYSTEM_INFO_KEY_CP_INTERFACE /**< The method of interface with CP */
+       SYSTEM_INFO_KEY_CP_INTERFACE, /**< The method of interface with CP */
+       SYSTEM_INFO_KEY_MMS_SUPPORTED, /**< Indicates whether the device supports MMS */
+       SYSTEM_INFO_KEY_SMS_SUPPORTED, /**< Indicates whether the device supports SMS */
+       SYSTEM_INFO_KEY_CBS_SUPPORTED, /**< Indicates whether the device supports CBS */
+       SYSTEM_INFO_KEY_NFC_RESERVED_PUSH_SUPPORTED, /**< Indicates whether the device supports nfc-reserved push */
 } system_info_key_e;
 
 /**
index e10448d..641cfbf 100644 (file)
@@ -51,7 +51,7 @@ typedef int (*system_info_get_value_cb) (system_info_key_e key, system_info_data
 int system_info_init(void);
 int system_info_get_system_info_initialized(void);
 void system_info_set_system_info_initialized(int value);
-system_info_mode_type_e system_info_get_system_info_model_type();
+system_info_mode_type_e system_info_get_system_info_model_type(void);
 
 int system_info_vconf_get_value_int(const char *vconf_key, int *value);
 int system_info_vconf_get_value_bool(const char *vconf_key, bool *value);
@@ -110,7 +110,12 @@ int system_info_get_cp_interface(system_info_key_e key, system_info_data_type_e
 int system_info_get_build_string(system_info_key_e key, system_info_data_type_e data_type, void **value);
 int system_info_get_build_date(system_info_key_e key, system_info_data_type_e data_type, void **value);
 int system_info_get_build_time(system_info_key_e key, system_info_data_type_e data_type, void **value);
+int system_info_get_mms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value);
+int system_info_get_sms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value);
+int system_info_get_cbs_supported(system_info_key_e key, system_info_data_type_e data_type, void **value);
+int system_info_get_nfc_reserved_push_supported(system_info_key_e key, system_info_data_type_e data_type, void **value);
 
+int system_info_get_value_from_xml(char *xml_file_path, char *model, char *id_field, char **value);
 #ifdef __cplusplus
 }
 #endif
index 705b36f..e9cad3b 100644 (file)
@@ -1,7 +1,7 @@
 #sbs-git:slp/api/system-info capi-system-info 0.1.0 63d15bafa590ee9de869c8a8ade712e06828e5c3
 Name:       capi-system-info
 Summary:    A System Information library in SLP C API
-Version: 0.1.8
+Version: 0.1.9
 Release:    0
 Group:      System/Libraries
 License:    Apache License, Version 2.0 and IEFT RFC Collection
@@ -40,16 +40,13 @@ Requires: %{name} = %{version}-%{release}
 %description devel
 
 
-
 %prep
 %setup -q
 
-
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 
-
 make %{?jobs:-j%jobs}
 
 %install
index b32f61a..ebb6ea7 100644 (file)
@@ -403,6 +403,35 @@ system_info_s system_info_table[] = {
 },
 
 {
+       /**< Indicates whether the device supports MMS */
+       SYSTEM_INFO_KEY_MMS_SUPPORTED,
+       SYSTEM_INFO_DATA_TYPE_BOOL,
+       system_info_get_mms_supported
+},
+
+{
+       /**< Indicates whether the device supports SMS */
+       SYSTEM_INFO_KEY_SMS_SUPPORTED,
+       SYSTEM_INFO_DATA_TYPE_BOOL,
+       system_info_get_sms_supported
+},
+
+{
+       /**< Indicates whether the device supports CBS */
+       SYSTEM_INFO_KEY_CBS_SUPPORTED,
+       SYSTEM_INFO_DATA_TYPE_BOOL,
+       system_info_get_cbs_supported
+},
+
+{
+       /**< Indicates whether the device supports nfc-reserved push */
+       SYSTEM_INFO_KEY_NFC_RESERVED_PUSH_SUPPORTED,
+       SYSTEM_INFO_DATA_TYPE_BOOL,
+       system_info_get_nfc_reserved_push_supported
+},
+
+
+{
        SYSTEM_INFO_MAX, -1, NULL
 }
 
@@ -411,7 +440,7 @@ system_info_s system_info_table[] = {
 static system_info_mode_type_e system_info_system_info_model_type;
 static int system_info_initialized;
 
-int system_info_get_system_info_initialized()
+int system_info_get_system_info_initialized(void)
 {
        return system_info_initialized;
 }
@@ -421,7 +450,7 @@ void system_info_set_system_info_initialized(int value)
        system_info_initialized = value;
 }
 
-system_info_mode_type_e system_info_get_system_info_model_type()
+system_info_mode_type_e system_info_get_system_info_model_type(void)
 {
        return system_info_system_info_model_type;
 }
index 9b686e8..2c6ab79 100644 (file)
@@ -91,6 +91,8 @@
 #define CAM_VIDEO_PRI_FILE_PATH "/usr/etc/mmfw_camcorder_dev_video_pri.ini"
 #define CAM_VIDEO_SEC_FILE_PATH "/usr/etc/mmfw_camcorder_dev_video_sec.ini"
 
+#define NFC_INFO_FILE_PATH "/etc/config/nfc/sysinfo-nfc-ug.xml"
+
 static char *FRONT_CAM_PATH;
 static char *BACK_CAM_PATH;
 
@@ -1237,3 +1239,31 @@ int system_info_get_cp_interface(system_info_key_e key, system_info_data_type_e
        xmlFreeDoc(doc);
        return SYSTEM_INFO_ERROR_NONE;
 }
+
+int system_info_get_nfc_reserved_push_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
+{
+       bool *supported;
+       char *string = NULL;
+       char *model = "default";
+
+       supported = (bool *)value;
+
+       if (access(NFC_INFO_FILE_PATH, R_OK)) {
+               *supported = false;
+               return SYSTEM_INFO_ERROR_NONE;
+       }
+
+       if (system_info_get_value_from_xml(NFC_INFO_FILE_PATH, model, "reserved-push-support", &string)) {
+               LOGE("cannot get reserved-push-support info from %s!!!", NFC_INFO_FILE_PATH);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
+               *supported = true;
+       else
+               *supported = false;
+
+       free(string);
+
+       return SYSTEM_INFO_ERROR_NONE;
+}
index 479ea07..58bd919 100644 (file)
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
 
 #define SIZE_OF_MODEL_NAME 8
 
+#define MESSAGE_INFO_FILE_PATH "/etc/config/sysinfo-message.xml"
+
+int system_info_get_value_from_xml(char *xml_file_path, char *model, char *id_field, char **value)
+{
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlNodePtr default_node = NULL;
+       xmlNodePtr model_node = NULL;
+       xmlNode *cur_node = NULL;
+       char *id = NULL;
+       char *string = NULL;
+
+       doc = xmlParseFile(xml_file_path);
+
+       if (doc == NULL) {
+               LOGE("cannot file open %s file!!!", xml_file_path);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               LOGE("empty document %s file!!!", xml_file_path);
+               xmlFreeDoc(doc);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       for (cur_node = cur; cur_node; cur_node = cur_node->next) {
+               if (!xmlStrcmp(cur->name, (const xmlChar*)"sys-info"))
+                       break;
+       }
+
+       if (cur == NULL) {
+               LOGE("cannot find %s root element file!!!", "sys-info");
+               xmlFreeDoc(doc);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       cur = cur->xmlChildrenNode;
+
+       for (cur_node = cur; cur_node; cur_node = cur_node->next) {
+               if (!xmlStrcmp(cur_node->name, (const xmlChar*)"default"))
+                       default_node = cur_node;
+               if (strcmp(model, "default") && !xmlStrcmp(cur_node->name, (const xmlChar*)model))
+                       model_node = cur_node;
+       }
+
+       if (model_node) {
+               cur = model_node->xmlChildrenNode;
+
+               for (cur_node = cur; cur_node; cur_node = cur_node->next) {
+                       if (cur_node->type == XML_ELEMENT_NODE) {
+                               id = (char *)xmlGetProp(cur_node, (const xmlChar*)"id");
+                               string = (char *) xmlGetProp(cur_node, (const xmlChar*)"string");
+
+                               if (!strncmp(id, id_field, strlen(id_field))) {
+                                       if (string) {
+                                               *value = strdup(string);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       if (*value == NULL) {
+               cur = default_node->xmlChildrenNode;
+
+               for (cur_node = cur; cur_node; cur_node = cur_node->next) {
+                       if (cur_node->type == XML_ELEMENT_NODE) {
+                               id = (char *)xmlGetProp(cur_node, (const xmlChar*)"id");
+                               string = (char *) xmlGetProp(cur_node, (const xmlChar*)"string");
+
+                               if (!strncmp(id, id_field, strlen(id_field))) {
+                                       if (string) {
+                                               *value = strdup(string);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       if (!cur_node) {
+               LOGE("cannot find %s field from %s file!!!", id_field, xml_file_path);
+               xmlFreeDoc(doc);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       if (*value == NULL) {
+               LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
+               xmlFreeDoc(doc);
+               return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
+       }
+
+       xmlFreeDoc(doc);
+       return SYSTEM_INFO_ERROR_NONE;
+}
+
 int system_info_get_model(system_info_key_e key, system_info_data_type_e data_type, void **value)
 {
        char *MODEL = NULL;
@@ -554,3 +656,87 @@ int system_info_get_build_time(system_info_key_e key, system_info_data_type_e da
        fclose(info);
        return SYSTEM_INFO_ERROR_NONE;
 }
+
+int system_info_get_mms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
+{
+       bool *supported;
+       char *string = NULL;
+       char *model = "default";
+
+       supported = (bool *)value;
+
+       if (access(MESSAGE_INFO_FILE_PATH, R_OK)) {
+       *supported = false;
+               return SYSTEM_INFO_ERROR_NONE;
+       }
+
+       if (system_info_get_value_from_xml(MESSAGE_INFO_FILE_PATH, model, "mms-support", &string)) {
+               LOGE("cannot get mms-support info from %s!!!", MESSAGE_INFO_FILE_PATH);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
+       *supported = true;
+       else
+               *supported = false;
+
+       free(string);
+
+       return SYSTEM_INFO_ERROR_NONE;
+}
+
+int system_info_get_sms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
+{
+       bool *supported;
+       char *string = NULL;
+       char *model = "default";
+
+       supported = (bool *)value;
+
+       if (access(MESSAGE_INFO_FILE_PATH, R_OK)) {
+               *supported = false;
+               return SYSTEM_INFO_ERROR_NONE;
+       }
+
+       if (system_info_get_value_from_xml(MESSAGE_INFO_FILE_PATH, model, "sms-support", &string)) {
+               LOGE("cannot get sms-support info from %s!!!", MESSAGE_INFO_FILE_PATH);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
+               *supported = true;
+       else
+               *supported = false;
+
+       free(string);
+
+       return SYSTEM_INFO_ERROR_NONE;
+}
+
+int system_info_get_cbs_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
+{
+       bool *supported;
+       char *string = NULL;
+       char *model = "default";
+
+       supported = (bool *)value;
+
+       if (access(MESSAGE_INFO_FILE_PATH, R_OK)) {
+               *supported = false;
+               return SYSTEM_INFO_ERROR_NONE;
+       }
+
+       if (system_info_get_value_from_xml(MESSAGE_INFO_FILE_PATH, model, "cbs-support", &string)) {
+               LOGE("cannot get cbs-support info from %s!!!", MESSAGE_INFO_FILE_PATH);
+               return SYSTEM_INFO_ERROR_IO_ERROR;
+       }
+
+       if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
+               *supported = true;
+       else
+               *supported = false;
+
+       free(string);
+
+       return SYSTEM_INFO_ERROR_NONE;
+}