From: Pawel Andruszkiewicz Date: Thu, 7 Apr 2016 11:22:24 +0000 (+0200) Subject: [Device] Code structure changed to match cordova architecture. X-Git-Tag: submit/tizen/20160411.115901^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e06f67b60e448a7df400b0e43b00a95e7e6ba374;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git [Device] Code structure changed to match cordova architecture. Change-Id: I157d52bfb87d82eebd1c12ee618a81e6a0bee88d Signed-off-by: Pawel Andruszkiewicz --- diff --git a/src/cordova-api.gyp b/src/cordova-api.gyp index 0266c84..e4e0e86 100644 --- a/src/cordova-api.gyp +++ b/src/cordova-api.gyp @@ -9,7 +9,6 @@ 'type': 'none', 'dependencies': [ 'cordova/cordova.gyp:*', - 'device/cordova_device.gyp:*', 'devicemotion/cordova_devicemotion.gyp:*', 'dialog/cordova_dialog.gyp:*', 'events/cordova_events.gyp:*', diff --git a/src/device/cordova_device.gyp b/src/device/cordova_device.gyp deleted file mode 100644 index b57f435..0000000 --- a/src/device/cordova_device.gyp +++ /dev/null @@ -1,25 +0,0 @@ -{ - 'includes':[ - '/usr/include/webapi-plugins/src/common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_cordova_device', - 'type': 'loadable_module', - 'sources': [ - 'cordova_device_api.js', - 'cordova_device_extension.cc', - 'cordova_device_extension.h', - ], - 'include_dirs': [ - '../', - '<(SHARED_INTERMEDIATE_DIR)', - ], - 'variables': { - 'packages': [ - 'webapi-plugins', - ], - }, - }, - ], -} diff --git a/src/device/cordova_device_api.js b/src/device/cordova_device_api.js deleted file mode 100755 index b154467..0000000 --- a/src/device/cordova_device_api.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// TODO: remove when added to public cordova repository -> begin -var plugin_name = 'cordova-plugin-device.tizen.Device'; - -cordova.define(plugin_name, function(require, exports, module) { -// TODO: remove -> end - -function DeviceInfo() { - this.cordovaVersion = require('cordova/platform').cordovaVersion; - this.model = tizen.systeminfo.getCapability('http://tizen.org/system/model_name'); - this.platform = tizen.systeminfo.getCapability('http://tizen.org/system/platform.name'); - this.uuid = tizen.systeminfo.getCapability('http://tizen.org/system/tizenid'); - this.version = tizen.systeminfo.getCapability('http://tizen.org/feature/platform.version'); - this.manufacturer = tizen.systeminfo.getCapability('http://tizen.org/system/manufacturer'); - this.isVirtual = -1 !== this.model.toLowerCase().indexOf('emulator'); - this.serial = this.uuid; -} - -var di; - -exports = { - getDeviceInfo: function (success, error) { - if (!di) { - di = new DeviceInfo(); - } - success({ - cordova: di.cordovaVersion, - model: di.model, - platform: di.platform, - uuid: di.uuid, - version: di.version, - manufacturer: di.manufacturer, // not documented, but required by tests - isVirtual: di.isVirtual, - serial: di.serial - }); - } -}; - -require("cordova/exec/proxy").add("Device", exports); - -console.log('Loaded cordova.device API'); - -// TODO: remove when added to public cordova repository -> begin -}); - -exports = function(require) { - require('cordova-tizen').addPlugin('cordova-plugin-device.device', plugin_name, 'runs'); -}; -// TODO: remove -> end diff --git a/src/device/cordova_device_extension.cc b/src/device/cordova_device_extension.cc deleted file mode 100755 index 7287d0c..0000000 --- a/src/device/cordova_device_extension.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "device/cordova_device_extension.h" - -// This will be generated from cordova_device_api.js -extern const char kSource_cordova_device_api[]; - -common::Extension* CreateExtension() { - return new extension::cordova::device::CordovaDeviceExtension(); -} - -namespace extension { -namespace cordova { -namespace device { - -CordovaDeviceExtension::CordovaDeviceExtension() { - SetExtensionName("tizen.cordova.device"); - SetJavaScriptAPI(kSource_cordova_device_api); -} - -CordovaDeviceExtension::~CordovaDeviceExtension() {} - -} // device -} // cordova -} // extension diff --git a/src/device/cordova_device_extension.h b/src/device/cordova_device_extension.h deleted file mode 100755 index 93a8072..0000000 --- a/src/device/cordova_device_extension.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DEVICE_CORDOVA_DEVICE_EXTENSION_H_ -#define DEVICE_CORDOVA_DEVICE_EXTENSION_H_ - -#include - -namespace extension { -namespace cordova { -namespace device { - -class CordovaDeviceExtension : public common::Extension { - public: - CordovaDeviceExtension(); - virtual ~CordovaDeviceExtension(); -}; - -} // device -} // cordova -} // extension - -#endif // DEVICE_CORDOVA_DEVICE_EXTENSION_H_ diff --git a/src/lib/cordova_plugins.js b/src/lib/cordova_plugins.js index 672cfbd..f85b712 100644 --- a/src/lib/cordova_plugins.js +++ b/src/lib/cordova_plugins.js @@ -21,6 +21,11 @@ module.exports = [ "device" ] }, + { + "file": "plugins/cordova-plugin-device/tizen/Device.js", + "id": "cordova-plugin-device.tizen.Device", + "runs": true + }, { "file": "plugins/cordova-plugin-device-motion/www/accelerometer.js", "id": "cordova-plugin-device-motion.Accelerometer", diff --git a/src/lib/plugins/cordova-plugin-device/tizen/Device.js b/src/lib/plugins/cordova-plugin-device/tizen/Device.js new file mode 100755 index 0000000..34da27c --- /dev/null +++ b/src/lib/plugins/cordova-plugin-device/tizen/Device.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +var plugin_name = 'cordova-plugin-device.tizen.Device'; + +cordova.define(plugin_name, function(require, exports, module) { +// TODO: remove -> end + +function DeviceInfo() { + this.cordovaVersion = require('cordova/platform').cordovaVersion; + this.model = tizen.systeminfo.getCapability('http://tizen.org/system/model_name'); + this.platform = tizen.systeminfo.getCapability('http://tizen.org/system/platform.name'); + this.uuid = tizen.systeminfo.getCapability('http://tizen.org/system/tizenid'); + this.version = tizen.systeminfo.getCapability('http://tizen.org/feature/platform.version'); + this.manufacturer = tizen.systeminfo.getCapability('http://tizen.org/system/manufacturer'); + this.isVirtual = -1 !== this.model.toLowerCase().indexOf('emulator'); + this.serial = this.uuid; +} + +var di; + +exports = { + getDeviceInfo: function (success, error) { + if (!di) { + di = new DeviceInfo(); + } + success({ + cordova: di.cordovaVersion, + model: di.model, + platform: di.platform, + uuid: di.uuid, + version: di.version, + manufacturer: di.manufacturer, // not documented, but required by tests + isVirtual: di.isVirtual, + serial: di.serial + }); + } +}; + +require("cordova/exec/proxy").add("Device", exports); + +console.log('Loaded cordova.device API'); + +// TODO: remove when added to public cordova repository -> begin +}); +// TODO: remove -> end