You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/07 17:13:48 UTC

[01/50] [abbrv] webworks commit: Renamed target.js to target due to help command issue

Updated Branches:
  refs/heads/future [created] 42b066f65


Renamed target.js to target due to help command issue

Reviewed by: Hasan Ahmad <ha...@blackberry.com>
Tested by: Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: a12a25cb2d18097eddb7e49dd89ce3c6c3d148da
Parents: 62a8640
Author: DanielAudino <da...@blackberry.com>
Authored: Wed Mar 20 16:30:28 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/target       |  187 +++++++++++++++
 .../bin/templates/project/cordova/lib/target.js    |  186 --------------
 blackberry10/bin/templates/project/cordova/target  |    2 +-
 .../bin/templates/project/cordova/target.bat       |    2 +-
 4 files changed, 189 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/blackberry10/bin/templates/project/cordova/lib/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target b/blackberry10/bin/templates/project/cordova/lib/target
new file mode 100644
index 0000000..61211d3
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/lib/target
@@ -0,0 +1,187 @@
+#!/usr/bin/env node
+/*
+ *  Copyright 2013 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 propertiesFile = 'project.json',
+    properties = require('../../' + propertiesFile),
+    fs = require('fs'),
+    commander = require('commander'),
+    command,
+    name,
+    ip,
+    type,
+    password,
+    pin,
+    pinRegex = new RegExp("[0-9A-Fa-f]{8}");
+
+function writeProjectFile(contents, file) {
+    fs.writeFile(file, contents, 'utf-8', function (err) {
+        if (err) console.log("Error updating project.json :(\n" + err);
+        process.exit();
+    });
+}
+
+function isValidIp(ip) {
+    var num,
+        result = true,
+        ipArray;
+
+    if (typeof ip !== 'string') {
+        throw "IP is required";
+    } else {
+        ipArray = ip.split('.');
+        if (ipArray.length !== 4) {
+            result = false;
+        }
+        ipArray.forEach(function (quadrant) {
+            num = Number(quadrant);
+            if (isNaN(num) || (num < 0) || (num > 255)) {
+                result = false;
+            }
+        });
+    }
+    return result;
+}
+
+function isValidType(type) {
+    var result = true;
+
+    if (typeof type !== 'string') {
+        throw "target type is required";
+    }
+    else if (!(type === 'device' || type === 'simulator')) {
+        result = false;
+    }
+    return result;
+}
+
+function isValidPin(pin) {
+    var result = true;
+    if (typeof pin !== 'undefined' && !pinRegex.test(pin)) {
+        result = false;
+    }
+    return result;
+}
+
+commander
+    .usage('[command] [params]')
+    .option('-p, --password <password>', 'Specifies password for this target')
+    .option('--pin <devicepin>', 'Specifies PIN for this device');
+
+commander
+    .on('--help', function () {
+        console.log('   Synopsis:');
+        console.log('   $ target');
+        console.log('   $ target add <name> <ip> <type> [-p | --password <password>] [--pin <devicepin>]');
+        console.log('   $ target remove <name>');
+        console.log('   $ target default [name]');
+        console.log(' ');
+    });
+
+commander
+    .command('add')
+    .description("Add specified target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            throw "Target details not specified";
+        }
+        name = commander.args[0];
+        ip = commander.args[1];
+        type = commander.args[2];
+        if (commander.password && typeof commander.password === 'string') {
+            password = commander.password;
+        }
+        if (commander.pin && typeof commander.pin === 'string') {
+            pin = commander.pin;
+        }
+        if (!isValidIp(ip)) {
+            throw "Invalid IP: " + ip;
+        }
+        if (!isValidType(type)) {
+            throw "Invalid target type: " + type;
+        }
+        if (!isValidPin(pin)) {
+            throw "Invalid PIN: " + pin;
+        }
+        if (properties.targets.hasOwnProperty(name)) {
+            console.log("Overwriting target: " + name);
+        }
+        properties.targets[name] = {"ip": ip, "type": type, "password": password, "pin": pin};
+    });
+
+commander
+    .command('remove')
+    .description("Remove specified target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            throw 'No target specified';
+        }
+        name = commander.args[0];
+        if (!properties.targets.hasOwnProperty(name)) {
+            throw "Target: '" + name + "' not found";
+        }
+        if (name === properties.defaultTarget) {
+            console.log("Deleting default target, please set a new default target");
+            properties.defaultTarget = "";
+        }
+        delete properties.targets[name];
+    });
+
+commander
+    .command('default')
+    .description("Get or set default target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            console.log(properties.defaultTarget);
+            process.exit();
+        }
+        name = commander.args[0];
+        if (properties.targets.hasOwnProperty(name)) {
+            properties.defaultTarget = name;
+        } else {
+            throw "Target '" + name + "' not found";
+        }
+    });
+
+commander
+    .command('*')
+    .action(function () {
+        throw 'Unrecognized command';
+    });
+
+
+try {
+    commander.parse(process.argv);
+
+    if (commander.args.length === 0) {
+        Object.keys(properties.targets).forEach(function (target) {
+            if (target === properties.defaultTarget) {
+                console.log('* ' + target);
+            } else {
+                console.log('  ' + target);
+            }
+        });
+        process.exit();
+    }
+    if (Object.keys(properties.targets).length === 1) {
+        properties.defaultTarget = Object.keys(properties.targets)[0];
+    }
+
+    writeProjectFile(JSON.stringify(properties, null, 4) + "\n", propertiesFile);
+} catch (e) {
+    console.log(e);
+    process.exit();
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/blackberry10/bin/templates/project/cordova/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target.js b/blackberry10/bin/templates/project/cordova/lib/target.js
deleted file mode 100644
index d8a1afe..0000000
--- a/blackberry10/bin/templates/project/cordova/lib/target.js
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- *  Copyright 2013 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 propertiesFile = 'project.json',
-    properties = require('../../' + propertiesFile),
-    fs = require('fs'),
-    commander = require('commander'),
-    command,
-    name,
-    ip,
-    type,
-    password,
-    pin,
-    pinRegex = new RegExp("[0-9A-Fa-f]{8}");
-
-function writeProjectFile(contents, file) {
-    fs.writeFile(file, contents, 'utf-8', function (err) {
-        if (err) console.log("Error updating project.json :(\n" + err);
-        process.exit();
-    });
-}
-
-function isValidIp(ip) {
-    var num,
-        result = true,
-        ipArray;
-
-    if (typeof ip !== 'string') {
-        throw "IP is required";
-    } else {
-        ipArray = ip.split('.');
-        if (ipArray.length !== 4) {
-            result = false;
-        }
-        ipArray.forEach(function (quadrant) {
-            num = Number(quadrant);
-            if (isNaN(num) || (num < 0) || (num > 255)) {
-                result = false;
-            }
-        });
-    }
-    return result;
-}
-
-function isValidType(type) {
-    var result = true;
-
-    if (typeof type !== 'string') {
-        throw "target type is required";
-    }
-    else if (!(type === 'device' || type === 'simulator')) {
-        result = false;
-    }
-    return result;
-}
-
-function isValidPin(pin) {
-    var result = true;
-    if (typeof pin !== 'undefined' && !pinRegex.test(pin)) {
-        result = false;
-    }
-    return result;
-}
-
-commander
-    .usage('[command] [params]')
-    .option('-p, --password <password>', 'Specifies password for this target')
-    .option('--pin <devicepin>', 'Specifies PIN for this device');
-
-commander
-    .on('--help', function () {
-        console.log('   Synopsis:');
-        console.log('   $ target');
-        console.log('   $ target add <name> <ip> <type> [-p | --password <password>] [--pin <devicepin>]');
-        console.log('   $ target remove <name>');
-        console.log('   $ target default [name]');
-        console.log(' ');
-    });
-
-commander
-    .command('add')
-    .description("Add specified target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            throw "Target details not specified";
-        }
-        name = commander.args[0];
-        ip = commander.args[1];
-        type = commander.args[2];
-        if (commander.password && typeof commander.password === 'string') {
-            password = commander.password;
-        }
-        if (commander.pin && typeof commander.pin === 'string') {
-            pin = commander.pin;
-        }
-        if (!isValidIp(ip)) {
-            throw "Invalid IP: " + ip;
-        }
-        if (!isValidType(type)) {
-            throw "Invalid target type: " + type;
-        }
-        if (!isValidPin(pin)) {
-            throw "Invalid PIN: " + pin;
-        }
-        if (properties.targets.hasOwnProperty(name)) {
-            console.log("Overwriting target: " + name);
-        }
-        properties.targets[name] = {"ip": ip, "type": type, "password": password, "pin": pin};
-    });
-
-commander
-    .command('remove')
-    .description("Remove specified target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            throw 'No target specified';
-        }
-        name = commander.args[0];
-        if (!properties.targets.hasOwnProperty(name)) {
-            throw "Target: '" + name + "' not found";
-        }
-        if (name === properties.defaultTarget) {
-            console.log("Deleting default target, please set a new default target");
-            properties.defaultTarget = "";
-        }
-        delete properties.targets[name];
-    });
-
-commander
-    .command('default')
-    .description("Get or set default target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            console.log(properties.defaultTarget);
-            process.exit();
-        }
-        name = commander.args[0];
-        if (properties.targets.hasOwnProperty(name)) {
-            properties.defaultTarget = name;
-        } else {
-            throw "Target '" + name + "' not found";
-        }
-    });
-
-commander
-    .command('*')
-    .action(function () {
-        throw 'Unrecognized command';
-    });
-
-
-try {
-    commander.parse(process.argv);
-
-    if (commander.args.length === 0) {
-        Object.keys(properties.targets).forEach(function (target) {
-            if (target === properties.defaultTarget) {
-                console.log('* ' + target);
-            } else {
-                console.log('  ' + target);
-            }
-        });
-        process.exit();
-    }
-    if (Object.keys(properties.targets).length === 1) {
-        properties.defaultTarget = Object.keys(properties.targets)[0];
-    }
-
-    writeProjectFile(JSON.stringify(properties, null, 4) + "\n", propertiesFile);
-} catch (e) {
-    console.log(e);
-    process.exit();
-}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/blackberry10/bin/templates/project/cordova/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/target b/blackberry10/bin/templates/project/cordova/target
index bbc88bc..624f835 100755
--- a/blackberry10/bin/templates/project/cordova/target
+++ b/blackberry10/bin/templates/project/cordova/target
@@ -2,4 +2,4 @@
 # go to project root
 cd $( dirname "$0")/../
 
-node "cordova/lib/target.js" "$@"
+node "cordova/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/blackberry10/bin/templates/project/cordova/target.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/target.bat b/blackberry10/bin/templates/project/cordova/target.bat
index 8e48d50..d9324c7 100755
--- a/blackberry10/bin/templates/project/cordova/target.bat
+++ b/blackberry10/bin/templates/project/cordova/target.bat
@@ -21,4 +21,4 @@ goto comment
 REM cd into project dir
 cd %~dp0\..\
 
-@node.exe ./cordova/lib/target.js %*
+@node.exe ./cordova/lib/target %*


[07/50] [abbrv] webworks commit: Add JPPS and Utils plugins to project template.

Posted by lo...@apache.org.
Add JPPS and Utils plugins to project template.

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/92134ef7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/92134ef7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/92134ef7

Branch: refs/heads/future
Commit: 92134ef72b12f76f8b44283c18e32629d6b8022e
Parents: ab134d0
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Apr 8 14:59:00 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/JPPS/Makefile    |    8 +
 .../templates/project/plugins/JPPS/src/Makefile    |    8 +
 .../project/plugins/JPPS/src/blackberry10/Makefile |    8 +
 .../plugins/JPPS/src/blackberry10/native/Makefile  |    8 +
 .../plugins/JPPS/src/blackberry10/native/common.mk |   34 +
 .../JPPS/src/blackberry10/native/device/libjpps.so |  Bin 0 -> 138046 bytes
 .../src/blackberry10/native/simulator/libjpps.so   |  Bin 0 -> 224392 bytes
 .../src/blackberry10/native/src/core/PPSEvent.h    |  108 +++
 .../blackberry10/native/src/core/PPSInterface.cpp  |  632 +++++++++++++++
 .../blackberry10/native/src/core/PPSInterface.h    |  238 ++++++
 .../blackberry10/native/src/core/PPSNotifier.cpp   |  126 +++
 .../src/blackberry10/native/src/core/PPSNotifier.h |  159 ++++
 .../native/src/core/PPSNotifyGroupManager.cpp      |  107 +++
 .../native/src/core/PPSNotifyGroupManager.h        |  133 +++
 .../src/blackberry10/native/src/core/PPSTypes.h    |   96 +++
 .../blackberry10/native/src/plugin/JPPSPlugin.cpp  |  149 ++++
 .../blackberry10/native/src/plugin/JPPSPlugin.h    |  122 +++
 .../native/src/plugin/JPPSServerPlugin.cpp         |  168 ++++
 .../native/src/plugin/JPPSServerPlugin.h           |  115 +++
 .../native/src/plugin/PPSInterfaceGlue.cpp         |  355 ++++++++
 .../native/src/plugin/PPSInterfaceGlue.h           |  177 ++++
 .../native/src/plugin/PPSServerGlue.cpp            |  300 +++++++
 .../blackberry10/native/src/plugin/PPSServerGlue.h |  165 ++++
 .../blackberry10/native/src/plugin/PluginTypes.h   |   35 +
 .../native/src/plugin/pluginManifest.cpp           |   76 ++
 .../src/blackberry10/native/src/utils/Logger.h     |   94 +++
 .../src/blackberry10/native/src/utils/Thread.cpp   |   71 ++
 .../src/blackberry10/native/src/utils/Thread.h     |   73 ++
 .../bin/templates/project/plugins/Utils/Makefile   |    8 +
 .../templates/project/plugins/Utils/src/Makefile   |    8 +
 .../plugins/Utils/src/blackberry10/Makefile        |    8 +
 .../plugins/Utils/src/blackberry10/native/Makefile |    8 +
 .../Utils/src/blackberry10/native/common.mk        |   18 +
 .../src/blackberry10/native/device/libutils.so     |  Bin 0 -> 130206 bytes
 .../src/blackberry10/native/simulator/libutils.so  |  Bin 0 -> 183184 bytes
 .../src/blackberry10/native/webworks_utils.cpp     |   55 ++
 .../src/blackberry10/native/webworks_utils.hpp     |   34 +
 37 files changed, 3704 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
new file mode 100644
index 0000000..6cecca9
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
@@ -0,0 +1,34 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=jpps
+PLUGIN=yes
+UTILS=yes
+
+include ../../../../../../meta.mk
+
+override CCFLAGS := $(filter-out -Werror , $(CCFLAGS))
+
+EXTRA_SRCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
+
+EXTRA_INCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
+
+SRCS+=src/utils/Thread.cpp \
+      src/core/PPSInterface.cpp \
+      src/core/PPSNotifier.cpp \
+      src/core/PPSNotifyGroupManager.cpp \
+      src/plugin/JPPSPlugin.cpp \
+      src/plugin/PPSInterfaceGlue.cpp \
+      src/plugin/JPPSServerPlugin.cpp \
+      src/plugin/PPSServerGlue.cpp \
+      src/plugin/pluginManifest.cpp
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+LIBS+=pps

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so
new file mode 100644
index 0000000..f0eb90d
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so
new file mode 100644
index 0000000..f2c12ff
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
new file mode 100644
index 0000000..808e699
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSEVENT_H_
+#define PPSEVENT_H_
+
+#include <string>
+#include "PPSTypes.h"
+
+namespace jpps {
+
+/**
+ * A class representing a PPS event. Used to notify interested parties when something
+ * happens to a PPS object.
+ */
+class PPSEvent {
+
+public:
+
+	/**
+	 * The possible types of this event.
+	 */
+	enum PPSEventType {
+		/** The PPS object's first data read is complete. */
+		PPS_EVENT_FIRST_READ_COMPLETE,
+		/** The PPS object has new data. */
+		PPS_EVENT_NEW_DATA,
+		/** The PPS object was successfully opened. */
+		PPS_EVENT_OPENED,
+		/** A PPS object was closed. */
+		PPS_EVENT_CLOSED,
+		/** An attempt to open a PPS object failed. */
+		PPS_EVENT_OPEN_FAILED,
+		/** An attempt to read from a PPS object failed. */
+		PPS_EVENT_READ_FAILED,
+		/** An attempt to write to a PPS object failed. */
+		PPS_EVENT_WRITE_FAILED,
+	};
+
+	/**
+	 * Constructor.
+	 *
+	 * @param eventType The type of event this is.
+	 * @param data If eventType == PPS_EVENT_NEW_DATA, the new data.
+	 */
+	PPSEvent(PPSEventType eventType, const std::string& msg = "", const ppsObject& newData = ppsObject())
+	: m_eventType(eventType)
+	, m_message(msg)
+	, m_newData(newData)
+	{}
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSEvent() {}
+
+	/**
+	 * Get the event type.
+	 */
+	inline PPSEventType getEventType() const { return m_eventType; }
+
+	/**
+	 * Get the message associated with this event.
+	 */
+	inline std::string getMessage() const { return m_message; }
+
+	/**
+	 * Get the new data. This value is only populated if the eventType is PPS_EVENT_NEW_DATA. This data
+	 * is what was parsed out of the PPS object.
+	 */
+	inline ppsObject getNewData() const { return m_newData; }
+
+private:
+
+	// Disable the default constructor.
+	PPSEvent();
+
+	/** The type of this event. */
+	PPSEventType m_eventType;
+
+	/** A message associated to the event. */
+	std::string m_message;
+
+	/** If m_eventType == PPS_EVENT_NEW_DATA, this contains the new data. Else m_newData is empty.
+	 * This data is the data that was read from the PPS object, un-massaged. */
+	ppsObject m_newData;
+};
+
+} /* namespace jpps */
+#endif /* PPSEVENT_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
new file mode 100644
index 0000000..dfb575b
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
@@ -0,0 +1,632 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSInterface.h"
+
+#include <sstream>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <ppsparse.h>
+#include <string.h>
+
+#include "PPSNotifyGroupManager.h"
+#include "PPSEvent.h"
+
+namespace jpps {
+
+// Const statics
+const char* PPSInterface::PPS_ROOT = "/pps/";
+const int PPSInterface::MaxPPSReadSize = (32 * 1024);
+
+// Static data members
+pthread_mutex_t PPSInterface::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t PPSInterface::sm_cond;
+volatile bool PPSInterface::sm_firstInitDone = false;
+std::map<unsigned int, PPSInterface*> PPSInterface::sm_interfaceLookupTable;
+
+PPSInterface::PPSInterface()
+: m_pEventFunc(NULL)
+, m_pEventArg(NULL)
+, m_interfaceId(0)
+, m_fd(-1)
+, m_oflags(0)
+, m_firstRead(true)
+, m_cachedRead()
+, m_logger()
+{
+	// This is used to assign a unique ID to each PPSInterface object
+	static unsigned int interfaceIDs = 0;
+
+	::pthread_mutex_lock(&sm_mutex);
+
+	m_interfaceId = interfaceIDs;
+	interfaceIDs++; // Increment this so that the next object has a unique id.
+
+	// Add myself to the lookup table
+	sm_interfaceLookupTable.insert(std::pair<unsigned int, PPSInterface*>(m_interfaceId, this));
+
+	if (!sm_firstInitDone) {
+
+		// Initialize the condvar
+		pthread_condattr_t condAttr;
+		::pthread_condattr_init(&condAttr);
+		::pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
+		::pthread_cond_init(&sm_cond, &condAttr);
+		::pthread_condattr_destroy(&condAttr);
+
+		sm_firstInitDone = true;
+	}
+
+	::pthread_mutex_unlock(&sm_mutex);
+}
+
+PPSInterface::~PPSInterface()
+{
+	std::ostringstream ostream;
+	ostream << "PPSInterface::~PPSInterface() - Destruct fd:" << m_fd << ".";
+	m_logger.slog(Logger::debug, ostream.str());
+
+	// Close my open PPS object, if I have one
+	close();
+
+	// Remove myself from the lookup table
+	sm_interfaceLookupTable.erase(m_interfaceId);
+}
+
+void PPSInterface::setVerbose(unsigned short v)
+{
+	m_logger.setVerbosity(v);
+}
+
+void PPSInterface::setEventFunc(const PPSEventFunc* pEventFunc, void* pArg)
+{
+	m_pEventFunc = pEventFunc;
+	m_pEventArg = pArg;
+}
+
+bool PPSInterface::open(const std::string& path, int oflag, int mode, bool server)
+{
+	// If we've already got an open file, fail
+	if (m_fd != -1) {
+
+		m_logger.slog(Logger::warning, "PPSInterface::open() Failed - Attempted to open an object that is already open.");
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_OPEN_FAILED, "Attempted to open an object that is already open."));
+		return false;
+	}
+
+	std::string errorMsg;
+	bool ok = false;
+
+	// Prepend PPS_ROOT to the path if it doesn't start with a '/'
+	std::string fullpath = (path[0] != '/' ? PPSInterface::PPS_ROOT : "") + path;
+
+	// This flag is used to prevent the notify thread from performing reads while the
+	// open() function is running and doing its first read.
+	::pthread_mutex_lock(&sm_mutex);
+	m_firstRead = true;
+	::pthread_mutex_unlock(&sm_mutex);
+
+	// Remove any options from the path otherwise lstat will fail
+	std::string pathNoOptions(fullpath);
+	std::size_t nPosOpts = fullpath.rfind('?');
+
+	if (nPosOpts != std::string::npos)
+		pathNoOptions = fullpath.substr(0, nPosOpts);
+
+	// There are a few complexities associated with symbolic links.  If
+	// the last component of the path is a symlink we have to resolve it
+	// since we won't be able to resolve the name when the options are
+	// added.  Also we need to get the path relative to the pps filesystem
+	// so we can locate the .notify file.  So, if the object already
+	// exists, resolve the path.  If it doesn't and O_CREAT is specified
+	// resolve the directory it's in, otherwise it's a failure.
+	std::string resolvedName;
+	char szResolvedName[PATH_MAX+128]; // buffer for use with the C functions
+
+	if (::realpath(pathNoOptions.c_str(), szResolvedName) != NULL) {
+
+		resolvedName = szResolvedName;
+		ok = true;
+	}
+	else if (oflag & O_CREAT) {
+
+		// Chop off the file name, so we can try to resolve the directory
+		size_t nPos = pathNoOptions.rfind('/');
+
+		// We found a '/'
+		if (nPos != std::string::npos) {
+
+			// Get the directory path
+			std::string dirPath = pathNoOptions.substr(0, nPos); // Don't include the '/'
+
+			if (::realpath(dirPath.c_str(), szResolvedName) != NULL) {
+
+				// Concatenate the file name to the resolved directory path
+				resolvedName = szResolvedName + pathNoOptions.substr(nPos); // include the '/' at the start
+				ok = true;
+			}
+		}
+	}
+
+	if (ok) {
+
+		struct stat info;
+		int result = ::lstat(resolvedName.c_str(), &info);
+
+		if (result != 0) {
+
+			// If we failed and we're not creating a non-existent file, it's an error.
+			if ((errno != ENOENT) && !(oflag & O_CREAT))
+				ok = false;
+		}
+		else if (S_ISDIR(info.st_mode))
+			ok = false;
+	}
+
+	if (ok) {
+
+		std::string options;
+
+		// Now lets work with the options to ensure we have a complete version
+		std::string pathOptions;
+		
+		// Get just the stuff after '?'
+		size_t nPos = fullpath.rfind('?');
+
+		if (nPos != std::string::npos) {
+			pathOptions = fullpath.substr(nPos);
+		}
+
+		if ((oflag & O_ACCMODE) != O_WRONLY) {
+
+			// This is used as the return object for the joinNotifyGroup() call
+			// It's only valid if joinNotifyGroup() returned true
+			std::string groupId;
+
+			PPSNotifyGroupManager::mutexLock();
+			PPSNotifyGroupManager& notifyManager = PPSNotifyGroupManager::getInstance();
+			bool groupJoined = notifyManager.joinNotifyGroup(resolvedName, groupId);
+			PPSNotifyGroupManager::mutexUnlock();
+
+			if (groupJoined) {
+
+				// If we're acting as a server, we use server as an option
+				// otherwise we have to specify delta mode.  PPS has a fit
+				// if we specify both delta and deltadir so check for this.
+				std::string modeExtra;
+
+				// Add in the options we need.  If both server and delta are specified, use only
+				// server (it kind of implies delta and at one point pps would not like both being
+				// present)
+				if (server) {
+					modeExtra = ",server";
+				}
+				// If we have no options or there's no 'deltadir' specified, use delta mode
+				else if (pathOptions.empty() || pathOptions.find("deltadir") == std::string::npos) {
+					modeExtra = ",delta";
+				}
+
+				// We embed the m_interfaceID as a unique identifier that will be passed on to the
+				// PPSNotifier. PPSNotifier will use this id in conjunction with getPPSInterface()
+				// in order to send this object notifications that content is ready for reading later.
+				std::ostringstream ostream;
+				ostream << "?" << (pathOptions.empty() ? "" : pathOptions.substr(1) + ",") << "notify="
+						<< groupId << ":" << m_interfaceId << modeExtra;
+				options = ostream.str();
+			}
+		}
+
+		if (!options.empty()) {
+
+			resolvedName += options;
+		}
+
+		// The big moment... Let's try to actually open the PPS object...
+		if (ok) {
+			m_fd = ::open(resolvedName.c_str(), oflag, mode);
+		}
+
+		// Error opening the PPS object
+		if (m_fd < 0) {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::open() Failed - ::open("
+					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+					<< ((oflag & O_CREAT) ? ":create" : "")
+					<< ") " << resolvedName << " (" << errno << ": " << strerror(errno) << ")";
+			m_logger.slog(Logger::warning, ostream.str());
+			errorMsg = ostream.str();
+		}
+		else {
+			// Depending on our umask, the permissions might not have
+			// been as specified. So if O_CREAT was specified, re-set the
+			// permissions.  The object might already exist, but perhaps
+			// that's OK too.
+			if (oflag & O_CREAT) {
+				::fchmod(m_fd, mode);
+			}
+
+			m_oflags = oflag;
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::open() - ::open("
+					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+					<< ((oflag & O_CREAT) ? ":create" : "")
+					<< ") " << resolvedName;
+			m_logger.slog(Logger::debug, ostream.str());
+		}
+	}
+	// For whatever reason, the path to the PPS object was not valid
+	else {
+		std::ostringstream ostream;
+		ostream << "PPSInterface::open() Failed - ::open("
+				<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+				   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+				   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+				<< ((oflag & O_CREAT) ? ":create" : "")
+				<< ") " << path << " The PPS object could not be resolved properly.";
+		m_logger.slog(Logger::warning, ostream.str());
+		errorMsg = ostream.str();
+	}
+
+	sendEvent(PPSEvent(m_fd >= 0 ? PPSEvent::PPS_EVENT_OPENED : PPSEvent::PPS_EVENT_OPEN_FAILED, errorMsg));
+
+	if (m_fd >= 0 && (oflag & O_ACCMODE) != O_WRONLY) {
+
+		// Perform the initial read
+		readFromObject();
+	}
+
+	// Tell the other thread we are done with the first read
+	::pthread_mutex_lock(&sm_mutex);
+	m_firstRead = false;
+	::pthread_cond_broadcast(&sm_cond);
+	::pthread_mutex_unlock(&sm_mutex);
+
+	return m_fd >= 0;
+}
+
+void PPSInterface::write(const std::string& data)
+{
+	// We're trying to write to an unopened PPS object
+	if (m_fd == -1) {
+
+		std::string msg("PPSInterface::write() Failed - Attempting to write to a file that isn't open.");
+		m_logger.slog(Logger::warning, msg);
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, msg));
+	}
+
+	ssize_t ret = ::write(m_fd, data.c_str(), data.length());
+
+	// Debug slog the write call if it was successful
+	if (ret >= 0) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::write() - fd:" << m_fd << " : \n" << data;
+		m_logger.slog(Logger::debug, ostream.str());
+	}
+
+	// There was an error writing
+	if (ret == -1) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::write() Failed - Error writing to fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+		m_logger.slog(Logger::warning, ostream.str());
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, ostream.str()));
+	}
+
+	// If we wrote successfully and the file is open in read/write mode, then we need to manually update the
+	// read cache. When in O_RDWR mode, we do NOT receive notifications of our own write() operations.
+	// This means that the cache of read data becomes stale - it is missing the data that we have written
+	// to the object ourselves. In this case, we will manually update the cache.
+	// NOTE: this seems fraught with peril, but unfortunately there don't seem to be any good solutions to
+	// fixing the problem of read/write mode and read() integrity.
+	if (ret >= 0 && (m_oflags & O_RDWR)) {
+
+		// We're going to try to fool the ppsparse() method into parsing the data we write.
+		char* pWriteData = new char[data.length() + 1];
+
+		// The later call to ppsparse() moves the pWriteData pointer forward, and we need the original pointer
+		// in order to properly delete the object later, so let's cache it here
+		char* pWriteDataCopy = pWriteData;
+
+		std::strcpy(pWriteData, data.c_str()); // strcpy null terminates for us
+
+		// Parse the write buffer - this should give us a ppsObject with only attributes
+		ppsObject parsedData = parsePPSData(pWriteData);
+
+		// The data being written does not include the object name other object properties (duh)
+		// So parsedData contains only attribute info. We want to preserve the object name
+		// and properties, so lets just copy the ones in the cache into our parsedData struct
+		// so that the call to updateCachedReadData() will preserve them (i.e. copy them back)
+		parsedData.name = m_cachedRead.name;
+		parsedData.flags = m_cachedRead.flags;
+		parsedData.options = m_cachedRead.options;
+		parsedData.optionMask = m_cachedRead.optionMask;
+
+		// Update the cache
+		updateCachedReadData(parsedData);
+
+		// Cleanup our allocated memory
+		if (pWriteDataCopy) {
+
+			delete[] pWriteDataCopy;
+		}
+	}
+}
+
+void PPSInterface::sync()
+{
+	if (m_fd >= 0)
+		::fsync(m_fd);
+}
+
+void PPSInterface::close()
+{
+	if (m_fd >= 0) {
+
+		::close(m_fd);
+		m_fd = -1;
+		m_cachedRead = ppsObject();
+		m_oflags = 0;
+
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_CLOSED));
+	}
+}
+
+void PPSInterface::onNotify(NotifyType event)
+{
+	// We only handle read notifications
+	if (event != PPS_READ) {
+		return;
+	}
+
+	if (m_firstRead) {
+		::pthread_mutex_lock(&sm_mutex);
+		while (m_firstRead) {
+			::pthread_cond_wait(&sm_cond, &sm_mutex);
+		}
+		::pthread_mutex_unlock(&sm_mutex);
+	}
+
+	readFromObject();
+}
+
+void PPSInterface::readFromObject()
+{
+	bool sendFirstReadEvent = m_firstRead;
+
+	// This was a uint8_t - was there a reason?
+	char szBuffer[MaxPPSReadSize + 1];
+	int bufferLen;
+
+	// Read from the actual PPS file - this call is not blocking
+	while ((bufferLen = ::read(m_fd, szBuffer, MaxPPSReadSize)) > 0) {
+
+		if (bufferLen <= MaxPPSReadSize) {
+
+			// Make sure the buffer is null terminated.
+			szBuffer[bufferLen] = '\0';
+
+			std::string buf(szBuffer, bufferLen);
+			std::ostringstream ostream;
+			ostream << "PPSInterface::readFromObject() - fd:" << m_fd << " len:" << bufferLen << "\n" << buf;
+			m_logger.slog(Logger::debug, ostream.str());
+
+			// Parse the PPS data
+			ppsObject parsedPPS = parsePPSData(szBuffer);
+
+			// Update the cache with the data we just read
+			updateCachedReadData(parsedPPS);
+
+			// If this is the first read, then send the first read event.
+			if (sendFirstReadEvent) {
+
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", parsedPPS));
+				sendFirstReadEvent = false;
+			}
+			else {
+
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_NEW_DATA, "", parsedPPS));
+			}
+		}
+		else {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::readFromObject() Failed - fd:" << m_fd << " oversized message len:" << bufferLen << ".";
+			m_logger.slog(Logger::warning, ostream.str());
+		}
+	}
+
+	if (bufferLen == -1) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::readFromObject() Failed - Error reading from fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+		m_logger.slog(Logger::warning, ostream.str());
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
+	}
+
+	// It's possible that we won't go into the while() loop above (sometimes the first read is legitimately empty)
+	// in which case, we still need to send a first read complete event
+	if (sendFirstReadEvent) {
+
+		// Send an empty first read object
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", ppsObject()));
+		sendFirstReadEvent = false;
+	}
+}
+
+void PPSInterface::sendEvent(const PPSEvent& event) const
+{
+	if (m_pEventFunc) {
+		m_pEventFunc(m_pEventArg, event);
+	}
+}
+
+PPSInterface* const PPSInterface::getPPSInterface(const unsigned int id)
+{
+	::pthread_mutex_lock(&sm_mutex);
+
+	std::map<unsigned int, PPSInterface*>::iterator it = sm_interfaceLookupTable.find(id);
+
+	if (it != sm_interfaceLookupTable.end()) {
+
+		::pthread_mutex_unlock(&sm_mutex);
+		return (*it).second;
+	}
+
+	::pthread_mutex_unlock(&sm_mutex);
+	return NULL;
+}
+
+ppsObject PPSInterface::parsePPSData(char* data) const
+{
+	// This is the structure that will contain parsed data for each line of the PPS object
+	// It needs to be initialized to NULL
+	pps_attrib_t info;
+	std::memset(&info, 0, sizeof(info));
+
+	// The return code for each PPS line that gets parsed
+	pps_status_t rc;
+	ppsObject ppsObj;
+
+	while ((rc = ::ppsparse(&data, NULL, NULL, &info, 0)) != PPS_END) {
+
+		if (rc == -1) {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::parsePPSData() Failed - Error calling ppsparse() fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+			m_logger.slog(Logger::warning, ostream.str());
+			sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
+		}
+
+		if (info.flags & PPS_INCOMPLETE) {
+			m_logger.slog(Logger::debug, "PPSInterface::parsePPSData - PPS data incomplete.");
+		}
+
+		switch (rc) {
+
+			// When the object has been modified, update the object settings
+			case PPS_OBJECT:
+			case PPS_OBJECT_CREATED:
+			case PPS_OBJECT_DELETED:
+			case PPS_OBJECT_TRUNCATED:
+			{
+				ppsObj.name = info.obj_name;
+				ppsObj.flags = info.flags;
+				ppsObj.options = info.options;
+				ppsObj.optionMask = info.option_mask;
+				break;
+			}
+
+			// An attribute has been updated
+			case PPS_ATTRIBUTE:
+			case PPS_ATTRIBUTE_DELETED:
+			{
+				ppsAttribute ppsAttrib;
+				ppsAttrib.name = info.attr_name;
+
+				// Value and encoding aren't valid if rc == PPS_ATTRIBUTE_DELETED
+				if (rc == PPS_ATTRIBUTE) {
+
+					ppsAttrib.value = info.value;
+					ppsAttrib.encoding = info.encoding;
+				}
+
+				ppsAttrib.flags = info.flags;
+				ppsAttrib.options = info.options;
+				ppsAttrib.optionMask = info.option_mask;
+
+				ppsObj.attributes.insert(ppsAttrPair(ppsAttrib.name, ppsAttrib));
+				break;
+			}
+
+			case PPS_ERROR:
+			{
+				std::string msg("PPSInterface::parsePPSData() Failed - Error parsing PPS data.");
+				m_logger.slog(Logger::warning, msg);
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, msg));
+				break;
+			}
+
+			case PPS_END:
+			default:
+				break;
+		}
+
+	}
+
+	return ppsObj;
+}
+
+void PPSInterface::updateCachedReadData(const ppsObject& newData)
+{
+	::pthread_mutex_lock(&sm_mutex);
+
+	// Update the object
+	m_cachedRead.name = newData.name;
+	m_cachedRead.flags = newData.flags;
+	m_cachedRead.options = newData.options;
+	m_cachedRead.optionMask = newData.optionMask;
+
+	::pthread_mutex_unlock(&sm_mutex);
+
+	// Update the attributes
+	for (const_ppsAttrIter it = newData.attributes.begin(); it != newData.attributes.end(); it++) {
+
+		ppsAttribute attr = (*it).second;
+
+		// An attribute is being deleted
+		if (attr.flags & PPS_DELETED) {
+
+			::pthread_mutex_lock(&sm_mutex);
+
+			// Look for this attribute in the cache and remove it
+			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
+
+			if (findIt != m_cachedRead.attributes.end()) {
+				m_cachedRead.attributes.erase(findIt);
+			}
+
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+		// We're adding a new attribute - don't search for it
+		else if (attr.flags & PPS_CREATED){
+
+			::pthread_mutex_lock(&sm_mutex);
+			m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+		else {
+
+			::pthread_mutex_lock(&sm_mutex);
+
+			// Look for this attribute in the cache
+			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
+
+			// If we find it, update the attribute values
+			if (findIt != m_cachedRead.attributes.end()) {
+
+				(*findIt).second.name = attr.name;
+				(*findIt).second.encoding = attr.encoding;
+				(*findIt).second.value = attr.value;
+				(*findIt).second.flags = attr.flags;
+				(*findIt).second.options = attr.options;
+				(*findIt).second.optionMask = attr.optionMask;
+			}
+			// If we don't find it, insert it
+			else {
+				m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
+			}
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+	}
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
new file mode 100644
index 0000000..0fde80c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPS_H_
+#define PPS_H_
+
+#include <string>
+#include <map>
+
+#include <sys/types.h>
+
+#include "PPSTypes.h"
+#include "PPSEvent.h"
+#include "../utils/Logger.h"
+
+namespace jpps {
+
+/**
+ * This class augments standard PPS functionality by providing events for when PPS objects are opened,
+ * closed, have new data, etc.
+ *
+ * When a PPS object is opened using PPSInterface::open(), the object is opened as part of a notification group
+ * managed by PPSNotifyGroupManager. The notification group monitors the PPS object and notifies PPSInterface
+ * whenever there is new data available in the PPS object.
+ *
+ * PPSInterface should be used in order to simplify PPS object monitoring (i.e. watching for new data in a PPS
+ * object.) PPSInterface takes over management of watching for new data and uses a notification callback mechanism
+ * with a defined set of possible events to inform the client of changes to the PPS object.
+ */
+class PPSInterface {
+
+public:
+
+	/**
+	 * Used with onNotify to allow the PPSNotifier to tell us what type of notification
+	 * message it is sending.
+	 */
+	enum NotifyType {
+		/** The .notify object received a notification that data is ready to be read. */
+		PPS_READ = 0,
+		/** The .notify object received a notification that a file being watched is closing. */
+		PPS_CLOSE = 1 };
+
+	/**
+	 * Constructor.
+	 */
+	PPSInterface();
+
+	/**
+	 * Destructor.
+	 */
+	~PPSInterface();
+
+	/**
+	 * Set up a function to call to be notified about PPS events.
+	 *
+	 * @param pEventFunc The function to call whenever an event happens in PPSInterface.
+	 * @param pArg An optional parameter that will be passed back to pEventFunc every time it
+	 * is called. PPSInterface will not modify pArg.
+	 */
+	void setEventFunc(const PPSEventFunc* pEventFunc, void* pArg = NULL);
+
+	/**
+	 * Enable verbose mode. Increase the number of �v�s to increase verbosity.
+	 *
+	 * @param v The level of verbosity. A value of 0 is off, 1 shows info messages, 2 shows
+	 * debug messages.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS object. If the open() call is successful, a PPS_EVENT_OPENED event will be sent.
+	 * The PPS object will be read as part of the open operation and the PPS_EVENT_FIRST_READ_COMPLETE
+	 * will be sent when the first read is complete. Note that there may be a PPS_EVENT_NEW_DATA
+	 * event *before* the PPS_EVENT_FIRST_READ_COMPLETE event, or there may not be.
+	 * PPS_EVENT_FIRST_READ_COMPLETE only guarantees that at least one read has been performed, not
+	 * that it will be the first read event to fire.
+	 *
+	 * If the open operation fails, the function returns false and a PPS_EVENT_OPEN_FAILED will be sent.
+	 *
+	 * @param path The PPS file/directory path.
+	 * @param oflags Flags passed to ::open.
+	 * @param mode Mode passed to ::open.
+	 * @param serverMode If true, open the object in server mode as the server.
+	 * @return True if the open was successful, false otherwise.
+	 */
+	bool open(const std::string& path, int oflags, int mode, bool serverMode);
+
+	/**
+	 * Check if this PPS object is open.
+	 * @return True if the file is open, false otherwise.
+	 */
+	inline bool isOpen() const { return m_fd >= 0; }
+
+	/**
+	 * Write data to a PPS object.
+	 * @param data The data to write to the PPS object.
+	 */
+	void write(const std::string& data);
+
+	/**
+	 * Read PPS data. Note that this reads cached data from the last read performed when a
+	 * new data available notification was received.
+	 *
+	 * @return A structured representation of the PPS object, culled from a call to ppsparse()
+	 * a function found in ppsparse.h.
+	 */
+
+	inline ppsObject read() const { return m_cachedRead; }
+
+	/**
+	 * Close this PPS object.
+	 */
+	void close();
+
+	/**
+	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
+	 * The function blocks until this is finished.
+	 */
+	void sync();
+
+	/**
+	 * Called to notify us that there is data ready to be read.
+	 *
+	 * @param event The type of event we're being notified about.
+	 */
+	void onNotify(NotifyType event);
+
+	/**
+	 * Given a unique id, return the PPSInterface* matching that id.
+	 *
+	 * Every PPSInterface object is assigned a unique identifier at construction. This
+	 * unique identifier can be used to get a pointer to a PPSInterface at runtime.
+	 *
+	 * In particular, the PPSNotifier gets notifications with this number embedded in them.
+	 * Using this id, the PPSNotifier can callback into the correct PPSInterface instance.
+	 *
+	 * @param id An id that uniquely identifies a PPSInterface object.
+	 * @return a PPSInterface* or NULL if no object matches the given id.
+	 */
+	static PPSInterface* const getPPSInterface(const unsigned int id);
+
+private:
+
+	/**
+	 * Read from the PPS object. Generally this function is called by onNotify() when
+	 * the notifier thread is notified that there is data to be read. This function
+	 * performs a read() of the PPS object that is non-blocking.
+	 */
+	void readFromObject();
+
+	/**
+	 * Given data from a PPS read, parse the PPS data.
+	 */
+	ppsObject parsePPSData(char* data) const;
+
+	/**
+	 * Given new PPS data, update the cached read value.
+	 */
+	void updateCachedReadData(const ppsObject& newData);
+
+	/**
+	 * Call the function set in setEventFunc() with the given event.
+	 *
+	 * @param event The event to send.
+	 */
+	void sendEvent(const PPSEvent& event) const;
+
+	/** The default PPS location. */
+	static const char* PPS_ROOT;
+
+	/** The maximum amount of data that can be read from a PPS object. */
+	static const int MaxPPSReadSize;
+
+	/** The function to call to notify about PPS events. */
+	PPSEventFunc* m_pEventFunc;
+
+	/** An argument that goes with m_pEventFunc. PPSInterface does not modify or use
+	 * this parameter - we simply send it back with every m_pEventFunc call. */
+	void* m_pEventArg;
+
+	/** An identifier that uniquely identifies this PPSInterface object. This is used to look up
+	 * this object in a global table. */
+	unsigned int m_interfaceId;
+
+	/** The file descriptor of the PPS object being opened. */
+	int m_fd;
+
+	/** The open mode flags used when this object was opened. */
+	int m_oflags;
+
+	/** If true, main thread is performing initial open/read of PPS object. This is shared
+	 * across threads and needs to be mutexed when accessed.*/
+	volatile bool m_firstRead;
+
+	/** The data from the last read performed. */
+	ppsObject m_cachedRead;
+
+	/** The logger used to log error messages */
+	Logger m_logger;
+
+	/** Mutex used to prevent threads from clobbering each other. */
+	static pthread_mutex_t sm_mutex;
+
+	/** Condvar used for multi-thread signaling. */
+	static pthread_cond_t sm_cond;
+
+	/** Used to ensure that initialization of statics happens only once. This is shared
+	 * across threads and needs to be mutexed when accessed.*/
+	static volatile bool sm_firstInitDone;
+
+	/** The PPSNotifier needs a way to transform an id that uniquely identifies a PPSInterface object
+	 * into an actual PPSInterface*. When we construct a new PPSInterface, we will assign it a unique id
+	 * and we will put the id and the pointer to the object into this table. The table can then be used
+	 * to lookup this object from its unique id. */
+	static std::map<unsigned int, PPSInterface*> sm_interfaceLookupTable;
+};
+
+} /* namespace jpps */
+#endif /* PPS_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
new file mode 100644
index 0000000..7869a56
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSNotifier.h"
+
+#include <sstream>
+
+#include <fcntl.h>
+
+#include "PPSInterface.h"
+#include "../utils/Logger.h"
+
+namespace jpps {
+
+PPSNotifier::PPSNotifier()
+: m_notifyObjPath("")
+, m_notifyObjFd(-1)
+, m_notifyGroupId("")
+, m_thread()
+{
+
+}
+
+PPSNotifier::~PPSNotifier()
+{
+	// Stop the thread
+	m_thread.stop();
+
+	// Close the .notify file
+	if (m_notifyObjFd >= 0) {
+		::close(m_notifyObjFd);
+	}
+}
+
+void PPSNotifier::startNotifyLoop()
+{
+	m_thread.start(_notifyLoop, this, "plugin_jPPS_PPSNotifier(" + m_notifyObjPath + "/.notify)");
+}
+
+
+void* PPSNotifier::_notifyLoop(void* pArg)
+{
+	// Something is messed up
+	if (pArg == NULL)
+		return NULL;
+
+	PPSNotifier* pNotifier = static_cast<PPSNotifier*> (pArg);
+
+	// pArg is supposed to be a PPSNotifier object...
+	if (pNotifier == NULL)
+		return NULL;
+
+	pNotifier->notifyLoop();
+
+	return NULL;
+}
+
+void PPSNotifier::notifyLoop()
+{
+	// Buffer for read() operation
+	char szData[256];
+	int dataLen;
+
+	// This is a blocking read call: this will wait in this loop forever
+	while ((dataLen = ::read(m_notifyObjFd, szData, sizeof(szData)-1)) > 0) {
+
+                szData[dataLen] = '\0';
+		std::string data(szData);
+
+		if ((unsigned int)dataLen > sizeof(szData)-1) {
+
+			std::ostringstream ostream;
+			ostream << "PPSNotifier::notifyLoop() - Notify read overflow " << dataLen << ".";
+			Logger logger;
+			logger.slog(Logger::error, ostream.str());
+		}
+
+		std::size_t nPos = data.find('\n');
+
+		// While we find linefeeds
+		while(nPos != std::string::npos) {
+
+			// Read the first char
+			PPSInterface::NotifyType event = data[0] == '-' ? PPSInterface::PPS_CLOSE : PPSInterface::PPS_READ;
+			std::size_t nAddrPos = data.find(':');
+
+			if (nAddrPos != std::string::npos) {
+
+				std::string sAddress = data.substr(nAddrPos+1);
+				std::size_t nAddrEnd = sAddress.find('\n');
+
+				if (nAddrEnd != std::string::npos) {
+
+					sAddress = sAddress.substr(0, nAddrEnd);
+
+					unsigned int interfaceId = 0;
+
+					std::stringstream ss;
+					ss << sAddress;
+					ss >> interfaceId;
+
+					PPSInterface* const pPPS = PPSInterface::getPPSInterface(interfaceId);
+
+					if (pPPS) {
+						pPPS->onNotify(event);
+					}
+				}
+			}
+
+			// Don't go off the end of the string
+			if (++nPos < data.length()) {
+
+				// Remove the stuff up to the first '\n' and look for the next '\n'
+				data = data.substr(nPos);
+				nPos = data.find('\n');
+			}
+			else {
+
+				nPos = std::string::npos;
+			}
+		}
+	}
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
new file mode 100644
index 0000000..143f052
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSNOTIFIER_H_
+#define PPSNOTIFIER_H_
+
+#include <string>
+
+#include "../utils/Thread.h"
+
+namespace jpps {
+
+/**
+ * PPSNotifier is an encapsulation of an open PPS .notify object. PPSNotifier has a
+ * blocking thread dedicated to reading from its .notify object. The thread constantly
+ * waits for new notifications in the .notify object.
+ *
+ * The way the PPS notify mechanism works is that on the first open/read of a .notify object,
+ * PPS provides a notify group id. This group id can be used when opening any PPS object to make
+ * the PPS object join the notify group.
+ *
+ * For example, you open a .notify file and the group id returned is "2a3".
+ * You subsequently open a PPS object and make it join that notify group:
+ *
+ * ::open("/pps/myppsobj?notify=2a3:someUniqueValueIDecide");
+ *
+ * Now, every time myppsobj changes, the .notify file will be updated in the following manner:
+ *
+ * <code>Notify 2a3:someUniqueValueIDecide</code>
+ *
+ * For a change to the file. And
+ *
+ * <code>-2a3:someUniqueValueIDecide</code>
+ *
+ * if myppsobj is closed.
+ *
+ * When PPSNotifier reads a notification, the unique value is actually a unique identifier for a
+ * PPSInterface object that can be looked up in a global PPSInterface lookup table. Getting the
+ * PPSInterface object designated by the unique identifier, PPSNotifier calls PPSInterface::onNotify()
+ * to inform the PPSInterface object that there is new data pending or that the file has closed.
+ * It is then up to the PPSInterface to decide how to proceed to get that data from myppsobj.
+ */
+class PPSNotifier {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSNotifier();
+
+	/**
+	 * Destructor. Note that this destructor will attempt to close the .notify
+	 * object's file.
+	 */
+	virtual ~PPSNotifier();
+
+	/**
+	 * Start the notify thread.
+	 */
+	void startNotifyLoop();
+
+	/**
+	 * Get the .notify object's path.
+	 *
+	 * @return The path to the .notify object.
+	 */
+	inline std::string getNotifyObjPath() const { return m_notifyObjPath; }
+
+	/**
+	 * Set the .notify object's path.
+	 *
+	 * @param path The path of the .notify object (note that this should not include the
+	 * .notify object name).
+	 */
+	inline void setNotifyOjbPath(const std::string& path) { m_notifyObjPath = path; }
+
+	/**
+	 * Get the .notify object's file descriptor.
+	 *
+	 * @return The file descriptor for the open .notify object.
+	 */
+	inline int getObjFd() const { return m_notifyObjFd; }
+
+	/**
+	 * Set the .notify object's file descriptor.
+	 *
+	 * @param The file descriptor for the open .notify object.
+	 */
+	inline void setObjFd(const int fd) { m_notifyObjFd = fd; }
+
+	/**
+	 * Set this notifier's .notify group ID (assigned by PPS).
+	 *
+	 * @param The .notify object's group ID, which is returned by PPS on the first read
+	 * of the .notify object.
+	 */
+	inline std::string getNotifyGroupId() const { return m_notifyGroupId; }
+
+	/**
+	 * Get this notifier's .notify group ID (assigned by PPS).
+	 *
+	 * @return The .notify object's group ID.
+	 */
+	inline void setNotifyGroupId(const std::string& id) { m_notifyGroupId = id; }
+
+private:
+
+	// Disable the copy constructor
+	PPSNotifier(const PPSNotifier& manager);
+
+	// Disable the assignment operator
+	PPSNotifier& operator=(const PPSNotifier& rhs);
+
+	/**
+	 * Function used to start the thread. Pass this into the Thread::start() function.
+	 *
+	 * @param pArg A pointer to a PPSNotifier.
+	 */
+	static void* _notifyLoop(void* pArg);
+
+	/**
+	 * The main thread loop. Blocks on reading the .notify file.
+	 */
+	void notifyLoop();
+
+	/** The path of the .notify file we're monitoring to know when to get data. */
+	std::string m_notifyObjPath;
+
+	/** The file descriptor of the .notify file we're monitoring to know when to get data. */
+	int m_notifyObjFd;
+
+	/** The .notify group ID assigned by PPS when the group was created. */
+	std::string m_notifyGroupId;
+
+	/** The thread I'm running on. */
+	Thread m_thread;
+};
+
+} /* namespace jpps */
+#endif /* PPSNOTIFIER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
new file mode 100644
index 0000000..5392ca8
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSNotifyGroupManager.h"
+
+#include <fcntl.h>
+
+#include "PPSNotifier.h"
+
+namespace jpps {
+
+typedef std::map<std::string, PPSNotifier*>::iterator groupIter;
+typedef std::map<std::string, PPSNotifier*>::const_iterator const_groupIter;
+typedef std::pair<std::string, PPSNotifier*> groupValue;
+
+pthread_mutex_t PPSNotifyGroupManager::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+PPSNotifyGroupManager::PPSNotifyGroupManager()
+{
+
+}
+
+PPSNotifyGroupManager::~PPSNotifyGroupManager()
+{
+	// Delete the allocated memory for all the PPSNotifiers
+	for (groupIter it = m_notifyGroups.begin(); it != m_notifyGroups.end(); it++) {
+
+		if ((*it).second != NULL) {
+
+			delete (*it).second;
+			(*it).second = NULL;
+		}
+	}
+}
+
+PPSNotifyGroupManager& PPSNotifyGroupManager::getInstance()
+{
+	// The one and only PPSNotifyGroupManager
+	static PPSNotifyGroupManager manager;
+	return manager;
+}
+
+bool PPSNotifyGroupManager::joinNotifyGroup(const std::string& path, std::string& groupId)
+{
+	std::string notifyFile;
+	std::string notifyPath(path);
+	std::size_t nPos = notifyPath.rfind('/');
+
+	// Search through the directories in the string until we find a valid .notify object
+	while (nPos != std::string::npos) {
+
+		// Chop off everything after the last '/' to get the path without the PPS object name
+		notifyPath = notifyPath.substr(0, nPos);
+
+		// Do we already have a notify group for this path?
+		const_groupIter it = m_notifyGroups.find(notifyPath);
+
+		// We found a match!
+		if (it != m_notifyGroups.end() && (*it).second != NULL) {
+
+			groupId = (*it).second->getNotifyGroupId();
+			return true;
+		}
+
+		// Add ".notify?wait" to the notify path, to make it a real file
+		notifyFile = notifyPath + "/.notify?wait";
+
+		// Try to open this .notify object
+		int fd = ::open(notifyFile.c_str(), O_RDONLY);
+
+		// This is the .notify object to use
+		if (fd >= 0) {
+
+			char data[20];
+			int len = ::read(fd, data, sizeof(data) - 1);
+			// Terminate string to remove the newline char
+			data[len > 0 ? len - 1 : 0] = '\0';
+
+			PPSNotifier* pNotifier = new PPSNotifier();
+			pNotifier->setNotifyGroupId(std::string(data));
+			pNotifier->setNotifyOjbPath(notifyPath);
+			pNotifier->setObjFd(::dup(fd));
+                        ::close(fd);
+
+			// Add this badboy to our cache of notify groups
+			m_notifyGroups.insert(groupValue(notifyPath, pNotifier));
+
+			// Start the notify reading thread
+			pNotifier->startNotifyLoop();
+
+			groupId = pNotifier->getNotifyGroupId();
+			return true;
+		}
+		// Keep looking
+		else {
+
+			nPos = notifyPath.rfind('/');
+		}
+	}
+
+	// We didn't find a notify group
+	groupId = "";
+	return false;
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
new file mode 100644
index 0000000..03b0e3e
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSNOTIFYGROUPMANAGER_H_
+#define PPSNOTIFYGROUPMANAGER_H_
+
+#include <map>
+#include <string>
+#include <pthread.h>
+
+namespace jpps {
+
+// Forward declaration
+class PPSNotifier;
+
+
+/**
+ * The PPSNotifyGroupManager is used to manage a global pool of .notify objects. PPS has a mechanism
+ * where every folder can contain a special PPS object ".notify". Opening the .notify object will return
+ * a group id on the first read of the .notify object. The group id is used to open the real PPS object
+ * for which we desire to receive notifications. Once this is done, the .notify object is the one that will
+ * receive change notifications for the real PPS object. In this model, the real PPS object DOES NOT
+ * open in blocking read or ionotify/select mode. The .notify object is the one responsible for blocking
+ * on read and tracking data publishing.
+ *
+ * This object is a global singleton - any access to it needs to be wrapped in a mutex to prevent
+ * concurrency problems. Two functions mutex_lock() and mutex_unlock() are provided for this purpose.
+ */
+class PPSNotifyGroupManager
+{
+public:
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSNotifyGroupManager();
+
+	/**
+	 * Get the one and only instance of the PPSNotifier.Always wrap calls to getInstance() in a call to
+	 * PPSNotifyGroupManager::mutexLock()/mutexUnlock().
+	 */
+	static PPSNotifyGroupManager& getInstance();
+
+	/**
+	 * Use this function to get the notify group id of the "closest" .notify object in the /pps hierarchy
+	 * that contains path.
+	 *
+	 * The function will go backwards through the directories in path looking for a .notify object. It will return
+	 * the group id of the first .notify object it finds on this path. It is the responsibility of the caller
+	 * to have the PPS object in path join the notify group by opening the object with the "notify=groupId:val"
+	 * option set.
+	 *
+	 * PPSNotifyGroupManager maintains a pool of opened .notify objects. It is possible for a single .notify object
+	 * to have a very disparate (and numerous) set of PPS objects that it monitors. In order to tweak performance
+	 * it is advisable that .notify object be created in strategic directories in the /pps directory hierarchy, in
+	 * order to spread the load of notification monitoring. Each .notify object opened will spawn a thread that blocks
+	 * on reading from the .notify object. Having several .notify objects means having several threads that read
+	 * notifications.
+	 *
+	 * Note that joinNotifyGroup() will NOT create any .notify PPS objects. The /pps/.notify object always exists,
+	 * and if the /pps directory hierarchy contains no other .notify objects, /pps/.notify will end up being the
+	 * notification group that all objects join.
+	 *
+	 * Always wrap calls to joinNotifyGroup() in a call to PPSNotifyGroupManager::mutexLock()/mutexUnlock().
+	 *
+	 * @param The PPS object that wants to join the notify group.
+	 * @param groupId The id of the notify group joined. This is an output parameter.
+	 * @return True if a notify group was successfully joined, false otherwise. If true, then the groupId
+	 * variable will be set.
+	 */
+	bool joinNotifyGroup(const std::string& path, std::string& groupId);
+
+	/**
+	 * Returns how many notification groups the manager is managing.
+	 *
+	 * @return The number of notification groups (i.e. open .notify objects) in use.
+	 */
+	inline std::size_t getNumGroups() const { return m_notifyGroups.size(); }
+
+	/**
+	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
+	 * object, multiple threads may try to access this object at one time. It is therefore important to
+	 * mutex lock all access to this object.
+	 */
+	static inline void mutexLock() { pthread_mutex_lock(&sm_mutex); }
+
+	/**
+	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
+	 * object, multiple threads may try to access this object at one time. It is therefore important to
+	 * mutex lock all access to this object.
+	 */
+	static inline void mutexUnlock() { pthread_mutex_unlock(&sm_mutex); }
+
+private:
+
+	/**
+	 * Constructor. Private as part of the singleton pattern of this object.
+	 */
+	PPSNotifyGroupManager();
+
+	// Disable the copy constructor.
+	PPSNotifyGroupManager(const PPSNotifyGroupManager& manager);
+
+	// Disable the assignment operator.
+	PPSNotifyGroupManager& operator=(const PPSNotifyGroupManager& rhs);
+
+	/** This is a cache of all the .notify objects. */
+	std::map<std::string, PPSNotifier*> m_notifyGroups;
+
+	/** Mutex used to prevent threads from clobbering each other. */
+	static pthread_mutex_t sm_mutex;
+};
+
+} /* namespace jpps */
+#endif /* PPSNOTIFYGROUPMANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
new file mode 100644
index 0000000..362d236
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSTYPES_H_
+#define PPSTYPES_H_
+
+#include <map>
+
+namespace jpps {
+
+class PPSEvent;
+
+/**
+ * A struct representing an attribute of a PPS object.
+ */
+struct ppsAttribute {
+
+	/** The attribute name. */
+	std::string name;
+	/** The attribute value. */
+	std::string value;
+	/** The attribute encoding. */
+	std::string encoding;
+	/** Flags associated to the attribute. */
+	int flags;
+	/** Attribute options. */
+	int options;
+	/** The attribute options mask. */
+	int optionMask;
+};
+
+/**
+ * A struct representing a PPS object.
+ */
+struct ppsObject {
+
+	/** The PPS object name. */
+	std::string name;
+	/** The PPS object flags. */
+	int flags;
+	/** The PPS object options. */
+	int options;
+	/** The PPS object option mask. */
+	int optionMask;
+	/** The attributes of this PPS object. */
+	std::map<std::string, ppsAttribute> attributes;
+};
+
+/**
+ * Typedef for ppsAttribute iterator.
+ */
+typedef std::map<std::string, ppsAttribute>::iterator ppsAttrIter;
+
+/**
+ * Typedef for ppsAttribute const iterator.
+ */
+typedef std::map<std::string, ppsAttribute>::const_iterator const_ppsAttrIter;
+
+/**
+ * A pair used to insert attributes into the map.
+ */
+typedef std::pair<std::string, ppsAttribute> ppsAttrPair;
+
+/**
+ * This is the definition of the notify function clients of PPSInterface use in order
+ * to be informed of events the PPSInterface generates.
+ *
+ * @param pArg A user defined parameter. This value can be passed in to PPSInterface::setEventFunc()
+ * and will be passed back with the event handler every time it is called. PPSInterface will not
+ * modify this value.
+ *
+ * @aparam event The PPS event being broadcast.
+ */
+typedef void (PPSEventFunc)(void* pArg, const PPSEvent& event);
+
+};
+
+#endif /* PPSTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
new file mode 100644
index 0000000..9b5d711
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "JPPSPlugin.h"
+
+#include <string>
+#include <sstream>
+
+namespace jpps {
+
+const char* JPPSPlugin::CLASS_NAME = "PPS";
+const std::string JPPSPlugin::METHOD_OPEN = "Open";
+const std::string JPPSPlugin::METHOD_CLOSE = "Close";
+const std::string JPPSPlugin::METHOD_WRITE = "Write";
+const std::string JPPSPlugin::METHOD_READ = "Read";
+const std::string JPPSPlugin::METHOD_SET_VERBOSE = "SetVerbose";
+
+JPPSPlugin::JPPSPlugin(const std::string& jnextObjectId)
+: m_jnextObjId(jnextObjectId)
+, m_ppsInterface()
+{
+	// We only have one event handler, we'll use it for all events
+	m_ppsInterface.callbackInit(this,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent);
+}
+
+JPPSPlugin::~JPPSPlugin()
+{
+
+}
+
+std::string JPPSPlugin::InvokeMethod(const std::string& strCommand)
+{
+	// Parameter sanity check
+	if (strCommand == "")
+		return std::string(szERROR) + " JPPSPlugin::InvokeMethod() called with no method to invoke.";
+
+	// Tokenize the stream of input information
+	std::stringstream args(strCommand);
+	std::string method;
+	args >> method;
+
+	// Invoke the method requested
+	if (method == JPPSPlugin::METHOD_WRITE) {
+		return write(args);
+	}
+	else if (method == JPPSPlugin::METHOD_READ) {
+		return read();
+	}
+	else if (method == JPPSPlugin::METHOD_OPEN) {
+		return open(args);
+	}
+	else if (method == JPPSPlugin::METHOD_CLOSE) {
+		return close();
+	}
+	else if (method == JPPSPlugin::METHOD_SET_VERBOSE) {
+		return setVerbose(args);
+	}
+
+	return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::InvokeMethod() - unknown method \"" + method + "\"";
+}
+
+std::string JPPSPlugin::open(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the path
+	std::string path;
+	args >> path;
+
+	// Missing argument
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
+
+	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
+	int oflags = 0;
+	args >> oflags;
+
+	bool bRet = m_ppsInterface.open(path, oflags);
+
+	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - failed to open \"" + path + "\".";
+}
+
+std::string JPPSPlugin::close()
+{
+	m_ppsInterface.close();
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSPlugin::write(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::write() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the initial whitespace that was between the method name and the parameter
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsInterface.write(tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSPlugin::read() const
+{
+	return std::string(szOK) + m_ppsInterface.read();
+}
+
+std::string JPPSPlugin::setVerbose(std::stringstream& args)
+{
+	unsigned short verbosity = 0;
+
+	// If no param was passed, default to 0, else read the value
+	if (!args.eof())
+		args >> verbosity;
+
+	m_ppsInterface.setVerbose(verbosity);
+	return szOK;
+}
+
+void JPPSPlugin::onEvent(const std::string& sEvent) const
+{
+	// We have to add our object Id to the event
+	std::string pluginEvent = m_jnextObjId + " " + sEvent;
+	SendPluginEvent(pluginEvent.c_str(), m_pContext);
+}
+
+void JPPSPlugin::onEvent(void* pArg, const std::string& sEvent)
+{
+	// Cast pArg back to JPPSPlugin and invoke onEvent()
+	JPPSPlugin* pPlugin = static_cast<JPPSPlugin*>(pArg);
+
+	if (pPlugin != NULL)
+		pPlugin->onEvent(sEvent);
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
new file mode 100644
index 0000000..1a56ab2
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef JPPSPLUGIN_H_
+#define JPPSPLUGIN_H_
+
+#include "../common/plugin.h"
+#include "PPSInterfaceGlue.h"
+
+namespace jpps {
+
+/**
+ * JPPSPlugin is a JNext extension which provides PPS support to JavaScript.
+ * This class is merely a wrapper for PPSInterfaceGlue, providing the necessary
+ * JNext interface and performing string-parameter encoding and decoding.
+ *
+ * The intention is that this class will be replaced with a different plug-in framework.
+ */
+class JPPSPlugin : public JSExt {
+
+public:
+
+	// Constants
+
+	/** The only class supported by this plugin. */
+	static const char* CLASS_NAME;
+
+	// List of object methods supported by this extension
+
+	/** Open a PPS object/directory. */
+	static const std::string METHOD_OPEN;
+	/** Close a PPS object/directory. */
+	static const std::string METHOD_CLOSE;
+	/** Write a PPS object. */
+	static const std::string METHOD_WRITE;
+	/** Read a PPS object. */
+	static const std::string METHOD_READ;
+	/** Adjust output verbosity. */
+	static const std::string METHOD_SET_VERBOSE;
+
+	/**
+	 * Constructor.
+	 */
+	JPPSPlugin(const std::string& jnextObjectId);
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~JPPSPlugin();
+
+	// Inherited from JSExt
+	virtual std::string InvokeMethod(const std::string& strCommand);
+	virtual inline bool CanDelete(void) { return true; }
+
+	/**
+	 *  Static callback method, changes pArg back into a JPPSPlugin and invokes
+	 *  the non-static version of onEvent().
+	 */
+	static void onEvent(void* pArg, const std::string& sEvent);
+
+private:
+
+	// Disable the default constructor
+	JPPSPlugin();
+
+	/**
+	 * The non-static version of onEvent. Handler for the PPSInterfaceGlue class' events.
+	 */
+	void onEvent(const std::string& sEvent) const;
+
+	/**
+	 * Open a PPS object.
+	 */
+	std::string open(std::stringstream& args);
+
+	/**
+	 * Close the PPS object.
+	 */
+	std::string close();
+
+	/**
+	 * Write data to the PPS object.
+	 */
+	std::string write(std::stringstream& args);
+
+	/**
+	 * Read the cached PPS data from the last read.
+	 */
+	std::string read() const;
+
+	/**
+	 * Set the verbosity level for logging to slog.
+	 */
+	std::string setVerbose(std::stringstream& args);
+
+	/** A unique JNext id for this object */
+	std::string m_jnextObjId;
+
+	/** The PPS object. */
+	PPSInterfaceGlue m_ppsInterface;
+};
+
+} /* namespace jpps */
+#endif /* JPPSPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
new file mode 100644
index 0000000..6c3bc2d
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "JPPSServerPlugin.h"
+
+#include <sstream>
+
+namespace jpps {
+
+const char* JPPSServerPlugin::CLASS_NAME = "PPSServer";
+
+const std::string JPPSServerPlugin::METHOD_OPEN = "Open";
+const std::string JPPSServerPlugin::METHOD_CLOSE = "Close";
+const std::string JPPSServerPlugin::METHOD_SET_VERBOSE = "SetVerbose";
+const std::string JPPSServerPlugin::METHOD_SEND_MESSAGE = "SendMessage";
+const std::string JPPSServerPlugin::METHOD_BROADCAST_MESSAGE = "BroadcastMessage";
+
+JPPSServerPlugin::JPPSServerPlugin(const std::string& jnextObjectId)
+: m_jnextObjId(jnextObjectId)
+, m_ppsServer()
+{
+	m_ppsServer.callbackInit(this,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent);
+}
+
+JPPSServerPlugin::~JPPSServerPlugin()
+{
+}
+
+std::string JPPSServerPlugin::InvokeMethod(const std::string& strCommand)
+{
+	// Parameter sanity check
+	if (strCommand == "")
+		return std::string(szERROR) + " JPPSServerPlugin::InvokeMethod() called with no method to invoke.";
+
+	// Tokenize the stream of input information
+	std::stringstream args(strCommand);
+	std::string method;
+	args >> method;
+
+	// Invoke the method requested
+	if (method == JPPSServerPlugin::METHOD_OPEN) {
+		return open(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_CLOSE) {
+		return close();
+	}
+	else if (method == JPPSServerPlugin::METHOD_SET_VERBOSE) {
+		return setVerbose(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_SEND_MESSAGE) {
+		return sendMessage(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_BROADCAST_MESSAGE) {
+		return broadcastMessage(args);
+	}
+
+	return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::InvokeMethod() - unknown method \"" + method + "\"";
+}
+
+std::string JPPSServerPlugin::open(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the path
+	std::string path;
+	args >> path;
+
+	// Missing argument
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
+
+	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
+	int oflags = 0;
+	args >> oflags;
+
+	bool bRet = m_ppsServer.open(path, oflags);
+
+	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - failed to open \"" + path + "\".";
+}
+
+std::string JPPSServerPlugin::close()
+{
+	m_ppsServer.close();
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::setVerbose(std::stringstream& args)
+{
+	unsigned short verbosity = 0;
+
+	// If no param was passed, default to 0, else read the value
+	if (!args.eof())
+		args >> verbosity;
+
+	m_ppsServer.setVerbose(verbosity);
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::sendMessage(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the clientId
+	std::string clientId;
+	args >> clientId;
+
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the clientID and the message
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsServer.sendMessage(clientId, tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::broadcastMessage(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::broadcastMessage() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the method name and the message
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsServer.broadcastMessage(tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+void JPPSServerPlugin::onEvent(const std::string& sEvent) const
+{
+	// We have to add our object Id to the event
+	std::string pluginEvent = m_jnextObjId + " " + sEvent;
+	SendPluginEvent(pluginEvent.c_str(), m_pContext);
+}
+
+void JPPSServerPlugin::onEvent(void* pArg, const std::string& sEvent)
+{
+	// Cast pArg back to JPPSPlugin and invoke onEvent()
+	JPPSServerPlugin* pPlugin = static_cast<JPPSServerPlugin*>(pArg);
+
+	if (pPlugin != NULL)
+		pPlugin->onEvent(sEvent);
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
new file mode 100644
index 0000000..ea5b18f
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef JPPSSERVERPLUGIN_H_
+#define JPPSSERVERPLUGIN_H_
+
+#include "../common/plugin.h"
+#include "PPSServerGlue.h"
+
+namespace jpps {
+
+class JPPSServerPlugin: public JSExt {
+
+public:
+
+	// Constants
+
+	/** The only class supported by this plugin. */
+	static const char* CLASS_NAME;
+
+	// List of object methods supported by this extension
+
+	/** Open a PPS object/directory. */
+	static const std::string METHOD_OPEN;
+	/** Close a PPS object/directory. */
+	static const std::string METHOD_CLOSE;
+	/** Adjust output verbosity. */
+	static const std::string METHOD_SET_VERBOSE;
+	/** Send a message to a particular client. */
+	static const std::string METHOD_SEND_MESSAGE;
+	/** Send a message to all clients. */
+	static const std::string METHOD_BROADCAST_MESSAGE;
+
+	/**
+	 * Constructor.
+	 */
+	JPPSServerPlugin(const std::string& jnextObjectId);
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~JPPSServerPlugin();
+
+	// Inherited from JSExt
+	virtual std::string InvokeMethod(const std::string& strCommand);
+	virtual inline bool CanDelete(void) { return true; }
+
+	/**
+	 *  Static callback method, changes pArg back into a JPPSServerPlugin and invokes
+	 *  the non-static version of onEvent().
+	 */
+	static void onEvent(void* pArg, const std::string& sEvent);
+
+private:
+
+	// Disable default constructor.
+	JPPSServerPlugin();
+
+	/**
+	 * The non-static version of onEvent. Handler for the PPSServerGlue class' events.
+	 */
+	void onEvent(const std::string& sEvent) const;
+
+	/**
+	 * Open a PPS object.
+	 */
+	std::string open(std::stringstream& args);
+
+	/**
+	 * Close the PPS object.
+	 */
+	std::string close();
+
+	/**
+	 * Set the verbosity level for logging to slog.
+	 */
+	std::string setVerbose(std::stringstream& args);
+
+	/**
+	 * Send a message to a particular client.
+	 */
+	std::string sendMessage(std::stringstream& args);
+
+	/**
+	 * Send a message to all clients.
+	 */
+	std::string broadcastMessage(std::stringstream& args);
+
+	/** A unique JNext id for this object */
+	std::string m_jnextObjId;
+
+	/** The PPS object. */
+	PPSServerGlue m_ppsServer;
+};
+
+} /* namespace jpps */
+#endif /* JPPSSERVERPLUGIN_H_ */


[12/50] [abbrv] webworks commit: Migrated camera to be a cordova plugin

Posted by lo...@apache.org.
Migrated camera to be a cordova plugin

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/042526cf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/042526cf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/042526cf

Branch: refs/heads/future
Commit: 042526cf06f779e0f1f110a044751f4e3678f463
Parents: b0edce5
Author: Rosa Tse <rt...@blackberry.com>
Authored: Thu Mar 28 16:23:42 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../project/cordova/lib/native-packager.js         |    2 +-
 .../bin/templates/project/plugins/Camera/index.js  |  124 ++++++
 blackberry10/bin/test/plugins/Camera/index.js      |  298 +++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |  142 ++-----
 4 files changed, 465 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/042526cf/blackberry10/bin/templates/project/cordova/lib/native-packager.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/native-packager.js b/blackberry10/bin/templates/project/cordova/lib/native-packager.js
index 2681bf2..8529458 100644
--- a/blackberry10/bin/templates/project/cordova/lib/native-packager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/native-packager.js
@@ -68,7 +68,7 @@ function generateTabletXMLFile(session, config) {
     //Enable slog2 output if debugging
     if (session.debug) {
         xmlObject.env.push({
-            _attr : { value : 'slog2', var : 'CONSOLE_MODE' }
+            _attr : { value : 'slog2', 'var' : 'CONSOLE_MODE' }
         });
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/042526cf/blackberry10/bin/templates/project/plugins/Camera/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Camera/index.js b/blackberry10/bin/templates/project/plugins/Camera/index.js
new file mode 100644
index 0000000..922f049
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Camera/index.js
@@ -0,0 +1,124 @@
+/*
+ * 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 PictureSourceType = {
+        PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
+        CAMERA : 1,          // Take picture from camera
+        SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+    },
+    DestinationType = {
+        DATA_URL: 0,         // Return base64 encoded string
+        FILE_URI: 1,         // Return file uri (content://media/external/images/media/2 for Android)
+        NATIVE_URI: 2        // Return native uri (eg. asset-library://... for iOS)
+    };
+
+function encodeBase64(filePath, callback) {
+    var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value
+        errorHandler = function (err) {
+            var msg = "An error occured: ";
+
+            switch (err.code) {
+            case FileError.NOT_FOUND_ERR:
+                msg += "File or directory not found";
+                break;
+
+            case FileError.NOT_READABLE_ERR:
+                msg += "File or directory not readable";
+                break;
+
+            case FileError.PATH_EXISTS_ERR:
+                msg += "File or directory already exists";
+                break;
+
+            case FileError.TYPE_MISMATCH_ERR:
+                msg += "Invalid file type";
+                break;
+
+            default:
+                msg += "Unknown Error";
+                break;
+            };
+
+            // set it back to original value
+            window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
+            callback(msg);
+        },
+        gotFile = function (fileEntry) {
+            fileEntry.file(function (file) {
+                var reader = new FileReader();
+
+                reader.onloadend = function (e) {
+                    // set it back to original value
+                    window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
+                    callback(this.result);
+                };
+
+                reader.readAsDataURL(file);
+            }, errorHandler);
+        },
+        onInitFs = function (fs) {
+            window.qnx.webplatform.getController().setFileSystemSandbox = false;
+            fs.root.getFile(filePath, {create: false}, gotFile, errorHandler);
+        };
+
+    window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max
+}
+
+module.exports = {
+    takePicture: function (success, fail, args, env) {
+        var destinationType = JSON.parse(decodeURIComponent(args[1])),
+            sourceType = JSON.parse(decodeURIComponent(args[2])),
+            result = new PluginResult(args, env),
+            done = function (data) {
+                if (destinationType === DestinationType.FILE_URI) {
+                    data = "file://" + data;
+                    result.callbackOk(data, false);
+                } else {
+                    encodeBase64(data, function (data) {
+                        if (/^data:/.test(data)) {
+                            data = data.slice(data.indexOf(",") + 1);
+                            result.callbackOk(data, false);
+                        } else {
+                            result.callbackError(data, false);
+                        }
+                    });
+                }
+            },
+            cancel = function (reason) {
+                result.callbackError(reason, false);
+            },
+            invoked = function (error) {
+                if (error) {
+                    result.callbackError(error, false);
+                }
+            };
+
+        switch(sourceType) {
+        case PictureSourceType.CAMERA:
+            window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked);
+            break;
+
+        case PictureSourceType.PHOTOLIBRARY:
+        case PictureSourceType.SAVEDPHOTOALBUM:
+            window.qnx.webplatform.getApplication().cards.filePicker.open({
+                mode: "Picker",
+                type: ["picture"]
+            }, done, cancel, invoked);
+            break;
+        }
+
+        result.noResult(true);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/042526cf/blackberry10/bin/test/plugins/Camera/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Camera/index.js b/blackberry10/bin/test/plugins/Camera/index.js
new file mode 100644
index 0000000..e629a41
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Camera/index.js
@@ -0,0 +1,298 @@
+/*
+* Copyright 2013 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.
+*/
+describe("Camera", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Camera/",
+        index,
+        mockDone,
+        mockCancel,
+        mockError,
+        mockedEnv = {
+            response: {
+                send: jasmine.createSpy()
+            },
+            webview: {
+                executeJavaScript: jasmine.createSpy()
+            }
+        },
+        PictureSourceType = {
+            PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
+            CAMERA : 1,          // Take picture from camera
+            SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+        },
+        DestinationType = {
+            DATA_URL: 0,         // Return base64 encoded string
+            FILE_URI: 1,         // Return file uri (content://media/external/images/media/2 for Android)
+            NATIVE_URI: 2        // Return native uri (eg. asset-library://... for iOS)
+        },
+        readFail,
+        mockBase64Data = "/9j/4QHRw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
+
+    function mockOpen(options, done, cancel, invoked) {
+        if (!mockError) {
+            invoked();
+        }
+
+        if (mockDone) {
+            done(mockDone.path);
+        } else if (mockCancel) {
+            cancel(mockCancel.reason);
+        } else if (mockError) {
+            invoked(mockError.error);
+        }
+    }
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+        mockedEnv.response.send.reset();
+        mockedEnv.webview.executeJavaScript.reset();
+    });
+
+    afterEach(function () {
+        index = null;
+        mockDone = null;
+        mockCancel = null;
+        mockError = null;
+        readFail = false;
+    });
+
+    describe("takePicture", function () {
+        beforeEach(function () {
+            GLOBAL.window = {
+                qnx: {
+                    webplatform: {
+                        getApplication: function () {
+                            return {
+                                cards: {
+                                    camera: {
+                                        open: jasmine.createSpy().andCallFake(mockOpen)
+                                    },
+                                    filePicker: {
+                                        open: jasmine.createSpy().andCallFake(mockOpen)
+                                    }
+                                }
+                            };
+                        },
+                        getController: function () {
+                            return {
+                                setFileSystemSandbox: true
+                            };
+                        }
+                    }
+                },
+                webkitRequestFileSystem: jasmine.createSpy().andCallFake(function (type, size, success, error) {
+                    success({
+                        root: {
+                            getFile: jasmine.createSpy().andCallFake(function (path, options, success, error) {
+                                if (readFail) {
+                                    error({
+                                        code: -1
+                                    });
+                                } else {
+                                    success({
+                                        file: jasmine.createSpy().andCallFake(function (cb) {
+                                            cb();
+                                        })
+                                    });
+                                }
+                            })
+                        }
+                    });
+                })
+            };
+
+            GLOBAL.FileReader = function () {
+                return {
+                    onloadend: jasmine.createSpy(),
+                    readAsDataURL: jasmine.createSpy().andCallFake(function (file) {
+                        this.onloadend.apply({
+                            result: "data:image/jpeg;base64," + mockBase64Data
+                        });
+                    })
+                };
+            };
+
+            GLOBAL.FileError = {
+                NOT_FOUND_ERR: 1,
+                NOT_READABLE_ERR: 4,
+                PATH_EXISTS_ERR: 12,
+                TYPE_MISMATCH_ERR: 11
+            };
+
+            GLOBAL.PluginResult = function (args, env) {};
+            GLOBAL.PluginResult.prototype.callbackOk = jasmine.createSpy();
+            GLOBAL.PluginResult.prototype.callbackError = jasmine.createSpy();
+            GLOBAL.PluginResult.prototype.noResult = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.window;
+            delete GLOBAL.FileReader;
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls PluginResult.callbackOk if invoke camera is successful and image doesn't need encoding", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.FILE_URI.toString(),
+                "2": PictureSourceType.CAMERA.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith("file://" + mockDone.path, false);
+        });
+
+        it("calls PluginResult.callbackOk if invoke camera and base64 encode image is successful", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.CAMERA.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith(mockBase64Data, false);
+        });
+
+        it("calls PluginResult.callbackError if invoke camera is successful but base64 encode image failed", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+            readFail = true;
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.CAMERA.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith("An error occured: Unknown Error", false);
+        });
+
+        it("calls PluginResult.callbackError if invoke camera is cancelled by user", function () {
+            mockCancel = {
+                reason: "done"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.FILE_URI.toString(),
+                "2": PictureSourceType.CAMERA.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockCancel.reason, false);
+        });
+
+        it("calls PluginResult.callbackError if invoke camera encounters error", function () {
+            mockError = {
+                error: "Camera error"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.FILE_URI.toString(),
+                "2": PictureSourceType.CAMERA.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockError.error, false);
+        });
+
+        it("calls PluginResult.callbackOk if invoke file picker is successful and image doesn't need encoding", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.FILE_URI.toString(),
+                "2": PictureSourceType.PHOTOLIBRARY.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith("file://" + mockDone.path, false);
+        });
+
+        it("calls PluginResult.callbackOk if invoke file picker and base64 encode image is successful", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.PHOTOLIBRARY.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith(mockBase64Data, false);
+        });
+
+        it("calls PluginResult.callbackError if invoke file picker is successful but base64 encode image failed", function () {
+            mockDone = {
+                path: "/foo/bar/abc.jpg"
+            };
+            readFail = true;
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.PHOTOLIBRARY.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith("An error occured: Unknown Error", false);
+        });
+
+        it("calls PluginResult.callbackError if invoke file picker is cancelled by user", function () {
+            mockCancel = {
+                reason: "cancel"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.PHOTOLIBRARY.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockCancel.reason, false);
+        });
+
+        it("calls PluginResult.callbackError if invoke file picker encounters error", function () {
+            mockError = {
+                error: "File picker error"
+            };
+
+            index.takePicture(undefined, undefined, {
+                "1": DestinationType.DATA_URL.toString(),
+                "2": PictureSourceType.PHOTOLIBRARY.toString(),
+                callbackId: "123"
+            }, mockedEnv);
+
+            expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
+            expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockError.error, false);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/042526cf/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 36d9ad1..27c3c3a 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit a69c579c923e9bb0b709a64b782d55a137edb043
+// commit 4c7d302ca09258a6ab9306e7647b1478b06c498a
 
-// File generated at :: Tue Mar 26 2013 15:21:10 GMT-0400 (EDT)
+// File generated at :: Mon Apr 01 2013 10:04:19 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -948,8 +948,15 @@ module.exports = {
 define("cordova/exec", function(require, exports, module) {
 
 var cordova = require('cordova'),
-    platform = require('cordova/platform'),
-    utils = require('cordova/utils');
+    plugins = {
+        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
+        'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
+        'Capture' : require('cordova/plugin/blackberry10/capture'),
+        'Logger' : require('cordova/plugin/blackberry10/logger'),
+        'Notification' : require('cordova/plugin/blackberry10/notification'),
+        'Media': require('cordova/plugin/blackberry10/media'),
+        'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
+    };
 
 /**
  * Execute a cordova command.  It is up to the native side whether this action
@@ -965,14 +972,11 @@ var cordova = require('cordova'),
  * @param {String} action       Action to be run in cordova
  * @param {String[]} [args]     Zero or more arguments to pass to the method
  */
-
-module.exports = function(success, fail, service, action, args) {
-    try {
-        require('cordova/plugin/blackberry10/manager').exec(success, fail, service, action, args);
-        return null;
-    } catch (e) {
-        utils.alert("Error: "+e);
+module.exports = function (success, fail, service, action, args) {
+    if (plugins[service] && plugins[service][action]) {
+        return plugins[service][action](args, success, fail);
     }
+    return webworks.exec(success, fail, service, action, args);
 };
 
 });
@@ -3867,23 +3871,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/camera.js
-define("cordova/plugin/blackberry10/camera", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    takePicture: function (args, win, fail) {
-        var noop = function () {};
-        blackberry.invoke.card.invokeCamera("photo", function (path) {
-            win("file://" + path);
-        }, noop, noop);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/capture.js
 define("cordova/plugin/blackberry10/capture", function(require, exports, module) {
 
@@ -4723,45 +4710,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/manager.js
-define("cordova/plugin/blackberry10/manager", function(require, exports, module) {
-
-var cordova = require('cordova'),
-    plugins = {
-        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
-        'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
-        'Camera' : require('cordova/plugin/blackberry10/camera'),
-        'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Logger' : require('cordova/plugin/blackberry10/logger'),
-        'Notification' : require('cordova/plugin/blackberry10/notification'),
-        'Media': require('cordova/plugin/blackberry10/media'),
-        'File' : require('cordova/plugin/blackberry10/file'),
-        'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
-        'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
-    };
-
-module.exports = {
-    addPlugin: function (key, module) {
-        plugins[key] = require(module);
-    },
-    exec: function (win, fail, clazz, action, args) {
-        var result = {"status" : cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message" : "Class " + clazz + " cannot be found"};
-
-        if (plugins[clazz] && plugins[clazz][action]) {
-            result = plugins[clazz][action](args, win, fail);
-        }
-        else {
-            result = webworks.exec(win, fail, clazz, action, args);
-        }
-        return result;
-    },
-    resume: function () {},
-    pause: function () {},
-    destroy: function () {}
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/media.js
 define("cordova/plugin/blackberry10/media", function(require, exports, module) {
 
@@ -7532,29 +7480,8 @@ window.cordova = require('cordova');
         }
     };
 
-    //Fire webworks ready once plugin javascript has been loaded
-    pluginUtils.getPlugins(
-        function (plugins) {
-            pluginUtils.loadClientJs(plugins, function () {
-                webworksReady = true;
-                fireWebworksReadyEvent();
-            });
-        },
-        function () {
-            console.log('Unable to load plugins.json');
-            webworksReady = true;
-            fireWebworksReadyEvent();
-        }
-    );
-
-    /**
-     * webworks.exec
-     *
-     * This will all be moved into lib/blackberry10/exec once cordova.exec can be replaced
-     */
-
     function RemoteFunctionCall(functionUri) {
-         var params = {};
+        var params = {};
 
         function composeUri() {
             return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
@@ -7573,11 +7500,11 @@ window.cordova = require('cordova');
 
         this.makeSyncCall = function (success, error) {
             var requestUri = composeUri(),
-                request = createXhrRequest(requestUri, false),
-                response,
-                errored,
-                cb,
-                data;
+            request = createXhrRequest(requestUri, false),
+            response,
+            errored,
+            cb,
+            data;
 
             request.send(JSON.stringify(params));
             response = JSON.parse(decodeURIComponent(request.responseText) || "null");
@@ -7588,11 +7515,11 @@ window.cordova = require('cordova');
     window.webworks = {
         exec: function (success, fail, service, action, args) {
             var uri = service + "/" + action,
-                request = new RemoteFunctionCall(uri),
-                callbackId = service + cordova.callbackId++,
-                response,
-                name,
-                didSucceed;
+            request = new RemoteFunctionCall(uri),
+            callbackId = service + cordova.callbackId++,
+            response,
+            name,
+            didSucceed;
 
             for (name in args) {
                 if (Object.hasOwnProperty.call(args, name)) {
@@ -7618,7 +7545,7 @@ window.cordova = require('cordova');
                 delete cordova.callbacks[callbackId];
             } else {
                 didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-                cordova.callbackFromNative(callbackId, didSucceed, response.code, [didSucceed ? response.data : response.msg], !!response.keepCallback);
+                cordova.callbackFromNative(callbackId, didSucceed, response.code, didSucceed ? response.data : response.msg, !!response.keepCallback);
             }
         },
         defineReadOnlyField: function (obj, field, value) {
@@ -7629,6 +7556,21 @@ window.cordova = require('cordova');
         },
         event: require("cordova/plugin/blackberry10/event")
     };
+
+    //Fire webworks ready once plugin javascript has been loaded
+    pluginUtils.getPlugins(
+        function (plugins) {
+            pluginUtils.loadClientJs(plugins, function () {
+                webworksReady = true;
+                fireWebworksReadyEvent();
+            });
+        },
+        function () {
+            console.log('Unable to load plugins.json');
+            webworksReady = true;
+            fireWebworksReadyEvent();
+        }
+    );
 }());
 
 document.addEventListener("DOMContentLoaded", function () {


[08/50] [abbrv] webworks commit: suppress console output for cordova/plugin on windows

Posted by lo...@apache.org.
suppress console output for cordova/plugin on windows

Reviewed by James Keshavarzi <jk...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/957fc5bf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/957fc5bf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/957fc5bf

Branch: refs/heads/future
Commit: 957fc5bf576e7db491940e103db13a60f838c238
Parents: 92134ef
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Tue Apr 9 15:08:47 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/plugin.bat       |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/957fc5bf/blackberry10/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin.bat b/blackberry10/bin/templates/project/cordova/plugin.bat
index 647412f..5406de4 100755
--- a/blackberry10/bin/templates/project/cordova/plugin.bat
+++ b/blackberry10/bin/templates/project/cordova/plugin.bat
@@ -1,4 +1,6 @@
-cd %~dp0\..\
+@ECHO OFF
+
+cd %~dp0..\
 
 if "%1" == "add" (
     @node.exe ./cordova/node_modules/plugman/plugman.js --platform blackberry10 --project . --plugin %2


[13/50] [abbrv] webworks commit: Updating pluginResult to allow keeping callbacks while returning OK.

Posted by lo...@apache.org.
Updating pluginResult to allow keeping callbacks while returning OK.

Reviewed by Bryan Higgins <bh...@blackberry.com>


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

Branch: refs/heads/future
Commit: b4ee225e0c688349049a6909c3d5d4c2b9cd15d7
Parents: a00b674
Author: Jeffrey Heifetz <jh...@rim.com>
Authored: Thu Mar 28 14:26:16 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/framework/lib/PluginResult.js |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b4ee225e/blackberry10/framework/lib/PluginResult.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/PluginResult.js b/blackberry10/framework/lib/PluginResult.js
index cbb57ff..7cae945 100644
--- a/blackberry10/framework/lib/PluginResult.js
+++ b/blackberry10/framework/lib/PluginResult.js
@@ -32,12 +32,12 @@ function PluginResult (args, env) {
         send({ code: CALLBACK_STATUS_NO_RESULT, keepCallback: !!keepCallback });
     };
 
-    this.error = function (msg) {
-        send({ code: CALLBACK_STATUS_ERROR, msg: msg, keepCallback: false });
+    this.error = function (msg, keepCallback) {
+        send({ code: CALLBACK_STATUS_ERROR, msg: msg, keepCallback: !!keepCallback });
     };
 
-    this.ok = function (data) {
-        send({ code: CALLBACK_STATUS_OK, data: data, keepCallback: false });
+    this.ok = function (data, keepCallback) {
+        send({ code: CALLBACK_STATUS_OK, data: data, keepCallback: !!keepCallback });
     };
 
     this.callbackOk = function (data, keepCallback) {


[31/50] [abbrv] Update plugin script and template to work with plugman changes

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Notification/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Notification/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Notification/src/blackberry10/index.js
new file mode 100644
index 0000000..fad04f7
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Notification/src/blackberry10/index.js
@@ -0,0 +1,91 @@
+/*
+* Copyright 2013 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.
+*/
+
+function showDialog(args, dialogType, result) {
+    //Unpack and map the args
+    var msg = JSON.parse(decodeURIComponent(args[0])),
+    title = JSON.parse(decodeURIComponent(args[1])),
+    btnLabel = JSON.parse(decodeURIComponent(args[2]));
+
+    if (!Array.isArray(btnLabel)) {
+        //Converts to array for (string) and (string,string, ...) cases
+        btnLabel = btnLabel.split(",");
+    }
+
+    if (msg && typeof msg === "string") {
+        msg = msg.replace(/^"|"$/g, "").replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+    } else {
+        result.error("message is undefined");
+        return;
+    }
+
+    var messageObj = {
+        title : title,
+        htmlmessage :  msg,
+        dialogType : dialogType,
+        optionalButtons : btnLabel
+    };
+
+    //TODO replace with getOverlayWebview() when available in webplatform
+    qnx.webplatform.getWebViews()[2].dialog.show(messageObj, function (data) {
+        if (typeof data === "number") {
+            //Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc]
+            result.callbackOk(++data, false);
+        } else {
+            //Prompt dialog callback expects object
+            result.callbackOk({
+                buttonIndex: data.ok ? 1 : 0,
+                input1: (data.oktext) ? decodeURIComponent(data.oktext) : ""
+            }, false);
+        }
+    });
+
+    result.noResult(true);
+}
+
+module.exports = {
+    alert: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - alert arguments not found.");
+        } else {
+            showDialog(args, "CustomAsk", result);
+        }
+    },
+    confirm: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - confirm arguments not found.");
+        } else {
+            showDialog(args, "CustomAsk", result);
+        }
+    },
+    prompt: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - prompt arguments not found.");
+        } else {
+            showDialog(args, "JavaScriptPrompt", result);
+        }
+    },
+    beep: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error("Beep not supported");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/SplashScreen/index.js b/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
deleted file mode 100644
index bd7e48c..0000000
--- a/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2013 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 = {
-    show: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        result.error("Not supported on platform", false);
-    },
-
-    hide: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        window.qnx.webplatform.getApplication().windowVisible = true;
-        result.ok(undefined, false);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/SplashScreen/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/SplashScreen/plugin.xml b/blackberry10/bin/templates/project/plugins/SplashScreen/plugin.xml
new file mode 100644
index 0000000..48c5824
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/SplashScreen/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>SplashScreen</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="SplashScreen" value="SplashScreen"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/SplashScreen/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/SplashScreen/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/SplashScreen/src/blackberry10/index.js
new file mode 100644
index 0000000..bd7e48c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/SplashScreen/src/blackberry10/index.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 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 = {
+    show: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error("Not supported on platform", false);
+    },
+
+    hide: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.qnx.webplatform.getApplication().windowVisible = true;
+        result.ok(undefined, false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=CPU
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
deleted file mode 100644
index 90a43db..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-NAME=utils
-LDFLAGS+=-Wl,-h,libutils.so
-
-include ../../../../../../meta.mk
-
-SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
-      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
-      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
-      webworks_utils.cpp
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-LIBS += socket

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
deleted file mode 100644
index 126d02c..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
deleted file mode 100644
index 392ad33..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
deleted file mode 100644
index 68397a1..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-
-#include <resolv.h>
-#include <sstream>
-#include <string>
-
-#include "webworks_utils.hpp"
-
-namespace webworks {
-
-std::string Utils::intToStr(const int val)
-{
-    std::string s;
-    std::stringstream out;
-    out << val;
-    return out.str();
-}
-
-int Utils::strToInt(const std::string& val) {
-    int number;
-
-    if (!(std::istringstream(val) >> number)) {
-        return -1;
-    }
-    return number;
-}
-
-std::string Utils::toBase64(const unsigned char *input, const size_t size)
-{
-    size_t outputSize = size * 4;
-    char *output = new char[outputSize];
-    outputSize = b64_ntop(input, size, output, outputSize);
-    output[outputSize] = 0;
-
-    std::string outputString(output);
-    delete output;
-
-    return outputString;
-}
-
-} // namespace webworks

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
deleted file mode 100644
index 4ab2ca7..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef WW_UTILS_HPP_
-#define WW_UTILS_HPP_
-
-#include <string.h>
-#include <string>
-
-namespace webworks {
-
-class Utils {
-public:
-    static std::string intToStr(const int val);
-    static int strToInt(const std::string& val);
-    static std::string toBase64(const unsigned char *input, const size_t size);
-};
-
-} // namespace webworks
-
-#endif // WW_UTILS_HPP_

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/plugin.xml b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/plugin.xml
new file mode 100644
index 0000000..9a3be81
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/plugin.xml
@@ -0,0 +1,22 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="com.blackberry.jpps"
+    version="1.0.0">
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/device/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/device/libjpps.so b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/device/libjpps.so
new file mode 100644
index 0000000..f0eb90d
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/device/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/simulator/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/simulator/libjpps.so b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/simulator/libjpps.so
new file mode 100644
index 0000000..f2c12ff
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/com.blackberry.jpps/src/blackberry10/native/simulator/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.utils/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.utils/plugin.xml b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/plugin.xml
new file mode 100644
index 0000000..f855ee8
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/plugin.xml
@@ -0,0 +1,22 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you 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.
+-->
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="com.blackberry.utils"
+    version="1.0.0">
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/device/libutils.so
new file mode 100644
index 0000000..126d02c
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/device/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/simulator/libutils.so
new file mode 100644
index 0000000..392ad33
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/com.blackberry.utils/src/blackberry10/native/simulator/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 286891b..a5e250d 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit dd02e6c9cd4121910c714e798f84fad2dc072879
+// commit cf23fc942bd8443aa673b6834690e9c55c811b36
 
-// File generated at :: Fri Apr 19 2013 11:54:58 GMT-0400 (EDT)
+// File generated at :: Thu Apr 25 2013 16:30:38 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -929,19 +929,16 @@ define("cordova/platform", function(require, exports, module) {
 module.exports = {
     id: "blackberry10",
     initialize: function() {
-        var builder = require('cordova/builder'),
-            modulemapper = require('cordova/modulemapper'),
-            platform = require('cordova/plugin/blackberry10/platform');
-
-        builder.buildIntoButDoNotClobber(platform.defaults, window);
-        builder.buildIntoAndClobber(platform.clobbers, window);
-        builder.buildIntoAndMerge(platform.merges, window);
+        var modulemapper = require('cordova/modulemapper'),
+            cordova = require('cordova');
 
         modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
         modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
-        modulemapper.mapModules(window);
 
-        platform.initialize();
+        modulemapper.clobbers('cordova/plugin/blackberry10/vibrate', 'navigator.notification.vibrate');
+        modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
+        modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
+
     }
 };
 
@@ -1728,20 +1725,17 @@ Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataO
 
 Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
-    var fail = errorCallback && function(code) {
-            errorCallback(new FileError(code));
-        },
-        srcPath = this.fullPath,
+    var srcPath = this.fullPath,
         name = newName || this.name,
         success = function(entry) {
             if (entry) {
-                if (successCallback === 'function') {
+                if (typeof successCallback === 'function') {
                     successCallback(fileUtils.createEntry(entry));
                 }
             }
             else {
-                if (typeof fail === 'function') {
-                    fail(FileError.NOT_FOUND_ERR);
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
                 }
             }
         };
@@ -1751,10 +1745,7 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
 
 Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
-    var fail = errorCallback && function(code) {
-            errorCallback(new FileError(code));
-        },
-        srcPath = this.fullPath,
+    var srcPath = this.fullPath,
         name = newName || this.name,
         success = function(entry) {
             if (entry) {
@@ -1763,8 +1754,8 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
                 }
             }
             else {
-                if (typeof fail === 'function') {
-                    fail(FileError.NOT_FOUND_ERR);
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
                 }
             }
         };
@@ -4016,135 +4007,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/platform.js
-define("cordova/plugin/blackberry10/platform", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    id: "blackberry10",
-    initialize: function () {
-        document.addEventListener("deviceready", function () {
-            /*
-             TODO
-            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");
-            });
-        });
-    },
-    clobbers: {
-        navigator: {
-            children: {
-                notification: {
-                    children: {
-                        vibrate: {
-                            path: 'cordova/plugin/blackberry10/vibrate'
-                        }
-                    }
-                }
-            }
-        },
-        File: {
-            path: 'cordova/plugin/File'
-        }
-    },
-    merges: {
-        navigator: {
-            children: {
-                compass: {
-                    path: 'cordova/plugin/blackberry10/compass'
-                }
-            }
-        }
-    }
-};
-
-});
-
-// file: lib/blackberry10/plugin/blackberry10/pluginUtils.js
-define("cordova/plugin/blackberry10/pluginUtils", function(require, exports, module) {
-
-function build(plugins) {
-    var builder = require('cordova/builder'),
-        plugin;
-    for (plugin in plugins) {
-        if (plugins.hasOwnProperty(plugin)) {
-            if (plugins[plugin].clobbers) {
-                builder.buildIntoAndClobber(plugins[plugin].clobbers, window);
-            }
-            if (plugins[plugin].merges) {
-                builder.buildIntoAndMerge(plugins[plugin].merges, window);
-            }
-        }
-    }
-}
-
-module.exports = {
-
-    loadClientJs: function (plugins, callback) {
-        var plugin,
-            script,
-            i,
-            count = 0;
-        for (plugin in plugins) {
-            if (plugins.hasOwnProperty(plugin) && plugins[plugin].modules) {
-                for (i = 0; i < plugins[plugin].modules.length; i++) {
-                    script = document.createElement('script');
-                    script.src = 'local:///plugins/' + plugin + '/' + plugins[plugin].modules[i];
-                    script.onload = function () {
-                        if (--count === 0 && typeof callback === 'function') {
-                            build(plugins);
-                            callback();
-                        }
-                    };
-                    count++;
-                    document.head.appendChild(script);
-                }
-            }
-        }
-        if (count === 0) {
-            callback();
-        }
-    },
-
-    getPlugins: function (success, error) {
-        var request,
-            response;
-        request = new XMLHttpRequest();
-        request.open('GET', 'local:///plugins/plugins.json', true);
-        request.onreadystatechange = function () {
-            if (request.readyState === 4) {
-                if (request.status === 200) {
-                    try {
-                        response = JSON.parse(decodeURIComponent(request.responseText));
-                        success(response);
-                    }
-                    catch (e) {
-                        error(e);
-                    }
-                }
-                else {
-                    error(request.status);
-                }
-            }
-        };
-        request.send(null);
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/utils.js
 define("cordova/plugin/blackberry10/utils", function(require, exports, module) {
 
@@ -6287,7 +6149,7 @@ module.exports = {
         // Android and iOS take an array of button label names.
         // Other platforms take a comma separated list.
         // For compatibility, we convert to the desired type based on the platform.
-        if (platform.id == "android" || platform.id == "ios") {
+        if (platform.id == "android" || platform.id == "ios" || platform.id == "blackberry10") {
             if (typeof _buttonLabels === 'string') {
                 var buttonLabelString = _buttonLabels;
                 _buttonLabels = buttonLabelString.split(",");
@@ -6762,8 +6624,7 @@ window.cordova = require('cordova');
 // file: lib/scripts/bootstrap-blackberry10.js
 
 (function () {
-    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils'),
-        docAddEventListener = document.addEventListener,
+    var docAddEventListener = document.addEventListener,
         webworksReady = false,
         alreadyFired = false,
         listenerRegistered = false;
@@ -6866,20 +6727,11 @@ window.cordova = require('cordova');
         event: require("cordova/plugin/blackberry10/event")
     };
 
-    //Fire webworks ready once plugin javascript has been loaded
-    pluginUtils.getPlugins(
-        function (plugins) {
-            pluginUtils.loadClientJs(plugins, function () {
-                webworksReady = true;
-                fireWebworksReadyEvent();
-            });
-        },
-        function () {
-            console.log('Unable to load plugins.json');
-            webworksReady = true;
-            fireWebworksReadyEvent();
-        }
-    );
+    require("cordova/channel").onPluginsReady.subscribe(function () {
+        require("cordova/modulemapper").mapModules(window);
+        webworksReady = true;
+        fireWebworksReadyEvent();
+    });
 }());
 
 document.addEventListener("DOMContentLoaded", function () {
@@ -6980,7 +6832,7 @@ document.addEventListener("DOMContentLoaded", function () {
         xhr.onerror = function() {
             finishPluginLoading();
         };
-        xhr.open('GET', 'cordova_plugins.json', true); // Async
+        xhr.open('GET', '/cordova_plugins.json', true); // Async
         xhr.send();
     }
     catch(err){


[06/50] [abbrv] Add JPPS and Utils plugins to project template.

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
new file mode 100644
index 0000000..83616b8
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
@@ -0,0 +1,355 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSInterfaceGlue.h"
+
+#include <json/value.h>
+#include <json/writer.h>
+#include <json/reader.h>
+
+#include <vector>
+#include <sstream>
+
+#include <ppsparse.h>
+
+#include "../core/PPSEvent.h"
+
+namespace jpps {
+
+const std::string PPSInterfaceGlue::EVENT_OPEN = "ppsOpened";
+const std::string PPSInterfaceGlue::EVENT_OPEN_FAILED = "ppsOpenFailed";
+const std::string PPSInterfaceGlue::EVENT_FIRST_READ = "ppsFirstRead";
+const std::string PPSInterfaceGlue::EVENT_NEW_DATA = "OnChange";//"ppsNewData";
+const std::string PPSInterfaceGlue::EVENT_CLOSE = "ppsClosed";
+const std::string PPSInterfaceGlue::EVENT_WRITE_FAILED = "ppsWriteFailed";
+const std::string PPSInterfaceGlue::EVENT_READ_FAILED = "ppsReadFailed";
+
+const std::string PPSInterfaceGlue::ENCODING_N = "n";
+const std::string PPSInterfaceGlue::ENCODING_B = "b";
+const std::string PPSInterfaceGlue::ENCODING_JSON = "json";
+
+const Json::StaticString PPSInterfaceGlue::JSON_REMOVE("remove");
+const Json::StaticString PPSInterfaceGlue::JSON_CHANGED("changed");
+const Json::StaticString PPSInterfaceGlue::JSON_DATA("data");
+const Json::StaticString PPSInterfaceGlue::JSON_OBJNAME("objName");
+const Json::StaticString PPSInterfaceGlue::JSON_CHANGE_DATA("changeData");
+const Json::StaticString PPSInterfaceGlue::JSON_ALL_DATA("allData");
+
+
+PPSInterfaceGlue::PPSInterfaceGlue()
+: m_interface()
+, m_pArg(NULL)
+, m_handleOpen(NULL)
+, m_handleFirstRead(NULL)
+, m_handleNewData(NULL)
+, m_handleClose(NULL)
+, m_handleOpenFailed(NULL)
+, m_handleWriteFailed(NULL)
+, m_handleReadFailed(NULL)
+{
+	m_interface.setEventFunc(onEvent, this);
+}
+
+PPSInterfaceGlue::~PPSInterfaceGlue()
+{
+	m_interface.setEventFunc(NULL);
+}
+
+void PPSInterfaceGlue::callbackInit(void* pArg,
+								    callback* handleOpen,
+								    callback* handleFirstRead,
+								    callback* handleNewData,
+								    callback* handleClose,
+								    callback* handleOpenFailed,
+								    callback* handleWriteFailed,
+								    callback* handleReadFailed)
+{
+	m_pArg = pArg;
+	m_handleOpen = handleOpen;
+	m_handleFirstRead = handleFirstRead;
+	m_handleNewData = handleNewData;
+	m_handleClose = handleClose;
+	m_handleOpenFailed = handleOpenFailed;
+	m_handleWriteFailed = handleWriteFailed;
+	m_handleReadFailed = handleReadFailed;
+}
+
+void PPSInterfaceGlue::setVerbose(unsigned short v)
+{
+	m_interface.setVerbose(v);
+}
+
+bool PPSInterfaceGlue::open(const std::string& path, int oflags)
+{
+	// We don't expose the "mode" to the JS layer - always create in 0666 mode
+	return m_interface.open(path, oflags, 0666, false);
+}
+
+void PPSInterfaceGlue::close()
+{
+	m_interface.close();
+}
+
+void PPSInterfaceGlue::sync()
+{
+	m_interface.sync();
+}
+
+void PPSInterfaceGlue::onEvent(void* pArg, const PPSEvent& event)
+{
+	PPSInterfaceGlue* pGlue = static_cast<PPSInterfaceGlue*>(pArg);
+
+	if (pGlue != NULL)
+		pGlue->onEvent(event);
+}
+
+void PPSInterfaceGlue::onEvent(const PPSEvent& event)
+{
+	callback* pFunc = NULL;
+	std::string sArg;
+
+	switch (event.getEventType()) {
+
+	case PPSEvent::PPS_EVENT_OPENED:
+		pFunc = m_handleOpen;
+		sArg = EVENT_OPEN;
+		break;
+
+	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
+		pFunc = m_handleFirstRead;
+		sArg = EVENT_FIRST_READ + " " + handleNewData(event.getNewData());
+		break;
+
+	case PPSEvent::PPS_EVENT_NEW_DATA:
+		pFunc = m_handleNewData;
+		sArg = EVENT_NEW_DATA + " " + handleNewData(event.getNewData());
+		break;
+
+	case PPSEvent::PPS_EVENT_CLOSED:
+		pFunc = m_handleClose;
+		sArg = EVENT_CLOSE;
+		break;
+
+	case PPSEvent::PPS_EVENT_OPEN_FAILED:
+		pFunc = m_handleOpenFailed;
+		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_WRITE_FAILED:
+		pFunc = m_handleWriteFailed;
+		sArg = EVENT_WRITE_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_READ_FAILED:
+		pFunc = m_handleReadFailed;
+		sArg = EVENT_READ_FAILED + " " + event.getMessage();
+		break;
+	}
+
+	if (pFunc != NULL)
+		pFunc(m_pArg, sArg);
+}
+
+std::string PPSInterfaceGlue::handleNewData(const ppsObject& newData)
+{
+	Json::Value data(Json::nullValue);
+	data[JSON_CHANGE_DATA] = JSONEncodeNewData(newData);
+	data[JSON_ALL_DATA] = JSONEncodeRead(m_interface.read());
+
+	Json::FastWriter writer;
+	return writer.write(data);
+}
+
+std::string PPSInterfaceGlue::read() const
+{
+	Json::Value data = JSONEncodeRead(m_interface.read());
+	Json::FastWriter writer;
+	return writer.write(data);
+}
+
+Json::Value PPSInterfaceGlue::JSONEncodeRead(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value readData(Json::nullValue);
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// An attribute was deleted: update the JSON data structure and the event data
+		if (ppsAttrib.flags & PPS_DELETED) {
+
+			readData.removeMember(ppsAttrib.name);
+		}
+		else {
+
+			// The value is a number
+			if (ppsAttrib.encoding == ENCODING_N) {
+
+				// Convert the value to floating point
+				// istringstream is locale aware - we shouldn't need to perform any special
+				// processing in order to properly convert the data to a floating point
+				// TODO: test that the istringstream conversion works with a locale
+				//       that uses alternate floating point number encoding
+				std::istringstream stream(ppsAttrib.value);
+				double doubleValue;
+
+				// Try to convert the value to a floating point
+				if (!(stream >> doubleValue)) {
+
+					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+					m_handleReadFailed(m_pArg, err);
+					return "";
+				}
+
+				readData[ppsAttrib.name] = doubleValue;
+			}
+			// The value is a boolean
+			else if (ppsAttrib.encoding == ENCODING_B) {
+
+				readData[ppsAttrib.name] = (ppsAttrib.value == "true");
+			}
+			// The value is JSON data
+			else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+				Json::Reader reader;
+				reader.parse(ppsAttrib.value, readData[ppsAttrib.name]);
+			}
+			// Just pass the value through as a straight string
+			else {
+
+				readData[ppsAttrib.name] = ppsAttrib.value;
+			}
+		}
+	}
+
+	return readData;
+}
+
+Json::Value PPSInterfaceGlue::JSONEncodeNewData(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value eventData(Json::nullValue);
+
+	// Set the PPS object name
+	eventData[JSON_OBJNAME] = ppsObj.name.substr(1); // PR 159829 : Remove the pre-pending '@' symbol
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// An attribute was deleted: update the JSON data structure and the event data
+		if (ppsAttrib.flags & PPS_DELETED) {
+
+			eventData[JSON_REMOVE][ppsAttrib.name] = true;
+		}
+		else {
+
+			eventData[JSON_CHANGED][ppsAttrib.name] = true;
+
+			// The value is a number
+			if (ppsAttrib.encoding == ENCODING_N) {
+
+				// Convert the value to floating point
+				// istringstream is locale aware - we shouldn't need to perform any special
+				// processing in order to properly convert the data to a floating point
+				// TODO: test that the istringstream conversion works with a locale
+				//       that uses alternate floating point number encoding
+				std::istringstream stream(ppsAttrib.value);
+				double doubleValue;
+
+				// Try to convert the value to a floating point
+				if (!(stream >> doubleValue)) {
+
+					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+					m_handleReadFailed(m_pArg, err);
+					return "";
+				}
+
+				eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
+			}
+			// The value is a boolean
+			else if (ppsAttrib.encoding == ENCODING_B) {
+
+				eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
+			}
+			// The value is JSON data
+			else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+				Json::Reader reader;
+				reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
+			}
+			// Just pass the value through as a straight string
+			else {
+
+				eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
+			}
+		}
+	}
+
+	return eventData;
+}
+
+void PPSInterfaceGlue::write(const std::string& data)
+{
+    Json::Reader reader;
+    Json::Value root;
+
+	bool parsingSuccessful = reader.parse(data, root);
+
+    // If parsing the JSON string fails, return a write error
+    if (!parsingSuccessful) {
+
+    	std::string err = EVENT_WRITE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
+        m_handleWriteFailed(m_pArg, err);
+        return;
+    }
+
+	Json::Value::Members memberNames = root.getMemberNames();
+
+	std::ostringstream output;
+	output.precision(15);
+
+	Json::Value member;
+
+	for (unsigned int i = 0; i < memberNames.size(); i++) {
+
+		output << memberNames[i] << ":";
+		member = root[memberNames[i]];
+
+		if (member.isObject() || member.isArray()) {
+
+			Json::FastWriter writer;
+			output << ENCODING_JSON << ":" << writer.write(member); // write() adds an \n
+		}
+		else if (member.isBool()) {
+
+			output << ENCODING_B << ":" << member.asString() << std::endl;
+		}
+		else if (member.isNumeric()) {
+
+			output << ENCODING_N << ":" << member.asDouble() << std::endl;
+		}
+		else if (member.isString()) {
+
+			output << ":" << member.asString() << std::endl;
+		}
+		else {
+
+			std::string err = EVENT_WRITE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
+			m_handleWriteFailed(m_pArg, err);
+			return;
+		}
+	}
+
+	m_interface.write(output.str());
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
new file mode 100644
index 0000000..fafbacd
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSINTERFACEGLUE_H_
+#define PPSINTERFACEGLUE_H_
+
+#include "../core/PPSInterface.h"
+#include "PluginTypes.h"
+
+#include <json/value.h>
+
+#include <string>
+
+namespace jpps {
+class PPSEvent;
+struct ppsObject;
+}
+
+namespace jpps {
+
+/**
+ * This class bridges JavaScript and the native PPSInterface code.
+ */
+class PPSInterfaceGlue {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSInterfaceGlue();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSInterfaceGlue();
+
+	/**
+	 * The browser plugin should set these handlers.
+	 *
+	 * @param pArg pArg will be passed back to each callback function when it is called.
+	 */
+	void callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleFirstRead,
+					  callback* handleNewData,
+					  callback* handleClose,
+					  callback* handleOpenFailed,
+					  callback* handleWriteFailed,
+					  callback* handleReadFailed);
+
+	/**
+	 * Set the verbosity of logging to the slog.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS object.
+	 */
+	bool open(const std::string& path, int oflags);
+
+	/**
+	 * Write to a PPS object.
+	 */
+	void write(const std::string& data);
+
+	/**
+	 * Read from the PPS object. This actually returns the cached value of the last
+	 * onNewData event from PPSInteraface, then encodes it as JSON.
+	 */
+	std::string read() const;
+
+	/**
+	 * Close this PPS object.
+	 */
+	void close();
+
+	/**
+	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
+	 * The function blocks until this is finished.
+	 */
+	void sync();
+
+	/**
+	 * The function that the PPSInterface will call when an event happens.
+	 * This is the static function that is used as a function pointer for
+	 * PPSInterface::setEventFunc().
+	 *
+	 * @param event The event PPSInterface is sending.
+	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
+	 * object construction.
+	 */
+	static void onEvent(void* pArg, const PPSEvent& event);
+
+private:
+
+	/**
+	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
+	 */
+	void onEvent(const PPSEvent& event);
+
+	/**
+	 * Handle a new data event.
+	 */
+	std::string handleNewData(const ppsObject& newData);
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * with a new data event. This structures the JSON with changed properties and the
+	 * data that has changed.
+	 */
+	Json::Value JSONEncodeNewData(const ppsObject& ppsObj) const;
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * when a call to read() is made.
+	 */
+	Json::Value JSONEncodeRead(const ppsObject& ppsObj) const;
+
+	// String names for the various events
+	static const std::string EVENT_OPEN;
+	static const std::string EVENT_OPEN_FAILED;
+	static const std::string EVENT_FIRST_READ;
+	static const std::string EVENT_NEW_DATA;
+	static const std::string EVENT_CLOSE;
+	static const std::string EVENT_READ_FAILED;
+	static const std::string EVENT_WRITE_FAILED;
+
+	/** Custom PPS encoding value: an "n" means a real number. */
+	static const std::string ENCODING_N;
+	/** Custom PPS encoding value: a "b" means a boolean value. */
+	static const std::string ENCODING_B;
+	/** Custom PPS encoding value: the data is encoded using JSON. */
+	static const std::string ENCODING_JSON;
+
+	// JSON constants
+	static const Json::StaticString JSON_REMOVE;
+	static const Json::StaticString JSON_CHANGED;
+	static const Json::StaticString JSON_DATA;
+	static const Json::StaticString JSON_OBJNAME;
+	static const Json::StaticString JSON_CHANGE_DATA;
+	static const Json::StaticString JSON_ALL_DATA;
+
+	/** The interface this object wraps. */
+	PPSInterface m_interface;
+
+	// Handlers for various events
+	void* m_pArg;
+	callback* m_handleOpen;
+	callback* m_handleFirstRead;
+	callback* m_handleNewData;
+	callback* m_handleClose;
+	callback* m_handleOpenFailed;
+	callback* m_handleWriteFailed;
+	callback* m_handleReadFailed;
+};
+
+} /* namespace jpps */
+#endif /* PPSINTERFACEGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
new file mode 100644
index 0000000..2eb4552
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSServerGlue.h"
+
+#include <json/value.h>
+#include <json/writer.h>
+#include <json/reader.h>
+
+#include <sstream>
+
+#include <ppsparse.h>
+#include <fcntl.h>
+
+namespace jpps {
+
+const std::string PPSServerGlue::EVENT_OPEN = "onOpen";
+const std::string PPSServerGlue::EVENT_CLOSE = "onClose";
+const std::string PPSServerGlue::EVENT_CLIENT_CONNECT = "onClientConnect";
+const std::string PPSServerGlue::EVENT_CLIENT_DISCONNECT = "onClientDisconnect";
+const std::string PPSServerGlue::EVENT_MESSAGE = "onMessage";
+const std::string PPSServerGlue::EVENT_OPEN_FAILED = "onOpenFailed";
+const std::string PPSServerGlue::EVENT_SEND_MESSAGE_FAILED = "onSendMessageFailed";
+const std::string PPSServerGlue::EVENT_RECEIVE_MESSAGE_FAILED = "onReceiveMessageFailed";
+
+const std::string PPSServerGlue::ENCODING_N = "n";
+const std::string PPSServerGlue::ENCODING_B = "b";
+const std::string PPSServerGlue::ENCODING_JSON = "json";
+
+const Json::StaticString PPSServerGlue::JSON_DATA("data");
+const Json::StaticString PPSServerGlue::JSON_CONNECTION_ID("clientId");
+
+PPSServerGlue::PPSServerGlue()
+: m_interface()
+, m_pArg(NULL)
+, m_handleOpen(NULL)
+, m_handleClose(NULL)
+, m_handleClientConnect(NULL)
+, m_handleClientDisconnect(NULL)
+, m_handleMessage(NULL)
+, m_handleOpenFailed(NULL)
+, m_handleSendMessageFailed(NULL)
+, m_handleReceiveMessageFailed(NULL)
+{
+	m_interface.setEventFunc(onEvent, this);
+}
+
+PPSServerGlue::~PPSServerGlue()
+{
+	m_interface.setEventFunc(NULL);
+}
+
+void PPSServerGlue::callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleClose,
+					  callback* handleClientConnect,
+					  callback* handleClientDisconnect,
+					  callback* handleMessage,
+					  callback* handleOpenFailed,
+					  callback* handleSendMessageFailed,
+					  callback* handleReceiveMessageFailed)
+{
+	m_pArg = pArg;
+	m_handleOpen = handleOpen;
+	m_handleClose = handleClose;
+	m_handleClientConnect = handleClientConnect;
+	m_handleClientDisconnect = handleClientDisconnect;
+	m_handleMessage = handleMessage;
+	m_handleOpenFailed = handleOpenFailed;
+	m_handleSendMessageFailed = handleSendMessageFailed;
+	m_handleReceiveMessageFailed = handleReceiveMessageFailed;
+}
+
+
+void PPSServerGlue::setVerbose(unsigned short v)
+{
+	m_interface.setVerbose(v);
+}
+
+bool PPSServerGlue::open(const std::string& path, int oflags)
+{
+	// Make sure we're creating the server, if it doesn't exist
+	if (!(oflags & O_CREAT))
+		oflags &= O_CREAT;
+
+	// We don't expose the "mode" to the JS layer - always create in 0666 mode
+	return m_interface.open(path, oflags, 0666, true);
+}
+
+void PPSServerGlue::close()
+{
+	m_interface.close();
+}
+
+void PPSServerGlue::sendMessage(const std::string& clientID, const std::string& msg)
+{
+	std::string decodedMsg = JSONDecodeData(msg);
+	std::string message(clientID + "\n" + decodedMsg);
+	m_interface.write(message);
+}
+
+void PPSServerGlue::broadcastMessage(const std::string& msg)
+{
+	m_interface.write(JSONDecodeData(msg));
+}
+
+void PPSServerGlue::onEvent(void* pArg, const PPSEvent& event)
+{
+	PPSServerGlue* pGlue = static_cast<PPSServerGlue*>(pArg);
+
+	if (pGlue != NULL)
+		pGlue->onEvent(event);
+}
+
+void PPSServerGlue::onEvent(const PPSEvent& event)
+{
+	callback* pFunc = NULL;
+	std::string sArg;
+
+	switch (event.getEventType()) {
+
+	case PPSEvent::PPS_EVENT_OPENED:
+		pFunc = m_handleOpen;
+		sArg = EVENT_OPEN;
+		break;
+
+	// The server doesn't do anything with this event
+	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
+		break;
+
+	case PPSEvent::PPS_EVENT_NEW_DATA:
+	{
+		ppsObject data(event.getNewData());
+
+		// This means a new connection
+		if (data.flags & PPS_CREATED) {
+			sArg = EVENT_CLIENT_CONNECT;
+			pFunc = m_handleClientConnect;
+		}
+		// This means a connection is closed
+		else if (data.flags & PPS_DELETED) {
+			sArg = EVENT_CLIENT_DISCONNECT;
+			pFunc = m_handleClientDisconnect;
+		}
+		// We're getting data from the connection
+		else {
+			sArg = EVENT_MESSAGE;
+			pFunc = m_handleMessage;
+		}
+
+		sArg += " " + JSONEncodeData(data);
+
+		break;
+	}
+
+	case PPSEvent::PPS_EVENT_CLOSED:
+		pFunc = m_handleClose;
+		sArg = EVENT_CLOSE;
+		break;
+
+	case PPSEvent::PPS_EVENT_OPEN_FAILED:
+		pFunc = m_handleOpenFailed;
+		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_WRITE_FAILED:
+		pFunc = m_handleSendMessageFailed;
+		sArg = EVENT_SEND_MESSAGE_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_READ_FAILED:
+		pFunc = m_handleReceiveMessageFailed;
+		sArg = EVENT_RECEIVE_MESSAGE_FAILED + event.getMessage();
+		break;
+	}
+
+	if (pFunc != NULL)
+		pFunc(m_pArg, sArg);
+
+}
+
+std::string PPSServerGlue::JSONEncodeData(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value eventData(Json::nullValue);
+
+	// Set the client id
+	// Chop off the '+' or '-' if it's there
+	eventData[JSON_CONNECTION_ID] = ppsObj.name;
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// The value is a number
+		if (ppsAttrib.encoding == ENCODING_N) {
+
+			// Convert the value to floating point
+			// istringstream is locale aware - we shouldn't need to perform any special
+			// processing in order to properly convert the data to a floating point
+			// TODO: test that the istringstream conversion works with a locale
+			//       that uses alternate floating point number encoding
+			std::istringstream stream(ppsAttrib.value);
+			double doubleValue;
+
+			// Try to convert the value to a floating point
+			if (!(stream >> doubleValue)) {
+
+				std::string err = EVENT_RECEIVE_MESSAGE_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+				m_handleReceiveMessageFailed(m_pArg, err);
+				return "";
+			}
+
+			eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
+		}
+		// The value is a boolean
+		else if (ppsAttrib.encoding == ENCODING_B) {
+
+			eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
+		}
+		// The value is JSON data
+		else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+			Json::Reader reader;
+			reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
+		}
+		// Just pass the value through as a straight string
+		else {
+
+			eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
+		}
+	}
+
+	Json::FastWriter writer;
+	return writer.write(eventData);
+}
+
+std::string PPSServerGlue::JSONDecodeData(const std::string& data) const
+{
+	 Json::Reader reader;
+	Json::Value root;
+
+	bool parsingSuccessful = reader.parse(data, root);
+
+	// If parsing the JSON string fails, return a write error
+	if (!parsingSuccessful) {
+
+		std::string err = EVENT_SEND_MESSAGE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
+		m_handleSendMessageFailed(m_pArg, err);
+		return "";
+	}
+
+	Json::Value::Members memberNames = root.getMemberNames();
+
+	std::ostringstream output;
+	output.precision(15);
+
+	Json::Value member;
+
+	for (unsigned int i = 0; i < memberNames.size(); i++) {
+
+		output << memberNames[i] << ":";
+		member = root[memberNames[i]];
+
+		if (member.isObject() || member.isArray()) {
+
+			Json::FastWriter writer;
+			output << ENCODING_JSON << ":" << writer.write(member);
+		}
+		else if (member.isBool()) {
+
+			output << ENCODING_B << ":" << member.asString();
+		}
+		else if (member.isNumeric()) {
+
+			output << ENCODING_N << ":" << member.asDouble();
+		}
+		else if (member.isString()) {
+
+			output << ":" << member.asString();
+		}
+		else {
+
+			std::string err = EVENT_SEND_MESSAGE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
+			m_handleSendMessageFailed(m_pArg, err);
+			return "";
+		}
+
+		// Make sure we terminate the line
+		output << std::endl;
+	}
+
+	return output.str();
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
new file mode 100644
index 0000000..8891829
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSSERVERGLUE_H_
+#define PPSSERVERGLUE_H_
+
+#include "../core/PPSInterface.h"
+#include "PluginTypes.h"
+
+// Forward declaration
+namespace Json {
+class StaticString;
+}
+namespace jpps {
+class PPSEvent;
+struct ppsObject;
+}
+
+namespace jpps {
+
+/**
+ * Act as glue between jpps Server class an the PPSInterface.
+ * This class encapsulates a PPS object as a PPS server.
+ * TODO: write a better comment
+ */
+class PPSServerGlue {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSServerGlue();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSServerGlue();
+
+	/**
+	 * The browser plugin should set these handlers.
+	 *
+	 * @param pArg pArg will be passed back to each callback function when it is called.
+	 */
+	void callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleClose,
+					  callback* handleClientConnect,
+					  callback* handleClientDisconnect,
+					  callback* handleMessage,
+					  callback* handleOpenFailed,
+					  callback* handleSendMessageFailed,
+					  callback* handleReceiveMessageFailed);
+
+	/**
+	 * Set the verbosity of logging to the slog.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS server object.
+	 */
+	bool open(const std::string& path, int oflags);
+
+	/**
+	 * Close this PPS server object.
+	 */
+	void close();
+
+	/**
+	 * Send a message to a particular client.
+	 */
+	void sendMessage(const std::string& clientID, const std::string& msg);
+
+	/**
+	 * Send a message to all clients.
+	 */
+	void broadcastMessage(const std::string& msg);
+
+	/**
+	 * The function that the PPSInterface will call when an event happens.
+	 * This is the static function that is used as a function pointer for
+	 * PPSInterface::setEventFunc().
+	 *
+	 * @param event The event PPSInterface is sending.
+	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
+	 * object construction.
+	 */
+	static void onEvent(void* pArg, const PPSEvent& event);
+
+private:
+
+	/**
+	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
+	 */
+	void onEvent(const PPSEvent& event);
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * with a onMessage event.
+	 */
+	std::string JSONEncodeData(const ppsObject& ppsObj) const;
+
+	/**
+	 * Take a JSON string and change it into a PPS consumable string.
+	 */
+	std::string JSONDecodeData(const std::string& data) const;
+
+	// String names for the various events
+	static const std::string EVENT_OPEN;
+	static const std::string EVENT_CLOSE;
+	static const std::string EVENT_CLIENT_CONNECT;
+	static const std::string EVENT_CLIENT_DISCONNECT;
+	static const std::string EVENT_MESSAGE;
+	static const std::string EVENT_OPEN_FAILED;
+	static const std::string EVENT_SEND_MESSAGE_FAILED;
+	static const std::string EVENT_RECEIVE_MESSAGE_FAILED;
+
+	/** Custom PPS encoding value: an "n" means a real number. */
+	static const std::string ENCODING_N;
+	/** Custom PPS encoding value: a "b" means a boolean value. */
+	static const std::string ENCODING_B;
+	/** Custom PPS encoding value: the data is encoded using JSON. */
+	static const std::string ENCODING_JSON;
+
+	// JSON constants
+	static const Json::StaticString JSON_DATA;
+	static const Json::StaticString JSON_CONNECTION_ID;
+
+	/** The interface this object wraps. */
+	PPSInterface m_interface;
+
+	// Handlers for various events
+	void* m_pArg;
+	callback* m_handleOpen;
+	callback* m_handleClose;
+	callback* m_handleClientConnect;
+	callback* m_handleClientDisconnect;
+	callback* m_handleMessage;
+	callback* m_handleOpenFailed;
+	callback* m_handleSendMessageFailed;
+	callback* m_handleReceiveMessageFailed;
+
+};
+
+} /* namespace jpps */
+#endif /* PPSSERVERGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
new file mode 100644
index 0000000..9ce6b32
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PLUGINTYPES_H_
+#define PLUGINTYPES_H_
+
+namespace jpps {
+
+/**
+ * Function type for setting handles between JNext plug-in and glue classes.
+ */
+typedef void (callback)(void* pArg, const std::string&);
+
+}
+
+
+#endif /* PLUGINTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
new file mode 100644
index 0000000..e06ad4c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#include "JPPSPlugin.h"
+#include "JPPSServerPlugin.h"
+
+#include <string>
+
+/**
+ * This callback must be implemented by all JSExt objects. It is invoked from
+ * plugin.cpp.
+ *
+ * @return A comma separated list of classes supported by this JNEXT extension
+ */
+char* onGetObjList(void)
+{
+	static char* ppsclasses = NULL;
+
+	if (ppsclasses == NULL) {
+
+		// Get the length of all the strings, +1 for the ',' +1 for the \0
+		int size = std::strlen(jpps::JPPSPlugin::CLASS_NAME) + std::strlen(jpps::JPPSServerPlugin::CLASS_NAME) + 1 + 1;
+		ppsclasses = new char[size];
+		std::strcpy(ppsclasses, jpps::JPPSPlugin::CLASS_NAME);
+		std::strcat(ppsclasses, ",");
+		std::strcat(ppsclasses, jpps::JPPSServerPlugin::CLASS_NAME);
+		ppsclasses[size] = '\0';
+	}
+    // Return a comma separated list of classes known to this plugin
+    return ppsclasses;
+}
+
+/**
+ * This callback must be implemented by all JSExt objects. It is invoked from
+ * plugin.cpp.
+ *
+ * @param strClassName Name of the class requested to be created Valid named are those
+ * that are returned in onGetObjList
+ *
+ * @param strObjId The unique object id for the class
+ *
+ * @return A pointer to the created extension object
+ */
+JSExt* onCreateObject(const std::string& strClassName, const std::string& strObjId)
+{
+    // Given a class name and identifier, create the relevant object.
+    if (strClassName == jpps::JPPSPlugin::CLASS_NAME) {
+        return new jpps::JPPSPlugin(strObjId);;
+    }
+    else if (strClassName == jpps::JPPSServerPlugin::CLASS_NAME) {
+    	return new jpps::JPPSServerPlugin(strObjId);
+    }
+
+    // Any other name is invalid
+    return NULL;
+}
+
+

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
new file mode 100644
index 0000000..37a9d17
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef LOGGER_H_
+#define LOGGER_H_
+
+#include <string>
+
+#include <sys/slog.h>
+#include <sys/slogcodes.h>
+
+namespace jpps {
+
+/**
+ * The Logger class writes messages to the system log. It has a verbosity setting
+ * in order to prevent cluttering the slog during normal operation.
+ */
+class Logger {
+
+public:
+
+	enum slogType {
+		info = _SLOG_INFO,
+		warning = _SLOG_WARNING,
+		error = _SLOG_ERROR,
+		critical = _SLOG_CRITICAL,
+		debug = _SLOG_DEBUG1
+	};
+
+	/**
+	 * Default constructor. Sets the verbosity to 0;
+	 */
+	Logger() : m_verbosity(0) {}
+
+	/**
+	 * Destructor.
+	 */
+	~Logger() {}
+
+	/**
+	 * Set the desired level of verbosity. A value of 0 means that only warning,
+	 * error and critical messages will appear in the slog. A verbosity of 1 adds
+	 * info messages. A verbosity of 2 adds debug messages.
+	 */
+	inline void setVerbosity(unsigned short value) { m_verbosity = value; }
+
+	/**
+	 * Get the current level of verbosity.
+	 */
+	inline unsigned short getVerbosity() const { return m_verbosity; }
+
+	/**
+	 * Used to send messages to the system log (slog).
+	 *
+	 * @param type The type of slog message.
+	 * @param message The message to put in the slog.
+	 */
+	void slog(const slogType& type, const std::string& message) const {
+
+		// Don't display info or debug when verbosity is set to 0
+		if (m_verbosity == 0 && (type == info || type == debug)) return;
+		// Don't display debug when verbosity is set to 1
+		if (m_verbosity == 1 && type == debug) return;
+
+		::slogf(_SLOG_SETCODE(_SLOGC_GRAPHICS, 300), type, "%s", message.c_str());
+	}
+
+private:
+
+	/** The verbosity level.  */
+	unsigned short m_verbosity;
+};
+
+}
+
+#endif /* LOGGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
new file mode 100644
index 0000000..82ab5d1
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "Thread.h"
+#include <pthread.h>
+#include "Logger.h"
+#include <sstream>
+#include <string.h>
+#include <errno.h>
+
+namespace jpps {
+
+Thread::Thread()
+: m_threadID(-1)
+{
+	// Init the thread with all defaults
+	pthread_attr_init(&m_attrib);
+}
+
+Thread::~Thread()
+{
+	// Dispose of the thread attributes
+	pthread_attr_destroy(&m_attrib);
+}
+
+void Thread::start(void* (*start_routine)(void*), void* arg, const std::string& thread_name)
+{
+	// If this thread is already started, you can't start a new one
+	if (m_threadID != -1) {
+		return;
+	}
+
+	// Create a new thread
+	if (pthread_create(&m_threadID, &m_attrib, start_routine, arg) != 0) {
+
+		std::ostringstream ostream;
+		ostream << "Thread::start() Failed - Failed to create a new thread. "
+				<< " (" << errno << ": " << strerror(errno) << ")";
+
+		Logger logger;
+		logger.slog(Logger::warning, ostream.str());
+	}
+
+	if (!thread_name.empty())
+		pthread_setname_np(m_threadID, thread_name.c_str());
+}
+
+void Thread::stop()
+{
+	// If the thread wasn't running, we can't stop it
+	if (m_threadID == -1) {
+		return;
+	}
+
+	// Cancel the thread
+	if (pthread_cancel(m_threadID) != 0) {
+
+		std::ostringstream ostream;
+		ostream << "Thread::stop() Failed - Failed to cancel thread " << m_threadID << "."
+				<< " (" << errno << ": " << strerror(errno) << ")";
+
+		Logger logger;
+		logger.slog(Logger::warning, ostream.str());
+	}
+
+	// Reset the thread ID
+	m_threadID = -1;
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
new file mode 100644
index 0000000..79cc62a
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef THREAD_H_
+#define THREAD_H_
+
+#include <sys/types.h>
+#include <string>
+
+namespace jpps {
+
+/**
+ * Simple wrapper to simplify thread management.
+ */
+class Thread {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	Thread();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~Thread();
+
+	/**
+	 * Start a thread with the given function. If the thread is already running and has not
+	 * been stopped, this does nothing.
+	 */
+	void start(void* (*start_routine)(void*), void* arg, const std::string& thread_name = "");
+
+	/**
+	 * Stop the thread. If the thread isn't running, this does nothing.
+	 */
+	void stop();
+
+	/**
+	 * Is the thread running?
+	 */
+	inline bool isRunning() const { return (m_threadID >= 0); }
+
+private:
+
+	/** The id of this thread. */
+	pthread_t m_threadID;
+
+	/** The attributes of this thread. */
+	pthread_attr_t m_attrib;
+};
+
+} /* namespace jpps */
+#endif /* THREAD_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/Makefile b/blackberry10/bin/templates/project/plugins/Utils/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
new file mode 100644
index 0000000..90a43db
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
@@ -0,0 +1,18 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=utils
+LDFLAGS+=-Wl,-h,libutils.so
+
+include ../../../../../../meta.mk
+
+SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
+      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
+      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
+      webworks_utils.cpp
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+LIBS += socket

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
new file mode 100644
index 0000000..126d02c
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
new file mode 100644
index 0000000..392ad33
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
new file mode 100644
index 0000000..68397a1
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include <resolv.h>
+#include <sstream>
+#include <string>
+
+#include "webworks_utils.hpp"
+
+namespace webworks {
+
+std::string Utils::intToStr(const int val)
+{
+    std::string s;
+    std::stringstream out;
+    out << val;
+    return out.str();
+}
+
+int Utils::strToInt(const std::string& val) {
+    int number;
+
+    if (!(std::istringstream(val) >> number)) {
+        return -1;
+    }
+    return number;
+}
+
+std::string Utils::toBase64(const unsigned char *input, const size_t size)
+{
+    size_t outputSize = size * 4;
+    char *output = new char[outputSize];
+    outputSize = b64_ntop(input, size, output, outputSize);
+    output[outputSize] = 0;
+
+    std::string outputString(output);
+    delete output;
+
+    return outputString;
+}
+
+} // namespace webworks

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/92134ef7/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
new file mode 100644
index 0000000..4ab2ca7
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#ifndef WW_UTILS_HPP_
+#define WW_UTILS_HPP_
+
+#include <string.h>
+#include <string>
+
+namespace webworks {
+
+class Utils {
+public:
+    static std::string intToStr(const int val);
+    static int strToInt(const std::string& val);
+    static std::string toBase64(const unsigned char *input, const size_t size);
+};
+
+} // namespace webworks
+
+#endif // WW_UTILS_HPP_


[36/50] [abbrv] webworks commit: writeFile in packager-utils updated to be sync

Posted by lo...@apache.org.
writeFile in packager-utils updated to be sync

This fixes a problem where config/user.js has not yet been written before it is added to frameworkModules.js for the simulator bar file.

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/2862189b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/2862189b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/2862189b

Branch: refs/heads/future
Commit: 2862189b17515bfb86e91bdd7b02cbc0d705d112
Parents: b0a540b
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed Apr 24 11:38:35 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 .../project/cordova/lib/packager-utils.js          |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/2862189b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
index 9b1c2e0..09465e8 100644
--- a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
@@ -47,9 +47,7 @@ _self = {
             wrench.mkdirSyncRecursive(fileLocation, "0755");
         }
 
-        fs.writeFile(path.join(fileLocation, fileName), fileData, function (err) {
-            if (err) throw err;
-        });
+        fs.writeFileSync(path.join(fileLocation, fileName), fileData);
     },
     
     copyFile: function (srcFile, destDir, baseDir) {


[45/50] [abbrv] webworks commit: Update cordova.blackberry10.js

Posted by lo...@apache.org.
Update cordova.blackberry10.js


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

Branch: refs/heads/future
Commit: fc73d210462b8b9565ccbb58bd98deb8ac9a5504
Parents: 961bdf4
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri May 3 10:15:59 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:15:59 2013 -0400

----------------------------------------------------------------------
 blackberry10/javascript/cordova.blackberry10.js |  287 ++++++++++--------
 1 files changed, 159 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fc73d210/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 7e50d79..4f6b690 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,9 +1,6 @@
 // Platform: blackberry10
-
-// commit f4db421d9c19f337ca764daa7a1a74e6cfef14a2
-
-// File generated at :: Fri Apr 26 2013 11:49:39 GMT-0400 (EDT)
-
+// 2.7.0rc1-36-g93152a0
+// File generated at :: Fri May 03 2013 09:51:02 GMT-0400 (EDT)
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -22,9 +19,8 @@
  specific language governing permissions and limitations
  under the License.
 */
-
 ;(function() {
-
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-36-g93152a0';
 // file: lib/scripts/require.js
 
 var require,
@@ -230,6 +226,10 @@ var cordova = {
             }
             else {
               setTimeout(function() {
+                  // Fire deviceready on listeners that were registered before cordova.js was loaded.
+                  if (type == 'deviceready') {
+                      document.dispatchEvent(evt);
+                  }
                   documentEventHandlers[type].fire(evt);
               }, 0);
             }
@@ -753,6 +753,7 @@ channel.createSticky('onDestroy');
 // Channels that must fire before "deviceready" is fired.
 channel.waitForInitialization('onCordovaReady');
 channel.waitForInitialization('onCordovaConnectionReady');
+channel.waitForInitialization('onDOMContentLoaded');
 
 module.exports = channel;
 
@@ -1106,8 +1107,6 @@ var CaptureAudioOptions = function(){
     this.limit = 1;
     // Maximum duration of a single sound clip in seconds.
     this.duration = 0;
-    // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
-    this.mode = null;
 };
 
 module.exports = CaptureAudioOptions;
@@ -1148,8 +1147,6 @@ define("cordova/plugin/CaptureImageOptions", function(require, exports, module)
 var CaptureImageOptions = function(){
     // Upper limit of images user can take. Value must be equal or greater than 1.
     this.limit = 1;
-    // The selected image mode. Must match with one of the elements in supportedImageModes array.
-    this.mode = null;
 };
 
 module.exports = CaptureImageOptions;
@@ -1167,8 +1164,6 @@ var CaptureVideoOptions = function(){
     this.limit = 1;
     // Maximum duration of a single video clip in seconds.
     this.duration = 0;
-    // The selected video mode. Must match with one of the elements in supportedVideoModes array.
-    this.mode = null;
 };
 
 module.exports = CaptureVideoOptions;
@@ -4852,7 +4847,7 @@ console.debug = function() {
 console.assert = function(expression) {
     if (expression) return;
 
-    var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
+    var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
     console.log("ASSERT: " + message);
 };
 
@@ -5049,12 +5044,16 @@ function Device() {
 
     channel.onCordovaReady.subscribe(function() {
         me.getInfo(function(info) {
+            var buildLabel = info.cordova;
+            if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
+                buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
+            }
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
             me.name = info.name;
             me.uuid = info.uuid;
-            me.cordova = info.cordova;
+            me.cordova = buildLabel;
             me.model = info.model;
             channel.onCordovaInfoReady.fire();
         },function(e) {
@@ -5941,10 +5940,10 @@ function logWithArgs(level, args) {
  * Parameters passed after message are used applied to
  * the message with utils.format()
  */
-logger.logLevel = function(level, message /* , ... */) {
+logger.logLevel = function(level /* , ... */) {
     // format the message with the parameters
-    var formatArgs = [].slice.call(arguments, 2);
-    message    = utils.vformat(message, formatArgs);
+    var formatArgs = [].slice.call(arguments, 1);
+    var message    = logger.format.apply(logger.format, formatArgs);
 
     if (LevelsMap[level] === null) {
         throw new Error("invalid logging level: " + level);
@@ -5979,6 +5978,92 @@ logger.logLevel = function(level, message /* , ... */) {
     }
 };
 
+
+/**
+ * Formats a string and arguments following it ala console.log()
+ *
+ * Any remaining arguments will be appended to the formatted string.
+ *
+ * for rationale, see FireBug's Console API:
+ *    http://getfirebug.com/wiki/index.php/Console_API
+ */
+logger.format = function(formatString, args) {
+    return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
+};
+
+
+//------------------------------------------------------------------------------
+/**
+ * Formats a string and arguments following it ala vsprintf()
+ *
+ * format chars:
+ *   %j - format arg as JSON
+ *   %o - format arg as JSON
+ *   %c - format arg as ''
+ *   %% - replace with '%'
+ * any other char following % will format it's
+ * arg via toString().
+ *
+ * Returns an array containing the formatted string and any remaining
+ * arguments.
+ */
+function __format(formatString, args) {
+    if (formatString === null || formatString === undefined) return [""];
+    if (arguments.length == 1) return [formatString.toString()];
+
+    if (typeof formatString != "string")
+        formatString = formatString.toString();
+
+    var pattern = /(.*?)%(.)(.*)/;
+    var rest    = formatString;
+    var result  = [];
+
+    while (args.length) {
+        var match = pattern.exec(rest);
+        if (!match) break;
+
+        var arg   = args.shift();
+        rest = match[3];
+        result.push(match[1]);
+
+        if (match[2] == '%') {
+            result.push('%');
+            args.unshift(arg);
+            continue;
+        }
+
+        result.push(__formatted(arg, match[2]));
+    }
+
+    result.push(rest);
+
+    var remainingArgs = [].slice.call(args);
+    remainingArgs.unshift(result.join(''));
+    return remainingArgs;
+}
+
+function __formatted(object, formatChar) {
+
+    try {
+        switch(formatChar) {
+            case 'j':
+            case 'o': return JSON.stringify(object);
+            case 'c': return '';
+        }
+    }
+    catch (e) {
+        return "error JSON.stringify()ing argument: " + e;
+    }
+
+    if ((object === null) || (object === undefined)) {
+        return Object.prototype.toString.call(object);
+    }
+
+    return object.toString();
+}
+
+
+//------------------------------------------------------------------------------
 // when deviceready fires, log queued messages
 logger.__onDeviceReady = function() {
     if (DeviceReady) return;
@@ -6147,13 +6232,13 @@ module.exports = {
             console.log("Notification.confirm(string, function, string, string) is deprecated.  Use Notification.confirm(string, function, string, array).");
         }
 
-        // Android and iOS take an array of button label names.
+        // Some platforms take an array of button label names.
         // Other platforms take a comma separated list.
         // For compatibility, we convert to the desired type based on the platform.
-        if (platform.id == "android" || platform.id == "ios" || platform.id == "blackberry10") {
+        if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
             if (typeof _buttonLabels === 'string') {
                 var buttonLabelString = _buttonLabels;
-                _buttonLabels = buttonLabelString.split(",");
+                _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
             }
         } else {
             if (Array.isArray(_buttonLabels)) {
@@ -6174,12 +6259,14 @@ module.exports = {
      * @param {Function} resultCallback     The callback that is called when user clicks on a button.
      * @param {String} title                Title of the dialog (default: "Prompt")
      * @param {Array} buttonLabels          Array of strings for the button labels (default: ["OK","Cancel"])
+     * @param {String} defaultText          Textbox input value (default: "Default text")
      */
-    prompt: function(message, resultCallback, title, buttonLabels) {
+    prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
         var _message = (message || "Prompt message");
         var _title = (title || "Prompt");
         var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
-        exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels]);
+        var _defaultText = (defaultText || "Default text");
+        exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
     },
 
     /**
@@ -6471,62 +6558,6 @@ utils.alert = function(msg) {
     }
 };
 
-/**
- * Formats a string and arguments following it ala sprintf()
- *
- * see utils.vformat() for more information
- */
-utils.format = function(formatString /* ,... */) {
-    var args = [].slice.call(arguments, 1);
-    return utils.vformat(formatString, args);
-};
-
-/**
- * Formats a string and arguments following it ala vsprintf()
- *
- * format chars:
- *   %j - format arg as JSON
- *   %o - format arg as JSON
- *   %c - format arg as ''
- *   %% - replace with '%'
- * any other char following % will format it's
- * arg via toString().
- *
- * for rationale, see FireBug's Console API:
- *    http://getfirebug.com/wiki/index.php/Console_API
- */
-utils.vformat = function(formatString, args) {
-    if (formatString === null || formatString === undefined) return "";
-    if (arguments.length == 1) return formatString.toString();
-    if (typeof formatString != "string") return formatString.toString();
-
-    var pattern = /(.*?)%(.)(.*)/;
-    var rest    = formatString;
-    var result  = [];
-
-    while (args.length) {
-        var arg   = args.shift();
-        var match = pattern.exec(rest);
-
-        if (!match) break;
-
-        rest = match[3];
-
-        result.push(match[1]);
-
-        if (match[2] == '%') {
-            result.push('%');
-            args.unshift(arg);
-            continue;
-        }
-
-        result.push(formatted(arg, match[2]));
-    }
-
-    result.push(rest);
-
-    return result.join('');
-};
 
 //------------------------------------------------------------------------------
 function UUIDcreatePart(length) {
@@ -6541,35 +6572,32 @@ function UUIDcreatePart(length) {
     return uuidpart;
 }
 
-//------------------------------------------------------------------------------
-function formatted(object, formatChar) {
-
-    try {
-        switch(formatChar) {
-            case 'j':
-            case 'o': return JSON.stringify(object);
-            case 'c': return '';
-        }
-    }
-    catch (e) {
-        return "error JSON.stringify()ing argument: " + e;
-    }
-
-    if ((object === null) || (object === undefined)) {
-        return Object.prototype.toString.call(object);
-    }
-
-    return object.toString();
-}
 
 });
 
-
 window.cordova = require('cordova');
-
 // file: lib/scripts/bootstrap.js
 
 (function (context) {
+    var channel = require('cordova/channel');
+    var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
+
+    function logUnfiredChannels(arr) {
+        for (var i = 0; i < arr.length; ++i) {
+            if (arr[i].state != 2) {
+                console.log('Channel not fired: ' + arr[i].type);
+            }
+        }
+    }
+
+    window.setTimeout(function() {
+        if (channel.onDeviceReady.state != 2) {
+            console.log('deviceready has not fired after 5 seconds.');
+            logUnfiredChannels(platformInitChannelsArray);
+            logUnfiredChannels(channel.deviceReadyChannelsArray);
+        }
+    }, 5000);
+
     // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
     // We replace it so that properties that can't be clobbered can instead be overridden.
     function replaceNavigator(origNavigator) {
@@ -6591,8 +6619,6 @@ window.cordova = require('cordova');
         context.navigator = replaceNavigator(context.navigator);
     }
 
-    var channel = require("cordova/channel");
-
     // _nativeReady is global variable that the native side can set
     // to signify that the native code is ready. It is a global since
     // it may be called before any cordova JS is ready.
@@ -6601,24 +6627,26 @@ window.cordova = require('cordova');
     }
 
     /**
-     * Create all cordova objects once page has fully loaded and native side is ready.
+     * Create all cordova objects once native side is ready.
      */
     channel.join(function() {
-        var platform = require('cordova/platform');
-
         // Call the platform-specific initialization
-        platform.initialize();
+        require('cordova/platform').initialize();
 
         // Fire event to notify that all objects are created
         channel.onCordovaReady.fire();
 
-        // Fire onDeviceReady event once all constructors have run and
-        // cordova info has been received from native side.
+        // Fire onDeviceReady event once page has fully loaded, all
+        // constructors have run and cordova info has been received from native
+        // side.
+        // This join call is deliberately made after platform.initialize() in
+        // order that plugins may manipulate channel.deviceReadyChannelsArray
+        // if necessary.
         channel.join(function() {
             require('cordova').fireDocumentEvent('deviceready');
         }, channel.deviceReadyChannelsArray);
 
-    }, [ channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady ]);
+    }, platformInitChannelsArray);
 
 }(window));
 
@@ -6817,29 +6845,32 @@ document.addEventListener("DOMContentLoaded", function () {
 
 
     // Try to XHR the cordova_plugins.json file asynchronously.
-    try { // we commented we were going to try, so let us actually try and catch
-        var xhr = new context.XMLHttpRequest();
-        xhr.onload = function() {
-            // If the response is a JSON string which composes an array, call handlePluginsObject.
-            // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
-            var obj = JSON.parse(this.responseText);
-            if (obj && obj instanceof Array && obj.length > 0) {
-                handlePluginsObject(obj);
-            } else {
-                finishPluginLoading();
-            }
-        };
-        xhr.onerror = function() {
+    var xhr = new XMLHttpRequest();
+    xhr.onload = function() {
+        // If the response is a JSON string which composes an array, call handlePluginsObject.
+        // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
+        var obj;
+        try {
+            obj = this.status == 200 && this.responseText && JSON.parse(this.responseText);
+        } catch (err) {
+            // obj will be undefined.
+        }
+        if (Array.isArray(obj) && obj.length > 0) {
+            handlePluginsObject(obj);
+        } else {
             finishPluginLoading();
-        };
-        xhr.open('GET', '/cordova_plugins.json', true); // Async
+        }
+    };
+    xhr.onerror = function() {
+        finishPluginLoading();
+    };
+    try { // we commented we were going to try, so let us actually try and catch
+        xhr.open('GET', 'cordova_plugins.json', true); // Async
         xhr.send();
-    }
-    catch(err){
+    } catch(err){
         finishPluginLoading();
     }
 }(window));
 
 
-
 })();
\ No newline at end of file


[37/50] [abbrv] webworks commit: Point to blackberry10 branch of plugman in package.json

Posted by lo...@apache.org.
Point to blackberry10 branch of plugman in package.json


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/82dfa2df
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/82dfa2df
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/82dfa2df

Branch: refs/heads/future
Commit: 82dfa2dfacfd226c29c66f0086633bdc0d0d43d1
Parents: d0742f5
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Apr 18 09:50:51 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 README.md                 |    7 +++++++
 blackberry10/package.json |    2 +-
 2 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/82dfa2df/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8aaf204
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+Cordova BlackBerry
+
+This repo contains cordova projects for the BlackBerry platforms:
+
+blackberry - BBOS 5+ and Tablet OS
+
+blackberry10 - BB10

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/82dfa2df/blackberry10/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/package.json b/blackberry10/package.json
index ed87b2a..6862757 100644
--- a/blackberry10/package.json
+++ b/blackberry10/package.json
@@ -20,7 +20,7 @@
     "xml2js": "0.1.13",
     "validator": "0.4.1",
     "wrench": "1.3.9",
-    "plugman": "git+https://github.com/blackberry/cordova-plugman.git#master"
+    "plugman": "git+https://github.com/blackberry/cordova-plugman.git#blackberry10"
   },
   "files": [
     "node_modules",


[10/50] [abbrv] webworks commit: Cordova plugin unit tests [Device, NetworkStatus]

Posted by lo...@apache.org.
Cordova plugin unit tests [Device, NetworkStatus]

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: eb75c14b71da3228a3d9929aab3886b24ea5a90a
Parents: c42ba50
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Fri Mar 22 10:17:48 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/NetworkStatus/index.js         |    4 +-
 blackberry10/bin/test/plugins/Device/index.js      |   68 +++++++++
 .../bin/test/plugins/NetworkStatus/index.js        |  109 +++++++++++++++
 blackberry10/scripts/test.js                       |    3 +-
 4 files changed, 181 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/eb75c14b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
index f96efe9..ae6cdf2 100644
--- a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
@@ -44,8 +44,8 @@ function mapConnectionType(con) {
 function currentConnectionType() {
     try {
         //possible for webplatform to throw pps exception
-        return mapConnectionType(qnx.webplatform.device.activeConnection || { type : 'none' });
-    } 
+        return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type : 'none' });
+    }
     catch (e) {
         return 'unknown';
     }

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/eb75c14b/blackberry10/bin/test/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Device/index.js b/blackberry10/bin/test/plugins/Device/index.js
new file mode 100644
index 0000000..bdfcfa4
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Device/index.js
@@ -0,0 +1,68 @@
+/*
+* Copyright 2013 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 _apiDir = __dirname + "./../../../templates/project/plugins/Device/",
+index;
+
+describe("Device", function () {
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+    });
+
+    afterEach(function () {
+        index = null;
+    });
+
+    describe("getDeviceInfo", function () {
+        beforeEach(function () {
+            GLOBAL.window = {
+                qnx: {
+                    webplatform: {
+                        device: {
+                        }
+                    }
+                }
+            };
+        });
+
+        afterEach(function () {
+            delete GLOBAL.window;
+        });
+
+        it("calls success with the Device info", function () {
+            var mockedDevice = {
+                scmBundle: "1.0.0.0",
+                modelName: "q10",
+                devicePin: (new Date()).getTime()
+            },
+            success = jasmine.createSpy().andCallFake(function (deviceInfo) {
+                expect(deviceInfo.platform).toEqual("blackberry10");
+                expect(deviceInfo.version).toEqual(mockedDevice.scmBundle);
+                expect(deviceInfo.model).toEqual(mockedDevice.modelName);
+                expect(deviceInfo.name).toEqual(mockedDevice.modelName);
+                expect(deviceInfo.uuid).toEqual(mockedDevice.devicePin);
+                expect(deviceInfo.cordova).toBeDefined();
+            }),
+            fail = jasmine.createSpy();
+
+            window.qnx.webplatform.device = mockedDevice;
+
+            index.getDeviceInfo(success, fail);
+
+            expect(success).toHaveBeenCalled();
+            expect(fail).not.toHaveBeenCalled();
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/eb75c14b/blackberry10/bin/test/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/NetworkStatus/index.js b/blackberry10/bin/test/plugins/NetworkStatus/index.js
new file mode 100644
index 0000000..87f6f0b
--- /dev/null
+++ b/blackberry10/bin/test/plugins/NetworkStatus/index.js
@@ -0,0 +1,109 @@
+/*
+* Copyright 2013 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 _apiDir = __dirname + "./../../../templates/project/plugins/NetworkStatus/",
+index;
+
+describe("NetworkStatus", function () {
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+    });
+
+    afterEach(function () {
+        index = null;
+    });
+
+    describe("getConnectionInfo", function () {
+        beforeEach(function () {
+            GLOBAL.window = {
+                qnx: {
+                    webplatform: {
+                        device: {
+                        }
+                    }
+                }
+            };
+        });
+
+        afterEach(function () {
+            delete GLOBAL.window;
+        });
+
+        function testConnection(expectedResult, mockedType, mockedTechnology) {
+            var mockedDevice = {
+                activeConnection: {
+                    type: mockedType,
+                    technology: mockedTechnology
+                }
+            },
+            success = jasmine.createSpy(),
+            fail = jasmine.createSpy();
+
+            if (mockedType) {
+                window.qnx.webplatform.device = mockedDevice;
+            }
+
+            index.getConnectionInfo(success, fail);
+
+            expect(success).toHaveBeenCalledWith(expectedResult);
+            expect(fail).not.toHaveBeenCalled();
+        }
+
+        it("calls success with a wired connection", function () {
+            testConnection("ethernet", "wired");
+        });
+
+        it("calls success with a wifi connection", function () {
+            testConnection("wifi", "wifi");
+        });
+
+        it("calls success with no connection", function () {
+            testConnection("none", "none");
+        });
+
+        it("calls success with a cellular edge connection", function () {
+            testConnection("2g", "cellular", "edge");
+        });
+
+        it("calls success with a cellular gsm connection", function () {
+            testConnection("2g", "cellular", "gsm");
+        });
+
+        it("calls success with a cellular evdo connection", function () {
+            testConnection("3g", "cellular", "evdo");
+        });
+
+        it("calls success with a cellular umts connection", function () {
+            testConnection("3g", "cellular", "umts");
+        });
+
+        it("calls success with a lte connection", function () {
+            testConnection("4g", "cellular", "lte");
+        });
+
+        it("calls success with a cellular connection", function () {
+            testConnection("cellular", "cellular");
+        });
+
+        it("defaults to none if no connection is found", function () {
+            testConnection("none");
+        });
+
+        it("defaults to unknown if connection type doesn't exist", function () {
+            testConnection("unknown", "fakeConnectionType");
+        });
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/eb75c14b/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
index e8d1e3f..05408c1 100644
--- a/blackberry10/scripts/test.js
+++ b/blackberry10/scripts/test.js
@@ -25,7 +25,8 @@ module.exports = function (done, custom) {
         specs = [
             "framework/test",
             "bin/test/cordova/integration",
-            "bin/test/cordova/unit"
+            "bin/test/cordova/unit",
+            "bin/test/plugins"
         ];
         key = {};
 


[21/50] [abbrv] webworks commit: Cordova Notification API implementation [alert, confirm, prompt, vibrate]

Posted by lo...@apache.org.
Cordova Notification API implementation [alert, confirm, prompt, vibrate]

Reviewed By: Bryan Higgins <bh...@blackberry.com>
Tested By: Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/63452dbf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/63452dbf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/63452dbf

Branch: refs/heads/future
Commit: 63452dbf43d6ec27399a74d884d9bffa38b479d7
Parents: 957fc5b
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Fri Apr 5 16:28:41 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/Notification/index.js          |   91 +++++++++++
 .../bin/test/plugins/Notification/index.js         |  119 +++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   69 ++++-----
 3 files changed, 239 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/63452dbf/blackberry10/bin/templates/project/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Notification/index.js b/blackberry10/bin/templates/project/plugins/Notification/index.js
new file mode 100644
index 0000000..497170b
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Notification/index.js
@@ -0,0 +1,91 @@
+/*
+* Copyright 2013 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.
+*/
+
+function showDialog(args, dialogType, result) {
+    //Unpack and map the args
+    var msg = JSON.parse(decodeURIComponent(args[0])),
+    title = JSON.parse(decodeURIComponent(args[1])),
+    btnLabel = JSON.parse(decodeURIComponent(args[2]));
+
+    if (!Array.isArray(btnLabel)) {
+        //Converts to array for (string) and (string,string, ...) cases
+        btnLabel = btnLabel.split(",");
+    }
+
+    if (msg && typeof msg === "string") {
+        msg = msg.replace(/^"|"$/g, "").replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+    } else {
+        result.error("message is undefined");
+        return;
+    }
+
+    var messageObj = {
+        title : title,
+        htmlmessage :  msg,
+        dialogType : dialogType,
+        optionalButtons : btnLabel
+    };
+
+    //TODO replace with getOverlayWebview() when available in webplatform
+    qnx.webplatform.getWebViews()[2].dialog.show(messageObj, function (data) {
+        if (typeof data === "number") {
+            //Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc]
+            result.callbackOk(++data, false);
+        } else {
+            //Prompt dialog callback expects object
+            result.callbackOk({
+                buttonIndex: data.ok ? 1 : 0,
+                input1: (data.oktext) ? decodeURIComponent(data.oktext) : null
+            }, false);
+        }
+    });
+
+    result.noResult(true);
+}
+
+module.exports = {
+    alert: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - alert arguments not found.");
+        } else {
+            showDialog(args, "CustomAsk", result);
+        }
+    },
+    confirm: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - confirm arguments not found.");
+        } else {
+            showDialog(args, "CustomAsk", result);
+        }
+    },
+    prompt: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+
+        if (Object.keys(args).length < 3) {
+            result.error("Notification action - prompt arguments not found.");
+        } else {
+            showDialog(args, "JavaScriptPrompt", result);
+        }
+    },
+    beep: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error("Beep not supported");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/63452dbf/blackberry10/bin/test/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Notification/index.js b/blackberry10/bin/test/plugins/Notification/index.js
new file mode 100644
index 0000000..2b585f8
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Notification/index.js
@@ -0,0 +1,119 @@
+/*
+* Copyright 2013 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.
+*/
+
+function mockAndTestDialog(htmlmessage, title, dialogType, buttonLabel) {
+    GLOBAL.qnx = {
+        webplatform: {
+            getWebViews: function () {
+                var webviews = [{}, {},
+                    {//overlayWebview
+                        dialog: {
+                            show: function(messageObj, callback) {
+                                expect(messageObj.title).toEqual(title);
+                                expect(messageObj.htmlmessage).toEqual(htmlmessage);
+                                expect(messageObj.dialogType).toEqual(dialogType);
+                                expect(messageObj.optionalButtons).toEqual(buttonLabel);
+                                expect(typeof callback).toEqual("function");
+                            }
+                        }
+                    }];
+                return webviews;
+            }
+        }
+    };
+
+}
+
+describe("Notification", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Notification/",
+    index,
+    success = function() {},
+    fail = function() {},
+    result = {
+        error: jasmine.createSpy(),
+        noResult: jasmine.createSpy()
+    },
+    args = {
+        0: "%22Dialog%20message.%22",
+        1: "%22Dialog%20Title%22",
+        2: "%22Continue%22"
+    };
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+
+        GLOBAL.PluginResult = function () {
+            return result;
+        };
+    });
+
+    afterEach(function () {
+        delete require.cache[require.resolve(_apiDir + "index")];
+        delete GLOBAL.qnx;
+        delete GLOBAL.PluginResult;
+    });
+
+    describe("alert", function () {
+        it("fails with invalid number of args", function () {
+            index.alert(success, fail, {}, {});
+            expect(result.error).toHaveBeenCalledWith("Notification action - alert arguments not found.");
+        });
+
+        it("calls dialog.show with correct params", function () {
+            mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue"]);
+            index.alert(success, fail, args, {});
+            expect(result.noResult).toHaveBeenCalled();
+        });
+    });
+
+    describe("confirm", function () {
+        it("fails with invalid number of args", function () {
+            index.confirm(success, fail, {}, {});
+            expect(result.error).toHaveBeenCalledWith("Notification action - confirm arguments not found.");
+        });
+
+        it("calls dialog.show with correct params", function () {
+            mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue"]);
+            index.confirm(success, fail, args, {});
+            expect(result.noResult).toHaveBeenCalled();
+        });
+
+        it("calls dialog.show with correct params [deprecated buttonArg]", function () {
+            var args = {
+                0: "%22Dialog%20message.%22",
+                1: "%22Dialog%20Title%22",
+                2: "%22Continue,Cancel%22"
+            };
+
+            mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue", "Cancel"]);
+            index.confirm(success, fail, args, {});
+            expect(result.noResult).toHaveBeenCalled();
+        });
+    });
+
+    describe("prompt", function () {
+        it("fails with invalid number of args", function () {
+            index.prompt(success, fail, {}, {});
+            expect(result.error).toHaveBeenCalledWith("Notification action - prompt arguments not found.");
+        });
+
+        it("calls dialog.show with correct params", function () {
+            mockAndTestDialog("Dialog message.", "Dialog Title", "JavaScriptPrompt", ["Continue"]);
+            index.prompt(success, fail, args, {});
+            expect(result.noResult).toHaveBeenCalled();
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/63452dbf/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 8fd6292..b730b08 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit 2a6ac9642dcc875318e348c64bf4e69d2e932cc1
+// commit f9ac2930aa892422deff2be5a3b3b8f5e8f7edc0
 
-// File generated at :: Mon Apr 08 2013 09:08:23 GMT-0400 (EDT)
+// File generated at :: Mon Apr 08 2013 15:58:16 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -952,7 +952,6 @@ var cordova = require('cordova'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
     };
@@ -4868,43 +4867,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/notification.js
-define("cordova/plugin/blackberry10/notification", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    alert: function (args, win, fail) {
-        if (args.length !== 3) {
-            return {"status" : 9, "message" : "Notification action - alert arguments not found"};
-        }
-
-        //Unpack and map the args
-        var msg = args[0],
-            title = args[1],
-            btnLabel = args[2];
-
-        blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title" : title } ]);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    },
-    confirm: function (args, win, fail) {
-        if (args.length !== 3) {
-            return {"status" : 9, "message" : "Notification action - confirm arguments not found"};
-        }
-
-        //Unpack and map the args
-        var msg = args[0],
-            title = args[1],
-            btnLabel = args[2],
-            btnLabels = btnLabel.split(",");
-
-        blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title" : title} ]);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/platform.js
 define("cordova/plugin/blackberry10/platform", function(require, exports, module) {
 
@@ -4935,6 +4897,17 @@ module.exports = {
     clobbers: {
         requestFileSystem: {
             path: "cordova/plugin/blackberry10/requestFileSystem"
+        },
+        navigator: {
+            children: {
+                notification: {
+                    children: {
+                        vibrate: {
+                            path: 'cordova/plugin/blackberry10/vibrate'
+                        }
+                    }
+                }
+            }
         }
     },
     merges: {
@@ -5588,6 +5561,22 @@ self = module.exports = {
 
 });
 
+// file: lib/blackberry10/plugin/blackberry10/vibrate.js
+define("cordova/plugin/blackberry10/vibrate", function(require, exports, module) {
+
+module.exports = function (time) {
+    var proto = Object.getPrototypeOf(navigator);
+
+    if (proto && proto.vibrate) {
+        proto.vibrate(time);
+    } else if (proto && proto.webkitVibrate) {
+        //Older OS contain webkit prefix
+        proto.webkitVibrate(time);
+    }
+};
+
+});
+
 // file: lib/common/plugin/capture.js
 define("cordova/plugin/capture", function(require, exports, module) {
 


[23/50] [abbrv] Fix JPPS and Utils plugins directory structure

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
deleted file mode 100644
index 5392ca8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSNotifyGroupManager.h"
-
-#include <fcntl.h>
-
-#include "PPSNotifier.h"
-
-namespace jpps {
-
-typedef std::map<std::string, PPSNotifier*>::iterator groupIter;
-typedef std::map<std::string, PPSNotifier*>::const_iterator const_groupIter;
-typedef std::pair<std::string, PPSNotifier*> groupValue;
-
-pthread_mutex_t PPSNotifyGroupManager::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-PPSNotifyGroupManager::PPSNotifyGroupManager()
-{
-
-}
-
-PPSNotifyGroupManager::~PPSNotifyGroupManager()
-{
-	// Delete the allocated memory for all the PPSNotifiers
-	for (groupIter it = m_notifyGroups.begin(); it != m_notifyGroups.end(); it++) {
-
-		if ((*it).second != NULL) {
-
-			delete (*it).second;
-			(*it).second = NULL;
-		}
-	}
-}
-
-PPSNotifyGroupManager& PPSNotifyGroupManager::getInstance()
-{
-	// The one and only PPSNotifyGroupManager
-	static PPSNotifyGroupManager manager;
-	return manager;
-}
-
-bool PPSNotifyGroupManager::joinNotifyGroup(const std::string& path, std::string& groupId)
-{
-	std::string notifyFile;
-	std::string notifyPath(path);
-	std::size_t nPos = notifyPath.rfind('/');
-
-	// Search through the directories in the string until we find a valid .notify object
-	while (nPos != std::string::npos) {
-
-		// Chop off everything after the last '/' to get the path without the PPS object name
-		notifyPath = notifyPath.substr(0, nPos);
-
-		// Do we already have a notify group for this path?
-		const_groupIter it = m_notifyGroups.find(notifyPath);
-
-		// We found a match!
-		if (it != m_notifyGroups.end() && (*it).second != NULL) {
-
-			groupId = (*it).second->getNotifyGroupId();
-			return true;
-		}
-
-		// Add ".notify?wait" to the notify path, to make it a real file
-		notifyFile = notifyPath + "/.notify?wait";
-
-		// Try to open this .notify object
-		int fd = ::open(notifyFile.c_str(), O_RDONLY);
-
-		// This is the .notify object to use
-		if (fd >= 0) {
-
-			char data[20];
-			int len = ::read(fd, data, sizeof(data) - 1);
-			// Terminate string to remove the newline char
-			data[len > 0 ? len - 1 : 0] = '\0';
-
-			PPSNotifier* pNotifier = new PPSNotifier();
-			pNotifier->setNotifyGroupId(std::string(data));
-			pNotifier->setNotifyOjbPath(notifyPath);
-			pNotifier->setObjFd(::dup(fd));
-                        ::close(fd);
-
-			// Add this badboy to our cache of notify groups
-			m_notifyGroups.insert(groupValue(notifyPath, pNotifier));
-
-			// Start the notify reading thread
-			pNotifier->startNotifyLoop();
-
-			groupId = pNotifier->getNotifyGroupId();
-			return true;
-		}
-		// Keep looking
-		else {
-
-			nPos = notifyPath.rfind('/');
-		}
-	}
-
-	// We didn't find a notify group
-	groupId = "";
-	return false;
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
deleted file mode 100644
index 03b0e3e..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSNOTIFYGROUPMANAGER_H_
-#define PPSNOTIFYGROUPMANAGER_H_
-
-#include <map>
-#include <string>
-#include <pthread.h>
-
-namespace jpps {
-
-// Forward declaration
-class PPSNotifier;
-
-
-/**
- * The PPSNotifyGroupManager is used to manage a global pool of .notify objects. PPS has a mechanism
- * where every folder can contain a special PPS object ".notify". Opening the .notify object will return
- * a group id on the first read of the .notify object. The group id is used to open the real PPS object
- * for which we desire to receive notifications. Once this is done, the .notify object is the one that will
- * receive change notifications for the real PPS object. In this model, the real PPS object DOES NOT
- * open in blocking read or ionotify/select mode. The .notify object is the one responsible for blocking
- * on read and tracking data publishing.
- *
- * This object is a global singleton - any access to it needs to be wrapped in a mutex to prevent
- * concurrency problems. Two functions mutex_lock() and mutex_unlock() are provided for this purpose.
- */
-class PPSNotifyGroupManager
-{
-public:
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSNotifyGroupManager();
-
-	/**
-	 * Get the one and only instance of the PPSNotifier.Always wrap calls to getInstance() in a call to
-	 * PPSNotifyGroupManager::mutexLock()/mutexUnlock().
-	 */
-	static PPSNotifyGroupManager& getInstance();
-
-	/**
-	 * Use this function to get the notify group id of the "closest" .notify object in the /pps hierarchy
-	 * that contains path.
-	 *
-	 * The function will go backwards through the directories in path looking for a .notify object. It will return
-	 * the group id of the first .notify object it finds on this path. It is the responsibility of the caller
-	 * to have the PPS object in path join the notify group by opening the object with the "notify=groupId:val"
-	 * option set.
-	 *
-	 * PPSNotifyGroupManager maintains a pool of opened .notify objects. It is possible for a single .notify object
-	 * to have a very disparate (and numerous) set of PPS objects that it monitors. In order to tweak performance
-	 * it is advisable that .notify object be created in strategic directories in the /pps directory hierarchy, in
-	 * order to spread the load of notification monitoring. Each .notify object opened will spawn a thread that blocks
-	 * on reading from the .notify object. Having several .notify objects means having several threads that read
-	 * notifications.
-	 *
-	 * Note that joinNotifyGroup() will NOT create any .notify PPS objects. The /pps/.notify object always exists,
-	 * and if the /pps directory hierarchy contains no other .notify objects, /pps/.notify will end up being the
-	 * notification group that all objects join.
-	 *
-	 * Always wrap calls to joinNotifyGroup() in a call to PPSNotifyGroupManager::mutexLock()/mutexUnlock().
-	 *
-	 * @param The PPS object that wants to join the notify group.
-	 * @param groupId The id of the notify group joined. This is an output parameter.
-	 * @return True if a notify group was successfully joined, false otherwise. If true, then the groupId
-	 * variable will be set.
-	 */
-	bool joinNotifyGroup(const std::string& path, std::string& groupId);
-
-	/**
-	 * Returns how many notification groups the manager is managing.
-	 *
-	 * @return The number of notification groups (i.e. open .notify objects) in use.
-	 */
-	inline std::size_t getNumGroups() const { return m_notifyGroups.size(); }
-
-	/**
-	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
-	 * object, multiple threads may try to access this object at one time. It is therefore important to
-	 * mutex lock all access to this object.
-	 */
-	static inline void mutexLock() { pthread_mutex_lock(&sm_mutex); }
-
-	/**
-	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
-	 * object, multiple threads may try to access this object at one time. It is therefore important to
-	 * mutex lock all access to this object.
-	 */
-	static inline void mutexUnlock() { pthread_mutex_unlock(&sm_mutex); }
-
-private:
-
-	/**
-	 * Constructor. Private as part of the singleton pattern of this object.
-	 */
-	PPSNotifyGroupManager();
-
-	// Disable the copy constructor.
-	PPSNotifyGroupManager(const PPSNotifyGroupManager& manager);
-
-	// Disable the assignment operator.
-	PPSNotifyGroupManager& operator=(const PPSNotifyGroupManager& rhs);
-
-	/** This is a cache of all the .notify objects. */
-	std::map<std::string, PPSNotifier*> m_notifyGroups;
-
-	/** Mutex used to prevent threads from clobbering each other. */
-	static pthread_mutex_t sm_mutex;
-};
-
-} /* namespace jpps */
-#endif /* PPSNOTIFYGROUPMANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
deleted file mode 100644
index 362d236..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSTYPES_H_
-#define PPSTYPES_H_
-
-#include <map>
-
-namespace jpps {
-
-class PPSEvent;
-
-/**
- * A struct representing an attribute of a PPS object.
- */
-struct ppsAttribute {
-
-	/** The attribute name. */
-	std::string name;
-	/** The attribute value. */
-	std::string value;
-	/** The attribute encoding. */
-	std::string encoding;
-	/** Flags associated to the attribute. */
-	int flags;
-	/** Attribute options. */
-	int options;
-	/** The attribute options mask. */
-	int optionMask;
-};
-
-/**
- * A struct representing a PPS object.
- */
-struct ppsObject {
-
-	/** The PPS object name. */
-	std::string name;
-	/** The PPS object flags. */
-	int flags;
-	/** The PPS object options. */
-	int options;
-	/** The PPS object option mask. */
-	int optionMask;
-	/** The attributes of this PPS object. */
-	std::map<std::string, ppsAttribute> attributes;
-};
-
-/**
- * Typedef for ppsAttribute iterator.
- */
-typedef std::map<std::string, ppsAttribute>::iterator ppsAttrIter;
-
-/**
- * Typedef for ppsAttribute const iterator.
- */
-typedef std::map<std::string, ppsAttribute>::const_iterator const_ppsAttrIter;
-
-/**
- * A pair used to insert attributes into the map.
- */
-typedef std::pair<std::string, ppsAttribute> ppsAttrPair;
-
-/**
- * This is the definition of the notify function clients of PPSInterface use in order
- * to be informed of events the PPSInterface generates.
- *
- * @param pArg A user defined parameter. This value can be passed in to PPSInterface::setEventFunc()
- * and will be passed back with the event handler every time it is called. PPSInterface will not
- * modify this value.
- *
- * @aparam event The PPS event being broadcast.
- */
-typedef void (PPSEventFunc)(void* pArg, const PPSEvent& event);
-
-};
-
-#endif /* PPSTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
deleted file mode 100644
index 9b5d711..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSPlugin.h"
-
-#include <string>
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSPlugin::CLASS_NAME = "PPS";
-const std::string JPPSPlugin::METHOD_OPEN = "Open";
-const std::string JPPSPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSPlugin::METHOD_WRITE = "Write";
-const std::string JPPSPlugin::METHOD_READ = "Read";
-const std::string JPPSPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-
-JPPSPlugin::JPPSPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsInterface()
-{
-	// We only have one event handler, we'll use it for all events
-	m_ppsInterface.callbackInit(this,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent);
-}
-
-JPPSPlugin::~JPPSPlugin()
-{
-
-}
-
-std::string JPPSPlugin::InvokeMethod(const std::string& strCommand)
-{
-	// Parameter sanity check
-	if (strCommand == "")
-		return std::string(szERROR) + " JPPSPlugin::InvokeMethod() called with no method to invoke.";
-
-	// Tokenize the stream of input information
-	std::stringstream args(strCommand);
-	std::string method;
-	args >> method;
-
-	// Invoke the method requested
-	if (method == JPPSPlugin::METHOD_WRITE) {
-		return write(args);
-	}
-	else if (method == JPPSPlugin::METHOD_READ) {
-		return read();
-	}
-	else if (method == JPPSPlugin::METHOD_OPEN) {
-		return open(args);
-	}
-	else if (method == JPPSPlugin::METHOD_CLOSE) {
-		return close();
-	}
-	else if (method == JPPSPlugin::METHOD_SET_VERBOSE) {
-		return setVerbose(args);
-	}
-
-	return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSPlugin::open(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the path
-	std::string path;
-	args >> path;
-
-	// Missing argument
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
-	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
-	int oflags = 0;
-	args >> oflags;
-
-	bool bRet = m_ppsInterface.open(path, oflags);
-
-	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSPlugin::close()
-{
-	m_ppsInterface.close();
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::write(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::write() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the initial whitespace that was between the method name and the parameter
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsInterface.write(tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::read() const
-{
-	return std::string(szOK) + m_ppsInterface.read();
-}
-
-std::string JPPSPlugin::setVerbose(std::stringstream& args)
-{
-	unsigned short verbosity = 0;
-
-	// If no param was passed, default to 0, else read the value
-	if (!args.eof())
-		args >> verbosity;
-
-	m_ppsInterface.setVerbose(verbosity);
-	return szOK;
-}
-
-void JPPSPlugin::onEvent(const std::string& sEvent) const
-{
-	// We have to add our object Id to the event
-	std::string pluginEvent = m_jnextObjId + " " + sEvent;
-	SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
-	// Cast pArg back to JPPSPlugin and invoke onEvent()
-	JPPSPlugin* pPlugin = static_cast<JPPSPlugin*>(pArg);
-
-	if (pPlugin != NULL)
-		pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
deleted file mode 100644
index 1a56ab2..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSPLUGIN_H_
-#define JPPSPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSInterfaceGlue.h"
-
-namespace jpps {
-
-/**
- * JPPSPlugin is a JNext extension which provides PPS support to JavaScript.
- * This class is merely a wrapper for PPSInterfaceGlue, providing the necessary
- * JNext interface and performing string-parameter encoding and decoding.
- *
- * The intention is that this class will be replaced with a different plug-in framework.
- */
-class JPPSPlugin : public JSExt {
-
-public:
-
-	// Constants
-
-	/** The only class supported by this plugin. */
-	static const char* CLASS_NAME;
-
-	// List of object methods supported by this extension
-
-	/** Open a PPS object/directory. */
-	static const std::string METHOD_OPEN;
-	/** Close a PPS object/directory. */
-	static const std::string METHOD_CLOSE;
-	/** Write a PPS object. */
-	static const std::string METHOD_WRITE;
-	/** Read a PPS object. */
-	static const std::string METHOD_READ;
-	/** Adjust output verbosity. */
-	static const std::string METHOD_SET_VERBOSE;
-
-	/**
-	 * Constructor.
-	 */
-	JPPSPlugin(const std::string& jnextObjectId);
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~JPPSPlugin();
-
-	// Inherited from JSExt
-	virtual std::string InvokeMethod(const std::string& strCommand);
-	virtual inline bool CanDelete(void) { return true; }
-
-	/**
-	 *  Static callback method, changes pArg back into a JPPSPlugin and invokes
-	 *  the non-static version of onEvent().
-	 */
-	static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
-	// Disable the default constructor
-	JPPSPlugin();
-
-	/**
-	 * The non-static version of onEvent. Handler for the PPSInterfaceGlue class' events.
-	 */
-	void onEvent(const std::string& sEvent) const;
-
-	/**
-	 * Open a PPS object.
-	 */
-	std::string open(std::stringstream& args);
-
-	/**
-	 * Close the PPS object.
-	 */
-	std::string close();
-
-	/**
-	 * Write data to the PPS object.
-	 */
-	std::string write(std::stringstream& args);
-
-	/**
-	 * Read the cached PPS data from the last read.
-	 */
-	std::string read() const;
-
-	/**
-	 * Set the verbosity level for logging to slog.
-	 */
-	std::string setVerbose(std::stringstream& args);
-
-	/** A unique JNext id for this object */
-	std::string m_jnextObjId;
-
-	/** The PPS object. */
-	PPSInterfaceGlue m_ppsInterface;
-};
-
-} /* namespace jpps */
-#endif /* JPPSPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
deleted file mode 100644
index 6c3bc2d..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSServerPlugin.h"
-
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSServerPlugin::CLASS_NAME = "PPSServer";
-
-const std::string JPPSServerPlugin::METHOD_OPEN = "Open";
-const std::string JPPSServerPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSServerPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-const std::string JPPSServerPlugin::METHOD_SEND_MESSAGE = "SendMessage";
-const std::string JPPSServerPlugin::METHOD_BROADCAST_MESSAGE = "BroadcastMessage";
-
-JPPSServerPlugin::JPPSServerPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsServer()
-{
-	m_ppsServer.callbackInit(this,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent);
-}
-
-JPPSServerPlugin::~JPPSServerPlugin()
-{
-}
-
-std::string JPPSServerPlugin::InvokeMethod(const std::string& strCommand)
-{
-	// Parameter sanity check
-	if (strCommand == "")
-		return std::string(szERROR) + " JPPSServerPlugin::InvokeMethod() called with no method to invoke.";
-
-	// Tokenize the stream of input information
-	std::stringstream args(strCommand);
-	std::string method;
-	args >> method;
-
-	// Invoke the method requested
-	if (method == JPPSServerPlugin::METHOD_OPEN) {
-		return open(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_CLOSE) {
-		return close();
-	}
-	else if (method == JPPSServerPlugin::METHOD_SET_VERBOSE) {
-		return setVerbose(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_SEND_MESSAGE) {
-		return sendMessage(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_BROADCAST_MESSAGE) {
-		return broadcastMessage(args);
-	}
-
-	return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSServerPlugin::open(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the path
-	std::string path;
-	args >> path;
-
-	// Missing argument
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
-	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
-	int oflags = 0;
-	args >> oflags;
-
-	bool bRet = m_ppsServer.open(path, oflags);
-
-	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSServerPlugin::close()
-{
-	m_ppsServer.close();
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::setVerbose(std::stringstream& args)
-{
-	unsigned short verbosity = 0;
-
-	// If no param was passed, default to 0, else read the value
-	if (!args.eof())
-		args >> verbosity;
-
-	m_ppsServer.setVerbose(verbosity);
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::sendMessage(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the clientId
-	std::string clientId;
-	args >> clientId;
-
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the clientID and the message
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsServer.sendMessage(clientId, tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::broadcastMessage(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::broadcastMessage() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the method name and the message
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsServer.broadcastMessage(tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-void JPPSServerPlugin::onEvent(const std::string& sEvent) const
-{
-	// We have to add our object Id to the event
-	std::string pluginEvent = m_jnextObjId + " " + sEvent;
-	SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSServerPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
-	// Cast pArg back to JPPSPlugin and invoke onEvent()
-	JPPSServerPlugin* pPlugin = static_cast<JPPSServerPlugin*>(pArg);
-
-	if (pPlugin != NULL)
-		pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
deleted file mode 100644
index ea5b18f..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSSERVERPLUGIN_H_
-#define JPPSSERVERPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSServerGlue.h"
-
-namespace jpps {
-
-class JPPSServerPlugin: public JSExt {
-
-public:
-
-	// Constants
-
-	/** The only class supported by this plugin. */
-	static const char* CLASS_NAME;
-
-	// List of object methods supported by this extension
-
-	/** Open a PPS object/directory. */
-	static const std::string METHOD_OPEN;
-	/** Close a PPS object/directory. */
-	static const std::string METHOD_CLOSE;
-	/** Adjust output verbosity. */
-	static const std::string METHOD_SET_VERBOSE;
-	/** Send a message to a particular client. */
-	static const std::string METHOD_SEND_MESSAGE;
-	/** Send a message to all clients. */
-	static const std::string METHOD_BROADCAST_MESSAGE;
-
-	/**
-	 * Constructor.
-	 */
-	JPPSServerPlugin(const std::string& jnextObjectId);
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~JPPSServerPlugin();
-
-	// Inherited from JSExt
-	virtual std::string InvokeMethod(const std::string& strCommand);
-	virtual inline bool CanDelete(void) { return true; }
-
-	/**
-	 *  Static callback method, changes pArg back into a JPPSServerPlugin and invokes
-	 *  the non-static version of onEvent().
-	 */
-	static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
-	// Disable default constructor.
-	JPPSServerPlugin();
-
-	/**
-	 * The non-static version of onEvent. Handler for the PPSServerGlue class' events.
-	 */
-	void onEvent(const std::string& sEvent) const;
-
-	/**
-	 * Open a PPS object.
-	 */
-	std::string open(std::stringstream& args);
-
-	/**
-	 * Close the PPS object.
-	 */
-	std::string close();
-
-	/**
-	 * Set the verbosity level for logging to slog.
-	 */
-	std::string setVerbose(std::stringstream& args);
-
-	/**
-	 * Send a message to a particular client.
-	 */
-	std::string sendMessage(std::stringstream& args);
-
-	/**
-	 * Send a message to all clients.
-	 */
-	std::string broadcastMessage(std::stringstream& args);
-
-	/** A unique JNext id for this object */
-	std::string m_jnextObjId;
-
-	/** The PPS object. */
-	PPSServerGlue m_ppsServer;
-};
-
-} /* namespace jpps */
-#endif /* JPPSSERVERPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
deleted file mode 100644
index 83616b8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSInterfaceGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <vector>
-#include <sstream>
-
-#include <ppsparse.h>
-
-#include "../core/PPSEvent.h"
-
-namespace jpps {
-
-const std::string PPSInterfaceGlue::EVENT_OPEN = "ppsOpened";
-const std::string PPSInterfaceGlue::EVENT_OPEN_FAILED = "ppsOpenFailed";
-const std::string PPSInterfaceGlue::EVENT_FIRST_READ = "ppsFirstRead";
-const std::string PPSInterfaceGlue::EVENT_NEW_DATA = "OnChange";//"ppsNewData";
-const std::string PPSInterfaceGlue::EVENT_CLOSE = "ppsClosed";
-const std::string PPSInterfaceGlue::EVENT_WRITE_FAILED = "ppsWriteFailed";
-const std::string PPSInterfaceGlue::EVENT_READ_FAILED = "ppsReadFailed";
-
-const std::string PPSInterfaceGlue::ENCODING_N = "n";
-const std::string PPSInterfaceGlue::ENCODING_B = "b";
-const std::string PPSInterfaceGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSInterfaceGlue::JSON_REMOVE("remove");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGED("changed");
-const Json::StaticString PPSInterfaceGlue::JSON_DATA("data");
-const Json::StaticString PPSInterfaceGlue::JSON_OBJNAME("objName");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGE_DATA("changeData");
-const Json::StaticString PPSInterfaceGlue::JSON_ALL_DATA("allData");
-
-
-PPSInterfaceGlue::PPSInterfaceGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleFirstRead(NULL)
-, m_handleNewData(NULL)
-, m_handleClose(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleWriteFailed(NULL)
-, m_handleReadFailed(NULL)
-{
-	m_interface.setEventFunc(onEvent, this);
-}
-
-PPSInterfaceGlue::~PPSInterfaceGlue()
-{
-	m_interface.setEventFunc(NULL);
-}
-
-void PPSInterfaceGlue::callbackInit(void* pArg,
-								    callback* handleOpen,
-								    callback* handleFirstRead,
-								    callback* handleNewData,
-								    callback* handleClose,
-								    callback* handleOpenFailed,
-								    callback* handleWriteFailed,
-								    callback* handleReadFailed)
-{
-	m_pArg = pArg;
-	m_handleOpen = handleOpen;
-	m_handleFirstRead = handleFirstRead;
-	m_handleNewData = handleNewData;
-	m_handleClose = handleClose;
-	m_handleOpenFailed = handleOpenFailed;
-	m_handleWriteFailed = handleWriteFailed;
-	m_handleReadFailed = handleReadFailed;
-}
-
-void PPSInterfaceGlue::setVerbose(unsigned short v)
-{
-	m_interface.setVerbose(v);
-}
-
-bool PPSInterfaceGlue::open(const std::string& path, int oflags)
-{
-	// We don't expose the "mode" to the JS layer - always create in 0666 mode
-	return m_interface.open(path, oflags, 0666, false);
-}
-
-void PPSInterfaceGlue::close()
-{
-	m_interface.close();
-}
-
-void PPSInterfaceGlue::sync()
-{
-	m_interface.sync();
-}
-
-void PPSInterfaceGlue::onEvent(void* pArg, const PPSEvent& event)
-{
-	PPSInterfaceGlue* pGlue = static_cast<PPSInterfaceGlue*>(pArg);
-
-	if (pGlue != NULL)
-		pGlue->onEvent(event);
-}
-
-void PPSInterfaceGlue::onEvent(const PPSEvent& event)
-{
-	callback* pFunc = NULL;
-	std::string sArg;
-
-	switch (event.getEventType()) {
-
-	case PPSEvent::PPS_EVENT_OPENED:
-		pFunc = m_handleOpen;
-		sArg = EVENT_OPEN;
-		break;
-
-	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
-		pFunc = m_handleFirstRead;
-		sArg = EVENT_FIRST_READ + " " + handleNewData(event.getNewData());
-		break;
-
-	case PPSEvent::PPS_EVENT_NEW_DATA:
-		pFunc = m_handleNewData;
-		sArg = EVENT_NEW_DATA + " " + handleNewData(event.getNewData());
-		break;
-
-	case PPSEvent::PPS_EVENT_CLOSED:
-		pFunc = m_handleClose;
-		sArg = EVENT_CLOSE;
-		break;
-
-	case PPSEvent::PPS_EVENT_OPEN_FAILED:
-		pFunc = m_handleOpenFailed;
-		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_WRITE_FAILED:
-		pFunc = m_handleWriteFailed;
-		sArg = EVENT_WRITE_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_READ_FAILED:
-		pFunc = m_handleReadFailed;
-		sArg = EVENT_READ_FAILED + " " + event.getMessage();
-		break;
-	}
-
-	if (pFunc != NULL)
-		pFunc(m_pArg, sArg);
-}
-
-std::string PPSInterfaceGlue::handleNewData(const ppsObject& newData)
-{
-	Json::Value data(Json::nullValue);
-	data[JSON_CHANGE_DATA] = JSONEncodeNewData(newData);
-	data[JSON_ALL_DATA] = JSONEncodeRead(m_interface.read());
-
-	Json::FastWriter writer;
-	return writer.write(data);
-}
-
-std::string PPSInterfaceGlue::read() const
-{
-	Json::Value data = JSONEncodeRead(m_interface.read());
-	Json::FastWriter writer;
-	return writer.write(data);
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeRead(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value readData(Json::nullValue);
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// An attribute was deleted: update the JSON data structure and the event data
-		if (ppsAttrib.flags & PPS_DELETED) {
-
-			readData.removeMember(ppsAttrib.name);
-		}
-		else {
-
-			// The value is a number
-			if (ppsAttrib.encoding == ENCODING_N) {
-
-				// Convert the value to floating point
-				// istringstream is locale aware - we shouldn't need to perform any special
-				// processing in order to properly convert the data to a floating point
-				// TODO: test that the istringstream conversion works with a locale
-				//       that uses alternate floating point number encoding
-				std::istringstream stream(ppsAttrib.value);
-				double doubleValue;
-
-				// Try to convert the value to a floating point
-				if (!(stream >> doubleValue)) {
-
-					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-					m_handleReadFailed(m_pArg, err);
-					return "";
-				}
-
-				readData[ppsAttrib.name] = doubleValue;
-			}
-			// The value is a boolean
-			else if (ppsAttrib.encoding == ENCODING_B) {
-
-				readData[ppsAttrib.name] = (ppsAttrib.value == "true");
-			}
-			// The value is JSON data
-			else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-				Json::Reader reader;
-				reader.parse(ppsAttrib.value, readData[ppsAttrib.name]);
-			}
-			// Just pass the value through as a straight string
-			else {
-
-				readData[ppsAttrib.name] = ppsAttrib.value;
-			}
-		}
-	}
-
-	return readData;
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeNewData(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value eventData(Json::nullValue);
-
-	// Set the PPS object name
-	eventData[JSON_OBJNAME] = ppsObj.name.substr(1); // PR 159829 : Remove the pre-pending '@' symbol
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// An attribute was deleted: update the JSON data structure and the event data
-		if (ppsAttrib.flags & PPS_DELETED) {
-
-			eventData[JSON_REMOVE][ppsAttrib.name] = true;
-		}
-		else {
-
-			eventData[JSON_CHANGED][ppsAttrib.name] = true;
-
-			// The value is a number
-			if (ppsAttrib.encoding == ENCODING_N) {
-
-				// Convert the value to floating point
-				// istringstream is locale aware - we shouldn't need to perform any special
-				// processing in order to properly convert the data to a floating point
-				// TODO: test that the istringstream conversion works with a locale
-				//       that uses alternate floating point number encoding
-				std::istringstream stream(ppsAttrib.value);
-				double doubleValue;
-
-				// Try to convert the value to a floating point
-				if (!(stream >> doubleValue)) {
-
-					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-					m_handleReadFailed(m_pArg, err);
-					return "";
-				}
-
-				eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
-			}
-			// The value is a boolean
-			else if (ppsAttrib.encoding == ENCODING_B) {
-
-				eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
-			}
-			// The value is JSON data
-			else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-				Json::Reader reader;
-				reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
-			}
-			// Just pass the value through as a straight string
-			else {
-
-				eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
-			}
-		}
-	}
-
-	return eventData;
-}
-
-void PPSInterfaceGlue::write(const std::string& data)
-{
-    Json::Reader reader;
-    Json::Value root;
-
-	bool parsingSuccessful = reader.parse(data, root);
-
-    // If parsing the JSON string fails, return a write error
-    if (!parsingSuccessful) {
-
-    	std::string err = EVENT_WRITE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
-        m_handleWriteFailed(m_pArg, err);
-        return;
-    }
-
-	Json::Value::Members memberNames = root.getMemberNames();
-
-	std::ostringstream output;
-	output.precision(15);
-
-	Json::Value member;
-
-	for (unsigned int i = 0; i < memberNames.size(); i++) {
-
-		output << memberNames[i] << ":";
-		member = root[memberNames[i]];
-
-		if (member.isObject() || member.isArray()) {
-
-			Json::FastWriter writer;
-			output << ENCODING_JSON << ":" << writer.write(member); // write() adds an \n
-		}
-		else if (member.isBool()) {
-
-			output << ENCODING_B << ":" << member.asString() << std::endl;
-		}
-		else if (member.isNumeric()) {
-
-			output << ENCODING_N << ":" << member.asDouble() << std::endl;
-		}
-		else if (member.isString()) {
-
-			output << ":" << member.asString() << std::endl;
-		}
-		else {
-
-			std::string err = EVENT_WRITE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
-			m_handleWriteFailed(m_pArg, err);
-			return;
-		}
-	}
-
-	m_interface.write(output.str());
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
deleted file mode 100644
index fafbacd..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSINTERFACEGLUE_H_
-#define PPSINTERFACEGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-#include <json/value.h>
-
-#include <string>
-
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * This class bridges JavaScript and the native PPSInterface code.
- */
-class PPSInterfaceGlue {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSInterfaceGlue();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSInterfaceGlue();
-
-	/**
-	 * The browser plugin should set these handlers.
-	 *
-	 * @param pArg pArg will be passed back to each callback function when it is called.
-	 */
-	void callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleFirstRead,
-					  callback* handleNewData,
-					  callback* handleClose,
-					  callback* handleOpenFailed,
-					  callback* handleWriteFailed,
-					  callback* handleReadFailed);
-
-	/**
-	 * Set the verbosity of logging to the slog.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS object.
-	 */
-	bool open(const std::string& path, int oflags);
-
-	/**
-	 * Write to a PPS object.
-	 */
-	void write(const std::string& data);
-
-	/**
-	 * Read from the PPS object. This actually returns the cached value of the last
-	 * onNewData event from PPSInteraface, then encodes it as JSON.
-	 */
-	std::string read() const;
-
-	/**
-	 * Close this PPS object.
-	 */
-	void close();
-
-	/**
-	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
-	 * The function blocks until this is finished.
-	 */
-	void sync();
-
-	/**
-	 * The function that the PPSInterface will call when an event happens.
-	 * This is the static function that is used as a function pointer for
-	 * PPSInterface::setEventFunc().
-	 *
-	 * @param event The event PPSInterface is sending.
-	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
-	 * object construction.
-	 */
-	static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
-	/**
-	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
-	 */
-	void onEvent(const PPSEvent& event);
-
-	/**
-	 * Handle a new data event.
-	 */
-	std::string handleNewData(const ppsObject& newData);
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * with a new data event. This structures the JSON with changed properties and the
-	 * data that has changed.
-	 */
-	Json::Value JSONEncodeNewData(const ppsObject& ppsObj) const;
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * when a call to read() is made.
-	 */
-	Json::Value JSONEncodeRead(const ppsObject& ppsObj) const;
-
-	// String names for the various events
-	static const std::string EVENT_OPEN;
-	static const std::string EVENT_OPEN_FAILED;
-	static const std::string EVENT_FIRST_READ;
-	static const std::string EVENT_NEW_DATA;
-	static const std::string EVENT_CLOSE;
-	static const std::string EVENT_READ_FAILED;
-	static const std::string EVENT_WRITE_FAILED;
-
-	/** Custom PPS encoding value: an "n" means a real number. */
-	static const std::string ENCODING_N;
-	/** Custom PPS encoding value: a "b" means a boolean value. */
-	static const std::string ENCODING_B;
-	/** Custom PPS encoding value: the data is encoded using JSON. */
-	static const std::string ENCODING_JSON;
-
-	// JSON constants
-	static const Json::StaticString JSON_REMOVE;
-	static const Json::StaticString JSON_CHANGED;
-	static const Json::StaticString JSON_DATA;
-	static const Json::StaticString JSON_OBJNAME;
-	static const Json::StaticString JSON_CHANGE_DATA;
-	static const Json::StaticString JSON_ALL_DATA;
-
-	/** The interface this object wraps. */
-	PPSInterface m_interface;
-
-	// Handlers for various events
-	void* m_pArg;
-	callback* m_handleOpen;
-	callback* m_handleFirstRead;
-	callback* m_handleNewData;
-	callback* m_handleClose;
-	callback* m_handleOpenFailed;
-	callback* m_handleWriteFailed;
-	callback* m_handleReadFailed;
-};
-
-} /* namespace jpps */
-#endif /* PPSINTERFACEGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
deleted file mode 100644
index 2eb4552..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSServerGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <sstream>
-
-#include <ppsparse.h>
-#include <fcntl.h>
-
-namespace jpps {
-
-const std::string PPSServerGlue::EVENT_OPEN = "onOpen";
-const std::string PPSServerGlue::EVENT_CLOSE = "onClose";
-const std::string PPSServerGlue::EVENT_CLIENT_CONNECT = "onClientConnect";
-const std::string PPSServerGlue::EVENT_CLIENT_DISCONNECT = "onClientDisconnect";
-const std::string PPSServerGlue::EVENT_MESSAGE = "onMessage";
-const std::string PPSServerGlue::EVENT_OPEN_FAILED = "onOpenFailed";
-const std::string PPSServerGlue::EVENT_SEND_MESSAGE_FAILED = "onSendMessageFailed";
-const std::string PPSServerGlue::EVENT_RECEIVE_MESSAGE_FAILED = "onReceiveMessageFailed";
-
-const std::string PPSServerGlue::ENCODING_N = "n";
-const std::string PPSServerGlue::ENCODING_B = "b";
-const std::string PPSServerGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSServerGlue::JSON_DATA("data");
-const Json::StaticString PPSServerGlue::JSON_CONNECTION_ID("clientId");
-
-PPSServerGlue::PPSServerGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleClose(NULL)
-, m_handleClientConnect(NULL)
-, m_handleClientDisconnect(NULL)
-, m_handleMessage(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleSendMessageFailed(NULL)
-, m_handleReceiveMessageFailed(NULL)
-{
-	m_interface.setEventFunc(onEvent, this);
-}
-
-PPSServerGlue::~PPSServerGlue()
-{
-	m_interface.setEventFunc(NULL);
-}
-
-void PPSServerGlue::callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleClose,
-					  callback* handleClientConnect,
-					  callback* handleClientDisconnect,
-					  callback* handleMessage,
-					  callback* handleOpenFailed,
-					  callback* handleSendMessageFailed,
-					  callback* handleReceiveMessageFailed)
-{
-	m_pArg = pArg;
-	m_handleOpen = handleOpen;
-	m_handleClose = handleClose;
-	m_handleClientConnect = handleClientConnect;
-	m_handleClientDisconnect = handleClientDisconnect;
-	m_handleMessage = handleMessage;
-	m_handleOpenFailed = handleOpenFailed;
-	m_handleSendMessageFailed = handleSendMessageFailed;
-	m_handleReceiveMessageFailed = handleReceiveMessageFailed;
-}
-
-
-void PPSServerGlue::setVerbose(unsigned short v)
-{
-	m_interface.setVerbose(v);
-}
-
-bool PPSServerGlue::open(const std::string& path, int oflags)
-{
-	// Make sure we're creating the server, if it doesn't exist
-	if (!(oflags & O_CREAT))
-		oflags &= O_CREAT;
-
-	// We don't expose the "mode" to the JS layer - always create in 0666 mode
-	return m_interface.open(path, oflags, 0666, true);
-}
-
-void PPSServerGlue::close()
-{
-	m_interface.close();
-}
-
-void PPSServerGlue::sendMessage(const std::string& clientID, const std::string& msg)
-{
-	std::string decodedMsg = JSONDecodeData(msg);
-	std::string message(clientID + "\n" + decodedMsg);
-	m_interface.write(message);
-}
-
-void PPSServerGlue::broadcastMessage(const std::string& msg)
-{
-	m_interface.write(JSONDecodeData(msg));
-}
-
-void PPSServerGlue::onEvent(void* pArg, const PPSEvent& event)
-{
-	PPSServerGlue* pGlue = static_cast<PPSServerGlue*>(pArg);
-
-	if (pGlue != NULL)
-		pGlue->onEvent(event);
-}
-
-void PPSServerGlue::onEvent(const PPSEvent& event)
-{
-	callback* pFunc = NULL;
-	std::string sArg;
-
-	switch (event.getEventType()) {
-
-	case PPSEvent::PPS_EVENT_OPENED:
-		pFunc = m_handleOpen;
-		sArg = EVENT_OPEN;
-		break;
-
-	// The server doesn't do anything with this event
-	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
-		break;
-
-	case PPSEvent::PPS_EVENT_NEW_DATA:
-	{
-		ppsObject data(event.getNewData());
-
-		// This means a new connection
-		if (data.flags & PPS_CREATED) {
-			sArg = EVENT_CLIENT_CONNECT;
-			pFunc = m_handleClientConnect;
-		}
-		// This means a connection is closed
-		else if (data.flags & PPS_DELETED) {
-			sArg = EVENT_CLIENT_DISCONNECT;
-			pFunc = m_handleClientDisconnect;
-		}
-		// We're getting data from the connection
-		else {
-			sArg = EVENT_MESSAGE;
-			pFunc = m_handleMessage;
-		}
-
-		sArg += " " + JSONEncodeData(data);
-
-		break;
-	}
-
-	case PPSEvent::PPS_EVENT_CLOSED:
-		pFunc = m_handleClose;
-		sArg = EVENT_CLOSE;
-		break;
-
-	case PPSEvent::PPS_EVENT_OPEN_FAILED:
-		pFunc = m_handleOpenFailed;
-		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_WRITE_FAILED:
-		pFunc = m_handleSendMessageFailed;
-		sArg = EVENT_SEND_MESSAGE_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_READ_FAILED:
-		pFunc = m_handleReceiveMessageFailed;
-		sArg = EVENT_RECEIVE_MESSAGE_FAILED + event.getMessage();
-		break;
-	}
-
-	if (pFunc != NULL)
-		pFunc(m_pArg, sArg);
-
-}
-
-std::string PPSServerGlue::JSONEncodeData(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value eventData(Json::nullValue);
-
-	// Set the client id
-	// Chop off the '+' or '-' if it's there
-	eventData[JSON_CONNECTION_ID] = ppsObj.name;
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// The value is a number
-		if (ppsAttrib.encoding == ENCODING_N) {
-
-			// Convert the value to floating point
-			// istringstream is locale aware - we shouldn't need to perform any special
-			// processing in order to properly convert the data to a floating point
-			// TODO: test that the istringstream conversion works with a locale
-			//       that uses alternate floating point number encoding
-			std::istringstream stream(ppsAttrib.value);
-			double doubleValue;
-
-			// Try to convert the value to a floating point
-			if (!(stream >> doubleValue)) {
-
-				std::string err = EVENT_RECEIVE_MESSAGE_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-				m_handleReceiveMessageFailed(m_pArg, err);
-				return "";
-			}
-
-			eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
-		}
-		// The value is a boolean
-		else if (ppsAttrib.encoding == ENCODING_B) {
-
-			eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
-		}
-		// The value is JSON data
-		else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-			Json::Reader reader;
-			reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
-		}
-		// Just pass the value through as a straight string
-		else {
-
-			eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
-		}
-	}
-
-	Json::FastWriter writer;
-	return writer.write(eventData);
-}
-
-std::string PPSServerGlue::JSONDecodeData(const std::string& data) const
-{
-	 Json::Reader reader;
-	Json::Value root;
-
-	bool parsingSuccessful = reader.parse(data, root);
-
-	// If parsing the JSON string fails, return a write error
-	if (!parsingSuccessful) {
-
-		std::string err = EVENT_SEND_MESSAGE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
-		m_handleSendMessageFailed(m_pArg, err);
-		return "";
-	}
-
-	Json::Value::Members memberNames = root.getMemberNames();
-
-	std::ostringstream output;
-	output.precision(15);
-
-	Json::Value member;
-
-	for (unsigned int i = 0; i < memberNames.size(); i++) {
-
-		output << memberNames[i] << ":";
-		member = root[memberNames[i]];
-
-		if (member.isObject() || member.isArray()) {
-
-			Json::FastWriter writer;
-			output << ENCODING_JSON << ":" << writer.write(member);
-		}
-		else if (member.isBool()) {
-
-			output << ENCODING_B << ":" << member.asString();
-		}
-		else if (member.isNumeric()) {
-
-			output << ENCODING_N << ":" << member.asDouble();
-		}
-		else if (member.isString()) {
-
-			output << ":" << member.asString();
-		}
-		else {
-
-			std::string err = EVENT_SEND_MESSAGE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
-			m_handleSendMessageFailed(m_pArg, err);
-			return "";
-		}
-
-		// Make sure we terminate the line
-		output << std::endl;
-	}
-
-	return output.str();
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
deleted file mode 100644
index 8891829..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSSERVERGLUE_H_
-#define PPSSERVERGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-// Forward declaration
-namespace Json {
-class StaticString;
-}
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * Act as glue between jpps Server class an the PPSInterface.
- * This class encapsulates a PPS object as a PPS server.
- * TODO: write a better comment
- */
-class PPSServerGlue {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSServerGlue();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSServerGlue();
-
-	/**
-	 * The browser plugin should set these handlers.
-	 *
-	 * @param pArg pArg will be passed back to each callback function when it is called.
-	 */
-	void callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleClose,
-					  callback* handleClientConnect,
-					  callback* handleClientDisconnect,
-					  callback* handleMessage,
-					  callback* handleOpenFailed,
-					  callback* handleSendMessageFailed,
-					  callback* handleReceiveMessageFailed);
-
-	/**
-	 * Set the verbosity of logging to the slog.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS server object.
-	 */
-	bool open(const std::string& path, int oflags);
-
-	/**
-	 * Close this PPS server object.
-	 */
-	void close();
-
-	/**
-	 * Send a message to a particular client.
-	 */
-	void sendMessage(const std::string& clientID, const std::string& msg);
-
-	/**
-	 * Send a message to all clients.
-	 */
-	void broadcastMessage(const std::string& msg);
-
-	/**
-	 * The function that the PPSInterface will call when an event happens.
-	 * This is the static function that is used as a function pointer for
-	 * PPSInterface::setEventFunc().
-	 *
-	 * @param event The event PPSInterface is sending.
-	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
-	 * object construction.
-	 */
-	static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
-	/**
-	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
-	 */
-	void onEvent(const PPSEvent& event);
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * with a onMessage event.
-	 */
-	std::string JSONEncodeData(const ppsObject& ppsObj) const;
-
-	/**
-	 * Take a JSON string and change it into a PPS consumable string.
-	 */
-	std::string JSONDecodeData(const std::string& data) const;
-
-	// String names for the various events
-	static const std::string EVENT_OPEN;
-	static const std::string EVENT_CLOSE;
-	static const std::string EVENT_CLIENT_CONNECT;
-	static const std::string EVENT_CLIENT_DISCONNECT;
-	static const std::string EVENT_MESSAGE;
-	static const std::string EVENT_OPEN_FAILED;
-	static const std::string EVENT_SEND_MESSAGE_FAILED;
-	static const std::string EVENT_RECEIVE_MESSAGE_FAILED;
-
-	/** Custom PPS encoding value: an "n" means a real number. */
-	static const std::string ENCODING_N;
-	/** Custom PPS encoding value: a "b" means a boolean value. */
-	static const std::string ENCODING_B;
-	/** Custom PPS encoding value: the data is encoded using JSON. */
-	static const std::string ENCODING_JSON;
-
-	// JSON constants
-	static const Json::StaticString JSON_DATA;
-	static const Json::StaticString JSON_CONNECTION_ID;
-
-	/** The interface this object wraps. */
-	PPSInterface m_interface;
-
-	// Handlers for various events
-	void* m_pArg;
-	callback* m_handleOpen;
-	callback* m_handleClose;
-	callback* m_handleClientConnect;
-	callback* m_handleClientDisconnect;
-	callback* m_handleMessage;
-	callback* m_handleOpenFailed;
-	callback* m_handleSendMessageFailed;
-	callback* m_handleReceiveMessageFailed;
-
-};
-
-} /* namespace jpps */
-#endif /* PPSSERVERGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
deleted file mode 100644
index 9ce6b32..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PLUGINTYPES_H_
-#define PLUGINTYPES_H_
-
-namespace jpps {
-
-/**
- * Function type for setting handles between JNext plug-in and glue classes.
- */
-typedef void (callback)(void* pArg, const std::string&);
-
-}
-
-
-#endif /* PLUGINTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
deleted file mode 100644
index e06ad4c..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#include "JPPSPlugin.h"
-#include "JPPSServerPlugin.h"
-
-#include <string>
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @return A comma separated list of classes supported by this JNEXT extension
- */
-char* onGetObjList(void)
-{
-	static char* ppsclasses = NULL;
-
-	if (ppsclasses == NULL) {
-
-		// Get the length of all the strings, +1 for the ',' +1 for the \0
-		int size = std::strlen(jpps::JPPSPlugin::CLASS_NAME) + std::strlen(jpps::JPPSServerPlugin::CLASS_NAME) + 1 + 1;
-		ppsclasses = new char[size];
-		std::strcpy(ppsclasses, jpps::JPPSPlugin::CLASS_NAME);
-		std::strcat(ppsclasses, ",");
-		std::strcat(ppsclasses, jpps::JPPSServerPlugin::CLASS_NAME);
-		ppsclasses[size] = '\0';
-	}
-    // Return a comma separated list of classes known to this plugin
-    return ppsclasses;
-}
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @param strClassName Name of the class requested to be created Valid named are those
- * that are returned in onGetObjList
- *
- * @param strObjId The unique object id for the class
- *
- * @return A pointer to the created extension object
- */
-JSExt* onCreateObject(const std::string& strClassName, const std::string& strObjId)
-{
-    // Given a class name and identifier, create the relevant object.
-    if (strClassName == jpps::JPPSPlugin::CLASS_NAME) {
-        return new jpps::JPPSPlugin(strObjId);;
-    }
-    else if (strClassName == jpps::JPPSServerPlugin::CLASS_NAME) {
-    	return new jpps::JPPSServerPlugin(strObjId);
-    }
-
-    // Any other name is invalid
-    return NULL;
-}
-
-

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
deleted file mode 100644
index 37a9d17..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef LOGGER_H_
-#define LOGGER_H_
-
-#include <string>
-
-#include <sys/slog.h>
-#include <sys/slogcodes.h>
-
-namespace jpps {
-
-/**
- * The Logger class writes messages to the system log. It has a verbosity setting
- * in order to prevent cluttering the slog during normal operation.
- */
-class Logger {
-
-public:
-
-	enum slogType {
-		info = _SLOG_INFO,
-		warning = _SLOG_WARNING,
-		error = _SLOG_ERROR,
-		critical = _SLOG_CRITICAL,
-		debug = _SLOG_DEBUG1
-	};
-
-	/**
-	 * Default constructor. Sets the verbosity to 0;
-	 */
-	Logger() : m_verbosity(0) {}
-
-	/**
-	 * Destructor.
-	 */
-	~Logger() {}
-
-	/**
-	 * Set the desired level of verbosity. A value of 0 means that only warning,
-	 * error and critical messages will appear in the slog. A verbosity of 1 adds
-	 * info messages. A verbosity of 2 adds debug messages.
-	 */
-	inline void setVerbosity(unsigned short value) { m_verbosity = value; }
-
-	/**
-	 * Get the current level of verbosity.
-	 */
-	inline unsigned short getVerbosity() const { return m_verbosity; }
-
-	/**
-	 * Used to send messages to the system log (slog).
-	 *
-	 * @param type The type of slog message.
-	 * @param message The message to put in the slog.
-	 */
-	void slog(const slogType& type, const std::string& message) const {
-
-		// Don't display info or debug when verbosity is set to 0
-		if (m_verbosity == 0 && (type == info || type == debug)) return;
-		// Don't display debug when verbosity is set to 1
-		if (m_verbosity == 1 && type == debug) return;
-
-		::slogf(_SLOG_SETCODE(_SLOGC_GRAPHICS, 300), type, "%s", message.c_str());
-	}
-
-private:
-
-	/** The verbosity level.  */
-	unsigned short m_verbosity;
-};
-
-}
-
-#endif /* LOGGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
deleted file mode 100644
index 82ab5d1..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "Thread.h"
-#include <pthread.h>
-#include "Logger.h"
-#include <sstream>
-#include <string.h>
-#include <errno.h>
-
-namespace jpps {
-
-Thread::Thread()
-: m_threadID(-1)
-{
-	// Init the thread with all defaults
-	pthread_attr_init(&m_attrib);
-}
-
-Thread::~Thread()
-{
-	// Dispose of the thread attributes
-	pthread_attr_destroy(&m_attrib);
-}
-
-void Thread::start(void* (*start_routine)(void*), void* arg, const std::string& thread_name)
-{
-	// If this thread is already started, you can't start a new one
-	if (m_threadID != -1) {
-		return;
-	}
-
-	// Create a new thread
-	if (pthread_create(&m_threadID, &m_attrib, start_routine, arg) != 0) {
-
-		std::ostringstream ostream;
-		ostream << "Thread::start() Failed - Failed to create a new thread. "
-				<< " (" << errno << ": " << strerror(errno) << ")";
-
-		Logger logger;
-		logger.slog(Logger::warning, ostream.str());
-	}
-
-	if (!thread_name.empty())
-		pthread_setname_np(m_threadID, thread_name.c_str());
-}
-
-void Thread::stop()
-{
-	// If the thread wasn't running, we can't stop it
-	if (m_threadID == -1) {
-		return;
-	}
-
-	// Cancel the thread
-	if (pthread_cancel(m_threadID) != 0) {
-
-		std::ostringstream ostream;
-		ostream << "Thread::stop() Failed - Failed to cancel thread " << m_threadID << "."
-				<< " (" << errno << ": " << strerror(errno) << ")";
-
-		Logger logger;
-		logger.slog(Logger::warning, ostream.str());
-	}
-
-	// Reset the thread ID
-	m_threadID = -1;
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
deleted file mode 100644
index 79cc62a..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef THREAD_H_
-#define THREAD_H_
-
-#include <sys/types.h>
-#include <string>
-
-namespace jpps {
-
-/**
- * Simple wrapper to simplify thread management.
- */
-class Thread {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	Thread();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~Thread();
-
-	/**
-	 * Start a thread with the given function. If the thread is already running and has not
-	 * been stopped, this does nothing.
-	 */
-	void start(void* (*start_routine)(void*), void* arg, const std::string& thread_name = "");
-
-	/**
-	 * Stop the thread. If the thread isn't running, this does nothing.
-	 */
-	void stop();
-
-	/**
-	 * Is the thread running?
-	 */
-	inline bool isRunning() const { return (m_threadID >= 0); }
-
-private:
-
-	/** The id of this thread. */
-	pthread_t m_threadID;
-
-	/** The attributes of this thread. */
-	pthread_attr_t m_attrib;
-};
-
-} /* namespace jpps */
-#endif /* THREAD_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/Makefile b/blackberry10/bin/templates/project/plugins/Utils/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
new file mode 100644
index 0000000..90a43db
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
@@ -0,0 +1,18 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=utils
+LDFLAGS+=-Wl,-h,libutils.so
+
+include ../../../../../../meta.mk
+
+SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
+      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
+      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
+      webworks_utils.cpp
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+LIBS += socket

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
new file mode 100644
index 0000000..126d02c
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
new file mode 100644
index 0000000..392ad33
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
new file mode 100644
index 0000000..68397a1
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include <resolv.h>
+#include <sstream>
+#include <string>
+
+#include "webworks_utils.hpp"
+
+namespace webworks {
+
+std::string Utils::intToStr(const int val)
+{
+    std::string s;
+    std::stringstream out;
+    out << val;
+    return out.str();
+}
+
+int Utils::strToInt(const std::string& val) {
+    int number;
+
+    if (!(std::istringstream(val) >> number)) {
+        return -1;
+    }
+    return number;
+}
+
+std::string Utils::toBase64(const unsigned char *input, const size_t size)
+{
+    size_t outputSize = size * 4;
+    char *output = new char[outputSize];
+    outputSize = b64_ntop(input, size, output, outputSize);
+    output[outputSize] = 0;
+
+    std::string outputString(output);
+    delete output;
+
+    return outputString;
+}
+
+} // namespace webworks

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
new file mode 100644
index 0000000..4ab2ca7
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#ifndef WW_UTILS_HPP_
+#define WW_UTILS_HPP_
+
+#include <string.h>
+#include <string>
+
+namespace webworks {
+
+class Utils {
+public:
+    static std::string intToStr(const int val);
+    static int strToInt(const std::string& val);
+    static std::string toBase64(const unsigned char *input, const size_t size);
+};
+
+} // namespace webworks
+
+#endif // WW_UTILS_HPP_

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=CPU
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
deleted file mode 100644
index 90a43db..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-NAME=utils
-LDFLAGS+=-Wl,-h,libutils.so
-
-include ../../../../../../meta.mk
-
-SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
-      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
-      $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
-      webworks_utils.cpp
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-LIBS += socket

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
deleted file mode 100644
index 126d02c..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
deleted file mode 100644
index 392ad33..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
deleted file mode 100644
index 68397a1..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-
-#include <resolv.h>
-#include <sstream>
-#include <string>
-
-#include "webworks_utils.hpp"
-
-namespace webworks {
-
-std::string Utils::intToStr(const int val)
-{
-    std::string s;
-    std::stringstream out;
-    out << val;
-    return out.str();
-}
-
-int Utils::strToInt(const std::string& val) {
-    int number;
-
-    if (!(std::istringstream(val) >> number)) {
-        return -1;
-    }
-    return number;
-}
-
-std::string Utils::toBase64(const unsigned char *input, const size_t size)
-{
-    size_t outputSize = size * 4;
-    char *output = new char[outputSize];
-    outputSize = b64_ntop(input, size, output, outputSize);
-    output[outputSize] = 0;
-
-    std::string outputString(output);
-    delete output;
-
-    return outputString;
-}
-
-} // namespace webworks

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
deleted file mode 100644
index 4ab2ca7..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef WW_UTILS_HPP_
-#define WW_UTILS_HPP_
-
-#include <string.h>
-#include <string>
-
-namespace webworks {
-
-class Utils {
-public:
-    static std::string intToStr(const int val);
-    static int strToInt(const std::string& val);
-    static std::string toBase64(const unsigned char *input, const size_t size);
-};
-
-} // namespace webworks
-
-#endif // WW_UTILS_HPP_


[40/50] [abbrv] webworks commit: Update README.md for BlackBerry 10

Posted by lo...@apache.org.
Update README.md for BlackBerry 10


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

Branch: refs/heads/future
Commit: b707831f7c62ea053614645f44f8a660e40234e7
Parents: 2862189
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Apr 25 09:59:11 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 README.md              |    5 ++-
 blackberry10/README.md |   97 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 97 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b707831f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 8aaf204..3e2dbf1 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,10 @@
-Cordova BlackBerry
+# Apache Cordova for BlackBerry
+===
 
 This repo contains cordova projects for the BlackBerry platforms:
 
 blackberry - BBOS 5+ and Tablet OS
 
 blackberry10 - BB10
+
+Please see README files in the sub folders for more information.

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b707831f/blackberry10/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/README.md b/blackberry10/README.md
index 8aaf204..a19b87a 100644
--- a/blackberry10/README.md
+++ b/blackberry10/README.md
@@ -1,7 +1,96 @@
-Cordova BlackBerry
+# Apache Cordova for BlackBerry 10
 
-This repo contains cordova projects for the BlackBerry platforms:
+Apache Cordova is an application development platform which allows mobile applications to be written with web technology: HTML, CSS and JavaScript. Access to device APIs is provided by native plugins.
 
-blackberry - BBOS 5+ and Tablet OS
+This implementation for BlackBerry 10 packages web assets into a BAR file which may be deployed to devices and simulators.
+
+## Pre-requisites
+
+Install the latest BlackBerry 10 NDK:
+
+[https://developer.blackberry.com/native/download/](https://developer.blackberry.com/native/download)
+
+Setup environment variables:
+- [Linux/Mac] `source [BBNDK directory]/bbndk-env.sh`
+- [Windows] `[BBNDK directory]\bbndk-env.bat`
+
+Install code signing keys:
+
+[https://developer.blackberry.com/html5/documentation/signing_setup_bb10_apps_2008396_11.html](https://developer.blackberry.com/html5/documentation/signing_setup_bb10_apps_2008396_11.html)
+
+Install node.js:
+
+[http://nodejs.org/](http://nodejs.org/)
+
+## Getting Started
+
+Create a new project:
+
+`bin/create <path to project>`
+
+## Managing Targets
+
+A target is a device or simulator which will run the app.
+
+This command will add a new target: 
+
+`<path to project>/cordova/target add <name> <ip> <device | simulator> [-p | --password <password>] [--pin <devicepin>]`
+
+To remove a target:
+
+`<path to project>/cordova/target remove <name>`
+
+To set a target as default:
+
+`<path to project>/cordova/target default <name>`
+
+## Building
+
+`<path to project>/cordova/build`
+
+A project can be built in debug or release mode.
+
+To run an application in debug mode, a debug token must first be installed on the device. The build script will automatically attempt to generate a token and install it. This requires code signing keys to be installed on the development machine. Debug mode will also enable WebInspector. A prompt will appear with the URL to access WebInspector from a remote machine.
+
+If building in release mode, a unique buildId must be provided, either via command line or by setting it in config.xml.
+
+Here is the build script syntax:
+
+`build command [<target>] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]`
+
+Commands:
+
+    release [options] 
+        Build in release mode. This will sign the resulting bar.
+    
+    debug [options] 
+        Build in debug mode.
+
+  Options:
+
+    -h, --help                       output usage information
+    -k, --keystorepass <password>    Signing key password
+    -b, --buildId <num>              Specifies the build number for signing (typically incremented from previous signing).
+    -p, --params <params JSON file>  Specifies additional parameters to pass to downstream tools.
+    -ll, --loglevel <loglevel>       set the logging level (error, warn, verbose)`
+
+## Deploying
+
+To deploy the project to a target, use the run command:
+
+`<path to project>/cordova/run <target>`
+
+## Plugin Management
+
+To add a plugin from a local path, you will first need to run fetch:
+
+`<path to project>/cordova/plugin fetch <path to plugin>`
+
+Now the plugin can be installed by name:
+
+`<path to project>/cordova/plugin install <name>`
+
+Plugins hosted remotely can be installed by name without using fetch. To see a list of available remote plugins use:
+
+`<path to project>/cordova/plugin list`
 
-blackberry10 - BB10


[25/50] [abbrv] webworks commit: Fix JPPS and Utils plugins directory structure

Posted by lo...@apache.org.
Fix JPPS and Utils plugins directory structure

Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: b3960ef0c39ee88a953c2be9ff4f11ec8637d5ec
Parents: 63452db
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed Apr 10 16:40:49 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/JPPS/Makefile    |    8 -
 .../templates/project/plugins/JPPS/native/Makefile |    8 +
 .../project/plugins/JPPS/native/common.mk          |   34 +
 .../project/plugins/JPPS/native/device/libjpps.so  |  Bin 0 -> 138046 bytes
 .../plugins/JPPS/native/simulator/libjpps.so       |  Bin 0 -> 224392 bytes
 .../plugins/JPPS/native/src/core/PPSEvent.h        |  108 +++
 .../plugins/JPPS/native/src/core/PPSInterface.cpp  |  632 +++++++++++++++
 .../plugins/JPPS/native/src/core/PPSInterface.h    |  238 ++++++
 .../plugins/JPPS/native/src/core/PPSNotifier.cpp   |  126 +++
 .../plugins/JPPS/native/src/core/PPSNotifier.h     |  159 ++++
 .../JPPS/native/src/core/PPSNotifyGroupManager.cpp |  107 +++
 .../JPPS/native/src/core/PPSNotifyGroupManager.h   |  133 +++
 .../plugins/JPPS/native/src/core/PPSTypes.h        |   96 +++
 .../plugins/JPPS/native/src/plugin/JPPSPlugin.cpp  |  149 ++++
 .../plugins/JPPS/native/src/plugin/JPPSPlugin.h    |  122 +++
 .../JPPS/native/src/plugin/JPPSServerPlugin.cpp    |  168 ++++
 .../JPPS/native/src/plugin/JPPSServerPlugin.h      |  115 +++
 .../JPPS/native/src/plugin/PPSInterfaceGlue.cpp    |  355 ++++++++
 .../JPPS/native/src/plugin/PPSInterfaceGlue.h      |  177 ++++
 .../JPPS/native/src/plugin/PPSServerGlue.cpp       |  300 +++++++
 .../plugins/JPPS/native/src/plugin/PPSServerGlue.h |  165 ++++
 .../plugins/JPPS/native/src/plugin/PluginTypes.h   |   35 +
 .../JPPS/native/src/plugin/pluginManifest.cpp      |   76 ++
 .../project/plugins/JPPS/native/src/utils/Logger.h |   94 +++
 .../plugins/JPPS/native/src/utils/Thread.cpp       |   71 ++
 .../project/plugins/JPPS/native/src/utils/Thread.h |   73 ++
 .../templates/project/plugins/JPPS/src/Makefile    |    8 -
 .../project/plugins/JPPS/src/blackberry10/Makefile |    8 -
 .../plugins/JPPS/src/blackberry10/native/Makefile  |    8 -
 .../plugins/JPPS/src/blackberry10/native/common.mk |   34 -
 .../JPPS/src/blackberry10/native/device/libjpps.so |  Bin 138046 -> 0 bytes
 .../src/blackberry10/native/simulator/libjpps.so   |  Bin 224392 -> 0 bytes
 .../src/blackberry10/native/src/core/PPSEvent.h    |  108 ---
 .../blackberry10/native/src/core/PPSInterface.cpp  |  632 ---------------
 .../blackberry10/native/src/core/PPSInterface.h    |  238 ------
 .../blackberry10/native/src/core/PPSNotifier.cpp   |  126 ---
 .../src/blackberry10/native/src/core/PPSNotifier.h |  159 ----
 .../native/src/core/PPSNotifyGroupManager.cpp      |  107 ---
 .../native/src/core/PPSNotifyGroupManager.h        |  133 ---
 .../src/blackberry10/native/src/core/PPSTypes.h    |   96 ---
 .../blackberry10/native/src/plugin/JPPSPlugin.cpp  |  149 ----
 .../blackberry10/native/src/plugin/JPPSPlugin.h    |  122 ---
 .../native/src/plugin/JPPSServerPlugin.cpp         |  168 ----
 .../native/src/plugin/JPPSServerPlugin.h           |  115 ---
 .../native/src/plugin/PPSInterfaceGlue.cpp         |  355 --------
 .../native/src/plugin/PPSInterfaceGlue.h           |  177 ----
 .../native/src/plugin/PPSServerGlue.cpp            |  300 -------
 .../blackberry10/native/src/plugin/PPSServerGlue.h |  165 ----
 .../blackberry10/native/src/plugin/PluginTypes.h   |   35 -
 .../native/src/plugin/pluginManifest.cpp           |   76 --
 .../src/blackberry10/native/src/utils/Logger.h     |   94 ---
 .../src/blackberry10/native/src/utils/Thread.cpp   |   71 --
 .../src/blackberry10/native/src/utils/Thread.h     |   73 --
 .../bin/templates/project/plugins/Utils/Makefile   |    8 -
 .../project/plugins/Utils/native/Makefile          |    8 +
 .../project/plugins/Utils/native/common.mk         |   18 +
 .../plugins/Utils/native/device/libutils.so        |  Bin 0 -> 130206 bytes
 .../plugins/Utils/native/simulator/libutils.so     |  Bin 0 -> 183184 bytes
 .../plugins/Utils/native/webworks_utils.cpp        |   55 ++
 .../plugins/Utils/native/webworks_utils.hpp        |   34 +
 .../templates/project/plugins/Utils/src/Makefile   |    8 -
 .../plugins/Utils/src/blackberry10/Makefile        |    8 -
 .../plugins/Utils/src/blackberry10/native/Makefile |    8 -
 .../Utils/src/blackberry10/native/common.mk        |   18 -
 .../src/blackberry10/native/device/libutils.so     |  Bin 130206 -> 0 bytes
 .../src/blackberry10/native/simulator/libutils.so  |  Bin 183184 -> 0 bytes
 .../src/blackberry10/native/webworks_utils.cpp     |   55 --
 .../src/blackberry10/native/webworks_utils.hpp     |   34 -
 68 files changed, 3656 insertions(+), 3704 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk b/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
new file mode 100644
index 0000000..6cecca9
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
@@ -0,0 +1,34 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=jpps
+PLUGIN=yes
+UTILS=yes
+
+include ../../../../../../meta.mk
+
+override CCFLAGS := $(filter-out -Werror , $(CCFLAGS))
+
+EXTRA_SRCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
+
+EXTRA_INCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
+				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
+
+SRCS+=src/utils/Thread.cpp \
+      src/core/PPSInterface.cpp \
+      src/core/PPSNotifier.cpp \
+      src/core/PPSNotifyGroupManager.cpp \
+      src/plugin/JPPSPlugin.cpp \
+      src/plugin/PPSInterfaceGlue.cpp \
+      src/plugin/JPPSServerPlugin.cpp \
+      src/plugin/PPSServerGlue.cpp \
+      src/plugin/pluginManifest.cpp
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+LIBS+=pps

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so
new file mode 100644
index 0000000..f0eb90d
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so
new file mode 100644
index 0000000..f2c12ff
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
new file mode 100644
index 0000000..808e699
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSEVENT_H_
+#define PPSEVENT_H_
+
+#include <string>
+#include "PPSTypes.h"
+
+namespace jpps {
+
+/**
+ * A class representing a PPS event. Used to notify interested parties when something
+ * happens to a PPS object.
+ */
+class PPSEvent {
+
+public:
+
+	/**
+	 * The possible types of this event.
+	 */
+	enum PPSEventType {
+		/** The PPS object's first data read is complete. */
+		PPS_EVENT_FIRST_READ_COMPLETE,
+		/** The PPS object has new data. */
+		PPS_EVENT_NEW_DATA,
+		/** The PPS object was successfully opened. */
+		PPS_EVENT_OPENED,
+		/** A PPS object was closed. */
+		PPS_EVENT_CLOSED,
+		/** An attempt to open a PPS object failed. */
+		PPS_EVENT_OPEN_FAILED,
+		/** An attempt to read from a PPS object failed. */
+		PPS_EVENT_READ_FAILED,
+		/** An attempt to write to a PPS object failed. */
+		PPS_EVENT_WRITE_FAILED,
+	};
+
+	/**
+	 * Constructor.
+	 *
+	 * @param eventType The type of event this is.
+	 * @param data If eventType == PPS_EVENT_NEW_DATA, the new data.
+	 */
+	PPSEvent(PPSEventType eventType, const std::string& msg = "", const ppsObject& newData = ppsObject())
+	: m_eventType(eventType)
+	, m_message(msg)
+	, m_newData(newData)
+	{}
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSEvent() {}
+
+	/**
+	 * Get the event type.
+	 */
+	inline PPSEventType getEventType() const { return m_eventType; }
+
+	/**
+	 * Get the message associated with this event.
+	 */
+	inline std::string getMessage() const { return m_message; }
+
+	/**
+	 * Get the new data. This value is only populated if the eventType is PPS_EVENT_NEW_DATA. This data
+	 * is what was parsed out of the PPS object.
+	 */
+	inline ppsObject getNewData() const { return m_newData; }
+
+private:
+
+	// Disable the default constructor.
+	PPSEvent();
+
+	/** The type of this event. */
+	PPSEventType m_eventType;
+
+	/** A message associated to the event. */
+	std::string m_message;
+
+	/** If m_eventType == PPS_EVENT_NEW_DATA, this contains the new data. Else m_newData is empty.
+	 * This data is the data that was read from the PPS object, un-massaged. */
+	ppsObject m_newData;
+};
+
+} /* namespace jpps */
+#endif /* PPSEVENT_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
new file mode 100644
index 0000000..dfb575b
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
@@ -0,0 +1,632 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSInterface.h"
+
+#include <sstream>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <ppsparse.h>
+#include <string.h>
+
+#include "PPSNotifyGroupManager.h"
+#include "PPSEvent.h"
+
+namespace jpps {
+
+// Const statics
+const char* PPSInterface::PPS_ROOT = "/pps/";
+const int PPSInterface::MaxPPSReadSize = (32 * 1024);
+
+// Static data members
+pthread_mutex_t PPSInterface::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t PPSInterface::sm_cond;
+volatile bool PPSInterface::sm_firstInitDone = false;
+std::map<unsigned int, PPSInterface*> PPSInterface::sm_interfaceLookupTable;
+
+PPSInterface::PPSInterface()
+: m_pEventFunc(NULL)
+, m_pEventArg(NULL)
+, m_interfaceId(0)
+, m_fd(-1)
+, m_oflags(0)
+, m_firstRead(true)
+, m_cachedRead()
+, m_logger()
+{
+	// This is used to assign a unique ID to each PPSInterface object
+	static unsigned int interfaceIDs = 0;
+
+	::pthread_mutex_lock(&sm_mutex);
+
+	m_interfaceId = interfaceIDs;
+	interfaceIDs++; // Increment this so that the next object has a unique id.
+
+	// Add myself to the lookup table
+	sm_interfaceLookupTable.insert(std::pair<unsigned int, PPSInterface*>(m_interfaceId, this));
+
+	if (!sm_firstInitDone) {
+
+		// Initialize the condvar
+		pthread_condattr_t condAttr;
+		::pthread_condattr_init(&condAttr);
+		::pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
+		::pthread_cond_init(&sm_cond, &condAttr);
+		::pthread_condattr_destroy(&condAttr);
+
+		sm_firstInitDone = true;
+	}
+
+	::pthread_mutex_unlock(&sm_mutex);
+}
+
+PPSInterface::~PPSInterface()
+{
+	std::ostringstream ostream;
+	ostream << "PPSInterface::~PPSInterface() - Destruct fd:" << m_fd << ".";
+	m_logger.slog(Logger::debug, ostream.str());
+
+	// Close my open PPS object, if I have one
+	close();
+
+	// Remove myself from the lookup table
+	sm_interfaceLookupTable.erase(m_interfaceId);
+}
+
+void PPSInterface::setVerbose(unsigned short v)
+{
+	m_logger.setVerbosity(v);
+}
+
+void PPSInterface::setEventFunc(const PPSEventFunc* pEventFunc, void* pArg)
+{
+	m_pEventFunc = pEventFunc;
+	m_pEventArg = pArg;
+}
+
+bool PPSInterface::open(const std::string& path, int oflag, int mode, bool server)
+{
+	// If we've already got an open file, fail
+	if (m_fd != -1) {
+
+		m_logger.slog(Logger::warning, "PPSInterface::open() Failed - Attempted to open an object that is already open.");
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_OPEN_FAILED, "Attempted to open an object that is already open."));
+		return false;
+	}
+
+	std::string errorMsg;
+	bool ok = false;
+
+	// Prepend PPS_ROOT to the path if it doesn't start with a '/'
+	std::string fullpath = (path[0] != '/' ? PPSInterface::PPS_ROOT : "") + path;
+
+	// This flag is used to prevent the notify thread from performing reads while the
+	// open() function is running and doing its first read.
+	::pthread_mutex_lock(&sm_mutex);
+	m_firstRead = true;
+	::pthread_mutex_unlock(&sm_mutex);
+
+	// Remove any options from the path otherwise lstat will fail
+	std::string pathNoOptions(fullpath);
+	std::size_t nPosOpts = fullpath.rfind('?');
+
+	if (nPosOpts != std::string::npos)
+		pathNoOptions = fullpath.substr(0, nPosOpts);
+
+	// There are a few complexities associated with symbolic links.  If
+	// the last component of the path is a symlink we have to resolve it
+	// since we won't be able to resolve the name when the options are
+	// added.  Also we need to get the path relative to the pps filesystem
+	// so we can locate the .notify file.  So, if the object already
+	// exists, resolve the path.  If it doesn't and O_CREAT is specified
+	// resolve the directory it's in, otherwise it's a failure.
+	std::string resolvedName;
+	char szResolvedName[PATH_MAX+128]; // buffer for use with the C functions
+
+	if (::realpath(pathNoOptions.c_str(), szResolvedName) != NULL) {
+
+		resolvedName = szResolvedName;
+		ok = true;
+	}
+	else if (oflag & O_CREAT) {
+
+		// Chop off the file name, so we can try to resolve the directory
+		size_t nPos = pathNoOptions.rfind('/');
+
+		// We found a '/'
+		if (nPos != std::string::npos) {
+
+			// Get the directory path
+			std::string dirPath = pathNoOptions.substr(0, nPos); // Don't include the '/'
+
+			if (::realpath(dirPath.c_str(), szResolvedName) != NULL) {
+
+				// Concatenate the file name to the resolved directory path
+				resolvedName = szResolvedName + pathNoOptions.substr(nPos); // include the '/' at the start
+				ok = true;
+			}
+		}
+	}
+
+	if (ok) {
+
+		struct stat info;
+		int result = ::lstat(resolvedName.c_str(), &info);
+
+		if (result != 0) {
+
+			// If we failed and we're not creating a non-existent file, it's an error.
+			if ((errno != ENOENT) && !(oflag & O_CREAT))
+				ok = false;
+		}
+		else if (S_ISDIR(info.st_mode))
+			ok = false;
+	}
+
+	if (ok) {
+
+		std::string options;
+
+		// Now lets work with the options to ensure we have a complete version
+		std::string pathOptions;
+		
+		// Get just the stuff after '?'
+		size_t nPos = fullpath.rfind('?');
+
+		if (nPos != std::string::npos) {
+			pathOptions = fullpath.substr(nPos);
+		}
+
+		if ((oflag & O_ACCMODE) != O_WRONLY) {
+
+			// This is used as the return object for the joinNotifyGroup() call
+			// It's only valid if joinNotifyGroup() returned true
+			std::string groupId;
+
+			PPSNotifyGroupManager::mutexLock();
+			PPSNotifyGroupManager& notifyManager = PPSNotifyGroupManager::getInstance();
+			bool groupJoined = notifyManager.joinNotifyGroup(resolvedName, groupId);
+			PPSNotifyGroupManager::mutexUnlock();
+
+			if (groupJoined) {
+
+				// If we're acting as a server, we use server as an option
+				// otherwise we have to specify delta mode.  PPS has a fit
+				// if we specify both delta and deltadir so check for this.
+				std::string modeExtra;
+
+				// Add in the options we need.  If both server and delta are specified, use only
+				// server (it kind of implies delta and at one point pps would not like both being
+				// present)
+				if (server) {
+					modeExtra = ",server";
+				}
+				// If we have no options or there's no 'deltadir' specified, use delta mode
+				else if (pathOptions.empty() || pathOptions.find("deltadir") == std::string::npos) {
+					modeExtra = ",delta";
+				}
+
+				// We embed the m_interfaceID as a unique identifier that will be passed on to the
+				// PPSNotifier. PPSNotifier will use this id in conjunction with getPPSInterface()
+				// in order to send this object notifications that content is ready for reading later.
+				std::ostringstream ostream;
+				ostream << "?" << (pathOptions.empty() ? "" : pathOptions.substr(1) + ",") << "notify="
+						<< groupId << ":" << m_interfaceId << modeExtra;
+				options = ostream.str();
+			}
+		}
+
+		if (!options.empty()) {
+
+			resolvedName += options;
+		}
+
+		// The big moment... Let's try to actually open the PPS object...
+		if (ok) {
+			m_fd = ::open(resolvedName.c_str(), oflag, mode);
+		}
+
+		// Error opening the PPS object
+		if (m_fd < 0) {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::open() Failed - ::open("
+					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+					<< ((oflag & O_CREAT) ? ":create" : "")
+					<< ") " << resolvedName << " (" << errno << ": " << strerror(errno) << ")";
+			m_logger.slog(Logger::warning, ostream.str());
+			errorMsg = ostream.str();
+		}
+		else {
+			// Depending on our umask, the permissions might not have
+			// been as specified. So if O_CREAT was specified, re-set the
+			// permissions.  The object might already exist, but perhaps
+			// that's OK too.
+			if (oflag & O_CREAT) {
+				::fchmod(m_fd, mode);
+			}
+
+			m_oflags = oflag;
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::open() - ::open("
+					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+					<< ((oflag & O_CREAT) ? ":create" : "")
+					<< ") " << resolvedName;
+			m_logger.slog(Logger::debug, ostream.str());
+		}
+	}
+	// For whatever reason, the path to the PPS object was not valid
+	else {
+		std::ostringstream ostream;
+		ostream << "PPSInterface::open() Failed - ::open("
+				<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
+				   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
+				   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
+				<< ((oflag & O_CREAT) ? ":create" : "")
+				<< ") " << path << " The PPS object could not be resolved properly.";
+		m_logger.slog(Logger::warning, ostream.str());
+		errorMsg = ostream.str();
+	}
+
+	sendEvent(PPSEvent(m_fd >= 0 ? PPSEvent::PPS_EVENT_OPENED : PPSEvent::PPS_EVENT_OPEN_FAILED, errorMsg));
+
+	if (m_fd >= 0 && (oflag & O_ACCMODE) != O_WRONLY) {
+
+		// Perform the initial read
+		readFromObject();
+	}
+
+	// Tell the other thread we are done with the first read
+	::pthread_mutex_lock(&sm_mutex);
+	m_firstRead = false;
+	::pthread_cond_broadcast(&sm_cond);
+	::pthread_mutex_unlock(&sm_mutex);
+
+	return m_fd >= 0;
+}
+
+void PPSInterface::write(const std::string& data)
+{
+	// We're trying to write to an unopened PPS object
+	if (m_fd == -1) {
+
+		std::string msg("PPSInterface::write() Failed - Attempting to write to a file that isn't open.");
+		m_logger.slog(Logger::warning, msg);
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, msg));
+	}
+
+	ssize_t ret = ::write(m_fd, data.c_str(), data.length());
+
+	// Debug slog the write call if it was successful
+	if (ret >= 0) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::write() - fd:" << m_fd << " : \n" << data;
+		m_logger.slog(Logger::debug, ostream.str());
+	}
+
+	// There was an error writing
+	if (ret == -1) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::write() Failed - Error writing to fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+		m_logger.slog(Logger::warning, ostream.str());
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, ostream.str()));
+	}
+
+	// If we wrote successfully and the file is open in read/write mode, then we need to manually update the
+	// read cache. When in O_RDWR mode, we do NOT receive notifications of our own write() operations.
+	// This means that the cache of read data becomes stale - it is missing the data that we have written
+	// to the object ourselves. In this case, we will manually update the cache.
+	// NOTE: this seems fraught with peril, but unfortunately there don't seem to be any good solutions to
+	// fixing the problem of read/write mode and read() integrity.
+	if (ret >= 0 && (m_oflags & O_RDWR)) {
+
+		// We're going to try to fool the ppsparse() method into parsing the data we write.
+		char* pWriteData = new char[data.length() + 1];
+
+		// The later call to ppsparse() moves the pWriteData pointer forward, and we need the original pointer
+		// in order to properly delete the object later, so let's cache it here
+		char* pWriteDataCopy = pWriteData;
+
+		std::strcpy(pWriteData, data.c_str()); // strcpy null terminates for us
+
+		// Parse the write buffer - this should give us a ppsObject with only attributes
+		ppsObject parsedData = parsePPSData(pWriteData);
+
+		// The data being written does not include the object name other object properties (duh)
+		// So parsedData contains only attribute info. We want to preserve the object name
+		// and properties, so lets just copy the ones in the cache into our parsedData struct
+		// so that the call to updateCachedReadData() will preserve them (i.e. copy them back)
+		parsedData.name = m_cachedRead.name;
+		parsedData.flags = m_cachedRead.flags;
+		parsedData.options = m_cachedRead.options;
+		parsedData.optionMask = m_cachedRead.optionMask;
+
+		// Update the cache
+		updateCachedReadData(parsedData);
+
+		// Cleanup our allocated memory
+		if (pWriteDataCopy) {
+
+			delete[] pWriteDataCopy;
+		}
+	}
+}
+
+void PPSInterface::sync()
+{
+	if (m_fd >= 0)
+		::fsync(m_fd);
+}
+
+void PPSInterface::close()
+{
+	if (m_fd >= 0) {
+
+		::close(m_fd);
+		m_fd = -1;
+		m_cachedRead = ppsObject();
+		m_oflags = 0;
+
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_CLOSED));
+	}
+}
+
+void PPSInterface::onNotify(NotifyType event)
+{
+	// We only handle read notifications
+	if (event != PPS_READ) {
+		return;
+	}
+
+	if (m_firstRead) {
+		::pthread_mutex_lock(&sm_mutex);
+		while (m_firstRead) {
+			::pthread_cond_wait(&sm_cond, &sm_mutex);
+		}
+		::pthread_mutex_unlock(&sm_mutex);
+	}
+
+	readFromObject();
+}
+
+void PPSInterface::readFromObject()
+{
+	bool sendFirstReadEvent = m_firstRead;
+
+	// This was a uint8_t - was there a reason?
+	char szBuffer[MaxPPSReadSize + 1];
+	int bufferLen;
+
+	// Read from the actual PPS file - this call is not blocking
+	while ((bufferLen = ::read(m_fd, szBuffer, MaxPPSReadSize)) > 0) {
+
+		if (bufferLen <= MaxPPSReadSize) {
+
+			// Make sure the buffer is null terminated.
+			szBuffer[bufferLen] = '\0';
+
+			std::string buf(szBuffer, bufferLen);
+			std::ostringstream ostream;
+			ostream << "PPSInterface::readFromObject() - fd:" << m_fd << " len:" << bufferLen << "\n" << buf;
+			m_logger.slog(Logger::debug, ostream.str());
+
+			// Parse the PPS data
+			ppsObject parsedPPS = parsePPSData(szBuffer);
+
+			// Update the cache with the data we just read
+			updateCachedReadData(parsedPPS);
+
+			// If this is the first read, then send the first read event.
+			if (sendFirstReadEvent) {
+
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", parsedPPS));
+				sendFirstReadEvent = false;
+			}
+			else {
+
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_NEW_DATA, "", parsedPPS));
+			}
+		}
+		else {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::readFromObject() Failed - fd:" << m_fd << " oversized message len:" << bufferLen << ".";
+			m_logger.slog(Logger::warning, ostream.str());
+		}
+	}
+
+	if (bufferLen == -1) {
+
+		std::ostringstream ostream;
+		ostream << "PPSInterface::readFromObject() Failed - Error reading from fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+		m_logger.slog(Logger::warning, ostream.str());
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
+	}
+
+	// It's possible that we won't go into the while() loop above (sometimes the first read is legitimately empty)
+	// in which case, we still need to send a first read complete event
+	if (sendFirstReadEvent) {
+
+		// Send an empty first read object
+		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", ppsObject()));
+		sendFirstReadEvent = false;
+	}
+}
+
+void PPSInterface::sendEvent(const PPSEvent& event) const
+{
+	if (m_pEventFunc) {
+		m_pEventFunc(m_pEventArg, event);
+	}
+}
+
+PPSInterface* const PPSInterface::getPPSInterface(const unsigned int id)
+{
+	::pthread_mutex_lock(&sm_mutex);
+
+	std::map<unsigned int, PPSInterface*>::iterator it = sm_interfaceLookupTable.find(id);
+
+	if (it != sm_interfaceLookupTable.end()) {
+
+		::pthread_mutex_unlock(&sm_mutex);
+		return (*it).second;
+	}
+
+	::pthread_mutex_unlock(&sm_mutex);
+	return NULL;
+}
+
+ppsObject PPSInterface::parsePPSData(char* data) const
+{
+	// This is the structure that will contain parsed data for each line of the PPS object
+	// It needs to be initialized to NULL
+	pps_attrib_t info;
+	std::memset(&info, 0, sizeof(info));
+
+	// The return code for each PPS line that gets parsed
+	pps_status_t rc;
+	ppsObject ppsObj;
+
+	while ((rc = ::ppsparse(&data, NULL, NULL, &info, 0)) != PPS_END) {
+
+		if (rc == -1) {
+
+			std::ostringstream ostream;
+			ostream << "PPSInterface::parsePPSData() Failed - Error calling ppsparse() fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
+			m_logger.slog(Logger::warning, ostream.str());
+			sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
+		}
+
+		if (info.flags & PPS_INCOMPLETE) {
+			m_logger.slog(Logger::debug, "PPSInterface::parsePPSData - PPS data incomplete.");
+		}
+
+		switch (rc) {
+
+			// When the object has been modified, update the object settings
+			case PPS_OBJECT:
+			case PPS_OBJECT_CREATED:
+			case PPS_OBJECT_DELETED:
+			case PPS_OBJECT_TRUNCATED:
+			{
+				ppsObj.name = info.obj_name;
+				ppsObj.flags = info.flags;
+				ppsObj.options = info.options;
+				ppsObj.optionMask = info.option_mask;
+				break;
+			}
+
+			// An attribute has been updated
+			case PPS_ATTRIBUTE:
+			case PPS_ATTRIBUTE_DELETED:
+			{
+				ppsAttribute ppsAttrib;
+				ppsAttrib.name = info.attr_name;
+
+				// Value and encoding aren't valid if rc == PPS_ATTRIBUTE_DELETED
+				if (rc == PPS_ATTRIBUTE) {
+
+					ppsAttrib.value = info.value;
+					ppsAttrib.encoding = info.encoding;
+				}
+
+				ppsAttrib.flags = info.flags;
+				ppsAttrib.options = info.options;
+				ppsAttrib.optionMask = info.option_mask;
+
+				ppsObj.attributes.insert(ppsAttrPair(ppsAttrib.name, ppsAttrib));
+				break;
+			}
+
+			case PPS_ERROR:
+			{
+				std::string msg("PPSInterface::parsePPSData() Failed - Error parsing PPS data.");
+				m_logger.slog(Logger::warning, msg);
+				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, msg));
+				break;
+			}
+
+			case PPS_END:
+			default:
+				break;
+		}
+
+	}
+
+	return ppsObj;
+}
+
+void PPSInterface::updateCachedReadData(const ppsObject& newData)
+{
+	::pthread_mutex_lock(&sm_mutex);
+
+	// Update the object
+	m_cachedRead.name = newData.name;
+	m_cachedRead.flags = newData.flags;
+	m_cachedRead.options = newData.options;
+	m_cachedRead.optionMask = newData.optionMask;
+
+	::pthread_mutex_unlock(&sm_mutex);
+
+	// Update the attributes
+	for (const_ppsAttrIter it = newData.attributes.begin(); it != newData.attributes.end(); it++) {
+
+		ppsAttribute attr = (*it).second;
+
+		// An attribute is being deleted
+		if (attr.flags & PPS_DELETED) {
+
+			::pthread_mutex_lock(&sm_mutex);
+
+			// Look for this attribute in the cache and remove it
+			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
+
+			if (findIt != m_cachedRead.attributes.end()) {
+				m_cachedRead.attributes.erase(findIt);
+			}
+
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+		// We're adding a new attribute - don't search for it
+		else if (attr.flags & PPS_CREATED){
+
+			::pthread_mutex_lock(&sm_mutex);
+			m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+		else {
+
+			::pthread_mutex_lock(&sm_mutex);
+
+			// Look for this attribute in the cache
+			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
+
+			// If we find it, update the attribute values
+			if (findIt != m_cachedRead.attributes.end()) {
+
+				(*findIt).second.name = attr.name;
+				(*findIt).second.encoding = attr.encoding;
+				(*findIt).second.value = attr.value;
+				(*findIt).second.flags = attr.flags;
+				(*findIt).second.options = attr.options;
+				(*findIt).second.optionMask = attr.optionMask;
+			}
+			// If we don't find it, insert it
+			else {
+				m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
+			}
+			::pthread_mutex_unlock(&sm_mutex);
+		}
+	}
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
new file mode 100644
index 0000000..0fde80c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPS_H_
+#define PPS_H_
+
+#include <string>
+#include <map>
+
+#include <sys/types.h>
+
+#include "PPSTypes.h"
+#include "PPSEvent.h"
+#include "../utils/Logger.h"
+
+namespace jpps {
+
+/**
+ * This class augments standard PPS functionality by providing events for when PPS objects are opened,
+ * closed, have new data, etc.
+ *
+ * When a PPS object is opened using PPSInterface::open(), the object is opened as part of a notification group
+ * managed by PPSNotifyGroupManager. The notification group monitors the PPS object and notifies PPSInterface
+ * whenever there is new data available in the PPS object.
+ *
+ * PPSInterface should be used in order to simplify PPS object monitoring (i.e. watching for new data in a PPS
+ * object.) PPSInterface takes over management of watching for new data and uses a notification callback mechanism
+ * with a defined set of possible events to inform the client of changes to the PPS object.
+ */
+class PPSInterface {
+
+public:
+
+	/**
+	 * Used with onNotify to allow the PPSNotifier to tell us what type of notification
+	 * message it is sending.
+	 */
+	enum NotifyType {
+		/** The .notify object received a notification that data is ready to be read. */
+		PPS_READ = 0,
+		/** The .notify object received a notification that a file being watched is closing. */
+		PPS_CLOSE = 1 };
+
+	/**
+	 * Constructor.
+	 */
+	PPSInterface();
+
+	/**
+	 * Destructor.
+	 */
+	~PPSInterface();
+
+	/**
+	 * Set up a function to call to be notified about PPS events.
+	 *
+	 * @param pEventFunc The function to call whenever an event happens in PPSInterface.
+	 * @param pArg An optional parameter that will be passed back to pEventFunc every time it
+	 * is called. PPSInterface will not modify pArg.
+	 */
+	void setEventFunc(const PPSEventFunc* pEventFunc, void* pArg = NULL);
+
+	/**
+	 * Enable verbose mode. Increase the number of �v�s to increase verbosity.
+	 *
+	 * @param v The level of verbosity. A value of 0 is off, 1 shows info messages, 2 shows
+	 * debug messages.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS object. If the open() call is successful, a PPS_EVENT_OPENED event will be sent.
+	 * The PPS object will be read as part of the open operation and the PPS_EVENT_FIRST_READ_COMPLETE
+	 * will be sent when the first read is complete. Note that there may be a PPS_EVENT_NEW_DATA
+	 * event *before* the PPS_EVENT_FIRST_READ_COMPLETE event, or there may not be.
+	 * PPS_EVENT_FIRST_READ_COMPLETE only guarantees that at least one read has been performed, not
+	 * that it will be the first read event to fire.
+	 *
+	 * If the open operation fails, the function returns false and a PPS_EVENT_OPEN_FAILED will be sent.
+	 *
+	 * @param path The PPS file/directory path.
+	 * @param oflags Flags passed to ::open.
+	 * @param mode Mode passed to ::open.
+	 * @param serverMode If true, open the object in server mode as the server.
+	 * @return True if the open was successful, false otherwise.
+	 */
+	bool open(const std::string& path, int oflags, int mode, bool serverMode);
+
+	/**
+	 * Check if this PPS object is open.
+	 * @return True if the file is open, false otherwise.
+	 */
+	inline bool isOpen() const { return m_fd >= 0; }
+
+	/**
+	 * Write data to a PPS object.
+	 * @param data The data to write to the PPS object.
+	 */
+	void write(const std::string& data);
+
+	/**
+	 * Read PPS data. Note that this reads cached data from the last read performed when a
+	 * new data available notification was received.
+	 *
+	 * @return A structured representation of the PPS object, culled from a call to ppsparse()
+	 * a function found in ppsparse.h.
+	 */
+
+	inline ppsObject read() const { return m_cachedRead; }
+
+	/**
+	 * Close this PPS object.
+	 */
+	void close();
+
+	/**
+	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
+	 * The function blocks until this is finished.
+	 */
+	void sync();
+
+	/**
+	 * Called to notify us that there is data ready to be read.
+	 *
+	 * @param event The type of event we're being notified about.
+	 */
+	void onNotify(NotifyType event);
+
+	/**
+	 * Given a unique id, return the PPSInterface* matching that id.
+	 *
+	 * Every PPSInterface object is assigned a unique identifier at construction. This
+	 * unique identifier can be used to get a pointer to a PPSInterface at runtime.
+	 *
+	 * In particular, the PPSNotifier gets notifications with this number embedded in them.
+	 * Using this id, the PPSNotifier can callback into the correct PPSInterface instance.
+	 *
+	 * @param id An id that uniquely identifies a PPSInterface object.
+	 * @return a PPSInterface* or NULL if no object matches the given id.
+	 */
+	static PPSInterface* const getPPSInterface(const unsigned int id);
+
+private:
+
+	/**
+	 * Read from the PPS object. Generally this function is called by onNotify() when
+	 * the notifier thread is notified that there is data to be read. This function
+	 * performs a read() of the PPS object that is non-blocking.
+	 */
+	void readFromObject();
+
+	/**
+	 * Given data from a PPS read, parse the PPS data.
+	 */
+	ppsObject parsePPSData(char* data) const;
+
+	/**
+	 * Given new PPS data, update the cached read value.
+	 */
+	void updateCachedReadData(const ppsObject& newData);
+
+	/**
+	 * Call the function set in setEventFunc() with the given event.
+	 *
+	 * @param event The event to send.
+	 */
+	void sendEvent(const PPSEvent& event) const;
+
+	/** The default PPS location. */
+	static const char* PPS_ROOT;
+
+	/** The maximum amount of data that can be read from a PPS object. */
+	static const int MaxPPSReadSize;
+
+	/** The function to call to notify about PPS events. */
+	PPSEventFunc* m_pEventFunc;
+
+	/** An argument that goes with m_pEventFunc. PPSInterface does not modify or use
+	 * this parameter - we simply send it back with every m_pEventFunc call. */
+	void* m_pEventArg;
+
+	/** An identifier that uniquely identifies this PPSInterface object. This is used to look up
+	 * this object in a global table. */
+	unsigned int m_interfaceId;
+
+	/** The file descriptor of the PPS object being opened. */
+	int m_fd;
+
+	/** The open mode flags used when this object was opened. */
+	int m_oflags;
+
+	/** If true, main thread is performing initial open/read of PPS object. This is shared
+	 * across threads and needs to be mutexed when accessed.*/
+	volatile bool m_firstRead;
+
+	/** The data from the last read performed. */
+	ppsObject m_cachedRead;
+
+	/** The logger used to log error messages */
+	Logger m_logger;
+
+	/** Mutex used to prevent threads from clobbering each other. */
+	static pthread_mutex_t sm_mutex;
+
+	/** Condvar used for multi-thread signaling. */
+	static pthread_cond_t sm_cond;
+
+	/** Used to ensure that initialization of statics happens only once. This is shared
+	 * across threads and needs to be mutexed when accessed.*/
+	static volatile bool sm_firstInitDone;
+
+	/** The PPSNotifier needs a way to transform an id that uniquely identifies a PPSInterface object
+	 * into an actual PPSInterface*. When we construct a new PPSInterface, we will assign it a unique id
+	 * and we will put the id and the pointer to the object into this table. The table can then be used
+	 * to lookup this object from its unique id. */
+	static std::map<unsigned int, PPSInterface*> sm_interfaceLookupTable;
+};
+
+} /* namespace jpps */
+#endif /* PPS_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
new file mode 100644
index 0000000..7869a56
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSNotifier.h"
+
+#include <sstream>
+
+#include <fcntl.h>
+
+#include "PPSInterface.h"
+#include "../utils/Logger.h"
+
+namespace jpps {
+
+PPSNotifier::PPSNotifier()
+: m_notifyObjPath("")
+, m_notifyObjFd(-1)
+, m_notifyGroupId("")
+, m_thread()
+{
+
+}
+
+PPSNotifier::~PPSNotifier()
+{
+	// Stop the thread
+	m_thread.stop();
+
+	// Close the .notify file
+	if (m_notifyObjFd >= 0) {
+		::close(m_notifyObjFd);
+	}
+}
+
+void PPSNotifier::startNotifyLoop()
+{
+	m_thread.start(_notifyLoop, this, "plugin_jPPS_PPSNotifier(" + m_notifyObjPath + "/.notify)");
+}
+
+
+void* PPSNotifier::_notifyLoop(void* pArg)
+{
+	// Something is messed up
+	if (pArg == NULL)
+		return NULL;
+
+	PPSNotifier* pNotifier = static_cast<PPSNotifier*> (pArg);
+
+	// pArg is supposed to be a PPSNotifier object...
+	if (pNotifier == NULL)
+		return NULL;
+
+	pNotifier->notifyLoop();
+
+	return NULL;
+}
+
+void PPSNotifier::notifyLoop()
+{
+	// Buffer for read() operation
+	char szData[256];
+	int dataLen;
+
+	// This is a blocking read call: this will wait in this loop forever
+	while ((dataLen = ::read(m_notifyObjFd, szData, sizeof(szData)-1)) > 0) {
+
+                szData[dataLen] = '\0';
+		std::string data(szData);
+
+		if ((unsigned int)dataLen > sizeof(szData)-1) {
+
+			std::ostringstream ostream;
+			ostream << "PPSNotifier::notifyLoop() - Notify read overflow " << dataLen << ".";
+			Logger logger;
+			logger.slog(Logger::error, ostream.str());
+		}
+
+		std::size_t nPos = data.find('\n');
+
+		// While we find linefeeds
+		while(nPos != std::string::npos) {
+
+			// Read the first char
+			PPSInterface::NotifyType event = data[0] == '-' ? PPSInterface::PPS_CLOSE : PPSInterface::PPS_READ;
+			std::size_t nAddrPos = data.find(':');
+
+			if (nAddrPos != std::string::npos) {
+
+				std::string sAddress = data.substr(nAddrPos+1);
+				std::size_t nAddrEnd = sAddress.find('\n');
+
+				if (nAddrEnd != std::string::npos) {
+
+					sAddress = sAddress.substr(0, nAddrEnd);
+
+					unsigned int interfaceId = 0;
+
+					std::stringstream ss;
+					ss << sAddress;
+					ss >> interfaceId;
+
+					PPSInterface* const pPPS = PPSInterface::getPPSInterface(interfaceId);
+
+					if (pPPS) {
+						pPPS->onNotify(event);
+					}
+				}
+			}
+
+			// Don't go off the end of the string
+			if (++nPos < data.length()) {
+
+				// Remove the stuff up to the first '\n' and look for the next '\n'
+				data = data.substr(nPos);
+				nPos = data.find('\n');
+			}
+			else {
+
+				nPos = std::string::npos;
+			}
+		}
+	}
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
new file mode 100644
index 0000000..143f052
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSNOTIFIER_H_
+#define PPSNOTIFIER_H_
+
+#include <string>
+
+#include "../utils/Thread.h"
+
+namespace jpps {
+
+/**
+ * PPSNotifier is an encapsulation of an open PPS .notify object. PPSNotifier has a
+ * blocking thread dedicated to reading from its .notify object. The thread constantly
+ * waits for new notifications in the .notify object.
+ *
+ * The way the PPS notify mechanism works is that on the first open/read of a .notify object,
+ * PPS provides a notify group id. This group id can be used when opening any PPS object to make
+ * the PPS object join the notify group.
+ *
+ * For example, you open a .notify file and the group id returned is "2a3".
+ * You subsequently open a PPS object and make it join that notify group:
+ *
+ * ::open("/pps/myppsobj?notify=2a3:someUniqueValueIDecide");
+ *
+ * Now, every time myppsobj changes, the .notify file will be updated in the following manner:
+ *
+ * <code>Notify 2a3:someUniqueValueIDecide</code>
+ *
+ * For a change to the file. And
+ *
+ * <code>-2a3:someUniqueValueIDecide</code>
+ *
+ * if myppsobj is closed.
+ *
+ * When PPSNotifier reads a notification, the unique value is actually a unique identifier for a
+ * PPSInterface object that can be looked up in a global PPSInterface lookup table. Getting the
+ * PPSInterface object designated by the unique identifier, PPSNotifier calls PPSInterface::onNotify()
+ * to inform the PPSInterface object that there is new data pending or that the file has closed.
+ * It is then up to the PPSInterface to decide how to proceed to get that data from myppsobj.
+ */
+class PPSNotifier {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSNotifier();
+
+	/**
+	 * Destructor. Note that this destructor will attempt to close the .notify
+	 * object's file.
+	 */
+	virtual ~PPSNotifier();
+
+	/**
+	 * Start the notify thread.
+	 */
+	void startNotifyLoop();
+
+	/**
+	 * Get the .notify object's path.
+	 *
+	 * @return The path to the .notify object.
+	 */
+	inline std::string getNotifyObjPath() const { return m_notifyObjPath; }
+
+	/**
+	 * Set the .notify object's path.
+	 *
+	 * @param path The path of the .notify object (note that this should not include the
+	 * .notify object name).
+	 */
+	inline void setNotifyOjbPath(const std::string& path) { m_notifyObjPath = path; }
+
+	/**
+	 * Get the .notify object's file descriptor.
+	 *
+	 * @return The file descriptor for the open .notify object.
+	 */
+	inline int getObjFd() const { return m_notifyObjFd; }
+
+	/**
+	 * Set the .notify object's file descriptor.
+	 *
+	 * @param The file descriptor for the open .notify object.
+	 */
+	inline void setObjFd(const int fd) { m_notifyObjFd = fd; }
+
+	/**
+	 * Set this notifier's .notify group ID (assigned by PPS).
+	 *
+	 * @param The .notify object's group ID, which is returned by PPS on the first read
+	 * of the .notify object.
+	 */
+	inline std::string getNotifyGroupId() const { return m_notifyGroupId; }
+
+	/**
+	 * Get this notifier's .notify group ID (assigned by PPS).
+	 *
+	 * @return The .notify object's group ID.
+	 */
+	inline void setNotifyGroupId(const std::string& id) { m_notifyGroupId = id; }
+
+private:
+
+	// Disable the copy constructor
+	PPSNotifier(const PPSNotifier& manager);
+
+	// Disable the assignment operator
+	PPSNotifier& operator=(const PPSNotifier& rhs);
+
+	/**
+	 * Function used to start the thread. Pass this into the Thread::start() function.
+	 *
+	 * @param pArg A pointer to a PPSNotifier.
+	 */
+	static void* _notifyLoop(void* pArg);
+
+	/**
+	 * The main thread loop. Blocks on reading the .notify file.
+	 */
+	void notifyLoop();
+
+	/** The path of the .notify file we're monitoring to know when to get data. */
+	std::string m_notifyObjPath;
+
+	/** The file descriptor of the .notify file we're monitoring to know when to get data. */
+	int m_notifyObjFd;
+
+	/** The .notify group ID assigned by PPS when the group was created. */
+	std::string m_notifyGroupId;
+
+	/** The thread I'm running on. */
+	Thread m_thread;
+};
+
+} /* namespace jpps */
+#endif /* PPSNOTIFIER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
new file mode 100644
index 0000000..5392ca8
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSNotifyGroupManager.h"
+
+#include <fcntl.h>
+
+#include "PPSNotifier.h"
+
+namespace jpps {
+
+typedef std::map<std::string, PPSNotifier*>::iterator groupIter;
+typedef std::map<std::string, PPSNotifier*>::const_iterator const_groupIter;
+typedef std::pair<std::string, PPSNotifier*> groupValue;
+
+pthread_mutex_t PPSNotifyGroupManager::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+PPSNotifyGroupManager::PPSNotifyGroupManager()
+{
+
+}
+
+PPSNotifyGroupManager::~PPSNotifyGroupManager()
+{
+	// Delete the allocated memory for all the PPSNotifiers
+	for (groupIter it = m_notifyGroups.begin(); it != m_notifyGroups.end(); it++) {
+
+		if ((*it).second != NULL) {
+
+			delete (*it).second;
+			(*it).second = NULL;
+		}
+	}
+}
+
+PPSNotifyGroupManager& PPSNotifyGroupManager::getInstance()
+{
+	// The one and only PPSNotifyGroupManager
+	static PPSNotifyGroupManager manager;
+	return manager;
+}
+
+bool PPSNotifyGroupManager::joinNotifyGroup(const std::string& path, std::string& groupId)
+{
+	std::string notifyFile;
+	std::string notifyPath(path);
+	std::size_t nPos = notifyPath.rfind('/');
+
+	// Search through the directories in the string until we find a valid .notify object
+	while (nPos != std::string::npos) {
+
+		// Chop off everything after the last '/' to get the path without the PPS object name
+		notifyPath = notifyPath.substr(0, nPos);
+
+		// Do we already have a notify group for this path?
+		const_groupIter it = m_notifyGroups.find(notifyPath);
+
+		// We found a match!
+		if (it != m_notifyGroups.end() && (*it).second != NULL) {
+
+			groupId = (*it).second->getNotifyGroupId();
+			return true;
+		}
+
+		// Add ".notify?wait" to the notify path, to make it a real file
+		notifyFile = notifyPath + "/.notify?wait";
+
+		// Try to open this .notify object
+		int fd = ::open(notifyFile.c_str(), O_RDONLY);
+
+		// This is the .notify object to use
+		if (fd >= 0) {
+
+			char data[20];
+			int len = ::read(fd, data, sizeof(data) - 1);
+			// Terminate string to remove the newline char
+			data[len > 0 ? len - 1 : 0] = '\0';
+
+			PPSNotifier* pNotifier = new PPSNotifier();
+			pNotifier->setNotifyGroupId(std::string(data));
+			pNotifier->setNotifyOjbPath(notifyPath);
+			pNotifier->setObjFd(::dup(fd));
+                        ::close(fd);
+
+			// Add this badboy to our cache of notify groups
+			m_notifyGroups.insert(groupValue(notifyPath, pNotifier));
+
+			// Start the notify reading thread
+			pNotifier->startNotifyLoop();
+
+			groupId = pNotifier->getNotifyGroupId();
+			return true;
+		}
+		// Keep looking
+		else {
+
+			nPos = notifyPath.rfind('/');
+		}
+	}
+
+	// We didn't find a notify group
+	groupId = "";
+	return false;
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
new file mode 100644
index 0000000..03b0e3e
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSNOTIFYGROUPMANAGER_H_
+#define PPSNOTIFYGROUPMANAGER_H_
+
+#include <map>
+#include <string>
+#include <pthread.h>
+
+namespace jpps {
+
+// Forward declaration
+class PPSNotifier;
+
+
+/**
+ * The PPSNotifyGroupManager is used to manage a global pool of .notify objects. PPS has a mechanism
+ * where every folder can contain a special PPS object ".notify". Opening the .notify object will return
+ * a group id on the first read of the .notify object. The group id is used to open the real PPS object
+ * for which we desire to receive notifications. Once this is done, the .notify object is the one that will
+ * receive change notifications for the real PPS object. In this model, the real PPS object DOES NOT
+ * open in blocking read or ionotify/select mode. The .notify object is the one responsible for blocking
+ * on read and tracking data publishing.
+ *
+ * This object is a global singleton - any access to it needs to be wrapped in a mutex to prevent
+ * concurrency problems. Two functions mutex_lock() and mutex_unlock() are provided for this purpose.
+ */
+class PPSNotifyGroupManager
+{
+public:
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSNotifyGroupManager();
+
+	/**
+	 * Get the one and only instance of the PPSNotifier.Always wrap calls to getInstance() in a call to
+	 * PPSNotifyGroupManager::mutexLock()/mutexUnlock().
+	 */
+	static PPSNotifyGroupManager& getInstance();
+
+	/**
+	 * Use this function to get the notify group id of the "closest" .notify object in the /pps hierarchy
+	 * that contains path.
+	 *
+	 * The function will go backwards through the directories in path looking for a .notify object. It will return
+	 * the group id of the first .notify object it finds on this path. It is the responsibility of the caller
+	 * to have the PPS object in path join the notify group by opening the object with the "notify=groupId:val"
+	 * option set.
+	 *
+	 * PPSNotifyGroupManager maintains a pool of opened .notify objects. It is possible for a single .notify object
+	 * to have a very disparate (and numerous) set of PPS objects that it monitors. In order to tweak performance
+	 * it is advisable that .notify object be created in strategic directories in the /pps directory hierarchy, in
+	 * order to spread the load of notification monitoring. Each .notify object opened will spawn a thread that blocks
+	 * on reading from the .notify object. Having several .notify objects means having several threads that read
+	 * notifications.
+	 *
+	 * Note that joinNotifyGroup() will NOT create any .notify PPS objects. The /pps/.notify object always exists,
+	 * and if the /pps directory hierarchy contains no other .notify objects, /pps/.notify will end up being the
+	 * notification group that all objects join.
+	 *
+	 * Always wrap calls to joinNotifyGroup() in a call to PPSNotifyGroupManager::mutexLock()/mutexUnlock().
+	 *
+	 * @param The PPS object that wants to join the notify group.
+	 * @param groupId The id of the notify group joined. This is an output parameter.
+	 * @return True if a notify group was successfully joined, false otherwise. If true, then the groupId
+	 * variable will be set.
+	 */
+	bool joinNotifyGroup(const std::string& path, std::string& groupId);
+
+	/**
+	 * Returns how many notification groups the manager is managing.
+	 *
+	 * @return The number of notification groups (i.e. open .notify objects) in use.
+	 */
+	inline std::size_t getNumGroups() const { return m_notifyGroups.size(); }
+
+	/**
+	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
+	 * object, multiple threads may try to access this object at one time. It is therefore important to
+	 * mutex lock all access to this object.
+	 */
+	static inline void mutexLock() { pthread_mutex_lock(&sm_mutex); }
+
+	/**
+	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
+	 * object, multiple threads may try to access this object at one time. It is therefore important to
+	 * mutex lock all access to this object.
+	 */
+	static inline void mutexUnlock() { pthread_mutex_unlock(&sm_mutex); }
+
+private:
+
+	/**
+	 * Constructor. Private as part of the singleton pattern of this object.
+	 */
+	PPSNotifyGroupManager();
+
+	// Disable the copy constructor.
+	PPSNotifyGroupManager(const PPSNotifyGroupManager& manager);
+
+	// Disable the assignment operator.
+	PPSNotifyGroupManager& operator=(const PPSNotifyGroupManager& rhs);
+
+	/** This is a cache of all the .notify objects. */
+	std::map<std::string, PPSNotifier*> m_notifyGroups;
+
+	/** Mutex used to prevent threads from clobbering each other. */
+	static pthread_mutex_t sm_mutex;
+};
+
+} /* namespace jpps */
+#endif /* PPSNOTIFYGROUPMANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
new file mode 100644
index 0000000..362d236
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSTYPES_H_
+#define PPSTYPES_H_
+
+#include <map>
+
+namespace jpps {
+
+class PPSEvent;
+
+/**
+ * A struct representing an attribute of a PPS object.
+ */
+struct ppsAttribute {
+
+	/** The attribute name. */
+	std::string name;
+	/** The attribute value. */
+	std::string value;
+	/** The attribute encoding. */
+	std::string encoding;
+	/** Flags associated to the attribute. */
+	int flags;
+	/** Attribute options. */
+	int options;
+	/** The attribute options mask. */
+	int optionMask;
+};
+
+/**
+ * A struct representing a PPS object.
+ */
+struct ppsObject {
+
+	/** The PPS object name. */
+	std::string name;
+	/** The PPS object flags. */
+	int flags;
+	/** The PPS object options. */
+	int options;
+	/** The PPS object option mask. */
+	int optionMask;
+	/** The attributes of this PPS object. */
+	std::map<std::string, ppsAttribute> attributes;
+};
+
+/**
+ * Typedef for ppsAttribute iterator.
+ */
+typedef std::map<std::string, ppsAttribute>::iterator ppsAttrIter;
+
+/**
+ * Typedef for ppsAttribute const iterator.
+ */
+typedef std::map<std::string, ppsAttribute>::const_iterator const_ppsAttrIter;
+
+/**
+ * A pair used to insert attributes into the map.
+ */
+typedef std::pair<std::string, ppsAttribute> ppsAttrPair;
+
+/**
+ * This is the definition of the notify function clients of PPSInterface use in order
+ * to be informed of events the PPSInterface generates.
+ *
+ * @param pArg A user defined parameter. This value can be passed in to PPSInterface::setEventFunc()
+ * and will be passed back with the event handler every time it is called. PPSInterface will not
+ * modify this value.
+ *
+ * @aparam event The PPS event being broadcast.
+ */
+typedef void (PPSEventFunc)(void* pArg, const PPSEvent& event);
+
+};
+
+#endif /* PPSTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
new file mode 100644
index 0000000..9b5d711
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "JPPSPlugin.h"
+
+#include <string>
+#include <sstream>
+
+namespace jpps {
+
+const char* JPPSPlugin::CLASS_NAME = "PPS";
+const std::string JPPSPlugin::METHOD_OPEN = "Open";
+const std::string JPPSPlugin::METHOD_CLOSE = "Close";
+const std::string JPPSPlugin::METHOD_WRITE = "Write";
+const std::string JPPSPlugin::METHOD_READ = "Read";
+const std::string JPPSPlugin::METHOD_SET_VERBOSE = "SetVerbose";
+
+JPPSPlugin::JPPSPlugin(const std::string& jnextObjectId)
+: m_jnextObjId(jnextObjectId)
+, m_ppsInterface()
+{
+	// We only have one event handler, we'll use it for all events
+	m_ppsInterface.callbackInit(this,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent,
+								onEvent);
+}
+
+JPPSPlugin::~JPPSPlugin()
+{
+
+}
+
+std::string JPPSPlugin::InvokeMethod(const std::string& strCommand)
+{
+	// Parameter sanity check
+	if (strCommand == "")
+		return std::string(szERROR) + " JPPSPlugin::InvokeMethod() called with no method to invoke.";
+
+	// Tokenize the stream of input information
+	std::stringstream args(strCommand);
+	std::string method;
+	args >> method;
+
+	// Invoke the method requested
+	if (method == JPPSPlugin::METHOD_WRITE) {
+		return write(args);
+	}
+	else if (method == JPPSPlugin::METHOD_READ) {
+		return read();
+	}
+	else if (method == JPPSPlugin::METHOD_OPEN) {
+		return open(args);
+	}
+	else if (method == JPPSPlugin::METHOD_CLOSE) {
+		return close();
+	}
+	else if (method == JPPSPlugin::METHOD_SET_VERBOSE) {
+		return setVerbose(args);
+	}
+
+	return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::InvokeMethod() - unknown method \"" + method + "\"";
+}
+
+std::string JPPSPlugin::open(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the path
+	std::string path;
+	args >> path;
+
+	// Missing argument
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
+
+	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
+	int oflags = 0;
+	args >> oflags;
+
+	bool bRet = m_ppsInterface.open(path, oflags);
+
+	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - failed to open \"" + path + "\".";
+}
+
+std::string JPPSPlugin::close()
+{
+	m_ppsInterface.close();
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSPlugin::write(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::write() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the initial whitespace that was between the method name and the parameter
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsInterface.write(tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSPlugin::read() const
+{
+	return std::string(szOK) + m_ppsInterface.read();
+}
+
+std::string JPPSPlugin::setVerbose(std::stringstream& args)
+{
+	unsigned short verbosity = 0;
+
+	// If no param was passed, default to 0, else read the value
+	if (!args.eof())
+		args >> verbosity;
+
+	m_ppsInterface.setVerbose(verbosity);
+	return szOK;
+}
+
+void JPPSPlugin::onEvent(const std::string& sEvent) const
+{
+	// We have to add our object Id to the event
+	std::string pluginEvent = m_jnextObjId + " " + sEvent;
+	SendPluginEvent(pluginEvent.c_str(), m_pContext);
+}
+
+void JPPSPlugin::onEvent(void* pArg, const std::string& sEvent)
+{
+	// Cast pArg back to JPPSPlugin and invoke onEvent()
+	JPPSPlugin* pPlugin = static_cast<JPPSPlugin*>(pArg);
+
+	if (pPlugin != NULL)
+		pPlugin->onEvent(sEvent);
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
new file mode 100644
index 0000000..1a56ab2
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef JPPSPLUGIN_H_
+#define JPPSPLUGIN_H_
+
+#include "../common/plugin.h"
+#include "PPSInterfaceGlue.h"
+
+namespace jpps {
+
+/**
+ * JPPSPlugin is a JNext extension which provides PPS support to JavaScript.
+ * This class is merely a wrapper for PPSInterfaceGlue, providing the necessary
+ * JNext interface and performing string-parameter encoding and decoding.
+ *
+ * The intention is that this class will be replaced with a different plug-in framework.
+ */
+class JPPSPlugin : public JSExt {
+
+public:
+
+	// Constants
+
+	/** The only class supported by this plugin. */
+	static const char* CLASS_NAME;
+
+	// List of object methods supported by this extension
+
+	/** Open a PPS object/directory. */
+	static const std::string METHOD_OPEN;
+	/** Close a PPS object/directory. */
+	static const std::string METHOD_CLOSE;
+	/** Write a PPS object. */
+	static const std::string METHOD_WRITE;
+	/** Read a PPS object. */
+	static const std::string METHOD_READ;
+	/** Adjust output verbosity. */
+	static const std::string METHOD_SET_VERBOSE;
+
+	/**
+	 * Constructor.
+	 */
+	JPPSPlugin(const std::string& jnextObjectId);
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~JPPSPlugin();
+
+	// Inherited from JSExt
+	virtual std::string InvokeMethod(const std::string& strCommand);
+	virtual inline bool CanDelete(void) { return true; }
+
+	/**
+	 *  Static callback method, changes pArg back into a JPPSPlugin and invokes
+	 *  the non-static version of onEvent().
+	 */
+	static void onEvent(void* pArg, const std::string& sEvent);
+
+private:
+
+	// Disable the default constructor
+	JPPSPlugin();
+
+	/**
+	 * The non-static version of onEvent. Handler for the PPSInterfaceGlue class' events.
+	 */
+	void onEvent(const std::string& sEvent) const;
+
+	/**
+	 * Open a PPS object.
+	 */
+	std::string open(std::stringstream& args);
+
+	/**
+	 * Close the PPS object.
+	 */
+	std::string close();
+
+	/**
+	 * Write data to the PPS object.
+	 */
+	std::string write(std::stringstream& args);
+
+	/**
+	 * Read the cached PPS data from the last read.
+	 */
+	std::string read() const;
+
+	/**
+	 * Set the verbosity level for logging to slog.
+	 */
+	std::string setVerbose(std::stringstream& args);
+
+	/** A unique JNext id for this object */
+	std::string m_jnextObjId;
+
+	/** The PPS object. */
+	PPSInterfaceGlue m_ppsInterface;
+};
+
+} /* namespace jpps */
+#endif /* JPPSPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
new file mode 100644
index 0000000..6c3bc2d
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "JPPSServerPlugin.h"
+
+#include <sstream>
+
+namespace jpps {
+
+const char* JPPSServerPlugin::CLASS_NAME = "PPSServer";
+
+const std::string JPPSServerPlugin::METHOD_OPEN = "Open";
+const std::string JPPSServerPlugin::METHOD_CLOSE = "Close";
+const std::string JPPSServerPlugin::METHOD_SET_VERBOSE = "SetVerbose";
+const std::string JPPSServerPlugin::METHOD_SEND_MESSAGE = "SendMessage";
+const std::string JPPSServerPlugin::METHOD_BROADCAST_MESSAGE = "BroadcastMessage";
+
+JPPSServerPlugin::JPPSServerPlugin(const std::string& jnextObjectId)
+: m_jnextObjId(jnextObjectId)
+, m_ppsServer()
+{
+	m_ppsServer.callbackInit(this,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent,
+							 onEvent);
+}
+
+JPPSServerPlugin::~JPPSServerPlugin()
+{
+}
+
+std::string JPPSServerPlugin::InvokeMethod(const std::string& strCommand)
+{
+	// Parameter sanity check
+	if (strCommand == "")
+		return std::string(szERROR) + " JPPSServerPlugin::InvokeMethod() called with no method to invoke.";
+
+	// Tokenize the stream of input information
+	std::stringstream args(strCommand);
+	std::string method;
+	args >> method;
+
+	// Invoke the method requested
+	if (method == JPPSServerPlugin::METHOD_OPEN) {
+		return open(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_CLOSE) {
+		return close();
+	}
+	else if (method == JPPSServerPlugin::METHOD_SET_VERBOSE) {
+		return setVerbose(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_SEND_MESSAGE) {
+		return sendMessage(args);
+	}
+	else if (method == JPPSServerPlugin::METHOD_BROADCAST_MESSAGE) {
+		return broadcastMessage(args);
+	}
+
+	return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::InvokeMethod() - unknown method \"" + method + "\"";
+}
+
+std::string JPPSServerPlugin::open(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the path
+	std::string path;
+	args >> path;
+
+	// Missing argument
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
+
+	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
+	int oflags = 0;
+	args >> oflags;
+
+	bool bRet = m_ppsServer.open(path, oflags);
+
+	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - failed to open \"" + path + "\".";
+}
+
+std::string JPPSServerPlugin::close()
+{
+	m_ppsServer.close();
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::setVerbose(std::stringstream& args)
+{
+	unsigned short verbosity = 0;
+
+	// If no param was passed, default to 0, else read the value
+	if (!args.eof())
+		args >> verbosity;
+
+	m_ppsServer.setVerbose(verbosity);
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::sendMessage(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
+
+	// Get the arguments
+	// 1st arg, the clientId
+	std::string clientId;
+	args >> clientId;
+
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the clientID and the message
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsServer.sendMessage(clientId, tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+std::string JPPSServerPlugin::broadcastMessage(std::stringstream& args)
+{
+	// We don't have enough args
+	if (args.eof())
+		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::broadcastMessage() - invalid number of arguments.";
+
+	// This truncates the buffer from the current position onwards (if you don't do this, you keep
+	// the method name that's at the beginning of the args stream)
+	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the method name and the message
+	std::stringstream tmp;
+	tmp << args.rdbuf();
+
+	m_ppsServer.broadcastMessage(tmp.str());
+	return szOK + m_jnextObjId;
+}
+
+void JPPSServerPlugin::onEvent(const std::string& sEvent) const
+{
+	// We have to add our object Id to the event
+	std::string pluginEvent = m_jnextObjId + " " + sEvent;
+	SendPluginEvent(pluginEvent.c_str(), m_pContext);
+}
+
+void JPPSServerPlugin::onEvent(void* pArg, const std::string& sEvent)
+{
+	// Cast pArg back to JPPSPlugin and invoke onEvent()
+	JPPSServerPlugin* pPlugin = static_cast<JPPSServerPlugin*>(pArg);
+
+	if (pPlugin != NULL)
+		pPlugin->onEvent(sEvent);
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
new file mode 100644
index 0000000..ea5b18f
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef JPPSSERVERPLUGIN_H_
+#define JPPSSERVERPLUGIN_H_
+
+#include "../common/plugin.h"
+#include "PPSServerGlue.h"
+
+namespace jpps {
+
+class JPPSServerPlugin: public JSExt {
+
+public:
+
+	// Constants
+
+	/** The only class supported by this plugin. */
+	static const char* CLASS_NAME;
+
+	// List of object methods supported by this extension
+
+	/** Open a PPS object/directory. */
+	static const std::string METHOD_OPEN;
+	/** Close a PPS object/directory. */
+	static const std::string METHOD_CLOSE;
+	/** Adjust output verbosity. */
+	static const std::string METHOD_SET_VERBOSE;
+	/** Send a message to a particular client. */
+	static const std::string METHOD_SEND_MESSAGE;
+	/** Send a message to all clients. */
+	static const std::string METHOD_BROADCAST_MESSAGE;
+
+	/**
+	 * Constructor.
+	 */
+	JPPSServerPlugin(const std::string& jnextObjectId);
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~JPPSServerPlugin();
+
+	// Inherited from JSExt
+	virtual std::string InvokeMethod(const std::string& strCommand);
+	virtual inline bool CanDelete(void) { return true; }
+
+	/**
+	 *  Static callback method, changes pArg back into a JPPSServerPlugin and invokes
+	 *  the non-static version of onEvent().
+	 */
+	static void onEvent(void* pArg, const std::string& sEvent);
+
+private:
+
+	// Disable default constructor.
+	JPPSServerPlugin();
+
+	/**
+	 * The non-static version of onEvent. Handler for the PPSServerGlue class' events.
+	 */
+	void onEvent(const std::string& sEvent) const;
+
+	/**
+	 * Open a PPS object.
+	 */
+	std::string open(std::stringstream& args);
+
+	/**
+	 * Close the PPS object.
+	 */
+	std::string close();
+
+	/**
+	 * Set the verbosity level for logging to slog.
+	 */
+	std::string setVerbose(std::stringstream& args);
+
+	/**
+	 * Send a message to a particular client.
+	 */
+	std::string sendMessage(std::stringstream& args);
+
+	/**
+	 * Send a message to all clients.
+	 */
+	std::string broadcastMessage(std::stringstream& args);
+
+	/** A unique JNext id for this object */
+	std::string m_jnextObjId;
+
+	/** The PPS object. */
+	PPSServerGlue m_ppsServer;
+};
+
+} /* namespace jpps */
+#endif /* JPPSSERVERPLUGIN_H_ */


[02/50] [abbrv] webworks commit: add plugin script for adding plugins, depends on plugman

Posted by lo...@apache.org.
add plugin script for adding plugins, depends on plugman

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/6567f47a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/6567f47a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/6567f47a

Branch: refs/heads/future
Commit: 6567f47a32a6c96f5aebd887300a760f0fd9283f
Parents: cd754d0
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Mon Mar 18 23:04:00 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/templates/project/cordova/plugin  |    7 +++++++
 .../bin/templates/project/cordova/plugin.bat       |    5 +++++
 blackberry10/package.json                          |    3 ++-
 3 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6567f47a/blackberry10/bin/templates/project/cordova/plugin
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin b/blackberry10/bin/templates/project/cordova/plugin
new file mode 100755
index 0000000..fb7c467
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/plugin
@@ -0,0 +1,7 @@
+#!/bin/sh
+cd $( dirname "$0")/../
+
+if [ "$1" = "add" ]
+    then
+        ./cordova/node_modules/plugman/plugman.js  --platform blackberry10 --project . --plugin $2
+fi

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6567f47a/blackberry10/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin.bat b/blackberry10/bin/templates/project/cordova/plugin.bat
new file mode 100755
index 0000000..647412f
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/plugin.bat
@@ -0,0 +1,5 @@
+cd %~dp0\..\
+
+if "%1" == "add" (
+    @node.exe ./cordova/node_modules/plugman/plugman.js --platform blackberry10 --project . --plugin %2
+)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6567f47a/blackberry10/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/package.json b/blackberry10/package.json
index 08d0e5e..ed87b2a 100644
--- a/blackberry10/package.json
+++ b/blackberry10/package.json
@@ -19,7 +19,8 @@
     "zip": "0.0.6",
     "xml2js": "0.1.13",
     "validator": "0.4.1",
-    "wrench": "1.3.9"
+    "wrench": "1.3.9",
+    "plugman": "git+https://github.com/blackberry/cordova-plugman.git#master"
   },
   "files": [
     "node_modules",


[33/50] [abbrv] webworks commit: Update plugin script and template to work with plugman changes

Posted by lo...@apache.org.
Update plugin script and template to work with plugman changes

Reviewed by Bryan Higgins <bh...@blackberry.com>


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

Branch: refs/heads/future
Commit: b0a540b83e520f6b4fcc01071e865f4a6e0a93c5
Parents: d753ae3
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Wed Apr 24 16:27:20 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 .gitignore                                         |    3 +
 .../templates/project/cordova/lib/file-manager.js  |    9 +-
 blackberry10/bin/templates/project/cordova/plugin  |   75 ++-
 .../bin/templates/project/cordova/plugin.bat       |   22 +-
 .../project/plugins/Accelerometer/index.js         |   45 -
 .../project/plugins/Accelerometer/plugin.xml       |   29 +
 .../Accelerometer/src/blackberry10/index.js        |   45 +
 .../bin/templates/project/plugins/Battery/index.js |   49 --
 .../templates/project/plugins/Battery/plugin.xml   |   29 +
 .../plugins/Battery/src/blackberry10/index.js      |   49 ++
 .../bin/templates/project/plugins/Camera/index.js  |  124 ---
 .../templates/project/plugins/Camera/plugin.xml    |   29 +
 .../plugins/Camera/src/blackberry10/index.js       |  124 +++
 .../bin/templates/project/plugins/Device/index.js  |   60 --
 .../templates/project/plugins/Device/plugin.xml    |   29 +
 .../plugins/Device/src/blackberry10/index.js       |   60 ++
 .../templates/project/plugins/JPPS/native/Makefile |    8 -
 .../project/plugins/JPPS/native/common.mk          |   34 -
 .../project/plugins/JPPS/native/device/libjpps.so  |  Bin 138046 -> 0 bytes
 .../plugins/JPPS/native/simulator/libjpps.so       |  Bin 224392 -> 0 bytes
 .../plugins/JPPS/native/src/core/PPSEvent.h        |  108 ---
 .../plugins/JPPS/native/src/core/PPSInterface.cpp  |  632 ---------------
 .../plugins/JPPS/native/src/core/PPSInterface.h    |  238 ------
 .../plugins/JPPS/native/src/core/PPSNotifier.cpp   |  126 ---
 .../plugins/JPPS/native/src/core/PPSNotifier.h     |  159 ----
 .../JPPS/native/src/core/PPSNotifyGroupManager.cpp |  107 ---
 .../JPPS/native/src/core/PPSNotifyGroupManager.h   |  133 ---
 .../plugins/JPPS/native/src/core/PPSTypes.h        |   96 ---
 .../plugins/JPPS/native/src/plugin/JPPSPlugin.cpp  |  149 ----
 .../plugins/JPPS/native/src/plugin/JPPSPlugin.h    |  122 ---
 .../JPPS/native/src/plugin/JPPSServerPlugin.cpp    |  168 ----
 .../JPPS/native/src/plugin/JPPSServerPlugin.h      |  115 ---
 .../JPPS/native/src/plugin/PPSInterfaceGlue.cpp    |  355 --------
 .../JPPS/native/src/plugin/PPSInterfaceGlue.h      |  177 ----
 .../JPPS/native/src/plugin/PPSServerGlue.cpp       |  300 -------
 .../plugins/JPPS/native/src/plugin/PPSServerGlue.h |  165 ----
 .../plugins/JPPS/native/src/plugin/PluginTypes.h   |   35 -
 .../JPPS/native/src/plugin/pluginManifest.cpp      |   76 --
 .../project/plugins/JPPS/native/src/utils/Logger.h |   94 ---
 .../plugins/JPPS/native/src/utils/Thread.cpp       |   71 --
 .../project/plugins/JPPS/native/src/utils/Thread.h |   73 --
 .../bin/templates/project/plugins/Logger/index.js  |   25 -
 .../templates/project/plugins/Logger/plugin.xml    |   29 +
 .../plugins/Logger/src/blackberry10/index.js       |   25 +
 .../project/plugins/NetworkStatus/index.js         |   59 --
 .../project/plugins/NetworkStatus/plugin.xml       |   29 +
 .../NetworkStatus/src/blackberry10/index.js        |   59 ++
 .../project/plugins/Notification/index.js          |   91 --
 .../project/plugins/Notification/plugin.xml        |   29 +
 .../plugins/Notification/src/blackberry10/index.js |   91 ++
 .../project/plugins/SplashScreen/index.js          |   28 -
 .../project/plugins/SplashScreen/plugin.xml        |   29 +
 .../plugins/SplashScreen/src/blackberry10/index.js |   28 +
 .../project/plugins/Utils/native/Makefile          |    8 -
 .../project/plugins/Utils/native/common.mk         |   18 -
 .../plugins/Utils/native/device/libutils.so        |  Bin 130206 -> 0 bytes
 .../plugins/Utils/native/simulator/libutils.so     |  Bin 183184 -> 0 bytes
 .../plugins/Utils/native/webworks_utils.cpp        |   55 --
 .../plugins/Utils/native/webworks_utils.hpp        |   34 -
 .../project/plugins/com.blackberry.jpps/plugin.xml |   22 +
 .../src/blackberry10/native/device/libjpps.so      |  Bin 0 -> 138046 bytes
 .../src/blackberry10/native/simulator/libjpps.so   |  Bin 0 -> 224392 bytes
 .../plugins/com.blackberry.utils/plugin.xml        |   22 +
 .../src/blackberry10/native/device/libutils.so     |  Bin 0 -> 130206 bytes
 .../src/blackberry10/native/simulator/libutils.so  |  Bin 0 -> 183184 bytes
 blackberry10/javascript/cordova.blackberry10.js    |  194 +----
 66 files changed, 875 insertions(+), 4322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9b1cdef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+#Output files
+*.o
+*.a

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/cordova/lib/file-manager.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/file-manager.js b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
index 3f9e92b..5f37894 100755
--- a/blackberry10/bin/templates/project/cordova/lib/file-manager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
@@ -235,25 +235,26 @@ function hasValidExtension(file) {
 
 function copyExtension(session, target, pluginPath) {
     var basename = path.basename(pluginPath),
+        pluginSrcPath = path.join(pluginPath, "src", "blackberry10"),
         extDest = session.sourcePaths.EXT,
         soDest = session.sourcePaths.JNEXT_PLUGINS,
-        soPath = path.normalize(path.join(pluginPath, "native", target)),
+        soPath = path.normalize(path.join(pluginSrcPath, "native", target)),
         jsFiles,
         soFiles;
 
-    if (fs.existsSync(pluginPath) && fs.statSync(pluginPath).isDirectory()) {
+    if (fs.existsSync(pluginSrcPath) && fs.statSync(pluginSrcPath).isDirectory()) {
         //create output folders
         wrench.mkdirSyncRecursive(path.join(extDest, basename), "0755");
         wrench.mkdirSyncRecursive(soDest, "0755");
 
         //find all .js and .json files
-        jsFiles = packagerUtils.listFiles(pluginPath, function (file) {
+        jsFiles = packagerUtils.listFiles(pluginSrcPath, function (file) {
             return hasValidExtension(file);
         });
 
         //Copy each .js file to its extensions folder
         jsFiles.forEach(function (jsFile) {
-            packagerUtils.copyFile(jsFile, path.join(extDest, basename), pluginPath);
+            packagerUtils.copyFile(jsFile, path.join(extDest, basename), pluginSrcPath);
         });
 
         if (fs.existsSync(soPath)) {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/cordova/plugin
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin b/blackberry10/bin/templates/project/cordova/plugin
index fb7c467..ae261b5 100755
--- a/blackberry10/bin/templates/project/cordova/plugin
+++ b/blackberry10/bin/templates/project/cordova/plugin
@@ -1,7 +1,70 @@
-#!/bin/sh
-cd $( dirname "$0")/../
+#!/usr/bin/env node
 
-if [ "$1" = "add" ]
-    then
-        ./cordova/node_modules/plugman/plugman.js  --platform blackberry10 --project . --plugin $2
-fi
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 action = process.argv[2],
+    plugin = process.argv[3],
+    PLUGMAN = require("path").join(__dirname, "node_modules", "plugman", "main.js"),
+    argumentor = {
+        argIndex: 2,
+        setAction: function () {
+            process.argv[this.argIndex++] = "--" + action;
+            return argumentor;
+        },
+        setPlatform: function () {
+            process.argv[this.argIndex++] = "--platform";
+            process.argv[this.argIndex++] = "blackberry10";
+            return argumentor;
+        },
+        setProject: function () {
+            process.argv[this.argIndex++] = "--project";
+            process.argv[this.argIndex++] = ".";
+            return argumentor;
+        },
+        setPlugin: function () {
+            process.argv[this.argIndex++] = "--plugin";
+            process.argv[this.argIndex++] = plugin.charAt(plugin.length - 1) === "/" ? plugin.slice(0, -1) : plugin;
+            return argumentor;
+        },
+        setPluginsDir: function () {
+            process.argv[this.argIndex++] = "--plugins_dir";
+            process.argv[this.argIndex++] = "./plugins";
+            return argumentor;
+        }
+    };
+
+switch(action) {
+    case "uninstall":
+        argumentor.setAction();
+    case "install":
+        argumentor.setPlatform().setProject().setPlugin().setPluginsDir();
+        break;
+    case "fetch":
+    case "remove":
+        argumentor.setAction().setPlugin().setPluginsDir();
+        break;
+    case "prepare":
+        argumentor.setAction().setPlatform().setProject().setPluginsDir();
+        break;
+    case "list":
+        argumentor.setAction();
+}
+
+require(PLUGMAN);

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin.bat b/blackberry10/bin/templates/project/cordova/plugin.bat
index 5406de4..b3874ac 100755
--- a/blackberry10/bin/templates/project/cordova/plugin.bat
+++ b/blackberry10/bin/templates/project/cordova/plugin.bat
@@ -1,7 +1,21 @@
 @ECHO OFF
+goto comment
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you 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
 
-cd %~dp0..\
+         http://www.apache.org/licenses/LICENSE-2.0
 
-if "%1" == "add" (
-    @node.exe ./cordova/node_modules/plugman/plugman.js --platform blackberry10 --project . --plugin %2
-)
+       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.
+:comment
+
+@node.exe %~dp0\plugin

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/index.js b/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
deleted file mode 100644
index 47abe42..0000000
--- a/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 callback;
-
-module.exports = {
-    start: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        window.removeEventListener("devicemotion", callback);
-        callback = function (motion) {
-            var info = {
-                x: motion.accelerationIncludingGravity.x,
-                y: motion.accelerationIncludingGravity.y,
-                z: motion.accelerationIncludingGravity.z,
-                timestamp: motion.timestamp
-            };
-            result.callbackOk(info, true);
-        };
-        window.addEventListener("devicemotion", callback);
-        result.noResult(true);
-    },
-    stop: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        window.removeEventListener("devicemotion", callback);
-        result.ok("removed");
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml b/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml
new file mode 100644
index 0000000..bc5c712
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Accelerometer</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Acceleromter" value="Accelerometer"/>
+        </config-file>
+      </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js
new file mode 100644
index 0000000..47abe42
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 callback;
+
+module.exports = {
+    start: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.removeEventListener("devicemotion", callback);
+        callback = function (motion) {
+            var info = {
+                x: motion.accelerationIncludingGravity.x,
+                y: motion.accelerationIncludingGravity.y,
+                z: motion.accelerationIncludingGravity.z,
+                timestamp: motion.timestamp
+            };
+            result.callbackOk(info, true);
+        };
+        window.addEventListener("devicemotion", callback);
+        result.noResult(true);
+    },
+    stop: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.removeEventListener("devicemotion", callback);
+        result.ok("removed");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Battery/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Battery/index.js b/blackberry10/bin/templates/project/plugins/Battery/index.js
deleted file mode 100644
index fcac7b2..0000000
--- a/blackberry10/bin/templates/project/plugins/Battery/index.js
+++ /dev/null
@@ -1,49 +0,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 SYSTEM_EVENTS = ["device.battery.statusChange",
-                     "device.battery.chargeLow",
-                     "device.battery.chargeCritical"],
-    clientListener;
-
-module.exports = {
-    start: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        if (!!clientListener) {
-            result.error("Battery listener already running");
-        } else {
-            clientListener = function (info) {
-                result.callbackOk(info, true);
-            };
-            SYSTEM_EVENTS.forEach(function (event) {
-                window.qnx.webplatform.device.addEventListener(event, clientListener);
-            });
-            result.noResult(true);
-        }
-    },
-    stop: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        if (!clientListener) {
-            result.error("Battery listener has not started");
-        } else {
-            SYSTEM_EVENTS.forEach(function (event) {
-                window.qnx.webplatform.device.removeEventListener(event, clientListener);
-            });
-            clientListener = null;
-            result.noResult(false);
-        }
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Battery/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Battery/plugin.xml b/blackberry10/bin/templates/project/plugins/Battery/plugin.xml
new file mode 100644
index 0000000..242ff4a
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Battery/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Battery</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Battery" value="Battery"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js
new file mode 100644
index 0000000..fcac7b2
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js
@@ -0,0 +1,49 @@
+/*
+ * 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 SYSTEM_EVENTS = ["device.battery.statusChange",
+                     "device.battery.chargeLow",
+                     "device.battery.chargeCritical"],
+    clientListener;
+
+module.exports = {
+    start: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        if (!!clientListener) {
+            result.error("Battery listener already running");
+        } else {
+            clientListener = function (info) {
+                result.callbackOk(info, true);
+            };
+            SYSTEM_EVENTS.forEach(function (event) {
+                window.qnx.webplatform.device.addEventListener(event, clientListener);
+            });
+            result.noResult(true);
+        }
+    },
+    stop: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        if (!clientListener) {
+            result.error("Battery listener has not started");
+        } else {
+            SYSTEM_EVENTS.forEach(function (event) {
+                window.qnx.webplatform.device.removeEventListener(event, clientListener);
+            });
+            clientListener = null;
+            result.noResult(false);
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Camera/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Camera/index.js b/blackberry10/bin/templates/project/plugins/Camera/index.js
deleted file mode 100644
index 922f049..0000000
--- a/blackberry10/bin/templates/project/plugins/Camera/index.js
+++ /dev/null
@@ -1,124 +0,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 PictureSourceType = {
-        PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
-        CAMERA : 1,          // Take picture from camera
-        SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
-    },
-    DestinationType = {
-        DATA_URL: 0,         // Return base64 encoded string
-        FILE_URI: 1,         // Return file uri (content://media/external/images/media/2 for Android)
-        NATIVE_URI: 2        // Return native uri (eg. asset-library://... for iOS)
-    };
-
-function encodeBase64(filePath, callback) {
-    var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value
-        errorHandler = function (err) {
-            var msg = "An error occured: ";
-
-            switch (err.code) {
-            case FileError.NOT_FOUND_ERR:
-                msg += "File or directory not found";
-                break;
-
-            case FileError.NOT_READABLE_ERR:
-                msg += "File or directory not readable";
-                break;
-
-            case FileError.PATH_EXISTS_ERR:
-                msg += "File or directory already exists";
-                break;
-
-            case FileError.TYPE_MISMATCH_ERR:
-                msg += "Invalid file type";
-                break;
-
-            default:
-                msg += "Unknown Error";
-                break;
-            };
-
-            // set it back to original value
-            window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
-            callback(msg);
-        },
-        gotFile = function (fileEntry) {
-            fileEntry.file(function (file) {
-                var reader = new FileReader();
-
-                reader.onloadend = function (e) {
-                    // set it back to original value
-                    window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
-                    callback(this.result);
-                };
-
-                reader.readAsDataURL(file);
-            }, errorHandler);
-        },
-        onInitFs = function (fs) {
-            window.qnx.webplatform.getController().setFileSystemSandbox = false;
-            fs.root.getFile(filePath, {create: false}, gotFile, errorHandler);
-        };
-
-    window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max
-}
-
-module.exports = {
-    takePicture: function (success, fail, args, env) {
-        var destinationType = JSON.parse(decodeURIComponent(args[1])),
-            sourceType = JSON.parse(decodeURIComponent(args[2])),
-            result = new PluginResult(args, env),
-            done = function (data) {
-                if (destinationType === DestinationType.FILE_URI) {
-                    data = "file://" + data;
-                    result.callbackOk(data, false);
-                } else {
-                    encodeBase64(data, function (data) {
-                        if (/^data:/.test(data)) {
-                            data = data.slice(data.indexOf(",") + 1);
-                            result.callbackOk(data, false);
-                        } else {
-                            result.callbackError(data, false);
-                        }
-                    });
-                }
-            },
-            cancel = function (reason) {
-                result.callbackError(reason, false);
-            },
-            invoked = function (error) {
-                if (error) {
-                    result.callbackError(error, false);
-                }
-            };
-
-        switch(sourceType) {
-        case PictureSourceType.CAMERA:
-            window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked);
-            break;
-
-        case PictureSourceType.PHOTOLIBRARY:
-        case PictureSourceType.SAVEDPHOTOALBUM:
-            window.qnx.webplatform.getApplication().cards.filePicker.open({
-                mode: "Picker",
-                type: ["picture"]
-            }, done, cancel, invoked);
-            break;
-        }
-
-        result.noResult(true);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Camera/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Camera/plugin.xml b/blackberry10/bin/templates/project/plugins/Camera/plugin.xml
new file mode 100644
index 0000000..a5df260
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Camera/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Camera</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Camera" value="Camera"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js
new file mode 100644
index 0000000..922f049
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js
@@ -0,0 +1,124 @@
+/*
+ * 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 PictureSourceType = {
+        PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
+        CAMERA : 1,          // Take picture from camera
+        SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+    },
+    DestinationType = {
+        DATA_URL: 0,         // Return base64 encoded string
+        FILE_URI: 1,         // Return file uri (content://media/external/images/media/2 for Android)
+        NATIVE_URI: 2        // Return native uri (eg. asset-library://... for iOS)
+    };
+
+function encodeBase64(filePath, callback) {
+    var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value
+        errorHandler = function (err) {
+            var msg = "An error occured: ";
+
+            switch (err.code) {
+            case FileError.NOT_FOUND_ERR:
+                msg += "File or directory not found";
+                break;
+
+            case FileError.NOT_READABLE_ERR:
+                msg += "File or directory not readable";
+                break;
+
+            case FileError.PATH_EXISTS_ERR:
+                msg += "File or directory already exists";
+                break;
+
+            case FileError.TYPE_MISMATCH_ERR:
+                msg += "Invalid file type";
+                break;
+
+            default:
+                msg += "Unknown Error";
+                break;
+            };
+
+            // set it back to original value
+            window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
+            callback(msg);
+        },
+        gotFile = function (fileEntry) {
+            fileEntry.file(function (file) {
+                var reader = new FileReader();
+
+                reader.onloadend = function (e) {
+                    // set it back to original value
+                    window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
+                    callback(this.result);
+                };
+
+                reader.readAsDataURL(file);
+            }, errorHandler);
+        },
+        onInitFs = function (fs) {
+            window.qnx.webplatform.getController().setFileSystemSandbox = false;
+            fs.root.getFile(filePath, {create: false}, gotFile, errorHandler);
+        };
+
+    window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max
+}
+
+module.exports = {
+    takePicture: function (success, fail, args, env) {
+        var destinationType = JSON.parse(decodeURIComponent(args[1])),
+            sourceType = JSON.parse(decodeURIComponent(args[2])),
+            result = new PluginResult(args, env),
+            done = function (data) {
+                if (destinationType === DestinationType.FILE_URI) {
+                    data = "file://" + data;
+                    result.callbackOk(data, false);
+                } else {
+                    encodeBase64(data, function (data) {
+                        if (/^data:/.test(data)) {
+                            data = data.slice(data.indexOf(",") + 1);
+                            result.callbackOk(data, false);
+                        } else {
+                            result.callbackError(data, false);
+                        }
+                    });
+                }
+            },
+            cancel = function (reason) {
+                result.callbackError(reason, false);
+            },
+            invoked = function (error) {
+                if (error) {
+                    result.callbackError(error, false);
+                }
+            };
+
+        switch(sourceType) {
+        case PictureSourceType.CAMERA:
+            window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked);
+            break;
+
+        case PictureSourceType.PHOTOLIBRARY:
+        case PictureSourceType.SAVEDPHOTOALBUM:
+            window.qnx.webplatform.getApplication().cards.filePicker.open({
+                mode: "Picker",
+                type: ["picture"]
+            }, done, cancel, invoked);
+            break;
+        }
+
+        result.noResult(true);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/index.js b/blackberry10/bin/templates/project/plugins/Device/index.js
deleted file mode 100644
index f4849f5..0000000
--- a/blackberry10/bin/templates/project/plugins/Device/index.js
+++ /dev/null
@@ -1,60 +0,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.
- */
-
-function getModelName () {
-    var modelName = window.qnx.webplatform.device.modelName;
-    //Pre 10.2 (meaning Z10 or Q10)
-    if (typeof modelName === "undefined") {
-        if (window.screen.height === 720 && window.screen.width === 720) {
-            modelName = "Q10";
-        } else if ((window.screen.height === 1280 && window.screen.width === 768) ||
-                   (window.screen.height === 768 && window.screen.width === 1280)) {
-            modelName = "Z10";
-        } else {
-            modelName = window.qnx.webplatform.deviceName;
-        }
-    }
-
-    return modelName;
-}
-
-function getUUID () {
-    var uuid = "";
-    try {
-        //Must surround by try catch because this will throw if the app is missing permissions
-        uuid = window.qnx.webplatform.device.devicePin;
-    } catch (e) {
-        //DO Nothing
-    }
-    return uuid;
-}
-
-module.exports = {
-    getDeviceInfo: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            modelName = getModelName(),
-            uuid = getUUID(),
-            info = {
-                platform: "blackberry10",
-                version: window.qnx.webplatform.device.scmBundle,
-                model: modelName,
-                name: modelName, // deprecated: please use device.model
-                uuid: uuid,
-                cordova: "2.5.0"
-            };
-        result.ok(info);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Device/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/plugin.xml b/blackberry10/bin/templates/project/plugins/Device/plugin.xml
new file mode 100644
index 0000000..39055c0
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Device/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Device</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Device" value="Device"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
new file mode 100644
index 0000000..f4849f5
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+function getModelName () {
+    var modelName = window.qnx.webplatform.device.modelName;
+    //Pre 10.2 (meaning Z10 or Q10)
+    if (typeof modelName === "undefined") {
+        if (window.screen.height === 720 && window.screen.width === 720) {
+            modelName = "Q10";
+        } else if ((window.screen.height === 1280 && window.screen.width === 768) ||
+                   (window.screen.height === 768 && window.screen.width === 1280)) {
+            modelName = "Z10";
+        } else {
+            modelName = window.qnx.webplatform.deviceName;
+        }
+    }
+
+    return modelName;
+}
+
+function getUUID () {
+    var uuid = "";
+    try {
+        //Must surround by try catch because this will throw if the app is missing permissions
+        uuid = window.qnx.webplatform.device.devicePin;
+    } catch (e) {
+        //DO Nothing
+    }
+    return uuid;
+}
+
+module.exports = {
+    getDeviceInfo: function (success, fail, args, env) {
+        var result = new PluginResult(args, env),
+            modelName = getModelName(),
+            uuid = getUUID(),
+            info = {
+                platform: "blackberry10",
+                version: window.qnx.webplatform.device.scmBundle,
+                model: modelName,
+                name: modelName, // deprecated: please use device.model
+                uuid: uuid,
+                cordova: "2.5.0"
+            };
+        result.ok(info);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=CPU
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk b/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
deleted file mode 100644
index 6cecca9..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/common.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-NAME=jpps
-PLUGIN=yes
-UTILS=yes
-
-include ../../../../../../meta.mk
-
-override CCFLAGS := $(filter-out -Werror , $(CCFLAGS))
-
-EXTRA_SRCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
-
-EXTRA_INCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
-
-SRCS+=src/utils/Thread.cpp \
-      src/core/PPSInterface.cpp \
-      src/core/PPSNotifier.cpp \
-      src/core/PPSNotifyGroupManager.cpp \
-      src/plugin/JPPSPlugin.cpp \
-      src/plugin/PPSInterfaceGlue.cpp \
-      src/plugin/JPPSServerPlugin.cpp \
-      src/plugin/PPSServerGlue.cpp \
-      src/plugin/pluginManifest.cpp
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-LIBS+=pps

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so
deleted file mode 100644
index f0eb90d..0000000
Binary files a/blackberry10/bin/templates/project/plugins/JPPS/native/device/libjpps.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so
deleted file mode 100644
index f2c12ff..0000000
Binary files a/blackberry10/bin/templates/project/plugins/JPPS/native/simulator/libjpps.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
deleted file mode 100644
index 808e699..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSEvent.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSEVENT_H_
-#define PPSEVENT_H_
-
-#include <string>
-#include "PPSTypes.h"
-
-namespace jpps {
-
-/**
- * A class representing a PPS event. Used to notify interested parties when something
- * happens to a PPS object.
- */
-class PPSEvent {
-
-public:
-
-	/**
-	 * The possible types of this event.
-	 */
-	enum PPSEventType {
-		/** The PPS object's first data read is complete. */
-		PPS_EVENT_FIRST_READ_COMPLETE,
-		/** The PPS object has new data. */
-		PPS_EVENT_NEW_DATA,
-		/** The PPS object was successfully opened. */
-		PPS_EVENT_OPENED,
-		/** A PPS object was closed. */
-		PPS_EVENT_CLOSED,
-		/** An attempt to open a PPS object failed. */
-		PPS_EVENT_OPEN_FAILED,
-		/** An attempt to read from a PPS object failed. */
-		PPS_EVENT_READ_FAILED,
-		/** An attempt to write to a PPS object failed. */
-		PPS_EVENT_WRITE_FAILED,
-	};
-
-	/**
-	 * Constructor.
-	 *
-	 * @param eventType The type of event this is.
-	 * @param data If eventType == PPS_EVENT_NEW_DATA, the new data.
-	 */
-	PPSEvent(PPSEventType eventType, const std::string& msg = "", const ppsObject& newData = ppsObject())
-	: m_eventType(eventType)
-	, m_message(msg)
-	, m_newData(newData)
-	{}
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSEvent() {}
-
-	/**
-	 * Get the event type.
-	 */
-	inline PPSEventType getEventType() const { return m_eventType; }
-
-	/**
-	 * Get the message associated with this event.
-	 */
-	inline std::string getMessage() const { return m_message; }
-
-	/**
-	 * Get the new data. This value is only populated if the eventType is PPS_EVENT_NEW_DATA. This data
-	 * is what was parsed out of the PPS object.
-	 */
-	inline ppsObject getNewData() const { return m_newData; }
-
-private:
-
-	// Disable the default constructor.
-	PPSEvent();
-
-	/** The type of this event. */
-	PPSEventType m_eventType;
-
-	/** A message associated to the event. */
-	std::string m_message;
-
-	/** If m_eventType == PPS_EVENT_NEW_DATA, this contains the new data. Else m_newData is empty.
-	 * This data is the data that was read from the PPS object, un-massaged. */
-	ppsObject m_newData;
-};
-
-} /* namespace jpps */
-#endif /* PPSEVENT_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
deleted file mode 100644
index dfb575b..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.cpp
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSInterface.h"
-
-#include <sstream>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <ppsparse.h>
-#include <string.h>
-
-#include "PPSNotifyGroupManager.h"
-#include "PPSEvent.h"
-
-namespace jpps {
-
-// Const statics
-const char* PPSInterface::PPS_ROOT = "/pps/";
-const int PPSInterface::MaxPPSReadSize = (32 * 1024);
-
-// Static data members
-pthread_mutex_t PPSInterface::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t PPSInterface::sm_cond;
-volatile bool PPSInterface::sm_firstInitDone = false;
-std::map<unsigned int, PPSInterface*> PPSInterface::sm_interfaceLookupTable;
-
-PPSInterface::PPSInterface()
-: m_pEventFunc(NULL)
-, m_pEventArg(NULL)
-, m_interfaceId(0)
-, m_fd(-1)
-, m_oflags(0)
-, m_firstRead(true)
-, m_cachedRead()
-, m_logger()
-{
-	// This is used to assign a unique ID to each PPSInterface object
-	static unsigned int interfaceIDs = 0;
-
-	::pthread_mutex_lock(&sm_mutex);
-
-	m_interfaceId = interfaceIDs;
-	interfaceIDs++; // Increment this so that the next object has a unique id.
-
-	// Add myself to the lookup table
-	sm_interfaceLookupTable.insert(std::pair<unsigned int, PPSInterface*>(m_interfaceId, this));
-
-	if (!sm_firstInitDone) {
-
-		// Initialize the condvar
-		pthread_condattr_t condAttr;
-		::pthread_condattr_init(&condAttr);
-		::pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
-		::pthread_cond_init(&sm_cond, &condAttr);
-		::pthread_condattr_destroy(&condAttr);
-
-		sm_firstInitDone = true;
-	}
-
-	::pthread_mutex_unlock(&sm_mutex);
-}
-
-PPSInterface::~PPSInterface()
-{
-	std::ostringstream ostream;
-	ostream << "PPSInterface::~PPSInterface() - Destruct fd:" << m_fd << ".";
-	m_logger.slog(Logger::debug, ostream.str());
-
-	// Close my open PPS object, if I have one
-	close();
-
-	// Remove myself from the lookup table
-	sm_interfaceLookupTable.erase(m_interfaceId);
-}
-
-void PPSInterface::setVerbose(unsigned short v)
-{
-	m_logger.setVerbosity(v);
-}
-
-void PPSInterface::setEventFunc(const PPSEventFunc* pEventFunc, void* pArg)
-{
-	m_pEventFunc = pEventFunc;
-	m_pEventArg = pArg;
-}
-
-bool PPSInterface::open(const std::string& path, int oflag, int mode, bool server)
-{
-	// If we've already got an open file, fail
-	if (m_fd != -1) {
-
-		m_logger.slog(Logger::warning, "PPSInterface::open() Failed - Attempted to open an object that is already open.");
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_OPEN_FAILED, "Attempted to open an object that is already open."));
-		return false;
-	}
-
-	std::string errorMsg;
-	bool ok = false;
-
-	// Prepend PPS_ROOT to the path if it doesn't start with a '/'
-	std::string fullpath = (path[0] != '/' ? PPSInterface::PPS_ROOT : "") + path;
-
-	// This flag is used to prevent the notify thread from performing reads while the
-	// open() function is running and doing its first read.
-	::pthread_mutex_lock(&sm_mutex);
-	m_firstRead = true;
-	::pthread_mutex_unlock(&sm_mutex);
-
-	// Remove any options from the path otherwise lstat will fail
-	std::string pathNoOptions(fullpath);
-	std::size_t nPosOpts = fullpath.rfind('?');
-
-	if (nPosOpts != std::string::npos)
-		pathNoOptions = fullpath.substr(0, nPosOpts);
-
-	// There are a few complexities associated with symbolic links.  If
-	// the last component of the path is a symlink we have to resolve it
-	// since we won't be able to resolve the name when the options are
-	// added.  Also we need to get the path relative to the pps filesystem
-	// so we can locate the .notify file.  So, if the object already
-	// exists, resolve the path.  If it doesn't and O_CREAT is specified
-	// resolve the directory it's in, otherwise it's a failure.
-	std::string resolvedName;
-	char szResolvedName[PATH_MAX+128]; // buffer for use with the C functions
-
-	if (::realpath(pathNoOptions.c_str(), szResolvedName) != NULL) {
-
-		resolvedName = szResolvedName;
-		ok = true;
-	}
-	else if (oflag & O_CREAT) {
-
-		// Chop off the file name, so we can try to resolve the directory
-		size_t nPos = pathNoOptions.rfind('/');
-
-		// We found a '/'
-		if (nPos != std::string::npos) {
-
-			// Get the directory path
-			std::string dirPath = pathNoOptions.substr(0, nPos); // Don't include the '/'
-
-			if (::realpath(dirPath.c_str(), szResolvedName) != NULL) {
-
-				// Concatenate the file name to the resolved directory path
-				resolvedName = szResolvedName + pathNoOptions.substr(nPos); // include the '/' at the start
-				ok = true;
-			}
-		}
-	}
-
-	if (ok) {
-
-		struct stat info;
-		int result = ::lstat(resolvedName.c_str(), &info);
-
-		if (result != 0) {
-
-			// If we failed and we're not creating a non-existent file, it's an error.
-			if ((errno != ENOENT) && !(oflag & O_CREAT))
-				ok = false;
-		}
-		else if (S_ISDIR(info.st_mode))
-			ok = false;
-	}
-
-	if (ok) {
-
-		std::string options;
-
-		// Now lets work with the options to ensure we have a complete version
-		std::string pathOptions;
-		
-		// Get just the stuff after '?'
-		size_t nPos = fullpath.rfind('?');
-
-		if (nPos != std::string::npos) {
-			pathOptions = fullpath.substr(nPos);
-		}
-
-		if ((oflag & O_ACCMODE) != O_WRONLY) {
-
-			// This is used as the return object for the joinNotifyGroup() call
-			// It's only valid if joinNotifyGroup() returned true
-			std::string groupId;
-
-			PPSNotifyGroupManager::mutexLock();
-			PPSNotifyGroupManager& notifyManager = PPSNotifyGroupManager::getInstance();
-			bool groupJoined = notifyManager.joinNotifyGroup(resolvedName, groupId);
-			PPSNotifyGroupManager::mutexUnlock();
-
-			if (groupJoined) {
-
-				// If we're acting as a server, we use server as an option
-				// otherwise we have to specify delta mode.  PPS has a fit
-				// if we specify both delta and deltadir so check for this.
-				std::string modeExtra;
-
-				// Add in the options we need.  If both server and delta are specified, use only
-				// server (it kind of implies delta and at one point pps would not like both being
-				// present)
-				if (server) {
-					modeExtra = ",server";
-				}
-				// If we have no options or there's no 'deltadir' specified, use delta mode
-				else if (pathOptions.empty() || pathOptions.find("deltadir") == std::string::npos) {
-					modeExtra = ",delta";
-				}
-
-				// We embed the m_interfaceID as a unique identifier that will be passed on to the
-				// PPSNotifier. PPSNotifier will use this id in conjunction with getPPSInterface()
-				// in order to send this object notifications that content is ready for reading later.
-				std::ostringstream ostream;
-				ostream << "?" << (pathOptions.empty() ? "" : pathOptions.substr(1) + ",") << "notify="
-						<< groupId << ":" << m_interfaceId << modeExtra;
-				options = ostream.str();
-			}
-		}
-
-		if (!options.empty()) {
-
-			resolvedName += options;
-		}
-
-		// The big moment... Let's try to actually open the PPS object...
-		if (ok) {
-			m_fd = ::open(resolvedName.c_str(), oflag, mode);
-		}
-
-		// Error opening the PPS object
-		if (m_fd < 0) {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::open() Failed - ::open("
-					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-					<< ((oflag & O_CREAT) ? ":create" : "")
-					<< ") " << resolvedName << " (" << errno << ": " << strerror(errno) << ")";
-			m_logger.slog(Logger::warning, ostream.str());
-			errorMsg = ostream.str();
-		}
-		else {
-			// Depending on our umask, the permissions might not have
-			// been as specified. So if O_CREAT was specified, re-set the
-			// permissions.  The object might already exist, but perhaps
-			// that's OK too.
-			if (oflag & O_CREAT) {
-				::fchmod(m_fd, mode);
-			}
-
-			m_oflags = oflag;
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::open() - ::open("
-					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-					<< ((oflag & O_CREAT) ? ":create" : "")
-					<< ") " << resolvedName;
-			m_logger.slog(Logger::debug, ostream.str());
-		}
-	}
-	// For whatever reason, the path to the PPS object was not valid
-	else {
-		std::ostringstream ostream;
-		ostream << "PPSInterface::open() Failed - ::open("
-				<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-				   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-				   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-				<< ((oflag & O_CREAT) ? ":create" : "")
-				<< ") " << path << " The PPS object could not be resolved properly.";
-		m_logger.slog(Logger::warning, ostream.str());
-		errorMsg = ostream.str();
-	}
-
-	sendEvent(PPSEvent(m_fd >= 0 ? PPSEvent::PPS_EVENT_OPENED : PPSEvent::PPS_EVENT_OPEN_FAILED, errorMsg));
-
-	if (m_fd >= 0 && (oflag & O_ACCMODE) != O_WRONLY) {
-
-		// Perform the initial read
-		readFromObject();
-	}
-
-	// Tell the other thread we are done with the first read
-	::pthread_mutex_lock(&sm_mutex);
-	m_firstRead = false;
-	::pthread_cond_broadcast(&sm_cond);
-	::pthread_mutex_unlock(&sm_mutex);
-
-	return m_fd >= 0;
-}
-
-void PPSInterface::write(const std::string& data)
-{
-	// We're trying to write to an unopened PPS object
-	if (m_fd == -1) {
-
-		std::string msg("PPSInterface::write() Failed - Attempting to write to a file that isn't open.");
-		m_logger.slog(Logger::warning, msg);
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, msg));
-	}
-
-	ssize_t ret = ::write(m_fd, data.c_str(), data.length());
-
-	// Debug slog the write call if it was successful
-	if (ret >= 0) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::write() - fd:" << m_fd << " : \n" << data;
-		m_logger.slog(Logger::debug, ostream.str());
-	}
-
-	// There was an error writing
-	if (ret == -1) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::write() Failed - Error writing to fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-		m_logger.slog(Logger::warning, ostream.str());
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, ostream.str()));
-	}
-
-	// If we wrote successfully and the file is open in read/write mode, then we need to manually update the
-	// read cache. When in O_RDWR mode, we do NOT receive notifications of our own write() operations.
-	// This means that the cache of read data becomes stale - it is missing the data that we have written
-	// to the object ourselves. In this case, we will manually update the cache.
-	// NOTE: this seems fraught with peril, but unfortunately there don't seem to be any good solutions to
-	// fixing the problem of read/write mode and read() integrity.
-	if (ret >= 0 && (m_oflags & O_RDWR)) {
-
-		// We're going to try to fool the ppsparse() method into parsing the data we write.
-		char* pWriteData = new char[data.length() + 1];
-
-		// The later call to ppsparse() moves the pWriteData pointer forward, and we need the original pointer
-		// in order to properly delete the object later, so let's cache it here
-		char* pWriteDataCopy = pWriteData;
-
-		std::strcpy(pWriteData, data.c_str()); // strcpy null terminates for us
-
-		// Parse the write buffer - this should give us a ppsObject with only attributes
-		ppsObject parsedData = parsePPSData(pWriteData);
-
-		// The data being written does not include the object name other object properties (duh)
-		// So parsedData contains only attribute info. We want to preserve the object name
-		// and properties, so lets just copy the ones in the cache into our parsedData struct
-		// so that the call to updateCachedReadData() will preserve them (i.e. copy them back)
-		parsedData.name = m_cachedRead.name;
-		parsedData.flags = m_cachedRead.flags;
-		parsedData.options = m_cachedRead.options;
-		parsedData.optionMask = m_cachedRead.optionMask;
-
-		// Update the cache
-		updateCachedReadData(parsedData);
-
-		// Cleanup our allocated memory
-		if (pWriteDataCopy) {
-
-			delete[] pWriteDataCopy;
-		}
-	}
-}
-
-void PPSInterface::sync()
-{
-	if (m_fd >= 0)
-		::fsync(m_fd);
-}
-
-void PPSInterface::close()
-{
-	if (m_fd >= 0) {
-
-		::close(m_fd);
-		m_fd = -1;
-		m_cachedRead = ppsObject();
-		m_oflags = 0;
-
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_CLOSED));
-	}
-}
-
-void PPSInterface::onNotify(NotifyType event)
-{
-	// We only handle read notifications
-	if (event != PPS_READ) {
-		return;
-	}
-
-	if (m_firstRead) {
-		::pthread_mutex_lock(&sm_mutex);
-		while (m_firstRead) {
-			::pthread_cond_wait(&sm_cond, &sm_mutex);
-		}
-		::pthread_mutex_unlock(&sm_mutex);
-	}
-
-	readFromObject();
-}
-
-void PPSInterface::readFromObject()
-{
-	bool sendFirstReadEvent = m_firstRead;
-
-	// This was a uint8_t - was there a reason?
-	char szBuffer[MaxPPSReadSize + 1];
-	int bufferLen;
-
-	// Read from the actual PPS file - this call is not blocking
-	while ((bufferLen = ::read(m_fd, szBuffer, MaxPPSReadSize)) > 0) {
-
-		if (bufferLen <= MaxPPSReadSize) {
-
-			// Make sure the buffer is null terminated.
-			szBuffer[bufferLen] = '\0';
-
-			std::string buf(szBuffer, bufferLen);
-			std::ostringstream ostream;
-			ostream << "PPSInterface::readFromObject() - fd:" << m_fd << " len:" << bufferLen << "\n" << buf;
-			m_logger.slog(Logger::debug, ostream.str());
-
-			// Parse the PPS data
-			ppsObject parsedPPS = parsePPSData(szBuffer);
-
-			// Update the cache with the data we just read
-			updateCachedReadData(parsedPPS);
-
-			// If this is the first read, then send the first read event.
-			if (sendFirstReadEvent) {
-
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", parsedPPS));
-				sendFirstReadEvent = false;
-			}
-			else {
-
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_NEW_DATA, "", parsedPPS));
-			}
-		}
-		else {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::readFromObject() Failed - fd:" << m_fd << " oversized message len:" << bufferLen << ".";
-			m_logger.slog(Logger::warning, ostream.str());
-		}
-	}
-
-	if (bufferLen == -1) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::readFromObject() Failed - Error reading from fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-		m_logger.slog(Logger::warning, ostream.str());
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
-	}
-
-	// It's possible that we won't go into the while() loop above (sometimes the first read is legitimately empty)
-	// in which case, we still need to send a first read complete event
-	if (sendFirstReadEvent) {
-
-		// Send an empty first read object
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", ppsObject()));
-		sendFirstReadEvent = false;
-	}
-}
-
-void PPSInterface::sendEvent(const PPSEvent& event) const
-{
-	if (m_pEventFunc) {
-		m_pEventFunc(m_pEventArg, event);
-	}
-}
-
-PPSInterface* const PPSInterface::getPPSInterface(const unsigned int id)
-{
-	::pthread_mutex_lock(&sm_mutex);
-
-	std::map<unsigned int, PPSInterface*>::iterator it = sm_interfaceLookupTable.find(id);
-
-	if (it != sm_interfaceLookupTable.end()) {
-
-		::pthread_mutex_unlock(&sm_mutex);
-		return (*it).second;
-	}
-
-	::pthread_mutex_unlock(&sm_mutex);
-	return NULL;
-}
-
-ppsObject PPSInterface::parsePPSData(char* data) const
-{
-	// This is the structure that will contain parsed data for each line of the PPS object
-	// It needs to be initialized to NULL
-	pps_attrib_t info;
-	std::memset(&info, 0, sizeof(info));
-
-	// The return code for each PPS line that gets parsed
-	pps_status_t rc;
-	ppsObject ppsObj;
-
-	while ((rc = ::ppsparse(&data, NULL, NULL, &info, 0)) != PPS_END) {
-
-		if (rc == -1) {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::parsePPSData() Failed - Error calling ppsparse() fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-			m_logger.slog(Logger::warning, ostream.str());
-			sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
-		}
-
-		if (info.flags & PPS_INCOMPLETE) {
-			m_logger.slog(Logger::debug, "PPSInterface::parsePPSData - PPS data incomplete.");
-		}
-
-		switch (rc) {
-
-			// When the object has been modified, update the object settings
-			case PPS_OBJECT:
-			case PPS_OBJECT_CREATED:
-			case PPS_OBJECT_DELETED:
-			case PPS_OBJECT_TRUNCATED:
-			{
-				ppsObj.name = info.obj_name;
-				ppsObj.flags = info.flags;
-				ppsObj.options = info.options;
-				ppsObj.optionMask = info.option_mask;
-				break;
-			}
-
-			// An attribute has been updated
-			case PPS_ATTRIBUTE:
-			case PPS_ATTRIBUTE_DELETED:
-			{
-				ppsAttribute ppsAttrib;
-				ppsAttrib.name = info.attr_name;
-
-				// Value and encoding aren't valid if rc == PPS_ATTRIBUTE_DELETED
-				if (rc == PPS_ATTRIBUTE) {
-
-					ppsAttrib.value = info.value;
-					ppsAttrib.encoding = info.encoding;
-				}
-
-				ppsAttrib.flags = info.flags;
-				ppsAttrib.options = info.options;
-				ppsAttrib.optionMask = info.option_mask;
-
-				ppsObj.attributes.insert(ppsAttrPair(ppsAttrib.name, ppsAttrib));
-				break;
-			}
-
-			case PPS_ERROR:
-			{
-				std::string msg("PPSInterface::parsePPSData() Failed - Error parsing PPS data.");
-				m_logger.slog(Logger::warning, msg);
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, msg));
-				break;
-			}
-
-			case PPS_END:
-			default:
-				break;
-		}
-
-	}
-
-	return ppsObj;
-}
-
-void PPSInterface::updateCachedReadData(const ppsObject& newData)
-{
-	::pthread_mutex_lock(&sm_mutex);
-
-	// Update the object
-	m_cachedRead.name = newData.name;
-	m_cachedRead.flags = newData.flags;
-	m_cachedRead.options = newData.options;
-	m_cachedRead.optionMask = newData.optionMask;
-
-	::pthread_mutex_unlock(&sm_mutex);
-
-	// Update the attributes
-	for (const_ppsAttrIter it = newData.attributes.begin(); it != newData.attributes.end(); it++) {
-
-		ppsAttribute attr = (*it).second;
-
-		// An attribute is being deleted
-		if (attr.flags & PPS_DELETED) {
-
-			::pthread_mutex_lock(&sm_mutex);
-
-			// Look for this attribute in the cache and remove it
-			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
-
-			if (findIt != m_cachedRead.attributes.end()) {
-				m_cachedRead.attributes.erase(findIt);
-			}
-
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-		// We're adding a new attribute - don't search for it
-		else if (attr.flags & PPS_CREATED){
-
-			::pthread_mutex_lock(&sm_mutex);
-			m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-		else {
-
-			::pthread_mutex_lock(&sm_mutex);
-
-			// Look for this attribute in the cache
-			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
-
-			// If we find it, update the attribute values
-			if (findIt != m_cachedRead.attributes.end()) {
-
-				(*findIt).second.name = attr.name;
-				(*findIt).second.encoding = attr.encoding;
-				(*findIt).second.value = attr.value;
-				(*findIt).second.flags = attr.flags;
-				(*findIt).second.options = attr.options;
-				(*findIt).second.optionMask = attr.optionMask;
-			}
-			// If we don't find it, insert it
-			else {
-				m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
-			}
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-	}
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
deleted file mode 100644
index 0fde80c..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSInterface.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPS_H_
-#define PPS_H_
-
-#include <string>
-#include <map>
-
-#include <sys/types.h>
-
-#include "PPSTypes.h"
-#include "PPSEvent.h"
-#include "../utils/Logger.h"
-
-namespace jpps {
-
-/**
- * This class augments standard PPS functionality by providing events for when PPS objects are opened,
- * closed, have new data, etc.
- *
- * When a PPS object is opened using PPSInterface::open(), the object is opened as part of a notification group
- * managed by PPSNotifyGroupManager. The notification group monitors the PPS object and notifies PPSInterface
- * whenever there is new data available in the PPS object.
- *
- * PPSInterface should be used in order to simplify PPS object monitoring (i.e. watching for new data in a PPS
- * object.) PPSInterface takes over management of watching for new data and uses a notification callback mechanism
- * with a defined set of possible events to inform the client of changes to the PPS object.
- */
-class PPSInterface {
-
-public:
-
-	/**
-	 * Used with onNotify to allow the PPSNotifier to tell us what type of notification
-	 * message it is sending.
-	 */
-	enum NotifyType {
-		/** The .notify object received a notification that data is ready to be read. */
-		PPS_READ = 0,
-		/** The .notify object received a notification that a file being watched is closing. */
-		PPS_CLOSE = 1 };
-
-	/**
-	 * Constructor.
-	 */
-	PPSInterface();
-
-	/**
-	 * Destructor.
-	 */
-	~PPSInterface();
-
-	/**
-	 * Set up a function to call to be notified about PPS events.
-	 *
-	 * @param pEventFunc The function to call whenever an event happens in PPSInterface.
-	 * @param pArg An optional parameter that will be passed back to pEventFunc every time it
-	 * is called. PPSInterface will not modify pArg.
-	 */
-	void setEventFunc(const PPSEventFunc* pEventFunc, void* pArg = NULL);
-
-	/**
-	 * Enable verbose mode. Increase the number of �v�s to increase verbosity.
-	 *
-	 * @param v The level of verbosity. A value of 0 is off, 1 shows info messages, 2 shows
-	 * debug messages.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS object. If the open() call is successful, a PPS_EVENT_OPENED event will be sent.
-	 * The PPS object will be read as part of the open operation and the PPS_EVENT_FIRST_READ_COMPLETE
-	 * will be sent when the first read is complete. Note that there may be a PPS_EVENT_NEW_DATA
-	 * event *before* the PPS_EVENT_FIRST_READ_COMPLETE event, or there may not be.
-	 * PPS_EVENT_FIRST_READ_COMPLETE only guarantees that at least one read has been performed, not
-	 * that it will be the first read event to fire.
-	 *
-	 * If the open operation fails, the function returns false and a PPS_EVENT_OPEN_FAILED will be sent.
-	 *
-	 * @param path The PPS file/directory path.
-	 * @param oflags Flags passed to ::open.
-	 * @param mode Mode passed to ::open.
-	 * @param serverMode If true, open the object in server mode as the server.
-	 * @return True if the open was successful, false otherwise.
-	 */
-	bool open(const std::string& path, int oflags, int mode, bool serverMode);
-
-	/**
-	 * Check if this PPS object is open.
-	 * @return True if the file is open, false otherwise.
-	 */
-	inline bool isOpen() const { return m_fd >= 0; }
-
-	/**
-	 * Write data to a PPS object.
-	 * @param data The data to write to the PPS object.
-	 */
-	void write(const std::string& data);
-
-	/**
-	 * Read PPS data. Note that this reads cached data from the last read performed when a
-	 * new data available notification was received.
-	 *
-	 * @return A structured representation of the PPS object, culled from a call to ppsparse()
-	 * a function found in ppsparse.h.
-	 */
-
-	inline ppsObject read() const { return m_cachedRead; }
-
-	/**
-	 * Close this PPS object.
-	 */
-	void close();
-
-	/**
-	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
-	 * The function blocks until this is finished.
-	 */
-	void sync();
-
-	/**
-	 * Called to notify us that there is data ready to be read.
-	 *
-	 * @param event The type of event we're being notified about.
-	 */
-	void onNotify(NotifyType event);
-
-	/**
-	 * Given a unique id, return the PPSInterface* matching that id.
-	 *
-	 * Every PPSInterface object is assigned a unique identifier at construction. This
-	 * unique identifier can be used to get a pointer to a PPSInterface at runtime.
-	 *
-	 * In particular, the PPSNotifier gets notifications with this number embedded in them.
-	 * Using this id, the PPSNotifier can callback into the correct PPSInterface instance.
-	 *
-	 * @param id An id that uniquely identifies a PPSInterface object.
-	 * @return a PPSInterface* or NULL if no object matches the given id.
-	 */
-	static PPSInterface* const getPPSInterface(const unsigned int id);
-
-private:
-
-	/**
-	 * Read from the PPS object. Generally this function is called by onNotify() when
-	 * the notifier thread is notified that there is data to be read. This function
-	 * performs a read() of the PPS object that is non-blocking.
-	 */
-	void readFromObject();
-
-	/**
-	 * Given data from a PPS read, parse the PPS data.
-	 */
-	ppsObject parsePPSData(char* data) const;
-
-	/**
-	 * Given new PPS data, update the cached read value.
-	 */
-	void updateCachedReadData(const ppsObject& newData);
-
-	/**
-	 * Call the function set in setEventFunc() with the given event.
-	 *
-	 * @param event The event to send.
-	 */
-	void sendEvent(const PPSEvent& event) const;
-
-	/** The default PPS location. */
-	static const char* PPS_ROOT;
-
-	/** The maximum amount of data that can be read from a PPS object. */
-	static const int MaxPPSReadSize;
-
-	/** The function to call to notify about PPS events. */
-	PPSEventFunc* m_pEventFunc;
-
-	/** An argument that goes with m_pEventFunc. PPSInterface does not modify or use
-	 * this parameter - we simply send it back with every m_pEventFunc call. */
-	void* m_pEventArg;
-
-	/** An identifier that uniquely identifies this PPSInterface object. This is used to look up
-	 * this object in a global table. */
-	unsigned int m_interfaceId;
-
-	/** The file descriptor of the PPS object being opened. */
-	int m_fd;
-
-	/** The open mode flags used when this object was opened. */
-	int m_oflags;
-
-	/** If true, main thread is performing initial open/read of PPS object. This is shared
-	 * across threads and needs to be mutexed when accessed.*/
-	volatile bool m_firstRead;
-
-	/** The data from the last read performed. */
-	ppsObject m_cachedRead;
-
-	/** The logger used to log error messages */
-	Logger m_logger;
-
-	/** Mutex used to prevent threads from clobbering each other. */
-	static pthread_mutex_t sm_mutex;
-
-	/** Condvar used for multi-thread signaling. */
-	static pthread_cond_t sm_cond;
-
-	/** Used to ensure that initialization of statics happens only once. This is shared
-	 * across threads and needs to be mutexed when accessed.*/
-	static volatile bool sm_firstInitDone;
-
-	/** The PPSNotifier needs a way to transform an id that uniquely identifies a PPSInterface object
-	 * into an actual PPSInterface*. When we construct a new PPSInterface, we will assign it a unique id
-	 * and we will put the id and the pointer to the object into this table. The table can then be used
-	 * to lookup this object from its unique id. */
-	static std::map<unsigned int, PPSInterface*> sm_interfaceLookupTable;
-};
-
-} /* namespace jpps */
-#endif /* PPS_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
deleted file mode 100644
index 7869a56..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSNotifier.h"
-
-#include <sstream>
-
-#include <fcntl.h>
-
-#include "PPSInterface.h"
-#include "../utils/Logger.h"
-
-namespace jpps {
-
-PPSNotifier::PPSNotifier()
-: m_notifyObjPath("")
-, m_notifyObjFd(-1)
-, m_notifyGroupId("")
-, m_thread()
-{
-
-}
-
-PPSNotifier::~PPSNotifier()
-{
-	// Stop the thread
-	m_thread.stop();
-
-	// Close the .notify file
-	if (m_notifyObjFd >= 0) {
-		::close(m_notifyObjFd);
-	}
-}
-
-void PPSNotifier::startNotifyLoop()
-{
-	m_thread.start(_notifyLoop, this, "plugin_jPPS_PPSNotifier(" + m_notifyObjPath + "/.notify)");
-}
-
-
-void* PPSNotifier::_notifyLoop(void* pArg)
-{
-	// Something is messed up
-	if (pArg == NULL)
-		return NULL;
-
-	PPSNotifier* pNotifier = static_cast<PPSNotifier*> (pArg);
-
-	// pArg is supposed to be a PPSNotifier object...
-	if (pNotifier == NULL)
-		return NULL;
-
-	pNotifier->notifyLoop();
-
-	return NULL;
-}
-
-void PPSNotifier::notifyLoop()
-{
-	// Buffer for read() operation
-	char szData[256];
-	int dataLen;
-
-	// This is a blocking read call: this will wait in this loop forever
-	while ((dataLen = ::read(m_notifyObjFd, szData, sizeof(szData)-1)) > 0) {
-
-                szData[dataLen] = '\0';
-		std::string data(szData);
-
-		if ((unsigned int)dataLen > sizeof(szData)-1) {
-
-			std::ostringstream ostream;
-			ostream << "PPSNotifier::notifyLoop() - Notify read overflow " << dataLen << ".";
-			Logger logger;
-			logger.slog(Logger::error, ostream.str());
-		}
-
-		std::size_t nPos = data.find('\n');
-
-		// While we find linefeeds
-		while(nPos != std::string::npos) {
-
-			// Read the first char
-			PPSInterface::NotifyType event = data[0] == '-' ? PPSInterface::PPS_CLOSE : PPSInterface::PPS_READ;
-			std::size_t nAddrPos = data.find(':');
-
-			if (nAddrPos != std::string::npos) {
-
-				std::string sAddress = data.substr(nAddrPos+1);
-				std::size_t nAddrEnd = sAddress.find('\n');
-
-				if (nAddrEnd != std::string::npos) {
-
-					sAddress = sAddress.substr(0, nAddrEnd);
-
-					unsigned int interfaceId = 0;
-
-					std::stringstream ss;
-					ss << sAddress;
-					ss >> interfaceId;
-
-					PPSInterface* const pPPS = PPSInterface::getPPSInterface(interfaceId);
-
-					if (pPPS) {
-						pPPS->onNotify(event);
-					}
-				}
-			}
-
-			// Don't go off the end of the string
-			if (++nPos < data.length()) {
-
-				// Remove the stuff up to the first '\n' and look for the next '\n'
-				data = data.substr(nPos);
-				nPos = data.find('\n');
-			}
-			else {
-
-				nPos = std::string::npos;
-			}
-		}
-	}
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
deleted file mode 100644
index 143f052..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifier.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSNOTIFIER_H_
-#define PPSNOTIFIER_H_
-
-#include <string>
-
-#include "../utils/Thread.h"
-
-namespace jpps {
-
-/**
- * PPSNotifier is an encapsulation of an open PPS .notify object. PPSNotifier has a
- * blocking thread dedicated to reading from its .notify object. The thread constantly
- * waits for new notifications in the .notify object.
- *
- * The way the PPS notify mechanism works is that on the first open/read of a .notify object,
- * PPS provides a notify group id. This group id can be used when opening any PPS object to make
- * the PPS object join the notify group.
- *
- * For example, you open a .notify file and the group id returned is "2a3".
- * You subsequently open a PPS object and make it join that notify group:
- *
- * ::open("/pps/myppsobj?notify=2a3:someUniqueValueIDecide");
- *
- * Now, every time myppsobj changes, the .notify file will be updated in the following manner:
- *
- * <code>Notify 2a3:someUniqueValueIDecide</code>
- *
- * For a change to the file. And
- *
- * <code>-2a3:someUniqueValueIDecide</code>
- *
- * if myppsobj is closed.
- *
- * When PPSNotifier reads a notification, the unique value is actually a unique identifier for a
- * PPSInterface object that can be looked up in a global PPSInterface lookup table. Getting the
- * PPSInterface object designated by the unique identifier, PPSNotifier calls PPSInterface::onNotify()
- * to inform the PPSInterface object that there is new data pending or that the file has closed.
- * It is then up to the PPSInterface to decide how to proceed to get that data from myppsobj.
- */
-class PPSNotifier {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSNotifier();
-
-	/**
-	 * Destructor. Note that this destructor will attempt to close the .notify
-	 * object's file.
-	 */
-	virtual ~PPSNotifier();
-
-	/**
-	 * Start the notify thread.
-	 */
-	void startNotifyLoop();
-
-	/**
-	 * Get the .notify object's path.
-	 *
-	 * @return The path to the .notify object.
-	 */
-	inline std::string getNotifyObjPath() const { return m_notifyObjPath; }
-
-	/**
-	 * Set the .notify object's path.
-	 *
-	 * @param path The path of the .notify object (note that this should not include the
-	 * .notify object name).
-	 */
-	inline void setNotifyOjbPath(const std::string& path) { m_notifyObjPath = path; }
-
-	/**
-	 * Get the .notify object's file descriptor.
-	 *
-	 * @return The file descriptor for the open .notify object.
-	 */
-	inline int getObjFd() const { return m_notifyObjFd; }
-
-	/**
-	 * Set the .notify object's file descriptor.
-	 *
-	 * @param The file descriptor for the open .notify object.
-	 */
-	inline void setObjFd(const int fd) { m_notifyObjFd = fd; }
-
-	/**
-	 * Set this notifier's .notify group ID (assigned by PPS).
-	 *
-	 * @param The .notify object's group ID, which is returned by PPS on the first read
-	 * of the .notify object.
-	 */
-	inline std::string getNotifyGroupId() const { return m_notifyGroupId; }
-
-	/**
-	 * Get this notifier's .notify group ID (assigned by PPS).
-	 *
-	 * @return The .notify object's group ID.
-	 */
-	inline void setNotifyGroupId(const std::string& id) { m_notifyGroupId = id; }
-
-private:
-
-	// Disable the copy constructor
-	PPSNotifier(const PPSNotifier& manager);
-
-	// Disable the assignment operator
-	PPSNotifier& operator=(const PPSNotifier& rhs);
-
-	/**
-	 * Function used to start the thread. Pass this into the Thread::start() function.
-	 *
-	 * @param pArg A pointer to a PPSNotifier.
-	 */
-	static void* _notifyLoop(void* pArg);
-
-	/**
-	 * The main thread loop. Blocks on reading the .notify file.
-	 */
-	void notifyLoop();
-
-	/** The path of the .notify file we're monitoring to know when to get data. */
-	std::string m_notifyObjPath;
-
-	/** The file descriptor of the .notify file we're monitoring to know when to get data. */
-	int m_notifyObjFd;
-
-	/** The .notify group ID assigned by PPS when the group was created. */
-	std::string m_notifyGroupId;
-
-	/** The thread I'm running on. */
-	Thread m_thread;
-};
-
-} /* namespace jpps */
-#endif /* PPSNOTIFIER_H_ */


[14/50] [abbrv] webworks commit: Added clean script to remove build folder

Posted by lo...@apache.org.
Added clean script to remove build folder

Reviewed by Hasan Ahmad <ha...@blackberry.com>
Tested by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/9160b4ab
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/9160b4ab
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/9160b4ab

Branch: refs/heads/future
Commit: 9160b4ab074fead8819bdc8ee758b5628415668c
Parents: 99b61a2
Author: DanielAudino <da...@blackberry.com>
Authored: Fri Mar 22 16:33:02 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/templates/project/cordova/clean   |    4 ++
 .../bin/templates/project/cordova/clean.bat        |    6 ++++
 .../bin/templates/project/cordova/lib/clean        |   24 +++++++++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/9160b4ab/blackberry10/bin/templates/project/cordova/clean
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/clean b/blackberry10/bin/templates/project/cordova/clean
new file mode 100755
index 0000000..0d29bd7
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/clean
@@ -0,0 +1,4 @@
+#cd into project dir
+cd $( dirname "$0")/../
+
+node ./cordova/lib/clean

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/9160b4ab/blackberry10/bin/templates/project/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/clean.bat b/blackberry10/bin/templates/project/cordova/clean.bat
new file mode 100644
index 0000000..eb5738c
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/clean.bat
@@ -0,0 +1,6 @@
+@ECHO OFF
+
+REM cd into project dir
+cd %~dp0\..\
+
+@node.exe ./cordova/lib/clean

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/9160b4ab/blackberry10/bin/templates/project/cordova/lib/clean
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/clean b/blackberry10/bin/templates/project/cordova/lib/clean
new file mode 100644
index 0000000..429e79b
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/lib/clean
@@ -0,0 +1,24 @@
+#!/usr/bin/env node
+
+/*
+ *  Copyright 2013 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 wrench = require('wrench'),
+    path = require("path"),
+    buildPath = path.normalize(__dirname + "/../../build/");
+
+   wrench.rmdirSyncRecursive(dirPath, true);
+


[38/50] [abbrv] webworks commit: Fixed build error on linux

Posted by lo...@apache.org.
Fixed build error on linux

Revewied by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/7093c3e9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/7093c3e9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/7093c3e9

Branch: refs/heads/future
Commit: 7093c3e97582ceb2ced3342dc3b6e17eb8f08756
Parents: d5a2530
Author: Danyi Lin <da...@blackberry.com>
Authored: Thu Apr 18 17:11:17 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/conf.js      |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7093c3e9/blackberry10/bin/templates/project/cordova/lib/conf.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/conf.js b/blackberry10/bin/templates/project/cordova/lib/conf.js
index f1500ff..75c47a8 100644
--- a/blackberry10/bin/templates/project/cordova/lib/conf.js
+++ b/blackberry10/bin/templates/project/cordova/lib/conf.js
@@ -28,14 +28,14 @@ function getToolsDir() {
 }
 
 module.exports = {
-    ROOT: path.normalize(__dirname + "/../Framework"),
+    ROOT: path.normalize(__dirname + "/../framework"),
     PROJECT_ROOT: path.normalize(__dirname + "/../../"),
-    BIN: path.normalize(__dirname + "/../Framework/bin"),
-    LIB: path.normalize(__dirname + "/../Framework/lib"),
+    BIN: path.normalize(__dirname + "/../framework/bin"),
+    LIB: path.normalize(__dirname + "/../framework/lib"),
     EXT: path.normalize(__dirname + "/../../plugins"),
-    UI: path.normalize(__dirname + "/../Framework/ui-resources"),
-    DEPENDENCIES: path.normalize(__dirname + "/../Framework/dependencies"),
-    DEPENDENCIES_BOOTSTRAP: path.normalize(__dirname + "/../Framework/bootstrap"),
+    UI: path.normalize(__dirname + "/../framework/ui-resources"),
+    DEPENDENCIES: path.normalize(__dirname + "/../framework/dependencies"),
+    DEPENDENCIES_BOOTSTRAP: path.normalize(__dirname + "/../framework/bootstrap"),
     DEPENDENCIES_TOOLS: getToolsDir(),
     DEPENDENCIES_WWE: path.normalize(__dirname + "/../dependencies/%s-wwe"),
     DEBUG_TOKEN: path.normalize(__dirname + "/../debugtoken.bar"),


[32/50] [abbrv] Update plugin script and template to work with plugman changes

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
deleted file mode 100644
index 5392ca8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSNotifyGroupManager.h"
-
-#include <fcntl.h>
-
-#include "PPSNotifier.h"
-
-namespace jpps {
-
-typedef std::map<std::string, PPSNotifier*>::iterator groupIter;
-typedef std::map<std::string, PPSNotifier*>::const_iterator const_groupIter;
-typedef std::pair<std::string, PPSNotifier*> groupValue;
-
-pthread_mutex_t PPSNotifyGroupManager::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-PPSNotifyGroupManager::PPSNotifyGroupManager()
-{
-
-}
-
-PPSNotifyGroupManager::~PPSNotifyGroupManager()
-{
-	// Delete the allocated memory for all the PPSNotifiers
-	for (groupIter it = m_notifyGroups.begin(); it != m_notifyGroups.end(); it++) {
-
-		if ((*it).second != NULL) {
-
-			delete (*it).second;
-			(*it).second = NULL;
-		}
-	}
-}
-
-PPSNotifyGroupManager& PPSNotifyGroupManager::getInstance()
-{
-	// The one and only PPSNotifyGroupManager
-	static PPSNotifyGroupManager manager;
-	return manager;
-}
-
-bool PPSNotifyGroupManager::joinNotifyGroup(const std::string& path, std::string& groupId)
-{
-	std::string notifyFile;
-	std::string notifyPath(path);
-	std::size_t nPos = notifyPath.rfind('/');
-
-	// Search through the directories in the string until we find a valid .notify object
-	while (nPos != std::string::npos) {
-
-		// Chop off everything after the last '/' to get the path without the PPS object name
-		notifyPath = notifyPath.substr(0, nPos);
-
-		// Do we already have a notify group for this path?
-		const_groupIter it = m_notifyGroups.find(notifyPath);
-
-		// We found a match!
-		if (it != m_notifyGroups.end() && (*it).second != NULL) {
-
-			groupId = (*it).second->getNotifyGroupId();
-			return true;
-		}
-
-		// Add ".notify?wait" to the notify path, to make it a real file
-		notifyFile = notifyPath + "/.notify?wait";
-
-		// Try to open this .notify object
-		int fd = ::open(notifyFile.c_str(), O_RDONLY);
-
-		// This is the .notify object to use
-		if (fd >= 0) {
-
-			char data[20];
-			int len = ::read(fd, data, sizeof(data) - 1);
-			// Terminate string to remove the newline char
-			data[len > 0 ? len - 1 : 0] = '\0';
-
-			PPSNotifier* pNotifier = new PPSNotifier();
-			pNotifier->setNotifyGroupId(std::string(data));
-			pNotifier->setNotifyOjbPath(notifyPath);
-			pNotifier->setObjFd(::dup(fd));
-                        ::close(fd);
-
-			// Add this badboy to our cache of notify groups
-			m_notifyGroups.insert(groupValue(notifyPath, pNotifier));
-
-			// Start the notify reading thread
-			pNotifier->startNotifyLoop();
-
-			groupId = pNotifier->getNotifyGroupId();
-			return true;
-		}
-		// Keep looking
-		else {
-
-			nPos = notifyPath.rfind('/');
-		}
-	}
-
-	// We didn't find a notify group
-	groupId = "";
-	return false;
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
deleted file mode 100644
index 03b0e3e..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSNotifyGroupManager.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSNOTIFYGROUPMANAGER_H_
-#define PPSNOTIFYGROUPMANAGER_H_
-
-#include <map>
-#include <string>
-#include <pthread.h>
-
-namespace jpps {
-
-// Forward declaration
-class PPSNotifier;
-
-
-/**
- * The PPSNotifyGroupManager is used to manage a global pool of .notify objects. PPS has a mechanism
- * where every folder can contain a special PPS object ".notify". Opening the .notify object will return
- * a group id on the first read of the .notify object. The group id is used to open the real PPS object
- * for which we desire to receive notifications. Once this is done, the .notify object is the one that will
- * receive change notifications for the real PPS object. In this model, the real PPS object DOES NOT
- * open in blocking read or ionotify/select mode. The .notify object is the one responsible for blocking
- * on read and tracking data publishing.
- *
- * This object is a global singleton - any access to it needs to be wrapped in a mutex to prevent
- * concurrency problems. Two functions mutex_lock() and mutex_unlock() are provided for this purpose.
- */
-class PPSNotifyGroupManager
-{
-public:
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSNotifyGroupManager();
-
-	/**
-	 * Get the one and only instance of the PPSNotifier.Always wrap calls to getInstance() in a call to
-	 * PPSNotifyGroupManager::mutexLock()/mutexUnlock().
-	 */
-	static PPSNotifyGroupManager& getInstance();
-
-	/**
-	 * Use this function to get the notify group id of the "closest" .notify object in the /pps hierarchy
-	 * that contains path.
-	 *
-	 * The function will go backwards through the directories in path looking for a .notify object. It will return
-	 * the group id of the first .notify object it finds on this path. It is the responsibility of the caller
-	 * to have the PPS object in path join the notify group by opening the object with the "notify=groupId:val"
-	 * option set.
-	 *
-	 * PPSNotifyGroupManager maintains a pool of opened .notify objects. It is possible for a single .notify object
-	 * to have a very disparate (and numerous) set of PPS objects that it monitors. In order to tweak performance
-	 * it is advisable that .notify object be created in strategic directories in the /pps directory hierarchy, in
-	 * order to spread the load of notification monitoring. Each .notify object opened will spawn a thread that blocks
-	 * on reading from the .notify object. Having several .notify objects means having several threads that read
-	 * notifications.
-	 *
-	 * Note that joinNotifyGroup() will NOT create any .notify PPS objects. The /pps/.notify object always exists,
-	 * and if the /pps directory hierarchy contains no other .notify objects, /pps/.notify will end up being the
-	 * notification group that all objects join.
-	 *
-	 * Always wrap calls to joinNotifyGroup() in a call to PPSNotifyGroupManager::mutexLock()/mutexUnlock().
-	 *
-	 * @param The PPS object that wants to join the notify group.
-	 * @param groupId The id of the notify group joined. This is an output parameter.
-	 * @return True if a notify group was successfully joined, false otherwise. If true, then the groupId
-	 * variable will be set.
-	 */
-	bool joinNotifyGroup(const std::string& path, std::string& groupId);
-
-	/**
-	 * Returns how many notification groups the manager is managing.
-	 *
-	 * @return The number of notification groups (i.e. open .notify objects) in use.
-	 */
-	inline std::size_t getNumGroups() const { return m_notifyGroups.size(); }
-
-	/**
-	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
-	 * object, multiple threads may try to access this object at one time. It is therefore important to
-	 * mutex lock all access to this object.
-	 */
-	static inline void mutexLock() { pthread_mutex_lock(&sm_mutex); }
-
-	/**
-	 * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
-	 * object, multiple threads may try to access this object at one time. It is therefore important to
-	 * mutex lock all access to this object.
-	 */
-	static inline void mutexUnlock() { pthread_mutex_unlock(&sm_mutex); }
-
-private:
-
-	/**
-	 * Constructor. Private as part of the singleton pattern of this object.
-	 */
-	PPSNotifyGroupManager();
-
-	// Disable the copy constructor.
-	PPSNotifyGroupManager(const PPSNotifyGroupManager& manager);
-
-	// Disable the assignment operator.
-	PPSNotifyGroupManager& operator=(const PPSNotifyGroupManager& rhs);
-
-	/** This is a cache of all the .notify objects. */
-	std::map<std::string, PPSNotifier*> m_notifyGroups;
-
-	/** Mutex used to prevent threads from clobbering each other. */
-	static pthread_mutex_t sm_mutex;
-};
-
-} /* namespace jpps */
-#endif /* PPSNOTIFYGROUPMANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
deleted file mode 100644
index 362d236..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/core/PPSTypes.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSTYPES_H_
-#define PPSTYPES_H_
-
-#include <map>
-
-namespace jpps {
-
-class PPSEvent;
-
-/**
- * A struct representing an attribute of a PPS object.
- */
-struct ppsAttribute {
-
-	/** The attribute name. */
-	std::string name;
-	/** The attribute value. */
-	std::string value;
-	/** The attribute encoding. */
-	std::string encoding;
-	/** Flags associated to the attribute. */
-	int flags;
-	/** Attribute options. */
-	int options;
-	/** The attribute options mask. */
-	int optionMask;
-};
-
-/**
- * A struct representing a PPS object.
- */
-struct ppsObject {
-
-	/** The PPS object name. */
-	std::string name;
-	/** The PPS object flags. */
-	int flags;
-	/** The PPS object options. */
-	int options;
-	/** The PPS object option mask. */
-	int optionMask;
-	/** The attributes of this PPS object. */
-	std::map<std::string, ppsAttribute> attributes;
-};
-
-/**
- * Typedef for ppsAttribute iterator.
- */
-typedef std::map<std::string, ppsAttribute>::iterator ppsAttrIter;
-
-/**
- * Typedef for ppsAttribute const iterator.
- */
-typedef std::map<std::string, ppsAttribute>::const_iterator const_ppsAttrIter;
-
-/**
- * A pair used to insert attributes into the map.
- */
-typedef std::pair<std::string, ppsAttribute> ppsAttrPair;
-
-/**
- * This is the definition of the notify function clients of PPSInterface use in order
- * to be informed of events the PPSInterface generates.
- *
- * @param pArg A user defined parameter. This value can be passed in to PPSInterface::setEventFunc()
- * and will be passed back with the event handler every time it is called. PPSInterface will not
- * modify this value.
- *
- * @aparam event The PPS event being broadcast.
- */
-typedef void (PPSEventFunc)(void* pArg, const PPSEvent& event);
-
-};
-
-#endif /* PPSTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
deleted file mode 100644
index 9b5d711..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSPlugin.h"
-
-#include <string>
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSPlugin::CLASS_NAME = "PPS";
-const std::string JPPSPlugin::METHOD_OPEN = "Open";
-const std::string JPPSPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSPlugin::METHOD_WRITE = "Write";
-const std::string JPPSPlugin::METHOD_READ = "Read";
-const std::string JPPSPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-
-JPPSPlugin::JPPSPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsInterface()
-{
-	// We only have one event handler, we'll use it for all events
-	m_ppsInterface.callbackInit(this,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent,
-								onEvent);
-}
-
-JPPSPlugin::~JPPSPlugin()
-{
-
-}
-
-std::string JPPSPlugin::InvokeMethod(const std::string& strCommand)
-{
-	// Parameter sanity check
-	if (strCommand == "")
-		return std::string(szERROR) + " JPPSPlugin::InvokeMethod() called with no method to invoke.";
-
-	// Tokenize the stream of input information
-	std::stringstream args(strCommand);
-	std::string method;
-	args >> method;
-
-	// Invoke the method requested
-	if (method == JPPSPlugin::METHOD_WRITE) {
-		return write(args);
-	}
-	else if (method == JPPSPlugin::METHOD_READ) {
-		return read();
-	}
-	else if (method == JPPSPlugin::METHOD_OPEN) {
-		return open(args);
-	}
-	else if (method == JPPSPlugin::METHOD_CLOSE) {
-		return close();
-	}
-	else if (method == JPPSPlugin::METHOD_SET_VERBOSE) {
-		return setVerbose(args);
-	}
-
-	return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSPlugin::open(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the path
-	std::string path;
-	args >> path;
-
-	// Missing argument
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
-	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
-	int oflags = 0;
-	args >> oflags;
-
-	bool bRet = m_ppsInterface.open(path, oflags);
-
-	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSPlugin::close()
-{
-	m_ppsInterface.close();
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::write(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::write() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the initial whitespace that was between the method name and the parameter
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsInterface.write(tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::read() const
-{
-	return std::string(szOK) + m_ppsInterface.read();
-}
-
-std::string JPPSPlugin::setVerbose(std::stringstream& args)
-{
-	unsigned short verbosity = 0;
-
-	// If no param was passed, default to 0, else read the value
-	if (!args.eof())
-		args >> verbosity;
-
-	m_ppsInterface.setVerbose(verbosity);
-	return szOK;
-}
-
-void JPPSPlugin::onEvent(const std::string& sEvent) const
-{
-	// We have to add our object Id to the event
-	std::string pluginEvent = m_jnextObjId + " " + sEvent;
-	SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
-	// Cast pArg back to JPPSPlugin and invoke onEvent()
-	JPPSPlugin* pPlugin = static_cast<JPPSPlugin*>(pArg);
-
-	if (pPlugin != NULL)
-		pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
deleted file mode 100644
index 1a56ab2..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSPlugin.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSPLUGIN_H_
-#define JPPSPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSInterfaceGlue.h"
-
-namespace jpps {
-
-/**
- * JPPSPlugin is a JNext extension which provides PPS support to JavaScript.
- * This class is merely a wrapper for PPSInterfaceGlue, providing the necessary
- * JNext interface and performing string-parameter encoding and decoding.
- *
- * The intention is that this class will be replaced with a different plug-in framework.
- */
-class JPPSPlugin : public JSExt {
-
-public:
-
-	// Constants
-
-	/** The only class supported by this plugin. */
-	static const char* CLASS_NAME;
-
-	// List of object methods supported by this extension
-
-	/** Open a PPS object/directory. */
-	static const std::string METHOD_OPEN;
-	/** Close a PPS object/directory. */
-	static const std::string METHOD_CLOSE;
-	/** Write a PPS object. */
-	static const std::string METHOD_WRITE;
-	/** Read a PPS object. */
-	static const std::string METHOD_READ;
-	/** Adjust output verbosity. */
-	static const std::string METHOD_SET_VERBOSE;
-
-	/**
-	 * Constructor.
-	 */
-	JPPSPlugin(const std::string& jnextObjectId);
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~JPPSPlugin();
-
-	// Inherited from JSExt
-	virtual std::string InvokeMethod(const std::string& strCommand);
-	virtual inline bool CanDelete(void) { return true; }
-
-	/**
-	 *  Static callback method, changes pArg back into a JPPSPlugin and invokes
-	 *  the non-static version of onEvent().
-	 */
-	static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
-	// Disable the default constructor
-	JPPSPlugin();
-
-	/**
-	 * The non-static version of onEvent. Handler for the PPSInterfaceGlue class' events.
-	 */
-	void onEvent(const std::string& sEvent) const;
-
-	/**
-	 * Open a PPS object.
-	 */
-	std::string open(std::stringstream& args);
-
-	/**
-	 * Close the PPS object.
-	 */
-	std::string close();
-
-	/**
-	 * Write data to the PPS object.
-	 */
-	std::string write(std::stringstream& args);
-
-	/**
-	 * Read the cached PPS data from the last read.
-	 */
-	std::string read() const;
-
-	/**
-	 * Set the verbosity level for logging to slog.
-	 */
-	std::string setVerbose(std::stringstream& args);
-
-	/** A unique JNext id for this object */
-	std::string m_jnextObjId;
-
-	/** The PPS object. */
-	PPSInterfaceGlue m_ppsInterface;
-};
-
-} /* namespace jpps */
-#endif /* JPPSPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
deleted file mode 100644
index 6c3bc2d..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSServerPlugin.h"
-
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSServerPlugin::CLASS_NAME = "PPSServer";
-
-const std::string JPPSServerPlugin::METHOD_OPEN = "Open";
-const std::string JPPSServerPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSServerPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-const std::string JPPSServerPlugin::METHOD_SEND_MESSAGE = "SendMessage";
-const std::string JPPSServerPlugin::METHOD_BROADCAST_MESSAGE = "BroadcastMessage";
-
-JPPSServerPlugin::JPPSServerPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsServer()
-{
-	m_ppsServer.callbackInit(this,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent,
-							 onEvent);
-}
-
-JPPSServerPlugin::~JPPSServerPlugin()
-{
-}
-
-std::string JPPSServerPlugin::InvokeMethod(const std::string& strCommand)
-{
-	// Parameter sanity check
-	if (strCommand == "")
-		return std::string(szERROR) + " JPPSServerPlugin::InvokeMethod() called with no method to invoke.";
-
-	// Tokenize the stream of input information
-	std::stringstream args(strCommand);
-	std::string method;
-	args >> method;
-
-	// Invoke the method requested
-	if (method == JPPSServerPlugin::METHOD_OPEN) {
-		return open(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_CLOSE) {
-		return close();
-	}
-	else if (method == JPPSServerPlugin::METHOD_SET_VERBOSE) {
-		return setVerbose(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_SEND_MESSAGE) {
-		return sendMessage(args);
-	}
-	else if (method == JPPSServerPlugin::METHOD_BROADCAST_MESSAGE) {
-		return broadcastMessage(args);
-	}
-
-	return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSServerPlugin::open(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the path
-	std::string path;
-	args >> path;
-
-	// Missing argument
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
-	// 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
-	int oflags = 0;
-	args >> oflags;
-
-	bool bRet = m_ppsServer.open(path, oflags);
-
-	return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSServerPlugin::close()
-{
-	m_ppsServer.close();
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::setVerbose(std::stringstream& args)
-{
-	unsigned short verbosity = 0;
-
-	// If no param was passed, default to 0, else read the value
-	if (!args.eof())
-		args >> verbosity;
-
-	m_ppsServer.setVerbose(verbosity);
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::sendMessage(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
-	// Get the arguments
-	// 1st arg, the clientId
-	std::string clientId;
-	args >> clientId;
-
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the clientID and the message
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsServer.sendMessage(clientId, tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::broadcastMessage(std::stringstream& args)
-{
-	// We don't have enough args
-	if (args.eof())
-		return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::broadcastMessage() - invalid number of arguments.";
-
-	// This truncates the buffer from the current position onwards (if you don't do this, you keep
-	// the method name that's at the beginning of the args stream)
-	args.seekg(1, std::ios_base::cur); 	// Skip the whitespace that was between the method name and the message
-	std::stringstream tmp;
-	tmp << args.rdbuf();
-
-	m_ppsServer.broadcastMessage(tmp.str());
-	return szOK + m_jnextObjId;
-}
-
-void JPPSServerPlugin::onEvent(const std::string& sEvent) const
-{
-	// We have to add our object Id to the event
-	std::string pluginEvent = m_jnextObjId + " " + sEvent;
-	SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSServerPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
-	// Cast pArg back to JPPSPlugin and invoke onEvent()
-	JPPSServerPlugin* pPlugin = static_cast<JPPSServerPlugin*>(pArg);
-
-	if (pPlugin != NULL)
-		pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
deleted file mode 100644
index ea5b18f..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/JPPSServerPlugin.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSSERVERPLUGIN_H_
-#define JPPSSERVERPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSServerGlue.h"
-
-namespace jpps {
-
-class JPPSServerPlugin: public JSExt {
-
-public:
-
-	// Constants
-
-	/** The only class supported by this plugin. */
-	static const char* CLASS_NAME;
-
-	// List of object methods supported by this extension
-
-	/** Open a PPS object/directory. */
-	static const std::string METHOD_OPEN;
-	/** Close a PPS object/directory. */
-	static const std::string METHOD_CLOSE;
-	/** Adjust output verbosity. */
-	static const std::string METHOD_SET_VERBOSE;
-	/** Send a message to a particular client. */
-	static const std::string METHOD_SEND_MESSAGE;
-	/** Send a message to all clients. */
-	static const std::string METHOD_BROADCAST_MESSAGE;
-
-	/**
-	 * Constructor.
-	 */
-	JPPSServerPlugin(const std::string& jnextObjectId);
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~JPPSServerPlugin();
-
-	// Inherited from JSExt
-	virtual std::string InvokeMethod(const std::string& strCommand);
-	virtual inline bool CanDelete(void) { return true; }
-
-	/**
-	 *  Static callback method, changes pArg back into a JPPSServerPlugin and invokes
-	 *  the non-static version of onEvent().
-	 */
-	static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
-	// Disable default constructor.
-	JPPSServerPlugin();
-
-	/**
-	 * The non-static version of onEvent. Handler for the PPSServerGlue class' events.
-	 */
-	void onEvent(const std::string& sEvent) const;
-
-	/**
-	 * Open a PPS object.
-	 */
-	std::string open(std::stringstream& args);
-
-	/**
-	 * Close the PPS object.
-	 */
-	std::string close();
-
-	/**
-	 * Set the verbosity level for logging to slog.
-	 */
-	std::string setVerbose(std::stringstream& args);
-
-	/**
-	 * Send a message to a particular client.
-	 */
-	std::string sendMessage(std::stringstream& args);
-
-	/**
-	 * Send a message to all clients.
-	 */
-	std::string broadcastMessage(std::stringstream& args);
-
-	/** A unique JNext id for this object */
-	std::string m_jnextObjId;
-
-	/** The PPS object. */
-	PPSServerGlue m_ppsServer;
-};
-
-} /* namespace jpps */
-#endif /* JPPSSERVERPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
deleted file mode 100644
index 83616b8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSInterfaceGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <vector>
-#include <sstream>
-
-#include <ppsparse.h>
-
-#include "../core/PPSEvent.h"
-
-namespace jpps {
-
-const std::string PPSInterfaceGlue::EVENT_OPEN = "ppsOpened";
-const std::string PPSInterfaceGlue::EVENT_OPEN_FAILED = "ppsOpenFailed";
-const std::string PPSInterfaceGlue::EVENT_FIRST_READ = "ppsFirstRead";
-const std::string PPSInterfaceGlue::EVENT_NEW_DATA = "OnChange";//"ppsNewData";
-const std::string PPSInterfaceGlue::EVENT_CLOSE = "ppsClosed";
-const std::string PPSInterfaceGlue::EVENT_WRITE_FAILED = "ppsWriteFailed";
-const std::string PPSInterfaceGlue::EVENT_READ_FAILED = "ppsReadFailed";
-
-const std::string PPSInterfaceGlue::ENCODING_N = "n";
-const std::string PPSInterfaceGlue::ENCODING_B = "b";
-const std::string PPSInterfaceGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSInterfaceGlue::JSON_REMOVE("remove");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGED("changed");
-const Json::StaticString PPSInterfaceGlue::JSON_DATA("data");
-const Json::StaticString PPSInterfaceGlue::JSON_OBJNAME("objName");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGE_DATA("changeData");
-const Json::StaticString PPSInterfaceGlue::JSON_ALL_DATA("allData");
-
-
-PPSInterfaceGlue::PPSInterfaceGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleFirstRead(NULL)
-, m_handleNewData(NULL)
-, m_handleClose(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleWriteFailed(NULL)
-, m_handleReadFailed(NULL)
-{
-	m_interface.setEventFunc(onEvent, this);
-}
-
-PPSInterfaceGlue::~PPSInterfaceGlue()
-{
-	m_interface.setEventFunc(NULL);
-}
-
-void PPSInterfaceGlue::callbackInit(void* pArg,
-								    callback* handleOpen,
-								    callback* handleFirstRead,
-								    callback* handleNewData,
-								    callback* handleClose,
-								    callback* handleOpenFailed,
-								    callback* handleWriteFailed,
-								    callback* handleReadFailed)
-{
-	m_pArg = pArg;
-	m_handleOpen = handleOpen;
-	m_handleFirstRead = handleFirstRead;
-	m_handleNewData = handleNewData;
-	m_handleClose = handleClose;
-	m_handleOpenFailed = handleOpenFailed;
-	m_handleWriteFailed = handleWriteFailed;
-	m_handleReadFailed = handleReadFailed;
-}
-
-void PPSInterfaceGlue::setVerbose(unsigned short v)
-{
-	m_interface.setVerbose(v);
-}
-
-bool PPSInterfaceGlue::open(const std::string& path, int oflags)
-{
-	// We don't expose the "mode" to the JS layer - always create in 0666 mode
-	return m_interface.open(path, oflags, 0666, false);
-}
-
-void PPSInterfaceGlue::close()
-{
-	m_interface.close();
-}
-
-void PPSInterfaceGlue::sync()
-{
-	m_interface.sync();
-}
-
-void PPSInterfaceGlue::onEvent(void* pArg, const PPSEvent& event)
-{
-	PPSInterfaceGlue* pGlue = static_cast<PPSInterfaceGlue*>(pArg);
-
-	if (pGlue != NULL)
-		pGlue->onEvent(event);
-}
-
-void PPSInterfaceGlue::onEvent(const PPSEvent& event)
-{
-	callback* pFunc = NULL;
-	std::string sArg;
-
-	switch (event.getEventType()) {
-
-	case PPSEvent::PPS_EVENT_OPENED:
-		pFunc = m_handleOpen;
-		sArg = EVENT_OPEN;
-		break;
-
-	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
-		pFunc = m_handleFirstRead;
-		sArg = EVENT_FIRST_READ + " " + handleNewData(event.getNewData());
-		break;
-
-	case PPSEvent::PPS_EVENT_NEW_DATA:
-		pFunc = m_handleNewData;
-		sArg = EVENT_NEW_DATA + " " + handleNewData(event.getNewData());
-		break;
-
-	case PPSEvent::PPS_EVENT_CLOSED:
-		pFunc = m_handleClose;
-		sArg = EVENT_CLOSE;
-		break;
-
-	case PPSEvent::PPS_EVENT_OPEN_FAILED:
-		pFunc = m_handleOpenFailed;
-		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_WRITE_FAILED:
-		pFunc = m_handleWriteFailed;
-		sArg = EVENT_WRITE_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_READ_FAILED:
-		pFunc = m_handleReadFailed;
-		sArg = EVENT_READ_FAILED + " " + event.getMessage();
-		break;
-	}
-
-	if (pFunc != NULL)
-		pFunc(m_pArg, sArg);
-}
-
-std::string PPSInterfaceGlue::handleNewData(const ppsObject& newData)
-{
-	Json::Value data(Json::nullValue);
-	data[JSON_CHANGE_DATA] = JSONEncodeNewData(newData);
-	data[JSON_ALL_DATA] = JSONEncodeRead(m_interface.read());
-
-	Json::FastWriter writer;
-	return writer.write(data);
-}
-
-std::string PPSInterfaceGlue::read() const
-{
-	Json::Value data = JSONEncodeRead(m_interface.read());
-	Json::FastWriter writer;
-	return writer.write(data);
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeRead(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value readData(Json::nullValue);
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// An attribute was deleted: update the JSON data structure and the event data
-		if (ppsAttrib.flags & PPS_DELETED) {
-
-			readData.removeMember(ppsAttrib.name);
-		}
-		else {
-
-			// The value is a number
-			if (ppsAttrib.encoding == ENCODING_N) {
-
-				// Convert the value to floating point
-				// istringstream is locale aware - we shouldn't need to perform any special
-				// processing in order to properly convert the data to a floating point
-				// TODO: test that the istringstream conversion works with a locale
-				//       that uses alternate floating point number encoding
-				std::istringstream stream(ppsAttrib.value);
-				double doubleValue;
-
-				// Try to convert the value to a floating point
-				if (!(stream >> doubleValue)) {
-
-					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-					m_handleReadFailed(m_pArg, err);
-					return "";
-				}
-
-				readData[ppsAttrib.name] = doubleValue;
-			}
-			// The value is a boolean
-			else if (ppsAttrib.encoding == ENCODING_B) {
-
-				readData[ppsAttrib.name] = (ppsAttrib.value == "true");
-			}
-			// The value is JSON data
-			else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-				Json::Reader reader;
-				reader.parse(ppsAttrib.value, readData[ppsAttrib.name]);
-			}
-			// Just pass the value through as a straight string
-			else {
-
-				readData[ppsAttrib.name] = ppsAttrib.value;
-			}
-		}
-	}
-
-	return readData;
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeNewData(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value eventData(Json::nullValue);
-
-	// Set the PPS object name
-	eventData[JSON_OBJNAME] = ppsObj.name.substr(1); // PR 159829 : Remove the pre-pending '@' symbol
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// An attribute was deleted: update the JSON data structure and the event data
-		if (ppsAttrib.flags & PPS_DELETED) {
-
-			eventData[JSON_REMOVE][ppsAttrib.name] = true;
-		}
-		else {
-
-			eventData[JSON_CHANGED][ppsAttrib.name] = true;
-
-			// The value is a number
-			if (ppsAttrib.encoding == ENCODING_N) {
-
-				// Convert the value to floating point
-				// istringstream is locale aware - we shouldn't need to perform any special
-				// processing in order to properly convert the data to a floating point
-				// TODO: test that the istringstream conversion works with a locale
-				//       that uses alternate floating point number encoding
-				std::istringstream stream(ppsAttrib.value);
-				double doubleValue;
-
-				// Try to convert the value to a floating point
-				if (!(stream >> doubleValue)) {
-
-					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-					m_handleReadFailed(m_pArg, err);
-					return "";
-				}
-
-				eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
-			}
-			// The value is a boolean
-			else if (ppsAttrib.encoding == ENCODING_B) {
-
-				eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
-			}
-			// The value is JSON data
-			else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-				Json::Reader reader;
-				reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
-			}
-			// Just pass the value through as a straight string
-			else {
-
-				eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
-			}
-		}
-	}
-
-	return eventData;
-}
-
-void PPSInterfaceGlue::write(const std::string& data)
-{
-    Json::Reader reader;
-    Json::Value root;
-
-	bool parsingSuccessful = reader.parse(data, root);
-
-    // If parsing the JSON string fails, return a write error
-    if (!parsingSuccessful) {
-
-    	std::string err = EVENT_WRITE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
-        m_handleWriteFailed(m_pArg, err);
-        return;
-    }
-
-	Json::Value::Members memberNames = root.getMemberNames();
-
-	std::ostringstream output;
-	output.precision(15);
-
-	Json::Value member;
-
-	for (unsigned int i = 0; i < memberNames.size(); i++) {
-
-		output << memberNames[i] << ":";
-		member = root[memberNames[i]];
-
-		if (member.isObject() || member.isArray()) {
-
-			Json::FastWriter writer;
-			output << ENCODING_JSON << ":" << writer.write(member); // write() adds an \n
-		}
-		else if (member.isBool()) {
-
-			output << ENCODING_B << ":" << member.asString() << std::endl;
-		}
-		else if (member.isNumeric()) {
-
-			output << ENCODING_N << ":" << member.asDouble() << std::endl;
-		}
-		else if (member.isString()) {
-
-			output << ":" << member.asString() << std::endl;
-		}
-		else {
-
-			std::string err = EVENT_WRITE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
-			m_handleWriteFailed(m_pArg, err);
-			return;
-		}
-	}
-
-	m_interface.write(output.str());
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
deleted file mode 100644
index fafbacd..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSINTERFACEGLUE_H_
-#define PPSINTERFACEGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-#include <json/value.h>
-
-#include <string>
-
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * This class bridges JavaScript and the native PPSInterface code.
- */
-class PPSInterfaceGlue {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSInterfaceGlue();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSInterfaceGlue();
-
-	/**
-	 * The browser plugin should set these handlers.
-	 *
-	 * @param pArg pArg will be passed back to each callback function when it is called.
-	 */
-	void callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleFirstRead,
-					  callback* handleNewData,
-					  callback* handleClose,
-					  callback* handleOpenFailed,
-					  callback* handleWriteFailed,
-					  callback* handleReadFailed);
-
-	/**
-	 * Set the verbosity of logging to the slog.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS object.
-	 */
-	bool open(const std::string& path, int oflags);
-
-	/**
-	 * Write to a PPS object.
-	 */
-	void write(const std::string& data);
-
-	/**
-	 * Read from the PPS object. This actually returns the cached value of the last
-	 * onNewData event from PPSInteraface, then encodes it as JSON.
-	 */
-	std::string read() const;
-
-	/**
-	 * Close this PPS object.
-	 */
-	void close();
-
-	/**
-	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
-	 * The function blocks until this is finished.
-	 */
-	void sync();
-
-	/**
-	 * The function that the PPSInterface will call when an event happens.
-	 * This is the static function that is used as a function pointer for
-	 * PPSInterface::setEventFunc().
-	 *
-	 * @param event The event PPSInterface is sending.
-	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
-	 * object construction.
-	 */
-	static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
-	/**
-	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
-	 */
-	void onEvent(const PPSEvent& event);
-
-	/**
-	 * Handle a new data event.
-	 */
-	std::string handleNewData(const ppsObject& newData);
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * with a new data event. This structures the JSON with changed properties and the
-	 * data that has changed.
-	 */
-	Json::Value JSONEncodeNewData(const ppsObject& ppsObj) const;
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * when a call to read() is made.
-	 */
-	Json::Value JSONEncodeRead(const ppsObject& ppsObj) const;
-
-	// String names for the various events
-	static const std::string EVENT_OPEN;
-	static const std::string EVENT_OPEN_FAILED;
-	static const std::string EVENT_FIRST_READ;
-	static const std::string EVENT_NEW_DATA;
-	static const std::string EVENT_CLOSE;
-	static const std::string EVENT_READ_FAILED;
-	static const std::string EVENT_WRITE_FAILED;
-
-	/** Custom PPS encoding value: an "n" means a real number. */
-	static const std::string ENCODING_N;
-	/** Custom PPS encoding value: a "b" means a boolean value. */
-	static const std::string ENCODING_B;
-	/** Custom PPS encoding value: the data is encoded using JSON. */
-	static const std::string ENCODING_JSON;
-
-	// JSON constants
-	static const Json::StaticString JSON_REMOVE;
-	static const Json::StaticString JSON_CHANGED;
-	static const Json::StaticString JSON_DATA;
-	static const Json::StaticString JSON_OBJNAME;
-	static const Json::StaticString JSON_CHANGE_DATA;
-	static const Json::StaticString JSON_ALL_DATA;
-
-	/** The interface this object wraps. */
-	PPSInterface m_interface;
-
-	// Handlers for various events
-	void* m_pArg;
-	callback* m_handleOpen;
-	callback* m_handleFirstRead;
-	callback* m_handleNewData;
-	callback* m_handleClose;
-	callback* m_handleOpenFailed;
-	callback* m_handleWriteFailed;
-	callback* m_handleReadFailed;
-};
-
-} /* namespace jpps */
-#endif /* PPSINTERFACEGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
deleted file mode 100644
index 2eb4552..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSServerGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <sstream>
-
-#include <ppsparse.h>
-#include <fcntl.h>
-
-namespace jpps {
-
-const std::string PPSServerGlue::EVENT_OPEN = "onOpen";
-const std::string PPSServerGlue::EVENT_CLOSE = "onClose";
-const std::string PPSServerGlue::EVENT_CLIENT_CONNECT = "onClientConnect";
-const std::string PPSServerGlue::EVENT_CLIENT_DISCONNECT = "onClientDisconnect";
-const std::string PPSServerGlue::EVENT_MESSAGE = "onMessage";
-const std::string PPSServerGlue::EVENT_OPEN_FAILED = "onOpenFailed";
-const std::string PPSServerGlue::EVENT_SEND_MESSAGE_FAILED = "onSendMessageFailed";
-const std::string PPSServerGlue::EVENT_RECEIVE_MESSAGE_FAILED = "onReceiveMessageFailed";
-
-const std::string PPSServerGlue::ENCODING_N = "n";
-const std::string PPSServerGlue::ENCODING_B = "b";
-const std::string PPSServerGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSServerGlue::JSON_DATA("data");
-const Json::StaticString PPSServerGlue::JSON_CONNECTION_ID("clientId");
-
-PPSServerGlue::PPSServerGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleClose(NULL)
-, m_handleClientConnect(NULL)
-, m_handleClientDisconnect(NULL)
-, m_handleMessage(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleSendMessageFailed(NULL)
-, m_handleReceiveMessageFailed(NULL)
-{
-	m_interface.setEventFunc(onEvent, this);
-}
-
-PPSServerGlue::~PPSServerGlue()
-{
-	m_interface.setEventFunc(NULL);
-}
-
-void PPSServerGlue::callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleClose,
-					  callback* handleClientConnect,
-					  callback* handleClientDisconnect,
-					  callback* handleMessage,
-					  callback* handleOpenFailed,
-					  callback* handleSendMessageFailed,
-					  callback* handleReceiveMessageFailed)
-{
-	m_pArg = pArg;
-	m_handleOpen = handleOpen;
-	m_handleClose = handleClose;
-	m_handleClientConnect = handleClientConnect;
-	m_handleClientDisconnect = handleClientDisconnect;
-	m_handleMessage = handleMessage;
-	m_handleOpenFailed = handleOpenFailed;
-	m_handleSendMessageFailed = handleSendMessageFailed;
-	m_handleReceiveMessageFailed = handleReceiveMessageFailed;
-}
-
-
-void PPSServerGlue::setVerbose(unsigned short v)
-{
-	m_interface.setVerbose(v);
-}
-
-bool PPSServerGlue::open(const std::string& path, int oflags)
-{
-	// Make sure we're creating the server, if it doesn't exist
-	if (!(oflags & O_CREAT))
-		oflags &= O_CREAT;
-
-	// We don't expose the "mode" to the JS layer - always create in 0666 mode
-	return m_interface.open(path, oflags, 0666, true);
-}
-
-void PPSServerGlue::close()
-{
-	m_interface.close();
-}
-
-void PPSServerGlue::sendMessage(const std::string& clientID, const std::string& msg)
-{
-	std::string decodedMsg = JSONDecodeData(msg);
-	std::string message(clientID + "\n" + decodedMsg);
-	m_interface.write(message);
-}
-
-void PPSServerGlue::broadcastMessage(const std::string& msg)
-{
-	m_interface.write(JSONDecodeData(msg));
-}
-
-void PPSServerGlue::onEvent(void* pArg, const PPSEvent& event)
-{
-	PPSServerGlue* pGlue = static_cast<PPSServerGlue*>(pArg);
-
-	if (pGlue != NULL)
-		pGlue->onEvent(event);
-}
-
-void PPSServerGlue::onEvent(const PPSEvent& event)
-{
-	callback* pFunc = NULL;
-	std::string sArg;
-
-	switch (event.getEventType()) {
-
-	case PPSEvent::PPS_EVENT_OPENED:
-		pFunc = m_handleOpen;
-		sArg = EVENT_OPEN;
-		break;
-
-	// The server doesn't do anything with this event
-	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
-		break;
-
-	case PPSEvent::PPS_EVENT_NEW_DATA:
-	{
-		ppsObject data(event.getNewData());
-
-		// This means a new connection
-		if (data.flags & PPS_CREATED) {
-			sArg = EVENT_CLIENT_CONNECT;
-			pFunc = m_handleClientConnect;
-		}
-		// This means a connection is closed
-		else if (data.flags & PPS_DELETED) {
-			sArg = EVENT_CLIENT_DISCONNECT;
-			pFunc = m_handleClientDisconnect;
-		}
-		// We're getting data from the connection
-		else {
-			sArg = EVENT_MESSAGE;
-			pFunc = m_handleMessage;
-		}
-
-		sArg += " " + JSONEncodeData(data);
-
-		break;
-	}
-
-	case PPSEvent::PPS_EVENT_CLOSED:
-		pFunc = m_handleClose;
-		sArg = EVENT_CLOSE;
-		break;
-
-	case PPSEvent::PPS_EVENT_OPEN_FAILED:
-		pFunc = m_handleOpenFailed;
-		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_WRITE_FAILED:
-		pFunc = m_handleSendMessageFailed;
-		sArg = EVENT_SEND_MESSAGE_FAILED + " " + event.getMessage();
-		break;
-
-	case PPSEvent::PPS_EVENT_READ_FAILED:
-		pFunc = m_handleReceiveMessageFailed;
-		sArg = EVENT_RECEIVE_MESSAGE_FAILED + event.getMessage();
-		break;
-	}
-
-	if (pFunc != NULL)
-		pFunc(m_pArg, sArg);
-
-}
-
-std::string PPSServerGlue::JSONEncodeData(const ppsObject& ppsObj) const
-{
-	// If the ppsObj is empty, we can't encode it
-	if (ppsObj.name.empty())
-		return "";
-
-	Json::Value eventData(Json::nullValue);
-
-	// Set the client id
-	// Chop off the '+' or '-' if it's there
-	eventData[JSON_CONNECTION_ID] = ppsObj.name;
-
-	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
-		ppsAttribute ppsAttrib = (*it).second;
-
-		// The value is a number
-		if (ppsAttrib.encoding == ENCODING_N) {
-
-			// Convert the value to floating point
-			// istringstream is locale aware - we shouldn't need to perform any special
-			// processing in order to properly convert the data to a floating point
-			// TODO: test that the istringstream conversion works with a locale
-			//       that uses alternate floating point number encoding
-			std::istringstream stream(ppsAttrib.value);
-			double doubleValue;
-
-			// Try to convert the value to a floating point
-			if (!(stream >> doubleValue)) {
-
-				std::string err = EVENT_RECEIVE_MESSAGE_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
-				m_handleReceiveMessageFailed(m_pArg, err);
-				return "";
-			}
-
-			eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
-		}
-		// The value is a boolean
-		else if (ppsAttrib.encoding == ENCODING_B) {
-
-			eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
-		}
-		// The value is JSON data
-		else if (ppsAttrib.encoding == ENCODING_JSON) {
-
-			Json::Reader reader;
-			reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
-		}
-		// Just pass the value through as a straight string
-		else {
-
-			eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
-		}
-	}
-
-	Json::FastWriter writer;
-	return writer.write(eventData);
-}
-
-std::string PPSServerGlue::JSONDecodeData(const std::string& data) const
-{
-	 Json::Reader reader;
-	Json::Value root;
-
-	bool parsingSuccessful = reader.parse(data, root);
-
-	// If parsing the JSON string fails, return a write error
-	if (!parsingSuccessful) {
-
-		std::string err = EVENT_SEND_MESSAGE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
-		m_handleSendMessageFailed(m_pArg, err);
-		return "";
-	}
-
-	Json::Value::Members memberNames = root.getMemberNames();
-
-	std::ostringstream output;
-	output.precision(15);
-
-	Json::Value member;
-
-	for (unsigned int i = 0; i < memberNames.size(); i++) {
-
-		output << memberNames[i] << ":";
-		member = root[memberNames[i]];
-
-		if (member.isObject() || member.isArray()) {
-
-			Json::FastWriter writer;
-			output << ENCODING_JSON << ":" << writer.write(member);
-		}
-		else if (member.isBool()) {
-
-			output << ENCODING_B << ":" << member.asString();
-		}
-		else if (member.isNumeric()) {
-
-			output << ENCODING_N << ":" << member.asDouble();
-		}
-		else if (member.isString()) {
-
-			output << ":" << member.asString();
-		}
-		else {
-
-			std::string err = EVENT_SEND_MESSAGE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
-			m_handleSendMessageFailed(m_pArg, err);
-			return "";
-		}
-
-		// Make sure we terminate the line
-		output << std::endl;
-	}
-
-	return output.str();
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
deleted file mode 100644
index 8891829..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSSERVERGLUE_H_
-#define PPSSERVERGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-// Forward declaration
-namespace Json {
-class StaticString;
-}
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * Act as glue between jpps Server class an the PPSInterface.
- * This class encapsulates a PPS object as a PPS server.
- * TODO: write a better comment
- */
-class PPSServerGlue {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSServerGlue();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSServerGlue();
-
-	/**
-	 * The browser plugin should set these handlers.
-	 *
-	 * @param pArg pArg will be passed back to each callback function when it is called.
-	 */
-	void callbackInit(void* pArg,
-					  callback* handleOpen,
-					  callback* handleClose,
-					  callback* handleClientConnect,
-					  callback* handleClientDisconnect,
-					  callback* handleMessage,
-					  callback* handleOpenFailed,
-					  callback* handleSendMessageFailed,
-					  callback* handleReceiveMessageFailed);
-
-	/**
-	 * Set the verbosity of logging to the slog.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS server object.
-	 */
-	bool open(const std::string& path, int oflags);
-
-	/**
-	 * Close this PPS server object.
-	 */
-	void close();
-
-	/**
-	 * Send a message to a particular client.
-	 */
-	void sendMessage(const std::string& clientID, const std::string& msg);
-
-	/**
-	 * Send a message to all clients.
-	 */
-	void broadcastMessage(const std::string& msg);
-
-	/**
-	 * The function that the PPSInterface will call when an event happens.
-	 * This is the static function that is used as a function pointer for
-	 * PPSInterface::setEventFunc().
-	 *
-	 * @param event The event PPSInterface is sending.
-	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
-	 * object construction.
-	 */
-	static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
-	/**
-	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
-	 */
-	void onEvent(const PPSEvent& event);
-
-	/**
-	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
-	 * with a onMessage event.
-	 */
-	std::string JSONEncodeData(const ppsObject& ppsObj) const;
-
-	/**
-	 * Take a JSON string and change it into a PPS consumable string.
-	 */
-	std::string JSONDecodeData(const std::string& data) const;
-
-	// String names for the various events
-	static const std::string EVENT_OPEN;
-	static const std::string EVENT_CLOSE;
-	static const std::string EVENT_CLIENT_CONNECT;
-	static const std::string EVENT_CLIENT_DISCONNECT;
-	static const std::string EVENT_MESSAGE;
-	static const std::string EVENT_OPEN_FAILED;
-	static const std::string EVENT_SEND_MESSAGE_FAILED;
-	static const std::string EVENT_RECEIVE_MESSAGE_FAILED;
-
-	/** Custom PPS encoding value: an "n" means a real number. */
-	static const std::string ENCODING_N;
-	/** Custom PPS encoding value: a "b" means a boolean value. */
-	static const std::string ENCODING_B;
-	/** Custom PPS encoding value: the data is encoded using JSON. */
-	static const std::string ENCODING_JSON;
-
-	// JSON constants
-	static const Json::StaticString JSON_DATA;
-	static const Json::StaticString JSON_CONNECTION_ID;
-
-	/** The interface this object wraps. */
-	PPSInterface m_interface;
-
-	// Handlers for various events
-	void* m_pArg;
-	callback* m_handleOpen;
-	callback* m_handleClose;
-	callback* m_handleClientConnect;
-	callback* m_handleClientDisconnect;
-	callback* m_handleMessage;
-	callback* m_handleOpenFailed;
-	callback* m_handleSendMessageFailed;
-	callback* m_handleReceiveMessageFailed;
-
-};
-
-} /* namespace jpps */
-#endif /* PPSSERVERGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
deleted file mode 100644
index 9ce6b32..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PLUGINTYPES_H_
-#define PLUGINTYPES_H_
-
-namespace jpps {
-
-/**
- * Function type for setting handles between JNext plug-in and glue classes.
- */
-typedef void (callback)(void* pArg, const std::string&);
-
-}
-
-
-#endif /* PLUGINTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
deleted file mode 100644
index e06ad4c..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#include "JPPSPlugin.h"
-#include "JPPSServerPlugin.h"
-
-#include <string>
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @return A comma separated list of classes supported by this JNEXT extension
- */
-char* onGetObjList(void)
-{
-	static char* ppsclasses = NULL;
-
-	if (ppsclasses == NULL) {
-
-		// Get the length of all the strings, +1 for the ',' +1 for the \0
-		int size = std::strlen(jpps::JPPSPlugin::CLASS_NAME) + std::strlen(jpps::JPPSServerPlugin::CLASS_NAME) + 1 + 1;
-		ppsclasses = new char[size];
-		std::strcpy(ppsclasses, jpps::JPPSPlugin::CLASS_NAME);
-		std::strcat(ppsclasses, ",");
-		std::strcat(ppsclasses, jpps::JPPSServerPlugin::CLASS_NAME);
-		ppsclasses[size] = '\0';
-	}
-    // Return a comma separated list of classes known to this plugin
-    return ppsclasses;
-}
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @param strClassName Name of the class requested to be created Valid named are those
- * that are returned in onGetObjList
- *
- * @param strObjId The unique object id for the class
- *
- * @return A pointer to the created extension object
- */
-JSExt* onCreateObject(const std::string& strClassName, const std::string& strObjId)
-{
-    // Given a class name and identifier, create the relevant object.
-    if (strClassName == jpps::JPPSPlugin::CLASS_NAME) {
-        return new jpps::JPPSPlugin(strObjId);;
-    }
-    else if (strClassName == jpps::JPPSServerPlugin::CLASS_NAME) {
-    	return new jpps::JPPSServerPlugin(strObjId);
-    }
-
-    // Any other name is invalid
-    return NULL;
-}
-
-

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
deleted file mode 100644
index 37a9d17..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef LOGGER_H_
-#define LOGGER_H_
-
-#include <string>
-
-#include <sys/slog.h>
-#include <sys/slogcodes.h>
-
-namespace jpps {
-
-/**
- * The Logger class writes messages to the system log. It has a verbosity setting
- * in order to prevent cluttering the slog during normal operation.
- */
-class Logger {
-
-public:
-
-	enum slogType {
-		info = _SLOG_INFO,
-		warning = _SLOG_WARNING,
-		error = _SLOG_ERROR,
-		critical = _SLOG_CRITICAL,
-		debug = _SLOG_DEBUG1
-	};
-
-	/**
-	 * Default constructor. Sets the verbosity to 0;
-	 */
-	Logger() : m_verbosity(0) {}
-
-	/**
-	 * Destructor.
-	 */
-	~Logger() {}
-
-	/**
-	 * Set the desired level of verbosity. A value of 0 means that only warning,
-	 * error and critical messages will appear in the slog. A verbosity of 1 adds
-	 * info messages. A verbosity of 2 adds debug messages.
-	 */
-	inline void setVerbosity(unsigned short value) { m_verbosity = value; }
-
-	/**
-	 * Get the current level of verbosity.
-	 */
-	inline unsigned short getVerbosity() const { return m_verbosity; }
-
-	/**
-	 * Used to send messages to the system log (slog).
-	 *
-	 * @param type The type of slog message.
-	 * @param message The message to put in the slog.
-	 */
-	void slog(const slogType& type, const std::string& message) const {
-
-		// Don't display info or debug when verbosity is set to 0
-		if (m_verbosity == 0 && (type == info || type == debug)) return;
-		// Don't display debug when verbosity is set to 1
-		if (m_verbosity == 1 && type == debug) return;
-
-		::slogf(_SLOG_SETCODE(_SLOGC_GRAPHICS, 300), type, "%s", message.c_str());
-	}
-
-private:
-
-	/** The verbosity level.  */
-	unsigned short m_verbosity;
-};
-
-}
-
-#endif /* LOGGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
deleted file mode 100644
index 82ab5d1..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "Thread.h"
-#include <pthread.h>
-#include "Logger.h"
-#include <sstream>
-#include <string.h>
-#include <errno.h>
-
-namespace jpps {
-
-Thread::Thread()
-: m_threadID(-1)
-{
-	// Init the thread with all defaults
-	pthread_attr_init(&m_attrib);
-}
-
-Thread::~Thread()
-{
-	// Dispose of the thread attributes
-	pthread_attr_destroy(&m_attrib);
-}
-
-void Thread::start(void* (*start_routine)(void*), void* arg, const std::string& thread_name)
-{
-	// If this thread is already started, you can't start a new one
-	if (m_threadID != -1) {
-		return;
-	}
-
-	// Create a new thread
-	if (pthread_create(&m_threadID, &m_attrib, start_routine, arg) != 0) {
-
-		std::ostringstream ostream;
-		ostream << "Thread::start() Failed - Failed to create a new thread. "
-				<< " (" << errno << ": " << strerror(errno) << ")";
-
-		Logger logger;
-		logger.slog(Logger::warning, ostream.str());
-	}
-
-	if (!thread_name.empty())
-		pthread_setname_np(m_threadID, thread_name.c_str());
-}
-
-void Thread::stop()
-{
-	// If the thread wasn't running, we can't stop it
-	if (m_threadID == -1) {
-		return;
-	}
-
-	// Cancel the thread
-	if (pthread_cancel(m_threadID) != 0) {
-
-		std::ostringstream ostream;
-		ostream << "Thread::stop() Failed - Failed to cancel thread " << m_threadID << "."
-				<< " (" << errno << ": " << strerror(errno) << ")";
-
-		Logger logger;
-		logger.slog(Logger::warning, ostream.str());
-	}
-
-	// Reset the thread ID
-	m_threadID = -1;
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
deleted file mode 100644
index 79cc62a..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef THREAD_H_
-#define THREAD_H_
-
-#include <sys/types.h>
-#include <string>
-
-namespace jpps {
-
-/**
- * Simple wrapper to simplify thread management.
- */
-class Thread {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	Thread();
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~Thread();
-
-	/**
-	 * Start a thread with the given function. If the thread is already running and has not
-	 * been stopped, this does nothing.
-	 */
-	void start(void* (*start_routine)(void*), void* arg, const std::string& thread_name = "");
-
-	/**
-	 * Stop the thread. If the thread isn't running, this does nothing.
-	 */
-	void stop();
-
-	/**
-	 * Is the thread running?
-	 */
-	inline bool isRunning() const { return (m_threadID >= 0); }
-
-private:
-
-	/** The id of this thread. */
-	pthread_t m_threadID;
-
-	/** The attributes of this thread. */
-	pthread_attr_t m_attrib;
-};
-
-} /* namespace jpps */
-#endif /* THREAD_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Logger/index.js b/blackberry10/bin/templates/project/plugins/Logger/index.js
deleted file mode 100644
index 497f477..0000000
--- a/blackberry10/bin/templates/project/plugins/Logger/index.js
+++ /dev/null
@@ -1,25 +0,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.
- */
-
-module.exports = {
-    logLevel: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            level = JSON.parse(decodeURIComponent(args[0])),
-            message = JSON.parse(decodeURIComponent(args[1]));
-        console.log(level + ": " + message);
-        result.noResult(false);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Logger/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Logger/plugin.xml b/blackberry10/bin/templates/project/plugins/Logger/plugin.xml
new file mode 100644
index 0000000..77f5455
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Logger/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Logger</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Logger" value="Logger"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Logger/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Logger/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Logger/src/blackberry10/index.js
new file mode 100644
index 0000000..497f477
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Logger/src/blackberry10/index.js
@@ -0,0 +1,25 @@
+/*
+ * 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 = {
+    logLevel: function (success, fail, args, env) {
+        var result = new PluginResult(args, env),
+            level = JSON.parse(decodeURIComponent(args[0])),
+            message = JSON.parse(decodeURIComponent(args[1]));
+        console.log(level + ": " + message);
+        result.noResult(false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
deleted file mode 100644
index 5a991fe..0000000
--- a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
+++ /dev/null
@@ -1,59 +0,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.
- */
-
-//map from BB10 to cordova connection types:
-//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js
-function mapConnectionType(con) {
-    switch (con.type) {
-    case 'wired':
-        return 'ethernet';
-    case 'wifi':
-        return 'wifi';
-    case 'none':
-        return 'none';
-    case 'cellular':
-        switch (con.technology) {
-        case 'edge':
-        case 'gsm':
-            return '2g';
-        case 'evdo':
-            return '3g';
-        case 'umts':
-            return '3g';
-        case 'lte':
-            return '4g';
-        }
-        return "cellular";
-    }
-    return 'unknown';
-}
-
-function currentConnectionType() {
-    try {
-        //possible for webplatform to throw pps exception
-        return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type : 'none' });
-    }
-    catch (e) {
-        return 'unknown';
-    }
-}
-
-module.exports = {
-    getConnectionInfo: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        result.ok(currentConnectionType());
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/NetworkStatus/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/plugin.xml b/blackberry10/bin/templates/project/plugins/NetworkStatus/plugin.xml
new file mode 100644
index 0000000..4108569
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>NetworkStatus</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="NetworkStatus" value="NetworkStatus"/>
+        </config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/NetworkStatus/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/src/blackberry10/index.js
new file mode 100644
index 0000000..5a991fe
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/src/blackberry10/index.js
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+//map from BB10 to cordova connection types:
+//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js
+function mapConnectionType(con) {
+    switch (con.type) {
+    case 'wired':
+        return 'ethernet';
+    case 'wifi':
+        return 'wifi';
+    case 'none':
+        return 'none';
+    case 'cellular':
+        switch (con.technology) {
+        case 'edge':
+        case 'gsm':
+            return '2g';
+        case 'evdo':
+            return '3g';
+        case 'umts':
+            return '3g';
+        case 'lte':
+            return '4g';
+        }
+        return "cellular";
+    }
+    return 'unknown';
+}
+
+function currentConnectionType() {
+    try {
+        //possible for webplatform to throw pps exception
+        return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type : 'none' });
+    }
+    catch (e) {
+        return 'unknown';
+    }
+}
+
+module.exports = {
+    getConnectionInfo: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.ok(currentConnectionType());
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Notification/index.js b/blackberry10/bin/templates/project/plugins/Notification/index.js
deleted file mode 100644
index fad04f7..0000000
--- a/blackberry10/bin/templates/project/plugins/Notification/index.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-* Copyright 2013 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.
-*/
-
-function showDialog(args, dialogType, result) {
-    //Unpack and map the args
-    var msg = JSON.parse(decodeURIComponent(args[0])),
-    title = JSON.parse(decodeURIComponent(args[1])),
-    btnLabel = JSON.parse(decodeURIComponent(args[2]));
-
-    if (!Array.isArray(btnLabel)) {
-        //Converts to array for (string) and (string,string, ...) cases
-        btnLabel = btnLabel.split(",");
-    }
-
-    if (msg && typeof msg === "string") {
-        msg = msg.replace(/^"|"$/g, "").replace(/\\"/g, '"').replace(/\\\\/g, '\\');
-    } else {
-        result.error("message is undefined");
-        return;
-    }
-
-    var messageObj = {
-        title : title,
-        htmlmessage :  msg,
-        dialogType : dialogType,
-        optionalButtons : btnLabel
-    };
-
-    //TODO replace with getOverlayWebview() when available in webplatform
-    qnx.webplatform.getWebViews()[2].dialog.show(messageObj, function (data) {
-        if (typeof data === "number") {
-            //Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc]
-            result.callbackOk(++data, false);
-        } else {
-            //Prompt dialog callback expects object
-            result.callbackOk({
-                buttonIndex: data.ok ? 1 : 0,
-                input1: (data.oktext) ? decodeURIComponent(data.oktext) : ""
-            }, false);
-        }
-    });
-
-    result.noResult(true);
-}
-
-module.exports = {
-    alert: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-
-        if (Object.keys(args).length < 3) {
-            result.error("Notification action - alert arguments not found.");
-        } else {
-            showDialog(args, "CustomAsk", result);
-        }
-    },
-    confirm: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-
-        if (Object.keys(args).length < 3) {
-            result.error("Notification action - confirm arguments not found.");
-        } else {
-            showDialog(args, "CustomAsk", result);
-        }
-    },
-    prompt: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-
-        if (Object.keys(args).length < 3) {
-            result.error("Notification action - prompt arguments not found.");
-        } else {
-            showDialog(args, "JavaScriptPrompt", result);
-        }
-    },
-    beep: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        result.error("Beep not supported");
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0a540b8/blackberry10/bin/templates/project/plugins/Notification/plugin.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Notification/plugin.xml b/blackberry10/bin/templates/project/plugins/Notification/plugin.xml
new file mode 100644
index 0000000..447a676
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Notification/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    id="org.apache.cordova.core"
+    version="0.0.1">
+
+    <name>Notification</name>
+
+    <platform name="blackberry10">
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="Notification" value="Notification"/>
+        </config-file>
+    </platform>
+</plugin>


[46/50] [abbrv] webworks commit: Update BlackBerry10 VERSION to dev on master

Posted by lo...@apache.org.
Update BlackBerry10 VERSION to dev on master


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/6ceaaa9b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/6ceaaa9b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/6ceaaa9b

Branch: refs/heads/future
Commit: 6ceaaa9b52711316f692f65d149e872f3642961e
Parents: fc73d21
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri May 3 10:24:54 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:24:54 2013 -0400

----------------------------------------------------------------------
 blackberry10/VERSION                              |    2 +-
 blackberry10/bin/templates/project/www/VERSION    |    2 +-
 blackberry10/bin/templates/project/www/index.html |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6ceaaa9b/blackberry10/VERSION
----------------------------------------------------------------------
diff --git a/blackberry10/VERSION b/blackberry10/VERSION
index edf28ac..38f8e88 100644
--- a/blackberry10/VERSION
+++ b/blackberry10/VERSION
@@ -1 +1 @@
-2.4.0rc1
\ No newline at end of file
+dev

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6ceaaa9b/blackberry10/bin/templates/project/www/VERSION
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/VERSION b/blackberry10/bin/templates/project/www/VERSION
index 2eca156..38f8e88 100644
--- a/blackberry10/bin/templates/project/www/VERSION
+++ b/blackberry10/bin/templates/project/www/VERSION
@@ -1 +1 @@
-2.4.0rc1
+dev

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/6ceaaa9b/blackberry10/bin/templates/project/www/index.html
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/index.html b/blackberry10/bin/templates/project/www/index.html
index d45ae9f..ce767eb 100644
--- a/blackberry10/bin/templates/project/www/index.html
+++ b/blackberry10/bin/templates/project/www/index.html
@@ -19,7 +19,7 @@
 -->
 <html>
     <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+        <meta charset="utf-8" />
         <meta name="format-detection" content="telephone=no" />
         <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
         <link rel="stylesheet" type="text/css" href="css/index.css" />
@@ -33,7 +33,7 @@
                 <p class="event received">Device is Ready</p>
             </div>
         </div>
-        <script type="text/javascript" src="cordova-2.4.0rc1.js"></script>
+        <script type="text/javascript" src="cordova-dev.js"></script>
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">
             app.initialize();


[35/50] [abbrv] webworks commit: Updating cordova.blackberry10.js

Posted by lo...@apache.org.
Updating cordova.blackberry10.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/5c848dfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/5c848dfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/5c848dfe

Branch: refs/heads/future
Commit: 5c848dfeab1e47583ae2b0f73d1306c52d3a76c6
Parents: 7093c3e
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Apr 19 11:07:14 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 blackberry10/javascript/cordova.blackberry10.js |   44 +++++++----------
 1 files changed, 18 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5c848dfe/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index b94f2c9..286891b 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit 57999a27c82207cdb0c73f6395d14d18fb1b4170
+// commit dd02e6c9cd4121910c714e798f84fad2dc072879
 
-// File generated at :: Wed Apr 17 2013 11:51:51 GMT-0400 (EDT)
+// File generated at :: Fri Apr 19 2013 11:54:58 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -1964,40 +1964,32 @@ FileReader.prototype.abort = function() {
     return this.nativeReader.abort();
 };
 
+function read(method, context, file, encoding) {
+    if (file.fullPath) {
+         fileUtils.getEntryForURI(file.fullPath, function (entry) {
+            entry.nativeEntry.file(function (nativeFile) {
+                context.nativeReader[method].call(context.nativeReader, nativeFile, encoding);
+            }, context.onerror);
+        }, context.onerror);
+    } else {
+        context.nativeReader[method](file, encoding);
+    }
+}
+
 FileReader.prototype.readAsText = function(file, encoding) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsText(nativeFile, encoding);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsText", this, file, encoding);
 };
 
 FileReader.prototype.readAsDataURL = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsDataURL(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsDataURL", this, file);
 };
 
 FileReader.prototype.readAsBinaryString = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsBinaryString(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsBinaryString", this, file);
 };
 
 FileReader.prototype.readAsArrayBuffer = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsArrayBuffer(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsArrayBuffer", this, file);
 };
 
 window.FileReader = FileReader;


[18/50] [abbrv] Update cordova.js

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/4255d17b/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 45f9aff..b94f2c9 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit c8e2a018e93036393bcf5e0edd855187e5c587c5
+// commit 57999a27c82207cdb0c73f6395d14d18fb1b4170
 
-// File generated at :: Thu Apr 11 2013 16:14:07 GMT-0400 (EDT)
+// File generated at :: Wed Apr 17 2013 11:51:51 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -273,7 +273,7 @@ var cordova = {
      */
     callbackSuccess: function(callbackId, args) {
         try {
-            cordova.callbackFromNative(callbackId, true, args.status, args.message, args.keepCallback);
+            cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
         } catch (e) {
             console.log("Error in error callback: " + callbackId + " = "+e);
         }
@@ -286,7 +286,7 @@ var cordova = {
         // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
         // Derive success from status.
         try {
-            cordova.callbackFromNative(callbackId, false, args.status, args.message, args.keepCallback);
+            cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
         } catch (e) {
             console.log("Error in error callback: " + callbackId + " = "+e);
         }
@@ -295,13 +295,13 @@ var cordova = {
     /**
      * Called by native code when returning the result from an action.
      */
-    callbackFromNative: function(callbackId, success, status, message, keepCallback) {
+    callbackFromNative: function(callbackId, success, status, args, keepCallback) {
         var callback = cordova.callbacks[callbackId];
         if (callback) {
             if (success && status == cordova.callbackStatus.OK) {
-                callback.success && callback.success(message);
+                callback.success && callback.success.apply(null, args);
             } else if (!success) {
-                callback.fail && callback.fail(message);
+                callback.fail && callback.fail.apply(null, args);
             }
 
             // Clear callback if not expecting any more results
@@ -410,6 +410,7 @@ function each(objects, func, context) {
 }
 
 function clobber(obj, key, value) {
+    exports.replaceHookForTesting(obj, key);
     obj[key] = value;
     // Getters can only be overridden by getters.
     if (obj[key] !== value) {
@@ -493,19 +494,18 @@ function recursiveMerge(target, src) {
     }
 }
 
-module.exports = {
-    buildIntoButDoNotClobber: function(objects, target) {
-        include(target, objects, false, false);
-    },
-    buildIntoAndClobber: function(objects, target) {
-        include(target, objects, true, false);
-    },
-    buildIntoAndMerge: function(objects, target) {
-        include(target, objects, true, true);
-    },
-    recursiveMerge: recursiveMerge,
-    assignOrWrapInDeprecateGetter: assignOrWrapInDeprecateGetter
+exports.buildIntoButDoNotClobber = function(objects, target) {
+    include(target, objects, false, false);
 };
+exports.buildIntoAndClobber = function(objects, target) {
+    include(target, objects, true, false);
+};
+exports.buildIntoAndMerge = function(objects, target) {
+    include(target, objects, true, true);
+};
+exports.recursiveMerge = recursiveMerge;
+exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
+exports.replaceHookForTesting = function() {};
 
 });
 
@@ -735,6 +735,9 @@ channel.createSticky('onCordovaInfoReady');
 // Event to indicate that the connection property has been set.
 channel.createSticky('onCordovaConnectionReady');
 
+// Event to indicate that all automatically loaded JS plugins are loaded and ready.
+channel.createSticky('onPluginsReady');
+
 // Event to indicate that Cordova is ready
 channel.createSticky('onDeviceReady');
 
@@ -785,176 +788,6 @@ module.exports = {
 };
 });
 
-// file: lib/common/common.js
-define("cordova/common", function(require, exports, module) {
-
-module.exports = {
-    defaults: {
-        cordova: {
-            path: 'cordova',
-            children: {
-                exec: {
-                    path: 'cordova/exec'
-                },
-                logger: {
-                    path: 'cordova/plugin/logger'
-                }
-            }
-        },
-        Cordova: {
-            children: {
-                exec: {
-                    path: 'cordova/exec'
-                }
-            }
-        },
-        open : {
-            path: 'cordova/plugin/InAppBrowser'
-        },
-        navigator: {
-            children: {
-                notification: {
-                    path: 'cordova/plugin/notification'
-                },
-                accelerometer: {
-                    path: 'cordova/plugin/accelerometer'
-                },
-                battery: {
-                    path: 'cordova/plugin/battery'
-                },
-                camera:{
-                    path: 'cordova/plugin/Camera'
-                },
-                compass:{
-                    path: 'cordova/plugin/compass'
-                },
-                contacts: {
-                    path: 'cordova/plugin/contacts'
-                },
-                device:{
-                    children:{
-                        capture: {
-                            path: 'cordova/plugin/capture'
-                        }
-                    }
-                },
-                geolocation: {
-                    path: 'cordova/plugin/geolocation'
-                },
-                globalization: {
-                    path: 'cordova/plugin/globalization'
-                },
-                network: {
-                    children: {
-                        connection: {
-                            path: 'cordova/plugin/network',
-                            deprecated: 'navigator.network.connection is deprecated. Use navigator.connection instead.'
-                        }
-                    }
-                },
-                splashscreen: {
-                    path: 'cordova/plugin/splashscreen'
-                }
-            }
-        },
-        Acceleration: {
-            path: 'cordova/plugin/Acceleration'
-        },
-        Camera:{
-            path: 'cordova/plugin/CameraConstants'
-        },
-        CameraPopoverOptions: {
-            path: 'cordova/plugin/CameraPopoverOptions'
-        },
-        CaptureError: {
-            path: 'cordova/plugin/CaptureError'
-        },
-        CaptureAudioOptions:{
-            path: 'cordova/plugin/CaptureAudioOptions'
-        },
-        CaptureImageOptions: {
-            path: 'cordova/plugin/CaptureImageOptions'
-        },
-        CaptureVideoOptions: {
-            path: 'cordova/plugin/CaptureVideoOptions'
-        },
-        CompassHeading:{
-            path: 'cordova/plugin/CompassHeading'
-        },
-        CompassError:{
-            path: 'cordova/plugin/CompassError'
-        },
-        ConfigurationData: {
-            path: 'cordova/plugin/ConfigurationData'
-        },
-        Connection: {
-            path: 'cordova/plugin/Connection'
-        },
-        Contact: {
-            path: 'cordova/plugin/Contact'
-        },
-        ContactAddress: {
-            path: 'cordova/plugin/ContactAddress'
-        },
-        ContactError: {
-            path: 'cordova/plugin/ContactError'
-        },
-        ContactField: {
-            path: 'cordova/plugin/ContactField'
-        },
-        ContactFindOptions: {
-            path: 'cordova/plugin/ContactFindOptions'
-        },
-        ContactName: {
-            path: 'cordova/plugin/ContactName'
-        },
-        ContactOrganization: {
-            path: 'cordova/plugin/ContactOrganization'
-        },
-        Coordinates: {
-            path: 'cordova/plugin/Coordinates'
-        },
-        device: {
-            path: 'cordova/plugin/device'
-        },
-        GlobalizationError: {
-            path: 'cordova/plugin/GlobalizationError'
-        },
-        Media: {
-            path: 'cordova/plugin/Media'
-        },
-        MediaError: {
-            path: 'cordova/plugin/MediaError'
-        },
-        MediaFile: {
-            path: 'cordova/plugin/MediaFile'
-        },
-        MediaFileData:{
-            path: 'cordova/plugin/MediaFileData'
-        },
-        Position: {
-            path: 'cordova/plugin/Position'
-        },
-        PositionError: {
-            path: 'cordova/plugin/PositionError'
-        },
-        ProgressEvent: {
-            path: 'cordova/plugin/ProgressEvent'
-        }
-    },
-    clobbers: {
-        navigator: {
-            children: {
-                connection: {
-                    path: 'cordova/plugin/network'
-                }
-            }
-        }
-    }
-};
-
-});
-
 // file: lib/blackberry10/exec.js
 define("cordova/exec", function(require, exports, module) {
 
@@ -1032,9 +865,9 @@ function prepareNamespace(symbolPath, context) {
     var parts = symbolPath.split('.');
     var cur = context;
     for (var i = 0, part; part = parts[i]; ++i) {
-        cur[part] = cur[part] || {};
+        cur = cur[part] = cur[part] || {};
     }
-    return cur[parts[i-1]];
+    return cur;
 }
 
 exports.mapModules = function(context) {
@@ -1056,7 +889,7 @@ exports.mapModules = function(context) {
         if (strategy == 'm' && target) {
             builder.recursiveMerge(target, module);
         } else if ((strategy == 'd' && !target) || (strategy != 'd')) {
-            if (target) {
+            if (!(symbolPath in origSymbols)) {
                 origSymbols[symbolPath] = target;
             }
             builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
@@ -1133,7 +966,8 @@ define("cordova/plugin/Camera", function(require, exports, module) {
 
 var argscheck = require('cordova/argscheck'),
     exec = require('cordova/exec'),
-    Camera = require('cordova/plugin/CameraConstants');
+    Camera = require('cordova/plugin/CameraConstants'),
+    CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
 
 var cameraExport = {};
 
@@ -1168,11 +1002,13 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) {
     var correctOrientation = !!options.correctOrientation;
     var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
     var popoverOptions = getValue(options.popoverOptions, null);
+    var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
 
     var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
-                mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions];
+                mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
 
     exec(successCallback, errorCallback, "Camera", "takePicture", args);
+    return new CameraPopoverHandle();
 };
 
 cameraExport.cleanup = function(successCallback, errorCallback) {
@@ -1212,11 +1048,33 @@ module.exports = {
       ARROW_LEFT : 4,
       ARROW_RIGHT : 8,
       ARROW_ANY : 15
+  },
+  Direction:{
+      BACK: 0,
+      FRONT: 1
   }
 };
 
 });
 
+// file: lib/common/plugin/CameraPopoverHandle.js
+define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
+
+var exec = require('cordova/exec');
+
+/**
+ * A handle to an image picker popover.
+ */
+var CameraPopoverHandle = function() {
+    this.setPosition = function(popoverOptions) {
+        console.log('CameraPopoverHandle.setPosition is only supported on iOS.');
+    };
+};
+
+module.exports = CameraPopoverHandle;
+
+});
+
 // file: lib/common/plugin/CameraPopoverOptions.js
 define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
 
@@ -1342,9 +1200,9 @@ module.exports = CompassError;
 define("cordova/plugin/CompassHeading", function(require, exports, module) {
 
 var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
-  this.magneticHeading = magneticHeading || null;
-  this.trueHeading = trueHeading || null;
-  this.headingAccuracy = headingAccuracy || null;
+  this.magneticHeading = magneticHeading;
+  this.trueHeading = trueHeading;
+  this.headingAccuracy = headingAccuracy;
   this.timestamp = timestamp || new Date().getTime();
 };
 
@@ -1762,167 +1620,88 @@ module.exports = Coordinates;
 
 });
 
-// file: lib/common/plugin/DirectoryEntry.js
+// file: lib/blackberry10/plugin/DirectoryEntry.js
 define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
 
 var argscheck = require('cordova/argscheck'),
     utils = require('cordova/utils'),
-    exec = require('cordova/exec'),
     Entry = require('cordova/plugin/Entry'),
     FileError = require('cordova/plugin/FileError'),
-    DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
-     DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
-};
+    DirectoryReader = require('cordova/plugin/DirectoryReader'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    DirectoryEntry = function (name, fullPath) {
+        DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
+    };
 
 utils.extend(DirectoryEntry, Entry);
 
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
+DirectoryEntry.prototype.createReader = function () {
     return new DirectoryReader(this.fullPath);
 };
 
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or exclusively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
+DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
-    var win = successCallback && function(result) {
-        var entry = new DirectoryEntry(result.name, result.fullPath);
-        successCallback(entry);
-    };
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
+    this.nativeEntry.getDirectory(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
 };
 
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
+DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
     argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
+    this.nativeEntry.removeRecursively(successCallback, errorCallback);
 };
 
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or exclusively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
+DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {
     argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
-    var win = successCallback && function(result) {
-        var FileEntry = require('cordova/plugin/FileEntry');
-        var entry = new FileEntry(result.name, result.fullPath);
-        successCallback(entry);
-    };
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
+    this.nativeEntry.getFile(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
 };
 
 module.exports = DirectoryEntry;
 
 });
 
-// file: lib/common/plugin/DirectoryReader.js
+// file: lib/blackberry10/plugin/DirectoryReader.js
 define("cordova/plugin/DirectoryReader", function(require, exports, module) {
 
-var exec = require('cordova/exec'),
-    FileError = require('cordova/plugin/FileError') ;
+var FileError = require('cordova/plugin/FileError'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils');
 
-/**
- * An interface that lists the files and directories in a directory.
- */
 function DirectoryReader(path) {
-    this.path = path || null;
+    this.path = path;
 }
 
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
 DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
     var win = typeof successCallback !== 'function' ? null : function(result) {
-        var retVal = [];
-        for (var i=0; i<result.length; i++) {
-            var entry = null;
-            if (result[i].isDirectory) {
-                entry = new (require('cordova/plugin/DirectoryEntry'))();
-            }
-            else if (result[i].isFile) {
-                entry = new (require('cordova/plugin/FileEntry'))();
+            var retVal = [];
+            for (var i=0; i<result.length; i++) {
+                retVal.push(fileUtils.createEntry(result[i]));
             }
-            entry.isDirectory = result[i].isDirectory;
-            entry.isFile = result[i].isFile;
-            entry.name = result[i].name;
-            entry.fullPath = result[i].fullPath;
-            retVal.push(entry);
-        }
-        successCallback(retVal);
-    };
-    var fail = typeof errorCallback !== 'function' ? null : function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(win, fail, "File", "readEntries", [this.path]);
+            successCallback(retVal);
+        },
+        fail = typeof errorCallback !== 'function' ? null : function(code) {
+            errorCallback(new FileError(code));
+        };
+    fileUtils.getEntryForURI(this.path, function (entry) {
+        entry.nativeEntry.createReader().readEntries(win, fail);
+    }, function () {
+        fail(FileError.NOT_FOUND_ERR);
+    });
 };
 
 module.exports = DirectoryReader;
 
 });
 
-// file: lib/common/plugin/Entry.js
+// file: lib/blackberry10/plugin/Entry.js
 define("cordova/plugin/Entry", function(require, exports, module) {
 
 var argscheck = require('cordova/argscheck'),
-    exec = require('cordova/exec'),
     FileError = require('cordova/plugin/FileError'),
-    Metadata = require('cordova/plugin/Metadata');
+    Metadata = require('cordova/plugin/Metadata'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils');
 
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- *            {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- *            {boolean} true if Entry is a directory (readonly)
- * @param name
- *            {DOMString} name of the file or directory, excluding the path
- *            leading to it (readonly)
- * @param fullPath
- *            {DOMString} the absolute full path to the file or directory
- *            (readonly)
- */
 function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
     this.isFile = !!isFile;
     this.isDirectory = !!isDirectory;
@@ -1931,175 +1710,87 @@ function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
     this.filesystem = fileSystem || null;
 }
 
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- *            {Function} is called with a Metadata object
- * @param errorCallback
- *            {Function} is called with a FileError
- */
 Entry.prototype.getMetadata = function(successCallback, errorCallback) {
     argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
-    var success = successCallback && function(lastModified) {
+    var success = function(lastModified) {
         var metadata = new Metadata(lastModified);
-        successCallback(metadata);
-    };
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
+        if (typeof successCallback === 'function') {
+            successCallback(metadata);
+        }
     };
-
-    exec(success, fail, "File", "getMetadata", [this.fullPath]);
+    this.nativeEntry.getMetadata(success, errorCallback);
 };
 
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- *            {Function} is called with a Metadata object
- * @param errorCallback
- *            {Function} is called with a FileError
- * @param metadataObject
- *            {Object} keys and values to set
- */
 Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
     argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
-    exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
+    errorCallback("Not supported by platform");
 };
 
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- *            {DirectoryEntry} the directory to which to move this entry
- * @param newName
- *            {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- *            {Function} called with the new DirectoryEntry object
- * @param errorCallback
- *            {Function} called with a FileError
- */
 Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
     var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    // source path
-    var srcPath = this.fullPath,
-        // entry name
+            errorCallback(new FileError(code));
+        },
+        srcPath = this.fullPath,
         name = newName || this.name,
         success = function(entry) {
             if (entry) {
-                if (successCallback) {
-                    // create appropriate Entry object
-                    var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
-                    successCallback(result);
+                if (successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
                 }
             }
             else {
-                // no Entry object returned
-                fail && fail(FileError.NOT_FOUND_ERR);
+                if (typeof fail === 'function') {
+                    fail(FileError.NOT_FOUND_ERR);
+                }
             }
         };
-
-    // copy
-    exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
+    this.nativeEntry.moveTo(parent.nativeEntry, newName, success, errorCallback);
 };
 
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- *            {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- *            {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- *            {Function} called with the new Entry object
- * @param errorCallback
- *            {Function} called with a FileError
- */
+
 Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
     var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-
-        // source path
-    var srcPath = this.fullPath,
-        // entry name
+            errorCallback(new FileError(code));
+        },
+        srcPath = this.fullPath,
         name = newName || this.name,
-        // success callback
         success = function(entry) {
             if (entry) {
-                if (successCallback) {
-                    // create appropriate Entry object
-                    var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
-                    successCallback(result);
+                if (typeof successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
                 }
             }
             else {
-                // no Entry object returned
-                fail && fail(FileError.NOT_FOUND_ERR);
+                if (typeof fail === 'function') {
+                    fail(FileError.NOT_FOUND_ERR);
+                }
             }
         };
-
-    // copy
-    exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
+    this.nativeEntry.copyTo(parent.nativeEntry, newName, success, errorCallback);
 };
 
-/**
- * Return a URL that can be used to identify this entry.
- */
 Entry.prototype.toURL = function() {
-    // fullPath attribute contains the full URL
     return this.fullPath;
 };
 
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
 Entry.prototype.toURI = function(mimeType) {
     console.log("DEPRECATED: Update your code to use 'toURL'");
-    // fullPath attribute contains the full URI
     return this.toURL();
 };
 
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
 Entry.prototype.remove = function(successCallback, errorCallback) {
     argscheck.checkArgs('FF', 'Entry.remove', arguments);
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(successCallback, fail, "File", "remove", [this.fullPath]);
+    this.nativeEntry.remove(successCallback, errorCallback);
 };
 
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
 Entry.prototype.getParent = function(successCallback, errorCallback) {
     argscheck.checkArgs('FF', 'Entry.getParent', arguments);
     var win = successCallback && function(result) {
-        var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-        var entry = new DirectoryEntry(result.name, result.fullPath);
-        successCallback(entry);
-    };
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
+        successCallback(fileUtils.createEntry(result));
     };
-    exec(win, fail, "File", "getParent", [this.fullPath]);
+    this.nativeEntry.getParent(win, errorCallback);
 };
 
 module.exports = Entry;
@@ -2168,67 +1859,34 @@ module.exports = File;
 
 });
 
-// file: lib/common/plugin/FileEntry.js
+// file: lib/blackberry10/plugin/FileEntry.js
 define("cordova/plugin/FileEntry", function(require, exports, module) {
 
 var utils = require('cordova/utils'),
-    exec = require('cordova/exec'),
     Entry = require('cordova/plugin/Entry'),
     FileWriter = require('cordova/plugin/FileWriter'),
     File = require('cordova/plugin/File'),
-    FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
-     FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
+    FileError = require('cordova/plugin/FileError'),
+    FileEntry = function (name, fullPath) {
+        FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
+    };
 
 utils.extend(FileEntry, Entry);
 
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
 FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
-    this.file(function(filePointer) {
-        var writer = new FileWriter(filePointer);
-
-        if (writer.fileName === null || writer.fileName === "") {
-            errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
-        } else {
-            successCallback && successCallback(writer);
-        }
+    this.file(function (file) {
+        successCallback(new FileWriter(file));
     }, errorCallback);
 };
 
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
 FileEntry.prototype.file = function(successCallback, errorCallback) {
-    var win = successCallback && function(f) {
-        var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
-        successCallback(file);
-    };
-    var fail = errorCallback && function(code) {
-        errorCallback(new FileError(code));
-    };
-    exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
+    var fullPath = this.fullPath,
+        success = function (file) {
+            successCallback(new File(file.name, fullPath, file.type, file.lastModifiedDate, file.size));
+        };
+    this.nativeEntry.file(success, errorCallback);
 };
 
-
 module.exports = FileEntry;
 
 });
@@ -2264,317 +1922,99 @@ module.exports = FileError;
 
 });
 
-// file: lib/common/plugin/FileReader.js
+// file: lib/blackberry10/plugin/FileReader.js
 define("cordova/plugin/FileReader", function(require, exports, module) {
 
-var exec = require('cordova/exec'),
-    modulemapper = require('cordova/modulemapper'),
-    utils = require('cordova/utils'),
-    File = require('cordova/plugin/File'),
-    FileError = require('cordova/plugin/FileError'),
-    ProgressEvent = require('cordova/plugin/ProgressEvent'),
-    origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
+var origFileReader = window.FileReader,
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    utils = require('cordova/utils');
 
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- *      The root directory is the root of the file system.
- *      To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
 var FileReader = function() {
-    this._readyState = 0;
-    this._error = null;
-    this._result = null;
-    this._fileName = '';
-    this._realReader = origFileReader ? new origFileReader() : {};
+    this.nativeReader = new origFileReader();
 };
 
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
 utils.defineGetter(FileReader.prototype, 'readyState', function() {
-    return this._fileName ? this._readyState : this._realReader.readyState;
+    return this.nativeReader.readyState;
 });
 
 utils.defineGetter(FileReader.prototype, 'error', function() {
-    return this._fileName ? this._error: this._realReader.error;
+    return this.nativeReader.error;
 });
 
 utils.defineGetter(FileReader.prototype, 'result', function() {
-    return this._fileName ? this._result: this._realReader.result;
+    return this.nativeReader.result;
 });
 
 function defineEvent(eventName) {
     utils.defineGetterSetter(FileReader.prototype, eventName, function() {
-        return this._realReader[eventName] || null;
+        return this.nativeReader[eventName] || null;
     }, function(value) {
-        this._realReader[eventName] = value;
+        this.nativeReader[eventName] = value;
     });
 }
-defineEvent('onloadstart');    // When the read starts.
-defineEvent('onprogress');     // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
-defineEvent('onload');         // When the read has successfully completed.
-defineEvent('onerror');        // When the read has failed (see errors).
-defineEvent('onloadend');      // When the request has completed (either in success or failure).
-defineEvent('onabort');        // When the read has been aborted. For instance, by invoking the abort() method.
-
-function initRead(reader, file) {
-    // Already loading something
-    if (reader.readyState == FileReader.LOADING) {
-      throw new FileError(FileError.INVALID_STATE_ERR);
-    }
-
-    reader._result = null;
-    reader._error = null;
-    reader._readyState = FileReader.LOADING;
 
-    if (typeof file == 'string') {
-        // Deprecated in Cordova 2.4.
-        console.warning('Using a string argument with FileReader.readAs functions is deprecated.');
-        reader._fileName = file;
-    } else if (typeof file.fullPath == 'string') {
-        reader._fileName = file.fullPath;
-    } else {
-        reader._fileName = '';
-        return true;
-    }
-
-    reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
-}
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onload');
+defineEvent('onloadend');
+defineEvent('onloadstart');
+defineEvent('onprogress');
 
-/**
- * Abort reading file.
- */
 FileReader.prototype.abort = function() {
-    if (origFileReader && !this._fileName) {
-        return this._realReader.abort();
-    }
-    this._result = null;
-
-    if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
-      return;
-    }
-
-    this._readyState = FileReader.DONE;
-
-    // If abort callback
-    if (typeof this.onabort === 'function') {
-        this.onabort(new ProgressEvent('abort', {target:this}));
-    }
-    // If load end callback
-    if (typeof this.onloadend === 'function') {
-        this.onloadend(new ProgressEvent('loadend', {target:this}));
-    }
+    return this.nativeReader.abort();
 };
 
-/**
- * Read text file.
- *
- * @param file          {File} File object containing file properties
- * @param encoding      [Optional] (see http://www.iana.org/assignments/character-sets)
- */
 FileReader.prototype.readAsText = function(file, encoding) {
-    if (initRead(this, file)) {
-        return this._realReader.readAsText(file, encoding);
-    }
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsText(nativeFile, encoding);
+        }, that.onerror);
+    }, that.onerror);
+};
 
-    // Default encoding is UTF-8
-    var enc = encoding ? encoding : "UTF-8";
-    var me = this;
-    var execArgs = [this._fileName, enc];
+FileReader.prototype.readAsDataURL = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsDataURL(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
 
-    // Maybe add slice parameters.
-    if (file.end < file.size) {
-        execArgs.push(file.start, file.end);
-    } else if (file.start > 0) {
-        execArgs.push(file.start);
-    }
+FileReader.prototype.readAsBinaryString = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsBinaryString(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
 
-    // Read file
-    exec(
-        // Success callback
-        function(r) {
-            // If DONE (cancelled), then don't do anything
-            if (me._readyState === FileReader.DONE) {
-                return;
-            }
+FileReader.prototype.readAsArrayBuffer = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsArrayBuffer(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
 
-            // Save result
-            me._result = r;
+window.FileReader = FileReader;
+module.exports = FileReader;
 
-            // If onload callback
-            if (typeof me.onload === "function") {
-                me.onload(new ProgressEvent("load", {target:me}));
-            }
+});
 
-            // DONE state
-            me._readyState = FileReader.DONE;
+// file: lib/blackberry10/plugin/FileSystem.js
+define("cordova/plugin/FileSystem", function(require, exports, module) {
 
-            // If onloadend callback
-            if (typeof me.onloadend === "function") {
-                me.onloadend(new ProgressEvent("loadend", {target:me}));
-            }
-        },
-        // Error callback
-        function(e) {
-            // If DONE (cancelled), then don't do anything
-            if (me._readyState === FileReader.DONE) {
-                return;
-            }
-
-            // DONE state
-            me._readyState = FileReader.DONE;
-
-            // null result
-            me._result = null;
-
-            // Save error
-            me._error = new FileError(e);
-
-            // If onerror callback
-            if (typeof me.onerror === "function") {
-                me.onerror(new ProgressEvent("error", {target:me}));
-            }
-
-            // If onloadend callback
-            if (typeof me.onloadend === "function") {
-                me.onloadend(new ProgressEvent("loadend", {target:me}));
-            }
-        }, "File", "readAsText", execArgs);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- *      data:[<mediatype>][;base64],<data>
- *
- * @param file          {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
-    if (initRead(this, file)) {
-        return this._realReader.readAsDataURL(file);
-    }
-
-    var me = this;
-    var execArgs = [this._fileName];
-
-    // Maybe add slice parameters.
-    if (file.end < file.size) {
-        execArgs.push(file.start, file.end);
-    } else if (file.start > 0) {
-        execArgs.push(file.start);
-    }
-
-    // Read file
-    exec(
-        // Success callback
-        function(r) {
-            // If DONE (cancelled), then don't do anything
-            if (me._readyState === FileReader.DONE) {
-                return;
-            }
-
-            // DONE state
-            me._readyState = FileReader.DONE;
-
-            // Save result
-            me._result = r;
-
-            // If onload callback
-            if (typeof me.onload === "function") {
-                me.onload(new ProgressEvent("load", {target:me}));
-            }
-
-            // If onloadend callback
-            if (typeof me.onloadend === "function") {
-                me.onloadend(new ProgressEvent("loadend", {target:me}));
-            }
-        },
-        // Error callback
-        function(e) {
-            // If DONE (cancelled), then don't do anything
-            if (me._readyState === FileReader.DONE) {
-                return;
-            }
-
-            // DONE state
-            me._readyState = FileReader.DONE;
-
-            me._result = null;
-
-            // Save error
-            me._error = new FileError(e);
-
-            // If onerror callback
-            if (typeof me.onerror === "function") {
-                me.onerror(new ProgressEvent("error", {target:me}));
-            }
-
-            // If onloadend callback
-            if (typeof me.onloadend === "function") {
-                me.onloadend(new ProgressEvent("loadend", {target:me}));
-            }
-        }, "File", "readAsDataURL", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file          {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
-    if (initRead(this, file)) {
-        return this._realReader.readAsBinaryString(file);
-    }
-    // TODO - Can't return binary data to browser.
-    console.log('method "readAsBinaryString" is not supported at this time.');
-    this.abort();
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file          {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
-    if (initRead(this, file)) {
-        return this._realReader.readAsArrayBuffer(file);
-    }
-    // TODO - Can't return binary data to browser.
-    console.log('This method is not supported at this time.');
-    this.abort();
-};
-
-module.exports = FileReader;
-
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
+module.exports = function(name, root) {
     this.name = name || null;
     if (root) {
-        this.root = new DirectoryEntry(root.name, root.fullPath);
+        this.root = root;
     }
 };
 
-module.exports = FileSystem;
-
 });
 
 // file: lib/common/plugin/FileTransfer.js
@@ -2593,6 +2033,38 @@ function newProgressEvent(result) {
     return pe;
 }
 
+function getBasicAuthHeader(urlString) {
+    var header =  null;
+
+    if (window.btoa) {
+        // parse the url using the Location object
+        var url = document.createElement('a');
+        url.href = urlString;
+
+        var credentials = null;
+        var protocol = url.protocol + "//";
+        var origin = protocol + url.host;
+
+        // check whether there are the username:password credentials in the url
+        if (url.href.indexOf(origin) !== 0) { // credentials found
+            var atIndex = url.href.indexOf("@");
+            credentials = url.href.substring(protocol.length, atIndex);
+        }
+
+        if (credentials) {
+            var authHeader = "Authorization";
+            var authHeaderValue = "Basic " + window.btoa(credentials);
+
+            header = {
+                name : authHeader,
+                value : authHeaderValue
+            };
+        }
+    }
+
+    return header;
+}
+
 var idCounter = 0;
 
 /**
@@ -2623,11 +2095,25 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
     var params = null;
     var chunkedMode = true;
     var headers = null;
+    var httpMethod = null;
+    var basicAuthHeader = getBasicAuthHeader(server);
+    if (basicAuthHeader) {
+        options = options || {};
+        options.headers = options.headers || {};
+        options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+    }
+
     if (options) {
         fileKey = options.fileKey;
         fileName = options.fileName;
         mimeType = options.mimeType;
         headers = options.headers;
+        httpMethod = options.httpMethod || "POST";
+        if (httpMethod.toUpperCase() == "PUT"){
+            httpMethod = "PUT";
+        } else {
+            httpMethod = "POST";
+        }
         if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
             chunkedMode = options.chunkedMode;
         }
@@ -2640,7 +2126,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
     }
 
     var fail = errorCallback && function(e) {
-        var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+        var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
         errorCallback(error);
     };
 
@@ -2654,7 +2140,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
             successCallback && successCallback(result);
         }
     };
-    exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id]);
+    exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
 };
 
 /**
@@ -2664,10 +2150,24 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
  * @param successCallback (Function}  Callback to be invoked when upload has completed
  * @param errorCallback {Function}    Callback to be invoked upon error
  * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
+ * @param options {FileDownloadOptions} Optional parameters such as headers
  */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts) {
+FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
     argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
     var self = this;
+
+    var basicAuthHeader = getBasicAuthHeader(source);
+    if (basicAuthHeader) {
+        options = options || {};
+        options.headers = options.headers || {};
+        options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+    }
+
+    var headers = null;
+    if (options) {
+        headers = options.headers || null;
+    }
+
     var win = function(result) {
         if (typeof result.lengthComputable != "undefined") {
             if (self.onprogress) {
@@ -2690,20 +2190,19 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
     };
 
     var fail = errorCallback && function(e) {
-        var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+        var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
         errorCallback(error);
     };
 
-    exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id]);
+    exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
 };
 
 /**
- * Aborts the ongoing file transfer on this object
- * @param successCallback {Function}  Callback to be invoked upon success
- * @param errorCallback {Function}    Callback to be invoked upon error
+ * Aborts the ongoing file transfer on this object. The original error
+ * callback for the file transfer will be called if necessary.
  */
-FileTransfer.prototype.abort = function(successCallback, errorCallback) {
-    exec(successCallback, errorCallback, 'FileTransfer', 'abort', [this._id]);
+FileTransfer.prototype.abort = function() {
+    exec(null, null, 'FileTransfer', 'abort', [this._id]);
 };
 
 module.exports = FileTransfer;
@@ -2717,11 +2216,12 @@ define("cordova/plugin/FileTransferError", function(require, exports, module) {
  * FileTransferError
  * @constructor
  */
-var FileTransferError = function(code, source, target, status) {
+var FileTransferError = function(code, source, target, status, body) {
     this.code = code || null;
     this.source = source || null;
     this.target = target || null;
     this.http_status = status || null;
+    this.body = body || null;
 };
 
 FileTransferError.FILE_NOT_FOUND_ERR = 1;
@@ -2746,12 +2246,13 @@ define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
  * @param headers {Object}   Keys are header names, values are header values. Multiple
  *                           headers of the same name are not supported.
  */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
+var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
     this.fileKey = fileKey || null;
     this.fileName = fileName || null;
     this.mimeType = mimeType || null;
     this.params = params || null;
     this.headers = headers || null;
+    this.httpMethod = httpMethod || null;
 };
 
 module.exports = FileUploadOptions;
@@ -2775,259 +2276,105 @@ module.exports = FileUploadResult;
 
 });
 
-// file: lib/common/plugin/FileWriter.js
+// file: lib/blackberry10/plugin/FileWriter.js
 define("cordova/plugin/FileWriter", function(require, exports, module) {
 
-var exec = require('cordova/exec'),
-    FileError = require('cordova/plugin/FileError'),
-    ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- *      The root directory is the root of the file system.
- *      To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
-    this.fileName = "";
-    this.length = 0;
-    if (file) {
-        this.fileName = file.fullPath || file;
-        this.length = file.size || 0;
-    }
-    // default is to write at the beginning of the file
-    this.position = 0;
-
-    this.readyState = 0; // EMPTY
+var FileError = require('cordova/plugin/FileError'),
+    ProgressEvent = require('cordova/plugin/ProgressEvent'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    utils = require('cordova/utils');
 
-    this.result = null;
+function FileWriter (file) {
+    var that = this;
+    this.file = file;
+    this.events = {};
+    this.pending = [];
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.createWriter(function (writer) {
+            var i,
+                event;
+            that.nativeWriter = writer;
+            for (event in that.events) {
+                if (that.events.hasOwnProperty(event)) {
+                    that.nativeWriter[event] = that.events[event];
+                }
+            }
+            for (i = 0; i < that.pending.length; i++) {
+                that.pending[i]();
+            }
+        });
+    });
+    this.events = {};
+    this.pending = [];
+}
 
-    // Error
-    this.error = null;
+utils.defineGetter(FileWriter.prototype, 'error', function() {
+    return this.nativeWriter ? this.nativeWriter.error : null;
+});
 
-    // Event handlers
-    this.onwritestart = null;   // When writing starts
-    this.onprogress = null;     // While writing the file, and reporting partial file data
-    this.onwrite = null;        // When the write has successfully completed.
-    this.onwriteend = null;     // When the request has completed (either in success or failure).
-    this.onabort = null;        // When the write has been aborted. For instance, by invoking the abort() method.
-    this.onerror = null;        // When the write has failed (see errors).
-};
+utils.defineGetter(FileWriter.prototype, 'fileName', function() {
+    return this.nativeWriter ? this.nativeWriter.fileName : this.file.name;
+});
 
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
+utils.defineGetter(FileWriter.prototype, 'length', function() {
+    return this.nativeWriter ? this.nativeWriter.length : this.file.size;
+});
 
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
-    // check for invalid state
-    if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
-        throw new FileError(FileError.INVALID_STATE_ERR);
-    }
+utils.defineGetter(FileWriter.prototype, 'position', function() {
+    return this.nativeWriter ? this.nativeWriter.position : 0;
+});
 
-    // set error
-    this.error = new FileError(FileError.ABORT_ERR);
+utils.defineGetter(FileWriter.prototype, 'readyState', function() {
+    return this.nativeWriter ? this.nativeWriter.readyState : 0;
+});
 
-    this.readyState = FileWriter.DONE;
+function defineEvent(eventName) {
+    utils.defineGetterSetter(FileWriter.prototype, eventName, function() {
+        return this.nativeWriter ? this.nativeWriter[eventName] || null : this.events[eventName] || null;
+    }, function(value) {
+        if (this.nativeWriter) {
+            this.nativeWriter[eventName] = value;
+        }
+        else {
+            this.events[eventName] = value;
+        }
+    });
+}
 
-    // If abort callback
-    if (typeof this.onabort === "function") {
-        this.onabort(new ProgressEvent("abort", {"target":this}));
-    }
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onprogress');
+defineEvent('onwrite');
+defineEvent('onwriteend');
+defineEvent('onwritestart');
 
-    // If write end callback
-    if (typeof this.onwriteend === "function") {
-        this.onwriteend(new ProgressEvent("writeend", {"target":this}));
-    }
+FileWriter.prototype.abort = function() {
+    this.nativeWriter.abort();
 };
 
-/**
- * Writes data to the file
- *
- * @param text to be written
- */
 FileWriter.prototype.write = function(text) {
-    // Throw an exception if we are already writing a file
-    if (this.readyState === FileWriter.WRITING) {
-        throw new FileError(FileError.INVALID_STATE_ERR);
-    }
-
-    // WRITING state
-    this.readyState = FileWriter.WRITING;
-
-    var me = this;
-
-    // If onwritestart callback
-    if (typeof me.onwritestart === "function") {
-        me.onwritestart(new ProgressEvent("writestart", {"target":me}));
-    }
-
-    // Write file
-    exec(
-        // Success callback
-        function(r) {
-            // If DONE (cancelled), then don't do anything
-            if (me.readyState === FileWriter.DONE) {
-                return;
-            }
-
-            // position always increases by bytes written because file would be extended
-            me.position += r;
-            // The length of the file is now where we are done writing.
-
-            me.length = me.position;
-
-            // DONE state
-            me.readyState = FileWriter.DONE;
-
-            // If onwrite callback
-            if (typeof me.onwrite === "function") {
-                me.onwrite(new ProgressEvent("write", {"target":me}));
-            }
-
-            // If onwriteend callback
-            if (typeof me.onwriteend === "function") {
-                me.onwriteend(new ProgressEvent("writeend", {"target":me}));
-            }
-        },
-        // Error callback
-        function(e) {
-            // If DONE (cancelled), then don't do anything
-            if (me.readyState === FileWriter.DONE) {
-                return;
-            }
-
-            // DONE state
-            me.readyState = FileWriter.DONE;
-
-            // Save error
-            me.error = new FileError(e);
-
-            // If onerror callback
-            if (typeof me.onerror === "function") {
-                me.onerror(new ProgressEvent("error", {"target":me}));
-            }
+    var that = this,
+        op = function () {
+            that.nativeWriter.write(new Blob([text]));
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
 
-            // If onwriteend callback
-            if (typeof me.onwriteend === "function") {
-                me.onwriteend(new ProgressEvent("writeend", {"target":me}));
-            }
-        }, "File", "write", [this.fileName, text, this.position]);
 };
 
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound.  If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
 FileWriter.prototype.seek = function(offset) {
-    // Throw an exception if we are already writing a file
-    if (this.readyState === FileWriter.WRITING) {
-        throw new FileError(FileError.INVALID_STATE_ERR);
-    }
-
-    if (!offset && offset !== 0) {
-        return;
-    }
-
-    // See back from end of file.
-    if (offset < 0) {
-        this.position = Math.max(offset + this.length, 0);
-    }
-    // Offset is bigger than file size so set position
-    // to the end of the file.
-    else if (offset > this.length) {
-        this.position = this.length;
-    }
-    // Offset is between 0 and file size so set the position
-    // to start writing.
-    else {
-        this.position = offset;
-    }
+    var that = this,
+        op = function () {
+            that.nativeWriter.seek(offset);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
 };
 
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
 FileWriter.prototype.truncate = function(size) {
-    // Throw an exception if we are already writing a file
-    if (this.readyState === FileWriter.WRITING) {
-        throw new FileError(FileError.INVALID_STATE_ERR);
-    }
-
-    // WRITING state
-    this.readyState = FileWriter.WRITING;
-
-    var me = this;
-
-    // If onwritestart callback
-    if (typeof me.onwritestart === "function") {
-        me.onwritestart(new ProgressEvent("writestart", {"target":this}));
-    }
-
-    // Write file
-    exec(
-        // Success callback
-        function(r) {
-            // If DONE (cancelled), then don't do anything
-            if (me.readyState === FileWriter.DONE) {
-                return;
-            }
-
-            // DONE state
-            me.readyState = FileWriter.DONE;
-
-            // Update the length of the file
-            me.length = r;
-            me.position = Math.min(me.position, r);
-
-            // If onwrite callback
-            if (typeof me.onwrite === "function") {
-                me.onwrite(new ProgressEvent("write", {"target":me}));
-            }
-
-            // If onwriteend callback
-            if (typeof me.onwriteend === "function") {
-                me.onwriteend(new ProgressEvent("writeend", {"target":me}));
-            }
-        },
-        // Error callback
-        function(e) {
-            // If DONE (cancelled), then don't do anything
-            if (me.readyState === FileWriter.DONE) {
-                return;
-            }
-
-            // DONE state
-            me.readyState = FileWriter.DONE;
-
-            // Save error
-            me.error = new FileError(e);
-
-            // If onerror callback
-            if (typeof me.onerror === "function") {
-                me.onerror(new ProgressEvent("error", {"target":me}));
-            }
-
-            // If onwriteend callback
-            if (typeof me.onwriteend === "function") {
-                me.onwriteend(new ProgressEvent("writeend", {"target":me}));
-            }
-        }, "File", "truncate", [this.fileName, size]);
+    var that = this,
+        op = function () {
+            that.nativeWriter.truncate(size);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
 };
 
 module.exports = FileWriter;
@@ -3086,11 +2433,13 @@ define("cordova/plugin/InAppBrowser", function(require, exports, module) {
 
 var exec = require('cordova/exec');
 var channel = require('cordova/channel');
+var modulemapper = require('cordova/modulemapper');
 
 function InAppBrowser() {
    this.channels = {
         'loadstart': channel.create('loadstart'),
         'loadstop' : channel.create('loadstop'),
+        'loaderror' : channel.create('loaderror'),
         'exit' : channel.create('exit')
    };
 }
@@ -3113,6 +2462,26 @@ InAppBrowser.prototype = {
         if (eventname in this.channels) {
             this.channels[eventname].unsubscribe(f);
         }
+    },
+
+    executeScript: function(injectDetails, cb) {
+        if (injectDetails.code) {
+            exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
+        } else if (injectDetails.file) {
+            exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
+        } else {
+            throw new Error('executeScript requires exactly one of code or file to be specified');
+        }
+    },
+
+    insertCSS: function(injectDetails, cb) {
+        if (injectDetails.code) {
+            exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
+        } else if (injectDetails.file) {
+            exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
+        } else {
+            throw new Error('insertCSS requires exactly one of code or file to be specified');
+        }
     }
 };
 
@@ -3121,12 +2490,17 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
     var cb = function(eventname) {
        iab._eventHandler(eventname);
     };
-    exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
+
+    // Don't catch calls that write to existing frames (e.g. named iframes).
+    if (window.frames && window.frames[strWindowName]) {
+        var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
+        return origOpenFunc.apply(window, arguments);
+    }
+
+    exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
     return iab;
 };
 
-//Export the original open so it can be used if needed
-module.exports._orig = window.open;
 
 });
 
@@ -3697,6 +3071,17 @@ module.exports = accelerometer;
 
 });
 
+// file: lib/common/plugin/accelerometer/symbols.js
+define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
+modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
+
+});
+
 // file: lib/common/plugin/battery.js
 define("cordova/plugin/battery", function(require, exports, module) {
 
@@ -3781,18 +3166,29 @@ module.exports = battery;
 
 });
 
+// file: lib/common/plugin/battery/symbols.js
+define("cordova/plugin/battery/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
+
+});
+
 // file: lib/blackberry10/plugin/blackberry10/InAppBrowser.js
 define("cordova/plugin/blackberry10/InAppBrowser", function(require, exports, module) {
 
 var cordova = require('cordova'),
-    core = require('cordova/plugin/InAppBrowser'),
+    modulemapper = require('cordova/modulemapper'),
+    origOpen = modulemapper.getOriginalSymbol(window, 'open'),
     browser = {
         close: function () { } //dummy so we don't have to check for undefined
     };
 
 var navigate = {
     "_blank": function (url, whitelisted) {
-        return core._orig.apply(null, [url, "_blank"]);
+        return origOpen(url, "_blank");
     },
 
     "_self": function (url, whitelisted) {
@@ -3801,7 +3197,7 @@ var navigate = {
             return window;
         }
         else {
-            return core._orig.apply(null, [url, "_blank"]);
+            return origOpen(url, "_blank");
         }
     },
 
@@ -4205,441 +3601,220 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/file.js
-define("cordova/plugin/blackberry10/file", function(require, exports, module) {
+// file: lib/blackberry10/plugin/blackberry10/fileTransfer.js
+define("cordova/plugin/blackberry10/fileTransfer", function(require, exports, module) {
 
-/*global WebKitBlobBuilder:false */
+/*global Blob:false */
 var cordova = require('cordova'),
-    FileError = require('cordova/plugin/FileError'),
-    DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
-    FileEntry = require('cordova/plugin/FileEntry'),
-    File = require('cordova/plugin/File'),
-    FileSystem = require('cordova/plugin/FileSystem'),
-    FileReader = require('cordova/plugin/FileReader'),
-    nativeRequestFileSystem = window.webkitRequestFileSystem,
+    ProgressEvent = require('cordova/plugin/ProgressEvent'),
     nativeResolveLocalFileSystemURI = function(uri, success, fail) {
         if (uri.substring(0,11) !== "filesystem:") {
             uri = "filesystem:" + uri;
         }
         window.webkitResolveLocalFileSystemURL(uri, success, fail);
     },
-    NativeFileReader = window.FileReader;
-
-window.FileReader = FileReader;
-window.File = File;
+    xhr;
 
-function getFileSystemName(nativeFs) {
-    return (nativeFs.name.indexOf("Persistent") != -1) ? "persistent" : "temporary";
+function getParentPath(filePath) {
+    var pos = filePath.lastIndexOf('/');
+    return filePath.substring(0, pos + 1);
 }
 
-function makeEntry(entry) {
-    if (entry.isDirectory) {
-        return new DirectoryEntry(entry.name, decodeURI(entry.toURL()).substring(11));
-    }
-    else {
-        return new FileEntry(entry.name, decodeURI(entry.toURL()).substring(11));
-    }
+function getFileName(filePath) {
+    var pos = filePath.lastIndexOf('/');
+    return filePath.substring(pos + 1);
 }
 
-module.exports = {
-    /* requestFileSystem */
-    requestFileSystem: function(args, successCallback, errorCallback) {
-        var type = args[0],
-            size = args[1];
-
-        nativeRequestFileSystem(type, size, function(nativeFs) {
-            successCallback(new FileSystem(getFileSystemName(nativeFs), makeEntry(nativeFs.root)));
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* resolveLocalFileSystemURI */
-    resolveLocalFileSystemURI: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            successCallback(makeEntry(entry));
-        }, function(error) {
-            var code = error.code;
-            switch (code) {
-                case 5:
-                    code = FileError.NOT_FOUND_ERR;
-                    break;
-
-                case 2:
-                    code = FileError.ENCODING_ERR;
-                    break;
-            }
-            errorCallback(code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* DirectoryReader */
-    readEntries: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(dirEntry) {
-            var reader = dirEntry.createReader();
-            reader.readEntries(function(entries) {
-                var retVal = [];
-                for (var i = 0; i < entries.length; i++) {
-                    retVal.push(makeEntry(entries[i]));
-                }
-                successCallback(retVal);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* Entry */
-    getMetadata: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            entry.getMetadata(function(metaData) {
-                successCallback(metaData.modificationTime);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    moveTo: function(args, successCallback, errorCallback) {
-        var srcUri = args[0],
-            parentUri = args[1],
-            name = args[2];
-
-        nativeResolveLocalFileSystemURI(srcUri, function(source) {
-            nativeResolveLocalFileSystemURI(parentUri, function(parent) {
-                source.moveTo(parent, name, function(entry) {
-                    successCallback(makeEntry(entry));
-                }, function(error) {
-                    errorCallback(error.code);
-                });
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    copyTo: function(args, successCallback, errorCallback) {
-        var srcUri = args[0],
-            parentUri = args[1],
-            name = args[2];
-
-        nativeResolveLocalFileSystemURI(srcUri, function(source) {
-            nativeResolveLocalFileSystemURI(parentUri, function(parent) {
-                source.copyTo(parent, name, function(entry) {
-                    successCallback(makeEntry(entry));
-                }, function(error) {
-                    errorCallback(error.code);
-                });
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    remove: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            if (entry.fullPath === "/") {
-                errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
-            } else {
-                entry.remove(
-                    function (success) {
-                        if (successCallback) {
-                            successCallback(success);
-                        }
-                    },
-                    function(error) {
-                        if (errorCallback) {
-                            errorCallback(error.code);
-                        }
-                    }
-                );
-            }
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    getParent: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            entry.getParent(function(entry) {
-                successCallback(makeEntry(entry));
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* FileEntry */
-    getFileMetadata: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            entry.file(function(file) {
-                var retVal = new File(file.name, decodeURI(entry.toURL()), file.type, file.lastModifiedDate, file.size);
-                successCallback(retVal);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* DirectoryEntry */
-    getDirectory: function(args, successCallback, errorCallback) {
-        var uri = args[0],
-            path = args[1],
-            options = args[2];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            entry.getDirectory(path, options, function(entry) {
-                successCallback(makeEntry(entry));
-            }, function(error) {
-                if (error.code === FileError.INVALID_MODIFICATION_ERR) {
-                    if (options.create) {
-                        errorCallback(FileError.PATH_EXISTS_ERR);
-                    } else {
-                        errorCallback(FileError.ENCODING_ERR);
-                    }
-                } else {
-                    errorCallback(error.code);
-                }
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    removeRecursively: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            if (entry.fullPath === "/") {
-                errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
-            } else {
-                entry.removeRecursively(
-                    function (success) {
-                        if (successCallback) {
-                            successCallback(success);
-                        }
-                    },
-                    function(error) {
-                        errorCallback(error.code);
-                    }
-                );
-            }
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    getFile: function(args, successCallback, errorCallback) {
-        var uri = args[0],
-            path = args[1],
-            options = args[2];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            entry.getFile(path, options, function(entry) {
-                successCallback(makeEntry(entry));
-            }, function(error) {
-                if (error.code === FileError.INVALID_MODIFICATION_ERR) {
-                    if (options.create) {
-                        errorCallback(FileError.PATH_EXISTS_ERR);
-                    } else {
-                        errorCallback(FileError.NOT_FOUND_ERR);
-                    }
-                } else {
-                    errorCallback(error.code);
-                }
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
-
-    /* FileReader */
-    readAsText: function(args, successCallback, errorCallback) {
-        var uri = args[0],
-            encoding = args[1];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            var onLoadEnd = function(evt) {
-                    if (!evt.target.error) {
-                        successCallback(evt.target.result);
-                    }
-            },
-                onError = function(evt) {
-                    errorCallback(evt.target.error.code);
-            };
+function cleanUpPath(filePath) {
+    var pos = filePath.lastIndexOf('/');
+    return filePath.substring(0, pos) + filePath.substring(pos + 1, filePath.length);
+}
 
-            var reader = new NativeFileReader();
+function checkURL(url) {
+    return url.indexOf(' ') === -1 ?  true : false;
+}
 
-            reader.onloadend = onLoadEnd;
-            reader.onerror = onError;
-            entry.file(function(file) {
-                reader.readAsText(file, encoding);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
+module.exports = {
+    abort: function () {
         return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
     },
 
-    readAsDataURL: function(args, successCallback, errorCallback) {
-        var uri = args[0];
-
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            var onLoadEnd = function(evt) {
-                    if (!evt.target.error) {
-                        successCallback(evt.target.result);
-                    }
-            },
-                onError = function(evt) {
-                    errorCallback(evt.target.error.code);
-            };
+    upload: function(args, win, fail) {
+        var filePath = args[0],
+            server = args[1],
+            fileKey = args[2],
+            fileName = args[3],
+            mimeType = args[4],
+            params = args[5],
+            /*trustAllHosts = args[6],*/
+            chunkedMode = args[7],
+            headers = args[8];
 
-            var reader = new NativeFileReader();
+        if (!checkURL(server)) {
+            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR));
+        }
 
-            reader.onloadend = onLoadEnd;
-            reader.onerror = onError;
+        nativeResolveLocalFileSystemURI(filePath, function(entry) {
             entry.file(function(file) {
-                reader.readAsDataURL(file);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
-    },
+                function uploadFile(blobFile) {
+                    var fd = new FormData();
 
-    /* FileWriter */
-    write: function(args, successCallback, errorCallback) {
-        var uri = args[0],
-            text = args[1],
-            position = args[2];
+                    fd.append(fileKey, blobFile, fileName);
+                    for (var prop in params) {
+                        if(params.hasOwnProperty(prop)) {
+                            fd.append(prop, params[prop]);
+                        }
+                    }
 
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            var onWriteEnd = function(evt) {
-                    if(!evt.target.error) {
-                        successCallback(evt.target.position - position);
-                    } else {
-                        errorCallback(evt.target.error.code);
+                    xhr = new XMLHttpRequest();
+                    xhr.open("POST", server);
+                    xhr.onload = function(evt) {
+                        if (xhr.status == 200) {
+                            var result = new window.FileUploadResult();
+                            result.bytesSent = file.size;
+                            result.responseCode = xhr.status;
+                            result.response = xhr.response;
+                            win(result);
+                        } else if (xhr.status == 404) {
+                            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR, server, filePath, xhr.status));
+                        } else {
+                            fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
+                        }
+                    };
+                    xhr.ontimeout = function(evt) {
+                        fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
+                    };
+                    xhr.onerror = function () {
+                        fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, this.status));
+                    };
+                    xhr.onprogress = function (evt) {
+                        win(evt);
+                    };
+
+                    for (var header in headers) {
+                        if (headers.hasOwnProperty(header)) {
+                            xhr.setRequestHeader(header, headers[header]);
+                        }
                     }
-            },
-                onError = function(evt) {
-                    errorCallback(evt.target.error.code);
-            };
 
-            entry.createWriter(function(writer) {
-                writer.onwriteend = onWriteEnd;
-                writer.onerror = onError;
+                    xhr.send(fd);
+                }
 
-                writer.seek(position);
-                writer.write(new Blob([text], {type: "text/plain"}));
+                var bytesPerChunk;
+                if (chunkedMode === true) {
+                    bytesPerChunk = 1024 * 1024; // 1MB chunk sizes.
+                } else {
+                    bytesPerChunk = file.size;
+                }
+                var start = 0;
+                var end = bytesPerChunk;
+                while (start < file.size) {
+                    var chunk = file.slice(start, end, mimeType);
+                    uploadFile(chunk);
+                    start = end;
+                    end = start + bytesPerChunk;
+                }
             }, function(error) {
-                errorCallback(error.code);
+                fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
             });
         }, function(error) {
-            errorCallback(error.code);
+            fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
         });
+
         return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
     },
 
-    truncate: function(args, successCallback, errorCallback) {
-        var uri = args[0],
-            size = args[1];
+    download: function (args, win, fail) {
+        var source = args[0],
+            target = cleanUpPath(args[1]),
+            fileWriter;
+
+        if (!checkURL(source)) {
+            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR));
+        }
 
-        nativeResolveLocalFileSystemURI(uri, function(entry) {
-            var onWriteEnd = function(evt) {
-                    if(!evt.target.error) {
-                        successCallback(evt.target.length);
+        xhr = new XMLHttpRequest();
+
+        function writeFile(entry) {
+            entry.createWriter(function (writer) {
+                fileWriter = writer;
+                fileWriter.onwriteend = function (evt) {
+                    if (!evt.target.error) {
+                        win(new window.FileEntry(entry.name, entry.toURL()));
                     } else {
-                        errorCallback(evt.target.error.code);
+                        fail(evt.target.error);
                     }
-            },
-                onError = function(evt) {
-                    errorCallback(evt.target.error.code);
-            };
+                };
+                fileWriter.onerror = function (evt) {
+                    fail(evt.target.error);
+                };
+                fileWriter.write(new Blob([xhr.response]));
+            }, function (error) {
+                fail(error);
+            });
+        }
 
-            entry.createWriter(function(writer) {
-                writer.onwriteend = onWriteEnd;
-                writer.onerror = onError;
+        xhr.onerror = function (e) {
+            fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, source, target, xhr.status));
+        };
 
-                writer.truncate(size);
-            }, function(error) {
-                errorCallback(error.code);
-            });
-        }, function(error) {
-            errorCallback(error.code);
-        });
+        xhr.onload = function () {
+            if (xhr.readyState === xhr.DONE) {
+                if (xhr.status === 200 && xhr.response) {
+                    nativeResolveLocalFileSystemURI(getParentPath(target), function (dir) {
+                        dir.getFile(getFileName(target), {create: true}, writeFile, function (error) {
+                            fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
+                        });
+                    }, function (error) {
+                        fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
+                    });
+                } else if (xhr.status === 404) {
+                    fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR, source, target, xhr.status));
+                } else {
+                    fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, source, target, xhr.status));
+                }
+            }
+        };
+        xhr.onprogress = function (evt) {
+            win(evt);
+        };
+
+        xhr.responseType = "blob";
+        xhr.open("GET", source, true);
+        xhr.send();
         return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
     }
 };
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/fileTransfer.js
-define("cordova/plugin/blackberry10/fileTransfer", function(require, exports, module) {
+// file: lib/blackberry10/plugin/blackberry10/fileUtils.js
+define("cordova/plugin/blackberry10/fileUtils", function(require, exports, module) {
 
-var cordova = require('cordova');
+function convertPath(url) {
+    return decodeURI(url).substring(11).replace(/\/$/, '');
+}
 
 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"};
+    createEntry: function (entry) {
+        var cordovaEntry;
+        if (entry.isFile) {
+            cordovaEntry = new window.FileEntry(entry.name, convertPath(entry.toURL()));
+        } else {
+            cordovaEntry = new window.DirectoryEntry(entry.name, convertPath(entry.toURL()));
+        }
+        cordovaEntry.nativeEntry = entry;
+        return cordovaEntry;
     },
 
-    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]
-            };
+    getEntryForURI: function (uri, success, fail) {
+        //TODO: account for local vs file system
+        window.resolveLocalFileSystemURI(uri, success, fail);
+    },
 
-        blackberry.io.filetransfer.upload(path, server, win, fail, options);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
+    getFileSystemName: function (fs) {
+        return (fs.name.indexOf('Persistent') != -1) ? 'persistent' : 'temporary';
     }
 };
 
@@ -4877,9 +4052,6 @@ module.exports = {
         });
     },
     clobbers: {
-        requestFileSystem: {
-            path: "cordova/plugin/blackberry10/requestFileSystem"
-        },
         navigator: {
             children: {
                 notification: {
@@ -4890,6 +4062,9 @@ module.exports = {
                     }
                 }
             }
+        },
+        File: {
+            path: 'cordova/plugin/File'
         }
     },
     merges: {
@@ -4947,7 +4122,7 @@ module.exports = {
             }
         }
         if (count === 0) {
-           callback();
+            callback();
         }
     },
 
@@ -4974,30 +4149,6 @@ module.exports = {
         };
         request.send(null);
     }
-}
-
-});
-
-// file: lib/blackberry10/plugin/blackberry10/requestFileSystem.js
-define("cordova/plugin/blackberry10/requestFileSystem", function(require, exports, module) {
-
-function getFileSystemName(fs) {
-    return (fs.name.indexOf("Persistent") != -1) ? "persistent" : "temporary";
-}
-
-function makeEntry(entry) {
-    if (entry.isDirectory) {
-        return new DirectoryEntry(entry.name, decodeURI(entry.toURL()).substring(11));
-    }
-    else {
-        return new FileEntry(entry.name, decodeURI(entry.toURL()).substring(11));
-    }
-}
-
-module.exports = function (type, size, success, fail) {
-    window.webkitRequestFileSystem(type, size, function (fs) {
-        success((new FileSystem

<TRUNCATED>

[03/50] [abbrv] webworks commit: Add NetworkStatus plugin

Posted by lo...@apache.org.
Add NetworkStatus plugin

Reviewed by Gord Tanner <gt...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: cd754d0c6770ff568eca53c3413716e81a601731
Parents: 187db1a
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Mar 19 13:44:19 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/NetworkStatus/index.js         |   58 +++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   18 +----
 2 files changed, 60 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/cd754d0c/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
new file mode 100644
index 0000000..f96efe9
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+//map from BB10 to cordova connection types:
+//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js
+function mapConnectionType(con) {
+    switch (con.type) {
+    case 'wired':
+        return 'ethernet';
+    case 'wifi':
+        return 'wifi';
+    case 'none':
+        return 'none';
+    case 'cellular':
+        switch (con.technology) {
+        case 'edge':
+        case 'gsm':
+            return '2g';
+        case 'evdo':
+            return '3g';
+        case 'umts':
+            return '3g';
+        case 'lte':
+            return '4g';
+        }
+        return "cellular";
+    }
+    return 'unknown';
+}
+
+function currentConnectionType() {
+    try {
+        //possible for webplatform to throw pps exception
+        return mapConnectionType(qnx.webplatform.device.activeConnection || { type : 'none' });
+    } 
+    catch (e) {
+        return 'unknown';
+    }
+}
+
+module.exports = {
+    getConnectionInfo: function (success, fail, args, env) {
+        success(currentConnectionType());
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/cd754d0c/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 5479211..2c169c5 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit e14d644ae4300282e837c6621522bd3895f556e5
+// commit 81a30b465c3f84cc020dda5a7ede6e83a8e44385
 
-// File generated at :: Mon Mar 18 2013 21:49:25 GMT-0400 (EDT)
+// File generated at :: Tue Mar 19 2013 13:22:52 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -4784,7 +4784,6 @@ define("cordova/plugin/blackberry10/manager", function(require, exports, module)
 
 var cordova = require('cordova'),
     plugins = {
-        'NetworkStatus' : require('cordova/plugin/blackberry10/network'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
@@ -4994,19 +4993,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/network.js
-define("cordova/plugin/blackberry10/network", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    getConnectionInfo: function (args, win, fail) {
-        return { "status": cordova.callbackStatus.OK, "message": blackberry.connection.type};
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/notification.js
 define("cordova/plugin/blackberry10/notification", function(require, exports, module) {
 


[44/50] [abbrv] webworks commit: Update paths for plugin unit tests

Posted by lo...@apache.org.
Update paths for plugin unit tests

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/5dad31c1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/5dad31c1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/5dad31c1

Branch: refs/heads/future
Commit: 5dad31c1842024ddfa9364def6e664fad6138f6d
Parents: 94fa3ff
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Mon Apr 29 15:22:48 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 .../bin/test/plugins/Accelerometer/index.js        |    2 +-
 blackberry10/bin/test/plugins/Battery/index.js     |    2 +-
 blackberry10/bin/test/plugins/Camera/index.js      |    2 +-
 blackberry10/bin/test/plugins/Device/index.js      |    4 ++--
 blackberry10/bin/test/plugins/Logger/index.js      |    6 +++---
 .../bin/test/plugins/NetworkStatus/index.js        |    2 +-
 .../bin/test/plugins/Notification/index.js         |    2 +-
 .../bin/test/plugins/SplashScreen/index.js         |    2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Accelerometer/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Accelerometer/index.js b/blackberry10/bin/test/plugins/Accelerometer/index.js
index a016219..e907d56 100644
--- a/blackberry10/bin/test/plugins/Accelerometer/index.js
+++ b/blackberry10/bin/test/plugins/Accelerometer/index.js
@@ -14,7 +14,7 @@
 * limitations under the License.
 */
 describe("Accelerometer", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Accelerometer/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Accelerometer/src/blackberry10/",
         index,
         callback,
         result = {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Battery/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Battery/index.js b/blackberry10/bin/test/plugins/Battery/index.js
index 3495629..a9c610a 100644
--- a/blackberry10/bin/test/plugins/Battery/index.js
+++ b/blackberry10/bin/test/plugins/Battery/index.js
@@ -16,7 +16,7 @@
 
 describe("Battery", function () {
 
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Battery/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Battery/src/blackberry10/",
         index,
         callback,
         result = {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Camera/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Camera/index.js b/blackberry10/bin/test/plugins/Camera/index.js
index e629a41..d498a56 100644
--- a/blackberry10/bin/test/plugins/Camera/index.js
+++ b/blackberry10/bin/test/plugins/Camera/index.js
@@ -14,7 +14,7 @@
 * limitations under the License.
 */
 describe("Camera", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Camera/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Camera/src/blackberry10/",
         index,
         mockDone,
         mockCancel,

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Device/index.js b/blackberry10/bin/test/plugins/Device/index.js
index 9792b09..d6b6d47 100644
--- a/blackberry10/bin/test/plugins/Device/index.js
+++ b/blackberry10/bin/test/plugins/Device/index.js
@@ -16,12 +16,12 @@
 
 describe("Device", function () {
 
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Device/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Device/src/blackberry10/",
         index,
         result = {
             ok: jasmine.createSpy()
         };
-    
+
     beforeEach(function () {
         index = require(_apiDir + "index");
     });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Logger/index.js b/blackberry10/bin/test/plugins/Logger/index.js
index e5dc9f9..4cd0dca 100644
--- a/blackberry10/bin/test/plugins/Logger/index.js
+++ b/blackberry10/bin/test/plugins/Logger/index.js
@@ -16,12 +16,12 @@
 
 describe("Logger", function () {
 
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Logger/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Logger/src/blackberry10/",
         index,
         result = {
             noResult: jasmine.createSpy("noResult")
         };
-    
+
     beforeEach(function () {
         index = require(_apiDir + "index");
     });
@@ -32,7 +32,7 @@ describe("Logger", function () {
 
     describe("logLevel", function () {
         beforeEach(function () {
-            spyOn(console, "log"); 
+            spyOn(console, "log");
             GLOBAL.PluginResult = function () {
                 return result;
             };

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/NetworkStatus/index.js b/blackberry10/bin/test/plugins/NetworkStatus/index.js
index 7d0371c..9aa270d 100644
--- a/blackberry10/bin/test/plugins/NetworkStatus/index.js
+++ b/blackberry10/bin/test/plugins/NetworkStatus/index.js
@@ -16,7 +16,7 @@
 
 
 describe("NetworkStatus", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/NetworkStatus/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/NetworkStatus/src/blackberry10/",
         index,
         result = {
             ok: jasmine.createSpy(),

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Notification/index.js b/blackberry10/bin/test/plugins/Notification/index.js
index 2b585f8..a8f680f 100644
--- a/blackberry10/bin/test/plugins/Notification/index.js
+++ b/blackberry10/bin/test/plugins/Notification/index.js
@@ -38,7 +38,7 @@ function mockAndTestDialog(htmlmessage, title, dialogType, buttonLabel) {
 }
 
 describe("Notification", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Notification/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Notification/src/blackberry10/",
     index,
     success = function() {},
     fail = function() {},

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5dad31c1/blackberry10/bin/test/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/SplashScreen/index.js b/blackberry10/bin/test/plugins/SplashScreen/index.js
index 1dcccee..ef010df 100644
--- a/blackberry10/bin/test/plugins/SplashScreen/index.js
+++ b/blackberry10/bin/test/plugins/SplashScreen/index.js
@@ -14,7 +14,7 @@
 * limitations under the License.
 */
 describe("SplashScreen", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/SplashScreen/",
+    var _apiDir = __dirname + "./../../../templates/project/plugins/SplashScreen/src/blackberry10/",
         index,
         mockedEnv = {
             response: {


[47/50] [abbrv] webworks commit: Strip out non-ascii characters in VERSION for create script

Posted by lo...@apache.org.
Strip out non-ascii characters in VERSION for create script


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

Branch: refs/heads/future
Commit: bf29f4ca811eac18ebb64f551592f18331bffdaa
Parents: 6ceaaa9
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri May 3 15:55:51 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 15:55:51 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/create.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/bf29f4ca/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index 9b99435..e347741 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -46,7 +46,7 @@ var build,
     function getVersion() {
         var version = fs.readFileSync(__dirname + "/../VERSION");
         if (version) {
-            return version.toString();
+            return version.toString().replace( /([^\x00-\xFF]|\s)*$/g, '' );//.replace("[^\u0000-\u007F]", ""); //.replace(/\W\./g, '');
         }
     }
 


[09/50] [abbrv] webworks commit: Implement Logger plugin

Posted by lo...@apache.org.
Implement Logger plugin

Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/66e38221
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/66e38221
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/66e38221

Branch: refs/heads/future
Commit: 66e382216a58cf6e3da0e23d64d4d7d6d9a8c9f5
Parents: 042526c
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 2 11:39:12 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/Logger/index.js  |   25 +++++++
 blackberry10/bin/test/plugins/Logger/index.js      |   51 ++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   52 +++++++++------
 3 files changed, 107 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/bin/templates/project/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Logger/index.js b/blackberry10/bin/templates/project/plugins/Logger/index.js
new file mode 100644
index 0000000..497f477
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Logger/index.js
@@ -0,0 +1,25 @@
+/*
+ * 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 = {
+    logLevel: function (success, fail, args, env) {
+        var result = new PluginResult(args, env),
+            level = JSON.parse(decodeURIComponent(args[0])),
+            message = JSON.parse(decodeURIComponent(args[1]));
+        console.log(level + ": " + message);
+        result.noResult(false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/bin/test/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Logger/index.js b/blackberry10/bin/test/plugins/Logger/index.js
new file mode 100644
index 0000000..e5dc9f9
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Logger/index.js
@@ -0,0 +1,51 @@
+/*
+* Copyright 2013 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.
+*/
+
+describe("Logger", function () {
+
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Logger/",
+        index,
+        result = {
+            noResult: jasmine.createSpy("noResult")
+        };
+    
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+    });
+
+    afterEach(function () {
+        index = null;
+    });
+
+    describe("logLevel", function () {
+        beforeEach(function () {
+            spyOn(console, "log"); 
+            GLOBAL.PluginResult = function () {
+                return result;
+            };
+        });
+
+        afterEach(function () {
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls console.log", function () {
+            index.logLevel(function () {}, function () {}, ["%22ERROR%22", "%22message%22"]);
+            expect(console.log).toHaveBeenCalledWith("ERROR: message");
+            expect(result.noResult).toHaveBeenCalledWith(false);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 27c3c3a..8fd6292 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit 4c7d302ca09258a6ab9306e7647b1478b06c498a
+// commit 2a6ac9642dcc875318e348c64bf4e69d2e932cc1
 
-// File generated at :: Mon Apr 01 2013 10:04:19 GMT-0400 (EDT)
+// File generated at :: Mon Apr 08 2013 09:08:23 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -952,7 +952,6 @@ var cordova = require('cordova'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Logger' : require('cordova/plugin/blackberry10/logger'),
         'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
@@ -4665,21 +4664,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/logger.js
-define("cordova/plugin/blackberry10/logger", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    log: function (args, win, fail) {
-        console.log(args);
-        return {"status" : cordova.callbackStatus.OK,
-                "message" : 'Message logged to console: ' + args};
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/magnetometer.js
 define("cordova/plugin/blackberry10/magnetometer", function(require, exports, module) {
 
@@ -4930,13 +4914,15 @@ module.exports = {
     id: "blackberry10",
     initialize: function () {
         document.addEventListener("deviceready", function () {
+            /*
+             TODO
             blackberry.event.addEventListener("pause", function () {
                 cordova.fireDocumentEvent("pause");
             });
             blackberry.event.addEventListener("resume", function () {
                 cordova.fireDocumentEvent("resume");
             });
-
+            */
             window.addEventListener("online", function () {
                 cordova.fireDocumentEvent("online");
             });
@@ -4947,8 +4933,8 @@ module.exports = {
         });
     },
     clobbers: {
-        open: {
-            path: "cordova/plugin/InAppBrowser"
+        requestFileSystem: {
+            path: "cordova/plugin/blackberry10/requestFileSystem"
         }
     },
     merges: {
@@ -5037,6 +5023,30 @@ module.exports = {
 
 });
 
+// file: lib/blackberry10/plugin/blackberry10/requestFileSystem.js
+define("cordova/plugin/blackberry10/requestFileSystem", function(require, exports, module) {
+
+function getFileSystemName(fs) {
+    return (fs.name.indexOf("Persistent") != -1) ? "persistent" : "temporary";
+}
+
+function makeEntry(entry) {
+    if (entry.isDirectory) {
+        return new DirectoryEntry(entry.name, decodeURI(entry.toURL()).substring(11));
+    }
+    else {
+        return new FileEntry(entry.name, decodeURI(entry.toURL()).substring(11));
+    }
+}
+
+module.exports = function (type, size, success, fail) {
+    window.webkitRequestFileSystem(type, size, function (fs) {
+        success((new FileSystem(getFileSystemName(fs), makeEntry(fs.root))));
+    }, fail);
+};
+
+});
+
 // file: lib/blackberry10/plugin/blackberry10/utils.js
 define("cordova/plugin/blackberry10/utils", function(require, exports, module) {
 


[41/50] [abbrv] webworks commit: Update bat files to pass arguments properly in Windows

Posted by lo...@apache.org.
Update bat files to pass arguments properly in Windows

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/5fdf5b0d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/5fdf5b0d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/5fdf5b0d

Branch: refs/heads/future
Commit: 5fdf5b0d868baeee80f7e698404c350f83cec46a
Parents: 7e06979
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Apr 26 10:33:24 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/check_reqs.bat                    |    2 +-
 .../bin/templates/project/cordova/clean.bat        |    2 +-
 .../bin/templates/project/cordova/plugin.bat       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5fdf5b0d/blackberry10/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs.bat b/blackberry10/bin/check_reqs.bat
index 9c8986e..ed05fac 100755
--- a/blackberry10/bin/check_reqs.bat
+++ b/blackberry10/bin/check_reqs.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\check_reqs
+@node.exe %~dp0\check_reqs %*

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5fdf5b0d/blackberry10/bin/templates/project/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/clean.bat b/blackberry10/bin/templates/project/cordova/clean.bat
index eb5738c..890f197 100644
--- a/blackberry10/bin/templates/project/cordova/clean.bat
+++ b/blackberry10/bin/templates/project/cordova/clean.bat
@@ -3,4 +3,4 @@
 REM cd into project dir
 cd %~dp0\..\
 
-@node.exe ./cordova/lib/clean
+@node.exe ./cordova/lib/clean %*

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/5fdf5b0d/blackberry10/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/plugin.bat b/blackberry10/bin/templates/project/cordova/plugin.bat
index b3874ac..54245e0 100755
--- a/blackberry10/bin/templates/project/cordova/plugin.bat
+++ b/blackberry10/bin/templates/project/cordova/plugin.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\plugin
+@node.exe %~dp0\plugin %*


[15/50] [abbrv] webworks commit: Initial work on cleaning up the exec chain, including the addition of a Battery plugin

Posted by lo...@apache.org.
Initial work on cleaning up the exec chain, including the addition of a Battery plugin

Reviewed by Rosa Tse <rt...@blackberry.com>
Tested by Rosa Tse <rt...@blackberry.com>


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

Branch: refs/heads/future
Commit: a00b67419b36f854083ad96b0d4e7101146c06a8
Parents: 9160b4a
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Mar 26 09:52:44 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/Battery/index.js |   49 +++++++
 .../bin/templates/project/plugins/Device/index.js  |   19 ++--
 .../project/plugins/NetworkStatus/index.js         |    3 +-
 blackberry10/bin/test/plugins/Battery/index.js     |   85 +++++++++++
 blackberry10/bin/test/plugins/Device/index.js      |   28 +++--
 .../bin/test/plugins/NetworkStatus/index.js        |   25 +++-
 blackberry10/framework/lib/PluginResult.js         |   52 +++++++
 blackberry10/framework/lib/server.js               |    2 +-
 blackberry10/framework/test/unit/lib/server.js     |    8 +-
 blackberry10/javascript/cordova.blackberry10.js    |  112 +++++----------
 10 files changed, 272 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/templates/project/plugins/Battery/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Battery/index.js b/blackberry10/bin/templates/project/plugins/Battery/index.js
new file mode 100644
index 0000000..fcac7b2
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Battery/index.js
@@ -0,0 +1,49 @@
+/*
+ * 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 SYSTEM_EVENTS = ["device.battery.statusChange",
+                     "device.battery.chargeLow",
+                     "device.battery.chargeCritical"],
+    clientListener;
+
+module.exports = {
+    start: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        if (!!clientListener) {
+            result.error("Battery listener already running");
+        } else {
+            clientListener = function (info) {
+                result.callbackOk(info, true);
+            };
+            SYSTEM_EVENTS.forEach(function (event) {
+                window.qnx.webplatform.device.addEventListener(event, clientListener);
+            });
+            result.noResult(true);
+        }
+    },
+    stop: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        if (!clientListener) {
+            result.error("Battery listener has not started");
+        } else {
+            SYSTEM_EVENTS.forEach(function (event) {
+                window.qnx.webplatform.device.removeEventListener(event, clientListener);
+            });
+            clientListener = null;
+            result.noResult(false);
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/templates/project/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/index.js b/blackberry10/bin/templates/project/plugins/Device/index.js
index 61be46a..41b454c 100644
--- a/blackberry10/bin/templates/project/plugins/Device/index.js
+++ b/blackberry10/bin/templates/project/plugins/Device/index.js
@@ -16,14 +16,15 @@
 
 module.exports = {
     getDeviceInfo: function (success, fail, args, env) {
-        var info = {
-            platform: "blackberry10",
-            version: window.qnx.webplatform.device.scmBundle,
-            model: window.qnx.webplatform.device.modelName,
-            name: window.qnx.webplatform.device.modelName, // deprecated: please use device.model
-            uuid: window.qnx.webplatform.device.devicePin,
-            cordova: "2.5.0"
-        };
-        success(info);
+        var result = new PluginResult(args, env),
+            info = {
+                platform: "blackberry10",
+                version: window.qnx.webplatform.device.scmBundle,
+                model: window.qnx.webplatform.device.modelName,
+                name: window.qnx.webplatform.device.modelName, // deprecated: please use device.model
+                uuid: window.qnx.webplatform.device.devicePin,
+                cordova: "2.5.0"
+            };
+        result.ok(info);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
index ae6cdf2..5a991fe 100644
--- a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
@@ -53,6 +53,7 @@ function currentConnectionType() {
 
 module.exports = {
     getConnectionInfo: function (success, fail, args, env) {
-        success(currentConnectionType());
+        var result = new PluginResult(args, env);
+        result.ok(currentConnectionType());
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/test/plugins/Battery/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Battery/index.js b/blackberry10/bin/test/plugins/Battery/index.js
new file mode 100644
index 0000000..3495629
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Battery/index.js
@@ -0,0 +1,85 @@
+/*
+* Copyright 2013 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.
+*/
+
+describe("Battery", function () {
+
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Battery/",
+        index,
+        callback,
+        result = {
+            ok: jasmine.createSpy(),
+            error: jasmine.createSpy(),
+            noResult: jasmine.createSpy(),
+            callbackOk: jasmine.createSpy()
+        };
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+        GLOBAL.window = {
+            qnx: {
+                webplatform: {
+                    device: {
+                        addEventListener: jasmine.createSpy().andCallFake(function (evt, cb) {
+                            callback = cb;
+                        }),
+                        removeEventListener: jasmine.createSpy()
+                    }
+                }
+            }
+        };
+        GLOBAL.PluginResult = function () {
+            return result;
+        };
+    });
+
+    afterEach(function () {
+        index = null;
+        delete GLOBAL.window;
+        delete GLOBAL.PluginResult;
+    });
+
+    describe("start", function () {
+
+        it("calls noResult and keeps callbacks", function () {
+            index.start();
+            expect(window.qnx.webplatform.device.addEventListener).toHaveBeenCalled();
+            expect(result.noResult).toHaveBeenCalledWith(true);
+        });
+
+        it("callback calls ok and keeps callbacks", function () {
+            callback("OK");
+            expect(result.callbackOk).toHaveBeenCalledWith("OK", true);
+        });
+
+        it("calls error if already started", function () {
+            index.start();
+            expect(window.qnx.webplatform.device.addEventListener).not.toHaveBeenCalled();
+            expect(result.error).toHaveBeenCalled();
+        });
+
+
+    });
+
+    describe("stop", function () {
+
+        it("calls noResult and does not keep callbacks", function () {
+            index.stop();
+            expect(window.qnx.webplatform.device.removeEventListener).toHaveBeenCalled();
+            expect(result.noResult).toHaveBeenCalledWith(false);
+        });
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/test/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Device/index.js b/blackberry10/bin/test/plugins/Device/index.js
index bdfcfa4..9792b09 100644
--- a/blackberry10/bin/test/plugins/Device/index.js
+++ b/blackberry10/bin/test/plugins/Device/index.js
@@ -13,10 +13,15 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-var _apiDir = __dirname + "./../../../templates/project/plugins/Device/",
-index;
 
 describe("Device", function () {
+
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Device/",
+        index,
+        result = {
+            ok: jasmine.createSpy()
+        };
+    
     beforeEach(function () {
         index = require(_apiDir + "index");
     });
@@ -35,34 +40,37 @@ describe("Device", function () {
                     }
                 }
             };
+            GLOBAL.PluginResult = function () {
+                return result;
+            };
         });
 
         afterEach(function () {
             delete GLOBAL.window;
+            delete GLOBAL.PluginResult;
         });
 
-        it("calls success with the Device info", function () {
+        it("calls ok with the Device info", function () {
             var mockedDevice = {
                 scmBundle: "1.0.0.0",
                 modelName: "q10",
                 devicePin: (new Date()).getTime()
-            },
-            success = jasmine.createSpy().andCallFake(function (deviceInfo) {
+            };
+
+            result.ok = jasmine.createSpy().andCallFake(function (deviceInfo) {
                 expect(deviceInfo.platform).toEqual("blackberry10");
                 expect(deviceInfo.version).toEqual(mockedDevice.scmBundle);
                 expect(deviceInfo.model).toEqual(mockedDevice.modelName);
                 expect(deviceInfo.name).toEqual(mockedDevice.modelName);
                 expect(deviceInfo.uuid).toEqual(mockedDevice.devicePin);
                 expect(deviceInfo.cordova).toBeDefined();
-            }),
-            fail = jasmine.createSpy();
+            });
 
             window.qnx.webplatform.device = mockedDevice;
 
-            index.getDeviceInfo(success, fail);
+            index.getDeviceInfo();
 
-            expect(success).toHaveBeenCalled();
-            expect(fail).not.toHaveBeenCalled();
+            expect(result.ok).toHaveBeenCalled();
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/bin/test/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/NetworkStatus/index.js b/blackberry10/bin/test/plugins/NetworkStatus/index.js
index 87f6f0b..7d0371c 100644
--- a/blackberry10/bin/test/plugins/NetworkStatus/index.js
+++ b/blackberry10/bin/test/plugins/NetworkStatus/index.js
@@ -13,10 +13,16 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-var _apiDir = __dirname + "./../../../templates/project/plugins/NetworkStatus/",
-index;
+
 
 describe("NetworkStatus", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/NetworkStatus/",
+        index,
+        result = {
+            ok: jasmine.createSpy(),
+            error: jasmine.createSpy()
+        };
+
     beforeEach(function () {
         index = require(_apiDir + "index");
     });
@@ -35,10 +41,14 @@ describe("NetworkStatus", function () {
                     }
                 }
             };
+            GLOBAL.PluginResult = function () {
+                return result;
+            };
         });
 
         afterEach(function () {
             delete GLOBAL.window;
+            delete GLOBAL.PluginResult;
         });
 
         function testConnection(expectedResult, mockedType, mockedTechnology) {
@@ -47,18 +57,16 @@ describe("NetworkStatus", function () {
                     type: mockedType,
                     technology: mockedTechnology
                 }
-            },
-            success = jasmine.createSpy(),
-            fail = jasmine.createSpy();
+            };
 
             if (mockedType) {
                 window.qnx.webplatform.device = mockedDevice;
             }
 
-            index.getConnectionInfo(success, fail);
+            index.getConnectionInfo();
 
-            expect(success).toHaveBeenCalledWith(expectedResult);
-            expect(fail).not.toHaveBeenCalled();
+            expect(result.ok).toHaveBeenCalledWith(expectedResult);
+            expect(result.error).not.toHaveBeenCalled();
         }
 
         it("calls success with a wired connection", function () {
@@ -106,4 +114,5 @@ describe("NetworkStatus", function () {
         });
 
     });
+
 });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/framework/lib/PluginResult.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/PluginResult.js b/blackberry10/framework/lib/PluginResult.js
new file mode 100644
index 0000000..cbb57ff
--- /dev/null
+++ b/blackberry10/framework/lib/PluginResult.js
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 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.
+ */
+
+function PluginResult (args, env) {
+
+    var CALLBACK_STATUS_NO_RESULT = 0,
+        CALLBACK_STATUS_OK = 1,
+        CALLBACK_STATUS_ERROR = 9,
+        send = function (data) {
+            env.response.send(200, encodeURIComponent(JSON.stringify(data)));
+        },
+        callback = function (success, status, data, keepCallback) {
+            var executeString = "cordova.callbackFromNative(" + decodeURIComponent(args.callbackId) +
+                ", " + !!success + ", " + status + ", " + data + ", " + !!keepCallback + ");";
+            env.webview.executeJavaScript(executeString);
+        };
+
+    this.noResult = function (keepCallback) {
+        send({ code: CALLBACK_STATUS_NO_RESULT, keepCallback: !!keepCallback });
+    };
+
+    this.error = function (msg) {
+        send({ code: CALLBACK_STATUS_ERROR, msg: msg, keepCallback: false });
+    };
+
+    this.ok = function (data) {
+        send({ code: CALLBACK_STATUS_OK, data: data, keepCallback: false });
+    };
+
+    this.callbackOk = function (data, keepCallback) {
+        callback(true, CALLBACK_STATUS_OK, JSON.stringify(data), keepCallback);
+    };
+
+    this.callbackError = function (msg, keepCallback) {
+        callback(false, CALLBACK_STATUS_ERROR, JSON.stringify(msg), keepCallback);
+    };
+}
+
+window.PluginResult = PluginResult;

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/framework/lib/server.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/server.js b/blackberry10/framework/lib/server.js
index 9c14b1e..15b95b0 100644
--- a/blackberry10/framework/lib/server.js
+++ b/blackberry10/framework/lib/server.js
@@ -91,7 +91,7 @@ module.exports = {
             plugin[req.params.action](req,
             function (result) {
                 res.send(200, encodeURIComponent(JSON.stringify({
-                    code: 1,
+                    code: 42,
                     data: result
                 })));
             },

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/framework/test/unit/lib/server.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/test/unit/lib/server.js b/blackberry10/framework/test/unit/lib/server.js
index 1d517b4..2b89b0a 100644
--- a/blackberry10/framework/test/unit/lib/server.js
+++ b/blackberry10/framework/test/unit/lib/server.js
@@ -181,7 +181,7 @@ describe("server", function () {
             );
         });
 
-        it("returns the result and code 1 when success callback called", function () {
+        it("returns the result and code 42 when success callback called", function () {
             spyOn(plugin, "exec").andCallFake(function (request, succ, fail, body) {
                 succ(["MyFeatureId"]);
             });
@@ -191,7 +191,7 @@ describe("server", function () {
 
             server.handle(req, res);
             expect(res.send).toHaveBeenCalledWith(200, encodeURIComponent(JSON.stringify({
-                code: 1,
+                code: 42,
                 data: ["MyFeatureId"]
             })));
         });
@@ -259,7 +259,7 @@ describe("server", function () {
             );
         });
 
-        it("returns the result and code 1 when success callback called", function () {
+        it("returns the result and code 42 when success callback called", function () {
             var expectedResult = {"getReadOnlyFields": "Yogi bear"};
 
             spyOn(applicationAPIServer, "getReadOnlyFields").andCallFake(function (success, fail) {
@@ -269,7 +269,7 @@ describe("server", function () {
             server.handle(req, res);
 
             expect(res.send).toHaveBeenCalledWith(200, encodeURIComponent(JSON.stringify({
-                code: 1,
+                code: 42,
                 data: expectedResult
             })));
         });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a00b6741/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 2c169c5..36d9ad1 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit 81a30b465c3f84cc020dda5a7ede6e83a8e44385
+// commit a69c579c923e9bb0b709a64b782d55a137edb043
 
-// File generated at :: Tue Mar 19 2013 13:22:52 GMT-0400 (EDT)
+// File generated at :: Tue Mar 26 2013 15:21:10 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -968,39 +968,8 @@ var cordova = require('cordova'),
 
 module.exports = function(success, fail, service, action, args) {
     try {
-        var manager = require('cordova/plugin/blackberry10/manager'),
-            v = manager.exec(success, fail, service, action, args);
-
-        // If status is OK, then return value back to caller
-        if (v.status == cordova.callbackStatus.OK) {
-
-            // If there is a success callback, then call it now with returned value
-            if (success) {
-                try {
-                    success(v.message);
-                }
-                catch (e) {
-                    console.log("Error in success callback: "+cordova.callbackId+" = "+e);
-                }
-            }
-            return v.message;
-        } else if (v.status == cordova.callbackStatus.NO_RESULT) {
-
-        } else {
-            // If error, then display error
-            console.log("Error: Status="+v.status+" Message="+v.message);
-
-            // If there is a fail callback, then call it now with returned value
-            if (fail) {
-                try {
-                    fail(v.message);
-                }
-                catch (e) {
-                    console.log("Error in error callback: "+cordova.callbackId+" = "+e);
-                }
-            }
-            return null;
-        }
+        require('cordova/plugin/blackberry10/manager').exec(success, fail, service, action, args);
+        return null;
     } catch (e) {
         utils.alert("Error: "+e);
     }
@@ -3898,31 +3867,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/battery.js
-define("cordova/plugin/blackberry10/battery", function(require, exports, module) {
-
-var cordova = require('cordova'),
-    interval;
-
-module.exports = {
-    start: function (args, win, fail) {
-        interval = window.setInterval(function () {
-            win({
-                level: navigator.webkitBattery.level * 100,
-                isPlugged: navigator.webkitBattery.charging
-            });
-        }, 500);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    },
-
-    stop: function (args, win, fail) {
-        window.clearInterval(interval);
-        return { "status" : cordova.callbackStatus.OK, "message" : "stopped" };
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/camera.js
 define("cordova/plugin/blackberry10/camera", function(require, exports, module) {
 
@@ -4785,7 +4729,6 @@ define("cordova/plugin/blackberry10/manager", function(require, exports, module)
 var cordova = require('cordova'),
     plugins = {
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
-        'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Camera' : require('cordova/plugin/blackberry10/camera'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
@@ -5102,7 +5045,7 @@ module.exports = {
             if (plugins.hasOwnProperty(plugin) && plugins[plugin].modules) {
                 for (i = 0; i < plugins[plugin].modules.length; i++) {
                     script = document.createElement('script');
-                    script.src = 'plugins/' + plugin + '/' + plugins[plugin].modules[i];
+                    script.src = 'local:///plugins/' + plugin + '/' + plugins[plugin].modules[i];
                     script.onload = function () {
                         if (--count === 0 && typeof callback === 'function') {
                             build(plugins);
@@ -5114,13 +5057,16 @@ module.exports = {
                 }
             }
         }
+        if (count === 0) {
+           callback();
+        }
     },
 
     getPlugins: function (success, error) {
         var request,
             response;
         request = new XMLHttpRequest();
-        request.open('GET', 'plugins/plugins.json', true);
+        request.open('GET', 'local:///plugins/plugins.json', true);
         request.onreadystatechange = function () {
             if (request.readyState === 4) {
                 if (request.status === 200) {
@@ -7634,20 +7580,8 @@ window.cordova = require('cordova');
                 data;
 
             request.send(JSON.stringify(params));
-
             response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-            errored = response.code < 0;
-            cb = errored ? error : success;
-            data = errored ? response.msg : response.data;
-
-            if (cb) {
-                cb(data, response);
-            }
-            else if (errored) {
-                throw data;
-            }
-
-            return { status: 0 };
+            return response;
         };
     }
 
@@ -7655,7 +7589,10 @@ window.cordova = require('cordova');
         exec: function (success, fail, service, action, args) {
             var uri = service + "/" + action,
                 request = new RemoteFunctionCall(uri),
-                name;
+                callbackId = service + cordova.callbackId++,
+                response,
+                name,
+                didSucceed;
 
             for (name in args) {
                 if (Object.hasOwnProperty.call(args, name)) {
@@ -7663,7 +7600,26 @@ window.cordova = require('cordova');
                 }
             }
 
-            return request.makeSyncCall(success, fail);
+            cordova.callbacks[callbackId] = {success:success, fail:fail};
+            request.addParam("callbackId", callbackId);
+
+            response = request.makeSyncCall();
+
+            //Old WebWorks Extension success
+            if (response.code === 42) {
+                if (success) {
+                    success(response.data, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else if (response.code < 0) {
+                if (fail) {
+                    fail(response.msg, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else {
+                didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
+                cordova.callbackFromNative(callbackId, didSucceed, response.code, [didSucceed ? response.data : response.msg], !!response.keepCallback);
+            }
         },
         defineReadOnlyField: function (obj, field, value) {
             Object.defineProperty(obj, field, {


[34/50] [abbrv] webworks commit: Wrap PluginResult data in array

Posted by lo...@apache.org.
Wrap PluginResult data in array

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: d5a2530280c8c95cf315805268b10fd66faaad06
Parents: 82dfa2d
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Apr 18 17:10:05 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 blackberry10/framework/lib/PluginResult.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/d5a25302/blackberry10/framework/lib/PluginResult.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/PluginResult.js b/blackberry10/framework/lib/PluginResult.js
index c3e999c..68acf23 100644
--- a/blackberry10/framework/lib/PluginResult.js
+++ b/blackberry10/framework/lib/PluginResult.js
@@ -25,7 +25,7 @@ function PluginResult (args, env) {
         },
         callback = function (success, status, data, keepCallback) {
             var executeString = "cordova.callbackFromNative('" + callbackId  + "', " +
-                !!success + ", " + status + ", " + data + ", " + !!keepCallback + ");";
+                !!success + ", " + status + ", [" + data + "], " + !!keepCallback + ");";
             env.webview.executeJavaScript(executeString);
         };
 


[11/50] [abbrv] webworks commit: Fixed the runs script for child processes

Posted by lo...@apache.org.
Fixed the runs script for child processes

Reviewed by Hasan Ahmad <ha...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/99b61a29
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/99b61a29
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/99b61a29

Branch: refs/heads/future
Commit: 99b61a291e89ff546abd4e48d53f2ad6f813c254
Parents: eb75c14
Author: DanielAudino <da...@blackberry.com>
Authored: Fri Mar 15 16:22:30 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/templates/project/cordova/lib/run |  132 +++++++++++----
 1 files changed, 98 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/99b61a29/blackberry10/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run b/blackberry10/bin/templates/project/cordova/lib/run
index 129a1cd..9f47e10 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -26,13 +26,14 @@ var childProcess = require("child_process"),
     pkgrUtils = require("./packager-utils"),
     properties = require('../../project.json'),
     program = require('commander'),
+    xml2js = require('xml2js'),
     target,
     ip,
     password,
     workingdir,
     barPath;
 
-function generateOptions() {
+function generateOptions(uninstall) {
     var options = [];
 
     workingdir = path.normalize(__dirname + "/.."),
@@ -49,31 +50,32 @@ function generateOptions() {
     options.push("-package");
     options.push(barPath);
 
-    if (program.uninstall) {
+    if (uninstall) {
         options.push("-uninstallApp");
-        execNativeDeploy(options, null);
-        options.pop();
-    }
+        return options;
+    } else {
 
-    options.push("-installApp");
+        options.push("-installApp");
 
-    if (program.launch) {
-        options.push("-launchApp");
-    }
+        if (program.launch) {
+            options.push("-launchApp");
+        }
 
-    return options;
+        return options;
+    }
 }
 
-function execNativeDeploy(options, callback) {
+function execNativeDeploy(optionsArray, callback) {
     var script = "/bin/blackberry-deploy",
         nativeDeploy;
+        options = optionsArray.join(" ");
 
     if (pkgrUtils.isWindows()) {
         script += ".bat";
     }
 
     if (fs.existsSync(conf.DEPENDENCIES_TOOLS)) {
-        nativeDeploy = childProcess.spawn(path.normalize(conf.DEPENDENCIES_TOOLS + script), options, {
+        nativeDeploy = childProcess.exec(path.normalize(conf.DEPENDENCIES_TOOLS + script +" "+ options), {
             "cwd": workingdir,
             "env": process.env
         });
@@ -93,48 +95,110 @@ function execNativeDeploy(options, callback) {
 }
 
 function checkTarget() {
-    if (!properties.targets[target]){
+    if (!target) {
+        console.log("No target exists, to add that target please run target add <name> <ip> <type> [-p <password>] [--pin <devicepin>]\n");
+        return false;
+    }
+    if (!properties.targets[target]) {
         console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> <type> [-p <password>] [--pin <devicepin>]\n");
         return false;
     }
-    if (properties.targets[target].ip){
+    if (properties.targets[target].ip) {
        ip = properties.targets[target].ip; 
     } else {
         console.log("IP is not defined in target \""+target+"\"\n");
         return false;
     }
-    if (properties.targets[target].password){
+    if (properties.targets[target].password) {
        password = properties.targets[target].password;
     } 
     return true;
-    
+
+}
+
+function deployAll(keys) {
+    target = keys[0];
+
+    if (target) {
+        if (checkTarget()) {
+            var options = generateOptions();
+            if (program.uninstall) {
+                uninstall(
+                    function() {
+                        keys.shift();
+                        deployAll(keys);
+                });
+            } else {
+                execNativeDeploy(options,
+                    function() {
+                        deployAll(keys);
+                });
+            }
+        }
+    }
+}
+
+function uninstall(callback) {
+    var script = "/bin/blackberry-deploy",
+        nativeDeploy;
+
+    if (pkgrUtils.isWindows()) {
+        script += ".bat";
+    }
+
+    if (fs.existsSync(conf.DEPENDENCIES_TOOLS)) {
+        nativeDeploy = childProcess.exec(path.normalize(conf.DEPENDENCIES_TOOLS + script +" -listInstalledApps -device " +ip+ " -password " +password), {
+            "cwd": workingdir,
+            "env": process.env
+        }, function (error, stdout, stderr) {
+            var parser = new xml2js.Parser();
+            fs.readFile(path.join(__dirname + "/../../www/", "config.xml"), function(err, data) {
+                parser.parseString(data, function (err, result) {
+                    if (stdout.indexOf(result['@'].id) != -1) {
+                        var options = generateOptions(true);
+                        execNativeDeploy(options,
+                            function(){
+                                options = generateOptions(false);
+                                execNativeDeploy(options, callback);
+                        });
+                    } else {
+                        options = generateOptions(false);
+                        execNativeDeploy(options, callback);
+                    }
+                });
+            });
+        });
+    }
 }
 
 function exec(callback) {
     program
-        .usage('<target> [--no-launch] [--no-uninstall]')
+        .usage('command [<target>] [--no-launch] [--no-uninstall]')
         .option('--no-uninstall', 'does not uninstall app from device')
         .option('--no-launch', 'do not launch the app on device')
-        .parse(process.argv);
-
-     target = program.args[0] ? program.args[0] : properties.defaultTarget
-
-     if(target == "all"){
-        for (var key in properties.targets) {
-            if (properties.targets.hasOwnProperty(key)) {
-                target = key;
-                if(checkTarget()) {
-                    var options = generateOptions();
-                    execNativeDeploy(options, callback);
-                }
-            }
-        }
+
+    program
+        .command('all')
+        .usage('all [--no-launch] [--no-uninstall]')
+        .description('    Deploy the app on all targets')
+        .option('--no-uninstall', 'does not uninstall app from device')
+        .option('--no-launch', 'do not launch the app on device')
+    
+    program.parse(process.argv);
+    target = program.args[0] ? program.args[0] : properties.defaultTarget
+
+    if (target === "all") {
+        deployAll(Object.keys(properties.targets));
     } else {
         if (checkTarget()) {
-            var options = generateOptions();
-            execNativeDeploy(options, callback);
+            if (program.uninstall) {
+                uninstall(callback);
+            } else {
+                options = generateOptions(false);
+                execNativeDeploy(options, callback)
+            }
         }
     }
 }
 
-exec(null);
+exec(null);
\ No newline at end of file


[42/50] [abbrv] webworks commit: Updating cordova.blackberry10.js

Posted by lo...@apache.org.
Updating cordova.blackberry10.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/7e069793
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/7e069793
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/7e069793

Branch: refs/heads/future
Commit: 7e0697933c34946b01251f422524acdb5643a604
Parents: b707831
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Apr 26 11:50:21 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 blackberry10/javascript/cordova.blackberry10.js |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7e069793/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index a5e250d..7e50d79 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit cf23fc942bd8443aa673b6834690e9c55c811b36
+// commit f4db421d9c19f337ca764daa7a1a74e6cfef14a2
 
-// File generated at :: Thu Apr 25 2013 16:30:38 GMT-0400 (EDT)
+// File generated at :: Fri Apr 26 2013 11:49:39 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -939,6 +939,7 @@ module.exports = {
         modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
         modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
 
+        modulemapper.mapModules(window);
     }
 };
 
@@ -6728,7 +6729,6 @@ window.cordova = require('cordova');
     };
 
     require("cordova/channel").onPluginsReady.subscribe(function () {
-        require("cordova/modulemapper").mapModules(window);
         webworksReady = true;
         fireWebworksReadyEvent();
     });


[29/50] [abbrv] webworks commit: Updated navigator.notification.prompt to return an empty string instead of null when no text is entered

Posted by lo...@apache.org.
Updated navigator.notification.prompt to return an empty string instead of null when no text is entered

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


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

Branch: refs/heads/future
Commit: d753ae3634d4134ad6765a270203590e99e75fc8
Parents: 5c848df
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Mon Apr 22 16:07:48 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/Notification/index.js          |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/d753ae36/blackberry10/bin/templates/project/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Notification/index.js b/blackberry10/bin/templates/project/plugins/Notification/index.js
index 497170b..fad04f7 100644
--- a/blackberry10/bin/templates/project/plugins/Notification/index.js
+++ b/blackberry10/bin/templates/project/plugins/Notification/index.js
@@ -48,7 +48,7 @@ function showDialog(args, dialogType, result) {
             //Prompt dialog callback expects object
             result.callbackOk({
                 buttonIndex: data.ok ? 1 : 0,
-                input1: (data.oktext) ? decodeURIComponent(data.oktext) : null
+                input1: (data.oktext) ? decodeURIComponent(data.oktext) : ""
             }, false);
         }
     });


[24/50] [abbrv] Fix JPPS and Utils plugins directory structure

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
new file mode 100644
index 0000000..83616b8
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.cpp
@@ -0,0 +1,355 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSInterfaceGlue.h"
+
+#include <json/value.h>
+#include <json/writer.h>
+#include <json/reader.h>
+
+#include <vector>
+#include <sstream>
+
+#include <ppsparse.h>
+
+#include "../core/PPSEvent.h"
+
+namespace jpps {
+
+const std::string PPSInterfaceGlue::EVENT_OPEN = "ppsOpened";
+const std::string PPSInterfaceGlue::EVENT_OPEN_FAILED = "ppsOpenFailed";
+const std::string PPSInterfaceGlue::EVENT_FIRST_READ = "ppsFirstRead";
+const std::string PPSInterfaceGlue::EVENT_NEW_DATA = "OnChange";//"ppsNewData";
+const std::string PPSInterfaceGlue::EVENT_CLOSE = "ppsClosed";
+const std::string PPSInterfaceGlue::EVENT_WRITE_FAILED = "ppsWriteFailed";
+const std::string PPSInterfaceGlue::EVENT_READ_FAILED = "ppsReadFailed";
+
+const std::string PPSInterfaceGlue::ENCODING_N = "n";
+const std::string PPSInterfaceGlue::ENCODING_B = "b";
+const std::string PPSInterfaceGlue::ENCODING_JSON = "json";
+
+const Json::StaticString PPSInterfaceGlue::JSON_REMOVE("remove");
+const Json::StaticString PPSInterfaceGlue::JSON_CHANGED("changed");
+const Json::StaticString PPSInterfaceGlue::JSON_DATA("data");
+const Json::StaticString PPSInterfaceGlue::JSON_OBJNAME("objName");
+const Json::StaticString PPSInterfaceGlue::JSON_CHANGE_DATA("changeData");
+const Json::StaticString PPSInterfaceGlue::JSON_ALL_DATA("allData");
+
+
+PPSInterfaceGlue::PPSInterfaceGlue()
+: m_interface()
+, m_pArg(NULL)
+, m_handleOpen(NULL)
+, m_handleFirstRead(NULL)
+, m_handleNewData(NULL)
+, m_handleClose(NULL)
+, m_handleOpenFailed(NULL)
+, m_handleWriteFailed(NULL)
+, m_handleReadFailed(NULL)
+{
+	m_interface.setEventFunc(onEvent, this);
+}
+
+PPSInterfaceGlue::~PPSInterfaceGlue()
+{
+	m_interface.setEventFunc(NULL);
+}
+
+void PPSInterfaceGlue::callbackInit(void* pArg,
+								    callback* handleOpen,
+								    callback* handleFirstRead,
+								    callback* handleNewData,
+								    callback* handleClose,
+								    callback* handleOpenFailed,
+								    callback* handleWriteFailed,
+								    callback* handleReadFailed)
+{
+	m_pArg = pArg;
+	m_handleOpen = handleOpen;
+	m_handleFirstRead = handleFirstRead;
+	m_handleNewData = handleNewData;
+	m_handleClose = handleClose;
+	m_handleOpenFailed = handleOpenFailed;
+	m_handleWriteFailed = handleWriteFailed;
+	m_handleReadFailed = handleReadFailed;
+}
+
+void PPSInterfaceGlue::setVerbose(unsigned short v)
+{
+	m_interface.setVerbose(v);
+}
+
+bool PPSInterfaceGlue::open(const std::string& path, int oflags)
+{
+	// We don't expose the "mode" to the JS layer - always create in 0666 mode
+	return m_interface.open(path, oflags, 0666, false);
+}
+
+void PPSInterfaceGlue::close()
+{
+	m_interface.close();
+}
+
+void PPSInterfaceGlue::sync()
+{
+	m_interface.sync();
+}
+
+void PPSInterfaceGlue::onEvent(void* pArg, const PPSEvent& event)
+{
+	PPSInterfaceGlue* pGlue = static_cast<PPSInterfaceGlue*>(pArg);
+
+	if (pGlue != NULL)
+		pGlue->onEvent(event);
+}
+
+void PPSInterfaceGlue::onEvent(const PPSEvent& event)
+{
+	callback* pFunc = NULL;
+	std::string sArg;
+
+	switch (event.getEventType()) {
+
+	case PPSEvent::PPS_EVENT_OPENED:
+		pFunc = m_handleOpen;
+		sArg = EVENT_OPEN;
+		break;
+
+	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
+		pFunc = m_handleFirstRead;
+		sArg = EVENT_FIRST_READ + " " + handleNewData(event.getNewData());
+		break;
+
+	case PPSEvent::PPS_EVENT_NEW_DATA:
+		pFunc = m_handleNewData;
+		sArg = EVENT_NEW_DATA + " " + handleNewData(event.getNewData());
+		break;
+
+	case PPSEvent::PPS_EVENT_CLOSED:
+		pFunc = m_handleClose;
+		sArg = EVENT_CLOSE;
+		break;
+
+	case PPSEvent::PPS_EVENT_OPEN_FAILED:
+		pFunc = m_handleOpenFailed;
+		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_WRITE_FAILED:
+		pFunc = m_handleWriteFailed;
+		sArg = EVENT_WRITE_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_READ_FAILED:
+		pFunc = m_handleReadFailed;
+		sArg = EVENT_READ_FAILED + " " + event.getMessage();
+		break;
+	}
+
+	if (pFunc != NULL)
+		pFunc(m_pArg, sArg);
+}
+
+std::string PPSInterfaceGlue::handleNewData(const ppsObject& newData)
+{
+	Json::Value data(Json::nullValue);
+	data[JSON_CHANGE_DATA] = JSONEncodeNewData(newData);
+	data[JSON_ALL_DATA] = JSONEncodeRead(m_interface.read());
+
+	Json::FastWriter writer;
+	return writer.write(data);
+}
+
+std::string PPSInterfaceGlue::read() const
+{
+	Json::Value data = JSONEncodeRead(m_interface.read());
+	Json::FastWriter writer;
+	return writer.write(data);
+}
+
+Json::Value PPSInterfaceGlue::JSONEncodeRead(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value readData(Json::nullValue);
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// An attribute was deleted: update the JSON data structure and the event data
+		if (ppsAttrib.flags & PPS_DELETED) {
+
+			readData.removeMember(ppsAttrib.name);
+		}
+		else {
+
+			// The value is a number
+			if (ppsAttrib.encoding == ENCODING_N) {
+
+				// Convert the value to floating point
+				// istringstream is locale aware - we shouldn't need to perform any special
+				// processing in order to properly convert the data to a floating point
+				// TODO: test that the istringstream conversion works with a locale
+				//       that uses alternate floating point number encoding
+				std::istringstream stream(ppsAttrib.value);
+				double doubleValue;
+
+				// Try to convert the value to a floating point
+				if (!(stream >> doubleValue)) {
+
+					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+					m_handleReadFailed(m_pArg, err);
+					return "";
+				}
+
+				readData[ppsAttrib.name] = doubleValue;
+			}
+			// The value is a boolean
+			else if (ppsAttrib.encoding == ENCODING_B) {
+
+				readData[ppsAttrib.name] = (ppsAttrib.value == "true");
+			}
+			// The value is JSON data
+			else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+				Json::Reader reader;
+				reader.parse(ppsAttrib.value, readData[ppsAttrib.name]);
+			}
+			// Just pass the value through as a straight string
+			else {
+
+				readData[ppsAttrib.name] = ppsAttrib.value;
+			}
+		}
+	}
+
+	return readData;
+}
+
+Json::Value PPSInterfaceGlue::JSONEncodeNewData(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value eventData(Json::nullValue);
+
+	// Set the PPS object name
+	eventData[JSON_OBJNAME] = ppsObj.name.substr(1); // PR 159829 : Remove the pre-pending '@' symbol
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// An attribute was deleted: update the JSON data structure and the event data
+		if (ppsAttrib.flags & PPS_DELETED) {
+
+			eventData[JSON_REMOVE][ppsAttrib.name] = true;
+		}
+		else {
+
+			eventData[JSON_CHANGED][ppsAttrib.name] = true;
+
+			// The value is a number
+			if (ppsAttrib.encoding == ENCODING_N) {
+
+				// Convert the value to floating point
+				// istringstream is locale aware - we shouldn't need to perform any special
+				// processing in order to properly convert the data to a floating point
+				// TODO: test that the istringstream conversion works with a locale
+				//       that uses alternate floating point number encoding
+				std::istringstream stream(ppsAttrib.value);
+				double doubleValue;
+
+				// Try to convert the value to a floating point
+				if (!(stream >> doubleValue)) {
+
+					std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+					m_handleReadFailed(m_pArg, err);
+					return "";
+				}
+
+				eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
+			}
+			// The value is a boolean
+			else if (ppsAttrib.encoding == ENCODING_B) {
+
+				eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
+			}
+			// The value is JSON data
+			else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+				Json::Reader reader;
+				reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
+			}
+			// Just pass the value through as a straight string
+			else {
+
+				eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
+			}
+		}
+	}
+
+	return eventData;
+}
+
+void PPSInterfaceGlue::write(const std::string& data)
+{
+    Json::Reader reader;
+    Json::Value root;
+
+	bool parsingSuccessful = reader.parse(data, root);
+
+    // If parsing the JSON string fails, return a write error
+    if (!parsingSuccessful) {
+
+    	std::string err = EVENT_WRITE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
+        m_handleWriteFailed(m_pArg, err);
+        return;
+    }
+
+	Json::Value::Members memberNames = root.getMemberNames();
+
+	std::ostringstream output;
+	output.precision(15);
+
+	Json::Value member;
+
+	for (unsigned int i = 0; i < memberNames.size(); i++) {
+
+		output << memberNames[i] << ":";
+		member = root[memberNames[i]];
+
+		if (member.isObject() || member.isArray()) {
+
+			Json::FastWriter writer;
+			output << ENCODING_JSON << ":" << writer.write(member); // write() adds an \n
+		}
+		else if (member.isBool()) {
+
+			output << ENCODING_B << ":" << member.asString() << std::endl;
+		}
+		else if (member.isNumeric()) {
+
+			output << ENCODING_N << ":" << member.asDouble() << std::endl;
+		}
+		else if (member.isString()) {
+
+			output << ":" << member.asString() << std::endl;
+		}
+		else {
+
+			std::string err = EVENT_WRITE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
+			m_handleWriteFailed(m_pArg, err);
+			return;
+		}
+	}
+
+	m_interface.write(output.str());
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
new file mode 100644
index 0000000..fafbacd
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSInterfaceGlue.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSINTERFACEGLUE_H_
+#define PPSINTERFACEGLUE_H_
+
+#include "../core/PPSInterface.h"
+#include "PluginTypes.h"
+
+#include <json/value.h>
+
+#include <string>
+
+namespace jpps {
+class PPSEvent;
+struct ppsObject;
+}
+
+namespace jpps {
+
+/**
+ * This class bridges JavaScript and the native PPSInterface code.
+ */
+class PPSInterfaceGlue {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSInterfaceGlue();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSInterfaceGlue();
+
+	/**
+	 * The browser plugin should set these handlers.
+	 *
+	 * @param pArg pArg will be passed back to each callback function when it is called.
+	 */
+	void callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleFirstRead,
+					  callback* handleNewData,
+					  callback* handleClose,
+					  callback* handleOpenFailed,
+					  callback* handleWriteFailed,
+					  callback* handleReadFailed);
+
+	/**
+	 * Set the verbosity of logging to the slog.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS object.
+	 */
+	bool open(const std::string& path, int oflags);
+
+	/**
+	 * Write to a PPS object.
+	 */
+	void write(const std::string& data);
+
+	/**
+	 * Read from the PPS object. This actually returns the cached value of the last
+	 * onNewData event from PPSInteraface, then encodes it as JSON.
+	 */
+	std::string read() const;
+
+	/**
+	 * Close this PPS object.
+	 */
+	void close();
+
+	/**
+	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
+	 * The function blocks until this is finished.
+	 */
+	void sync();
+
+	/**
+	 * The function that the PPSInterface will call when an event happens.
+	 * This is the static function that is used as a function pointer for
+	 * PPSInterface::setEventFunc().
+	 *
+	 * @param event The event PPSInterface is sending.
+	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
+	 * object construction.
+	 */
+	static void onEvent(void* pArg, const PPSEvent& event);
+
+private:
+
+	/**
+	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
+	 */
+	void onEvent(const PPSEvent& event);
+
+	/**
+	 * Handle a new data event.
+	 */
+	std::string handleNewData(const ppsObject& newData);
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * with a new data event. This structures the JSON with changed properties and the
+	 * data that has changed.
+	 */
+	Json::Value JSONEncodeNewData(const ppsObject& ppsObj) const;
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * when a call to read() is made.
+	 */
+	Json::Value JSONEncodeRead(const ppsObject& ppsObj) const;
+
+	// String names for the various events
+	static const std::string EVENT_OPEN;
+	static const std::string EVENT_OPEN_FAILED;
+	static const std::string EVENT_FIRST_READ;
+	static const std::string EVENT_NEW_DATA;
+	static const std::string EVENT_CLOSE;
+	static const std::string EVENT_READ_FAILED;
+	static const std::string EVENT_WRITE_FAILED;
+
+	/** Custom PPS encoding value: an "n" means a real number. */
+	static const std::string ENCODING_N;
+	/** Custom PPS encoding value: a "b" means a boolean value. */
+	static const std::string ENCODING_B;
+	/** Custom PPS encoding value: the data is encoded using JSON. */
+	static const std::string ENCODING_JSON;
+
+	// JSON constants
+	static const Json::StaticString JSON_REMOVE;
+	static const Json::StaticString JSON_CHANGED;
+	static const Json::StaticString JSON_DATA;
+	static const Json::StaticString JSON_OBJNAME;
+	static const Json::StaticString JSON_CHANGE_DATA;
+	static const Json::StaticString JSON_ALL_DATA;
+
+	/** The interface this object wraps. */
+	PPSInterface m_interface;
+
+	// Handlers for various events
+	void* m_pArg;
+	callback* m_handleOpen;
+	callback* m_handleFirstRead;
+	callback* m_handleNewData;
+	callback* m_handleClose;
+	callback* m_handleOpenFailed;
+	callback* m_handleWriteFailed;
+	callback* m_handleReadFailed;
+};
+
+} /* namespace jpps */
+#endif /* PPSINTERFACEGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
new file mode 100644
index 0000000..2eb4552
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "PPSServerGlue.h"
+
+#include <json/value.h>
+#include <json/writer.h>
+#include <json/reader.h>
+
+#include <sstream>
+
+#include <ppsparse.h>
+#include <fcntl.h>
+
+namespace jpps {
+
+const std::string PPSServerGlue::EVENT_OPEN = "onOpen";
+const std::string PPSServerGlue::EVENT_CLOSE = "onClose";
+const std::string PPSServerGlue::EVENT_CLIENT_CONNECT = "onClientConnect";
+const std::string PPSServerGlue::EVENT_CLIENT_DISCONNECT = "onClientDisconnect";
+const std::string PPSServerGlue::EVENT_MESSAGE = "onMessage";
+const std::string PPSServerGlue::EVENT_OPEN_FAILED = "onOpenFailed";
+const std::string PPSServerGlue::EVENT_SEND_MESSAGE_FAILED = "onSendMessageFailed";
+const std::string PPSServerGlue::EVENT_RECEIVE_MESSAGE_FAILED = "onReceiveMessageFailed";
+
+const std::string PPSServerGlue::ENCODING_N = "n";
+const std::string PPSServerGlue::ENCODING_B = "b";
+const std::string PPSServerGlue::ENCODING_JSON = "json";
+
+const Json::StaticString PPSServerGlue::JSON_DATA("data");
+const Json::StaticString PPSServerGlue::JSON_CONNECTION_ID("clientId");
+
+PPSServerGlue::PPSServerGlue()
+: m_interface()
+, m_pArg(NULL)
+, m_handleOpen(NULL)
+, m_handleClose(NULL)
+, m_handleClientConnect(NULL)
+, m_handleClientDisconnect(NULL)
+, m_handleMessage(NULL)
+, m_handleOpenFailed(NULL)
+, m_handleSendMessageFailed(NULL)
+, m_handleReceiveMessageFailed(NULL)
+{
+	m_interface.setEventFunc(onEvent, this);
+}
+
+PPSServerGlue::~PPSServerGlue()
+{
+	m_interface.setEventFunc(NULL);
+}
+
+void PPSServerGlue::callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleClose,
+					  callback* handleClientConnect,
+					  callback* handleClientDisconnect,
+					  callback* handleMessage,
+					  callback* handleOpenFailed,
+					  callback* handleSendMessageFailed,
+					  callback* handleReceiveMessageFailed)
+{
+	m_pArg = pArg;
+	m_handleOpen = handleOpen;
+	m_handleClose = handleClose;
+	m_handleClientConnect = handleClientConnect;
+	m_handleClientDisconnect = handleClientDisconnect;
+	m_handleMessage = handleMessage;
+	m_handleOpenFailed = handleOpenFailed;
+	m_handleSendMessageFailed = handleSendMessageFailed;
+	m_handleReceiveMessageFailed = handleReceiveMessageFailed;
+}
+
+
+void PPSServerGlue::setVerbose(unsigned short v)
+{
+	m_interface.setVerbose(v);
+}
+
+bool PPSServerGlue::open(const std::string& path, int oflags)
+{
+	// Make sure we're creating the server, if it doesn't exist
+	if (!(oflags & O_CREAT))
+		oflags &= O_CREAT;
+
+	// We don't expose the "mode" to the JS layer - always create in 0666 mode
+	return m_interface.open(path, oflags, 0666, true);
+}
+
+void PPSServerGlue::close()
+{
+	m_interface.close();
+}
+
+void PPSServerGlue::sendMessage(const std::string& clientID, const std::string& msg)
+{
+	std::string decodedMsg = JSONDecodeData(msg);
+	std::string message(clientID + "\n" + decodedMsg);
+	m_interface.write(message);
+}
+
+void PPSServerGlue::broadcastMessage(const std::string& msg)
+{
+	m_interface.write(JSONDecodeData(msg));
+}
+
+void PPSServerGlue::onEvent(void* pArg, const PPSEvent& event)
+{
+	PPSServerGlue* pGlue = static_cast<PPSServerGlue*>(pArg);
+
+	if (pGlue != NULL)
+		pGlue->onEvent(event);
+}
+
+void PPSServerGlue::onEvent(const PPSEvent& event)
+{
+	callback* pFunc = NULL;
+	std::string sArg;
+
+	switch (event.getEventType()) {
+
+	case PPSEvent::PPS_EVENT_OPENED:
+		pFunc = m_handleOpen;
+		sArg = EVENT_OPEN;
+		break;
+
+	// The server doesn't do anything with this event
+	case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
+		break;
+
+	case PPSEvent::PPS_EVENT_NEW_DATA:
+	{
+		ppsObject data(event.getNewData());
+
+		// This means a new connection
+		if (data.flags & PPS_CREATED) {
+			sArg = EVENT_CLIENT_CONNECT;
+			pFunc = m_handleClientConnect;
+		}
+		// This means a connection is closed
+		else if (data.flags & PPS_DELETED) {
+			sArg = EVENT_CLIENT_DISCONNECT;
+			pFunc = m_handleClientDisconnect;
+		}
+		// We're getting data from the connection
+		else {
+			sArg = EVENT_MESSAGE;
+			pFunc = m_handleMessage;
+		}
+
+		sArg += " " + JSONEncodeData(data);
+
+		break;
+	}
+
+	case PPSEvent::PPS_EVENT_CLOSED:
+		pFunc = m_handleClose;
+		sArg = EVENT_CLOSE;
+		break;
+
+	case PPSEvent::PPS_EVENT_OPEN_FAILED:
+		pFunc = m_handleOpenFailed;
+		sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_WRITE_FAILED:
+		pFunc = m_handleSendMessageFailed;
+		sArg = EVENT_SEND_MESSAGE_FAILED + " " + event.getMessage();
+		break;
+
+	case PPSEvent::PPS_EVENT_READ_FAILED:
+		pFunc = m_handleReceiveMessageFailed;
+		sArg = EVENT_RECEIVE_MESSAGE_FAILED + event.getMessage();
+		break;
+	}
+
+	if (pFunc != NULL)
+		pFunc(m_pArg, sArg);
+
+}
+
+std::string PPSServerGlue::JSONEncodeData(const ppsObject& ppsObj) const
+{
+	// If the ppsObj is empty, we can't encode it
+	if (ppsObj.name.empty())
+		return "";
+
+	Json::Value eventData(Json::nullValue);
+
+	// Set the client id
+	// Chop off the '+' or '-' if it's there
+	eventData[JSON_CONNECTION_ID] = ppsObj.name;
+
+	for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
+
+		ppsAttribute ppsAttrib = (*it).second;
+
+		// The value is a number
+		if (ppsAttrib.encoding == ENCODING_N) {
+
+			// Convert the value to floating point
+			// istringstream is locale aware - we shouldn't need to perform any special
+			// processing in order to properly convert the data to a floating point
+			// TODO: test that the istringstream conversion works with a locale
+			//       that uses alternate floating point number encoding
+			std::istringstream stream(ppsAttrib.value);
+			double doubleValue;
+
+			// Try to convert the value to a floating point
+			if (!(stream >> doubleValue)) {
+
+				std::string err = EVENT_RECEIVE_MESSAGE_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
+				m_handleReceiveMessageFailed(m_pArg, err);
+				return "";
+			}
+
+			eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
+		}
+		// The value is a boolean
+		else if (ppsAttrib.encoding == ENCODING_B) {
+
+			eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
+		}
+		// The value is JSON data
+		else if (ppsAttrib.encoding == ENCODING_JSON) {
+
+			Json::Reader reader;
+			reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
+		}
+		// Just pass the value through as a straight string
+		else {
+
+			eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
+		}
+	}
+
+	Json::FastWriter writer;
+	return writer.write(eventData);
+}
+
+std::string PPSServerGlue::JSONDecodeData(const std::string& data) const
+{
+	 Json::Reader reader;
+	Json::Value root;
+
+	bool parsingSuccessful = reader.parse(data, root);
+
+	// If parsing the JSON string fails, return a write error
+	if (!parsingSuccessful) {
+
+		std::string err = EVENT_SEND_MESSAGE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
+		m_handleSendMessageFailed(m_pArg, err);
+		return "";
+	}
+
+	Json::Value::Members memberNames = root.getMemberNames();
+
+	std::ostringstream output;
+	output.precision(15);
+
+	Json::Value member;
+
+	for (unsigned int i = 0; i < memberNames.size(); i++) {
+
+		output << memberNames[i] << ":";
+		member = root[memberNames[i]];
+
+		if (member.isObject() || member.isArray()) {
+
+			Json::FastWriter writer;
+			output << ENCODING_JSON << ":" << writer.write(member);
+		}
+		else if (member.isBool()) {
+
+			output << ENCODING_B << ":" << member.asString();
+		}
+		else if (member.isNumeric()) {
+
+			output << ENCODING_N << ":" << member.asDouble();
+		}
+		else if (member.isString()) {
+
+			output << ":" << member.asString();
+		}
+		else {
+
+			std::string err = EVENT_SEND_MESSAGE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
+			m_handleSendMessageFailed(m_pArg, err);
+			return "";
+		}
+
+		// Make sure we terminate the line
+		output << std::endl;
+	}
+
+	return output.str();
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
new file mode 100644
index 0000000..8891829
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PPSServerGlue.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PPSSERVERGLUE_H_
+#define PPSSERVERGLUE_H_
+
+#include "../core/PPSInterface.h"
+#include "PluginTypes.h"
+
+// Forward declaration
+namespace Json {
+class StaticString;
+}
+namespace jpps {
+class PPSEvent;
+struct ppsObject;
+}
+
+namespace jpps {
+
+/**
+ * Act as glue between jpps Server class an the PPSInterface.
+ * This class encapsulates a PPS object as a PPS server.
+ * TODO: write a better comment
+ */
+class PPSServerGlue {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	PPSServerGlue();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~PPSServerGlue();
+
+	/**
+	 * The browser plugin should set these handlers.
+	 *
+	 * @param pArg pArg will be passed back to each callback function when it is called.
+	 */
+	void callbackInit(void* pArg,
+					  callback* handleOpen,
+					  callback* handleClose,
+					  callback* handleClientConnect,
+					  callback* handleClientDisconnect,
+					  callback* handleMessage,
+					  callback* handleOpenFailed,
+					  callback* handleSendMessageFailed,
+					  callback* handleReceiveMessageFailed);
+
+	/**
+	 * Set the verbosity of logging to the slog.
+	 */
+	void setVerbose(unsigned short v);
+
+	/**
+	 * Open a PPS server object.
+	 */
+	bool open(const std::string& path, int oflags);
+
+	/**
+	 * Close this PPS server object.
+	 */
+	void close();
+
+	/**
+	 * Send a message to a particular client.
+	 */
+	void sendMessage(const std::string& clientID, const std::string& msg);
+
+	/**
+	 * Send a message to all clients.
+	 */
+	void broadcastMessage(const std::string& msg);
+
+	/**
+	 * The function that the PPSInterface will call when an event happens.
+	 * This is the static function that is used as a function pointer for
+	 * PPSInterface::setEventFunc().
+	 *
+	 * @param event The event PPSInterface is sending.
+	 * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
+	 * object construction.
+	 */
+	static void onEvent(void* pArg, const PPSEvent& event);
+
+private:
+
+	/**
+	 * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
+	 */
+	void onEvent(const PPSEvent& event);
+
+	/**
+	 * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
+	 * with a onMessage event.
+	 */
+	std::string JSONEncodeData(const ppsObject& ppsObj) const;
+
+	/**
+	 * Take a JSON string and change it into a PPS consumable string.
+	 */
+	std::string JSONDecodeData(const std::string& data) const;
+
+	// String names for the various events
+	static const std::string EVENT_OPEN;
+	static const std::string EVENT_CLOSE;
+	static const std::string EVENT_CLIENT_CONNECT;
+	static const std::string EVENT_CLIENT_DISCONNECT;
+	static const std::string EVENT_MESSAGE;
+	static const std::string EVENT_OPEN_FAILED;
+	static const std::string EVENT_SEND_MESSAGE_FAILED;
+	static const std::string EVENT_RECEIVE_MESSAGE_FAILED;
+
+	/** Custom PPS encoding value: an "n" means a real number. */
+	static const std::string ENCODING_N;
+	/** Custom PPS encoding value: a "b" means a boolean value. */
+	static const std::string ENCODING_B;
+	/** Custom PPS encoding value: the data is encoded using JSON. */
+	static const std::string ENCODING_JSON;
+
+	// JSON constants
+	static const Json::StaticString JSON_DATA;
+	static const Json::StaticString JSON_CONNECTION_ID;
+
+	/** The interface this object wraps. */
+	PPSInterface m_interface;
+
+	// Handlers for various events
+	void* m_pArg;
+	callback* m_handleOpen;
+	callback* m_handleClose;
+	callback* m_handleClientConnect;
+	callback* m_handleClientDisconnect;
+	callback* m_handleMessage;
+	callback* m_handleOpenFailed;
+	callback* m_handleSendMessageFailed;
+	callback* m_handleReceiveMessageFailed;
+
+};
+
+} /* namespace jpps */
+#endif /* PPSSERVERGLUE_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
new file mode 100644
index 0000000..9ce6b32
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/PluginTypes.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef PLUGINTYPES_H_
+#define PLUGINTYPES_H_
+
+namespace jpps {
+
+/**
+ * Function type for setting handles between JNext plug-in and glue classes.
+ */
+typedef void (callback)(void* pArg, const std::string&);
+
+}
+
+
+#endif /* PLUGINTYPES_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
new file mode 100644
index 0000000..e06ad4c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/plugin/pluginManifest.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#include "JPPSPlugin.h"
+#include "JPPSServerPlugin.h"
+
+#include <string>
+
+/**
+ * This callback must be implemented by all JSExt objects. It is invoked from
+ * plugin.cpp.
+ *
+ * @return A comma separated list of classes supported by this JNEXT extension
+ */
+char* onGetObjList(void)
+{
+	static char* ppsclasses = NULL;
+
+	if (ppsclasses == NULL) {
+
+		// Get the length of all the strings, +1 for the ',' +1 for the \0
+		int size = std::strlen(jpps::JPPSPlugin::CLASS_NAME) + std::strlen(jpps::JPPSServerPlugin::CLASS_NAME) + 1 + 1;
+		ppsclasses = new char[size];
+		std::strcpy(ppsclasses, jpps::JPPSPlugin::CLASS_NAME);
+		std::strcat(ppsclasses, ",");
+		std::strcat(ppsclasses, jpps::JPPSServerPlugin::CLASS_NAME);
+		ppsclasses[size] = '\0';
+	}
+    // Return a comma separated list of classes known to this plugin
+    return ppsclasses;
+}
+
+/**
+ * This callback must be implemented by all JSExt objects. It is invoked from
+ * plugin.cpp.
+ *
+ * @param strClassName Name of the class requested to be created Valid named are those
+ * that are returned in onGetObjList
+ *
+ * @param strObjId The unique object id for the class
+ *
+ * @return A pointer to the created extension object
+ */
+JSExt* onCreateObject(const std::string& strClassName, const std::string& strObjId)
+{
+    // Given a class name and identifier, create the relevant object.
+    if (strClassName == jpps::JPPSPlugin::CLASS_NAME) {
+        return new jpps::JPPSPlugin(strObjId);;
+    }
+    else if (strClassName == jpps::JPPSServerPlugin::CLASS_NAME) {
+    	return new jpps::JPPSServerPlugin(strObjId);
+    }
+
+    // Any other name is invalid
+    return NULL;
+}
+
+

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
new file mode 100644
index 0000000..37a9d17
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Logger.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef LOGGER_H_
+#define LOGGER_H_
+
+#include <string>
+
+#include <sys/slog.h>
+#include <sys/slogcodes.h>
+
+namespace jpps {
+
+/**
+ * The Logger class writes messages to the system log. It has a verbosity setting
+ * in order to prevent cluttering the slog during normal operation.
+ */
+class Logger {
+
+public:
+
+	enum slogType {
+		info = _SLOG_INFO,
+		warning = _SLOG_WARNING,
+		error = _SLOG_ERROR,
+		critical = _SLOG_CRITICAL,
+		debug = _SLOG_DEBUG1
+	};
+
+	/**
+	 * Default constructor. Sets the verbosity to 0;
+	 */
+	Logger() : m_verbosity(0) {}
+
+	/**
+	 * Destructor.
+	 */
+	~Logger() {}
+
+	/**
+	 * Set the desired level of verbosity. A value of 0 means that only warning,
+	 * error and critical messages will appear in the slog. A verbosity of 1 adds
+	 * info messages. A verbosity of 2 adds debug messages.
+	 */
+	inline void setVerbosity(unsigned short value) { m_verbosity = value; }
+
+	/**
+	 * Get the current level of verbosity.
+	 */
+	inline unsigned short getVerbosity() const { return m_verbosity; }
+
+	/**
+	 * Used to send messages to the system log (slog).
+	 *
+	 * @param type The type of slog message.
+	 * @param message The message to put in the slog.
+	 */
+	void slog(const slogType& type, const std::string& message) const {
+
+		// Don't display info or debug when verbosity is set to 0
+		if (m_verbosity == 0 && (type == info || type == debug)) return;
+		// Don't display debug when verbosity is set to 1
+		if (m_verbosity == 1 && type == debug) return;
+
+		::slogf(_SLOG_SETCODE(_SLOGC_GRAPHICS, 300), type, "%s", message.c_str());
+	}
+
+private:
+
+	/** The verbosity level.  */
+	unsigned short m_verbosity;
+};
+
+}
+
+#endif /* LOGGER_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
new file mode 100644
index 0000000..82ab5d1
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+#include "Thread.h"
+#include <pthread.h>
+#include "Logger.h"
+#include <sstream>
+#include <string.h>
+#include <errno.h>
+
+namespace jpps {
+
+Thread::Thread()
+: m_threadID(-1)
+{
+	// Init the thread with all defaults
+	pthread_attr_init(&m_attrib);
+}
+
+Thread::~Thread()
+{
+	// Dispose of the thread attributes
+	pthread_attr_destroy(&m_attrib);
+}
+
+void Thread::start(void* (*start_routine)(void*), void* arg, const std::string& thread_name)
+{
+	// If this thread is already started, you can't start a new one
+	if (m_threadID != -1) {
+		return;
+	}
+
+	// Create a new thread
+	if (pthread_create(&m_threadID, &m_attrib, start_routine, arg) != 0) {
+
+		std::ostringstream ostream;
+		ostream << "Thread::start() Failed - Failed to create a new thread. "
+				<< " (" << errno << ": " << strerror(errno) << ")";
+
+		Logger logger;
+		logger.slog(Logger::warning, ostream.str());
+	}
+
+	if (!thread_name.empty())
+		pthread_setname_np(m_threadID, thread_name.c_str());
+}
+
+void Thread::stop()
+{
+	// If the thread wasn't running, we can't stop it
+	if (m_threadID == -1) {
+		return;
+	}
+
+	// Cancel the thread
+	if (pthread_cancel(m_threadID) != 0) {
+
+		std::ostringstream ostream;
+		ostream << "Thread::stop() Failed - Failed to cancel thread " << m_threadID << "."
+				<< " (" << errno << ": " << strerror(errno) << ")";
+
+		Logger logger;
+		logger.slog(Logger::warning, ostream.str());
+	}
+
+	// Reset the thread ID
+	m_threadID = -1;
+}
+
+} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
new file mode 100644
index 0000000..79cc62a
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/JPPS/native/src/utils/Thread.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ */
+
+/*
+ * $QNXLicenseC:
+ * Copyright 2009, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software.   Free development
+ * licenses are available for evaluation and non-commercial purposes.  For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others.  Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ */
+
+#ifndef THREAD_H_
+#define THREAD_H_
+
+#include <sys/types.h>
+#include <string>
+
+namespace jpps {
+
+/**
+ * Simple wrapper to simplify thread management.
+ */
+class Thread {
+
+public:
+
+	/**
+	 * Constructor.
+	 */
+	Thread();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~Thread();
+
+	/**
+	 * Start a thread with the given function. If the thread is already running and has not
+	 * been stopped, this does nothing.
+	 */
+	void start(void* (*start_routine)(void*), void* arg, const std::string& thread_name = "");
+
+	/**
+	 * Stop the thread. If the thread isn't running, this does nothing.
+	 */
+	void stop();
+
+	/**
+	 * Is the thread running?
+	 */
+	inline bool isRunning() const { return (m_threadID >= 0); }
+
+private:
+
+	/** The id of this thread. */
+	pthread_t m_threadID;
+
+	/** The attributes of this thread. */
+	pthread_attr_t m_attrib;
+};
+
+} /* namespace jpps */
+#endif /* THREAD_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=CPU
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
deleted file mode 100644
index 6cecca9..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/common.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-NAME=jpps
-PLUGIN=yes
-UTILS=yes
-
-include ../../../../../../meta.mk
-
-override CCFLAGS := $(filter-out -Werror , $(CCFLAGS))
-
-EXTRA_SRCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
-
-EXTRA_INCVPATH+=$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/utils \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/core \
-				$(WEBWORKS_DIR)/plugin/com.blackberry.jpps/src/blackberry10/native/src/plugin
-
-SRCS+=src/utils/Thread.cpp \
-      src/core/PPSInterface.cpp \
-      src/core/PPSNotifier.cpp \
-      src/core/PPSNotifyGroupManager.cpp \
-      src/plugin/JPPSPlugin.cpp \
-      src/plugin/PPSInterfaceGlue.cpp \
-      src/plugin/JPPSServerPlugin.cpp \
-      src/plugin/PPSServerGlue.cpp \
-      src/plugin/pluginManifest.cpp
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-LIBS+=pps

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so
deleted file mode 100644
index f0eb90d..0000000
Binary files a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/device/libjpps.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so
deleted file mode 100644
index f2c12ff..0000000
Binary files a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/simulator/libjpps.so and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
deleted file mode 100644
index 808e699..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSEvent.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSEVENT_H_
-#define PPSEVENT_H_
-
-#include <string>
-#include "PPSTypes.h"
-
-namespace jpps {
-
-/**
- * A class representing a PPS event. Used to notify interested parties when something
- * happens to a PPS object.
- */
-class PPSEvent {
-
-public:
-
-	/**
-	 * The possible types of this event.
-	 */
-	enum PPSEventType {
-		/** The PPS object's first data read is complete. */
-		PPS_EVENT_FIRST_READ_COMPLETE,
-		/** The PPS object has new data. */
-		PPS_EVENT_NEW_DATA,
-		/** The PPS object was successfully opened. */
-		PPS_EVENT_OPENED,
-		/** A PPS object was closed. */
-		PPS_EVENT_CLOSED,
-		/** An attempt to open a PPS object failed. */
-		PPS_EVENT_OPEN_FAILED,
-		/** An attempt to read from a PPS object failed. */
-		PPS_EVENT_READ_FAILED,
-		/** An attempt to write to a PPS object failed. */
-		PPS_EVENT_WRITE_FAILED,
-	};
-
-	/**
-	 * Constructor.
-	 *
-	 * @param eventType The type of event this is.
-	 * @param data If eventType == PPS_EVENT_NEW_DATA, the new data.
-	 */
-	PPSEvent(PPSEventType eventType, const std::string& msg = "", const ppsObject& newData = ppsObject())
-	: m_eventType(eventType)
-	, m_message(msg)
-	, m_newData(newData)
-	{}
-
-	/**
-	 * Destructor.
-	 */
-	virtual ~PPSEvent() {}
-
-	/**
-	 * Get the event type.
-	 */
-	inline PPSEventType getEventType() const { return m_eventType; }
-
-	/**
-	 * Get the message associated with this event.
-	 */
-	inline std::string getMessage() const { return m_message; }
-
-	/**
-	 * Get the new data. This value is only populated if the eventType is PPS_EVENT_NEW_DATA. This data
-	 * is what was parsed out of the PPS object.
-	 */
-	inline ppsObject getNewData() const { return m_newData; }
-
-private:
-
-	// Disable the default constructor.
-	PPSEvent();
-
-	/** The type of this event. */
-	PPSEventType m_eventType;
-
-	/** A message associated to the event. */
-	std::string m_message;
-
-	/** If m_eventType == PPS_EVENT_NEW_DATA, this contains the new data. Else m_newData is empty.
-	 * This data is the data that was read from the PPS object, un-massaged. */
-	ppsObject m_newData;
-};
-
-} /* namespace jpps */
-#endif /* PPSEVENT_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
deleted file mode 100644
index dfb575b..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.cpp
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSInterface.h"
-
-#include <sstream>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <ppsparse.h>
-#include <string.h>
-
-#include "PPSNotifyGroupManager.h"
-#include "PPSEvent.h"
-
-namespace jpps {
-
-// Const statics
-const char* PPSInterface::PPS_ROOT = "/pps/";
-const int PPSInterface::MaxPPSReadSize = (32 * 1024);
-
-// Static data members
-pthread_mutex_t PPSInterface::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t PPSInterface::sm_cond;
-volatile bool PPSInterface::sm_firstInitDone = false;
-std::map<unsigned int, PPSInterface*> PPSInterface::sm_interfaceLookupTable;
-
-PPSInterface::PPSInterface()
-: m_pEventFunc(NULL)
-, m_pEventArg(NULL)
-, m_interfaceId(0)
-, m_fd(-1)
-, m_oflags(0)
-, m_firstRead(true)
-, m_cachedRead()
-, m_logger()
-{
-	// This is used to assign a unique ID to each PPSInterface object
-	static unsigned int interfaceIDs = 0;
-
-	::pthread_mutex_lock(&sm_mutex);
-
-	m_interfaceId = interfaceIDs;
-	interfaceIDs++; // Increment this so that the next object has a unique id.
-
-	// Add myself to the lookup table
-	sm_interfaceLookupTable.insert(std::pair<unsigned int, PPSInterface*>(m_interfaceId, this));
-
-	if (!sm_firstInitDone) {
-
-		// Initialize the condvar
-		pthread_condattr_t condAttr;
-		::pthread_condattr_init(&condAttr);
-		::pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
-		::pthread_cond_init(&sm_cond, &condAttr);
-		::pthread_condattr_destroy(&condAttr);
-
-		sm_firstInitDone = true;
-	}
-
-	::pthread_mutex_unlock(&sm_mutex);
-}
-
-PPSInterface::~PPSInterface()
-{
-	std::ostringstream ostream;
-	ostream << "PPSInterface::~PPSInterface() - Destruct fd:" << m_fd << ".";
-	m_logger.slog(Logger::debug, ostream.str());
-
-	// Close my open PPS object, if I have one
-	close();
-
-	// Remove myself from the lookup table
-	sm_interfaceLookupTable.erase(m_interfaceId);
-}
-
-void PPSInterface::setVerbose(unsigned short v)
-{
-	m_logger.setVerbosity(v);
-}
-
-void PPSInterface::setEventFunc(const PPSEventFunc* pEventFunc, void* pArg)
-{
-	m_pEventFunc = pEventFunc;
-	m_pEventArg = pArg;
-}
-
-bool PPSInterface::open(const std::string& path, int oflag, int mode, bool server)
-{
-	// If we've already got an open file, fail
-	if (m_fd != -1) {
-
-		m_logger.slog(Logger::warning, "PPSInterface::open() Failed - Attempted to open an object that is already open.");
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_OPEN_FAILED, "Attempted to open an object that is already open."));
-		return false;
-	}
-
-	std::string errorMsg;
-	bool ok = false;
-
-	// Prepend PPS_ROOT to the path if it doesn't start with a '/'
-	std::string fullpath = (path[0] != '/' ? PPSInterface::PPS_ROOT : "") + path;
-
-	// This flag is used to prevent the notify thread from performing reads while the
-	// open() function is running and doing its first read.
-	::pthread_mutex_lock(&sm_mutex);
-	m_firstRead = true;
-	::pthread_mutex_unlock(&sm_mutex);
-
-	// Remove any options from the path otherwise lstat will fail
-	std::string pathNoOptions(fullpath);
-	std::size_t nPosOpts = fullpath.rfind('?');
-
-	if (nPosOpts != std::string::npos)
-		pathNoOptions = fullpath.substr(0, nPosOpts);
-
-	// There are a few complexities associated with symbolic links.  If
-	// the last component of the path is a symlink we have to resolve it
-	// since we won't be able to resolve the name when the options are
-	// added.  Also we need to get the path relative to the pps filesystem
-	// so we can locate the .notify file.  So, if the object already
-	// exists, resolve the path.  If it doesn't and O_CREAT is specified
-	// resolve the directory it's in, otherwise it's a failure.
-	std::string resolvedName;
-	char szResolvedName[PATH_MAX+128]; // buffer for use with the C functions
-
-	if (::realpath(pathNoOptions.c_str(), szResolvedName) != NULL) {
-
-		resolvedName = szResolvedName;
-		ok = true;
-	}
-	else if (oflag & O_CREAT) {
-
-		// Chop off the file name, so we can try to resolve the directory
-		size_t nPos = pathNoOptions.rfind('/');
-
-		// We found a '/'
-		if (nPos != std::string::npos) {
-
-			// Get the directory path
-			std::string dirPath = pathNoOptions.substr(0, nPos); // Don't include the '/'
-
-			if (::realpath(dirPath.c_str(), szResolvedName) != NULL) {
-
-				// Concatenate the file name to the resolved directory path
-				resolvedName = szResolvedName + pathNoOptions.substr(nPos); // include the '/' at the start
-				ok = true;
-			}
-		}
-	}
-
-	if (ok) {
-
-		struct stat info;
-		int result = ::lstat(resolvedName.c_str(), &info);
-
-		if (result != 0) {
-
-			// If we failed and we're not creating a non-existent file, it's an error.
-			if ((errno != ENOENT) && !(oflag & O_CREAT))
-				ok = false;
-		}
-		else if (S_ISDIR(info.st_mode))
-			ok = false;
-	}
-
-	if (ok) {
-
-		std::string options;
-
-		// Now lets work with the options to ensure we have a complete version
-		std::string pathOptions;
-		
-		// Get just the stuff after '?'
-		size_t nPos = fullpath.rfind('?');
-
-		if (nPos != std::string::npos) {
-			pathOptions = fullpath.substr(nPos);
-		}
-
-		if ((oflag & O_ACCMODE) != O_WRONLY) {
-
-			// This is used as the return object for the joinNotifyGroup() call
-			// It's only valid if joinNotifyGroup() returned true
-			std::string groupId;
-
-			PPSNotifyGroupManager::mutexLock();
-			PPSNotifyGroupManager& notifyManager = PPSNotifyGroupManager::getInstance();
-			bool groupJoined = notifyManager.joinNotifyGroup(resolvedName, groupId);
-			PPSNotifyGroupManager::mutexUnlock();
-
-			if (groupJoined) {
-
-				// If we're acting as a server, we use server as an option
-				// otherwise we have to specify delta mode.  PPS has a fit
-				// if we specify both delta and deltadir so check for this.
-				std::string modeExtra;
-
-				// Add in the options we need.  If both server and delta are specified, use only
-				// server (it kind of implies delta and at one point pps would not like both being
-				// present)
-				if (server) {
-					modeExtra = ",server";
-				}
-				// If we have no options or there's no 'deltadir' specified, use delta mode
-				else if (pathOptions.empty() || pathOptions.find("deltadir") == std::string::npos) {
-					modeExtra = ",delta";
-				}
-
-				// We embed the m_interfaceID as a unique identifier that will be passed on to the
-				// PPSNotifier. PPSNotifier will use this id in conjunction with getPPSInterface()
-				// in order to send this object notifications that content is ready for reading later.
-				std::ostringstream ostream;
-				ostream << "?" << (pathOptions.empty() ? "" : pathOptions.substr(1) + ",") << "notify="
-						<< groupId << ":" << m_interfaceId << modeExtra;
-				options = ostream.str();
-			}
-		}
-
-		if (!options.empty()) {
-
-			resolvedName += options;
-		}
-
-		// The big moment... Let's try to actually open the PPS object...
-		if (ok) {
-			m_fd = ::open(resolvedName.c_str(), oflag, mode);
-		}
-
-		// Error opening the PPS object
-		if (m_fd < 0) {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::open() Failed - ::open("
-					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-					<< ((oflag & O_CREAT) ? ":create" : "")
-					<< ") " << resolvedName << " (" << errno << ": " << strerror(errno) << ")";
-			m_logger.slog(Logger::warning, ostream.str());
-			errorMsg = ostream.str();
-		}
-		else {
-			// Depending on our umask, the permissions might not have
-			// been as specified. So if O_CREAT was specified, re-set the
-			// permissions.  The object might already exist, but perhaps
-			// that's OK too.
-			if (oflag & O_CREAT) {
-				::fchmod(m_fd, mode);
-			}
-
-			m_oflags = oflag;
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::open() - ::open("
-					<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-					   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-					   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-					<< ((oflag & O_CREAT) ? ":create" : "")
-					<< ") " << resolvedName;
-			m_logger.slog(Logger::debug, ostream.str());
-		}
-	}
-	// For whatever reason, the path to the PPS object was not valid
-	else {
-		std::ostringstream ostream;
-		ostream << "PPSInterface::open() Failed - ::open("
-				<< (((oflag & O_ACCMODE) == O_WRONLY) ? "write" :
-				   ((oflag & O_ACCMODE) == O_RDONLY) ? "read" :
-				   ((oflag & O_ACCMODE) == O_RDWR) ? "r/w" : "???")
-				<< ((oflag & O_CREAT) ? ":create" : "")
-				<< ") " << path << " The PPS object could not be resolved properly.";
-		m_logger.slog(Logger::warning, ostream.str());
-		errorMsg = ostream.str();
-	}
-
-	sendEvent(PPSEvent(m_fd >= 0 ? PPSEvent::PPS_EVENT_OPENED : PPSEvent::PPS_EVENT_OPEN_FAILED, errorMsg));
-
-	if (m_fd >= 0 && (oflag & O_ACCMODE) != O_WRONLY) {
-
-		// Perform the initial read
-		readFromObject();
-	}
-
-	// Tell the other thread we are done with the first read
-	::pthread_mutex_lock(&sm_mutex);
-	m_firstRead = false;
-	::pthread_cond_broadcast(&sm_cond);
-	::pthread_mutex_unlock(&sm_mutex);
-
-	return m_fd >= 0;
-}
-
-void PPSInterface::write(const std::string& data)
-{
-	// We're trying to write to an unopened PPS object
-	if (m_fd == -1) {
-
-		std::string msg("PPSInterface::write() Failed - Attempting to write to a file that isn't open.");
-		m_logger.slog(Logger::warning, msg);
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, msg));
-	}
-
-	ssize_t ret = ::write(m_fd, data.c_str(), data.length());
-
-	// Debug slog the write call if it was successful
-	if (ret >= 0) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::write() - fd:" << m_fd << " : \n" << data;
-		m_logger.slog(Logger::debug, ostream.str());
-	}
-
-	// There was an error writing
-	if (ret == -1) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::write() Failed - Error writing to fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-		m_logger.slog(Logger::warning, ostream.str());
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_WRITE_FAILED, ostream.str()));
-	}
-
-	// If we wrote successfully and the file is open in read/write mode, then we need to manually update the
-	// read cache. When in O_RDWR mode, we do NOT receive notifications of our own write() operations.
-	// This means that the cache of read data becomes stale - it is missing the data that we have written
-	// to the object ourselves. In this case, we will manually update the cache.
-	// NOTE: this seems fraught with peril, but unfortunately there don't seem to be any good solutions to
-	// fixing the problem of read/write mode and read() integrity.
-	if (ret >= 0 && (m_oflags & O_RDWR)) {
-
-		// We're going to try to fool the ppsparse() method into parsing the data we write.
-		char* pWriteData = new char[data.length() + 1];
-
-		// The later call to ppsparse() moves the pWriteData pointer forward, and we need the original pointer
-		// in order to properly delete the object later, so let's cache it here
-		char* pWriteDataCopy = pWriteData;
-
-		std::strcpy(pWriteData, data.c_str()); // strcpy null terminates for us
-
-		// Parse the write buffer - this should give us a ppsObject with only attributes
-		ppsObject parsedData = parsePPSData(pWriteData);
-
-		// The data being written does not include the object name other object properties (duh)
-		// So parsedData contains only attribute info. We want to preserve the object name
-		// and properties, so lets just copy the ones in the cache into our parsedData struct
-		// so that the call to updateCachedReadData() will preserve them (i.e. copy them back)
-		parsedData.name = m_cachedRead.name;
-		parsedData.flags = m_cachedRead.flags;
-		parsedData.options = m_cachedRead.options;
-		parsedData.optionMask = m_cachedRead.optionMask;
-
-		// Update the cache
-		updateCachedReadData(parsedData);
-
-		// Cleanup our allocated memory
-		if (pWriteDataCopy) {
-
-			delete[] pWriteDataCopy;
-		}
-	}
-}
-
-void PPSInterface::sync()
-{
-	if (m_fd >= 0)
-		::fsync(m_fd);
-}
-
-void PPSInterface::close()
-{
-	if (m_fd >= 0) {
-
-		::close(m_fd);
-		m_fd = -1;
-		m_cachedRead = ppsObject();
-		m_oflags = 0;
-
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_CLOSED));
-	}
-}
-
-void PPSInterface::onNotify(NotifyType event)
-{
-	// We only handle read notifications
-	if (event != PPS_READ) {
-		return;
-	}
-
-	if (m_firstRead) {
-		::pthread_mutex_lock(&sm_mutex);
-		while (m_firstRead) {
-			::pthread_cond_wait(&sm_cond, &sm_mutex);
-		}
-		::pthread_mutex_unlock(&sm_mutex);
-	}
-
-	readFromObject();
-}
-
-void PPSInterface::readFromObject()
-{
-	bool sendFirstReadEvent = m_firstRead;
-
-	// This was a uint8_t - was there a reason?
-	char szBuffer[MaxPPSReadSize + 1];
-	int bufferLen;
-
-	// Read from the actual PPS file - this call is not blocking
-	while ((bufferLen = ::read(m_fd, szBuffer, MaxPPSReadSize)) > 0) {
-
-		if (bufferLen <= MaxPPSReadSize) {
-
-			// Make sure the buffer is null terminated.
-			szBuffer[bufferLen] = '\0';
-
-			std::string buf(szBuffer, bufferLen);
-			std::ostringstream ostream;
-			ostream << "PPSInterface::readFromObject() - fd:" << m_fd << " len:" << bufferLen << "\n" << buf;
-			m_logger.slog(Logger::debug, ostream.str());
-
-			// Parse the PPS data
-			ppsObject parsedPPS = parsePPSData(szBuffer);
-
-			// Update the cache with the data we just read
-			updateCachedReadData(parsedPPS);
-
-			// If this is the first read, then send the first read event.
-			if (sendFirstReadEvent) {
-
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", parsedPPS));
-				sendFirstReadEvent = false;
-			}
-			else {
-
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_NEW_DATA, "", parsedPPS));
-			}
-		}
-		else {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::readFromObject() Failed - fd:" << m_fd << " oversized message len:" << bufferLen << ".";
-			m_logger.slog(Logger::warning, ostream.str());
-		}
-	}
-
-	if (bufferLen == -1) {
-
-		std::ostringstream ostream;
-		ostream << "PPSInterface::readFromObject() Failed - Error reading from fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-		m_logger.slog(Logger::warning, ostream.str());
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
-	}
-
-	// It's possible that we won't go into the while() loop above (sometimes the first read is legitimately empty)
-	// in which case, we still need to send a first read complete event
-	if (sendFirstReadEvent) {
-
-		// Send an empty first read object
-		sendEvent(PPSEvent(PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE, "", ppsObject()));
-		sendFirstReadEvent = false;
-	}
-}
-
-void PPSInterface::sendEvent(const PPSEvent& event) const
-{
-	if (m_pEventFunc) {
-		m_pEventFunc(m_pEventArg, event);
-	}
-}
-
-PPSInterface* const PPSInterface::getPPSInterface(const unsigned int id)
-{
-	::pthread_mutex_lock(&sm_mutex);
-
-	std::map<unsigned int, PPSInterface*>::iterator it = sm_interfaceLookupTable.find(id);
-
-	if (it != sm_interfaceLookupTable.end()) {
-
-		::pthread_mutex_unlock(&sm_mutex);
-		return (*it).second;
-	}
-
-	::pthread_mutex_unlock(&sm_mutex);
-	return NULL;
-}
-
-ppsObject PPSInterface::parsePPSData(char* data) const
-{
-	// This is the structure that will contain parsed data for each line of the PPS object
-	// It needs to be initialized to NULL
-	pps_attrib_t info;
-	std::memset(&info, 0, sizeof(info));
-
-	// The return code for each PPS line that gets parsed
-	pps_status_t rc;
-	ppsObject ppsObj;
-
-	while ((rc = ::ppsparse(&data, NULL, NULL, &info, 0)) != PPS_END) {
-
-		if (rc == -1) {
-
-			std::ostringstream ostream;
-			ostream << "PPSInterface::parsePPSData() Failed - Error calling ppsparse() fd:" << m_fd << " (" << errno << ": " << strerror(errno) << ")";
-			m_logger.slog(Logger::warning, ostream.str());
-			sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, ostream.str()));
-		}
-
-		if (info.flags & PPS_INCOMPLETE) {
-			m_logger.slog(Logger::debug, "PPSInterface::parsePPSData - PPS data incomplete.");
-		}
-
-		switch (rc) {
-
-			// When the object has been modified, update the object settings
-			case PPS_OBJECT:
-			case PPS_OBJECT_CREATED:
-			case PPS_OBJECT_DELETED:
-			case PPS_OBJECT_TRUNCATED:
-			{
-				ppsObj.name = info.obj_name;
-				ppsObj.flags = info.flags;
-				ppsObj.options = info.options;
-				ppsObj.optionMask = info.option_mask;
-				break;
-			}
-
-			// An attribute has been updated
-			case PPS_ATTRIBUTE:
-			case PPS_ATTRIBUTE_DELETED:
-			{
-				ppsAttribute ppsAttrib;
-				ppsAttrib.name = info.attr_name;
-
-				// Value and encoding aren't valid if rc == PPS_ATTRIBUTE_DELETED
-				if (rc == PPS_ATTRIBUTE) {
-
-					ppsAttrib.value = info.value;
-					ppsAttrib.encoding = info.encoding;
-				}
-
-				ppsAttrib.flags = info.flags;
-				ppsAttrib.options = info.options;
-				ppsAttrib.optionMask = info.option_mask;
-
-				ppsObj.attributes.insert(ppsAttrPair(ppsAttrib.name, ppsAttrib));
-				break;
-			}
-
-			case PPS_ERROR:
-			{
-				std::string msg("PPSInterface::parsePPSData() Failed - Error parsing PPS data.");
-				m_logger.slog(Logger::warning, msg);
-				sendEvent(PPSEvent(PPSEvent::PPS_EVENT_READ_FAILED, msg));
-				break;
-			}
-
-			case PPS_END:
-			default:
-				break;
-		}
-
-	}
-
-	return ppsObj;
-}
-
-void PPSInterface::updateCachedReadData(const ppsObject& newData)
-{
-	::pthread_mutex_lock(&sm_mutex);
-
-	// Update the object
-	m_cachedRead.name = newData.name;
-	m_cachedRead.flags = newData.flags;
-	m_cachedRead.options = newData.options;
-	m_cachedRead.optionMask = newData.optionMask;
-
-	::pthread_mutex_unlock(&sm_mutex);
-
-	// Update the attributes
-	for (const_ppsAttrIter it = newData.attributes.begin(); it != newData.attributes.end(); it++) {
-
-		ppsAttribute attr = (*it).second;
-
-		// An attribute is being deleted
-		if (attr.flags & PPS_DELETED) {
-
-			::pthread_mutex_lock(&sm_mutex);
-
-			// Look for this attribute in the cache and remove it
-			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
-
-			if (findIt != m_cachedRead.attributes.end()) {
-				m_cachedRead.attributes.erase(findIt);
-			}
-
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-		// We're adding a new attribute - don't search for it
-		else if (attr.flags & PPS_CREATED){
-
-			::pthread_mutex_lock(&sm_mutex);
-			m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-		else {
-
-			::pthread_mutex_lock(&sm_mutex);
-
-			// Look for this attribute in the cache
-			ppsAttrIter findIt = m_cachedRead.attributes.find(attr.name);
-
-			// If we find it, update the attribute values
-			if (findIt != m_cachedRead.attributes.end()) {
-
-				(*findIt).second.name = attr.name;
-				(*findIt).second.encoding = attr.encoding;
-				(*findIt).second.value = attr.value;
-				(*findIt).second.flags = attr.flags;
-				(*findIt).second.options = attr.options;
-				(*findIt).second.optionMask = attr.optionMask;
-			}
-			// If we don't find it, insert it
-			else {
-				m_cachedRead.attributes.insert(ppsAttrPair(attr.name, attr));
-			}
-			::pthread_mutex_unlock(&sm_mutex);
-		}
-	}
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
deleted file mode 100644
index 0fde80c..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSInterface.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPS_H_
-#define PPS_H_
-
-#include <string>
-#include <map>
-
-#include <sys/types.h>
-
-#include "PPSTypes.h"
-#include "PPSEvent.h"
-#include "../utils/Logger.h"
-
-namespace jpps {
-
-/**
- * This class augments standard PPS functionality by providing events for when PPS objects are opened,
- * closed, have new data, etc.
- *
- * When a PPS object is opened using PPSInterface::open(), the object is opened as part of a notification group
- * managed by PPSNotifyGroupManager. The notification group monitors the PPS object and notifies PPSInterface
- * whenever there is new data available in the PPS object.
- *
- * PPSInterface should be used in order to simplify PPS object monitoring (i.e. watching for new data in a PPS
- * object.) PPSInterface takes over management of watching for new data and uses a notification callback mechanism
- * with a defined set of possible events to inform the client of changes to the PPS object.
- */
-class PPSInterface {
-
-public:
-
-	/**
-	 * Used with onNotify to allow the PPSNotifier to tell us what type of notification
-	 * message it is sending.
-	 */
-	enum NotifyType {
-		/** The .notify object received a notification that data is ready to be read. */
-		PPS_READ = 0,
-		/** The .notify object received a notification that a file being watched is closing. */
-		PPS_CLOSE = 1 };
-
-	/**
-	 * Constructor.
-	 */
-	PPSInterface();
-
-	/**
-	 * Destructor.
-	 */
-	~PPSInterface();
-
-	/**
-	 * Set up a function to call to be notified about PPS events.
-	 *
-	 * @param pEventFunc The function to call whenever an event happens in PPSInterface.
-	 * @param pArg An optional parameter that will be passed back to pEventFunc every time it
-	 * is called. PPSInterface will not modify pArg.
-	 */
-	void setEventFunc(const PPSEventFunc* pEventFunc, void* pArg = NULL);
-
-	/**
-	 * Enable verbose mode. Increase the number of �v�s to increase verbosity.
-	 *
-	 * @param v The level of verbosity. A value of 0 is off, 1 shows info messages, 2 shows
-	 * debug messages.
-	 */
-	void setVerbose(unsigned short v);
-
-	/**
-	 * Open a PPS object. If the open() call is successful, a PPS_EVENT_OPENED event will be sent.
-	 * The PPS object will be read as part of the open operation and the PPS_EVENT_FIRST_READ_COMPLETE
-	 * will be sent when the first read is complete. Note that there may be a PPS_EVENT_NEW_DATA
-	 * event *before* the PPS_EVENT_FIRST_READ_COMPLETE event, or there may not be.
-	 * PPS_EVENT_FIRST_READ_COMPLETE only guarantees that at least one read has been performed, not
-	 * that it will be the first read event to fire.
-	 *
-	 * If the open operation fails, the function returns false and a PPS_EVENT_OPEN_FAILED will be sent.
-	 *
-	 * @param path The PPS file/directory path.
-	 * @param oflags Flags passed to ::open.
-	 * @param mode Mode passed to ::open.
-	 * @param serverMode If true, open the object in server mode as the server.
-	 * @return True if the open was successful, false otherwise.
-	 */
-	bool open(const std::string& path, int oflags, int mode, bool serverMode);
-
-	/**
-	 * Check if this PPS object is open.
-	 * @return True if the file is open, false otherwise.
-	 */
-	inline bool isOpen() const { return m_fd >= 0; }
-
-	/**
-	 * Write data to a PPS object.
-	 * @param data The data to write to the PPS object.
-	 */
-	void write(const std::string& data);
-
-	/**
-	 * Read PPS data. Note that this reads cached data from the last read performed when a
-	 * new data available notification was received.
-	 *
-	 * @return A structured representation of the PPS object, culled from a call to ppsparse()
-	 * a function found in ppsparse.h.
-	 */
-
-	inline ppsObject read() const { return m_cachedRead; }
-
-	/**
-	 * Close this PPS object.
-	 */
-	void close();
-
-	/**
-	 * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
-	 * The function blocks until this is finished.
-	 */
-	void sync();
-
-	/**
-	 * Called to notify us that there is data ready to be read.
-	 *
-	 * @param event The type of event we're being notified about.
-	 */
-	void onNotify(NotifyType event);
-
-	/**
-	 * Given a unique id, return the PPSInterface* matching that id.
-	 *
-	 * Every PPSInterface object is assigned a unique identifier at construction. This
-	 * unique identifier can be used to get a pointer to a PPSInterface at runtime.
-	 *
-	 * In particular, the PPSNotifier gets notifications with this number embedded in them.
-	 * Using this id, the PPSNotifier can callback into the correct PPSInterface instance.
-	 *
-	 * @param id An id that uniquely identifies a PPSInterface object.
-	 * @return a PPSInterface* or NULL if no object matches the given id.
-	 */
-	static PPSInterface* const getPPSInterface(const unsigned int id);
-
-private:
-
-	/**
-	 * Read from the PPS object. Generally this function is called by onNotify() when
-	 * the notifier thread is notified that there is data to be read. This function
-	 * performs a read() of the PPS object that is non-blocking.
-	 */
-	void readFromObject();
-
-	/**
-	 * Given data from a PPS read, parse the PPS data.
-	 */
-	ppsObject parsePPSData(char* data) const;
-
-	/**
-	 * Given new PPS data, update the cached read value.
-	 */
-	void updateCachedReadData(const ppsObject& newData);
-
-	/**
-	 * Call the function set in setEventFunc() with the given event.
-	 *
-	 * @param event The event to send.
-	 */
-	void sendEvent(const PPSEvent& event) const;
-
-	/** The default PPS location. */
-	static const char* PPS_ROOT;
-
-	/** The maximum amount of data that can be read from a PPS object. */
-	static const int MaxPPSReadSize;
-
-	/** The function to call to notify about PPS events. */
-	PPSEventFunc* m_pEventFunc;
-
-	/** An argument that goes with m_pEventFunc. PPSInterface does not modify or use
-	 * this parameter - we simply send it back with every m_pEventFunc call. */
-	void* m_pEventArg;
-
-	/** An identifier that uniquely identifies this PPSInterface object. This is used to look up
-	 * this object in a global table. */
-	unsigned int m_interfaceId;
-
-	/** The file descriptor of the PPS object being opened. */
-	int m_fd;
-
-	/** The open mode flags used when this object was opened. */
-	int m_oflags;
-
-	/** If true, main thread is performing initial open/read of PPS object. This is shared
-	 * across threads and needs to be mutexed when accessed.*/
-	volatile bool m_firstRead;
-
-	/** The data from the last read performed. */
-	ppsObject m_cachedRead;
-
-	/** The logger used to log error messages */
-	Logger m_logger;
-
-	/** Mutex used to prevent threads from clobbering each other. */
-	static pthread_mutex_t sm_mutex;
-
-	/** Condvar used for multi-thread signaling. */
-	static pthread_cond_t sm_cond;
-
-	/** Used to ensure that initialization of statics happens only once. This is shared
-	 * across threads and needs to be mutexed when accessed.*/
-	static volatile bool sm_firstInitDone;
-
-	/** The PPSNotifier needs a way to transform an id that uniquely identifies a PPSInterface object
-	 * into an actual PPSInterface*. When we construct a new PPSInterface, we will assign it a unique id
-	 * and we will put the id and the pointer to the object into this table. The table can then be used
-	 * to lookup this object from its unique id. */
-	static std::map<unsigned int, PPSInterface*> sm_interfaceLookupTable;
-};
-
-} /* namespace jpps */
-#endif /* PPS_H_ */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
deleted file mode 100644
index 7869a56..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSNotifier.h"
-
-#include <sstream>
-
-#include <fcntl.h>
-
-#include "PPSInterface.h"
-#include "../utils/Logger.h"
-
-namespace jpps {
-
-PPSNotifier::PPSNotifier()
-: m_notifyObjPath("")
-, m_notifyObjFd(-1)
-, m_notifyGroupId("")
-, m_thread()
-{
-
-}
-
-PPSNotifier::~PPSNotifier()
-{
-	// Stop the thread
-	m_thread.stop();
-
-	// Close the .notify file
-	if (m_notifyObjFd >= 0) {
-		::close(m_notifyObjFd);
-	}
-}
-
-void PPSNotifier::startNotifyLoop()
-{
-	m_thread.start(_notifyLoop, this, "plugin_jPPS_PPSNotifier(" + m_notifyObjPath + "/.notify)");
-}
-
-
-void* PPSNotifier::_notifyLoop(void* pArg)
-{
-	// Something is messed up
-	if (pArg == NULL)
-		return NULL;
-
-	PPSNotifier* pNotifier = static_cast<PPSNotifier*> (pArg);
-
-	// pArg is supposed to be a PPSNotifier object...
-	if (pNotifier == NULL)
-		return NULL;
-
-	pNotifier->notifyLoop();
-
-	return NULL;
-}
-
-void PPSNotifier::notifyLoop()
-{
-	// Buffer for read() operation
-	char szData[256];
-	int dataLen;
-
-	// This is a blocking read call: this will wait in this loop forever
-	while ((dataLen = ::read(m_notifyObjFd, szData, sizeof(szData)-1)) > 0) {
-
-                szData[dataLen] = '\0';
-		std::string data(szData);
-
-		if ((unsigned int)dataLen > sizeof(szData)-1) {
-
-			std::ostringstream ostream;
-			ostream << "PPSNotifier::notifyLoop() - Notify read overflow " << dataLen << ".";
-			Logger logger;
-			logger.slog(Logger::error, ostream.str());
-		}
-
-		std::size_t nPos = data.find('\n');
-
-		// While we find linefeeds
-		while(nPos != std::string::npos) {
-
-			// Read the first char
-			PPSInterface::NotifyType event = data[0] == '-' ? PPSInterface::PPS_CLOSE : PPSInterface::PPS_READ;
-			std::size_t nAddrPos = data.find(':');
-
-			if (nAddrPos != std::string::npos) {
-
-				std::string sAddress = data.substr(nAddrPos+1);
-				std::size_t nAddrEnd = sAddress.find('\n');
-
-				if (nAddrEnd != std::string::npos) {
-
-					sAddress = sAddress.substr(0, nAddrEnd);
-
-					unsigned int interfaceId = 0;
-
-					std::stringstream ss;
-					ss << sAddress;
-					ss >> interfaceId;
-
-					PPSInterface* const pPPS = PPSInterface::getPPSInterface(interfaceId);
-
-					if (pPPS) {
-						pPPS->onNotify(event);
-					}
-				}
-			}
-
-			// Don't go off the end of the string
-			if (++nPos < data.length()) {
-
-				// Remove the stuff up to the first '\n' and look for the next '\n'
-				data = data.substr(nPos);
-				nPos = data.find('\n');
-			}
-			else {
-
-				nPos = std::string::npos;
-			}
-		}
-	}
-}
-
-} /* namespace jpps */

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
deleted file mode 100644
index 143f052..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifier.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software.   Free development
- * licenses are available for evaluation and non-commercial purposes.  For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others.  Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSNOTIFIER_H_
-#define PPSNOTIFIER_H_
-
-#include <string>
-
-#include "../utils/Thread.h"
-
-namespace jpps {
-
-/**
- * PPSNotifier is an encapsulation of an open PPS .notify object. PPSNotifier has a
- * blocking thread dedicated to reading from its .notify object. The thread constantly
- * waits for new notifications in the .notify object.
- *
- * The way the PPS notify mechanism works is that on the first open/read of a .notify object,
- * PPS provides a notify group id. This group id can be used when opening any PPS object to make
- * the PPS object join the notify group.
- *
- * For example, you open a .notify file and the group id returned is "2a3".
- * You subsequently open a PPS object and make it join that notify group:
- *
- * ::open("/pps/myppsobj?notify=2a3:someUniqueValueIDecide");
- *
- * Now, every time myppsobj changes, the .notify file will be updated in the following manner:
- *
- * <code>Notify 2a3:someUniqueValueIDecide</code>
- *
- * For a change to the file. And
- *
- * <code>-2a3:someUniqueValueIDecide</code>
- *
- * if myppsobj is closed.
- *
- * When PPSNotifier reads a notification, the unique value is actually a unique identifier for a
- * PPSInterface object that can be looked up in a global PPSInterface lookup table. Getting the
- * PPSInterface object designated by the unique identifier, PPSNotifier calls PPSInterface::onNotify()
- * to inform the PPSInterface object that there is new data pending or that the file has closed.
- * It is then up to the PPSInterface to decide how to proceed to get that data from myppsobj.
- */
-class PPSNotifier {
-
-public:
-
-	/**
-	 * Constructor.
-	 */
-	PPSNotifier();
-
-	/**
-	 * Destructor. Note that this destructor will attempt to close the .notify
-	 * object's file.
-	 */
-	virtual ~PPSNotifier();
-
-	/**
-	 * Start the notify thread.
-	 */
-	void startNotifyLoop();
-
-	/**
-	 * Get the .notify object's path.
-	 *
-	 * @return The path to the .notify object.
-	 */
-	inline std::string getNotifyObjPath() const { return m_notifyObjPath; }
-
-	/**
-	 * Set the .notify object's path.
-	 *
-	 * @param path The path of the .notify object (note that this should not include the
-	 * .notify object name).
-	 */
-	inline void setNotifyOjbPath(const std::string& path) { m_notifyObjPath = path; }
-
-	/**
-	 * Get the .notify object's file descriptor.
-	 *
-	 * @return The file descriptor for the open .notify object.
-	 */
-	inline int getObjFd() const { return m_notifyObjFd; }
-
-	/**
-	 * Set the .notify object's file descriptor.
-	 *
-	 * @param The file descriptor for the open .notify object.
-	 */
-	inline void setObjFd(const int fd) { m_notifyObjFd = fd; }
-
-	/**
-	 * Set this notifier's .notify group ID (assigned by PPS).
-	 *
-	 * @param The .notify object's group ID, which is returned by PPS on the first read
-	 * of the .notify object.
-	 */
-	inline std::string getNotifyGroupId() const { return m_notifyGroupId; }
-
-	/**
-	 * Get this notifier's .notify group ID (assigned by PPS).
-	 *
-	 * @return The .notify object's group ID.
-	 */
-	inline void setNotifyGroupId(const std::string& id) { m_notifyGroupId = id; }
-
-private:
-
-	// Disable the copy constructor
-	PPSNotifier(const PPSNotifier& manager);
-
-	// Disable the assignment operator
-	PPSNotifier& operator=(const PPSNotifier& rhs);
-
-	/**
-	 * Function used to start the thread. Pass this into the Thread::start() function.
-	 *
-	 * @param pArg A pointer to a PPSNotifier.
-	 */
-	static void* _notifyLoop(void* pArg);
-
-	/**
-	 * The main thread loop. Blocks on reading the .notify file.
-	 */
-	void notifyLoop();
-
-	/** The path of the .notify file we're monitoring to know when to get data. */
-	std::string m_notifyObjPath;
-
-	/** The file descriptor of the .notify file we're monitoring to know when to get data. */
-	int m_notifyObjFd;
-
-	/** The .notify group ID assigned by PPS when the group was created. */
-	std::string m_notifyGroupId;
-
-	/** The thread I'm running on. */
-	Thread m_thread;
-};
-
-} /* namespace jpps */
-#endif /* PPSNOTIFIER_H_ */


[30/50] [abbrv] webworks commit: Updating config.xml to remove the id field of the widget that prevents packaging on playbook

Posted by lo...@apache.org.
Updating config.xml to remove the id field of the widget that prevents packaging on playbook


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

Branch: refs/heads/future
Commit: d0742f560d7370433f62b058988a6805744cc86d
Parents: 4255d17
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Wed Apr 17 14:27:49 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:31 2013 -0400

----------------------------------------------------------------------
 blackberry/bin/templates/project/www/config.xml |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/d0742f56/blackberry/bin/templates/project/www/config.xml
----------------------------------------------------------------------
diff --git a/blackberry/bin/templates/project/www/config.xml b/blackberry/bin/templates/project/www/config.xml
index 0de8bb5..0dc6aaa 100644
--- a/blackberry/bin/templates/project/www/config.xml
+++ b/blackberry/bin/templates/project/www/config.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- 
+<!--
        Licensed to the Apache Software Foundation (ASF) under one
        or more contributor license agreements.  See the NOTICE file
        distributed with this work for additional information
@@ -24,7 +24,7 @@
 
 <widget xmlns="http://www.w3.org/ns/widgets"
         xmlns:rim="http://www.blackberry.com/ns/widgets"
-	version="1.0.0.0" id="__PACKAGE__">
+	version="1.0.0.0">
 
   <name>__NAME__</name>
 
@@ -33,7 +33,7 @@
   <description>
        A sample Apache Cordova application that responds to the deviceready event.
   </description>
-    
+
   <license href="http://opensource.org/licenses/alphabetical">
   </license>
 
@@ -65,7 +65,7 @@
   <feature id="blackberry.invoked" />
   <feature id="blackberry.push" />
   <feature id="blackberry.media.microphone" required="true" version="1.0.0.0"/>
-  
+
   <!-- Cordova API -->
   <access subdomains="true" uri="file:///store/home" />
   <access subdomains="true" uri="file:///SDCard" />
@@ -89,8 +89,8 @@
     <rim:permit>read_device_identifying_information</rim:permit>
     <rim:permit>access_shared</rim:permit>
     <rim:permit>read_geolocation</rim:permit>
-    <rim:permit>record_audio</rim:permit> 
-    <rim:permit>access_pimdomain_contacts</rim:permit> 
+    <rim:permit>record_audio</rim:permit>
+    <rim:permit>access_pimdomain_contacts</rim:permit>
   </rim:permissions>
 
 </widget>


[43/50] [abbrv] webworks commit: Added fix to use commandline keystorepass

Posted by lo...@apache.org.
Added fix to use commandline keystorepass

Reviewed by: Bryan Higgins <bh...@blackberry.com>
Tested by: Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/94fa3ffd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/94fa3ffd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/94fa3ffd

Branch: refs/heads/future
Commit: 94fa3ffdb349e647faa9a3a555374d919a8d30e9
Parents: 5fdf5b0
Author: DanielAudino <da...@blackberry.com>
Authored: Wed Apr 24 13:04:12 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/build        |    3 ++-
 .../project/cordova/lib/debugtoken-helper.js       |    6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/94fa3ffd/blackberry10/bin/templates/project/cordova/lib/build
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/build b/blackberry10/bin/templates/project/cordova/lib/build
index 81e7dd6..bee735c 100644
--- a/blackberry10/bin/templates/project/cordova/lib/build
+++ b/blackberry10/bin/templates/project/cordova/lib/build
@@ -45,9 +45,10 @@ function copyArgIfExists(arg) {
 }
 
 function createDebugtoken(previous, baton) {
+    var keystorepass = command["keystorepass"] ? command["keystorepass"] : projectProperties.keystorepass;
     baton.take();
     logger.info(localize.translate("PROGRESS_WILL_CREATE_DEBUG_TOKEN"));
-    debugTokenHelper.createToken(projectProperties, getTarget(), function (code) {
+    debugTokenHelper.createToken(projectProperties, getTarget(), keystorepass, function (code) {
         if (code === 0) {
             debugtoken = true;
         }

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/94fa3ffd/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
index 8a936b1..791973c 100755
--- a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -130,7 +130,7 @@ function deployTokenToTargetsRecursively() {
     }
 }
 
-self.createToken = function (projectProperties, target, callback) {
+self.createToken = function (projectProperties, target, keystorepass, callback) {
     var pins = [],
         key;
 
@@ -159,7 +159,7 @@ self.createToken = function (projectProperties, target, callback) {
         if (callback && typeof callback === "function") {
             callback(-1);
         }
-    } else if (!properties.keystorepass) {
+    } else if (!keystorepass) {
         logger.warn(localize.translate("WARN_NO_SIGNING_PASSWORD_PROVIDED"));
         if (callback && typeof callback === "function") {
             callback(-1);
@@ -168,7 +168,7 @@ self.createToken = function (projectProperties, target, callback) {
         logger.info(localize.translate("PROGRESS_GENERATING_DEBUG_TOKEN"));
         // Call "blackberry-debugtokenrequest" to generate debug token
         execNativeScript("/bin/blackberry-debugtokenrequest",
-            generateCreateTokenOptions(pins, properties.keystorepass),
+            generateCreateTokenOptions(pins, keystorepass),
             callback
         );
     }


[39/50] [abbrv] webworks commit: Update config.xml for splash screen and icons

Posted by lo...@apache.org.
Update config.xml for splash screen and icons

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/961bdf4e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/961bdf4e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/961bdf4e

Branch: refs/heads/future
Commit: 961bdf4e34b1af025f36ae22ef37d3adb92fea9c
Parents: 5dad31c
Author: DanielAudino <da...@blackberry.com>
Authored: Mon Apr 29 15:37:40 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:32 2013 -0400

----------------------------------------------------------------------
 .../templates/project/cordova/lib/config-parser.js |    1 +
 blackberry10/bin/templates/project/www/config.xml  |   12 ++++--------
 .../www/res/screen/blackberry/screen-225.png       |  Bin 16776 -> 0 bytes
 .../www/res/screen/blackberry/splash-1280x768.png  |  Bin 0 -> 60771 bytes
 .../www/res/screen/blackberry/splash-720x720.png   |  Bin 0 -> 50431 bytes
 .../www/res/screen/blackberry/splash-768x1280.png  |  Bin 0 -> 57145 bytes
 6 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/cordova/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/config-parser.js b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
index 15d6281..0e3d9e9 100644
--- a/blackberry10/bin/templates/project/cordova/lib/config-parser.js
+++ b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
@@ -149,6 +149,7 @@ function processWidgetData(data, widgetConfig, session) {
     widgetConfig.autoOrientation = true;
     widgetConfig.autoDeferNetworkingAndJavaScript = true;
     widgetConfig.theme = "default";
+    widgetConfig.autoHideSplashScreen = "true";
 
     //set locally available features to access list
    if (data.feature) {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/www/config.xml
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/config.xml b/blackberry10/bin/templates/project/www/config.xml
index 6e0d3c3..3edc941 100644
--- a/blackberry10/bin/templates/project/www/config.xml
+++ b/blackberry10/bin/templates/project/www/config.xml
@@ -42,14 +42,10 @@
   <access subdomains="true" uri="file:///SDCard" />
   <access subdomains="true" uri="*" />
 
-  <icon rim:hover="false" src="res/icon/blackberry/icon-80.png" />
-  <icon rim:hover="true" src="res/icon/blackberry/icon-80.png" />
-
-  <rim:loadingScreen backgroundColor="#CFCFCF"
-                     foregroundImage="res/screen/blackberry/screen-225.png"
-		     onFirstLaunch="true">
-    <rim:transitionEffect type="fadeOut" />
-  </rim:loadingScreen>
+  <icon src="res/icon/blackberry/icon-80.png" />
+  <rim:splash src="res/screen/blackberry/splash-1280x768.png" />
+  <rim:splash src="res/screen/blackberry/splash-720x720.png" />
+  <rim:splash src="res/screen/blackberry/splash-768x1280.png" />
 
   <content src="index.html" />
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/www/res/screen/blackberry/screen-225.png
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/res/screen/blackberry/screen-225.png b/blackberry10/bin/templates/project/www/res/screen/blackberry/screen-225.png
deleted file mode 100644
index 29873e9..0000000
Binary files a/blackberry10/bin/templates/project/www/res/screen/blackberry/screen-225.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-1280x768.png
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-1280x768.png b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-1280x768.png
new file mode 100644
index 0000000..5f4bca9
Binary files /dev/null and b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-1280x768.png differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-720x720.png
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-720x720.png b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-720x720.png
new file mode 100644
index 0000000..fe1756f
Binary files /dev/null and b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-720x720.png differ

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/961bdf4e/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-768x1280.png
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-768x1280.png b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-768x1280.png
new file mode 100644
index 0000000..0fb9c1b
Binary files /dev/null and b/blackberry10/bin/templates/project/www/res/screen/blackberry/splash-768x1280.png differ


[27/50] [abbrv] webworks commit: Updating PluginResult to add a getter for the callbackId.

Posted by lo...@apache.org.
Updating PluginResult to add a getter for the callbackId.

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/860544e0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/860544e0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/860544e0

Branch: refs/heads/future
Commit: 860544e08a5a8543e4ec8553c5df84f314d86e7d
Parents: 0d59102
Author: Jeffrey Heifetz <jh...@rim.com>
Authored: Thu Apr 4 13:42:34 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 blackberry10/framework/lib/PluginResult.js |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/860544e0/blackberry10/framework/lib/PluginResult.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/PluginResult.js b/blackberry10/framework/lib/PluginResult.js
index 7cae945..c3e999c 100644
--- a/blackberry10/framework/lib/PluginResult.js
+++ b/blackberry10/framework/lib/PluginResult.js
@@ -19,15 +19,18 @@ function PluginResult (args, env) {
     var CALLBACK_STATUS_NO_RESULT = 0,
         CALLBACK_STATUS_OK = 1,
         CALLBACK_STATUS_ERROR = 9,
+        callbackId = JSON.parse(decodeURIComponent(args.callbackId)),
         send = function (data) {
             env.response.send(200, encodeURIComponent(JSON.stringify(data)));
         },
         callback = function (success, status, data, keepCallback) {
-            var executeString = "cordova.callbackFromNative(" + decodeURIComponent(args.callbackId) +
-                ", " + !!success + ", " + status + ", " + data + ", " + !!keepCallback + ");";
+            var executeString = "cordova.callbackFromNative('" + callbackId  + "', " +
+                !!success + ", " + status + ", " + data + ", " + !!keepCallback + ");";
             env.webview.executeJavaScript(executeString);
         };
 
+    Object.defineProperty(this, "callbackId", {enumerable: true, value: callbackId});
+
     this.noResult = function (keepCallback) {
         send({ code: CALLBACK_STATUS_NO_RESULT, keepCallback: !!keepCallback });
     };


[05/50] [abbrv] webworks commit: fix cordova/clean

Posted by lo...@apache.org.
fix cordova/clean

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Bryan Higgins <bh...@blackberry.com>


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

Branch: refs/heads/future
Commit: ab134d02cb06c9afe9d3bb0055e57e994a588993
Parents: 66e3822
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Fri Apr 5 14:39:12 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/clean        |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ab134d02/blackberry10/bin/templates/project/cordova/lib/clean
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/clean b/blackberry10/bin/templates/project/cordova/lib/clean
index 429e79b..46391d3 100644
--- a/blackberry10/bin/templates/project/cordova/lib/clean
+++ b/blackberry10/bin/templates/project/cordova/lib/clean
@@ -20,5 +20,5 @@ var wrench = require('wrench'),
     path = require("path"),
     buildPath = path.normalize(__dirname + "/../../build/");
 
-   wrench.rmdirSyncRecursive(dirPath, true);
+   wrench.rmdirSyncRecursive(buildPath, true);
 


[50/50] [abbrv] webworks commit: Update cordova.blackberry10.js

Posted by lo...@apache.org.
Update cordova.blackberry10.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/42b066f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/42b066f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/42b066f6

Branch: refs/heads/future
Commit: 42b066f65d14a903e3ef9239de651a68f4a40c80
Parents: 812293a
Author: Bryan Higgins <br...@bryanhiggins.net>
Authored: Mon May 6 18:50:17 2013 -0400
Committer: Bryan Higgins <br...@bryanhiggins.net>
Committed: Mon May 6 18:50:17 2013 -0400

----------------------------------------------------------------------
 blackberry10/javascript/cordova.blackberry10.js |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/42b066f6/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 4f6b690..8a97433 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,6 +1,6 @@
 // Platform: blackberry10
-// 2.7.0rc1-36-g93152a0
-// File generated at :: Fri May 03 2013 09:51:02 GMT-0400 (EDT)
+// dev-ga2e3993
+// File generated at :: Mon May 06 2013 18:49:10 GMT-0400 (EDT)
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -20,7 +20,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-36-g93152a0';
+var CORDOVA_JS_BUILD_LABEL = 'dev-ga2e3993';
 // file: lib/scripts/require.js
 
 var require,
@@ -937,7 +937,7 @@ module.exports = {
         modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
 
         modulemapper.clobbers('cordova/plugin/blackberry10/vibrate', 'navigator.notification.vibrate');
-        modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
+        modulemapper.clobbers('cordova/plugin/File', 'File');
         modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
 
         modulemapper.mapModules(window);
@@ -6865,7 +6865,7 @@ document.addEventListener("DOMContentLoaded", function () {
         finishPluginLoading();
     };
     try { // we commented we were going to try, so let us actually try and catch
-        xhr.open('GET', 'cordova_plugins.json', true); // Async
+        xhr.open('GET', '/cordova_plugins.json', true); // Async
         xhr.send();
     } catch(err){
         finishPluginLoading();


[16/50] [abbrv] webworks commit: Adds new script: bin/check_reqs

Posted by lo...@apache.org.
Adds new script: bin/check_reqs

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Bryan Higgins <bh...@blackberry.com>


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

Branch: refs/heads/future
Commit: b0edce53577c3c066ed664a602bbfb90140863a0
Parents: 34ff4f1
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Mon Mar 25 16:02:02 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/check_reqs     |   28 ++++++++++++++++++++++++++++
 blackberry10/bin/check_reqs.bat |   21 +++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0edce53/blackberry10/bin/check_reqs
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs b/blackberry10/bin/check_reqs
new file mode 100755
index 0000000..9a8e9ee
--- /dev/null
+++ b/blackberry10/bin/check_reqs
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 qnxHost = process.env.QNX_HOST;
+
+if (typeof qnxHost !== "undefined" && typeof process.env.QNX_TARGET !== "undefined" && process.env.PATH.indexOf(qnxHost) !== -1) {
+    process.exit(0);
+} else {
+    process.exit(-1);
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b0edce53/blackberry10/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs.bat b/blackberry10/bin/check_reqs.bat
new file mode 100755
index 0000000..9c8986e
--- /dev/null
+++ b/blackberry10/bin/check_reqs.bat
@@ -0,0 +1,21 @@
+@ECHO OFF
+goto comment
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you 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.
+:comment
+
+@node.exe %~dp0\check_reqs


[48/50] [abbrv] webworks commit: Remove invalid test for js file copying at build time

Posted by lo...@apache.org.
Remove invalid test for js file copying at build time


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/4c29f284
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/4c29f284
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/4c29f284

Branch: refs/heads/future
Commit: 4c29f2844bc5cb41dd0c270b6525fc9d1e5a7b91
Parents: bf29f4c
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri May 3 17:35:07 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 17:35:07 2013 -0400

----------------------------------------------------------------------
 .../bin/test/cordova/unit/spec/lib/file-manager.js |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/4c29f284/blackberry10/bin/test/cordova/unit/spec/lib/file-manager.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/file-manager.js b/blackberry10/bin/test/cordova/unit/spec/lib/file-manager.js
index 363d625..68b60b8 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/file-manager.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/file-manager.js
@@ -47,7 +47,7 @@ describe("File manager", function () {
 
         expect(packager_utils.copyFile).toHaveBeenCalledWith(path.normalize(session.conf.DEPENDENCIES_BOOTSTRAP + "/wwe"), path.normalize(session.sourceDir));
     });
-
+/* TODO: this test needs to be re-written
     it("copyExtensions() should copy all .js files required by features listed in config.xml", function () {
         var session = testData.session,
             featureId = "Device",
@@ -85,7 +85,7 @@ describe("File manager", function () {
         expect(packager_utils.copyFile).toHaveBeenCalledWith(clientJS, toDir, apiDir);
         expect(packager_utils.copyFile).toHaveBeenCalledWith(subfolderJS, toDir, apiDir);
     });
-
+*/
     it("copyExtensions() should copy .so files required by features listed in config.xml", function () {
         var session = testData.session,
             extBasename = "app",


[20/50] [abbrv] webworks commit: Modifying device to account for API not existing on older versions of the OS and for errors with missing properties.

Posted by lo...@apache.org.
Modifying device to account for API not existing on older versions of the OS
and for errors with missing properties.

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/0d591024
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/0d591024
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/0d591024

Branch: refs/heads/future
Commit: 0d591024cab242cdfe4fb9797585dd68ac174465
Parents: 2fa00c4
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Thu Apr 11 11:28:02 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/Device/index.js  |   36 +++++++++++++-
 1 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/0d591024/blackberry10/bin/templates/project/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/index.js b/blackberry10/bin/templates/project/plugins/Device/index.js
index 41b454c..f4849f5 100644
--- a/blackberry10/bin/templates/project/plugins/Device/index.js
+++ b/blackberry10/bin/templates/project/plugins/Device/index.js
@@ -14,15 +14,45 @@
  * limitations under the License.
  */
 
+function getModelName () {
+    var modelName = window.qnx.webplatform.device.modelName;
+    //Pre 10.2 (meaning Z10 or Q10)
+    if (typeof modelName === "undefined") {
+        if (window.screen.height === 720 && window.screen.width === 720) {
+            modelName = "Q10";
+        } else if ((window.screen.height === 1280 && window.screen.width === 768) ||
+                   (window.screen.height === 768 && window.screen.width === 1280)) {
+            modelName = "Z10";
+        } else {
+            modelName = window.qnx.webplatform.deviceName;
+        }
+    }
+
+    return modelName;
+}
+
+function getUUID () {
+    var uuid = "";
+    try {
+        //Must surround by try catch because this will throw if the app is missing permissions
+        uuid = window.qnx.webplatform.device.devicePin;
+    } catch (e) {
+        //DO Nothing
+    }
+    return uuid;
+}
+
 module.exports = {
     getDeviceInfo: function (success, fail, args, env) {
         var result = new PluginResult(args, env),
+            modelName = getModelName(),
+            uuid = getUUID(),
             info = {
                 platform: "blackberry10",
                 version: window.qnx.webplatform.device.scmBundle,
-                model: window.qnx.webplatform.device.modelName,
-                name: window.qnx.webplatform.device.modelName, // deprecated: please use device.model
-                uuid: window.qnx.webplatform.device.devicePin,
+                model: modelName,
+                name: modelName, // deprecated: please use device.model
+                uuid: uuid,
                 cordova: "2.5.0"
             };
         result.ok(info);


[17/50] [abbrv] webworks commit: create integration tests

Posted by lo...@apache.org.
create integration tests

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/34ff4f18
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/34ff4f18
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/34ff4f18

Branch: refs/heads/future
Commit: 34ff4f18c86a8c3700199f65dd5a63c6d81d38a6
Parents: b4ee225
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Fri Mar 22 11:30:55 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/create.js                         |    4 +-
 .../bin/test/cordova/integration/create.js         |  158 +++++++++++++++
 .../bin/test/cordova/integration/target.js         |    3 -
 3 files changed, 160 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index 7a0950b..9b99435 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -141,7 +141,6 @@ var build,
             process.exit(1);
         }
         else {
-            console.log("Project creation complete!");
             process.exit();
         }
     }
@@ -156,7 +155,8 @@ var build,
                 .andThen(clean)
                 .andThen(copyJavascript)
                 .andThen(copyFilesToProject)
-                .andThen(updateProject);
+                .andThen(updateProject)
+                .andThen(clean);
 
             build.start(function (error) {
                 done(error);

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js
new file mode 100644
index 0000000..d193580
--- /dev/null
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -0,0 +1,158 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you 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 childProcess = require('child_process'),
+    tempFolder = '.tmp/',
+    appFolder = tempFolder + 'tempCordovaApp/',
+    projectFile = 'project.json',
+    wrench = require('wrench'),
+    fs = require('fs'),
+    flag = false,
+    _stdout = "",
+    _stderr = "";
+
+function executeScript(shellCommand) {
+    childProcess.exec(shellCommand, function (error, stdout, stderr) {
+        if (error) {
+            console.log("Error executing command: " + error);
+        }
+        _stdout = stdout.toString().trim();
+        _stderr = stderr.toString().trim();
+        flag = true;
+    });
+}
+
+describe("create tests", function () {
+    it("creates project", function () {
+        var project,
+            appIdRegExp = /id="default\.app\.id"/g;
+        executeScript("bin/create " + appFolder);
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(fs.existsSync(appFolder)).toEqual(true);
+            expect(fs.existsSync(appFolder + "/plugins")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/node_modules")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/lib")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/third_party")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/www")).toEqual(true);
+            expect(project.barName).toEqual("cordova-BB10-app");
+            expect(project.keystorepass).toEqual("password");
+            expect(project.defaultTarget).toEqual("");
+            expect(project.targets).toEqual({});
+            expect(fs.existsSync("./build")).toEqual(false);
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("sets appId", function () {
+        var configEt,
+            appIdRegExp = /id="com\.example\.bb10app"/g;
+        executeScript("bin/create " + appFolder + " com.example.bb10app");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("sets appId and barName", function () {
+        var project,
+            appIdRegExp = /id="com\.example\.bb10app"/g;
+        executeScript("bin/create " + appFolder + " com.example.bb10app bb10appV1");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(project.barName).toEqual("bb10appV1");
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("No args", function () {
+        executeScript("bin/create");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("You must give a project PATH");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Empty dir error", function () {
+        executeScript("bin/create ./");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("The project path must be an empty directory");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Invalid appId error", function () {
+        executeScript("bin/create " + appFolder + " 23.21#$");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Invalid barName error", function () {
+        executeScript("bin/create " + appFolder + " com.example.app %bad@bar^name");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters");
+            expect(_stderr).toEqual("");
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/test/cordova/integration/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/target.js b/blackberry10/bin/test/cordova/integration/target.js
index 62eab37..e948a87 100644
--- a/blackberry10/bin/test/cordova/integration/target.js
+++ b/blackberry10/bin/test/cordova/integration/target.js
@@ -46,9 +46,6 @@ describe("cordova/target tests", function () {
         });
         runs(function () {
             flag = false;
-            expect(fs.existsSync(appFolder)).toEqual(true);
-            expect(_stdout).toEqual("Project creation complete!");
-            expect(_stderr).toEqual("");
         });
     });
 


[28/50] [abbrv] webworks commit: Added SplashScreen plugin

Posted by lo...@apache.org.
Added SplashScreen plugin

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/991e4fdb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/991e4fdb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/991e4fdb

Branch: refs/heads/future
Commit: 991e4fdb71e4c38a4d413b7a7c7862d5b7886602
Parents: 860544e
Author: Rosa Tse <rt...@blackberry.com>
Authored: Wed Apr 10 23:38:22 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../templates/project/cordova/lib/config-parser.js |    7 +-
 .../project/plugins/SplashScreen/index.js          |   28 +++++
 .../bin/test/plugins/SplashScreen/index.js         |   82 +++++++++++++++
 blackberry10/framework/lib/webview.js              |   11 ++-
 4 files changed, 123 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/templates/project/cordova/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/config-parser.js b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
index 2282a81..15d6281 100644
--- a/blackberry10/bin/templates/project/cordova/lib/config-parser.js
+++ b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
@@ -516,9 +516,10 @@ function processNameAndDescription(data, widgetConfig) {
 }
 
 function processCordovaPreferences(data, widgetConfig) {
-    if (data.preferences) {
-        var preferences = processParamObj(data.preferences);
-        widgetConfig.packageCordovaJs = preferences.packageCordovaJs === "enable";
+    if (data.preference) {
+        var preference = processParamObj(data.preference);
+        widgetConfig.packageCordovaJs = preference.packageCordovaJs === "enable";
+        widgetConfig.autoHideSplashScreen = preference.AutoHideSplashScreen !== "false";
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/SplashScreen/index.js b/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
new file mode 100644
index 0000000..bd7e48c
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/SplashScreen/index.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 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 = {
+    show: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error("Not supported on platform", false);
+    },
+
+    hide: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.qnx.webplatform.getApplication().windowVisible = true;
+        result.ok(undefined, false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/bin/test/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/SplashScreen/index.js b/blackberry10/bin/test/plugins/SplashScreen/index.js
new file mode 100644
index 0000000..1dcccee
--- /dev/null
+++ b/blackberry10/bin/test/plugins/SplashScreen/index.js
@@ -0,0 +1,82 @@
+/*
+* Copyright 2013 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.
+*/
+describe("SplashScreen", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/SplashScreen/",
+        index,
+        mockedEnv = {
+            response: {
+                send: jasmine.createSpy()
+            }
+        },
+        mockedApplication = {
+            windowVisible: undefined
+        };
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+        mockedEnv.response.send.reset();
+    });
+
+    afterEach(function () {
+        index = null;
+        delete require.cache[require.resolve(_apiDir + "index")];
+    });
+    describe("show", function () {
+        beforeEach(function () {
+            GLOBAL.PluginResult = function (args, env) {};
+            GLOBAL.PluginResult.prototype.error = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls PluginResult.error if show is called", function () {
+            index.show();
+
+            expect(PluginResult.prototype.error).toHaveBeenCalledWith("Not supported on platform", false);
+        });
+    });
+
+    describe("hide", function () {
+        beforeEach(function () {
+            GLOBAL.window = {
+                qnx: {
+                    webplatform: {
+                        getApplication: function () {
+                            return mockedApplication;
+                        }
+                    }
+                }
+            };
+
+            GLOBAL.PluginResult = function (args, env) {};
+            GLOBAL.PluginResult.prototype.ok = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.window;
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls PluginResult.ok if hide is called", function () {
+            index.hide();
+
+            expect(mockedApplication.windowVisible).toBeTruthy();
+            expect(PluginResult.prototype.ok).toHaveBeenCalledWith(undefined, false);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/991e4fdb/blackberry10/framework/lib/webview.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/lib/webview.js b/blackberry10/framework/lib/webview.js
index 690fd1c..495dfbe 100644
--- a/blackberry10/framework/lib/webview.js
+++ b/blackberry10/framework/lib/webview.js
@@ -58,7 +58,12 @@ webview =
             _webviewObj.allowWebEvent("DialogRequested");
 
             _webviewObj.addEventListener("DocumentLoadFinished", function () {
-                window.qnx.webplatform.getApplication().windowVisible = true;
+                // show app window if auto hide splash screen is true, OR splash screen is not specified
+                // if auto hide is set to false explicitly but no splash screen is specified, should still show app window
+                // otherwise the app cannot be launched
+                if (config.autoHideSplashScreen || !config["rim:splash"]) {
+                    window.qnx.webplatform.getApplication().windowVisible = true;
+                }
             });
 
 
@@ -70,7 +75,9 @@ webview =
 
             // If content is not loaded, too bad open the visibility up.
             setTimeout(function () {
-                window.qnx.webplatform.getApplication().windowVisible = true;
+                if (config.autoHideSplashScreen || !config["rim:splash"]) {
+                    window.qnx.webplatform.getApplication().windowVisible = true;
+                }
             }, 2500);
         });
 


[49/50] [abbrv] webworks commit: Replace version in Device with dev

Posted by lo...@apache.org.
Replace version in Device with dev


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/812293a3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/812293a3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/812293a3

Branch: refs/heads/future
Commit: 812293a3eeddec3098e26585ab0d854e58eb0d4c
Parents: 4c29f28
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri May 3 17:43:56 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 17:47:22 2013 -0400

----------------------------------------------------------------------
 .../plugins/Device/src/blackberry10/index.js       |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/812293a3/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
index f4849f5..89a40e4 100644
--- a/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
+++ b/blackberry10/bin/templates/project/plugins/Device/src/blackberry10/index.js
@@ -53,7 +53,7 @@ module.exports = {
                 model: modelName,
                 name: modelName, // deprecated: please use device.model
                 uuid: uuid,
-                cordova: "2.5.0"
+                cordova: "dev"
             };
         result.ok(info);
     }


[26/50] [abbrv] webworks commit: Add full content of modules to frameworkModules.js

Posted by lo...@apache.org.
Add full content of modules to frameworkModules.js

Reviewed by Eric Li <el...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/2fa00c43
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/2fa00c43
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/2fa00c43

Branch: refs/heads/future
Commit: 2fa00c43bef0eda0ab199d9456fb032939f04ab8
Parents: 70152ad
Author: Jeffrey Heifetz <jh...@rim.com>
Authored: Wed Apr 3 14:23:08 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../templates/project/cordova/lib/file-manager.js  |   17 +++++++++++---
 1 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/2fa00c43/blackberry10/bin/templates/project/cordova/lib/file-manager.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/file-manager.js b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
index 3ce3f15..3f9e92b 100755
--- a/blackberry10/bin/templates/project/cordova/lib/file-manager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
@@ -134,7 +134,7 @@ function getModulesArray(dest, files, baseDir) {
 
         if (!fs.statSync(file).isDirectory()) {
             if (baseDir !== dest.EXT || !isExcluded(file)) {
-                modulesList.push(path.relative(path.normalize(dest.CHROME), file).replace(/\\/g, "/"));
+                modulesList.push({name: path.relative(path.normalize(dest.CHROME), file).replace(/\\/g, "/"), file: file});
             }
         }
     });
@@ -145,7 +145,8 @@ function getModulesArray(dest, files, baseDir) {
 function generateFrameworkModulesJS(session) {
     var dest = session.sourcePaths,
         modulesList = [],
-        modulesStr = "var frameworkModules = ",
+        modulesStr = "(function () { ",
+        frameworkModulesStr = "window.frameworkModules = [",
         libFiles = wrench.readdirSyncRecursive(dest.LIB),
         extFiles,
         extModules;
@@ -158,8 +159,16 @@ function generateFrameworkModulesJS(session) {
         modulesList = modulesList.concat(extModules);
     }
 
-    modulesStr += JSON.stringify(modulesList, null, "    ") + ";";
-    fs.writeFileSync(path.normalize(dest.CHROME + "/frameworkModules.js"), modulesStr);
+    modulesList.forEach(function (module, index) {
+        modulesStr += "define('" + module.name + "', function (require, exports, module) {\n" +
+                      fs.readFileSync(module.file, "utf-8") + "\n" +
+                      "});\n";
+        frameworkModulesStr += "'" + module.name + "'" +  (index !== modulesList.length-1 ? ", " : "");
+    });
+
+    modulesStr += "}());";
+    frameworkModulesStr += "];\n";
+    fs.writeFileSync(path.normalize(dest.CHROME + "/frameworkModules.js"), frameworkModulesStr + modulesStr);
 }
 
 function copyWWE(session, target) {


[19/50] [abbrv] webworks commit: Update cordova.js

Posted by lo...@apache.org.
Update cordova.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/4255d17b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/4255d17b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/4255d17b

Branch: refs/heads/future
Commit: 4255d17b492c6b5f773a2107dbd47f5e26d273e6
Parents: 991e4fd
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed Apr 17 11:30:45 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 blackberry10/javascript/cordova.blackberry10.js | 2511 +++++++-----------
 1 files changed, 974 insertions(+), 1537 deletions(-)
----------------------------------------------------------------------



[04/50] [abbrv] webworks commit: add execute permission to plugman create.js after copying node_modules

Posted by lo...@apache.org.
add execute permission to plugman create.js after copying node_modules

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/62a86408
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/62a86408
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/62a86408

Branch: refs/heads/future
Commit: 62a864080fee1287c8f8e37904b2824a0ae32bce
Parents: 6567f47
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Wed Mar 20 15:43:10 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 blackberry10/bin/create.js |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/62a86408/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index 737d9e2..1c8b814 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -108,6 +108,7 @@ var build,
         //copy node modules to cordova build directory
         wrench.mkdirSyncRecursive(project_path + "/cordova/node_modules", 0777);
         wrench.copyDirSyncRecursive(__dirname + modules_project_dir, project_path + "/cordova/node_modules");
+        fs.chmodSync(project_path + "/cordova/node_modules/plugman/plugman.js", 0755);
 
         //copy framework
         wrench.copyDirSyncRecursive(__dirname + framework_project_dir, project_path + "/cordova/framework");


[22/50] [abbrv] webworks commit: Add Accelerometer plugin

Posted by lo...@apache.org.
Add Accelerometer plugin

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/70152add
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/70152add
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/70152add

Branch: refs/heads/future
Commit: 70152adda6e020c41f0f56e7d7f133e1ec953cda
Parents: b3960ef
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Wed Mar 27 15:00:30 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/Accelerometer/index.js         |   45 ++++++++
 .../bin/test/plugins/Accelerometer/index.js        |   81 +++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   54 +++-------
 3 files changed, 144 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/70152add/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/index.js b/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
new file mode 100644
index 0000000..47abe42
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Accelerometer/index.js
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 callback;
+
+module.exports = {
+    start: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.removeEventListener("devicemotion", callback);
+        callback = function (motion) {
+            var info = {
+                x: motion.accelerationIncludingGravity.x,
+                y: motion.accelerationIncludingGravity.y,
+                z: motion.accelerationIncludingGravity.z,
+                timestamp: motion.timestamp
+            };
+            result.callbackOk(info, true);
+        };
+        window.addEventListener("devicemotion", callback);
+        result.noResult(true);
+    },
+    stop: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        window.removeEventListener("devicemotion", callback);
+        result.ok("removed");
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/70152add/blackberry10/bin/test/plugins/Accelerometer/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Accelerometer/index.js b/blackberry10/bin/test/plugins/Accelerometer/index.js
new file mode 100644
index 0000000..a016219
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Accelerometer/index.js
@@ -0,0 +1,81 @@
+/*
+* Copyright 2013 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.
+*/
+describe("Accelerometer", function () {
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Accelerometer/",
+        index,
+        callback,
+        result = {
+            ok: jasmine.createSpy(),
+            error: jasmine.createSpy(),
+            noResult: jasmine.createSpy(),
+            callbackOk: jasmine.createSpy()
+        },
+        motion = {
+            timestamp: 0,
+            accelerationIncludingGravity: {
+                x: 0,
+                y: 0,
+                z: 0
+            }
+        };
+
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+        GLOBAL.window = {
+            removeEventListener: jasmine.createSpy("removeEventListener spy"),
+            addEventListener: jasmine.createSpy("addEventListener spy").andCallFake(function (evt, cb) {
+                callback = cb;
+            })
+        };
+        GLOBAL.PluginResult = function () {
+            return result;
+        };
+    });
+
+    afterEach(function () {
+        index = null;
+        delete GLOBAL.window;
+        delete GLOBAL.PluginResult;
+    });
+
+    describe("start", function () {
+        it("calls noResult and keeps callbacks", function () {
+            index.start();
+            expect(window.addEventListener).toHaveBeenCalled();
+            expect(result.noResult).toHaveBeenCalledWith(true);
+        });
+
+        it("callback calls ok and keeps callbacks", function () {
+            callback(motion);
+            expect(result.callbackOk).toHaveBeenCalled();
+        });
+
+        it("does not call error if already started", function () {
+            index.start();
+            expect(window.removeEventListener).toHaveBeenCalled();
+            expect(window.addEventListener).toHaveBeenCalled();
+            expect(result.error).not.toHaveBeenCalled();
+        });
+    });
+
+    describe("stop", function () {
+        it("calls result ok", function () {
+            index.stop();
+            expect(window.removeEventListener).toHaveBeenCalled();
+            expect(result.ok).toHaveBeenCalledWith("removed");
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/70152add/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index b730b08..45f9aff 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit f9ac2930aa892422deff2be5a3b3b8f5e8f7edc0
+// commit c8e2a018e93036393bcf5e0edd855187e5c587c5
 
-// File generated at :: Mon Apr 08 2013 15:58:16 GMT-0400 (EDT)
+// File generated at :: Thu Apr 11 2013 16:14:07 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -31,17 +31,28 @@ var require,
     define;
 
 (function () {
-    var modules = {};
+    var modules = {},
     // Stack of moduleIds currently being built.
-    var requireStack = [];
+        requireStack = [],
     // Map of module ID -> index into requireStack of modules currently being built.
-    var inProgressModules = {};
+        inProgressModules = {},
+        SEPERATOR = ".";
+
+
 
     function build(module) {
-        var factory = module.factory;
+        var factory = module.factory,
+            localRequire = function (id) {
+                var resultantId = id;
+                //Its a relative path, so lop off the last portion and add the id (minus "./")
+                if (id.charAt(0) === ".") {
+                    resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
+                }
+                return require(resultantId);
+            };
         module.exports = {};
         delete module.factory;
-        factory(require, module.exports, module);
+        factory(localRequire, module.exports, module);
         return module.exports;
     }
 
@@ -949,7 +960,6 @@ define("cordova/exec", function(require, exports, module) {
 
 var cordova = require('cordova'),
     plugins = {
-        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
         'Media': require('cordova/plugin/blackberry10/media'),
@@ -3841,34 +3851,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/accelerometer.js
-define("cordova/plugin/blackberry10/accelerometer", function(require, exports, module) {
-
-var cordova = require('cordova'),
-    callback;
-
-module.exports = {
-    start: function (args, win, fail) {
-        window.removeEventListener("devicemotion", callback);
-        callback = function (motion) {
-            win({
-                x: motion.accelerationIncludingGravity.x,
-                y: motion.accelerationIncludingGravity.y,
-                z: motion.accelerationIncludingGravity.z,
-                timestamp: motion.timestamp
-            });
-        };
-        window.addEventListener("devicemotion", callback);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    },
-    stop: function (args, win, fail) {
-        window.removeEventListener("devicemotion", callback);
-        return { "status" : cordova.callbackStatus.OK, "message" : "removed" };
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/capture.js
 define("cordova/plugin/blackberry10/capture", function(require, exports, module) {