You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/02/21 20:43:55 UTC
[3/4] 2.5.0rc1 (2.5.0 in package.json). Removed old test related to
webworks scripts. Updated lbiraries to 2.5.0rc1. Added a VERSION file.
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-android/test/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-android/test/res/xml/config.xml b/lib/cordova-android/test/res/xml/config.xml
index b9ae3a6..675aeb5 100644
--- a/lib/cordova-android/test/res/xml/config.xml
+++ b/lib/cordova-android/test/res/xml/config.xml
@@ -45,12 +45,13 @@
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
<plugin name="Notification" value="org.apache.cordova.Notification"/>
<plugin name="Storage" value="org.apache.cordova.Storage"/>
- <plugin name="Temperature" value="org.apache.cordova.TempListener"/>
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
<plugin name="Capture" value="org.apache.cordova.Capture"/>
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
<plugin name="Echo" value="org.apache.cordova.Echo" />
+ <plugin name="Globalization" value="org.apache.cordova.Globalization"/>
+ <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/>
</plugins>
</cordova>
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-android/test/src/org/apache/cordova/test/ActivityPlugin.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/test/src/org/apache/cordova/test/ActivityPlugin.java b/lib/cordova-android/test/src/org/apache/cordova/test/ActivityPlugin.java
index 805454a..0c1d1da 100755
--- a/lib/cordova-android/test/src/org/apache/cordova/test/ActivityPlugin.java
+++ b/lib/cordova-android/test/src/org/apache/cordova/test/ActivityPlugin.java
@@ -18,19 +18,21 @@
*/
package org.apache.cordova.test;
+import org.apache.cordova.CordovaArgs;
import org.apache.cordova.api.LOG;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Intent;
-import org.apache.cordova.api.Plugin;
+import org.apache.cordova.api.CallbackContext;
+import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
/**
* This class provides a service.
*/
-public class ActivityPlugin extends Plugin {
+public class ActivityPlugin extends CordovaPlugin {
static String TAG = "ActivityPlugin";
@@ -48,19 +50,21 @@ public class ActivityPlugin extends Plugin {
* @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
- @Override
- public PluginResult execute(String action, JSONArray args, String callbackId) {
- PluginResult.Status status = PluginResult.Status.OK;
- String result = "";
-
+ public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) {
+ PluginResult result = new PluginResult(PluginResult.Status.OK, "");
try {
if (action.equals("start")) {
this.startActivity(args.getString(0));
+ callbackContext.sendPluginResult(result);
+ callbackContext.success();
+ return true;
}
- return new PluginResult(status, result);
} catch (JSONException e) {
- return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
+ result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, "JSON Exception");
+ callbackContext.sendPluginResult(result);
+ return false;
}
+ return false;
}
// --------------------------------------------------------------------------
@@ -69,9 +73,9 @@ public class ActivityPlugin extends Plugin {
public void startActivity(String className) {
try {
- Intent intent = new Intent().setClass(this.ctx.getActivity(), Class.forName(className));
+ Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className));
LOG.d(TAG, "Starting activity %s", className);
- this.ctx.getActivity().startActivity(intent);
+ this.cordova.getActivity().startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
LOG.e(TAG, "Error starting activity %s", className);
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/README.md
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/README.md b/lib/cordova-blackberry/README.md
index b504c42..e2f9896 100644
--- a/lib/cordova-blackberry/README.md
+++ b/lib/cordova-blackberry/README.md
@@ -7,7 +7,7 @@ Directory Structure
-------------------
framework/ ... BlackBerry WebWorks JavaScript Extension (Cordova native code)
- javascript/ .. Cordova JavaScript (Non-concatenated, non-minified)
+ javascript/ .. Cordova JavaScript (concatenated, non-minified)
bin/ ......... Scripts for project creation
Introduction
@@ -47,7 +47,7 @@ The Cordova developer tooling is split between general tooling and project level
### General Commands
- ./bin/create [path appname] ............ creates a sample app with the specified application name, to the specified path
+ ./bin/create [path appname packagename] ............ creates a sample app with the specified application name, to the specified path
Please note that once you `create` a Cordova BlackBerry project, you
will need to edit the `project.properties` file that resides inside your
@@ -67,11 +67,11 @@ Create the example project and build it to the first device:
./bin/create
cd example
- ./cordova/debug
+ ./cordova/run blackberry
#### Creating a new Cordova BlackBerry Project
- ./bin/create ~/Desktop/myapp MyApp
+ ./bin/create ~/Desktop/myapp MyAppName MyAppPackageName
### Project Commands
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/VERSION b/lib/cordova-blackberry/VERSION
index 197c4d5..aa0822f 100644
--- a/lib/cordova-blackberry/VERSION
+++ b/lib/cordova-blackberry/VERSION
@@ -1 +1 @@
-2.4.0
+2.5.0rc1
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/bin/templates/project/lib/ant-contrib/ant-contrib-1.0b3.jar
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/lib/ant-contrib/ant-contrib-1.0b3.jar b/lib/cordova-blackberry/bin/templates/project/lib/ant-contrib/ant-contrib-1.0b3.jar
new file mode 100644
index 0000000..0625376
Binary files /dev/null and b/lib/cordova-blackberry/bin/templates/project/lib/ant-contrib/ant-contrib-1.0b3.jar differ
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/bin/templates/project/www/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/VERSION b/lib/cordova-blackberry/bin/templates/project/www/VERSION
index 2eca156..aa0822f 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/VERSION
+++ b/lib/cordova-blackberry/bin/templates/project/www/VERSION
@@ -1 +1 @@
-2.4.0rc1
+2.5.0rc1
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/bin/templates/project/www/index.html
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/index.html b/lib/cordova-blackberry/bin/templates/project/www/index.html
index f3c00e2..ab0ca50 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/index.html
+++ b/lib/cordova-blackberry/bin/templates/project/www/index.html
@@ -33,7 +33,7 @@
<p class="event received">Device is Ready</p>
</div>
</div>
- <script type="text/javascript" src="cordova-2.4.0.js"></script>
+ <script type="text/javascript" src="cordova-2.5.0rc1.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/framework/ext/src/org/apache/cordova/device/Device.java
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/framework/ext/src/org/apache/cordova/device/Device.java b/lib/cordova-blackberry/framework/ext/src/org/apache/cordova/device/Device.java
index e11f924..1e56cee 100644
--- a/lib/cordova-blackberry/framework/ext/src/org/apache/cordova/device/Device.java
+++ b/lib/cordova-blackberry/framework/ext/src/org/apache/cordova/device/Device.java
@@ -54,7 +54,7 @@ public final class Device extends Plugin {
JSONObject device = new JSONObject();
device.put( FIELD_PLATFORM, "BlackBerry");
device.put( FIELD_UUID, new Integer( DeviceInfo.getDeviceId()) );
- device.put( FIELD_CORDOVA, "2.4.0rc1" );
+ device.put( FIELD_CORDOVA, "2.5.0rc1" );
device.put( FIELD_MODEL, new String(DeviceInfo.getDeviceName()) );
device.put( FIELD_NAME, new String(DeviceInfo.getDeviceName()) );
device.put( FIELD_VERSION, new String(DeviceInfo.getSoftwareVersion()) );
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-blackberry/javascript/cordova.blackberry.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/javascript/cordova.blackberry.js b/lib/cordova-blackberry/javascript/cordova.blackberry.js
index a963a2d..cb48379 100644
--- a/lib/cordova-blackberry/javascript/cordova.blackberry.js
+++ b/lib/cordova-blackberry/javascript/cordova.blackberry.js
@@ -1,8 +1,8 @@
// Platform: blackberry
-// commit ac725f6ae0bd655789771e2a40b8d60cb4c8c221
+// commit cded0ad0826489ca07ae8bdd33905a37d40f3adf
-// File generated at :: Tue Feb 05 2013 16:15:50 GMT-0800 (PST)
+// File generated at :: Wed Feb 20 2013 13:20:15 GMT-0800 (PST)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -399,6 +399,7 @@ function each(objects, func, context) {
}
function clobber(obj, key, value) {
+ exports.replaceHookForTesting(obj, key);
obj[key] = value;
// Getters can only be overridden by getters.
if (obj[key] !== value) {
@@ -482,19 +483,18 @@ function recursiveMerge(target, src) {
}
}
-module.exports = {
- buildIntoButDoNotClobber: function(objects, target) {
- include(target, objects, false, false);
- },
- buildIntoAndClobber: function(objects, target) {
- include(target, objects, true, false);
- },
- buildIntoAndMerge: function(objects, target) {
- include(target, objects, true, true);
- },
- recursiveMerge: recursiveMerge,
- assignOrWrapInDeprecateGetter: assignOrWrapInDeprecateGetter
+exports.buildIntoButDoNotClobber = function(objects, target) {
+ include(target, objects, false, false);
};
+exports.buildIntoAndClobber = function(objects, target) {
+ include(target, objects, true, false);
+};
+exports.buildIntoAndMerge = function(objects, target) {
+ include(target, objects, true, true);
+};
+exports.recursiveMerge = recursiveMerge;
+exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
+exports.replaceHookForTesting = function() {};
});
@@ -774,176 +774,6 @@ module.exports = {
};
});
-// file: lib/common/common.js
-define("cordova/common", function(require, exports, module) {
-
-module.exports = {
- defaults: {
- cordova: {
- path: 'cordova',
- children: {
- exec: {
- path: 'cordova/exec'
- },
- logger: {
- path: 'cordova/plugin/logger'
- }
- }
- },
- Cordova: {
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- open : {
- path: 'cordova/plugin/InAppBrowser'
- },
- navigator: {
- children: {
- notification: {
- path: 'cordova/plugin/notification'
- },
- accelerometer: {
- path: 'cordova/plugin/accelerometer'
- },
- battery: {
- path: 'cordova/plugin/battery'
- },
- camera:{
- path: 'cordova/plugin/Camera'
- },
- compass:{
- path: 'cordova/plugin/compass'
- },
- contacts: {
- path: 'cordova/plugin/contacts'
- },
- device:{
- children:{
- capture: {
- path: 'cordova/plugin/capture'
- }
- }
- },
- geolocation: {
- path: 'cordova/plugin/geolocation'
- },
- globalization: {
- path: 'cordova/plugin/globalization'
- },
- network: {
- children: {
- connection: {
- path: 'cordova/plugin/network',
- deprecated: 'navigator.network.connection is deprecated. Use navigator.connection instead.'
- }
- }
- },
- splashscreen: {
- path: 'cordova/plugin/splashscreen'
- }
- }
- },
- Acceleration: {
- path: 'cordova/plugin/Acceleration'
- },
- Camera:{
- path: 'cordova/plugin/CameraConstants'
- },
- CameraPopoverOptions: {
- path: 'cordova/plugin/CameraPopoverOptions'
- },
- CaptureError: {
- path: 'cordova/plugin/CaptureError'
- },
- CaptureAudioOptions:{
- path: 'cordova/plugin/CaptureAudioOptions'
- },
- CaptureImageOptions: {
- path: 'cordova/plugin/CaptureImageOptions'
- },
- CaptureVideoOptions: {
- path: 'cordova/plugin/CaptureVideoOptions'
- },
- CompassHeading:{
- path: 'cordova/plugin/CompassHeading'
- },
- CompassError:{
- path: 'cordova/plugin/CompassError'
- },
- ConfigurationData: {
- path: 'cordova/plugin/ConfigurationData'
- },
- Connection: {
- path: 'cordova/plugin/Connection'
- },
- Contact: {
- path: 'cordova/plugin/Contact'
- },
- ContactAddress: {
- path: 'cordova/plugin/ContactAddress'
- },
- ContactError: {
- path: 'cordova/plugin/ContactError'
- },
- ContactField: {
- path: 'cordova/plugin/ContactField'
- },
- ContactFindOptions: {
- path: 'cordova/plugin/ContactFindOptions'
- },
- ContactName: {
- path: 'cordova/plugin/ContactName'
- },
- ContactOrganization: {
- path: 'cordova/plugin/ContactOrganization'
- },
- Coordinates: {
- path: 'cordova/plugin/Coordinates'
- },
- device: {
- path: 'cordova/plugin/device'
- },
- GlobalizationError: {
- path: 'cordova/plugin/GlobalizationError'
- },
- Media: {
- path: 'cordova/plugin/Media'
- },
- MediaError: {
- path: 'cordova/plugin/MediaError'
- },
- MediaFile: {
- path: 'cordova/plugin/MediaFile'
- },
- MediaFileData:{
- path: 'cordova/plugin/MediaFileData'
- },
- Position: {
- path: 'cordova/plugin/Position'
- },
- PositionError: {
- path: 'cordova/plugin/PositionError'
- },
- ProgressEvent: {
- path: 'cordova/plugin/ProgressEvent'
- }
- },
- clobbers: {
- navigator: {
- children: {
- connection: {
- path: 'cordova/plugin/network'
- }
- }
- }
- }
-};
-
-});
-
// file: lib/blackberry/exec.js
define("cordova/exec", function(require, exports, module) {
@@ -1051,9 +881,9 @@ function prepareNamespace(symbolPath, context) {
var parts = symbolPath.split('.');
var cur = context;
for (var i = 0, part; part = parts[i]; ++i) {
- cur[part] = cur[part] || {};
+ cur = cur[part] = cur[part] || {};
}
- return cur[parts[i-1]];
+ return cur;
}
exports.mapModules = function(context) {
@@ -1075,7 +905,7 @@ exports.mapModules = function(context) {
if (strategy == 'm' && target) {
builder.recursiveMerge(target, module);
} else if ((strategy == 'd' && !target) || (strategy != 'd')) {
- if (target) {
+ if (!(symbolPath in origSymbols)) {
origSymbols[symbolPath] = target;
}
builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
@@ -1130,20 +960,16 @@ module.exports = {
}
},
initialize: function() {
- var builder = require('cordova/builder'),
- modulemapper = require('cordova/modulemapper'),
+ var modulemapper = require('cordova/modulemapper'),
platform = require('cordova/plugin/' + this.runtime() + '/platform');
- builder.buildIntoButDoNotClobber(platform.defaults, window);
- builder.buildIntoAndClobber(platform.clobbers, window);
- builder.buildIntoAndMerge(platform.merges, window);
-
modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
modulemapper.loadMatchingModules(new RegExp('cordova/.*' + this.runtime() + '/.*bbsymbols$'));
- modulemapper.mapModules(window);
+ modulemapper.mapModules(this.contextObj);
platform.initialize();
- }
+ },
+ contextObj: this // Used for testing.
};
});
@@ -1376,9 +1202,9 @@ module.exports = CompassError;
define("cordova/plugin/CompassHeading", function(require, exports, module) {
var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = magneticHeading || null;
- this.trueHeading = trueHeading || null;
- this.headingAccuracy = headingAccuracy || null;
+ this.magneticHeading = magneticHeading;
+ this.trueHeading = trueHeading;
+ this.headingAccuracy = headingAccuracy;
this.timestamp = timestamp || new Date().getTime();
};
@@ -2751,11 +2577,12 @@ define("cordova/plugin/FileTransferError", function(require, exports, module) {
* FileTransferError
* @constructor
*/
-var FileTransferError = function(code, source, target, status) {
+var FileTransferError = function(code, source, target, status, body) {
this.code = code || null;
this.source = source || null;
this.target = target || null;
this.http_status = status || null;
+ this.body = body || null;
};
FileTransferError.FILE_NOT_FOUND_ERR = 1;
@@ -3159,8 +2986,6 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
return iab;
};
-//Export the original open so it can be used if needed
-module.exports._orig = window.open;
});
@@ -3731,6 +3556,17 @@ module.exports = accelerometer;
});
+// file: lib/common/plugin/accelerometer/symbols.js
+define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
+modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
+
+});
+
// file: lib/blackberry/plugin/air/DirectoryEntry.js
define("cordova/plugin/air/DirectoryEntry", function(require, exports, module) {
@@ -5348,7 +5184,7 @@ module.exports = {
model: "PlayBook",
name: "PlayBook", // deprecated: please use device.model
uuid: info.uuid,
- cordova: "2.4.0"
+ cordova: "2.5.0rc1"
});
}),
request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getDeviceInfo");
@@ -5708,6 +5544,28 @@ module.exports = battery;
});
+// file: lib/common/plugin/battery/symbols.js
+define("cordova/plugin/battery/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
+
+});
+
+// file: lib/common/plugin/camera/symbols.js
+define("cordova/plugin/camera/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Camera', 'navigator.camera');
+modulemapper.defaults('cordova/plugin/CameraConstants', 'Camera');
+modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptions');
+
+});
+
// file: lib/common/plugin/capture.js
define("cordova/plugin/capture", function(require, exports, module) {
@@ -5786,6 +5644,22 @@ module.exports = new Capture();
});
+// file: lib/common/plugin/capture/symbols.js
+define("cordova/plugin/capture/symbols", function(require, exports, module) {
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/CaptureError', 'CaptureError');
+modulemapper.clobbers('cordova/plugin/CaptureAudioOptions', 'CaptureAudioOptions');
+modulemapper.clobbers('cordova/plugin/CaptureImageOptions', 'CaptureImageOptions');
+modulemapper.clobbers('cordova/plugin/CaptureVideoOptions', 'CaptureVideoOptions');
+modulemapper.clobbers('cordova/plugin/ConfigurationData', 'ConfigurationData');
+modulemapper.clobbers('cordova/plugin/MediaFile', 'MediaFile');
+modulemapper.clobbers('cordova/plugin/MediaFileData', 'MediaFileData');
+modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
+
+});
+
// file: lib/common/plugin/compass.js
define("cordova/plugin/compass", function(require, exports, module) {
@@ -5873,6 +5747,18 @@ module.exports = compass;
});
+// file: lib/common/plugin/compass/symbols.js
+define("cordova/plugin/compass/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/CompassHeading', 'CompassHeading');
+modulemapper.clobbers('cordova/plugin/CompassError', 'CompassError');
+modulemapper.clobbers('cordova/plugin/compass', 'navigator.compass');
+
+});
+
// file: lib/common/plugin/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
@@ -6106,6 +5992,23 @@ module.exports = contacts;
});
+// file: lib/common/plugin/contacts/symbols.js
+define("cordova/plugin/contacts/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/contacts', 'navigator.contacts');
+modulemapper.clobbers('cordova/plugin/Contact', 'Contact');
+modulemapper.clobbers('cordova/plugin/ContactAddress', 'ContactAddress');
+modulemapper.clobbers('cordova/plugin/ContactError', 'ContactError');
+modulemapper.clobbers('cordova/plugin/ContactField', 'ContactField');
+modulemapper.clobbers('cordova/plugin/ContactFindOptions', 'ContactFindOptions');
+modulemapper.clobbers('cordova/plugin/ContactName', 'ContactName');
+modulemapper.clobbers('cordova/plugin/ContactOrganization', 'ContactOrganization');
+
+});
+
// file: lib/common/plugin/device.js
define("cordova/plugin/device", function(require, exports, module) {
@@ -6165,6 +6068,16 @@ module.exports = new Device();
});
+// file: lib/common/plugin/device/symbols.js
+define("cordova/plugin/device/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/device', 'device');
+
+});
+
// file: lib/common/plugin/echo.js
define("cordova/plugin/echo", function(require, exports, module) {
@@ -6211,20 +6124,30 @@ module.exports = function(exportFunc) {
exportFunc('cordova/plugin/FileError', 'FileError');
exportFunc('cordova/plugin/FileReader', 'FileReader');
exportFunc('cordova/plugin/FileSystem', 'FileSystem');
- exportFunc('cordova/plugin/FileTransfer', 'FileTransfer');
- exportFunc('cordova/plugin/FileTransferError', 'FileTransferError');
exportFunc('cordova/plugin/FileUploadOptions', 'FileUploadOptions');
exportFunc('cordova/plugin/FileUploadResult', 'FileUploadResult');
exportFunc('cordova/plugin/FileWriter', 'FileWriter');
exportFunc('cordova/plugin/Flags', 'Flags');
exportFunc('cordova/plugin/LocalFileSystem', 'LocalFileSystem');
exportFunc('cordova/plugin/Metadata', 'Metadata');
+ exportFunc('cordova/plugin/ProgressEvent', 'ProgressEvent');
exportFunc('cordova/plugin/requestFileSystem', 'requestFileSystem');
exportFunc('cordova/plugin/resolveLocalFileSystemURI', 'resolveLocalFileSystemURI');
};
});
+// file: lib/common/plugin/filetransfer/symbols.js
+define("cordova/plugin/filetransfer/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/FileTransfer', 'FileTransfer');
+modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
+
+});
+
// file: lib/common/plugin/geolocation.js
define("cordova/plugin/geolocation", function(require, exports, module) {
@@ -6421,6 +6344,19 @@ module.exports = geolocation;
});
+// file: lib/common/plugin/geolocation/symbols.js
+define("cordova/plugin/geolocation/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/geolocation', 'navigator.geolocation');
+modulemapper.clobbers('cordova/plugin/PositionError', 'PositionError');
+modulemapper.clobbers('cordova/plugin/Position', 'Position');
+modulemapper.clobbers('cordova/plugin/Coordinates', 'Coordinates');
+
+});
+
// file: lib/common/plugin/globalization.js
define("cordova/plugin/globalization", function(require, exports, module) {
@@ -6797,6 +6733,17 @@ module.exports = globalization;
});
+// file: lib/common/plugin/globalization/symbols.js
+define("cordova/plugin/globalization/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/globalization', 'navigator.globalization');
+modulemapper.clobbers('cordova/plugin/GlobalizationError', 'GlobalizationError');
+
+});
+
// file: lib/blackberry/plugin/java/Contact.js
define("cordova/plugin/java/Contact", function(require, exports, module) {
@@ -7965,6 +7912,16 @@ module.exports = {
});
+// file: lib/blackberry/plugin/java/app/bbsymbols.js
+define("cordova/plugin/java/app/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/java/app', 'navigator.app');
+
+});
+
// file: lib/blackberry/plugin/java/contacts.js
define("cordova/plugin/java/contacts", function(require, exports, module) {
@@ -8034,6 +7991,17 @@ module.exports = {
});
+// file: lib/blackberry/plugin/java/contacts/bbsymbols.js
+define("cordova/plugin/java/contacts/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/java/contacts', 'navigator.contacts');
+modulemapper.merges('cordova/plugin/java/Contact', 'Contact');
+
+});
+
// file: lib/blackberry/plugin/java/file/bbsymbols.js
define("cordova/plugin/java/file/bbsymbols", function(require, exports, module) {
@@ -8123,6 +8091,19 @@ module.exports = {
});
+// file: lib/blackberry/plugin/java/media/bbsymbols.js
+define("cordova/plugin/java/media/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Media', 'Media');
+modulemapper.defaults('cordova/plugin/MediaError', 'MediaError');
+// Exists natively on BB OS 6+, merge in Cordova specifics
+modulemapper.merges('cordova/plugin/java/MediaError', 'MediaError');
+
+});
+
// file: lib/blackberry/plugin/java/notification.js
define("cordova/plugin/java/notification", function(require, exports, module) {
@@ -8182,6 +8163,16 @@ module.exports = {
});
+// file: lib/blackberry/plugin/java/notification/bbsymbols.js
+define("cordova/plugin/java/notification/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/java/notification', 'navigator.notification');
+
+});
+
// file: lib/blackberry/plugin/java/platform.js
define("cordova/plugin/java/platform", function(require, exports, module) {
@@ -8310,33 +8301,6 @@ module.exports = {
// Trap BlackBerry WebWorks exit. Allow plugins to clean up before exiting.
blackberry.app.event.onExit(app.exitApp);
- },
- clobbers: {
- navigator: {
- children: {
- app: {
- path: "cordova/plugin/java/app"
- }
- }
- }
- },
- merges: {
- navigator: {
- children: {
- contacts: {
- path: 'cordova/plugin/java/contacts'
- },
- notification: {
- path: 'cordova/plugin/java/notification'
- }
- }
- },
- Contact: {
- path: 'cordova/plugin/java/Contact'
- },
- MediaError: { // Exists natively on BB OS 6+, merge in Cordova specifics
- path: 'cordova/plugin/java/MediaError'
- }
}
};
@@ -8570,6 +8534,27 @@ document.addEventListener("deviceready", logger.__onDeviceReady, false);
});
+// file: lib/common/plugin/logger/symbols.js
+define("cordova/plugin/logger/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
+
+});
+
+// file: lib/common/plugin/media/symbols.js
+define("cordova/plugin/media/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Media', 'Media');
+modulemapper.defaults('cordova/plugin/MediaError', 'MediaError');
+
+});
+
// file: lib/common/plugin/network.js
define("cordova/plugin/network", function(require, exports, module) {
@@ -8642,6 +8627,18 @@ module.exports = me;
});
+// file: lib/common/plugin/networkstatus/symbols.js
+define("cordova/plugin/networkstatus/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/network', 'navigator.network.connection', 'navigator.network.connection is deprecated. Use navigator.connection instead.');
+modulemapper.clobbers('cordova/plugin/network', 'navigator.connection');
+modulemapper.defaults('cordova/plugin/Connection', 'Connection');
+
+});
+
// file: lib/common/plugin/notification.js
define("cordova/plugin/notification", function(require, exports, module) {
@@ -8704,18 +8701,29 @@ module.exports = {
});
+// file: lib/common/plugin/notification/symbols.js
+define("cordova/plugin/notification/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/notification', 'navigator.notification');
+
+});
+
// file: lib/blackberry/plugin/qnx/InAppBrowser.js
define("cordova/plugin/qnx/InAppBrowser", function(require, exports, module) {
var cordova = require('cordova'),
- core = require('cordova/plugin/InAppBrowser'),
+ modulemapper = require('cordova/modulemapper'),
+ origOpen = modulemapper.getOriginalSymbol(window, 'open'),
browser = {
close: function () { } //dummy so we don't have to check for undefined
};
var navigate = {
"_blank": function (url, whitelisted) {
- return core._orig.apply(null, [url, "_blank"]);
+ return origOpen(url, "_blank");
},
"_self": function (url, whitelisted) {
@@ -8724,7 +8732,7 @@ var navigate = {
return window;
}
else {
- return core._orig.apply(null, [url, "_blank"]);
+ return origOpen(url, "_blank");
}
},
@@ -9024,6 +9032,16 @@ module.exports = compass;
});
+// file: lib/blackberry/plugin/qnx/compass/bbsymbols.js
+define("cordova/plugin/qnx/compass/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/qnx/compass', 'navigator.compass');
+
+});
+
// file: lib/blackberry/plugin/qnx/device.js
define("cordova/plugin/qnx/device", function(require, exports, module) {
@@ -9041,7 +9059,7 @@ module.exports = {
model: "Dev Alpha",
name: "Dev Alpha", // deprecated: please use device.model
uuid: blackberry.identity.uuid,
- cordova: "2.4.0"
+ cordova: "2.5.0rc1"
});
return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "Device info returned" };
@@ -9490,6 +9508,16 @@ module.exports = {
});
+// file: lib/blackberry/plugin/qnx/inappbrowser/bbsymbols.js
+define("cordova/plugin/qnx/inappbrowser/bbsymbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/InAppBrowser', 'open');
+
+});
+
// file: lib/blackberry/plugin/qnx/magnetometer.js
define("cordova/plugin/qnx/magnetometer", function(require, exports, module) {
@@ -9602,20 +9630,6 @@ module.exports = {
cordova.fireDocumentEvent("offline");
});
});
- },
- clobbers: {
- open: {
- path: "cordova/plugin/InAppBrowser"
- }
- },
- merges: {
- navigator: {
- children: {
- compass: {
- path: 'cordova/plugin/qnx/compass'
- }
- }
- }
}
};
@@ -9734,6 +9748,16 @@ module.exports = splashscreen;
});
+// file: lib/common/plugin/splashscreen/symbols.js
+define("cordova/plugin/splashscreen/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/splashscreen', 'navigator.splashscreen');
+
+});
+
// file: lib/blackberry/plugin/webworks/accelerometer.js
define("cordova/plugin/webworks/accelerometer", function(require, exports, module) {
@@ -9791,7 +9815,7 @@ module.exports = {
var id = args[0],
src = args[1];
-
+
if (typeof src == "undefined"){
audioObjects[id] = new Audio();
} else {
@@ -9988,6 +10012,19 @@ module.exports = {
});
+// file: lib/common/symbols.js
+define("cordova/symbols", function(require, exports, module) {
+
+var modulemapper = require('cordova/modulemapper');
+
+// Use merges here in case others symbols files depend on this running first,
+// but fail to declare the dependency with a require().
+modulemapper.merges('cordova', 'cordova');
+modulemapper.clobbers('cordova/exec', 'cordova.exec');
+modulemapper.clobbers('cordova/exec', 'Cordova.exec');
+
+});
+
// file: lib/common/utils.js
define("cordova/utils", function(require, exports, module) {
@@ -10255,18 +10292,7 @@ window.cordova = require('cordova');
* Create all cordova objects once page has fully loaded and native side is ready.
*/
channel.join(function() {
- var builder = require('cordova/builder'),
- base = require('cordova/common'),
- platform = require('cordova/platform');
-
- // Drop the common globals into the window object, but be nice and don't overwrite anything.
- builder.buildIntoButDoNotClobber(base.defaults, context);
- builder.buildIntoAndClobber(base.clobbers, context);
- builder.buildIntoAndMerge(base.merges, context);
-
- builder.buildIntoButDoNotClobber(platform.defaults, context);
- builder.buildIntoAndClobber(platform.clobbers, context);
- builder.buildIntoAndMerge(platform.merges, context);
+ var platform = require('cordova/platform');
// Call the platform-specific initialization
platform.initialize();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h b/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
index 67583be..33c6799 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
@@ -36,6 +36,7 @@
#define __CORDOVA_2_2_0 20200
#define __CORDOVA_2_3_0 20300
#define __CORDOVA_2_4_0 20400
+#define __CORDOVA_2_5_0 20500
#define __CORDOVA_NA 99999 /* not available */
/*
@@ -46,7 +47,7 @@
#endif
*/
#ifndef CORDOVA_VERSION_MIN_REQUIRED
- #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_4_0
+ #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_5_0
#endif
/*
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
index 4cf5c82..22aca98 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
@@ -232,66 +232,68 @@ static NSSet* org_apache_cordova_validArrowDirections;
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
// IMAGE TYPE
if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- // get the image
- UIImage* image = nil;
- if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
+ if (cameraPicker.returnType == DestinationTypeNativeUri) {
+ NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
} else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
+ // get the image
+ UIImage* image = nil;
+ if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
+ image = [info objectForKey:UIImagePickerControllerEditedImage];
+ } else {
+ image = [info objectForKey:UIImagePickerControllerOriginalImage];
+ }
- if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
- }
+ if (cameraPicker.saveToPhotoAlbum) {
+ UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
+ }
- if (cameraPicker.correctOrientation) {
- image = [self imageCorrectedForCaptureOrientation:image];
- }
+ if (cameraPicker.correctOrientation) {
+ image = [self imageCorrectedForCaptureOrientation:image];
+ }
- UIImage* scaledImage = nil;
+ UIImage* scaledImage = nil;
- if ((cameraPicker.targetSize.width > 0) && (cameraPicker.targetSize.height > 0)) {
- // if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping
- if (cameraPicker.cropToSize) {
- scaledImage = [self imageByScalingAndCroppingForSize:image toSize:cameraPicker.targetSize];
- } else {
- scaledImage = [self imageByScalingNotCroppingForSize:image toSize:cameraPicker.targetSize];
+ if ((cameraPicker.targetSize.width > 0) && (cameraPicker.targetSize.height > 0)) {
+ // if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping
+ if (cameraPicker.cropToSize) {
+ scaledImage = [self imageByScalingAndCroppingForSize:image toSize:cameraPicker.targetSize];
+ } else {
+ scaledImage = [self imageByScalingNotCroppingForSize:image toSize:cameraPicker.targetSize];
+ }
}
- }
- NSData* data = nil;
+ NSData* data = nil;
- if (cameraPicker.encodingType == EncodingTypePNG) {
- data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
- } else {
- data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
- }
+ if (cameraPicker.encodingType == EncodingTypePNG) {
+ data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
+ } else {
+ data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
+ }
- if (cameraPicker.returnType == DestinationTypeFileUri) {
- // write to temp directory and return URI
- // get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath];
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs [NSFileManager defaultManager]) to be threadsafe
- // generate unique file name
- NSString* filePath;
-
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, cameraPicker.encodingType == EncodingTypePNG ? @"png":@"jpg"];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- // save file
- if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
+ if (cameraPicker.returnType == DestinationTypeFileUri) {
+ // write to temp directory and return URI
+ // get the temp directory path
+ NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath];
+ NSError* err = nil;
+ NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs [NSFileManager defaultManager]) to be threadsafe
+ // generate unique file name
+ NSString* filePath;
+
+ int i = 1;
+ do {
+ filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, cameraPicker.encodingType == EncodingTypePNG ? @"png":@"jpg"];
+ } while ([fileMgr fileExistsAtPath:filePath]);
+
+ // save file
+ if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
+ } else {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL fileURLWithPath:filePath] absoluteString]];
+ }
} else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL fileURLWithPath:filePath] absoluteString]];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[data base64EncodedString]];
}
- } else if (cameraPicker.returnType == DestinationTypeNativeUri) {
- NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[data base64EncodedString]];
}
}
// NOT IMAGE TYPE (MOVIE)
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m b/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
index 95c3f17..ed9f664 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
@@ -20,7 +20,6 @@
#import "CDVCapture.h"
#import "CDVJSON.h"
#import "CDVAvailability.h"
-#import "CDVViewController.h"
#define kW3CMediaFormatHeight @"height"
#define kW3CMediaFormatWidth @"width"
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegate.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegate.h b/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegate.h
index 6b1dedd..e177c63 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegate.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegate.h
@@ -22,9 +22,12 @@
@class CDVPlugin;
@class CDVPluginResult;
+@class CDVWhitelist;
@protocol CDVCommandDelegate <NSObject>
+@property (nonatomic, readonly) NSDictionary* settings;
+
- (NSString*)pathForResource:(NSString*)resourcepath;
- (id)getCommandInstance:(NSString*)pluginName;
- (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className CDV_DEPRECATED(2.2, "Use CDVViewController to register plugins, or use config.xml.");
@@ -46,5 +49,7 @@
- (void)runInBackground:(void (^)())block;
// Returns the User-Agent of the associated UIWebView.
- (NSString*)userAgent;
+// Returns whether the given URL passes the white-list.
+- (BOOL)URLIsWhitelisted:(NSURL*)url;
@end
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegateImpl.m b/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegateImpl.m
index 8845e40..e399289 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -137,4 +137,15 @@
return [_viewController userAgent];
}
+- (BOOL)URLIsWhitelisted:(NSURL*)url
+{
+ return ![_viewController.whitelist schemeIsAllowed:[url scheme]] ||
+ [_viewController.whitelist URLIsAllowed:url];
+}
+
+- (NSDictionary*)settings
+{
+ return _viewController.settings;
+}
+
@end
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
index 0f4fa4c..7392580 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
@@ -22,8 +22,7 @@
@property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
@property (nonatomic, readonly, strong) NSMutableArray* whitelistHosts;
+@property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames;
@property (nonatomic, readonly, strong) NSString* startPage;
-- (NSString*)getStartPage;
-
@end
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
index 3938b3e..6fd5913 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
@@ -24,21 +24,23 @@
@property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict;
@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
@property (nonatomic, readwrite, strong) NSMutableArray* whitelistHosts;
+@property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
@property (nonatomic, readwrite, strong) NSString* startPage;
@end
@implementation CDVConfigParser
-@synthesize pluginsDict, settings, whitelistHosts, startPage;
+@synthesize pluginsDict, settings, whitelistHosts, startPage, startupPluginNames;
- (id)init
{
self = [super init];
if (self != nil) {
- self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:4];
- self.settings = [[NSMutableDictionary alloc] initWithCapacity:4];
- self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:1];
+ self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30];
+ self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
+ self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
+ self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
}
return self;
}
@@ -46,13 +48,17 @@
- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{
if ([elementName isEqualToString:@"preference"]) {
- [settings setObject:[attributeDict objectForKey:@"value"] forKey:[attributeDict objectForKey:@"name"]];
+ settings[attributeDict[@"name"]] = attributeDict[@"value"];
} else if ([elementName isEqualToString:@"plugin"]) {
- [pluginsDict setObject:[attributeDict objectForKey:@"value"] forKey:[attributeDict objectForKey:@"name"]];
+ NSString* name = [attributeDict[@"name"] lowercaseString];
+ pluginsDict[name] = attributeDict[@"value"];
+ if ([@"true" isEqualToString:attributeDict[@"onload"]]) {
+ [self.startupPluginNames addObject:name];
+ }
} else if ([elementName isEqualToString:@"access"]) {
- [whitelistHosts addObject:[attributeDict objectForKey:@"origin"]];
+ [whitelistHosts addObject:attributeDict[@"origin"]];
} else if ([elementName isEqualToString:@"content"]) {
- self.startPage = [attributeDict objectForKey:@"src"];
+ self.startPage = attributeDict[@"src"];
}
}
@@ -61,13 +67,4 @@
NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]);
}
-- (NSString*)getStartPage
-{
- if (self.startPage != nil) {
- return self.startPage;
- } else {
- return @"index.html";
- }
-}
-
@end
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m b/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
index 46195e8..cc7ad89 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
@@ -58,6 +58,7 @@
NSDictionary* temp = [CDVViewController getBundlePlist:@"Settings"];
if ([temp respondsToSelector:@selector(JSONString)]) {
+ NSLog(@"Deprecation warning: window.Setting will be removed Aug 2013. Refer to https://issues.apache.org/jira/browse/CB-2433");
NSString* js = [NSString stringWithFormat:@"window.Settings = %@;", [temp JSONString]];
[self.commandDelegate evalJs:js];
}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVFile.m b/lib/cordova-ios/CordovaLib/Classes/CDVFile.m
index 11b2b77..d52405d 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVFile.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVFile.m
@@ -22,6 +22,9 @@
#import "NSDictionary+Extensions.h"
#import "CDVJSON.h"
#import "NSData+Base64.h"
+#import <AssetsLibrary/ALAsset.h>
+#import <AssetsLibrary/ALAssetRepresentation.h>
+#import <AssetsLibrary/ALAssetsLibrary.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "CDVAvailability.h"
#import "sys/xattr.h"
@@ -434,9 +437,9 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
// arguments are URL encoded
NSString* fullPath = [command.arguments objectAtIndex:0];
- // return unsupported result for assets-library URLs
+ // we don't (yet?) support getting the parent of an asset
if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"remove not supported for assets-library URLs."];
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
return;
}
@@ -477,11 +480,33 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
{
// arguments
NSString* argPath = [command.arguments objectAtIndex:0];
+ __block CDVPluginResult* result = nil;
- // return unsupported result for assets-library URLs
if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getMetadata not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ // In this case, we need to use an asynchronous method to retrieve the file.
+ // Because of this, we can't just assign to `result` and send it at the end of the method.
+ // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset * asset) {
+ if (asset) {
+ // We have the asset! Retrieve the metadata and send it off.
+ NSDate* date = [asset valueForProperty:ALAssetPropertyDate];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[date timeIntervalSince1970] * 1000];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ } else {
+ // We couldn't find the asset. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ }
+ };
+ // TODO(maxw): Consider making this a class variable since it's the same every time.
+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError * error) {
+ // Retrieving the asset failed for some reason. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ };
+
+ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
+ [assetsLibrary assetForURL:[NSURL URLWithString:argPath] resultBlock:resultBlock failureBlock:failureBlock];
return;
}
@@ -489,7 +514,6 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
NSFileManager* fileMgr = [[NSFileManager alloc] init];
NSError* __autoreleasing error = nil;
- CDVPluginResult* result = nil;
NSDictionary* fileAttribs = [fileMgr attributesOfItemAtPath:testPath error:&error];
@@ -501,7 +525,7 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
} else {
// didn't get fileAttribs
CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [error localizedDescription]);
+ NSLog (@"error getting metadata: %@", [error localizedDescription]);
if ([error code] == NSFileNoSuchFileError) {
errorCode = NOT_FOUND_ERR;
}
@@ -524,34 +548,29 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
// arguments
NSString* filePath = [command.arguments objectAtIndex:0];
NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:nil];
-
- // return unsupported result for assets-library URLs
- if ([filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"setMetadata not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
CDVPluginResult* result = nil;
BOOL ok = NO;
- // we only care about this iCloud key for now.
- // set to 1/true to skip backup, set to 0/false to back it up (effectively removing the attribute)
- NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";
- id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];
-
- if ((iCloudBackupExtendedAttributeValue != nil) && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {
- if (IsAtLeastiOSVersion(@"5.1")) {
- NSURL* url = [NSURL fileURLWithPath:filePath];
- NSError* __autoreleasing error = nil;
-
- ok = [url setResourceValue:[NSNumber numberWithBool:[iCloudBackupExtendedAttributeValue boolValue]] forKey:NSURLIsExcludedFromBackupKey error:&error];
- } else { // below 5.1 (deprecated - only really supported in 5.01)
- u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
- if (value == 0) { // remove the attribute (allow backup, the default)
- ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
- } else { // set the attribute (skip backup)
- ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
+ // setMetadata doesn't make sense for asset library files
+ if (![filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ // we only care about this iCloud key for now.
+ // set to 1/true to skip backup, set to 0/false to back it up (effectively removing the attribute)
+ NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";
+ id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];
+
+ if ((iCloudBackupExtendedAttributeValue != nil) && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {
+ if (IsAtLeastiOSVersion(@"5.1")) {
+ NSURL* url = [NSURL fileURLWithPath:filePath];
+ NSError* __autoreleasing error = nil;
+
+ ok = [url setResourceValue:[NSNumber numberWithBool:[iCloudBackupExtendedAttributeValue boolValue]] forKey:NSURLIsExcludedFromBackupKey error:&error];
+ } else { // below 5.1 (deprecated - only really supported in 5.01)
+ u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
+ if (value == 0) { // remove the attribute (allow backup, the default)
+ ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
+ } else { // set the attribute (skip backup)
+ ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
+ }
}
}
}
@@ -570,26 +589,21 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
* 0 - NSString* fullPath
*
* returns NO_MODIFICATION_ALLOWED_ERR if is top level directory or no permission to delete dir
- * returns INVALID_MODIFICATION_ERR if is dir and is not empty
+ * returns INVALID_MODIFICATION_ERR if is non-empty dir or asset library file
* returns NOT_FOUND_ERR if file or dir is not found
*/
- (void)remove:(CDVInvokedUrlCommand*)command
{
// arguments
NSString* fullPath = [command.arguments objectAtIndex:0];
-
- // return unsupported result for assets-library URLs
- if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"remove not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
CDVPluginResult* result = nil;
CDVFileError errorCode = 0; // !! 0 not currently defined
- // error if try to remove top level (documents or tmp) dir
- if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
+ // return error for assets-library URLs
+ if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ errorCode = INVALID_MODIFICATION_ERR;
+ } else if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
+ // error if try to remove top level (documents or tmp) dir
errorCode = NO_MODIFICATION_ALLOWED_ERR;
} else {
NSFileManager* fileMgr = [[NSFileManager alloc] init];
@@ -738,14 +752,7 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
// optional argument
NSString* newName = ([arguments count] > 2) ? [arguments objectAtIndex:2] : [srcFullPath lastPathComponent]; // use last component from appPath if new name not provided
- // return unsupported result for assets-library URLs
- if ([srcFullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"moveTo/copyTo not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
+ __block CDVPluginResult* result = nil;
CDVFileError errCode = 0; // !! Currently 0 is not defined, use this to signal error !!
/*NSString* destRootPath = nil;
@@ -762,12 +769,59 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
errCode = ENCODING_ERR;
} else {
NSString* newFullPath = [destRootPath stringByAppendingPathComponent:newName];
+ NSFileManager* fileMgr = [[NSFileManager alloc] init];
if ([newFullPath isEqualToString:srcFullPath]) {
// source and destination can not be the same
errCode = INVALID_MODIFICATION_ERR;
- } else {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
+ } else if ([srcFullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ if (bCopy) {
+ // Copying (as opposed to moving) an assets library file is okay.
+ // In this case, we need to use an asynchronous method to retrieve the file.
+ // Because of this, we can't just assign to `result` and send it at the end of the method.
+ // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset * asset) {
+ if (asset) {
+ // We have the asset! Get the data and try to copy it over.
+ if (![fileMgr fileExistsAtPath:destRootPath]) {
+ // The destination directory doesn't exist.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ return;
+ } else if ([fileMgr fileExistsAtPath:newFullPath]) {
+ // A file already exists at the destination path.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:PATH_EXISTS_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ return;
+ }
+ // We're good to go! Write the file to the new destination.
+ ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
+ Byte* buffer = (Byte*)malloc ([assetRepresentation size]);
+ NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
+ NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
+ [data writeToFile:newFullPath atomically:YES];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:newFullPath isDirectory:NO]];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ } else {
+ // We couldn't find the asset. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ }
+ };
+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError * error) {
+ // Retrieving the asset failed for some reason. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ };
+
+ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
+ [assetsLibrary assetForURL:[NSURL URLWithString:srcFullPath] resultBlock:resultBlock failureBlock:failureBlock];
+ return;
+ } else {
+ // Moving an assets library file is not doable, since we can't remove it.
+ errCode = INVALID_MODIFICATION_ERR;
+ }
+ } else {
BOOL bSrcIsDir = NO;
BOOL bDestIsDir = NO;
BOOL bNewIsDir = NO;
@@ -890,37 +944,67 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
// arguments
NSString* argPath = [command.arguments objectAtIndex:0];
- // return unsupported result for assets-library URLs
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFileMetadata not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
+ __block CDVPluginResult* result = nil;
NSString* fullPath = argPath; // [self getFullPath: argPath];
if (fullPath) {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- BOOL bIsDir = NO;
- // make sure it exists and is not a directory
- BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
- if (!bExists || bIsDir) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ // In this case, we need to use an asynchronous method to retrieve the file.
+ // Because of this, we can't just assign to `result` and send it at the end of the method.
+ // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset * asset) {
+ if (asset) {
+ // We have the asset! Populate the dictionary and send it off.
+ NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
+ ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
+ [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[assetRepresentation size]] forKey:@"size"];
+ [fileInfo setObject:argPath forKey:@"fullPath"];
+ NSString* filename = [assetRepresentation filename];
+ [fileInfo setObject:filename forKey:@"name"];
+ [fileInfo setObject:[self getMimeTypeFromPath:filename] forKey:@"type"];
+ NSDate* creationDate = [asset valueForProperty:ALAssetPropertyDate];
+ NSNumber* msDate = [NSNumber numberWithDouble:[creationDate timeIntervalSince1970] * 1000];
+ [fileInfo setObject:msDate forKey:@"lastModifiedDate"];
+
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ } else {
+ // We couldn't find the asset. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ }
+ };
+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError * error) {
+ // Retrieving the asset failed for some reason. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ };
+
+ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
+ [assetsLibrary assetForURL:[NSURL URLWithString:argPath] resultBlock:resultBlock failureBlock:failureBlock];
+ return;
} else {
- // create dictionary of file info
- NSError* __autoreleasing error = nil;
- NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:&error];
- NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
- [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
- [fileInfo setObject:argPath forKey:@"fullPath"];
- [fileInfo setObject:@"" forKey:@"type"]; // can't easily get the mimetype unless create URL, send request and read response so skipping
- [fileInfo setObject:[argPath lastPathComponent] forKey:@"name"];
- NSDate* modDate = [fileAttrs fileModificationDate];
- NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
- [fileInfo setObject:msDate forKey:@"lastModifiedDate"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
+ NSFileManager* fileMgr = [[NSFileManager alloc] init];
+ BOOL bIsDir = NO;
+ // make sure it exists and is not a directory
+ BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
+ if (!bExists || bIsDir) {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ } else {
+ // create dictionary of file info
+ NSError* __autoreleasing error = nil;
+ NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:&error];
+ NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
+ [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
+ [fileInfo setObject:argPath forKey:@"fullPath"];
+ [fileInfo setObject:@"" forKey:@"type"]; // can't easily get the mimetype unless create URL, send request and read response so skipping
+ [fileInfo setObject:[argPath lastPathComponent] forKey:@"name"];
+ NSDate* modDate = [fileAttrs fileModificationDate];
+ NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
+ [fileInfo setObject:msDate forKey:@"lastModifiedDate"];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
+ }
}
}
if (!result) {
@@ -991,19 +1075,15 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
end = [[command.arguments objectAtIndex:3] integerValue];
}
- // return unsupported result for assets-library URLs
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"readAsText not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
// NSString* encoding = [command.arguments objectAtIndex:2]; // not currently used
CDVPluginResult* result = nil;
NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:argPath];
- if (!file) {
+ if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ // can't read assets-library URLs as text
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
+ } else if (!file) {
// invalid path entry
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
} else {
@@ -1054,18 +1134,41 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
end = [[command.arguments objectAtIndex:2] integerValue];
}
- // return unsupported result for assets-library URLs
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"readAsDataURL not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
CDVFileError errCode = ABORT_ERR;
- CDVPluginResult* result = nil;
+ __block CDVPluginResult* result = nil;
if (!argPath) {
errCode = SYNTAX_ERR;
+ } else if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
+ // In this case, we need to use an asynchronous method to retrieve the file.
+ // Because of this, we can't just assign to `result` and send it at the end of the method.
+ // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset * asset) {
+ if (asset) {
+ // We have the asset! Get the data and send it off.
+ ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
+ Byte* buffer = (Byte*)malloc ([assetRepresentation size]);
+ NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
+ NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
+ NSString* mimeType = [self getMimeTypeFromPath:[assetRepresentation filename]];
+ NSString* dataString = [NSString stringWithFormat:@"data:%@;base64,%@", mimeType, [data base64EncodedString]];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:dataString];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ } else {
+ // We couldn't find the asset. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ }
+ };
+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError * error) {
+ // Retrieving the asset failed for some reason. Send the appropriate error.
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+ };
+
+ ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
+ [assetsLibrary assetForURL:[NSURL URLWithString:argPath] resultBlock:resultBlock failureBlock:failureBlock];
+ return;
} else {
NSString* mimeType = [self getMimeTypeFromPath:argPath];
if (!mimeType) {
@@ -1134,9 +1237,9 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
NSString* argPath = [command.arguments objectAtIndex:0];
unsigned long long pos = (unsigned long long)[[command.arguments objectAtIndex:1] longLongValue];
- // return unsupported result for assets-library URLs
+ // assets-library files can't be truncated
if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"truncate not supported for assets-library URLs."];
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
return;
}
@@ -1181,9 +1284,9 @@ NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
NSString* argData = [arguments objectAtIndex:1];
unsigned long long pos = (unsigned long long)[[arguments objectAtIndex:2] longLongValue];
- // return unsupported result for assets-library URLs
+ // text can't be written into assets-library files
if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"write not supported for assets-library URLs."];
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
return;
}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2bb8baca/lib/cordova-ios/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVFileTransfer.h b/lib/cordova-ios/CordovaLib/Classes/CDVFileTransfer.h
index 5392236..f96bb7d 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVFileTransfer.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVFileTransfer.h
@@ -50,7 +50,8 @@ extern NSString* const kOptionsKeyCookie;
- (NSMutableDictionary*)createFileTransferError:(int)code
AndSource :(NSString*)source
AndTarget :(NSString*)target
- AndHttpStatus :(int)httpStatus;
+ AndHttpStatus :(int)httpStatus
+ AndBody :(NSString*)body;
@property (readonly) NSMutableDictionary* activeTransfers;
@end
@@ -64,6 +65,7 @@ extern NSString* const kOptionsKeyCookie;
@property (nonatomic, copy) NSString* objectId;
@property (nonatomic, copy) NSString* source;
@property (nonatomic, copy) NSString* target;
+@property (nonatomic, copy) NSString* mimeType;
@property (assign) int responseCode; // atomic
@property (nonatomic, assign) NSInteger bytesTransfered;
@property (nonatomic, assign) NSInteger bytesExpected;