[Systeminfo] New implementation of listeners was added
authorPiotr Kosko <p.kosko@samsung.com>
Mon, 7 Sep 2015 06:48:52 +0000 (08:48 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Tue, 8 Sep 2015 10:01:01 +0000 (12:01 +0200)
[Feature] Implementation of listeners was changed to use SysteminfoManager.
  Old implementation of listeners was removed.

[Verification] Checked in chrome console.
  TCT r39 passrate is 99.66% (known issue).

Change-Id: I345e32c9be6aff416bcece53a1fafdf4b5c72a93
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/systeminfo/systeminfo-utils.cpp
src/systeminfo/systeminfo-utils.h
src/systeminfo/systeminfo_instance.cc
src/systeminfo/systeminfo_manager.cc
src/systeminfo/systeminfo_manager.h
src/systeminfo/systeminfo_properties_manager.cc

index 1a3480449d367a3f44887e58fb1f10cc1ad9318a..cf948d5647abd53196bd71bf8cad09d32888e00a 100644 (file)
 #include "systeminfo-utils.h"
 #include "systeminfo/systeminfo_instance.h"
 
-#include <fstream>
-#include <sstream>
 #include <memory>
-#include <mutex>
 
-#include <system_settings.h>
-#include <system_info.h>
-#include <sys/statfs.h>
-
-#include <vconf.h>
-#include <vconf-internal-keys.h>
 #include <net_connection.h>
-#include <tapi_common.h>
-#include <ITapiModem.h>
-#include <ITapiSim.h>
 #include <device.h>
-#include <device/callback.h>
-#include <device/device-error.h>
-#include <sensor_internal.h>
-#include <wifi.h>
 
 #include "common/logger.h"
 #include "common/platform_exception.h"
 #include "common/dbus_operation.h"
 #include "common/scope_exit.h"
 
-// TODO:: hardcoded value, only for IsBluetoothAlwaysOn
-#define PROFILE_MOBILE 1
-
 namespace extension {
 namespace systeminfo {
 
 namespace {
-
-const std::string MEMORY_STATE_NORMAL = "NORMAL";
-const std::string MEMORY_STATE_WARNING = "WARNING";
 const int MEMORY_TO_BYTE = 1024;
-const int BASE_GATHERING_INTERVAL = 100;
-const double DISPLAY_INCH_TO_MILLIMETER = 2.54;
-
-const int kDefaultPropertyCount = 1;
-
 }  // namespace
 
-using namespace common;
-
-//Callback functions declarations
-static void OnBatteryChangedCb(keynode_t* node, void* event_ptr);
-static gboolean OnCpuChangedCb(gpointer event_ptr);
-static gboolean OnStorageChangedCb(gpointer event_ptr);
-static void OnMmcChangedCb(keynode_t* node, void* event_ptr);
-static void OnDisplayChangedCb(keynode_t* node, void* event_ptr);
-static void OnDeviceAutoRotationChangedCb(keynode_t* node, void* event_ptr);
-static void OnDeviceOrientationChangedCb(sensor_t sensor, unsigned int event_type,
-                                         sensor_data_t *data, void *user_data);
-static void OnLocaleChangedCb(system_settings_key_e key, void* event_ptr);
-static void OnNetworkChangedCb(connection_type_e type, void* event_ptr);
-static void OnNetworkValueChangedCb(const char* ipv4_address,
-                                    const char* ipv6_address, void* event_ptr);
-static void OnCellularNetworkValueChangedCb(keynode_t *node, void *event_ptr);
-static void OnPeripheralChangedCb(keynode_t* node, void* event_ptr);
-static void OnMemoryChangedCb(keynode_t* node, void* event_ptr);
-static void OnBrightnessChangedCb(device_callback_e type, void *value, void *user_data);
-static void OnWifiLevelChangedCb (wifi_rssi_level_e rssi_level, void *user_data);
-
-static void SimCphsValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
-static void SimMsisdnValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
-static void SimSpnValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
-
-namespace {
-const std::string kPropertyIdCpu = "CPU";
-//Battery
-const double kRemainingBatteryChargeMax = 100.0;
-const int kVconfErrorNone = 0;
-//Display
-const double kDisplayBrightnessDivideValue = 100;
-//Device Orientation
-const std::string kOrientationPortraitPrimary = "PORTRAIT_PRIMARY";
-const std::string kOrientationPortraitSecondary = "PORTRAIT_SECONDARY";
-const std::string kOrientationLandscapePrimary = "LANDSCAPE_PRIMARY";
-const std::string kOrientationLandscapeSecondary = "LANDSCAPE_SECONDARY";
-//Peripheral
-const std::string kVideoOutputString = "isVideoOutputOn";
-//Storage
-const char* kStorageInternalPath = "/opt/usr/media";
-const char* kStorageSdcardPath = "/opt/storage/sdcard";
-const std::string kPropertyIdStorage = "STORAGE";
-const std::string kTypeUnknown = "UNKNOWN";
-const std::string kTypeInternal = "INTERNAL";
-const std::string kTypeUsbHost = "USB_HOST";
-const std::string kTypeMmc = "MMC";
-const double kPropertyWatcherTime = 1;
-//Network
-enum NetworkType {
-  kNone,
-  kType2G,
-  kType2_5G,
-  kType3G,
-  kType4G,
-  kWifi,
-  kEthernet,
-  kUnknown
-};
-
-const char* kNetworkTypeNone = "NONE";
-const char* kNetworkType2G = "2G";
-const char* kNetworkType2_5G = "2.5G";
-const char* kNetworkType3G = "3G";
-const char* kNetworkType4G = "4G";
-const char* kNetworkTypeWifi = "WIFI";
-const char* kNetworkTypeEthernet = "ETHERNET";
-const char* kNetworkTypeUnknown = "UNKNOWN";
-//Wifi Network
-const std::string kWifiStatusOn = "ON";
-const std::string kWifiStatusOff = "OFF";
-const int kWifiSignalStrengthDivideValue = 100;
-//Cellular Network
-const unsigned short kMccDivider = 100;
-const char* kConnectionOff = "OFF";
-const char* kConnectionOn = "ON";
-
-static std::string parseWifiNetworkError(int error) {
-  switch (error) {
-    case WIFI_ERROR_NONE : return "WIFI_ERROR_NONE";
-    case WIFI_ERROR_INVALID_PARAMETER : return "WIFI_ERROR_INVALID_PARAMETER";
-    case WIFI_ERROR_OUT_OF_MEMORY : return "WIFI_ERROR_OUT_OF_MEMORY";
-    case WIFI_ERROR_INVALID_OPERATION : return "WIFI_ERROR_INVALID_OPERATION";
-    case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED : return "WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
-    case WIFI_ERROR_OPERATION_FAILED : return "WIFI_ERROR_OPERATION_FAILED";
-    case WIFI_ERROR_NO_CONNECTION : return "WIFI_ERROR_NO_CONNECTION";
-    case WIFI_ERROR_NOW_IN_PROGRESS : return "WIFI_ERROR_NOW_IN_PROGRESS";
-    case WIFI_ERROR_ALREADY_EXISTS : return "WIFI_ERROR_ALREADY_EXISTS";
-    case WIFI_ERROR_OPERATION_ABORTED : return "WIFI_ERROR_OPERATION_ABORTED";
-    case WIFI_ERROR_DHCP_FAILED : return "WIFI_ERROR_DHCP_FAILED";
-    case WIFI_ERROR_INVALID_KEY : return "WIFI_ERROR_INVALID_KEY";
-    case WIFI_ERROR_NO_REPLY : return "WIFI_ERROR_NO_REPLY";
-    case WIFI_ERROR_SECURITY_RESTRICTED : return "WIFI_ERROR_SECURITY_RESTRICTED";
-    case WIFI_ERROR_PERMISSION_DENIED : return "WIFI_ERROR_PERMISSION_DENIED";
-    case WIFI_ERROR_NOT_SUPPORTED : return "WIFI_ERROR_NOT_SUPPORTED";
-    default : return "Unknown Wi-Fi error";
-  }
-}
-
-}
-
-/////////////////////////// SystemInfoListeners ////////////////////////////////
-
-class SystemInfoListeners {
- public:
-  SystemInfoListeners();
-  ~SystemInfoListeners();
-
-  PlatformResult RegisterBatteryListener(const SysteminfoUtilsCallback& callback,
-                                         SysteminfoInstance& instance);
-  PlatformResult UnregisterBatteryListener();
-  PlatformResult RegisterCpuListener(const SysteminfoUtilsCallback& callback,
-                                     SysteminfoInstance& instance);
-  PlatformResult UnregisterCpuListener();
-  PlatformResult RegisterStorageListener(const SysteminfoUtilsCallback& callback,
-                                         SysteminfoInstance& instance);
-  PlatformResult UnregisterStorageListener();
-  PlatformResult RegisterDisplayListener(const SysteminfoUtilsCallback& callback,
-                                         SysteminfoInstance& instance);
-  PlatformResult UnregisterDisplayListener();
-  PlatformResult RegisterDeviceOrientationListener(const SysteminfoUtilsCallback& callback,
-                                                   SysteminfoInstance& instance);
-  PlatformResult UnregisterDeviceOrientationListener();
-  PlatformResult RegisterLocaleListener(const SysteminfoUtilsCallback& callback,
-                                        SysteminfoInstance& instance);
-  PlatformResult UnregisterLocaleListener();
-  PlatformResult RegisterNetworkListener(const SysteminfoUtilsCallback& callback,
-                                         SysteminfoInstance& instance);
-  PlatformResult UnregisterNetworkListener();
-  PlatformResult RegisterWifiNetworkListener(const SysteminfoUtilsCallback& callback,
-                                             SysteminfoInstance& instance);
-  PlatformResult UnregisterWifiNetworkListener();
-  PlatformResult RegisterEthernetNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                 SysteminfoInstance& instance);
-  PlatformResult UnregisterEthernetNetworkListener();
-  PlatformResult RegisterCellularNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                 SysteminfoInstance& instance);
-  PlatformResult UnregisterCellularNetworkListener();
-  PlatformResult RegisterPeripheralListener(const SysteminfoUtilsCallback& callback,
-                                            SysteminfoInstance& instance);
-  PlatformResult UnregisterPeripheralListener();
-  PlatformResult RegisterMemoryListener(const SysteminfoUtilsCallback& callback,
-                                        SysteminfoInstance& instance);
-  PlatformResult UnregisterMemoryListener();
-  PlatformResult RegisterCameraFlashListener(const SysteminfoUtilsCallback& callback,
-                                        SysteminfoInstance& instance);
-  PlatformResult UnregisterCameraFlashListener();
-
-  void SetCpuInfoLoad(double load);
-  void SetAvailableCapacityInternal(unsigned long long capacity);
-  void SetAvailableCapacityMmc(unsigned long long capacity);
-
-  void OnBatteryChangedCallback(keynode_t* node, void* event_ptr);
-  void OnCpuChangedCallback(void* event_ptr);
-  void OnStorageChangedCallback(void* event_ptr);
-  void OnMmcChangedCallback(keynode_t* node, void* event_ptr);
-  void OnDisplayChangedCallback(keynode_t* node, void* event_ptr);
-  void OnDeviceAutoRotationChangedCallback(keynode_t* node, void* event_ptr);
-  void OnDeviceOrientationChangedCallback(sensor_t sensor, unsigned int event_type,
-                                          sensor_data_t *data, void *user_data);
-  void OnLocaleChangedCallback(system_settings_key_e key, void* event_ptr);
-  void OnNetworkChangedCallback(connection_type_e type, void* event_ptr);
-  void OnNetworkValueCallback(const char* ipv4_address,
-                              const char* ipv6_address, void* event_ptr);
-  void OnCellularNetworkValueCallback(keynode_t *node, void *event_ptr);
-  void OnPeripheralChangedCallback(keynode_t* node, void* event_ptr);
-  void OnMemoryChangedCallback(keynode_t* node, void* event_ptr);
-  void OnBrightnessChangedCallback(device_callback_e type, void* value, void* user_data);
-
-  TapiHandle* GetTapiHandle();
-  TapiHandle** GetTapiHandles();
-  PlatformResult GetConnectionHandle(connection_h&);
-  int GetSensorHandle();
-  PlatformResult ConnectSensor(int* result);
-  void DisconnectSensor(int handle_orientation);
-  wifi_rssi_level_e GetWifiLevel();
-  void SetWifiLevel(wifi_rssi_level_e level);
-  std::string GetCameraTypes(int index);
-  int GetCameraTypesCount();
- private:
-  static PlatformResult RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
-                                              SysteminfoInstance& instance);
-  static PlatformResult UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb);
-  PlatformResult RegisterIpChangeCallback(SysteminfoInstance& instance);
-  PlatformResult UnregisterIpChangeCallback();
-  bool IsIpChangeCallbackInvalid();
-  void InitTapiHandles();
-  void InitCameraTypes();
-
-  guint m_cpu_event_id;
-  guint m_storage_event_id;
-
-  double m_cpu_load;
-  double m_last_cpu_load;
-  unsigned long long m_available_capacity_internal;
-  unsigned long long m_available_capacity_mmc;
-  unsigned long long m_last_available_capacity_internal;
-  unsigned long long m_last_available_capacity_mmc;
-  wifi_rssi_level_e m_wifi_level;
-
-  SysteminfoUtilsCallback m_battery_listener;
-  SysteminfoUtilsCallback m_cpu_listener;
-  SysteminfoUtilsCallback m_storage_listener;
-  SysteminfoUtilsCallback m_display_listener;
-  SysteminfoUtilsCallback m_device_orientation_listener;
-  SysteminfoUtilsCallback m_locale_listener;
-  SysteminfoUtilsCallback m_network_listener;
-  SysteminfoUtilsCallback m_wifi_network_listener;
-  SysteminfoUtilsCallback m_ethernet_network_listener;
-  SysteminfoUtilsCallback m_cellular_network_listener;
-  SysteminfoUtilsCallback m_peripheral_listener;
-  SysteminfoUtilsCallback m_memory_listener;
-  SysteminfoUtilsCallback m_camera_flash_listener;
-
-  TapiHandle *m_tapi_handles[kTapiMaxHandle+1];
-  //for ip change callback
-  connection_h m_connection_handle;
-  //! Sensor handle for DeviceOrientation purposes
-  int m_sensor_handle;
-  std::vector<std::string> m_camera_types;
-};
-SystemInfoListeners::SystemInfoListeners():
-            m_cpu_event_id(0),
-            m_storage_event_id(0),
-            m_cpu_load(0),
-            m_last_cpu_load(0),
-            m_available_capacity_internal(0),
-            m_available_capacity_mmc(0),
-            m_last_available_capacity_internal(0),
-            m_last_available_capacity_mmc(0),
-            m_wifi_level(WIFI_RSSI_LEVEL_0),
-            m_battery_listener(nullptr),
-            m_cpu_listener(nullptr),
-            m_storage_listener(nullptr),
-            m_display_listener(nullptr),
-            m_device_orientation_listener(nullptr),
-            m_locale_listener(nullptr),
-            m_network_listener(nullptr),
-            m_wifi_network_listener(nullptr),
-            m_ethernet_network_listener(nullptr),
-            m_cellular_network_listener(nullptr),
-            m_peripheral_listener(nullptr),
-            m_memory_listener(nullptr),
-            m_camera_flash_listener(nullptr),
-            m_tapi_handles{nullptr},
-            m_connection_handle(nullptr),
-            m_sensor_handle(-1)
-{
-  LoggerD("Entered");
-  int error = wifi_initialize();
-  if (WIFI_ERROR_NONE != error) {
-    std::string log_msg = "Initialize failed: " + parseWifiNetworkError(error);
-    LoggerE("%s", log_msg.c_str());
-  } else {
-    LoggerD("WIFI initialization succeed");
-  }
-
-  error = wifi_set_rssi_level_changed_cb(OnWifiLevelChangedCb, nullptr);
-  if (WIFI_ERROR_NONE != error) {
-    std::string log_msg = "Setting wifi listener failed: " + parseWifiNetworkError(error);
-    LoggerE("%s", log_msg.c_str());
-  } else {
-    LoggerD("Setting wifi listener succeed");
-  }
-  InitCameraTypes();
-}
-
-SystemInfoListeners::~SystemInfoListeners(){
-  LoggerD("Entered");
-  UnregisterBatteryListener();
-  UnregisterCpuListener();
-  UnregisterStorageListener();
-  UnregisterDisplayListener();
-  UnregisterDeviceOrientationListener();
-  UnregisterLocaleListener();
-  UnregisterNetworkListener();
-  UnregisterWifiNetworkListener();
-  UnregisterCellularNetworkListener();
-  UnregisterPeripheralListener();
-  UnregisterMemoryListener();
-
-  DisconnectSensor(m_sensor_handle);
-
-  unsigned int i = 0;
-  while(m_tapi_handles[i]) {
-    tel_deinit(m_tapi_handles[i]);
-    i++;
-  }
-  if (nullptr != m_connection_handle) {
-    connection_destroy(m_connection_handle);
-  }
-
-  wifi_deinitialize();
-}
-
-#define CHECK_LISTENER_ERROR(method) \
-  ret = method; \
-  if (ret.IsError()) { \
-    return ret; \
-  }
-
-int SystemInfoListeners::GetSensorHandle() {
-  if (m_sensor_handle < 0) {
-    LoggerD("Connecting to sensor");
-    ConnectSensor(&m_sensor_handle);
-  } else {
-    LoggerD("Sensor already connected");
-  }
-  return m_sensor_handle;
-}
-
-PlatformResult SystemInfoListeners::ConnectSensor(int* result) {
-  LoggerD("Entered");
-  sensor_t sensor = sensord_get_sensor(AUTO_ROTATION_SENSOR);
-  int handle_orientation = sensord_connect(sensor);
-  if (handle_orientation < 0) {
-    std::string log_msg = "Failed to connect auto rotation sensor";
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
-  }
-  bool ret = sensord_start(handle_orientation, 0);
-  if(!ret) {
-    sensord_disconnect(handle_orientation);
-    std::string log_msg = "Failed to start auto rotation sensor";
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
-  }
-  LoggerD("Sensor starts successfully = %d", handle_orientation);
-  *result = handle_orientation;
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-void SystemInfoListeners::DisconnectSensor(int handle_orientation)
-{
-  if (handle_orientation >= 0) {
-    LoggerD("Entered");
-    bool state = sensord_stop(handle_orientation);
-    LoggerD("sensord_stop() returned state = %d", state);
-    state = sensord_disconnect(handle_orientation);
-    LoggerD("sensord_disconnect() returned state %d", state);
-  } else {
-    LoggerD("sensor already disconnected - no action needed");
-  }
-}
-
-wifi_rssi_level_e SystemInfoListeners::GetWifiLevel()
-{
-  return m_wifi_level;
-}
-
-void SystemInfoListeners::SetWifiLevel(wifi_rssi_level_e level)
-{
-  m_wifi_level = level;
-}
-
-std::string SystemInfoListeners::GetCameraTypes(int index) {
-  if (index >= m_camera_types.size()) {
-    return "";
-  }
-  return m_camera_types[index];
-}
-
-int SystemInfoListeners::GetCameraTypesCount() {
-  return m_camera_types.size();
-}
-
-PlatformResult SystemInfoListeners::RegisterBatteryListener(
-    const SysteminfoUtilsCallback& callback, SysteminfoInstance& instance) {
-  LoggerD("Entered");
-  if (nullptr == m_battery_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        RegisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CAPACITY, OnBatteryChangedCb, instance))
-    CHECK_LISTENER_ERROR(
-        RegisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, OnBatteryChangedCb, instance))
-    LoggerD("Added callback for BATTERY");
-    m_battery_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterBatteryListener()
-{
-  if (nullptr != m_battery_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        UnregisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CAPACITY, OnBatteryChangedCb))
-    CHECK_LISTENER_ERROR(
-        UnregisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, OnBatteryChangedCb))
-    LoggerD("Removed callback for BATTERY");
-    m_battery_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterCpuListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance)
-{
-  if (nullptr == m_cpu_listener) {
-    m_cpu_event_id = g_timeout_add_seconds(kPropertyWatcherTime, OnCpuChangedCb, static_cast<void*>(&instance));
-    LoggerD("Added callback for CPU");
-    m_cpu_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterCpuListener()
-{
-  if (nullptr != m_cpu_listener) {
-    g_source_remove(m_cpu_event_id);
-    m_cpu_event_id = 0;
-    LoggerD("Removed callback for CPU");
-    m_cpu_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterStorageListener(const SysteminfoUtilsCallback& callback,
-                                                            SysteminfoInstance& instance)
-{
-  if (nullptr == m_storage_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        RegisterVconfCallback(VCONFKEY_SYSMAN_MMC_STATUS, OnMmcChangedCb, instance))
-
-    m_storage_event_id = g_timeout_add_seconds(kPropertyWatcherTime, OnStorageChangedCb, static_cast<void*>(&instance));
-    LoggerD("Added callback for STORAGE");
-    m_storage_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterStorageListener()
-{
-  if (nullptr != m_storage_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        UnregisterVconfCallback(VCONFKEY_SYSMAN_MMC_STATUS, OnMmcChangedCb))
-
-    g_source_remove(m_storage_event_id);
-    m_storage_event_id = 0;
-    LoggerD("Removed callback for STORAGE");
-    m_storage_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterDisplayListener(const SysteminfoUtilsCallback& callback,
-                                                            SysteminfoInstance& instance)
-{
-  if (nullptr == m_display_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        RegisterVconfCallback(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, OnDisplayChangedCb, instance))
-    LoggerD("Added callback for DISPLAY");
-    m_display_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterDisplayListener()
-{
-  if (nullptr != m_display_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        UnregisterVconfCallback(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, OnDisplayChangedCb))
-    LoggerD("Removed callback for DISPLAY");
-    m_display_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterDeviceOrientationListener(const SysteminfoUtilsCallback& callback,
-                                                                      SysteminfoInstance& instance)
-{
-  if (nullptr == m_device_orientation_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        RegisterVconfCallback(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OnDeviceAutoRotationChangedCb, instance))
-
-    bool sensor_ret = sensord_register_event(GetSensorHandle(), AUTO_ROTATION_EVENT_CHANGE_STATE,
-                                     BASE_GATHERING_INTERVAL, 0,
-                                     OnDeviceOrientationChangedCb, static_cast<void*>(&instance));
-    if (!sensor_ret) {
-      LoggerE("Failed to register orientation change event listener");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR,
-                            "Failed to register orientation change event listener");
-    }
-
-    LoggerD("Added callback for DEVICE_ORIENTATION");
-    m_device_orientation_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterDeviceOrientationListener()
-{
-  if (nullptr != m_device_orientation_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(
-        UnregisterVconfCallback(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OnDeviceAutoRotationChangedCb))
-    bool sensor_ret = sensord_unregister_event(GetSensorHandle(), AUTO_ROTATION_EVENT_CHANGE_STATE);
-    if (!sensor_ret) {
-      LoggerE("Failed to unregister orientation change event listener");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister"
-          " orientation change event listener");
-    }
-
-    LoggerD("Removed callback for DEVICE_ORIENTATION");
-    m_device_orientation_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterLocaleListener(const SysteminfoUtilsCallback& callback,
-                                                           SysteminfoInstance& instance)
-{
-  if (nullptr == m_locale_listener) {
-    if (SYSTEM_SETTINGS_ERROR_NONE !=
-        system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
-                                    OnLocaleChangedCb, static_cast<void*>(&instance)) ) {
-      LoggerE("Country change callback registration failed");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Country change callback registration failed");
-    }
-    if (SYSTEM_SETTINGS_ERROR_NONE !=
-        system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
-                                    OnLocaleChangedCb, static_cast<void*>(&instance)) ) {
-      LoggerE("Language change callback registration failed");
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Language change callback registration failed");
-    }
-    LoggerD("Added callback for LOCALE");
-    m_locale_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterLocaleListener()
-{
-  if (nullptr != m_locale_listener) {
-    if (SYSTEM_SETTINGS_ERROR_NONE !=
-        system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE) ) {
-      LoggerE("Unregistration of language change callback failed");
-    }
-    if (SYSTEM_SETTINGS_ERROR_NONE !=
-        system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY) ) {
-      LoggerE("Unregistration of country change callback failed");
-    }
-    LoggerD("Removed callback for LOCALE");
-    m_locale_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                            SysteminfoInstance& instance)
-{
-  if (nullptr == m_network_listener) {
-    connection_h handle;
-    PlatformResult ret(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
-    if (CONNECTION_ERROR_NONE !=
-        connection_set_type_changed_cb(handle, OnNetworkChangedCb, static_cast<void*>(&instance))) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Registration of listener failed");
-    }
-    LoggerD("Added callback for NETWORK");
-    m_network_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterNetworkListener()
-{
-  if (nullptr != m_network_listener) {
-    connection_h handle;
-    PlatformResult ret(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
-    if (CONNECTION_ERROR_NONE != connection_unset_type_changed_cb(handle)) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unregistration of listener failed");
-    }
-    LoggerD("Removed callback for NETWORK");
-    m_network_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterWifiNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                SysteminfoInstance& instance)
-{
-  LoggerD("Entered");
-
-  if (IsIpChangeCallbackInvalid()) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(RegisterIpChangeCallback(instance));
-    LoggerD("Registered IP change listener");
-  } else {
-    LoggerD("No need to register IP listener on platform, already registered");
-  }
-
-  if (nullptr == m_wifi_network_listener) {
-    LoggerD("Added callback for WIFI_NETWORK");
-    m_wifi_network_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterWifiNetworkListener()
-{
-  LoggerD("Entered");
-
-  m_wifi_network_listener = nullptr;
-
-  if (IsIpChangeCallbackInvalid()) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
-    LoggerD("Removed IP change listener");
-  } else {
-    LoggerD("Removed callback for WIFI_NETWORK, but IP change listener still works");
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult CheckIfEthernetNetworkSupported()
-{
-  LoggerD("Entered");
-  connection_h connection_handle = nullptr;
-  connection_ethernet_state_e connection_state = CONNECTION_ETHERNET_STATE_DEACTIVATED;
-
-  int error = connection_create(&connection_handle);
-  if (CONNECTION_ERROR_NONE != error) {
-    std::string log_msg = "Cannot create connection: " + std::to_string(error);
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
-  }
-  std::unique_ptr<std::remove_pointer<connection_h>::type, int (*)(connection_h)> connection_handle_ptr(
-    connection_handle, &connection_destroy);  // automatically release the memory
-
-  error = connection_get_ethernet_state(connection_handle, &connection_state);
-  if (CONNECTION_ERROR_NOT_SUPPORTED == error) {
-    std::string log_msg = "Cannot get ethernet connection state: Not supported";
-    LoggerE("%s", log_msg.c_str());
-    return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, log_msg);
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterEthernetNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                    SysteminfoInstance& instance)
-{
-  LoggerD("Entered");
-  PlatformResult ret = CheckIfEthernetNetworkSupported();
-  if (ret.IsError()){
-    return ret;
-  }
-
-  if (IsIpChangeCallbackInvalid()) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(RegisterIpChangeCallback(instance));
-    LoggerD("Registered IP change listener");
-  } else {
-    LoggerD("No need to register IP listener on platform, already registered");
-  }
-
-  if (nullptr == m_ethernet_network_listener) {
-    LoggerD("Added callback for ETHERNET_NETWORK");
-    m_ethernet_network_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterEthernetNetworkListener()
-{
-  LoggerD("Entered");
-
-  m_ethernet_network_listener = nullptr;
-
-  if (IsIpChangeCallbackInvalid()) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
-    LoggerD("Removed IP change listener");
-  } else {
-    LoggerD("Removed callback for ETHERNET_NETWORK, but IP change listener still works");
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterCellularNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                    SysteminfoInstance& instance)
-{
-  LoggerD("Entered");
-  PlatformResult ret = SysteminfoUtils::CheckTelephonySupport();
-  if (ret.IsError()) {
-      return ret;
-  }
-
-  if (IsIpChangeCallbackInvalid()) {
-    CHECK_LISTENER_ERROR(RegisterIpChangeCallback(instance));
-    LoggerD("Registered IP change listener");
-  } else {
-    LoggerD("No need to register IP listener on platform, already registered");
-  }
-
-  if (nullptr == m_cellular_network_listener) {
-    CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                          OnCellularNetworkValueChangedCb, instance))
-    CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_TELEPHONY_CELLID,
-                          OnCellularNetworkValueChangedCb, instance))
-    CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_TELEPHONY_LAC,
-                          OnCellularNetworkValueChangedCb, instance))
-    CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM,
-                          OnCellularNetworkValueChangedCb, instance))
-    LoggerD("Added callback for CELLULAR_NETWORK");
-    m_cellular_network_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterCellularNetworkListener()
-{
-  LoggerD("Entered");
-
-  if (nullptr != m_cellular_network_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                            OnCellularNetworkValueChangedCb))
-    CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_TELEPHONY_CELLID,
-                            OnCellularNetworkValueChangedCb))
-    CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_TELEPHONY_LAC,
-                            OnCellularNetworkValueChangedCb))
-    CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM,
-                            OnCellularNetworkValueChangedCb))
-  }
-  m_cellular_network_listener = nullptr;
-
-  if (IsIpChangeCallbackInvalid()) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
-    LoggerD("Removed IP change listener");
-  } else {
-    LoggerD("Removed callback for CELLULAR_NETWORK, but IP change listener still works");
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterPeripheralListener(const SysteminfoUtilsCallback& callback,
-                                                               SysteminfoInstance& instance)
-{
-  if (nullptr == m_peripheral_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    int value = 0;
-/*    if (-1 != vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &value)) {
-      CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS,
-                                                 OnPeripheralChangedCb, instance))
-    }*/
-    if (-1 != vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value)) {
-      CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_SYSMAN_HDMI,
-                                                 OnPeripheralChangedCb, instance))
-    }
-
-    LoggerD("Added callback for PERIPHERAL");
-    m_peripheral_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterPeripheralListener()
-{
-  if (nullptr != m_peripheral_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    int value = 0;
-/*    if (-1 != vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &value)) {
-      CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS,
-                                                   OnPeripheralChangedCb))
-    }*/
-    if (-1 != vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value)) {
-      CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_SYSMAN_HDMI,
-                                                   OnPeripheralChangedCb))
-    }
-
-    LoggerD("Removed callback for PERIPHERAL");
-    m_peripheral_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterMemoryListener(const SysteminfoUtilsCallback& callback,
-                                                           SysteminfoInstance& instance)
-{
-  if (nullptr == m_memory_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    int value = 0;
-    if (-1 != vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &value)) {
-      CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_SYSMAN_LOW_MEMORY, OnMemoryChangedCb, instance))
-    }
-    LoggerD("Added callback for MEMORY");
-    m_memory_listener = callback;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterMemoryListener()
-{
-  if (nullptr != m_memory_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    int value = 0;
-    if (-1 != vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &value)) {
-      CHECK_LISTENER_ERROR(UnregisterVconfCallback(VCONFKEY_SYSMAN_LOW_MEMORY, OnMemoryChangedCb))
-    }
-    LoggerD("Removed callback for MEMORY");
-    m_memory_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterCameraFlashListener(const SysteminfoUtilsCallback& callback,
-                                                           SysteminfoInstance& instance)
-{
-  if (nullptr == m_camera_flash_listener) {
-    if (DEVICE_ERROR_NONE != device_add_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
-                              OnBrightnessChangedCb, static_cast<void*>(&instance))) {
-        return PlatformResult(ErrorCode::UNKNOWN_ERR);
-      }
-      m_camera_flash_listener = callback;
-  }
-    return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterCameraFlashListener()
-{
-  if (nullptr != m_camera_flash_listener) {
-    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
-    if (DEVICE_ERROR_NONE != device_remove_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
-                                                 OnBrightnessChangedCb)) {
-      return PlatformResult(ErrorCode::UNKNOWN_ERR);
-    }
-    LoggerD("Removed callback for camera_flash");
-    m_camera_flash_listener = nullptr;
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-
-void SystemInfoListeners::SetCpuInfoLoad(double load)
-{
-  m_cpu_load = load;
-}
-
-void SystemInfoListeners::SetAvailableCapacityInternal(unsigned long long capacity)
-{
-  m_available_capacity_internal = capacity;
-}
-
-void SystemInfoListeners::SetAvailableCapacityMmc(unsigned long long capacity)
-{
-  m_available_capacity_mmc = capacity;
-}
-
-void SystemInfoListeners::OnBatteryChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  if (nullptr != m_battery_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_battery_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnCpuChangedCallback(void* event_ptr)
-{
-  LoggerD("");
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdCpu, false, result);
-//  if (ret.IsSuccess()) {
-//    if (m_cpu_load == m_last_cpu_load) {
-//      return;
-//    }
-//    if (nullptr != m_cpu_listener) {
-//      SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-//      m_last_cpu_load = m_cpu_load;
-//      m_cpu_listener(*instance);
-//    }
-//  }
-}
-
-void SystemInfoListeners::OnStorageChangedCallback(void* event_ptr)
-{
-  LoggerD("");
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdStorage, false, result);
-//  if (ret.IsSuccess()) {
-//    if (m_available_capacity_internal == m_last_available_capacity_internal) {
-//      return;
-//    }
-//
-//    if (nullptr != m_storage_listener) {
-//      SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-//      m_last_available_capacity_internal = m_available_capacity_internal;
-//      m_storage_listener(*instance);
-//    }
-//  }
-}
-
-void SystemInfoListeners::OnMmcChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  LoggerD("");
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdStorage, false, result);
-//  if (ret.IsSuccess()) {
-//    if (m_available_capacity_mmc == m_last_available_capacity_mmc) {
-//      return;
-//    }
-//    if (nullptr != m_storage_listener) {
-//      SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-//      m_last_available_capacity_mmc = m_available_capacity_mmc;
-//      m_storage_listener(*instance);
-//    }
-//  }
-}
-
-
-void SystemInfoListeners::OnDisplayChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  if (nullptr != m_display_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_display_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnDeviceAutoRotationChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  if (nullptr != m_device_orientation_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_device_orientation_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnDeviceOrientationChangedCallback(sensor_t sensor, unsigned int event_type,
-                                                             sensor_data_t *data, void *user_data)
-{
-  if (nullptr != m_device_orientation_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(user_data);
-    m_device_orientation_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnLocaleChangedCallback(system_settings_key_e /*key*/, void* event_ptr)
-{
-  if (nullptr != m_locale_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_locale_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnNetworkChangedCallback(connection_type_e /*type*/, void* event_ptr)
-{
-  if (nullptr != m_network_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_network_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnNetworkValueCallback(const char* /*ipv4_address*/,
-                                                 const char* /*ipv6_address*/, void* event_ptr)
-{
-  LoggerD("Entered");
-
-  SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-  if (nullptr != m_wifi_network_listener) {
-    m_wifi_network_listener(*instance);
-  }
-  if (nullptr != m_ethernet_network_listener) {
-    m_ethernet_network_listener(*instance);
-  }
-  if (nullptr != m_cellular_network_listener) {
-    m_cellular_network_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnCellularNetworkValueCallback(keynode_t */*node*/, void *event_ptr)
-{
-  if (nullptr != m_cellular_network_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_cellular_network_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnPeripheralChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  if (nullptr != m_peripheral_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_peripheral_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnMemoryChangedCallback(keynode_t* /*node*/, void* event_ptr)
-{
-  if (nullptr != m_memory_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(event_ptr);
-    m_memory_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::OnBrightnessChangedCallback(device_callback_e type, void* value, void* user_data)
-{
-  if (nullptr != m_camera_flash_listener) {
-    SysteminfoInstance* instance = static_cast<SysteminfoInstance*>(user_data);
-    m_camera_flash_listener(*instance);
-  }
-}
-
-void SystemInfoListeners::InitTapiHandles()
-{
-  LoggerD("Entered");
-  int sim_count = 0;
-  if (nullptr == m_tapi_handles[0]){  //check if anything is in table
-    char **cp_list = tel_get_cp_name_list();
-    if (nullptr != cp_list) {
-      while (cp_list[sim_count]) {
-        m_tapi_handles[sim_count] = tel_init(cp_list[sim_count]);
-        if (nullptr == m_tapi_handles[sim_count]) {
-          LoggerE("Failed to connect with tapi, handle is null");
-          break;
-        }
-        sim_count++;
-        LoggerD("%d modem: %s", sim_count, cp_list[sim_count]);
-      }
-    } else {
-      LoggerE("Failed to get cp list");
-      sim_count = kTapiMaxHandle;
-    }
-    g_strfreev(cp_list);
-  }
-}
-
-void SystemInfoListeners::InitCameraTypes() {
-  bool supported = false;
-  PlatformResult ret = SystemInfoDeviceCapability::GetValueBool(
-      "tizen.org/feature/camera.back.flash", &supported);
-  if (ret.IsSuccess()) {
-    if (supported) {
-      m_camera_types.push_back("BACK");
-    }
-  }
-  ret = SystemInfoDeviceCapability::GetValueBool(
-      "tizen.org/feature/camera.front.flash", &supported);
-  if (ret.IsSuccess()) {
-    if (supported) {
-      m_camera_types.push_back("FRONT");
-    }
-  }
-}
-
-TapiHandle* SystemInfoListeners::GetTapiHandle() {
-
-  LoggerD("Entered");
-  InitTapiHandles();
-  return m_tapi_handles[0];
-}
-
-TapiHandle** SystemInfoListeners::GetTapiHandles()
-{
-  InitTapiHandles();
-  return m_tapi_handles;
-}
-
-PlatformResult SystemInfoListeners::GetConnectionHandle(connection_h& handle)
-{
-  if (nullptr == m_connection_handle) {
-    int error = connection_create(&m_connection_handle);
-    if (CONNECTION_ERROR_NONE != error) {
-      LoggerE("Failed to create connection: %d", error);
-      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot create connection");
-    }
-  }
-  handle = m_connection_handle;
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-//////////////// Private ////////////////////
-
-PlatformResult SystemInfoListeners::RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
-                                                          SysteminfoInstance& instance)
-{
-  if (0 != vconf_notify_key_changed(in_key, cb, static_cast<void*>(&instance))) {
-    LoggerE("Failed to register vconf callback: %s", in_key);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register vconf callback");
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb)
-{
-  if (0 != vconf_ignore_key_changed(in_key, cb)) {
-    LoggerE("Failed to unregister vconf callback: %s", in_key);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister vconf callback");
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::RegisterIpChangeCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Registering connection callback");
-  connection_h handle;
-  PlatformResult ret(ErrorCode::NO_ERROR);
-  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
-  int error = connection_set_ip_address_changed_cb(handle,
-                                                   OnNetworkValueChangedCb,
-                                                   static_cast<void*>(&instance));
-  if (CONNECTION_ERROR_NONE != error) {
-    LoggerE("Failed to register ip change callback: %d", error);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot register ip change callback");
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult SystemInfoListeners::UnregisterIpChangeCallback()
-{
-  LoggerD("Unregistering connection callback");
-  connection_h handle;
-  PlatformResult ret(ErrorCode::NO_ERROR);
-  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
-  int error = connection_unset_ip_address_changed_cb(handle);
-  if (CONNECTION_ERROR_NONE != error) {
-    LoggerE("Failed to unregister ip change callback: %d", error);
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot unregister ip change callback");
-  }
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-bool SystemInfoListeners::IsIpChangeCallbackInvalid() {
-  LoggerD("Entered");
-  return (nullptr == m_wifi_network_listener &&
-          nullptr == m_ethernet_network_listener &&
-          nullptr == m_cellular_network_listener);
-}
-
-/////////////////////////// system_info_listeners object ////////////////////////
-
-static SystemInfoListeners system_info_listeners;
-
-//global sim manager - needed for async gathering informations
-static SimDetailsManager sim_mgr;
-
-/////////////////// Callbacks ///////////////////////////////////////////////////
-
-void OnBatteryChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnBatteryChangedCallback(node, event_ptr);
-}
-
-gboolean OnCpuChangedCb(gpointer event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnCpuChangedCallback(event_ptr);
-  return G_SOURCE_CONTINUE;
-}
-gboolean OnStorageChangedCb(gpointer event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnStorageChangedCallback(event_ptr);
-  return G_SOURCE_CONTINUE;
-}
-void OnMmcChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnMmcChangedCallback(node, event_ptr);
-}
-
-void OnDisplayChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnDisplayChangedCallback(node, event_ptr);
-}
-
-void OnDeviceAutoRotationChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnDeviceAutoRotationChangedCallback(node, event_ptr);
-}
-
-void OnDeviceOrientationChangedCb(sensor_t sensor, unsigned int event_type,
-                                  sensor_data_t *data, void *user_data)
-{
-  LoggerD("");
-  system_info_listeners.OnDeviceOrientationChangedCallback(sensor, event_type, data, user_data);
-}
-
-void OnLocaleChangedCb(system_settings_key_e key, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnLocaleChangedCallback(key, event_ptr);
-}
-
-void OnNetworkChangedCb(connection_type_e type, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnNetworkChangedCallback(type, event_ptr);
-}
-
-void OnNetworkValueChangedCb(const char* ipv4_address,
-                             const char* ipv6_address, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnNetworkValueCallback(ipv4_address, ipv6_address, event_ptr);
-}
-
-void OnCellularNetworkValueChangedCb(keynode_t *node, void *event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnCellularNetworkValueCallback(node, event_ptr);
-}
-
-void OnPeripheralChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnPeripheralChangedCallback(node, event_ptr);
-}
-
-void OnMemoryChangedCb(keynode_t* node, void* event_ptr)
-{
-  LoggerD("");
-  system_info_listeners.OnMemoryChangedCallback(node, event_ptr);
-}
-
-void OnBrightnessChangedCb(device_callback_e type, void* value, void* user_data)
-{
-  LoggerD("");
-  if (type == DEVICE_CALLBACK_FLASH_BRIGHTNESS) {
-    system_info_listeners.OnBrightnessChangedCallback(type, value, user_data);
-  }
-}
-
-void OnWifiLevelChangedCb (wifi_rssi_level_e rssi_level, void *user_data)
-{
-  LoggerD("Entered");
-  LoggerD("Level %d", rssi_level);
-  system_info_listeners.SetWifiLevel(rssi_level);
-}
-
-/////////////////////////// SysteminfoUtils ////////////////////////////////
-PlatformResult SysteminfoUtils::RegisterBatteryListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterBatteryListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterBatteryListener()
-{
-  return system_info_listeners.UnregisterBatteryListener();
-}
-
-
-PlatformResult SysteminfoUtils::RegisterCpuListener(const SysteminfoUtilsCallback& callback,
-                                                    SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterCpuListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterCpuListener()
-{
-  return system_info_listeners.UnregisterCpuListener();
-}
-
-
-PlatformResult SysteminfoUtils::RegisterStorageListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterStorageListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterStorageListener()
-{
-  return system_info_listeners.UnregisterStorageListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterDisplayListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterDisplayListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterDisplayListener()
-{
-  return system_info_listeners.UnregisterDisplayListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterDeviceOrientationListener(const SysteminfoUtilsCallback& callback,
-                                                                  SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterDeviceOrientationListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterDeviceOrientationListener()
-{
-  return system_info_listeners.UnregisterDeviceOrientationListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterLocaleListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterLocaleListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterLocaleListener()
-{
-  return system_info_listeners.UnregisterLocaleListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterNetworkListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterNetworkListener()
-{
-  return system_info_listeners.UnregisterNetworkListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterWifiNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                            SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterWifiNetworkListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterWifiNetworkListener()
-{
-  return system_info_listeners.UnregisterWifiNetworkListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterEthernetNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                SysteminfoInstance& instance)
-{
-  LoggerD("Entered");
-  return system_info_listeners.RegisterEthernetNetworkListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterEthernetNetworkListener()
-{
-  LoggerD("Entered");
-  return system_info_listeners.UnregisterEthernetNetworkListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterCellularNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterCellularNetworkListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterCellularNetworkListener()
-{
-  return system_info_listeners.UnregisterCellularNetworkListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterPeripheralListener(const SysteminfoUtilsCallback& callback,
-                                                           SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterPeripheralListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterPeripheralListener()
-{
-  return system_info_listeners.UnregisterPeripheralListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterMemoryListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterMemoryListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterMemoryListener()
-{
-  return system_info_listeners.UnregisterMemoryListener();
-}
-
-PlatformResult SysteminfoUtils::RegisterCameraFlashListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance)
-{
-  return system_info_listeners.RegisterCameraFlashListener(callback, instance);
-}
-
-PlatformResult SysteminfoUtils::UnregisterCameraFlashListener()
-{
-  return system_info_listeners.UnregisterCameraFlashListener();
-}
+using common::PlatformResult;
+using common::ErrorCode;
 
 PlatformResult SysteminfoUtils::GetVconfInt(const char *key, int *value) {
   if (0 == vconf_get_int(key, value)) {
@@ -1505,8 +93,7 @@ PlatformResult SysteminfoUtils::CheckCameraFlashSupport() {
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
-PlatformResult SysteminfoUtils::CheckIfEthernetNetworkSupported()
-{
+PlatformResult SysteminfoUtils::CheckIfEthernetNetworkSupported() {
   LoggerD("Entered");
   connection_h connection_handle = nullptr;
   connection_ethernet_state_e connection_state = CONNECTION_ETHERNET_STATE_DEACTIVATED;
@@ -1529,8 +116,7 @@ PlatformResult SysteminfoUtils::CheckIfEthernetNetworkSupported()
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
-PlatformResult SysteminfoUtils::GetTotalMemory(long long* result)
-{
+PlatformResult SysteminfoUtils::GetTotalMemory(long long* result) {
   LoggerD("Entered");
 
   unsigned int value = 0;
@@ -1546,8 +132,7 @@ PlatformResult SysteminfoUtils::GetTotalMemory(long long* result)
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
-PlatformResult SysteminfoUtils::GetAvailableMemory(long long* result)
-{
+PlatformResult SysteminfoUtils::GetAvailableMemory(long long* result) {
   LoggerD("Entered");
 
   unsigned int value = 0;
@@ -1563,5 +148,23 @@ PlatformResult SysteminfoUtils::GetAvailableMemory(long long* result)
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
+PlatformResult SysteminfoUtils::RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
+                                                          void* event_ptr) {
+  if (0 != vconf_notify_key_changed(in_key, cb, event_ptr)) {
+    LoggerE("Failed to register vconf callback: %s", in_key);
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register vconf callback");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoUtils::UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb) {
+  if (0 != vconf_ignore_key_changed(in_key, cb)) {
+    LoggerE("Failed to unregister vconf callback: %s", in_key);
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister vconf callback");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+
 } // namespace systeminfo
 } // namespace webapi
index 2f7a034dbd7587cd75de5ac6f8c095afbd4b5c5b..4ccdd36aa3c8063eba673d54f8e55dfe46c5fd31 100644 (file)
@@ -18,8 +18,9 @@
 #define WEBAPI_PLUGINS_SYSTEMINFO_SYSTEMINFO_UTILS_H__
 
 #include <string>
-#include <functional>
 #include <system_settings.h>
+#include <vconf.h>
+#include <vconf-internal-keys.h>
 #include "common/picojson.h"
 #include "common/platform_result.h"
 #include "systeminfo/systeminfo_device_capability.h"
@@ -35,10 +36,6 @@ struct CpuInfo {
   double load;
 };
 
-class SysteminfoInstance;
-
-typedef std::function<void(SysteminfoInstance& instance)> SysteminfoUtilsCallback;
-
 class SysteminfoUtils {
  public:
   static common::PlatformResult GetVconfInt(const char *key, int *value);
@@ -49,48 +46,9 @@ class SysteminfoUtils {
   static common::PlatformResult CheckIfEthernetNetworkSupported();
   static common::PlatformResult GetTotalMemory(long long* result);
   static common::PlatformResult GetAvailableMemory(long long* result);
-
-  static common::PlatformResult RegisterBatteryListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterBatteryListener();
-  static common::PlatformResult RegisterCpuListener(const SysteminfoUtilsCallback& callback,
-                                                    SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterCpuListener();
-  static common::PlatformResult RegisterStorageListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterStorageListener();
-  static common::PlatformResult RegisterDisplayListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterDisplayListener();
-  static common::PlatformResult RegisterDeviceOrientationListener(const SysteminfoUtilsCallback& callback,
-                                                                  SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterDeviceOrientationListener();
-  static common::PlatformResult RegisterLocaleListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterLocaleListener();
-  static common::PlatformResult RegisterNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                        SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterNetworkListener();
-  static common::PlatformResult RegisterWifiNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                            SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterWifiNetworkListener();
-  static common::PlatformResult RegisterEthernetNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterEthernetNetworkListener();
-  static common::PlatformResult RegisterCellularNetworkListener(const SysteminfoUtilsCallback& callback,
-                                                                SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterCellularNetworkListener();
-  static common::PlatformResult RegisterPeripheralListener(const SysteminfoUtilsCallback& callback,
-                                                           SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterPeripheralListener();
-  static common::PlatformResult RegisterMemoryListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterMemoryListener();
-  static common::PlatformResult RegisterCameraFlashListener(const SysteminfoUtilsCallback& callback,
-                                                       SysteminfoInstance& instance);
-  static common::PlatformResult UnregisterCameraFlashListener();
-
- private:
+  static common::PlatformResult RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
+                                                            void* event_ptr);
+  static common::PlatformResult UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb);
 };
 
 typedef unsigned char byte;
index f6541e1f32f3612fa0e8d3edad56b27fea7eb07c..8cc81358efa4eeb010fa316bc5a9faeb394ddcc7 100644 (file)
@@ -35,87 +35,15 @@ using common::PlatformResult;
 using common::ErrorCode;
 using common::TypeMismatchException;
 
-//Callback functions declarations
-static void OnBatteryChangedCallback(SysteminfoInstance& instance);
-static void OnCpuChangedCallback(SysteminfoInstance& instance);
-static void OnStorageChangedCallback(SysteminfoInstance& instance);
-static void OnDisplayChangedCallback(SysteminfoInstance& instance);
-static void OnDeviceOrientationChangedCallback(SysteminfoInstance& instance);
-static void OnLocaleChangedCallback(SysteminfoInstance& instance);
-static void OnNetworkChangedCallback(SysteminfoInstance& instance);
-static void OnWifiNetworkChangedCallback(SysteminfoInstance& instance);
-static void OnEthernetNetworkChangedCallback(SysteminfoInstance& instance);
-static void OnCellularNetworkChangedCallback(SysteminfoInstance& instance);
-static void OnPeripheralChangedCallback(SysteminfoInstance& instance);
-static void OnMemoryChangedCallback(SysteminfoInstance& instance);
-static void OnBrigthnessChangedCallback(SysteminfoInstance& instance);
-
 namespace {
 const std::string kPropertyIdString = "propertyId";
 const std::string kListenerIdString = "listenerId";
-const std::string kListenerConstValue = "SysteminfoCommonListenerLabel";
-
-const std::string kPropertyIdBattery = "BATTERY";
-const std::string kPropertyIdCpu = "CPU";
-const std::string kPropertyIdStorage = "STORAGE";
-const std::string kPropertyIdDisplay = "DISPLAY";
-const std::string kPropertyIdDeviceOrientation = "DEVICE_ORIENTATION";
-const std::string kPropertyIdBuild = "BUILD";
-const std::string kPropertyIdLocale = "LOCALE";
-const std::string kPropertyIdNetwork = "NETWORK";
-const std::string kPropertyIdWifiNetwork = "WIFI_NETWORK";
-const std::string kPropertyIdEthernetNetwork = "ETHERNET_NETWORK";
-const std::string kPropertyIdCellularNetwork = "CELLULAR_NETWORK";
-const std::string kPropertyIdSim = "SIM";
-const std::string kPropertyIdPeripheral = "PERIPHERAL";
-const std::string kPropertyIdMemory= "MEMORY";
-const std::string kPropertyIdCameraFlash= "CAMERA_FLASH";
 
 #define CHECK_EXIST(args, name, out) \
   if (!args.contains(name)) {\
     ReportError(TypeMismatchException(name" is required argument"), out);\
       return;\
     }
-
-#define DEFAULT_REPORT_BOOL_CAPABILITY(str_name, feature_name) \
-  ret = SystemInfoDeviceCapability::GetValueBool(feature_name, &bool_value); \
-  if (ret.IsError()) { \
-    ReportError(ret,&out); \
-    return; \
-  } \
-  result_obj.insert(std::make_pair(str_name, picojson::value(bool_value)));
-
-#define REPORT_BOOL_CAPABILITY(str_name, method) \
-  ret = method(&bool_value); \
-  if (ret.IsError()) { \
-    ReportError(ret,&out); \
-    return; \
-  } \
-  result_obj.insert(std::make_pair(str_name, picojson::value(bool_value)));
-
-#define DEFAULT_REPORT_INT_CAPABILITY(str_name, feature_name) \
-  ret = SystemInfoDeviceCapability::GetValueInt(feature_name, &int_value); \
-  if (ret.IsError()) { \
-    ReportError(ret,&out); \
-    return; \
-  } \
-  result_obj.insert(std::make_pair(str_name, picojson::value(std::to_string(int_value))));
-
-#define DEFAULT_REPORT_STRING_CAPABILITY(str_name, feature_name) \
-  ret = SystemInfoDeviceCapability::GetValueString(feature_name, &str_value); \
-  if (ret.IsError()) { \
-    ReportError(ret,&out); \
-    return; \
-  } \
-  result_obj.insert(std::make_pair(str_name, picojson::value(str_value)));
-
-#define REPORT_STRING_CAPABILITY(str_name, method) \
-  ret = method(&str_value); \
-  if (ret.IsError()) { \
-    ReportError(ret,&out); \
-    return; \
-  } \
-  result_obj.insert(std::make_pair(str_name, picojson::value(str_value)));
 }
 
 SysteminfoInstance::SysteminfoInstance() : manager_(this) {
@@ -146,20 +74,6 @@ SysteminfoInstance::SysteminfoInstance() : manager_(this) {
 
 SysteminfoInstance::~SysteminfoInstance() {
   LoggerD("Entered");
-  //TODO Below solution is temporary
-  //Implementation should be changed that each SysteminfoInstance object
-  //should have own SystemInfoListeners manager
-  SysteminfoUtils::UnregisterBatteryListener();
-  SysteminfoUtils::UnregisterCpuListener();
-  SysteminfoUtils::UnregisterStorageListener();
-  SysteminfoUtils::UnregisterDisplayListener();
-  SysteminfoUtils::UnregisterDeviceOrientationListener();
-  SysteminfoUtils::UnregisterLocaleListener();
-  SysteminfoUtils::UnregisterNetworkListener();
-  SysteminfoUtils::UnregisterWifiNetworkListener();
-  SysteminfoUtils::UnregisterCellularNetworkListener();
-  SysteminfoUtils::UnregisterPeripheralListener();
-  SysteminfoUtils::UnregisterMemoryListener();
 }
 
 void SysteminfoInstance::GetCapabilities(const picojson::value& args, picojson::object& out) {
@@ -184,110 +98,12 @@ void SysteminfoInstance::GetPropertyValueArray(const picojson::value& args, pico
 
 void SysteminfoInstance::AddPropertyValueChangeListener(const picojson::value& args, picojson::object& out) {
   LoggerD("Enter");
-  // Check type of property for which listener should be registered
-  CHECK_EXIST(args, "property", out)
-  const std::string& property_name = args.get("property").get<std::string>();
-
-  LoggerD("Adding listener for property with id: %s ", property_name.c_str());
-  PlatformResult ret(ErrorCode::NO_ERROR);
-  if (property_name == kPropertyIdBattery) {
-    ret = SysteminfoUtils::RegisterBatteryListener(OnBatteryChangedCallback, *this);
-  } else if (property_name == kPropertyIdCpu) {
-    ret = SysteminfoUtils::RegisterCpuListener(OnCpuChangedCallback, *this);
-  } else if (property_name == kPropertyIdStorage) {
-    ret = SysteminfoUtils::RegisterStorageListener(OnStorageChangedCallback, *this);
-  } else if (property_name == kPropertyIdDisplay) {
-    ret = SysteminfoUtils::RegisterDisplayListener(OnDisplayChangedCallback, *this);
-  } else if (property_name == kPropertyIdDeviceOrientation) {
-    ret = SysteminfoUtils::RegisterDeviceOrientationListener(OnDeviceOrientationChangedCallback, *this);
-  } else if (property_name == kPropertyIdBuild) {
-    LoggerW("BUILD property's value is a fixed value");
-    //should be accepted, but no registration is needed
-    //ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
-  } else if (property_name == kPropertyIdLocale) {
-    ret = SysteminfoUtils::RegisterLocaleListener(OnLocaleChangedCallback, *this);
-  } else if (property_name == kPropertyIdNetwork) {
-    ret = SysteminfoUtils::RegisterNetworkListener(OnNetworkChangedCallback, *this);
-  } else if (property_name == kPropertyIdWifiNetwork) {
-    ret = SysteminfoUtils::RegisterWifiNetworkListener(OnWifiNetworkChangedCallback, *this);
-  } else if (property_name == kPropertyIdEthernetNetwork) {
-    ret = SysteminfoUtils::RegisterEthernetNetworkListener(OnEthernetNetworkChangedCallback, *this);
-  } else if (property_name == kPropertyIdCellularNetwork) {
-    ret = SysteminfoUtils::RegisterCellularNetworkListener(OnCellularNetworkChangedCallback, *this);
-  } else if (property_name == kPropertyIdSim) {
-    //SIM listeners are not supported by core API, so we just pass over
-    LoggerW("SIM listener is not supported by Core API - ignoring");
-  } else if (property_name == kPropertyIdPeripheral) {
-    ret = SysteminfoUtils::RegisterPeripheralListener(OnPeripheralChangedCallback, *this);
-  } else if (property_name == kPropertyIdMemory) {
-    ret = SysteminfoUtils::RegisterMemoryListener(OnMemoryChangedCallback, *this);
-  } else if (property_name == kPropertyIdCameraFlash) {
-    ret = SysteminfoUtils::RegisterCameraFlashListener(OnBrigthnessChangedCallback, *this);
-  } else {
-    LoggerE("Not supported property");
-    ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
-  }
-  if (ret.IsSuccess()) {
-    ReportSuccess(out);
-    LoggerD("Success");
-    return;
-  }
-  LoggerD("Error");
-  ReportError(ret, &out);
+  manager_.AddPropertyValueChangeListener(args, &out);
 }
 
 void SysteminfoInstance::RemovePropertyValueChangeListener(const picojson::value& args, picojson::object& out) {
   LoggerD("Enter");
-
-  // Check type of property for which listener should be removed
-  CHECK_EXIST(args, "property", out)
-  const std::string& property_name = args.get("property").get<std::string>();
-  LoggerD("Removing listener for property with id: %s ", property_name.c_str());
-  PlatformResult ret(ErrorCode::NO_ERROR);
-  if (property_name == kPropertyIdBattery) {
-    ret = SysteminfoUtils::UnregisterBatteryListener();
-  } else if (property_name == kPropertyIdCpu) {
-    ret = SysteminfoUtils::UnregisterCpuListener();
-  } else if (property_name == kPropertyIdStorage) {
-    ret = SysteminfoUtils::UnregisterStorageListener();
-  } else if (property_name == kPropertyIdDisplay) {
-    ret = SysteminfoUtils::UnregisterDisplayListener();
-  } else if (property_name == kPropertyIdDeviceOrientation) {
-    ret = SysteminfoUtils::UnregisterDeviceOrientationListener();
-  } else if (property_name == kPropertyIdBuild) {
-    LoggerW("BUILD property's value is a fixed value");
-    //should be accepted, but no unregistration is needed
-    //ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
-  } else if (property_name == kPropertyIdLocale) {
-    ret = SysteminfoUtils::UnregisterLocaleListener();
-  } else if (property_name == kPropertyIdNetwork) {
-    ret = SysteminfoUtils::UnregisterNetworkListener();
-  } else if (property_name == kPropertyIdWifiNetwork) {
-    ret = SysteminfoUtils::UnregisterWifiNetworkListener();
-  } else if (property_name == kPropertyIdEthernetNetwork) {
-    ret = SysteminfoUtils::UnregisterEthernetNetworkListener();
-  } else if (property_name == kPropertyIdCellularNetwork) {
-    ret = SysteminfoUtils::UnregisterCellularNetworkListener();
-  } else if (property_name == kPropertyIdSim) {
-    //SIM listeners are not supported by core API, so we just pass over
-    LoggerW("SIM listener is not supported by Core API - ignoring");
-  } else if (property_name == kPropertyIdPeripheral) {
-    ret = SysteminfoUtils::UnregisterPeripheralListener();
-  } else if (property_name == kPropertyIdMemory) {
-    ret = SysteminfoUtils::UnregisterMemoryListener();
-  } else if (property_name == kPropertyIdCameraFlash) {
-    ret = SysteminfoUtils::UnregisterCameraFlashListener();
-  } else {
-    LoggerE("Not supported property");
-    ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
-  }
-  if (ret.IsSuccess()) {
-    ReportSuccess(out);
-    LoggerD("Success");
-    return;
-  }
-  LoggerD("Error");
-  ReportError(ret, &out);
+  manager_.RemovePropertyValueChangeListener(args, &out);
 }
 
 void SysteminfoInstance::GetTotalMemory(const picojson::value& args, picojson::object& out) {
@@ -353,214 +169,6 @@ void SysteminfoInstance::GetMaxBrightness(const picojson::value& args, picojson:
   ReportSuccess(picojson::value(std::to_string(brightness)), out);
 }
 
-//Callback functions
-void OnBatteryChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdBattery);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdBattery, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnCpuChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdCpu);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdCpu, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnStorageChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdStorage);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdStorage, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnDisplayChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdDisplay);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdDisplay, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnDeviceOrientationChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdDeviceOrientation);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdDeviceOrientation, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnLocaleChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdLocale);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdLocale, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnNetworkChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdNetwork);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdNetwork, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnWifiNetworkChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdWifiNetwork);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdWifiNetwork, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnEthernetNetworkChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Entered");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdEthernetNetwork);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdEthernetNetwork, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnCellularNetworkChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdCellularNetwork);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdCellularNetwork, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnPeripheralChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdPeripheral);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdPeripheral, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnMemoryChangedCallback(SysteminfoInstance& instance)
-{
-  LoggerD("Enter");
-  const std::shared_ptr<picojson::value>& response =
-      std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-  response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdMemory);
-  response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-  picojson::value result = picojson::value(picojson::object());
-//  PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdMemory, true, result);
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(result,response->get<picojson::object>());
-//    Instance::PostMessage(&instance, response->serialize().c_str());
-//  }
-}
-
-void OnBrigthnessChangedCallback(SysteminfoInstance &instance)
-{
-    LoggerD("Enter");
-    const std::shared_ptr<picojson::value>& response =
-        std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
-    response->get<picojson::object>()[kPropertyIdString] = picojson::value(kPropertyIdCameraFlash);
-    response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
-
-    picojson::value result = picojson::value(picojson::object());
-//    PlatformResult ret = SysteminfoUtils::GetPropertyValue(kPropertyIdCameraFlash, true, result);
-//    if (ret.IsSuccess()) {
-//      ReportSuccess(result,response->get<picojson::object>());
-//      Instance::PostMessage(&instance, response->serialize().c_str());
-//    }
-}
 
 } // namespace systeminfo
 } // namespace extension
index 307f2b9e1146173f2671b8efe3129ea1d00235e3..4585c7a82b1ffd6c9f083e8c95c45c606b1fe080 100644 (file)
 #include <memory>
 
 #include <device.h>
+#include <device/callback.h>
+#include <device/device-error.h>
 #include <sensor_internal.h>
+#include <wifi.h>
 
 #include "systeminfo/systeminfo_instance.h"
 #include "systeminfo/systeminfo_device_capability.h"
@@ -42,6 +45,28 @@ namespace systeminfo {
 
 namespace {
 const int kDefaultPropertyCount = 1;
+const int BASE_GATHERING_INTERVAL = 100;
+const double kPropertyWatcherTime = 1;
+
+const std::string kPropertyIdString = "propertyId";
+const std::string kListenerIdString = "listenerId";
+const std::string kListenerConstValue = "SysteminfoCommonListenerLabel";
+
+const std::string kPropertyIdBattery = "BATTERY";
+const std::string kPropertyIdCpu = "CPU";
+const std::string kPropertyIdStorage = "STORAGE";
+const std::string kPropertyIdDisplay = "DISPLAY";
+const std::string kPropertyIdDeviceOrientation = "DEVICE_ORIENTATION";
+const std::string kPropertyIdBuild = "BUILD";
+const std::string kPropertyIdLocale = "LOCALE";
+const std::string kPropertyIdNetwork = "NETWORK";
+const std::string kPropertyIdWifiNetwork = "WIFI_NETWORK";
+const std::string kPropertyIdEthernetNetwork = "ETHERNET_NETWORK";
+const std::string kPropertyIdCellularNetwork = "CELLULAR_NETWORK";
+const std::string kPropertyIdSim = "SIM";
+const std::string kPropertyIdPeripheral = "PERIPHERAL";
+const std::string kPropertyIdMemory= "MEMORY";
+const std::string kPropertyIdCameraFlash= "CAMERA_FLASH";
 
 #define CHECK_EXIST(args, name, out) \
   if (!args.contains(name)) {\
@@ -89,6 +114,106 @@ const int kDefaultPropertyCount = 1;
   } \
   result_obj.insert(std::make_pair(str_name, picojson::value(str_value)));
 
+//Callback static functions
+static void OnBatteryChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdBattery);
+}
+
+static gboolean OnCpuChangedCb(gpointer event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdCpu);
+  return G_SOURCE_CONTINUE;
+}
+
+static gboolean OnStorageChangedCb(gpointer event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdStorage);
+  return G_SOURCE_CONTINUE;
+}
+
+static void OnMmcChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdStorage);
+}
+
+static void OnDisplayChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdDisplay);
+}
+
+static void OnDeviceAutoRotationChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdDeviceOrientation);
+}
+
+static void OnDeviceOrientationChangedCb(sensor_t sensor, unsigned int event_type,
+                                  sensor_data_t *data, void *user_data) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(user_data);
+  manager->CallListenerCallback(kPropertyIdDeviceOrientation);
+}
+
+static void OnLocaleChangedCb(system_settings_key_e key, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdLocale);
+}
+
+static void OnNetworkChangedCb(connection_type_e type, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdNetwork);
+}
+
+static void OnNetworkValueChangedCb(const char* ipv4_address,
+                             const char* ipv6_address, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdWifiNetwork);
+  manager->CallListenerCallback(kPropertyIdEthernetNetwork);
+  manager->CallListenerCallback(kPropertyIdCellularNetwork);
+}
+
+static void OnCellularNetworkValueChangedCb(keynode_t *node, void *event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdCellularNetwork);
+}
+
+static void OnPeripheralChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdPeripheral);
+}
+
+static void OnMemoryChangedCb(keynode_t* node, void* event_ptr) {
+  LoggerD("Enter");
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(event_ptr);
+  manager->CallListenerCallback(kPropertyIdMemory);
+}
+
+static void OnBrightnessChangedCb(device_callback_e type, void* value, void* user_data) {
+  LoggerD("Entered");
+  if (type == DEVICE_CALLBACK_FLASH_BRIGHTNESS) {
+    SysteminfoManager* manager = static_cast<SysteminfoManager*>(user_data);
+    manager->CallListenerCallback(kPropertyIdCameraFlash);
+  }
+}
+
+static void OnWifiLevelChangedCb (wifi_rssi_level_e rssi_level, void *user_data) {
+  LoggerD("Entered");
+  LoggerD("Level %d", rssi_level);
+  SysteminfoManager* manager = static_cast<SysteminfoManager*>(user_data);
+  manager->SetWifiLevel(rssi_level);
+}
+
 } //namespace
 
 SysteminfoManager::SysteminfoManager(SysteminfoInstance* instance)
@@ -100,41 +225,57 @@ SysteminfoManager::SysteminfoManager(SysteminfoInstance* instance)
       available_capacity_internal_(0),
       available_capacity_mmc_(0),
       sim_count_(0),
-      tapi_handles_{nullptr} {
-  LoggerD("Entered");
-    int error = wifi_initialize();
-    if (WIFI_ERROR_NONE != error) {
-      std::string log_msg = "Initialize failed: " + std::string(get_error_message(error));
-      LoggerE("%s", log_msg.c_str());
-    } else {
-      LoggerD("WIFI initialization succeed");
-    }
+      tapi_handles_{nullptr},
+      cpu_event_id_(0),
+      storage_event_id_(0),
+      connection_handle_(nullptr) {
+        LoggerD("Entered");
+        int error = wifi_initialize();
+        if (WIFI_ERROR_NONE != error) {
+          std::string log_msg = "Initialize failed: " + std::string(get_error_message(error));
+          LoggerE("%s", log_msg.c_str());
+        } else {
+          LoggerD("WIFI initialization succeed");
+        }
 
-    //TODO
-//    error = wifi_set_rssi_level_changed_cb(OnWifiLevelChangedCb, nullptr);
-//    if (WIFI_ERROR_NONE != error) {
-//      std::string log_msg = "Setting wifi listener failed: " + parseWifiNetworkError(error);
-//      LoggerE("%s", log_msg.c_str());
-//    } else {
-//      LoggerD("Setting wifi listener succeed");
-//    }
-    InitCameraTypes();
-}
+        error = wifi_set_rssi_level_changed_cb(OnWifiLevelChangedCb, this);
+        if (WIFI_ERROR_NONE != error) {
+          std::string log_msg = "Setting wifi listener failed: " +
+              std::string(get_error_message(error));
+          LoggerE("%s", log_msg.c_str());
+        } else {
+          LoggerD("Setting wifi listener succeed");
+        }
+        InitCameraTypes();
+      }
 
 SysteminfoManager::~SysteminfoManager() {
   LoggerD("Enter");
   DisconnectSensor(sensor_handle_);
 
+  if (IsListenerRegistered(kPropertyIdBattery)) { UnregisterBatteryListener(); }
+  if (IsListenerRegistered(kPropertyIdCpu)) { UnregisterCpuListener(); }
+  if (IsListenerRegistered(kPropertyIdStorage)) { UnregisterStorageListener(); }
+  if (IsListenerRegistered(kPropertyIdDisplay)) { UnregisterDisplayListener(); }
+  if (IsListenerRegistered(kPropertyIdDeviceOrientation)) { UnregisterDeviceOrientationListener(); }
+  if (IsListenerRegistered(kPropertyIdLocale)) { UnregisterLocaleListener(); }
+  if (IsListenerRegistered(kPropertyIdNetwork)) { UnregisterNetworkListener(); }
+  if (IsListenerRegistered(kPropertyIdWifiNetwork)) { UnregisterWifiNetworkListener(); }
+  if (IsListenerRegistered(kPropertyIdEthernetNetwork)) { UnregisterEthernetNetworkListener(); }
+  if (IsListenerRegistered(kPropertyIdCellularNetwork)) { UnregisterCellularNetworkListener(); }
+  if (IsListenerRegistered(kPropertyIdPeripheral)) { UnregisterPeripheralListener(); }
+  if (IsListenerRegistered(kPropertyIdMemory)) { UnregisterMemoryListener(); }
+  if (IsListenerRegistered(kPropertyIdCameraFlash)) { UnregisterCameraFlashListener(); }
 
   unsigned int i = 0;
   while(tapi_handles_[i]) {
     tel_deinit(tapi_handles_[i]);
     i++;
   }
-//TODO
-//  if (nullptr != m_connection_handle) {
-//    connection_destroy(m_connection_handle);
-//  }
+
+  if (nullptr != connection_handle_) {
+    connection_destroy(connection_handle_);
+  }
 
   wifi_deinitialize();
 }
@@ -362,112 +503,542 @@ void SysteminfoManager::GetCount(const picojson::value& args, picojson::object*
   LoggerD("Success");
 }
 
-void SysteminfoManager::AddPropertyValueChangeListener(const picojson::value& args, picojson::object* out) {
+void SysteminfoManager::AddPropertyValueChangeListener(const picojson::value& args,
+                                                       picojson::object* out) {
   LoggerD("Enter");
   // Check type of property for which listener should be registered
   CHECK_EXIST(args, "property", out)
   const std::string& property_name = args.get("property").get<std::string>();
 
-  LoggerD("Adding listener for property with id: %s ", property_name.c_str());
-//  PlatformResult ret(ErrorCode::NO_ERROR);
-//  if (property_name == kPropertyIdBattery) {
-//    ret = SysteminfoUtils::RegisterBatteryListener(OnBatteryChangedCallback, *this);
-//  } else if (property_name == kPropertyIdCpu) {
-//    ret = SysteminfoUtils::RegisterCpuListener(OnCpuChangedCallback, *this);
-//  } else if (property_name == kPropertyIdStorage) {
-//    ret = SysteminfoUtils::RegisterStorageListener(OnStorageChangedCallback, *this);
-//  } else if (property_name == kPropertyIdDisplay) {
-//    ret = SysteminfoUtils::RegisterDisplayListener(OnDisplayChangedCallback, *this);
-//  } else if (property_name == kPropertyIdDeviceOrientation) {
-//    ret = SysteminfoUtils::RegisterDeviceOrientationListener(OnDeviceOrientationChangedCallback, *this);
-//  } else if (property_name == kPropertyIdBuild) {
-//    LoggerW("BUILD property's value is a fixed value");
-//    //should be accepted, but no registration is needed
-//    //ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
-//  } else if (property_name == kPropertyIdLocale) {
-//    ret = SysteminfoUtils::RegisterLocaleListener(OnLocaleChangedCallback, *this);
-//  } else if (property_name == kPropertyIdNetwork) {
-//    ret = SysteminfoUtils::RegisterNetworkListener(OnNetworkChangedCallback, *this);
-//  } else if (property_name == kPropertyIdWifiNetwork) {
-//    ret = SysteminfoUtils::RegisterWifiNetworkListener(OnWifiNetworkChangedCallback, *this);
-//  } else if (property_name == kPropertyIdEthernetNetwork) {
-//    ret = SysteminfoUtils::RegisterEthernetNetworkListener(OnEthernetNetworkChangedCallback, *this);
-//  } else if (property_name == kPropertyIdCellularNetwork) {
-//    ret = SysteminfoUtils::RegisterCellularNetworkListener(OnCellularNetworkChangedCallback, *this);
-//  } else if (property_name == kPropertyIdSim) {
-//    //SIM listeners are not supported by core API, so we just pass over
-//    LoggerW("SIM listener is not supported by Core API - ignoring");
-//  } else if (property_name == kPropertyIdPeripheral) {
-//    ret = SysteminfoUtils::RegisterPeripheralListener(OnPeripheralChangedCallback, *this);
-//  } else if (property_name == kPropertyIdMemory) {
-//    ret = SysteminfoUtils::RegisterMemoryListener(OnMemoryChangedCallback, *this);
-//  } else if (property_name == kPropertyIdCameraFlash) {
-//    ret = SysteminfoUtils::RegisterCameraFlashListener(OnBrigthnessChangedCallback, *this);
-//  } else {
-//    LoggerE("Not supported property");
-//    ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
-//  }
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(out);
-//    LoggerD("Success");
-//    return;
-//  }
-//  LoggerD("Error");
-//  ReportError(ret, &out);
-}
-
-void SysteminfoManager::RemovePropertyValueChangeListener(const picojson::value& args, picojson::object* out) {
+  PlatformResult ret(ErrorCode::NO_ERROR);
+  if (!IsListenerRegistered(property_name)){
+    LoggerD("Adding listener for property with id: %s ", property_name.c_str());
+    if (property_name == kPropertyIdBattery) {
+      ret = RegisterBatteryListener();
+    } else if (property_name == kPropertyIdCpu) {
+      ret = RegisterCpuListener();
+    } else if (property_name == kPropertyIdStorage) {
+      ret = RegisterStorageListener();
+    } else if (property_name == kPropertyIdDisplay) {
+      ret = RegisterDisplayListener();
+    } else if (property_name == kPropertyIdDeviceOrientation) {
+      ret = RegisterDeviceOrientationListener();
+    } else if (property_name == kPropertyIdBuild) {
+      LoggerW("BUILD property's value is a fixed value");
+      //should be accepted, but no registration is needed
+      ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
+    } else if (property_name == kPropertyIdLocale) {
+      ret = RegisterLocaleListener();
+    } else if (property_name == kPropertyIdNetwork) {
+      ret = RegisterNetworkListener();
+    } else if (property_name == kPropertyIdWifiNetwork) {
+      ret = RegisterWifiNetworkListener();
+    } else if (property_name == kPropertyIdEthernetNetwork) {
+      ret = RegisterEthernetNetworkListener();
+    } else if (property_name == kPropertyIdCellularNetwork) {
+      ret = RegisterCellularNetworkListener();
+    } else if (property_name == kPropertyIdSim) {
+      //SIM listeners are not supported by core API, so we just pass over
+      LoggerW("SIM listener is not supported by Core API - ignoring");
+    } else if (property_name == kPropertyIdPeripheral) {
+      ret = RegisterPeripheralListener();
+    } else if (property_name == kPropertyIdMemory) {
+      ret = RegisterMemoryListener();
+    } else if (property_name == kPropertyIdCameraFlash) {
+      ret = RegisterCameraFlashListener();
+    } else {
+      LoggerE("Not supported property");
+      ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
+    }
+    if (ret.IsSuccess()) {
+      registered_listeners_.insert(property_name);
+    }
+  } else {
+    LoggerD("Adding listener for property with id: %s is not needed, already registered",
+            property_name.c_str());
+  }
+  if (ret.IsSuccess()) {
+    ReportSuccess(*out);
+    LoggerD("Success");
+    return;
+  }
+  LoggerD("Error");
+  ReportError(ret, out);
+}
+
+void SysteminfoManager::RemovePropertyValueChangeListener(const picojson::value& args,
+                                                          picojson::object* out) {
   LoggerD("Enter");
 
   // Check type of property for which listener should be removed
   CHECK_EXIST(args, "property", out)
   const std::string& property_name = args.get("property").get<std::string>();
-  LoggerD("Removing listener for property with id: %s ", property_name.c_str());
+
   PlatformResult ret(ErrorCode::NO_ERROR);
-//  if (property_name == kPropertyIdBattery) {
-//    ret = SysteminfoUtils::UnregisterBatteryListener();
-//  } else if (property_name == kPropertyIdCpu) {
-//    ret = SysteminfoUtils::UnregisterCpuListener();
-//  } else if (property_name == kPropertyIdStorage) {
-//    ret = SysteminfoUtils::UnregisterStorageListener();
-//  } else if (property_name == kPropertyIdDisplay) {
-//    ret = SysteminfoUtils::UnregisterDisplayListener();
-//  } else if (property_name == kPropertyIdDeviceOrientation) {
-//    ret = SysteminfoUtils::UnregisterDeviceOrientationListener();
-//  } else if (property_name == kPropertyIdBuild) {
-//    LoggerW("BUILD property's value is a fixed value");
-//    //should be accepted, but no unregistration is needed
-//    //ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
-//  } else if (property_name == kPropertyIdLocale) {
-//    ret = SysteminfoUtils::UnregisterLocaleListener();
-//  } else if (property_name == kPropertyIdNetwork) {
-//    ret = SysteminfoUtils::UnregisterNetworkListener();
-//  } else if (property_name == kPropertyIdWifiNetwork) {
-//    ret = SysteminfoUtils::UnregisterWifiNetworkListener();
-//  } else if (property_name == kPropertyIdEthernetNetwork) {
-//    ret = SysteminfoUtils::UnregisterEthernetNetworkListener();
-//  } else if (property_name == kPropertyIdCellularNetwork) {
-//    ret = SysteminfoUtils::UnregisterCellularNetworkListener();
-//  } else if (property_name == kPropertyIdSim) {
-//    //SIM listeners are not supported by core API, so we just pass over
-//    LoggerW("SIM listener is not supported by Core API - ignoring");
-//  } else if (property_name == kPropertyIdPeripheral) {
-//    ret = SysteminfoUtils::UnregisterPeripheralListener();
-//  } else if (property_name == kPropertyIdMemory) {
-//    ret = SysteminfoUtils::UnregisterMemoryListener();
-//  } else if (property_name == kPropertyIdCameraFlash) {
-//    ret = SysteminfoUtils::UnregisterCameraFlashListener();
-//  } else {
-//    LoggerE("Not supported property");
-//    ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
-//  }
-//  if (ret.IsSuccess()) {
-//    ReportSuccess(out);
-//    LoggerD("Success");
-//    return;
-//  }
-//  LoggerD("Error");
-//  ReportError(ret, &out);
+  if (IsListenerRegistered(property_name)){
+    LoggerD("Removing listener for property with id: %s ", property_name.c_str());
+    registered_listeners_.erase(property_name);
+    if (property_name == kPropertyIdBattery) {
+      ret = UnregisterBatteryListener();
+    } else if (property_name == kPropertyIdCpu) {
+      ret = UnregisterCpuListener();
+    } else if (property_name == kPropertyIdStorage) {
+      ret = UnregisterStorageListener();
+    } else if (property_name == kPropertyIdDisplay) {
+      ret = UnregisterDisplayListener();
+    } else if (property_name == kPropertyIdDeviceOrientation) {
+      ret = UnregisterDeviceOrientationListener();
+    } else if (property_name == kPropertyIdBuild) {
+      LoggerW("BUILD property's value is a fixed value");
+      //should be accepted, but no unregistration is needed
+      //ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
+    } else if (property_name == kPropertyIdLocale) {
+      ret = UnregisterLocaleListener();
+    } else if (property_name == kPropertyIdNetwork) {
+      ret = UnregisterNetworkListener();
+    } else if (property_name == kPropertyIdWifiNetwork) {
+      ret = UnregisterWifiNetworkListener();
+    } else if (property_name == kPropertyIdEthernetNetwork) {
+      ret = UnregisterEthernetNetworkListener();
+    } else if (property_name == kPropertyIdCellularNetwork) {
+      ret = UnregisterCellularNetworkListener();
+    } else if (property_name == kPropertyIdSim) {
+      //SIM listeners are not supported by core API, so we just pass over
+      LoggerW("SIM listener is not supported by Core API - ignoring");
+    } else if (property_name == kPropertyIdPeripheral) {
+      ret = UnregisterPeripheralListener();
+    } else if (property_name == kPropertyIdMemory) {
+      ret = UnregisterMemoryListener();
+    } else if (property_name == kPropertyIdCameraFlash) {
+      ret = UnregisterCameraFlashListener();
+    } else {
+      LoggerE("Not supported property");
+      ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
+    }
+  } else {
+    LoggerD("Removing listener for property with id: %s is not needed, not registered",
+            property_name.c_str());
+  }
+  if (ret.IsSuccess()) {
+    ReportSuccess(*out);
+    LoggerD("Success");
+    return;
+  }
+  LoggerD("Error");
+  ReportError(ret, out);
+}
+
+#define CHECK_LISTENER_ERROR(method) \
+  ret = method; \
+  if (ret.IsError()) { \
+    return ret; \
+  }
+
+bool SysteminfoManager::IsIpChangeCallbackNotRegistered() {
+  LoggerD("Entered");
+  return !(IsListenerRegistered(kPropertyIdWifiNetwork) ||
+      IsListenerRegistered(kPropertyIdEthernetNetwork) ||
+      IsListenerRegistered(kPropertyIdCellularNetwork));
+}
+
+PlatformResult SysteminfoManager::RegisterIpChangeCallback() {
+  LoggerD("Entered");
+  connection_h handle;
+  PlatformResult ret(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
+  int error = connection_set_ip_address_changed_cb(handle,
+                                                   OnNetworkValueChangedCb,
+                                                   static_cast<void*>(this));
+  if (CONNECTION_ERROR_NONE != error) {
+    LoggerE("Failed to register ip change callback: %d", error);
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot register ip change callback");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterIpChangeCallback() {
+  LoggerD("Entered");
+  connection_h handle;
+  PlatformResult ret(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
+  int error = connection_unset_ip_address_changed_cb(handle);
+  if (CONNECTION_ERROR_NONE != error) {
+    LoggerE("Failed to unregister ip change callback: %d", error);
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot unregister ip change callback");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterBatteryListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+                                             OnBatteryChangedCb, this))
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+                                             OnBatteryChangedCb, this))
+                                             LoggerD("Added callback for BATTERY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterBatteryListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+                                               OnBatteryChangedCb))
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+                                               OnBatteryChangedCb))
+                                               LoggerD("Removed callback for BATTERY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterCpuListener() {
+  LoggerD("Entered");
+  cpu_event_id_ = g_timeout_add_seconds(kPropertyWatcherTime, OnCpuChangedCb, static_cast<void*>(this));
+  LoggerD("Added callback for CPU");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterCpuListener() {
+  LoggerD("Entered");
+  g_source_remove(cpu_event_id_);
+  cpu_event_id_ = 0;
+  LoggerD("Removed callback for CPU");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterStorageListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SYSMAN_MMC_STATUS,
+                                             OnMmcChangedCb, this))
+
+  storage_event_id_ = g_timeout_add_seconds(kPropertyWatcherTime,
+                                             OnStorageChangedCb, static_cast<void*>(this));
+  LoggerD("Added callback for STORAGE");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterStorageListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SYSMAN_MMC_STATUS, OnMmcChangedCb))
+
+  g_source_remove(storage_event_id_);
+  storage_event_id_ = 0;
+  LoggerD("Removed callback for STORAGE");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterDisplayListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
+                                             OnDisplayChangedCb, this))
+  LoggerD("Added callback for DISPLAY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterDisplayListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
+                                               OnDisplayChangedCb))
+  LoggerD("Removed callback for DISPLAY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterDeviceOrientationListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL,
+                                             OnDeviceAutoRotationChangedCb, this))
+
+  bool sensor_ret = sensord_register_event(GetSensorHandle(), AUTO_ROTATION_EVENT_CHANGE_STATE,
+                                           BASE_GATHERING_INTERVAL, 0,
+                                           OnDeviceOrientationChangedCb, this);
+  if (!sensor_ret) {
+    LoggerE("Failed to register orientation change event listener");
+    return PlatformResult(ErrorCode::UNKNOWN_ERR,
+                          "Failed to register orientation change event listener");
+  }
+
+  LoggerD("Added callback for DEVICE_ORIENTATION");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterDeviceOrientationListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(
+      SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL,
+                                               OnDeviceAutoRotationChangedCb))
+  bool sensor_ret = sensord_unregister_event(GetSensorHandle(), AUTO_ROTATION_EVENT_CHANGE_STATE);
+  if (!sensor_ret) {
+    LoggerE("Failed to unregister orientation change event listener");
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister"
+                          " orientation change event listener");
+  }
+
+  LoggerD("Removed callback for DEVICE_ORIENTATION");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterLocaleListener() {
+  LoggerD("Entered");
+  if (SYSTEM_SETTINGS_ERROR_NONE !=
+      system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
+                                     OnLocaleChangedCb, static_cast<void*>(this)) ) {
+    LoggerE("Country change callback registration failed");
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Country change callback registration failed");
+  }
+  if (SYSTEM_SETTINGS_ERROR_NONE !=
+      system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
+                                     OnLocaleChangedCb, static_cast<void*>(this)) ) {
+    LoggerE("Language change callback registration failed");
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Language change callback registration failed");
+  }
+  LoggerD("Added callback for LOCALE");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterLocaleListener() {
+  LoggerD("Entered");
+  if (SYSTEM_SETTINGS_ERROR_NONE !=
+      system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE) ) {
+    LoggerE("Unregistration of language change callback failed");
+  }
+  if (SYSTEM_SETTINGS_ERROR_NONE !=
+      system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY) ) {
+    LoggerE("Unregistration of country change callback failed");
+  }
+  LoggerD("Removed callback for LOCALE");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterNetworkListener() {
+  LoggerD("Entered");
+  connection_h handle;
+  PlatformResult ret(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
+  if (CONNECTION_ERROR_NONE !=
+      connection_set_type_changed_cb(handle, OnNetworkChangedCb, static_cast<void*>(this))) {
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Registration of listener failed");
+  }
+  LoggerD("Added callback for NETWORK");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterNetworkListener() {
+  LoggerD("Entered");
+  connection_h handle;
+  PlatformResult ret(ErrorCode::NO_ERROR);
+  CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
+  if (CONNECTION_ERROR_NONE != connection_unset_type_changed_cb(handle)) {
+    return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unregistration of listener failed");
+  }
+  LoggerD("Removed callback for NETWORK");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterWifiNetworkListener() {
+  LoggerD("Entered");
+
+  if (IsIpChangeCallbackNotRegistered()) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(RegisterIpChangeCallback());
+    LoggerD("Registered IP change listener");
+  } else {
+    LoggerD("No need to register IP listener on platform, already registered");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterWifiNetworkListener() {
+  LoggerD("Entered");
+  // if there is no other ip-relateded listeners left, unregister
+  if (IsIpChangeCallbackNotRegistered()) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
+    LoggerD("Removed IP change listener");
+  } else {
+    LoggerD("Removed callback for WIFI_NETWORK, but IP change listener still works");
+  }
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterEthernetNetworkListener() {
+  LoggerD("Entered");
+  PlatformResult ret = SysteminfoUtils::CheckIfEthernetNetworkSupported();
+  if (ret.IsError()){
+    return ret;
+  }
+
+  if (IsIpChangeCallbackNotRegistered()) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(RegisterIpChangeCallback());
+    LoggerD("Registered IP change listener");
+  } else {
+    LoggerD("No need to register IP listener on platform, already registered");
+  }
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterEthernetNetworkListener() {
+  LoggerD("Entered");
+
+  if (IsIpChangeCallbackNotRegistered()) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
+    LoggerD("Removed IP change listener");
+  } else {
+    LoggerD("Removed callback for ETHERNET_NETWORK, but IP change listener still works");
+  }
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterCellularNetworkListener() {
+  LoggerD("Entered");
+  PlatformResult ret = SysteminfoUtils::CheckTelephonySupport();
+  if (ret.IsError()) {
+      return ret;
+  }
+
+  if (IsIpChangeCallbackNotRegistered()) {
+    CHECK_LISTENER_ERROR(RegisterIpChangeCallback());
+    LoggerD("Registered IP change listener");
+  } else {
+    LoggerD("No need to register IP listener on platform, already registered");
+  }
+
+  if (!IsListenerRegistered(kPropertyIdCellularNetwork)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                          OnCellularNetworkValueChangedCb, this))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_CELLID,
+                          OnCellularNetworkValueChangedCb, this))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_LAC,
+                          OnCellularNetworkValueChangedCb, this))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM,
+                          OnCellularNetworkValueChangedCb, this))
+    LoggerD("Added callback for CELLULAR_NETWORK");
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterCellularNetworkListener() {
+  LoggerD("Entered");
+
+  // if there is no other ip-relateded listeners left, unregister
+  if (!IsListenerRegistered(kPropertyIdCellularNetwork)) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                            OnCellularNetworkValueChangedCb))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_CELLID,
+                            OnCellularNetworkValueChangedCb))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_LAC,
+                            OnCellularNetworkValueChangedCb))
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_TELEPHONY_SVC_ROAM,
+                            OnCellularNetworkValueChangedCb))
+  }
+
+  if (IsIpChangeCallbackNotRegistered()) {
+    PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+    CHECK_LISTENER_ERROR(UnregisterIpChangeCallback());
+    LoggerD("Removed IP change listener");
+  } else {
+    LoggerD("Removed callback for CELLULAR_NETWORK, but IP change listener still works");
+  }
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterPeripheralListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  int value = 0;
+/*  if (-1 != vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &value)) {
+    CHECK_LISTENER_ERROR(RegisterVconfCallback(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS,
+                                               OnPeripheralChangedCb, instance))
+  }*/
+  if (-1 != vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SYSMAN_HDMI,
+                                               OnPeripheralChangedCb, this))
+  }
+
+  LoggerD("Added callback for PERIPHERAL");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterPeripheralListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  int value = 0;
+/*  if (-1 != vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &value)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS,
+                                                 OnPeripheralChangedCb))
+  }*/
+  if (-1 != vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SYSMAN_HDMI,
+                                                 OnPeripheralChangedCb))
+  }
+
+  LoggerD("Removed callback for PERIPHERAL");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterMemoryListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  int value = 0;
+  if (-1 != vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &value)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::RegisterVconfCallback(VCONFKEY_SYSMAN_LOW_MEMORY,
+                                                                OnMemoryChangedCb, this))
+  }
+  LoggerD("Added callback for MEMORY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterMemoryListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  int value = 0;
+  if (-1 != vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &value)) {
+    CHECK_LISTENER_ERROR(SysteminfoUtils::UnregisterVconfCallback(VCONFKEY_SYSMAN_LOW_MEMORY,
+                                                                  OnMemoryChangedCb))
+  }
+  LoggerD("Removed callback for MEMORY");
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::RegisterCameraFlashListener() {
+  LoggerD("Entered");
+  if (DEVICE_ERROR_NONE != device_add_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
+                                               OnBrightnessChangedCb, this)) {
+    return PlatformResult(ErrorCode::UNKNOWN_ERR);
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterCameraFlashListener() {
+  LoggerD("Entered");
+  PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
+  if (DEVICE_ERROR_NONE != device_remove_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
+                                                  OnBrightnessChangedCb)) {
+    return PlatformResult(ErrorCode::UNKNOWN_ERR);
+  }
+  LoggerD("Removed callback for camera_flash");
+  return PlatformResult(ErrorCode::NO_ERROR);
 }
 
 void SysteminfoManager::SetBrightness(const picojson::value& args, picojson::object* out) {
@@ -512,8 +1083,7 @@ void SysteminfoManager::GetMaxBrightness(const picojson::value& args, picojson::
 }
 
 PlatformResult SysteminfoManager::GetPropertyCount(const std::string& property,
-                                                   unsigned long* count)
-{
+                                                   unsigned long* count) {
   LoggerD("Enter");
 
   if ("BATTERY" == property || "CPU" == property || "STORAGE" == property ||
@@ -557,6 +1127,11 @@ wifi_rssi_level_e SysteminfoManager::GetWifiLevel() {
   return wifi_level_;
 }
 
+void SysteminfoManager::SetWifiLevel(wifi_rssi_level_e level) {
+  LoggerD("Entered");
+  wifi_level_ = level;
+}
+
 int SysteminfoManager::GetSensorHandle() {
   LoggerD("Enter");
   if (sensor_handle_ < 0) {
@@ -602,18 +1177,33 @@ void SysteminfoManager::DisconnectSensor(int handle_orientation) {
   }
 }
 
+double SysteminfoManager::GetCpuInfoLoad() {
+  LoggerD("Enter");
+  return cpu_load_;
+}
+
 void SysteminfoManager::SetCpuInfoLoad(double load) {
   LoggerD("Enter");
   cpu_load_ = load;
 }
 
+unsigned long long SysteminfoManager::GetAvailableCapacityInternal() {
+  LoggerD("Entered");
+  return available_capacity_internal_;
+}
+
 void SysteminfoManager::SetAvailableCapacityInternal(unsigned long long capacity) {
-  LoggerD("Enter");
+  LoggerD("Entered");
   available_capacity_internal_ = capacity;
 }
 
+unsigned long long SysteminfoManager::GetAvailableCapacityMmc() {
+  LoggerD("Entered");
+  return available_capacity_mmc_;
+}
+
 void SysteminfoManager::SetAvailableCapacityMmc(unsigned long long capacity) {
-  LoggerD("Enter");
+  LoggerD("Entered");
   available_capacity_mmc_ = capacity;
 }
 
@@ -690,5 +1280,92 @@ int SysteminfoManager::GetCameraTypesCount() {
   return camera_types_.size();
 }
 
+PlatformResult SysteminfoManager::GetConnectionHandle(connection_h& handle) {
+  LoggerD("Entered");
+  if (nullptr == connection_handle_) {
+    int error = connection_create(&connection_handle_);
+    if (CONNECTION_ERROR_NONE != error) {
+      LoggerE("Failed to create connection: %d", error);
+      return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot create connection");
+    }
+  }
+  handle = connection_handle_;
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+bool SysteminfoManager::IsListenerRegistered(const std::string& property_id) {
+  LoggerD("Entered");
+  return (registered_listeners_.find(property_id) != registered_listeners_.end());
+}
+
+void SysteminfoManager::CallListenerCallback(const std::string& property_id) {
+  LoggerD("Enter");
+  if(IsListenerRegistered(property_id)) {
+    LoggerD("listener for %s property is registered, calling it", property_id.c_str());
+    const std::shared_ptr<picojson::value>& response =
+        std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
+    response->get<picojson::object>()[kPropertyIdString] = picojson::value(property_id);
+    response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
+
+    picojson::value result = picojson::value(picojson::object());
+    PlatformResult ret = GetPropertiesManager().GetPropertyValue(
+        property_id, true, &result);
+    if (ret.IsSuccess()) {
+      ReportSuccess(result,response->get<picojson::object>());
+      Instance::PostMessage(instance_, response->serialize().c_str());
+    }
+  } else {
+    LoggerD("listener for %s property is not registered, ignoring", property_id.c_str());
+  }
+}
+
+void SysteminfoManager::CallCpuListenerCallback() {
+  LoggerD("Enter");
+  std::string property_id = kPropertyIdCpu;
+  if(IsListenerRegistered(property_id)) {
+    LoggerD("listener for %s property is registered, calling it", property_id.c_str());
+    const std::shared_ptr<picojson::value>& response =
+        std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
+    response->get<picojson::object>()[kPropertyIdString] = picojson::value(property_id);
+    response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
+
+    picojson::value result = picojson::value(picojson::object());
+    PlatformResult ret = GetPropertiesManager().GetPropertyValue(
+        property_id, true, &result);
+    if (ret.IsSuccess()) {
+      ReportSuccess(result,response->get<picojson::object>());
+      Instance::PostMessage(instance_, response->serialize().c_str());
+    }
+  } else {
+    LoggerD("listener for %s property is not registered, ignoring", property_id.c_str());
+  }
+}
+
+void SysteminfoManager::CallStorageListenerCallback() {
+  LoggerD("Enter");
+  std::string property_id = kPropertyIdStorage;
+  if(IsListenerRegistered(property_id)) {
+    LoggerD("listener for %s property is registered, calling it", property_id.c_str());
+    const std::shared_ptr<picojson::value>& response =
+        std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
+    response->get<picojson::object>()[kPropertyIdString] = picojson::value(property_id);
+    response->get<picojson::object>()[kListenerIdString] = picojson::value(kListenerConstValue);
+
+    picojson::value result = picojson::value(picojson::object());
+    PlatformResult ret = GetPropertiesManager().GetPropertyValue(
+        property_id, true, &result);
+    if (ret.IsSuccess()) {
+      if (available_capacity_internal_ == last_available_capacity_internal_) {
+        return;
+      }
+      last_available_capacity_internal_ = available_capacity_internal_;
+      ReportSuccess(result,response->get<picojson::object>());
+      Instance::PostMessage(instance_, response->serialize().c_str());
+    }
+  } else {
+    LoggerD("listener for %s property is not registered, ignoring", property_id.c_str());
+  }
+}
+
 }  // namespace systeminfo
 }  // namespace extension
index 636013748648c27724e20cdd2abf8528c4150971..813875f3aea320bf541e1cc11de8688519de8bb7 100644 (file)
 #ifndef WEBAPI_PLUGINS_SYSTEMINFO_SYSTEMINFO_MANAGER_H__
 #define WEBAPI_PLUGINS_SYSTEMINFO_SYSTEMINFO_MANAGER_H__
 
+#include <set>
+
 #include <wifi.h>
+#include <net_connection.h>
 
 #include "common/picojson.h"
 #include "common/platform_result.h"
@@ -50,15 +53,28 @@ class SysteminfoManager {
 
   common::PlatformResult GetPropertyCount(const std::string& property, unsigned long* count);
   wifi_rssi_level_e GetWifiLevel();
+  void SetWifiLevel(wifi_rssi_level_e level);
   int GetSensorHandle();
   TapiHandle* GetTapiHandle();
   TapiHandle** GetTapiHandles();
+  common::PlatformResult GetConnectionHandle(connection_h& handle);
+
+  SysteminfoInstance* GetInstance() { return instance_;};
+  SysteminfoPropertiesManager& GetPropertiesManager() { return prop_manager_;};
 
+  double GetCpuInfoLoad();
   void SetCpuInfoLoad(double load);
+  unsigned long long GetAvailableCapacityInternal();
   void SetAvailableCapacityInternal(unsigned long long capacity);
+  unsigned long long GetAvailableCapacityMmc();
   void SetAvailableCapacityMmc(unsigned long long capacity);
   std::string GetCameraTypes(int index);
   int GetCameraTypesCount();
+
+  bool IsListenerRegistered(const std::string& property_id);
+  void CallListenerCallback(const std::string& property_id);
+  void CallCpuListenerCallback();
+  void CallStorageListenerCallback();
  private:
   common::PlatformResult ConnectSensor(int* result);
   void DisconnectSensor(int handle_orientation);
@@ -66,6 +82,37 @@ class SysteminfoManager {
   void InitCameraTypes();
   int GetSimCount();
 
+  bool IsIpChangeCallbackNotRegistered();
+  common::PlatformResult RegisterIpChangeCallback();
+  common::PlatformResult UnregisterIpChangeCallback();
+
+  common::PlatformResult RegisterBatteryListener();
+  common::PlatformResult UnregisterBatteryListener();
+  common::PlatformResult RegisterCpuListener();
+  common::PlatformResult UnregisterCpuListener();
+  common::PlatformResult RegisterStorageListener();
+  common::PlatformResult UnregisterStorageListener();
+  common::PlatformResult RegisterDisplayListener();
+  common::PlatformResult UnregisterDisplayListener();
+  common::PlatformResult RegisterDeviceOrientationListener();
+  common::PlatformResult UnregisterDeviceOrientationListener();
+  common::PlatformResult RegisterLocaleListener();
+  common::PlatformResult UnregisterLocaleListener();
+  common::PlatformResult RegisterNetworkListener();
+  common::PlatformResult UnregisterNetworkListener();
+  common::PlatformResult RegisterWifiNetworkListener();
+  common::PlatformResult UnregisterWifiNetworkListener();
+  common::PlatformResult RegisterEthernetNetworkListener();
+  common::PlatformResult UnregisterEthernetNetworkListener();
+  common::PlatformResult RegisterCellularNetworkListener();
+  common::PlatformResult UnregisterCellularNetworkListener();
+  common::PlatformResult RegisterPeripheralListener();
+  common::PlatformResult UnregisterPeripheralListener();
+  common::PlatformResult RegisterMemoryListener();
+  common::PlatformResult UnregisterMemoryListener();
+  common::PlatformResult RegisterCameraFlashListener();
+  common::PlatformResult UnregisterCameraFlashListener();
+
   SysteminfoInstance* instance_;
   SysteminfoPropertiesManager prop_manager_;
 
@@ -76,10 +123,20 @@ class SysteminfoManager {
   wifi_rssi_level_e wifi_level_;
   double cpu_load_;
   unsigned long long available_capacity_internal_;
+  unsigned long long last_available_capacity_internal_;
   unsigned long long available_capacity_mmc_;
+  unsigned long long last_available_capacity_mmc_;
 
   int sim_count_;
   TapiHandle *tapi_handles_[kTapiMaxHandle+1];
+
+  std::set<std::string> registered_listeners_;
+
+  guint cpu_event_id_;
+  guint storage_event_id_;
+
+  connection_h connection_handle_;
+
 };
 } // namespace systeminfo
 } // namespace webapi
index cb7de0506657c8f714aa72eebdd7e041fe04ee55..c94becd7c01c1981f1c706f3e9758d9cbcd59a5d 100644 (file)
@@ -101,8 +101,8 @@ SysteminfoPropertiesManager::~SysteminfoPropertiesManager() {
 }
 
 PlatformResult SysteminfoPropertiesManager::GetPropertyValue(const std::string& property,
-                                                             bool is_array_type, picojson::value* res)
-{
+                                                             bool is_array_type,
+                                                             picojson::value* res) {
   LoggerD("Entered getPropertyValue");
 
   if (!is_array_type) {
@@ -323,8 +323,7 @@ PlatformResult SysteminfoPropertiesManager::ReportDisplay(picojson::object* out)
 }
 
 /// DEVICE_ORIENTATION
-PlatformResult SysteminfoPropertiesManager::FetchIsAutoRotation(bool* result)
-{
+PlatformResult SysteminfoPropertiesManager::FetchIsAutoRotation(bool* result) {
   LoggerD("Entered");
   int is_auto_rotation = 0;
 
@@ -344,8 +343,7 @@ PlatformResult SysteminfoPropertiesManager::FetchIsAutoRotation(bool* result)
   }
 }
 
-PlatformResult SysteminfoPropertiesManager::FetchStatus(std::string* result)
-{
+PlatformResult SysteminfoPropertiesManager::FetchStatus(std::string* result) {
   LoggerD("Entered");
   int rotation = 0;
   std::string status = kOrientationPortraitPrimary;
@@ -455,8 +453,7 @@ PlatformResult SysteminfoPropertiesManager::ReportLocale(picojson::object* out)
 }
 
 /// NETWORK
-static PlatformResult GetNetworkTypeString(NetworkType type, std::string& type_string)
-{
+static PlatformResult GetNetworkTypeString(NetworkType type, std::string& type_string) {
   switch (type) {
     case kNone:
       type_string = kNetworkTypeNone;
@@ -557,7 +554,7 @@ PlatformResult SysteminfoPropertiesManager::ReportNetwork(picojson::object* out)
 
 /// WIFI_NETWORK
 static PlatformResult GetIps(wifi_ap_h wifi_ap_handle, std::string* ip_addr_str,
-                   std::string* ipv6_addr_str){
+                   std::string* ipv6_addr_str) {
   //getting ipv4 address
   char* ip_addr = nullptr;
   int error = wifi_ap_get_ip_address(wifi_ap_handle,
@@ -830,8 +827,7 @@ static PlatformResult FetchBasicSimProperties(TapiHandle *tapi_handle,
     unsigned short *result_cell_id,
     unsigned short *result_lac,
     bool *result_is_roaming,
-    bool *result_is_flight_mode)
-{
+    bool *result_is_flight_mode) {
   LoggerD("Entered");
   int result_value = 0;
   int tapi_res = TAPI_API_SUCCESS;
@@ -878,8 +874,7 @@ static PlatformResult FetchBasicSimProperties(TapiHandle *tapi_handle,
 
 static PlatformResult FetchConnection(TapiHandle *tapi_handle, std::string* result_status,
                             std::string* result_apn, std::string* result_ip_address,
-                            std::string* result_ipv6_address, std::string* result_imei)
-{
+                            std::string* result_ipv6_address, std::string* result_imei) {
   LoggerD("Entered");
   connection_type_e connection_type = CONNECTION_TYPE_DISCONNECTED;
   connection_profile_h profile_handle = nullptr;