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/07/17 01:36:06 UTC

git commit: [CB-3702] media capture plugin breakout initial commit

Updated Branches:
  refs/heads/master 4328d48fe -> 9f1f6a7e6


[CB-3702] media capture plugin breakout initial commit


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/9f1f6a7e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/9f1f6a7e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/9f1f6a7e

Branch: refs/heads/master
Commit: 9f1f6a7e6bffe33f1253fd759ac431311b4b0854
Parents: 4328d48
Author: lorinbeer <lo...@adobe.com>
Authored: Tue Jul 16 16:36:01 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Tue Jul 16 16:36:01 2013 -0700

----------------------------------------------------------------------
 plugin.xml                |  8 ++++
 src/blackberry10/index.js | 94 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/9f1f6a7e/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index ad7e00c..eeaac37 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -63,6 +63,14 @@
         <resource-file src="src/ios/CDVCapture.bundle" />
     </platform>
 
+    <!-- blackberry10 -->
+    <platform name="blackberry10">
+        <source-file src="src/blackberry10/index.js" target-dir="Capture" />
+        <config-file target="www/config.xml" parent="/widget">
+            <feature name="media-capture" value="Capture"/>
+        </config-file>
+      </platform>
+
     <!-- wp7 -->
     <platform name="wp7">
         <config-file target="config.xml" parent="/*">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/9f1f6a7e/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
new file mode 100644
index 0000000..d7c5627
--- /dev/null
+++ b/src/blackberry10/index.js
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+//cordova-js/lib/common/plugin/CaptureError.js
+var INTERNAL_ERROR_CODE = 0,
+    APPLICATION_BUSY_ERROR_CODE = 1,
+    INVALID_ARGUMENT_ERROR_CODE = 2,
+    NO_MEDIA_FILES_ERROR_CODE = 3,
+    NOT_SUPPORTED_ERROR_CODE = 20;
+
+function capture(action, options, result, webview) {
+    var noop = function () {},
+        limit = options.limit || 1,
+        fail = function (error) {
+            result.callbackError({code: INTERNAL_ERROR_CODE});
+        },
+        onCaptured = function (path) {
+            var sb = webview.setFileSystemSandbox;
+            webview.setFileSystemSandbox = false;
+            window.webkitRequestFileSystem(window.PERSISTENT, 1024, function (fs) {
+                fs.root.getFile(path, {}, function (fe) {
+                    fe.file(function (file) {
+                        file.fullPath = fe.fullPath;
+                        webview.setFileSystemSandbox = sb;
+                        result.callbackOk([file]);
+                    }, fail);
+                }, fail);
+            }, fail);
+        },
+        onCancelled = function () {
+            result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
+        },
+        onInvoked = function (error) {
+            if (error) {
+                result.callbackError({code: APPLICATION_BUSY_ERROR_CODE});
+            }
+        };
+
+    if (limit < 0) {
+        result.error({code: INVALID_ARGUMENT_ERROR_CODE});
+    } else {
+        window.qnx.webplatform.getApplication().cards.camera.open(action, onCaptured, onCancelled, onInvoked);
+        result.noResult(true);
+    }
+}
+
+module.exports = {
+    getSupportedAudioModes: function (success, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.ok([]);
+    },
+    getSupportedImageModes: function (win, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.ok([]);
+    },
+    getSupportedVideoModes: function (win, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.ok([]);
+    },
+    captureImage: function (win, fail, args, env) {
+        var result = new PluginResult(args, env),
+            options = args[0] === "undefined" ? {} : JSON.parse(decodeURIComponent(args[0]));
+
+        capture("photo", options,  result, env.webview);
+    },
+    captureVideo: function (win, fail, args, env) {
+        var result = new PluginResult(args, env),
+            options = args[0] === "undefined" ? {} : JSON.parse(decodeURIComponent(args[0]));
+
+        capture("video", options, result, env.webview);
+    },
+    captureAudio: function (win, fail, args, env) {
+        var result = new PluginResult(args, env);
+        result.error({code: NOT_SUPPORTED_ERROR_CODE});
+    }
+};