From 62b4f1f6a28778a852a33bd0197e3e5e1abbb1dc Mon Sep 17 00:00:00 2001 From: Michal Michalski Date: Wed, 30 Oct 2019 18:14:54 +0100 Subject: [PATCH] [common] Simplify instance methods registration (5) + Macros REGISTER_(A)SYNC have been replaced with new macro REGISTER_METHOD, which takes only the method name. The string parameter is now created from the method name. [Verification] + tct-sensor-tizen-tests 100% pass (mobile) + tct-sound-tizen-tests 100% pass (mobile) + tct-systeminfo-tizen-tests 100% pass (mobile) + tct-systemsetting-tizen-tests 100% pass (mobile) + tct-time-tizen-tests 100% pass (mobile) + !!! utils module has no tests !!! + tct-voicecontrol-tizen-tests 100% pass (mobile) + tct-widgetservice-tizen-tests 100% pass (tw3) Signed-off-by: Michal Michalski Change-Id: I41180f982002e547080f9c311e82cf468fadbd05 --- src/sensor/sensor_api.js | 14 ++-- src/sensor/sensor_instance.cc | 25 +++--- src/sensor/sensor_instance.h | 4 +- src/sound/sound_api.js | 22 ++--- src/sound/sound_instance.cc | 31 ++++--- src/systeminfo/systeminfo_api.js | 24 +++--- src/systeminfo/systeminfo_instance.cc | 57 +++++++------ src/systeminfo/systeminfo_instance.h | 24 +++--- src/systemsetting/systemsetting_api.js | 4 +- src/systemsetting/systemsetting_instance.cc | 15 ++-- src/systemsetting/systemsetting_instance.h | 4 +- src/time/time_api.js | 38 ++++----- src/time/time_instance.cc | 89 ++++++++++----------- src/time/time_instance.h | 38 ++++----- src/utils/utils_api.js | 12 +-- src/utils/utils_instance.cc | 36 ++++----- src/utils/utils_instance.h | 12 +-- src/voicecontrol/voicecontrol_api.js | 18 ++--- src/voicecontrol/voicecontrol_instance.cc | 43 +++++----- src/voicecontrol/voicecontrol_instance.h | 20 ++--- src/widgetservice/widgetservice_api.js | 26 +++--- src/widgetservice/widgetservice_instance.cc | 67 ++++++++-------- src/widgetservice/widgetservice_instance.h | 26 +++--- 23 files changed, 318 insertions(+), 331 deletions(-) diff --git a/src/sensor/sensor_api.js b/src/sensor/sensor_api.js index 1d8466a0..68977edb 100755 --- a/src/sensor/sensor_api.js +++ b/src/sensor/sensor_api.js @@ -79,7 +79,7 @@ SensorListener.prototype.start = function(successCallback, errorCallback) { // sensor not started this.state = SensorStates.STARTING; var thisObject = this; - native_.call('Sensor_start', { sensorType: thisObject.sensorType }, function( + native_.call('SensorStart', { sensorType: thisObject.sensorType }, function( result ) { if (native_.isFailure(result)) { @@ -102,7 +102,7 @@ SensorListener.prototype.start = function(successCallback, errorCallback) { SensorListener.prototype.stop = function() { if (SensorStates.NOT_STARTED != this.state) { - var result = native_.callSync('Sensor_stop', { sensorType: this.sensorType }); + var result = native_.callSync('SensorStop', { sensorType: this.sensorType }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -117,7 +117,7 @@ SensorListener.prototype.setListener = function(successCallback, interval, batch this.callbackBatchLatency != batchLatency ) { //call platform only if there was no listener registered or parameters changed - var result = native_.callSync('Sensor_setChangeListener', { + var result = native_.callSync('SensorSetChangeListener', { sensorType: this.sensorType, interval: interval, batchLatency: batchLatency @@ -136,7 +136,7 @@ SensorListener.prototype.unsetListener = function() { if (this.callback) { //unregister in platform only if there is callback registered this.callback = undefined; - var result = native_.callSync('Sensor_unsetChangeListener', { + var result = native_.callSync('SensorUnsetChangeListener', { sensorType: this.sensorType }); if (native_.isFailure(result)) { @@ -159,7 +159,7 @@ SensorListener.prototype.getData = function(successCallback, errorCallback) { } }, 0); } else { - native_.call('Sensor_getData', { type: thisObj.sensorType }, function(result) { + native_.call('SensorGetData', { type: thisObj.sensorType }, function(result) { if (native_.isFailure(result)) { if (!T_.isNullOrUndefined(errorCallback)) { errorCallback(native_.getErrorObject(result)); @@ -208,7 +208,7 @@ var SENSOR_CHANGED_LISTENER = 'SensorChangedListener'; native_.addListener(SENSOR_CHANGED_LISTENER, _listener); function getAvailableSensors() { - var result = native_.callSync('SensorService_getAvailableSensors', {}); + var result = native_.callSync('SensorServiceGetAvailableSensors', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -371,7 +371,7 @@ Sensor.prototype.getSensorHardwareInfo = function() { }; var result = native_.call( - 'Sensor_getSensorHardwareInfo', + 'SensorGetSensorHardwareInfo', { type: this.sensorType }, callback ); diff --git a/src/sensor/sensor_instance.cc b/src/sensor/sensor_instance.cc index b137ef0f..102a955d 100644 --- a/src/sensor/sensor_instance.cc +++ b/src/sensor/sensor_instance.cc @@ -30,24 +30,23 @@ SensorInstance::SensorInstance() : service_(*this) { using std::placeholders::_1; using std::placeholders::_2; -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&SensorInstance::x, this, _1, _2)); - REGISTER_SYNC("SensorService_getAvailableSensors", GetAvailableSensors); - REGISTER_SYNC("Sensor_stop", SensorStop); - REGISTER_SYNC("Sensor_setChangeListener", SensorSetChangeListener); - REGISTER_SYNC("Sensor_unsetChangeListener", SensorUnsetChangeListener); -#undef REGISTER_SYNC -#define REGISTER_ASYNC(c, x) RegisterSyncHandler(c, std::bind(&SensorInstance::x, this, _1, _2)); - REGISTER_ASYNC("Sensor_start", SensorStart); - REGISTER_ASYNC("Sensor_getData", SensorGetData); - REGISTER_ASYNC("Sensor_getSensorHardwareInfo", GetSensorHardwareInfo); -#undef REGISTER_ASYNC +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&SensorInstance::M, this, _1, _2)) + REGISTER_METHOD(SensorServiceGetAvailableSensors); + REGISTER_METHOD(SensorStop); + REGISTER_METHOD(SensorSetChangeListener); + REGISTER_METHOD(SensorUnsetChangeListener); + REGISTER_METHOD(SensorStart); + REGISTER_METHOD(SensorGetData); + REGISTER_METHOD(SensorGetSensorHardwareInfo); +#undef REGISTER_METHOD } SensorInstance::~SensorInstance() { ScopeLogger(); } -void SensorInstance::GetAvailableSensors(const picojson::value& args, picojson::object& out) { +void SensorInstance::SensorServiceGetAvailableSensors(const picojson::value& args, picojson::object& out) { ScopeLogger(); service_.GetAvailableSensors(out); } @@ -78,7 +77,7 @@ void SensorInstance::SensorGetData(const picojson::value& args, picojson::object service_.GetSensorData(args, out); } -void SensorInstance::GetSensorHardwareInfo(const picojson::value& args, picojson::object& out) { +void SensorInstance::SensorGetSensorHardwareInfo(const picojson::value& args, picojson::object& out) { ScopeLogger(); service_.GetSensorHardwareInfo(args, out); diff --git a/src/sensor/sensor_instance.h b/src/sensor/sensor_instance.h index 5abc2a75..9dd1a854 100644 --- a/src/sensor/sensor_instance.h +++ b/src/sensor/sensor_instance.h @@ -30,13 +30,13 @@ class SensorInstance : public common::ParsedInstance { virtual ~SensorInstance(); private: - void GetAvailableSensors(const picojson::value& args, picojson::object& out); + void SensorServiceGetAvailableSensors(const picojson::value& args, picojson::object& out); void SensorStop(const picojson::value& args, picojson::object& out); void SensorSetChangeListener(const picojson::value& args, picojson::object& out); void SensorUnsetChangeListener(const picojson::value& args, picojson::object& out); void SensorStart(const picojson::value& args, picojson::object& out); void SensorGetData(const picojson::value& args, picojson::object& out); - void GetSensorHardwareInfo(const picojson::value& args, picojson::object& out); + void SensorGetSensorHardwareInfo(const picojson::value& args, picojson::object& out); SensorService service_; }; diff --git a/src/sound/sound_api.js b/src/sound/sound_api.js index 7c3c86d2..fb0c376f 100644 --- a/src/sound/sound_api.js +++ b/src/sound/sound_api.js @@ -67,7 +67,7 @@ ListenerManager.prototype.addListener = function(callback) { var id = this.nextId; if (!this.nativeSet) { this.native.addListener(this.listenerName, this.onListenerCalled.bind(this)); - this.native.callSync('SoundManager_addDeviceStateChangeListener'); + this.native.callSync('SoundManagerAddDeviceStateChangeListener'); this.nativeSet = true; } @@ -85,7 +85,7 @@ ListenerManager.prototype.removeListener = function(watchId) { delete this.listeners[watchId]; if (this.nativeSet && type_.isEmptyObject(this.listeners)) { - this.native.callSync('SoundManager_removeDeviceStateChangeListener'); + this.native.callSync('SoundManagerRemoveDeviceStateChangeListener'); this.native.removeListener(this.listenerName); this.nativeSet = false; } @@ -100,7 +100,7 @@ var soundDeviceStateChangeListener = new ListenerManager( function SoundManager() {} SoundManager.prototype.getSoundMode = function() { - var result = native_.callSync('SoundManager_getSoundMode'); + var result = native_.callSync('SoundManagerGetSoundMode'); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -117,7 +117,7 @@ SoundManager.prototype.setVolume = function(type, volume) { if (args.volume < 0 || args.volume > 1) { throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } - var result = native_.callSync('SoundManager_setVolume', args); + var result = native_.callSync('SoundManagerSetVolume', args); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -128,7 +128,7 @@ SoundManager.prototype.getVolume = function(type) { { name: 'type', type: types_.ENUM, values: Object.keys(SoundType) } ]); - var result = native_.callSync('SoundManager_getVolume', args); + var result = native_.callSync('SoundManagerGetVolume', args); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -166,7 +166,7 @@ SoundManager.prototype.setSoundModeChangeListener = function(callback) { _soundModeChangeListener = args.callback; native_.addListener('SoundModeChangeListener', _soundModeChangeListenerCallback); - var result = native_.callSync('SoundManager_setSoundModeChangeListener', {}); + var result = native_.callSync('SoundManagerSetSoundModeChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -176,7 +176,7 @@ SoundManager.prototype.setSoundModeChangeListener = function(callback) { SoundManager.prototype.unsetSoundModeChangeListener = function() { native_.removeListener('SoundModeChangeListener', _soundModeChangeListenerCallback); - var result = native_.callSync('SoundManager_unsetSoundModeChangeListener', {}); + var result = native_.callSync('SoundManagerUnsetSoundModeChangeListener', {}); _soundModeChangeListener = undefined; @@ -199,7 +199,7 @@ SoundManager.prototype.setVolumeChangeListener = function(callback) { _volumeChangeListener = args.callback; native_.addListener('VolumeChangeListener', _volumeChangeListenerCallback); - var result = native_.callSync('SoundManager_setVolumeChangeListener', {}); + var result = native_.callSync('SoundManagerSetVolumeChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -209,7 +209,7 @@ SoundManager.prototype.setVolumeChangeListener = function(callback) { SoundManager.prototype.unsetVolumeChangeListener = function() { native_.removeListener('VolumeChangeListener', _volumeChangeListenerCallback); - var result = native_.callSync('SoundManager_unsetVolumeChangeListener', {}); + var result = native_.callSync('SoundManagerUnsetVolumeChangeListener', {}); _volumeChangeListener = undefined; @@ -219,7 +219,7 @@ SoundManager.prototype.unsetVolumeChangeListener = function() { }; SoundManager.prototype.getConnectedDeviceList = function() { - var result = native_.callSync('SoundManager_getConnectedDeviceList', {}); + var result = native_.callSync('SoundManagerGetConnectedDeviceList', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -229,7 +229,7 @@ SoundManager.prototype.getConnectedDeviceList = function() { }; SoundManager.prototype.getActivatedDeviceList = function() { - var result = native_.callSync('SoundManager_getActivatedDeviceList', {}); + var result = native_.callSync('SoundManagerGetActivatedDeviceList', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } diff --git a/src/sound/sound_instance.cc b/src/sound/sound_instance.cc index c45e7d67..fae03617 100644 --- a/src/sound/sound_instance.cc +++ b/src/sound/sound_instance.cc @@ -41,22 +41,21 @@ SoundInstance::SoundInstance() : manager_(*this) { using std::placeholders::_1; using std::placeholders::_2; -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&SoundInstance::x, this, _1, _2)); - REGISTER_SYNC("SoundManager_setVolume", SoundManagerSetVolume); - REGISTER_SYNC("SoundManager_unsetSoundModeChangeListener", - SoundManagerUnsetSoundModeChangeListener); - REGISTER_SYNC("SoundManager_getVolume", SoundManagerGetVolume); - REGISTER_SYNC("SoundManager_unsetVolumeChangeListener", SoundManagerUnsetVolumeChangeListener); - REGISTER_SYNC("SoundManager_setSoundModeChangeListener", SoundManagerSetSoundModeChangeListener); - REGISTER_SYNC("SoundManager_setVolumeChangeListener", SoundManagerSetVolumeChangeListener); - REGISTER_SYNC("SoundManager_getSoundMode", SoundManagerGetSoundMode); - REGISTER_SYNC("SoundManager_getConnectedDeviceList", SoundManagerGetConnectedDeviceList); - REGISTER_SYNC("SoundManager_getActivatedDeviceList", SoundManagerGetActivatedDeviceList); - REGISTER_SYNC("SoundManager_addDeviceStateChangeListener", - SoundManagerAddDeviceStateChangeListener); - REGISTER_SYNC("SoundManager_removeDeviceStateChangeListener", - SoundManagerRemoveDeviceStateChangeListener); -#undef REGISTER_SYNC + +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&SoundInstance::M, this, _1, _2)) + REGISTER_METHOD(SoundManagerSetVolume); + REGISTER_METHOD(SoundManagerUnsetSoundModeChangeListener); + REGISTER_METHOD(SoundManagerGetVolume); + REGISTER_METHOD(SoundManagerUnsetVolumeChangeListener); + REGISTER_METHOD(SoundManagerSetSoundModeChangeListener); + REGISTER_METHOD(SoundManagerSetVolumeChangeListener); + REGISTER_METHOD(SoundManagerGetSoundMode); + REGISTER_METHOD(SoundManagerGetConnectedDeviceList); + REGISTER_METHOD(SoundManagerGetActivatedDeviceList); + REGISTER_METHOD(SoundManagerAddDeviceStateChangeListener); + REGISTER_METHOD(SoundManagerRemoveDeviceStateChangeListener); +#undef REGISTER_METHOD } SoundInstance::~SoundInstance() { diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index ad714e8f..c5f61387 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -738,7 +738,7 @@ function SystemInfoMemory(data) { function SystemInfoCameraFlash(data) { var getBrightness = function() { - var result = native_.callSync('SystemInfo_getBrightness', {}); + var result = native_.callSync('SystemInfoGetBrightness', {}); if (native_.isSuccess(result)) { return Converter_.toLong(native_.getResultObject(result)) / this.levels; } @@ -746,7 +746,7 @@ function SystemInfoCameraFlash(data) { }; var getLevels = function() { - var result = native_.callSync('SystemInfo_getMaxBrightness', {}); + var result = native_.callSync('SystemInfoGetMaxBrightness', {}); if (native_.isSuccess(result)) { return Converter_.toLong(native_.getResultObject(result)); } @@ -784,7 +784,7 @@ SystemInfoCameraFlash.prototype.setBrightness = function(brightness) { ); args.brightness = args.brightness * this.levels; - var result = native_.callSync('SystemInfo_setBrightness', args); + var result = native_.callSync('SystemInfoSetBrightness', args); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -800,7 +800,7 @@ SystemInfo.prototype.getCapabilities = function() { 'from next release. Use getCapability() instead.' ); - var result = native_.callSync('SystemInfo_getCapabilities', {}); + var result = native_.callSync('SystemInfoGetCapabilities', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -816,7 +816,7 @@ SystemInfo.prototype.getCapability = function() { } ]); - var result = native_.callSync('SystemInfo_getCapability', { key: args.key }); + var result = native_.callSync('SystemInfoGetCapability', { key: args.key }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -935,14 +935,14 @@ var getPropertyFunction = function(cppLabel, objectCreateFunction) { }; SystemInfo.prototype.getPropertyValue = function() { - getPropertyFunction('SystemInfo_getPropertyValue', _createProperty).apply( + getPropertyFunction('SystemInfoGetPropertyValue', _createProperty).apply( this, arguments ); }; SystemInfo.prototype.getPropertyValueArray = function() { - getPropertyFunction('SystemInfo_getPropertyValueArray', _createPropertyArray).apply( + getPropertyFunction('SystemInfoGetPropertyValueArray', _createPropertyArray).apply( this, arguments ); @@ -1408,7 +1408,7 @@ var _registerListener = function(property, listener, errorCallback) { var fail = false; if (T_.isEmptyObject(callbacksMap)) { //registration in C++ layer - result = native_.callSync('SystemInfo_addPropertyValueChangeListener', { + result = native_.callSync('SystemInfoAddPropertyValueChangeListener', { property: Converter_.toString(property) }); fail = native_.isFailure(result); @@ -1461,7 +1461,7 @@ var _unregisterListener = function(watchId, isTimeout) { delete callbacksMap[Number(watchId)]; if (T_.isEmptyObject(callbacksMap)) { //unregistration in C++ layer - result = native_.callSync('SystemInfo_removePropertyValueChangeListener', { + result = native_.callSync('SystemInfoRemovePropertyValueChangeListener', { property: Converter_.toString(property) }); if (native_.isFailure(result)) { @@ -1553,7 +1553,7 @@ SystemInfo.prototype.removePropertyValueChangeListener = function() { }; SystemInfo.prototype.getTotalMemory = function() { - var result = native_.callSync('SystemInfo_getTotalMemory', {}); + var result = native_.callSync('SystemInfoGetTotalMemory', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -1561,7 +1561,7 @@ SystemInfo.prototype.getTotalMemory = function() { }; SystemInfo.prototype.getAvailableMemory = function() { - var result = native_.callSync('SystemInfo_getAvailableMemory', {}); + var result = native_.callSync('SystemInfoGetAvailableMemory', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -1577,7 +1577,7 @@ SystemInfo.prototype.getCount = function() { } ]); - var result = native_.callSync('SystemInfo_getCount', { property: args.property }); + var result = native_.callSync('SystemInfoGetCount', { property: args.property }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } diff --git a/src/systeminfo/systeminfo_instance.cc b/src/systeminfo/systeminfo_instance.cc index f8818d79..8ebbe676 100644 --- a/src/systeminfo/systeminfo_instance.cc +++ b/src/systeminfo/systeminfo_instance.cc @@ -54,31 +54,28 @@ SysteminfoInstance::SysteminfoInstance() : manager_(this) { using std::placeholders::_1; using std::placeholders::_2; -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&SysteminfoInstance::x, this, _1, _2)); - REGISTER_SYNC("SystemInfo_getCapabilities", GetCapabilities); - REGISTER_SYNC("SystemInfo_getCapability", GetCapability); - REGISTER_SYNC("SystemInfo_addPropertyValueChangeListener", AddPropertyValueChangeListener); - REGISTER_SYNC("SystemInfo_removePropertyValueChangeListener", RemovePropertyValueChangeListener); - REGISTER_SYNC("SystemInfo_getTotalMemory", GetTotalMemory); - REGISTER_SYNC("SystemInfo_getAvailableMemory", GetAvailableMemory); - REGISTER_SYNC("SystemInfo_getCount", GetCount); - REGISTER_SYNC("SystemInfo_setBrightness", SetBrightness); - REGISTER_SYNC("SystemInfo_getBrightness", GetBrightness); - REGISTER_SYNC("SystemInfo_getMaxBrightness", GetMaxBrightness); - -#undef REGISTER_SYNC -#define REGISTER_ASYNC(c, x) \ - RegisterSyncHandler(c, std::bind(&SysteminfoInstance::x, this, _1, _2)); - REGISTER_ASYNC("SystemInfo_getPropertyValue", GetPropertyValue); - REGISTER_ASYNC("SystemInfo_getPropertyValueArray", GetPropertyValueArray); -#undef REGISTER_ASYNC +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&SysteminfoInstance::M, this, _1, _2)) + REGISTER_METHOD(SystemInfoGetCapabilities); + REGISTER_METHOD(SystemInfoGetCapability); + REGISTER_METHOD(SystemInfoAddPropertyValueChangeListener); + REGISTER_METHOD(SystemInfoRemovePropertyValueChangeListener); + REGISTER_METHOD(SystemInfoGetTotalMemory); + REGISTER_METHOD(SystemInfoGetAvailableMemory); + REGISTER_METHOD(SystemInfoGetCount); + REGISTER_METHOD(SystemInfoSetBrightness); + REGISTER_METHOD(SystemInfoGetBrightness); + REGISTER_METHOD(SystemInfoGetMaxBrightness); + REGISTER_METHOD(SystemInfoGetPropertyValue); + REGISTER_METHOD(SystemInfoGetPropertyValueArray); +#undef REGISTER_METHOD } SysteminfoInstance::~SysteminfoInstance() { ScopeLogger(); } -void SysteminfoInstance::GetCapabilities(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetCapabilities(const picojson::value& args, picojson::object& out) { ScopeLogger(); LoggerW( "DEPRECATION WARNING: getCapabilities() is deprecated and will be removed from next release. " @@ -87,49 +84,49 @@ void SysteminfoInstance::GetCapabilities(const picojson::value& args, picojson:: manager_.GetCapabilities(args, &out); } -void SysteminfoInstance::GetCapability(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetCapability(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetCapability(args, &out); } -void SysteminfoInstance::GetPropertyValue(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetPropertyValue(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetPropertyValue(args, &out); } -void SysteminfoInstance::GetPropertyValueArray(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetPropertyValueArray(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetPropertyValueArray(args, &out); } -void SysteminfoInstance::AddPropertyValueChangeListener(const picojson::value& args, +void SysteminfoInstance::SystemInfoAddPropertyValueChangeListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.AddPropertyValueChangeListener(args, &out); } -void SysteminfoInstance::RemovePropertyValueChangeListener(const picojson::value& args, +void SysteminfoInstance::SystemInfoRemovePropertyValueChangeListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.RemovePropertyValueChangeListener(args, &out); } -void SysteminfoInstance::GetTotalMemory(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetTotalMemory(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetTotalMemory(args, &out); } -void SysteminfoInstance::GetAvailableMemory(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetAvailableMemory(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetAvailableMemory(args, &out); } -void SysteminfoInstance::GetCount(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetCount(const picojson::value& args, picojson::object& out) { ScopeLogger(); manager_.GetCount(args, &out); } -void SysteminfoInstance::SetBrightness(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoSetBrightness(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeLED, &out); @@ -153,7 +150,7 @@ void SysteminfoInstance::SetBrightness(const picojson::value& args, picojson::ob ReportSuccess(out); } -void SysteminfoInstance::GetBrightness(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetBrightness(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeLED, &out); @@ -169,7 +166,7 @@ void SysteminfoInstance::GetBrightness(const picojson::value& args, picojson::ob ReportSuccess(picojson::value(std::to_string(brightness)), out); } -void SysteminfoInstance::GetMaxBrightness(const picojson::value& args, picojson::object& out) { +void SysteminfoInstance::SystemInfoGetMaxBrightness(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeLED, &out); diff --git a/src/systeminfo/systeminfo_instance.h b/src/systeminfo/systeminfo_instance.h index 95e7550e..4025fd0b 100644 --- a/src/systeminfo/systeminfo_instance.h +++ b/src/systeminfo/systeminfo_instance.h @@ -29,18 +29,18 @@ class SysteminfoInstance : public common::ParsedInstance { virtual ~SysteminfoInstance(); private: - void GetCapabilities(const picojson::value& args, picojson::object& out); - void GetCapability(const picojson::value& args, picojson::object& out); - void GetPropertyValue(const picojson::value& args, picojson::object& out); - void GetPropertyValueArray(const picojson::value& args, picojson::object& out); - void AddPropertyValueChangeListener(const picojson::value& args, picojson::object& out); - void RemovePropertyValueChangeListener(const picojson::value& args, picojson::object& out); - void GetMaxBrightness(const picojson::value& args, picojson::object& out); - void GetBrightness(const picojson::value& args, picojson::object& out); - void SetBrightness(const picojson::value& args, picojson::object& out); - void GetTotalMemory(const picojson::value& args, picojson::object& out); - void GetAvailableMemory(const picojson::value& args, picojson::object& out); - void GetCount(const picojson::value& args, picojson::object& out); + void SystemInfoGetCapabilities(const picojson::value& args, picojson::object& out); + void SystemInfoGetCapability(const picojson::value& args, picojson::object& out); + void SystemInfoGetPropertyValue(const picojson::value& args, picojson::object& out); + void SystemInfoGetPropertyValueArray(const picojson::value& args, picojson::object& out); + void SystemInfoAddPropertyValueChangeListener(const picojson::value& args, picojson::object& out); + void SystemInfoRemovePropertyValueChangeListener(const picojson::value& args, picojson::object& out); + void SystemInfoGetMaxBrightness(const picojson::value& args, picojson::object& out); + void SystemInfoGetBrightness(const picojson::value& args, picojson::object& out); + void SystemInfoSetBrightness(const picojson::value& args, picojson::object& out); + void SystemInfoGetTotalMemory(const picojson::value& args, picojson::object& out); + void SystemInfoGetAvailableMemory(const picojson::value& args, picojson::object& out); + void SystemInfoGetCount(const picojson::value& args, picojson::object& out); SysteminfoManager manager_; }; diff --git a/src/systemsetting/systemsetting_api.js b/src/systemsetting/systemsetting_api.js index 630bb342..0b9439a6 100644 --- a/src/systemsetting/systemsetting_api.js +++ b/src/systemsetting/systemsetting_api.js @@ -47,7 +47,7 @@ SystemSettingManager.prototype.getProperty = function() { type: args.type }; - var result = native_.call('SystemSettingManager_getProperty', callArgs, callback); + var result = native_.call('SystemSettingManagerGetProperty', callArgs, callback); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -75,7 +75,7 @@ SystemSettingManager.prototype.setProperty = function() { value: args.value }; - var result = native_.call('SystemSettingManager_setProperty', callArgs, callback); + var result = native_.call('SystemSettingManagerSetProperty', callArgs, callback); if (native_.isFailure(result)) { throw native_.getErrorObject(result); diff --git a/src/systemsetting/systemsetting_instance.cc b/src/systemsetting/systemsetting_instance.cc index 55c58af5..34267dca 100644 --- a/src/systemsetting/systemsetting_instance.cc +++ b/src/systemsetting/systemsetting_instance.cc @@ -47,19 +47,18 @@ SystemSettingInstance::SystemSettingInstance() { using std::placeholders::_1; using std::placeholders::_2; -#define REGISTER(c, x) RegisterSyncHandler(c, std::bind(&SystemSettingInstance::x, this, _1, _2)); - - REGISTER("SystemSettingManager_getProperty", getProperty); - REGISTER("SystemSettingManager_setProperty", setProperty); - -#undef REGISTER +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&SystemSettingInstance::M, this, _1, _2)) + REGISTER_METHOD(SystemSettingManagerGetProperty); + REGISTER_METHOD(SystemSettingManagerSetProperty); +#undef REGISTER_METHOD } SystemSettingInstance::~SystemSettingInstance() { ScopeLogger(); } -void SystemSettingInstance::getProperty(const picojson::value& args, picojson::object& out) { +void SystemSettingInstance::SystemSettingManagerGetProperty(const picojson::value& args, picojson::object& out) { ScopeLogger(); const double callback_id = args.get("callbackId").get(); @@ -129,7 +128,7 @@ PlatformResult SystemSettingInstance::getPlatformPropertyValue(const std::string } } -void SystemSettingInstance::setProperty(const picojson::value& args, picojson::object& out) { +void SystemSettingInstance::SystemSettingManagerSetProperty(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeSetting, &out); diff --git a/src/systemsetting/systemsetting_instance.h b/src/systemsetting/systemsetting_instance.h index 799d3caf..c464061c 100644 --- a/src/systemsetting/systemsetting_instance.h +++ b/src/systemsetting/systemsetting_instance.h @@ -29,11 +29,11 @@ class SystemSettingInstance : public common::ParsedInstance { virtual ~SystemSettingInstance(); private: - void getProperty(const picojson::value& args, picojson::object& out); + void SystemSettingManagerGetProperty(const picojson::value& args, picojson::object& out); common::PlatformResult getPlatformPropertyValue(const std::string& valueType, picojson::value* out); - void setProperty(const picojson::value& args, picojson::object& out); + void SystemSettingManagerSetProperty(const picojson::value& args, picojson::object& out); common::PlatformResult setPlatformPropertyValue(const std::string& settingType, const std::string& settingValue); }; diff --git a/src/time/time_api.js b/src/time/time_api.js index 9839b387..1531f616 100644 --- a/src/time/time_api.js +++ b/src/time/time_api.js @@ -57,7 +57,7 @@ function _getTimezoneOffset(timestamp, tzName) { timezone: converter_.toString(tzName), timestamp: converter_.toString(timestamp) }; - var result = native_.callSync('TZDate_getTimezoneOffset', callArgs); + var result = native_.callSync('TZDateGetTimezoneOffset', callArgs); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -484,7 +484,7 @@ tizen.TZDate.prototype.addDuration = function() { tizen.TZDate.prototype.toLocaleDateString = function() { utils_.log('Entered TZDate.toLocaleDateString'); - var result = native_.callSync('TZDate_toLocaleDateString', { + var result = native_.callSync('TZDateToLocaleDateString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -496,7 +496,7 @@ tizen.TZDate.prototype.toLocaleDateString = function() { tizen.TZDate.prototype.toLocaleTimeString = function() { utils_.log('Entered TZDate.toLocaleTimeString'); - var result = native_.callSync('TZDate_toLocaleTimeString', { + var result = native_.callSync('TZDateToLocaleTimeString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -508,7 +508,7 @@ tizen.TZDate.prototype.toLocaleTimeString = function() { tizen.TZDate.prototype.toLocaleString = function() { utils_.log('Entered TZDate.toLocaleString'); - var result = native_.callSync('TZDate_toLocaleString', { + var result = native_.callSync('TZDateToLocaleString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -520,7 +520,7 @@ tizen.TZDate.prototype.toLocaleString = function() { tizen.TZDate.prototype.toDateString = function() { utils_.log('Entered TZDate.toDateString'); - var result = native_.callSync('TZDate_toDateString', { + var result = native_.callSync('TZDateToDateString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -532,7 +532,7 @@ tizen.TZDate.prototype.toDateString = function() { tizen.TZDate.prototype.toTimeString = function() { utils_.log('Entered TZDate.toTimeString'); - var result = native_.callSync('TZDate_toTimeString', { + var result = native_.callSync('TZDateToTimeString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -544,7 +544,7 @@ tizen.TZDate.prototype.toTimeString = function() { tizen.TZDate.prototype.toString = function() { utils_.log('Entered TZDate.toString'); - var result = native_.callSync('TZDate_toString', { + var result = native_.callSync('TZDateToString', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -561,7 +561,7 @@ tizen.TZDate.prototype.getTimezoneAbbreviation = function() { 'removed from next release.' ); - var result = native_.callSync('TZDate_getTimezoneAbbreviation', { + var result = native_.callSync('TZDateGetTimezoneAbbreviation', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -578,7 +578,7 @@ tizen.TZDate.prototype.secondsFromUTC = function() { tizen.TZDate.prototype.isDST = function() { utils_.log('Entered TZDate.isDST'); - var result = native_.callSync('TZDate_isDST', { + var result = native_.callSync('TZDateIsDST', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -590,7 +590,7 @@ tizen.TZDate.prototype.isDST = function() { tizen.TZDate.prototype.getPreviousDSTTransition = function() { utils_.log('Entered TZDate.getPreviousDSTTransition'); - var result = native_.callSync('TZDate_getPreviousDSTTransition', { + var result = native_.callSync('TZDateGetPreviousDSTTransition', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -605,7 +605,7 @@ tizen.TZDate.prototype.getPreviousDSTTransition = function() { tizen.TZDate.prototype.getNextDSTTransition = function() { utils_.log('Entered TZDate.getNextDSTTransition'); - var result = native_.callSync('TZDate_getNextDSTTransition', { + var result = native_.callSync('TZDateGetNextDSTTransition', { timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp) }); @@ -809,7 +809,7 @@ exports.getCurrentDateTime = function() { exports.getLocalTimezone = function() { utils_.log('Entered TimeUtil.getLocalTimezone'); - var result = native_.callSync('TZDate_getLocalTimezone', {}); + var result = native_.callSync('TZDateGetLocalTimezone', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -821,7 +821,7 @@ var _availableTimezones = []; //an array for holding available timezones exports.getAvailableTimezones = function() { utils_.log('Entered TimeUtil.getAvailableTimezones'); if (_availableTimezones.length === 0) { - var result = native_.callSync('TimeUtil_getAvailableTimezones', {}); + var result = native_.callSync('TimeUtilGetAvailableTimezones', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -847,7 +847,7 @@ exports.getDateFormat = function() { args.shortformat = false; } - var result = native_.callSync('TimeUtil_getDateFormat', { + var result = native_.callSync('TimeUtilGetDateFormat', { shortformat: args.shortformat }); if (native_.isFailure(result)) { @@ -858,7 +858,7 @@ exports.getDateFormat = function() { exports.getTimeFormat = function() { utils_.log('Entered TimeUtil.getTimeFormat'); - var result = native_.callSync('TimeUtil_getTimeFormat', {}); + var result = native_.callSync('TimeUtilGetTimeFormat', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -893,7 +893,7 @@ exports.setDateTimeChangeListener = function() { type: validator_.Types.FUNCTION } ]); - var result = native_.callSync('TimeUtil_setDateTimeChangeListener', {}); + var result = native_.callSync('TimeUtilSetDateTimeChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -903,7 +903,7 @@ exports.setDateTimeChangeListener = function() { exports.unsetDateTimeChangeListener = function() { utils_.log('Entered TimeUtil.unsetDateTimeChangeListener'); - var result = native_.callSync('TimeUtil_unsetDateTimeChangeListener', {}); + var result = native_.callSync('TimeUtilUnsetDateTimeChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -925,7 +925,7 @@ exports.setTimezoneChangeListener = function() { type: validator_.Types.FUNCTION } ]); - var result = native_.callSync('TimeUtil_setTimezoneChangeListener', {}); + var result = native_.callSync('TimeUtilSetTimezoneChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -936,7 +936,7 @@ exports.setTimezoneChangeListener = function() { exports.unsetTimezoneChangeListener = function() { utils_.log('Entered TimeUtil.unsetTimezoneChangeListener'); native_.removeListener('TimezoneChangeListener'); - var result = native_.callSync('TimeUtil_unsetTimezoneChangeListener', {}); + var result = native_.callSync('TimeUtilUnsetTimezoneChangeListener', {}); _timeUtilTimezoneChangeListener = undefined; if (native_.isFailure(result)) { throw native_.getErrorObject(result); diff --git a/src/time/time_instance.cc b/src/time/time_instance.cc index 5ef0a2af..40984314 100644 --- a/src/time/time_instance.cc +++ b/src/time/time_instance.cc @@ -14,43 +14,40 @@ namespace time { using namespace common; TimeInstance::TimeInstance() : manager_(this) { + ScopeLogger(); + using std::placeholders::_1; using std::placeholders::_2; - ScopeLogger(); - -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&TimeInstance::x, this, _1, _2)); -#define REGISTER_ASYNC(c, x) RegisterSyncHandler(c, std::bind(&TimeInstance::x, this, _1, _2)); - - REGISTER_SYNC("TimeUtil_getAvailableTimezones", TimeUtil_getAvailableTimezones); - REGISTER_SYNC("TimeUtil_getDateFormat", TimeUtil_getDateFormat); - REGISTER_SYNC("TimeUtil_getTimeFormat", TimeUtil_getTimeFormat); - REGISTER_SYNC("TimeUtil_setDateTimeChangeListener", TimeUtil_setDateTimeChangeListener); - REGISTER_SYNC("TimeUtil_unsetDateTimeChangeListener", TimeUtil_unsetDateTimeChangeListener); - REGISTER_SYNC("TimeUtil_setTimezoneChangeListener", TimeUtil_setTimezoneChangeListener); - REGISTER_SYNC("TimeUtil_unsetTimezoneChangeListener", TimeUtil_unsetTimezoneChangeListener); - REGISTER_SYNC("TZDate_getLocalTimezone", TZDate_getLocalTimezone); - REGISTER_SYNC("TZDate_getTimezoneOffset", TZDate_GetTimezoneOffset); - REGISTER_SYNC("TZDate_toLocaleDateString", TZDate_toLocaleDateString); - REGISTER_SYNC("TZDate_toLocaleTimeString", TZDate_toLocaleTimeString); - REGISTER_SYNC("TZDate_toLocaleString", TZDate_toLocaleString); - REGISTER_SYNC("TZDate_toDateString", TZDate_toDateString); - REGISTER_SYNC("TZDate_toTimeString", TZDate_toTimeString); - REGISTER_SYNC("TZDate_toString", TZDate_toString); - REGISTER_SYNC("TZDate_getTimezoneAbbreviation", TZDate_getTimezoneAbbreviation); - REGISTER_SYNC("TZDate_isDST", TZDate_isDST); - REGISTER_SYNC("TZDate_getPreviousDSTTransition", TZDate_getPreviousDSTTransition); - REGISTER_SYNC("TZDate_getNextDSTTransition", TZDate_getNextDSTTransition); - -#undef REGISTER_SYNC -#undef REGISTER_ASYNC +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&TimeInstance::M, this, _1, _2)) + REGISTER_METHOD(TimeUtilGetAvailableTimezones); + REGISTER_METHOD(TimeUtilGetDateFormat); + REGISTER_METHOD(TimeUtilGetTimeFormat); + REGISTER_METHOD(TimeUtilSetDateTimeChangeListener); + REGISTER_METHOD(TimeUtilUnsetDateTimeChangeListener); + REGISTER_METHOD(TimeUtilSetTimezoneChangeListener); + REGISTER_METHOD(TimeUtilUnsetTimezoneChangeListener); + REGISTER_METHOD(TZDateGetLocalTimezone); + REGISTER_METHOD(TZDateGetTimezoneOffset); + REGISTER_METHOD(TZDateToLocaleDateString); + REGISTER_METHOD(TZDateToLocaleTimeString); + REGISTER_METHOD(TZDateToLocaleString); + REGISTER_METHOD(TZDateToDateString); + REGISTER_METHOD(TZDateToTimeString); + REGISTER_METHOD(TZDateToString); + REGISTER_METHOD(TZDateGetTimezoneAbbreviation); + REGISTER_METHOD(TZDateIsDST); + REGISTER_METHOD(TZDateGetPreviousDSTTransition); + REGISTER_METHOD(TZDateGetNextDSTTransition); +#undef REGISTER_METHOD } TimeInstance::~TimeInstance() { ScopeLogger(); } -void TimeInstance::TimeUtil_getAvailableTimezones(const picojson::value& /*args*/, +void TimeInstance::TimeUtilGetAvailableTimezones(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); picojson::value result = picojson::value(picojson::object()); @@ -67,7 +64,7 @@ void TimeInstance::TimeUtil_getAvailableTimezones(const picojson::value& /*args* ReportSuccess(result, out); } -void TimeInstance::TimeUtil_getDateFormat(const picojson::value& args, picojson::object& out) { +void TimeInstance::TimeUtilGetDateFormat(const picojson::value& args, picojson::object& out) { ScopeLogger(); if (!args.contains("shortformat")) { LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."), @@ -90,7 +87,7 @@ void TimeInstance::TimeUtil_getDateFormat(const picojson::value& args, picojson: ReportSuccess(result, out); } -void TimeInstance::TimeUtil_getTimeFormat(const picojson::value& /* args */, +void TimeInstance::TimeUtilGetTimeFormat(const picojson::value& /* args */, picojson::object& out) { ScopeLogger(); std::string format; @@ -107,7 +104,7 @@ void TimeInstance::TimeUtil_getTimeFormat(const picojson::value& /* args */, ReportSuccess(result, out); } -void TimeInstance::TimeUtil_setDateTimeChangeListener(const picojson::value& /*args*/, +void TimeInstance::TimeUtilSetDateTimeChangeListener(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); PlatformResult res = manager_.RegisterVconfCallback(kTimeChange); @@ -117,7 +114,7 @@ void TimeInstance::TimeUtil_setDateTimeChangeListener(const picojson::value& /*a ReportSuccess(out); } -void TimeInstance::TimeUtil_unsetDateTimeChangeListener(const picojson::value& /*args*/, +void TimeInstance::TimeUtilUnsetDateTimeChangeListener(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); PlatformResult res = manager_.UnregisterVconfCallback(kTimeChange); @@ -127,7 +124,7 @@ void TimeInstance::TimeUtil_unsetDateTimeChangeListener(const picojson::value& / ReportSuccess(out); } -void TimeInstance::TimeUtil_setTimezoneChangeListener(const picojson::value& /*args*/, +void TimeInstance::TimeUtilSetTimezoneChangeListener(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); PlatformResult res = manager_.RegisterVconfCallback(kTimezoneChange); @@ -137,7 +134,7 @@ void TimeInstance::TimeUtil_setTimezoneChangeListener(const picojson::value& /*a ReportSuccess(out); } -void TimeInstance::TimeUtil_unsetTimezoneChangeListener(const picojson::value& /*args*/, +void TimeInstance::TimeUtilUnsetTimezoneChangeListener(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); PlatformResult res = manager_.UnregisterVconfCallback(kTimezoneChange); @@ -147,7 +144,7 @@ void TimeInstance::TimeUtil_unsetTimezoneChangeListener(const picojson::value& / ReportSuccess(out); } -void TimeInstance::TZDate_getLocalTimezone(const picojson::value& /*args*/, picojson::object& out) { +void TimeInstance::TZDateGetLocalTimezone(const picojson::value& /*args*/, picojson::object& out) { ScopeLogger(); std::string local_timezone = TimeManager::GetDefaultTimezone(); @@ -159,7 +156,7 @@ void TimeInstance::TZDate_getLocalTimezone(const picojson::value& /*args*/, pico ReportSuccess(result, out); } -void TimeInstance::TZDate_GetTimezoneOffset(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateGetTimezoneOffset(const picojson::value& args, picojson::object& out) { ScopeLogger(); if (!args.contains("timezone") || !args.contains("timestamp")) { LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."), @@ -216,37 +213,37 @@ void TimeInstance::ToStringTemplate(const picojson::value& args, bool use_locale ReportSuccess(result, *out); } -void TimeInstance::TZDate_toLocaleDateString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToLocaleDateString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, true, TimeUtilTools::DateTimeFormatType::kDateFormat, &out); } -void TimeInstance::TZDate_toLocaleTimeString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToLocaleTimeString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, true, TimeUtilTools::DateTimeFormatType::kTimeFormat, &out); } -void TimeInstance::TZDate_toLocaleString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToLocaleString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, true, TimeUtilTools::DateTimeFormatType::kDateTimeFormat, &out); } -void TimeInstance::TZDate_toDateString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToDateString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, false, TimeUtilTools::DateTimeFormatType::kDateFormat, &out); } -void TimeInstance::TZDate_toTimeString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToTimeString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, false, TimeUtilTools::DateTimeFormatType::kTimeFormat, &out); } -void TimeInstance::TZDate_toString(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateToString(const picojson::value& args, picojson::object& out) { ScopeLogger(); ToStringTemplate(args, false, TimeUtilTools::DateTimeFormatType::kDateTimeFormat, &out); } -void TimeInstance::TZDate_getTimezoneAbbreviation(const picojson::value& args, +void TimeInstance::TZDateGetTimezoneAbbreviation(const picojson::value& args, picojson::object& out) { ScopeLogger(); LoggerW( @@ -278,7 +275,7 @@ void TimeInstance::TZDate_getTimezoneAbbreviation(const picojson::value& args, ReportSuccess(result, out); } -void TimeInstance::TZDate_isDST(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateIsDST(const picojson::value& args, picojson::object& out) { ScopeLogger(); if (!args.contains("timezone") || !args.contains("timestamp")) { LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."), @@ -303,7 +300,7 @@ void TimeInstance::TZDate_isDST(const picojson::value& args, picojson::object& o ReportSuccess(result, out); } -void TimeInstance::TZDate_getPreviousDSTTransition(const picojson::value& args, +void TimeInstance::TZDateGetPreviousDSTTransition(const picojson::value& args, picojson::object& out) { ScopeLogger(); if (!args.contains("timezone") || !args.contains("timestamp")) { @@ -326,7 +323,7 @@ void TimeInstance::TZDate_getPreviousDSTTransition(const picojson::value& args, ReportSuccess(result, out); } -void TimeInstance::TZDate_getNextDSTTransition(const picojson::value& args, picojson::object& out) { +void TimeInstance::TZDateGetNextDSTTransition(const picojson::value& args, picojson::object& out) { ScopeLogger(); if (!args.contains("timezone") || !args.contains("timestamp")) { LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid parameter passed."), diff --git a/src/time/time_instance.h b/src/time/time_instance.h index adcf08a7..06a29d71 100644 --- a/src/time/time_instance.h +++ b/src/time/time_instance.h @@ -23,27 +23,27 @@ class TimeInstance : public common::ParsedInstance { virtual ~TimeInstance(); private: - void TimeUtil_getAvailableTimezones(const picojson::value& args, picojson::object& out); - void TimeUtil_getDateFormat(const picojson::value& args, picojson::object& out); - void TimeUtil_getTimeFormat(const picojson::value& args, picojson::object& out); - void TimeUtil_setDateTimeChangeListener(const picojson::value& args, picojson::object& out); - void TimeUtil_unsetDateTimeChangeListener(const picojson::value& args, picojson::object& out); - void TimeUtil_setTimezoneChangeListener(const picojson::value& args, picojson::object& out); - void TimeUtil_unsetTimezoneChangeListener(const picojson::value& args, picojson::object& out); - void TZDate_getLocalTimezone(const picojson::value& args, picojson::object& out); - void TZDate_GetTimezoneOffset(const picojson::value& args, picojson::object& out); + void TimeUtilGetAvailableTimezones(const picojson::value& args, picojson::object& out); + void TimeUtilGetDateFormat(const picojson::value& args, picojson::object& out); + void TimeUtilGetTimeFormat(const picojson::value& args, picojson::object& out); + void TimeUtilSetDateTimeChangeListener(const picojson::value& args, picojson::object& out); + void TimeUtilUnsetDateTimeChangeListener(const picojson::value& args, picojson::object& out); + void TimeUtilSetTimezoneChangeListener(const picojson::value& args, picojson::object& out); + void TimeUtilUnsetTimezoneChangeListener(const picojson::value& args, picojson::object& out); + void TZDateGetLocalTimezone(const picojson::value& args, picojson::object& out); + void TZDateGetTimezoneOffset(const picojson::value& args, picojson::object& out); void ToStringTemplate(const picojson::value& args, bool use_locale_fmt, TimeUtilTools::DateTimeFormatType type, picojson::object* out); - void TZDate_toLocaleDateString(const picojson::value& args, picojson::object& out); - void TZDate_toLocaleTimeString(const picojson::value& args, picojson::object& out); - void TZDate_toLocaleString(const picojson::value& args, picojson::object& out); - void TZDate_toDateString(const picojson::value& args, picojson::object& out); - void TZDate_toTimeString(const picojson::value& args, picojson::object& out); - void TZDate_toString(const picojson::value& args, picojson::object& out); - void TZDate_getTimezoneAbbreviation(const picojson::value& args, picojson::object& out); - void TZDate_isDST(const picojson::value& args, picojson::object& out); - void TZDate_getPreviousDSTTransition(const picojson::value& args, picojson::object& out); - void TZDate_getNextDSTTransition(const picojson::value& args, picojson::object& out); + void TZDateToLocaleDateString(const picojson::value& args, picojson::object& out); + void TZDateToLocaleTimeString(const picojson::value& args, picojson::object& out); + void TZDateToLocaleString(const picojson::value& args, picojson::object& out); + void TZDateToDateString(const picojson::value& args, picojson::object& out); + void TZDateToTimeString(const picojson::value& args, picojson::object& out); + void TZDateToString(const picojson::value& args, picojson::object& out); + void TZDateGetTimezoneAbbreviation(const picojson::value& args, picojson::object& out); + void TZDateIsDST(const picojson::value& args, picojson::object& out); + void TZDateGetPreviousDSTTransition(const picojson::value& args, picojson::object& out); + void TZDateGetNextDSTTransition(const picojson::value& args, picojson::object& out); TimeManager manager_; }; diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 03c44dd0..217ca353 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -310,7 +310,7 @@ Utils.prototype.validateObject = function(object, signature, attributes) { }; Utils.prototype.getPkgApiVersion = function() { - var result = native_.callSync('Utils_getPkgApiVersion'); + var result = native_.callSync('UtilsGetPkgApiVersion'); if (native_.isFailure(result)) { throw native_.getErrorObject(result); } @@ -332,7 +332,7 @@ Utils.prototype.checkPrivilegeAccess = function(privilege) { throw new WebAPIException(WebAPIException.SECURITY_ERR); } - var result = native_.callSync('Utils_checkPrivilegeAccess', { + var result = native_.callSync('UtilsCheckPrivilegeAccess', { privilege: _toString(privilege) }); @@ -379,7 +379,7 @@ Utils.prototype.checkBackwardCompabilityPrivilegeAccess = function( current_privilege, previous_privilege ) { - var result = native_.callSync('Utils_checkBackwardCompabilityPrivilegeAccess', { + var result = native_.callSync('UtilsCheckBackwardCompabilityPrivilegeAccess', { current_privilege: _toString(current_privilege), previous_privilege: _toString(previous_privilege) }); @@ -390,7 +390,7 @@ Utils.prototype.checkBackwardCompabilityPrivilegeAccess = function( }; Utils.prototype.checkProfile = function() { - var result = native_.callSync('Utils_checkProfile', {}); + var result = native_.callSync('UtilsCheckProfile', {}); return native_.getResultObject(result); }; @@ -557,7 +557,7 @@ function _toLongLong(val) { // of requested val. We're converting the val to signed long and then pass it // to C++ to get the value in required range. return native_.getResultObject( - native_.callSync('Utils_toLongLong', { + native_.callSync('UtilsToLongLong', { n: _toLong(val) }) ); @@ -580,7 +580,7 @@ function _toUnsignedLongLong(val) { // of requested val. We're converting the val to signed long and then pass it // to C++ to get the value in required range. return native_.getResultObject( - native_.callSync('Utils_toUnsignedLongLong', { + native_.callSync('UtilsToUnsignedLongLong', { n: _toLong(val) }) ); diff --git a/src/utils/utils_instance.cc b/src/utils/utils_instance.cc index 9cb9dd57..36664828 100644 --- a/src/utils/utils_instance.cc +++ b/src/utils/utils_instance.cc @@ -20,26 +20,22 @@ namespace extension { namespace utils { UtilsInstance::UtilsInstance() { + ScopeLogger(); using std::placeholders::_1; using std::placeholders::_2; - ScopeLogger(); -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&UtilsInstance::x, this, _1, _2)); -#define REGISTER_ASYNC(c, x) RegisterSyncHandler(c, std::bind(&UtilsInstance::x, this, _1, _2)); - - REGISTER_SYNC("Utils_getPkgApiVersion", GetPkgApiVersion); - REGISTER_SYNC("Utils_checkPrivilegeAccess", CheckPrivilegeAccess); - REGISTER_SYNC("Utils_checkBackwardCompabilityPrivilegeAccess", - CheckBackwardCompabilityPrivilegeAccess); - REGISTER_SYNC("Utils_toLongLong", ToLongLong); - REGISTER_SYNC("Utils_toUnsignedLongLong", ToUnsignedLongLong); - REGISTER_SYNC("Utils_checkProfile", CheckProfile); - -#undef REGISTER_SYNC -#undef REGISTER_ASYNC +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&UtilsInstance::M, this, _1, _2)) + REGISTER_METHOD(UtilsGetPkgApiVersion); + REGISTER_METHOD(UtilsCheckPrivilegeAccess); + REGISTER_METHOD(UtilsCheckBackwardCompabilityPrivilegeAccess); + REGISTER_METHOD(UtilsToLongLong); + REGISTER_METHOD(UtilsToUnsignedLongLong); + REGISTER_METHOD(UtilsCheckProfile); +#undef REGISTER_METHOD } -void UtilsInstance::GetPkgApiVersion(const picojson::value& args, picojson::object& out) { +void UtilsInstance::UtilsGetPkgApiVersion(const picojson::value& args, picojson::object& out) { ScopeLogger(); std::string api_version; @@ -50,14 +46,14 @@ void UtilsInstance::GetPkgApiVersion(const picojson::value& args, picojson::obje ReportSuccess(picojson::value(api_version), out); } -void UtilsInstance::CheckPrivilegeAccess(const picojson::value& args, picojson::object& out) { +void UtilsInstance::UtilsCheckPrivilegeAccess(const picojson::value& args, picojson::object& out) { ScopeLogger(); const auto& privilege = args.get("privilege").to_str(); CHECK_PRIVILEGE_ACCESS(privilege, &out); ReportSuccess(out); } -void UtilsInstance::CheckBackwardCompabilityPrivilegeAccess(const picojson::value& args, +void UtilsInstance::UtilsCheckBackwardCompabilityPrivilegeAccess(const picojson::value& args, picojson::object& out) { ScopeLogger(); const auto& current_priv = args.get("current_privilege").to_str(); @@ -79,7 +75,7 @@ const double kTwoPow64 = 18446744073709551616.0; } // namespace -void UtilsInstance::ToLongLong(const picojson::value& args, picojson::object& out) { +void UtilsInstance::UtilsToLongLong(const picojson::value& args, picojson::object& out) { ScopeLogger(); const auto& n = args.get("n"); @@ -98,7 +94,7 @@ void UtilsInstance::ToLongLong(const picojson::value& args, picojson::object& ou ReportSuccess(picojson::value(static_cast(output)), out); } -void UtilsInstance::ToUnsignedLongLong(const picojson::value& args, picojson::object& out) { +void UtilsInstance::UtilsToUnsignedLongLong(const picojson::value& args, picojson::object& out) { ScopeLogger(); const auto& n = args.get("n"); @@ -117,7 +113,7 @@ void UtilsInstance::ToUnsignedLongLong(const picojson::value& args, picojson::ob ReportSuccess(picojson::value(static_cast(output)), out); } -void UtilsInstance::CheckProfile(const picojson::value& args, picojson::object& out) { +void UtilsInstance::UtilsCheckProfile(const picojson::value& args, picojson::object& out) { ScopeLogger(); std::string profile = "common"; diff --git a/src/utils/utils_instance.h b/src/utils/utils_instance.h index df065d52..0d216824 100644 --- a/src/utils/utils_instance.h +++ b/src/utils/utils_instance.h @@ -22,13 +22,13 @@ class UtilsInstance : public common::ParsedInstance { } private: - void GetPkgApiVersion(const picojson::value& args, picojson::object& out); - void CheckPrivilegeAccess(const picojson::value& args, picojson::object& out); - void CheckBackwardCompabilityPrivilegeAccess(const picojson::value& args, picojson::object& out); + void UtilsGetPkgApiVersion(const picojson::value& args, picojson::object& out); + void UtilsCheckPrivilegeAccess(const picojson::value& args, picojson::object& out); + void UtilsCheckBackwardCompabilityPrivilegeAccess(const picojson::value& args, picojson::object& out); - void ToLongLong(const picojson::value& args, picojson::object& out); - void ToUnsignedLongLong(const picojson::value& args, picojson::object& out); - void CheckProfile(const picojson::value& args, picojson::object& out); + void UtilsToLongLong(const picojson::value& args, picojson::object& out); + void UtilsToUnsignedLongLong(const picojson::value& args, picojson::object& out); + void UtilsCheckProfile(const picojson::value& args, picojson::object& out); }; } // namespace utils } // namespace extension diff --git a/src/voicecontrol/voicecontrol_api.js b/src/voicecontrol/voicecontrol_api.js index a0ab77a1..69eece7e 100755 --- a/src/voicecontrol/voicecontrol_api.js +++ b/src/voicecontrol/voicecontrol_api.js @@ -100,7 +100,7 @@ var VoiceControlCommandType = { function VoiceControlClientManager() {} VoiceControlClientManager.prototype.getVoiceControlClient = function() { - var result = native_.callSync('VoiceControlClientManager_getVoiceControlClient', {}); + var result = native_.callSync('VoiceControlClientManagerGetVoiceControlClient', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -112,7 +112,7 @@ VoiceControlClientManager.prototype.getVoiceControlClient = function() { function VoiceControlClient() {} VoiceControlClient.prototype.getCurrentLanguage = function() { - var result = native_.callSync('VoiceControlClient_getCurrentLanguage', {}); + var result = native_.callSync('VoiceControlClientGetCurrentLanguage', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -142,7 +142,7 @@ VoiceControlClient.prototype.setCommandList = function(list, type) { type: args.type }; - var result = native_.callSync('VoiceControlClient_setCommandList', data); + var result = native_.callSync('VoiceControlClientSetCommandList', data); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -164,7 +164,7 @@ VoiceControlClient.prototype.unsetCommandList = function(type) { args.type = VoiceControlCommandType.FOREGROUND; } - var result = native_.callSync('VoiceControlClient_unsetCommandList', { + var result = native_.callSync('VoiceControlClientUnsetCommandList', { type: args.type }); @@ -180,7 +180,7 @@ VoiceControlClient.prototype.addResultListener = function(listener) { return VcResultListener.addListener( args.listener, - 'VoiceControlClient_addResultListener' + 'VoiceControlClientAddResultListener' ); }; @@ -194,7 +194,7 @@ VoiceControlClient.prototype.removeResultListener = function(id) { var args = validator_.validateArgs(arguments, [{ name: 'id', type: types_.LONG }]); - VcResultListener.removeListener(args.id, 'VoiceControlClient_removeResultListener'); + VcResultListener.removeListener(args.id, 'VoiceControlClientRemoveResultListener'); }; VoiceControlClient.prototype.addLanguageChangeListener = function(listener) { @@ -204,7 +204,7 @@ VoiceControlClient.prototype.addLanguageChangeListener = function(listener) { return VcLangListener.addListener( args.listener, - 'VoiceControlClient_addLanguageChangeListener' + 'VoiceControlClientAddLanguageChangeListener' ); }; @@ -220,12 +220,12 @@ VoiceControlClient.prototype.removeLanguageChangeListener = function(id) { VcLangListener.removeListener( args.id, - 'VoiceControlClient_removeLanguageChangeListener' + 'VoiceControlClientRemoveLanguageChangeListener' ); }; VoiceControlClient.prototype.release = function() { - var result = native_.callSync('VoiceControlClient_release', {}); + var result = native_.callSync('VoiceControlClientRelease', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); diff --git a/src/voicecontrol/voicecontrol_instance.cc b/src/voicecontrol/voicecontrol_instance.cc index 8e59714b..770ec745 100644 --- a/src/voicecontrol/voicecontrol_instance.cc +++ b/src/voicecontrol/voicecontrol_instance.cc @@ -42,18 +42,19 @@ using namespace extension::voicecontrol; VoiceControlInstance::VoiceControlInstance() : voice_control_client() { ScopeLogger(); using namespace std::placeholders; -#define REGISTER_SYNC(c, x) \ - RegisterSyncHandler(c, std::bind(&VoiceControlInstance::x, this, _1, _2)); - REGISTER_SYNC("VoiceControlClient_getCurrentLanguage", GetCurrentLanguage); - REGISTER_SYNC("VoiceControlClient_setCommandList", SetCommandList); - REGISTER_SYNC("VoiceControlClient_unsetCommandList", UnsetCommandList); - REGISTER_SYNC("VoiceControlClient_addResultListener", AddResultListener); - REGISTER_SYNC("VoiceControlClient_removeResultListener", RemoveResultListener); - REGISTER_SYNC("VoiceControlClient_addLanguageChangeListener", AddLanguageChangeListener); - REGISTER_SYNC("VoiceControlClient_removeLanguageChangeListener", RemoveLanguageChangeListener); - REGISTER_SYNC("VoiceControlClient_release", Release); - REGISTER_SYNC("VoiceControlClientManager_getVoiceControlClient", GetVoiceControlClient); -#undef REGISTER_SYNC + +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&VoiceControlInstance::M, this, _1, _2)) + REGISTER_METHOD(VoiceControlClientGetCurrentLanguage); + REGISTER_METHOD(VoiceControlClientSetCommandList); + REGISTER_METHOD(VoiceControlClientUnsetCommandList); + REGISTER_METHOD(VoiceControlClientAddResultListener); + REGISTER_METHOD(VoiceControlClientRemoveResultListener); + REGISTER_METHOD(VoiceControlClientAddLanguageChangeListener); + REGISTER_METHOD(VoiceControlClientRemoveLanguageChangeListener); + REGISTER_METHOD(VoiceControlClientRelease); + REGISTER_METHOD(VoiceControlClientManagerGetVoiceControlClient); +#undef REGISTER_METHOD } VoiceControlInstance::~VoiceControlInstance() { @@ -71,7 +72,7 @@ VoiceControlInstance::~VoiceControlInstance() { return; \ } -void VoiceControlInstance::GetVoiceControlClient(const picojson::value& args, +void VoiceControlInstance::VoiceControlClientManagerGetVoiceControlClient(const picojson::value& args, picojson::object& out) { ScopeLogger(); @@ -118,7 +119,7 @@ void VoiceControlInstance::GetVoiceControlClient(const picojson::value& args, ReportSuccess(out); } -void VoiceControlInstance::Release(const picojson::value& args, picojson::object& out) { +void VoiceControlInstance::VoiceControlClientRelease(const picojson::value& args, picojson::object& out) { ScopeLogger(); int ret = VC_ERROR_NONE; @@ -149,7 +150,7 @@ void VoiceControlInstance::Release(const picojson::value& args, picojson::object ReportSuccess(out); } -void VoiceControlInstance::GetCurrentLanguage(const picojson::value& args, picojson::object& out) { +void VoiceControlInstance::VoiceControlClientGetCurrentLanguage(const picojson::value& args, picojson::object& out) { ScopeLogger(); std::string language; @@ -162,7 +163,7 @@ void VoiceControlInstance::GetCurrentLanguage(const picojson::value& args, picoj } } -void VoiceControlInstance::SetCommandList(const picojson::value& args, picojson::object& out) { +void VoiceControlInstance::VoiceControlClientSetCommandList(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeVoiceControl, &out); @@ -181,7 +182,7 @@ void VoiceControlInstance::SetCommandList(const picojson::value& args, picojson: } } -void VoiceControlInstance::UnsetCommandList(const picojson::value& args, picojson::object& out) { +void VoiceControlInstance::VoiceControlClientUnsetCommandList(const picojson::value& args, picojson::object& out) { ScopeLogger(); CHECK_PRIVILEGE_ACCESS(kPrivilegeVoiceControl, &out); @@ -198,7 +199,7 @@ void VoiceControlInstance::UnsetCommandList(const picojson::value& args, picojso } } -void VoiceControlInstance::AddResultListener(const picojson::value& args, picojson::object& out) { +void VoiceControlInstance::VoiceControlClientAddResultListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); common::PlatformResult result = voice_control_client.AddResultListener(); @@ -210,7 +211,7 @@ void VoiceControlInstance::AddResultListener(const picojson::value& args, picojs } } -void VoiceControlInstance::RemoveResultListener(const picojson::value& args, +void VoiceControlInstance::VoiceControlClientRemoveResultListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); @@ -223,7 +224,7 @@ void VoiceControlInstance::RemoveResultListener(const picojson::value& args, } } -void VoiceControlInstance::AddLanguageChangeListener(const picojson::value& args, +void VoiceControlInstance::VoiceControlClientAddLanguageChangeListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); @@ -236,7 +237,7 @@ void VoiceControlInstance::AddLanguageChangeListener(const picojson::value& args } } -void VoiceControlInstance::RemoveLanguageChangeListener(const picojson::value& args, +void VoiceControlInstance::VoiceControlClientRemoveLanguageChangeListener(const picojson::value& args, picojson::object& out) { ScopeLogger(); diff --git a/src/voicecontrol/voicecontrol_instance.h b/src/voicecontrol/voicecontrol_instance.h index 03d2aace..1e4502f7 100644 --- a/src/voicecontrol/voicecontrol_instance.h +++ b/src/voicecontrol/voicecontrol_instance.h @@ -31,16 +31,16 @@ class VoiceControlInstance : public common::ParsedInstance { virtual ~VoiceControlInstance(); private: - void GetVoiceControlClient(const picojson::value& args, picojson::object& out); - void Release(const picojson::value& args, picojson::object& out); - - void GetCurrentLanguage(const picojson::value& args, picojson::object& out); - void SetCommandList(const picojson::value& args, picojson::object& out); - void UnsetCommandList(const picojson::value& args, picojson::object& out); - void AddResultListener(const picojson::value& args, picojson::object& out); - void RemoveResultListener(const picojson::value& args, picojson::object& out); - void AddLanguageChangeListener(const picojson::value& args, picojson::object& out); - void RemoveLanguageChangeListener(const picojson::value& args, picojson::object& out); + void VoiceControlClientManagerGetVoiceControlClient(const picojson::value& args, picojson::object& out); + void VoiceControlClientRelease(const picojson::value& args, picojson::object& out); + + void VoiceControlClientGetCurrentLanguage(const picojson::value& args, picojson::object& out); + void VoiceControlClientSetCommandList(const picojson::value& args, picojson::object& out); + void VoiceControlClientUnsetCommandList(const picojson::value& args, picojson::object& out); + void VoiceControlClientAddResultListener(const picojson::value& args, picojson::object& out); + void VoiceControlClientRemoveResultListener(const picojson::value& args, picojson::object& out); + void VoiceControlClientAddLanguageChangeListener(const picojson::value& args, picojson::object& out); + void VoiceControlClientRemoveLanguageChangeListener(const picojson::value& args, picojson::object& out); static void VcLanguageChangedCb(const char* previous, const char* current, void* user_data); static void VcResultCb(vc_result_event_e event, vc_cmd_list_h cmd_list, const char* result, diff --git a/src/widgetservice/widgetservice_api.js b/src/widgetservice/widgetservice_api.js index ad0cd3f9..53b5a150 100644 --- a/src/widgetservice/widgetservice_api.js +++ b/src/widgetservice/widgetservice_api.js @@ -130,7 +130,7 @@ WidgetInstance.prototype.changeUpdatePeriod = function() { callArgs.instanceId = this.id; callArgs.seconds = args.seconds; - var ret = native.callSync('WidgetInstance_changeUpdatePeriod', callArgs); + var ret = native.callSync('WidgetInstanceChangeUpdatePeriod', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -155,7 +155,7 @@ WidgetInstance.prototype.sendContent = function() { callArgs.data = args.data; callArgs.updateIfPaused = args.updateIfPaused; - var ret = native.callSync('WidgetInstance_sendContent', callArgs); + var ret = native.callSync('WidgetInstanceSendContent', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -186,7 +186,7 @@ WidgetInstance.prototype.getContent = function() { } }; - var result = native.call('WidgetInstance_getContent', callArgs, callback); + var result = native.call('WidgetInstanceGetContent', callArgs, callback); if (native.isFailure(result)) { throw native.getErrorObject(result); } @@ -247,7 +247,7 @@ Widget.prototype.getName = function() { callArgs.locale = args.locale; } - var ret = native.callSync('Widget_getName', callArgs); + var ret = native.callSync('WidgetGetName', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -282,7 +282,7 @@ Widget.prototype.getInstances = function() { var callArgs = {}; callArgs.widgetId = this.id; - var result = native.call('Widget_getInstances', callArgs, callback); + var result = native.call('WidgetGetInstances', callArgs, callback); if (native.isFailure(result)) { throw native.getErrorObject(result); } @@ -301,7 +301,7 @@ Widget.prototype.getVariant = function() { callArgs.widgetId = this.id; callArgs.sizeType = args.sizeType; - var ret = native.callSync('Widget_getVariant', callArgs); + var ret = native.callSync('WidgetGetVariant', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -336,7 +336,7 @@ Widget.prototype.getVariants = function() { var callArgs = {}; callArgs.widgetId = this.id; - var result = native.call('Widget_getVariants', callArgs, callback); + var result = native.call('WidgetGetVariants', callArgs, callback); if (native.isFailure(result)) { throw native.getErrorObject(result); } @@ -351,7 +351,7 @@ Widget.prototype.addStateChangeListener = function() { ]); if (widgetToListenerManagerMapping[this.id].numberOfListeners == 0) { - var result = native.callSync('Widget_addStateChangeListener', { + var result = native.callSync('WidgetAddStateChangeListener', { widgetId: this.id }); if (native.isFailure(result)) { @@ -379,7 +379,7 @@ Widget.prototype.removeStateChangeListener = function() { widgetToListenerManagerMapping[this.id].removeListener(args.watchId); if (widgetToListenerManagerMapping[this.id].numberOfListeners == 0) { - var result = native.callSync('Widget_removeStateChangeListener', { + var result = native.callSync('WidgetRemoveStateChangeListener', { widgetId: this.id }); if (native.isFailure(result)) { @@ -401,7 +401,7 @@ WidgetServiceManager.prototype.getWidget = function() { var callArgs = {}; callArgs.widgetId = args.widgetId; - var ret = native.callSync('WidgetServiceManager_getWidget', callArgs); + var ret = native.callSync('WidgetServiceManagerGetWidget', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -444,7 +444,7 @@ WidgetServiceManager.prototype.getWidgets = function() { callArgs.packageId = args.packageId; } - var result = native.call('WidgetServiceManager_getWidgets', callArgs, callback); + var result = native.call('WidgetServiceManagerGetWidgets', callArgs, callback); if (native.isFailure(result)) { throw native.getErrorObject(result); } @@ -461,7 +461,7 @@ WidgetServiceManager.prototype.getPrimaryWidgetId = function() { var callArgs = {}; callArgs.id = args.id; - var ret = native.callSync('WidgetServiceManager_getPrimaryWidgetId', callArgs); + var ret = native.callSync('WidgetServiceManagerGetPrimaryWidgetId', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); @@ -482,7 +482,7 @@ WidgetServiceManager.prototype.getSize = function() { var callArgs = {}; callArgs.sizeType = args.sizeType; - var ret = native.callSync('WidgetServiceManager_getSize', callArgs); + var ret = native.callSync('WidgetServiceManagerGetSize', callArgs); if (native.isFailure(ret)) { throw native.getErrorObject(ret); diff --git a/src/widgetservice/widgetservice_instance.cc b/src/widgetservice/widgetservice_instance.cc index c1a2bb5c..263b71b9 100644 --- a/src/widgetservice/widgetservice_instance.cc +++ b/src/widgetservice/widgetservice_instance.cc @@ -167,27 +167,26 @@ WidgetServiceInstance::WidgetServiceInstance() { using std::placeholders::_1; using std::placeholders::_2; -#define REGISTER_SYNC(c, x) RegisterSyncHandler(c, std::bind(&WidgetServiceInstance::x, this, _1)); - - REGISTER_SYNC("WidgetServiceManager_getWidget", GetWidget); - REGISTER_SYNC("WidgetServiceManager_getPrimaryWidgetId", GetPrimaryWidgetId); - REGISTER_SYNC("WidgetServiceManager_getSize", GetSize); - REGISTER_SYNC("Widget_getName", GetName); - REGISTER_SYNC("Widget_getVariant", GetVariant); - REGISTER_SYNC("Widget_addStateChangeListener", AddStateChangeListener); - REGISTER_SYNC("Widget_removeStateChangeListener", RemoveStateChangeListener); - REGISTER_SYNC("WidgetInstance_changeUpdatePeriod", ChangeUpdatePeriod); - REGISTER_SYNC("WidgetInstance_sendContent", SendContent); - -#undef REGISTER_SYNC - -#define REGISTER_ASYNC(c, x) RegisterHandler(c, std::bind(&WidgetServiceInstance::x, this, _1, _2)); - - REGISTER_ASYNC("WidgetServiceManager_getWidgets", GetWidgets); - REGISTER_ASYNC("Widget_getInstances", GetInstances); - REGISTER_ASYNC("Widget_getVariants", GetVariants); - REGISTER_ASYNC("WidgetInstance_getContent", GetContent); -#undef REGISTER_ASYNC +#define REGISTER_METHOD(M) \ + RegisterSyncHandler(#M, std::bind(&WidgetServiceInstance::M, this, _1)) + REGISTER_METHOD(WidgetServiceManagerGetWidget); + REGISTER_METHOD(WidgetServiceManagerGetPrimaryWidgetId); + REGISTER_METHOD(WidgetServiceManagerGetSize); + REGISTER_METHOD(WidgetGetName); + REGISTER_METHOD(WidgetGetVariant); + REGISTER_METHOD(WidgetAddStateChangeListener); + REGISTER_METHOD(WidgetRemoveStateChangeListener); + REGISTER_METHOD(WidgetInstanceChangeUpdatePeriod); + REGISTER_METHOD(WidgetInstanceSendContent); +#undef REGISTER_METHOD + +#define REGISTER_METHOD(M) \ + RegisterHandler(#M, std::bind(&WidgetServiceInstance::M, this, _1, _2)) + REGISTER_METHOD(WidgetServiceManagerGetWidgets); + REGISTER_METHOD(WidgetGetInstances); + REGISTER_METHOD(WidgetGetVariants); + REGISTER_METHOD(WidgetInstanceGetContent); +#undef REGISTER_METHOD } WidgetServiceInstance::~WidgetServiceInstance() { @@ -204,7 +203,7 @@ WidgetServiceInstance::~WidgetServiceInstance() { listener_map_.clear(); } -TizenResult WidgetServiceInstance::GetWidget(const picojson::object& args) { +TizenResult WidgetServiceInstance::WidgetServiceManagerGetWidget(const picojson::object& args) { ScopeLogger(); CHECK_PRIVILEGE(kPrivilegeWidgetService); @@ -224,7 +223,7 @@ TizenResult WidgetServiceInstance::GetWidget(const picojson::object& args) { return TizenSuccess(value); } -TizenResult WidgetServiceInstance::GetWidgets(const picojson::object& args, +TizenResult WidgetServiceInstance::WidgetServiceManagerGetWidgets(const picojson::object& args, const common::AsyncToken& token) { ScopeLogger(); @@ -267,7 +266,7 @@ TizenResult WidgetServiceInstance::GetWidgets(const picojson::object& args, return TizenSuccess(); } -TizenResult WidgetServiceInstance::GetPrimaryWidgetId(const picojson::object& args) { +TizenResult WidgetServiceInstance::WidgetServiceManagerGetPrimaryWidgetId(const picojson::object& args) { ScopeLogger(); CHECK_PRIVILEGE(kPrivilegeWidgetService); @@ -289,7 +288,7 @@ TizenResult WidgetServiceInstance::GetPrimaryWidgetId(const picojson::object& ar return TizenSuccess(picojson::value(widget_id)); } -TizenResult WidgetServiceInstance::GetSize(const picojson::object& args) { +TizenResult WidgetServiceInstance::WidgetServiceManagerGetSize(const picojson::object& args) { ScopeLogger(); CHECK_EXIST(args, kSizeType, out) @@ -311,7 +310,7 @@ TizenResult WidgetServiceInstance::GetSize(const picojson::object& args) { return TizenSuccess(value); } -TizenResult WidgetServiceInstance::GetName(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetGetName(picojson::object const& args) { ScopeLogger(); CHECK_PRIVILEGE(kPrivilegeWidgetService); @@ -339,7 +338,7 @@ TizenResult WidgetServiceInstance::GetName(picojson::object const& args) { return TizenSuccess(picojson::value(name)); } -TizenResult WidgetServiceInstance::GetInstances(picojson::object const& args, +TizenResult WidgetServiceInstance::WidgetGetInstances(picojson::object const& args, const common::AsyncToken& token) { ScopeLogger(); @@ -371,7 +370,7 @@ TizenResult WidgetServiceInstance::GetInstances(picojson::object const& args, return TizenSuccess(); } -TizenResult WidgetServiceInstance::GetVariant(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetGetVariant(picojson::object const& args) { ScopeLogger(); CHECK_EXIST(args, kWidgetId, out) @@ -404,7 +403,7 @@ TizenResult WidgetServiceInstance::GetVariant(picojson::object const& args) { return TizenSuccess(value); } -TizenResult WidgetServiceInstance::GetVariants(picojson::object const& args, +TizenResult WidgetServiceInstance::WidgetGetVariants(picojson::object const& args, const common::AsyncToken& token) { ScopeLogger(); @@ -484,7 +483,7 @@ void WidgetServiceInstance::CallWidgetLifecycleListener(const std::string& widge LoggerW("widget id was not found."); } -TizenResult WidgetServiceInstance::AddStateChangeListener(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetAddStateChangeListener(picojson::object const& args) { ScopeLogger(); CHECK_PRIVILEGE(kPrivilegeWidgetService); @@ -511,7 +510,7 @@ TizenResult WidgetServiceInstance::AddStateChangeListener(picojson::object const return TizenSuccess(); } -TizenResult WidgetServiceInstance::RemoveStateChangeListener(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetRemoveStateChangeListener(picojson::object const& args) { ScopeLogger(); CHECK_EXIST(args, kWidgetId, out) @@ -537,7 +536,7 @@ TizenResult WidgetServiceInstance::RemoveStateChangeListener(picojson::object co return TizenSuccess(); } -TizenResult WidgetServiceInstance::ChangeUpdatePeriod(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetInstanceChangeUpdatePeriod(picojson::object const& args) { ScopeLogger(); CHECK_EXIST(args, kWidgetId, out) @@ -564,7 +563,7 @@ TizenResult WidgetServiceInstance::ChangeUpdatePeriod(picojson::object const& ar return TizenSuccess(); } -TizenResult WidgetServiceInstance::SendContent(picojson::object const& args) { +TizenResult WidgetServiceInstance::WidgetInstanceSendContent(picojson::object const& args) { ScopeLogger(); CHECK_EXIST(args, kWidgetId, out) @@ -602,7 +601,7 @@ TizenResult WidgetServiceInstance::SendContent(picojson::object const& args) { return TizenSuccess(); } -TizenResult WidgetServiceInstance::GetContent(picojson::object const& args, +TizenResult WidgetServiceInstance::WidgetInstanceGetContent(picojson::object const& args, const common::AsyncToken& token) { ScopeLogger(); diff --git a/src/widgetservice/widgetservice_instance.h b/src/widgetservice/widgetservice_instance.h index b9b80f29..9a6fb59c 100644 --- a/src/widgetservice/widgetservice_instance.h +++ b/src/widgetservice/widgetservice_instance.h @@ -33,21 +33,21 @@ class WidgetServiceInstance : public common::TizenInstance { private: // WidgetManager - common::TizenResult GetWidget(picojson::object const& args); - common::TizenResult GetWidgets(picojson::object const& args, const common::AsyncToken& token); - common::TizenResult GetPrimaryWidgetId(picojson::object const& args); - common::TizenResult GetSize(picojson::object const& args); + common::TizenResult WidgetServiceManagerGetWidget(picojson::object const& args); + common::TizenResult WidgetServiceManagerGetWidgets(picojson::object const& args, const common::AsyncToken& token); + common::TizenResult WidgetServiceManagerGetPrimaryWidgetId(picojson::object const& args); + common::TizenResult WidgetServiceManagerGetSize(picojson::object const& args); // Widget - common::TizenResult GetName(picojson::object const& args); - common::TizenResult GetInstances(picojson::object const& args, const common::AsyncToken& token); - common::TizenResult GetVariant(picojson::object const& args); - common::TizenResult GetVariants(picojson::object const& args, const common::AsyncToken& token); - common::TizenResult AddStateChangeListener(picojson::object const& args); - common::TizenResult RemoveStateChangeListener(picojson::object const& args); + common::TizenResult WidgetGetName(picojson::object const& args); + common::TizenResult WidgetGetInstances(picojson::object const& args, const common::AsyncToken& token); + common::TizenResult WidgetGetVariant(picojson::object const& args); + common::TizenResult WidgetGetVariants(picojson::object const& args, const common::AsyncToken& token); + common::TizenResult WidgetAddStateChangeListener(picojson::object const& args); + common::TizenResult WidgetRemoveStateChangeListener(picojson::object const& args); // WidgetInstance - common::TizenResult ChangeUpdatePeriod(picojson::object const& args); - common::TizenResult SendContent(picojson::object const& args); - common::TizenResult GetContent(picojson::object const& args, const common::AsyncToken& token); + common::TizenResult WidgetInstanceChangeUpdatePeriod(picojson::object const& args); + common::TizenResult WidgetInstanceSendContent(picojson::object const& args); + common::TizenResult WidgetInstanceGetContent(picojson::object const& args, const common::AsyncToken& token); static std::mutex listener_mutex_; std::map listener_map_; -- 2.34.1