[DeviceMotion] Code structure changed to match cordova architecture.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 11:39:48 +0000 (13:39 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 11:39:48 +0000 (13:39 +0200)
Change-Id: Ifa81b9b708b8c1abea9d71333776b4f8d565928f
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/cordova-api.gyp
src/devicemotion/cordova_devicemotion.gyp [deleted file]
src/devicemotion/cordova_devicemotion_api.js [deleted file]
src/devicemotion/cordova_devicemotion_extension.cc [deleted file]
src/devicemotion/cordova_devicemotion_extension.h [deleted file]
src/lib/cordova_plugins.js
src/lib/plugins/cordova-plugin-device-motion/tizen/Accelerometer.js [new file with mode: 0755]

index e4e0e868886d7dea3e04d25b1b552dca8389bbc9..9741543267bba69e54d22071ee1895bacb818e20 100644 (file)
@@ -9,7 +9,6 @@
       'type': 'none',
       'dependencies': [
         'cordova/cordova.gyp:*',
-        'devicemotion/cordova_devicemotion.gyp:*',
         'dialog/cordova_dialog.gyp:*',
         'events/cordova_events.gyp:*',
         'file/cordova_file.gyp:*',
diff --git a/src/devicemotion/cordova_devicemotion.gyp b/src/devicemotion/cordova_devicemotion.gyp
deleted file mode 100644 (file)
index 39990cf..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  'includes':[
-    '/usr/include/webapi-plugins/src/common/common.gypi',
-  ],
-  'targets': [
-    {
-      'target_name': 'tizen_cordova_devicemotion',
-      'type': 'loadable_module',
-      'sources': [
-        'cordova_devicemotion_api.js',
-        'cordova_devicemotion_extension.cc',
-        'cordova_devicemotion_extension.h',
-      ],
-      'include_dirs': [
-        '../',
-        '<(SHARED_INTERMEDIATE_DIR)',
-      ],
-      'variables': {
-        'packages': [
-          'webapi-plugins',
-        ],
-      },
-    },
-  ],
-}
diff --git a/src/devicemotion/cordova_devicemotion_api.js b/src/devicemotion/cordova_devicemotion_api.js
deleted file mode 100755 (executable)
index 353d0ee..0000000
+++ /dev/null
@@ -1,70 +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-motion.tizen.Accelerometer';
-
-cordova.define(plugin_name, function(require, exports, module) {
-// TODO: remove -> end
-
-var successCB = null;
-var count = 0;
-
-function listener(eventData) {
-  var accel = {};
-
-  accel.x = eventData.acceleration.x;
-  accel.y = eventData.acceleration.y;
-  accel.z = eventData.acceleration.z;
-  accel.timestamp = new Date().getTime();
-
-  if (accel.x === null || accel.y === null || accel.z === null) {
-    // Ignore first event with nulls
-    return;
-  }
-
-  if (count++ === 0) {
-    return;
-  }
-
-  successCB && successCB(accel);
-}
-
-var Accelerometer = {
-  start: function (success, error) {
-    if (!successCB) {
-      count = 0;
-      successCB = success;
-      window.addEventListener('devicemotion', listener, false);
-    }
-  }, stop: function () {
-    window.removeEventListener('devicemotion', listener, false);
-    successCB = null;
-  }
-};
-
-module.exports = Accelerometer;
-require('cordova/exec/proxy').add('Accelerometer', Accelerometer);
-
-console.log('Loaded cordova.device-motion API');
-
-// TODO: remove when added to public cordova repository -> begin
-});
-
-exports = function(require) {
-  require('cordova-tizen').addPlugin('cordova-plugin-device-motion.Accelerometer', plugin_name, 'runs');
-};
-// TODO: remove -> end
diff --git a/src/devicemotion/cordova_devicemotion_extension.cc b/src/devicemotion/cordova_devicemotion_extension.cc
deleted file mode 100755 (executable)
index 458e43b..0000000
+++ /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 "devicemotion/cordova_devicemotion_extension.h"
-
-// This will be generated from cordova_devicemotion_api.js
-extern const char kSource_cordova_devicemotion_api[];
-
-common::Extension* CreateExtension() {
-  return new extension::cordova::devicemotion::CordovaDevicemotionExtension();
-}
-
-namespace extension {
-namespace cordova {
-namespace devicemotion {
-
-CordovaDevicemotionExtension::CordovaDevicemotionExtension() {
-  SetExtensionName("tizen.cordova.devicemotion");
-  SetJavaScriptAPI(kSource_cordova_devicemotion_api);
-}
-
-CordovaDevicemotionExtension::~CordovaDevicemotionExtension() {}
-
-}  // devicemotion
-}  // cordova
-}  // extension
diff --git a/src/devicemotion/cordova_devicemotion_extension.h b/src/devicemotion/cordova_devicemotion_extension.h
deleted file mode 100755 (executable)
index 734f928..0000000
+++ /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 DEVICEMOTION_CORDOVA_DEVICEMOTION_EXTENSION_H_
-#define DEVICEMOTION_CORDOVA_DEVICEMOTION_EXTENSION_H_
-
-#include <common/extension.h>
-
-namespace extension {
-namespace cordova {
-namespace devicemotion {
-
-class CordovaDevicemotionExtension : public common::Extension {
- public:
-  CordovaDevicemotionExtension();
-  virtual ~CordovaDevicemotionExtension();
-};
-
-}  // devicemotion
-}  // cordova
-}  // extension
-
-#endif // DEVICEMOTION_CORDOVA_DEVICEMOTION_EXTENSION_H_
index f85b71202df33fee166a6a7774e36869b16b5850..7c2cb1d15678e4406d880cda28f57b6a659856bb 100644 (file)
@@ -40,6 +40,11 @@ module.exports = [
             "navigator.Acceleration"
         ]
     },
+    {
+      "file": "plugins/cordova-plugin-device-motion/tizen/Accelerometer.js",
+      "id": "cordova-plugin-device-motion.tizen.Accelerometer",
+      "runs": true
+    },
     {
         "file": "plugins/cordova-plugin-dialogs/www/notification.js",
         "id": "cordova-plugin-dialogs.notification",
diff --git a/src/lib/plugins/cordova-plugin-device-motion/tizen/Accelerometer.js b/src/lib/plugins/cordova-plugin-device-motion/tizen/Accelerometer.js
new file mode 100755 (executable)
index 0000000..b4e12ea
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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-motion.tizen.Accelerometer';
+
+cordova.define(plugin_name, function(require, exports, module) {
+// TODO: remove -> end
+
+var successCB = null;
+var count = 0;
+
+function listener(eventData) {
+  var accel = {};
+
+  accel.x = eventData.acceleration.x;
+  accel.y = eventData.acceleration.y;
+  accel.z = eventData.acceleration.z;
+  accel.timestamp = new Date().getTime();
+
+  if (accel.x === null || accel.y === null || accel.z === null) {
+    // Ignore first event with nulls
+    return;
+  }
+
+  if (count++ === 0) {
+    return;
+  }
+
+  successCB && successCB(accel);
+}
+
+var Accelerometer = {
+  start: function (success, error) {
+    if (!successCB) {
+      count = 0;
+      successCB = success;
+      window.addEventListener('devicemotion', listener, false);
+    }
+  }, stop: function () {
+    window.removeEventListener('devicemotion', listener, false);
+    successCB = null;
+  }
+};
+
+module.exports = Accelerometer;
+require('cordova/exec/proxy').add('Accelerometer', Accelerometer);
+
+console.log('Loaded cordova.device-motion API');
+
+// TODO: remove when added to public cordova repository -> begin
+});
+// TODO: remove -> end