You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/03/28 03:15:47 UTC
[12/17] wp7 commit: remove Cast callbacks from Capture
remove Cast callbacks from Capture
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/c2700bba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/c2700bba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/c2700bba
Branch: refs/heads/master
Commit: c2700bba2b070a2e54152b24996e9e0d65f25aa7
Parents: 449ac05
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Mar 26 11:58:29 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Mar 26 11:58:29 2012 -0700
----------------------------------------------------------------------
framework/Cordova/Commands/Capture.cs | 16 +++---
framework/js/capture.js | 71 +++++++++++++++++++--------
2 files changed, 58 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/c2700bba/framework/Cordova/Commands/Capture.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Capture.cs b/framework/Cordova/Commands/Capture.cs
index 2bf676f..60feb70 100644
--- a/framework/Cordova/Commands/Capture.cs
+++ b/framework/Cordova/Commands/Capture.cs
@@ -473,7 +473,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
}
@@ -487,7 +487,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
if (files.Count > 0)
{
// User canceled operation, but some images were made
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
else
@@ -499,7 +499,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
default:
if (files.Count > 0)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
else
@@ -540,7 +540,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
}
@@ -554,7 +554,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
if (files.Count > 0)
{
// User canceled operation, but some audio clips were made
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
else
@@ -566,7 +566,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
default:
if (files.Count > 0)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
else
@@ -607,7 +607,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
}
@@ -633,7 +633,7 @@ namespace WP7CordovaClassLib.Cordova.Commands
default:
if (files.Count > 0)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files, "navigator.device.capture._castMediaFile"));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
files.Clear();
}
else
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/c2700bba/framework/js/capture.js
----------------------------------------------------------------------
diff --git a/framework/js/capture.js b/framework/js/capture.js
index ef5d681..13291f3 100644
--- a/framework/js/capture.js
+++ b/framework/js/capture.js
@@ -94,6 +94,26 @@ var Capture = function(){
this.supportedVideoModes = [];
};
+function _capture(type, successCallback, errorCallback, options)
+{
+ var win = function (pluginResult)
+ {
+ var mediaFiles = [];
+ var i;
+ for (i = 0; i < pluginResult.length; i++) {
+ var mediaFile = new MediaFile();
+ mediaFile.name = pluginResult[i].name;
+ mediaFile.fullPath = pluginResult[i].fullPath;
+ mediaFile.type = pluginResult[i].type;
+ mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
+ mediaFile.size = pluginResult[i].size;
+ mediaFiles.push(mediaFile);
+ }
+ successCallback(mediaFiles);
+ };
+ Cordova.exec(win, errorCallback, "Capture", type, [options]);
+}
+
/**
* Launch audio recorder application for recording audio clip(s).
*
@@ -101,8 +121,10 @@ var Capture = function(){
* @param {Function} errorCB
* @param {CaptureAudioOptions} options
*/
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", options);
+Capture.prototype.captureAudio = function (successCallback, errorCallback, options)
+{
+ _capture("captureAudio", successCallback, errorCallback, options);
+ //Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", options);
};
/**
@@ -112,8 +134,10 @@ Capture.prototype.captureAudio = function(successCallback, errorCallback, option
* @param {Function} errorCB
* @param {CaptureImageOptions} options
*/
-Capture.prototype.captureImage = function (successCallback, errorCallback, options) {
- Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", options);
+Capture.prototype.captureImage = function (successCallback, errorCallback, options)
+{
+ _capture("captureImage", successCallback, errorCallback, options);
+ //Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", options);
};
/**
@@ -123,29 +147,34 @@ Capture.prototype.captureImage = function (successCallback, errorCallback, optio
* @param {Function} errorCB
* @param {CaptureVideoOptions} options
*/
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", options);
+Capture.prototype.captureVideo = function (successCallback, errorCallback, options)
+{
+ _capture("captureVideo", successCallback, errorCallback, options);
+ //Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", options);
};
+
+
+
/**
* This function returns and array of MediaFiles. It is required as we need to convert raw
* JSON objects into MediaFile objects.
*/
-Capture.prototype._castMediaFile = function(pluginResult){
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
-};
+//Capture.prototype._castMediaFile = function(pluginResult){
+// var mediaFiles = [];
+// var i;
+// for (i = 0; i < pluginResult.message.length; i++) {
+// var mediaFile = new MediaFile();
+// mediaFile.name = pluginResult.message[i].name;
+// mediaFile.fullPath = pluginResult.message[i].fullPath;
+// mediaFile.type = pluginResult.message[i].type;
+// mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
+// mediaFile.size = pluginResult.message[i].size;
+// mediaFiles.push(mediaFile);
+// }
+// pluginResult.message = mediaFiles;
+// return pluginResult;
+//};
/**
* Encapsulates a set of parameters that the capture device supports.