Synchronize system-info Api : up to Tizen 3.0
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 7 Feb 2014 09:09:23 +0000 (10:09 +0100)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Mon, 10 Feb 2014 15:36:01 +0000 (16:36 +0100)
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
packaging/tizen-extensions-crosswalk.spec
system_info/system_info.gyp
system_info/system_info_cellular_network_mobile.cc
system_info/system_info_instance.cc
system_info/system_info_utils.cc
system_info/system_info_utils.h

index 4f07147..d2cd23e 100644 (file)
@@ -37,6 +37,7 @@ BuildRequires: pkgconfig(dbus-glib-1)
 # Evas.h is required by capi-web-favorites.
 BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(tapi)
 BuildRequires: pkgconfig(libudev)
 BuildRequires: pkgconfig(message-port)
 BuildRequires: pkgconfig(notification)
index 01c786e..6ccbfcc 100644 (file)
@@ -26,6 +26,7 @@
               'capi-telephony-sim',
               'pkgmgr-info',
               'vconf',
+              'tapi',
             ]
           },
         }],
index d228f33..de0216f 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "system_info/system_info_cellular_network.h"
 
+#include <ITapiModem.h>
 #include <net_connection.h>
 #include <system_info.h>
 
@@ -114,14 +115,11 @@ void SysInfoCellularNetwork::SetFlightMode() {
 
 void SysInfoCellularNetwork::SetIMEI() {
   char* imei = NULL;
-  if (system_info_get_value_string(SYSTEM_INFO_KEY_MOBILE_DEVICE_ID, &imei) !=
-      SYSTEM_INFO_ERROR_NONE) {
+  imei = tel_get_misc_me_imei_sync(NULL);
+  if (!imei)
     imei_ = "";
-    return;
-  }
-
-  imei_ = imei;
-  free(imei);
+  else
+    imei_ = imei;
 }
 
 void SysInfoCellularNetwork::Get(picojson::value& error,
index 594beb8..0bc665b 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "system_info/system_info_instance.h"
 
+#include <dlfcn.h>
 #include <stdlib.h>
 #if defined(TIZEN_MOBILE)
 #include <pkgmgr-info.h>
@@ -29,8 +30,6 @@
 #include "system_info/system_info_utils.h"
 #include "system_info/system_info_wifi_network.h"
 
-const char* sSystemInfoFilePath = "/usr/etc/system-info.ini";
-
 template <class T>
 void SystemInfoInstance::RegisterClass() {
   classes_.insert(SysInfoClassPair(T::name_ , T::GetInstance()));
@@ -151,253 +150,426 @@ void SystemInfoInstance::HandleGetCapabilities() {
 #if defined(TIZEN_MOBILE)
   bool b;
   int i;
-  char* s;
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &b);
-  o["bluetooth"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_NFC_SUPPORTED, &b);
-  o["nfc"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_NFC_RESERVED_PUSH_SUPPORTED, &b);
-  o["nfcReservedPush"] = picojson::value(b);
-
-  system_info_get_value_int(SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT, &i);
-  o["multiTouchCount"] = picojson::value(static_cast<double>(i));
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &b);
-  o["inputKeyboard"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &b);
-  o["inputKeyboardLayout"] = picojson::value(b);
+  char* s = NULL;
+  std::string string_full;
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.bluetooth",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["bluetooth"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.nfc",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["nfc"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/network.nfc.reserved_push",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["nfcReservedPush"] = picojson::value(b);
+
+  if (system_info_get_platform_int(
+      "tizen.org/feature/multi_point_touch.point_count",
+      &i) == SYSTEM_INFO_ERROR_NONE)
+    o["multiTouchCount"] = picojson::value(static_cast<double>(i));
+
+  if (system_info_get_platform_bool("tizen.org/feature/input.keyboard",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["inputKeyboard"] = picojson::value(b);
+
+  if (system_info_get_platform_string(
+      "tizen.org/feature/input.keyboard.layout",
+      &s) == SYSTEM_INFO_ERROR_NONE) {
+    o["inputKeyboardLayout"] = picojson::value(s);
+    free(s);
+  }
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_SUPPORTED, &b);
-  o["wifi"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/network.wifi",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["wifi"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED, &b);
-  o["wifiDirect"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/network.wifi.direct",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["wifiDirect"] = picojson::value(b);
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &s);
-  if (s && (strlen(s) != 0)) {
+  if ((system_info_get_platform_bool("tizen.org/feature/opengles",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+      && b == true) {
     o["opengles"] = picojson::value(true);
+    if (system_info_get_platform_bool("tizen.org/feature/opengles.version.1_1",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+      o["openglesVersion1_1"] = picojson::value(b);
 
-    if (strstr(s, "1.1"))
-      o["openglesVersion1_1"] = picojson::value(true);
-    else
-      o["openglesVersion1_1"] = picojson::value(false);
-
-    if (strstr(s, "2.0"))
-      o["openglesVersion2_0"] = picojson::value(true);
-    else
-      o["openglesVersion2_0"] = picojson::value(false);
+    if (system_info_get_platform_bool("tizen.org/feature/opengles.version.2_0",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+      o["openglesVersion2_0"] = picojson::value(b);
   } else {
     o["opengles"] = picojson::value(false);
     o["openglesVersion1_1"] = picojson::value(false);
     o["openglesVersion2_0"] = picojson::value(false);
   }
-  free(s);
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT, &s);
-  SetStringPropertyValue(o, "openglestextureFormat", s ? s : "");
-  free(s);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.utc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    string_full += "utc";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.ptc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full += " | ";
+    string_full +=  "ptc";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.etc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "etc";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.3dc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "3dc";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.atc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "atc";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/opengles.texture_format.pvrtc",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full +=  "pvrtc";
+  }
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_FMRADIO_SUPPORTED, &b);
-  o["fmRadio"] = picojson::value(b);
+  SetStringPropertyValue(o, "openglestextureFormat",
+                         string_full.c_str() ? string_full.c_str() : "");
+  string_full.clear();
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &s);
-  SetStringPropertyValue(o, "platformVersion", s ? s : "");
-  free(s);
+  if (system_info_get_platform_bool("tizen.org/feature/fmradio",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["fmRadio"] = picojson::value(b);
 
-  std::string version =
-      system_info::GetPropertyFromFile(
-          sSystemInfoFilePath,
-          "http://tizen.org/feature/platform.web.api.version");
-  SetStringPropertyValue(o, "webApiVersion", version.c_str());
+  if (system_info_get_platform_string("tizen.org/feature/platform.version",
+      &s) == SYSTEM_INFO_ERROR_NONE) {
+    SetStringPropertyValue(o, "platformVersion", s ? s : "");
+    free(s);
+  }
 
-  version = system_info::GetPropertyFromFile(
-                sSystemInfoFilePath,
-                "http://tizen.org/feature/platform.native.api.version");
-  SetStringPropertyValue(o, "nativeApiVersion", version.c_str());
+  if (system_info_get_platform_string(
+      "tizen.org/feature/platform.web.api.version",
+      &s) == SYSTEM_INFO_ERROR_NONE) {
+    SetStringPropertyValue(o, "webApiVersion", s);
+    free(s);
+  }
+  if (system_info_get_platform_string(
+      "tizen.org/feature/platform.native.api.version",
+      &s) == SYSTEM_INFO_ERROR_NONE) {
+    SetStringPropertyValue(o, "nativeApiVersion", s);
+    free(s);
+  }
+  if (system_info_get_platform_string("tizen.org/system/platform.name",
+      &s) == SYSTEM_INFO_ERROR_NONE) {
+    SetStringPropertyValue(o, "platformName", s ? s : "");
+    free(s);
+  }
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &s);
-  SetStringPropertyValue(o, "platformName", s ? s : "");
-  free(s);
+  if (system_info_get_platform_bool("tizen.org/feature/camera",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["camera"] = picojson::value(b);
 
-  system_info_get_value_int(SYSTEM_INFO_KEY_CAMERA_COUNT, &i);
-  o["camera"] = picojson::value(i > 0);
+  if (system_info_get_platform_bool("tizen.org/feature/camera.front",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["cameraFront"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED, &b);
-  o["cameraFront"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/camera.front.flash",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["cameraFrontFlash"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED, &b);
-  o["cameraFrontFlash"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/camera.back",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["cameraBack"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_SUPPORTED, &b);
-  o["cameraBack"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/camera.back.flash",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["cameraBackFlash"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_FLASH_SUPPORTED, &b);
-  o["cameraBackFlash"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/location",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["location"] = picojson::value(b);
 
-  bool b_gps;
-  system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &b_gps);
-  o["locationGps"] = picojson::value(b_gps);
+  if (system_info_get_platform_bool("tizen.org/feature/location.gps",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["locationGps"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_WPS_SUPPORTED, &b);
-  o["locationWps"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/location.wps",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["locationWps"] = picojson::value(b);
 
-  o["location"] = picojson::value(b && b_gps);
+  if (system_info_get_platform_bool("tizen.org/feature/microphone",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["microphone"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED, &b);
-  o["microphone"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/usb.host",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["usbHost"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_USB_HOST_SUPPORTED, &b);
-  o["usbHost"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/usb.accessory",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["usbAccessory"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_USB_ACCESSORY_SUPPORTED, &b);
-  o["usbAccessory"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/screen.output.rca",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["screenOutputRca"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_RCA_SUPPORTED, &b);
-  o["screenOutputRca"] = picojson::value(b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/screen.output.hdmi",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["screenOutputHdmi"] = picojson::value(b);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_HDMI_SUPPORTED, &b);
-  o["screenOutputHdmi"] = picojson::value(b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.cpu.arch.armv6",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    string_full += "armv6";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.cpu.arch.armv7",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "armv7";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.cpu.arch.x86",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "x86";
+  }
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &s);
-  SetStringPropertyValue(o, "platformCoreCpuArch", s ? s : "");
-  free(s);
+  SetStringPropertyValue(o, "platformCoreCpuArch",
+                         string_full.c_str() ? string_full.c_str() : "");
+  string_full.clear();
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &s);
-  SetStringPropertyValue(o, "platformCoreFpuArch", s ? s : "");
-  free(s);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.fpu.arch.sse2",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    string_full += "sse2";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.fpu.arch.sse3",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "sse3";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.fpu.arch.ssse3",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "ssse3";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.fpu.arch.vfpv2",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "vfpv2";
+  }
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.core.fpu.arch.vfpv3",
+      &b) == SYSTEM_INFO_ERROR_NONE
+      && b == true) {
+    if (!string_full.empty())
+      string_full +=  " | ";
+    string_full += "vfpv3";
+  }
+  SetStringPropertyValue(o, "platformCoreFpuArch",
+                         string_full.c_str() ? string_full.c_str() : "");
+  string_full.clear();
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED, &b);
-  o["sipVoip"] = picojson::value(b);
+  if (system_info_get_platform_bool("tizen.org/feature/sip.voip",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["sipVoip"] = picojson::value(b);
 
-  s = NULL;
-  system_info_get_value_string(SYSTEM_INFO_KEY_DEVICE_UUID, &s);
+  s = system_info::GetDuidProperty();
   SetStringPropertyValue(o, "duid", s ? s : "");
   free(s);
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED, &b);
-  o["speechRecognition"] = picojson::value(b);
-
-  b = system_info::PathExists("/usr/lib/libtts.so");
-  o["speechSynthesis"] = picojson::value(b);
-
-  sensor_is_supported(SENSOR_ACCELEROMETER, &b);
-  o["accelerometer"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_ACCELEROMETER, &b);
-  o["accelerometerWakeup"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED, &b);
-  o["barometer"] = picojson::value(b);
-
-  // FIXME(halton): find which key reflect this prop
-  o["barometerWakeup"] = picojson::value(false);
-
-  sensor_is_supported(SENSOR_GYROSCOPE, &b);
-  o["gyroscope"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_GYROSCOPE, &b);
-  o["gyroscopeWakeup"] = picojson::value(b);
-
-  sensor_is_supported(SENSOR_MAGNETIC, &b);
-  o["magnetometer"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_MAGNETIC, &b);
-  o["magnetometerWakeup"] = picojson::value(b);
-
-  sensor_is_supported(SENSOR_LIGHT, &b);
-  o["photometer"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_LIGHT, &b);
-  o["photometerWakeup"] = picojson::value(b);
-
-  sensor_is_supported(SENSOR_PROXIMITY, &b);
-  o["proximity"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_PROXIMITY, &b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/speech.recognition",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["speechRecognition"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+     "tizen.org/feature/speech.synthesis",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["speechSynthesis"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.accelerometer",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["accelerometer"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.accelerometer.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["accelerometerWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/sensor.barometer",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["barometer"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.barometer.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["barometerWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/sensor.gyroscope",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["gyroscope"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.gyroscope.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["gyroscopeWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/sensor.magnetometer",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["magnetometer"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.magnetometer.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["magnetometerWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.photometer",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["photometer"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+     "tizen.org/feature/sensor.photometer.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["photometerWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/sensor.proximity",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["proximity"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.proximity.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
   o["proximityWakeup"] = picojson::value(b);
 
-  sensor_is_supported(SENSOR_MOTION_TILT, &b);
-  o["tiltmeter"] = picojson::value(b);
-
-  sensor_awake_is_supported(SENSOR_MOTION_TILT, &b);
-  o["tiltmeterWakeup"] = picojson::value(b);
-
-  b = system_info::PathExists("/usr/lib/libsqlite3.so.0");
-  o["dataEncryption"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_GRAPHICS_HWACCEL_SUPPORTED, &b);
-  o["graphicsAcceleration"] = picojson::value(b);
-
-  b = system_info::PathExists("/usr/bin/pushd");
-  o["push"] = picojson::value(b);
-
-  b = system_info::PathExists("/usr/bin/telephony-daemon");
-  o["telephony"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_MMS_SUPPORTED, &b);
-  o["telephonyMms"] = picojson::value(b);
-
-  system_info_get_value_bool(SYSTEM_INFO_KEY_SMS_SUPPORTED, &b);
-  o["telephonySms"] = picojson::value(b);
-
-  std::string screensize_normal =
-      system_info::GetPropertyFromFile(
-          sSystemInfoFilePath,
-          "http://tizen.org/feature/screen.coordinate_system.size.normal");
-  o["screenSizeNormal"] =
-      picojson::value(system_info::ParseBoolean(screensize_normal));
-
-  int height;
-  int width;
-  system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_HEIGHT, &height);
-  system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &width);
-  o["screenSize480_800"] = picojson::value(false);
-  o["screenSize720_1280"] = picojson::value(false);
-  if ((width == 480) && (height == 800)) {
-    o["screenSize480_800"] = picojson::value(true);
-  } else if ((width == 720) && (height == 1280)) {
-    o["screenSize720_1280"] = picojson::value(true);
+  if (system_info_get_platform_bool("tizen.org/feature/sensor.tiltmeter",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["tiltmeter"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/sensor.tiltmeter.wakeup",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["tiltmeterWakeup"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/database.encryption",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["dataEncryption"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/graphics.acceleration",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["graphicsAcceleration"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.push",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["push"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.telephony",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["telephony"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.telephony.mms",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["telephonyMms"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/network.telephony.sms",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["telephonySms"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/screen.size.normal",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+  o["screenSizeNormal"] =  picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/screen.size.normal.480.800",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+      o["screenSize480_800"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/screen.size.normal.720.1280",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+      o["screenSize720_1280"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/screen.auto_rotation",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["autoRotation"] = picojson::value(b);
+
+  if (system_info_get_platform_bool("tizen.org/feature/shell.appwidget",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["shellAppWidget"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/vision.image_recognition",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["visionImageRecognition"] = picojson::value(b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/vision.qrcode_generation",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["visionQrcodeGeneration"] = picojson::value(b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/vision.qrcode_recognition",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["visionQrcodeRecognition"] = picojson::value(b);
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/vision.face_recognition",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["visionFaceRecognition"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/network.secure_element",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["secureElement"] = picojson::value(b);
+
+  if (system_info_get_platform_bool(
+      "tizen.org/feature/platform.native.osp_compatible",
+      &b) == SYSTEM_INFO_ERROR_NONE)
+    o["nativeOspCompatible"] = picojson::value(b);
+
+  if (system_info_get_platform_string("tizen.org/feature/profile",
+      &s)  == SYSTEM_INFO_ERROR_NONE) {
+    o["profile"] = picojson::value(s ? s : "");
+    free(s);
   }
 
-  system_info_get_value_bool(SYSTEM_INFO_KEY_FEATURE_AUTO_ROTATION_SUPPORTED,
-                             &b);
-  o["autoRotation"] = picojson::value(b);
-
-  pkgmgrinfo_pkginfo_h handle;
-  if (pkgmgrinfo_pkginfo_get_pkginfo("gi2qxenosh", &handle) == PMINFO_R_OK)
-    o["shellAppWidget"] = picojson::value(true);
-  else
-    o["shellAppWidget"] = picojson::value(false);
-
-  b = system_info::PathExists("/usr/lib/osp/libarengine.so");
-  o["visionImageRecognition"] = picojson::value(b);
-  o["visionQrcodeGeneration"] = picojson::value(b);
-  o["visionQrcodeRecognition"] = picojson::value(b);
-  o["visionFaceRecognition"] = picojson::value(b);
-
-  b = system_info::PathExists("/usr/bin/smartcard-daemon");
-  o["secureElement"] = picojson::value(b);
-
-  std::string osp_compatible =
-      system_info::GetPropertyFromFile(
-          sSystemInfoFilePath,
-          "http://tizen.org/feature/platform.native.osp_compatible");
-  o["nativeOspCompatible"] =
-      picojson::value(system_info::ParseBoolean(osp_compatible));
-
-  // FIXME(halton): Not supported until Tizen 2.2
-  o["profile"] = picojson::value("MOBILE_WEB");
-
   o["error"] = picojson::value("");
 #elif defined(GENERIC_DESKTOP)
   o["error"] = picojson::value("getCapabilities is not supported on desktop.");
index cd0d900..ef49f9e 100644 (file)
 #include <algorithm>
 #include <fstream>
 
+namespace {
+
+const int kDuid_buffer_size = 100;
+const char kDuid_str_key[] = "http://tizen.org/system/duid";
+
+}  // namespace
+
 namespace system_info {
 
+char* GetDuidProperty() {
+  char *s = NULL;
+  FILE *fp = NULL;
+  static char duid[kDuid_buffer_size] = {0, };
+  size_t len = strlen(kDuid_str_key);
+  fp = fopen("/opt/usr/etc/system_info_cache.ini", "r");
+
+  if (fp) {
+    while (fgets(duid, kDuid_buffer_size - 1, fp)) {
+      if (strncmp(duid, kDuid_str_key, len) == 0) {
+        char* token = NULL;
+        char* ptr = NULL;
+        token = strtok_r(duid, "=\r\n", &ptr);
+        if (token != NULL) {
+            token = strtok_r(NULL, "=\r\n", &ptr);
+            if (token != NULL)
+              s = token;
+        }
+        break;
+      }
+    }
+    fclose(fp);
+  }
+  return s;
+}
+
 int ReadOneByte(const char* path) {
   FILE* fp = fopen(path, "r");
 
index 9052bfd..32a46b7 100644 (file)
@@ -24,7 +24,7 @@ namespace system_info {
 
 // The default timeout interval is set to 1s to match the top update interval.
 const int default_timeout_interval = 1000;
-
+char* GetDuidProperty();
 int ReadOneByte(const char* path);
 // Free the returned value after using.
 char* ReadOneLine(const char* path);