return PlatformResult(ErrorCode::NO_ERROR);
}
+PlatformResult SysteminfoUtils::GetServiceCountry(std::string *result) {
+ ScopeLogger();
+
+ char *country_code;
+ country_code = vconf_get_str("db/comss/countrycode");
+ if (nullptr != country_code) {
+ *result = country_code;
+ free(country_code);
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+ }
+ return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Property SERVICE_COUNTRY is Not Supported");
+}
+
PlatformResult SysteminfoUtils::GetAvailableMemory(long long *result) {
ScopeLogger();
static common::PlatformResult CheckCameraFlashSupport();
static common::PlatformResult CheckIfEthernetNetworkSupported();
static common::PlatformResult GetTotalMemory(long long *result);
+ static common::PlatformResult GetServiceCountry(std::string *result);
static common::PlatformResult GetAvailableMemory(long long *result);
static common::PlatformResult RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
void *event_ptr);
PERIPHERAL : 'PERIPHERAL',
MEMORY : 'MEMORY',
CAMERA_FLASH : 'CAMERA_FLASH',
- ADS : 'ADS'
+ ADS : 'ADS',
+ SERVICE_COUNTRY : 'SERVICE_COUNTRY'
};
var SystemInfoPropertyIdToFeature = {
});
}
+function SystemInfoServiceCountry(data) {
+ Object.defineProperties(this, {
+ serviceCountry : {value: data.serviceCountry, writable: false, enumerable: true},
+ });
+}
+
SystemInfoCameraFlash.prototype.setBrightness = function(brightness) {
var args = validator_.validateArgs(arguments, [
{name: 'brightness', type: types_.DOUBLE}
var _peripheralStr = SystemInfoPropertyId.PERIPHERAL;
var _memoryStr = SystemInfoPropertyId.MEMORY;
var _cameraFlashStr = SystemInfoPropertyId.CAMERA_FLASH;
+var _serviceCountryStr = SystemInfoPropertyId.SERVICE_COUNTRY;
var _nextId = 0;
}
}
+function _systeminfoServiceCountryListenerCallback(eventObj) {
+ var property = _serviceCountryStr;
+ var callbacks = _propertyContainer[property].callbacks;
+
+ for (var watchId in callbacks) {
+ if (callbacks.hasOwnProperty(watchId)) {
+ var listener = callbacks[watchId];
+ var propObj = !listener.isArrayType ?
+ _createProperty(property, eventObj.result.array[0]) :
+ _createPropertyArray(property, eventObj.result);
+ callbacks[watchId].callback(propObj);
+ }
+ }
+}
+
var _propertyContainer = {
'BATTERY' : {
callbacks : {},
constructor : SystemInfoADS,
broadcastFunction : function(){},
signalLabel : ''
+ },
+ 'SERVICE_COUNTRY' : {
+ callbacks : {},
+ constructor : SystemInfoServiceCountry,
+ broadcastFunction : _systeminfoServiceCountryListenerCallback,
+ signalLabel : 'SystemInfoServiceCountryChangeBroadcast'
}
};
const std::string kPropertyIdPeripheral = "PERIPHERAL";
const std::string kPropertyIdMemory = "MEMORY";
const std::string kPropertyIdCameraFlash = "CAMERA_FLASH";
+const std::string kPropertyIdServiceCountry = "SERVICE_COUNTRY";
#define CHECK_EXIST(args, name, out) \
if (!args.contains(name)) { \
manager->SetWifiLevel(rssi_level);
}
+static void OnServiceCountryChangedCb(keynode_t* key, void* user_data) {
+ ScopeLogger();
+ SysteminfoManager* manager = static_cast<SysteminfoManager*>(user_data);
+
+ manager->CallListenerCallback(kPropertyIdServiceCountry);
+}
+
} // namespace
class SysteminfoManager::TapiManager {
ret = RegisterMemoryListener();
} else if (property_name == kPropertyIdCameraFlash) {
ret = RegisterCameraFlashListener();
+ } else if (property_name == kPropertyIdServiceCountry) {
+ ret = RegisterServiceCountryListener();
} else {
ret = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
}
ret = UnregisterMemoryListener();
} else if (property_name == kPropertyIdCameraFlash) {
ret = UnregisterCameraFlashListener();
+ } else if (property_name == kPropertyIdServiceCountry) {
+ ret = UnregisterServiceCountryListener();
} else {
ret = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
}
return PlatformResult(ErrorCode::NO_ERROR);
}
+PlatformResult SysteminfoManager::RegisterServiceCountryListener() {
+ ScopeLogger();
+
+ int ret = vconf_notify_key_changed("db/comss/countrycode", OnServiceCountryChangedCb, this);
+ if (0 != ret) {
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "SERVICE_COUNTRY is not supported property.",
+ ("vconf_notify_key_changed error"));
+ }
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult SysteminfoManager::UnregisterServiceCountryListener() {
+ ScopeLogger();
+ int ret = vconf_ignore_key_changed("db/comss/countrycode", OnServiceCountryChangedCb);
+ if (0 != ret) {
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "SERVICE_COUNTRY is not supported property.",
+ ("vconf_ignore_key_changed error"));
+ }
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
void SysteminfoManager::SetBrightness(const picojson::value& args, picojson::object* out) {
ScopeLogger();
} else {
*count = kDefaultPropertyCount;
}
+ } else if (kPropertyIdServiceCountry == property) {
+ std::string tmp;
+ PlatformResult ret = SysteminfoUtils::GetServiceCountry(&tmp);
+ if (ret.IsError()) {
+ *count = 0;
+ } else {
+ *count = 1;
+ }
} else {
return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
"Property with given id is not supported",
common::PlatformResult UnregisterMemoryListener();
common::PlatformResult RegisterCameraFlashListener();
common::PlatformResult UnregisterCameraFlashListener();
+ common::PlatformResult RegisterServiceCountryListener();
+ common::PlatformResult UnregisterServiceCountryListener();
SysteminfoInstance* instance_;
SysteminfoPropertiesManager prop_manager_;
return ReportCameraFlash(res_obj, index);
} else if ("ADS" == property) {
return ReportAds(res_obj);
+ } else if ("SERVICE_COUNTRY" == property) {
+ return ReportServiceCountry(res_obj);
}
return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
"Property with given id is not supported");
return PlatformResult(ErrorCode::NO_ERROR);
}
+PlatformResult SysteminfoPropertiesManager::ReportServiceCountry(picojson::object* out) {
+ ScopeLogger();
+
+ std::string service_country;
+ PlatformResult ret = SysteminfoUtils::GetServiceCountry(&service_country);
+
+ if (ret.IsError()) {
+ return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR);
+ }
+
+ out->insert(std::make_pair("serviceCountry", picojson::value(service_country)));
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
} // namespace systeminfo
} // namespace webapi
common::PlatformResult ReportMemory(picojson::object* out);
common::PlatformResult ReportStorage(picojson::object* out);
common::PlatformResult ReportAds(picojson::object* out);
+ common::PlatformResult ReportServiceCountry(picojson::object* out);
common::PlatformResult FetchIsAutoRotation(bool* result);
common::PlatformResult FetchStatus(std::string* result);