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/14 06:15:39 UTC
[32/50] [abbrv] webworks commit: Update plugin script and template to
work with plugman changes
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/master
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_ */