Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Framework] Fixed line endings (CRLF -> LF)

  • Loading branch information...
commit da98fc451c8de0e36c15df2f3ce6d55bdcb00501 1 parent 155ce93
James Keshavarzi jkeshavarzi authored
Showing with 6,575 additions and 6,575 deletions.
  1. +23 −23 dependencies/bootstrap/index.html
  2. +3,366 −3,366 dependencies/cpplint/cpplint.py
  3. +5 −5 dependencies/test-server/.gitignore
  4. +37 −37 dependencies/test-server/README.md
  5. +71 −71 dependencies/test-server/app.js
  6. +260 −260 dependencies/test-server/job.js
  7. +34 −34 dependencies/test-server/widget/config.xml
  8. +17 −17 dist.xml
  9. +85 −85 ext/blackberry.app/index.js
  10. +53 −53 ext/blackberry.app/navEvents.js
  11. +37 −37 ext/blackberry.connection/connectionEvents.js
  12. +109 −109 ext/blackberry.connection/connectionJNEXT.js
  13. +79 −79 ext/blackberry.event/index.js
  14. +31 −31 ext/blackberry.identity/client.js
  15. +36 −36 ext/blackberry.identity/index.js
  16. +189 −189 ext/blackberry.system/index.js
  17. +22 −22 lib/config.js
  18. +71 −71 lib/config/default.js
  19. +40 −40 lib/event.js
  20. +69 −69 lib/exception.js
  21. +175 −175 lib/policy/folderAccess.js
  22. +297 −297 lib/policy/whitelist.js
  23. +93 −93 lib/public/event.js
  24. +59 −59 lib/public/testbed_event.html
  25. +21 −21 lib/public/window.js
  26. +87 −87 lib/webkitEvent.js
  27. +77 −77 lib/webview.js
  28. +163 −163 test/functional/blackberry.app.js
  29. +28 −28 test/functional/blackberry.event.js
  30. +35 −35 test/functional/blackberry.identity.js
  31. +86 −86 test/functional/blackberry.invoke.js
  32. +23 −23 test/functional/blackberry.ui.dialog.js
  33. +57 −57 test/unit/ext/blackberry.connection/connectionEvents.js
  34. +81 −81 test/unit/ext/blackberry.identity/client.js
  35. +73 −73 test/unit/ext/blackberry.identity/index.js
  36. +91 −91 test/unit/ext/blackberry.invoke/client.js
  37. +189 −189 test/unit/ext/blackberry.system/index.js
  38. +51 −51 test/unit/lib/event.js
  39. +94 −94 test/unit/lib/public/builder.js
  40. +161 −161 test/unit/lib/public/event.js
46 dependencies/bootstrap/index.html
View
@@ -1,23 +1,23 @@
-<!DOCTYPE HTML>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="user-scalable=no, target-densitydpi=device-dpi, width=device-width">
- <title>WebWorks For BBX Bootstrap</title>
- <script src="./require.js"></script>
- <script src="./webplatform.js"></script>
- <script src="./frameworkModules.js"></script>
- <script>
- function start() {
- //Must load jnext first, as there seemed to be a race condition for if it was defined before it was used
- require("lib/jnext.js");
- require(frameworkModules, function () {
- require('lib/framework').start();
- });
- }
- </script>
- </head>
- <body onload="start();">
- I am the man behind the curtain.
- </body>
-</html>
+<!DOCTYPE HTML>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="user-scalable=no, target-densitydpi=device-dpi, width=device-width">
+ <title>WebWorks For BBX Bootstrap</title>
+ <script src="./require.js"></script>
+ <script src="./webplatform.js"></script>
+ <script src="./frameworkModules.js"></script>
+ <script>
+ function start() {
+ //Must load jnext first, as there seemed to be a race condition for if it was defined before it was used
+ require("lib/jnext.js");
+ require(frameworkModules, function () {
+ require('lib/framework').start();
+ });
+ }
+ </script>
+ </head>
+ <body onload="start();">
+ I am the man behind the curtain.
+ </body>
+</html>
6,732 dependencies/cpplint/cpplint.py 100755 → 100644
View
3,366 additions, 3,366 deletions not shown
10 dependencies/test-server/.gitignore
View
@@ -1,6 +1,6 @@
-node_modules/
-workspace/
-widget/device/
-widget/simulator/
-widget/widget.zip
+node_modules/
+workspace/
+widget/device/
+widget/simulator/
+widget/widget.zip
public/spec/
74 dependencies/test-server/README.md
View
@@ -1,37 +1,37 @@
-#BB10 WebWorks Jasmine Functional Tests
-#### Automated Testing on a Blackberry Tablet
-
-### Requirements
-- Playbook device/simulator
-- node(v0.6.12) & npm
-- [Windows] zip cli. Place `http://stahlworks.com/dev/zip.exe` in your Windows folder.
-
-### Instructions
-###### Setup
-`~ ./configure`<br/>
-
-###### Configuration
-- Open `job.js` and edit
- - edit `DEVICE` true if running on a device. false if running on a simulator
- - edit `DEVICE_IP` & `DEVICE_PASSWORD`
- - edit `LOCAL_PACKAGER` e.g. C:/Users/adrilee/Desktop/50 (use forward slashes)
-- Open `widget/config.xml` and edit
- - Whitelist your features/extensions
- - `<content src="http://<server-hostname-ip>:3000">`
- - `<access uri="http://<server-hostname-ip>:3000">`
-- Open `public/index.html` and add the specs found in your test/functional directory
- - e.g. if blackberry.app.js exists in the test/functional folder, then add `<script type="text/javascript" src="spec/blackberry.app.js"></script>` in the `<head>` tag of the index.html file
-
-###### Run server
-`~ node app.js`
-
-### How to use
-###### Testing on your local machine
-- Make sure `LOCAL_PACKAGER` has been specified as the absolute path to your Webworks Packager
-- Use Browser and visit site `http://<server-hostname-ip>:3000/run` e.g. http://localhost:3000/run
-
-###### Testing using Hudson
-- Send a HTTP GET request to
-`http://<server-hostname-ip>/run/<job-name-on-hudson>`
-and expect response to be results of tests.
-
+#BB10 WebWorks Jasmine Functional Tests
+#### Automated Testing on a Blackberry Tablet
+
+### Requirements
+- Playbook device/simulator
+- node(v0.6.12) & npm
+- [Windows] zip cli. Place `http://stahlworks.com/dev/zip.exe` in your Windows folder.
+
+### Instructions
+###### Setup
+`~ ./configure`<br/>
+
+###### Configuration
+- Open `job.js` and edit
+ - edit `DEVICE` true if running on a device. false if running on a simulator
+ - edit `DEVICE_IP` & `DEVICE_PASSWORD`
+ - edit `LOCAL_PACKAGER` e.g. C:/Users/adrilee/Desktop/50 (use forward slashes)
+- Open `widget/config.xml` and edit
+ - Whitelist your features/extensions
+ - `<content src="http://<server-hostname-ip>:3000">`
+ - `<access uri="http://<server-hostname-ip>:3000">`
+- Open `public/index.html` and add the specs found in your test/functional directory
+ - e.g. if blackberry.app.js exists in the test/functional folder, then add `<script type="text/javascript" src="spec/blackberry.app.js"></script>` in the `<head>` tag of the index.html file
+
+###### Run server
+`~ node app.js`
+
+### How to use
+###### Testing on your local machine
+- Make sure `LOCAL_PACKAGER` has been specified as the absolute path to your Webworks Packager
+- Use Browser and visit site `http://<server-hostname-ip>:3000/run` e.g. http://localhost:3000/run
+
+###### Testing using Hudson
+- Send a HTTP GET request to
+`http://<server-hostname-ip>/run/<job-name-on-hudson>`
+and expect response to be results of tests.
+
142 dependencies/test-server/app.js
View
@@ -1,72 +1,72 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 http = require('http'),
- express = require('express'),
- events = require('events'),
- eventEmitter = new events.EventEmitter();
- app = express.createServer(),
- job = require('./job');
-
-app.configure(function() {
- app.use(express.bodyParser())
- app.use(express.static(__dirname + '/public'))
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true}))
-});
-
-
-app.get('/run', function(req, res) {
- job.run(null, function (err) {
- if (err) {
- console.log('ERROR: ' + err);
- res.send(err);
- } else {
- eventEmitter.on('results', function(message){
- console.log(message);
- res.send(message);
- })
- }
- });
-});
-
-app.get('/run/:job', function(req, res) {
- job.run(req.params.job, function (err) {
- if (err) {
- console.log('ERROR: ' + err);
- res.send(err);
- } else {
- eventEmitter.on('results', function(message){
- console.log(message);
- res.send(message);
- })
- }
- });
-});
-
-app.post('/results', function(req, res) {
- console.log(req.body);
- if (req.body) {
- console.log(req);
- eventEmitter.emit('results', req.body);
- res.send('OK');
- }
-});
-
-
-var port = 3000;
-app.listen(port);
-
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 http = require('http'),
+ express = require('express'),
+ events = require('events'),
+ eventEmitter = new events.EventEmitter();
+ app = express.createServer(),
+ job = require('./job');
+
+app.configure(function() {
+ app.use(express.bodyParser())
+ app.use(express.static(__dirname + '/public'))
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true}))
+});
+
+
+app.get('/run', function(req, res) {
+ job.run(null, function (err) {
+ if (err) {
+ console.log('ERROR: ' + err);
+ res.send(err);
+ } else {
+ eventEmitter.on('results', function(message){
+ console.log(message);
+ res.send(message);
+ })
+ }
+ });
+});
+
+app.get('/run/:job', function(req, res) {
+ job.run(req.params.job, function (err) {
+ if (err) {
+ console.log('ERROR: ' + err);
+ res.send(err);
+ } else {
+ eventEmitter.on('results', function(message){
+ console.log(message);
+ res.send(message);
+ })
+ }
+ });
+});
+
+app.post('/results', function(req, res) {
+ console.log(req.body);
+ if (req.body) {
+ console.log(req);
+ eventEmitter.emit('results', req.body);
+ res.send('OK');
+ }
+});
+
+
+var port = 3000;
+app.listen(port);
+
console.log('Server now listening on port ' + port);
520 dependencies/test-server/job.js
View
@@ -1,261 +1,261 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 fs = require('fs'),
- fs_extra = require('fs-extra'),
- http = require('http'),
- url = require('url'),
- path = require("path"),
- childProcess = require("child_process"),
- wrench = require("wrench"),
- zip = require("zip"),
- _widget = path.normalize(__dirname + "/widget"),
- _workspace = path.normalize(__dirname + "/workspace"),
- _functional_dir = path.normalize(__dirname + "/../../test/functional"),
- _spec_dir = path.normalize(__dirname + "/public/spec"),
- DEVICE_IP = "192.168.198.128",
- DEVICE_PASSWORD = "123",
- BUILD_ON_HUDSON = false,
- LOCAL_PACKAGER = "C:/Users/adrilee/Desktop/50";
-
-function prepare(job, callback) {
- var PACKAGER_URL = "http://mac-ci:9000/job/" + job + "/ws/target/zip/*zip*/zip.zip",
- EXECUTABLES_URL = "http://mac-ci:9000/job/" + job + "/ws/target/dependency/*zip*/dependency.zip",
- FUNCTIONAL_TEST_URL = "http://mac-ci:9000/job/" + job + "/ws/Framework/ext/test/functional/*zip*/functional.zip",
- PACKAGER_FILENAME = "/zip.zip",
- EXECUTABLES_FILENAME = "/dependency.zip",
- FUNCTIONAL_TEST_FILENAME = "/functional.zip";
-
- // TODO: Do a CLEAN/Delete workspace first
- if (!path.existsSync(_workspace)) {
- console.log('CREATE: new workspace')
- fs.mkdirSync(_workspace, "0755");
- } else {
- console.log('DELETE: old workspace')
- wrench.rmdirSyncRecursive(_workspace);
- console.log('CREATE: new workspace')
- fs.mkdirSync(_workspace, "0755");
- }
-
- if (BUILD_ON_HUDSON) {
- // grab functional tests from framework/ext/test.functional and place in workpace/public/spec
- downloadUnzipDelete(PACKAGER_URL, PACKAGER_FILENAME, function() {
- downloadUnzipDelete(EXECUTABLES_URL, EXECUTABLES_FILENAME, function() {
- wrench.copyDirSyncRecursive(_workspace + "/dependency", _workspace + "/zip/dependencies");
- downloadUnzipDelete(FUNCTIONAL_TEST_URL, FUNCTIONAL_TEST_FILENAME, callback);
- });
- });
-
- function downloadUnzipDelete(url, filename, callback) {
- downloadDependency(url, filename, function (err) {
- if (err) {
- callback(err);
- } else {
- unzipDependency(filename, function (err) {
- if (err) {
- callback(err);
- } else {
- fs.unlinkSync(_workspace + filename);
- callback();
- }
- });
- }
- });
- }
- } else {
- // copy framwork/test.functional content to test-server/public/spec dir.
- wrench.copyDirSyncRecursive(_functional_dir, _spec_dir);
- fs_extra.copyFileSync(LOCAL_PACKAGER + "/Framework/clientFiles/webworks.js", path.normalize(__dirname + "/public/webworks.js"));
- callback();
- }
-}
-
-function downloadDependency(source, destination, callback) {
- var _url = url.parse(source),
- _destination = _workspace + destination,
- req;
-
- if (!path.existsSync(_destination)) {
- console.log("DL&UNZIP: " + destination);
-
- // TODO: check HTTP response status code for
-
- req = http.get({'host': 'mac-ci', 'port': '9000', 'path': _url.pathname}, function (res) {
- if (res.statusCode !== 200) {
- callback("downloadDependency - http request status: " + res.statusCode);
- } else {
- var stream = fs.createWriteStream(_destination);
- res.pipe(stream);
- res.on('end', function () {
- callback();
- });
- }
- }).on('error', function (e) {
- callback('downloadDependency - Unable to Download Dependency: ' + e.message);
- });
-
- req.on('error', function (e) {
- callback('downloadDependency - Problem with request: ' + e.message);
- });
- } else {
- console.log("SKIP-DL&UNZIP: " + destination);
- callback();
- }
-}
-
-function unzipDependency(target, callback) {
- var data,
- filesObj,
- p,
- parent,
- to = _workspace;
-
- if (!path.existsSync(_workspace + target)) {
- callback('.zip is missing ...');
- }
-
- data = fs.readFileSync(_workspace + target);
- filesObj = zip.Reader(data).toObject();
-
- if (!path.existsSync(to)) {
- wrench.mkdirSyncRecursive(to, "0755");
- }
-
- for (p in filesObj) {
- if (p.split("/").length > 1) {
- parent = p.split("/").slice(0, -1).join("/");
- wrench.mkdirSyncRecursive(to + "/" + parent, "0755");
- }
-
- fs.writeFileSync(to + "/" + p, filesObj[p]);
- }
- callback();
-}
-
-function execute(cmd, callback) {
- childProcess.exec(cmd, function (error, stdout, stderr) {
- console.log('EXECUTE: ' + cmd);
- console.log(stdout);
- if (error) {
- callback();
- } else {
- callback();
- }
- });
-}
-
-function spawn(cmd, callback) {
- var cmd_split = cmd.split(" "),
- success = false,
- array = [],
- sh;
-
- for (i=1; i <= cmd_split.length-1; i++) {
- array.push(cmd_split[i]);
- }
-
- sh = childProcess.spawn(cmd_split[0], array);
-
- sh.stdout.on('data', function (data) {
- console.log('stdout: ' + data);
- if (data.toString().indexOf('success') !== -1) {
- success = true;
- }
- });
-
- sh.stderr.on('data', function (data) {
- console.log('stderr: ' + data);
- });
-
- sh.on('exit', function (code) {
- console.log('child process exited with code ' + code);
- if (!success) {
- callback(false);
- } else {
- callback(true);
- }
-
- });
-}
-
-function package(callback) {
- // TODO: generate config.xml
-
- // ZIP widget & BBWP Package
- function packageWidget() {
- var package_cmd;
-
- if (BUILD_ON_HUDSON) {
- package_cmd = _workspace + "/zip/bbwp " + _widget + "/widget.zip -d";
- } else {
- package_cmd = LOCAL_PACKAGER + "/bbwp " + _widget + "/widget.zip -d";
- }
-
- execute(package_cmd, callback);
- }
-
- var zip_cmd = "cd " + _widget + " && " + "zip widget.zip config.xml";
-
- execute(zip_cmd, packageWidget);
-}
-
-
-function deploy(callback) {
- var deploy_cmd;
-
- if (BUILD_ON_HUDSON) {
- deploy_cmd = _workspace + "/zip/dependencies/tools/bin/blackberry-deploy" + (require(LOCAL_PACKAGER + "/lib/packager-utils.js").isWindows() ? ".bat" : "") + " -package " + _widget + "/simulator/widget.bar " +
- "-device " + DEVICE_IP + " -password " + DEVICE_PASSWORD + " -installApp -launchApp";
- } else {
- deploy_cmd = LOCAL_PACKAGER + "/dependencies/tools/bin/blackberry-deploy" + (require(LOCAL_PACKAGER + "/lib/packager-utils.js").isWindows() ? ".bat" : "") + " -package " + _widget + "/simulator/widget.bar " +
- "-device " + DEVICE_IP + " -password " + DEVICE_PASSWORD + " -installApp -launchApp";
- }
-
- console.log('DEPLOY: ' + deploy_cmd);
- spawn(deploy_cmd, function (success) {
- if (!success) {
- spawn(deploy_cmd, function (success) {
- if (!success) {
- callback("DEPLOY: Unable to get success status")
- } else {
- callback();
- }
- });
- } else {
- callback();
- }
- });
-}
-
-_self = {
- run: function (job, callback) {
- prepare(job, function (err) {
- if (err) {
- callback(err);
- } else {
- package(function (err) {
- if (err) {
- callback(err);
- } else {
- deploy(callback);
- }
- });
- }
- });
- }
-};
-
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 fs = require('fs'),
+ fs_extra = require('fs-extra'),
+ http = require('http'),
+ url = require('url'),
+ path = require("path"),
+ childProcess = require("child_process"),
+ wrench = require("wrench"),
+ zip = require("zip"),
+ _widget = path.normalize(__dirname + "/widget"),
+ _workspace = path.normalize(__dirname + "/workspace"),
+ _functional_dir = path.normalize(__dirname + "/../../test/functional"),
+ _spec_dir = path.normalize(__dirname + "/public/spec"),
+ DEVICE_IP = "192.168.198.128",
+ DEVICE_PASSWORD = "123",
+ BUILD_ON_HUDSON = false,
+ LOCAL_PACKAGER = "C:/Users/adrilee/Desktop/50";
+
+function prepare(job, callback) {
+ var PACKAGER_URL = "http://mac-ci:9000/job/" + job + "/ws/target/zip/*zip*/zip.zip",
+ EXECUTABLES_URL = "http://mac-ci:9000/job/" + job + "/ws/target/dependency/*zip*/dependency.zip",
+ FUNCTIONAL_TEST_URL = "http://mac-ci:9000/job/" + job + "/ws/Framework/ext/test/functional/*zip*/functional.zip",
+ PACKAGER_FILENAME = "/zip.zip",
+ EXECUTABLES_FILENAME = "/dependency.zip",
+ FUNCTIONAL_TEST_FILENAME = "/functional.zip";
+
+ // TODO: Do a CLEAN/Delete workspace first
+ if (!path.existsSync(_workspace)) {
+ console.log('CREATE: new workspace')
+ fs.mkdirSync(_workspace, "0755");
+ } else {
+ console.log('DELETE: old workspace')
+ wrench.rmdirSyncRecursive(_workspace);
+ console.log('CREATE: new workspace')
+ fs.mkdirSync(_workspace, "0755");
+ }
+
+ if (BUILD_ON_HUDSON) {
+ // grab functional tests from framework/ext/test.functional and place in workpace/public/spec
+ downloadUnzipDelete(PACKAGER_URL, PACKAGER_FILENAME, function() {
+ downloadUnzipDelete(EXECUTABLES_URL, EXECUTABLES_FILENAME, function() {
+ wrench.copyDirSyncRecursive(_workspace + "/dependency", _workspace + "/zip/dependencies");
+ downloadUnzipDelete(FUNCTIONAL_TEST_URL, FUNCTIONAL_TEST_FILENAME, callback);
+ });
+ });
+
+ function downloadUnzipDelete(url, filename, callback) {
+ downloadDependency(url, filename, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ unzipDependency(filename, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ fs.unlinkSync(_workspace + filename);
+ callback();
+ }
+ });
+ }
+ });
+ }
+ } else {
+ // copy framwork/test.functional content to test-server/public/spec dir.
+ wrench.copyDirSyncRecursive(_functional_dir, _spec_dir);
+ fs_extra.copyFileSync(LOCAL_PACKAGER + "/Framework/clientFiles/webworks.js", path.normalize(__dirname + "/public/webworks.js"));
+ callback();
+ }
+}
+
+function downloadDependency(source, destination, callback) {
+ var _url = url.parse(source),
+ _destination = _workspace + destination,
+ req;
+
+ if (!path.existsSync(_destination)) {
+ console.log("DL&UNZIP: " + destination);
+
+ // TODO: check HTTP response status code for
+
+ req = http.get({'host': 'mac-ci', 'port': '9000', 'path': _url.pathname}, function (res) {
+ if (res.statusCode !== 200) {
+ callback("downloadDependency - http request status: " + res.statusCode);
+ } else {
+ var stream = fs.createWriteStream(_destination);
+ res.pipe(stream);
+ res.on('end', function () {
+ callback();
+ });
+ }
+ }).on('error', function (e) {
+ callback('downloadDependency - Unable to Download Dependency: ' + e.message);
+ });
+
+ req.on('error', function (e) {
+ callback('downloadDependency - Problem with request: ' + e.message);
+ });
+ } else {
+ console.log("SKIP-DL&UNZIP: " + destination);
+ callback();
+ }
+}
+
+function unzipDependency(target, callback) {
+ var data,
+ filesObj,
+ p,
+ parent,
+ to = _workspace;
+
+ if (!path.existsSync(_workspace + target)) {
+ callback('.zip is missing ...');
+ }
+
+ data = fs.readFileSync(_workspace + target);
+ filesObj = zip.Reader(data).toObject();
+
+ if (!path.existsSync(to)) {
+ wrench.mkdirSyncRecursive(to, "0755");
+ }
+
+ for (p in filesObj) {
+ if (p.split("/").length > 1) {
+ parent = p.split("/").slice(0, -1).join("/");
+ wrench.mkdirSyncRecursive(to + "/" + parent, "0755");
+ }
+
+ fs.writeFileSync(to + "/" + p, filesObj[p]);
+ }
+ callback();
+}
+
+function execute(cmd, callback) {
+ childProcess.exec(cmd, function (error, stdout, stderr) {
+ console.log('EXECUTE: ' + cmd);
+ console.log(stdout);
+ if (error) {
+ callback();
+ } else {
+ callback();
+ }
+ });
+}
+
+function spawn(cmd, callback) {
+ var cmd_split = cmd.split(" "),
+ success = false,
+ array = [],
+ sh;
+
+ for (i=1; i <= cmd_split.length-1; i++) {
+ array.push(cmd_split[i]);
+ }
+
+ sh = childProcess.spawn(cmd_split[0], array);
+
+ sh.stdout.on('data', function (data) {
+ console.log('stdout: ' + data);
+ if (data.toString().indexOf('success') !== -1) {
+ success = true;
+ }
+ });
+
+ sh.stderr.on('data', function (data) {
+ console.log('stderr: ' + data);
+ });
+
+ sh.on('exit', function (code) {
+ console.log('child process exited with code ' + code);
+ if (!success) {
+ callback(false);
+ } else {
+ callback(true);
+ }
+
+ });
+}
+
+function package(callback) {
+ // TODO: generate config.xml
+
+ // ZIP widget & BBWP Package
+ function packageWidget() {
+ var package_cmd;
+
+ if (BUILD_ON_HUDSON) {
+ package_cmd = _workspace + "/zip/bbwp " + _widget + "/widget.zip -d";
+ } else {
+ package_cmd = LOCAL_PACKAGER + "/bbwp " + _widget + "/widget.zip -d";
+ }
+
+ execute(package_cmd, callback);
+ }
+
+ var zip_cmd = "cd " + _widget + " && " + "zip widget.zip config.xml";
+
+ execute(zip_cmd, packageWidget);
+}
+
+
+function deploy(callback) {
+ var deploy_cmd;
+
+ if (BUILD_ON_HUDSON) {
+ deploy_cmd = _workspace + "/zip/dependencies/tools/bin/blackberry-deploy" + (require(LOCAL_PACKAGER + "/lib/packager-utils.js").isWindows() ? ".bat" : "") + " -package " + _widget + "/simulator/widget.bar " +
+ "-device " + DEVICE_IP + " -password " + DEVICE_PASSWORD + " -installApp -launchApp";
+ } else {
+ deploy_cmd = LOCAL_PACKAGER + "/dependencies/tools/bin/blackberry-deploy" + (require(LOCAL_PACKAGER + "/lib/packager-utils.js").isWindows() ? ".bat" : "") + " -package " + _widget + "/simulator/widget.bar " +
+ "-device " + DEVICE_IP + " -password " + DEVICE_PASSWORD + " -installApp -launchApp";
+ }
+
+ console.log('DEPLOY: ' + deploy_cmd);
+ spawn(deploy_cmd, function (success) {
+ if (!success) {
+ spawn(deploy_cmd, function (success) {
+ if (!success) {
+ callback("DEPLOY: Unable to get success status")
+ } else {
+ callback();
+ }
+ });
+ } else {
+ callback();
+ }
+ });
+}
+
+_self = {
+ run: function (job, callback) {
+ prepare(job, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ package(function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ deploy(callback);
+ }
+ });
+ }
+ });
+ }
+};
+
module.exports = _self;
68 dependencies/test-server/widget/config.xml
View
@@ -1,35 +1,35 @@
-<?xml version="1.0" encoding="utf-8"?>
-<widget xmlns=" http://www.w3.org/ns/widgets"
- xmlns:rim="http://www.blackberry.com/ns/widgets"
- version="1.0.0"
- id="jasmine">
-
- <name>Jasmine</name>
-
- <description>This application points to a the functional test server.</description>
-
- <content src="http://10.137.40.49:3000"/>
-
- <author rim:copyright="Copyright 1998-2011 My Corp" email="hello.bob@blah.com" href="http://www.blah.com">Research In Motion Ltd.</author>
-
- <access subdomains="true" uri="http://10.137.40.49:3000">
- <feature id="blackberry.app" required="true" version="1.0.0.0"/>
- <feature id="blackberry.app" required="true" version="1.0.0.0"/>
- </access>
-
- <license href="http://www.apache.org/licenses/LICENSE-2.0">
- 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.
- </license>
- <rim:permissions>
- <rim:permit>read_device_identifying_information</rim:permit>
- </rim:permissions>
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns=" http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.0.0"
+ id="jasmine">
+
+ <name>Jasmine</name>
+
+ <description>This application points to a the functional test server.</description>
+
+ <content src="http://10.137.40.49:3000"/>
+
+ <author rim:copyright="Copyright 1998-2011 My Corp" email="hello.bob@blah.com" href="http://www.blah.com">Research In Motion Ltd.</author>
+
+ <access subdomains="true" uri="http://10.137.40.49:3000">
+ <feature id="blackberry.app" required="true" version="1.0.0.0"/>
+ <feature id="blackberry.app" required="true" version="1.0.0.0"/>
+ </access>
+
+ <license href="http://www.apache.org/licenses/LICENSE-2.0">
+ 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.
+ </license>
+ <rim:permissions>
+ <rim:permit>read_device_identifying_information</rim:permit>
+ </rim:permissions>
</widget>
34 dist.xml
View
@@ -1,17 +1,17 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>framework</id>
- <formats>
- <format>zip</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <baseDirectory>/</baseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target/zip</directory>
- <outputDirectory></outputDirectory>
- </fileSet>
- </fileSets>
-</assembly>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>framework</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <baseDirectory>/</baseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/zip</directory>
+ <outputDirectory></outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
170 ext/blackberry.app/index.js
View
@@ -1,85 +1,85 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 _config = require("./../../lib/config"),
- _event = require("./../../lib/event"),
- _eventExt = require("./../blackberry.event/index"),
- _actionMap = {
- pause: {
- context: require("./navEvents"),
- event: "pause",
- trigger: function () {
- _event.trigger("pause");
- }
- },
- resume: {
- context: require("./navEvents"),
- event: "resume",
- trigger: function () {
- _event.trigger("resume");
- }
- }
- };
-
-module.exports = {
- registerEvents: function (success, fail, args, env) {
- try {
- _eventExt.registerEvents(_actionMap);
- success();
- } catch (e) {
- fail(-1, e);
- }
- },
-
- author: function (success, fail, args, env) {
- success(_config.author);
- },
-
- authorEmail: function (success, fail, args, env) {
- success(_config.authorEmail);
- },
-
- authorURL: function (success, fail, args, env) {
- success(_config.authorURL);
- },
-
- copyright: function (success, fail, args, env) {
- success(_config.copyright);
- },
-
- description: function (success, fail, args, env) {
- success(_config.description);
- },
-
- id: function (success, fail, args, env) {
- success(_config.id);
- },
-
- license: function (success, fail, args, env) {
- success(_config.license);
- },
-
- licenseURL: function (success, fail, args, env) {
- success(_config.licenseURL);
- },
-
- name: function (success, fail, args, env) {
- success(_config.name);
- },
-
- version: function (success, fail, args, env) {
- success(_config.version);
- }
-};
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 _config = require("./../../lib/config"),
+ _event = require("./../../lib/event"),
+ _eventExt = require("./../blackberry.event/index"),
+ _actionMap = {
+ pause: {
+ context: require("./navEvents"),
+ event: "pause",
+ trigger: function () {
+ _event.trigger("pause");
+ }
+ },
+ resume: {
+ context: require("./navEvents"),
+ event: "resume",
+ trigger: function () {
+ _event.trigger("resume");
+ }
+ }
+ };
+
+module.exports = {
+ registerEvents: function (success, fail, args, env) {
+ try {
+ _eventExt.registerEvents(_actionMap);
+ success();
+ } catch (e) {
+ fail(-1, e);
+ }
+ },
+
+ author: function (success, fail, args, env) {
+ success(_config.author);
+ },
+
+ authorEmail: function (success, fail, args, env) {
+ success(_config.authorEmail);
+ },
+
+ authorURL: function (success, fail, args, env) {
+ success(_config.authorURL);
+ },
+
+ copyright: function (success, fail, args, env) {
+ success(_config.copyright);
+ },
+
+ description: function (success, fail, args, env) {
+ success(_config.description);
+ },
+
+ id: function (success, fail, args, env) {
+ success(_config.id);
+ },
+
+ license: function (success, fail, args, env) {
+ success(_config.license);
+ },
+
+ licenseURL: function (success, fail, args, env) {
+ success(_config.licenseURL);
+ },
+
+ name: function (success, fail, args, env) {
+ success(_config.name);
+ },
+
+ version: function (success, fail, args, env) {
+ success(_config.version);
+ }
+};
106 ext/blackberry.app/navEvents.js
View
@@ -1,54 +1,54 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 framework = require("../../lib/framework");
-
-module.exports = {
- addEventListener: function (event, trigger) {
- if (event) {
- switch (event) {
- case "pause":
- framework.setOnPause(trigger);
- break;
-
- case "resume":
- framework.setOnResume(trigger);
- break;
-
- default:
- console.log("Ignore registration for unknown event: " + event);
- break;
- }
- }
- },
- removeEventListener: function (event) {
- if (event) {
- switch (event) {
- case "pause":
- framework.setOnPause(null);
- break;
-
- case "resume":
- framework.setOnResume(null);
- break;
-
- default:
- console.log("Ignore un-registration for unknown event: " + event);
- break;
- }
- }
- }
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 framework = require("../../lib/framework");
+
+module.exports = {
+ addEventListener: function (event, trigger) {
+ if (event) {
+ switch (event) {
+ case "pause":
+ framework.setOnPause(trigger);
+ break;
+
+ case "resume":
+ framework.setOnResume(trigger);
+ break;
+
+ default:
+ console.log("Ignore registration for unknown event: " + event);
+ break;
+ }
+ }
+ },
+ removeEventListener: function (event) {
+ if (event) {
+ switch (event) {
+ case "pause":
+ framework.setOnPause(null);
+ break;
+
+ case "resume":
+ framework.setOnResume(null);
+ break;
+
+ default:
+ console.log("Ignore un-registration for unknown event: " + event);
+ break;
+ }
+ }
+ }
};
74 ext/blackberry.connection/connectionEvents.js
View
@@ -1,37 +1,37 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 connection = require("./connectionJNEXT").connection;
-
-module.exports = {
- addEventListener: function (event, trigger) {
- if (event === "connectionchange") {
- connection.startEvents(trigger);
- }
- else {
- console.log("Ignore registration for unknown event: " + event);
- }
- },
- removeEventListener: function (event) {
- if (event === "connectionchange") {
- connection.stopEvents();
- }
- else {
- console.log("Ignore un-registration for unknown event: " + event);
- }
- }
-};
-
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 connection = require("./connectionJNEXT").connection;
+
+module.exports = {
+ addEventListener: function (event, trigger) {
+ if (event === "connectionchange") {
+ connection.startEvents(trigger);
+ }
+ else {
+ console.log("Ignore registration for unknown event: " + event);
+ }
+ },
+ removeEventListener: function (event) {
+ if (event === "connectionchange") {
+ connection.stopEvents();
+ }
+ else {
+ console.log("Ignore un-registration for unknown event: " + event);
+ }
+ }
+};
+
218 ext/blackberry.connection/connectionJNEXT.js
View
@@ -1,109 +1,109 @@
-/*
-* Copyright 2012 Research In Motion Limited.
-*
-* 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 connection,
- triggerCallback = null;
-
-function getConnectionTypeString(type) {
- switch (type) {
- case 0:
- return "unknown";
- case 1:
- return "ethernet";
- case 2:
- return "wifi";
- case 3:
- return "bluetooth_dun";
- case 4:
- return "usb";
- case 5:
- return "vpn";
- case 6:
- return "rim-bb";
- case 7:
- return "4g"; // always return 4g for cellular
- case 8:
- return "none";
- }
-
- return type;
-}
-
-///////////////////////////////////////////////////////////////////
-// JavaScript wrapper for JNEXT plugin for blackberry.connection
-///////////////////////////////////////////////////////////////////
-
-JNEXT.Connection = function () {
- var self = this;
-
- self.getType = function () {
- var val = JNEXT.invoke(self.m_id, "getType");
- return getConnectionTypeString(JSON.parse(val));
- };
-
- self.startEvents = function (trigger) {
- triggerCallback = trigger;
- JNEXT.invoke(self.m_id, "startEvents");
- };
-
- self.stopEvents = function () {
- JNEXT.invoke(self.m_id, "stopEvents");
- triggerCallback = null;
- };
-
- self.onEvent = function (strData) {
- var arData = strData.split(" "),
- strEventDesc = arData[0],
- info = {};
-
- if (strEventDesc === "connectionchange") {
- info.oldType = getConnectionTypeString(JSON.parse(arData[1]));
- info.newType = getConnectionTypeString(JSON.parse(arData[2]));
-
- if (triggerCallback) {
- triggerCallback(info);
- }
- }
- };
-
- self.getId = function () {
- return self.m_id;
- };
-
- self.init = function () {
- if (!JNEXT.require("netstatus")) {
- return false;
- }
-
- self.m_id = JNEXT.createObject("netstatus.Connection");
-
- if (self.m_id === "") {
- return false;
- }
-
- JNEXT.registerEvents(self);
- };
-
- self.m_id = "";
-
- self.init();
-};
-
-connection = new JNEXT.Connection();
-
-module.exports = {
- connection: connection
-};
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* 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 connection,
+ triggerCallback = null;
+
+function getConnectionTypeString(type) {
+ switch (type) {
+ case 0:
+ return "unknown";
+ case 1:
+ return "ethernet";
+ case 2:
+ return "wifi";
+ case 3:
+ return "bluetooth_dun";
+ case 4:
+ return "usb";
+ case 5:
+ return "vpn";
+ case 6:
+ return "rim-bb";
+ case 7:
+ return "4g"; // always return 4g for cellular
+ case 8:
+ return "none";
+ }
+
+ return type;
+}
+
+///////////////////////////////////////////////////////////////////
+// JavaScript wrapper for JNEXT plugin for blackberry.connection
+///////////////////////////////////////////////////////////////////
+
+JNEXT.Connection = function () {
+ var self = this;
+
+ self.getType = function () {
+ var val = JNEXT.invoke(self.m_id, "getType");
+ return getConnectionTypeString(JSON.parse(val));
+ };
+
+ self.startEvents = function (trigger) {
+ triggerCallback = trigger;
+ JNEXT.invoke(self.m_id, "startEvents");
+ };
+
+ self.stopEvents = function () {
+ JNEXT.invoke(self.m_id, "stopEvents");
+ triggerCallback = null;
+ };
+
+ self.onEvent = function (strData) {
+ var arData = strData.split(" "),
+ strEventDesc = arData[0],
+ info = {};
+
+ if (strEventDesc === "connectionchange") {
+ info.oldType = getConnectionTypeString(JSON.parse(arData[1]));
+ info.newType = getConnectionTypeString(JSON.parse(arData[2]));
+
+ if (triggerCallback) {
+ triggerCallback(info);
+ }
+ }
+ };
+
+ self.getId = function () {
+ return self.m_id;
+ };
+
+ self.init = function () {
+ if (!JNEXT.require("netstatus")) {
+ return false;
+ }
+
+ self.m_id = JNEXT.createObject("netstatus.Connection");
+
+ if (self.m_id === "") {
+ return false;
+ }
+
+ JNEXT.registerEvents(self);
+ };
+
+ self.m_id = "";
+
+ self.init();
+};
+
+connection = new JNEXT.Connection();
+
+module.exports = {
+ connection: connection
+};
158 ext/blackberry.event/index.js 100755 → 100644
View
@@ -1,79 +1,79 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 _event = require("../../lib/event"),
- _actionMap = {};
-
-var ADD_EVENT_ERROR = "Error occured while adding event listener.",
- REMOVE_EVENT_ERROR = "Error occured while removing event listener.",
- ERROR_ID = -1;
-
-module.exports = {
- add: function (success, fail, args) {
- try {
- var eventName = decodeURIComponent(args.eventName).replace(/\"/g, ""),
- action = _actionMap[eventName];
-
- _event.add(action);
-
- if (success) {
- success();
- }
- }
- catch (e) {
- if (fail) {
- fail(ERROR_ID, ADD_EVENT_ERROR);
- }
- }
- },
- remove: function (success, fail, args) {
- try {
- var eventName = decodeURIComponent(args.eventName).replace(/\"/g, ""),
- action = _actionMap[eventName];
- _event.remove(action);
- if (success) {
- success();
- }
- }
- catch (e) {
- if (fail) {
- fail(ERROR_ID, REMOVE_EVENT_ERROR);
- }
- }
- },
- isEventRegistered: function (eventName) {
- return !!_actionMap[eventName];
- },
- registerEvents: function (map) {
- if (!map) {
- throw "map is null or undefined";
- }
-
- Object.getOwnPropertyNames(map).forEach(function (eventName) {
- if (eventName && map[eventName]) {
- var action = map[eventName];
-
- if (action.context && typeof action.context.addEventListener === "function" && typeof action.context.removeEventListener === "function") {
- _actionMap[eventName] = action;
- } else {
- throw "action '" + eventName + "' does not have valid context";
- }
- } else {
- throw "map contains invalid action: '" + eventName + "'";
- }
- });
- }
-};
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 _event = require("../../lib/event"),
+ _actionMap = {};
+
+var ADD_EVENT_ERROR = "Error occured while adding event listener.",
+ REMOVE_EVENT_ERROR = "Error occured while removing event listener.",
+ ERROR_ID = -1;
+
+module.exports = {
+ add: function (success, fail, args) {
+ try {
+ var eventName = decodeURIComponent(args.eventName).replace(/\"/g, ""),
+ action = _actionMap[eventName];
+
+ _event.add(action);
+
+ if (success) {
+ success();
+ }
+ }
+ catch (e) {
+ if (fail) {
+ fail(ERROR_ID, ADD_EVENT_ERROR);
+ }
+ }
+ },
+ remove: function (success, fail, args) {
+ try {
+ var eventName = decodeURIComponent(args.eventName).replace(/\"/g, ""),
+ action = _actionMap[eventName];
+ _event.remove(action);
+ if (success) {
+ success();
+ }
+ }
+ catch (e) {
+ if (fail) {
+ fail(ERROR_ID, REMOVE_EVENT_ERROR);
+ }
+ }
+ },
+ isEventRegistered: function (eventName) {
+ return !!_actionMap[eventName];
+ },
+ registerEvents: function (map) {
+ if (!map) {
+ throw "map is null or undefined";
+ }
+
+ Object.getOwnPropertyNames(map).forEach(function (eventName) {
+ if (eventName && map[eventName]) {
+ var action = map[eventName];
+
+ if (action.context && typeof action.context.addEventListener === "function" && typeof action.context.removeEventListener === "function") {
+ _actionMap[eventName] = action;
+ } else {
+ throw "action '" + eventName + "' does not have valid context";
+ }
+ } else {
+ throw "map contains invalid action: '" + eventName + "'";
+ }
+ });
+ }
+};
62 ext/blackberry.identity/client.js
View
@@ -1,32 +1,32 @@
-/*
- * Copyright 2012 Research In Motion Limited.
- *
- * 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 _self = {};
-
-function getFieldValue(field) {
- var value = null;
-
- try {
- value = window.webworks.execSync("blackberry.identity", field, null);
- } catch (e) {
- console.error(e);
- }
-
- return value;
-}
-
-window.webworks.defineReadOnlyField(_self, "uuid", getFieldValue("uuid"));
-
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * 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 _self = {};
+
+function getFieldValue(field) {
+ var value = null;
+
+ try {
+ value = window.webworks.execSync("blackberry.identity", field, null);
+ } catch (e) {
+ console.error(e);
+ }
+
+ return value;
+}
+
+window.webworks.defineReadOnlyField(_self, "uuid", getFieldValue("uuid"));
+
module.exports = _self;
72 ext/blackberry.identity/index.js
View
@@ -1,37 +1,37 @@
-/*
- * Copyright 2012 Research In Motion Limited.
- *
- * 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 _ppsUtils = require("../../lib/pps/ppsUtils");
-
-module.exports = {
- uuid: function (success, fail, args, env) {
- var PPSUtils = _ppsUtils.createObject(),
- deviceprops;
-
- PPSUtils.init();
-
- if (PPSUtils.open("/pps/services/private/deviceproperties", "0")) {
- deviceprops = PPSUtils.read();
- }
-
- PPSUtils.close();
-
- if (deviceprops) {
- success(deviceprops.devicepin);
- } else {
- fail(-1, "Cannot open PPS object");
- }
- }
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * 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 _ppsUtils = require("../../lib/pps/ppsUtils");
+
+module.exports = {
+ uuid: function (success, fail, args, env) {
+ var PPSUtils = _ppsUtils.createObject(),
+ deviceprops;
+
+ PPSUtils.init();
+
+ if (PPSUtils.open("/pps/services/private/deviceproperties", "0")) {
+ deviceprops = PPSUtils.read();
+ }
+
+ PPSUtils.close();
+
+ if (deviceprops) {
+ success(deviceprops.devicepin);
+ } else {
+ fail(-1, "Cannot open PPS object");
+ }
+ }
};
378 ext/blackberry.system/index.js
View
@@ -1,189 +1,189 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 Whitelist = require("../../lib/policy/whitelist").Whitelist,
- _whitelist = new Whitelist(),
- _event = require("../../lib/event"),
- _eventExt = require("../blackberry.event/index"),
- _ppsEvents = require("../../lib/pps/ppsEvents"),
- // This object is used by action map and contains links between pps object fields monitored for change in that object helper methods
- // to analyze if the value is the one callback should be invoked and fields name and value format as would appear on return.
- // Set disableOnChange to true if not interested on change for a particular field but still interested to return its value.
- _eventsMap = {
- batterycritical: {
- eventName: "batterycritical",
- eventDetailsArr: [{
- path: "/pps/services/power/battery?wait,delta",
- fieldNameArr: [{
- eventName: "StateOfCharge",
- paramName: "level",
- fieldValue: null,
- reset: function () {
- this.setFieldValue(null);
- },
- setFieldValue: function (value) {
- this.fieldValue = value ? this.formatValue(value) : value;
- },
- formatValue: function (str) {
- return parseInt(str, 10);
- },
- skipTrigger: function (value) {
- var threshold = 4,
- formattedValue = this.formatValue(value),
- result = (formattedValue > threshold) || (this.fieldValue && this.fieldValue <= threshold);
-
- this.fieldValue = formattedValue;
-
- return result;
- }
- }]
- }, {
- path: "/pps/services/power/charger?wait,delta",
- disableOnChange: true,
- fieldNameArr: [{
- eventName: "ChargingState",
- paramName: "isPlugged",
- formatValue: function (str) {
- return (str === "NC" ? false : true);
- }
- }]
- }],
- mode: 0
- },
- batterylow: {
- eventName: "batterylow",
- eventDetailsArr: [{
- path: "/pps/services/power/battery?wait,delta",
- fieldNameArr: [{
- eventName: "StateOfCharge",
- paramName: "level",
- fieldValue: null,
- reset: function () {
- this.setFieldValue(null);
- },
- setFieldValue: function (value) {
- this.fieldValue = value ? this.formatValue(value) : value;
- },
- formatValue: function (str) {
- return parseInt(str, 10);
- },
- skipTrigger: function (value) {
- var threshold = 14,
- formattedValue = this.formatValue(value),
- result = (formattedValue > threshold) || (this.fieldValue && this.fieldValue <= threshold);
-
- this.fieldValue = value;
-
- return result;
- }
- }]
- }, {
- path: "/pps/services/power/charger?wait,delta",
- disableOnChange: true,
- fieldNameArr: [{
- eventName: "ChargingState",
- paramName: "isPlugged",
- formatValue: function (str) {
- return (str === "NC" ? false : true);
- }
- }]
- }],
- mode: 0
- },
- batterystatus: {
- eventName: "batterystatus",
- eventDetailsArr: [{
- path: "/pps/services/power/battery?wait,delta",
- fieldNameArr: [{
- eventName: "StateOfCharge",
- paramName: "level",
- formatValue: function (str) {
- return parseInt(str, 10);
- }
- }]
- }, {
- path: "/pps/services/power/charger?wait,delta",
- fieldNameArr: [{
- eventName: "ChargingState",
- paramName: "isPlugged",
- formatValue: function (str) {
- return (str === "NC" ? false : true);
- }
- }]
- }],
- mode: 0
- }
- },
- _actionMap = {
- batterycritical: {
- context: _ppsEvents,
- event: _eventsMap.batterycritical,
- trigger: function (args) {
- _event.trigger("batterycritical", args);
- }
- },
- batterylow: {
- context: _ppsEvents,
- event: _eventsMap.batterylow,
- trigger: function (args) {
- _event.trigger("batterylow", args);
- }
- },
- batterystatus: {
- context: _ppsEvents,
- event: _eventsMap.batterystatus,
- trigger: function (args) {
- _event.trigger("batterystatus", args);
- }
- }
- };
-
-module.exports = {
- registerEvents: function (success, fail, args, env) {
- try {
- _eventExt.registerEvents(_actionMap);
- success();
- } catch (e) {
- fail(-1, e);
- }
- },
-
- hasPermission: function (success, fail, args, env) {
- // TODO string argument surrounded by %22
- // preserve dot for feature id
- var module = args.module.replace(/[^a-zA-Z.]+/g, ""),
- allowed = _whitelist.isFeatureAllowed(env.request.origin, module);
-
- // ALLOW - 0, DENY - 1
- success(allowed ? 0 : 1);
- },
-
- hasCapability: function (success, fail, args, env) {
- var SUPPORTED_CAPABILITIES = [
- "input.touch",
- "location.gps",
- "media.audio.capture",
- "media.video.capture",
- "media.recording",
- "network.bluetooth",
- "network.wlan"
- ],
- // TODO string argument surrounded by %22
- // preserve dot for capabiliity
- capability = args.capability.replace(/[^a-zA-Z.]+/g, "");
-
- success(SUPPORTED_CAPABILITIES.indexOf(capability) >= 0);
- }
-};
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 Whitelist = require("../../lib/policy/whitelist").Whitelist,
+ _whitelist = new Whitelist(),
+ _event = require("../../lib/event"),
+ _eventExt = require("../blackberry.event/index"),
+ _ppsEvents = require("../../lib/pps/ppsEvents"),
+ // This object is used by action map and contains links between pps object fields monitored for change in that object helper methods
+ // to analyze if the value is the one callback should be invoked and fields name and value format as would appear on return.
+ // Set disableOnChange to true if not interested on change for a particular field but still interested to return its value.
+ _eventsMap = {
+ batterycritical: {
+ eventName: "batterycritical",
+ eventDetailsArr: [{
+ path: "/pps/services/power/battery?wait,delta",
+ fieldNameArr: [{
+ eventName: "StateOfCharge",
+ paramName: "level",
+ fieldValue: null,
+ reset: function () {
+ this.setFieldValue(null);
+ },
+ setFieldValue: function (value) {
+ this.fieldValue = value ? this.formatValue(value) : value;
+ },
+ formatValue: function (str) {
+ return parseInt(str, 10);
+ },
+ skipTrigger: function (value) {
+ var threshold = 4,
+ formattedValue = this.formatValue(value),
+ result = (formattedValue > threshold) || (this.fieldValue && this.fieldValue <= threshold);
+
+ this.fieldValue = formattedValue;
+
+ return result;
+ }
+ }]
+ }, {
+ path: "/pps/services/power/charger?wait,delta",
+ disableOnChange: true,
+ fieldNameArr: [{
+ eventName: "ChargingState",
+ paramName: "isPlugged",
+ formatValue: function (str) {
+ return (str === "NC" ? false : true);
+ }
+ }]
+ }],
+ mode: 0
+ },
+ batterylow: {
+ eventName: "batterylow",
+ eventDetailsArr: [{
+ path: "/pps/services/power/battery?wait,delta",
+ fieldNameArr: [{
+ eventName: "StateOfCharge",
+ paramName: "level",
+ fieldValue: null,
+ reset: function () {
+ this.setFieldValue(null);
+ },
+ setFieldValue: function (value) {
+ this.fieldValue = value ? this.formatValue(value) : value;
+ },
+ formatValue: function (str) {
+ return parseInt(str, 10);
+ },
+ skipTrigger: function (value) {
+ var threshold = 14,
+ formattedValue = this.formatValue(value),
+ result = (formattedValue > threshold) || (this.fieldValue && this.fieldValue <= threshold);
+
+ this.fieldValue = value;
+
+ return result;
+ }
+ }]
+ }, {
+ path: "/pps/services/power/charger?wait,delta",
+ disableOnChange: true,
+ fieldNameArr: [{
+ eventName: "ChargingState",
+ paramName: "isPlugged",
+ formatValue: function (str) {
+ return (str === "NC" ? false : true);
+ }
+ }]
+ }],
+ mode: 0
+ },
+ batterystatus: {
+ eventName: "batterystatus",
+ eventDetailsArr: [{
+ path: "/pps/services/power/battery?wait,delta",
+ fieldNameArr: [{
+ eventName: "StateOfCharge",
+ paramName: "level",
+ formatValue: function (str) {
+ return parseInt(str, 10);
+ }
+ }]
+ }, {
+ path: "/pps/services/power/charger?wait,delta",
+ fieldNameArr: [{
+ eventName: "ChargingState",
+ paramName: "isPlugged",
+ formatValue: function (str) {
+ return (str === "NC" ? false : true);
+ }
+ }]
+ }],
+ mode: 0
+ }
+ },
+ _actionMap = {
+ batterycritical: {
+ context: _ppsEvents,
+ event: _eventsMap.batterycritical,
+ trigger: function (args) {
+ _event.trigger("batterycritical", args);
+ }
+ },
+ batterylow: {
+ context: _ppsEvents,
+ event: _eventsMap.batterylow,
+ trigger: function (args) {
+ _event.trigger("batterylow", args);
+ }
+ },
+ batterystatus: {
+ context: _ppsEvents,
+ event: _eventsMap.batterystatus,
+ trigger: function (args) {
+ _event.trigger("batterystatus", args);
+ }
+ }
+ };
+
+module.exports = {
+ registerEvents: function (success, fail, args, env) {
+ try {
+ _eventExt.registerEvents(_actionMap);
+ success();
+ } catch (e) {
+ fail(-1, e);
+ }
+ },
+
+ hasPermission: function (success, fail, args, env) {
+ // TODO string argument surrounded by %22
+ // preserve dot for feature id
+ var module = args.module.replace(/[^a-zA-Z.]+/g, ""),
+ allowed = _whitelist.isFeatureAllowed(env.request.origin, module);
+
+ // ALLOW - 0, DENY - 1
+ success(allowed ? 0 : 1);
+ },
+
+ hasCapability: function (success, fail, args, env) {
+ var SUPPORTED_CAPABILITIES = [
+ "input.touch",
+ "location.gps",
+ "media.audio.capture",
+ "media.video.capture",
+ "media.recording",
+ "network.bluetooth",
+ "network.wlan"
+ ],
+ // TODO string argument surrounded by %22
+ // preserve dot for capabiliity
+ capability = args.capability.replace(/[^a-zA-Z.]+/g, "");
+
+ success(SUPPORTED_CAPABILITIES.indexOf(capability) >= 0);
+ }
+};
44 lib/config.js
View
@@ -1,22 +1,22 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 defaults = require('./config/default'),
- user = require('./config/user'),
- utils = require('./utils');
-
-module.exports = utils.mixin(user,
- utils.mixin(defaults, {}));
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 defaults = require('./config/default'),
+ user = require('./config/user'),
+ utils = require('./utils');
+
+module.exports = utils.mixin(user,
+ utils.mixin(defaults, {}));
142 lib/config/default.js
View
@@ -1,71 +1,71 @@
-/*
- * Copyright 2010-2011 Research In Motion Limited.
- *
- * 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 = {
- configXML: "config.xml",
- configXMLDoc: null,
-
- backButtonBehavior: "back",
- customHeaders: {},
- version: "1.0.0",
-
- author: "",
- authorURL: "",
- authorEmail: "",
- copyright: "",
- content: "index.html",
- contentCharset: "",
- contentType: "",
- description: "",
- icon: "AIRApp_72.png",
- iconHover: "",
- id: "",
- license: "",
- licenseURL: "",
- name: "WebWorksAppTemplate",
-
- navigationMode: "pointer",
-
- preferredTransports: null,
- transportTimeout: 300000,
-
- hasMultiAccess: false,
- widgetExtensions: null,
- featureTable: null,
- accessList: null,
-
- loadingScreenColor: "#FFFFFF",
- backgroundImage: "",
- foregroundImage: "",
- onFirstLaunch: false,
- onLocalPageLoad: false,
- onRemotePageLoad: false,
- transitionType: -1,
- transitionDuration: 250,
- transitionDirection: 128,
-
- disableAllCache: false,
- aggressiveCacheAge: 2592000,
- maxCacheSizeTotal: 1024,
- maxCacheSizeItem: 128,
- maxStandardCacheAge: 2592000,
-
- runOnStartUp: false,
- allowInvokeParams: false,
- backgroundSource: "",
- foregroundSource: "index.html",
- debugEnabled: false
-};
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * 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 = {
+ configXML: "config.xml",
+ configXMLDoc: null,
+
+ backButtonBehavior: "back",
+ customHeaders: {},
+ version: "1.0.0",
+
+ author: "",
+ authorURL: "",
+ authorEmail: "",
+ copyright: "",
+ content: "index.html",
+ contentCharset: "",
+ contentType: "",
+ description: "",
+ icon: "AIRApp_72.png",
+ iconHover: "",
+ id: "",
+ license: "",
+ licenseURL: "",
+ name: "WebWorksAppTemplate",
+
+ navigationMode: "pointer",
+
+ preferredTransports: null,
+ transportTimeout: 300000,
+
+ hasMultiAccess: false,
+ widgetExtensions: null,
+ featureTable: null,
+ accessList: null,
+
+ loadingScreenColor: "#FFFFFF",
+ backgroundImage: "",
+ foregroundImage: "",
+ onFirstLaunch: false,
+ onLocalPageLoad: false,
+ onRemotePageLoad: false,
+ transitionType: -1,
+ transitionDuration: 250,
+ transitionDirection: 128,
+
+ disableAllCache: false,
+ aggressiveCacheAge: 2592000,
+ maxCacheSizeTotal: 1024,
+ maxCacheSizeItem: 128,
+ maxStandardCacheAge: 2592000,
+
+ runOnStartUp: false,
+ allowInvokeParams: false,
+ backgroundSource: "",
+ foregroundSource: "index.html",
+ debugEnabled: false
+};
80 lib/event.js
View
@@ -1,41 +1,41 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* 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 util = require("./utils"),
- _webview = util.requireWebview();
-
-module.exports = {
- trigger: function (name, args) {
- _webview.executeJavascript("webworks.event.trigger('" + name + "', '" + JSON.stringify(args) + "')");
- },
-
- add: function (action) {
- if (action) {
- action.context.addEventListener(action.event, action.trigger || this.trigger);
- } else {
- throw "Action is null or undefined";
- }
- },
-
- remove: function (action) {
- if (action) {
- action.context.removeEventListener(action.event);
- } else {
- throw "Action is null or undefined";
- }
-
- }
+/*
+* Copyright 2010-2011 Research In Motion Limited.
+*
+* 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 util = require("./utils"),
+ _webview = util.requireWebview();
+
+module.exports = {
+ trigger: function (name, args) {
+ _webview.executeJavascript("webworks.event.trigger('" + name + "', '" + JSON.stringify(args) + "')");
+ },
+
+ add: function (action) {
+ if (action) {
+ action.context.addEventListener(action.event, action.trigger || this.trigger);
+ } else {
+ throw "Action is null or undefined";
+ }
+ },
+
+ remove: function (action) {
+ if (action) {
+ action.context.removeEventListener(action.event);
+ } else {
+ throw "Action is null or undefined";
+ }
+
+ }
};
138 lib/exception.js
View
@@ -1,69 +1,69 @@
-/*
- * Copyright 2011 Research In Motion Limited.
- *
- * 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 = {
-
- types: {
- Application: "Application",
- ArgumentLength: "ArgumentLength",
- ArgumentType: "ArgumentType",
- Argument: "Argument",
- NotificationType: "NotificationType",
- NotificationStateType: "NotificationStateType",
- DomObjectNotFound: "DomObjectNotFound",
- MethodNotImplemented: "MethodNotImplemented",
- InvalidState: "InvalidState",
- ApplicationState: "ApplicationState"
- },
-
- handle: function handle(exception, reThrow) {
- reThrow = reThrow || false;
-
- var eMsg = exception.message || "exception caught!",
- msg = eMsg + "\n\n" + (exception.stack || "*no stack provided*") + "\n\n";
-
- console.error(msg);
-
- if (reThrow) {
- throw exception;
- }
- },
-
- raise: function raise(exceptionType, message, customExceptionObject) {
- var obj = customExceptionObject || {
- type: "",
- message: "",
-
- toString: function () {
- var result = this.name + ': "' + this.message + '"';
-
- if (this.stack) {
- result += "\n" + this.stack;
- }
- return result;
- }
- };
-
- message = message || "";
-
- obj.name = exceptionType;
- obj.type = exceptionType;
- // TODO: include the exception objects original message if exists
- obj.message = message;
-
- throw obj;
- }
-};
+/*
+ * Copyright 2011 Research In Motion Limited.
+ *
+ * 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 = {
+
+ types: {
+ Application: "Application",
+ ArgumentLength