cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtan...@apache.org
Subject [5/6] js commit: Added support for some more events in BB10
Date Thu, 04 Oct 2012 15:24:01 GMT
Added support for some more events in BB10

- online
- offline
- pause
- resume
- batterystatus
- batterylow
- batterycritical


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/dd9c8576
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/dd9c8576
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/dd9c8576

Branch: refs/heads/master
Commit: dd9c85766cc4ab4d66023a083e2c75c68a87a19a
Parents: 0e58060
Author: Gord Tanner <gtanner@gmail.com>
Authored: Wed Aug 29 14:23:40 2012 -0400
Committer: Gord Tanner <gtanner@gmail.com>
Committed: Thu Sep 27 17:35:51 2012 -0400

----------------------------------------------------------------------
 lib/webworks/qnx/platform.js                |   21 ++++++++++++++++-
 lib/webworks/qnx/plugin/manager.js          |    1 +
 lib/webworks/qnx/plugin/qnx/battery.js      |   16 +++++++++++++
 lib/webworks/qnx/plugin/qnx/fileTransfer.js |   26 ++++++++++++++++++++++
 4 files changed, 63 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd9c8576/lib/webworks/qnx/platform.js
----------------------------------------------------------------------
diff --git a/lib/webworks/qnx/platform.js b/lib/webworks/qnx/platform.js
index 8d1189f..3c7b4cc 100644
--- a/lib/webworks/qnx/platform.js
+++ b/lib/webworks/qnx/platform.js
@@ -19,9 +19,28 @@
  *
 */
 
+var cordova = require('cordova');
+
 module.exports = {
     id: "qnx",
-    initialize: function () { },
+    initialize: function () {
+        document.addEventListener("deviceready", function () {
+            blackberry.event.addEventListener("pause", function () {
+                cordova.fireDocumentEvent("pause");
+            });
+            blackberry.event.addEventListener("resume", function () {
+                cordova.fireDocumentEvent("resume");
+            });
+
+            window.addEventListener("online", function () {
+                cordova.fireDocumentEvent("online");
+            });
+
+            window.addEventListener("offline", function () {
+                cordova.fireDocumentEvent("offline");
+            });
+        });
+    },
     objects: {
         requestFileSystem:{
             path: 'cordova/plugin/qnx/requestFileSystem'

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd9c8576/lib/webworks/qnx/plugin/manager.js
----------------------------------------------------------------------
diff --git a/lib/webworks/qnx/plugin/manager.js b/lib/webworks/qnx/plugin/manager.js
index 9052bae..cfa6ebd 100644
--- a/lib/webworks/qnx/plugin/manager.js
+++ b/lib/webworks/qnx/plugin/manager.js
@@ -24,6 +24,7 @@ var cordova = require('cordova'),
         'NetworkStatus' : require('cordova/plugin/qnx/network'),
         'Accelerometer' : require('cordova/plugin/webworks/accelerometer'),
         'Device' : require('cordova/plugin/qnx/device'),
+        'Battery' : require('cordova/plugin/qnx/battery'),
         'Logger' : require('cordova/plugin/webworks/logger'),
         'Notification' : require('cordova/plugin/webworks/notification'),
         'Media': require('cordova/plugin/webworks/media')

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd9c8576/lib/webworks/qnx/plugin/qnx/battery.js
----------------------------------------------------------------------
diff --git a/lib/webworks/qnx/plugin/qnx/battery.js b/lib/webworks/qnx/plugin/qnx/battery.js
new file mode 100644
index 0000000..f1ae695
--- /dev/null
+++ b/lib/webworks/qnx/plugin/qnx/battery.js
@@ -0,0 +1,16 @@
+var cordova = require('cordova'),
+    handler;
+
+
+module.exports = {
+    start: function (args, win, fail) {
+        handler = win;
+        blackberry.event.addEventListener("batterystatus", handler);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    },
+
+    stop: function (args, win, fail) {
+        blackberry.event.removeEventListener("batterystatus", handler);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On
It" };
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd9c8576/lib/webworks/qnx/plugin/qnx/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/webworks/qnx/plugin/qnx/fileTransfer.js b/lib/webworks/qnx/plugin/qnx/fileTransfer.js
new file mode 100644
index 0000000..6010da0
--- /dev/null
+++ b/lib/webworks/qnx/plugin/qnx/fileTransfer.js
@@ -0,0 +1,26 @@
+var cordova = require('cordova');
+
+module.exports = {
+    download: function (args, win, fail) {
+        var source = args[0],
+            target = args[1];
+
+        blackberry.io.filetransfer.download(source, target, win, fail);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
+    },
+
+    upload: function (args, win, fail) {
+        var path = args[0],
+            server = args[1],
+            options = {
+                fileKey: args[2],
+                fileName: args[3],
+                mimeType: args[4],
+                params: args[5],
+                chunkedMode: args[6]
+            };
+
+        blackberry.io.filetransfer.upload(path, server, win, fail, options);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
+    }
+};


Mime
View raw message