You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/12/06 22:01:29 UTC
[3/4] js commit: add ubuntu platform
add ubuntu platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/9d74694a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/9d74694a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/9d74694a
Branch: refs/heads/3.3.x
Commit: 9d74694a61c603032c08ff638a6f1fd76273387c
Parents: e1fe3a5
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Fri Nov 22 19:48:44 2013 +0400
Committer: Steven Gill <st...@gmail.com>
Committed: Fri Dec 6 13:01:03 2013 -0800
----------------------------------------------------------------------
Gruntfile.js | 3 +-
lib/ubuntu/exec.js | 74 +++++++++++++++++++++++++++++++++++++++++++++
lib/ubuntu/platform.js | 30 ++++++++++++++++++
3 files changed, 106 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9d74694a/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 02de1d2..3fb4d32 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -33,7 +33,8 @@ module.exports = function(grunt) {
"test": {},
"windows8": { useWindowsLineEndings: true },
"windowsphone": { useWindowsLineEndings: true },
- "firefoxos": {}
+ "firefoxos": {},
+ "ubuntu": {}
},
clean: ['pkg'],
jshint: {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9d74694a/lib/ubuntu/exec.js
----------------------------------------------------------------------
diff --git a/lib/ubuntu/exec.js b/lib/ubuntu/exec.js
new file mode 100644
index 0000000..b9a107f
--- /dev/null
+++ b/lib/ubuntu/exec.js
@@ -0,0 +1,74 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * 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.
+ *
+*/
+var cordova = require('cordova'),
+ utils = require('cordova/utils');
+
+var callbackId = 1;
+cordova.callbacks = [];
+
+cordova.callback = function() {
+ var scId = arguments[0];
+ var callbackRef = null;
+
+ var parameters = [];
+ for (var i = 1; i < arguments.length; i++) {
+ parameters[i-1] = arguments[i];
+ }
+ callbackRef = cordova.callbacks[scId];
+
+ // Even IDs are success-, odd are error-callbacks - make sure we remove both
+ if ((scId % 2) !== 0) {
+ scId = scId - 1;
+ }
+ // Remove both the success as well as the error callback from the stack
+ delete cordova.callbacks[scId];
+ delete cordova.callbacks[scId + 1];
+
+ if (typeof callbackRef == "function") callbackRef.apply(this, parameters);
+};
+
+cordova.callbackWithoutRemove = function() {
+ var scId = arguments[0];
+ var callbackRef = null;
+
+ var parameters = [];
+ for (var i = 1; i < arguments.length; i++) {
+ parameters[i-1] = arguments[i];
+ }
+ callbackRef = cordova.callbacks[scId];
+
+ if (typeof(callbackRef) == "function") callbackRef.apply(this, parameters);
+};
+
+function ubuntuExec(success, fail, service, action, args) {
+ if (callbackId % 2) {
+ callbackId++;
+ }
+
+ var scId = callbackId++;
+ var ecId = callbackId++;
+ cordova.callbacks[scId] = success;
+ cordova.callbacks[ecId] = fail;
+
+ args.unshift(ecId);
+ args.unshift(scId);
+
+ navigator.qt.postMessage(JSON.stringify({messageType: "callPluginFunction", plugin: service, func: action, params: args}));
+}
+module.exports = ubuntuExec;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9d74694a/lib/ubuntu/platform.js
----------------------------------------------------------------------
diff --git a/lib/ubuntu/platform.js b/lib/ubuntu/platform.js
new file mode 100644
index 0000000..4b2ac03
--- /dev/null
+++ b/lib/ubuntu/platform.js
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * 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.
+ *
+*/
+module.exports = {
+ id: "ubuntu",
+ bootstrap: function() {
+ var channel = require("cordova/channel"),
+ cordova = require('cordova'),
+ exec = require('cordova/exec'),
+ modulemapper = require('cordova/modulemapper');
+
+ modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
+ require('cordova/channel').onNativeReady.fire();
+ }
+};