if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int(
SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, &physicalWidth)) {
LOGE("Cannot get value of phisical screen width");
- throw UnknownException("Cannot get value of phisical screen width");
+ //TODO uncomment when api would support this key
+ //throw UnknownException("Cannot get value of phisical screen width");
}
out.insert(std::make_pair("physicalWidth", std::to_string(physicalWidth)));
if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int(
SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, &physicalHeight)) {
LOGE("Cannot get value of phisical screen height");
- throw UnknownException("Cannot get value of phisical screen height");
+ //TODO uncomment when api would support this key
+ //throw UnknownException("Cannot get value of phisical screen height");
}
out.insert(std::make_pair("physicalHeight", std::to_string(physicalHeight)));
std::string result_ssid;
std::string result_ip_address;
std::string result_ipv6_address;
+ std::string result_mac_address;
double result_signal_strength = 0;
connection_h connection_handle = nullptr;
connection_handle_ptr(connection_handle, &connection_destroy);
// automatically release the memory
+ char* mac = NULL;
+ error = wifi_get_mac_address(&mac);
+ if(WIFI_ERROR_NONE == error) {
+ LOGD("macAddress fetched: %s", mac);
+ result_mac_address = mac;
+ free(mac);
+ } else {
+ std::string log_msg = "Failed to get mac address: " + std::to_string(error);
+ LOGE("%s", log_msg.c_str());
+ throw UnknownException(log_msg.c_str());
+ }
+
error = connection_get_type(connection_handle, &connection_type);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot get connection type: " + std::to_string(error);
out.insert(std::make_pair("ssid", result_ssid));
out.insert(std::make_pair("ipAddress", result_ip_address));
out.insert(std::make_pair("ipv6Address", result_ipv6_address));
+ out.insert(std::make_pair("macAddress", result_mac_address));
out.insert(std::make_pair("signalStrength", std::to_string(result_signal_strength)));
}
*value = SystemInfoDeviceCapability::GetProfile();
} else if (key == kTizenSystemDuid) {
*value = SystemInfoDeviceCapability::GetDuid();
- } else if (key == kTizenFeatureInputKeyboardLayout ||
- key == kTizenFeatureNativeApiVersion ||
- key == kTizenSystemPlatformVersion ||
- key == kTizenSystemPlatformWebApiVersion ||
- key == kTizenSystemPlatformName) {
+ } else {
try {
*value = GetValueString(key.substr(strlen("http://")).c_str());
} catch (...){
return false;
}
- } else {
- return false;
}
return true;
}
static bool CheckIntCapability(const std::string& key, std::string* value)
{
LOGD("Entered CheckIntCapability");
- if (key == kTizenFeatureMultitouchCount ||
- key == kTizenFeatureScreenBpp ||
- key == kTizenFeatureScreenDpi ||
- key == kTizenFeatureScreenHeight ||
- key == kTizenFeatureScreenWidth) {
try {
*value = std::to_string(GetValueInt(key.substr(strlen("http://")).c_str()));
return true;
} catch (...) {
//empty for purpose - ignore that key was not found
}
- }
return false;
}
result_obj.insert(std::make_pair("value", value));
} else {
LOGD("Value for given key was not found");
- throw UnknownException("Value for given key was not found");
+ throw NotSupportedException("Value for given key was not found");
}
result_obj.insert(std::make_pair("type", type));
};
Common.prototype.getTypeMismatch = function(msg) {
- _getTypeMismatch(msg);
+ return _getException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ msg || 'Provided arguments are not valid.');
};
Common.prototype.throwTypeMismatch = function(msg) {
};
Common.prototype.getInvalidValues = function(msg) {
- return _getException('InvalidValuesError',
+ return _getException(tizen.WebAPIException.INVALID_VALUES_ERR,
msg || 'There\'s a problem with input value.');
};
};
Common.prototype.getIOError = function (msg) {
- return _getException('IOError', msg || 'Unexpected IO error.');
+ return _getException(tizen.WebAPIException.IO_ERR, msg || 'Unexpected IO error.');
};
Common.prototype.throwIOError = function (msg) {
};
Common.prototype.getNotFound = function (msg) {
- return _getException('NotFoundError', msg || 'Not found.');
+ return _getException(tizen.WebAPIException.NOT_FOUND_ERR, msg || 'Not found.');
};
Common.prototype.throwNotFound = function (msg) {
};
Common.prototype.getUnknownError = function (msg) {
- return _getException('UnknownError', msg || 'Unknown error.');
+ return _getException(tizen.WebAPIException.UNKNOWN_ERR, msg || 'Unknown error.');
};
Common.prototype.throwUnknownError = function (msg) {
ssid : {value: data.ssid, writable: false, enumerable: true},
ipAddress : {value: data.ipAddress, writable: false, enumerable: true},
ipv6Address : {value: data.ipv6Address, writable: false, enumerable: true},
+ macAddress : {value: data.macAddress, writable: false, enumerable: true},
signalStrength : {value: Number(data.signalStrength), writable: false, enumerable: true}
});
}
//class SystemInfoMemory ////////////////////////////////////////////////////
function SystemInfoMemory(data) {
Object.defineProperties(this, {
- state : {value: data.state, writable: false, enumerable: true}
+ status : {value: data.state, writable: false, enumerable: true}
});
}
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);
var executeCall = (T.isUndefined(listener.lowThreshold) ||
(propObj.load <= listener.lowThreshold)) ||
(T.isUndefined(listener.highThreshold) ||
(propObj.load >= listener.highThreshold));
- var propObj = !listener.isArrayType ?
- _createProperty(property, eventObj.result.array[0]) :
- _createPropertyArray(property, eventObj.result);
if (executeCall) {
listener.callback(propObj);
}
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);
var executeCall = (T.isUndefined(listener.lowThreshold) ||
(propObj.brightness <= listener.lowThreshold)) ||
(T.isUndefined(listener.highThreshold) ||
(propObj.brightness >= listener.highThreshold));
- var propObj = !listener.isArrayType ?
- _createProperty(property, eventObj.result.array[0]) :
- _createPropertyArray(property, eventObj.result);
if (executeCall) {
listener.callback(propObj);
}
'SystemInfo_addPropertyValueChangeListener',
{property: Converter.toString(property)});
fail = C.isFailure(result);
- if (fail) {
+ if (C.isFailure(result)) {
setTimeout(function() {
C.callIfPossible(errorCallback, C.getErrorObject(result));
}, 0);
isArrayType : isArray,
highThreshold : !T.isNullOrUndefined(args.options) ?
args.options.highThreshold : undefined,
- lowThreshold : !T.isNullOrUndefined(args.options) ?
- args.options.lowThreshold : undefined
+ lowThreshold : !T.isNullOrUndefined(args.options) ?
+ args.options.lowThreshold : undefined
};
var watchId = _registerListener(args.property, listener, args.errorCallback);
SystemInfo.prototype.getCount = function() {
var args = AV.validateMethod(arguments, [
{
- name : 'key',
- type : AV.Types.STRING
+ name : 'property',
+ type : AV.Types.ENUM,
+ values : T.getValues(SystemInfoPropertyId)
}
]);
- var result = _callSync('SystemInfo_getCount', {key: args.key});
+ var result = _callSync('SystemInfo_getCount', {property: args.property});
if (C.isFailure(result)) {
throw C.getErrorObject(result);
}
SysteminfoUtils::RegisterDeviceOrientationListener(OnDeviceOrientationChangedCallback);
} else if (property_name == kPropertyIdBuild) {
LoggerW("BUILD property's value is a fixed value");
- throw NotSupportedException("BUILD property's value is a fixed value");
+ //should be accepted, but no registration is needed
+ //throw NotSupportedException("BUILD property's value is a fixed value");
} else if (property_name == kPropertyIdLocale) {
SysteminfoUtils::RegisterLocaleListener(OnLocaleChangedCallback);
} else if (property_name == kPropertyIdNetwork) {
void SysteminfoInstance::GetCount(const picojson::value& args, picojson::object& out) {
- const std::string& key = args.get("key").get<std::string>();
- LoggerD("Getting capability with key: %s ", key.c_str());
+ const std::string& property = args.get("property").get<std::string>();
+ LoggerD("Getting count of property with id: %s ", property.c_str());
picojson::value result = picojson::value(picojson::object());
picojson::object& result_obj = result.get<picojson::object>();
result_obj.insert(std::make_pair("count",
- static_cast<double>(SysteminfoUtils::GetCount(key)) ));
+ static_cast<double>(SysteminfoUtils::GetCount(property)) ));
ReportSuccess(result, out);
LoggerD("Success");
SysteminfoUtils::UnregisterDeviceOrientationListener();
} else if (property_name == kPropertyIdBuild) {
LoggerW("BUILD property's value is a fixed value");
- throw NotSupportedException("BUILD property's value is a fixed value");
+ //should be accepted, but no unregistration is needed
+ //throw NotSupportedException("BUILD property's value is a fixed value");
} else if (property_name == kPropertyIdLocale) {
SysteminfoUtils::UnregisterLocaleListener();
} else if (property_name == kPropertyIdNetwork) {