You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/06/28 17:07:09 UTC
[01/50] [abbrv] ios commit: updated cordovajs,
removed globalization and camera
Updated Branches:
refs/heads/2.9.x 00e62aad4 -> eb6d5b928
refs/heads/master 9e48d8245 -> 66aeb9017
updated cordovajs, removed globalization and camera
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/cae2231c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/cae2231c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/cae2231c
Branch: refs/heads/master
Commit: cae2231c476532da6e42b7f116679853a056c2f8
Parents: 7d637e3
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 13:24:32 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 13 13:24:32 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 1972 +-------------------------------------------
1 file changed, 6 insertions(+), 1966 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cae2231c/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 22dd433..2e67604 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-84-g62c5786
+// 2.7.0rc1-100-g6a53312
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
// file: lib/scripts/require.js
var require,
@@ -1145,157 +1145,6 @@ module.exports = {
});
-// file: lib/common/plugin/Acceleration.js
-define("cordova/plugin/Acceleration", function(require, exports, module) {
-
-var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
-};
-
-module.exports = Acceleration;
-
-});
-
-// file: lib/common/plugin/Camera.js
-define("cordova/plugin/Camera", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants'),
- CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
- options = options || {};
- var getValue = argscheck.getValue;
-
- var quality = getValue(options.quality, 50);
- var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
- var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
- var targetWidth = getValue(options.targetWidth, -1);
- var targetHeight = getValue(options.targetHeight, -1);
- var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
- var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
- var allowEdit = !!options.allowEdit;
- var correctOrientation = !!options.correctOrientation;
- var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
- var popoverOptions = getValue(options.popoverOptions, null);
- var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
-
- var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
-
- exec(successCallback, errorCallback, "Camera", "takePicture", args);
- return new CameraPopoverHandle();
-};
-
-cameraExport.cleanup = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "Camera", "cleanup", []);
-};
-
-module.exports = cameraExport;
-
-});
-
-// file: lib/common/plugin/CameraConstants.js
-define("cordova/plugin/CameraConstants", function(require, exports, module) {
-
-module.exports = {
- 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)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- 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)
- },
- PopoverArrowDirection:{
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- },
- Direction:{
- BACK: 0,
- FRONT: 1
- }
-};
-
-});
-
-// file: lib/ios/plugin/CameraPopoverHandle.js
-define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * A handle to an image picker popover.
- */
-var CameraPopoverHandle = function() {
- this.setPosition = function(popoverOptions) {
- var args = [ popoverOptions ];
- exec(null, null, "Camera", "repositionPopover", args);
- };
-};
-
-module.exports = CameraPopoverHandle;
-
-});
-
-// file: lib/common/plugin/CameraPopoverOptions.js
-define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
-
-var Camera = require('cordova/plugin/CameraConstants');
-
-/**
- * Encapsulates options for iOS Popover image picker
- */
-var CameraPopoverOptions = function(x,y,width,height,arrowDir){
- // information of rectangle that popover should be anchored to
- this.x = x || 0;
- this.y = y || 32;
- this.width = width || 320;
- this.height = height || 480;
- // The direction of the popover arrow
- this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
-};
-
-module.exports = CameraPopoverOptions;
-
-});
-
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
@@ -1370,39 +1219,6 @@ module.exports = CaptureVideoOptions;
});
-// file: lib/common/plugin/CompassError.js
-define("cordova/plugin/CompassError", function(require, exports, module) {
-
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
-
-});
-
-// file: lib/common/plugin/CompassHeading.js
-define("cordova/plugin/CompassHeading", function(require, exports, module) {
-
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = magneticHeading;
- this.trueHeading = trueHeading;
- this.headingAccuracy = headingAccuracy;
- this.timestamp = timestamp || new Date().getTime();
-};
-
-module.exports = CompassHeading;
-
-});
-
// file: lib/common/plugin/ConfigurationData.js
define("cordova/plugin/ConfigurationData", function(require, exports, module) {
@@ -1443,322 +1259,6 @@ module.exports = {
});
-// file: lib/common/plugin/Contact.js
-define("cordova/plugin/Contact", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-}
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value !== null) {
- // try to make it a Date object if it is not already
- if (!utils.isDate(value)){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (utils.isDate(value)){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-}
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- argscheck.checkArgs('FF', 'Contact.remove', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- clonedContact.id = null;
- clonedContact.rawId = null;
-
- function nullIds(arr) {
- if (arr) {
- for (var i = 0; i < arr.length; ++i) {
- arr[i].id = null;
- }
- }
- }
-
- // Loop through and clear out any id's in phones, emails, etc.
- nullIds(clonedContact.phoneNumbers);
- nullIds(clonedContact.emails);
- nullIds(clonedContact.addresses);
- nullIds(clonedContact.ims);
- nullIds(clonedContact.organizations);
- nullIds(clonedContact.categories);
- nullIds(clonedContact.photos);
- nullIds(clonedContact.urls);
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- argscheck.checkArgs('FFO', 'Contact.save', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (successCB) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
-
-});
-
-// file: lib/common/plugin/ContactAddress.js
-define("cordova/plugin/ContactAddress", function(require, exports, module) {
-
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
-
-});
-
-// file: lib/common/plugin/ContactError.js
-define("cordova/plugin/ContactError", function(require, exports, module) {
-
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
-
-});
-
-// file: lib/common/plugin/ContactField.js
-define("cordova/plugin/ContactField", function(require, exports, module) {
-
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = (type && type.toString()) || null;
- this.value = (value && value.toString()) || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
-
-});
-
-// file: lib/common/plugin/ContactFindOptions.js
-define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
-
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
-
-});
-
-// file: lib/common/plugin/ContactName.js
-define("cordova/plugin/ContactName", function(require, exports, module) {
-
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
-
-});
-
-// file: lib/common/plugin/ContactOrganization.js
-define("cordova/plugin/ContactOrganization", function(require, exports, module) {
-
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
-
-});
-
// file: lib/common/plugin/Coordinates.js
define("cordova/plugin/Coordinates", function(require, exports, module) {
@@ -3249,111 +2749,6 @@ module.exports = Flags;
});
-// file: lib/common/plugin/GlobalizationError.js
-define("cordova/plugin/GlobalizationError", function(require, exports, module) {
-
-
-/**
- * Globalization error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var GlobalizationError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-// Globalization error codes
-GlobalizationError.UNKNOWN_ERROR = 0;
-GlobalizationError.FORMATTING_ERROR = 1;
-GlobalizationError.PARSING_ERROR = 2;
-GlobalizationError.PATTERN_ERROR = 3;
-
-module.exports = GlobalizationError;
-
-});
-
-// file: lib/common/plugin/InAppBrowser.js
-define("cordova/plugin/InAppBrowser", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var channel = require('cordova/channel');
-var modulemapper = require('cordova/modulemapper');
-
-function InAppBrowser() {
- this.channels = {
- 'loadstart': channel.create('loadstart'),
- 'loadstop' : channel.create('loadstop'),
- 'loaderror' : channel.create('loaderror'),
- 'exit' : channel.create('exit')
- };
-}
-
-InAppBrowser.prototype = {
- _eventHandler: function (event) {
- if (event.type in this.channels) {
- this.channels[event.type].fire(event);
- }
- },
- close: function (eventname) {
- exec(null, null, "InAppBrowser", "close", []);
- },
- show: function (eventname) {
- exec(null, null, "InAppBrowser", "show", []);
- },
- addEventListener: function (eventname,f) {
- if (eventname in this.channels) {
- this.channels[eventname].subscribe(f);
- }
- },
- removeEventListener: function(eventname, f) {
- if (eventname in this.channels) {
- this.channels[eventname].unsubscribe(f);
- }
- },
-
- executeScript: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('executeScript requires exactly one of code or file to be specified');
- }
- },
-
- insertCSS: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('insertCSS requires exactly one of code or file to be specified');
- }
- }
-};
-
-module.exports = function(strUrl, strWindowName, strWindowFeatures) {
- var iab = new InAppBrowser();
- var cb = function(eventname) {
- iab._eventHandler(eventname);
- };
-
- // Don't catch calls that write to existing frames (e.g. named iframes).
- if (window.frames && window.frames[strWindowName]) {
- var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
- return origOpenFunc.apply(window, arguments);
- }
-
- exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
- return iab;
-};
-
-
-});
-
// file: lib/common/plugin/LocalFileSystem.js
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
@@ -3673,47 +3068,6 @@ module.exports = Metadata;
});
-// file: lib/common/plugin/Position.js
-define("cordova/plugin/Position", function(require, exports, module) {
-
-var Coordinates = require('cordova/plugin/Coordinates');
-
-var Position = function(coords, timestamp) {
- if (coords) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
- } else {
- this.coords = new Coordinates();
- }
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
-};
-
-module.exports = Position;
-
-});
-
-// file: lib/common/plugin/PositionError.js
-define("cordova/plugin/PositionError", function(require, exports, module) {
-
-/**
- * Position error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var PositionError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-PositionError.PERMISSION_DENIED = 1;
-PositionError.POSITION_UNAVAILABLE = 2;
-PositionError.TIMEOUT = 3;
-
-module.exports = PositionError;
-
-});
-
// file: lib/common/plugin/ProgressEvent.js
define("cordova/plugin/ProgressEvent", function(require, exports, module) {
@@ -3766,283 +3120,11 @@ module.exports = ProgressEvent;
});
-// file: lib/common/plugin/accelerometer.js
-define("cordova/plugin/accelerometer", function(require, exports, module) {
-
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var argscheck = require('cordova/argscheck'),
- utils = require("cordova/utils"),
- exec = require("cordova/exec"),
- Acceleration = require('cordova/plugin/Acceleration');
+// file: lib/common/plugin/capture.js
+define("cordova/plugin/capture", function(require, exports, module) {
-// Is the accel sensor running?
-var running = false;
-
-// Keeps reference to watchAcceleration calls.
-var timers = {};
-
-// Array of listeners; used to keep track of when we should call start and stop.
-var listeners = [];
-
-// Last returned acceleration object from native
-var accel = null;
-
-// Tells native to start.
-function start() {
- exec(function(a) {
- var tempListeners = listeners.slice(0);
- accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].win(accel);
- }
- }, function(e) {
- var tempListeners = listeners.slice(0);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].fail(e);
- }
- }, "Accelerometer", "start", []);
- running = true;
-}
-
-// Tells native to stop.
-function stop() {
- exec(null, null, "Accelerometer", "stop", []);
- running = false;
-}
-
-// Adds a callback pair to the listeners array
-function createCallbackPair(win, fail) {
- return {win:win, fail:fail};
-}
-
-// Removes a win/fail listener pair from the listeners array
-function removeListeners(l) {
- var idx = listeners.indexOf(l);
- if (idx > -1) {
- listeners.splice(idx, 1);
- if (listeners.length === 0) {
- stop();
- }
- }
-}
-
-var accelerometer = {
- /**
- * Asynchronously acquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
-
- var p;
- var win = function(a) {
- removeListeners(p);
- successCallback(a);
- };
- var fail = function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- };
-
- p = createCallbackPair(win, fail);
- listeners.push(p);
-
- if (!running) {
- start();
- }
- },
-
- /**
- * Asynchronously acquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
- // Default interval (10 sec)
- var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
-
- // Keep reference to watch id, and report accel readings as often as defined in frequency
- var id = utils.createUUID();
-
- var p = createCallbackPair(function(){}, function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- });
- listeners.push(p);
-
- timers[id] = {
- timer:window.setInterval(function() {
- if (accel) {
- successCallback(accel);
- }
- }, frequency),
- listeners:p
- };
-
- if (running) {
- // If we're already running then immediately invoke the success callback
- // but only if we have retrieved a value, sample code does not check for null ...
- if (accel) {
- successCallback(accel);
- }
- } else {
- start();
- }
-
- return id;
- },
-
- /**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
- clearWatch: function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- window.clearInterval(timers[id].timer);
- removeListeners(timers[id].listeners);
- delete timers[id];
- }
- }
-};
-
-module.exports = accelerometer;
-
-});
-
-// file: lib/common/plugin/accelerometer/symbols.js
-define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
-modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
-
-});
-
-// file: lib/common/plugin/battery.js
-define("cordova/plugin/battery", function(require, exports, module) {
-
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
-
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus"),
- batterylow:cordova.addWindowEventHandler("batterylow"),
- batterycritical:cordova.addWindowEventHandler("batterycritical")
- };
- for (var key in this.channels) {
- this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
- }
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.onHasSubscribersChange = function() {
- // If we just registered the first handler, make sure native listener is started.
- if (this.numHandlers === 1 && handlers() === 1) {
- exec(battery._status, battery._error, "Battery", "start", []);
- } else if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
-
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
-
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
- }
- }
- }
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
-
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
-
-var battery = new Battery();
-
-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) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
+var exec = require('cordova/exec'),
+ MediaFile = require('cordova/plugin/MediaFile');
/**
* Launches a capture of different types.
@@ -4132,105 +3214,6 @@ modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
});
-// file: lib/common/plugin/compass.js
-define("cordova/plugin/compass", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- utils = require('cordova/utils'),
- CompassHeading = require('cordova/plugin/CompassHeading'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
-
- var win = function(result) {
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- successCallback(ch);
- };
- var fail = errorCallback && function(code) {
- var ce = new CompassError(code);
- errorCallback(ce);
- };
-
- // Get heading
- exec(win, fail, "Compass", "getHeading", [options]);
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
- // Default interval (100 msec)
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- var id = utils.createUUID();
- if (filter > 0) {
- // is an iOS request for watch by filter, no timer needed
- timers[id] = "iOS";
- compass.getCurrentHeading(successCallback, errorCallback, options);
- } else {
- // Start watch timer to get headings
- timers[id] = window.setInterval(function() {
- compass.getCurrentHeading(successCallback, errorCallback);
- }, frequency);
- }
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
- // is iOS watch by filter so call into device to stop
- exec(null, null, "Compass", "stopHeading", []);
- }
- delete timers[id];
- }
- }
- };
-
-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) {
@@ -4403,84 +3386,6 @@ for (var key in console) {
});
-// file: lib/common/plugin/contacts.js
-define("cordova/plugin/contacts", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var contacts = {
- /**
- * Returns an array of Contacts matching the search criteria.
- * @param fields that should be searched
- * @param successCB success callback
- * @param errorCB error callback
- * @param {ContactFindOptions} options that can be applied to contact searching
- * @return array of Contacts matching search criteria
- */
- find:function(fields, successCB, errorCB, options) {
- argscheck.checkArgs('afFO', 'contacts.find', arguments);
- if (!fields.length) {
- errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- } else {
- var win = function(result) {
- var cs = [];
- for (var i = 0, l = result.length; i < l; i++) {
- cs.push(contacts.create(result[i]));
- }
- successCB(cs);
- };
- exec(win, errorCB, "Contacts", "search", [fields, options]);
- }
- },
-
- /**
- * This function creates a new contact, but it does not persist the contact
- * to device storage. To persist the contact to device storage, invoke
- * contact.save().
- * @param properties an object whose properties will be examined to create a new Contact
- * @returns new Contact object
- */
- create:function(properties) {
- argscheck.checkArgs('O', 'contacts.create', arguments);
- var contact = new Contact();
- for (var i in properties) {
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
- contact[i] = properties[i];
- }
- }
- return contact;
- }
-};
-
-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) {
@@ -4638,648 +3543,6 @@ modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
});
-// file: lib/common/plugin/geolocation.js
-define("cordova/plugin/geolocation", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('cordova/plugin/PositionError'),
- Position = require('cordova/plugin/Position');
-
-var timers = {}; // list of timers in use
-
-// Returns default params, overrides if provided with values
-function parseParameters(options) {
- var opt = {
- maximumAge: 0,
- enableHighAccuracy: false,
- timeout: Infinity
- };
-
- if (options) {
- if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
- opt.maximumAge = options.maximumAge;
- }
- if (options.enableHighAccuracy !== undefined) {
- opt.enableHighAccuracy = options.enableHighAccuracy;
- }
- if (options.timeout !== undefined && !isNaN(options.timeout)) {
- if (options.timeout < 0) {
- opt.timeout = 0;
- } else {
- opt.timeout = options.timeout;
- }
- }
- }
-
- return opt;
-}
-
-// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
- clearTimeout(t);
- t = null;
- errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
- });
- }, timeout);
- return t;
-}
-
-var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
- /**
- * Asynchronously acquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
- */
- getCurrentPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- // Timer var that will fire an error callback if no position is retrieved from native
- // before the "timeout" param provided expires
- var timeoutTimer = {timer:null};
-
- var win = function(p) {
- clearTimeout(timeoutTimer.timer);
- if (!(timeoutTimer.timer)) {
- // Timeout already happened, or native fired error callback for
- // this geo request.
- // Don't continue with success callback.
- return;
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
- var fail = function(e) {
- clearTimeout(timeoutTimer.timer);
- timeoutTimer.timer = null;
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
- // fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
- successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
- } else if (options.timeout === 0) {
- fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
- });
- // Otherwise we have to call into native to retrieve a position.
- } else {
- if (options.timeout !== Infinity) {
- // If the timeout value was not set to Infinity (default), then
- // set up a timeout function that will fire the error callback
- // if no successful position was retrieved before timeout expired.
- timeoutTimer.timer = createTimeout(fail, options.timeout);
- } else {
- // This is here so the check in the win function doesn't mess stuff up
- // may seem weird but this guarantees timeoutTimer is
- // always truthy before we call into native
- timeoutTimer.timer = true;
- }
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
- }
- return timeoutTimer;
- },
- /**
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
- * the successCallback is called with the new location.
- *
- * @param {Function} successCallback The function to call each time the location data is available
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- var id = utils.createUUID();
-
- // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
- timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
-
- var fail = function(e) {
- clearTimeout(timers[id].timer);
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- var win = function(p) {
- clearTimeout(timers[id].timer);
- if (options.timeout !== Infinity) {
- timers[id].timer = createTimeout(fail, options.timeout);
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
-
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
-
- return id;
- },
- /**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchPosition
- */
- clearWatch:function(id) {
- if (id && timers[id] !== undefined) {
- clearTimeout(timers[id].timer);
- timers[id].timer = false;
- exec(null, null, "Geolocation", "clearWatch", [id]);
- }
- }
-};
-
-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) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- GlobalizationError = require('cordova/plugin/GlobalizationError');
-
-var globalization = {
-
-/**
-* Returns the string identifier for the client's current language.
-* It returns the language identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the language,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The language identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
-* function () {});
-*/
-getPreferredLanguage:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
- exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
-},
-
-/**
-* Returns the string identifier for the client's current locale setting.
-* It returns the locale identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the locale,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The locale identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
-* function () {});
-*/
-getLocaleName:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
- exec(successCB, failureCB, "Globalization","getLocaleName", []);
-},
-
-
-/**
-* Returns a date formatted as a string according to the client's user preferences and
-* calendar using the time zone of the client. It returns the formatted date string to the
-* successCB callback with a properties object as a parameter. If there is an error
-* formatting the date, then the errorCB callback is invoked.
-*
-* The defaults are: formatLenght="short" and selector="date and time"
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.value {String}: The localized date string
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.dateToString(new Date(),
-* function (date) {alert('date:' + date.value + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {formatLength:'short'});
-*/
-dateToString:function(date, successCB, failureCB, options) {
- argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
-},
-
-
-/**
-* Parses a date formatted as a string according to the client's user
-* preferences and calendar using the time zone of the client and returns
-* the corresponding date object. It returns the date to the successCB
-* callback with a properties object as a parameter. If there is an error
-* parsing the date string, then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {String} dateString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.year {Number}: The four digit year
-* Object.month {Number}: The month from (0 - 11)
-* Object.day {Number}: The day from (1 - 31)
-* Object.hour {Number}: The hour from (0 - 23)
-* Object.minute {Number}: The minute from (0 - 59)
-* Object.second {Number}: The second from (0 - 59)
-* Object.millisecond {Number}: The milliseconds (from 0 - 999),
-* not available on all platforms
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToDate('4/11/2011',
-* function (date) { alert('Month:' + date.month + '\n' +
-* 'Day:' + date.day + '\n' +
-* 'Year:' + date.year + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {selector:'date'});
-*/
-stringToDate:function(dateString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
- exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
-},
-
-
-/**
-* Returns a pattern string for formatting and parsing dates according to the client's
-* user preferences. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern,
-* then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.timezone {String}: The abbreviated name of the time zone on the client
-* Object.utc_offset {Number}: The current difference in seconds between the client's
-* time zone and coordinated universal time.
-* Object.dst_offset {Number}: The current daylight saving time offset in seconds
-* between the client's non-daylight saving's time zone
-* and the client's daylight saving's time zone.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getDatePattern(
-* function (date) {alert('pattern:' + date.pattern + '\n');},
-* function () {},
-* {formatLength:'short'});
-*/
-getDatePattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
- exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
-},
-
-
-/**
-* Returns an array of either the names of the months or days of the week
-* according to the client's user preferences and calendar. It returns the array of names to the
-* successCB callback with a properties object as a parameter. If there is an error obtaining the
-* names, then the errorCB callback is invoked.
-*
-* The defaults are: type="wide" and item="months"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'narrow' or 'wide'
-* item {String}: 'months', or 'days'
-*
-* @return Object.value {Array{String}}: The array of names starting from either
-* the first month in the year or the
-* first day of the week.
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getDateNames(function (names) {
-* for(var i = 0; i < names.value.length; i++) {
-* alert('Month:' + names.value[i] + '\n');}},
-* function () {});
-*/
-getDateNames:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
- exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
-},
-
-/**
-* Returns whether daylight savings time is in effect for a given date using the client's
-* time zone and calendar. It returns whether or not daylight savings time is in effect
-* to the successCB callback with a properties object as a parameter. If there is an error
-* reading the date, then the errorCB callback is invoked.
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
-* in effect for the given date and "false" indicate that it is not.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.isDayLightSavingsTime(new Date(),
-* function (date) {alert('dst:' + date.dst + '\n');}
-* function () {});
-*/
-isDayLightSavingsTime:function(date, successCB, failureCB) {
- argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
-},
-
-/**
-* Returns the first day of the week according to the client's user preferences and calendar.
-* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
-* It returns the day to the successCB callback with a properties object as a parameter.
-* If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {Number}: The number of the first day of the week.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getFirstDayOfWeek(function (day)
-* { alert('Day:' + day.value + '\n');},
-* function () {});
-*/
-getFirstDayOfWeek:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
- exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
-},
-
-
-/**
-* Returns a number formatted as a string according to the client's user preferences.
-* It returns the formatted number string to the successCB callback with a properties object as a
-* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Number} number
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {String}: The formatted number string.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.numberToString(3.25,
-* function (number) {alert('number:' + number.value + '\n');},
-* function () {},
-* {type:'decimal'});
-*/
-numberToString:function(number, successCB, failureCB, options) {
- argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
- exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
-},
-
-/**
-* Parses a number formatted as a string according to the client's user preferences and
-* returns the corresponding number. It returns the number to the successCB callback with a
-* properties object as a parameter. If there is an error parsing the number string, then
-* the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {String} numberString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {Number}: The parsed number.
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToNumber('1234.56',
-* function (number) {alert('Number:' + number.value + '\n');},
-* function () { alert('Error parsing number');});
-*/
-stringToNumber:function(numberString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
- exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing numbers according to the client's user
-* preferences. It returns the pattern to the successCB callback with a properties object as a
-* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
-* The patterns follow Unicode Technical Standard #35.
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.symbol {String}: The symbol to be used when formatting and parsing
-* e.g., percent or currency symbol.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting numbers.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
-* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getNumberPattern(
-* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
-* function () {});
-*/
-getNumberPattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing currency values according to the client's
-* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
-* callback is invoked.
-*
-* @param {String} currencyCode
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.code {String}: The ISO 4217 currency code for the pattern.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting currency.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.getCurrencyPattern('EUR',
-* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
-* function () {});
-*/
-getCurrencyPattern:function(currencyCode, successCB, failureCB) {
- argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
-}
-
-};
-
-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/ios/plugin/inappbrowser/symbols.js
-define("cordova/plugin/inappbrowser/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/InAppBrowser', 'open');
-
-});
-
-// file: lib/ios/plugin/ios/Contact.js
-define("cordova/plugin/ios/Contact", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError');
-
-/**
- * Provides iOS Contact.display API.
- */
-module.exports = {
- display : function(errorCB, options) {
- /*
- * Display a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- */
-
- if (this.id === null) {
- if (typeof errorCB === "function") {
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
- errorCB(errorObj);
- }
- }
- else {
- exec(null, errorCB, "Contacts","displayContact", [this.id, options]);
- }
- }
-};
-
-});
-
// file: lib/ios/plugin/ios/Entry.js
define("cordova/plugin/ios/Entry", function(require, exports, module) {
@@ -5297,74 +3560,6 @@ module.exports = {
});
-// file: lib/ios/plugin/ios/contacts.js
-define("cordova/plugin/ios/contacts", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Provides iOS enhanced contacts API.
- */
-module.exports = {
- newContactUI : function(successCallback) {
- /*
- * Create a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * returns: the id of the created contact as param to successCallback
- */
- exec(successCallback, null, "Contacts","newContact", []);
- },
- chooseContact : function(successCallback, options) {
- /*
- * Select a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- * fields: array of fields to return in contact object (see ContactOptions.fields)
- *
- * @returns
- * id of contact selected
- * ContactObject
- * if no fields provided contact contains just id information
- * if fields provided contact object contains information for the specified fields
- *
- */
- var win = function(result) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCallback(fullContact.id, fullContact);
- };
- exec(win, null, "Contacts","chooseContact", [options]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts/symbols.js
-define("cordova/plugin/ios/contacts/symbols", function(require, exports, module) {
-
-require('cordova/plugin/contacts/symbols');
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/ios/contacts', 'navigator.contacts');
-modulemapper.merges('cordova/plugin/ios/Contact', 'Contact');
-
-});
-
-// file: lib/ios/plugin/ios/geolocation/symbols.js
-define("cordova/plugin/ios/geolocation/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/geolocation', 'navigator.geolocation');
-
-});
-
// file: lib/ios/plugin/ios/logger/plugininit.js
define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
@@ -5384,19 +3579,6 @@ modulemapper.clobbers('cordova/plugin/logger', 'console');
});
-// file: lib/ios/plugin/ios/notification.js
-define("cordova/plugin/ios/notification", function(require, exports, module) {
-
-var Media = require('cordova/plugin/Media');
-
-module.exports = {
- beep:function(count) {
- (new Media('beep.wav')).play();
- }
-};
-
-});
-
// file: lib/common/plugin/logger.js
define("cordova/plugin/logger", function(require, exports, module) {
@@ -5832,120 +4014,6 @@ modulemapper.defaults('cordova/plugin/Connection', 'Connection');
});
-// file: lib/common/plugin/notification.js
-define("cordova/plugin/notification", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var platform = require('cordova/platform');
-
-/**
- * Provides access to notifications on the device.
- */
-
-module.exports = {
-
- /**
- * Open a native alert dialog, with a customizable title and button text.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Alert)
- * @param {String} buttonLabel Label of the close button (default: OK)
- */
- alert: function(message, completeCallback, title, buttonLabel) {
- var _title = (title || "Alert");
- var _buttonLabel = (buttonLabel || "OK");
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
- },
-
- /**
- * Open a native confirm dialog, with a customizable title and button text.
- * The result that the user selects is returned to the result callback.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Confirm)
- * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
- */
- confirm: function(message, resultCallback, title, buttonLabels) {
- var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
-
- // Strings are deprecated!
- if (typeof _buttonLabels === 'string') {
- console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
- }
-
- // Some platforms take an array of button label names.
- // Other platforms take a comma separated list.
- // For compatibility, we convert to the desired type based on the platform.
- if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
- if (typeof _buttonLabels === 'string') {
- var buttonLabelString = _buttonLabels;
- _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
- }
- } else {
- if (Array.isArray(_buttonLabels)) {
- var buttonLabelArray = _buttonLabels;
- _buttonLabels = buttonLabelArray.toString();
- }
- }
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
- },
-
- /**
- * Open a native prompt dialog, with a customizable title and button text.
- * The following results are returned to the result callback:
- * buttonIndex Index number of the button selected.
- * input1 The text entered in the prompt dialog box.
- *
- * @param {String} message Dialog message to display (default: "Prompt message")
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the dialog (default: "Prompt")
- * @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
- * @param {String} defaultText Textbox input value (default: "Default text")
- */
- prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
- var _message = (message || "Prompt message");
- var _title = (title || "Prompt");
- var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
- var _defaultText = (defaultText || "Default text");
- exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
- },
-
- /**
- * Causes the device to vibrate.
- *
- * @param {Integer} mills The number of milliseconds to vibrate for.
- */
- vibrate: function(mills) {
- exec(null, null, "Notification", "vibrate", [mills]);
- },
-
- /**
- * Causes the device to beep.
- * On Android, the default notification ringtone is played "count" times.
- *
- * @param {Integer} count The number of beeps.
- */
- beep: function(count) {
- exec(null, null, "Notification", "beep", [count]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/notification/symbols.js
-define("cordova/plugin/notification/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/notification', 'navigator.notification');
-modulemapper.merges('cordova/plugin/ios/notification', 'navigator.notification');
-
-});
-
// file: lib/common/plugin/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
@@ -6041,34 +4109,6 @@ module.exports = function(uri, successCallback, errorCallback) {
});
-// file: lib/common/plugin/splashscreen.js
-define("cordova/plugin/splashscreen", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-var splashscreen = {
- show:function() {
- exec(null, null, "SplashScreen", "show", []);
- },
- hide:function() {
- exec(null, null, "SplashScreen", "hide", []);
- }
-};
-
-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/common/symbols.js
define("cordova/symbols", function(require, exports, module) {
[04/50] [abbrv] ios commit: updated cordovajs
Posted by ag...@apache.org.
updated cordovajs
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/1b5b123b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/1b5b123b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/1b5b123b
Branch: refs/heads/master
Commit: 1b5b123b928038916fef030f1204b679d115522c
Parents: 83b0ad7
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 15:56:37 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 13 15:56:37 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 58 ++--------------------------------------------
1 file changed, 2 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1b5b123b/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 574a571..e05b317 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-101-gc6482ac
+// 2.7.0rc1-116-gf0108ae
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
// file: lib/scripts/require.js
var require,
@@ -1259,60 +1259,6 @@ module.exports = {
});
-// file: lib/common/plugin/Coordinates.js
-define("cordova/plugin/Coordinates", function(require, exports, module) {
-
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = (alt !== undefined ? alt : null);
- /**
- * The direction the device is moving at the position.
- */
- this.heading = (head !== undefined ? head : null);
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = (vel !== undefined ? vel : null);
-
- if (this.speed === 0 || this.speed === null) {
- this.heading = NaN;
- }
-
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
-
-});
-
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
[45/50] [abbrv] ios commit: Updated js to 2.9.0
Posted by ag...@apache.org.
Updated js to 2.9.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/d5103866
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/d5103866
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/d5103866
Branch: refs/heads/2.9.x
Commit: d5103866d2c36f1c4d82aaac9badbcd98684aba1
Parents: f7b82da
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Jun 25 16:20:05 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Jun 25 16:20:05 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d5103866/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index b2fc871..fd8aa39 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.9.0rc1-0-g002f33d
+// 2.9.0-0-g83dc4bd
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
+var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
// file: lib/scripts/require.js
var require,
@@ -923,7 +923,7 @@ function iOSExec() {
actionArgs = Array.prototype.splice.call(arguments, 1);
console.log('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' +
- "cordova.exec(null, null, \"" + service + "\", " + action + "\"," + JSON.stringify(actionArgs) + ");"
+ "cordova.exec(null, null, \"" + service + "\", \"" + action + "\"," + JSON.stringify(actionArgs) + ");"
);
return;
} catch (e) {
[09/50] [abbrv] ios commit: fixed duplication with file plugin issue
Posted by ag...@apache.org.
fixed duplication with file plugin issue
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8159679a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8159679a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8159679a
Branch: refs/heads/master
Commit: 8159679afc6ed6399cea61418510edb470591ce3
Parents: b6869e1
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:18:49 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 17:18:49 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVURLProtocol.m | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8159679a/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
index 3c85f34..9bd4050 100644
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ b/CordovaLib/Classes/CDVURLProtocol.m
@@ -35,7 +35,7 @@ static CDVWhitelist* gWhitelist = nil;
// the actual pointer to avoid retaining.
static NSMutableSet* gRegisteredControllers = nil;
-NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
+NSString* const kCDVAssetsLibraryPrefixs = @"assets-library://";
// Returns the registered view controller that sent the given request.
// If the user-agent is not from a UIWebView, or if it's from an unregistered one,
@@ -110,7 +110,7 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
NSURL* theUrl = [theRequest URL];
CDVViewController* viewController = viewControllerForRequest(theRequest);
- if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
+ if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixs]) {
return YES;
} else if (viewController != nil) {
if ([[theUrl path] isEqualToString:@"/!gap_exec"]) {
@@ -159,7 +159,7 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
if ([[url path] isEqualToString:@"/!gap_exec"]) {
[self sendResponseWithResponseCode:200 data:nil mimeType:nil];
return;
- } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
+ } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixs]) {
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
if (asset) {
// We have the asset! Get the data and send it along.
[07/50] [abbrv] ios commit: removed device, capture, file,
filetransfer
Posted by ag...@apache.org.
removed device, capture, file, filetransfer
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b428f241
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b428f241
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b428f241
Branch: refs/heads/master
Commit: b428f241d87d176d2a9961a7c0d462a2d460da00
Parents: 1b5b123
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 16:59:45 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 16:59:45 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 4 -
CordovaLib/Classes/CDVCapture.h | 118 --
CordovaLib/Classes/CDVCapture.m | 845 -----------
CordovaLib/Classes/CDVDevice.h | 30 -
CordovaLib/Classes/CDVDevice.m | 89 --
CordovaLib/Classes/CDVFile.h | 106 --
CordovaLib/Classes/CDVFile.m | 1414 ------------------
CordovaLib/Classes/CDVFileTransfer.h | 82 -
CordovaLib/Classes/CDVFileTransfer.m | 730 ---------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 34 +-
bin/templates/project/__TESTING__/config.xml | 12 -
11 files changed, 1 insertion(+), 3463 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 03c2a3e..cef896b 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,12 +25,8 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVCapture.h"
#import "CDVConnection.h"
#import "CDVDebug.h"
-#import "CDVDevice.h"
-#import "CDVFile.h"
-#import "CDVFileTransfer.h"
#import "CDVPluginResult.h"
#import "CDVReachability.h"
#import "CDVSound.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVCapture.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h
deleted file mode 100644
index afb82b4..0000000
--- a/CordovaLib/Classes/CDVCapture.h
+++ /dev/null
@@ -1,118 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <AVFoundation/AVFoundation.h>
-#import "CDVPlugin.h"
-#import "CDVFile.h"
-
-enum CDVCaptureError {
- CAPTURE_INTERNAL_ERR = 0,
- CAPTURE_APPLICATION_BUSY = 1,
- CAPTURE_INVALID_ARGUMENT = 2,
- CAPTURE_NO_MEDIA_FILES = 3,
- CAPTURE_NOT_SUPPORTED = 20
-};
-typedef NSUInteger CDVCaptureError;
-
-@interface CDVImagePicker : UIImagePickerController
-{
- NSString* callbackid;
- NSInteger quality;
- NSString* mimeType;
-}
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* mimeType;
-
-@end
-
-@interface CDVCapture : CDVPlugin <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
-{
- CDVImagePicker* pickerController;
- BOOL inUse;
-}
-@property BOOL inUse;
-- (void)captureAudio:(CDVInvokedUrlCommand*)command;
-- (void)captureImage:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId;
-- (void)captureVideo:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId;
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command;
-- (void)getFormatData:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-
-@end
-
-@interface CDVAudioNavigationController : UINavigationController
-
-@end
-
-/* AudioRecorderViewController is used to create a simple view for audio recording.
- * It is created from [Capture captureAudio]. It creates a very simple interface for
- * recording by presenting just a record/stop button and a Done button to close the view.
- * The recording time is displayed and recording for a specified duration is supported. When duration
- * is specified there is no UI to the user - recording just stops when the specified
- * duration is reached. The UI has been minimized to avoid localization.
- */
-@interface CDVAudioRecorderViewController : UIViewController <AVAudioRecorderDelegate>
-{
- CDVCaptureError errorCode;
- NSString* callbackId;
- NSNumber* duration;
- CDVCapture* captureCommand;
- UIBarButtonItem* doneButton;
- UIView* recordingView;
- UIButton* recordButton;
- UIImage* recordImage;
- UIImage* stopRecordImage;
- UILabel* timerLabel;
- AVAudioRecorder* avRecorder;
- AVAudioSession* avSession;
- CDVPluginResult* pluginResult;
- NSTimer* timer;
- BOOL isTimed;
-}
-@property (nonatomic) CDVCaptureError errorCode;
-@property (nonatomic, copy) NSString* callbackId;
-@property (nonatomic, copy) NSNumber* duration;
-@property (nonatomic, strong) CDVCapture* captureCommand;
-@property (nonatomic, strong) UIBarButtonItem* doneButton;
-@property (nonatomic, strong) UIView* recordingView;
-@property (nonatomic, strong) UIButton* recordButton;
-@property (nonatomic, strong) UIImage* recordImage;
-@property (nonatomic, strong) UIImage* stopRecordImage;
-@property (nonatomic, strong) UILabel* timerLabel;
-@property (nonatomic, strong) AVAudioRecorder* avRecorder;
-@property (nonatomic, strong) AVAudioSession* avSession;
-@property (nonatomic, strong) CDVPluginResult* pluginResult;
-@property (nonatomic, strong) NSTimer* timer;
-@property (nonatomic) BOOL isTimed;
-
-- (id)initWithCommand:(CDVPlugin*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId;
-- (void)processButton:(id)sender;
-- (void)stopRecordingCleanup;
-- (void)dismissAudioView:(id)sender;
-- (NSString*)formatTime:(int)interval;
-- (void)updateTime;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
deleted file mode 100644
index 6b7ed44..0000000
--- a/CordovaLib/Classes/CDVCapture.m
+++ /dev/null
@@ -1,845 +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.
- */
-
-#import "CDVCapture.h"
-#import "CDVJSON.h"
-#import "CDVAvailability.h"
-
-#define kW3CMediaFormatHeight @"height"
-#define kW3CMediaFormatWidth @"width"
-#define kW3CMediaFormatCodecs @"codecs"
-#define kW3CMediaFormatBitrate @"bitrate"
-#define kW3CMediaFormatDuration @"duration"
-#define kW3CMediaModeType @"type"
-
-@implementation CDVImagePicker
-
-@synthesize quality;
-@synthesize callbackId;
-@synthesize mimeType;
-
-- (uint64_t)accessibilityTraits
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-
- if (([systemVersion compare:@"4.0" options:NSNumericSearch] != NSOrderedAscending)) { // this means system version is not less than 4.0
- return UIAccessibilityTraitStartsMediaSession;
- }
-
- return UIAccessibilityTraitNone;
-}
-
-@end
-
-@implementation CDVCapture
-@synthesize inUse;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVCapture*)[super initWithWebView:theWebView];
- if (self) {
- self.inUse = NO;
- }
- return self;
-}
-
-- (void)captureAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- NSNumber* duration = [options objectForKey:@"duration"];
- // the default value of duration is 0 so use nil (no duration) if default value
- if (duration) {
- duration = [duration doubleValue] == 0 ? nil : duration;
- }
- CDVPluginResult* result = nil;
-
- if (NSClassFromString(@"AVAudioRecorder") == nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- } else if (self.inUse == YES) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_APPLICATION_BUSY];
- } else {
- // all the work occurs here
- CDVAudioRecorderViewController* audioViewController = [[CDVAudioRecorderViewController alloc] initWithCommand:self duration:duration callbackId:callbackId];
-
- // Now create a nav controller and display the view...
- CDVAudioNavigationController* navController = [[CDVAudioNavigationController alloc] initWithRootViewController:audioViewController];
-
- self.inUse = YES;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:navController animated:YES];
- }
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)captureImage:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit and mode neither of which are supported at this time
- // taking more than one picture (limit) is only supported if provide own controls via cameraOverlayView property
- // can support mode in OS
-
- if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- NSLog(@"Capture.imageCapture: camera not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (pickerController == nil) {
- pickerController = [[CDVImagePicker alloc] init];
- }
-
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- if ([pickerController respondsToSelector:@selector(mediaTypes)]) {
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
- }
-
- /*if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]){
- // iOS 4.0
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
- pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }*/
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-/* Process a still image from the camera.
- * IN:
- * UIImage* image - the UIImage data returned from the camera
- * NSString* callbackId
- */
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
-
- // save the image to photo album
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
-
- NSData* data = nil;
- if (mimeType && [mimeType isEqualToString:@"image/png"]) {
- data = UIImagePNGRepresentation(image);
- } else {
- data = UIImageJPEGRepresentation(image, 0.5);
- }
-
- // write to temp directory and return URI
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/photo_%03d.jpg", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- if (err) {
- NSLog(@"Error saving image: %@", [err localizedDescription]);
- }
- } else {
- // create MediaFile object
-
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:filePath ofType:mimeType];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- }
-
- return result;
-}
-
-- (void)captureVideo:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit, duration and mode, only duration is supported (but is not due to apple bug)
- // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property
- // NSNumber* duration = [options objectForKey:@"duration"];
- NSString* mediaType = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, it is available, make sure it can do movies
- pickerController = [[CDVImagePicker alloc] init];
-
- NSArray* types = nil;
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
- // NSLog(@"MediaTypes: %@", [types description]);
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- mediaType = (NSString*)kUTTypeMovie;
- } else if ([types containsObject:(NSString*)kUTTypeVideo]) {
- mediaType = (NSString*)kUTTypeVideo;
- }
- }
- }
- if (!mediaType) {
- // don't have video camera return error
- NSLog(@"Capture.captureVideo: video mode not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
- } else {
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:mediaType, nil];
-
- /*if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
- if (duration) {
- pickerController.videoMaximumDuration = [duration doubleValue];
- }
- //NSLog(@"pickerController.videoMaximumDuration = %f", pickerController.videoMaximumDuration);
- }*/
-
- // iOS 4.0
- if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
- // pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
- // pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- // pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId
-{
- // save the movie to photo album (only avail as of iOS 3.1)
-
- /* don't need, it should automatically get saved
- NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath));
- if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) {
- NSLog(@"try to save movie");
- UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil);
- NSLog(@"finished saving movie");
- }*/
- // create MediaFile object
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-}
-
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command
-{
- // NSString* callbackId = [arguments objectAtIndex:0];
- // NSMutableDictionary* imageModes = nil;
- NSArray* imageArray = nil;
- NSArray* movieArray = nil;
- NSArray* audioArray = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, find the modes
- // can get image/jpeg or image/png from camera
-
- /* can't find a way to get the default height and width and other info
- * for images/movies taken with UIImagePickerController
- */
- NSDictionary* jpg = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/jpeg", kW3CMediaModeType,
- nil];
- NSDictionary* png = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/png", kW3CMediaModeType,
- nil];
- imageArray = [NSArray arrayWithObjects:jpg, png, nil];
-
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- NSArray* types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- NSDictionary* mov = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"video/quicktime", kW3CMediaModeType,
- nil];
- movieArray = [NSArray arrayWithObject:mov];
- }
- }
- }
- NSDictionary* modes = [NSDictionary dictionaryWithObjectsAndKeys:
- imageArray ? (NSObject*) imageArray:[NSNull null], @"image",
- movieArray ? (NSObject*) movieArray:[NSNull null], @"video",
- audioArray ? (NSObject*) audioArray:[NSNull null], @"audio",
- nil];
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.capture.setSupportedModes(%@);", [modes JSONString]];
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)getFormatData:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- // existence of fullPath checked on JS side
- NSString* fullPath = [command.arguments objectAtIndex:0];
- // mimeType could be null
- NSString* mimeType = nil;
-
- if ([command.arguments count] > 1) {
- mimeType = [command.arguments objectAtIndex:1];
- }
- BOOL bError = NO;
- CDVCaptureError errorCode = CAPTURE_INTERNAL_ERR;
- CDVPluginResult* result = nil;
-
- if (!mimeType || [mimeType isKindOfClass:[NSNull class]]) {
- // try to determine mime type if not provided
- id command = [self.commandDelegate getCommandInstance:@"File"];
- bError = !([command isKindOfClass:[CDVFile class]]);
- if (!bError) {
- CDVFile* cdvFile = (CDVFile*)command;
- mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- if (!mimeType) {
- // can't do much without mimeType, return error
- bError = YES;
- errorCode = CAPTURE_INVALID_ARGUMENT;
- }
- }
- }
- if (!bError) {
- // create and initialize return dictionary
- NSMutableDictionary* formatData = [NSMutableDictionary dictionaryWithCapacity:5];
- [formatData setObject:[NSNull null] forKey:kW3CMediaFormatCodecs];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatBitrate];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatDuration];
-
- if ([mimeType rangeOfString:@"image/"].location != NSNotFound) {
- UIImage* image = [UIImage imageWithContentsOfFile:fullPath];
- if (image) {
- CGSize imgSize = [image size];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.width] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.height] forKey:kW3CMediaFormatHeight];
- }
- } else if (([mimeType rangeOfString:@"video/"].location != NSNotFound) && (NSClassFromString(@"AVURLAsset") != nil)) {
- NSURL* movieURL = [NSURL fileURLWithPath:fullPath];
- AVURLAsset* movieAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
- CMTime duration = [movieAsset duration];
- [formatData setObject:[NSNumber numberWithFloat:CMTimeGetSeconds(duration)] forKey:kW3CMediaFormatDuration];
-
- NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
- if ([allVideoTracks count] > 0) {
- AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
- CGSize size = [track naturalSize];
-
- [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
- // not sure how to get codecs or bitrate???
- // AVMetadataItem
- // AudioFile
- } else {
- NSLog(@"No video tracks found for %@", fullPath);
- }
- } else if ([mimeType rangeOfString:@"audio/"].location != NSNotFound) {
- if (NSClassFromString(@"AVAudioPlayer") != nil) {
- NSURL* fileURL = [NSURL fileURLWithPath:fullPath];
- NSError* err = nil;
-
- AVAudioPlayer* avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&err];
- if (!err) {
- // get the data
- [formatData setObject:[NSNumber numberWithDouble:[avPlayer duration]] forKey:kW3CMediaFormatDuration];
- if ([avPlayer respondsToSelector:@selector(settings)]) {
- NSDictionary* info = [avPlayer settings];
- NSNumber* bitRate = [info objectForKey:AVEncoderBitRateKey];
- if (bitRate) {
- [formatData setObject:bitRate forKey:kW3CMediaFormatBitrate];
- }
- }
- } // else leave data init'ed to 0
- }
- }
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:formatData];
- // NSLog(@"getFormatData: %@", [formatData description]);
- }
- if (bError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errorCode];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type
-{
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSMutableDictionary* fileDict = [NSMutableDictionary dictionaryWithCapacity:5];
-
- [fileDict setObject:[fullPath lastPathComponent] forKey:@"name"];
- [fileDict setObject:fullPath forKey:@"fullPath"];
- // determine type
- if (!type) {
- id command = [self.commandDelegate getCommandInstance:@"File"];
- if ([command isKindOfClass:[CDVFile class]]) {
- CDVFile* cdvFile = (CDVFile*)command;
- NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
- }
- }
- NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
- [fileDict setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
- NSDate* modDate = [fileAttrs fileModificationDate];
- NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
- [fileDict setObject:msDate forKey:@"lastModifiedDate"];
-
- return fileDict;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- // older api calls new one
- [self imagePickerController:picker didFinishPickingMediaWithInfo:editingInfo];
-}
-
-/* Called when image/movie is finished recording.
- * Calls success or error code as appropriate
- * if successful, result contains an array (with just one entry since can only get one image unless build own camera UI) of MediaFile object representing the image
- * name
- * fullPath
- * type
- * lastModifiedDate
- * size
- */
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = nil;
-
- UIImage* image = nil;
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- if (!mediaType || [mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- // mediaType is nil then only option is UIImagePickerControllerOriginalImage
- if ([UIImagePickerController respondsToSelector:@selector(allowsEditing)] &&
- (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage])) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
- }
- if (image != nil) {
- // mediaType was image
- result = [self processImage:image type:cameraPicker.mimeType forCallbackId:callbackId];
- } else if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]) {
- // process video
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
- if (moviePath) {
- result = [self processVideo:moviePath forCallbackId:callbackId];
- }
- }
- if (!result) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NO_MEDIA_FILES];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-@end
-
-@implementation CDVAudioNavigationController
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- // delegate to CVDAudioRecorderViewController
- return [self.topViewController supportedInterfaceOrientations];
- }
-#endif
-
-@end
-
-@implementation CDVAudioRecorderViewController
-@synthesize errorCode, callbackId, duration, captureCommand, doneButton, recordingView, recordButton, recordImage, stopRecordImage, timerLabel, avRecorder, avSession, pluginResult, timer, isTimed;
-
-- (NSString*)resolveImageResource:(NSString*)resource
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
- BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
-
- // the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
- // if user wants iPhone only app to run on iPad they must remove *~ipad.* images from capture.bundle
- if (isLessThaniOS4) {
- NSString* iPadResource = [NSString stringWithFormat:@"%@~ipad.png", resource];
- if (CDV_IsIPad() && [UIImage imageNamed:iPadResource]) {
- return iPadResource;
- } else {
- return [NSString stringWithFormat:@"%@.png", resource];
- }
- }
-
- return resource;
-}
-
-- (id)initWithCommand:(CDVCapture*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId
-{
- if ((self = [super init])) {
- self.captureCommand = theCommand;
- self.duration = theDuration;
- self.callbackId = theCallbackId;
- self.errorCode = CAPTURE_NO_MEDIA_FILES;
- self.isTimed = self.duration != nil;
-
- return self;
- }
-
- return nil;
-}
-
-- (void)loadView
-{
- // create view and display
- CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
- UIView* tmp = [[UIView alloc] initWithFrame:viewRect];
-
- // make backgrounds
- NSString* microphoneResource = @"Capture.bundle/microphone";
-
- if (CDV_IsIPhone5()) {
- microphoneResource = @"Capture.bundle/microphone-568h";
- }
-
- UIImage* microphone = [UIImage imageNamed:[self resolveImageResource:microphoneResource]];
- UIView* microphoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, microphone.size.height)];
- [microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
- [microphoneView setUserInteractionEnabled:NO];
- [microphoneView setIsAccessibilityElement:NO];
- [tmp addSubview:microphoneView];
-
- // add bottom bar view
- UIImage* grayBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/controls_bg"]];
- UIView* controls = [[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width, grayBkg.size.height)];
- [controls setBackgroundColor:[UIColor colorWithPatternImage:grayBkg]];
- [controls setUserInteractionEnabled:NO];
- [controls setIsAccessibilityElement:NO];
- [tmp addSubview:controls];
-
- // make red recording background view
- UIImage* recordingBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/recording_bg"]];
- UIColor* background = [UIColor colorWithPatternImage:recordingBkg];
- self.recordingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- [self.recordingView setBackgroundColor:background];
- [self.recordingView setHidden:YES];
- [self.recordingView setUserInteractionEnabled:NO];
- [self.recordingView setIsAccessibilityElement:NO];
- [tmp addSubview:self.recordingView];
-
- // add label
- self.timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- // timerLabel.autoresizingMask = reSizeMask;
- [self.timerLabel setBackgroundColor:[UIColor clearColor]];
- [self.timerLabel setTextColor:[UIColor whiteColor]];
- [self.timerLabel setTextAlignment:UITextAlignmentCenter];
- [self.timerLabel setText:@"0:00"];
- [self.timerLabel setAccessibilityHint:NSLocalizedString(@"recorded time in minutes and seconds", nil)];
- self.timerLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
- self.timerLabel.accessibilityTraits &= ~UIAccessibilityTraitStaticText;
- [tmp addSubview:self.timerLabel];
-
- // Add record button
-
- self.recordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/record_button"]];
- self.stopRecordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/stop_button"]];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- self.recordButton = [[UIButton alloc] initWithFrame:CGRectMake((viewRect.size.width - recordImage.size.width) / 2, (microphone.size.height + (grayBkg.size.height - recordImage.size.height) / 2), recordImage.size.width, recordImage.size.height)];
- [self.recordButton setAccessibilityLabel:NSLocalizedString(@"toggle audio recording", nil)];
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- [self.recordButton addTarget:self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
- [tmp addSubview:recordButton];
-
- // make and add done button to navigation bar
- self.doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)];
- [self.doneButton setStyle:UIBarButtonItemStyleDone];
- self.navigationItem.rightBarButtonItem = self.doneButton;
-
- [self setView:tmp];
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- NSError* error = nil;
-
- if (self.avSession == nil) {
- // create audio session
- self.avSession = [AVAudioSession sharedInstance];
- if (error) {
- // return error if can't create recording audio session
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- }
- }
-
- // create file to record to in temporary dir
-
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/audio_%03d.wav", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- NSURL* fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
-
- // create AVAudioPlayer
- self.avRecorder = [[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err];
- if (err) {
- NSLog(@"Failed to initialize AVAudioRecorder: %@\n", [err localizedDescription]);
- self.avRecorder = nil;
- // return error
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- self.avRecorder.delegate = self;
- [self.avRecorder prepareToRecord];
- self.recordButton.enabled = YES;
- self.doneButton.enabled = YES;
- }
-}
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
- NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
-
- orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
- return orientation;
- }
-#endif
-
-- (void)viewDidUnload
-{
- [self setView:nil];
- [self.captureCommand setInUse:NO];
-}
-
-- (void)processButton:(id)sender
-{
- if (self.avRecorder.recording) {
- // stop recording
- [self.avRecorder stop];
- self.isTimed = NO; // recording was stopped via button so reset isTimed
- // view cleanup will occur in audioRecordingDidFinishRecording
- } else {
- // begin recording
- [self.recordButton setImage:stopRecordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits &= ~[self accessibilityTraits];
- [self.recordingView setHidden:NO];
- NSError* error = nil;
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:&error];
- [self.avSession setActive:YES error:&error];
- if (error) {
- // can't continue without active audio session
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- if (self.duration) {
- self.isTimed = true;
- [self.avRecorder recordForDuration:[duration doubleValue]];
- } else {
- [self.avRecorder record];
- }
- [self.timerLabel setText:@"0.00"];
- self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
- self.doneButton.enabled = NO;
- }
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- }
-}
-
-/*
- * helper method to clean up when stop recording
- */
-- (void)stopRecordingCleanup
-{
- if (self.avRecorder.recording) {
- [self.avRecorder stop];
- }
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- [self.recordingView setHidden:YES];
- self.doneButton.enabled = YES;
- if (self.avSession) {
- // deactivate session so sounds can come through
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- }
- if (self.duration && self.isTimed) {
- // VoiceOver announcement so user knows timed recording has finished
- BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
- if (isUIAccessibilityAnnouncementNotification) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
- UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString(@"timed recording complete", nil));
- });
- }
- } else {
- // issue a layout notification change so that VO will reannounce the button label when recording completes
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- }
-}
-
-- (void)dismissAudioView:(id)sender
-{
- // called when done button pressed or when error condition to do cleanup and remove view
- if ([self.captureCommand.viewController.modalViewController respondsToSelector:@selector(presentingViewController)]) {
- [[self.captureCommand.viewController.modalViewController presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[self.captureCommand.viewController.modalViewController parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- if (!self.pluginResult) {
- // return error
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:self.errorCode];
- }
-
- self.avRecorder = nil;
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- [self.captureCommand setInUse:NO];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- // return result
- [self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
-}
-
-- (void)updateTime
-{
- // update the label with the elapsed time
- [self.timerLabel setText:[self formatTime:self.avRecorder.currentTime]];
-}
-
-- (NSString*)formatTime:(int)interval
-{
- // is this format universal?
- int secs = interval % 60;
- int min = interval / 60;
-
- if (interval < 60) {
- return [NSString stringWithFormat:@"0:%02d", interval];
- } else {
- return [NSString stringWithFormat:@"%d:%02d", min, secs];
- }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
- // may be called when timed audio finishes - need to stop time and reset buttons
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- // generate success result
- if (flag) {
- NSString* filePath = [avRecorder.url path];
- // NSLog(@"filePath: %@", filePath);
- NSDictionary* fileDict = [captureCommand getMediaDictionaryFromPath:filePath ofType:@"audio/wav"];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- } else {
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
-}
-
-- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder*)recorder error:(NSError*)error
-{
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- NSLog(@"error recording audio");
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- [self dismissAudioView:nil];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVDevice.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.h b/CordovaLib/Classes/CDVDevice.h
deleted file mode 100644
index fd6ea12..0000000
--- a/CordovaLib/Classes/CDVDevice.h
+++ /dev/null
@@ -1,30 +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.
- */
-
-#import <UIKit/UIKit.h>
-#import "CDVPlugin.h"
-
-@interface CDVDevice : CDVPlugin
-{}
-
-+ (NSString*)cordovaVersion;
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
deleted file mode 100644
index a331b81..0000000
--- a/CordovaLib/Classes/CDVDevice.m
+++ /dev/null
@@ -1,89 +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.
- */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#import "CDV.h"
-
-@implementation UIDevice (ModelVersion)
-
-- (NSString*)modelVersion
-{
- size_t size;
-
- sysctlbyname("hw.machine", NULL, &size, NULL, 0);
- char* machine = malloc(size);
- sysctlbyname("hw.machine", machine, &size, NULL, 0);
- NSString* platform = [NSString stringWithUTF8String:machine];
- free(machine);
-
- return platform;
-}
-
-@end
-
-@interface CDVDevice () {}
-@end
-
-@implementation CDVDevice
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
-{
- NSDictionary* deviceProperties = [self deviceProperties];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
-
- /* Settings.plist
- * Read the optional Settings.plist file and push these user-defined settings down into the web application.
- * This can be useful for supplying build-time configuration variables down to the app to change its behavior,
- * such as specifying Full / Lite version, or localization (English vs German, for instance).
- */
- // TODO: turn this into an iOS only plugin
- 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];
- }
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (NSDictionary*)deviceProperties
-{
- UIDevice* device = [UIDevice currentDevice];
- NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
- [devProps setObject:[device modelVersion] forKey:@"model"];
- [devProps setObject:@"iOS" forKey:@"platform"];
- [devProps setObject:[device systemVersion] forKey:@"version"];
- [devProps setObject:[device uniqueAppInstanceIdentifier] forKey:@"uuid"];
- [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
-
- NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
- return devReturn;
-}
-
-+ (NSString*)cordovaVersion
-{
- return CDV_VERSION;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVFile.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.h b/CordovaLib/Classes/CDVFile.h
deleted file mode 100644
index eaf8cbe..0000000
--- a/CordovaLib/Classes/CDVFile.h
+++ /dev/null
@@ -1,106 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileError {
- NO_ERROR = 0,
- NOT_FOUND_ERR = 1,
- SECURITY_ERR = 2,
- ABORT_ERR = 3,
- NOT_READABLE_ERR = 4,
- ENCODING_ERR = 5,
- NO_MODIFICATION_ALLOWED_ERR = 6,
- INVALID_STATE_ERR = 7,
- SYNTAX_ERR = 8,
- INVALID_MODIFICATION_ERR = 9,
- QUOTA_EXCEEDED_ERR = 10,
- TYPE_MISMATCH_ERR = 11,
- PATH_EXISTS_ERR = 12
-};
-typedef int CDVFileError;
-
-enum CDVFileSystemType {
- TEMPORARY = 0,
- PERSISTENT = 1
-};
-typedef int CDVFileSystemType;
-
-extern NSString* const kCDVAssetsLibraryPrefix;
-
-@interface CDVFile : CDVPlugin {
- NSString* appDocsPath;
- NSString* appLibraryPath;
- NSString* appTempPath;
- NSString* persistentPath;
- NSString* temporaryPath;
-
- BOOL userHasAllowed;
-}
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
-- (NSString*)getAppPath:(NSString*)pathFragment;
-// -(NSString*) getFullPath: (NSString*)pathFragment;
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir;
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
-- (void)getDirectory:(CDVInvokedUrlCommand*)command;
-- (void)getFile:(CDVInvokedUrlCommand*)command;
-- (void)getParent:(CDVInvokedUrlCommand*)command;
-- (void)getMetadata:(CDVInvokedUrlCommand*)command;
-- (void)removeRecursively:(CDVInvokedUrlCommand*)command;
-- (void)remove:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)doRemove:(NSString*)fullPath;
-- (void)copyTo:(CDVInvokedUrlCommand*)command;
-- (void)moveTo:(CDVInvokedUrlCommand*)command;
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest;
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
-// - (void) toURI:(CDVInvokedUrlCommand*)command;
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
-- (void)readEntries:(CDVInvokedUrlCommand*)command;
-
-- (void)readAsText:(CDVInvokedUrlCommand*)command;
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
-- (void)write:(CDVInvokedUrlCommand*)command;
-- (void)testFileExists:(CDVInvokedUrlCommand*)command;
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
-// - (void) createDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteFile:(CDVInvokedUrlCommand*)command;
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
-- (void)truncate:(CDVInvokedUrlCommand*)command;
-
-// - (BOOL) fileExists:(NSString*)fileName;
-// - (BOOL) directoryExists:(NSString*)dirName;
-- (void)writeToFile:(NSString*)fileName withData:(NSString*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId;
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos;
-
-@property (nonatomic, strong) NSString* appDocsPath;
-@property (nonatomic, strong) NSString* appLibraryPath;
-@property (nonatomic, strong) NSString* appTempPath;
-@property (nonatomic, strong) NSString* persistentPath;
-@property (nonatomic, strong) NSString* temporaryPath;
-@property BOOL userHasAllowed;
-
-@end
-
-#define kW3FileTemporary @"temporary"
-#define kW3FilePersistent @"persistent"
[49/50] [abbrv] ios commit: [CB-4045] Merge branch 'master' into 2.9.x
Posted by ag...@apache.org.
[CB-4045] Merge branch 'master' into 2.9.x
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/eb6d5b92
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/eb6d5b92
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/eb6d5b92
Branch: refs/heads/2.9.x
Commit: eb6d5b9289bc25bee6911527b5e2f59c6f93c381
Parents: 00e62aa 9e48d82
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jun 28 11:04:29 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jun 28 11:04:29 2013 -0400
----------------------------------------------------------------------
bin/templates/project/cordova/emulate | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[39/50] [abbrv] ios commit: fixed js merge issue
Posted by ag...@apache.org.
fixed js merge issue
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/62dfb556
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/62dfb556
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/62dfb556
Branch: refs/heads/master
Commit: 62dfb55628bba669857d37aaf825cafb8f8ae2d8
Parents: e5ee1f2 42644d0
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 20 14:34:08 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:34:08 2013 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------
[26/50] [abbrv] ios commit: updated cordovajs,
removed globalization and camera
Posted by ag...@apache.org.
updated cordovajs, removed globalization and camera
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b229ae01
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b229ae01
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b229ae01
Branch: refs/heads/master
Commit: b229ae01c34fb77373dc6b01b7671de202c3e08e
Parents: 2e1830a
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 13:24:32 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:24:51 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 1978 +-------------------------------------------
1 file changed, 13 insertions(+), 1965 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b229ae01/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 4139a3d..c6cf612 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,9 +1,13 @@
// Platform: ios
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
=======
// 2.7.0rc1-84-g62c5786
>>>>>>> updated cordova js file
+=======
+// 2.7.0rc1-100-g6a53312
+>>>>>>> updated cordovajs, removed globalization and camera
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -24,10 +28,14 @@
*/
;(function() {
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
>>>>>>> updated cordova js file
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
+>>>>>>> updated cordovajs, removed globalization and camera
// file: lib/scripts/require.js
var require,
@@ -1153,157 +1161,6 @@ module.exports = {
});
-// file: lib/common/plugin/Acceleration.js
-define("cordova/plugin/Acceleration", function(require, exports, module) {
-
-var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
-};
-
-module.exports = Acceleration;
-
-});
-
-// file: lib/common/plugin/Camera.js
-define("cordova/plugin/Camera", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants'),
- CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
- options = options || {};
- var getValue = argscheck.getValue;
-
- var quality = getValue(options.quality, 50);
- var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
- var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
- var targetWidth = getValue(options.targetWidth, -1);
- var targetHeight = getValue(options.targetHeight, -1);
- var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
- var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
- var allowEdit = !!options.allowEdit;
- var correctOrientation = !!options.correctOrientation;
- var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
- var popoverOptions = getValue(options.popoverOptions, null);
- var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
-
- var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
-
- exec(successCallback, errorCallback, "Camera", "takePicture", args);
- return new CameraPopoverHandle();
-};
-
-cameraExport.cleanup = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "Camera", "cleanup", []);
-};
-
-module.exports = cameraExport;
-
-});
-
-// file: lib/common/plugin/CameraConstants.js
-define("cordova/plugin/CameraConstants", function(require, exports, module) {
-
-module.exports = {
- 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)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- 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)
- },
- PopoverArrowDirection:{
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- },
- Direction:{
- BACK: 0,
- FRONT: 1
- }
-};
-
-});
-
-// file: lib/ios/plugin/CameraPopoverHandle.js
-define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * A handle to an image picker popover.
- */
-var CameraPopoverHandle = function() {
- this.setPosition = function(popoverOptions) {
- var args = [ popoverOptions ];
- exec(null, null, "Camera", "repositionPopover", args);
- };
-};
-
-module.exports = CameraPopoverHandle;
-
-});
-
-// file: lib/common/plugin/CameraPopoverOptions.js
-define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
-
-var Camera = require('cordova/plugin/CameraConstants');
-
-/**
- * Encapsulates options for iOS Popover image picker
- */
-var CameraPopoverOptions = function(x,y,width,height,arrowDir){
- // information of rectangle that popover should be anchored to
- this.x = x || 0;
- this.y = y || 32;
- this.width = width || 320;
- this.height = height || 480;
- // The direction of the popover arrow
- this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
-};
-
-module.exports = CameraPopoverOptions;
-
-});
-
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
@@ -1378,39 +1235,6 @@ module.exports = CaptureVideoOptions;
});
-// file: lib/common/plugin/CompassError.js
-define("cordova/plugin/CompassError", function(require, exports, module) {
-
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
-
-});
-
-// file: lib/common/plugin/CompassHeading.js
-define("cordova/plugin/CompassHeading", function(require, exports, module) {
-
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = magneticHeading;
- this.trueHeading = trueHeading;
- this.headingAccuracy = headingAccuracy;
- this.timestamp = timestamp || new Date().getTime();
-};
-
-module.exports = CompassHeading;
-
-});
-
// file: lib/common/plugin/ConfigurationData.js
define("cordova/plugin/ConfigurationData", function(require, exports, module) {
@@ -1451,322 +1275,6 @@ module.exports = {
});
-// file: lib/common/plugin/Contact.js
-define("cordova/plugin/Contact", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-}
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value !== null) {
- // try to make it a Date object if it is not already
- if (!utils.isDate(value)){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (utils.isDate(value)){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-}
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- argscheck.checkArgs('FF', 'Contact.remove', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- clonedContact.id = null;
- clonedContact.rawId = null;
-
- function nullIds(arr) {
- if (arr) {
- for (var i = 0; i < arr.length; ++i) {
- arr[i].id = null;
- }
- }
- }
-
- // Loop through and clear out any id's in phones, emails, etc.
- nullIds(clonedContact.phoneNumbers);
- nullIds(clonedContact.emails);
- nullIds(clonedContact.addresses);
- nullIds(clonedContact.ims);
- nullIds(clonedContact.organizations);
- nullIds(clonedContact.categories);
- nullIds(clonedContact.photos);
- nullIds(clonedContact.urls);
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- argscheck.checkArgs('FFO', 'Contact.save', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (successCB) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
-
-});
-
-// file: lib/common/plugin/ContactAddress.js
-define("cordova/plugin/ContactAddress", function(require, exports, module) {
-
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
-
-});
-
-// file: lib/common/plugin/ContactError.js
-define("cordova/plugin/ContactError", function(require, exports, module) {
-
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
-
-});
-
-// file: lib/common/plugin/ContactField.js
-define("cordova/plugin/ContactField", function(require, exports, module) {
-
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = (type && type.toString()) || null;
- this.value = (value && value.toString()) || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
-
-});
-
-// file: lib/common/plugin/ContactFindOptions.js
-define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
-
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
-
-});
-
-// file: lib/common/plugin/ContactName.js
-define("cordova/plugin/ContactName", function(require, exports, module) {
-
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
-
-});
-
-// file: lib/common/plugin/ContactOrganization.js
-define("cordova/plugin/ContactOrganization", function(require, exports, module) {
-
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
-
-});
-
// file: lib/common/plugin/Coordinates.js
define("cordova/plugin/Coordinates", function(require, exports, module) {
@@ -3279,111 +2787,6 @@ module.exports = Flags;
});
-// file: lib/common/plugin/GlobalizationError.js
-define("cordova/plugin/GlobalizationError", function(require, exports, module) {
-
-
-/**
- * Globalization error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var GlobalizationError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-// Globalization error codes
-GlobalizationError.UNKNOWN_ERROR = 0;
-GlobalizationError.FORMATTING_ERROR = 1;
-GlobalizationError.PARSING_ERROR = 2;
-GlobalizationError.PATTERN_ERROR = 3;
-
-module.exports = GlobalizationError;
-
-});
-
-// file: lib/common/plugin/InAppBrowser.js
-define("cordova/plugin/InAppBrowser", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var channel = require('cordova/channel');
-var modulemapper = require('cordova/modulemapper');
-
-function InAppBrowser() {
- this.channels = {
- 'loadstart': channel.create('loadstart'),
- 'loadstop' : channel.create('loadstop'),
- 'loaderror' : channel.create('loaderror'),
- 'exit' : channel.create('exit')
- };
-}
-
-InAppBrowser.prototype = {
- _eventHandler: function (event) {
- if (event.type in this.channels) {
- this.channels[event.type].fire(event);
- }
- },
- close: function (eventname) {
- exec(null, null, "InAppBrowser", "close", []);
- },
- show: function (eventname) {
- exec(null, null, "InAppBrowser", "show", []);
- },
- addEventListener: function (eventname,f) {
- if (eventname in this.channels) {
- this.channels[eventname].subscribe(f);
- }
- },
- removeEventListener: function(eventname, f) {
- if (eventname in this.channels) {
- this.channels[eventname].unsubscribe(f);
- }
- },
-
- executeScript: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('executeScript requires exactly one of code or file to be specified');
- }
- },
-
- insertCSS: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('insertCSS requires exactly one of code or file to be specified');
- }
- }
-};
-
-module.exports = function(strUrl, strWindowName, strWindowFeatures) {
- var iab = new InAppBrowser();
- var cb = function(eventname) {
- iab._eventHandler(eventname);
- };
-
- // Don't catch calls that write to existing frames (e.g. named iframes).
- if (window.frames && window.frames[strWindowName]) {
- var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
- return origOpenFunc.apply(window, arguments);
- }
-
- exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
- return iab;
-};
-
-
-});
-
// file: lib/common/plugin/LocalFileSystem.js
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
@@ -3703,47 +3106,6 @@ module.exports = Metadata;
});
-// file: lib/common/plugin/Position.js
-define("cordova/plugin/Position", function(require, exports, module) {
-
-var Coordinates = require('cordova/plugin/Coordinates');
-
-var Position = function(coords, timestamp) {
- if (coords) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
- } else {
- this.coords = new Coordinates();
- }
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
-};
-
-module.exports = Position;
-
-});
-
-// file: lib/common/plugin/PositionError.js
-define("cordova/plugin/PositionError", function(require, exports, module) {
-
-/**
- * Position error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var PositionError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-PositionError.PERMISSION_DENIED = 1;
-PositionError.POSITION_UNAVAILABLE = 2;
-PositionError.TIMEOUT = 3;
-
-module.exports = PositionError;
-
-});
-
// file: lib/common/plugin/ProgressEvent.js
define("cordova/plugin/ProgressEvent", function(require, exports, module) {
@@ -3796,283 +3158,11 @@ module.exports = ProgressEvent;
});
-// file: lib/common/plugin/accelerometer.js
-define("cordova/plugin/accelerometer", function(require, exports, module) {
-
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var argscheck = require('cordova/argscheck'),
- utils = require("cordova/utils"),
- exec = require("cordova/exec"),
- Acceleration = require('cordova/plugin/Acceleration');
-
-// Is the accel sensor running?
-var running = false;
-
-// Keeps reference to watchAcceleration calls.
-var timers = {};
-
-// Array of listeners; used to keep track of when we should call start and stop.
-var listeners = [];
-
-// Last returned acceleration object from native
-var accel = null;
-
-// Tells native to start.
-function start() {
- exec(function(a) {
- var tempListeners = listeners.slice(0);
- accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].win(accel);
- }
- }, function(e) {
- var tempListeners = listeners.slice(0);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].fail(e);
- }
- }, "Accelerometer", "start", []);
- running = true;
-}
-
-// Tells native to stop.
-function stop() {
- exec(null, null, "Accelerometer", "stop", []);
- running = false;
-}
-
-// Adds a callback pair to the listeners array
-function createCallbackPair(win, fail) {
- return {win:win, fail:fail};
-}
-
-// Removes a win/fail listener pair from the listeners array
-function removeListeners(l) {
- var idx = listeners.indexOf(l);
- if (idx > -1) {
- listeners.splice(idx, 1);
- if (listeners.length === 0) {
- stop();
- }
- }
-}
-
-var accelerometer = {
- /**
- * Asynchronously acquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
-
- var p;
- var win = function(a) {
- removeListeners(p);
- successCallback(a);
- };
- var fail = function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- };
-
- p = createCallbackPair(win, fail);
- listeners.push(p);
-
- if (!running) {
- start();
- }
- },
-
- /**
- * Asynchronously acquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
- // Default interval (10 sec)
- var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
-
- // Keep reference to watch id, and report accel readings as often as defined in frequency
- var id = utils.createUUID();
-
- var p = createCallbackPair(function(){}, function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- });
- listeners.push(p);
-
- timers[id] = {
- timer:window.setInterval(function() {
- if (accel) {
- successCallback(accel);
- }
- }, frequency),
- listeners:p
- };
-
- if (running) {
- // If we're already running then immediately invoke the success callback
- // but only if we have retrieved a value, sample code does not check for null ...
- if (accel) {
- successCallback(accel);
- }
- } else {
- start();
- }
-
- return id;
- },
-
- /**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
- clearWatch: function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- window.clearInterval(timers[id].timer);
- removeListeners(timers[id].listeners);
- delete timers[id];
- }
- }
-};
-
-module.exports = accelerometer;
-
-});
-
-// file: lib/common/plugin/accelerometer/symbols.js
-define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
-modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
-
-});
-
-// file: lib/common/plugin/battery.js
-define("cordova/plugin/battery", function(require, exports, module) {
-
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
-
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus"),
- batterylow:cordova.addWindowEventHandler("batterylow"),
- batterycritical:cordova.addWindowEventHandler("batterycritical")
- };
- for (var key in this.channels) {
- this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
- }
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.onHasSubscribersChange = function() {
- // If we just registered the first handler, make sure native listener is started.
- if (this.numHandlers === 1 && handlers() === 1) {
- exec(battery._status, battery._error, "Battery", "start", []);
- } else if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
-
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
-
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
- }
- }
- }
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
-
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
-
-var battery = new Battery();
-
-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) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
+// file: lib/common/plugin/capture.js
+define("cordova/plugin/capture", function(require, exports, module) {
+
+var exec = require('cordova/exec'),
+ MediaFile = require('cordova/plugin/MediaFile');
/**
* Launches a capture of different types.
@@ -4162,105 +3252,6 @@ modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
});
-// file: lib/common/plugin/compass.js
-define("cordova/plugin/compass", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- utils = require('cordova/utils'),
- CompassHeading = require('cordova/plugin/CompassHeading'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
-
- var win = function(result) {
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- successCallback(ch);
- };
- var fail = errorCallback && function(code) {
- var ce = new CompassError(code);
- errorCallback(ce);
- };
-
- // Get heading
- exec(win, fail, "Compass", "getHeading", [options]);
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
- // Default interval (100 msec)
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- var id = utils.createUUID();
- if (filter > 0) {
- // is an iOS request for watch by filter, no timer needed
- timers[id] = "iOS";
- compass.getCurrentHeading(successCallback, errorCallback, options);
- } else {
- // Start watch timer to get headings
- timers[id] = window.setInterval(function() {
- compass.getCurrentHeading(successCallback, errorCallback);
- }, frequency);
- }
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
- // is iOS watch by filter so call into device to stop
- exec(null, null, "Compass", "stopHeading", []);
- }
- delete timers[id];
- }
- }
- };
-
-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) {
@@ -4433,84 +3424,6 @@ for (var key in console) {
});
-// file: lib/common/plugin/contacts.js
-define("cordova/plugin/contacts", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var contacts = {
- /**
- * Returns an array of Contacts matching the search criteria.
- * @param fields that should be searched
- * @param successCB success callback
- * @param errorCB error callback
- * @param {ContactFindOptions} options that can be applied to contact searching
- * @return array of Contacts matching search criteria
- */
- find:function(fields, successCB, errorCB, options) {
- argscheck.checkArgs('afFO', 'contacts.find', arguments);
- if (!fields.length) {
- errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- } else {
- var win = function(result) {
- var cs = [];
- for (var i = 0, l = result.length; i < l; i++) {
- cs.push(contacts.create(result[i]));
- }
- successCB(cs);
- };
- exec(win, errorCB, "Contacts", "search", [fields, options]);
- }
- },
-
- /**
- * This function creates a new contact, but it does not persist the contact
- * to device storage. To persist the contact to device storage, invoke
- * contact.save().
- * @param properties an object whose properties will be examined to create a new Contact
- * @returns new Contact object
- */
- create:function(properties) {
- argscheck.checkArgs('O', 'contacts.create', arguments);
- var contact = new Contact();
- for (var i in properties) {
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
- contact[i] = properties[i];
- }
- }
- return contact;
- }
-};
-
-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) {
@@ -4668,648 +3581,6 @@ modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
});
-// file: lib/common/plugin/geolocation.js
-define("cordova/plugin/geolocation", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('cordova/plugin/PositionError'),
- Position = require('cordova/plugin/Position');
-
-var timers = {}; // list of timers in use
-
-// Returns default params, overrides if provided with values
-function parseParameters(options) {
- var opt = {
- maximumAge: 0,
- enableHighAccuracy: false,
- timeout: Infinity
- };
-
- if (options) {
- if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
- opt.maximumAge = options.maximumAge;
- }
- if (options.enableHighAccuracy !== undefined) {
- opt.enableHighAccuracy = options.enableHighAccuracy;
- }
- if (options.timeout !== undefined && !isNaN(options.timeout)) {
- if (options.timeout < 0) {
- opt.timeout = 0;
- } else {
- opt.timeout = options.timeout;
- }
- }
- }
-
- return opt;
-}
-
-// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
- clearTimeout(t);
- t = null;
- errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
- });
- }, timeout);
- return t;
-}
-
-var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
- /**
- * Asynchronously acquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
- */
- getCurrentPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- // Timer var that will fire an error callback if no position is retrieved from native
- // before the "timeout" param provided expires
- var timeoutTimer = {timer:null};
-
- var win = function(p) {
- clearTimeout(timeoutTimer.timer);
- if (!(timeoutTimer.timer)) {
- // Timeout already happened, or native fired error callback for
- // this geo request.
- // Don't continue with success callback.
- return;
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
- var fail = function(e) {
- clearTimeout(timeoutTimer.timer);
- timeoutTimer.timer = null;
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
- // fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
- successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
- } else if (options.timeout === 0) {
- fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
- });
- // Otherwise we have to call into native to retrieve a position.
- } else {
- if (options.timeout !== Infinity) {
- // If the timeout value was not set to Infinity (default), then
- // set up a timeout function that will fire the error callback
- // if no successful position was retrieved before timeout expired.
- timeoutTimer.timer = createTimeout(fail, options.timeout);
- } else {
- // This is here so the check in the win function doesn't mess stuff up
- // may seem weird but this guarantees timeoutTimer is
- // always truthy before we call into native
- timeoutTimer.timer = true;
- }
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
- }
- return timeoutTimer;
- },
- /**
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
- * the successCallback is called with the new location.
- *
- * @param {Function} successCallback The function to call each time the location data is available
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- var id = utils.createUUID();
-
- // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
- timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
-
- var fail = function(e) {
- clearTimeout(timers[id].timer);
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- var win = function(p) {
- clearTimeout(timers[id].timer);
- if (options.timeout !== Infinity) {
- timers[id].timer = createTimeout(fail, options.timeout);
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
-
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
-
- return id;
- },
- /**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchPosition
- */
- clearWatch:function(id) {
- if (id && timers[id] !== undefined) {
- clearTimeout(timers[id].timer);
- timers[id].timer = false;
- exec(null, null, "Geolocation", "clearWatch", [id]);
- }
- }
-};
-
-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) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- GlobalizationError = require('cordova/plugin/GlobalizationError');
-
-var globalization = {
-
-/**
-* Returns the string identifier for the client's current language.
-* It returns the language identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the language,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The language identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
-* function () {});
-*/
-getPreferredLanguage:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
- exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
-},
-
-/**
-* Returns the string identifier for the client's current locale setting.
-* It returns the locale identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the locale,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The locale identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
-* function () {});
-*/
-getLocaleName:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
- exec(successCB, failureCB, "Globalization","getLocaleName", []);
-},
-
-
-/**
-* Returns a date formatted as a string according to the client's user preferences and
-* calendar using the time zone of the client. It returns the formatted date string to the
-* successCB callback with a properties object as a parameter. If there is an error
-* formatting the date, then the errorCB callback is invoked.
-*
-* The defaults are: formatLenght="short" and selector="date and time"
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.value {String}: The localized date string
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.dateToString(new Date(),
-* function (date) {alert('date:' + date.value + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {formatLength:'short'});
-*/
-dateToString:function(date, successCB, failureCB, options) {
- argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
-},
-
-
-/**
-* Parses a date formatted as a string according to the client's user
-* preferences and calendar using the time zone of the client and returns
-* the corresponding date object. It returns the date to the successCB
-* callback with a properties object as a parameter. If there is an error
-* parsing the date string, then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {String} dateString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.year {Number}: The four digit year
-* Object.month {Number}: The month from (0 - 11)
-* Object.day {Number}: The day from (1 - 31)
-* Object.hour {Number}: The hour from (0 - 23)
-* Object.minute {Number}: The minute from (0 - 59)
-* Object.second {Number}: The second from (0 - 59)
-* Object.millisecond {Number}: The milliseconds (from 0 - 999),
-* not available on all platforms
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToDate('4/11/2011',
-* function (date) { alert('Month:' + date.month + '\n' +
-* 'Day:' + date.day + '\n' +
-* 'Year:' + date.year + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {selector:'date'});
-*/
-stringToDate:function(dateString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
- exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
-},
-
-
-/**
-* Returns a pattern string for formatting and parsing dates according to the client's
-* user preferences. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern,
-* then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.timezone {String}: The abbreviated name of the time zone on the client
-* Object.utc_offset {Number}: The current difference in seconds between the client's
-* time zone and coordinated universal time.
-* Object.dst_offset {Number}: The current daylight saving time offset in seconds
-* between the client's non-daylight saving's time zone
-* and the client's daylight saving's time zone.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getDatePattern(
-* function (date) {alert('pattern:' + date.pattern + '\n');},
-* function () {},
-* {formatLength:'short'});
-*/
-getDatePattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
- exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
-},
-
-
-/**
-* Returns an array of either the names of the months or days of the week
-* according to the client's user preferences and calendar. It returns the array of names to the
-* successCB callback with a properties object as a parameter. If there is an error obtaining the
-* names, then the errorCB callback is invoked.
-*
-* The defaults are: type="wide" and item="months"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'narrow' or 'wide'
-* item {String}: 'months', or 'days'
-*
-* @return Object.value {Array{String}}: The array of names starting from either
-* the first month in the year or the
-* first day of the week.
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getDateNames(function (names) {
-* for(var i = 0; i < names.value.length; i++) {
-* alert('Month:' + names.value[i] + '\n');}},
-* function () {});
-*/
-getDateNames:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
- exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
-},
-
-/**
-* Returns whether daylight savings time is in effect for a given date using the client's
-* time zone and calendar. It returns whether or not daylight savings time is in effect
-* to the successCB callback with a properties object as a parameter. If there is an error
-* reading the date, then the errorCB callback is invoked.
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
-* in effect for the given date and "false" indicate that it is not.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.isDayLightSavingsTime(new Date(),
-* function (date) {alert('dst:' + date.dst + '\n');}
-* function () {});
-*/
-isDayLightSavingsTime:function(date, successCB, failureCB) {
- argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
-},
-
-/**
-* Returns the first day of the week according to the client's user preferences and calendar.
-* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
-* It returns the day to the successCB callback with a properties object as a parameter.
-* If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {Number}: The number of the first day of the week.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getFirstDayOfWeek(function (day)
-* { alert('Day:' + day.value + '\n');},
-* function () {});
-*/
-getFirstDayOfWeek:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
- exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
-},
-
-
-/**
-* Returns a number formatted as a string according to the client's user preferences.
-* It returns the formatted number string to the successCB callback with a properties object as a
-* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Number} number
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {String}: The formatted number string.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.numberToString(3.25,
-* function (number) {alert('number:' + number.value + '\n');},
-* function () {},
-* {type:'decimal'});
-*/
-numberToString:function(number, successCB, failureCB, options) {
- argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
- exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
-},
-
-/**
-* Parses a number formatted as a string according to the client's user preferences and
-* returns the corresponding number. It returns the number to the successCB callback with a
-* properties object as a parameter. If there is an error parsing the number string, then
-* the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {String} numberString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {Number}: The parsed number.
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToNumber('1234.56',
-* function (number) {alert('Number:' + number.value + '\n');},
-* function () { alert('Error parsing number');});
-*/
-stringToNumber:function(numberString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
- exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing numbers according to the client's user
-* preferences. It returns the pattern to the successCB callback with a properties object as a
-* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
-* The patterns follow Unicode Technical Standard #35.
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.symbol {String}: The symbol to be used when formatting and parsing
-* e.g., percent or currency symbol.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting numbers.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
-* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getNumberPattern(
-* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
-* function () {});
-*/
-getNumberPattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing currency values according to the client's
-* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
-* callback is invoked.
-*
-* @param {String} currencyCode
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.code {String}: The ISO 4217 currency code for the pattern.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting currency.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.getCurrencyPattern('EUR',
-* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
-* function () {});
-*/
-getCurrencyPattern:function(currencyCode, successCB, failureCB) {
- argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
-}
-
-};
-
-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/ios/plugin/inappbrowser/symbols.js
-define("cordova/plugin/inappbrowser/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/InAppBrowser', 'open');
-
-});
-
-// file: lib/ios/plugin/ios/Contact.js
-define("cordova/plugin/ios/Contact", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError');
-
-/**
- * Provides iOS Contact.display API.
- */
-module.exports = {
- display : function(errorCB, options) {
- /*
- * Display a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- */
-
- if (this.id === null) {
- if (typeof errorCB === "function") {
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
- errorCB(errorObj);
- }
- }
- else {
- exec(null, errorCB, "Contacts","displayContact", [this.id, options]);
- }
- }
-};
-
-});
-
// file: lib/ios/plugin/ios/Entry.js
define("cordova/plugin/ios/Entry", function(require, exports, module) {
@@ -5327,74 +3598,6 @@ module.exports = {
});
-// file: lib/ios/plugin/ios/contacts.js
-define("cordova/plugin/ios/contacts", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Provides iOS enhanced contacts API.
- */
-module.exports = {
- newContactUI : function(successCallback) {
- /*
- * Create a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * returns: the id of the created contact as param to successCallback
- */
- exec(successCallback, null, "Contacts","newContact", []);
- },
- chooseContact : function(successCallback, options) {
- /*
- * Select a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- * fields: array of fields to return in contact object (see ContactOptions.fields)
- *
- * @returns
- * id of contact selected
- * ContactObject
- * if no fields provided contact contains just id information
- * if fields provided contact object contains information for the specified fields
- *
- */
- var win = function(result) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCallback(fullContact.id, fullContact);
- };
- exec(win, null, "Contacts","chooseContact", [options]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts/symbols.js
-define("cordova/plugin/ios/contacts/symbols", function(require, exports, module) {
-
-require('cordova/plugin/contacts/symbols');
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/ios/contacts', 'navigator.contacts');
-modulemapper.merges('cordova/plugin/ios/Contact', 'Contact');
-
-});
-
-// file: lib/ios/plugin/ios/geolocation/symbols.js
-define("cordova/plugin/ios/geolocation/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/geolocation', 'navigator.geolocation');
-
-});
-
// file: lib/ios/plugin/ios/logger/plugininit.js
define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
@@ -5414,19 +3617,6 @@ modulemapper.clobbers('cordova/plugin/logger', 'console');
});
-// file: lib/ios/plugin/ios/notification.js
-define("cordova/plugin/ios/notification", function(require, exports, module) {
-
-var Media = require('cordova/plugin/Media');
-
-module.exports = {
- beep:function(count) {
- (new Media('beep.wav')).play();
- }
-};
-
-});
-
// file: lib/common/plugin/logger.js
define("cordova/plugin/logger", function(require, exports, module) {
@@ -5862,120 +4052,6 @@ modulemapper.defaults('cordova/plugin/Connection', 'Connection');
});
-// file: lib/common/plugin/notification.js
-define("cordova/plugin/notification", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var platform = require('cordova/platform');
-
-/**
- * Provides access to notifications on the device.
- */
-
-module.exports = {
-
- /**
- * Open a native alert dialog, with a customizable title and button text.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Alert)
- * @param {String} buttonLabel Label of the close button (default: OK)
- */
- alert: function(message, completeCallback, title, buttonLabel) {
- var _title = (title || "Alert");
- var _buttonLabel = (buttonLabel || "OK");
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
- },
-
- /**
- * Open a native confirm dialog, with a customizable title and button text.
- * The result that the user selects is returned to the result callback.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Confirm)
- * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
- */
- confirm: function(message, resultCallback, title, buttonLabels) {
- var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
-
- // Strings are deprecated!
- if (typeof _buttonLabels === 'string') {
- console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
- }
-
- // Some platforms take an array of button label names.
- // Other platforms take a comma separated list.
- // For compatibility, we convert to the desired type based on the platform.
- if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
- if (typeof _buttonLabels === 'string') {
- var buttonLabelString = _buttonLabels;
- _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
- }
- } else {
- if (Array.isArray(_buttonLabels)) {
- var buttonLabelArray = _buttonLabels;
- _buttonLabels = buttonLabelArray.toString();
- }
- }
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
- },
-
- /**
- * Open a native prompt dialog, with a customizable title and button text.
- * The following results are returned to the result callback:
- * buttonIndex Index number of the button selected.
- * input1 The text entered in the prompt dialog box.
- *
- * @param {String} message Dialog message to display (default: "Prompt message")
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the dialog (default: "Prompt")
- * @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
- * @param {String} defaultText Textbox input value (default: "Default text")
- */
- prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
- var _message = (message || "Prompt message");
- var _title = (title || "Prompt");
- var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
- var _defaultText = (defaultText || "Default text");
- exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
- },
-
- /**
- * Causes the device to vibrate.
- *
- * @param {Integer} mills The number of milliseconds to vibrate for.
- */
- vibrate: function(mills) {
- exec(null, null, "Notification", "vibrate", [mills]);
- },
-
- /**
- * Causes the device to beep.
- * On Android, the default notification ringtone is played "count" times.
- *
- * @param {Integer} count The number of beeps.
- */
- beep: function(count) {
- exec(null, null, "Notification", "beep", [count]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/notification/symbols.js
-define("cordova/plugin/notification/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/notification', 'navigator.notification');
-modulemapper.merges('cordova/plugin/ios/notification', 'navigator.notification');
-
-});
-
// file: lib/common/plugin/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
@@ -6071,34 +4147,6 @@ module.exports = function(uri, successCallback, errorCallback) {
});
-// file: lib/common/plugin/splashscreen.js
-define("cordova/plugin/splashscreen", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-var splashscreen = {
- show:function() {
- exec(null, null, "SplashScreen", "show", []);
- },
- hide:function() {
- exec(null, null, "SplashScreen", "hide", []);
- }
-};
-
-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/common/symbols.js
define("cordova/symbols", function(require, exports, module) {
[21/50] [abbrv] ios commit: removed native plugin files for various
plugins
Posted by ag...@apache.org.
removed native plugin files for various plugins
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/eb64bf3c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/eb64bf3c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/eb64bf3c
Branch: refs/heads/master
Commit: eb64bf3c2b81d732f18203bf9eed891900f18d78
Parents: c7750bb
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 18:22:16 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:23:51 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 8 -
CordovaLib/Classes/CDVAccelerometer.h | 39 -
CordovaLib/Classes/CDVAccelerometer.m | 128 --
CordovaLib/Classes/CDVBattery.h | 40 -
CordovaLib/Classes/CDVBattery.m | 152 ---
CordovaLib/Classes/CDVContact.h | 136 ---
CordovaLib/Classes/CDVContact.m | 1752 ----------------------------
CordovaLib/Classes/CDVContacts.h | 151 ---
CordovaLib/Classes/CDVContacts.m | 593 ----------
CordovaLib/Classes/CDVGlobalization.h | 150 ---
CordovaLib/Classes/CDVGlobalization.m | 790 -------------
CordovaLib/Classes/CDVInAppBrowser.h | 89 --
CordovaLib/Classes/CDVInAppBrowser.m | 818 -------------
CordovaLib/Classes/CDVLocation.h | 104 --
CordovaLib/Classes/CDVLocation.m | 623 ----------
CordovaLib/Classes/CDVNotification.h | 37 -
CordovaLib/Classes/CDVNotification.m | 130 ---
CordovaLib/Classes/CDVSplashScreen.h | 33 -
CordovaLib/Classes/CDVSplashScreen.m | 230 ----
19 files changed, 6003 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 15d9316..9da128a 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,26 +25,18 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVAccelerometer.h"
-#import "CDVBattery.h"
#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
-#import "CDVContact.h"
-#import "CDVContacts.h"
#import "CDVDebug.h"
#import "CDVDevice.h"
#import "CDVFile.h"
#import "CDVFileTransfer.h"
-#import "CDVLocation.h"
-#import "CDVNotification.h"
#import "CDVPluginResult.h"
#import "CDVReachability.h"
#import "CDVSound.h"
-#import "CDVSplashScreen.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
-#import "CDVInAppBrowser.h"
#import "CDVScreenOrientationDelegate.h"
#import "CDVTimer.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVAccelerometer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.h b/CordovaLib/Classes/CDVAccelerometer.h
deleted file mode 100644
index 044ca53..0000000
--- a/CordovaLib/Classes/CDVAccelerometer.h
+++ /dev/null
@@ -1,39 +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.
- */
-
-#import <UIKit/UIKit.h>
-#import "CDVPlugin.h"
-
-@interface CDVAccelerometer : CDVPlugin <UIAccelerometerDelegate>
-{
- double x;
- double y;
- double z;
- NSTimeInterval timestamp;
-}
-
-@property (readonly, assign) BOOL isRunning;
-@property (nonatomic, strong) NSString* callbackId;
-
-- (CDVAccelerometer*)init;
-
-- (void)start:(CDVInvokedUrlCommand*)command;
-- (void)stop:(CDVInvokedUrlCommand*)command;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m
deleted file mode 100644
index 33093d0..0000000
--- a/CordovaLib/Classes/CDVAccelerometer.m
+++ /dev/null
@@ -1,128 +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.
- */
-
-#import "CDVAccelerometer.h"
-
-@interface CDVAccelerometer () {}
-@property (readwrite, assign) BOOL isRunning;
-@end
-
-@implementation CDVAccelerometer
-
-@synthesize callbackId, isRunning;
-
-// defaults to 10 msec
-#define kAccelerometerInterval 40
-// g constant: -9.81 m/s^2
-#define kGravitationalConstant -9.81
-
-- (CDVAccelerometer*)init
-{
- self = [super init];
- if (self) {
- x = 0;
- y = 0;
- z = 0;
- timestamp = 0;
- self.callbackId = nil;
- self.isRunning = NO;
- }
- return self;
-}
-
-- (void)dealloc
-{
- [self stop:nil];
-}
-
-- (void)start:(CDVInvokedUrlCommand*)command
-{
- NSString* cbId = command.callbackId;
- NSTimeInterval desiredFrequency_num = kAccelerometerInterval;
- UIAccelerometer* pAccel = [UIAccelerometer sharedAccelerometer];
-
- // accelerometer expects fractional seconds, but we have msecs
- pAccel.updateInterval = desiredFrequency_num / 1000;
- self.callbackId = cbId;
- if (!self.isRunning) {
- pAccel.delegate = self;
- self.isRunning = YES;
- }
-}
-
-- (void)onReset
-{
- [self stop:nil];
-}
-
-- (void)stop:(CDVInvokedUrlCommand*)command
-{
- UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer];
-
- theAccelerometer.delegate = nil;
- self.isRunning = NO;
-}
-
-/**
- * Picks up accel updates from device and stores them in this class
- */
-- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
-{
- if (self.isRunning) {
- x = acceleration.x;
- y = acceleration.y;
- z = acceleration.z;
- timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
- [self returnAccelInfo];
- }
-}
-
-- (void)returnAccelInfo
-{
- // Create an acceleration object
- NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
- [accelProps setValue:[NSNumber numberWithDouble:x * kGravitationalConstant] forKey:@"x"];
- [accelProps setValue:[NSNumber numberWithDouble:y * kGravitationalConstant] forKey:@"y"];
- [accelProps setValue:[NSNumber numberWithDouble:z * kGravitationalConstant] forKey:@"z"];
- [accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
- [result setKeepCallback:[NSNumber numberWithBool:YES]];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
-}
-
-// TODO: Consider using filtering to isolate instantaneous data vs. gravity data -jm
-
-/*
- #define kFilteringFactor 0.1
-
- // Use a basic low-pass filter to keep only the gravity component of each axis.
- grav_accelX = (acceleration.x * kFilteringFactor) + ( grav_accelX * (1.0 - kFilteringFactor));
- grav_accelY = (acceleration.y * kFilteringFactor) + ( grav_accelY * (1.0 - kFilteringFactor));
- grav_accelZ = (acceleration.z * kFilteringFactor) + ( grav_accelZ * (1.0 - kFilteringFactor));
-
- // Subtract the low-pass value from the current value to get a simplified high-pass filter
- instant_accelX = acceleration.x - ( (acceleration.x * kFilteringFactor) + (instant_accelX * (1.0 - kFilteringFactor)) );
- instant_accelY = acceleration.y - ( (acceleration.y * kFilteringFactor) + (instant_accelY * (1.0 - kFilteringFactor)) );
- instant_accelZ = acceleration.z - ( (acceleration.z * kFilteringFactor) + (instant_accelZ * (1.0 - kFilteringFactor)) );
-
-
- */
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVBattery.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.h b/CordovaLib/Classes/CDVBattery.h
deleted file mode 100644
index ba26c3a..0000000
--- a/CordovaLib/Classes/CDVBattery.h
+++ /dev/null
@@ -1,40 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-@interface CDVBattery : CDVPlugin {
- UIDeviceBatteryState state;
- float level;
- bool isPlugged;
- NSString* callbackId;
-}
-
-@property (nonatomic) UIDeviceBatteryState state;
-@property (nonatomic) float level;
-@property (nonatomic) bool isPlugged;
-@property (strong) NSString* callbackId;
-
-- (void)updateBatteryStatus:(NSNotification*)notification;
-- (NSDictionary*)getBatteryStatus;
-- (void)start:(CDVInvokedUrlCommand*)command;
-- (void)stop:(CDVInvokedUrlCommand*)command;
-- (void)dealloc;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVBattery.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.m b/CordovaLib/Classes/CDVBattery.m
deleted file mode 100644
index 681511c..0000000
--- a/CordovaLib/Classes/CDVBattery.m
+++ /dev/null
@@ -1,152 +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.
- */
-
-#import "CDVBattery.h"
-
-@interface CDVBattery (PrivateMethods)
-- (void)updateOnlineStatus;
-@end
-
-@implementation CDVBattery
-
-@synthesize state, level, callbackId, isPlugged;
-
-/* determining type of event occurs on JavaScript side
-- (void) updateBatteryLevel:(NSNotification*)notification
-{
- // send batterylow event for less than 25% battery
- // send batterycritical event for less than 10% battery
- // W3c says to send batteryStatus event when batterylevel changes by more than 1% (iOS seems to notify each 5%)
- // always update the navigator.device.battery info
- float currentLevel = [[UIDevice currentDevice] batteryLevel];
- NSString* type = @"";
- // no check for level == -1 since this api is only called when monitoring is enabled so level should be valid
- if (currentLevel < 0.10){
- type = @"batterycritical";
- } else if (currentLevel < 0.25) {
- type = @"batterylow";
- } else {
- float onePercent = 0.1;
- if (self.level >= 0 ){
- onePercent = self.level * 0.01;
- }
- if (fabsf(currentLevel - self.level) > onePercent){
- // issue batteryStatus event
- type = @"batterystatus";
- }
- }
- // update the battery info and fire event
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.battery._status(\"%@\", %@)", type,[[self getBatteryStatus] JSONRepresentation]];
- [super writeJavascript:jsString];
-}
- */
-
-- (void)updateBatteryStatus:(NSNotification*)notification
-{
- NSDictionary* batteryData = [self getBatteryStatus];
-
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
-}
-
-/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
- * monitoring is turned off.
- */
-- (NSDictionary*)getBatteryStatus
-{
- UIDevice* currentDevice = [UIDevice currentDevice];
- UIDeviceBatteryState currentState = [currentDevice batteryState];
-
- isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
- if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
- isPlugged = TRUE;
- }
- float currentLevel = [currentDevice batteryLevel];
-
- if ((currentLevel != self.level) || (currentState != self.state)) {
- self.level = currentLevel;
- self.state = currentState;
- }
-
- // W3C spec says level must be null if it is unknown
- NSObject* w3cLevel = nil;
- if ((currentState == UIDeviceBatteryStateUnknown) || (currentLevel == -1.0)) {
- w3cLevel = [NSNull null];
- } else {
- w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
- }
- NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
- [batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
- [batteryData setObject:w3cLevel forKey:@"level"];
- return batteryData;
-}
-
-/* turn on battery monitoring*/
-- (void)start:(CDVInvokedUrlCommand*)command
-{
- self.callbackId = command.callbackId;
-
- if ([UIDevice currentDevice].batteryMonitoringEnabled == NO) {
- [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryLevelDidChangeNotification object:nil];
- }
-}
-
-/* turn off battery monitoring */
-- (void)stop:(CDVInvokedUrlCommand*)command
-{
- // callback one last time to clear the callback function on JS side
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getBatteryStatus]];
- [result setKeepCallbackAsBool:NO];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
- self.callbackId = nil;
- [[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVBattery*)[super initWithWebView:theWebView];
- if (self) {
- self.state = UIDeviceBatteryStateUnknown;
- self.level = -1.0;
- }
- return self;
-}
-
-- (void)dealloc
-{
- [self stop:nil];
-}
-
-- (void)onReset
-{
- [self stop:nil];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVContact.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.h b/CordovaLib/Classes/CDVContact.h
deleted file mode 100644
index 5187efc..0000000
--- a/CordovaLib/Classes/CDVContact.h
+++ /dev/null
@@ -1,136 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <AddressBook/ABAddressBook.h>
-#import <AddressBookUI/AddressBookUI.h>
-
-enum CDVContactError {
- UNKNOWN_ERROR = 0,
- INVALID_ARGUMENT_ERROR = 1,
- TIMEOUT_ERROR = 2,
- PENDING_OPERATION_ERROR = 3,
- IO_ERROR = 4,
- NOT_SUPPORTED_ERROR = 5,
- PERMISSION_DENIED_ERROR = 20
-};
-typedef NSUInteger CDVContactError;
-
-@interface CDVContact : NSObject {
- ABRecordRef record; // the ABRecord associated with this contact
- NSDictionary* returnFields; // dictionary of fields to return when performing search
-}
-
-@property (nonatomic, assign) ABRecordRef record;
-@property (nonatomic, strong) NSDictionary* returnFields;
-
-+ (NSDictionary*)defaultABtoW3C;
-+ (NSDictionary*)defaultW3CtoAB;
-+ (NSSet*)defaultW3CtoNull;
-+ (NSDictionary*)defaultObjectAndProperties;
-+ (NSDictionary*)defaultFields;
-
-+ (NSDictionary*)calcReturnFields:(NSArray*)fields;
-- (id)init;
-- (id)initFromABRecord:(ABRecordRef)aRecord;
-- (bool)setFromContactDict:(NSDictionary*)aContact asUpdate:(BOOL)bUpdate;
-
-+ (BOOL)needsConversion:(NSString*)W3Label;
-+ (CFStringRef)convertContactTypeToPropertyLabel:(NSString*)label;
-+ (NSString*)convertPropertyLabelToContactType:(NSString*)label;
-+ (BOOL)isValidW3ContactType:(NSString*)label;
-- (bool)setValue:(id)aValue forProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord asUpdate:(BOOL)bUpdate;
-
-- (NSDictionary*)toDictionary:(NSDictionary*)withFields;
-- (NSNumber*)getDateAsNumber:(ABPropertyID)datePropId;
-- (NSObject*)extractName;
-- (NSObject*)extractMultiValue:(NSString*)propertyId;
-- (NSObject*)extractAddresses;
-- (NSObject*)extractIms;
-- (NSObject*)extractOrganizations;
-- (NSObject*)extractPhotos;
-
-- (NSMutableDictionary*)translateW3Dict:(NSDictionary*)dict forProperty:(ABPropertyID)prop;
-- (bool)setMultiValueStrings:(NSArray*)fieldArray forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (bool)setMultiValueDictionary:(NSArray*)array forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (ABMultiValueRef)allocStringMultiValueFromArray:array;
-- (ABMultiValueRef)allocDictMultiValueFromArray:array forProperty:(ABPropertyID)prop;
-- (BOOL)foundValue:(NSString*)testValue inFields:(NSDictionary*)searchFields;
-- (BOOL)testStringValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)testDateValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)searchContactFields:(NSArray*)fields forMVStringProperty:(ABPropertyID)propId withValue:testValue;
-- (BOOL)testMultiValueStrings:(NSString*)testValue forProperty:(ABPropertyID)propId ofType:(NSString*)type;
-- (NSArray*)valuesForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (NSArray*)labelsForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (BOOL)searchContactFields:(NSArray*)fields forMVDictionaryProperty:(ABPropertyID)propId withValue:(NSString*)testValue;
-
-@end
-
-// generic ContactField types
-#define kW3ContactFieldType @"type"
-#define kW3ContactFieldValue @"value"
-#define kW3ContactFieldPrimary @"pref"
-// Various labels for ContactField types
-#define kW3ContactWorkLabel @"work"
-#define kW3ContactHomeLabel @"home"
-#define kW3ContactOtherLabel @"other"
-#define kW3ContactPhoneFaxLabel @"fax"
-#define kW3ContactPhoneMobileLabel @"mobile"
-#define kW3ContactPhonePagerLabel @"pager"
-#define kW3ContactUrlBlog @"blog"
-#define kW3ContactUrlProfile @"profile"
-#define kW3ContactImAIMLabel @"aim"
-#define kW3ContactImICQLabel @"icq"
-#define kW3ContactImMSNLabel @"msn"
-#define kW3ContactImYahooLabel @"yahoo"
-#define kW3ContactFieldId @"id"
-// special translation for IM field value and type
-#define kW3ContactImType @"type"
-#define kW3ContactImValue @"value"
-
-// Contact object
-#define kW3ContactId @"id"
-#define kW3ContactName @"name"
-#define kW3ContactFormattedName @"formatted"
-#define kW3ContactGivenName @"givenName"
-#define kW3ContactFamilyName @"familyName"
-#define kW3ContactMiddleName @"middleName"
-#define kW3ContactHonorificPrefix @"honorificPrefix"
-#define kW3ContactHonorificSuffix @"honorificSuffix"
-#define kW3ContactDisplayName @"displayName"
-#define kW3ContactNickname @"nickname"
-#define kW3ContactPhoneNumbers @"phoneNumbers"
-#define kW3ContactAddresses @"addresses"
-#define kW3ContactAddressFormatted @"formatted"
-#define kW3ContactStreetAddress @"streetAddress"
-#define kW3ContactLocality @"locality"
-#define kW3ContactRegion @"region"
-#define kW3ContactPostalCode @"postalCode"
-#define kW3ContactCountry @"country"
-#define kW3ContactEmails @"emails"
-#define kW3ContactIms @"ims"
-#define kW3ContactOrganizations @"organizations"
-#define kW3ContactOrganizationName @"name"
-#define kW3ContactTitle @"title"
-#define kW3ContactDepartment @"department"
-#define kW3ContactBirthday @"birthday"
-#define kW3ContactNote @"note"
-#define kW3ContactPhotos @"photos"
-#define kW3ContactCategories @"categories"
-#define kW3ContactUrls @"urls"
[35/50] [abbrv] ios commit: updated cordovajs
Posted by ag...@apache.org.
updated cordovajs
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/bc66e148
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/bc66e148
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/bc66e148
Branch: refs/heads/master
Commit: bc66e1484e1891bb5ed3988eda1ee50e6ed0d2b2
Parents: 33b2858
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:50:33 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:42 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bc66e148/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 1690aba..f5353c3 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -4,6 +4,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
=======
// 2.7.0rc1-84-g62c5786
@@ -20,6 +21,9 @@
=======
// 2.7.0rc1-119-gf0251c4
>>>>>>> updated js
+=======
+// 2.7.0rc1-120-g8731b31
+>>>>>>> updated cordovajs
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -44,6 +48,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
@@ -60,6 +65,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-119-gf0251c4';
>>>>>>> updated js
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-120-g8731b31';
+>>>>>>> updated cordovajs
// file: lib/scripts/require.js
var require,
@@ -564,8 +572,6 @@ var utils = require('cordova/utils'),
* onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
* onNativeReady* Internal event that indicates the Cordova native side is ready.
* onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady* Internal event fired when device properties are available.
- * onCordovaConnectionReady* Internal event fired when the connection property has been set.
* onDeviceReady* User event fired to indicate that Cordova is ready
* onResume User event fired to indicate a start/resume lifecycle event
* onPause User event fired to indicate a pause lifecycle event
@@ -768,9 +774,6 @@ channel.createSticky('onNativeReady');
// and it's time to run plugin constructors.
channel.createSticky('onCordovaReady');
-// Event to indicate that device properties are available
-channel.createSticky('onCordovaInfoReady');
-
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
channel.createSticky('onPluginsReady');
[28/50] [abbrv] ios commit: updated js
Posted by ag...@apache.org.
updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9586f942
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9586f942
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9586f942
Branch: refs/heads/master
Commit: 9586f9427118893da87502c31ab88bab2d66a933
Parents: 6fa81c3
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 15:18:26 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:30:41 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9586f942/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index c6cf612..1c33e04 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,6 +1,7 @@
// Platform: ios
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
=======
// 2.7.0rc1-84-g62c5786
@@ -8,6 +9,9 @@
=======
// 2.7.0rc1-100-g6a53312
>>>>>>> updated cordovajs, removed globalization and camera
+=======
+// 2.7.0rc1-101-gc6482ac
+>>>>>>> updated js
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -29,6 +33,7 @@
;(function() {
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
@@ -36,6 +41,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
>>>>>>> updated cordovajs, removed globalization and camera
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
+>>>>>>> updated js
// file: lib/scripts/require.js
var require,
[46/50] [abbrv] ios commit: added cdvshared
Posted by ag...@apache.org.
added cdvshared
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f705b31e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f705b31e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f705b31e
Branch: refs/heads/master
Commit: f705b31e27693bf44f7f2231cb438fa7809e7fba
Parents: 9ca7421
Author: Steven Gill <st...@gmail.com>
Authored: Tue Jun 25 17:01:09 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Tue Jun 25 17:01:09 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVShared.h | 35 ++++++++++++
CordovaLib/Classes/CDVShared.m | 59 ++++++++++++++++++++
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 10 +++-
3 files changed, 103 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/Classes/CDVShared.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVShared.h b/CordovaLib/Classes/CDVShared.h
new file mode 100644
index 0000000..0b59a37
--- /dev/null
+++ b/CordovaLib/Classes/CDVShared.h
@@ -0,0 +1,35 @@
+/*
+ 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+
+@interface NSError (JSONMethods)
+
+- (NSString*)JSONRepresentation;
+
+@end
+
+@interface CLLocation (JSONMethods)
+
+- (NSString*)JSONRepresentation;
+
+@end
+
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/Classes/CDVShared.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVShared.m b/CordovaLib/Classes/CDVShared.m
new file mode 100644
index 0000000..8756c17
--- /dev/null
+++ b/CordovaLib/Classes/CDVShared.m
@@ -0,0 +1,59 @@
+/*
+ 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.
+ */
+
+#import "CDVShared.h"
+
+#pragma mark -
+#pragma mark CLLocation(JSONMethods)
+
+@implementation CLLocation (JSONMethods)
+
+- (NSString*)JSONRepresentation
+{
+ return [NSString stringWithFormat:
+ @"{ timestamp: %.00f, \
+ coords: { latitude: %f, longitude: %f, altitude: %.02f, heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
+ }",
+ [self.timestamp timeIntervalSince1970] * 1000.0,
+ self.coordinate.latitude,
+ self.coordinate.longitude,
+ self.altitude,
+ self.course,
+ self.speed,
+ self.horizontalAccuracy,
+ self.verticalAccuracy
+ ];
+}
+
+@end
+
+#pragma mark NSError(JSONMethods)
+
+@implementation NSError (JSONMethods)
+
+- (NSString*)JSONRepresentation
+{
+ return [NSString stringWithFormat:
+ @"{ code: %d, message: '%@'}",
+ self.code,
+ [self localizedDescription]
+ ];
+}
+
+@end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index bf92ac3..2d97260 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B701026177A61CF00AE11F4 /* CDVShared.h */; };
+ 1B701029177A61CF00AE11F4 /* CDVShared.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B701027177A61CF00AE11F4 /* CDVShared.m */; };
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /* CDVPluginResult.m */; };
301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 301F2F2914F3C9CA003FE9FC /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -57,6 +59,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 1B701026177A61CF00AE11F4 /* CDVShared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVShared.h; path = Classes/CDVShared.h; sourceTree = "<group>"; };
+ 1B701027177A61CF00AE11F4 /* CDVShared.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVShared.m; path = Classes/CDVShared.m; sourceTree = "<group>"; };
1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree = "<group>"; };
1F92F49F1314023E0046367C /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVPluginResult.m; path = Classes/CDVPluginResult.m; sourceTree = "<group>"; };
301F2F2914F3C9CA003FE9FC /* CDV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDV.h; path = Classes/CDV.h; sourceTree = "<group>"; };
@@ -207,12 +211,14 @@
30C684921407044A004C1A8E /* CDVURLProtocol.h */,
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
+ 1B701026177A61CF00AE11F4 /* CDVShared.h */,
+ 1B701027177A61CF00AE11F4 /* CDVShared.m */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
+ EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
@@ -290,6 +296,7 @@
EBFF4DBD16D3FE2E008F452B /* CDVWebViewDelegate.h in Headers */,
EB96673B16A8970A00D86CDF /* CDVUserAgentUtil.h in Headers */,
7E14B5A81705050A0032169E /* CDVTimer.h in Headers */,
+ 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -368,6 +375,7 @@
EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */,
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */,
+ 1B701029177A61CF00AE11F4 /* CDVShared.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
[23/50] [abbrv] ios commit: converted cordova template to arc
Posted by ag...@apache.org.
converted cordova template to arc
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9f1d0fdb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9f1d0fdb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9f1d0fdb
Branch: refs/heads/master
Commit: 9f1d0fdb66c1eef1fc13997d81b38ef1efbdafd6
Parents: 3af6ca4
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 18:05:04 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:23:51 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9f1d0fdb/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index f0f80bb..8617ccb 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -481,7 +481,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_ARC = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -500,7 +500,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_ARC = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "__TESTING__/__TESTING__-Prefix.pch";
[03/50] [abbrv] ios commit: updated js
Posted by ag...@apache.org.
updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/83b0ad7b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/83b0ad7b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/83b0ad7b
Branch: refs/heads/master
Commit: 83b0ad7b01e12432ef3424f51f446d036fafe97e
Parents: e07c199
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 15:18:26 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 13 15:18:26 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83b0ad7b/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 2e67604..574a571 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-100-g6a53312
+// 2.7.0rc1-101-gc6482ac
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
// file: lib/scripts/require.js
var require,
[05/50] [abbrv] removed device, capture, file, filetransfer
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
deleted file mode 100644
index 0f6b174..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ /dev/null
@@ -1,730 +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.
- */
-
-#import "CDV.h"
-
-#import <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <CFNetwork/CFNetwork.h>
-
-@interface CDVFileTransfer ()
-// Sets the requests headers for the request.
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req;
-// Creates a delegate to handle an upload.
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command;
-// Creates an NSData* for the file for the given upload arguments.
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command;
-@end
-
-// Buffer size to use for streaming uploads.
-static const NSUInteger kStreamBufferSize = 32768;
-// Magic value within the options dict used to set a cookie.
-NSString* const kOptionsKeyCookie = @"__cookie";
-// Form boundary for multi-part requests.
-NSString* const kFormBoundary = @"+++++org.apache.cordova.formBoundary";
-
-// Writes the given data to the stream in a blocking way.
-// If successful, returns bytesToWrite.
-// If the stream was closed on the other end, returns 0.
-// If there was an error, returns -1.
-static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
-{
- UInt8* bytes = (UInt8*)[data bytes];
- NSUInteger bytesToWrite = [data length];
- NSUInteger totalBytesWritten = 0;
-
- while (totalBytesWritten < bytesToWrite) {
- CFIndex result = CFWriteStreamWrite(stream,
- bytes + totalBytesWritten,
- bytesToWrite - totalBytesWritten);
- if (result < 0) {
- CFStreamError error = CFWriteStreamGetError(stream);
- NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, error.error);
- return result;
- } else if (result == 0) {
- return result;
- }
- totalBytesWritten += result;
- }
-
- return totalBytesWritten;
-}
-
-@implementation CDVFileTransfer
-@synthesize activeTransfers;
-
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString
-{
- NSRange schemeAndHostRange = [urlString rangeOfString:@"://.*?/" options:NSRegularExpressionSearch];
-
- if (schemeAndHostRange.length == 0) {
- return urlString;
- }
-
- NSInteger schemeAndHostEndIndex = NSMaxRange(schemeAndHostRange);
- NSString* schemeAndHost = [urlString substringToIndex:schemeAndHostEndIndex];
- NSString* pathComponent = [urlString substringFromIndex:schemeAndHostEndIndex];
- pathComponent = [pathComponent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- return [schemeAndHost stringByAppendingString:pathComponent];
-}
-
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req
-{
- [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
-
- NSString* userAgent = [self.commandDelegate userAgent];
- if (userAgent) {
- [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
- }
-
- for (NSString* headerName in headers) {
- id value = [headers objectForKey:headerName];
- if (!value || (value == [NSNull null])) {
- value = @"null";
- }
-
- // First, remove an existing header if one exists.
- [req setValue:nil forHTTPHeaderField:headerName];
-
- if (![value isKindOfClass:[NSArray class]]) {
- value = [NSArray arrayWithObject:value];
- }
-
- // Then, append all header values.
- for (id __strong subValue in value) {
- // Convert from an NSNumber -> NSString.
- if ([subValue respondsToSelector:@selector(stringValue)]) {
- subValue = [subValue stringValue];
- }
- if ([subValue isKindOfClass:[NSString class]]) {
- [req addValue:subValue forHTTPHeaderField:headerName];
- }
- }
- }
-}
-
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData
-{
- // arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]
- // however, params is a JavaScript object and during marshalling is put into the options dict,
- // thus debug and chunkedMode are the 6th and 7th arguments
- NSString* target = [command argumentAtIndex:0];
- NSString* server = [command argumentAtIndex:1];
- NSString* fileKey = [command argumentAtIndex:2 withDefault:@"file"];
- NSString* fileName = [command argumentAtIndex:3 withDefault:@"no-filename"];
- NSString* mimeType = [command argumentAtIndex:4 withDefault:nil];
- NSDictionary* options = [command argumentAtIndex:5 withDefault:nil];
- // BOOL trustAllHosts = [[arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- BOOL chunkedMode = [[command argumentAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
- NSDictionary* headers = [command argumentAtIndex:8 withDefault:nil];
- // Allow alternative http method, default to POST. JS side checks
- // for allowed methods, currently PUT or POST (forces POST for
- // unrecognised values)
- NSString* httpMethod = [command argumentAtIndex:10 withDefault:@"POST"];
- CDVPluginResult* result = nil;
- CDVFileTransferError errorCode = 0;
-
- // NSURL does not accepts URLs with spaces in the path. We escape the path in order
- // to be more lenient.
- NSURL* url = [NSURL URLWithString:server];
-
- if (!url) {
- errorCode = INVALID_URL_ERR;
- NSLog(@"File Transfer Error: Invalid server URL %@", server);
- } else if (!fileData) {
- errorCode = FILE_NOT_FOUND_ERR;
- }
-
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:target AndTarget:server]];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return nil;
- }
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
-
- [req setHTTPMethod:httpMethod];
-
- // Magic value to set a cookie
- if ([options objectForKey:kOptionsKeyCookie]) {
- [req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"];
- [req setHTTPShouldHandleCookies:NO];
- }
-
- NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-Type"];
- [self applyRequestHeaders:headers toRequest:req];
-
- NSData* formBoundaryData = [[NSString stringWithFormat:@"--%@\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
- NSMutableData* postBodyBeforeFile = [NSMutableData data];
-
- for (NSString* key in options) {
- id val = [options objectForKey:key];
- if (!val || (val == [NSNull null]) || [key isEqualToString:kOptionsKeyCookie]) {
- continue;
- }
- // if it responds to stringValue selector (eg NSNumber) get the NSString
- if ([val respondsToSelector:@selector(stringValue)]) {
- val = [val stringValue];
- }
- // finally, check whether it is a NSString (for dataUsingEncoding selector below)
- if (![val isKindOfClass:[NSString class]]) {
- continue;
- }
-
- [postBodyBeforeFile appendData:formBoundaryData];
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
- [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
- }
-
- [postBodyBeforeFile appendData:formBoundaryData];
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
- if (mimeType != nil) {
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
- }
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %d\r\n\r\n", [fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];
-
- DLog(@"fileData length: %d", [fileData length]);
- NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
-
- NSUInteger totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
- [req setValue:[[NSNumber numberWithInteger:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
-
- if (chunkedMode) {
- CFReadStreamRef readStream = NULL;
- CFWriteStreamRef writeStream = NULL;
- CFStreamCreateBoundPair(NULL, &readStream, &writeStream, kStreamBufferSize);
- [req setHTTPBodyStream:CFBridgingRelease(readStream)];
-
- self.backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
- [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskID];
- self.backgroundTaskID = UIBackgroundTaskInvalid;
- NSLog(@"Background task to upload media finished.");
- }];
-
- [self.commandDelegate runInBackground:^{
- if (CFWriteStreamOpen(writeStream)) {
- NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
- int numChunks = sizeof(chunks) / sizeof(chunks[0]);
-
- for (int i = 0; i < numChunks; ++i) {
- CFIndex result = WriteDataToStream(chunks[i], writeStream);
- if (result <= 0) {
- break;
- }
- }
- } else {
- NSLog(@"FileTransfer: Failed to open writeStream");
- }
- CFWriteStreamClose(writeStream);
- CFRelease(writeStream);
- }];
- } else {
- [postBodyBeforeFile appendData:fileData];
- [postBodyBeforeFile appendData:postBodyAfterFile];
- [req setHTTPBody:postBodyBeforeFile];
- }
- return req;
-}
-
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command
-{
- NSString* source = [command.arguments objectAtIndex:0];
- NSString* server = [command.arguments objectAtIndex:1];
- BOOL trustAllHosts = [[command.arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- NSString* objectId = [command.arguments objectAtIndex:9];
-
- CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-
- delegate.command = self;
- delegate.callbackId = command.callbackId;
- delegate.direction = CDV_TRANSFER_UPLOAD;
- delegate.objectId = objectId;
- delegate.source = source;
- delegate.target = server;
- delegate.trustAllHosts = trustAllHosts;
-
- return delegate;
-}
-
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
-{
- NSString* target = (NSString*)[command.arguments objectAtIndex:0];
- NSError* __autoreleasing err = nil;
-
- // return unsupported result for assets-library URLs
- if ([target hasPrefix:kCDVAssetsLibraryPrefix]) {
- // 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* fileData = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
- [self uploadData:fileData command:command];
- } else {
- // We couldn't find the asset. Send the appropriate error.
- CDVPluginResult* 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.
- CDVPluginResult* 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:target] resultBlock:resultBlock failureBlock:failureBlock];
- return;
- } else {
- // Extract the path part out of a file: URL.
- NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
- if (filePath == nil) {
- // We couldn't find the asset. Send the appropriate error.
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- // Memory map the file so that it can be read efficiently even if it is large.
- NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
-
- if (err != nil) {
- NSLog(@"Error opening file %@: %@", target, err);
- }
- [self uploadData:fileData command:command];
- }
-}
-
-- (void)upload:(CDVInvokedUrlCommand*)command
-{
- // fileData and req are split into helper functions to ease the unit testing of delegateForUpload.
- // First, get the file data. This method will call `uploadData:command`.
- [self fileDataForUploadCommand:command];
-}
-
-- (void)uploadData:(NSData*)fileData command:(CDVInvokedUrlCommand*)command
-{
- NSURLRequest* req = [self requestForUploadCommand:command fileData:fileData];
-
- if (req == nil) {
- return;
- }
- CDVFileTransferDelegate* delegate = [self delegateForUploadCommand:command];
- [NSURLConnection connectionWithRequest:req delegate:delegate];
-
- if (activeTransfers == nil) {
- activeTransfers = [[NSMutableDictionary alloc] init];
- }
-
- [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (void)abort:(CDVInvokedUrlCommand*)command
-{
- NSString* objectId = [command.arguments objectAtIndex:0];
-
- CDVFileTransferDelegate* delegate = [activeTransfers objectForKey:objectId];
-
- if (delegate != nil) {
- [delegate cancelTransfer:delegate.connection];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]];
- [self.commandDelegate sendPluginResult:result callbackId:delegate.callbackId];
- }
-}
-
-- (void)download:(CDVInvokedUrlCommand*)command
-{
- DLog(@"File Transfer downloading file...");
- NSString* sourceUrl = [command.arguments objectAtIndex:0];
- NSString* filePath = [command.arguments objectAtIndex:1];
- BOOL trustAllHosts = [[command.arguments objectAtIndex:2 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- NSString* objectId = [command.arguments objectAtIndex:3];
- NSDictionary* headers = [command.arguments objectAtIndex:4 withDefault:nil];
-
- // return unsupported result for assets-library URLs
- if ([filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"download not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- CDVFileTransferError errorCode = 0;
-
- NSURL* file;
-
- if ([filePath hasPrefix:@"/"]) {
- file = [NSURL fileURLWithPath:filePath];
- } else {
- file = [NSURL URLWithString:filePath];
- }
-
- NSURL* url = [NSURL URLWithString:sourceUrl];
-
- if (!url) {
- errorCode = INVALID_URL_ERR;
- NSLog(@"File Transfer Error: Invalid server URL %@", sourceUrl);
- } else if (![file isFileURL]) {
- errorCode = FILE_NOT_FOUND_ERR;
- NSLog(@"File Transfer Error: Invalid file path or URL %@", filePath);
- }
-
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:sourceUrl AndTarget:filePath]];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
- [self applyRequestHeaders:headers toRequest:req];
-
- CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
- delegate.command = self;
- delegate.direction = CDV_TRANSFER_DOWNLOAD;
- delegate.callbackId = command.callbackId;
- delegate.objectId = objectId;
- delegate.source = sourceUrl;
- delegate.target = filePath;
- delegate.trustAllHosts = trustAllHosts;
-
- delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate];
-
- if (activeTransfers == nil) {
- activeTransfers = [[NSMutableDictionary alloc] init];
- }
-
- [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target
-{
- NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3];
-
- [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- if (source != nil) {
- [result setObject:source forKey:@"source"];
- }
- if (target != nil) {
- [result setObject:target forKey:@"target"];
- }
- NSLog(@"FileTransferError %@", result);
-
- return result;
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
- AndSource:(NSString*)source
- AndTarget:(NSString*)target
- AndHttpStatus:(int)httpStatus
- AndBody:(NSString*)body
-{
- NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:5];
-
- [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- if (source != nil) {
- [result setObject:source forKey:@"source"];
- }
- if (target != nil) {
- [result setObject:target forKey:@"target"];
- }
- [result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
- if (body != nil) {
- [result setObject:body forKey:@"body"];
- }
- NSLog(@"FileTransferError %@", result);
-
- return result;
-}
-
-- (void)onReset
-{
- for (CDVFileTransferDelegate* delegate in [activeTransfers allValues]) {
- [delegate.connection cancel];
- }
-
- [activeTransfers removeAllObjects];
-}
-
-@end
-
-@interface CDVFileTransferEntityLengthRequest : NSObject {
- NSURLConnection* _connection;
- CDVFileTransferDelegate* __weak _originalDelegate;
-}
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate;
-
-@end;
-
-@implementation CDVFileTransferEntityLengthRequest;
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate
-{
- if (self) {
- DLog(@"Requesting entity length for GZIPped content...");
-
- NSMutableURLRequest* req = [originalRequest mutableCopy];
- [req setHTTPMethod:@"HEAD"];
- [req setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"];
-
- _originalDelegate = originalDelegate;
- _connection = [NSURLConnection connectionWithRequest:req delegate:self];
- }
- return self;
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
- DLog(@"HEAD request returned; content-length is %lld", [response expectedContentLength]);
- [_originalDelegate updateBytesExpected:[response expectedContentLength]];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{}
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{}
-
-@end
-
-@implementation CDVFileTransferDelegate
-
-@synthesize callbackId, connection = _connection, source, target, responseData, command, bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle;
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{
- NSString* uploadResponse = nil;
- NSString* downloadResponse = nil;
- NSMutableDictionary* uploadResult;
- CDVPluginResult* result = nil;
- BOOL bDirRequest = NO;
- CDVFile* file;
-
- NSLog(@"File Transfer Finished with response code %d", self.responseCode);
-
- if (self.direction == CDV_TRANSFER_UPLOAD) {
- uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
-
- if ((self.responseCode >= 200) && (self.responseCode < 300)) {
- // create dictionary to return FileUploadResult object
- uploadResult = [NSMutableDictionary dictionaryWithCapacity:3];
- if (uploadResponse != nil) {
- [uploadResult setObject:uploadResponse forKey:@"response"];
- }
- [uploadResult setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"bytesSent"];
- [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:uploadResponse]];
- }
- }
- if (self.direction == CDV_TRANSFER_DOWNLOAD) {
- if (self.targetFileHandle) {
- [self.targetFileHandle closeFile];
- self.targetFileHandle = nil;
- DLog(@"File Transfer Download success");
-
- file = [[CDVFile alloc] init];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[file getDirectoryEntry:target isDirectory:bDirRequest]];
- } else {
- downloadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:downloadResponse]];
- }
- }
-
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-
- // remove connection for activeTransfers
- [command.activeTransfers removeObjectForKey:objectId];
-
- // remove background id task in case our upload was done in the background
- [[UIApplication sharedApplication] endBackgroundTask:self.command.backgroundTaskID];
- self.command.backgroundTaskID = UIBackgroundTaskInvalid;
-}
-
-- (void)removeTargetFile
-{
- NSFileManager* fileMgr = [NSFileManager defaultManager];
-
- [fileMgr removeItemAtPath:self.target error:nil];
-}
-
-- (void)cancelTransfer:(NSURLConnection*)connection
-{
- [connection cancel];
- [self.command.activeTransfers removeObjectForKey:self.objectId];
- [self removeTargetFile];
-}
-
-- (void)cancelTransferWithError:(NSURLConnection*)connection errorMessage:(NSString*)errorMessage
-{
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsDictionary:[self.command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:self.source AndTarget:self.target AndHttpStatus:self.responseCode AndBody:errorMessage]];
-
- NSLog(@"File Transfer Error: %@", errorMessage);
- [self cancelTransfer:connection];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
- NSError* __autoreleasing error = nil;
-
- self.mimeType = [response MIMEType];
- self.targetFileHandle = nil;
-
- // required for iOS 4.3, for some reason; response is
- // a plain NSURLResponse, not the HTTP subclass
- if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
- NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
-
- self.responseCode = [httpResponse statusCode];
- self.bytesExpected = [response expectedContentLength];
- if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode == 200) && (self.bytesExpected == NSURLResponseUnknownLength)) {
- // Kick off HEAD request to server to get real length
- // bytesExpected will be updated when that response is returned
- self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self];
- }
- } else if ([response.URL isFileURL]) {
- NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil];
- self.responseCode = 200;
- self.bytesExpected = [attr[NSFileSize] longLongValue];
- } else {
- self.responseCode = 200;
- self.bytesExpected = NSURLResponseUnknownLength;
- }
- if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode >= 200) && (self.responseCode < 300)) {
- // Download response is okay; begin streaming output to file
- NSString* parentPath = [self.target stringByDeletingLastPathComponent];
-
- // create parent directories if needed
- if ([[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error] == NO) {
- if (error) {
- [self cancelTransferWithError:connection errorMessage:[NSString stringWithFormat:@"Could not create path to save downloaded file: %@", [error localizedDescription]]];
- } else {
- [self cancelTransferWithError:connection errorMessage:@"Could not create path to save downloaded file"];
- }
- return;
- }
- // create target file
- if ([[NSFileManager defaultManager] createFileAtPath:self.target contents:nil attributes:nil] == NO) {
- [self cancelTransferWithError:connection errorMessage:@"Could not create target file"];
- return;
- }
- // open target file for writing
- self.targetFileHandle = [NSFileHandle fileHandleForWritingAtPath:self.target];
- if (self.targetFileHandle == nil) {
- [self cancelTransferWithError:connection errorMessage:@"Could not open target file for writing"];
- }
- DLog(@"Streaming to file %@", target);
- }
-}
-
-- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
-{
- NSString* body = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:body]];
-
- NSLog(@"File Transfer Error: %@", [error localizedDescription]);
-
- [self cancelTransfer:connection];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{
- self.bytesTransfered += data.length;
- if (self.targetFileHandle) {
- [self.targetFileHandle writeData:data];
- } else {
- [self.responseData appendData:data];
- }
- [self updateProgress];
-}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected
-{
- DLog(@"Updating bytesExpected to %d", newBytesExpected);
- self.bytesExpected = newBytesExpected;
- [self updateProgress];
-}
-
-- (void)updateProgress
-{
- if (self.direction == CDV_TRANSFER_DOWNLOAD) {
- BOOL lengthComputable = (self.bytesExpected != NSURLResponseUnknownLength);
- // If the response is GZipped, and we have an outstanding HEAD request to get
- // the length, then hold off on sending progress events.
- if (!lengthComputable && (self.entityLengthRequest != nil)) {
- return;
- }
- NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
- [downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"];
- [downloadProgress setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"loaded"];
- [downloadProgress setObject:[NSNumber numberWithInt:self.bytesExpected] forKey:@"total"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress];
- [result setKeepCallbackAsBool:true];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
-{
- if (self.direction == CDV_TRANSFER_UPLOAD) {
- NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-
- [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
- [uploadProgress setObject:[NSNumber numberWithInt:totalBytesWritten] forKey:@"loaded"];
- [uploadProgress setObject:[NSNumber numberWithInt:totalBytesExpectedToWrite] forKey:@"total"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];
- [result setKeepCallbackAsBool:true];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- self.bytesTransfered = totalBytesWritten;
-}
-
-// for self signed certificates
-- (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
-{
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
- if (self.trustAllHosts) {
- NSURLCredential* credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
- [challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
- }
- [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
- } else {
- [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
- }
-}
-
-- (id)init
-{
- if ((self = [super init])) {
- self.responseData = [NSMutableData data];
- self.targetFileHandle = nil;
- }
- return self;
-}
-
-@end;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index d025e35..b96f0b0 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F584B991385A28900ED25E8 /* CDVCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F584B9A1385A28900ED25E8 /* CDVCapture.m */; };
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /* CDVPluginResult.m */; };
301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 301F2F2914F3C9CA003FE9FC /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -21,8 +19,6 @@
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
- 30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C5F1DD15AF9E950052A00D /* CDVDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C5F1DE15AF9E950052A00D /* CDVDevice.m */; };
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */; };
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C684921407044A004C1A8E /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -42,8 +38,6 @@
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
- 8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD711090FBE7009987E8 /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD311090FBE7009987E8 /* CDVFile.m */; };
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -51,8 +45,6 @@
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
- C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = C937A4541337599E002C4C79 /* CDVFileTransfer.h */; settings = {ATTRIBUTES = (Public, ); }; };
- C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = C937A4551337599E002C4C79 /* CDVFileTransfer.m */; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -70,8 +62,6 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 1F584B991385A28900ED25E8 /* CDVCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCapture.h; path = Classes/CDVCapture.h; sourceTree = "<group>"; };
- 1F584B9A1385A28900ED25E8 /* CDVCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCapture.m; path = Classes/CDVCapture.m; sourceTree = "<group>"; };
1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree = "<group>"; };
1F92F49F1314023E0046367C /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVPluginResult.m; path = Classes/CDVPluginResult.m; sourceTree = "<group>"; };
301F2F2914F3C9CA003FE9FC /* CDV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDV.h; path = Classes/CDV.h; sourceTree = "<group>"; };
@@ -85,8 +75,6 @@
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
- 30C5F1DD15AF9E950052A00D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = Classes/CDVDevice.h; sourceTree = "<group>"; };
- 30C5F1DE15AF9E950052A00D /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = Classes/CDVDevice.m; sourceTree = "<group>"; };
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWhitelist.m; path = Classes/CDVWhitelist.m; sourceTree = "<group>"; };
30C684921407044A004C1A8E /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVURLProtocol.h; path = Classes/CDVURLProtocol.h; sourceTree = "<group>"; };
@@ -119,8 +107,6 @@
8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
- 8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
- 8887FD311090FBE7009987E8 /* CDVFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFile.m; path = Classes/CDVFile.m; sourceTree = "<group>"; };
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInvokedUrlCommand.h; path = Classes/CDVInvokedUrlCommand.h; sourceTree = "<group>"; };
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
@@ -130,8 +116,6 @@
8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
- C937A4541337599E002C4C79 /* CDVFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFileTransfer.h; path = Classes/CDVFileTransfer.h; sourceTree = "<group>"; };
- C937A4551337599E002C4C79 /* CDVFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFileTransfer.m; path = Classes/CDVFileTransfer.m; sourceTree = "<group>"; };
EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandQueue.h; path = Classes/CDVCommandQueue.h; sourceTree = "<group>"; };
EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCommandQueue.m; path = Classes/CDVCommandQueue.m; sourceTree = "<group>"; };
EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandDelegateImpl.h; path = Classes/CDVCommandDelegateImpl.h; sourceTree = "<group>"; };
@@ -224,8 +208,6 @@
children = (
EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */,
EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */,
- 30C5F1DD15AF9E950052A00D /* CDVDevice.h */,
- 30C5F1DE15AF9E950052A00D /* CDVDevice.m */,
301F2F2914F3C9CA003FE9FC /* CDV.h */,
3034979A1513D56A0090E688 /* CDVLocalStorage.h */,
3034979B1513D56A0090E688 /* CDVLocalStorage.m */,
@@ -243,16 +225,10 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 1F584B991385A28900ED25E8 /* CDVCapture.h */,
- 1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
+ EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
- 8887FD301090FBE7009987E8 /* CDVFile.h */,
- 8887FD311090FBE7009987E8 /* CDVFile.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
- C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
- C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
@@ -306,15 +282,12 @@
buildActionMask = 2147483647;
files = (
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
- 8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
- C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */,
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
- 1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
@@ -328,7 +301,6 @@
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */,
3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */,
EBA3557315ABD38C00F4DE24 /* NSArray+Comparisons.h in Headers */,
- 30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */,
EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */,
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */,
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */,
@@ -396,15 +368,12 @@
buildActionMask = 2147483647;
files = (
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
- 8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
- C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */,
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
- 1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
@@ -414,7 +383,6 @@
3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */,
3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */,
EBA3557515ABD38C00F4DE24 /* NSArray+Comparisons.m in Sources */,
- 30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */,
EB80C2AD15DEA63D004D9E7B /* CDVEcho.m in Sources */,
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */,
EB3B357D161F2A45003DBE7D /* CDVCommandDelegateImpl.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 38af0bc..1771906 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -52,24 +52,12 @@
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
- <feature name="Device">
- <param name="ios-package" value="CDVDevice"/>
- </feature>
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="File">
- <param name="ios-package" value="CDVFile"/>
- </feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection"/>
</feature>
- <feature name="FileTransfer">
- <param name="ios-package" value="CDVFileTransfer"/>
- </feature>
- <feature name="Capture">
- <param name="ios-package" value="CDVCapture"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[20/50] [abbrv] removed native plugin files for various plugins
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
deleted file mode 100644
index 3844525..0000000
--- a/CordovaLib/Classes/CDVContact.m
+++ /dev/null
@@ -1,1752 +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.
- */
-
-#import "CDVContact.h"
-#import "NSDictionary+Extensions.h"
-
-#define DATE_OR_NULL(dateObj) ((aDate != nil) ? (id)([aDate descriptionWithLocale:[NSLocale currentLocale]]) : (id)([NSNull null]))
-#define IS_VALID_VALUE(value) ((value != nil) && (![value isKindOfClass:[NSNull class]]))
-
-static NSDictionary* org_apache_cordova_contacts_W3CtoAB = nil;
-static NSDictionary* org_apache_cordova_contacts_ABtoW3C = nil;
-static NSSet* org_apache_cordova_contacts_W3CtoNull = nil;
-static NSDictionary* org_apache_cordova_contacts_objectAndProperties = nil;
-static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
-
-@implementation CDVContact : NSObject
-
- @synthesize returnFields;
-
-- (id)init
-{
- if ((self = [super init]) != nil) {
- ABRecordRef rec = ABPersonCreate();
- self.record = rec;
- if (rec) {
- CFRelease(rec);
- }
- }
- return self;
-}
-
-- (id)initFromABRecord:(ABRecordRef)aRecord
-{
- if ((self = [super init]) != nil) {
- self.record = aRecord;
- }
- return self;
-}
-
-/* synthesize 'record' ourselves to have retain properties for CF types */
-
-- (void)setRecord:(ABRecordRef)aRecord
-{
- if (record != NULL) {
- CFRelease(record);
- }
- if (aRecord != NULL) {
- record = CFRetain(aRecord);
- }
-}
-
-- (ABRecordRef)record
-{
- return record;
-}
-
-/* Rather than creating getters and setters for each AddressBook (AB) Property, generic methods are used to deal with
- * simple properties, MultiValue properties( phone numbers and emails) and MultiValueDictionary properties (Ims and addresses).
- * The dictionaries below are used to translate between the W3C identifiers and the AB properties. Using the dictionaries,
- * allows looping through sets of properties to extract from or set into the W3C dictionary to/from the ABRecord.
- */
-
-/* The two following dictionaries translate between W3C properties and AB properties. It currently mixes both
- * Properties (kABPersonAddressProperty for example) and Strings (kABPersonAddressStreetKey) so users should be aware of
- * what types of values are expected.
- * a bit.
-*/
-+ (NSDictionary*)defaultABtoW3C
-{
- if (org_apache_cordova_contacts_ABtoW3C == nil) {
- org_apache_cordova_contacts_ABtoW3C = [NSDictionary dictionaryWithObjectsAndKeys:
- kW3ContactNickname, [NSNumber numberWithInt:kABPersonNicknameProperty],
- kW3ContactGivenName, [NSNumber numberWithInt:kABPersonFirstNameProperty],
- kW3ContactFamilyName, [NSNumber numberWithInt:kABPersonLastNameProperty],
- kW3ContactMiddleName, [NSNumber numberWithInt:kABPersonMiddleNameProperty],
- kW3ContactHonorificPrefix, [NSNumber numberWithInt:kABPersonPrefixProperty],
- kW3ContactHonorificSuffix, [NSNumber numberWithInt:kABPersonSuffixProperty],
- kW3ContactPhoneNumbers, [NSNumber numberWithInt:kABPersonPhoneProperty],
- kW3ContactAddresses, [NSNumber numberWithInt:kABPersonAddressProperty],
- kW3ContactStreetAddress, kABPersonAddressStreetKey,
- kW3ContactLocality, kABPersonAddressCityKey,
- kW3ContactRegion, kABPersonAddressStateKey,
- kW3ContactPostalCode, kABPersonAddressZIPKey,
- kW3ContactCountry, kABPersonAddressCountryKey,
- kW3ContactEmails, [NSNumber numberWithInt:kABPersonEmailProperty],
- kW3ContactIms, [NSNumber numberWithInt:kABPersonInstantMessageProperty],
- kW3ContactOrganizations, [NSNumber numberWithInt:kABPersonOrganizationProperty],
- kW3ContactOrganizationName, [NSNumber numberWithInt:kABPersonOrganizationProperty],
- kW3ContactTitle, [NSNumber numberWithInt:kABPersonJobTitleProperty],
- kW3ContactDepartment, [NSNumber numberWithInt:kABPersonDepartmentProperty],
- kW3ContactBirthday, [NSNumber numberWithInt:kABPersonBirthdayProperty],
- kW3ContactUrls, [NSNumber numberWithInt:kABPersonURLProperty],
- kW3ContactNote, [NSNumber numberWithInt:kABPersonNoteProperty],
- nil];
- }
-
- return org_apache_cordova_contacts_ABtoW3C;
-}
-
-+ (NSDictionary*)defaultW3CtoAB
-{
- if (org_apache_cordova_contacts_W3CtoAB == nil) {
- org_apache_cordova_contacts_W3CtoAB = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:kABPersonNicknameProperty], kW3ContactNickname,
- [NSNumber numberWithInt:kABPersonFirstNameProperty], kW3ContactGivenName,
- [NSNumber numberWithInt:kABPersonLastNameProperty], kW3ContactFamilyName,
- [NSNumber numberWithInt:kABPersonMiddleNameProperty], kW3ContactMiddleName,
- [NSNumber numberWithInt:kABPersonPrefixProperty], kW3ContactHonorificPrefix,
- [NSNumber numberWithInt:kABPersonSuffixProperty], kW3ContactHonorificSuffix,
- [NSNumber numberWithInt:kABPersonPhoneProperty], kW3ContactPhoneNumbers,
- [NSNumber numberWithInt:kABPersonAddressProperty], kW3ContactAddresses,
- kABPersonAddressStreetKey, kW3ContactStreetAddress,
- kABPersonAddressCityKey, kW3ContactLocality,
- kABPersonAddressStateKey, kW3ContactRegion,
- kABPersonAddressZIPKey, kW3ContactPostalCode,
- kABPersonAddressCountryKey, kW3ContactCountry,
- [NSNumber numberWithInt:kABPersonEmailProperty], kW3ContactEmails,
- [NSNumber numberWithInt:kABPersonInstantMessageProperty], kW3ContactIms,
- [NSNumber numberWithInt:kABPersonOrganizationProperty], kW3ContactOrganizations,
- [NSNumber numberWithInt:kABPersonJobTitleProperty], kW3ContactTitle,
- [NSNumber numberWithInt:kABPersonDepartmentProperty], kW3ContactDepartment,
- [NSNumber numberWithInt:kABPersonBirthdayProperty], kW3ContactBirthday,
- [NSNumber numberWithInt:kABPersonNoteProperty], kW3ContactNote,
- [NSNumber numberWithInt:kABPersonURLProperty], kW3ContactUrls,
- kABPersonInstantMessageUsernameKey, kW3ContactImValue,
- kABPersonInstantMessageServiceKey, kW3ContactImType,
- [NSNull null], kW3ContactFieldType, /* include entries in dictionary to indicate ContactField properties */
- [NSNull null], kW3ContactFieldValue,
- [NSNull null], kW3ContactFieldPrimary,
- [NSNull null], kW3ContactFieldId,
- [NSNumber numberWithInt:kABPersonOrganizationProperty], kW3ContactOrganizationName, /* careful, name is used multiple times*/
- nil];
- }
- return org_apache_cordova_contacts_W3CtoAB;
-}
-
-+ (NSSet*)defaultW3CtoNull
-{
- // these are values that have no AddressBook Equivalent OR have not been implemented yet
- if (org_apache_cordova_contacts_W3CtoNull == nil) {
- org_apache_cordova_contacts_W3CtoNull = [NSSet setWithObjects:kW3ContactDisplayName,
- kW3ContactCategories, kW3ContactFormattedName, nil];
- }
- return org_apache_cordova_contacts_W3CtoNull;
-}
-
-/*
- * The objectAndProperties dictionary contains the all of the properties of the W3C Contact Objects specified by the key
- * Used in calcReturnFields, and various extract<Property> methods
- */
-+ (NSDictionary*)defaultObjectAndProperties
-{
- if (org_apache_cordova_contacts_objectAndProperties == nil) {
- org_apache_cordova_contacts_objectAndProperties = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSArray arrayWithObjects:kW3ContactGivenName, kW3ContactFamilyName,
- kW3ContactMiddleName, kW3ContactHonorificPrefix, kW3ContactHonorificSuffix, kW3ContactFormattedName, nil], kW3ContactName,
- [NSArray arrayWithObjects:kW3ContactStreetAddress, kW3ContactLocality, kW3ContactRegion,
- kW3ContactPostalCode, kW3ContactCountry, /*kW3ContactAddressFormatted,*/ nil], kW3ContactAddresses,
- [NSArray arrayWithObjects:kW3ContactOrganizationName, kW3ContactTitle, kW3ContactDepartment, nil], kW3ContactOrganizations,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactPhoneNumbers,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactEmails,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactPhotos,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactUrls,
- [NSArray arrayWithObjects:kW3ContactImValue, kW3ContactImType, nil], kW3ContactIms,
- nil];
- }
- return org_apache_cordova_contacts_objectAndProperties;
-}
-
-+ (NSDictionary*)defaultFields
-{
- if (org_apache_cordova_contacts_defaultFields == nil) {
- org_apache_cordova_contacts_defaultFields = [NSDictionary dictionaryWithObjectsAndKeys:
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactName], kW3ContactName,
- [NSNull null], kW3ContactNickname,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactAddresses], kW3ContactAddresses,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactOrganizations], kW3ContactOrganizations,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactPhoneNumbers], kW3ContactPhoneNumbers,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactEmails], kW3ContactEmails,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactIms], kW3ContactIms,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactPhotos], kW3ContactPhotos,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactUrls], kW3ContactUrls,
- [NSNull null], kW3ContactBirthday,
- [NSNull null], kW3ContactNote,
- nil];
- }
- return org_apache_cordova_contacts_defaultFields;
-}
-
-/* Translate W3C Contact data into ABRecordRef
- *
- * New contact information comes in as a NSMutableDictionary. All Null entries in Contact object are set
- * as [NSNull null] in the dictionary when translating from the JSON input string of Contact data. However, if
- * user did not set a value within a Contact object or sub-object (by not using the object constructor) some data
- * may not exist.
- * bUpdate = YES indicates this is a save of an existing record
- */
-- (bool)setFromContactDict:(NSDictionary*)aContact asUpdate:(BOOL)bUpdate
-{
- if (![aContact isKindOfClass:[NSDictionary class]]) {
- return FALSE; // can't do anything if no dictionary!
- }
-
- ABRecordRef person = self.record;
- bool bSuccess = TRUE;
- CFErrorRef error;
-
- // set name info
- // iOS doesn't have displayName - might have to pull parts from it to create name
- bool bName = false;
- NSDictionary* dict = [aContact valueForKey:kW3ContactName];
- if ([dict isKindOfClass:[NSDictionary class]]) {
- bName = true;
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactName];
-
- for (id i in propArray) {
- if (![(NSString*)i isEqualToString : kW3ContactFormattedName]) { // kW3ContactFormattedName is generated from ABRecordCopyCompositeName() and can't be set
- [self setValue:[dict valueForKey:i] forProperty:(ABPropertyID)[(NSNumber*)[[CDVContact defaultW3CtoAB] objectForKey:i] intValue]
- inRecord:person asUpdate:bUpdate];
- }
- }
- }
-
- id nn = [aContact valueForKey:kW3ContactNickname];
- if (![nn isKindOfClass:[NSNull class]]) {
- bName = true;
- [self setValue:nn forProperty:kABPersonNicknameProperty inRecord:person asUpdate:bUpdate];
- }
- if (!bName) {
- // if no name or nickname - try and use displayName as W3Contact must have displayName or ContactName
- [self setValue:[aContact valueForKey:kW3ContactDisplayName] forProperty:kABPersonNicknameProperty
- inRecord:person asUpdate:bUpdate];
- }
-
- // set phoneNumbers
- // NSLog(@"setting phoneNumbers");
- NSArray* array = [aContact valueForKey:kW3ContactPhoneNumbers];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonPhoneProperty inRecord:person asUpdate:bUpdate];
- }
- // set Emails
- // NSLog(@"setting emails");
- array = [aContact valueForKey:kW3ContactEmails];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonEmailProperty inRecord:person asUpdate:bUpdate];
- }
- // set Urls
- // NSLog(@"setting urls");
- array = [aContact valueForKey:kW3ContactUrls];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonURLProperty inRecord:person asUpdate:bUpdate];
- }
-
- // set multivalue dictionary properties
- // set addresses: streetAddress, locality, region, postalCode, country
- // set ims: value = username, type = servicetype
- // iOS addresses and im are a MultiValue Properties with label, value=dictionary of info, and id
- // NSLog(@"setting addresses");
- error = nil;
- array = [aContact valueForKey:kW3ContactAddresses];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueDictionary:array forProperty:kABPersonAddressProperty inRecord:person asUpdate:bUpdate];
- }
- // ims
- // NSLog(@"setting ims");
- array = [aContact valueForKey:kW3ContactIms];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueDictionary:array forProperty:kABPersonInstantMessageProperty inRecord:person asUpdate:bUpdate];
- }
-
- // organizations
- // W3C ContactOrganization has pref, type, name, title, department
- // iOS only supports name, title, department
- // NSLog(@"setting organizations");
- // TODO this may need work - should Organization information be removed when array is empty??
- array = [aContact valueForKey:kW3ContactOrganizations]; // iOS only supports one organization - use first one
- if ([array isKindOfClass:[NSArray class]]) {
- BOOL bRemove = NO;
- NSDictionary* dict = nil;
- if ([array count] > 0) {
- dict = [array objectAtIndex:0];
- } else {
- // remove the organization info entirely
- bRemove = YES;
- }
- if ([dict isKindOfClass:[NSDictionary class]] || (bRemove == YES)) {
- [self setValue:(bRemove ? @"" : [dict valueForKey:@"name"]) forProperty:kABPersonOrganizationProperty inRecord:person asUpdate:bUpdate];
- [self setValue:(bRemove ? @"" : [dict valueForKey:kW3ContactTitle]) forProperty:kABPersonJobTitleProperty inRecord:person asUpdate:bUpdate];
- [self setValue:(bRemove ? @"" : [dict valueForKey:kW3ContactDepartment]) forProperty:kABPersonDepartmentProperty inRecord:person asUpdate:bUpdate];
- }
- }
- // add dates
- // Dates come in as milliseconds in NSNumber Object
- id ms = [aContact valueForKey:kW3ContactBirthday];
- NSDate* aDate = nil;
- if (ms && [ms isKindOfClass:[NSNumber class]]) {
- double msValue = [ms doubleValue];
- msValue = msValue / 1000;
- aDate = [NSDate dateWithTimeIntervalSince1970:msValue];
- }
- if ((aDate != nil) || [ms isKindOfClass:[NSString class]]) {
- [self setValue:aDate != nil ? aDate:ms forProperty:kABPersonBirthdayProperty inRecord:person asUpdate:bUpdate];
- }
- // don't update creation date
- // modification date will get updated when save
- // anniversary is removed from W3C Contact api Dec 9, 2010 spec - don't waste time on it yet
-
- // kABPersonDateProperty
-
- // kABPersonAnniversaryLabel
-
- // iOS doesn't have gender - ignore
- // note
- [self setValue:[aContact valueForKey:kW3ContactNote] forProperty:kABPersonNoteProperty inRecord:person asUpdate:bUpdate];
-
- // iOS doesn't have preferredName- ignore
-
- // photo
- array = [aContact valueForKey:kW3ContactPhotos];
- if ([array isKindOfClass:[NSArray class]]) {
- if (bUpdate && ([array count] == 0)) {
- // remove photo
- bSuccess = ABPersonRemoveImageData(person, &error);
- } else if ([array count] > 0) {
- NSDictionary* dict = [array objectAtIndex:0]; // currently only support one photo
- if ([dict isKindOfClass:[NSDictionary class]]) {
- id value = [dict objectForKey:kW3ContactFieldValue];
- if ([value isKindOfClass:[NSString class]]) {
- if (bUpdate && ([value length] == 0)) {
- // remove the current image
- bSuccess = ABPersonRemoveImageData(person, &error);
- } else {
- // use this image
- // don't know if string is encoded or not so first unencode it then encode it again
- NSString* cleanPath = [value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL* photoUrl = [NSURL URLWithString:[cleanPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
- // caller is responsible for checking for a connection, if no connection this will fail
- NSError* err = nil;
- NSData* data = nil;
- if (photoUrl) {
- data = [NSData dataWithContentsOfURL:photoUrl options:NSDataReadingUncached error:&err];
- }
- if (data && ([data length] > 0)) {
- bSuccess = ABPersonSetImageData(person, (__bridge CFDataRef)data, &error);
- }
- if (!data || !bSuccess) {
- NSLog(@"error setting contact image: %@", (err != nil ? [err localizedDescription] : @""));
- }
- }
- }
- }
- }
- }
-
- // TODO WebURLs
-
- // TODO timezone
-
- return bSuccess;
-}
-
-/* Set item into an AddressBook Record for the specified property.
- * aValue - the value to set into the address book (code checks for null or [NSNull null]
- * aProperty - AddressBook property ID
- * aRecord - the record to update
- * bUpdate - whether this is a possible update vs a new entry
- * RETURN
- * true - property was set (or input value as null)
- * false - property was not set
- */
-- (bool)setValue:(id)aValue forProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = true; // if property was null, just ignore and return success
- CFErrorRef error;
-
- if (aValue && ![aValue isKindOfClass:[NSNull class]]) {
- if (bUpdate && ([aValue isKindOfClass:[NSString class]] && ([aValue length] == 0))) { // if updating, empty string means to delete
- aValue = NULL;
- } // really only need to set if different - more efficient to just update value or compare and only set if necessary???
- bSuccess = ABRecordSetValue(aRecord, aProperty, (__bridge CFTypeRef)aValue, &error);
- if (!bSuccess) {
- NSLog(@"error setting %d property", aProperty);
- }
- }
-
- return bSuccess;
-}
-
-- (bool)removeProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord
-{
- CFErrorRef err;
- bool bSuccess = ABRecordRemoveValue(aRecord, aProperty, &err);
-
- if (!bSuccess) {
- CFStringRef errDescription = CFErrorCopyDescription(err);
- NSLog(@"Unable to remove property %d: %@", aProperty, errDescription);
- CFRelease(errDescription);
- }
- return bSuccess;
-}
-
-- (bool)addToMultiValue:(ABMultiValueRef)multi fromDictionary:dict
-{
- bool bSuccess = FALSE;
- id value = [dict valueForKey:kW3ContactFieldValue];
-
- if (IS_VALID_VALUE(value)) {
- CFStringRef label = [CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
- bSuccess = ABMultiValueAddValueAndLabel(multi, (__bridge CFTypeRef)value, label, NULL);
- if (!bSuccess) {
- NSLog(@"Error setting Value: %@ and label: %@", value, label);
- }
- }
- return bSuccess;
-}
-
-- (ABMultiValueRef)allocStringMultiValueFromArray:array
-{
- ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiStringPropertyType);
-
- for (NSDictionary* dict in array) {
- [self addToMultiValue:multi fromDictionary:dict];
- }
-
- return multi; // caller is responsible for releasing multi
-}
-
-- (bool)setValue:(CFTypeRef)value forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person
-{
- CFErrorRef error;
- bool bSuccess = ABRecordSetValue(person, prop, value, &error);
-
- if (!bSuccess) {
- NSLog(@"Error setting value for property: %d", prop);
- }
- return bSuccess;
-}
-
-/* Set MultiValue string properties into Address Book Record.
- * NSArray* fieldArray - array of dictionaries containing W3C properties to be set into record
- * ABPropertyID prop - the property to be set (generally used for phones and emails)
- * ABRecordRef person - the record to set values into
- * BOOL bUpdate - whether or not to update date or set as new.
- * When updating:
- * empty array indicates to remove entire property
- * empty string indicates to remove
- * [NSNull null] do not modify (keep existing record value)
- * RETURNS
- * bool false indicates error
- *
- * used for phones and emails
- */
-- (bool)setMultiValueStrings:(NSArray*)fieldArray forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = TRUE;
- ABMutableMultiValueRef multi = nil;
-
- if (!bUpdate) {
- multi = [self allocStringMultiValueFromArray:fieldArray];
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- } else if (bUpdate && ([fieldArray count] == 0)) {
- // remove entire property
- bSuccess = [self removeProperty:prop inRecord:person];
- } else { // check for and apply changes
- ABMultiValueRef copy = ABRecordCopyValue(person, prop);
- if (copy != nil) {
- multi = ABMultiValueCreateMutableCopy(copy);
- CFRelease(copy);
-
- for (NSDictionary* dict in fieldArray) {
- id val;
- NSString* label = nil;
- val = [dict valueForKey:kW3ContactFieldValue];
- label = (__bridge NSString*)[CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
- if (IS_VALID_VALUE(val)) {
- // is an update, find index of entry with matching id, if values are different, update.
- id idValue = [dict valueForKey:kW3ContactFieldId];
- int identifier = [idValue isKindOfClass:[NSNumber class]] ? [idValue intValue] : -1;
- CFIndex i = identifier >= 0 ? ABMultiValueGetIndexForIdentifier(multi, identifier) : kCFNotFound;
- if (i != kCFNotFound) {
- if ([val length] == 0) {
- // remove both value and label
- ABMultiValueRemoveValueAndLabelAtIndex(multi, i);
- } else {
- NSString* valueAB = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
- NSString* labelAB = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- if ((valueAB == nil) || ![val isEqualToString:valueAB]) {
- ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)val, i);
- }
- if ((labelAB == nil) || ![label isEqualToString:labelAB]) {
- ABMultiValueReplaceLabelAtIndex(multi, (__bridge CFStringRef)label, i);
- }
- }
- } else {
- // is a new value - insert
- [self addToMultiValue:multi fromDictionary:dict];
- }
- } // end of if value
- } // end of for
- } else { // adding all new value(s)
- multi = [self allocStringMultiValueFromArray:fieldArray];
- }
- // set the (updated) copy as the new value
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- }
-
- if (multi) {
- CFRelease(multi);
- }
-
- return bSuccess;
-}
-
-// used for ims and addresses
-- (ABMultiValueRef)allocDictMultiValueFromArray:array forProperty:(ABPropertyID)prop
-{
- ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
- NSMutableDictionary* newDict;
- NSMutableDictionary* addDict;
-
- for (NSDictionary* dict in array) {
- newDict = [self translateW3Dict:dict forProperty:prop];
- addDict = [NSMutableDictionary dictionaryWithCapacity:2];
- if (newDict) { // create a new dictionary with a Label and Value, value is the dictionary previously created
- // June, 2011 W3C Contact spec adds type into ContactAddress book
- // get the type out of the original dictionary for address
- NSString* addrType = (NSString*)[dict valueForKey:kW3ContactFieldType];
- if (!addrType) {
- addrType = (NSString*)kABOtherLabel;
- }
- NSObject* typeValue = ((prop == kABPersonInstantMessageProperty) ? (NSObject*)kABOtherLabel : addrType);
- // NSLog(@"typeValue: %@", typeValue);
- [addDict setObject:typeValue forKey:kW3ContactFieldType]; // im labels will be set as Other and address labels as type from dictionary
- [addDict setObject:newDict forKey:kW3ContactFieldValue];
- [self addToMultiValue:multi fromDictionary:addDict];
- }
- }
-
- return multi; // caller is responsible for releasing
-}
-
-// used for ims and addresses to convert W3 dictionary of values to AB Dictionary
-// got messier when June, 2011 W3C Contact spec added type field into ContactAddress
-- (NSMutableDictionary*)translateW3Dict:(NSDictionary*)dict forProperty:(ABPropertyID)prop
-{
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] valueForKey:[[CDVContact defaultABtoW3C] objectForKey:[NSNumber numberWithInt:prop]]];
-
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:1];
- id value;
-
- for (NSString* key in propArray) { // for each W3 Contact key get the value
- if (((value = [dict valueForKey:key]) != nil) && ![value isKindOfClass:[NSNull class]]) {
- // if necessary convert the W3 value to AB Property label
- NSString* setValue = value;
- if ([CDVContact needsConversion:key]) { // IM types must be converted
- setValue = (NSString*)[CDVContact convertContactTypeToPropertyLabel:value];
- // IMs must have a valid AB value!
- if ((prop == kABPersonInstantMessageProperty) && [setValue isEqualToString:(NSString*)kABOtherLabel]) {
- setValue = @""; // try empty string
- }
- }
- // set the AB value into the dictionary
- [newDict setObject:setValue forKey:(NSString*)[[CDVContact defaultW3CtoAB] valueForKey:(NSString*)key]];
- }
- }
-
- if ([newDict count] == 0) {
- newDict = nil; // no items added
- }
- return newDict;
-}
-
-/* set multivalue dictionary properties into an AddressBook Record
- * NSArray* array - array of dictionaries containing the W3C properties to set into the record
- * ABPropertyID prop - the property id for the multivalue dictionary (addresses and ims)
- * ABRecordRef person - the record to set the values into
- * BOOL bUpdate - YES if this is an update to an existing record
- * When updating:
- * empty array indicates to remove entire property
- * value/label == "" indicates to remove
- * value/label == [NSNull null] do not modify (keep existing record value)
- * RETURN
- * bool false indicates fatal error
- *
- * iOS addresses and im are a MultiValue Properties with label, value=dictionary of info, and id
- * set addresses: streetAddress, locality, region, postalCode, country
- * set ims: value = username, type = servicetype
- * there are some special cases in here for ims - needs cleanup / simplification
- *
- */
-- (bool)setMultiValueDictionary:(NSArray*)array forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = FALSE;
- ABMutableMultiValueRef multi = nil;
-
- if (!bUpdate) {
- multi = [self allocDictMultiValueFromArray:array forProperty:prop];
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- } else if (bUpdate && ([array count] == 0)) {
- // remove property
- bSuccess = [self removeProperty:prop inRecord:person];
- } else { // check for and apply changes
- ABMultiValueRef copy = ABRecordCopyValue(person, prop);
- if (copy) {
- multi = ABMultiValueCreateMutableCopy(copy);
- CFRelease(copy);
- // get the W3C values for this property
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] valueForKey:[[CDVContact defaultABtoW3C] objectForKey:[NSNumber numberWithInt:prop]]];
- id value;
- id valueAB;
-
- for (NSDictionary* field in array) {
- NSMutableDictionary* dict;
- // find the index for the current property
- id idValue = [field valueForKey:kW3ContactFieldId];
- int identifier = [idValue isKindOfClass:[NSNumber class]] ? [idValue intValue] : -1;
- CFIndex idx = identifier >= 0 ? ABMultiValueGetIndexForIdentifier(multi, identifier) : kCFNotFound;
- BOOL bUpdateLabel = NO;
- if (idx != kCFNotFound) {
- dict = [NSMutableDictionary dictionaryWithCapacity:1];
- // NSDictionary* existingDictionary = (NSDictionary*)ABMultiValueCopyValueAtIndex(multi, idx);
- CFTypeRef existingDictionary = ABMultiValueCopyValueAtIndex(multi, idx);
- NSString* existingABLabel = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, idx);
- NSString* testLabel = [field valueForKey:kW3ContactFieldType];
- // fixes cb-143 where setting empty label could cause address to not be removed
- // (because empty label would become 'other' in convertContactTypeToPropertyLabel
- // which may not have matched existing label thus resulting in an incorrect updating of the label
- // and the address not getting removed at the end of the for loop)
- if (testLabel && [testLabel isKindOfClass:[NSString class]] && ([testLabel length] > 0)) {
- CFStringRef w3cLabel = [CDVContact convertContactTypeToPropertyLabel:testLabel];
- if (w3cLabel && ![existingABLabel isEqualToString:(__bridge NSString*)w3cLabel]) {
- // replace the label
- ABMultiValueReplaceLabelAtIndex(multi, w3cLabel, idx);
- bUpdateLabel = YES;
- }
- } // else was invalid or empty label string so do not update
-
- for (id k in propArray) {
- value = [field valueForKey:k];
- bool bSet = (value != nil && ![value isKindOfClass:[NSNull class]] && ([value isKindOfClass:[NSString class]] && [value length] > 0));
- // if there is a contact value, put it into dictionary
- if (bSet) {
- NSString* setValue = [CDVContact needsConversion:(NSString*)k] ? (NSString*)[CDVContact convertContactTypeToPropertyLabel:value] : value;
- [dict setObject:setValue forKey:(NSString*)[[CDVContact defaultW3CtoAB] valueForKey:(NSString*)k]];
- } else if ((value == nil) || ([value isKindOfClass:[NSString class]] && ([value length] != 0))) {
- // value not provided in contact dictionary - if prop exists in AB dictionary, preserve it
- valueAB = [(__bridge NSDictionary*)existingDictionary valueForKey : [[CDVContact defaultW3CtoAB] valueForKey:k]];
- if (valueAB != nil) {
- [dict setValue:valueAB forKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
- }
- } // else if value == "" it will not be added into updated dict and thus removed
- } // end of for loop (moving here fixes cb-143, need to end for loop before replacing or removing multivalue)
-
- if ([dict count] > 0) {
- // something was added into new dict,
- ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)dict, idx);
- } else if (!bUpdateLabel) {
- // nothing added into new dict and no label change so remove this property entry
- ABMultiValueRemoveValueAndLabelAtIndex(multi, idx);
- }
-
- CFRelease(existingDictionary);
- } else {
- // not found in multivalue so add it
- dict = [self translateW3Dict:field forProperty:prop];
- if (dict) {
- NSMutableDictionary* addDict = [NSMutableDictionary dictionaryWithCapacity:2];
- // get the type out of the original dictionary for address
- NSObject* typeValue = ((prop == kABPersonInstantMessageProperty) ? (NSObject*)kABOtherLabel : (NSString*)[field valueForKey:kW3ContactFieldType]);
- // NSLog(@"typeValue: %@", typeValue);
- [addDict setObject:typeValue forKey:kW3ContactFieldType]; // im labels will be set as Other and address labels as type from dictionary
- [addDict setObject:dict forKey:kW3ContactFieldValue];
- [self addToMultiValue:multi fromDictionary:addDict];
- }
- }
- } // end of looping through dictionaries
-
- // set the (updated) copy as the new value
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- }
- } // end of copy and apply changes
- if (multi) {
- CFRelease(multi);
- }
-
- return bSuccess;
-}
-
-/* Determine which W3C labels need to be converted
- */
-+ (BOOL)needsConversion:(NSString*)W3Label
-{
- BOOL bConvert = NO;
-
- if ([W3Label isEqualToString:kW3ContactFieldType] || [W3Label isEqualToString:kW3ContactImType]) {
- bConvert = YES;
- }
- return bConvert;
-}
-
-/* Translation of property type labels contact API ---> iPhone
- *
- * phone: work, home, other, mobile, fax, pager -->
- * kABWorkLabel, kABHomeLabel, kABOtherLabel, kABPersonPhoneMobileLabel, kABPersonHomeFAXLabel || kABPersonHomeFAXLabel, kABPersonPhonePagerLabel
- * emails: work, home, other ---> kABWorkLabel, kABHomeLabel, kABOtherLabel
- * ims: aim, gtalk, icq, xmpp, msn, skype, qq, yahoo --> kABPersonInstantMessageService + (AIM, ICG, MSN, Yahoo). No support for gtalk, xmpp, skype, qq
- * addresses: work, home, other --> kABWorkLabel, kABHomeLabel, kABOtherLabel
- *
- *
- */
-+ (CFStringRef)convertContactTypeToPropertyLabel:(NSString*)label
-{
- CFStringRef type;
-
- if ([label isKindOfClass:[NSNull class]] || ![label isKindOfClass:[NSString class]]) {
- type = NULL; // no label
- } else if ([label caseInsensitiveCompare:kW3ContactWorkLabel] == NSOrderedSame) {
- type = kABWorkLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactHomeLabel] == NSOrderedSame) {
- type = kABHomeLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactOtherLabel] == NSOrderedSame) {
- type = kABOtherLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactPhoneMobileLabel] == NSOrderedSame) {
- type = kABPersonPhoneMobileLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactPhonePagerLabel] == NSOrderedSame) {
- type = kABPersonPhonePagerLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactImAIMLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceAIM;
- } else if ([label caseInsensitiveCompare:kW3ContactImICQLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceICQ;
- } else if ([label caseInsensitiveCompare:kW3ContactImMSNLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceMSN;
- } else if ([label caseInsensitiveCompare:kW3ContactImYahooLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceYahoo;
- } else if ([label caseInsensitiveCompare:kW3ContactUrlProfile] == NSOrderedSame) {
- type = kABPersonHomePageLabel;
- } else {
- type = kABOtherLabel;
- }
-
- return type;
-}
-
-+ (NSString*)convertPropertyLabelToContactType:(NSString*)label
-{
- NSString* type = nil;
-
- if (label != nil) { // improve efficiency......
- if ([label isEqualToString:(NSString*)kABPersonPhoneMobileLabel]) {
- type = kW3ContactPhoneMobileLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonPhoneHomeFAXLabel] ||
- [label isEqualToString:(NSString*)kABPersonPhoneWorkFAXLabel]) {
- type = kW3ContactPhoneFaxLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonPhonePagerLabel]) {
- type = kW3ContactPhonePagerLabel;
- } else if ([label isEqualToString:(NSString*)kABHomeLabel]) {
- type = kW3ContactHomeLabel;
- } else if ([label isEqualToString:(NSString*)kABWorkLabel]) {
- type = kW3ContactWorkLabel;
- } else if ([label isEqualToString:(NSString*)kABOtherLabel]) {
- type = kW3ContactOtherLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceAIM]) {
- type = kW3ContactImAIMLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceICQ]) {
- type = kW3ContactImICQLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceJabber]) {
- type = kW3ContactOtherLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceMSN]) {
- type = kW3ContactImMSNLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceYahoo]) {
- type = kW3ContactImYahooLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonHomePageLabel]) {
- type = kW3ContactUrlProfile;
- } else {
- type = kW3ContactOtherLabel;
- }
- }
- return type;
-}
-
-/* Check if the input label is a valid W3C ContactField.type. This is used when searching,
- * only search field types if the search string is a valid type. If we converted any search
- * string to a ABPropertyLabel it could convert to kABOtherLabel which is probably not want
- * the user wanted to search for and could skew the results.
- */
-+ (BOOL)isValidW3ContactType:(NSString*)label
-{
- BOOL isValid = NO;
-
- if ([label isKindOfClass:[NSNull class]] || ![label isKindOfClass:[NSString class]]) {
- isValid = NO; // no label
- } else if ([label caseInsensitiveCompare:kW3ContactWorkLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactHomeLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactOtherLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactPhoneMobileLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactPhonePagerLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImAIMLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImICQLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImMSNLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImYahooLabel] == NSOrderedSame) {
- isValid = YES;
- } else {
- isValid = NO;
- }
-
- return isValid;
-}
-
-/* Create a new Contact Dictionary object from an ABRecordRef that contains information in a format such that
- * it can be returned to JavaScript callback as JSON object string.
- * Uses:
- * ABRecordRef set into Contact Object
- * NSDictionary withFields indicates which fields to return from the AddressBook Record
- *
- * JavaScript Contact:
- * @param {DOMString} id unique identifier
- * @param {DOMString} displayName
- * @param {ContactName} name
- * @param {DOMString} nickname
- * @param {ContactField[]} phoneNumbers array of phone numbers
- * @param {ContactField[]} emails array of email addresses
- * @param {ContactAddress[]} addresses array of addresses
- * @param {ContactField[]} ims instant messaging user ids
- * @param {ContactOrganization[]} organizations
- * @param {DOMString} published date contact was first created
- * @param {DOMString} updated date contact was last updated
- * @param {DOMString} birthday contact's birthday
- * @param (DOMString} anniversary contact's anniversary
- * @param {DOMString} gender contact's gender
- * @param {DOMString} note user notes about contact
- * @param {DOMString} preferredUsername
- * @param {ContactField[]} photos
- * @param {ContactField[]} tags
- * @param {ContactField[]} relationships
- * @param {ContactField[]} urls contact's web sites
- * @param {ContactAccounts[]} accounts contact's online accounts
- * @param {DOMString} timezone UTC time zone offset
- * @param {DOMString} connected
- */
-
-- (NSDictionary*)toDictionary:(NSDictionary*)withFields
-{
- // if not a person type record bail out for now
- if (ABRecordGetRecordType(self.record) != kABPersonType) {
- return NULL;
- }
- id value = nil;
- self.returnFields = withFields;
-
- NSMutableDictionary* nc = [NSMutableDictionary dictionaryWithCapacity:1]; // new contact dictionary to fill in from ABRecordRef
- // id
- [nc setObject:[NSNumber numberWithInt:ABRecordGetRecordID(self.record)] forKey:kW3ContactId];
- if (self.returnFields == nil) {
- // if no returnFields specified, W3C says to return empty contact (but Cordova will at least return id)
- return nc;
- }
- if ([self.returnFields objectForKey:kW3ContactDisplayName]) {
- // displayname requested - iOS doesn't have so return null
- [nc setObject:[NSNull null] forKey:kW3ContactDisplayName];
- // may overwrite below if requested ContactName and there are no values
- }
- // nickname
- if ([self.returnFields valueForKey:kW3ContactNickname]) {
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactNickname];
- }
-
- // name dictionary
- // NSLog(@"getting name info");
- NSObject* data = [self extractName];
- if (data != nil) {
- [nc setObject:data forKey:kW3ContactName];
- }
- if ([self.returnFields objectForKey:kW3ContactDisplayName] && ((data == nil) || ([(NSDictionary*)data objectForKey : kW3ContactFormattedName] == [NSNull null]))) {
- // user asked for displayName which iOS doesn't support but there is no other name data being returned
- // try and use Composite Name so some name is returned
- id tryName = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- if (tryName != nil) {
- [nc setObject:tryName forKey:kW3ContactDisplayName];
- } else {
- // use nickname or empty string
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
- [nc setObject:(value != nil) ? value:@"" forKey:kW3ContactDisplayName];
- }
- }
- // phoneNumbers array
- // NSLog(@"getting phoneNumbers");
- value = [self extractMultiValue:kW3ContactPhoneNumbers];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactPhoneNumbers];
- }
- // emails array
- // NSLog(@"getting emails");
- value = [self extractMultiValue:kW3ContactEmails];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactEmails];
- }
- // urls array
- value = [self extractMultiValue:kW3ContactUrls];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactUrls];
- }
- // addresses array
- // NSLog(@"getting addresses");
- value = [self extractAddresses];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactAddresses];
- }
- // im array
- // NSLog(@"getting ims");
- value = [self extractIms];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactIms];
- }
- // organization array (only info for one organization in iOS)
- // NSLog(@"getting organizations");
- value = [self extractOrganizations];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactOrganizations];
- }
-
- // for simple properties, could make this a bit more efficient by storing all simple properties in a single
- // array in the returnFields dictionary and setting them via a for loop through the array
-
- // add dates
- // NSLog(@"getting dates");
- NSNumber* ms;
-
- /** Contact Revision field removed from June 16, 2011 version of specification
-
- if ([self.returnFields valueForKey:kW3ContactUpdated]){
- ms = [self getDateAsNumber: kABPersonModificationDateProperty];
- if (!ms){
- // try and get published date
- ms = [self getDateAsNumber: kABPersonCreationDateProperty];
- }
- if (ms){
- [nc setObject: ms forKey:kW3ContactUpdated];
- }
-
- }
- */
-
- if ([self.returnFields valueForKey:kW3ContactBirthday]) {
- ms = [self getDateAsNumber:kABPersonBirthdayProperty];
- if (ms) {
- [nc setObject:ms forKey:kW3ContactBirthday];
- }
- }
-
- /* Anniversary removed from 12-09-2010 W3C Contacts api spec
- if ([self.returnFields valueForKey:kW3ContactAnniversary]){
- // Anniversary date is stored in a multivalue property
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonDateProperty);
- if (multi){
- CFStringRef label = nil;
- CFIndex count = ABMultiValueGetCount(multi);
- // see if contains an Anniversary date
- for(CFIndex i=0; i<count; i++){
- label = ABMultiValueCopyLabelAtIndex(multi, i);
- if(label && [(NSString*)label isEqualToString:(NSString*)kABPersonAnniversaryLabel]){
- CFDateRef aDate = ABMultiValueCopyValueAtIndex(multi, i);
- if(aDate){
- [nc setObject: (NSString*)aDate forKey: kW3ContactAnniversary];
- CFRelease(aDate);
- }
- CFRelease(label);
- break;
- }
- }
- CFRelease(multi);
- }
- }*/
-
- if ([self.returnFields valueForKey:kW3ContactNote]) {
- // note
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNoteProperty);
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactNote];
- }
-
- if ([self.returnFields valueForKey:kW3ContactPhotos]) {
- value = [self extractPhotos];
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactPhotos];
- }
-
- /* TimeZone removed from June 16, 2011 Contacts spec
- *
- if ([self.returnFields valueForKey:kW3ContactTimezone]){
- [NSTimeZone resetSystemTimeZone];
- NSTimeZone* currentTZ = [NSTimeZone localTimeZone];
- NSInteger seconds = [currentTZ secondsFromGMT];
- NSString* tz = [NSString stringWithFormat:@"%2d:%02u", seconds/3600, seconds % 3600 ];
- [nc setObject:tz forKey:kW3ContactTimezone];
- }
- */
- // TODO WebURLs
- // [nc setObject:[NSNull null] forKey:kW3ContactUrls];
- // online accounts - not available on iOS
-
- return nc;
-}
-
-- (NSNumber*)getDateAsNumber:(ABPropertyID)datePropId
-{
- NSNumber* msDate = nil;
- NSDate* aDate = nil;
- CFTypeRef cfDate = ABRecordCopyValue(self.record, datePropId);
-
- if (cfDate) {
- aDate = (__bridge NSDate*)cfDate;
- msDate = [NSNumber numberWithDouble:([aDate timeIntervalSince1970] * 1000)];
- CFRelease(cfDate);
- }
- return msDate;
-}
-
-/* Create Dictionary to match JavaScript ContactName object:
- * formatted - ABRecordCopyCompositeName
- * familyName
- * givenName
- * middleName
- * honorificPrefix
- * honorificSuffix
-*/
-
-- (NSObject*)extractName
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactName];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
-
- NSMutableDictionary* newName = [NSMutableDictionary dictionaryWithCapacity:6];
- id value;
-
- for (NSString* i in fields) {
- if ([i isEqualToString:kW3ContactFormattedName]) {
- value = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- [newName setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFormattedName];
- } else {
- // W3CtoAB returns NSNumber for AB name properties, get intValue and cast to ABPropertyID)
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
- [newName setObject:(value != nil) ? value:[NSNull null] forKey:(NSString*)i];
- }
- }
-
- return newName;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactField object for simple multiValue properties phoneNumbers, emails
- * Input: (NSString*) W3Contact Property name
- * type
- * for phoneNumbers type is one of (work,home,other, mobile, fax, pager)
- * for emails type is one of (work,home, other)
- * value - phone number or email address
- * (bool) primary (not supported on iphone)
- * id
-*/
-- (NSObject*)extractMultiValue:(NSString*)propertyId
-{
- NSArray* fields = [self.returnFields objectForKey:propertyId];
-
- if (fields == nil) {
- return nil;
- }
- ABMultiValueRef multi = nil;
- NSObject* valuesArray = nil;
- NSNumber* propNumber = [[CDVContact defaultW3CtoAB] valueForKey:propertyId];
- ABPropertyID propId = [propNumber intValue];
- multi = ABRecordCopyValue(self.record, propId);
- // multi = ABRecordCopyValue(self.record, (ABPropertyID)[[[Contact defaultW3CtoAB] valueForKey:propertyId] intValue]);
- CFIndex count = multi != nil ? ABMultiValueGetCount(multi) : 0;
- id value;
- if (count) {
- valuesArray = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < count; i++) {
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:4];
- if ([fields containsObject:kW3ContactFieldType]) {
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- value = [CDVContact convertPropertyLabelToContactType:label];
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldType];
- }
- if ([fields containsObject:kW3ContactFieldValue]) {
- value = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldValue];
- }
- if ([fields containsObject:kW3ContactFieldPrimary]) {
- [newDict setObject:[NSNumber numberWithBool:(BOOL)NO] forKey:kW3ContactFieldPrimary]; // iOS doesn't support primary so set all to false
- }
- // always set id
- value = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldId];
- [(NSMutableArray*)valuesArray addObject : newDict];
- }
- } else {
- valuesArray = [NSNull null];
- }
- if (multi) {
- CFRelease(multi);
- }
-
- return valuesArray;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactAddress object for addresses
- * pref - not supported
- * type - address type
- * formatted - formatted for mailing label (what about localization?)
- * streetAddress
- * locality
- * region;
- * postalCode
- * country
- * id
- *
- * iOS addresses are a MultiValue Properties with label, value=dictionary of address info, and id
- */
-- (NSObject*)extractAddresses
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactAddresses];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- CFStringRef value;
- NSObject* addresses;
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonAddressProperty);
- CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
- if (count) {
- addresses = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < count; i++) {
- NSMutableDictionary* newAddress = [NSMutableDictionary dictionaryWithCapacity:7];
- // if we got this far, at least some address info is being requested.
-
- // Always set id
- id identifier = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newAddress setObject:(identifier != nil) ? identifier:[NSNull null] forKey:kW3ContactFieldId];
- // set the type label
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
-
- [newAddress setObject:(label != nil) ? (NSObject*)[[CDVContact class] convertPropertyLabelToContactType:label]:[NSNull null] forKey:kW3ContactFieldType];
- // set the pref - iOS doesn't support so set to default of false
- [newAddress setObject:@"false" forKey:kW3ContactFieldPrimary];
- // get dictionary of values for this address
- CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(multi, i);
-
- for (id k in fields) {
- bool bFound;
- id key = [[CDVContact defaultW3CtoAB] valueForKey:k];
- if (key && ![k isKindOfClass:[NSNull class]]) {
- bFound = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)key, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newAddress setObject:(__bridge id)value forKey:k];
- CFRelease(value);
- } else {
- [newAddress setObject:[NSNull null] forKey:k];
- }
- } else {
- // was a property that iPhone doesn't support
- [newAddress setObject:[NSNull null] forKey:k];
- }
- }
-
- if ([newAddress count] > 0) { // ?? this will always be true since we set id,label,primary field??
- [(NSMutableArray*)addresses addObject : newAddress];
- }
- CFRelease(dict);
- } // end of loop through addresses
- } else {
- addresses = [NSNull null];
- }
- if (multi) {
- CFRelease(multi);
- }
-
- return addresses;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactField object for ims
- * type one of [aim, gtalk, icq, xmpp, msn, skype, qq, yahoo] needs other as well
- * value
- * (bool) primary
- * id
- *
- * iOS IMs are a MultiValue Properties with label, value=dictionary of IM details (service, username), and id
- */
-- (NSObject*)extractIms
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactIms];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- NSObject* imArray;
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonInstantMessageProperty);
- CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
- if (count) {
- imArray = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) {
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:3];
- // iOS has label property (work, home, other) for each IM but W3C contact API doesn't use
- CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(multi, i);
- CFStringRef value; // all values should be CFStringRefs / NSString*
- bool bFound;
- if ([fields containsObject:kW3ContactFieldValue]) {
- // value = user name
- bFound = CFDictionaryGetValueIfPresent(dict, kABPersonInstantMessageUsernameKey, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newDict setObject:(__bridge id)value forKey:kW3ContactFieldValue];
- CFRelease(value);
- } else {
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldValue];
- }
- }
- if ([fields containsObject:kW3ContactFieldType]) {
- bFound = CFDictionaryGetValueIfPresent(dict, kABPersonInstantMessageServiceKey, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newDict setObject:(id)[[CDVContact class] convertPropertyLabelToContactType : (__bridge NSString*)value] forKey:kW3ContactFieldType];
- CFRelease(value);
- } else {
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
- }
- }
- // always set ID
- id identifier = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newDict setObject:(identifier != nil) ? identifier:[NSNull null] forKey:kW3ContactFieldId];
-
- [(NSMutableArray*)imArray addObject : newDict];
- CFRelease(dict);
- }
- } else {
- imArray = [NSNull null];
- }
-
- if (multi) {
- CFRelease(multi);
- }
- return imArray;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactOrganization object
- * pref - not supported in iOS
- * type - not supported in iOS
- * name
- * department
- * title
- */
-
-- (NSObject*)extractOrganizations
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactOrganizations];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- NSObject* array = nil;
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:5];
- id value;
- int validValueCount = 0;
-
- for (id i in fields) {
- id key = [[CDVContact defaultW3CtoAB] valueForKey:i];
- if (key && [key isKindOfClass:[NSNumber class]]) {
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
- if (value != nil) {
- // if there are no organization values we should return null for organization
- // this counter keeps indicates if any organization values have been set
- validValueCount++;
- }
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:i];
- } else { // not a key iOS supports, set to null
- [newDict setObject:[NSNull null] forKey:i];
- }
- }
-
- if (([newDict count] > 0) && (validValueCount > 0)) {
- // add pref and type
- // they are not supported by iOS and thus these values never change
- [newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
- array = [NSMutableArray arrayWithCapacity:1];
- [(NSMutableArray*)array addObject : newDict];
- } else {
- array = [NSNull null];
- }
- return array;
-}
-
-// W3C Contacts expects an array of photos. Can return photos in more than one format, currently
-// just returning the default format
-// Save the photo data into tmp directory and return FileURI - temp directory is deleted upon application exit
-- (NSObject*)extractPhotos
-{
- NSMutableArray* photos = nil;
-
- if (ABPersonHasImageData(self.record)) {
- CFDataRef photoData = ABPersonCopyImageData(self.record);
- NSData* data = (__bridge NSData*)photoData;
- // write to temp directory and store URI in photos array
- // get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
- NSError* err = nil;
- NSString* filePath = [NSString stringWithFormat:@"%@/photo_XXXXX", docsPath];
- char template[filePath.length + 1];
- strcpy(template, [filePath cStringUsingEncoding:NSASCIIStringEncoding]);
- mkstemp(template);
- filePath = [[NSFileManager defaultManager]
- stringWithFileSystemRepresentation:template
- length:strlen(template)];
-
- // save file
- if ([data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- photos = [NSMutableArray arrayWithCapacity:1];
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:2];
- [newDict setObject:filePath forKey:kW3ContactFieldValue];
- [newDict setObject:@"url" forKey:kW3ContactFieldType];
- [newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
- [photos addObject:newDict];
- }
-
- CFRelease(photoData);
- }
- return photos;
-}
-
-/**
- * given an array of W3C Contact field names, create a dictionary of field names to extract
- * if field name represents an object, return all properties for that object: "name" - returns all properties in ContactName
- * if field name is an explicit property, return only those properties: "name.givenName - returns a ContactName with only ContactName.givenName
- * if field contains ONLY ["*"] return all fields
- * dictionary format:
- * key is W3Contact #define
- * value is NSMutableArray* for complex keys: name,addresses,organizations, phone, emails, ims
- * value is [NSNull null] for simple keys
-*/
-+ (NSDictionary*)calcReturnFields:(NSArray*)fieldsArray // NSLog(@"getting self.returnFields");
-{
- NSMutableDictionary* d = [NSMutableDictionary dictionaryWithCapacity:1];
-
- if ((fieldsArray != nil) && [fieldsArray isKindOfClass:[NSArray class]]) {
- if (([fieldsArray count] == 1) && [[fieldsArray objectAtIndex:0] isEqualToString:@"*"]) {
- return [CDVContact defaultFields]; // return all fields
- }
-
- for (id i in fieldsArray) {
- NSMutableArray* keys = nil;
- NSString* fieldStr = nil;
- if ([i isKindOfClass:[NSNumber class]]) {
- fieldStr = [i stringValue];
- } else {
- fieldStr = i;
- }
-
- // see if this is specific property request in object - object.property
- NSArray* parts = [fieldStr componentsSeparatedByString:@"."]; // returns original string if no separator found
- NSString* name = [parts objectAtIndex:0];
- NSString* property = nil;
- if ([parts count] > 1) {
- property = [parts objectAtIndex:1];
- }
- // see if this is a complex field by looking for its array of properties in objectAndProperties dictionary
- id fields = [[CDVContact defaultObjectAndProperties] objectForKey:name];
-
- // if find complex name (name,addresses,organizations, phone, emails, ims) in fields, add name as key
- // with array of associated properties as the value
- if ((fields != nil) && (property == nil)) { // request was for full object
- keys = [NSMutableArray arrayWithArray:fields];
- if (keys != nil) {
- [d setObject:keys forKey:name]; // will replace if prop array already exists
- }
- } else if ((fields != nil) && (property != nil)) {
- // found an individual property request in form of name.property
- // verify is real property name by using it as key in W3CtoAB
- id abEquiv = [[CDVContact defaultW3CtoAB] objectForKey:property];
- if (abEquiv || [[CDVContact defaultW3CtoNull] containsObject:property]) {
- // if existing array add to it
- if ((keys = [d objectForKey:name]) != nil) {
- [keys addObject:property];
- } else {
- keys = [NSMutableArray arrayWithObject:property];
- [d setObject:keys forKey:name];
- }
- } else {
- NSLog(@"Contacts.find -- request for invalid property ignored: %@.%@", name, property);
- }
- } else { // is an individual property, verify is real property name by using it as key in W3CtoAB
- id valid = [[CDVContact defaultW3CtoAB] objectForKey:name];
- if (valid || [[CDVContact defaultW3CtoNull] containsObject:name]) {
- [d setObject:[NSNull null] forKey:name];
- }
- }
- }
- }
- if ([d count] == 0) {
- // no array or nothing in the array. W3C spec says to return nothing
- return nil; // [Contact defaultFields];
- }
- return d;
-}
-
-/*
- * Search for the specified value in each of the fields specified in the searchFields dictionary.
- * NSString* value - the string value to search for (need clarification from W3C on how to search for dates)
- * NSDictionary* searchFields - a dictionary created via calcReturnFields where the key is the top level W3C
- * object and the object is the array of specific fields within that object or null if it is a single property
- * RETURNS
- * YES as soon as a match is found in any of the fields
- * NO - the specified value does not exist in any of the fields in this contact
- *
- * Note: I'm not a fan of returning in the middle of methods but have done it some in this method in order to
- * keep the code simpler. bgibson
- */
-- (BOOL)foundValue:(NSString*)testValue inFields:(NSDictionary*)searchFields
-{
- BOOL bFound = NO;
-
- if ((testValue == nil) || ![testValue isKindOfClass:[NSString class]] || ([testValue length] == 0)) {
- // nothing to find so return NO
- return NO;
- }
- NSInteger valueAsInt = [testValue integerValue];
-
- // per W3C spec, always include id in search
- int recordId = ABRecordGetRecordID(self.record);
- if (valueAsInt && (recordId == valueAsInt)) {
- return YES;
- }
-
- if (searchFields == nil) {
- // no fields to search
- return NO;
- }
-
- if ([searchFields valueForKey:kW3ContactNickname]) {
- bFound = [self testStringValue:testValue forW3CProperty:kW3ContactNickname];
- if (bFound == YES) {
- return bFound;
- }
- }
-
- if ([searchFields valueForKeyIsArray:kW3ContactName]) {
- // test name fields. All are string properties obtained via ABRecordCopyValue except kW3ContactFormattedName
- NSArray* fields = [searchFields valueForKey:kW3ContactName];
-
- for (NSString* testItem in fields) {
- if ([testItem isEqualToString:kW3ContactFormattedName]) {
- NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- if ((propValue != nil) && ([propValue length] > 0)) {
- NSRange range = [propValue rangeOfString:testValue options:NSCaseInsensitiveSearch];
- bFound = (range.location != NSNotFound);
- propValue = nil;
- }
- } else {
- bFound = [self testStringValue:testValue forW3CProperty:testItem];
- }
-
- if (bFound) {
- break;
- }
- }
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactPhoneNumbers]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactPhoneNumbers]
- forMVStringProperty:kABPersonPhoneProperty withValue:testValue];
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactEmails]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactEmails]
- forMVStringProperty:kABPersonEmailProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactAddresses]) {
- bFound = [self searchContactFields:[searchFields valueForKey:kW3ContactAddresses]
- forMVDictionaryProperty:kABPersonAddressProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactIms]) {
- bFound = [self searchContactFields:[searchFields valueForKey:kW3ContactIms]
- forMVDictionaryProperty:kABPersonInstantMessageProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactOrganizations]) {
- NSArray* fields = [searchFields valueForKey:kW3ContactOrganizations];
-
- for (NSString* testItem in fields) {
- bFound = [self testStringValue:testValue forW3CProperty:testItem];
- if (bFound == YES) {
- break;
- }
- }
- }
- if (!bFound && [searchFields valueForKey:kW3ContactNote]) {
- bFound = [self testStringValue:testValue forW3CProperty:kW3ContactNote];
- }
-
- // if searching for a date field is requested, get the date field as a localized string then look for match against testValue in date string
- // searching for photos is not supported
- if (!bFound && [searchFields valueForKey:kW3ContactBirthday]) {
- bFound = [self testDateValue:testValue forW3CProperty:kW3ContactBirthday];
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactUrls]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactUrls]
- forMVStringProperty:kABPersonURLProperty withValue:testValue];
- }
-
- return bFound;
-}
-
-/*
- * Test for the existence of a given string within the value of a ABPersonRecord string property based on the W3c property name.
- *
- * IN:
- * NSString* testValue - the value to find - search is case insensitive
- * NSString* property - the W3c property string
- * OUT:
- * BOOL YES if the given string was found within the property value
- * NO if the testValue was not found, W3C property string was invalid or the AddressBook property was not a string
- */
-- (BOOL)testStringValue:(NSString*)testValue forW3CProperty:(NSString*)property
-{
- BOOL bFound = NO;
-
- if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber:property]) {
- ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey:property] intValue];
- if (ABPersonGetTypeOfProperty(propId) == kABStringPropertyType) {
- NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, propId);
- if ((propValue != nil) && ([propValue length] > 0)) {
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:propValue];
- // NSRange range = [propValue rangeOfString:testValue options: NSCaseInsensitiveSearch];
- // bFound = (range.location != NSNotFound);
- }
- }
- }
- return bFound;
-}
-
-/*
- * Test for the existence of a given Date string within the value of a ABPersonRecord datetime property based on the W3c property name.
- *
- * IN:
- * NSString* testValue - the value to find - search is case insensitive
- * NSString* property - the W3c property string
- * OUT:
- * BOOL YES if the given string was found within the localized date string value
- * NO if the testValue was not found, W3C property string was invalid or the AddressBook property was not a DateTime
- */
-- (BOOL)testDateValue:(NSString*)testValue forW3CProperty:(NSString*)property
-{
- BOOL bFound = NO;
-
- if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber:property]) {
- ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey:property] intValue];
- if (ABPersonGetTypeOfProperty(propId) == kABDateTimePropertyType) {
- NSDate* date = (__bridge_transfer NSDate*)ABRecordCopyValue(self.record, propId);
- if (date != nil) {
- NSString* dateString = [date descriptionWithLocale:[NSLocale currentLocale]];
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:dateString];
- }
- }
- }
- return bFound;
-}
-
-/*
- * Search the specified fields within an AddressBook multivalue string property for the specified test value.
- * Used for phoneNumbers, emails and urls.
- * IN:
- * NSArray* fields - the fields to search for within the multistring property (value and/or type)
- * ABPropertyID - the property to search
- * NSString* testValue - the value to search for. Will convert between W3C types and AB types. Will only
- * search for types if the testValue is a valid ContactField type.
- * OUT:
- * YES if the test value was found in one of the specified fields
- * NO if the test value was not found
- */
-- (BOOL)searchContactFields:(NSArray*)fields forMVStringProperty:(ABPropertyID)propId withValue:testValue
-{
- BOOL bFound = NO;
-
- for (NSString* type in fields) {
- NSString* testString = nil;
- if ([type isEqualToString:kW3ContactFieldType]) {
- if ([CDVContact isValidW3ContactType:testValue]) {
- // only search types if the filter string is a valid ContactField.type
- testString = (NSString*)[CDVContact convertContactTypeToPropertyLabel:testValue];
- }
- } else {
- testString = testValue;
- }
-
- if (testString != nil) {
- bFound = [self testMultiValueStrings:testString forProperty:propId ofType:type];
- }
- if (bFound == YES) {
- break;
- }
- }
-
- return bFound;
-}
-
-/*
- * Searches a multiString value of the specified type for the specified test value.
- *
- * IN:
- * NSString* testValue - the value to test for
- * ABPropertyID propId - the property id of the multivalue property to search
- * NSString* type - the W3C contact type to search for (value or type)
- * OUT:
- * YES is the test value was found
- * NO if the test value was not found
- */
-- (BOOL)testMultiValueStrings:(NSString*)testValue forProperty:(ABPropertyID)propId ofType:(NSString*)type
-{
- BOOL bFound = NO;
-
- if (ABPersonGetTypeOfProperty(propId) == kABMultiStringPropertyType) {
- NSArray* valueArray = nil;
- if ([type isEqualToString:kW3ContactFieldType]) {
- valueArray = [self labelsForProperty:propId inRecord:self.record];
- } else if ([type isEqualToString:kW3ContactFieldValue]) {
- valueArray = [self valuesForProperty:propId inRecord:self.record];
- }
- if (valueArray) {
- NSString* valuesAsString = [valueArray componentsJoinedByString:@" "];
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:valuesAsString];
- }
- }
- return bFound;
-}
-
-/*
- * Returns the array of values for a multivalue string property of the specified property id
- */
-- (__autoreleasing NSArray*)valuesForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord
-{
- ABMultiValueRef multi = ABRecordCopyValue(aRecord, propId);
- NSArray* values = (__bridge_transfer NSArray*)ABMultiValueCopyArrayOfAllValues(multi);
-
- CFRelease(multi);
- return values;
-}
-
-/*
- * Returns the array of labels for a multivalue string property of the specified property id
- */
-- (NSArray*)labelsForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord
-{
- ABMultiValueRef multi = ABRecordCopyValue(aRecord, propId);
- CFIndex count = ABMultiValueGetCount(multi);
- NSMutableArray* labels = [NSMutableArray arrayWithCapacity:count];
-
- for (int i = 0; i < count; i++) {
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- if (label) {
- [labels addObject:label];
- }
- }
-
- CFRelease(multi);
- return labels;
-}
-
-/* search for values within MultiValue Dictionary properties Address or IM property
- * IN:
- * (NSArray*) fields - the array of W3C field names to search within
- * (ABPropertyID) propId - the AddressBook property that returns a multivalue dictionary
- * (NSString*) testValue - the string to search for within the specified fields
- *
- */
-- (BOOL)searchContactFields:(NSArray*)fields forMVDictionaryProperty:(ABPropertyID)propId withValue:(NSString*)testValue
-{
- BOOL bFound = NO;
-
- NSArray* values = [self valuesForProperty:propId inRecord:self.record]; // array of dictionaries (as CFDictionaryRef)
- int dictCount = [values count];
-
- // for ims dictionary contains with service (w3C type) and username (W3c value)
- // for addresses dictionary contains street, city, state, zip, country
- for (int i = 0; i < dictCount; i++) {
- CFDictionaryRef dict = (__bridge CFDictionaryRef)[values objectAtIndex:i];
-
- for (NSString* member in fields) {
- NSString* abKey = [[CDVContact defaultW3CtoAB] valueForKey:member]; // im and address fields are all strings
- CFStringRef abValue = nil;
- if (abKey) {
- NSString* testString = nil;
- if ([member isEqualToString:kW3ContactImType]) {
- if ([CDVContact isValidW3ContactType:testValue]) {
- // only search service/types if the filter string is a valid ContactField.type
- testString = (NSString*)[CDVContact convertContactTypeToPropertyLabel:testValue];
- }
- } else {
- testString = testValue;
- }
- if (testString != nil) {
- BOOL bExists = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)abKey, (void*)&abValue);
- if (bExists) {
- CFRetain(abValue);
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testString];
- bFound = [containPred evaluateWithObject:(__bridge id)abValue];
- CFRelease(abValue);
- }
- }
- }
- if (bFound == YES) {
- break;
- }
- } // end of for each member in fields
-
- if (bFound == YES) {
- break;
- }
- } // end of for each dictionary
-
- return bFound;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
deleted file mode 100644
index 0342f5b..0000000
--- a/CordovaLib/Classes/CDVContacts.h
+++ /dev/null
@@ -1,151 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <AddressBook/ABAddressBook.h>
-#import <AddressBookUI/AddressBookUI.h>
-#import "CDVPlugin.h"
-#import "CDVContact.h"
-
-@interface CDVContacts : CDVPlugin <ABNewPersonViewControllerDelegate,
- ABPersonViewControllerDelegate,
- ABPeoplePickerNavigationControllerDelegate
- >
-{
- ABAddressBookRef addressBook;
-}
-
-/*
- * newContact - create a new contact via the GUI
- *
- * arguments:
- * 1: successCallback: this is the javascript function that will be called with the newly created contactId
- */
-- (void)newContact:(CDVInvokedUrlCommand*)command;
-
-/*
- * displayContact - IN PROGRESS
- *
- * arguments:
- * 1: recordID of the contact to display in the iPhone contact display
- * 2: successCallback - currently not used
- * 3: error callback
- * options:
- * allowsEditing: set to true to allow the user to edit the contact - currently not supported
- */
-- (void)displayContact:(CDVInvokedUrlCommand*)command;
-
-/*
- * chooseContact
- *
- * arguments:
- * 1: this is the javascript function that will be called with the contact data as a JSON object (as the first param)
- * options:
- * allowsEditing: set to true to not choose the contact, but to edit it in the iPhone contact editor
- */
-- (void)chooseContact:(CDVInvokedUrlCommand*)command;
-
-- (void)newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person;
-- (BOOL)personViewController:(ABPersonViewController*)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
- property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue;
-
-/*
- * search - searches for contacts. Only person records are currently supported.
- *
- * arguments:
- * 1: successcallback - this is the javascript function that will be called with the array of found contacts
- * 2: errorCallback - optional javascript function to be called in the event of an error with an error code.
- * options: dictionary containing ContactFields and ContactFindOptions
- * fields - ContactFields array
- * findOptions - ContactFindOptions object as dictionary
- *
- */
-- (void)search:(CDVInvokedUrlCommand*)command;
-
-/*
- * save - saves a new contact or updates and existing contact
- *
- * arguments:
- * 1: success callback - this is the javascript function that will be called with the JSON representation of the saved contact
- * search calls a fixed navigator.service.contacts._findCallback which then calls the success callback stored before making the call into obj-c
- */
-- (void)save:(CDVInvokedUrlCommand*)command;
-
-/*
- * remove - removes a contact from the address book
- *
- * arguments:
- * 1: 1: successcallback - this is the javascript function that will be called with a (now) empty contact object
- *
- * options: dictionary containing Contact object to remove
- * contact - Contact object as dictionary
- */
-- (void)remove:(CDVInvokedUrlCommand*)command;
-
-// - (void) dealloc;
-
-@end
-
-@interface CDVContactsPicker : ABPeoplePickerNavigationController
-{
- BOOL allowsEditing;
- NSString* callbackId;
- NSDictionary* options;
- NSDictionary* pickedContactDictionary;
-}
-
-@property BOOL allowsEditing;
-@property (copy) NSString* callbackId;
-@property (nonatomic, strong) NSDictionary* options;
-@property (nonatomic, strong) NSDictionary* pickedContactDictionary;
-
-@end
-
-@interface CDVNewContactsController : ABNewPersonViewController
-{
- NSString* callbackId;
-}
-@property (copy) NSString* callbackId;
-@end
-
-/* ABPersonViewController does not have any UI to dismiss. Adding navigationItems to it does not work properly, the navigationItems are lost when the app goes into the background.
- The solution was to create an empty NavController in front of the ABPersonViewController. This
- causes the ABPersonViewController to have a back button. By subclassing the ABPersonViewController,
- we can override viewWillDisappear and take down the entire NavigationController at that time.
- */
-@interface CDVDisplayContactViewController : ABPersonViewController
-{}
-@property (nonatomic, strong) CDVPlugin* contactsPlugin;
-
-@end
-@interface CDVAddressBookAccessError : NSObject
-{}
-@property (assign) CDVContactError errorCode;
-- (CDVAddressBookAccessError*)initWithCode:(CDVContactError)code;
-@end
-
-typedef void (^ CDVAddressBookWorkerBlock)(
- ABAddressBookRef addressBook,
- CDVAddressBookAccessError* error
- );
-@interface CDVAddressBookHelper : NSObject
-{}
-
-- (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock;
-@end
[11/50] [abbrv] ios commit: removed network information from ios
Posted by ag...@apache.org.
removed network information from ios
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/5c7efe08
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/5c7efe08
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/5c7efe08
Branch: refs/heads/master
Commit: 5c7efe08b0b7d45da45fb7f6f888470bf3d952bd
Parents: 6067588
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 18:12:25 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 18:12:25 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 2 -
CordovaLib/Classes/CDVConnection.h | 34 ---
CordovaLib/Classes/CDVConnection.m | 132 ----------
CordovaLib/Classes/CDVReachability.h | 85 ------
CordovaLib/Classes/CDVReachability.m | 260 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 16 --
bin/templates/project/__TESTING__/config.xml | 3 -
7 files changed, 532 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index cef896b..0c1779f 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,10 +25,8 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVConnection.h"
#import "CDVDebug.h"
#import "CDVPluginResult.h"
-#import "CDVReachability.h"
#import "CDVSound.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/Classes/CDVConnection.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.h b/CordovaLib/Classes/CDVConnection.h
deleted file mode 100644
index d3e8c5d..0000000
--- a/CordovaLib/Classes/CDVConnection.h
+++ /dev/null
@@ -1,34 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-#import "CDVReachability.h"
-
-@interface CDVConnection : CDVPlugin {
- NSString* type;
- NSString* _callbackId;
-
- CDVReachability* internetReach;
-}
-
-@property (copy) NSString* connectionType;
-@property (strong) CDVReachability* internetReach;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/Classes/CDVConnection.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m
deleted file mode 100644
index b3f5cab..0000000
--- a/CordovaLib/Classes/CDVConnection.m
+++ /dev/null
@@ -1,132 +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.
- */
-
-#import "CDVConnection.h"
-#import "CDVReachability.h"
-
-@interface CDVConnection (PrivateMethods)
-- (void)updateOnlineStatus;
-- (void)sendPluginResult;
-@end
-
-@implementation CDVConnection
-
-@synthesize connectionType, internetReach;
-
-- (void)getConnectionInfo:(CDVInvokedUrlCommand*)command
-{
- _callbackId = command.callbackId;
- [self sendPluginResult];
-}
-
-- (void)sendPluginResult
-{
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType];
-
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:_callbackId];
-}
-
-- (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
-{
- NetworkStatus networkStatus = [reachability currentReachabilityStatus];
-
- switch (networkStatus) {
- case NotReachable:
- return @"none";
-
- case ReachableViaWWAN:
- // Return value of '2g' is deprecated as of 2.6.0 and will be replaced with 'cellular' in 3.0.0
- return @"2g";
-
- case ReachableViaWiFi:
- return @"wifi";
-
- default:
- return @"unknown";
- }
-}
-
-- (BOOL)isCellularConnection:(NSString*)theConnectionType
-{
- return [theConnectionType isEqualToString:@"2g"] ||
- [theConnectionType isEqualToString:@"3g"] ||
- [theConnectionType isEqualToString:@"4g"] ||
- [theConnectionType isEqualToString:@"cellular"];
-}
-
-- (void)updateReachability:(CDVReachability*)reachability
-{
- if (reachability) {
- // check whether the connection type has changed
- NSString* newConnectionType = [self w3cConnectionTypeFor:reachability];
- if ([newConnectionType isEqualToString:self.connectionType]) { // the same as before, remove dupes
- return;
- } else {
- self.connectionType = [self w3cConnectionTypeFor:reachability];
- }
- }
- [self sendPluginResult];
-}
-
-- (void)updateConnectionType:(NSNotification*)note
-{
- CDVReachability* curReach = [note object];
-
- if ((curReach != nil) && [curReach isKindOfClass:[CDVReachability class]]) {
- [self updateReachability:curReach];
- }
-}
-
-- (void)onPause
-{
- [self.internetReach stopNotifier];
-}
-
-- (void)onResume
-{
- [self.internetReach startNotifier];
- [self updateReachability:self.internetReach];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super initWithWebView:theWebView];
- if (self) {
- self.connectionType = @"none";
- self.internetReach = [CDVReachability reachabilityForInternetConnection];
- self.connectionType = [self w3cConnectionTypeFor:self.internetReach];
- [self.internetReach startNotifier];
- [self printDeprecationNotice];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
- name:kReachabilityChangedNotification object:nil];
- if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- }
- }
- return self;
-}
-
-- (void)printDeprecationNotice
-{
- NSLog(@"DEPRECATION NOTICE: The Connection ReachableViaWWAN return value of '2g' is deprecated as of Cordova version 2.6.0 and will be changed to 'cellular' in a future release. ");
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/Classes/CDVReachability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.h b/CordovaLib/Classes/CDVReachability.h
deleted file mode 100644
index 01a95c3..0000000
--- a/CordovaLib/Classes/CDVReachability.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-
- File: Reachability.h
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <Foundation/Foundation.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-#import <netinet/in.h>
-
-typedef enum {
- NotReachable = 0,
- ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
- ReachableViaWiFi // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
-} NetworkStatus;
-#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
-
-@interface CDVReachability : NSObject
-{
- BOOL localWiFiRef;
- SCNetworkReachabilityRef reachabilityRef;
-}
-
-// reachabilityWithHostName- Use to check the reachability of a particular host name.
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-
-// reachabilityWithAddress- Use to check the reachability of a particular IP address.
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-
-// reachabilityForInternetConnection- checks whether the default route is available.
-// Should be used by applications that do not connect to a particular host
-+ (CDVReachability*)reachabilityForInternetConnection;
-
-// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
-+ (CDVReachability*)reachabilityForLocalWiFi;
-
-// Start listening for reachability notifications on the current run loop
-- (BOOL)startNotifier;
-- (void)stopNotifier;
-
-- (NetworkStatus)currentReachabilityStatus;
-// WWAN may be available, but not active until a connection has been established.
-// WiFi may require a connection for VPN on Demand.
-- (BOOL)connectionRequired;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/Classes/CDVReachability.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.m b/CordovaLib/Classes/CDVReachability.m
deleted file mode 100644
index 89f4ec9..0000000
--- a/CordovaLib/Classes/CDVReachability.m
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-
- File: Reachability.m
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <sys/socket.h>
-#import <netinet/in.h>
-#import <netinet6/in6.h>
-#import <arpa/inet.h>
-#import <ifaddrs.h>
-#import <netdb.h>
-
-#import <CoreFoundation/CoreFoundation.h>
-
-#import "CDVReachability.h"
-
-#define kShouldPrintReachabilityFlags 0
-
-static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
-{
-#if kShouldPrintReachabilityFlags
- NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
-
- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
- comment
- );
-#endif
-}
-
-@implementation CDVReachability
-
-static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
-{
-#pragma unused (target, flags)
- // NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
- // NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
-
- // Converted the asserts above to conditionals, with safe return from the function
- if (info == NULL) {
- NSLog(@"info was NULL in ReachabilityCallback");
- return;
- }
-
- if (![(__bridge NSObject*)info isKindOfClass :[CDVReachability class]]) {
- NSLog(@"info was wrong class in ReachabilityCallback");
- return;
- }
-
- // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
- // in case someon uses the Reachability object in a different thread.
- @autoreleasepool {
- CDVReachability* noteObject = (__bridge CDVReachability*)info;
- // Post a notification to notify the client that the network reachability changed.
- [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
- }
-}
-
-- (BOOL)startNotifier
-{
- BOOL retVal = NO;
- SCNetworkReachabilityContext context = {0, (__bridge void*)(self), NULL, NULL, NULL};
-
- if (SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context)) {
- if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
- retVal = YES;
- }
- }
- return retVal;
-}
-
-- (void)stopNotifier
-{
- if (reachabilityRef != NULL) {
- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- }
-}
-
-- (void)dealloc
-{
- [self stopNotifier];
- if (reachabilityRef != NULL) {
- CFRelease(reachabilityRef);
- }
-}
-
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-{
- CDVReachability* retVal = NULL;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-{
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
- CDVReachability* retVal = NULL;
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityForInternetConnection;
-{
- struct sockaddr_in zeroAddress;
- bzero(&zeroAddress, sizeof(zeroAddress));
- zeroAddress.sin_len = sizeof(zeroAddress);
- zeroAddress.sin_family = AF_INET;
- return [self reachabilityWithAddress:&zeroAddress];
-}
-
-+ (CDVReachability*)reachabilityForLocalWiFi;
-{
- struct sockaddr_in localWifiAddress;
- bzero(&localWifiAddress, sizeof(localWifiAddress));
- localWifiAddress.sin_len = sizeof(localWifiAddress);
- localWifiAddress.sin_family = AF_INET;
- // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
- localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
- CDVReachability* retVal = [self reachabilityWithAddress:&localWifiAddress];
- if (retVal != NULL) {
- retVal->localWiFiRef = YES;
- }
- return retVal;
-}
-
-#pragma mark Network Flag Handling
-
-- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags");
-
- BOOL retVal = NotReachable;
- if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) {
- retVal = ReachableViaWiFi;
- }
- return retVal;
-}
-
-- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "networkStatusForFlags");
- if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
- // if target host is not reachable
- return NotReachable;
- }
-
- BOOL retVal = NotReachable;
-
- if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) {
- // if target host is reachable and no connection is required
- // then we'll assume (for now) that your on Wi-Fi
- retVal = ReachableViaWiFi;
- }
-
- if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
- ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
- // ... and the connection is on-demand (or on-traffic) if the
- // calling application is using the CFSocketStream or higher APIs
-
- if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) {
- // ... and no [user] intervention is needed
- retVal = ReachableViaWiFi;
- }
- }
-
- if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
- // ... but WWAN connections are OK if the calling application
- // is using the CFNetwork (CFSocketStream?) APIs.
- retVal = ReachableViaWWAN;
- }
- return retVal;
-}
-
-- (BOOL)connectionRequired;
-{
- NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- return flags & kSCNetworkReachabilityFlagsConnectionRequired;
- }
- return NO;
-}
-
-- (NetworkStatus)currentReachabilityStatus
-{
- NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
- NetworkStatus retVal = NotReachable;
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- if (localWiFiRef) {
- retVal = [self localWiFiStatusForFlags:flags];
- } else {
- retVal = [self networkStatusForFlags:flags];
- }
- }
- return retVal;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index b96f0b0..2e0f696 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -17,8 +17,6 @@
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */; };
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */; };
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C684921407044A004C1A8E /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -42,8 +40,6 @@
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
- 8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
@@ -73,8 +69,6 @@
3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+Extensions.h"; path = "Classes/UIDevice+Extensions.h"; sourceTree = "<group>"; };
3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+Extensions.m"; path = "Classes/UIDevice+Extensions.m"; sourceTree = "<group>"; };
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
- 307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
- 307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWhitelist.m; path = Classes/CDVWhitelist.m; sourceTree = "<group>"; };
30C684921407044A004C1A8E /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVURLProtocol.h; path = Classes/CDVURLProtocol.h; sourceTree = "<group>"; };
@@ -111,8 +105,6 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVReachability.h; path = Classes/CDVReachability.h; sourceTree = "<group>"; };
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVReachability.m; path = Classes/CDVReachability.m; sourceTree = "<group>"; };
8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
@@ -221,16 +213,12 @@
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
- 307A8F9C1385A2EC00E43782 /* CDVConnection.h */,
- 307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
8887FD611090FBE7009987E8 /* CDVSound.m */,
3E76876B156A90EE00EB6FA3 /* CDVLogger.m */,
@@ -284,10 +272,8 @@
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
- 8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
- 307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
@@ -370,10 +356,8 @@
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
- 8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
- 307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c7efe08/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 1771906..018490c 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -55,9 +55,6 @@
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="NetworkStatus">
- <param name="ios-package" value="CDVConnection"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[02/50] [abbrv] ios commit: removed camera code
Posted by ag...@apache.org.
removed camera code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/e07c199b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/e07c199b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/e07c199b
Branch: refs/heads/master
Commit: e07c199b9c02f7138cd5559c736260f1355ec283
Parents: cae2231
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 14:01:38 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 13 14:01:38 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVCamera.h | 102 ---
CordovaLib/Classes/CDVCamera.m | 729 -------------------
CordovaLib/Classes/CDVExif.h | 43 --
CordovaLib/Classes/CDVJpegHeaderWriter.h | 62 --
CordovaLib/Classes/CDVJpegHeaderWriter.m | 547 --------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 20 -
bin/templates/project/__TESTING__/config.xml | 3 -
8 files changed, 1507 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 9da128a..03c2a3e 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
#import "CDVDebug.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
deleted file mode 100644
index 2932e3b..0000000
--- a/CordovaLib/Classes/CDVCamera.h
+++ /dev/null
@@ -1,102 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <CoreLocation/CoreLocation.h>
-#import <CoreLocation/CLLocationManager.h>
-#import "CDVPlugin.h"
-
-enum CDVDestinationType {
- DestinationTypeDataUrl = 0,
- DestinationTypeFileUri,
- DestinationTypeNativeUri
-};
-typedef NSUInteger CDVDestinationType;
-
-enum CDVEncodingType {
- EncodingTypeJPEG = 0,
- EncodingTypePNG
-};
-typedef NSUInteger CDVEncodingType;
-
-enum CDVMediaType {
- MediaTypePicture = 0,
- MediaTypeVideo,
- MediaTypeAll
-};
-typedef NSUInteger CDVMediaType;
-
-@interface CDVCameraPicker : UIImagePickerController
-{}
-
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* postUrl;
-@property (nonatomic) enum CDVDestinationType returnType;
-@property (nonatomic) enum CDVEncodingType encodingType;
-@property (strong) UIPopoverController* popoverController;
-@property (assign) CGSize targetSize;
-@property (assign) bool correctOrientation;
-@property (assign) bool saveToPhotoAlbum;
-@property (assign) bool cropToSize;
-@property (strong) UIWebView* webView;
-@property (assign) BOOL popoverSupported;
-
-@end
-
-// ======================================================================= //
-
-@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- UIPopoverControllerDelegate,
- CLLocationManagerDelegate>
-{}
-
-@property (strong) CDVCameraPicker* pickerController;
-@property (strong) NSMutableDictionary *metadata;
-@property (strong, nonatomic) CLLocationManager *locationManager;
-@property (strong) NSData* data;
-
-/*
- * getPicture
- *
- * arguments:
- * 1: this is the javascript function that will be called with the results, the first parameter passed to the
- * javascript function is the picture as a Base64 encoded string
- * 2: this is the javascript function to be called if there was an error
- * options:
- * quality: integer between 1 and 100
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command;
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
-- (void)cleanup:(CDVInvokedUrlCommand*)command;
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command;
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize;
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation;
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
deleted file mode 100644
index 1ee641c..0000000
--- a/CordovaLib/Classes/CDVCamera.m
+++ /dev/null
@@ -1,729 +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.
- */
-
-#import "CDVCamera.h"
-#import "CDVJpegHeaderWriter.h"
-#import "NSArray+Comparisons.h"
-#import "NSData+Base64.h"
-#import "NSDictionary+Extensions.h"
-#import <ImageIO/CGImageProperties.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <ImageIO/CGImageSource.h>
-#import <ImageIO/CGImageProperties.h>
-#import <ImageIO/CGImageDestination.h>
-#import <MobileCoreServices/UTCoreTypes.h>
-
-#define CDV_PHOTO_PREFIX @"cdv_photo_"
-
-static NSSet* org_apache_cordova_validArrowDirections;
-
-@interface CDVCamera ()
-
-@property (readwrite, assign) BOOL hasPendingOperation;
-
-@end
-
-@implementation CDVCamera
-
-+ (void)initialize
-{
- org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
-}
-
-@synthesize hasPendingOperation, pickerController, locationManager;
-
-- (BOOL)popoverSupported
-{
- return (NSClassFromString(@"UIPopoverController") != nil) &&
- (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
-}
-
-/* takePicture arguments:
- * INDEX ARGUMENT
- * 0 quality
- * 1 destination type
- * 2 source type
- * 3 targetWidth
- * 4 targetHeight
- * 5 encodingType
- * 6 mediaType
- * 7 allowsEdit
- * 8 correctOrientation
- * 9 saveToPhotoAlbum
- * 10 popoverOptions
- * 11 cameraDirection
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* arguments = command.arguments;
-
- self.hasPendingOperation = NO;
-
- NSString* sourceTypeString = [arguments objectAtIndex:2];
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
- if (sourceTypeString != nil) {
- sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
- }
-
- bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
- if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no camera available"];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool allowEdit = [[arguments objectAtIndex:7] boolValue];
- NSNumber* targetWidth = [arguments objectAtIndex:3];
- NSNumber* targetHeight = [arguments objectAtIndex:4];
- NSNumber* mediaValue = [arguments objectAtIndex:6];
- CDVMediaType mediaType = (mediaValue) ? [mediaValue intValue] : MediaTypePicture;
-
- CGSize targetSize = CGSizeMake(0, 0);
- if ((targetWidth != nil) && (targetHeight != nil)) {
- targetSize = CGSizeMake([targetWidth floatValue], [targetHeight floatValue]);
- }
-
- // If a popover is already open, close it; we only want one at a time.
- if (([[self pickerController] popoverController] != nil) && [[[self pickerController] popoverController] isPopoverVisible]) {
- [[[self pickerController] popoverController] dismissPopoverAnimated:YES];
- [[[self pickerController] popoverController] setDelegate:nil];
- [[self pickerController] setPopoverController:nil];
- }
-
- CDVCameraPicker* cameraPicker = [[CDVCameraPicker alloc] init];
- self.pickerController = cameraPicker;
-
- cameraPicker.delegate = self;
- cameraPicker.sourceType = sourceType;
- cameraPicker.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING - jm
- cameraPicker.callbackId = callbackId;
- cameraPicker.targetSize = targetSize;
- cameraPicker.cropToSize = NO;
- // we need to capture this state for memory warnings that dealloc this object
- cameraPicker.webView = self.webView;
- cameraPicker.popoverSupported = [self popoverSupported];
-
- cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue];
- cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue];
-
- cameraPicker.encodingType = ([arguments objectAtIndex:5]) ? [[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG;
-
- cameraPicker.quality = ([arguments objectAtIndex:0]) ? [[arguments objectAtIndex:0] intValue] : 50;
- cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
-
- if (sourceType == UIImagePickerControllerSourceTypeCamera) {
- // We only allow taking pictures (no video) in this API.
- cameraPicker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
-
- // We can only set the camera device if we're actually using the camera.
- NSNumber* cameraDirection = [command argumentAtIndex:11 withDefault:[NSNumber numberWithInteger:UIImagePickerControllerCameraDeviceRear]];
- cameraPicker.cameraDevice = (UIImagePickerControllerCameraDevice)[cameraDirection intValue];
- } else if (mediaType == MediaTypeAll) {
- cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
- } else {
- NSArray* mediaArray = [NSArray arrayWithObjects:(NSString*)(mediaType == MediaTypeVideo ? kUTTypeMovie : kUTTypeImage), nil];
- cameraPicker.mediaTypes = mediaArray;
- }
-
- if ([self popoverSupported] && (sourceType != UIImagePickerControllerSourceTypeCamera)) {
- if (cameraPicker.popoverController == nil) {
- cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController")alloc] initWithContentViewController:cameraPicker];
- }
- NSDictionary* options = [command.arguments objectAtIndex:10 withDefault:nil];
- [self displayPopover:options];
- } else {
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:cameraPicker animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:cameraPicker animated:YES];
- }
- }
- self.hasPendingOperation = YES;
-}
-
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command
-{
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
-
- [self displayPopover:options];
-}
-
-- (void)displayPopover:(NSDictionary*)options
-{
- int x = 0;
- int y = 32;
- int width = 320;
- int height = 480;
- UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
-
- if (options) {
- x = [options integerValueForKey:@"x" defaultValue:0];
- y = [options integerValueForKey:@"y" defaultValue:32];
- width = [options integerValueForKey:@"width" defaultValue:320];
- height = [options integerValueForKey:@"height" defaultValue:480];
- arrowDirection = [options integerValueForKey:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
- if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]) {
- arrowDirection = UIPopoverArrowDirectionAny;
- }
- }
-
- [[[self pickerController] popoverController] setDelegate:self];
- [[[self pickerController] popoverController] presentPopoverFromRect:CGRectMake(x, y, width, height)
- inView:[self.webView superview]
- permittedArrowDirections:arrowDirection
- animated:YES];
-}
-
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
-{
- if([navigationController isKindOfClass:[UIImagePickerController class]]){
- UIImagePickerController * cameraPicker = (UIImagePickerController*)navigationController;
-
- if(![cameraPicker.mediaTypes containsObject:(NSString*) kUTTypeImage]){
- [viewController.navigationItem setTitle:NSLocalizedString(@"Videos title", nil)];
- }
- }
-}
-
-- (void)cleanup:(CDVInvokedUrlCommand*)command
-{
- // empty the tmp directory
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* err = nil;
- BOOL hasErrors = NO;
-
- // clear contents of NSTemporaryDirectory
- NSString* tempDirectoryPath = NSTemporaryDirectory();
- NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
- NSString* fileName = nil;
- BOOL result;
-
- while ((fileName = [directoryEnumerator nextObject])) {
- // only delete the files we created
- if (![fileName hasPrefix:CDV_PHOTO_PREFIX]) {
- continue;
- }
- NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
- result = [fileMgr removeItemAtPath:filePath error:&err];
- if (!result && err) {
- NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
- hasErrors = YES;
- }
- }
-
- CDVPluginResult* pluginResult;
- if (hasErrors) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)popoverControllerDidDismissPopover:(id)popoverController
-{
- // [ self imagePickerControllerDidCancel:self.pickerController ]; '
- UIPopoverController* pc = (UIPopoverController*)popoverController;
-
- [pc dismissPopoverAnimated:YES];
- pc.delegate = nil;
- if (self.pickerController && self.pickerController.callbackId && self.pickerController.popoverController) {
- self.pickerController.popoverController = nil;
- NSString* callbackId = self.pickerController.callbackId;
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- self.hasPendingOperation = NO;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if (cameraPicker.popoverSupported && (cameraPicker.popoverController != nil)) {
- [cameraPicker.popoverController dismissPopoverAnimated:YES];
- cameraPicker.popoverController.delegate = nil;
- cameraPicker.popoverController = nil;
- } else {
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
-
- CDVPluginResult* result = nil;
-
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- // IMAGE TYPE
- if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- if (cameraPicker.returnType == DestinationTypeNativeUri) {
- NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
- } else {
- // get the image
- UIImage* image = nil;
- if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
-
- if (cameraPicker.correctOrientation) {
- image = [self imageCorrectedForCaptureOrientation:image];
- }
-
- 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];
- }
- }
-
- NSData* data = nil;
-
- if (cameraPicker.encodingType == EncodingTypePNG) {
- data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
- } else {
- self.data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
-
- NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
- if (controllerMetadata) {
- self.metadata = [[NSMutableDictionary alloc] init];
-
- NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
- if (EXIFDictionary) [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
-
- [[self locationManager] startUpdatingLocation];
- return;
- }
- }
-
- if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
- }
-
- 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:[data base64EncodedString]];
- }
- }
- }
- // NOT IMAGE TYPE (MOVIE)
- else {
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-// older api calls newer didFinishPickingMediaWithInfo
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage];
-
- [self imagePickerController:picker didFinishPickingMediaWithInfo:imageInfo];
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- // popoverControllerDidDismissPopover:(id)popoverController is called if popover is cancelled
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = targetSize.width;
- CGFloat targetHeight = targetSize.height;
- CGFloat scaleFactor = 0.0;
- CGFloat scaledWidth = targetWidth;
- CGFloat scaledHeight = targetHeight;
- CGPoint thumbnailPoint = CGPointMake(0.0, 0.0);
-
- if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- if (widthFactor > heightFactor) {
- scaleFactor = widthFactor; // scale to fit height
- } else {
- scaleFactor = heightFactor; // scale to fit width
- }
- scaledWidth = width * scaleFactor;
- scaledHeight = height * scaleFactor;
-
- // center the image
- if (widthFactor > heightFactor) {
- thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
- } else if (widthFactor < heightFactor) {
- thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
- }
- }
-
- UIGraphicsBeginImageContext(targetSize); // this will crop
-
- CGRect thumbnailRect = CGRectZero;
- thumbnailRect.origin = thumbnailPoint;
- thumbnailRect.size.width = scaledWidth;
- thumbnailRect.size.height = scaledHeight;
-
- [sourceImage drawInRect:thumbnailRect];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage
-{
- float rotation_radians = 0;
- bool perpendicular = false;
-
- switch ([anImage imageOrientation]) {
- case UIImageOrientationUp :
- rotation_radians = 0.0;
- break;
-
- case UIImageOrientationDown:
- rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
- break;
-
- case UIImageOrientationRight:
- rotation_radians = M_PI_2;
- perpendicular = true;
- break;
-
- case UIImageOrientationLeft:
- rotation_radians = -M_PI_2;
- perpendicular = true;
- break;
-
- default:
- break;
- }
-
- UIGraphicsBeginImageContext(CGSizeMake(anImage.size.width, anImage.size.height));
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- // Rotate around the center point
- CGContextTranslateCTM(context, anImage.size.width / 2, anImage.size.height / 2);
- CGContextRotateCTM(context, rotation_radians);
-
- CGContextScaleCTM(context, 1.0, -1.0);
- float width = perpendicular ? anImage.size.height : anImage.size.width;
- float height = perpendicular ? anImage.size.width : anImage.size.height;
- CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [anImage CGImage]);
-
- // Move the origin back since the rotation might've change it (if its 90 degrees)
- if (perpendicular) {
- CGContextTranslateCTM(context, -anImage.size.height / 2, -anImage.size.width / 2);
- }
-
- UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = frameSize.width;
- CGFloat targetHeight = frameSize.height;
- CGFloat scaleFactor = 0.0;
- CGSize scaledSize = frameSize;
-
- if (CGSizeEqualToSize(imageSize, frameSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- // opposite comparison to imageByScalingAndCroppingForSize in order to contain the image within the given bounds
- if (widthFactor > heightFactor) {
- scaleFactor = heightFactor; // scale to fit height
- } else {
- scaleFactor = widthFactor; // scale to fit width
- }
- scaledSize = CGSizeMake(MIN(width * scaleFactor, targetWidth), MIN(height * scaleFactor, targetHeight));
- }
-
- UIGraphicsBeginImageContext(scaledSize); // this will resize
-
- [sourceImage drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
-{
- self.hasPendingOperation = YES;
-
- NSString* boundary = @"----BOUNDARY_IS_I";
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
- [req setHTTPMethod:@"POST"];
-
- NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-type"];
-
- NSData* imageData = UIImagePNGRepresentation(anImage);
-
- // adding the body
- NSMutableData* postBody = [NSMutableData data];
-
- // first parameter an image
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
- [postBody appendData:imageData];
-
- // // second parameter information
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
-
- [req setHTTPBody:postBody];
-
- NSURLResponse* response;
- NSError* error;
- [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
-
- // NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
- // NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
-
- self.hasPendingOperation = NO;
-}
-
-
-- (CLLocationManager *)locationManager {
-
- if (locationManager != nil) {
- return locationManager;
- }
-
- locationManager = [[CLLocationManager alloc] init];
- [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
- [locationManager setDelegate:self];
-
- return locationManager;
-}
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
-{
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- NSMutableDictionary *GPSDictionary = [[NSMutableDictionary dictionary] init];
-
- CLLocationDegrees latitude = newLocation.coordinate.latitude;
- CLLocationDegrees longitude = newLocation.coordinate.longitude;
-
- // latitude
- if (latitude < 0.0) {
- latitude = latitude * -1.0f;
- [GPSDictionary setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- } else {
- [GPSDictionary setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:latitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
-
- // longitude
- if (longitude < 0.0) {
- longitude = longitude * -1.0f;
- [GPSDictionary setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- else {
- [GPSDictionary setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:longitude] forKey:(NSString*)kCGImagePropertyGPSLongitude];
-
- // altitude
- CGFloat altitude = newLocation.altitude;
- if (!isnan(altitude)){
- if (altitude < 0) {
- altitude = -altitude;
- [GPSDictionary setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- } else {
- [GPSDictionary setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude];
- }
-
- // Time and date
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"HH:mm:ss.SSSSSS"];
- [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSTimeStamp];
- [formatter setDateFormat:@"yyyy:MM:dd"];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSDateStamp];
-
- [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary];
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)imagePickerControllerReturnImageResult
-{
- CDVPluginResult* result = nil;
-
- if (self.metadata) {
- CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge_retained CFDataRef)self.data, NULL);
- CFStringRef sourceType = CGImageSourceGetType(sourceImage);
-
- CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL);
- CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata);
- CGImageDestinationFinalize(destinationImage);
-
- CFRelease(sourceImage);
- CFRelease(destinationImage);
- }
-
- if (self.pickerController.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[self data]], nil, nil, nil);
- }
-
- if (self.pickerController.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++, self.pickerController.encodingType == EncodingTypePNG ? @"png":@"jpg"];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- // save file
- if (![self.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:[self.data base64EncodedString]];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
- self.data = nil;
- self.metadata = nil;
-}
-
-@end
-
-@implementation CDVCameraPicker
-
-@synthesize quality, postUrl;
-@synthesize returnType;
-@synthesize callbackId;
-@synthesize popoverController;
-@synthesize targetSize;
-@synthesize correctOrientation;
-@synthesize saveToPhotoAlbum;
-@synthesize encodingType;
-@synthesize cropToSize;
-@synthesize webView;
-@synthesize popoverSupported;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDVExif.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVExif.h b/CordovaLib/Classes/CDVExif.h
deleted file mode 100644
index 3e8adbd..0000000
--- a/CordovaLib/Classes/CDVExif.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-#ifndef CordovaLib_ExifData_h
-#define CordovaLib_ExifData_h
-
-// exif data types
-typedef enum exifDataTypes {
- EDT_UBYTE = 1, // 8 bit unsigned integer
- EDT_ASCII_STRING, // 8 bits containing 7 bit ASCII code, null terminated
- EDT_USHORT, // 16 bit unsigned integer
- EDT_ULONG, // 32 bit unsigned integer
- EDT_URATIONAL, // 2 longs, first is numerator and second is denominator
- EDT_SBYTE,
- EDT_UNDEFINED, // 8 bits
- EDT_SSHORT,
- EDT_SLONG, // 32bit signed integer (2's complement)
- EDT_SRATIONAL, // 2 SLONGS, first long is numerator, second is denominator
- EDT_SINGLEFLOAT,
- EDT_DOUBLEFLOAT
-} ExifDataTypes;
-
-// maps integer code for exif data types to width in bytes
-static const int DataTypeToWidth[] = {1,1,2,4,8,1,1,2,4,8,4,8};
-
-static const int RECURSE_HORIZON = 8;
-#endif
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDVJpegHeaderWriter.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.h b/CordovaLib/Classes/CDVJpegHeaderWriter.h
deleted file mode 100644
index 3b43ef0..0000000
--- a/CordovaLib/Classes/CDVJpegHeaderWriter.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#import <Foundation/Foundation.h>
-
-@interface CDVJpegHeaderWriter : NSObject {
- NSDictionary * SubIFDTagFormatDict;
- NSDictionary * IFD0TagFormatDict;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata
- withExifBlock: (NSString*) exifstr;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb
- withPlaces: (NSNumber*) width;
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber*) numb
- withPlaces: (NSNumber*) places;
-- (NSString*) decimalToUnsignedRational: (NSNumber*) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator;
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon;
-//- (void) expandContinuedFraction: (NSArray*) fractionlist;
-- (void) splitDouble: (double) val
- withIntComponent: (int*) rightside
- withFloatRemainder: (double*) leftside;
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator
- withDenominator: (NSNumber*) denominator
- asSigned: (Boolean) signedFlag;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-
-/*
-- (void) readExifMetaData : (NSData*) imgdata;
-- (void) spliceImageData : (NSData*) imgdata withExifData: (NSDictionary*) exifdata;
-- (void) locateExifMetaData : (NSData*) imgdata;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (void) createExifDataString : (NSDictionary*) datadict;
-- (NSString*) createDataElement : (NSString*) element
- withElementData: (NSString*) data
- withExternalDataBlock: (NSDictionary*) memblock;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-*/
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/Classes/CDVJpegHeaderWriter.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.m b/CordovaLib/Classes/CDVJpegHeaderWriter.m
deleted file mode 100644
index 93cafb8..0000000
--- a/CordovaLib/Classes/CDVJpegHeaderWriter.m
+++ /dev/null
@@ -1,547 +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.
- */
-
-#import "CDVJpegHeaderWriter.h"
-#include "CDVExif.h"
-
-/* macros for tag info shorthand:
- tagno : tag number
- typecode : data type
- components : number of components
- appendString (TAGINF_W_APPEND only) : string to append to data
- Exif date data format include an extra 0x00 to the end of the data
- */
-#define TAGINF(tagno, typecode, components) [NSArray arrayWithObjects: tagno, typecode, components, nil]
-#define TAGINF_W_APPEND(tagno, typecode, components, appendString) [NSArray arrayWithObjects: tagno, typecode, components, appendString, nil]
-
-const uint mJpegId = 0xffd8; // JPEG format marker
-const uint mExifMarker = 0xffe1; // APP1 jpeg header marker
-const uint mExif = 0x45786966; // ASCII 'Exif', first characters of valid exif header after size
-const uint mMotorallaByteAlign = 0x4d4d; // 'MM', motorola byte align, msb first or 'sane'
-const uint mIntelByteAlgin = 0x4949; // 'II', Intel byte align, lsb first or 'batshit crazy reverso world'
-const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a(MM) or 0x2a00(II), tiff version number
-
-
-@implementation CDVJpegHeaderWriter
-
-- (id) init {
- self = [super init];
- // supported tags for exif IFD
- IFD0TagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- // TAGINF(@"010e", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"ImageDescription",
- TAGINF_W_APPEND(@"0132", [NSNumber numberWithInt:EDT_ASCII_STRING], @20, @"00"), @"DateTime",
- TAGINF(@"010f", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Make",
- TAGINF(@"0110", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Model",
- TAGINF(@"0131", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Software",
- TAGINF(@"011a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"XResolution",
- TAGINF(@"011b", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"YResolution",
- // currently supplied outside of Exif data block by UIImagePickerControllerMediaMetadata, this is set manually in CDVCamera.m
- /* TAGINF(@"0112", [NSNumber numberWithInt:EDT_USHORT], @1), @"Orientation",
-
- // rest of the tags are supported by exif spec, but are not specified by UIImagePickerControllerMediaMedadata
- // should camera hardware supply these values in future versions, or if they can be derived, ImageHeaderWriter will include them gracefully
- TAGINF(@"0128", [NSNumber numberWithInt:EDT_USHORT], @1), @"ResolutionUnit",
- TAGINF(@"013e", [NSNumber numberWithInt:EDT_URATIONAL], @2), @"WhitePoint",
- TAGINF(@"013f", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"PrimaryChromaticities",
- TAGINF(@"0211", [NSNumber numberWithInt:EDT_URATIONAL], @3), @"YCbCrCoefficients",
- TAGINF(@"0213", [NSNumber numberWithInt:EDT_USHORT], @1), @"YCbCrPositioning",
- TAGINF(@"0214", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"ReferenceBlackWhite",
- TAGINF(@"8298", [NSNumber numberWithInt:EDT_URATIONAL], @0), @"Copyright",
-
- // offset to exif subifd, we determine this dynamically based on the size of the main exif IFD
- TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",*/
- nil];
-
-
- // supported tages for exif subIFD
- SubIFDTagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- //TAGINF(@"9000", [NSNumber numberWithInt:], @), @"ExifVersion",
- //TAGINF(@"9202",[NSNumber numberWithInt:EDT_URATIONAL],@1), @"ApertureValue",
- //TAGINF(@"9203",[NSNumber numberWithInt:EDT_SRATIONAL],@1), @"BrightnessValue",
- TAGINF(@"a001",[NSNumber numberWithInt:EDT_USHORT],@1), @"ColorSpace",
- TAGINF_W_APPEND(@"9004",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeDigitized",
- TAGINF_W_APPEND(@"9003",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeOriginal",
- TAGINF(@"a402", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureMode",
- TAGINF(@"8822", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureProgram",
- //TAGINF(@"829a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"ExposureTime",
- //TAGINF(@"829d", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FNumber",
- TAGINF(@"9209", [NSNumber numberWithInt:EDT_USHORT], @1), @"Flash",
- // FocalLengthIn35mmFilm
- TAGINF(@"a405", [NSNumber numberWithInt:EDT_USHORT], @1), @"FocalLenIn35mmFilm",
- //TAGINF(@"920a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FocalLength",
- //TAGINF(@"8827", [NSNumber numberWithInt:EDT_USHORT], @2), @"ISOSpeedRatings",
- TAGINF(@"9207", [NSNumber numberWithInt:EDT_USHORT],@1), @"MeteringMode",
- // specific to compressed data
- TAGINF(@"a002", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelXDimension",
- TAGINF(@"a003", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelYDimension",
- // data type undefined, but this is a DSC camera, so value is always 1, treat as ushort
- TAGINF(@"a301", [NSNumber numberWithInt:EDT_USHORT],@1), @"SceneType",
- TAGINF(@"a217",[NSNumber numberWithInt:EDT_USHORT],@1), @"SensingMethod",
- //TAGINF(@"9201", [NSNumber numberWithInt:EDT_SRATIONAL], @1), @"ShutterSpeedValue",
- // specifies location of main subject in scene (x,y,wdith,height) expressed before rotation processing
- //TAGINF(@"9214", [NSNumber numberWithInt:EDT_USHORT], @4), @"SubjectArea",
- TAGINF(@"a403", [NSNumber numberWithInt:EDT_USHORT], @1), @"WhiteBalance",
- nil];
- return self;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata withExifBlock: (NSString*) exifstr {
-
- CDVJpegHeaderWriter * exifWriter = [[CDVJpegHeaderWriter alloc] init];
-
- NSMutableData * exifdata = [NSMutableData dataWithCapacity: [exifstr length]/2];
- int idx;
- for (idx = 0; idx+1 < [exifstr length]; idx+=2) {
- NSRange range = NSMakeRange(idx, 2);
- NSString* hexStr = [exifstr substringWithRange:range];
- NSScanner* scanner = [NSScanner scannerWithString:hexStr];
- unsigned int intValue;
- [scanner scanHexInt:&intValue];
- [exifdata appendBytes:&intValue length:1];
- }
-
- NSMutableData * ddata = [NSMutableData dataWithCapacity: [jpegdata length]];
- NSMakeRange(0,4);
- int loc = 0;
- bool done = false;
- // read the jpeg data until we encounter the app1==0xFFE1 marker
- while (loc+1 < [jpegdata length]) {
- NSData * blag = [jpegdata subdataWithRange: NSMakeRange(loc,2)];
- if( [[blag description] isEqualToString : @"<ffe1>"]) {
- // read the APP1 block size bits
- NSString * the = [exifWriter hexStringFromData:[jpegdata subdataWithRange: NSMakeRange(loc+2,2)]];
- NSNumber * app1width = [exifWriter numericFromHexString:the];
- //consume the original app1 block
- [ddata appendData:exifdata];
- // advance our loc marker past app1
- loc += [app1width intValue] + 2;
- done = true;
- } else {
- if(!done) {
- [ddata appendData:blag];
- loc += 2;
- } else {
- break;
- }
- }
- }
- // copy the remaining data
- [ddata appendData:[jpegdata subdataWithRange: NSMakeRange(loc,[jpegdata length]-loc)]];
- return ddata;
-}
-
-
-
-/**
- * Create the Exif data block as a hex string
- * jpeg uses Application Markers (APP's) as markers for application data
- * APP1 is the application marker reserved for exif data
- *
- * (NSDictionary*) datadict - with subdictionaries marked '{TIFF}' and '{EXIF}' as returned by imagePickerController with a valid
- * didFinishPickingMediaWithInfo data dict, under key @"UIImagePickerControllerMediaMetadata"
- *
- * the following constructs a hex string to Exif specifications, and is therefore brittle
- * altering the order of arguments to the string constructors, modifying field sizes or formats,
- * and any other minor change will likely prevent the exif data from being read
- */
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict {
- NSMutableString * app1; // holds finalized product
- NSString * exifIFD; // exif information file directory
- NSString * subExifIFD; // subexif information file directory
-
- // FFE1 is the hex APP1 marker code, and will allow client apps to read the data
- NSString * app1marker = @"ffe1";
- // SSSS size, to be determined
- // EXIF ascii characters followed by 2bytes of zeros
- NSString * exifmarker = @"457869660000";
- // Tiff header: 4d4d is motorolla byte align (big endian), 002a is hex for 42
- NSString * tiffheader = @"4d4d002a";
- //first IFD offset from the Tiff header to IFD0. Since we are writing it, we know it's address 0x08
- NSString * ifd0offset = @"00000008";
- // current offset to next data area
- int currentDataOffset = 0;
-
- //data labeled as TIFF in UIImagePickerControllerMediaMetaData is part of the EXIF IFD0 portion of APP1
- exifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{TIFF}"] withFormatDict: IFD0TagFormatDict isIFD0:YES currentDataOffset:¤tDataOffset];
-
- //data labeled as EXIF in UIImagePickerControllerMediaMetaData is part of the EXIF Sub IFD portion of APP1
- subExifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{Exif}"] withFormatDict: SubIFDTagFormatDict isIFD0:NO currentDataOffset:¤tDataOffset];
- /*
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",exifIFD,[exifIFD length]);
-
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",subExifIFD,[subExifIFD length]);
- */
- // construct the complete app1 data block
- app1 = [[NSMutableString alloc] initWithFormat: @"%@%04x%@%@%@%@%@",
- app1marker,
- 16 + ([exifIFD length]/2) + ([subExifIFD length]/2) /*16+[exifIFD length]/2*/,
- exifmarker,
- tiffheader,
- ifd0offset,
- exifIFD,
- subExifIFD];
-
- return app1;
-}
-
-// returns hex string representing a valid exif information file directory constructed from the datadict and formatdict
-- (NSString*) createExifIFDFromDict : (NSDictionary*) datadict
- withFormatDict : (NSDictionary*) formatdict
- isIFD0 : (BOOL) ifd0flag
- currentDataOffset : (int*) dataoffset {
- NSArray * datakeys = [datadict allKeys]; // all known data keys
- NSArray * knownkeys = [formatdict allKeys]; // only keys in knowkeys are considered for entry in this IFD
- NSMutableArray * ifdblock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // all ifd entries
- NSMutableArray * ifddatablock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // data block entries
- // ifd0flag = NO; // ifd0 requires a special flag and has offset to next ifd appended to end
-
- // iterate through known provided data keys
- for (int i = 0; i < [datakeys count]; i++) {
- NSString * key = [datakeys objectAtIndex:i];
- // don't muck about with unknown keys
- if ([knownkeys indexOfObject: key] != NSNotFound) {
- // create new IFD entry
- NSString * entry = [self createIFDElement: key
- withFormat: [formatdict objectForKey:key]
- withElementData: [datadict objectForKey:key]];
- // create the IFD entry's data block
- NSString * data = [self createIFDElementDataWithFormat: [formatdict objectForKey:key]
- withData: [datadict objectForKey:key]];
- if (entry) {
- [ifdblock addObject:entry];
- if(!data) {
- [ifdblock addObject:@""];
- } else {
- [ifddatablock addObject:data];
- }
- }
- }
- }
-
- NSMutableString * exifstr = [[NSMutableString alloc] initWithCapacity: [ifdblock count] * 24];
- NSMutableString * dbstr = [[NSMutableString alloc] initWithCapacity: 100];
-
- int addr=*dataoffset; // current offset/address in datablock
- if (ifd0flag) {
- // calculate offset to datablock based on ifd file entry count
- addr += 14+(12*([ifddatablock count]+1)); // +1 for tag 0x8769, exifsubifd offset
- } else {
- // current offset + numSubIFDs (2-bytes) + 12*numSubIFDs + endMarker (4-bytes)
- addr += 2+(12*[ifddatablock count])+4;
- }
-
- for (int i = 0; i < [ifdblock count]; i++) {
- NSString * entry = [ifdblock objectAtIndex:i];
- NSString * data = [ifddatablock objectAtIndex:i];
-
- // check if the data fits into 4 bytes
- if( [data length] <= 8) {
- // concatenate the entry and the (4byte) data entry into the final IFD entry and append to exif ifd string
- [exifstr appendFormat : @"%@%@", entry, data];
- } else {
- [exifstr appendFormat : @"%@%08x", entry, addr];
- [dbstr appendFormat: @"%@", data];
- addr+= [data length] / 2;
- /*
- NSLog(@"=====data-length[%i]=======",[data length]);
- NSLog(@"addr-offset[%i]",addr);
- NSLog(@"entry[%@]",entry);
- NSLog(@"data[%@]",data);
- */
- }
- }
-
- // calculate IFD0 terminal offset tags, currently ExifSubIFD
- int entrycount = [ifdblock count];
- if (ifd0flag) {
- // 18 accounts for 8769's width + offset to next ifd, 8 accounts for start of header
- NSNumber * offset = [NSNumber numberWithInt:[exifstr length] / 2 + [dbstr length] / 2 + 18+8];
-
- [self appendExifOffsetTagTo: exifstr
- withOffset : offset];
- entrycount++;
- }
- *dataoffset = addr;
- return [[NSString alloc] initWithFormat: @"%04x%@%@%@",
- entrycount,
- exifstr,
- @"00000000", // offset to next IFD, 0 since there is none
- dbstr]; // lastly, the datablock
-}
-
-// Creates an exif formatted exif information file directory entry
-- (NSString*) createIFDElement: (NSString*) elementName withFormat: (NSArray*) formtemplate withElementData: (NSString*) data {
- //NSArray * fielddata = [formatdict objectForKey: elementName];// format data of desired field
- if (formtemplate) {
- // format string @"%@%@%@%@", tag number, data format, components, value
- NSNumber * dataformat = [formtemplate objectAtIndex:1];
- NSNumber * components = [formtemplate objectAtIndex:2];
- if([components intValue] == 0) {
- components = [NSNumber numberWithInt: [data length] * DataTypeToWidth[[dataformat intValue]-1]];
- }
-
- return [[NSString alloc] initWithFormat: @"%@%@%08x",
- [formtemplate objectAtIndex:0], // the field code
- [self formatNumberWithLeadingZeroes: dataformat withPlaces: @4], // the data type code
- [components intValue]]; // number of components
- }
- return NULL;
-}
-
-/**
- * appends exif IFD0 tag 8769 "ExifOffset" to the string provided
- * (NSMutableString*) str - string you wish to append the 8769 tag to: APP1 or IFD0 hex data string
- * // TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",
- */
-- (void) appendExifOffsetTagTo: (NSMutableString*) str withOffset : (NSNumber*) offset {
- NSArray * format = TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1);
-
- NSString * entry = [self createIFDElement: @"ExifOffset"
- withFormat: format
- withElementData: [offset stringValue]];
-
- NSString * data = [self createIFDElementDataWithFormat: format
- withData: [offset stringValue]];
- [str appendFormat:@"%@%@", entry, data];
-}
-
-// formats the Information File Directory Data to exif format
-- (NSString*) createIFDElementDataWithFormat: (NSArray*) dataformat withData: (NSString*) data {
- NSMutableString * datastr = nil;
- NSNumber * tmp = nil;
- NSNumber * formatcode = [dataformat objectAtIndex:1];
- NSUInteger formatItemsCount = [dataformat count];
- NSNumber * num = @0;
- NSNumber * denom = @0;
-
- switch ([formatcode intValue]) {
- case EDT_UBYTE:
- break;
- case EDT_ASCII_STRING:
- datastr = [[NSMutableString alloc] init];
- for (int i = 0; i < [data length]; i++) {
- [datastr appendFormat:@"%02x",[data characterAtIndex:i]];
- }
- if (formatItemsCount > 3) {
- // We have additional data to append.
- // currently used by Date format to append final 0x00 but can be used by other data types as well in the future
- [datastr appendString:[dataformat objectAtIndex:3]];
- }
- if ([datastr length] < 8) {
- NSString * format = [NSString stringWithFormat:@"%%0%dd", 8 - [datastr length]];
- [datastr appendFormat:format,0];
- }
- return datastr;
- case EDT_USHORT:
- return [[NSString alloc] initWithFormat : @"%@%@",
- [self formattedHexStringFromDecimalNumber: [NSNumber numberWithInt: [data intValue]] withPlaces: @4],
- @"0000"];
- case EDT_ULONG:
- tmp = [NSNumber numberWithUnsignedLong:[data intValue]];
- return [NSString stringWithFormat : @"%@",
- [self formattedHexStringFromDecimalNumber: tmp withPlaces: @8]];
- case EDT_URATIONAL:
- return [self decimalToUnsignedRational: [NSNumber numberWithDouble:[data doubleValue]]
- withResultNumerator: &num
- withResultDenominator: &denom];
- case EDT_SBYTE:
-
- break;
- case EDT_UNDEFINED:
- break; // 8 bits
- case EDT_SSHORT:
- break;
- case EDT_SLONG:
- break; // 32bit signed integer (2's complement)
- case EDT_SRATIONAL:
- break; // 2 SLONGS, first long is numerator, second is denominator
- case EDT_SINGLEFLOAT:
- break;
- case EDT_DOUBLEFLOAT:
- break;
- }
- return datastr;
-}
-
-//======================================================================================================================
-// Utility Methods
-//======================================================================================================================
-
-// creates a formatted little endian hex string from a number and width specifier
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb withPlaces: (NSNumber*) width {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:[width intValue]];
- NSString * formatstr = [[NSString alloc] initWithFormat: @"%%%@%dx", @"0", [width intValue]];
- [str appendFormat:formatstr, [numb intValue]];
- return str;
-}
-
-// format number as string with leading 0's
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber *) numb withPlaces: (NSNumber *) places {
- NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
- NSString *formatstr = [@"" stringByPaddingToLength:[places unsignedIntegerValue] withString:@"0" startingAtIndex:0];
- [formatter setPositiveFormat:formatstr];
- return [formatter stringFromNumber:numb];
-}
-
-// approximate a decimal with a rational by method of continued fraction
-// can be collasped into decimalToUnsignedRational after testing
-- (void) decimalToRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
-}
-
-// approximate a decimal with an unsigned rational by method of continued fraction
-- (NSString*) decimalToUnsignedRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- // generate partial fraction list
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
- return [self formatFractionList: fractionlist];
-}
-
-// recursive implementation of decimal approximation by continued fraction
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon {
- int whole;
- double remainder;
- // 1. split term
- [self splitDouble: val withIntComponent: &whole withFloatRemainder: &remainder];
- [fractionlist addObject: [NSNumber numberWithInt:whole]];
-
- // 2. calculate reciprocal of remainder
- if (!remainder) return; // early exit, exact fraction found, avoids recip/0
- double recip = 1 / remainder;
-
- // 3. exit condition
- if ([fractionlist count] > horizon) {
- return;
- }
-
- // 4. recurse
- [self continuedFraction:recip withFractionList: fractionlist withHorizon: horizon];
-
-}
-
-// expand continued fraction list, creating a single level rational approximation
--(void) expandContinuedFraction: (NSArray*) fractionlist
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- int i = 0;
- int den = 0;
- int num = 0;
- if ([fractionlist count] == 1) {
- *numerator = [NSNumber numberWithInt:[[fractionlist objectAtIndex:0] intValue]];
- *denominator = @1;
- return;
- }
-
- //begin at the end of the list
- i = [fractionlist count] - 1;
- num = 1;
- den = [[fractionlist objectAtIndex:i] intValue];
-
- while (i > 0) {
- int t = [[fractionlist objectAtIndex: i-1] intValue];
- num = t * den + num;
- if (i==1) {
- break;
- } else {
- t = num;
- num = den;
- den = t;
- }
- i--;
- }
- // set result parameters values
- *numerator = [NSNumber numberWithInt: num];
- *denominator = [NSNumber numberWithInt: den];
-}
-
-// formats expanded fraction list to string matching exif specification
-- (NSString*) formatFractionList: (NSArray *) fractionlist {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
-
- if ([fractionlist count] == 1){
- [str appendFormat: @"%08x00000001", [[fractionlist objectAtIndex:0] intValue]];
- }
- return str;
-}
-
-// format rational as
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator withDenominator: (NSNumber*) denominator asSigned: (Boolean) signedFlag {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
- if (signedFlag) {
- long num = [numerator longValue];
- long den = [denominator longValue];
- [str appendFormat: @"%08lx%08lx", num >= 0 ? num : ~ABS(num) + 1, num >= 0 ? den : ~ABS(den) + 1];
- } else {
- [str appendFormat: @"%08lx%08lx", [numerator unsignedLongValue], [denominator unsignedLongValue]];
- }
- return str;
-}
-
-// split a floating point number into two integer values representing the left and right side of the decimal
-- (void) splitDouble: (double) val withIntComponent: (int*) rightside withFloatRemainder: (double*) leftside {
- *rightside = val; // convert numb to int representation, which truncates the decimal portion
- *leftside = val - *rightside;
-}
-
-
-//
-- (NSString*) hexStringFromData : (NSData*) data {
- //overflow detection
- const unsigned char *dataBuffer = [data bytes];
- return [[NSString alloc] initWithFormat: @"%02x%02x",
- (unsigned char)dataBuffer[0],
- (unsigned char)dataBuffer[1]];
-}
-
-// convert a hex string to a number
-- (NSNumber*) numericFromHexString : (NSString *) hexstring {
- NSScanner * scan = NULL;
- unsigned int numbuf= 0;
-
- scan = [NSScanner scannerWithString:hexstring];
- [scan scanHexInt:&numbuf];
- return [NSNumber numberWithInt:numbuf];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index dac83e2..d025e35 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -36,15 +36,10 @@
30F5EBAB14CA26E700987760 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F5EBA914CA26E700987760 /* CDVCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E76876B156A90EE00EB6FA3 /* CDVLogger.m */; };
3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E76876C156A90EE00EB6FA3 /* CDVLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */; };
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516A16FD18190076A8B4 /* CDVExif.h */; settings = {ATTRIBUTES = (Public, ); }; };
7E14B5A81705050A0032169E /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E14B5A61705050A0032169E /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; };
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E14B5A71705050A0032169E /* CDVTimer.m */; };
8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD261090FBE7009987E8 /* CDVCamera.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD271090FBE7009987E8 /* CDVCamera.m */; };
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -117,16 +112,11 @@
686357DC14100B1600DF4CF2 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
68A32D7114102E1C006B237C /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; };
68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
- 68B7516A16FD18190076A8B4 /* CDVExif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVExif.h; path = Classes/CDVExif.h; sourceTree = "<group>"; };
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVJpegHeaderWriter.h; path = Classes/CDVJpegHeaderWriter.h; sourceTree = "<group>"; };
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVJpegHeaderWriter.m; path = Classes/CDVJpegHeaderWriter.m; sourceTree = "<group>"; };
7E14B5A61705050A0032169E /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVTimer.h; path = Classes/CDVTimer.h; sourceTree = "<group>"; };
7E14B5A71705050A0032169E /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVTimer.m; path = Classes/CDVTimer.m; sourceTree = "<group>"; };
8220B5C316D5427E00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
8852C43614B65FD800F0E735 /* CDVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVViewController.h; path = Classes/CDVViewController.h; sourceTree = "<group>"; };
8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
- 8887FD261090FBE7009987E8 /* CDVCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCamera.h; path = Classes/CDVCamera.h; sourceTree = "<group>"; };
- 8887FD271090FBE7009987E8 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCamera.m; path = Classes/CDVCamera.m; sourceTree = "<group>"; };
8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
@@ -253,13 +243,8 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 8887FD261090FBE7009987E8 /* CDVCamera.h */,
- 8887FD271090FBE7009987E8 /* CDVCamera.m */,
1F584B991385A28900ED25E8 /* CDVCapture.h */,
1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- 68B7516A16FD18190076A8B4 /* CDVExif.h */,
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */,
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD301090FBE7009987E8 /* CDVFile.h */,
@@ -320,9 +305,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */,
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */,
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */,
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
@@ -413,7 +395,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */,
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
@@ -441,7 +422,6 @@
30F3930C169F839700B22307 /* CDVJSON.m in Sources */,
EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */,
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */,
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e07c199b/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 16e6919..38af0bc 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -58,9 +58,6 @@
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="Camera">
- <param name="ios-package" value="CDVCamera"/>
- </feature>
<feature name="File">
<param name="ios-package" value="CDVFile"/>
</feature>
[06/50] [abbrv] removed device, capture, file, filetransfer
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
deleted file mode 100644
index 10908ce..0000000
--- a/CordovaLib/Classes/CDVFile.m
+++ /dev/null
@@ -1,1414 +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.
- */
-
-#import "CDVFile.h"
-#import "NSArray+Comparisons.h"
-#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"
-
-extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
-
-#ifndef __IPHONE_5_1
- NSString* const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
-#endif
-
-NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
-
-@implementation CDVFile
-
-@synthesize appDocsPath, appLibraryPath, appTempPath, persistentPath, temporaryPath, userHasAllowed;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVFile*)[super initWithWebView:theWebView];
- if (self) {
- // get the documents directory path
- NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- self.appDocsPath = [paths objectAtIndex:0];
-
- paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
- self.appLibraryPath = [paths objectAtIndex:0];
-
- self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath]; // remove trailing slash from NSTemporaryDirectory()
-
- self.persistentPath = [NSString stringWithFormat:@"/%@", [self.appDocsPath lastPathComponent]];
- self.temporaryPath = [NSString stringWithFormat:@"/%@", [self.appTempPath lastPathComponent]];
- // NSLog(@"docs: %@ - temp: %@", self.appDocsPath, self.appTempPath);
- }
-
- return self;
-}
-
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath
-{
- NSFileManager* fMgr = [[NSFileManager alloc] init];
-
- NSError* __autoreleasing pError = nil;
-
- NSDictionary* pDict = [fMgr attributesOfFileSystemForPath:appPath error:&pError];
- NSNumber* pNumAvail = (NSNumber*)[pDict objectForKey:NSFileSystemFreeSize];
-
- return pNumAvail;
-}
-
-// figure out if the pathFragment represents a persistent of temporary directory and return the full application path.
-// returns nil if path is not persistent or temporary
-- (NSString*)getAppPath:(NSString*)pathFragment
-{
- NSString* appPath = nil;
- NSRange rangeP = [pathFragment rangeOfString:self.persistentPath];
- NSRange rangeT = [pathFragment rangeOfString:self.temporaryPath];
-
- if ((rangeP.location != NSNotFound) && (rangeT.location != NSNotFound)) {
- // we found both in the path, return whichever one is first
- if (rangeP.length < rangeT.length) {
- appPath = self.appDocsPath;
- } else {
- appPath = self.appTempPath;
- }
- } else if (rangeP.location != NSNotFound) {
- appPath = self.appDocsPath;
- } else if (rangeT.location != NSNotFound) {
- appPath = self.appTempPath;
- }
- return appPath;
-}
-
-/* get the full path to this resource
- * IN
- * NSString* pathFragment - full Path from File or Entry object (includes system path info)
- * OUT
- * NSString* fullPath - full iOS path to this resource, nil if not found
- */
-
-/* Was here in order to NOT have to return full path, but W3C synchronous DirectoryEntry.toURI() killed that idea since I can't call into iOS to
- * resolve full URI. Leaving this code here in case W3C spec changes.
--(NSString*) getFullPath: (NSString*)pathFragment
-{
- return pathFragment;
- NSString* fullPath = nil;
- NSString *appPath = [ self getAppPath: pathFragment];
- if (appPath){
-
- // remove last component from appPath
- NSRange range = [appPath rangeOfString:@"/" options: NSBackwardsSearch];
- NSString* newPath = [appPath substringToIndex:range.location];
- // add pathFragment to get test Path
- fullPath = [newPath stringByAppendingPathComponent:pathFragment];
- }
- return fullPath;
-} */
-
-/* Request the File System info
- *
- * IN:
- * arguments[0] - type (number as string)
- * TEMPORARY = 0, PERSISTENT = 1;
- * arguments[1] - size
- *
- * OUT:
- * Dictionary representing FileSystem object
- * name - the human readable directory name
- * root = DirectoryEntry object
- * bool isDirectory
- * bool isFile
- * string name
- * string fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference !!
- */
-
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command
-{
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* strType = [arguments objectAtIndex:0];
- unsigned long long size = [[arguments objectAtIndex:1] longLongValue];
-
- int type = [strType intValue];
- CDVPluginResult* result = nil;
-
- if (type > 1) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:NOT_FOUND_ERR];
- NSLog(@"iOS only supports TEMPORARY and PERSISTENT file systems");
- } else {
- // NSString* fullPath = [NSString stringWithFormat:@"/%@", (type == 0 ? [self.appTempPath lastPathComponent] : [self.appDocsPath lastPathComponent])];
- NSString* fullPath = (type == 0 ? self.appTempPath : self.appDocsPath);
- // check for avail space for size request
- NSNumber* pNumAvail = [self checkFreeDiskSpace:fullPath];
- // NSLog(@"Free space: %@", [NSString stringWithFormat:@"%qu", [ pNumAvail unsignedLongLongValue ]]);
- if (pNumAvail && ([pNumAvail unsignedLongLongValue] < size)) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:QUOTA_EXCEEDED_ERR];
- } else {
- NSMutableDictionary* fileSystem = [NSMutableDictionary dictionaryWithCapacity:2];
- [fileSystem setObject:(type == TEMPORARY ? kW3FileTemporary : kW3FilePersistent) forKey:@"name"];
- NSDictionary* dirEntry = [self getDirectoryEntry:fullPath isDirectory:YES];
- [fileSystem setObject:dirEntry forKey:@"root"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- }
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* Creates a dictionary representing an Entry Object
- *
- * IN:
- * NSString* fullPath of the entry
- * FileSystem type
- * BOOL isDirectory - YES if this is a directory, NO if is a file
- * OUT:
- * NSDictionary*
- Entry object
- * bool as NSNumber isDirectory
- * bool as NSNumber isFile
- * NSString* name - last part of path
- * NSString* fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir
-{
- NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:4];
- NSString* lastPart = [fullPath lastPathComponent];
-
- [dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];
- [dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];
- // NSURL* fileUrl = [NSURL fileURLWithPath:fullPath];
- // [dirEntry setObject: [fileUrl absoluteString] forKey: @"fullPath"];
- [dirEntry setObject:fullPath forKey:@"fullPath"];
- [dirEntry setObject:lastPart forKey:@"name"];
-
- return dirEntry;
-}
-
-/*
- * Given a URI determine the File System information associated with it and return an appropriate W3C entry object
- * IN
- * NSString* fileURI - currently requires full file URI
- * OUT
- * Entry object
- * bool isDirectory
- * bool isFile
- * string name
- * string fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* inputUri = [command.arguments objectAtIndex:0];
-
- // don't know if string is encoded or not so unescape
- NSString* cleanUri = [inputUri stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- // now escape in order to create URL
- NSString* strUri = [cleanUri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL* testUri = [NSURL URLWithString:strUri];
- CDVPluginResult* result = nil;
-
- if (!testUri) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
- } else if ([testUri isFileURL]) {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSString* path = [testUri path];
- // NSLog(@"url path: %@", path);
- BOOL isDir = NO;
- // see if exists and is file or dir
- BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];
- if (bExists) {
- // see if it contains docs path
- NSRange range = [path rangeOfString:self.appDocsPath];
- NSString* foundFullPath = nil;
- // there's probably an api or easier way to figure out the path type but I can't find it!
- if ((range.location != NSNotFound) && (range.length == [self.appDocsPath length])) {
- foundFullPath = self.appDocsPath;
- } else {
- // see if it contains the temp path
- range = [path rangeOfString:self.appTempPath];
- if ((range.location != NSNotFound) && (range.length == [self.appTempPath length])) {
- foundFullPath = self.appTempPath;
- }
- }
- if (foundFullPath == nil) {
- // error SECURITY_ERR - not one of the two paths types supported
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SECURITY_ERR];
- } else {
- NSDictionary* fileSystem = [self getDirectoryEntry:path isDirectory:isDir];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- }
- } else {
- // return NOT_FOUND_ERR
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
- } else if ([strUri hasPrefix:@"assets-library://"]) {
- NSDictionary* fileSystem = [self getDirectoryEntry:strUri isDirectory:NO];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
- }
-
- if (result != nil) {
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }
-}
-
-/* Part of DirectoryEntry interface, creates or returns the specified directory
- * IN:
- * NSString* fullPath - full path for this directory
- * NSString* path - directory to be created/returned; may be full path or relative path
- * NSDictionary* - Flags object
- * boolean as NSNumber create -
- * if create is true and directory does not exist, create dir and return directory entry
- * if create is true and exclusive is true and directory does exist, return error
- * if create is false and directory does not exist, return error
- * if create is false and the path represents a file, return error
- * boolean as NSNumber exclusive - used in conjunction with create
- * if exclusive is true and create is true - specifies failure if directory already exists
- *
- *
- */
-- (void)getDirectory:(CDVInvokedUrlCommand*)command
-{
- NSMutableArray* arguments = [NSMutableArray arrayWithArray:command.arguments];
- NSMutableDictionary* options = nil;
-
- if ([arguments count] >= 3) {
- options = [arguments objectAtIndex:2 withDefault:nil];
- }
- // add getDir to options and call getFile()
- if (options != nil) {
- options = [NSMutableDictionary dictionaryWithDictionary:options];
- } else {
- options = [NSMutableDictionary dictionaryWithCapacity:1];
- }
- [options setObject:[NSNumber numberWithInt:1] forKey:@"getDir"];
- if ([arguments count] >= 3) {
- [arguments replaceObjectAtIndex:2 withObject:options];
- } else {
- [arguments addObject:options];
- }
- CDVInvokedUrlCommand* subCommand =
- [[CDVInvokedUrlCommand alloc] initWithArguments:arguments
- callbackId:command.callbackId
- className:command.className
- methodName:command.methodName];
-
- [self getFile:subCommand];
-}
-
-/* Part of DirectoryEntry interface, creates or returns the specified file
- * IN:
- * NSString* fullPath - full path for this file
- * NSString* path - file to be created/returned; may be full path or relative path
- * NSDictionary* - Flags object
- * boolean as NSNumber create -
- * if create is true and file does not exist, create file and return File entry
- * if create is true and exclusive is true and file does exist, return error
- * if create is false and file does not exist, return error
- * if create is false and the path represents a directory, return error
- * boolean as NSNumber exclusive - used in conjunction with create
- * if exclusive is true and create is true - specifies failure if file already exists
- *
- *
- */
-- (void)getFile:(CDVInvokedUrlCommand*)command
-{
- // arguments are URL encoded
- NSString* fullPath = [command.arguments objectAtIndex:0];
- NSString* requestedPath = [command.arguments objectAtIndex:1];
- NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-
- // return unsupported result for assets-library URLs
- if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFile not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- BOOL bDirRequest = NO;
- BOOL create = NO;
- BOOL exclusive = NO;
- int errorCode = 0; // !!! risky - no error code currently defined for 0
-
- if ([options valueForKeyIsNumber:@"create"]) {
- create = [(NSNumber*)[options valueForKey:@"create"] boolValue];
- }
- if ([options valueForKeyIsNumber:@"exclusive"]) {
- exclusive = [(NSNumber*)[options valueForKey:@"exclusive"] boolValue];
- }
-
- if ([options valueForKeyIsNumber:@"getDir"]) {
- // this will not exist for calls directly to getFile but will have been set by getDirectory before calling this method
- bDirRequest = [(NSNumber*)[options valueForKey:@"getDir"] boolValue];
- }
- // see if the requested path has invalid characters - should we be checking for more than just ":"?
- if ([requestedPath rangeOfString:@":"].location != NSNotFound) {
- errorCode = ENCODING_ERR;
- } else {
- // was full or relative path provided?
- NSRange range = [requestedPath rangeOfString:fullPath];
- BOOL bIsFullPath = range.location != NSNotFound;
-
- NSString* reqFullPath = nil;
-
- if (!bIsFullPath) {
- reqFullPath = [fullPath stringByAppendingPathComponent:requestedPath];
- } else {
- reqFullPath = requestedPath;
- }
-
- // NSLog(@"reqFullPath = %@", reqFullPath);
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- BOOL bIsDir;
- BOOL bExists = [fileMgr fileExistsAtPath:reqFullPath isDirectory:&bIsDir];
- if (bExists && (create == NO) && (bIsDir == !bDirRequest)) {
- // path exists and is of requested type - return TYPE_MISMATCH_ERR
- errorCode = TYPE_MISMATCH_ERR;
- } else if (!bExists && (create == NO)) {
- // path does not exist and create is false - return NOT_FOUND_ERR
- errorCode = NOT_FOUND_ERR;
- } else if (bExists && (create == YES) && (exclusive == YES)) {
- // file/dir already exists and exclusive and create are both true - return PATH_EXISTS_ERR
- errorCode = PATH_EXISTS_ERR;
- } else {
- // if bExists and create == YES - just return data
- // if bExists and create == NO - just return data
- // if !bExists and create == YES - create and return data
- BOOL bSuccess = YES;
- NSError __autoreleasing* pError = nil;
- if (!bExists && (create == YES)) {
- if (bDirRequest) {
- // create the dir
- bSuccess = [fileMgr createDirectoryAtPath:reqFullPath withIntermediateDirectories:NO attributes:nil error:&pError];
- } else {
- // create the empty file
- bSuccess = [fileMgr createFileAtPath:reqFullPath contents:nil attributes:nil];
- }
- }
- if (!bSuccess) {
- errorCode = ABORT_ERR;
- if (pError) {
- NSLog(@"error creating directory: %@", [pError localizedDescription]);
- }
- } else {
- // NSLog(@"newly created file/dir (%@) exists: %d", reqFullPath, [fileMgr fileExistsAtPath:reqFullPath]);
- // file existed or was created
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:reqFullPath isDirectory:bDirRequest]];
- }
- } // are all possible conditions met?
- }
-
- if (errorCode > 0) {
- // create error callback
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * Look up the parent Entry containing this Entry.
- * If this Entry is the root of its filesystem, its parent is itself.
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * NSMutableDictionary* options
- * empty
- */
-- (void)getParent:(CDVInvokedUrlCommand*)command
-{
- // arguments are URL encoded
- NSString* fullPath = [command.arguments objectAtIndex:0];
-
- // we don't (yet?) support getting the parent of an asset
- if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- NSString* newPath = nil;
-
- if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
- // return self
- newPath = fullPath;
- } else {
- // since this call is made from an existing Entry object - the parent should already exist so no additional error checking
- // remove last component and return Entry
- NSRange range = [fullPath rangeOfString:@"/" options:NSBackwardsSearch];
- newPath = [fullPath substringToIndex:range.location];
- }
-
- if (newPath) {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- BOOL bIsDir;
- BOOL bExists = [fileMgr fileExistsAtPath:newPath isDirectory:&bIsDir];
- if (bExists) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:newPath isDirectory:bIsDir]];
- }
- }
- if (!result) {
- // invalid path or file does not exist
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * get MetaData of entry
- * Currently MetaData only includes modificationTime.
- */
-- (void)getMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
- __block CDVPluginResult* result = nil;
-
- 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! 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;
- }
-
- NSString* testPath = argPath; // [self getFullPath: argPath];
-
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing error = nil;
-
- NSDictionary* fileAttribs = [fileMgr attributesOfItemAtPath:testPath error:&error];
-
- if (fileAttribs) {
- NSDate* modDate = [fileAttribs fileModificationDate];
- if (modDate) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[modDate timeIntervalSince1970] * 1000];
- }
- } else {
- // didn't get fileAttribs
- CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [error localizedDescription]);
- if ([error code] == NSFileNoSuchFileError) {
- errorCode = NOT_FOUND_ERR;
- }
- // log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];
- }
- if (!result) {
- // invalid path or file does not exist
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * set MetaData of entry
- * Currently we only support "com.apple.MobileBackup" (boolean)
- */
-- (void)setMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* filePath = [command.arguments objectAtIndex:0];
- NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:nil];
- CDVPluginResult* result = nil;
- BOOL ok = NO;
-
- // 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);
- }
- }
- }
- }
-
- if (ok) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* removes the directory or file entry
- * IN:
- * NSArray* arguments
- * 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 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];
- CDVPluginResult* result = nil;
- CDVFileError errorCode = 0; // !! 0 not currently defined
-
- // 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];
- BOOL bIsDir = NO;
- BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
- if (!bExists) {
- errorCode = NOT_FOUND_ERR;
- }
- if (bIsDir && ([[fileMgr contentsOfDirectoryAtPath:fullPath error:nil] count] != 0)) {
- // dir is not empty
- errorCode = INVALID_MODIFICATION_ERR;
- }
- }
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- } else {
- // perform actual remove
- result = [self doRemove:fullPath];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* recursively removes the directory
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- *
- * returns NO_MODIFICATION_ALLOWED_ERR if is top level directory or no permission to delete dir
- * returns NOT_FOUND_ERR if file or dir is not found
- */
-- (void)removeRecursively:(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:@"removeRecursively not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
-
- // error if try to remove top level (documents or tmp) dir
- if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- } else {
- result = [self doRemove:fullPath];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* remove the file or directory (recursively)
- * IN:
- * NSString* fullPath - the full path to the file or directory to be removed
- * NSString* callbackId
- * called from remove and removeRecursively - check all pubic api specific error conditions (dir not empty, etc) before calling
- */
-
-- (CDVPluginResult*)doRemove:(NSString*)fullPath
-{
- CDVPluginResult* result = nil;
- BOOL bSuccess = NO;
- NSError* __autoreleasing pError = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- @try {
- bSuccess = [fileMgr removeItemAtPath:fullPath error:&pError];
- if (bSuccess) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- // see if we can give a useful error
- CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [pError localizedDescription]);
- if ([pError code] == NSFileNoSuchFileError) {
- errorCode = NOT_FOUND_ERR;
- } else if ([pError code] == NSFileWriteNoPermissionError) {
- errorCode = NO_MODIFICATION_ALLOWED_ERR;
- }
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
- } @catch(NSException* e) { // NSInvalidArgumentException if path is . or ..
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SYNTAX_ERR];
- }
-
- return result;
-}
-
-- (void)copyTo:(CDVInvokedUrlCommand*)command
-{
- [self doCopyMove:command isCopy:YES];
-}
-
-- (void)moveTo:(CDVInvokedUrlCommand*)command
-{
- [self doCopyMove:command isCopy:NO];
-}
-
-/**
- * Helper function to check to see if the user attempted to copy an entry into its parent without changing its name,
- * or attempted to copy a directory into a directory that it contains directly or indirectly.
- *
- * IN:
- * NSString* srcDir
- * NSString* destinationDir
- * OUT:
- * YES copy/ move is allows
- * NO move is onto itself
- */
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest
-{
- // This weird test is to determine if we are copying or moving a directory into itself.
- // Copy /Documents/myDir to /Documents/myDir-backup is okay but
- // Copy /Documents/myDir to /Documents/myDir/backup not okay
- BOOL copyOK = YES;
- NSRange range = [dest rangeOfString:src];
-
- if (range.location != NSNotFound) {
- NSRange testRange = {range.length - 1, ([dest length] - range.length)};
- NSRange resultRange = [dest rangeOfString:@"/" options:0 range:testRange];
- if (resultRange.location != NSNotFound) {
- copyOK = NO;
- }
- }
- return copyOK;
-}
-
-/* Copy/move a file or directory to a new location
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath of entry
- * 1 - NSString* newName the new name of the entry, defaults to the current name
- * NSMutableDictionary* options - DirectoryEntry to which to copy the entry
- * BOOL - bCopy YES if copy, NO if move
- *
- */
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy
-{
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* srcFullPath = [arguments objectAtIndex:0];
- NSString* destRootPath = [arguments objectAtIndex:1];
- // optional argument
- NSString* newName = ([arguments count] > 2) ? [arguments objectAtIndex:2] : [srcFullPath lastPathComponent]; // use last component from appPath if new name not provided
-
- __block CDVPluginResult* result = nil;
- CDVFileError errCode = 0; // !! Currently 0 is not defined, use this to signal error !!
-
- /*NSString* destRootPath = nil;
- NSString* key = @"fullPath";
- if([options valueForKeyIsString:key]){
- destRootPath = [options objectForKey:@"fullPath"];
- }*/
-
- if (!destRootPath) {
- // no destination provided
- errCode = NOT_FOUND_ERR;
- } else if ([newName rangeOfString:@":"].location != NSNotFound) {
- // invalid chars in new name
- 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 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;
- BOOL bSrcExists = [fileMgr fileExistsAtPath:srcFullPath isDirectory:&bSrcIsDir];
- BOOL bDestExists = [fileMgr fileExistsAtPath:destRootPath isDirectory:&bDestIsDir];
- BOOL bNewExists = [fileMgr fileExistsAtPath:newFullPath isDirectory:&bNewIsDir];
- if (!bSrcExists || !bDestExists) {
- // the source or the destination root does not exist
- errCode = NOT_FOUND_ERR;
- } else if (bSrcIsDir && (bNewExists && !bNewIsDir)) {
- // can't copy/move dir to file
- errCode = INVALID_MODIFICATION_ERR;
- } else { // no errors yet
- NSError* __autoreleasing error = nil;
- BOOL bSuccess = NO;
- if (bCopy) {
- if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath] /*[newFullPath hasPrefix:srcFullPath]*/) {
- // can't copy dir into self
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bNewExists) {
- // the full destination should NOT already exist if a copy
- errCode = PATH_EXISTS_ERR;
- } else {
- bSuccess = [fileMgr copyItemAtPath:srcFullPath toPath:newFullPath error:&error];
- }
- } else { // move
- // iOS requires that destination must not exist before calling moveTo
- // is W3C INVALID_MODIFICATION_ERR error if destination dir exists and has contents
- //
- if (!bSrcIsDir && (bNewExists && bNewIsDir)) {
- // can't move a file to directory
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath]) { // [newFullPath hasPrefix:srcFullPath]){
- // can't move a dir into itself
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bNewExists) {
- if (bNewIsDir && ([[fileMgr contentsOfDirectoryAtPath:newFullPath error:NULL] count] != 0)) {
- // can't move dir to a dir that is not empty
- errCode = INVALID_MODIFICATION_ERR;
- newFullPath = nil; // so we won't try to move
- } else {
- // remove destination so can perform the moveItemAtPath
- bSuccess = [fileMgr removeItemAtPath:newFullPath error:NULL];
- if (!bSuccess) {
- errCode = INVALID_MODIFICATION_ERR; // is this the correct error?
- newFullPath = nil;
- }
- }
- } else if (bNewIsDir && [newFullPath hasPrefix:srcFullPath]) {
- // can't move a directory inside itself or to any child at any depth;
- errCode = INVALID_MODIFICATION_ERR;
- newFullPath = nil;
- }
-
- if (newFullPath != nil) {
- bSuccess = [fileMgr moveItemAtPath:srcFullPath toPath:newFullPath error:&error];
- }
- }
- if (bSuccess) {
- // should verify it is there and of the correct type???
- NSDictionary* newEntry = [self getDirectoryEntry:newFullPath isDirectory:bSrcIsDir]; // should be the same type as source
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];
- } else {
- errCode = INVALID_MODIFICATION_ERR; // catch all
- if (error) {
- if (([error code] == NSFileReadUnknownError) || ([error code] == NSFileReadTooLargeError)) {
- errCode = NOT_READABLE_ERR;
- } else if ([error code] == NSFileWriteOutOfSpaceError) {
- errCode = QUOTA_EXCEEDED_ERR;
- } else if ([error code] == NSFileWriteNoPermissionError) {
- errCode = NO_MODIFICATION_ALLOWED_ERR;
- }
- }
- }
- }
- }
- }
- if (errCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errCode];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* return the URI to the entry
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath of entry
- * 1 - desired mime type of entry - ignored - always returns file://
- */
-
-/* Not needed since W3C toURI is synchronous. Leaving code here for now in case W3C spec changes.....
-- (void) toURI:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* argPath = [command.arguments objectAtIndex:0];
- PluginResult* result = nil;
- NSString* jsString = nil;
-
- NSString* fullPath = [self getFullPath: argPath];
- if (fullPath) {
- // do we need to make sure the file actually exists?
- // create file uri
- NSString* strUri = [fullPath stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
- NSURL* fileUrl = [NSURL fileURLWithPath:strUri];
- if (fileUrl) {
- result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: [fileUrl absoluteString]];
- jsString = [result toSuccessCallbackString:callbackId];
- } // else NOT_FOUND_ERR
- }
- if(!jsString) {
- // was error
- result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: NOT_FOUND_ERR cast: @"window.localFileSystem._castError"];
- jsString = [result toErrorCallbackString:callbackId];
- }
-
- [self writeJavascript:jsString];
-}*/
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- __block CDVPluginResult* result = nil;
-
- NSString* fullPath = argPath; // [self getFullPath: argPath];
-
- if (fullPath) {
- 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 {
- 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) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_INSTANTIATION_EXCEPTION];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readEntries:(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:@"readEntries not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
-
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing error = nil;
- NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fullPath error:&error];
-
- if (contents) {
- NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];
- if ([contents count] > 0) {
- // create an Entry (as JSON) for each file/dir
- for (NSString* name in contents) {
- // see if is dir or file
- NSString* entryPath = [fullPath stringByAppendingPathComponent:name];
- BOOL bIsDir = NO;
- [fileMgr fileExistsAtPath:entryPath isDirectory:&bIsDir];
- NSDictionary* entryDict = [self getDirectoryEntry:entryPath isDirectory:bIsDir];
- [entries addObject:entryDict];
- }
- }
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:entries];
- } else {
- // assume not found but could check error for more specific error conditions
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readFileWithPath:(NSString*)path start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback
-{
- if (path == nil) {
- callback(nil, nil, SYNTAX_ERR);
- } else {
- [self.commandDelegate runInBackground:^ {
- if ([path 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 = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
-
- callback(data, MIMEType, NO_ERROR);
- } else {
- callback(nil, nil, NOT_FOUND_ERR);
- }
- };
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
- // Retrieving the asset failed for some reason. Send the appropriate error.
- NSLog(@"Error: %@", error);
- callback(nil, nil, SECURITY_ERR);
- };
-
- ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
- [assetsLibrary assetForURL:[NSURL URLWithString:path] resultBlock:resultBlock failureBlock:failureBlock];
- } else {
- NSString* mimeType = [self getMimeTypeFromPath:path];
- if (mimeType == nil) {
- mimeType = @"*/*";
- }
- NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:path];
- if (start > 0) {
- [file seekToFileOffset:start];
- }
-
- NSData* readData;
- if (end < 0) {
- readData = [file readDataToEndOfFile];
- } else {
- readData = [file readDataOfLength:(end - start)];
- }
-
- [file closeFile];
-
- callback(readData, mimeType, readData != nil ? NO_ERROR : NOT_FOUND_ERR);
- }
- }];
- }
-}
-
-/* read and return file data
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* encoding
- * 2 - NSString* start
- * 3 - NSString* end
- */
-- (void)readAsText:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* path = [command argumentAtIndex:0];
- NSString* encoding = [command argumentAtIndex:1];
- NSInteger start = [[command argumentAtIndex:2] integerValue];
- NSInteger end = [[command argumentAtIndex:3] integerValue];
-
- // TODO: implement
- if (![@"UTF-8" isEqualToString : encoding]) {
- NSLog(@"Only UTF-8 encodings are currently supported by readAsText");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ENCODING_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- NSString* str = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSUTF8StringEncoding freeWhenDone:NO];
- // Check that UTF8 conversion did not fail.
- if (str != nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:str];
- result.associatedObject = data;
- } else {
- errorCode = ENCODING_ERR;
- }
- }
- if (result == nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* Read content of text file and return as base64 encoded data url.
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* start
- * 2 - NSString* end
- *
- * Determines the mime type from the file extension, returns ENCODING_ERR if mimetype can not be determined.
- */
-
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- // TODO: Would be faster to base64 encode directly to the final string.
- NSString* output = [NSString stringWithFormat:@"data:%@;base64,%@", mimeType, [data base64EncodedString]];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:output];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* Read content of text file and return as an arraybuffer
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* start
- * 2 - NSString* end
- */
-
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArrayBuffer:data];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-- (void)readAsBinaryString:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- NSString* payload = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSASCIIStringEncoding freeWhenDone:NO];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload];
- result.associatedObject = data;
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* helper function to get the mimeType from the file extension
- * IN:
- * NSString* fullPath - filename (may include path)
- * OUT:
- * NSString* the mime type as type/subtype. nil if not able to determine
- */
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath
-{
- NSString* mimeType = nil;
-
- if (fullPath) {
- CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);
- if (typeId) {
- mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);
- if (!mimeType) {
- // special case for m4a
- if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {
- mimeType = @"audio/mp4";
- } else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {
- mimeType = @"audio/wav";
- }
- }
- CFRelease(typeId);
- }
- }
- return mimeType;
-}
-
-- (void)truncate:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
- unsigned long long pos = (unsigned long long)[[command.arguments objectAtIndex:1] longLongValue];
-
- // assets-library files can't be truncated
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSString* appFile = argPath; // [self getFullPath:argPath];
-
- unsigned long long newPos = [self truncateFile:appFile atPosition:pos];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:newPos];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos
-{
- unsigned long long newPos = 0UL;
-
- NSFileHandle* file = [NSFileHandle fileHandleForWritingAtPath:filePath];
-
- if (file) {
- [file truncateFileAtOffset:(unsigned long long)pos];
- newPos = [file offsetInFile];
- [file synchronizeFile];
- [file closeFile];
- }
- return newPos;
-}
-
-/* write
- * IN:
- * NSArray* arguments
- * 0 - NSString* file path to write to
- * 1 - NSString* data to write
- * 2 - NSNumber* position to begin writing
- */
-- (void)write:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* argPath = [arguments objectAtIndex:0];
- NSString* argData = [arguments objectAtIndex:1];
- unsigned long long pos = (unsigned long long)[[arguments objectAtIndex:2] longLongValue];
-
- // text can't be written into assets-library files
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSString* fullPath = argPath; // [self getFullPath:argPath];
-
- [self truncateFile:fullPath atPosition:pos];
-
- [self writeToFile:fullPath withData:argData append:YES callback:callbackId];
-}
-
-- (void)writeToFile:(NSString*)filePath withData:(NSString*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
- CDVFileError errCode = INVALID_MODIFICATION_ERR;
- int bytesWritten = 0;
- NSData* encData = [data dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
-
- if (filePath) {
- NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];
- if (fileStream) {
- NSUInteger len = [encData length];
- [fileStream open];
-
- bytesWritten = [fileStream write:[encData bytes] maxLength:len];
-
- [fileStream close];
- if (bytesWritten > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
- // } else {
- // can probably get more detailed error info via [fileStream streamError]
- // errCode already set to INVALID_MODIFICATION_ERR;
- // bytesWritten = 0; // may be set to -1 on error
- }
- } // else fileStream not created return INVALID_MODIFICATION_ERR
- } else {
- // invalid filePath
- errCode = NOT_FOUND_ERR;
- }
- if (!result) {
- // was an error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)testFileExists:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- // Get the file manager
- NSFileManager* fMgr = [NSFileManager defaultManager];
- NSString* appFile = argPath; // [ self getFullPath: argPath];
-
- BOOL bExists = [fMgr fileExistsAtPath:appFile];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(bExists ? 1 : 0)];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- // Get the file manager
- NSFileManager* fMgr = [[NSFileManager alloc] init];
- NSString* appFile = argPath; // [self getFullPath: argPath];
- BOOL bIsDir = NO;
- BOOL bExists = [fMgr fileExistsAtPath:appFile isDirectory:&bIsDir];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:((bExists && bIsDir) ? 1 : 0)];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-// Returns number of bytes available via callback
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command
-{
- // no arguments
-
- NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];
-
- NSString* strFreeSpace = [NSString stringWithFormat:@"%qu", [pNumAvail unsignedLongLongValue]];
- // NSLog(@"Free space is %@", strFreeSpace );
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:strFreeSpace];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b428f241/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
deleted file mode 100644
index 35e3fdd..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ /dev/null
@@ -1,82 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileTransferError {
- FILE_NOT_FOUND_ERR = 1,
- INVALID_URL_ERR = 2,
- CONNECTION_ERR = 3,
- CONNECTION_ABORTED = 4
-};
-typedef int CDVFileTransferError;
-
-enum CDVFileTransferDirection {
- CDV_TRANSFER_UPLOAD = 1,
- CDV_TRANSFER_DOWNLOAD = 2,
-};
-typedef int CDVFileTransferDirection;
-
-// Magic value within the options dict used to set a cookie.
-extern NSString* const kOptionsKeyCookie;
-
-@interface CDVFileTransfer : CDVPlugin {}
-
-- (void)upload:(CDVInvokedUrlCommand*)command;
-- (void)download:(CDVInvokedUrlCommand*)command;
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString;
-
-// Visible for testing.
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData;
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
- AndSource:(NSString*)source
- AndTarget:(NSString*)target
- AndHttpStatus:(int)httpStatus
- AndBody:(NSString*)body;
-@property (readonly) NSMutableDictionary* activeTransfers;
-@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskID;
-@end
-
-@class CDVFileTransferEntityLengthRequest;
-
-@interface CDVFileTransferDelegate : NSObject {}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected;
-- (void)cancelTransfer:(NSURLConnection*)connection;
-
-@property (strong) NSMutableData* responseData; // atomic
-@property (nonatomic, strong) CDVFileTransfer* command;
-@property (nonatomic, assign) CDVFileTransferDirection direction;
-@property (nonatomic, strong) NSURLConnection* connection;
-@property (nonatomic, copy) NSString* callbackId;
-@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;
-@property (nonatomic, assign) BOOL trustAllHosts;
-@property (strong) NSFileHandle* targetFileHandle;
-@property (nonatomic, strong) CDVFileTransferEntityLengthRequest* entityLengthRequest;
-
-@end;
[29/50] [abbrv] ios commit: updated cordovajs
Posted by ag...@apache.org.
updated cordovajs
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/48f3dd92
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/48f3dd92
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/48f3dd92
Branch: refs/heads/master
Commit: 48f3dd926ff47d02126dd386300db241e1a2d9fe
Parents: 9586f94
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 15:56:37 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:30:53 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 62 ++++++----------------------------------------
1 file changed, 8 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/48f3dd92/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 1c33e04..e8bc477 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -2,6 +2,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
=======
// 2.7.0rc1-84-g62c5786
@@ -12,6 +13,9 @@
=======
// 2.7.0rc1-101-gc6482ac
>>>>>>> updated js
+=======
+// 2.7.0rc1-116-gf0108ae
+>>>>>>> updated cordovajs
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -34,6 +38,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
@@ -44,6 +49,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
>>>>>>> updated js
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
+>>>>>>> updated cordovajs
// file: lib/scripts/require.js
var require,
@@ -1283,60 +1291,6 @@ module.exports = {
});
-// file: lib/common/plugin/Coordinates.js
-define("cordova/plugin/Coordinates", function(require, exports, module) {
-
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = (alt !== undefined ? alt : null);
- /**
- * The direction the device is moving at the position.
- */
- this.heading = (head !== undefined ? head : null);
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = (vel !== undefined ? vel : null);
-
- if (this.speed === 0 || this.speed === null) {
- this.heading = NaN;
- }
-
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
-
-});
-
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
[47/50] [abbrv] ios commit: added cdvshared to buildphases
Posted by ag...@apache.org.
added cdvshared to buildphases
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/ce9a0d68
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/ce9a0d68
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/ce9a0d68
Branch: refs/heads/master
Commit: ce9a0d68f5f7e616183e7376f2372ce5ec94f28f
Parents: f705b31
Author: Steven Gill <st...@gmail.com>
Authored: Tue Jun 25 17:05:31 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Tue Jun 25 17:05:31 2013 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ce9a0d68/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 2d97260..d238213 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,7 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
- 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B701026177A61CF00AE11F4 /* CDVShared.h */; };
+ 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B701026177A61CF00AE11F4 /* CDVShared.h */; settings = {ATTRIBUTES = (Public, ); }; };
1B701029177A61CF00AE11F4 /* CDVShared.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B701027177A61CF00AE11F4 /* CDVShared.m */; };
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /* CDVPluginResult.m */; };
@@ -290,13 +290,13 @@
EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */,
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */,
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */,
+ 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */,
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */,
F858FBC6166009A8007DA594 /* CDVConfigParser.h in Headers */,
30F3930B169F839700B22307 /* CDVJSON.h in Headers */,
EBFF4DBD16D3FE2E008F452B /* CDVWebViewDelegate.h in Headers */,
EB96673B16A8970A00D86CDF /* CDVUserAgentUtil.h in Headers */,
7E14B5A81705050A0032169E /* CDVTimer.h in Headers */,
- 1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
[24/50] [abbrv] ios commit: removed globalization
Posted by ag...@apache.org.
removed globalization
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/2e1830a2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/2e1830a2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/2e1830a2
Branch: refs/heads/master
Commit: 2e1830a241ba690982edcb352241644a01ac34bd
Parents: c28b0b8
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 11:48:14 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:24:34 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__/config.xml | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2e1830a2/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index aded8e0..16e6919 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -73,9 +73,6 @@
<feature name="Capture">
<param name="ios-package" value="CDVCapture"/>
</feature>
- <feature name="Globalization">
- <param name="ios-package" value="CDVGlobalization"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[36/50] [abbrv] ios commit: removed network information from ios
Posted by ag...@apache.org.
removed network information from ios
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/362e4f1e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/362e4f1e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/362e4f1e
Branch: refs/heads/master
Commit: 362e4f1e5be4746e6d6b3e507f5e587db450395e
Parents: bc66e14
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 18:12:25 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:42 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 2 -
CordovaLib/Classes/CDVConnection.h | 34 ---
CordovaLib/Classes/CDVConnection.m | 132 ----------
CordovaLib/Classes/CDVReachability.h | 85 ------
CordovaLib/Classes/CDVReachability.m | 260 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 16 --
bin/templates/project/__TESTING__/config.xml | 3 -
7 files changed, 532 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index cef896b..0c1779f 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,10 +25,8 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVConnection.h"
#import "CDVDebug.h"
#import "CDVPluginResult.h"
-#import "CDVReachability.h"
#import "CDVSound.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/Classes/CDVConnection.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.h b/CordovaLib/Classes/CDVConnection.h
deleted file mode 100644
index d3e8c5d..0000000
--- a/CordovaLib/Classes/CDVConnection.h
+++ /dev/null
@@ -1,34 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-#import "CDVReachability.h"
-
-@interface CDVConnection : CDVPlugin {
- NSString* type;
- NSString* _callbackId;
-
- CDVReachability* internetReach;
-}
-
-@property (copy) NSString* connectionType;
-@property (strong) CDVReachability* internetReach;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/Classes/CDVConnection.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m
deleted file mode 100644
index b3f5cab..0000000
--- a/CordovaLib/Classes/CDVConnection.m
+++ /dev/null
@@ -1,132 +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.
- */
-
-#import "CDVConnection.h"
-#import "CDVReachability.h"
-
-@interface CDVConnection (PrivateMethods)
-- (void)updateOnlineStatus;
-- (void)sendPluginResult;
-@end
-
-@implementation CDVConnection
-
-@synthesize connectionType, internetReach;
-
-- (void)getConnectionInfo:(CDVInvokedUrlCommand*)command
-{
- _callbackId = command.callbackId;
- [self sendPluginResult];
-}
-
-- (void)sendPluginResult
-{
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType];
-
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:_callbackId];
-}
-
-- (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
-{
- NetworkStatus networkStatus = [reachability currentReachabilityStatus];
-
- switch (networkStatus) {
- case NotReachable:
- return @"none";
-
- case ReachableViaWWAN:
- // Return value of '2g' is deprecated as of 2.6.0 and will be replaced with 'cellular' in 3.0.0
- return @"2g";
-
- case ReachableViaWiFi:
- return @"wifi";
-
- default:
- return @"unknown";
- }
-}
-
-- (BOOL)isCellularConnection:(NSString*)theConnectionType
-{
- return [theConnectionType isEqualToString:@"2g"] ||
- [theConnectionType isEqualToString:@"3g"] ||
- [theConnectionType isEqualToString:@"4g"] ||
- [theConnectionType isEqualToString:@"cellular"];
-}
-
-- (void)updateReachability:(CDVReachability*)reachability
-{
- if (reachability) {
- // check whether the connection type has changed
- NSString* newConnectionType = [self w3cConnectionTypeFor:reachability];
- if ([newConnectionType isEqualToString:self.connectionType]) { // the same as before, remove dupes
- return;
- } else {
- self.connectionType = [self w3cConnectionTypeFor:reachability];
- }
- }
- [self sendPluginResult];
-}
-
-- (void)updateConnectionType:(NSNotification*)note
-{
- CDVReachability* curReach = [note object];
-
- if ((curReach != nil) && [curReach isKindOfClass:[CDVReachability class]]) {
- [self updateReachability:curReach];
- }
-}
-
-- (void)onPause
-{
- [self.internetReach stopNotifier];
-}
-
-- (void)onResume
-{
- [self.internetReach startNotifier];
- [self updateReachability:self.internetReach];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super initWithWebView:theWebView];
- if (self) {
- self.connectionType = @"none";
- self.internetReach = [CDVReachability reachabilityForInternetConnection];
- self.connectionType = [self w3cConnectionTypeFor:self.internetReach];
- [self.internetReach startNotifier];
- [self printDeprecationNotice];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
- name:kReachabilityChangedNotification object:nil];
- if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- }
- }
- return self;
-}
-
-- (void)printDeprecationNotice
-{
- NSLog(@"DEPRECATION NOTICE: The Connection ReachableViaWWAN return value of '2g' is deprecated as of Cordova version 2.6.0 and will be changed to 'cellular' in a future release. ");
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/Classes/CDVReachability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.h b/CordovaLib/Classes/CDVReachability.h
deleted file mode 100644
index 01a95c3..0000000
--- a/CordovaLib/Classes/CDVReachability.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-
- File: Reachability.h
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <Foundation/Foundation.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-#import <netinet/in.h>
-
-typedef enum {
- NotReachable = 0,
- ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
- ReachableViaWiFi // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
-} NetworkStatus;
-#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
-
-@interface CDVReachability : NSObject
-{
- BOOL localWiFiRef;
- SCNetworkReachabilityRef reachabilityRef;
-}
-
-// reachabilityWithHostName- Use to check the reachability of a particular host name.
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-
-// reachabilityWithAddress- Use to check the reachability of a particular IP address.
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-
-// reachabilityForInternetConnection- checks whether the default route is available.
-// Should be used by applications that do not connect to a particular host
-+ (CDVReachability*)reachabilityForInternetConnection;
-
-// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
-+ (CDVReachability*)reachabilityForLocalWiFi;
-
-// Start listening for reachability notifications on the current run loop
-- (BOOL)startNotifier;
-- (void)stopNotifier;
-
-- (NetworkStatus)currentReachabilityStatus;
-// WWAN may be available, but not active until a connection has been established.
-// WiFi may require a connection for VPN on Demand.
-- (BOOL)connectionRequired;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/Classes/CDVReachability.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.m b/CordovaLib/Classes/CDVReachability.m
deleted file mode 100644
index 89f4ec9..0000000
--- a/CordovaLib/Classes/CDVReachability.m
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-
- File: Reachability.m
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <sys/socket.h>
-#import <netinet/in.h>
-#import <netinet6/in6.h>
-#import <arpa/inet.h>
-#import <ifaddrs.h>
-#import <netdb.h>
-
-#import <CoreFoundation/CoreFoundation.h>
-
-#import "CDVReachability.h"
-
-#define kShouldPrintReachabilityFlags 0
-
-static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
-{
-#if kShouldPrintReachabilityFlags
- NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
-
- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
- comment
- );
-#endif
-}
-
-@implementation CDVReachability
-
-static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
-{
-#pragma unused (target, flags)
- // NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
- // NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
-
- // Converted the asserts above to conditionals, with safe return from the function
- if (info == NULL) {
- NSLog(@"info was NULL in ReachabilityCallback");
- return;
- }
-
- if (![(__bridge NSObject*)info isKindOfClass :[CDVReachability class]]) {
- NSLog(@"info was wrong class in ReachabilityCallback");
- return;
- }
-
- // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
- // in case someon uses the Reachability object in a different thread.
- @autoreleasepool {
- CDVReachability* noteObject = (__bridge CDVReachability*)info;
- // Post a notification to notify the client that the network reachability changed.
- [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
- }
-}
-
-- (BOOL)startNotifier
-{
- BOOL retVal = NO;
- SCNetworkReachabilityContext context = {0, (__bridge void*)(self), NULL, NULL, NULL};
-
- if (SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context)) {
- if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
- retVal = YES;
- }
- }
- return retVal;
-}
-
-- (void)stopNotifier
-{
- if (reachabilityRef != NULL) {
- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- }
-}
-
-- (void)dealloc
-{
- [self stopNotifier];
- if (reachabilityRef != NULL) {
- CFRelease(reachabilityRef);
- }
-}
-
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-{
- CDVReachability* retVal = NULL;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-{
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
- CDVReachability* retVal = NULL;
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityForInternetConnection;
-{
- struct sockaddr_in zeroAddress;
- bzero(&zeroAddress, sizeof(zeroAddress));
- zeroAddress.sin_len = sizeof(zeroAddress);
- zeroAddress.sin_family = AF_INET;
- return [self reachabilityWithAddress:&zeroAddress];
-}
-
-+ (CDVReachability*)reachabilityForLocalWiFi;
-{
- struct sockaddr_in localWifiAddress;
- bzero(&localWifiAddress, sizeof(localWifiAddress));
- localWifiAddress.sin_len = sizeof(localWifiAddress);
- localWifiAddress.sin_family = AF_INET;
- // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
- localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
- CDVReachability* retVal = [self reachabilityWithAddress:&localWifiAddress];
- if (retVal != NULL) {
- retVal->localWiFiRef = YES;
- }
- return retVal;
-}
-
-#pragma mark Network Flag Handling
-
-- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags");
-
- BOOL retVal = NotReachable;
- if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) {
- retVal = ReachableViaWiFi;
- }
- return retVal;
-}
-
-- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "networkStatusForFlags");
- if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
- // if target host is not reachable
- return NotReachable;
- }
-
- BOOL retVal = NotReachable;
-
- if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) {
- // if target host is reachable and no connection is required
- // then we'll assume (for now) that your on Wi-Fi
- retVal = ReachableViaWiFi;
- }
-
- if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
- ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
- // ... and the connection is on-demand (or on-traffic) if the
- // calling application is using the CFSocketStream or higher APIs
-
- if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) {
- // ... and no [user] intervention is needed
- retVal = ReachableViaWiFi;
- }
- }
-
- if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
- // ... but WWAN connections are OK if the calling application
- // is using the CFNetwork (CFSocketStream?) APIs.
- retVal = ReachableViaWWAN;
- }
- return retVal;
-}
-
-- (BOOL)connectionRequired;
-{
- NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- return flags & kSCNetworkReachabilityFlagsConnectionRequired;
- }
- return NO;
-}
-
-- (NetworkStatus)currentReachabilityStatus
-{
- NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
- NetworkStatus retVal = NotReachable;
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- if (localWiFiRef) {
- retVal = [self localWiFiStatusForFlags:flags];
- } else {
- retVal = [self networkStatusForFlags:flags];
- }
- }
- return retVal;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 09c8af3..cd3908d 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -17,8 +17,6 @@
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */; };
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */; };
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C684921407044A004C1A8E /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -42,8 +40,6 @@
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
- 8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
@@ -73,8 +69,6 @@
3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+Extensions.h"; path = "Classes/UIDevice+Extensions.h"; sourceTree = "<group>"; };
3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+Extensions.m"; path = "Classes/UIDevice+Extensions.m"; sourceTree = "<group>"; };
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
- 307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
- 307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWhitelist.m; path = Classes/CDVWhitelist.m; sourceTree = "<group>"; };
30C684921407044A004C1A8E /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVURLProtocol.h; path = Classes/CDVURLProtocol.h; sourceTree = "<group>"; };
@@ -111,8 +105,6 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVReachability.h; path = Classes/CDVReachability.h; sourceTree = "<group>"; };
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVReachability.m; path = Classes/CDVReachability.m; sourceTree = "<group>"; };
8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
@@ -221,16 +213,12 @@
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
- 307A8F9C1385A2EC00E43782 /* CDVConnection.h */,
- 307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
8887FD611090FBE7009987E8 /* CDVSound.m */,
3E76876B156A90EE00EB6FA3 /* CDVLogger.m */,
@@ -284,10 +272,8 @@
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
- 8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
- 307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
@@ -370,10 +356,8 @@
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
- 8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
- 307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/362e4f1e/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 1771906..018490c 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -55,9 +55,6 @@
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="NetworkStatus">
- <param name="ios-package" value="CDVConnection"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[18/50] [abbrv] removed native plugin files for various plugins
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
deleted file mode 100644
index b832e23..0000000
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ /dev/null
@@ -1,818 +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.
- */
-
-#import "CDVInAppBrowser.h"
-#import "CDVPluginResult.h"
-#import "CDVUserAgentUtil.h"
-#import "CDVJSON.h"
-
-#define kInAppBrowserTargetSelf @"_self"
-#define kInAppBrowserTargetSystem @"_system"
-#define kInAppBrowserTargetBlank @"_blank"
-
-#define TOOLBAR_HEIGHT 44.0
-#define LOCATIONBAR_HEIGHT 21.0
-#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
-
-#pragma mark CDVInAppBrowser
-
-@implementation CDVInAppBrowser
-
-- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super initWithWebView:theWebView];
- if (self != nil) {
- // your initialization here
- }
-
- return self;
-}
-
-- (void)onReset
-{
- [self close:nil];
-}
-
-- (void)close:(CDVInvokedUrlCommand*)command
-{
- if (self.inAppBrowserViewController != nil) {
- [self.inAppBrowserViewController close];
- self.inAppBrowserViewController = nil;
- }
-
- self.callbackId = nil;
-}
-
-- (void)open:(CDVInvokedUrlCommand*)command
-{
- CDVPluginResult* pluginResult;
-
- NSString* url = [command argumentAtIndex:0];
- NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
- NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
-
- self.callbackId = command.callbackId;
-
- if (url != nil) {
- NSURL* baseUrl = [self.webView.request URL];
- NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
- if ([target isEqualToString:kInAppBrowserTargetSelf]) {
- [self openInCordovaWebView:absoluteUrl withOptions:options];
- } else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
- [self openInSystem:absoluteUrl];
- } else { // _blank or anything else
- [self openInInAppBrowser:absoluteUrl withOptions:options];
- }
-
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of arguments"];
- }
-
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
-{
- if (self.inAppBrowserViewController == nil) {
- NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
- self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent]];
- self.inAppBrowserViewController.navigationDelegate = self;
-
- if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
- self.inAppBrowserViewController.orientationDelegate = (UIViewController <CDVScreenOrientationDelegate>*)self.viewController;
- }
- }
-
-
- CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
- [self.inAppBrowserViewController showLocationBar:browserOptions.location];
- [self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
- if (browserOptions.closebuttoncaption != nil) {
- [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
- }
- // Set Presentation Style
- UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
- if (browserOptions.presentationstyle != nil) {
- if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"pagesheet"]) {
- presentationStyle = UIModalPresentationPageSheet;
- } else if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"formsheet"]) {
- presentationStyle = UIModalPresentationFormSheet;
- }
- }
- self.inAppBrowserViewController.modalPresentationStyle = presentationStyle;
-
- // Set Transition Style
- UIModalTransitionStyle transitionStyle = UIModalTransitionStyleCoverVertical; // default
- if (browserOptions.transitionstyle != nil) {
- if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"fliphorizontal"]) {
- transitionStyle = UIModalTransitionStyleFlipHorizontal;
- } else if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"crossdissolve"]) {
- transitionStyle = UIModalTransitionStyleCrossDissolve;
- }
- }
- self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
-
-
- // UIWebView options
- self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
- self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
- self.inAppBrowserViewController.webView.allowsInlineMediaPlayback = browserOptions.allowinlinemediaplayback;
- if (IsAtLeastiOSVersion(@"6.0")) {
- self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
- self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
- }
-
- if (! browserOptions.hidden) {
- if (self.viewController.modalViewController != self.inAppBrowserViewController) {
- [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
- }
- }
- [self.inAppBrowserViewController navigateTo:url];
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command
-{
- [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
-}
-
-- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
-{
- if ([self.commandDelegate URLIsWhitelisted:url]) {
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
- [self.webView loadRequest:request];
- } else { // this assumes the InAppBrowser can be excepted from the white-list
- [self openInInAppBrowser:url withOptions:options];
- }
-}
-
-- (void)openInSystem:(NSURL*)url
-{
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url];
- } else { // handle any custom schemes to plugins
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
- }
-}
-
-// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
-// provides a consistent method for injecting JavaScript code into the document.
-//
-// If a wrapper string is supplied, then the source string will be JSON-encoded (adding
-// quotes) and wrapped using string formatting. (The wrapper string should have a single
-// '%@' marker).
-//
-// If no wrapper is supplied, then the source string is executed directly.
-
-- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
-{
- if (!_injectedIframeBridge) {
- _injectedIframeBridge = YES;
- // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
- }
-
- if (jsWrapper != nil) {
- NSString* sourceArrayString = [@[source] JSONString];
- if (sourceArrayString) {
- NSString* sourceString = [sourceArrayString substringWithRange:NSMakeRange(1, [sourceArrayString length] - 2)];
- NSString* jsToInject = [NSString stringWithFormat:jsWrapper, sourceString];
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:jsToInject];
- }
- } else {
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:source];
- }
-}
-
-- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper = nil;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"_cdvIframeBridge.src='gap-iab://%@/'+window.escape(JSON.stringify([eval(%%@)]));", command.callbackId];
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('script'); c.src = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('style'); c.innerHTML = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('style'); c.innerHTML = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-/**
- * The iframe bridge provided for the InAppBrowser is capable of executing any oustanding callback belonging
- * to the InAppBrowser plugin. Care has been taken that other callbacks cannot be triggered, and that no
- * other code execution is possible.
- *
- * To trigger the bridge, the iframe (or any other resource) should attempt to load a url of the form:
- *
- * gap-iab://<callbackId>/<arguments>
- *
- * where <callbackId> is the string id of the callback to trigger (something like "InAppBrowser0123456789")
- *
- * If present, the path component of the special gap-iab:// url is expected to be a URL-escaped JSON-encoded
- * value to pass to the callback. [NSURL path] should take care of the URL-unescaping, and a JSON_EXCEPTION
- * is returned if the JSON is invalid.
- */
-- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- NSURL* url = request.URL;
- BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
-
- // See if the url uses the 'gap-iab' protocol. If so, the host should be the id of a callback to execute,
- // and the path, if present, should be a JSON-encoded value to pass to the callback.
- if ([[url scheme] isEqualToString:@"gap-iab"]) {
- NSString* scriptCallbackId = [url host];
- CDVPluginResult* pluginResult = nil;
-
- if ([scriptCallbackId hasPrefix:@"InAppBrowser"]) {
- NSString* scriptResult = [url path];
- NSError* __autoreleasing error = nil;
-
- // The message should be a JSON-encoded array of the result of the script which executed.
- if ((scriptResult != nil) && ([scriptResult length] > 1)) {
- scriptResult = [scriptResult substringFromIndex:1];
- NSData* decodedResult = [NSJSONSerialization JSONObjectWithData:[scriptResult dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
- if ((error == nil) && [decodedResult isKindOfClass:[NSArray class]]) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:(NSArray*)decodedResult];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION];
- }
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:@[]];
- }
- [self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
- return NO;
- }
- } else if ((self.callbackId != nil) && isTopLevelNavigation) {
- // Send a loadstart event for each top-level navigation (includes redirects).
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-
- return YES;
-}
-
-- (void)webViewDidStartLoad:(UIWebView*)theWebView
-{
- _injectedIframeBridge = NO;
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- if (self.callbackId != nil) {
- // TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected).
- NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"loadstop", @"url":url}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-}
-
-- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- if (self.callbackId != nil) {
- NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-}
-
-- (void)browserExit
-{
- if (self.callbackId != nil) {
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"exit"}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
- // Don't recycle the ViewController since it may be consuming a lot of memory.
- // Also - this is required for the PDF/User-Agent bug work-around.
- self.inAppBrowserViewController = nil;
-}
-
-@end
-
-#pragma mark CDVInAppBrowserViewController
-
-@implementation CDVInAppBrowserViewController
-
-@synthesize currentURL;
-
-- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent
-{
- self = [super init];
- if (self != nil) {
- _userAgent = userAgent;
- _prevUserAgent = prevUserAgent;
- _webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
- [self createViews];
- }
-
- return self;
-}
-
-- (void)createViews
-{
- // We create the views in code for primarily for ease of upgrades and not requiring an external .xib to be included
-
- CGRect webViewBounds = self.view.bounds;
-
- webViewBounds.size.height -= FOOTER_HEIGHT;
-
- self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
- self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-
- [self.view addSubview:self.webView];
- [self.view sendSubviewToBack:self.webView];
-
- self.webView.delegate = _webViewDelegate;
- self.webView.backgroundColor = [UIColor whiteColor];
-
- self.webView.clearsContextBeforeDrawing = YES;
- self.webView.clipsToBounds = YES;
- self.webView.contentMode = UIViewContentModeScaleToFill;
- self.webView.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.webView.multipleTouchEnabled = YES;
- self.webView.opaque = YES;
- self.webView.scalesPageToFit = NO;
- self.webView.userInteractionEnabled = YES;
-
- self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
- self.spinner.alpha = 1.000;
- self.spinner.autoresizesSubviews = YES;
- self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
- self.spinner.clearsContextBeforeDrawing = NO;
- self.spinner.clipsToBounds = NO;
- self.spinner.contentMode = UIViewContentModeScaleToFill;
- self.spinner.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
- self.spinner.hidden = YES;
- self.spinner.hidesWhenStopped = YES;
- self.spinner.multipleTouchEnabled = NO;
- self.spinner.opaque = NO;
- self.spinner.userInteractionEnabled = NO;
- [self.spinner stopAnimating];
-
- self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
- self.closeButton.enabled = YES;
-
- UIBarButtonItem* flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
-
- UIBarButtonItem* fixedSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- fixedSpaceButton.width = 20;
-
- self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, (self.view.bounds.size.height - TOOLBAR_HEIGHT), self.view.bounds.size.width, TOOLBAR_HEIGHT)];
- self.toolbar.alpha = 1.000;
- self.toolbar.autoresizesSubviews = YES;
- self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
- self.toolbar.barStyle = UIBarStyleBlackOpaque;
- self.toolbar.clearsContextBeforeDrawing = NO;
- self.toolbar.clipsToBounds = NO;
- self.toolbar.contentMode = UIViewContentModeScaleToFill;
- self.toolbar.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.toolbar.hidden = NO;
- self.toolbar.multipleTouchEnabled = NO;
- self.toolbar.opaque = NO;
- self.toolbar.userInteractionEnabled = YES;
-
- CGFloat labelInset = 5.0;
- self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelInset, (self.view.bounds.size.height - FOOTER_HEIGHT), self.view.bounds.size.width - labelInset, LOCATIONBAR_HEIGHT)];
- self.addressLabel.adjustsFontSizeToFitWidth = NO;
- self.addressLabel.alpha = 1.000;
- self.addressLabel.autoresizesSubviews = YES;
- self.addressLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
- self.addressLabel.backgroundColor = [UIColor clearColor];
- self.addressLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
- self.addressLabel.clearsContextBeforeDrawing = YES;
- self.addressLabel.clipsToBounds = YES;
- self.addressLabel.contentMode = UIViewContentModeScaleToFill;
- self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.addressLabel.enabled = YES;
- self.addressLabel.hidden = NO;
- self.addressLabel.lineBreakMode = UILineBreakModeTailTruncation;
- self.addressLabel.minimumFontSize = 10.000;
- self.addressLabel.multipleTouchEnabled = NO;
- self.addressLabel.numberOfLines = 1;
- self.addressLabel.opaque = NO;
- self.addressLabel.shadowOffset = CGSizeMake(0.0, -1.0);
- self.addressLabel.text = @"Loading...";
- self.addressLabel.textAlignment = UITextAlignmentLeft;
- self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
- self.addressLabel.userInteractionEnabled = NO;
-
- NSString* frontArrowString = @"â–º"; // create arrow from Unicode char
- self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)];
- self.forwardButton.enabled = YES;
- self.forwardButton.imageInsets = UIEdgeInsetsZero;
-
- NSString* backArrowString = @"â—„"; // create arrow from Unicode char
- self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
- self.backButton.enabled = YES;
- self.backButton.imageInsets = UIEdgeInsetsZero;
-
- [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
-
- self.view.backgroundColor = [UIColor grayColor];
- [self.view addSubview:self.toolbar];
- [self.view addSubview:self.addressLabel];
- [self.view addSubview:self.spinner];
-}
-
-- (void)setCloseButtonTitle:(NSString*)title
-{
- // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
- // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one)
- self.closeButton = nil;
- self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)];
- self.closeButton.enabled = YES;
- self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
-
- NSMutableArray* items = [self.toolbar.items mutableCopy];
- [items replaceObjectAtIndex:0 withObject:self.closeButton];
- [self.toolbar setItems:items];
-}
-
-- (void)showLocationBar:(BOOL)show
-{
- CGRect locationbarFrame = self.addressLabel.frame;
-
- BOOL toolbarVisible = !self.toolbar.hidden;
-
- // prevent double show/hide
- if (show == !(self.addressLabel.hidden)) {
- return;
- }
-
- if (show) {
- self.addressLabel.hidden = NO;
-
- if (toolbarVisible) {
- // toolBar at the bottom, leave as is
- // put locationBar on top of the toolBar
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= FOOTER_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- } else {
- // no toolBar, so put locationBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- }
- } else {
- self.addressLabel.hidden = YES;
-
- if (toolbarVisible) {
- // locationBar is on top of toolBar, hide locationBar
-
- // webView take up whole height less toolBar height
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= TOOLBAR_HEIGHT;
- self.webView.frame = webViewBounds;
- } else {
- // no toolBar, expand webView to screen dimensions
-
- CGRect webViewBounds = self.view.bounds;
- self.webView.frame = webViewBounds;
- }
- }
-}
-
-- (void)showToolBar:(BOOL)show
-{
- CGRect toolbarFrame = self.toolbar.frame;
- CGRect locationbarFrame = self.addressLabel.frame;
-
- BOOL locationbarVisible = !self.addressLabel.hidden;
-
- // prevent double show/hide
- if (show == !(self.toolbar.hidden)) {
- return;
- }
-
- if (show) {
- self.toolbar.hidden = NO;
-
- if (locationbarVisible) {
- // locationBar at the bottom, move locationBar up
- // put toolBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= FOOTER_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
-
- toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
- self.toolbar.frame = toolbarFrame;
- } else {
- // no locationBar, so put toolBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= TOOLBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- toolbarFrame.origin.y = webViewBounds.size.height;
- self.toolbar.frame = toolbarFrame;
- }
- } else {
- self.toolbar.hidden = YES;
-
- if (locationbarVisible) {
- // locationBar is on top of toolBar, hide toolBar
- // put locationBar at the bottom
-
- // webView take up whole height less locationBar height
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- // move locationBar down
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- } else {
- // no locationBar, expand webView to screen dimensions
-
- CGRect webViewBounds = self.view.bounds;
- self.webView.frame = webViewBounds;
- }
- }
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-}
-
-- (void)viewDidUnload
-{
- [self.webView loadHTMLString:nil baseURL:nil];
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
- [super viewDidUnload];
-}
-
-- (void)close
-{
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
-
- if ([self respondsToSelector:@selector(presentingViewController)]) {
- [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- self.currentURL = nil;
-
- if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserExit)]) {
- [self.navigationDelegate browserExit];
- }
-}
-
-- (void)navigateTo:(NSURL*)url
-{
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
-
- if (_userAgentLockToken != 0) {
- [self.webView loadRequest:request];
- } else {
- [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
- _userAgentLockToken = lockToken;
- [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
- [self.webView loadRequest:request];
- }];
- }
-}
-
-- (void)goBack:(id)sender
-{
- [self.webView goBack];
-}
-
-- (void)goForward:(id)sender
-{
- [self.webView goForward];
-}
-
-#pragma mark UIWebViewDelegate
-
-- (void)webViewDidStartLoad:(UIWebView*)theWebView
-{
- // loading url, start spinner, update back/forward
-
- self.addressLabel.text = @"Loading...";
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
-
- [self.spinner startAnimating];
-
- return [self.navigationDelegate webViewDidStartLoad:theWebView];
-}
-
-- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
-
- if (isTopLevelNavigation) {
- self.currentURL = request.URL;
- }
- return [self.navigationDelegate webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- // update url, stop spinner, update back/forward
-
- self.addressLabel.text = [self.currentURL absoluteString];
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
-
- [self.spinner stopAnimating];
-
- // Work around a bug where the first time a PDF is opened, all UIWebViews
- // reload their User-Agent from NSUserDefaults.
- // This work-around makes the following assumptions:
- // 1. The app has only a single Cordova Webview. If not, then the app should
- // take it upon themselves to load a PDF in the background as a part of
- // their start-up flow.
- // 2. That the PDF does not require any additional network requests. We change
- // the user-agent here back to that of the CDVViewController, so requests
- // from it must pass through its white-list. This *does* break PDFs that
- // contain links to other remote PDF/websites.
- // More info at https://issues.apache.org/jira/browse/CB-2225
- BOOL isPDF = [@"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
- if (isPDF) {
- [CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
- }
-
- [self.navigationDelegate webViewDidFinishLoad:theWebView];
-}
-
-- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- // log fail message, stop spinner, update back/forward
- NSLog(@"webView:didFailLoadWithError - %@", [error localizedDescription]);
-
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
- [self.spinner stopAnimating];
-
- self.addressLabel.text = @"Load Error";
-
- [self.navigationDelegate webView:theWebView didFailLoadWithError:error];
-}
-
-#pragma mark CDVScreenOrientationDelegate
-
-- (BOOL)shouldAutorotate
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
- return [self.orientationDelegate shouldAutorotate];
- }
- return YES;
-}
-
-- (NSUInteger)supportedInterfaceOrientations
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
- return [self.orientationDelegate supportedInterfaceOrientations];
- }
-
- return 1 << UIInterfaceOrientationPortrait;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
- return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
- }
-
- return YES;
-}
-
-@end
-
-@implementation CDVInAppBrowserOptions
-
-- (id)init
-{
- if (self = [super init]) {
- // default values
- self.location = YES;
- self.toolbar = YES;
- self.closebuttoncaption = nil;
-
- self.enableviewportscale = NO;
- self.mediaplaybackrequiresuseraction = NO;
- self.allowinlinemediaplayback = NO;
- self.keyboarddisplayrequiresuseraction = YES;
- self.suppressesincrementalrendering = NO;
- self.hidden = NO;
- }
-
- return self;
-}
-
-+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options
-{
- CDVInAppBrowserOptions* obj = [[CDVInAppBrowserOptions alloc] init];
-
- // NOTE: this parsing does not handle quotes within values
- NSArray* pairs = [options componentsSeparatedByString:@","];
-
- // parse keys and values, set the properties
- for (NSString* pair in pairs) {
- NSArray* keyvalue = [pair componentsSeparatedByString:@"="];
-
- if ([keyvalue count] == 2) {
- NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
- NSString* value = [keyvalue objectAtIndex:1];
- NSString* value_lc = [value lowercaseString];
-
- BOOL isBoolean = [value_lc isEqualToString:@"yes"] || [value_lc isEqualToString:@"no"];
- NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
- [numberFormatter setAllowsFloats:YES];
- BOOL isNumber = [numberFormatter numberFromString:value_lc] != nil;
-
- // set the property according to the key name
- if ([obj respondsToSelector:NSSelectorFromString(key)]) {
- if (isNumber) {
- [obj setValue:[numberFormatter numberFromString:value_lc] forKey:key];
- } else if (isBoolean) {
- [obj setValue:[NSNumber numberWithBool:[value_lc isEqualToString:@"yes"]] forKey:key];
- } else {
- [obj setValue:value forKey:key];
- }
- }
- }
- }
-
- return obj;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
deleted file mode 100644
index caf0798..0000000
--- a/CordovaLib/Classes/CDVLocation.h
+++ /dev/null
@@ -1,104 +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.
- */
-
-#import <UIKit/UIKit.h>
-#import <CoreLocation/CoreLocation.h>
-#import "CDVPlugin.h"
-
-enum CDVHeadingStatus {
- HEADINGSTOPPED = 0,
- HEADINGSTARTING,
- HEADINGRUNNING,
- HEADINGERROR
-};
-typedef NSUInteger CDVHeadingStatus;
-
-enum CDVLocationStatus {
- PERMISSIONDENIED = 1,
- POSITIONUNAVAILABLE,
- TIMEOUT
-};
-typedef NSUInteger CDVLocationStatus;
-
-// simple object to keep track of heading information
-@interface CDVHeadingData : NSObject {}
-
-@property (nonatomic, assign) CDVHeadingStatus headingStatus;
-@property (nonatomic, strong) CLHeading* headingInfo;
-@property (nonatomic, strong) NSMutableArray* headingCallbacks;
-@property (nonatomic, copy) NSString* headingFilter;
-@property (nonatomic, strong) NSDate* headingTimestamp;
-@property (assign) NSInteger timeout;
-
-@end
-
-// simple object to keep track of location information
-@interface CDVLocationData : NSObject {
- CDVLocationStatus locationStatus;
- NSMutableArray* locationCallbacks;
- NSMutableDictionary* watchCallbacks;
- CLLocation* locationInfo;
-}
-
-@property (nonatomic, assign) CDVLocationStatus locationStatus;
-@property (nonatomic, strong) CLLocation* locationInfo;
-@property (nonatomic, strong) NSMutableArray* locationCallbacks;
-@property (nonatomic, strong) NSMutableDictionary* watchCallbacks;
-
-@end
-
-@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{
- @private BOOL __locationStarted;
- @private BOOL __highAccuracyEnabled;
- CDVHeadingData* headingData;
- CDVLocationData* locationData;
-}
-
-@property (nonatomic, strong) CLLocationManager* locationManager;
-@property (strong) CDVHeadingData* headingData;
-@property (nonatomic, strong) CDVLocationData* locationData;
-
-- (BOOL)hasHeadingSupport;
-- (void)getLocation:(CDVInvokedUrlCommand*)command;
-- (void)addWatch:(CDVInvokedUrlCommand*)command;
-- (void)clearWatch:(CDVInvokedUrlCommand*)command;
-- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback;
-- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message;
-- (void)startLocation:(BOOL)enableHighAccuracy;
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateToLocation:(CLLocation*)newLocation
- fromLocation:(CLLocation*)oldLocation;
-
-- (void)locationManager:(CLLocationManager*)manager
- didFailWithError:(NSError*)error;
-
-- (BOOL)isLocationServicesEnabled;
-
-- (void)getHeading:(CDVInvokedUrlCommand*)command;
-- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain;
-- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command;
-- (void)stopHeading:(CDVInvokedUrlCommand*)command;
-- (void)startHeadingWithFilter:(CLLocationDegrees)filter;
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateHeading:(CLHeading*)heading;
-
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
deleted file mode 100644
index ed9ec26..0000000
--- a/CordovaLib/Classes/CDVLocation.m
+++ /dev/null
@@ -1,623 +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.
- */
-
-#import "CDVLocation.h"
-#import "NSArray+Comparisons.h"
-
-#pragma mark Constants
-
-#define kPGLocationErrorDomain @"kPGLocationErrorDomain"
-#define kPGLocationDesiredAccuracyKey @"desiredAccuracy"
-#define kPGLocationForcePromptKey @"forcePrompt"
-#define kPGLocationDistanceFilterKey @"distanceFilter"
-#define kPGLocationFrequencyKey @"frequency"
-
-#pragma mark -
-#pragma mark Categories
-
-@interface NSError (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-@interface CLLocation (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-@interface CLHeading (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-#pragma mark -
-#pragma mark CDVHeadingData
-
-@implementation CDVHeadingData
-
-@synthesize headingStatus, headingInfo, headingCallbacks, headingFilter, headingTimestamp, timeout;
-- (CDVHeadingData*)init
-{
- self = (CDVHeadingData*)[super init];
- if (self) {
- self.headingStatus = HEADINGSTOPPED;
- self.headingInfo = nil;
- self.headingCallbacks = nil;
- self.headingFilter = nil;
- self.headingTimestamp = nil;
- self.timeout = 10;
- }
- return self;
-}
-
-@end
-
-@implementation CDVLocationData
-
-@synthesize locationStatus, locationInfo, locationCallbacks, watchCallbacks;
-- (CDVLocationData*)init
-{
- self = (CDVLocationData*)[super init];
- if (self) {
- self.locationInfo = nil;
- self.locationCallbacks = nil;
- self.watchCallbacks = nil;
- }
- return self;
-}
-
-@end
-
-#pragma mark -
-#pragma mark CDVLocation
-
-@implementation CDVLocation
-
-@synthesize locationManager, headingData, locationData;
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVLocation*)[super initWithWebView:(UIWebView*)theWebView];
- if (self) {
- self.locationManager = [[CLLocationManager alloc] init];
- self.locationManager.delegate = self; // Tells the location manager to send updates to this object
- __locationStarted = NO;
- __highAccuracyEnabled = NO;
- self.headingData = nil;
- self.locationData = nil;
- }
- return self;
-}
-
-- (BOOL)hasHeadingSupport
-{
- BOOL headingInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(headingAvailable)]; // iOS 3.x
- BOOL headingClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(headingAvailable)]; // iOS 4.x
-
- if (headingInstancePropertyAvailable) { // iOS 3.x
- return [(id)self.locationManager headingAvailable];
- } else if (headingClassPropertyAvailable) { // iOS 4.x
- return [CLLocationManager headingAvailable];
- } else { // iOS 2.x
- return NO;
- }
-}
-
-- (BOOL)isAuthorized
-{
- BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
-
- if (authorizationStatusClassPropertyAvailable) {
- NSUInteger authStatus = [CLLocationManager authorizationStatus];
- return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
- }
-
- // by default, assume YES (for iOS < 4.2)
- return YES;
-}
-
-- (BOOL)isLocationServicesEnabled
-{
- BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
- BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
-
- if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
- return [CLLocationManager locationServicesEnabled];
- } else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x
- return [(id)self.locationManager locationServicesEnabled];
- } else {
- return NO;
- }
-}
-
-- (void)startLocation:(BOOL)enableHighAccuracy
-{
- if (![self isLocationServicesEnabled]) {
- [self returnLocationError:PERMISSIONDENIED withMessage:@"Location services are not enabled."];
- return;
- }
- if (![self isAuthorized]) {
- NSString* message = nil;
- BOOL authStatusAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
- if (authStatusAvailable) {
- NSUInteger code = [CLLocationManager authorizationStatus];
- if (code == kCLAuthorizationStatusNotDetermined) {
- // could return POSITION_UNAVAILABLE but need to coordinate with other platforms
- message = @"User undecided on application's use of location services.";
- } else if (code == kCLAuthorizationStatusRestricted) {
- message = @"Application's use of location services is restricted.";
- }
- }
- // PERMISSIONDENIED is only PositionError that makes sense when authorization denied
- [self returnLocationError:PERMISSIONDENIED withMessage:message];
-
- return;
- }
-
- // Tell the location manager to start notifying us of location updates. We
- // first stop, and then start the updating to ensure we get at least one
- // update, even if our location did not change.
- [self.locationManager stopUpdatingLocation];
- [self.locationManager startUpdatingLocation];
- __locationStarted = YES;
- if (enableHighAccuracy) {
- __highAccuracyEnabled = YES;
- // Set to distance filter to "none" - which should be the minimum for best results.
- self.locationManager.distanceFilter = kCLDistanceFilterNone;
- // Set desired accuracy to Best.
- self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
- } else {
- __highAccuracyEnabled = NO;
- // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary.
- self.locationManager.distanceFilter = 10;
- self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
- }
-}
-
-- (void)_stopLocation
-{
- if (__locationStarted) {
- if (![self isLocationServicesEnabled]) {
- return;
- }
-
- [self.locationManager stopUpdatingLocation];
- __locationStarted = NO;
- __highAccuracyEnabled = NO;
- }
-}
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateToLocation:(CLLocation*)newLocation
- fromLocation:(CLLocation*)oldLocation
-{
- CDVLocationData* cData = self.locationData;
-
- cData.locationInfo = newLocation;
- if (self.locationData.locationCallbacks.count > 0) {
- for (NSString* callbackId in self.locationData.locationCallbacks) {
- [self returnLocationInfo:callbackId andKeepCallback:NO];
- }
-
- [self.locationData.locationCallbacks removeAllObjects];
- }
- if (self.locationData.watchCallbacks.count > 0) {
- for (NSString* timerId in self.locationData.watchCallbacks) {
- [self returnLocationInfo:[self.locationData.watchCallbacks objectForKey:timerId] andKeepCallback:YES];
- }
- } else {
- // No callbacks waiting on us anymore, turn off listening.
- [self _stopLocation];
- }
-}
-
-- (void)getLocation:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- BOOL enableHighAccuracy = [[command.arguments objectAtIndex:0] boolValue];
-
- if ([self isLocationServicesEnabled] == NO) {
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
- [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
- [posError setObject:@"Location services are disabled." forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!self.locationData) {
- self.locationData = [[CDVLocationData alloc] init];
- }
- CDVLocationData* lData = self.locationData;
- if (!lData.locationCallbacks) {
- lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
- }
-
- if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
- // add the callbackId into the array so we can call back when get data
- if (callbackId != nil) {
- [lData.locationCallbacks addObject:callbackId];
- }
- // Tell the location manager to start notifying us of heading updates
- [self startLocation:enableHighAccuracy];
- } else {
- [self returnLocationInfo:callbackId andKeepCallback:NO];
- }
- }
-}
-
-- (void)addWatch:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* timerId = [command.arguments objectAtIndex:0];
- BOOL enableHighAccuracy = [[command.arguments objectAtIndex:1] boolValue];
-
- if (!self.locationData) {
- self.locationData = [[CDVLocationData alloc] init];
- }
- CDVLocationData* lData = self.locationData;
-
- if (!lData.watchCallbacks) {
- lData.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1];
- }
-
- // add the callbackId into the dictionary so we can call back whenever get data
- [lData.watchCallbacks setObject:callbackId forKey:timerId];
-
- if ([self isLocationServicesEnabled] == NO) {
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
- [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
- [posError setObject:@"Location services are disabled." forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
- // Tell the location manager to start notifying us of location updates
- [self startLocation:enableHighAccuracy];
- }
- }
-}
-
-- (void)clearWatch:(CDVInvokedUrlCommand*)command
-{
- NSString* timerId = [command.arguments objectAtIndex:0];
-
- if (self.locationData && self.locationData.watchCallbacks && [self.locationData.watchCallbacks objectForKey:timerId]) {
- [self.locationData.watchCallbacks removeObjectForKey:timerId];
- }
-}
-
-- (void)stopLocation:(CDVInvokedUrlCommand*)command
-{
- [self _stopLocation];
-}
-
-- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback
-{
- CDVPluginResult* result = nil;
- CDVLocationData* lData = self.locationData;
-
- if (lData && !lData.locationInfo) {
- // return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE];
- } else if (lData && lData.locationInfo) {
- CLLocation* lInfo = lData.locationInfo;
- NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:8];
- NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970] * 1000)];
- [returnInfo setObject:timestamp forKey:@"timestamp"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.speed] forKey:@"velocity"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.horizontalAccuracy] forKey:@"accuracy"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.course] forKey:@"heading"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.altitude] forKey:@"altitude"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
- [result setKeepCallbackAsBool:keepCallback];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message
-{
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-
- [posError setObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
- [posError setObject:message ? message:@"" forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
-
- for (NSString* callbackId in self.locationData.locationCallbacks) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
- [self.locationData.locationCallbacks removeAllObjects];
-
- for (NSString* callbackId in self.locationData.watchCallbacks) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-// called to get the current heading
-// Will call location manager to startUpdatingHeading if necessary
-
-- (void)getHeading:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
- NSNumber* filter = [options valueForKey:@"filter"];
-
- if (filter) {
- [self watchHeadingFilter:command];
- return;
- }
- if ([self hasHeadingSupport] == NO) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- // heading retrieval does is not affected by disabling locationServices and authorization of app for location services
- if (!self.headingData) {
- self.headingData = [[CDVHeadingData alloc] init];
- }
- CDVHeadingData* hData = self.headingData;
-
- if (!hData.headingCallbacks) {
- hData.headingCallbacks = [NSMutableArray arrayWithCapacity:1];
- }
- // add the callbackId into the array so we can call back when get data
- [hData.headingCallbacks addObject:callbackId];
-
- if ((hData.headingStatus != HEADINGRUNNING) && (hData.headingStatus != HEADINGERROR)) {
- // Tell the location manager to start notifying us of heading updates
- [self startHeadingWithFilter:0.2];
- } else {
- [self returnHeadingInfo:callbackId keepCallback:NO];
- }
- }
-}
-
-// called to request heading updates when heading changes by a certain amount (filter)
-- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
- NSNumber* filter = [options valueForKey:@"filter"];
- CDVHeadingData* hData = self.headingData;
-
- if ([self hasHeadingSupport] == NO) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!hData) {
- self.headingData = [[CDVHeadingData alloc] init];
- hData = self.headingData;
- }
- if (hData.headingStatus != HEADINGRUNNING) {
- // Tell the location manager to start notifying us of heading updates
- [self startHeadingWithFilter:[filter doubleValue]];
- } else {
- // if already running check to see if due to existing watch filter
- if (hData.headingFilter && ![hData.headingFilter isEqualToString:callbackId]) {
- // new watch filter being specified
- // send heading data one last time to clear old successCallback
- [self returnHeadingInfo:hData.headingFilter keepCallback:NO];
- }
- }
- // save the new filter callback and update the headingFilter setting
- hData.headingFilter = callbackId;
- // check if need to stop and restart in order to change value???
- self.locationManager.headingFilter = [filter doubleValue];
- }
-}
-
-- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain
-{
- CDVPluginResult* result = nil;
- CDVHeadingData* hData = self.headingData;
-
- self.headingData.headingTimestamp = [NSDate date];
-
- if (hData && (hData.headingStatus == HEADINGERROR)) {
- // return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- } else if (hData && (hData.headingStatus == HEADINGRUNNING) && hData.headingInfo) {
- // if there is heading info, return it
- CLHeading* hInfo = hData.headingInfo;
- NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:4];
- NSNumber* timestamp = [NSNumber numberWithDouble:([hInfo.timestamp timeIntervalSince1970] * 1000)];
- [returnInfo setObject:timestamp forKey:@"timestamp"];
- [returnInfo setObject:[NSNumber numberWithDouble:hInfo.magneticHeading] forKey:@"magneticHeading"];
- id trueHeading = __locationStarted ? (id)[NSNumber numberWithDouble : hInfo.trueHeading] : (id)[NSNull null];
- [returnInfo setObject:trueHeading forKey:@"trueHeading"];
- [returnInfo setObject:[NSNumber numberWithDouble:hInfo.headingAccuracy] forKey:@"headingAccuracy"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
- [result setKeepCallbackAsBool:bRetain];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)stopHeading:(CDVInvokedUrlCommand*)command
-{
- // CDVHeadingData* hData = self.headingData;
- if (self.headingData && (self.headingData.headingStatus != HEADINGSTOPPED)) {
- if (self.headingData.headingFilter) {
- // callback one last time to clear callback
- [self returnHeadingInfo:self.headingData.headingFilter keepCallback:NO];
- self.headingData.headingFilter = nil;
- }
- [self.locationManager stopUpdatingHeading];
- NSLog(@"heading STOPPED");
- self.headingData = nil;
- }
-}
-
-// helper method to check the orientation and start updating headings
-- (void)startHeadingWithFilter:(CLLocationDegrees)filter
-{
- // FYI UIDeviceOrientation and CLDeviceOrientation enums are currently the same
- self.locationManager.headingOrientation = (CLDeviceOrientation)self.viewController.interfaceOrientation;
- self.locationManager.headingFilter = filter;
- [self.locationManager startUpdatingHeading];
- self.headingData.headingStatus = HEADINGSTARTING;
-}
-
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager
-{
- return YES;
-}
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateHeading:(CLHeading*)heading
-{
- CDVHeadingData* hData = self.headingData;
-
- // normally we would clear the delegate to stop getting these notifications, but
- // we are sharing a CLLocationManager to get location data as well, so we do a nil check here
- // ideally heading and location should use their own CLLocationManager instances
- if (hData == nil) {
- return;
- }
-
- // save the data for next call into getHeadingData
- hData.headingInfo = heading;
- BOOL bTimeout = NO;
- if (!hData.headingFilter && hData.headingTimestamp) {
- bTimeout = fabs([hData.headingTimestamp timeIntervalSinceNow]) > hData.timeout;
- }
-
- if (hData.headingStatus == HEADINGSTARTING) {
- hData.headingStatus = HEADINGRUNNING; // so returnHeading info will work
-
- // this is the first update
- for (NSString* callbackId in hData.headingCallbacks) {
- [self returnHeadingInfo:callbackId keepCallback:NO];
- }
-
- [hData.headingCallbacks removeAllObjects];
- }
- if (hData.headingFilter) {
- [self returnHeadingInfo:hData.headingFilter keepCallback:YES];
- } else if (bTimeout) {
- [self stopHeading:nil];
- }
- hData.headingStatus = HEADINGRUNNING; // to clear any error
-}
-
-- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
-{
- NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]);
-
- // Compass Error
- if ([error code] == kCLErrorHeadingFailure) {
- CDVHeadingData* hData = self.headingData;
- if (hData) {
- if (hData.headingStatus == HEADINGSTARTING) {
- // heading error during startup - report error
- for (NSString* callbackId in hData.headingCallbacks) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
- [hData.headingCallbacks removeAllObjects];
- } // else for frequency watches next call to getCurrentHeading will report error
- if (hData.headingFilter) {
- CDVPluginResult* resultFilter = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- [self.commandDelegate sendPluginResult:resultFilter callbackId:hData.headingFilter];
- }
- hData.headingStatus = HEADINGERROR;
- }
- }
- // Location Error
- else {
- CDVLocationData* lData = self.locationData;
- if (lData && __locationStarted) {
- // TODO: probably have to once over the various error codes and return one of:
- // PositionError.PERMISSION_DENIED = 1;
- // PositionError.POSITION_UNAVAILABLE = 2;
- // PositionError.TIMEOUT = 3;
- NSUInteger positionError = POSITIONUNAVAILABLE;
- if (error.code == kCLErrorDenied) {
- positionError = PERMISSIONDENIED;
- }
- [self returnLocationError:positionError withMessage:[error localizedDescription]];
- }
- }
-
- [self.locationManager stopUpdatingLocation];
- __locationStarted = NO;
-}
-
-- (void)dealloc
-{
- self.locationManager.delegate = nil;
-}
-
-- (void)onReset
-{
- [self _stopLocation];
- [self.locationManager stopUpdatingHeading];
- self.headingData = nil;
-}
-
-@end
-
-#pragma mark -
-#pragma mark CLLocation(JSONMethods)
-
-@implementation CLLocation (JSONMethods)
-
-- (NSString*)JSONRepresentation
-{
- return [NSString stringWithFormat:
- @"{ timestamp: %.00f, \
- coords: { latitude: %f, longitude: %f, altitude: %.02f, heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
- }",
- [self.timestamp timeIntervalSince1970] * 1000.0,
- self.coordinate.latitude,
- self.coordinate.longitude,
- self.altitude,
- self.course,
- self.speed,
- self.horizontalAccuracy,
- self.verticalAccuracy
- ];
-}
-
-@end
-
-#pragma mark NSError(JSONMethods)
-
-@implementation NSError (JSONMethods)
-
-- (NSString*)JSONRepresentation
-{
- return [NSString stringWithFormat:
- @"{ code: %d, message: '%@'}",
- self.code,
- [self localizedDescription]
- ];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVNotification.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.h b/CordovaLib/Classes/CDVNotification.h
deleted file mode 100644
index 5b5b89f..0000000
--- a/CordovaLib/Classes/CDVNotification.h
+++ /dev/null
@@ -1,37 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
-#import <AudioToolbox/AudioServices.h>
-#import "CDVPlugin.h"
-
-@interface CDVNotification : CDVPlugin <UIAlertViewDelegate>{}
-
-- (void)alert:(CDVInvokedUrlCommand*)command;
-- (void)confirm:(CDVInvokedUrlCommand*)command;
-- (void)prompt:(CDVInvokedUrlCommand*)command;
-- (void)vibrate:(CDVInvokedUrlCommand*)command;
-
-@end
-
-@interface CDVAlertView : UIAlertView {}
-@property (nonatomic, copy) NSString* callbackId;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.m b/CordovaLib/Classes/CDVNotification.m
deleted file mode 100644
index 464eb1f..0000000
--- a/CordovaLib/Classes/CDVNotification.m
+++ /dev/null
@@ -1,130 +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.
- */
-
-#import "CDVNotification.h"
-#import "NSDictionary+Extensions.h"
-
-#define DIALOG_TYPE_ALERT @"alert"
-#define DIALOG_TYPE_PROMPT @"prompt"
-
-@implementation CDVNotification
-
-/*
- * showDialogWithMessage - Common method to instantiate the alert view for alert, confirm, and prompt notifications.
- * Parameters:
- * message The alert view message.
- * title The alert view title.
- * buttons The array of customized strings for the buttons.
- * defaultText The input text for the textbox (if textbox exists).
- * callbackId The commmand callback id.
- * dialogType The type of alert view [alert | prompt].
- */
-- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
-{
- CDVAlertView* alertView = [[CDVAlertView alloc]
- initWithTitle:title
- message:message
- delegate:self
- cancelButtonTitle:nil
- otherButtonTitles:nil];
-
- alertView.callbackId = callbackId;
-
- int count = [buttons count];
-
- for (int n = 0; n < count; n++) {
- [alertView addButtonWithTitle:[buttons objectAtIndex:n]];
- }
-
- if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
- alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
- UITextField* textField = [alertView textFieldAtIndex:0];
- textField.text = defaultText;
- }
-
- [alertView show];
-}
-
-- (void)alert:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSString* buttons = [command argumentAtIndex:2];
-
- [self showDialogWithMessage:message title:title buttons:@[buttons] defaultText:nil callbackId:callbackId dialogType:DIALOG_TYPE_ALERT];
-}
-
-- (void)confirm:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSArray* buttons = [command argumentAtIndex:2];
-
- [self showDialogWithMessage:message title:title buttons:buttons defaultText:nil callbackId:callbackId dialogType:DIALOG_TYPE_ALERT];
-}
-
-- (void)prompt:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSArray* buttons = [command argumentAtIndex:2];
- NSString* defaultText = [command argumentAtIndex:3];
-
- [self showDialogWithMessage:message title:title buttons:buttons defaultText:defaultText callbackId:callbackId dialogType:DIALOG_TYPE_PROMPT];
-}
-
-/**
- * Callback invoked when an alert dialog's buttons are clicked.
- */
-- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
- CDVAlertView* cdvAlertView = (CDVAlertView*)alertView;
- CDVPluginResult* result;
-
- // Determine what gets returned to JS based on the alert view type.
- if (alertView.alertViewStyle == UIAlertViewStyleDefault) {
- // For alert and confirm, return button index as int back to JS.
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:buttonIndex + 1];
- } else {
- // For prompt, return button index and input text back to JS.
- NSString* value0 = [[alertView textFieldAtIndex:0] text];
- NSDictionary* info = @{
- @"buttonIndex":@(buttonIndex + 1),
- @"input1":(value0 ? value0 : [NSNull null])
- };
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
- }
- [self.commandDelegate sendPluginResult:result callbackId:cdvAlertView.callbackId];
-}
-
-- (void)vibrate:(CDVInvokedUrlCommand*)command
-{
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
-}
-
-@end
-
-@implementation CDVAlertView
-
-@synthesize callbackId;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVSplashScreen.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.h b/CordovaLib/Classes/CDVSplashScreen.h
deleted file mode 100644
index 704ab43..0000000
--- a/CordovaLib/Classes/CDVSplashScreen.h
+++ /dev/null
@@ -1,33 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-@interface CDVSplashScreen : CDVPlugin {
- UIActivityIndicatorView* _activityView;
- UIImageView* _imageView;
- NSString* _curImageName;
- BOOL _visible;
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command;
-- (void)hide:(CDVInvokedUrlCommand*)command;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m
deleted file mode 100644
index fdb79fa..0000000
--- a/CordovaLib/Classes/CDVSplashScreen.m
+++ /dev/null
@@ -1,230 +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.
- */
-
-#import "CDVSplashScreen.h"
-
-#define kSplashScreenDurationDefault 0.25f
-
-@implementation CDVSplashScreen
-
-- (void)pluginInitialize
-{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:self.webView];
-
- [self setVisible:YES];
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command
-{
- [self setVisible:YES];
-}
-
-- (void)hide:(CDVInvokedUrlCommand*)command
-{
- [self setVisible:NO];
-}
-
-- (void)pageDidLoad
-{
- id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:@"AutoHideSplashScreen"];
-
- // if value is missing, default to yes
- if ((autoHideSplashScreenValue == nil) || [autoHideSplashScreenValue boolValue]) {
- [self setVisible:NO];
- }
-}
-
-- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
-{
- [self updateImage];
-}
-
-- (void)createViews
-{
- /*
- * The Activity View is the top spinning throbber in the status/battery bar. We init it with the default Grey Style.
- *
- * whiteLarge = UIActivityIndicatorViewStyleWhiteLarge
- * white = UIActivityIndicatorViewStyleWhite
- * gray = UIActivityIndicatorViewStyleGray
- *
- */
- NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:@"TopActivityIndicator"];
- UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray;
-
- if ([topActivityIndicator isEqualToString:@"whiteLarge"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhiteLarge;
- } else if ([topActivityIndicator isEqualToString:@"white"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhite;
- } else if ([topActivityIndicator isEqualToString:@"gray"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray;
- }
-
- UIView* parentView = self.viewController.view;
- parentView.userInteractionEnabled = NO; // disable user interaction while splashscreen is shown
- _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:topActivityIndicatorStyle];
- _activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2);
- _activityView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
- | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin;
- [_activityView startAnimating];
-
- // Set the frame & image later.
- _imageView = [[UIImageView alloc] init];
- [parentView addSubview:_imageView];
-
- id showSplashScreenSpinnerValue = [self.commandDelegate.settings objectForKey:@"ShowSplashScreenSpinner"];
- // backwards compatibility - if key is missing, default to true
- if ((showSplashScreenSpinnerValue == nil) || [showSplashScreenSpinnerValue boolValue]) {
- [parentView addSubview:_activityView];
- }
-
- // Frame is required when launching in portrait mode.
- // Bounds for landscape since it captures the rotation.
- [parentView addObserver:self forKeyPath:@"frame" options:0 context:nil];
- [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];
-
- [self updateImage];
-}
-
-- (void)destroyViews
-{
- [_imageView removeFromSuperview];
- [_activityView removeFromSuperview];
- _imageView = nil;
- _activityView = nil;
- _curImageName = nil;
-
- self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion
- [self.viewController.view removeObserver:self forKeyPath:@"frame"];
- [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
-}
-
-// Sets the view's frame and image.
-- (void)updateImage
-{
- UIInterfaceOrientation orientation = self.viewController.interfaceOrientation;
-
- // Use UILaunchImageFile if specified in plist. Otherwise, use Default.
- NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
-
- if (imageName) {
- imageName = [imageName stringByDeletingPathExtension];
- } else {
- imageName = @"Default";
- }
-
- if (CDV_IsIPhone5()) {
- imageName = [imageName stringByAppendingString:@"-568h"];
- } else if (CDV_IsIPad()) {
- switch (orientation) {
- case UIInterfaceOrientationLandscapeLeft:
- case UIInterfaceOrientationLandscapeRight:
- imageName = [imageName stringByAppendingString:@"-Landscape"];
- break;
-
- case UIInterfaceOrientationPortrait:
- case UIInterfaceOrientationPortraitUpsideDown:
- default:
- imageName = [imageName stringByAppendingString:@"-Portrait"];
- break;
- }
- }
-
- if (![imageName isEqualToString:_curImageName]) {
- UIImage* img = [UIImage imageNamed:imageName];
- _imageView.image = img;
- _curImageName = imageName;
- }
-
- // Check that splash screen's image exists before updating bounds
- if (_imageView.image) {
- [self updateBounds];
- } else {
- NSLog(@"WARNING: The splashscreen image named %@ was not found", imageName);
- }
-}
-
-- (void)updateBounds
-{
- UIImage* img = _imageView.image;
- CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height);
-
- CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
-
- // There's a special case when the image is the size of the screen.
- if (CGSizeEqualToSize(screenSize, imgBounds.size)) {
- CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
- imgBounds.origin.y -= statusFrame.size.height;
- } else {
- CGRect viewBounds = self.viewController.view.bounds;
- CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
- CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;
- // This matches the behaviour of the native splash screen.
- CGFloat ratio;
- if (viewAspect > imgAspect) {
- ratio = viewBounds.size.width / imgBounds.size.width;
- } else {
- ratio = viewBounds.size.height / imgBounds.size.height;
- }
- imgBounds.size.height *= ratio;
- imgBounds.size.width *= ratio;
- }
-
- _imageView.frame = imgBounds;
-}
-
-- (void)setVisible:(BOOL)visible
-{
- if (visible == _visible) {
- return;
- }
- _visible = visible;
-
- id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:@"FadeSplashScreen"];
- id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:@"FadeSplashScreenDuration"];
-
- float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
-
- if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue]) {
- fadeDuration = 0;
- }
-
- // Never animate the showing of the splash screen.
- if (visible) {
- if (_imageView == nil) {
- [self createViews];
- }
- } else if (fadeDuration == 0) {
- [self destroyViews];
- } else {
- [UIView transitionWithView:self.viewController.view
- duration:fadeDuration
- options:UIViewAnimationOptionTransitionNone
- animations:^(void) {
- [_imageView setAlpha:0];
- [_activityView setAlpha:0];
- }
-
- completion:^(BOOL finished) {
- [self destroyViews];
- }];
- }
-}
-
-@end
[43/50] [abbrv] ios commit: [CB-3701] Removed Capture.bundle from
default project template for 3.0.0
Posted by ag...@apache.org.
[CB-3701] Removed Capture.bundle from default project template for 3.0.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9ca74218
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9ca74218
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9ca74218
Branch: refs/heads/master
Commit: 9ca74218088d04f0f76e41c192554c3f02b21842
Parents: 7569c3e
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Jun 25 15:23:42 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Jun 25 15:23:42 2013 -0700
----------------------------------------------------------------------
.../project/__TESTING__.xcodeproj/project.pbxproj | 4 ----
.../Resources/Capture.bundle/controls_bg.png | Bin 955 -> 0 bytes
.../Resources/Capture.bundle/controls_bg@2x.png | Bin 971 -> 0 bytes
.../Capture.bundle/controls_bg@2x~ipad.png | Bin 2858 -> 0 bytes
.../Resources/Capture.bundle/controls_bg~ipad.png | Bin 969 -> 0 bytes
.../Capture.bundle/microphone-568h@2x~iphone.png | Bin 531673 -> 0 bytes
.../Resources/Capture.bundle/microphone.png | Bin 72226 -> 0 bytes
.../Resources/Capture.bundle/microphone@2x.png | Bin 282409 -> 0 bytes
.../Capture.bundle/microphone@2x~ipad.png | Bin 911582 -> 0 bytes
.../Resources/Capture.bundle/microphone~ipad.png | Bin 393975 -> 0 bytes
.../Resources/Capture.bundle/record_button.png | Bin 5852 -> 0 bytes
.../Resources/Capture.bundle/record_button@2x.png | Bin 13875 -> 0 bytes
.../Capture.bundle/record_button@2x~ipad.png | Bin 15822 -> 0 bytes
.../Capture.bundle/record_button~ipad.png | Bin 7547 -> 0 bytes
.../Resources/Capture.bundle/recording_bg.png | Bin 973 -> 0 bytes
.../Resources/Capture.bundle/recording_bg@2x.png | Bin 990 -> 0 bytes
.../Capture.bundle/recording_bg@2x~ipad.png | Bin 1026 -> 0 bytes
.../Capture.bundle/recording_bg~ipad.png | Bin 996 -> 0 bytes
.../Resources/Capture.bundle/stop_button.png | Bin 5514 -> 0 bytes
.../Resources/Capture.bundle/stop_button@2x.png | Bin 12965 -> 0 bytes
.../Capture.bundle/stop_button@2x~ipad.png | Bin 14474 -> 0 bytes
.../Resources/Capture.bundle/stop_button~ipad.png | Bin 7119 -> 0 bytes
22 files changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index 8617ccb..4a2bf13 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -27,7 +27,6 @@
302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; };
302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; };
305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */; };
- 3072F99713A8081B00425683 /* Capture.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3072F99613A8081B00425683 /* Capture.bundle */; };
3088BBBD154F3926009F9C59 /* Default-Landscape@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 3088BBB7154F3926009F9C59 /* Default-Landscape@2x~ipad.png */; };
3088BBBE154F3926009F9C59 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 3088BBB8154F3926009F9C59 /* Default-Landscape~ipad.png */; };
3088BBBF154F3926009F9C59 /* Default-Portrait@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 3088BBB9154F3926009F9C59 /* Default-Portrait@2x~ipad.png */; };
@@ -91,7 +90,6 @@
302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
302D95F014D2391D003F00A1 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
- 3072F99613A8081B00425683 /* Capture.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Capture.bundle; sourceTree = "<group>"; };
3088BBB7154F3926009F9C59 /* Default-Landscape@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape@2x~ipad.png"; sourceTree = "<group>"; };
3088BBB8154F3926009F9C59 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape~ipad.png"; sourceTree = "<group>"; };
3088BBB9154F3926009F9C59 /* Default-Portrait@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait@2x~ipad.png"; sourceTree = "<group>"; };
@@ -215,7 +213,6 @@
30A0434514DC770100060A13 /* se.lproj */,
1F766FDB13BBADB100FB74C0 /* en.lproj */,
1F766FDE13BBADB100FB74C0 /* es.lproj */,
- 3072F99613A8081B00425683 /* Capture.bundle */,
308D052D1370CCF300D202BF /* icons */,
308D05311370CCF300D202BF /* splash */,
8D1107310486CEB800E47090 /* __TESTING__-Info.plist */,
@@ -384,7 +381,6 @@
308D05371370CCF300D202BF /* icon-72.png in Resources */,
308D05381370CCF300D202BF /* icon.png in Resources */,
308D05391370CCF300D202BF /* icon@2x.png in Resources */,
- 3072F99713A8081B00425683 /* Capture.bundle in Resources */,
1F766FE113BBADB100FB74C0 /* Localizable.strings in Resources */,
1F766FE213BBADB100FB74C0 /* Localizable.strings in Resources */,
302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg.png
deleted file mode 100644
index 784e9c7..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x.png
deleted file mode 100644
index 1e28c6d..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x~ipad.png
deleted file mode 100644
index d4e3483..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg@2x~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg~ipad.png
deleted file mode 100644
index efbef8a..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/controls_bg~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone-568h@2x~iphone.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone-568h@2x~iphone.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone-568h@2x~iphone.png
deleted file mode 100644
index 8e80f73..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone-568h@2x~iphone.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone.png
deleted file mode 100644
index 155b88c..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x.png
deleted file mode 100644
index 79ef16b..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x~ipad.png
deleted file mode 100644
index af1bbb2..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone@2x~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone~ipad.png
deleted file mode 100644
index ef1c472..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/microphone~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button.png
deleted file mode 100644
index ceb9589..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x.png
deleted file mode 100644
index d6ce302..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x~ipad.png
deleted file mode 100644
index 0ac2e67..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button@2x~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button~ipad.png
deleted file mode 100644
index d8e24a4..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/record_button~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg.png
deleted file mode 100644
index bafc087..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x.png
deleted file mode 100644
index 798490b..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x~ipad.png
deleted file mode 100644
index a1b7208..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg@2x~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg~ipad.png
deleted file mode 100644
index 3b467f6..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/recording_bg~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button.png
deleted file mode 100644
index 9c31838..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x.png
deleted file mode 100644
index 8cf657e..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x~ipad.png
deleted file mode 100644
index 88b606c..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button@2x~ipad.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ca74218/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button~ipad.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button~ipad.png b/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button~ipad.png
deleted file mode 100644
index 59bb7a5..0000000
Binary files a/bin/templates/project/__TESTING__/Resources/Capture.bundle/stop_button~ipad.png and /dev/null differ
[32/50] [abbrv] ios commit: removed device, capture, file,
filetransfer
Posted by ag...@apache.org.
removed device, capture, file, filetransfer
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/43d748ce
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/43d748ce
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/43d748ce
Branch: refs/heads/master
Commit: 43d748ceb7ff899f4107c43e2be627b2fb45da02
Parents: 48f3dd9
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 16:59:45 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:24 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 4 -
CordovaLib/Classes/CDVCapture.h | 118 --
CordovaLib/Classes/CDVCapture.m | 845 -----------
CordovaLib/Classes/CDVDevice.h | 30 -
CordovaLib/Classes/CDVDevice.m | 89 --
CordovaLib/Classes/CDVFile.h | 107 --
CordovaLib/Classes/CDVFile.m | 1426 ------------------
CordovaLib/Classes/CDVFileTransfer.h | 82 -
CordovaLib/Classes/CDVFileTransfer.m | 730 ---------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 34 +-
bin/templates/project/__TESTING__/config.xml | 12 -
11 files changed, 1 insertion(+), 3476 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 03c2a3e..cef896b 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,12 +25,8 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVCapture.h"
#import "CDVConnection.h"
#import "CDVDebug.h"
-#import "CDVDevice.h"
-#import "CDVFile.h"
-#import "CDVFileTransfer.h"
#import "CDVPluginResult.h"
#import "CDVReachability.h"
#import "CDVSound.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVCapture.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h
deleted file mode 100644
index afb82b4..0000000
--- a/CordovaLib/Classes/CDVCapture.h
+++ /dev/null
@@ -1,118 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <AVFoundation/AVFoundation.h>
-#import "CDVPlugin.h"
-#import "CDVFile.h"
-
-enum CDVCaptureError {
- CAPTURE_INTERNAL_ERR = 0,
- CAPTURE_APPLICATION_BUSY = 1,
- CAPTURE_INVALID_ARGUMENT = 2,
- CAPTURE_NO_MEDIA_FILES = 3,
- CAPTURE_NOT_SUPPORTED = 20
-};
-typedef NSUInteger CDVCaptureError;
-
-@interface CDVImagePicker : UIImagePickerController
-{
- NSString* callbackid;
- NSInteger quality;
- NSString* mimeType;
-}
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* mimeType;
-
-@end
-
-@interface CDVCapture : CDVPlugin <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
-{
- CDVImagePicker* pickerController;
- BOOL inUse;
-}
-@property BOOL inUse;
-- (void)captureAudio:(CDVInvokedUrlCommand*)command;
-- (void)captureImage:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId;
-- (void)captureVideo:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId;
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command;
-- (void)getFormatData:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-
-@end
-
-@interface CDVAudioNavigationController : UINavigationController
-
-@end
-
-/* AudioRecorderViewController is used to create a simple view for audio recording.
- * It is created from [Capture captureAudio]. It creates a very simple interface for
- * recording by presenting just a record/stop button and a Done button to close the view.
- * The recording time is displayed and recording for a specified duration is supported. When duration
- * is specified there is no UI to the user - recording just stops when the specified
- * duration is reached. The UI has been minimized to avoid localization.
- */
-@interface CDVAudioRecorderViewController : UIViewController <AVAudioRecorderDelegate>
-{
- CDVCaptureError errorCode;
- NSString* callbackId;
- NSNumber* duration;
- CDVCapture* captureCommand;
- UIBarButtonItem* doneButton;
- UIView* recordingView;
- UIButton* recordButton;
- UIImage* recordImage;
- UIImage* stopRecordImage;
- UILabel* timerLabel;
- AVAudioRecorder* avRecorder;
- AVAudioSession* avSession;
- CDVPluginResult* pluginResult;
- NSTimer* timer;
- BOOL isTimed;
-}
-@property (nonatomic) CDVCaptureError errorCode;
-@property (nonatomic, copy) NSString* callbackId;
-@property (nonatomic, copy) NSNumber* duration;
-@property (nonatomic, strong) CDVCapture* captureCommand;
-@property (nonatomic, strong) UIBarButtonItem* doneButton;
-@property (nonatomic, strong) UIView* recordingView;
-@property (nonatomic, strong) UIButton* recordButton;
-@property (nonatomic, strong) UIImage* recordImage;
-@property (nonatomic, strong) UIImage* stopRecordImage;
-@property (nonatomic, strong) UILabel* timerLabel;
-@property (nonatomic, strong) AVAudioRecorder* avRecorder;
-@property (nonatomic, strong) AVAudioSession* avSession;
-@property (nonatomic, strong) CDVPluginResult* pluginResult;
-@property (nonatomic, strong) NSTimer* timer;
-@property (nonatomic) BOOL isTimed;
-
-- (id)initWithCommand:(CDVPlugin*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId;
-- (void)processButton:(id)sender;
-- (void)stopRecordingCleanup;
-- (void)dismissAudioView:(id)sender;
-- (NSString*)formatTime:(int)interval;
-- (void)updateTime;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
deleted file mode 100644
index 6b7ed44..0000000
--- a/CordovaLib/Classes/CDVCapture.m
+++ /dev/null
@@ -1,845 +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.
- */
-
-#import "CDVCapture.h"
-#import "CDVJSON.h"
-#import "CDVAvailability.h"
-
-#define kW3CMediaFormatHeight @"height"
-#define kW3CMediaFormatWidth @"width"
-#define kW3CMediaFormatCodecs @"codecs"
-#define kW3CMediaFormatBitrate @"bitrate"
-#define kW3CMediaFormatDuration @"duration"
-#define kW3CMediaModeType @"type"
-
-@implementation CDVImagePicker
-
-@synthesize quality;
-@synthesize callbackId;
-@synthesize mimeType;
-
-- (uint64_t)accessibilityTraits
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-
- if (([systemVersion compare:@"4.0" options:NSNumericSearch] != NSOrderedAscending)) { // this means system version is not less than 4.0
- return UIAccessibilityTraitStartsMediaSession;
- }
-
- return UIAccessibilityTraitNone;
-}
-
-@end
-
-@implementation CDVCapture
-@synthesize inUse;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVCapture*)[super initWithWebView:theWebView];
- if (self) {
- self.inUse = NO;
- }
- return self;
-}
-
-- (void)captureAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- NSNumber* duration = [options objectForKey:@"duration"];
- // the default value of duration is 0 so use nil (no duration) if default value
- if (duration) {
- duration = [duration doubleValue] == 0 ? nil : duration;
- }
- CDVPluginResult* result = nil;
-
- if (NSClassFromString(@"AVAudioRecorder") == nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- } else if (self.inUse == YES) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_APPLICATION_BUSY];
- } else {
- // all the work occurs here
- CDVAudioRecorderViewController* audioViewController = [[CDVAudioRecorderViewController alloc] initWithCommand:self duration:duration callbackId:callbackId];
-
- // Now create a nav controller and display the view...
- CDVAudioNavigationController* navController = [[CDVAudioNavigationController alloc] initWithRootViewController:audioViewController];
-
- self.inUse = YES;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:navController animated:YES];
- }
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)captureImage:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit and mode neither of which are supported at this time
- // taking more than one picture (limit) is only supported if provide own controls via cameraOverlayView property
- // can support mode in OS
-
- if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- NSLog(@"Capture.imageCapture: camera not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (pickerController == nil) {
- pickerController = [[CDVImagePicker alloc] init];
- }
-
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- if ([pickerController respondsToSelector:@selector(mediaTypes)]) {
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
- }
-
- /*if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]){
- // iOS 4.0
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
- pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }*/
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-/* Process a still image from the camera.
- * IN:
- * UIImage* image - the UIImage data returned from the camera
- * NSString* callbackId
- */
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
-
- // save the image to photo album
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
-
- NSData* data = nil;
- if (mimeType && [mimeType isEqualToString:@"image/png"]) {
- data = UIImagePNGRepresentation(image);
- } else {
- data = UIImageJPEGRepresentation(image, 0.5);
- }
-
- // write to temp directory and return URI
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/photo_%03d.jpg", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- if (err) {
- NSLog(@"Error saving image: %@", [err localizedDescription]);
- }
- } else {
- // create MediaFile object
-
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:filePath ofType:mimeType];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- }
-
- return result;
-}
-
-- (void)captureVideo:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit, duration and mode, only duration is supported (but is not due to apple bug)
- // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property
- // NSNumber* duration = [options objectForKey:@"duration"];
- NSString* mediaType = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, it is available, make sure it can do movies
- pickerController = [[CDVImagePicker alloc] init];
-
- NSArray* types = nil;
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
- // NSLog(@"MediaTypes: %@", [types description]);
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- mediaType = (NSString*)kUTTypeMovie;
- } else if ([types containsObject:(NSString*)kUTTypeVideo]) {
- mediaType = (NSString*)kUTTypeVideo;
- }
- }
- }
- if (!mediaType) {
- // don't have video camera return error
- NSLog(@"Capture.captureVideo: video mode not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
- } else {
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:mediaType, nil];
-
- /*if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
- if (duration) {
- pickerController.videoMaximumDuration = [duration doubleValue];
- }
- //NSLog(@"pickerController.videoMaximumDuration = %f", pickerController.videoMaximumDuration);
- }*/
-
- // iOS 4.0
- if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
- // pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
- // pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- // pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId
-{
- // save the movie to photo album (only avail as of iOS 3.1)
-
- /* don't need, it should automatically get saved
- NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath));
- if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) {
- NSLog(@"try to save movie");
- UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil);
- NSLog(@"finished saving movie");
- }*/
- // create MediaFile object
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-}
-
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command
-{
- // NSString* callbackId = [arguments objectAtIndex:0];
- // NSMutableDictionary* imageModes = nil;
- NSArray* imageArray = nil;
- NSArray* movieArray = nil;
- NSArray* audioArray = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, find the modes
- // can get image/jpeg or image/png from camera
-
- /* can't find a way to get the default height and width and other info
- * for images/movies taken with UIImagePickerController
- */
- NSDictionary* jpg = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/jpeg", kW3CMediaModeType,
- nil];
- NSDictionary* png = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/png", kW3CMediaModeType,
- nil];
- imageArray = [NSArray arrayWithObjects:jpg, png, nil];
-
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- NSArray* types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- NSDictionary* mov = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"video/quicktime", kW3CMediaModeType,
- nil];
- movieArray = [NSArray arrayWithObject:mov];
- }
- }
- }
- NSDictionary* modes = [NSDictionary dictionaryWithObjectsAndKeys:
- imageArray ? (NSObject*) imageArray:[NSNull null], @"image",
- movieArray ? (NSObject*) movieArray:[NSNull null], @"video",
- audioArray ? (NSObject*) audioArray:[NSNull null], @"audio",
- nil];
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.capture.setSupportedModes(%@);", [modes JSONString]];
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)getFormatData:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- // existence of fullPath checked on JS side
- NSString* fullPath = [command.arguments objectAtIndex:0];
- // mimeType could be null
- NSString* mimeType = nil;
-
- if ([command.arguments count] > 1) {
- mimeType = [command.arguments objectAtIndex:1];
- }
- BOOL bError = NO;
- CDVCaptureError errorCode = CAPTURE_INTERNAL_ERR;
- CDVPluginResult* result = nil;
-
- if (!mimeType || [mimeType isKindOfClass:[NSNull class]]) {
- // try to determine mime type if not provided
- id command = [self.commandDelegate getCommandInstance:@"File"];
- bError = !([command isKindOfClass:[CDVFile class]]);
- if (!bError) {
- CDVFile* cdvFile = (CDVFile*)command;
- mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- if (!mimeType) {
- // can't do much without mimeType, return error
- bError = YES;
- errorCode = CAPTURE_INVALID_ARGUMENT;
- }
- }
- }
- if (!bError) {
- // create and initialize return dictionary
- NSMutableDictionary* formatData = [NSMutableDictionary dictionaryWithCapacity:5];
- [formatData setObject:[NSNull null] forKey:kW3CMediaFormatCodecs];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatBitrate];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatDuration];
-
- if ([mimeType rangeOfString:@"image/"].location != NSNotFound) {
- UIImage* image = [UIImage imageWithContentsOfFile:fullPath];
- if (image) {
- CGSize imgSize = [image size];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.width] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.height] forKey:kW3CMediaFormatHeight];
- }
- } else if (([mimeType rangeOfString:@"video/"].location != NSNotFound) && (NSClassFromString(@"AVURLAsset") != nil)) {
- NSURL* movieURL = [NSURL fileURLWithPath:fullPath];
- AVURLAsset* movieAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
- CMTime duration = [movieAsset duration];
- [formatData setObject:[NSNumber numberWithFloat:CMTimeGetSeconds(duration)] forKey:kW3CMediaFormatDuration];
-
- NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
- if ([allVideoTracks count] > 0) {
- AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
- CGSize size = [track naturalSize];
-
- [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
- // not sure how to get codecs or bitrate???
- // AVMetadataItem
- // AudioFile
- } else {
- NSLog(@"No video tracks found for %@", fullPath);
- }
- } else if ([mimeType rangeOfString:@"audio/"].location != NSNotFound) {
- if (NSClassFromString(@"AVAudioPlayer") != nil) {
- NSURL* fileURL = [NSURL fileURLWithPath:fullPath];
- NSError* err = nil;
-
- AVAudioPlayer* avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&err];
- if (!err) {
- // get the data
- [formatData setObject:[NSNumber numberWithDouble:[avPlayer duration]] forKey:kW3CMediaFormatDuration];
- if ([avPlayer respondsToSelector:@selector(settings)]) {
- NSDictionary* info = [avPlayer settings];
- NSNumber* bitRate = [info objectForKey:AVEncoderBitRateKey];
- if (bitRate) {
- [formatData setObject:bitRate forKey:kW3CMediaFormatBitrate];
- }
- }
- } // else leave data init'ed to 0
- }
- }
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:formatData];
- // NSLog(@"getFormatData: %@", [formatData description]);
- }
- if (bError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errorCode];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type
-{
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSMutableDictionary* fileDict = [NSMutableDictionary dictionaryWithCapacity:5];
-
- [fileDict setObject:[fullPath lastPathComponent] forKey:@"name"];
- [fileDict setObject:fullPath forKey:@"fullPath"];
- // determine type
- if (!type) {
- id command = [self.commandDelegate getCommandInstance:@"File"];
- if ([command isKindOfClass:[CDVFile class]]) {
- CDVFile* cdvFile = (CDVFile*)command;
- NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
- }
- }
- NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
- [fileDict setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
- NSDate* modDate = [fileAttrs fileModificationDate];
- NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
- [fileDict setObject:msDate forKey:@"lastModifiedDate"];
-
- return fileDict;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- // older api calls new one
- [self imagePickerController:picker didFinishPickingMediaWithInfo:editingInfo];
-}
-
-/* Called when image/movie is finished recording.
- * Calls success or error code as appropriate
- * if successful, result contains an array (with just one entry since can only get one image unless build own camera UI) of MediaFile object representing the image
- * name
- * fullPath
- * type
- * lastModifiedDate
- * size
- */
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = nil;
-
- UIImage* image = nil;
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- if (!mediaType || [mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- // mediaType is nil then only option is UIImagePickerControllerOriginalImage
- if ([UIImagePickerController respondsToSelector:@selector(allowsEditing)] &&
- (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage])) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
- }
- if (image != nil) {
- // mediaType was image
- result = [self processImage:image type:cameraPicker.mimeType forCallbackId:callbackId];
- } else if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]) {
- // process video
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
- if (moviePath) {
- result = [self processVideo:moviePath forCallbackId:callbackId];
- }
- }
- if (!result) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NO_MEDIA_FILES];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-@end
-
-@implementation CDVAudioNavigationController
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- // delegate to CVDAudioRecorderViewController
- return [self.topViewController supportedInterfaceOrientations];
- }
-#endif
-
-@end
-
-@implementation CDVAudioRecorderViewController
-@synthesize errorCode, callbackId, duration, captureCommand, doneButton, recordingView, recordButton, recordImage, stopRecordImage, timerLabel, avRecorder, avSession, pluginResult, timer, isTimed;
-
-- (NSString*)resolveImageResource:(NSString*)resource
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
- BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
-
- // the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
- // if user wants iPhone only app to run on iPad they must remove *~ipad.* images from capture.bundle
- if (isLessThaniOS4) {
- NSString* iPadResource = [NSString stringWithFormat:@"%@~ipad.png", resource];
- if (CDV_IsIPad() && [UIImage imageNamed:iPadResource]) {
- return iPadResource;
- } else {
- return [NSString stringWithFormat:@"%@.png", resource];
- }
- }
-
- return resource;
-}
-
-- (id)initWithCommand:(CDVCapture*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId
-{
- if ((self = [super init])) {
- self.captureCommand = theCommand;
- self.duration = theDuration;
- self.callbackId = theCallbackId;
- self.errorCode = CAPTURE_NO_MEDIA_FILES;
- self.isTimed = self.duration != nil;
-
- return self;
- }
-
- return nil;
-}
-
-- (void)loadView
-{
- // create view and display
- CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
- UIView* tmp = [[UIView alloc] initWithFrame:viewRect];
-
- // make backgrounds
- NSString* microphoneResource = @"Capture.bundle/microphone";
-
- if (CDV_IsIPhone5()) {
- microphoneResource = @"Capture.bundle/microphone-568h";
- }
-
- UIImage* microphone = [UIImage imageNamed:[self resolveImageResource:microphoneResource]];
- UIView* microphoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, microphone.size.height)];
- [microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
- [microphoneView setUserInteractionEnabled:NO];
- [microphoneView setIsAccessibilityElement:NO];
- [tmp addSubview:microphoneView];
-
- // add bottom bar view
- UIImage* grayBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/controls_bg"]];
- UIView* controls = [[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width, grayBkg.size.height)];
- [controls setBackgroundColor:[UIColor colorWithPatternImage:grayBkg]];
- [controls setUserInteractionEnabled:NO];
- [controls setIsAccessibilityElement:NO];
- [tmp addSubview:controls];
-
- // make red recording background view
- UIImage* recordingBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/recording_bg"]];
- UIColor* background = [UIColor colorWithPatternImage:recordingBkg];
- self.recordingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- [self.recordingView setBackgroundColor:background];
- [self.recordingView setHidden:YES];
- [self.recordingView setUserInteractionEnabled:NO];
- [self.recordingView setIsAccessibilityElement:NO];
- [tmp addSubview:self.recordingView];
-
- // add label
- self.timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- // timerLabel.autoresizingMask = reSizeMask;
- [self.timerLabel setBackgroundColor:[UIColor clearColor]];
- [self.timerLabel setTextColor:[UIColor whiteColor]];
- [self.timerLabel setTextAlignment:UITextAlignmentCenter];
- [self.timerLabel setText:@"0:00"];
- [self.timerLabel setAccessibilityHint:NSLocalizedString(@"recorded time in minutes and seconds", nil)];
- self.timerLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
- self.timerLabel.accessibilityTraits &= ~UIAccessibilityTraitStaticText;
- [tmp addSubview:self.timerLabel];
-
- // Add record button
-
- self.recordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/record_button"]];
- self.stopRecordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/stop_button"]];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- self.recordButton = [[UIButton alloc] initWithFrame:CGRectMake((viewRect.size.width - recordImage.size.width) / 2, (microphone.size.height + (grayBkg.size.height - recordImage.size.height) / 2), recordImage.size.width, recordImage.size.height)];
- [self.recordButton setAccessibilityLabel:NSLocalizedString(@"toggle audio recording", nil)];
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- [self.recordButton addTarget:self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
- [tmp addSubview:recordButton];
-
- // make and add done button to navigation bar
- self.doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)];
- [self.doneButton setStyle:UIBarButtonItemStyleDone];
- self.navigationItem.rightBarButtonItem = self.doneButton;
-
- [self setView:tmp];
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- NSError* error = nil;
-
- if (self.avSession == nil) {
- // create audio session
- self.avSession = [AVAudioSession sharedInstance];
- if (error) {
- // return error if can't create recording audio session
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- }
- }
-
- // create file to record to in temporary dir
-
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/audio_%03d.wav", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- NSURL* fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
-
- // create AVAudioPlayer
- self.avRecorder = [[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err];
- if (err) {
- NSLog(@"Failed to initialize AVAudioRecorder: %@\n", [err localizedDescription]);
- self.avRecorder = nil;
- // return error
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- self.avRecorder.delegate = self;
- [self.avRecorder prepareToRecord];
- self.recordButton.enabled = YES;
- self.doneButton.enabled = YES;
- }
-}
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
- NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
-
- orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
- return orientation;
- }
-#endif
-
-- (void)viewDidUnload
-{
- [self setView:nil];
- [self.captureCommand setInUse:NO];
-}
-
-- (void)processButton:(id)sender
-{
- if (self.avRecorder.recording) {
- // stop recording
- [self.avRecorder stop];
- self.isTimed = NO; // recording was stopped via button so reset isTimed
- // view cleanup will occur in audioRecordingDidFinishRecording
- } else {
- // begin recording
- [self.recordButton setImage:stopRecordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits &= ~[self accessibilityTraits];
- [self.recordingView setHidden:NO];
- NSError* error = nil;
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:&error];
- [self.avSession setActive:YES error:&error];
- if (error) {
- // can't continue without active audio session
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- if (self.duration) {
- self.isTimed = true;
- [self.avRecorder recordForDuration:[duration doubleValue]];
- } else {
- [self.avRecorder record];
- }
- [self.timerLabel setText:@"0.00"];
- self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
- self.doneButton.enabled = NO;
- }
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- }
-}
-
-/*
- * helper method to clean up when stop recording
- */
-- (void)stopRecordingCleanup
-{
- if (self.avRecorder.recording) {
- [self.avRecorder stop];
- }
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- [self.recordingView setHidden:YES];
- self.doneButton.enabled = YES;
- if (self.avSession) {
- // deactivate session so sounds can come through
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- }
- if (self.duration && self.isTimed) {
- // VoiceOver announcement so user knows timed recording has finished
- BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
- if (isUIAccessibilityAnnouncementNotification) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
- UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString(@"timed recording complete", nil));
- });
- }
- } else {
- // issue a layout notification change so that VO will reannounce the button label when recording completes
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- }
-}
-
-- (void)dismissAudioView:(id)sender
-{
- // called when done button pressed or when error condition to do cleanup and remove view
- if ([self.captureCommand.viewController.modalViewController respondsToSelector:@selector(presentingViewController)]) {
- [[self.captureCommand.viewController.modalViewController presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[self.captureCommand.viewController.modalViewController parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- if (!self.pluginResult) {
- // return error
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:self.errorCode];
- }
-
- self.avRecorder = nil;
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- [self.captureCommand setInUse:NO];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- // return result
- [self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
-}
-
-- (void)updateTime
-{
- // update the label with the elapsed time
- [self.timerLabel setText:[self formatTime:self.avRecorder.currentTime]];
-}
-
-- (NSString*)formatTime:(int)interval
-{
- // is this format universal?
- int secs = interval % 60;
- int min = interval / 60;
-
- if (interval < 60) {
- return [NSString stringWithFormat:@"0:%02d", interval];
- } else {
- return [NSString stringWithFormat:@"%d:%02d", min, secs];
- }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
- // may be called when timed audio finishes - need to stop time and reset buttons
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- // generate success result
- if (flag) {
- NSString* filePath = [avRecorder.url path];
- // NSLog(@"filePath: %@", filePath);
- NSDictionary* fileDict = [captureCommand getMediaDictionaryFromPath:filePath ofType:@"audio/wav"];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- } else {
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
-}
-
-- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder*)recorder error:(NSError*)error
-{
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- NSLog(@"error recording audio");
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- [self dismissAudioView:nil];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVDevice.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.h b/CordovaLib/Classes/CDVDevice.h
deleted file mode 100644
index fd6ea12..0000000
--- a/CordovaLib/Classes/CDVDevice.h
+++ /dev/null
@@ -1,30 +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.
- */
-
-#import <UIKit/UIKit.h>
-#import "CDVPlugin.h"
-
-@interface CDVDevice : CDVPlugin
-{}
-
-+ (NSString*)cordovaVersion;
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
deleted file mode 100644
index a331b81..0000000
--- a/CordovaLib/Classes/CDVDevice.m
+++ /dev/null
@@ -1,89 +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.
- */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#import "CDV.h"
-
-@implementation UIDevice (ModelVersion)
-
-- (NSString*)modelVersion
-{
- size_t size;
-
- sysctlbyname("hw.machine", NULL, &size, NULL, 0);
- char* machine = malloc(size);
- sysctlbyname("hw.machine", machine, &size, NULL, 0);
- NSString* platform = [NSString stringWithUTF8String:machine];
- free(machine);
-
- return platform;
-}
-
-@end
-
-@interface CDVDevice () {}
-@end
-
-@implementation CDVDevice
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
-{
- NSDictionary* deviceProperties = [self deviceProperties];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
-
- /* Settings.plist
- * Read the optional Settings.plist file and push these user-defined settings down into the web application.
- * This can be useful for supplying build-time configuration variables down to the app to change its behavior,
- * such as specifying Full / Lite version, or localization (English vs German, for instance).
- */
- // TODO: turn this into an iOS only plugin
- 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];
- }
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (NSDictionary*)deviceProperties
-{
- UIDevice* device = [UIDevice currentDevice];
- NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
- [devProps setObject:[device modelVersion] forKey:@"model"];
- [devProps setObject:@"iOS" forKey:@"platform"];
- [devProps setObject:[device systemVersion] forKey:@"version"];
- [devProps setObject:[device uniqueAppInstanceIdentifier] forKey:@"uuid"];
- [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
-
- NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
- return devReturn;
-}
-
-+ (NSString*)cordovaVersion
-{
- return CDV_VERSION;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVFile.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.h b/CordovaLib/Classes/CDVFile.h
deleted file mode 100644
index 017b066..0000000
--- a/CordovaLib/Classes/CDVFile.h
+++ /dev/null
@@ -1,107 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileError {
- NO_ERROR = 0,
- NOT_FOUND_ERR = 1,
- SECURITY_ERR = 2,
- ABORT_ERR = 3,
- NOT_READABLE_ERR = 4,
- ENCODING_ERR = 5,
- NO_MODIFICATION_ALLOWED_ERR = 6,
- INVALID_STATE_ERR = 7,
- SYNTAX_ERR = 8,
- INVALID_MODIFICATION_ERR = 9,
- QUOTA_EXCEEDED_ERR = 10,
- TYPE_MISMATCH_ERR = 11,
- PATH_EXISTS_ERR = 12
-};
-typedef int CDVFileError;
-
-enum CDVFileSystemType {
- TEMPORARY = 0,
- PERSISTENT = 1
-};
-typedef int CDVFileSystemType;
-
-extern NSString* const kCDVAssetsLibraryPrefix;
-
-@interface CDVFile : CDVPlugin {
- NSString* appDocsPath;
- NSString* appLibraryPath;
- NSString* appTempPath;
- NSString* persistentPath;
- NSString* temporaryPath;
-
- BOOL userHasAllowed;
-}
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
-- (NSString*)getAppPath:(NSString*)pathFragment;
-// -(NSString*) getFullPath: (NSString*)pathFragment;
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir;
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
-- (void)getDirectory:(CDVInvokedUrlCommand*)command;
-- (void)getFile:(CDVInvokedUrlCommand*)command;
-- (void)getParent:(CDVInvokedUrlCommand*)command;
-- (void)getMetadata:(CDVInvokedUrlCommand*)command;
-- (void)removeRecursively:(CDVInvokedUrlCommand*)command;
-- (void)remove:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)doRemove:(NSString*)fullPath;
-- (void)copyTo:(CDVInvokedUrlCommand*)command;
-- (void)moveTo:(CDVInvokedUrlCommand*)command;
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest;
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
-// - (void) toURI:(CDVInvokedUrlCommand*)command;
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
-- (void)readEntries:(CDVInvokedUrlCommand*)command;
-
-- (void)readAsText:(CDVInvokedUrlCommand*)command;
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
-- (void)write:(CDVInvokedUrlCommand*)command;
-- (void)testFileExists:(CDVInvokedUrlCommand*)command;
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
-// - (void) createDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteFile:(CDVInvokedUrlCommand*)command;
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
-- (void)truncate:(CDVInvokedUrlCommand*)command;
-
-// - (BOOL) fileExists:(NSString*)fileName;
-// - (BOOL) directoryExists:(NSString*)dirName;
-- (void)writeToFile:(NSString*)fileName withData:(NSData*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId;
-- (void)writeToFile:(NSString*)fileName withString:(NSString*)data encoding:(NSStringEncoding)encoding append:(BOOL)shouldAppend callback:(NSString*)callbackId;
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos;
-
-@property (nonatomic, strong) NSString* appDocsPath;
-@property (nonatomic, strong) NSString* appLibraryPath;
-@property (nonatomic, strong) NSString* appTempPath;
-@property (nonatomic, strong) NSString* persistentPath;
-@property (nonatomic, strong) NSString* temporaryPath;
-@property BOOL userHasAllowed;
-
-@end
-
-#define kW3FileTemporary @"temporary"
-#define kW3FilePersistent @"persistent"
[30/50] [abbrv] removed device, capture, file, filetransfer
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
deleted file mode 100644
index 0f6b174..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ /dev/null
@@ -1,730 +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.
- */
-
-#import "CDV.h"
-
-#import <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <CFNetwork/CFNetwork.h>
-
-@interface CDVFileTransfer ()
-// Sets the requests headers for the request.
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req;
-// Creates a delegate to handle an upload.
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command;
-// Creates an NSData* for the file for the given upload arguments.
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command;
-@end
-
-// Buffer size to use for streaming uploads.
-static const NSUInteger kStreamBufferSize = 32768;
-// Magic value within the options dict used to set a cookie.
-NSString* const kOptionsKeyCookie = @"__cookie";
-// Form boundary for multi-part requests.
-NSString* const kFormBoundary = @"+++++org.apache.cordova.formBoundary";
-
-// Writes the given data to the stream in a blocking way.
-// If successful, returns bytesToWrite.
-// If the stream was closed on the other end, returns 0.
-// If there was an error, returns -1.
-static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
-{
- UInt8* bytes = (UInt8*)[data bytes];
- NSUInteger bytesToWrite = [data length];
- NSUInteger totalBytesWritten = 0;
-
- while (totalBytesWritten < bytesToWrite) {
- CFIndex result = CFWriteStreamWrite(stream,
- bytes + totalBytesWritten,
- bytesToWrite - totalBytesWritten);
- if (result < 0) {
- CFStreamError error = CFWriteStreamGetError(stream);
- NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, error.error);
- return result;
- } else if (result == 0) {
- return result;
- }
- totalBytesWritten += result;
- }
-
- return totalBytesWritten;
-}
-
-@implementation CDVFileTransfer
-@synthesize activeTransfers;
-
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString
-{
- NSRange schemeAndHostRange = [urlString rangeOfString:@"://.*?/" options:NSRegularExpressionSearch];
-
- if (schemeAndHostRange.length == 0) {
- return urlString;
- }
-
- NSInteger schemeAndHostEndIndex = NSMaxRange(schemeAndHostRange);
- NSString* schemeAndHost = [urlString substringToIndex:schemeAndHostEndIndex];
- NSString* pathComponent = [urlString substringFromIndex:schemeAndHostEndIndex];
- pathComponent = [pathComponent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
- return [schemeAndHost stringByAppendingString:pathComponent];
-}
-
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req
-{
- [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
-
- NSString* userAgent = [self.commandDelegate userAgent];
- if (userAgent) {
- [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
- }
-
- for (NSString* headerName in headers) {
- id value = [headers objectForKey:headerName];
- if (!value || (value == [NSNull null])) {
- value = @"null";
- }
-
- // First, remove an existing header if one exists.
- [req setValue:nil forHTTPHeaderField:headerName];
-
- if (![value isKindOfClass:[NSArray class]]) {
- value = [NSArray arrayWithObject:value];
- }
-
- // Then, append all header values.
- for (id __strong subValue in value) {
- // Convert from an NSNumber -> NSString.
- if ([subValue respondsToSelector:@selector(stringValue)]) {
- subValue = [subValue stringValue];
- }
- if ([subValue isKindOfClass:[NSString class]]) {
- [req addValue:subValue forHTTPHeaderField:headerName];
- }
- }
- }
-}
-
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData
-{
- // arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]
- // however, params is a JavaScript object and during marshalling is put into the options dict,
- // thus debug and chunkedMode are the 6th and 7th arguments
- NSString* target = [command argumentAtIndex:0];
- NSString* server = [command argumentAtIndex:1];
- NSString* fileKey = [command argumentAtIndex:2 withDefault:@"file"];
- NSString* fileName = [command argumentAtIndex:3 withDefault:@"no-filename"];
- NSString* mimeType = [command argumentAtIndex:4 withDefault:nil];
- NSDictionary* options = [command argumentAtIndex:5 withDefault:nil];
- // BOOL trustAllHosts = [[arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- BOOL chunkedMode = [[command argumentAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
- NSDictionary* headers = [command argumentAtIndex:8 withDefault:nil];
- // Allow alternative http method, default to POST. JS side checks
- // for allowed methods, currently PUT or POST (forces POST for
- // unrecognised values)
- NSString* httpMethod = [command argumentAtIndex:10 withDefault:@"POST"];
- CDVPluginResult* result = nil;
- CDVFileTransferError errorCode = 0;
-
- // NSURL does not accepts URLs with spaces in the path. We escape the path in order
- // to be more lenient.
- NSURL* url = [NSURL URLWithString:server];
-
- if (!url) {
- errorCode = INVALID_URL_ERR;
- NSLog(@"File Transfer Error: Invalid server URL %@", server);
- } else if (!fileData) {
- errorCode = FILE_NOT_FOUND_ERR;
- }
-
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:target AndTarget:server]];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return nil;
- }
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
-
- [req setHTTPMethod:httpMethod];
-
- // Magic value to set a cookie
- if ([options objectForKey:kOptionsKeyCookie]) {
- [req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"];
- [req setHTTPShouldHandleCookies:NO];
- }
-
- NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-Type"];
- [self applyRequestHeaders:headers toRequest:req];
-
- NSData* formBoundaryData = [[NSString stringWithFormat:@"--%@\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
- NSMutableData* postBodyBeforeFile = [NSMutableData data];
-
- for (NSString* key in options) {
- id val = [options objectForKey:key];
- if (!val || (val == [NSNull null]) || [key isEqualToString:kOptionsKeyCookie]) {
- continue;
- }
- // if it responds to stringValue selector (eg NSNumber) get the NSString
- if ([val respondsToSelector:@selector(stringValue)]) {
- val = [val stringValue];
- }
- // finally, check whether it is a NSString (for dataUsingEncoding selector below)
- if (![val isKindOfClass:[NSString class]]) {
- continue;
- }
-
- [postBodyBeforeFile appendData:formBoundaryData];
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
- [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
- }
-
- [postBodyBeforeFile appendData:formBoundaryData];
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
- if (mimeType != nil) {
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
- }
- [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %d\r\n\r\n", [fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];
-
- DLog(@"fileData length: %d", [fileData length]);
- NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
-
- NSUInteger totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
- [req setValue:[[NSNumber numberWithInteger:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
-
- if (chunkedMode) {
- CFReadStreamRef readStream = NULL;
- CFWriteStreamRef writeStream = NULL;
- CFStreamCreateBoundPair(NULL, &readStream, &writeStream, kStreamBufferSize);
- [req setHTTPBodyStream:CFBridgingRelease(readStream)];
-
- self.backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
- [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskID];
- self.backgroundTaskID = UIBackgroundTaskInvalid;
- NSLog(@"Background task to upload media finished.");
- }];
-
- [self.commandDelegate runInBackground:^{
- if (CFWriteStreamOpen(writeStream)) {
- NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
- int numChunks = sizeof(chunks) / sizeof(chunks[0]);
-
- for (int i = 0; i < numChunks; ++i) {
- CFIndex result = WriteDataToStream(chunks[i], writeStream);
- if (result <= 0) {
- break;
- }
- }
- } else {
- NSLog(@"FileTransfer: Failed to open writeStream");
- }
- CFWriteStreamClose(writeStream);
- CFRelease(writeStream);
- }];
- } else {
- [postBodyBeforeFile appendData:fileData];
- [postBodyBeforeFile appendData:postBodyAfterFile];
- [req setHTTPBody:postBodyBeforeFile];
- }
- return req;
-}
-
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command
-{
- NSString* source = [command.arguments objectAtIndex:0];
- NSString* server = [command.arguments objectAtIndex:1];
- BOOL trustAllHosts = [[command.arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- NSString* objectId = [command.arguments objectAtIndex:9];
-
- CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-
- delegate.command = self;
- delegate.callbackId = command.callbackId;
- delegate.direction = CDV_TRANSFER_UPLOAD;
- delegate.objectId = objectId;
- delegate.source = source;
- delegate.target = server;
- delegate.trustAllHosts = trustAllHosts;
-
- return delegate;
-}
-
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
-{
- NSString* target = (NSString*)[command.arguments objectAtIndex:0];
- NSError* __autoreleasing err = nil;
-
- // return unsupported result for assets-library URLs
- if ([target hasPrefix:kCDVAssetsLibraryPrefix]) {
- // 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* fileData = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
- [self uploadData:fileData command:command];
- } else {
- // We couldn't find the asset. Send the appropriate error.
- CDVPluginResult* 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.
- CDVPluginResult* 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:target] resultBlock:resultBlock failureBlock:failureBlock];
- return;
- } else {
- // Extract the path part out of a file: URL.
- NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
- if (filePath == nil) {
- // We couldn't find the asset. Send the appropriate error.
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- // Memory map the file so that it can be read efficiently even if it is large.
- NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
-
- if (err != nil) {
- NSLog(@"Error opening file %@: %@", target, err);
- }
- [self uploadData:fileData command:command];
- }
-}
-
-- (void)upload:(CDVInvokedUrlCommand*)command
-{
- // fileData and req are split into helper functions to ease the unit testing of delegateForUpload.
- // First, get the file data. This method will call `uploadData:command`.
- [self fileDataForUploadCommand:command];
-}
-
-- (void)uploadData:(NSData*)fileData command:(CDVInvokedUrlCommand*)command
-{
- NSURLRequest* req = [self requestForUploadCommand:command fileData:fileData];
-
- if (req == nil) {
- return;
- }
- CDVFileTransferDelegate* delegate = [self delegateForUploadCommand:command];
- [NSURLConnection connectionWithRequest:req delegate:delegate];
-
- if (activeTransfers == nil) {
- activeTransfers = [[NSMutableDictionary alloc] init];
- }
-
- [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (void)abort:(CDVInvokedUrlCommand*)command
-{
- NSString* objectId = [command.arguments objectAtIndex:0];
-
- CDVFileTransferDelegate* delegate = [activeTransfers objectForKey:objectId];
-
- if (delegate != nil) {
- [delegate cancelTransfer:delegate.connection];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]];
- [self.commandDelegate sendPluginResult:result callbackId:delegate.callbackId];
- }
-}
-
-- (void)download:(CDVInvokedUrlCommand*)command
-{
- DLog(@"File Transfer downloading file...");
- NSString* sourceUrl = [command.arguments objectAtIndex:0];
- NSString* filePath = [command.arguments objectAtIndex:1];
- BOOL trustAllHosts = [[command.arguments objectAtIndex:2 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
- NSString* objectId = [command.arguments objectAtIndex:3];
- NSDictionary* headers = [command.arguments objectAtIndex:4 withDefault:nil];
-
- // return unsupported result for assets-library URLs
- if ([filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"download not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- CDVFileTransferError errorCode = 0;
-
- NSURL* file;
-
- if ([filePath hasPrefix:@"/"]) {
- file = [NSURL fileURLWithPath:filePath];
- } else {
- file = [NSURL URLWithString:filePath];
- }
-
- NSURL* url = [NSURL URLWithString:sourceUrl];
-
- if (!url) {
- errorCode = INVALID_URL_ERR;
- NSLog(@"File Transfer Error: Invalid server URL %@", sourceUrl);
- } else if (![file isFileURL]) {
- errorCode = FILE_NOT_FOUND_ERR;
- NSLog(@"File Transfer Error: Invalid file path or URL %@", filePath);
- }
-
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:sourceUrl AndTarget:filePath]];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
- [self applyRequestHeaders:headers toRequest:req];
-
- CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
- delegate.command = self;
- delegate.direction = CDV_TRANSFER_DOWNLOAD;
- delegate.callbackId = command.callbackId;
- delegate.objectId = objectId;
- delegate.source = sourceUrl;
- delegate.target = filePath;
- delegate.trustAllHosts = trustAllHosts;
-
- delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate];
-
- if (activeTransfers == nil) {
- activeTransfers = [[NSMutableDictionary alloc] init];
- }
-
- [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target
-{
- NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3];
-
- [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- if (source != nil) {
- [result setObject:source forKey:@"source"];
- }
- if (target != nil) {
- [result setObject:target forKey:@"target"];
- }
- NSLog(@"FileTransferError %@", result);
-
- return result;
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
- AndSource:(NSString*)source
- AndTarget:(NSString*)target
- AndHttpStatus:(int)httpStatus
- AndBody:(NSString*)body
-{
- NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:5];
-
- [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- if (source != nil) {
- [result setObject:source forKey:@"source"];
- }
- if (target != nil) {
- [result setObject:target forKey:@"target"];
- }
- [result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
- if (body != nil) {
- [result setObject:body forKey:@"body"];
- }
- NSLog(@"FileTransferError %@", result);
-
- return result;
-}
-
-- (void)onReset
-{
- for (CDVFileTransferDelegate* delegate in [activeTransfers allValues]) {
- [delegate.connection cancel];
- }
-
- [activeTransfers removeAllObjects];
-}
-
-@end
-
-@interface CDVFileTransferEntityLengthRequest : NSObject {
- NSURLConnection* _connection;
- CDVFileTransferDelegate* __weak _originalDelegate;
-}
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate;
-
-@end;
-
-@implementation CDVFileTransferEntityLengthRequest;
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate
-{
- if (self) {
- DLog(@"Requesting entity length for GZIPped content...");
-
- NSMutableURLRequest* req = [originalRequest mutableCopy];
- [req setHTTPMethod:@"HEAD"];
- [req setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"];
-
- _originalDelegate = originalDelegate;
- _connection = [NSURLConnection connectionWithRequest:req delegate:self];
- }
- return self;
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
- DLog(@"HEAD request returned; content-length is %lld", [response expectedContentLength]);
- [_originalDelegate updateBytesExpected:[response expectedContentLength]];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{}
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{}
-
-@end
-
-@implementation CDVFileTransferDelegate
-
-@synthesize callbackId, connection = _connection, source, target, responseData, command, bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle;
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{
- NSString* uploadResponse = nil;
- NSString* downloadResponse = nil;
- NSMutableDictionary* uploadResult;
- CDVPluginResult* result = nil;
- BOOL bDirRequest = NO;
- CDVFile* file;
-
- NSLog(@"File Transfer Finished with response code %d", self.responseCode);
-
- if (self.direction == CDV_TRANSFER_UPLOAD) {
- uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
-
- if ((self.responseCode >= 200) && (self.responseCode < 300)) {
- // create dictionary to return FileUploadResult object
- uploadResult = [NSMutableDictionary dictionaryWithCapacity:3];
- if (uploadResponse != nil) {
- [uploadResult setObject:uploadResponse forKey:@"response"];
- }
- [uploadResult setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"bytesSent"];
- [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:uploadResponse]];
- }
- }
- if (self.direction == CDV_TRANSFER_DOWNLOAD) {
- if (self.targetFileHandle) {
- [self.targetFileHandle closeFile];
- self.targetFileHandle = nil;
- DLog(@"File Transfer Download success");
-
- file = [[CDVFile alloc] init];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[file getDirectoryEntry:target isDirectory:bDirRequest]];
- } else {
- downloadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:downloadResponse]];
- }
- }
-
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-
- // remove connection for activeTransfers
- [command.activeTransfers removeObjectForKey:objectId];
-
- // remove background id task in case our upload was done in the background
- [[UIApplication sharedApplication] endBackgroundTask:self.command.backgroundTaskID];
- self.command.backgroundTaskID = UIBackgroundTaskInvalid;
-}
-
-- (void)removeTargetFile
-{
- NSFileManager* fileMgr = [NSFileManager defaultManager];
-
- [fileMgr removeItemAtPath:self.target error:nil];
-}
-
-- (void)cancelTransfer:(NSURLConnection*)connection
-{
- [connection cancel];
- [self.command.activeTransfers removeObjectForKey:self.objectId];
- [self removeTargetFile];
-}
-
-- (void)cancelTransferWithError:(NSURLConnection*)connection errorMessage:(NSString*)errorMessage
-{
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsDictionary:[self.command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:self.source AndTarget:self.target AndHttpStatus:self.responseCode AndBody:errorMessage]];
-
- NSLog(@"File Transfer Error: %@", errorMessage);
- [self cancelTransfer:connection];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
- NSError* __autoreleasing error = nil;
-
- self.mimeType = [response MIMEType];
- self.targetFileHandle = nil;
-
- // required for iOS 4.3, for some reason; response is
- // a plain NSURLResponse, not the HTTP subclass
- if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
- NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
-
- self.responseCode = [httpResponse statusCode];
- self.bytesExpected = [response expectedContentLength];
- if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode == 200) && (self.bytesExpected == NSURLResponseUnknownLength)) {
- // Kick off HEAD request to server to get real length
- // bytesExpected will be updated when that response is returned
- self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self];
- }
- } else if ([response.URL isFileURL]) {
- NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil];
- self.responseCode = 200;
- self.bytesExpected = [attr[NSFileSize] longLongValue];
- } else {
- self.responseCode = 200;
- self.bytesExpected = NSURLResponseUnknownLength;
- }
- if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode >= 200) && (self.responseCode < 300)) {
- // Download response is okay; begin streaming output to file
- NSString* parentPath = [self.target stringByDeletingLastPathComponent];
-
- // create parent directories if needed
- if ([[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error] == NO) {
- if (error) {
- [self cancelTransferWithError:connection errorMessage:[NSString stringWithFormat:@"Could not create path to save downloaded file: %@", [error localizedDescription]]];
- } else {
- [self cancelTransferWithError:connection errorMessage:@"Could not create path to save downloaded file"];
- }
- return;
- }
- // create target file
- if ([[NSFileManager defaultManager] createFileAtPath:self.target contents:nil attributes:nil] == NO) {
- [self cancelTransferWithError:connection errorMessage:@"Could not create target file"];
- return;
- }
- // open target file for writing
- self.targetFileHandle = [NSFileHandle fileHandleForWritingAtPath:self.target];
- if (self.targetFileHandle == nil) {
- [self cancelTransferWithError:connection errorMessage:@"Could not open target file for writing"];
- }
- DLog(@"Streaming to file %@", target);
- }
-}
-
-- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
-{
- NSString* body = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:body]];
-
- NSLog(@"File Transfer Error: %@", [error localizedDescription]);
-
- [self cancelTransfer:connection];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{
- self.bytesTransfered += data.length;
- if (self.targetFileHandle) {
- [self.targetFileHandle writeData:data];
- } else {
- [self.responseData appendData:data];
- }
- [self updateProgress];
-}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected
-{
- DLog(@"Updating bytesExpected to %d", newBytesExpected);
- self.bytesExpected = newBytesExpected;
- [self updateProgress];
-}
-
-- (void)updateProgress
-{
- if (self.direction == CDV_TRANSFER_DOWNLOAD) {
- BOOL lengthComputable = (self.bytesExpected != NSURLResponseUnknownLength);
- // If the response is GZipped, and we have an outstanding HEAD request to get
- // the length, then hold off on sending progress events.
- if (!lengthComputable && (self.entityLengthRequest != nil)) {
- return;
- }
- NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
- [downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"];
- [downloadProgress setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"loaded"];
- [downloadProgress setObject:[NSNumber numberWithInt:self.bytesExpected] forKey:@"total"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress];
- [result setKeepCallbackAsBool:true];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
-{
- if (self.direction == CDV_TRANSFER_UPLOAD) {
- NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-
- [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
- [uploadProgress setObject:[NSNumber numberWithInt:totalBytesWritten] forKey:@"loaded"];
- [uploadProgress setObject:[NSNumber numberWithInt:totalBytesExpectedToWrite] forKey:@"total"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];
- [result setKeepCallbackAsBool:true];
- [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- self.bytesTransfered = totalBytesWritten;
-}
-
-// for self signed certificates
-- (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
-{
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
- if (self.trustAllHosts) {
- NSURLCredential* credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
- [challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
- }
- [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
- } else {
- [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
- }
-}
-
-- (id)init
-{
- if ((self = [super init])) {
- self.responseData = [NSMutableData data];
- self.targetFileHandle = nil;
- }
- return self;
-}
-
-@end;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 3500567..09c8af3 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F584B991385A28900ED25E8 /* CDVCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F584B9A1385A28900ED25E8 /* CDVCapture.m */; };
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /* CDVPluginResult.m */; };
301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 301F2F2914F3C9CA003FE9FC /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -21,8 +19,6 @@
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
- 30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C5F1DD15AF9E950052A00D /* CDVDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C5F1DE15AF9E950052A00D /* CDVDevice.m */; };
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */; };
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C684921407044A004C1A8E /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -42,8 +38,6 @@
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
- 8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD711090FBE7009987E8 /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD311090FBE7009987E8 /* CDVFile.m */; };
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -51,8 +45,6 @@
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
- C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = C937A4541337599E002C4C79 /* CDVFileTransfer.h */; settings = {ATTRIBUTES = (Public, ); }; };
- C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = C937A4551337599E002C4C79 /* CDVFileTransfer.m */; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -70,8 +62,6 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 1F584B991385A28900ED25E8 /* CDVCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCapture.h; path = Classes/CDVCapture.h; sourceTree = "<group>"; };
- 1F584B9A1385A28900ED25E8 /* CDVCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCapture.m; path = Classes/CDVCapture.m; sourceTree = "<group>"; };
1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree = "<group>"; };
1F92F49F1314023E0046367C /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVPluginResult.m; path = Classes/CDVPluginResult.m; sourceTree = "<group>"; };
301F2F2914F3C9CA003FE9FC /* CDV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDV.h; path = Classes/CDV.h; sourceTree = "<group>"; };
@@ -85,8 +75,6 @@
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
- 30C5F1DD15AF9E950052A00D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = Classes/CDVDevice.h; sourceTree = "<group>"; };
- 30C5F1DE15AF9E950052A00D /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = Classes/CDVDevice.m; sourceTree = "<group>"; };
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWhitelist.m; path = Classes/CDVWhitelist.m; sourceTree = "<group>"; };
30C684921407044A004C1A8E /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVURLProtocol.h; path = Classes/CDVURLProtocol.h; sourceTree = "<group>"; };
@@ -119,8 +107,6 @@
8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
- 8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
- 8887FD311090FBE7009987E8 /* CDVFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFile.m; path = Classes/CDVFile.m; sourceTree = "<group>"; };
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInvokedUrlCommand.h; path = Classes/CDVInvokedUrlCommand.h; sourceTree = "<group>"; };
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
@@ -130,8 +116,6 @@
8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
- C937A4541337599E002C4C79 /* CDVFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFileTransfer.h; path = Classes/CDVFileTransfer.h; sourceTree = "<group>"; };
- C937A4551337599E002C4C79 /* CDVFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFileTransfer.m; path = Classes/CDVFileTransfer.m; sourceTree = "<group>"; };
EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandQueue.h; path = Classes/CDVCommandQueue.h; sourceTree = "<group>"; };
EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCommandQueue.m; path = Classes/CDVCommandQueue.m; sourceTree = "<group>"; };
EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandDelegateImpl.h; path = Classes/CDVCommandDelegateImpl.h; sourceTree = "<group>"; };
@@ -224,8 +208,6 @@
children = (
EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */,
EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */,
- 30C5F1DD15AF9E950052A00D /* CDVDevice.h */,
- 30C5F1DE15AF9E950052A00D /* CDVDevice.m */,
301F2F2914F3C9CA003FE9FC /* CDV.h */,
3034979A1513D56A0090E688 /* CDVLocalStorage.h */,
3034979B1513D56A0090E688 /* CDVLocalStorage.m */,
@@ -243,16 +225,10 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 1F584B991385A28900ED25E8 /* CDVCapture.h */,
- 1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
+ EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
- 8887FD301090FBE7009987E8 /* CDVFile.h */,
- 8887FD311090FBE7009987E8 /* CDVFile.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
- C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
- C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
@@ -306,15 +282,12 @@
buildActionMask = 2147483647;
files = (
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
- 8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
- C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */,
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
- 1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
@@ -328,7 +301,6 @@
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */,
3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */,
EBA3557315ABD38C00F4DE24 /* NSArray+Comparisons.h in Headers */,
- 30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */,
EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */,
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */,
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */,
@@ -396,15 +368,12 @@
buildActionMask = 2147483647;
files = (
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
- 8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
- C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */,
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
- 1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
@@ -414,7 +383,6 @@
3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */,
3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */,
EBA3557515ABD38C00F4DE24 /* NSArray+Comparisons.m in Sources */,
- 30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */,
EB80C2AD15DEA63D004D9E7B /* CDVEcho.m in Sources */,
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */,
EB3B357D161F2A45003DBE7D /* CDVCommandDelegateImpl.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 38af0bc..1771906 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -52,24 +52,12 @@
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
- <feature name="Device">
- <param name="ios-package" value="CDVDevice"/>
- </feature>
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="File">
- <param name="ios-package" value="CDVFile"/>
- </feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection"/>
</feature>
- <feature name="FileTransfer">
- <param name="ios-package" value="CDVFileTransfer"/>
- </feature>
- <feature name="Capture">
- <param name="ios-package" value="CDVCapture"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[31/50] [abbrv] removed device, capture, file, filetransfer
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
deleted file mode 100644
index 9487dd4..0000000
--- a/CordovaLib/Classes/CDVFile.m
+++ /dev/null
@@ -1,1426 +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.
- */
-
-#import "CDVFile.h"
-#import "NSArray+Comparisons.h"
-#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"
-
-extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
-
-#ifndef __IPHONE_5_1
- NSString* const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
-#endif
-
-NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
-
-@implementation CDVFile
-
-@synthesize appDocsPath, appLibraryPath, appTempPath, persistentPath, temporaryPath, userHasAllowed;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVFile*)[super initWithWebView:theWebView];
- if (self) {
- // get the documents directory path
- NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- self.appDocsPath = [paths objectAtIndex:0];
-
- paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
- self.appLibraryPath = [paths objectAtIndex:0];
-
- self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath]; // remove trailing slash from NSTemporaryDirectory()
-
- self.persistentPath = [NSString stringWithFormat:@"/%@", [self.appDocsPath lastPathComponent]];
- self.temporaryPath = [NSString stringWithFormat:@"/%@", [self.appTempPath lastPathComponent]];
- // NSLog(@"docs: %@ - temp: %@", self.appDocsPath, self.appTempPath);
- }
-
- return self;
-}
-
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath
-{
- NSFileManager* fMgr = [[NSFileManager alloc] init];
-
- NSError* __autoreleasing pError = nil;
-
- NSDictionary* pDict = [fMgr attributesOfFileSystemForPath:appPath error:&pError];
- NSNumber* pNumAvail = (NSNumber*)[pDict objectForKey:NSFileSystemFreeSize];
-
- return pNumAvail;
-}
-
-// figure out if the pathFragment represents a persistent of temporary directory and return the full application path.
-// returns nil if path is not persistent or temporary
-- (NSString*)getAppPath:(NSString*)pathFragment
-{
- NSString* appPath = nil;
- NSRange rangeP = [pathFragment rangeOfString:self.persistentPath];
- NSRange rangeT = [pathFragment rangeOfString:self.temporaryPath];
-
- if ((rangeP.location != NSNotFound) && (rangeT.location != NSNotFound)) {
- // we found both in the path, return whichever one is first
- if (rangeP.length < rangeT.length) {
- appPath = self.appDocsPath;
- } else {
- appPath = self.appTempPath;
- }
- } else if (rangeP.location != NSNotFound) {
- appPath = self.appDocsPath;
- } else if (rangeT.location != NSNotFound) {
- appPath = self.appTempPath;
- }
- return appPath;
-}
-
-/* get the full path to this resource
- * IN
- * NSString* pathFragment - full Path from File or Entry object (includes system path info)
- * OUT
- * NSString* fullPath - full iOS path to this resource, nil if not found
- */
-
-/* Was here in order to NOT have to return full path, but W3C synchronous DirectoryEntry.toURI() killed that idea since I can't call into iOS to
- * resolve full URI. Leaving this code here in case W3C spec changes.
--(NSString*) getFullPath: (NSString*)pathFragment
-{
- return pathFragment;
- NSString* fullPath = nil;
- NSString *appPath = [ self getAppPath: pathFragment];
- if (appPath){
-
- // remove last component from appPath
- NSRange range = [appPath rangeOfString:@"/" options: NSBackwardsSearch];
- NSString* newPath = [appPath substringToIndex:range.location];
- // add pathFragment to get test Path
- fullPath = [newPath stringByAppendingPathComponent:pathFragment];
- }
- return fullPath;
-} */
-
-/* Request the File System info
- *
- * IN:
- * arguments[0] - type (number as string)
- * TEMPORARY = 0, PERSISTENT = 1;
- * arguments[1] - size
- *
- * OUT:
- * Dictionary representing FileSystem object
- * name - the human readable directory name
- * root = DirectoryEntry object
- * bool isDirectory
- * bool isFile
- * string name
- * string fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference !!
- */
-
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command
-{
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* strType = [arguments objectAtIndex:0];
- unsigned long long size = [[arguments objectAtIndex:1] longLongValue];
-
- int type = [strType intValue];
- CDVPluginResult* result = nil;
-
- if (type > 1) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:NOT_FOUND_ERR];
- NSLog(@"iOS only supports TEMPORARY and PERSISTENT file systems");
- } else {
- // NSString* fullPath = [NSString stringWithFormat:@"/%@", (type == 0 ? [self.appTempPath lastPathComponent] : [self.appDocsPath lastPathComponent])];
- NSString* fullPath = (type == 0 ? self.appTempPath : self.appDocsPath);
- // check for avail space for size request
- NSNumber* pNumAvail = [self checkFreeDiskSpace:fullPath];
- // NSLog(@"Free space: %@", [NSString stringWithFormat:@"%qu", [ pNumAvail unsignedLongLongValue ]]);
- if (pNumAvail && ([pNumAvail unsignedLongLongValue] < size)) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:QUOTA_EXCEEDED_ERR];
- } else {
- NSMutableDictionary* fileSystem = [NSMutableDictionary dictionaryWithCapacity:2];
- [fileSystem setObject:(type == TEMPORARY ? kW3FileTemporary : kW3FilePersistent) forKey:@"name"];
- NSDictionary* dirEntry = [self getDirectoryEntry:fullPath isDirectory:YES];
- [fileSystem setObject:dirEntry forKey:@"root"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- }
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* Creates a dictionary representing an Entry Object
- *
- * IN:
- * NSString* fullPath of the entry
- * FileSystem type
- * BOOL isDirectory - YES if this is a directory, NO if is a file
- * OUT:
- * NSDictionary*
- Entry object
- * bool as NSNumber isDirectory
- * bool as NSNumber isFile
- * NSString* name - last part of path
- * NSString* fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir
-{
- NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:4];
- NSString* lastPart = [fullPath lastPathComponent];
-
- [dirEntry setObject:[NSNumber numberWithBool:!isDir] forKey:@"isFile"];
- [dirEntry setObject:[NSNumber numberWithBool:isDir] forKey:@"isDirectory"];
- // NSURL* fileUrl = [NSURL fileURLWithPath:fullPath];
- // [dirEntry setObject: [fileUrl absoluteString] forKey: @"fullPath"];
- [dirEntry setObject:fullPath forKey:@"fullPath"];
- [dirEntry setObject:lastPart forKey:@"name"];
-
- return dirEntry;
-}
-
-/*
- * Given a URI determine the File System information associated with it and return an appropriate W3C entry object
- * IN
- * NSString* fileURI - currently requires full file URI
- * OUT
- * Entry object
- * bool isDirectory
- * bool isFile
- * string name
- * string fullPath
- * fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* inputUri = [command.arguments objectAtIndex:0];
-
- // don't know if string is encoded or not so unescape
- NSString* cleanUri = [inputUri stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- // now escape in order to create URL
- NSString* strUri = [cleanUri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL* testUri = [NSURL URLWithString:strUri];
- CDVPluginResult* result = nil;
-
- if (!testUri) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
- } else if ([testUri isFileURL]) {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSString* path = [testUri path];
- // NSLog(@"url path: %@", path);
- BOOL isDir = NO;
- // see if exists and is file or dir
- BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];
- if (bExists) {
- // see if it contains docs path
- NSRange range = [path rangeOfString:self.appDocsPath];
- NSString* foundFullPath = nil;
- // there's probably an api or easier way to figure out the path type but I can't find it!
- if ((range.location != NSNotFound) && (range.length == [self.appDocsPath length])) {
- foundFullPath = self.appDocsPath;
- } else {
- // see if it contains the temp path
- range = [path rangeOfString:self.appTempPath];
- if ((range.location != NSNotFound) && (range.length == [self.appTempPath length])) {
- foundFullPath = self.appTempPath;
- }
- }
- if (foundFullPath == nil) {
- // error SECURITY_ERR - not one of the two paths types supported
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SECURITY_ERR];
- } else {
- NSDictionary* fileSystem = [self getDirectoryEntry:path isDirectory:isDir];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- }
- } else {
- // return NOT_FOUND_ERR
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
- } else if ([strUri hasPrefix:@"assets-library://"]) {
- NSDictionary* fileSystem = [self getDirectoryEntry:strUri isDirectory:NO];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
- }
-
- if (result != nil) {
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }
-}
-
-/* Part of DirectoryEntry interface, creates or returns the specified directory
- * IN:
- * NSString* fullPath - full path for this directory
- * NSString* path - directory to be created/returned; may be full path or relative path
- * NSDictionary* - Flags object
- * boolean as NSNumber create -
- * if create is true and directory does not exist, create dir and return directory entry
- * if create is true and exclusive is true and directory does exist, return error
- * if create is false and directory does not exist, return error
- * if create is false and the path represents a file, return error
- * boolean as NSNumber exclusive - used in conjunction with create
- * if exclusive is true and create is true - specifies failure if directory already exists
- *
- *
- */
-- (void)getDirectory:(CDVInvokedUrlCommand*)command
-{
- NSMutableArray* arguments = [NSMutableArray arrayWithArray:command.arguments];
- NSMutableDictionary* options = nil;
-
- if ([arguments count] >= 3) {
- options = [arguments objectAtIndex:2 withDefault:nil];
- }
- // add getDir to options and call getFile()
- if (options != nil) {
- options = [NSMutableDictionary dictionaryWithDictionary:options];
- } else {
- options = [NSMutableDictionary dictionaryWithCapacity:1];
- }
- [options setObject:[NSNumber numberWithInt:1] forKey:@"getDir"];
- if ([arguments count] >= 3) {
- [arguments replaceObjectAtIndex:2 withObject:options];
- } else {
- [arguments addObject:options];
- }
- CDVInvokedUrlCommand* subCommand =
- [[CDVInvokedUrlCommand alloc] initWithArguments:arguments
- callbackId:command.callbackId
- className:command.className
- methodName:command.methodName];
-
- [self getFile:subCommand];
-}
-
-/* Part of DirectoryEntry interface, creates or returns the specified file
- * IN:
- * NSString* fullPath - full path for this file
- * NSString* path - file to be created/returned; may be full path or relative path
- * NSDictionary* - Flags object
- * boolean as NSNumber create -
- * if create is true and file does not exist, create file and return File entry
- * if create is true and exclusive is true and file does exist, return error
- * if create is false and file does not exist, return error
- * if create is false and the path represents a directory, return error
- * boolean as NSNumber exclusive - used in conjunction with create
- * if exclusive is true and create is true - specifies failure if file already exists
- *
- *
- */
-- (void)getFile:(CDVInvokedUrlCommand*)command
-{
- // arguments are URL encoded
- NSString* fullPath = [command.arguments objectAtIndex:0];
- NSString* requestedPath = [command.arguments objectAtIndex:1];
- NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-
- // return unsupported result for assets-library URLs
- if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFile not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- BOOL bDirRequest = NO;
- BOOL create = NO;
- BOOL exclusive = NO;
- int errorCode = 0; // !!! risky - no error code currently defined for 0
-
- if ([options valueForKeyIsNumber:@"create"]) {
- create = [(NSNumber*)[options valueForKey:@"create"] boolValue];
- }
- if ([options valueForKeyIsNumber:@"exclusive"]) {
- exclusive = [(NSNumber*)[options valueForKey:@"exclusive"] boolValue];
- }
-
- if ([options valueForKeyIsNumber:@"getDir"]) {
- // this will not exist for calls directly to getFile but will have been set by getDirectory before calling this method
- bDirRequest = [(NSNumber*)[options valueForKey:@"getDir"] boolValue];
- }
- // see if the requested path has invalid characters - should we be checking for more than just ":"?
- if ([requestedPath rangeOfString:@":"].location != NSNotFound) {
- errorCode = ENCODING_ERR;
- } else {
- // was full or relative path provided?
- NSRange range = [requestedPath rangeOfString:fullPath];
- BOOL bIsFullPath = range.location != NSNotFound;
-
- NSString* reqFullPath = nil;
-
- if (!bIsFullPath) {
- reqFullPath = [fullPath stringByAppendingPathComponent:requestedPath];
- } else {
- reqFullPath = requestedPath;
- }
-
- // NSLog(@"reqFullPath = %@", reqFullPath);
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- BOOL bIsDir;
- BOOL bExists = [fileMgr fileExistsAtPath:reqFullPath isDirectory:&bIsDir];
- if (bExists && (create == NO) && (bIsDir == !bDirRequest)) {
- // path exists and is of requested type - return TYPE_MISMATCH_ERR
- errorCode = TYPE_MISMATCH_ERR;
- } else if (!bExists && (create == NO)) {
- // path does not exist and create is false - return NOT_FOUND_ERR
- errorCode = NOT_FOUND_ERR;
- } else if (bExists && (create == YES) && (exclusive == YES)) {
- // file/dir already exists and exclusive and create are both true - return PATH_EXISTS_ERR
- errorCode = PATH_EXISTS_ERR;
- } else {
- // if bExists and create == YES - just return data
- // if bExists and create == NO - just return data
- // if !bExists and create == YES - create and return data
- BOOL bSuccess = YES;
- NSError __autoreleasing* pError = nil;
- if (!bExists && (create == YES)) {
- if (bDirRequest) {
- // create the dir
- bSuccess = [fileMgr createDirectoryAtPath:reqFullPath withIntermediateDirectories:NO attributes:nil error:&pError];
- } else {
- // create the empty file
- bSuccess = [fileMgr createFileAtPath:reqFullPath contents:nil attributes:nil];
- }
- }
- if (!bSuccess) {
- errorCode = ABORT_ERR;
- if (pError) {
- NSLog(@"error creating directory: %@", [pError localizedDescription]);
- }
- } else {
- // NSLog(@"newly created file/dir (%@) exists: %d", reqFullPath, [fileMgr fileExistsAtPath:reqFullPath]);
- // file existed or was created
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:reqFullPath isDirectory:bDirRequest]];
- }
- } // are all possible conditions met?
- }
-
- if (errorCode > 0) {
- // create error callback
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * Look up the parent Entry containing this Entry.
- * If this Entry is the root of its filesystem, its parent is itself.
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * NSMutableDictionary* options
- * empty
- */
-- (void)getParent:(CDVInvokedUrlCommand*)command
-{
- // arguments are URL encoded
- NSString* fullPath = [command.arguments objectAtIndex:0];
-
- // we don't (yet?) support getting the parent of an asset
- if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
- NSString* newPath = nil;
-
- if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
- // return self
- newPath = fullPath;
- } else {
- // since this call is made from an existing Entry object - the parent should already exist so no additional error checking
- // remove last component and return Entry
- NSRange range = [fullPath rangeOfString:@"/" options:NSBackwardsSearch];
- newPath = [fullPath substringToIndex:range.location];
- }
-
- if (newPath) {
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- BOOL bIsDir;
- BOOL bExists = [fileMgr fileExistsAtPath:newPath isDirectory:&bIsDir];
- if (bExists) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:newPath isDirectory:bIsDir]];
- }
- }
- if (!result) {
- // invalid path or file does not exist
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * get MetaData of entry
- * Currently MetaData only includes modificationTime.
- */
-- (void)getMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
- __block CDVPluginResult* result = nil;
-
- 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! 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;
- }
-
- NSString* testPath = argPath; // [self getFullPath: argPath];
-
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing error = nil;
-
- NSDictionary* fileAttribs = [fileMgr attributesOfItemAtPath:testPath error:&error];
-
- if (fileAttribs) {
- NSDate* modDate = [fileAttribs fileModificationDate];
- if (modDate) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[modDate timeIntervalSince1970] * 1000];
- }
- } else {
- // didn't get fileAttribs
- CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [error localizedDescription]);
- if ([error code] == NSFileNoSuchFileError) {
- errorCode = NOT_FOUND_ERR;
- }
- // log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];
- }
- if (!result) {
- // invalid path or file does not exist
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * set MetaData of entry
- * Currently we only support "com.apple.MobileBackup" (boolean)
- */
-- (void)setMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* filePath = [command.arguments objectAtIndex:0];
- NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:nil];
- CDVPluginResult* result = nil;
- BOOL ok = NO;
-
- // 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);
- }
- }
- }
- }
-
- if (ok) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* removes the directory or file entry
- * IN:
- * NSArray* arguments
- * 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 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];
- CDVPluginResult* result = nil;
- CDVFileError errorCode = 0; // !! 0 not currently defined
-
- // 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];
- BOOL bIsDir = NO;
- BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
- if (!bExists) {
- errorCode = NOT_FOUND_ERR;
- }
- if (bIsDir && ([[fileMgr contentsOfDirectoryAtPath:fullPath error:nil] count] != 0)) {
- // dir is not empty
- errorCode = INVALID_MODIFICATION_ERR;
- }
- }
- if (errorCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- } else {
- // perform actual remove
- result = [self doRemove:fullPath];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* recursively removes the directory
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- *
- * returns NO_MODIFICATION_ALLOWED_ERR if is top level directory or no permission to delete dir
- * returns NOT_FOUND_ERR if file or dir is not found
- */
-- (void)removeRecursively:(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:@"removeRecursively not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
-
- // error if try to remove top level (documents or tmp) dir
- if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- } else {
- result = [self doRemove:fullPath];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* remove the file or directory (recursively)
- * IN:
- * NSString* fullPath - the full path to the file or directory to be removed
- * NSString* callbackId
- * called from remove and removeRecursively - check all pubic api specific error conditions (dir not empty, etc) before calling
- */
-
-- (CDVPluginResult*)doRemove:(NSString*)fullPath
-{
- CDVPluginResult* result = nil;
- BOOL bSuccess = NO;
- NSError* __autoreleasing pError = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- @try {
- bSuccess = [fileMgr removeItemAtPath:fullPath error:&pError];
- if (bSuccess) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- // see if we can give a useful error
- CDVFileError errorCode = ABORT_ERR;
- NSLog(@"error getting metadata: %@", [pError localizedDescription]);
- if ([pError code] == NSFileNoSuchFileError) {
- errorCode = NOT_FOUND_ERR;
- } else if ([pError code] == NSFileWriteNoPermissionError) {
- errorCode = NO_MODIFICATION_ALLOWED_ERR;
- }
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
- } @catch(NSException* e) { // NSInvalidArgumentException if path is . or ..
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SYNTAX_ERR];
- }
-
- return result;
-}
-
-- (void)copyTo:(CDVInvokedUrlCommand*)command
-{
- [self doCopyMove:command isCopy:YES];
-}
-
-- (void)moveTo:(CDVInvokedUrlCommand*)command
-{
- [self doCopyMove:command isCopy:NO];
-}
-
-/**
- * Helper function to check to see if the user attempted to copy an entry into its parent without changing its name,
- * or attempted to copy a directory into a directory that it contains directly or indirectly.
- *
- * IN:
- * NSString* srcDir
- * NSString* destinationDir
- * OUT:
- * YES copy/ move is allows
- * NO move is onto itself
- */
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest
-{
- // This weird test is to determine if we are copying or moving a directory into itself.
- // Copy /Documents/myDir to /Documents/myDir-backup is okay but
- // Copy /Documents/myDir to /Documents/myDir/backup not okay
- BOOL copyOK = YES;
- NSRange range = [dest rangeOfString:src];
-
- if (range.location != NSNotFound) {
- NSRange testRange = {range.length - 1, ([dest length] - range.length)};
- NSRange resultRange = [dest rangeOfString:@"/" options:0 range:testRange];
- if (resultRange.location != NSNotFound) {
- copyOK = NO;
- }
- }
- return copyOK;
-}
-
-/* Copy/move a file or directory to a new location
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath of entry
- * 1 - NSString* newName the new name of the entry, defaults to the current name
- * NSMutableDictionary* options - DirectoryEntry to which to copy the entry
- * BOOL - bCopy YES if copy, NO if move
- *
- */
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy
-{
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* srcFullPath = [arguments objectAtIndex:0];
- NSString* destRootPath = [arguments objectAtIndex:1];
- // optional argument
- NSString* newName = ([arguments count] > 2) ? [arguments objectAtIndex:2] : [srcFullPath lastPathComponent]; // use last component from appPath if new name not provided
-
- __block CDVPluginResult* result = nil;
- CDVFileError errCode = 0; // !! Currently 0 is not defined, use this to signal error !!
-
- /*NSString* destRootPath = nil;
- NSString* key = @"fullPath";
- if([options valueForKeyIsString:key]){
- destRootPath = [options objectForKey:@"fullPath"];
- }*/
-
- if (!destRootPath) {
- // no destination provided
- errCode = NOT_FOUND_ERR;
- } else if ([newName rangeOfString:@":"].location != NSNotFound) {
- // invalid chars in new name
- 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 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;
- BOOL bSrcExists = [fileMgr fileExistsAtPath:srcFullPath isDirectory:&bSrcIsDir];
- BOOL bDestExists = [fileMgr fileExistsAtPath:destRootPath isDirectory:&bDestIsDir];
- BOOL bNewExists = [fileMgr fileExistsAtPath:newFullPath isDirectory:&bNewIsDir];
- if (!bSrcExists || !bDestExists) {
- // the source or the destination root does not exist
- errCode = NOT_FOUND_ERR;
- } else if (bSrcIsDir && (bNewExists && !bNewIsDir)) {
- // can't copy/move dir to file
- errCode = INVALID_MODIFICATION_ERR;
- } else { // no errors yet
- NSError* __autoreleasing error = nil;
- BOOL bSuccess = NO;
- if (bCopy) {
- if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath] /*[newFullPath hasPrefix:srcFullPath]*/) {
- // can't copy dir into self
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bNewExists) {
- // the full destination should NOT already exist if a copy
- errCode = PATH_EXISTS_ERR;
- } else {
- bSuccess = [fileMgr copyItemAtPath:srcFullPath toPath:newFullPath error:&error];
- }
- } else { // move
- // iOS requires that destination must not exist before calling moveTo
- // is W3C INVALID_MODIFICATION_ERR error if destination dir exists and has contents
- //
- if (!bSrcIsDir && (bNewExists && bNewIsDir)) {
- // can't move a file to directory
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath]) { // [newFullPath hasPrefix:srcFullPath]){
- // can't move a dir into itself
- errCode = INVALID_MODIFICATION_ERR;
- } else if (bNewExists) {
- if (bNewIsDir && ([[fileMgr contentsOfDirectoryAtPath:newFullPath error:NULL] count] != 0)) {
- // can't move dir to a dir that is not empty
- errCode = INVALID_MODIFICATION_ERR;
- newFullPath = nil; // so we won't try to move
- } else {
- // remove destination so can perform the moveItemAtPath
- bSuccess = [fileMgr removeItemAtPath:newFullPath error:NULL];
- if (!bSuccess) {
- errCode = INVALID_MODIFICATION_ERR; // is this the correct error?
- newFullPath = nil;
- }
- }
- } else if (bNewIsDir && [newFullPath hasPrefix:srcFullPath]) {
- // can't move a directory inside itself or to any child at any depth;
- errCode = INVALID_MODIFICATION_ERR;
- newFullPath = nil;
- }
-
- if (newFullPath != nil) {
- bSuccess = [fileMgr moveItemAtPath:srcFullPath toPath:newFullPath error:&error];
- }
- }
- if (bSuccess) {
- // should verify it is there and of the correct type???
- NSDictionary* newEntry = [self getDirectoryEntry:newFullPath isDirectory:bSrcIsDir]; // should be the same type as source
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];
- } else {
- errCode = INVALID_MODIFICATION_ERR; // catch all
- if (error) {
- if (([error code] == NSFileReadUnknownError) || ([error code] == NSFileReadTooLargeError)) {
- errCode = NOT_READABLE_ERR;
- } else if ([error code] == NSFileWriteOutOfSpaceError) {
- errCode = QUOTA_EXCEEDED_ERR;
- } else if ([error code] == NSFileWriteNoPermissionError) {
- errCode = NO_MODIFICATION_ALLOWED_ERR;
- }
- }
- }
- }
- }
- }
- if (errCode > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errCode];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* return the URI to the entry
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath of entry
- * 1 - desired mime type of entry - ignored - always returns file://
- */
-
-/* Not needed since W3C toURI is synchronous. Leaving code here for now in case W3C spec changes.....
-- (void) toURI:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* argPath = [command.arguments objectAtIndex:0];
- PluginResult* result = nil;
- NSString* jsString = nil;
-
- NSString* fullPath = [self getFullPath: argPath];
- if (fullPath) {
- // do we need to make sure the file actually exists?
- // create file uri
- NSString* strUri = [fullPath stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
- NSURL* fileUrl = [NSURL fileURLWithPath:strUri];
- if (fileUrl) {
- result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: [fileUrl absoluteString]];
- jsString = [result toSuccessCallbackString:callbackId];
- } // else NOT_FOUND_ERR
- }
- if(!jsString) {
- // was error
- result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: NOT_FOUND_ERR cast: @"window.localFileSystem._castError"];
- jsString = [result toErrorCallbackString:callbackId];
- }
-
- [self writeJavascript:jsString];
-}*/
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- __block CDVPluginResult* result = nil;
-
- NSString* fullPath = argPath; // [self getFullPath: argPath];
-
- if (fullPath) {
- 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 {
- 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) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_INSTANTIATION_EXCEPTION];
- }
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readEntries:(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:@"readEntries not supported for assets-library URLs."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- CDVPluginResult* result = nil;
-
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing error = nil;
- NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fullPath error:&error];
-
- if (contents) {
- NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];
- if ([contents count] > 0) {
- // create an Entry (as JSON) for each file/dir
- for (NSString* name in contents) {
- // see if is dir or file
- NSString* entryPath = [fullPath stringByAppendingPathComponent:name];
- BOOL bIsDir = NO;
- [fileMgr fileExistsAtPath:entryPath isDirectory:&bIsDir];
- NSDictionary* entryDict = [self getDirectoryEntry:entryPath isDirectory:bIsDir];
- [entries addObject:entryDict];
- }
- }
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:entries];
- } else {
- // assume not found but could check error for more specific error conditions
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readFileWithPath:(NSString*)path start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback
-{
- if (path == nil) {
- callback(nil, nil, SYNTAX_ERR);
- } else {
- [self.commandDelegate runInBackground:^ {
- if ([path 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 = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
-
- callback(data, MIMEType, NO_ERROR);
- } else {
- callback(nil, nil, NOT_FOUND_ERR);
- }
- };
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
- // Retrieving the asset failed for some reason. Send the appropriate error.
- NSLog(@"Error: %@", error);
- callback(nil, nil, SECURITY_ERR);
- };
-
- ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
- [assetsLibrary assetForURL:[NSURL URLWithString:path] resultBlock:resultBlock failureBlock:failureBlock];
- } else {
- NSString* mimeType = [self getMimeTypeFromPath:path];
- if (mimeType == nil) {
- mimeType = @"*/*";
- }
- NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:path];
- if (start > 0) {
- [file seekToFileOffset:start];
- }
-
- NSData* readData;
- if (end < 0) {
- readData = [file readDataToEndOfFile];
- } else {
- readData = [file readDataOfLength:(end - start)];
- }
-
- [file closeFile];
-
- callback(readData, mimeType, readData != nil ? NO_ERROR : NOT_FOUND_ERR);
- }
- }];
- }
-}
-
-/* read and return file data
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* encoding
- * 2 - NSString* start
- * 3 - NSString* end
- */
-- (void)readAsText:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* path = [command argumentAtIndex:0];
- NSString* encoding = [command argumentAtIndex:1];
- NSInteger start = [[command argumentAtIndex:2] integerValue];
- NSInteger end = [[command argumentAtIndex:3] integerValue];
-
- // TODO: implement
- if (![@"UTF-8" isEqualToString : encoding]) {
- NSLog(@"Only UTF-8 encodings are currently supported by readAsText");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ENCODING_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- NSString* str = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSUTF8StringEncoding freeWhenDone:NO];
- // Check that UTF8 conversion did not fail.
- if (str != nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:str];
- result.associatedObject = data;
- } else {
- errorCode = ENCODING_ERR;
- }
- }
- if (result == nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* Read content of text file and return as base64 encoded data url.
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* start
- * 2 - NSString* end
- *
- * Determines the mime type from the file extension, returns ENCODING_ERR if mimetype can not be determined.
- */
-
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- // TODO: Would be faster to base64 encode directly to the final string.
- NSString* output = [NSString stringWithFormat:@"data:%@;base64,%@", mimeType, [data base64EncodedString]];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:output];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* Read content of text file and return as an arraybuffer
- * IN:
- * NSArray* arguments
- * 0 - NSString* fullPath
- * 1 - NSString* start
- * 2 - NSString* end
- */
-
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArrayBuffer:data];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-- (void)readAsBinaryString:(CDVInvokedUrlCommand*)command
-{
- NSString* path = [command argumentAtIndex:0];
- NSInteger start = [[command argumentAtIndex:1] integerValue];
- NSInteger end = [[command argumentAtIndex:2] integerValue];
-
- [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
- CDVPluginResult* result = nil;
- if (data != nil) {
- NSString* payload = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSASCIIStringEncoding freeWhenDone:NO];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload];
- result.associatedObject = data;
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }];
-}
-
-/* helper function to get the mimeType from the file extension
- * IN:
- * NSString* fullPath - filename (may include path)
- * OUT:
- * NSString* the mime type as type/subtype. nil if not able to determine
- */
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath
-{
- NSString* mimeType = nil;
-
- if (fullPath) {
- CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);
- if (typeId) {
- mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);
- if (!mimeType) {
- // special case for m4a
- if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {
- mimeType = @"audio/mp4";
- } else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {
- mimeType = @"audio/wav";
- }
- }
- CFRelease(typeId);
- }
- }
- return mimeType;
-}
-
-- (void)truncate:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
- unsigned long long pos = (unsigned long long)[[command.arguments objectAtIndex:1] longLongValue];
-
- // assets-library files can't be truncated
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSString* appFile = argPath; // [self getFullPath:argPath];
-
- unsigned long long newPos = [self truncateFile:appFile atPosition:pos];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:newPos];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos
-{
- unsigned long long newPos = 0UL;
-
- NSFileHandle* file = [NSFileHandle fileHandleForWritingAtPath:filePath];
-
- if (file) {
- [file truncateFileAtOffset:(unsigned long long)pos];
- newPos = [file offsetInFile];
- [file synchronizeFile];
- [file closeFile];
- }
- return newPos;
-}
-
-/* write
- * IN:
- * NSArray* arguments
- * 0 - NSString* file path to write to
- * 1 - NSString* or NSData* data to write
- * 2 - NSNumber* position to begin writing
- */
-- (void)write:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* arguments = command.arguments;
-
- // arguments
- NSString* argPath = [arguments objectAtIndex:0];
- id argData = [arguments objectAtIndex:1];
- unsigned long long pos = (unsigned long long)[[arguments objectAtIndex:2] longLongValue];
-
- // text can't be written into assets-library files
- if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- NSString* fullPath = argPath; // [self getFullPath:argPath];
-
- [self truncateFile:fullPath atPosition:pos];
-
- if ([argData isKindOfClass:[NSString class]]) {
- [self writeToFile:fullPath withString:argData encoding:NSUTF8StringEncoding append:YES callback:callbackId];
- } else if ([argData isKindOfClass:[NSData class]]) {
- [self writeToFile:fullPath withData:argData append:YES callback:callbackId];
- } else {
- CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid parameter type"];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
-}
-
-- (void)writeToFile:(NSString*)filePath withData:(NSData*)encData append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
- CDVFileError errCode = INVALID_MODIFICATION_ERR;
- int bytesWritten = 0;
-
- if (filePath) {
- NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];
- if (fileStream) {
- NSUInteger len = [encData length];
- [fileStream open];
-
- bytesWritten = [fileStream write:[encData bytes] maxLength:len];
-
- [fileStream close];
- if (bytesWritten > 0) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
- // } else {
- // can probably get more detailed error info via [fileStream streamError]
- // errCode already set to INVALID_MODIFICATION_ERR;
- // bytesWritten = 0; // may be set to -1 on error
- }
- } // else fileStream not created return INVALID_MODIFICATION_ERR
- } else {
- // invalid filePath
- errCode = NOT_FOUND_ERR;
- }
- if (!result) {
- // was an error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)writeToFile:(NSString*)filePath withString:(NSString*)stringData encoding:(NSStringEncoding)encoding append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
- [self writeToFile:filePath withData:[stringData dataUsingEncoding:encoding allowLossyConversion:YES] append:shouldAppend callback:callbackId];
-}
-
-- (void)testFileExists:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- // Get the file manager
- NSFileManager* fMgr = [NSFileManager defaultManager];
- NSString* appFile = argPath; // [ self getFullPath: argPath];
-
- BOOL bExists = [fMgr fileExistsAtPath:appFile];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(bExists ? 1 : 0)];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command
-{
- // arguments
- NSString* argPath = [command.arguments objectAtIndex:0];
-
- // Get the file manager
- NSFileManager* fMgr = [[NSFileManager alloc] init];
- NSString* appFile = argPath; // [self getFullPath: argPath];
- BOOL bIsDir = NO;
- BOOL bExists = [fMgr fileExistsAtPath:appFile isDirectory:&bIsDir];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:((bExists && bIsDir) ? 1 : 0)];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-// Returns number of bytes available via callback
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command
-{
- // no arguments
-
- NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];
-
- NSString* strFreeSpace = [NSString stringWithFormat:@"%qu", [pNumAvail unsignedLongLongValue]];
- // NSLog(@"Free space is %@", strFreeSpace );
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:strFreeSpace];
-
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/43d748ce/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
deleted file mode 100644
index 35e3fdd..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ /dev/null
@@ -1,82 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileTransferError {
- FILE_NOT_FOUND_ERR = 1,
- INVALID_URL_ERR = 2,
- CONNECTION_ERR = 3,
- CONNECTION_ABORTED = 4
-};
-typedef int CDVFileTransferError;
-
-enum CDVFileTransferDirection {
- CDV_TRANSFER_UPLOAD = 1,
- CDV_TRANSFER_DOWNLOAD = 2,
-};
-typedef int CDVFileTransferDirection;
-
-// Magic value within the options dict used to set a cookie.
-extern NSString* const kOptionsKeyCookie;
-
-@interface CDVFileTransfer : CDVPlugin {}
-
-- (void)upload:(CDVInvokedUrlCommand*)command;
-- (void)download:(CDVInvokedUrlCommand*)command;
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString;
-
-// Visible for testing.
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData;
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
- AndSource:(NSString*)source
- AndTarget:(NSString*)target
- AndHttpStatus:(int)httpStatus
- AndBody:(NSString*)body;
-@property (readonly) NSMutableDictionary* activeTransfers;
-@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskID;
-@end
-
-@class CDVFileTransferEntityLengthRequest;
-
-@interface CDVFileTransferDelegate : NSObject {}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected;
-- (void)cancelTransfer:(NSURLConnection*)connection;
-
-@property (strong) NSMutableData* responseData; // atomic
-@property (nonatomic, strong) CDVFileTransfer* command;
-@property (nonatomic, assign) CDVFileTransferDirection direction;
-@property (nonatomic, strong) NSURLConnection* connection;
-@property (nonatomic, copy) NSString* callbackId;
-@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;
-@property (nonatomic, assign) BOOL trustAllHosts;
-@property (strong) NSFileHandle* targetFileHandle;
-@property (nonatomic, strong) CDVFileTransferEntityLengthRequest* entityLengthRequest;
-
-@end;
[44/50] [abbrv] ios commit: [CB-3530] Updated unit tests
Posted by ag...@apache.org.
[CB-3530] Updated unit tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f7b82dab
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f7b82dab
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f7b82dab
Branch: refs/heads/2.9.x
Commit: f7b82dab42fe7f45042c3d7c0a898e0c60940019
Parents: f721482
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Jun 25 16:02:23 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Jun 25 16:02:23 2013 -0700
----------------------------------------------------------------------
CordovaLibTests/CDVWebViewDelegateTests.m | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f7b82dab/CordovaLibTests/CDVWebViewDelegateTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVWebViewDelegateTests.m b/CordovaLibTests/CDVWebViewDelegateTests.m
index 1e536fa..ad05213 100644
--- a/CordovaLibTests/CDVWebViewDelegateTests.m
+++ b/CordovaLibTests/CDVWebViewDelegateTests.m
@@ -38,23 +38,28 @@
- (void)testFragmentIdentifiersWithHttpUrl
{
- [self doTestFragmentIdentifiersWithBaseUrl:@"http://cordova.apache.org"];
+ [self doTestFragmentIdentifiersWithBaseUrl:@"http://cordova.apache.org" fragment:@"myfragment"];
}
- (void)testFragmentIdentifiersWithFileUrl
{
- [self doTestFragmentIdentifiersWithBaseUrl:@"file:///var/mobile/GASGEQGQsdga3313/www/index.html"];
+ [self doTestFragmentIdentifiersWithBaseUrl:@"file:///var/mobile/GASGEQGQsdga3313/www/index.html" fragment:@"myfragment"];
}
-- (void)doTestFragmentIdentifiersWithBaseUrl:(NSString*)baseUrl
+- (void)testFragmentIdentifiersWithFileUrlAndMalformedFragment
+{
+ [self doTestFragmentIdentifiersWithBaseUrl:@"file:///var/mobile/GASGEQGQsdga3313/www/index.html" fragment:@"/var/mobile/GASGEQGQsdga3313/www/index.html"];
+}
+
+- (void)doTestFragmentIdentifiersWithBaseUrl:(NSString*)baseUrl fragment:(NSString*)fragment
{
CDVWebViewDelegate* wvd = [[CDVWebViewDelegate alloc] initWithDelegate:nil]; // not really testing delegate handling
NSString* originalUrlString = baseUrl;
NSURL* originalUrl = [NSURL URLWithString:originalUrlString];
- NSURL* originalUrlWithFragmentOnly = [NSURL URLWithString:[NSString stringWithFormat:@"%@#myfragment", originalUrlString]];
+ NSURL* originalUrlWithFragmentOnly = [NSURL URLWithString:[NSString stringWithFormat:@"%@#%@", originalUrlString, fragment]];
NSURL* originalUrlWithFragmentOnlyNoIdentifier = [NSURL URLWithString:[NSString stringWithFormat:@"%@#", originalUrlString]];
- NSURL* originalUrlWithQueryParamsAndFragment = [NSURL URLWithString:[NSString stringWithFormat:@"%@?foo=bar#myfragment", originalUrlString]];
+ NSURL* originalUrlWithQueryParamsAndFragment = [NSURL URLWithString:[NSString stringWithFormat:@"%@?foo=bar#%@", originalUrlString, fragment]];
NSURLRequest* originalRequest = [NSURLRequest requestWithURL:originalUrl];
NSURLRequest* originalRequestWithFragmentOnly = [NSURLRequest requestWithURL:originalUrlWithFragmentOnly];
[34/50] [abbrv] ios commit: fixed duplication with file plugin issue
Posted by ag...@apache.org.
fixed duplication with file plugin issue
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/33b2858e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/33b2858e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/33b2858e
Branch: refs/heads/master
Commit: 33b2858ea1877e310c0e76168c59a349f31af54c
Parents: 57dbc0a
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:18:49 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:33 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVURLProtocol.m | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/33b2858e/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
index 3c85f34..9bd4050 100644
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ b/CordovaLib/Classes/CDVURLProtocol.m
@@ -35,7 +35,7 @@ static CDVWhitelist* gWhitelist = nil;
// the actual pointer to avoid retaining.
static NSMutableSet* gRegisteredControllers = nil;
-NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
+NSString* const kCDVAssetsLibraryPrefixs = @"assets-library://";
// Returns the registered view controller that sent the given request.
// If the user-agent is not from a UIWebView, or if it's from an unregistered one,
@@ -110,7 +110,7 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
NSURL* theUrl = [theRequest URL];
CDVViewController* viewController = viewControllerForRequest(theRequest);
- if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
+ if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixs]) {
return YES;
} else if (viewController != nil) {
if ([[theUrl path] isEqualToString:@"/!gap_exec"]) {
@@ -159,7 +159,7 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
if ([[url path] isEqualToString:@"/!gap_exec"]) {
[self sendResponseWithResponseCode:200 data:nil mimeType:nil];
return;
- } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
+ } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixs]) {
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
if (asset) {
// We have the asset! Get the data and send it along.
[08/50] [abbrv] ios commit: updated js
Posted by ag...@apache.org.
updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b6869e1f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b6869e1f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b6869e1f
Branch: refs/heads/master
Commit: b6869e1f52b880a7b6086aebbaf97d1b15d0b061
Parents: b428f24
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:05:59 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 17:05:59 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVURLProtocol.m | 3 +-
CordovaLib/cordova.js | 182 +------------------------------
2 files changed, 4 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b6869e1f/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
index afc10de..3c85f34 100644
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ b/CordovaLib/Classes/CDVURLProtocol.m
@@ -25,7 +25,6 @@
#import "CDVCommandQueue.h"
#import "CDVWhitelist.h"
#import "CDVViewController.h"
-#import "CDVFile.h"
@interface CDVHTTPURLResponse : NSHTTPURLResponse
@property (nonatomic) NSInteger statusCode;
@@ -36,6 +35,8 @@ static CDVWhitelist* gWhitelist = nil;
// the actual pointer to avoid retaining.
static NSMutableSet* gRegisteredControllers = nil;
+NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
+
// Returns the registered view controller that sent the given request.
// If the user-agent is not from a UIWebView, or if it's from an unregistered one,
// then nil is returned.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b6869e1f/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index e05b317..d5fdb7d 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-116-gf0108ae
+// 2.7.0rc1-119-gf0251c4
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-119-gf0251c4';
// file: lib/scripts/require.js
var require,
@@ -731,9 +731,6 @@ channel.createSticky('onCordovaReady');
// Event to indicate that device properties are available
channel.createSticky('onCordovaInfoReady');
-// Event to indicate that the connection property has been set.
-channel.createSticky('onCordovaConnectionReady');
-
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
channel.createSticky('onPluginsReady');
@@ -751,7 +748,6 @@ channel.createSticky('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaConnectionReady');
channel.waitForInitialization('onDOMContentLoaded');
module.exports = channel;
@@ -1240,25 +1236,6 @@ module.exports = ConfigurationData;
});
-// file: lib/common/plugin/Connection.js
-define("cordova/plugin/Connection", function(require, exports, module) {
-
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- CELL:"cellular",
- NONE: "none"
-};
-
-});
-
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
@@ -3332,77 +3309,6 @@ for (var key in console) {
});
-// file: lib/common/plugin/device.js
-define("cordova/plugin/device", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.uuid = null;
- this.cordova = null;
- this.model = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- var buildLabel = info.cordova;
- if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
- buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
- }
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.uuid = info.uuid;
- me.cordova = buildLabel;
- me.model = info.model;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
- argscheck.checkArgs('fF', 'Device.getInfo', arguments);
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-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) {
@@ -3876,90 +3782,6 @@ modulemapper.clobbers('cordova/plugin/MediaError', 'MediaError');
});
-// file: lib/common/plugin/network.js
-define("cordova/plugin/network", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils');
-
-// Link the onLine property with the Cordova-supplied network info.
-// This works because we clobber the naviagtor object with our own
-// object in bootstrap.js.
-if (typeof navigator != 'undefined') {
- utils.defineGetter(navigator, 'onLine', function() {
- return this.connection.type != 'none';
- });
-}
-
-function NetworkConnection() {
- this.type = 'unknown';
-}
-
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
- */
-NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
-};
-
-var me = new NetworkConnection();
-var timerId = null;
-var timeout = 500;
-
-channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- timerId = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- timerId = null;
- }, timeout);
- } else {
- // If there is a current offline event pending clear it
- if (timerId !== null) {
- clearTimeout(timerId);
- timerId = null;
- }
- cordova.fireDocumentEvent("online");
- }
-
- // should only fire this once
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
-});
-
-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/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
[33/50] [abbrv] ios commit: updated js
Posted by ag...@apache.org.
updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/57dbc0a9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/57dbc0a9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/57dbc0a9
Branch: refs/heads/master
Commit: 57dbc0a9f96d2b54ddb8aad7e0d2d7739dbaccae
Parents: 43d748c
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:05:59 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:33 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVURLProtocol.m | 3 +-
CordovaLib/cordova.js | 186 ++-----------------------------
2 files changed, 10 insertions(+), 179 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/57dbc0a9/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
index afc10de..3c85f34 100644
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ b/CordovaLib/Classes/CDVURLProtocol.m
@@ -25,7 +25,6 @@
#import "CDVCommandQueue.h"
#import "CDVWhitelist.h"
#import "CDVViewController.h"
-#import "CDVFile.h"
@interface CDVHTTPURLResponse : NSHTTPURLResponse
@property (nonatomic) NSInteger statusCode;
@@ -36,6 +35,8 @@ static CDVWhitelist* gWhitelist = nil;
// the actual pointer to avoid retaining.
static NSMutableSet* gRegisteredControllers = nil;
+NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
+
// Returns the registered view controller that sent the given request.
// If the user-agent is not from a UIWebView, or if it's from an unregistered one,
// then nil is returned.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/57dbc0a9/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index e8bc477..1690aba 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -3,6 +3,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
=======
// 2.7.0rc1-84-g62c5786
@@ -16,6 +17,9 @@
=======
// 2.7.0rc1-116-gf0108ae
>>>>>>> updated cordovajs
+=======
+// 2.7.0rc1-119-gf0251c4
+>>>>>>> updated js
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -39,6 +43,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
@@ -52,6 +57,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
>>>>>>> updated cordovajs
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-119-gf0251c4';
+>>>>>>> updated js
// file: lib/scripts/require.js
var require,
@@ -763,9 +771,6 @@ channel.createSticky('onCordovaReady');
// Event to indicate that device properties are available
channel.createSticky('onCordovaInfoReady');
-// Event to indicate that the connection property has been set.
-channel.createSticky('onCordovaConnectionReady');
-
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
channel.createSticky('onPluginsReady');
@@ -783,7 +788,6 @@ channel.createSticky('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaConnectionReady');
channel.waitForInitialization('onDOMContentLoaded');
module.exports = channel;
@@ -1272,25 +1276,6 @@ module.exports = ConfigurationData;
});
-// file: lib/common/plugin/Connection.js
-define("cordova/plugin/Connection", function(require, exports, module) {
-
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- CELL:"cellular",
- NONE: "none"
-};
-
-});
-
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
@@ -3386,77 +3371,6 @@ for (var key in console) {
});
-// file: lib/common/plugin/device.js
-define("cordova/plugin/device", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.uuid = null;
- this.cordova = null;
- this.model = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- var buildLabel = info.cordova;
- if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
- buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
- }
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.uuid = info.uuid;
- me.cordova = buildLabel;
- me.model = info.model;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
- argscheck.checkArgs('fF', 'Device.getInfo', arguments);
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-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) {
@@ -3930,90 +3844,6 @@ modulemapper.clobbers('cordova/plugin/MediaError', 'MediaError');
});
-// file: lib/common/plugin/network.js
-define("cordova/plugin/network", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils');
-
-// Link the onLine property with the Cordova-supplied network info.
-// This works because we clobber the naviagtor object with our own
-// object in bootstrap.js.
-if (typeof navigator != 'undefined') {
- utils.defineGetter(navigator, 'onLine', function() {
- return this.connection.type != 'none';
- });
-}
-
-function NetworkConnection() {
- this.type = 'unknown';
-}
-
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
- */
-NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
-};
-
-var me = new NetworkConnection();
-var timerId = null;
-var timeout = 500;
-
-channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- timerId = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- timerId = null;
- }, timeout);
- } else {
- // If there is a current offline event pending clear it
- if (timerId !== null) {
- clearTimeout(timerId);
- timerId = null;
- }
- cordova.fireDocumentEvent("online");
- }
-
- // should only fire this once
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
-});
-
-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/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
[19/50] [abbrv] removed native plugin files for various plugins
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
deleted file mode 100644
index 6cb9f08..0000000
--- a/CordovaLib/Classes/CDVContacts.m
+++ /dev/null
@@ -1,593 +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.
- */
-
-#import "CDVContacts.h"
-#import <UIKit/UIKit.h>
-#import "NSArray+Comparisons.h"
-#import "NSDictionary+Extensions.h"
-#import "CDVNotification.h"
-
-@implementation CDVContactsPicker
-
-@synthesize allowsEditing;
-@synthesize callbackId;
-@synthesize options;
-@synthesize pickedContactDictionary;
-
-@end
-@implementation CDVNewContactsController
-
-@synthesize callbackId;
-
-@end
-
-@implementation CDVContacts
-
-// no longer used since code gets AddressBook for each operation.
-// If address book changes during save or remove operation, may get error but not much we can do about it
-// If address book changes during UI creation, display or edit, we don't control any saves so no need for callback
-
-/*void addressBookChanged(ABAddressBookRef addressBook, CFDictionaryRef info, void* context)
-{
- // note that this function is only called when another AddressBook instance modifies
- // the address book, not the current one. For example, through an OTA MobileMe sync
- Contacts* contacts = (Contacts*)context;
- [contacts addressBookDirty];
-}*/
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVContacts*)[super initWithWebView:(UIWebView*)theWebView];
-
- /*if (self) {
- addressBook = ABAddressBookCreate();
- ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);
- }*/
-
- return self;
-}
-
-// overridden to clean up Contact statics
-- (void)onAppTerminate
-{
- // NSLog(@"Contacts::onAppTerminate");
-}
-
-// iPhone only method to create a new contact through the GUI
-- (void)newContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error just return (no error callback)
- return;
- }
- CDVNewContactsController* npController = [[CDVNewContactsController alloc] init];
- npController.addressBook = addrBook; // a CF retaining assign
- CFRelease(addrBook);
-
- npController.newPersonViewDelegate = self;
- npController.callbackId = callbackId;
-
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:npController];
-
- if ([weakSelf.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [weakSelf.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [weakSelf.viewController presentModalViewController:navController animated:YES];
- }
- }];
-}
-
-- (void)newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person
-{
- ABRecordID recordId = kABRecordInvalidID;
- CDVNewContactsController* newCP = (CDVNewContactsController*)newPersonViewController;
- NSString* callbackId = newCP.callbackId;
-
- if (person != NULL) {
- // return the contact id
- recordId = ABRecordGetRecordID(person);
- }
-
- if ([newPersonViewController respondsToSelector:@selector(presentingViewController)]) {
- [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[newPersonViewController parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:recordId];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)displayContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- ABRecordID recordID = [[command.arguments objectAtIndex:0] intValue];
- NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:[NSNull null]];
- bool bEdit = [options isKindOfClass:[NSNull class]] ? false : [options existsValue:@"true" forKey:@"allowsEditing"];
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errCode ? errCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
- ABRecordRef rec = ABAddressBookGetPersonWithRecordID(addrBook, recordID);
-
- if (rec) {
- CDVDisplayContactViewController* personController = [[CDVDisplayContactViewController alloc] init];
- personController.displayedPerson = rec;
- personController.personViewDelegate = self;
- personController.allowsEditing = NO;
-
- // create this so DisplayContactViewController will have a "back" button.
- UIViewController* parentController = [[UIViewController alloc] init];
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:parentController];
-
- [navController pushViewController:personController animated:YES];
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:navController animated:YES];
- }
-
- if (bEdit) {
- // create the editing controller and push it onto the stack
- ABPersonViewController* editPersonController = [[ABPersonViewController alloc] init];
- editPersonController.displayedPerson = rec;
- editPersonController.personViewDelegate = self;
- editPersonController.allowsEditing = YES;
- [navController pushViewController:editPersonController animated:YES];
- }
- } else {
- // no record, return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- CFRelease(addrBook);
- }];
-}
-
-- (BOOL)personViewController:(ABPersonViewController*)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
- property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
-{
- return YES;
-}
-
-- (void)chooseContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:[NSNull null]];
-
- CDVContactsPicker* pickerController = [[CDVContactsPicker alloc] init];
-
- pickerController.peoplePickerDelegate = self;
- pickerController.callbackId = callbackId;
- pickerController.options = options;
- pickerController.pickedContactDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kABRecordInvalidID], kW3ContactId, nil];
- pickerController.allowsEditing = (BOOL)[options existsValue : @"true" forKey : @"allowsEditing"];
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
-}
-
-- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person
-{
- CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
- NSNumber* pickedId = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
-
- if (picker.allowsEditing) {
- ABPersonViewController* personController = [[ABPersonViewController alloc] init];
- personController.displayedPerson = person;
- personController.personViewDelegate = self;
- personController.allowsEditing = picker.allowsEditing;
- // store id so can get info in peoplePickerNavigationControllerDidCancel
- picker.pickedContactDictionary = [NSDictionary dictionaryWithObjectsAndKeys:pickedId, kW3ContactId, nil];
-
- [peoplePicker pushViewController:personController animated:YES];
- } else {
- // Retrieve and return pickedContact information
- CDVContact* pickedContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)person];
- NSArray* fields = [picker.options objectForKey:@"fields"];
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
- picker.pickedContactDictionary = [pickedContact toDictionary:returnFields];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
- [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
- return NO;
-}
-
-- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
-{
- return YES;
-}
-
-- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController*)peoplePicker
-{
- // return contactId or invalid if none picked
- CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
-
- if (picker.allowsEditing) {
- // get the info after possible edit
- // if we got this far, user has already approved/ disapproved addressBook access
- ABAddressBookRef addrBook = nil;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- if (&ABAddressBookCreateWithOptions != NULL) {
- addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
- } else
-#endif
- {
- // iOS 4 & 5
- addrBook = ABAddressBookCreate();
- }
- ABRecordRef person = ABAddressBookGetPersonWithRecordID(addrBook, [[picker.pickedContactDictionary objectForKey:kW3ContactId] integerValue]);
- if (person) {
- CDVContact* pickedContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)person];
- NSArray* fields = [picker.options objectForKey:@"fields"];
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
- picker.pickedContactDictionary = [pickedContact toDictionary:returnFields];
- }
- CFRelease(addrBook);
- }
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
- [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
-
- if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) {
- [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-}
-
-- (void)search:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* fields = [command.arguments objectAtIndex:0];
- NSDictionary* findOptions = [command.arguments objectAtIndex:1 withDefault:[NSNull null]];
-
- [self.commandDelegate runInBackground:^{
- // from Apple: Important You must ensure that an instance of ABAddressBookRef is used by only one thread.
- // which is why address book is created within the dispatch queue.
- // more details here: http: //blog.byadrian.net/2012/05/05/ios-addressbook-framework-and-gcd/
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
- // it gets uglier, block within block.....
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errCode ? errCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- NSArray* foundRecords = nil;
- // get the findOptions values
- BOOL multiple = NO; // default is false
- NSString* filter = nil;
- if (![findOptions isKindOfClass:[NSNull class]]) {
- id value = nil;
- filter = (NSString*)[findOptions objectForKey:@"filter"];
- value = [findOptions objectForKey:@"multiple"];
- if ([value isKindOfClass:[NSNumber class]]) {
- // multiple is a boolean that will come through as an NSNumber
- multiple = [(NSNumber*)value boolValue];
- // NSLog(@"multiple is: %d", multiple);
- }
- }
-
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
-
- NSMutableArray* matches = nil;
- if (!filter || [filter isEqualToString:@""]) {
- // get all records
- foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
- if (foundRecords && ([foundRecords count] > 0)) {
- // create Contacts and put into matches array
- // doesn't make sense to ask for all records when multiple == NO but better check
- int xferCount = multiple == YES ? [foundRecords count] : 1;
- matches = [NSMutableArray arrayWithCapacity:xferCount];
-
- for (int k = 0; k < xferCount; k++) {
- CDVContact* xferContact = [[CDVContact alloc] initFromABRecord:(__bridge ABRecordRef)[foundRecords objectAtIndex:k]];
- [matches addObject:xferContact];
- xferContact = nil;
- }
- }
- } else {
- foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
- matches = [NSMutableArray arrayWithCapacity:1];
- BOOL bFound = NO;
- int testCount = [foundRecords count];
-
- for (int j = 0; j < testCount; j++) {
- CDVContact* testContact = [[CDVContact alloc] initFromABRecord:(__bridge ABRecordRef)[foundRecords objectAtIndex:j]];
- if (testContact) {
- bFound = [testContact foundValue:filter inFields:returnFields];
- if (bFound) {
- [matches addObject:testContact];
- }
- testContact = nil;
- }
- }
- }
- NSMutableArray* returnContacts = [NSMutableArray arrayWithCapacity:1];
-
- if ((matches != nil) && ([matches count] > 0)) {
- // convert to JS Contacts format and return in callback
- // - returnFields determines what properties to return
- @autoreleasepool {
- int count = multiple == YES ? [matches count] : 1;
-
- for (int i = 0; i < count; i++) {
- CDVContact* newContact = [matches objectAtIndex:i];
- NSDictionary* aContact = [newContact toDictionary:returnFields];
- [returnContacts addObject:aContact];
- }
- }
- }
- // return found contacts (array is empty if no contacts found)
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:returnContacts];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- // NSLog(@"findCallback string: %@", jsString);
-
- if (addrBook) {
- CFRelease(addrBook);
- }
- }];
- }]; // end of workQueue block
-
- return;
-}
-
-- (void)save:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* contactDict = [command.arguments objectAtIndex:0];
-
- [self.commandDelegate runInBackground:^{
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errorCode) {
- CDVPluginResult* result = nil;
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode ? errorCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool bIsError = FALSE, bSuccess = FALSE;
- BOOL bUpdate = NO;
- CDVContactError errCode = UNKNOWN_ERROR;
- CFErrorRef error;
- NSNumber* cId = [contactDict valueForKey:kW3ContactId];
- CDVContact* aContact = nil;
- ABRecordRef rec = nil;
- if (cId && ![cId isKindOfClass:[NSNull class]]) {
- rec = ABAddressBookGetPersonWithRecordID(addrBook, [cId intValue]);
- if (rec) {
- aContact = [[CDVContact alloc] initFromABRecord:rec];
- bUpdate = YES;
- }
- }
- if (!aContact) {
- aContact = [[CDVContact alloc] init];
- }
-
- bSuccess = [aContact setFromContactDict:contactDict asUpdate:bUpdate];
- if (bSuccess) {
- if (!bUpdate) {
- bSuccess = ABAddressBookAddRecord(addrBook, [aContact record], &error);
- }
- if (bSuccess) {
- bSuccess = ABAddressBookSave(addrBook, &error);
- }
- if (!bSuccess) { // need to provide error codes
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- // give original dictionary back? If generate dictionary from saved contact, have no returnFields specified
- // so would give back all fields (which W3C spec. indicates is not desired)
- // for now (while testing) give back saved, full contact
- NSDictionary* newContact = [aContact toDictionary:[CDVContact defaultFields]];
- // NSString* contactStr = [newContact JSONRepresentation];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newContact];
- }
- } else {
- bIsError = TRUE;
- errCode = IO_ERROR;
- }
- CFRelease(addrBook);
-
- if (bIsError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
-
- if (result) {
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- }];
- }]; // end of queue
-}
-
-- (void)remove:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSNumber* cId = [command.arguments objectAtIndex:0];
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errorCode) {
- CDVPluginResult* result = nil;
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode ? errorCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool bIsError = FALSE, bSuccess = FALSE;
- CDVContactError errCode = UNKNOWN_ERROR;
- CFErrorRef error;
- ABRecordRef rec = nil;
- if (cId && ![cId isKindOfClass:[NSNull class]] && ([cId intValue] != kABRecordInvalidID)) {
- rec = ABAddressBookGetPersonWithRecordID(addrBook, [cId intValue]);
- if (rec) {
- bSuccess = ABAddressBookRemoveRecord(addrBook, rec, &error);
- if (!bSuccess) {
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- bSuccess = ABAddressBookSave(addrBook, &error);
- if (!bSuccess) {
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- // set id to null
- // [contactDict setObject:[NSNull null] forKey:kW3ContactId];
- // result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: contactDict];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- // NSString* contactStr = [contactDict JSONRepresentation];
- }
- }
- } else {
- // no record found return error
- bIsError = TRUE;
- errCode = UNKNOWN_ERROR;
- }
- } else {
- // invalid contact id provided
- bIsError = TRUE;
- errCode = INVALID_ARGUMENT_ERROR;
- }
-
- if (addrBook) {
- CFRelease(addrBook);
- }
- if (bIsError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
- if (result) {
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- }];
- return;
-}
-
-@end
-
-/* ABPersonViewController does not have any UI to dismiss. Adding navigationItems to it does not work properly
- * The navigationItems are lost when the app goes into the background. The solution was to create an empty
- * NavController in front of the ABPersonViewController. This will cause the ABPersonViewController to have a back button. By subclassing the ABPersonViewController, we can override viewDidDisappear and take down the entire NavigationController.
- */
-@implementation CDVDisplayContactViewController
-@synthesize contactsPlugin;
-
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
-
- if ([self respondsToSelector:@selector(presentingViewController)]) {
- [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- }
-}
-
-@end
-@implementation CDVAddressBookAccessError
-
-@synthesize errorCode;
-
-- (CDVAddressBookAccessError*)initWithCode:(CDVContactError)code
-{
- self = [super init];
- if (self) {
- self.errorCode = code;
- }
- return self;
-}
-
-@end
-
-@implementation CDVAddressBookHelper
-
-/**
- * NOTE: workerBlock is responsible for releasing the addressBook that is passed to it
- */
-- (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock
-{
- // TODO: this probably should be reworked - seems like the workerBlock can just create and release its own AddressBook,
- // and also this important warning from (http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/BasicObjects.html):
- // "Important: Instances of ABAddressBookRef cannot be used by multiple threads. Each thread must make its own instance."
- ABAddressBookRef addressBook;
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- if (&ABAddressBookCreateWithOptions != NULL) {
- CFErrorRef error = nil;
- // CFIndex status = ABAddressBookGetAuthorizationStatus();
- addressBook = ABAddressBookCreateWithOptions(NULL, &error);
- // NSLog(@"addressBook access: %lu", status);
- ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
- // callback can occur in background, address book must be accessed on thread it was created on
- dispatch_sync(dispatch_get_main_queue(), ^{
- if (error) {
- workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
- } else if (!granted) {
- workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
- } else {
- // access granted
- workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
- }
- });
- });
- } else
-#endif
- {
- // iOS 4 or 5 no checks needed
- addressBook = ABAddressBookCreate();
- workerBlock(addressBook, NULL);
- }
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVGlobalization.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVGlobalization.h b/CordovaLib/Classes/CDVGlobalization.h
deleted file mode 100644
index 0384656..0000000
--- a/CordovaLib/Classes/CDVGlobalization.h
+++ /dev/null
@@ -1,150 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-#define CDV_FORMAT_SHORT 0
-#define CDV_FORMAT_MEDIUM 1
-#define CDV_FORMAT_LONG 2
-#define CDV_FORMAT_FULL 3
-#define CDV_SELECTOR_MONTHS 0
-#define CDV_SELECTOR_DAYS 1
-
-enum CDVGlobalizationError {
- CDV_UNKNOWN_ERROR = 0,
- CDV_FORMATTING_ERROR = 1,
- CDV_PARSING_ERROR = 2,
- CDV_PATTERN_ERROR = 3,
-};
-typedef NSUInteger CDVGlobalizationError;
-
-@interface CDVGlobalization : CDVPlugin {
- CFLocaleRef currentLocale;
-}
-
-- (void)getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns the string identifier for the clients current locale setting.
- * It returns the locale identifier string to the successCB callback with a
- * properties object as a parameter. If there is an error getting the locale,
- * then the errorCB callback is invoked.
- */
-- (void)getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a date formatted as a string according to the clients user preferences and
- * calendar using the time zone of the client. It returns the formatted date string to the
- * successCB callback with a properties object as a parameter. If there is an error
- * formatting the date, then the errorCB callback is invoked.
- *
- * options: "date" contains the number of milliseconds that represents the JavaScript date
- */
-- (void)dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Parses a date formatted as a string according to the clients user
- * preferences and calendar using the time zone of the client and returns
- * the corresponding date object. It returns the date to the successCB
- * callback with a properties object as a parameter. If there is an error
- * parsing the date string, then the errorCB callback is invoked.
- *
- * options: "dateString" contains the JavaScript string to parse for a date
- */
-- (void)stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing dates according to the clients
- * user preferences. It returns the pattern to the successCB callback with a
- * properties object as a parameter. If there is an error obtaining the pattern,
- * then the errorCB callback is invoked.
- *
- */
-- (void)getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns an array of either the names of the months or days of the week
- * according to the clients user preferences and calendar. It returns the array of names to the
- * successCB callback with a properties object as a parameter. If there is an error obtaining the
- * names, then the errorCB callback is invoked.
- *
- */
-- (void)getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns whether daylight savings time is in effect for a given date using the clients
- * time zone and calendar. It returns whether or not daylight savings time is in effect
- * to the successCB callback with a properties object as a parameter. If there is an error
- * reading the date, then the errorCB callback is invoked.
- *
- * options: "date" contains the number of milliseconds that represents the JavaScript date
- *
- */
-- (void)isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns the first day of the week according to the clients user preferences and calendar.
- * The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
- * It returns the day to the successCB callback with a properties object as a parameter.
- * If there is an error obtaining the pattern, then the errorCB callback is invoked.
- *
- */
-- (void)getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a number formatted as a string according to the clients user preferences.
- * It returns the formatted number string to the successCB callback with a properties object as a
- * parameter. If there is an error formatting the number, then the errorCB callback is invoked.
- *
- * options: "number" contains the JavaScript number to format
- *
- */
-- (void)numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Parses a number formatted as a string according to the clients user preferences and
- * returns the corresponding number. It returns the number to the successCB callback with a
- * properties object as a parameter. If there is an error parsing the number string, then
- * the errorCB callback is invoked.
- *
- * options: "numberString" contains the JavaScript string to parse for a number
- *
- */
-- (void)stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing numbers according to the clients user
- * preferences. It returns the pattern to the successCB callback with a properties object as a
- * parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
- *
- */
-- (void)getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing currency values according to the clients
- * user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
- * properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
- * callback is invoked.
- *
- * options: "currencyCode" contains the ISO currency code from JavaScript
- */
-- (void)getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVGlobalization.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVGlobalization.m b/CordovaLib/Classes/CDVGlobalization.m
deleted file mode 100644
index 9eb9721..0000000
--- a/CordovaLib/Classes/CDVGlobalization.m
+++ /dev/null
@@ -1,790 +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.
- */
-
-#import "CDVGlobalization.h"
-
-@implementation CDVGlobalization
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVGlobalization*)[super initWithWebView:theWebView];
- if (self) {
- currentLocale = CFLocaleCopyCurrent();
- }
- return self;
-}
-
-- (void)getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- NSString* callbackId = [arguments objectAtIndex:0];
- CDVPluginResult* result = nil;
-
- NSLog(@"log1");
- // Source: http://stackoverflow.com/questions/3910244/getting-current-device-language-in-ios
- // (should be OK)
- NSString* language = [[NSLocale preferredLanguages] objectAtIndex:0];
-
- if (language) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:language forKey:@"value"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:dictionary];
- } else {
- // TBD is this ever expected to happen?
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callbackId = [arguments objectAtIndex:0];
- NSDictionary* dictionary = nil;
-
- NSLocale* locale = [NSLocale currentLocale];
-
- if (locale) {
- dictionary = [NSDictionary dictionaryWithObject:[locale localeIdentifier] forKey:@"value"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- } else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- NSDate* date = nil;
- NSString* dateString = nil;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- id milliseconds = [options valueForKey:@"date"];
-
- if (milliseconds && [milliseconds isKindOfClass:[NSNumber class]]) {
- // get the number of seconds since 1970 and create the date object
- date = [NSDate dateWithTimeIntervalSince1970:[milliseconds doubleValue] / 1000];
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // create the formatter using the user's current default locale and formats for dates and times
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
- // if we have a valid date object then call the formatter
- if (date) {
- dateString = (__bridge_transfer NSString*)CFDateFormatterCreateStringWithDate(kCFAllocatorDefault,
- formatter,
- (__bridge CFDateRef)date);
- }
-
- // if the date was converted to a string successfully then return the result
- if (dateString) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:dateString forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand dateToString unable to format %@", [date description]);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_FORMATTING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Formatting error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- NSString* dateString = nil;
- NSDateComponents* comps = nil;
-
- // get the string that is to be parsed for a date
- id ms = [options valueForKey:@"dateString"];
-
- if (ms && [ms isKindOfClass:[NSString class]]) {
- dateString = ms;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // get the user's default settings for date and time formats
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
-
- // set the parsing to be more lenient
- CFDateFormatterSetProperty(formatter, kCFDateFormatterIsLenient, kCFBooleanTrue);
-
- // parse tha date and time string
- CFDateRef date = CFDateFormatterCreateDateFromString(kCFAllocatorDefault,
- formatter,
- (__bridge CFStringRef)dateString,
- NULL);
-
- // if we were able to parse the date then get the date and time components
- if (date != NULL) {
- NSCalendar* calendar = [NSCalendar currentCalendar];
-
- unsigned unitFlags = NSYearCalendarUnit |
- NSMonthCalendarUnit |
- NSDayCalendarUnit |
- NSHourCalendarUnit |
- NSMinuteCalendarUnit |
- NSSecondCalendarUnit;
-
- comps = [calendar components:unitFlags fromDate:(__bridge NSDate*)date];
- CFRelease(date);
- }
-
- // put the various elements of the date and time into a dictionary
- if (comps != nil) {
- NSArray* keys = [NSArray arrayWithObjects:@"year", @"month", @"day", @"hour", @"minute", @"second", @"millisecond", nil];
- NSArray* values = [NSArray arrayWithObjects:[NSNumber numberWithInt:[comps year]],
- [NSNumber numberWithInt:[comps month] - 1],
- [NSNumber numberWithInt:[comps day]],
- [NSNumber numberWithInt:[comps hour]],
- [NSNumber numberWithInt:[comps minute]],
- [NSNumber numberWithInt:[comps second]],
- [NSNumber numberWithInt:0], /* iOS does not provide milliseconds */
- nil];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // Dlog(@"GlobalizationCommand stringToDate unable to parse %@", dateString);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PARSING_ERROR] forKey:@"code"];
- [dictionary setValue:@"unable to parse" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // get the user's default settings for date and time formats
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
-
- // get the date pattern to apply when formatting and parsing
- CFStringRef datePattern = CFDateFormatterGetFormat(formatter);
- // get the user's current time zone information
- CFTimeZoneRef timezone = (CFTimeZoneRef)CFDateFormatterCopyProperty(formatter, kCFDateFormatterTimeZone);
-
- // put the pattern and time zone information into the dictionary
- if ((datePattern != nil) && (timezone != nil)) {
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"timezone", @"utc_offset", @"dst_offset", nil];
- NSArray* values = [NSArray arrayWithObjects:((__bridge NSString*)datePattern),
- [((__bridge NSTimeZone*)timezone)abbreviation],
- [NSNumber numberWithLong:[((__bridge NSTimeZone*)timezone)secondsFromGMT]],
- [NSNumber numberWithDouble:[((__bridge NSTimeZone*)timezone)daylightSavingTimeOffset]],
- nil];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Pattern error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- if (timezone) {
- CFRelease(timezone);
- }
- CFRelease(formatter);
-}
-
-- (void)getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- int style = CDV_FORMAT_LONG;
- int selector = CDV_SELECTOR_MONTHS;
- CFStringRef dataStyle = kCFDateFormatterMonthSymbols;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired type of name
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"narrow"]) {
- style = CDV_FORMAT_SHORT;
- } else if ([item isEqualToString:@"wide"]) {
- style = CDV_FORMAT_LONG;
- }
- }
- // determine if months or days are needed
- else if ([key isEqualToString:@"item"]) {
- if ([item isEqualToString:@"months"]) {
- selector = CDV_SELECTOR_MONTHS;
- } else if ([item isEqualToString:@"days"]) {
- selector = CDV_SELECTOR_DAYS;
- }
- }
- }
- }
- }
-
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFDateFormatterFullStyle,
- kCFDateFormatterFullStyle);
-
- if ((selector == CDV_SELECTOR_MONTHS) && (style == CDV_FORMAT_LONG)) {
- dataStyle = kCFDateFormatterMonthSymbols;
- } else if ((selector == CDV_SELECTOR_MONTHS) && (style == CDV_FORMAT_SHORT)) {
- dataStyle = kCFDateFormatterShortMonthSymbols;
- } else if ((selector == CDV_SELECTOR_DAYS) && (style == CDV_FORMAT_LONG)) {
- dataStyle = kCFDateFormatterWeekdaySymbols;
- } else if ((selector == CDV_SELECTOR_DAYS) && (style == CDV_FORMAT_SHORT)) {
- dataStyle = kCFDateFormatterShortWeekdaySymbols;
- }
-
- CFArrayRef names = (CFArrayRef)CFDateFormatterCopyProperty(formatter, dataStyle);
-
- if (names) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:((__bridge NSArray*)names) forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- CFRelease(names);
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- NSDate* date = nil;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- id milliseconds = [options valueForKey:@"date"];
-
- if (milliseconds && [milliseconds isKindOfClass:[NSNumber class]]) {
- // get the number of seconds since 1970 and create the date object
- date = [NSDate dateWithTimeIntervalSince1970:[milliseconds doubleValue] / 1000];
- }
-
- if (date) {
- // get the current calendar for the user and check if the date is using DST
- NSCalendar* calendar = [NSCalendar currentCalendar];
- NSTimeZone* timezone = [calendar timeZone];
- NSNumber* dst = [NSNumber numberWithBool:[timezone isDaylightSavingTimeForDate:date]];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:dst forKey:@"dst"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- NSCalendar* calendar = [NSCalendar autoupdatingCurrentCalendar];
-
- NSNumber* day = [NSNumber numberWithInt:[calendar firstWeekday]];
-
- if (day) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:day forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- NSNumber* number = nil;
-
- id value = [options valueForKey:@"number"];
-
- if (value && [value isKindOfClass:[NSNumber class]]) {
- number = (NSNumber*)value;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- // get the localized string based upon the locale and user preferences
- NSString* numberString = (__bridge_transfer NSString*)CFNumberFormatterCreateStringWithNumber(kCFAllocatorDefault,
- formatter,
- (__bridge CFNumberRef)number);
-
- if (numberString) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:numberString forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand numberToString unable to format %@", [number stringValue]);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_FORMATTING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to format" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- NSString* numberString = nil;
- double doubleValue;
-
- id value = [options valueForKey:@"numberString"];
-
- if (value && [value isKindOfClass:[NSString class]]) {
- numberString = (NSString*)value;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- // we need to make this lenient so as to avoid problems with parsing currencies that have non-breaking space characters
- if (style == kCFNumberFormatterCurrencyStyle) {
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterIsLenient, kCFBooleanTrue);
- }
-
- // parse againist the largest type to avoid data loss
- Boolean rc = CFNumberFormatterGetValueFromString(formatter,
- (__bridge CFStringRef)numberString,
- NULL,
- kCFNumberDoubleType,
- &doubleValue);
-
- if (rc) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:doubleValue] forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand stringToNumber unable to parse %@", numberString);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PARSING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to parse" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- CFStringRef symbolType = NULL;
- NSString* symbol = @"";
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- NSString* numberPattern = (__bridge NSString*)CFNumberFormatterGetFormat(formatter);
-
- if (style == kCFNumberFormatterCurrencyStyle) {
- symbolType = kCFNumberFormatterCurrencySymbol;
- } else if (style == kCFNumberFormatterPercentStyle) {
- symbolType = kCFNumberFormatterPercentSymbol;
- }
-
- if (symbolType) {
- symbol = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, symbolType);
- }
-
- NSString* decimal = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterDecimalSeparator);
- NSString* grouping = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterGroupingSeparator);
- NSString* posSign = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterPlusSign);
- NSString* negSign = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterMinusSign);
- NSNumber* fracDigits = (__bridge_transfer NSNumber*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterMinFractionDigits);
- NSNumber* roundingDigits = (__bridge_transfer NSNumber*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterRoundingIncrement);
-
- // put the pattern information into the dictionary
- if (numberPattern != nil) {
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"symbol", @"fraction", @"rounding",
- @"positive", @"negative", @"decimal", @"grouping", nil];
- NSArray* values = [NSArray arrayWithObjects:numberPattern, symbol, fracDigits, roundingDigits,
- posSign, negSign, decimal, grouping, nil];
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Pattern error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- NSString* currencyCode = nil;
- NSString* numberPattern = nil;
- NSString* decimal = nil;
- NSString* grouping = nil;
- int32_t defaultFractionDigits;
- double roundingIncrement;
- Boolean rc;
-
- id value = [options valueForKey:@"currencyCode"];
-
- if (value && [value isKindOfClass:[NSString class]]) {
- currencyCode = (NSString*)value;
- }
-
- // first see if there is base currency info available and fill in the currency_info structure
- rc = CFNumberFormatterGetDecimalInfoForCurrencyCode((__bridge CFStringRef)currencyCode, &defaultFractionDigits, &roundingIncrement);
-
- // now set the currency code in the formatter
- if (rc) {
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFNumberFormatterCurrencyStyle);
-
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterCurrencyCode, (__bridge CFStringRef)currencyCode);
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterInternationalCurrencySymbol, (__bridge CFStringRef)currencyCode);
-
- numberPattern = (__bridge NSString*)CFNumberFormatterGetFormat(formatter);
- decimal = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterCurrencyDecimalSeparator);
- grouping = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterCurrencyGroupingSeparator);
-
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"code", @"fraction", @"rounding",
- @"decimal", @"grouping", nil];
- NSArray* values = [NSArray arrayWithObjects:numberPattern, currencyCode, [NSNumber numberWithInt:defaultFractionDigits],
- [NSNumber numberWithDouble:roundingIncrement], decimal, grouping, nil];
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- CFRelease(formatter);
- }
- // error
- else {
- // DLog(@"GlobalizationCommand getCurrencyPattern unable to get pattern for %@", currencyCode);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to get pattern" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)dealloc
-{
- if (currentLocale) {
- CFRelease(currentLocale);
- currentLocale = nil;
- }
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb64bf3c/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
deleted file mode 100644
index 248274a..0000000
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ /dev/null
@@ -1,89 +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.
- */
-
-#import "CDVPlugin.h"
-#import "CDVInvokedUrlCommand.h"
-#import "CDVScreenOrientationDelegate.h"
-#import "CDVWebViewDelegate.h"
-
-@class CDVInAppBrowserViewController;
-
-@interface CDVInAppBrowser : CDVPlugin {
- BOOL _injectedIframeBridge;
-}
-
-@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
-@property (nonatomic, copy) NSString* callbackId;
-
-- (void)open:(CDVInvokedUrlCommand*)command;
-- (void)close:(CDVInvokedUrlCommand*)command;
-- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
-- (void)show:(CDVInvokedUrlCommand*)command;
-
-@end
-
-@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
- @private
- NSString* _userAgent;
- NSString* _prevUserAgent;
- NSInteger _userAgentLockToken;
- CDVWebViewDelegate* _webViewDelegate;
-}
-
-@property (nonatomic, strong) IBOutlet UIWebView* webView;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
-@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
-@property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
-@property (nonatomic, strong) IBOutlet UIToolbar* toolbar;
-
-@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
-@property (nonatomic, weak) CDVInAppBrowser* navigationDelegate;
-@property (nonatomic) NSURL* currentURL;
-
-- (void)close;
-- (void)navigateTo:(NSURL*)url;
-- (void)showLocationBar:(BOOL)show;
-- (void)showToolBar:(BOOL)show;
-- (void)setCloseButtonTitle:(NSString*)title;
-
-- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent;
-
-@end
-
-@interface CDVInAppBrowserOptions : NSObject {}
-
-@property (nonatomic, assign) BOOL location;
-@property (nonatomic, assign) BOOL toolbar;
-@property (nonatomic, copy) NSString* closebuttoncaption;
-
-@property (nonatomic, copy) NSString* presentationstyle;
-@property (nonatomic, copy) NSString* transitionstyle;
-
-@property (nonatomic, assign) BOOL enableviewportscale;
-@property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
-@property (nonatomic, assign) BOOL allowinlinemediaplayback;
-@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
-@property (nonatomic, assign) BOOL suppressesincrementalrendering;
-@property (nonatomic, assign) BOOL hidden;
-
-+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
-
-@end
[17/50] [abbrv] ios commit: updated view controller
Posted by ag...@apache.org.
updated view controller
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/165b8bea
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/165b8bea
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/165b8bea
Branch: refs/heads/master
Commit: 165b8bea08e9288eca276f0af0cc6e8e3bf16144
Parents: eb64bf3
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 18:23:37 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:23:51 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVViewController.m | 5 -----
1 file changed, 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/165b8bea/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 94f4552..b186326 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -262,7 +262,6 @@
// /////////////////
- NSNumber* enableLocation = [self.settings objectForKey:@"EnableLocation"];
NSString* enableViewportScale = [self.settings objectForKey:@"EnableViewportScale"];
NSNumber* allowInlineMediaPlayback = [self.settings objectForKey:@"AllowInlineMediaPlayback"];
BOOL mediaPlaybackRequiresUserAction = YES; // default value
@@ -280,10 +279,6 @@
* Fire up the GPS Service right away as it takes a moment for data to come back.
*/
- if ([enableLocation boolValue]) {
- NSLog(@"Deprecated: The 'EnableLocation' boolean property is deprecated in 2.5.0, and will be removed in 3.0.0. Use the 'onload' boolean attribute (of the CDVLocation plugin.");
- [[self.commandDelegate getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand new]];
- }
if (hideKeyboardFormAccessoryBar) {
__weak CDVViewController* weakSelf = self;
[13/50] [abbrv] ios commit: Update JS snapshot to version 2.9.0rc1
(from re-tag)
Posted by ag...@apache.org.
Update JS snapshot to version 2.9.0rc1 (from re-tag)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/478f683a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/478f683a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/478f683a
Branch: refs/heads/2.9.x
Commit: 478f683a1021b97845a57acc4b9bb6a398556cb6
Parents: d9d77c4
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Jun 19 15:10:18 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Jun 19 15:10:18 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 129 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 97 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/478f683a/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index a3d1ae0..b2fc871 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-75-g76065a1
+// 2.9.0rc1-0-g002f33d
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-75-g76065a1';
+var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
// file: lib/scripts/require.js
var require,
@@ -2383,11 +2383,7 @@ function initRead(reader, file) {
reader._error = null;
reader._readyState = FileReader.LOADING;
- if (typeof file == 'string') {
- // Deprecated in Cordova 2.4.
- console.warn('Using a string argument with FileReader.readAs functions is deprecated.');
- reader._fileName = file;
- } else if (typeof file.fullPath == 'string') {
+ if (typeof file.fullPath == 'string') {
reader._fileName = file.fullPath;
} else {
reader._fileName = '';
@@ -3050,9 +3046,31 @@ FileWriter.prototype.abort = function() {
/**
* Writes data to the file
*
- * @param text to be written
+ * @param data text or blob to be written
*/
-FileWriter.prototype.write = function(text) {
+FileWriter.prototype.write = function(data) {
+
+ var isBinary = false;
+
+ // If we don't have Blob or ArrayBuffer support, don't bother.
+ if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
+
+ // Check to see if the incoming data is a blob
+ if (data instanceof Blob) {
+ var that=this;
+ var fileReader = new FileReader();
+ fileReader.onload = function() {
+ // Call this method again, with the arraybuffer as argument
+ FileWriter.prototype.write.call(that, this.result);
+ };
+ fileReader.readAsArrayBuffer(data);
+ return;
+ }
+
+ // Mark data type for safer transport over the binary bridge
+ isBinary = (data instanceof ArrayBuffer);
+ }
+
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);
@@ -3118,7 +3136,7 @@ FileWriter.prototype.write = function(text) {
if (typeof me.onwriteend === "function") {
me.onwriteend(new ProgressEvent("writeend", {"target":me}));
}
- }, "File", "write", [this.fileName, text, this.position]);
+ }, "File", "write", [this.fileName, data, this.position, isBinary]);
};
/**
@@ -3304,6 +3322,9 @@ InAppBrowser.prototype = {
close: function (eventname) {
exec(null, null, "InAppBrowser", "close", []);
},
+ show: function (eventname) {
+ exec(null, null, "InAppBrowser", "show", []);
+ },
addEventListener: function (eventname,f) {
if (eventname in this.channels) {
this.channels[eventname].subscribe(f);
@@ -6354,11 +6375,21 @@ require('cordova/channel').onNativeReady.fire();
}
}
+ function scriptErrorCallback(err) {
+ // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
+ // this is currently just continuing.
+ scriptCounter--;
+ if (scriptCounter === 0) {
+ onScriptLoadingComplete && onScriptLoadingComplete();
+ }
+ }
+
// Helper function to inject a <script> tag.
function injectScript(path) {
scriptCounter++;
var script = document.createElement("script");
script.onload = scriptLoadedCallback;
+ script.onerror = scriptErrorCallback;
script.src = path;
document.head.appendChild(script);
}
@@ -6370,10 +6401,10 @@ require('cordova/channel').onNativeReady.fire();
context.cordova.require('cordova/channel').onPluginsReady.fire();
}
- // Handler for the cordova_plugins.json content.
+ // Handler for the cordova_plugins.js content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
- // Otherwise the XHR response handler will just call finishPluginLoading().
+ // Otherwise the onerror response handler will just call finishPluginLoading().
function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
@@ -6381,26 +6412,31 @@ require('cordova/channel').onNativeReady.fire();
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
- if (!module) continue;
-
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- mapper.clobbers(module.id, module.clobbers[j]);
+ if (module) {
+ try {
+ if (module.clobbers && module.clobbers.length) {
+ for (var j = 0; j < module.clobbers.length; j++) {
+ mapper.clobbers(module.id, module.clobbers[j]);
+ }
+ }
+
+ if (module.merges && module.merges.length) {
+ for (var k = 0; k < module.merges.length; k++) {
+ mapper.merges(module.id, module.merges[k]);
+ }
+ }
+
+ // Finally, if runs is truthy we want to simply require() the module.
+ // This can be skipped if it had any merges or clobbers, though,
+ // since the mapper will already have required the module.
+ if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
+ context.cordova.require(module.id);
+ }
}
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- mapper.merges(module.id, module.merges[k]);
+ catch(err) {
+ // error with module, most likely clobbers, should we continue?
}
}
-
- // Finally, if runs is truthy we want to simply require() the module.
- // This can be skipped if it had any merges or clobbers, though,
- // since the mapper will already have required the module.
- if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
- context.cordova.require(module.id);
- }
}
finishPluginLoading();
@@ -6423,6 +6459,33 @@ require('cordova/channel').onNativeReady.fire();
break;
}
}
+
+ var plugins_json = path + 'cordova_plugins.json';
+ var plugins_js = path + 'cordova_plugins.js';
+
+ // One some phones (Windows) this xhr.open throws an Access Denied exception
+ // So lets keep trying, but with a script tag injection technique instead of XHR
+ var injectPluginScript = function injectPluginScript() {
+ try {
+ var script = document.createElement("script");
+ script.onload = function(){
+ var list = cordova.require("cordova/plugin_list");
+ handlePluginsObject(list,path);
+ };
+ script.onerror = function() {
+ // Error loading cordova_plugins.js, file not found or something
+ // this is an acceptable error, pre-3.0.0, so we just move on.
+ finishPluginLoading();
+ };
+ script.src = plugins_js;
+ document.head.appendChild(script);
+
+ } catch(err){
+ finishPluginLoading();
+ }
+ }
+
+
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -6441,14 +6504,16 @@ require('cordova/channel').onNativeReady.fire();
}
};
xhr.onerror = function() {
- finishPluginLoading();
+ // In this case, the json file was not present, but XHR was allowed,
+ // so we should still try the script injection technique with the js file
+ // in case that is there.
+ injectPluginScript();
};
- var plugins_json = path + 'cordova_plugins.json';
try { // we commented we were going to try, so let us actually try and catch
xhr.open('GET', plugins_json, true); // Async
xhr.send();
} catch(err){
- finishPluginLoading();
+ injectPluginScript();
}
}(window));
[14/50] [abbrv] ios commit: [CB-3530] PhoneGap app crashes on iOS
with error "CDVWebViewDelegate: Navigation started when state=1" (for
navigation to an anchor on the same page)
Posted by ag...@apache.org.
[CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
commit fe971530ea4bd5e083cc4d8f70f692f55bd3469f
Author: Shazron Abdullah <sh...@apache.org>
Date: Wed Jun 19 15:13:59 2013 -0700
Remove verbose NSLogs.
commit caa93a57b0de81d619effff217fdc20fcc329bc4
Author: Shazron Abdullah <sh...@apache.org>
Date: Tue Jun 18 17:50:01 2013 -0700
[CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/db43c766
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/db43c766
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/db43c766
Branch: refs/heads/2.9.x
Commit: db43c7668c93e916eddba978475f22e6e8b9d61f
Parents: 478f683
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Jun 19 15:16:37 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Jun 19 15:16:37 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVWebViewDelegate.h | 1 +
CordovaLib/Classes/CDVWebViewDelegate.m | 49 ++++++++++++-
CordovaLibTests/CDVWebViewDelegateTests.m | 77 ++++++++++++++++++++
.../CordovaTests.xcodeproj/project.pbxproj | 4 +
4 files changed, 127 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/db43c766/CordovaLib/Classes/CDVWebViewDelegate.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewDelegate.h b/CordovaLib/Classes/CDVWebViewDelegate.h
index a4d78bd..dd71807 100644
--- a/CordovaLib/Classes/CDVWebViewDelegate.h
+++ b/CordovaLib/Classes/CDVWebViewDelegate.h
@@ -34,5 +34,6 @@
}
- (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate;
+- (BOOL)request:(NSURLRequest*)newRequest isFragmentIdentifierToRequest:(NSURLRequest*)originalRequest;
@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/db43c766/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m
index 1ee7aea..7254c2e 100644
--- a/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -103,6 +103,45 @@ typedef enum {
return self;
}
+- (BOOL)request:(NSURLRequest*)newRequest isFragmentIdentifierToRequest:(NSURLRequest*)originalRequest
+{
+ if (originalRequest.URL && newRequest.URL) {
+ NSString* originalRequestUrl = [originalRequest.URL absoluteString];
+ NSString* newRequestUrl = [newRequest.URL absoluteString];
+
+ // no fragment, easy
+ if (newRequest.URL.fragment == nil) {
+ return NO;
+ }
+
+ // if the urls have fragments and they are equal
+ if ((originalRequest.URL.fragment && newRequest.URL.fragment) && [originalRequestUrl isEqualToString:newRequestUrl]) {
+ return YES;
+ }
+
+ NSString* urlFormat = @"%@://%@:%d/%@#%@";
+ // reconstruct the URLs (ignoring basic auth credentials, query string)
+ NSString* baseOriginalRequestUrl = [NSString stringWithFormat:urlFormat,
+ [originalRequest.URL scheme],
+ [originalRequest.URL host],
+ [[originalRequest.URL port] intValue],
+ [originalRequest.URL path],
+ [newRequest.URL fragment] // add the new request's fragment
+ ];
+ NSString* baseNewRequestUrl = [NSString stringWithFormat:urlFormat,
+ [newRequest.URL scheme],
+ [newRequest.URL host],
+ [[newRequest.URL port] intValue],
+ [newRequest.URL path],
+ [newRequest.URL fragment]
+ ];
+
+ return [baseOriginalRequestUrl isEqualToString:baseNewRequestUrl];
+ }
+
+ return NO;
+}
+
- (BOOL)isPageLoaded:(UIWebView*)webView
{
NSString* readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
@@ -198,10 +237,12 @@ typedef enum {
NSLog(@"%@", description);
_loadCount = 0;
_state = STATE_WAITING_FOR_LOAD_START;
- if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
- NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate" code:1 userInfo:errorDictionary];
- [_delegate webView:webView didFailLoadWithError:error];
+ if (![self request:request isFragmentIdentifierToRequest:webView.request]) {
+ if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
+ NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
+ NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate" code:1 userInfo:errorDictionary];
+ [_delegate webView:webView didFailLoadWithError:error];
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/db43c766/CordovaLibTests/CDVWebViewDelegateTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVWebViewDelegateTests.m b/CordovaLibTests/CDVWebViewDelegateTests.m
new file mode 100644
index 0000000..1e536fa
--- /dev/null
+++ b/CordovaLibTests/CDVWebViewDelegateTests.m
@@ -0,0 +1,77 @@
+/*
+ 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.
+ */
+
+#import <SenTestingKit/SenTestingKit.h>
+
+#import <Cordova/CDVWebViewDelegate.h>
+
+@interface CDVWebViewDelegateTests : SenTestCase
+@end
+
+@implementation CDVWebViewDelegateTests
+
+- (void)setUp
+{
+ [super setUp];
+}
+
+- (void)tearDown
+{
+ [super tearDown];
+}
+
+- (void)testFragmentIdentifiersWithHttpUrl
+{
+ [self doTestFragmentIdentifiersWithBaseUrl:@"http://cordova.apache.org"];
+}
+
+- (void)testFragmentIdentifiersWithFileUrl
+{
+ [self doTestFragmentIdentifiersWithBaseUrl:@"file:///var/mobile/GASGEQGQsdga3313/www/index.html"];
+}
+
+- (void)doTestFragmentIdentifiersWithBaseUrl:(NSString*)baseUrl
+{
+ CDVWebViewDelegate* wvd = [[CDVWebViewDelegate alloc] initWithDelegate:nil]; // not really testing delegate handling
+
+ NSString* originalUrlString = baseUrl;
+ NSURL* originalUrl = [NSURL URLWithString:originalUrlString];
+ NSURL* originalUrlWithFragmentOnly = [NSURL URLWithString:[NSString stringWithFormat:@"%@#myfragment", originalUrlString]];
+ NSURL* originalUrlWithFragmentOnlyNoIdentifier = [NSURL URLWithString:[NSString stringWithFormat:@"%@#", originalUrlString]];
+ NSURL* originalUrlWithQueryParamsAndFragment = [NSURL URLWithString:[NSString stringWithFormat:@"%@?foo=bar#myfragment", originalUrlString]];
+
+ NSURLRequest* originalRequest = [NSURLRequest requestWithURL:originalUrl];
+ NSURLRequest* originalRequestWithFragmentOnly = [NSURLRequest requestWithURL:originalUrlWithFragmentOnly];
+ NSURLRequest* originalRequestWithFragmentOnlyNoIdentifier = [NSURLRequest requestWithURL:originalUrlWithFragmentOnlyNoIdentifier];
+ NSURLRequest* originalRequestWithQueryParamsAndFragment = [NSURLRequest requestWithURL:originalUrlWithQueryParamsAndFragment];
+ NSURLRequest* notOriginalRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://httpd.apache.org"]];
+
+ STAssertFalse([wvd request:originalRequest isFragmentIdentifierToRequest:originalRequest], @"originalRequest should not be a fragment of originalRequest");
+ STAssertTrue([wvd request:originalRequestWithFragmentOnly isFragmentIdentifierToRequest:originalRequest], @"originalRequestWithFragment should be a fragment of originalRequest");
+ STAssertTrue([wvd request:originalRequestWithFragmentOnlyNoIdentifier isFragmentIdentifierToRequest:originalRequest], @"originalRequestWithFragmentNoIdentifier should be a fragment of originalRequest");
+ STAssertTrue([wvd request:originalRequestWithQueryParamsAndFragment isFragmentIdentifierToRequest:originalRequest], @"originalRequestWithQueryParamsAndFragment should be a fragment of originalRequest");
+ STAssertFalse([wvd request:notOriginalRequest isFragmentIdentifierToRequest:originalRequest], @"notOriginalRequest should not be a fragment of originalRequest");
+
+ // equality tests
+ STAssertTrue([wvd request:originalRequestWithFragmentOnly isFragmentIdentifierToRequest:originalRequestWithFragmentOnly], @"originalRequestWithFragment should be a fragment of itself");
+ STAssertTrue([wvd request:originalRequestWithFragmentOnlyNoIdentifier isFragmentIdentifierToRequest:originalRequestWithFragmentOnlyNoIdentifier], @"originalRequestWithFragmentNoIdentifier should be a fragment of itself");
+ STAssertTrue([wvd request:originalRequestWithQueryParamsAndFragment isFragmentIdentifierToRequest:originalRequestWithQueryParamsAndFragment], @"originalRequestWithQueryParamsAndFragment should be a fragment of itself");
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/db43c766/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj b/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
index 3ac6c85..88ac047 100644
--- a/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
+++ b/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
68A32D7E141030EB006B237C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AA141002F100DF4CF2 /* UIKit.framework */; };
68A32D7F141030F3006B237C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AC141002F100DF4CF2 /* Foundation.framework */; };
7E13A295175D487B00E522AB /* CDVExifTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E13A294175D487B00E522AB /* CDVExifTests.m */; };
+ 7E91406017711D88002C6A3F /* CDVWebViewDelegateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E91405F17711D88002C6A3F /* CDVWebViewDelegateTests.m */; };
8220B5C216D541BD00EC3921 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */; };
8220B5C616D542F500EC3921 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */; };
EB3B34E9161B5532003DBE7D /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EB3B34E6161B5454003DBE7D /* libCordova.a */; };
@@ -110,6 +111,7 @@
68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
7E13A293175D487B00E522AB /* CDVExifTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVExifTests.h; sourceTree = "<group>"; };
7E13A294175D487B00E522AB /* CDVExifTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVExifTests.m; sourceTree = "<group>"; };
+ 7E91405F17711D88002C6A3F /* CDVWebViewDelegateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVWebViewDelegateTests.m; sourceTree = "<group>"; };
8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
EB37018115D18B2D00BEBC43 /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = ../CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
EB89634915FE66EA00E12277 /* CDVInvokedUrlCommandTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVInvokedUrlCommandTests.m; sourceTree = "<group>"; };
@@ -250,6 +252,7 @@
EB3B34F4161B585D003DBE7D /* CordovaLibTests */ = {
isa = PBXGroup;
children = (
+ 7E91405F17711D88002C6A3F /* CDVWebViewDelegateTests.m */,
7E13A293175D487B00E522AB /* CDVExifTests.h */,
7E13A294175D487B00E522AB /* CDVExifTests.m */,
EB96677116ADBCF500D86CDF /* CDVUserAgentTest.m */,
@@ -435,6 +438,7 @@
EB89634A15FE66EA00E12277 /* CDVInvokedUrlCommandTests.m in Sources */,
EB96677216ADBCF500D86CDF /* CDVUserAgentTest.m in Sources */,
7E13A295175D487B00E522AB /* CDVExifTests.m in Sources */,
+ 7E91406017711D88002C6A3F /* CDVWebViewDelegateTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
[27/50] [abbrv] ios commit: removed camera code
Posted by ag...@apache.org.
removed camera code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/6fa81c34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/6fa81c34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/6fa81c34
Branch: refs/heads/master
Commit: 6fa81c34b68deef4377f0c9b4763943eea0ad1fe
Parents: b229ae0
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 13 14:01:38 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:29:19 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVCamera.h | 102 ---
CordovaLib/Classes/CDVCamera.m | 730 -------------------
CordovaLib/Classes/CDVExif.h | 43 --
CordovaLib/Classes/CDVJpegHeaderWriter.h | 62 --
CordovaLib/Classes/CDVJpegHeaderWriter.m | 547 --------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 20 -
bin/templates/project/__TESTING__/config.xml | 3 -
8 files changed, 1508 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 9da128a..03c2a3e 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
#import "CDVDebug.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
deleted file mode 100644
index 2932e3b..0000000
--- a/CordovaLib/Classes/CDVCamera.h
+++ /dev/null
@@ -1,102 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <CoreLocation/CoreLocation.h>
-#import <CoreLocation/CLLocationManager.h>
-#import "CDVPlugin.h"
-
-enum CDVDestinationType {
- DestinationTypeDataUrl = 0,
- DestinationTypeFileUri,
- DestinationTypeNativeUri
-};
-typedef NSUInteger CDVDestinationType;
-
-enum CDVEncodingType {
- EncodingTypeJPEG = 0,
- EncodingTypePNG
-};
-typedef NSUInteger CDVEncodingType;
-
-enum CDVMediaType {
- MediaTypePicture = 0,
- MediaTypeVideo,
- MediaTypeAll
-};
-typedef NSUInteger CDVMediaType;
-
-@interface CDVCameraPicker : UIImagePickerController
-{}
-
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* postUrl;
-@property (nonatomic) enum CDVDestinationType returnType;
-@property (nonatomic) enum CDVEncodingType encodingType;
-@property (strong) UIPopoverController* popoverController;
-@property (assign) CGSize targetSize;
-@property (assign) bool correctOrientation;
-@property (assign) bool saveToPhotoAlbum;
-@property (assign) bool cropToSize;
-@property (strong) UIWebView* webView;
-@property (assign) BOOL popoverSupported;
-
-@end
-
-// ======================================================================= //
-
-@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- UIPopoverControllerDelegate,
- CLLocationManagerDelegate>
-{}
-
-@property (strong) CDVCameraPicker* pickerController;
-@property (strong) NSMutableDictionary *metadata;
-@property (strong, nonatomic) CLLocationManager *locationManager;
-@property (strong) NSData* data;
-
-/*
- * getPicture
- *
- * arguments:
- * 1: this is the javascript function that will be called with the results, the first parameter passed to the
- * javascript function is the picture as a Base64 encoded string
- * 2: this is the javascript function to be called if there was an error
- * options:
- * quality: integer between 1 and 100
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command;
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
-- (void)cleanup:(CDVInvokedUrlCommand*)command;
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command;
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize;
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation;
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
deleted file mode 100644
index d0a36dd..0000000
--- a/CordovaLib/Classes/CDVCamera.m
+++ /dev/null
@@ -1,730 +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.
- */
-
-#import "CDVCamera.h"
-#import "CDVJpegHeaderWriter.h"
-#import "NSArray+Comparisons.h"
-#import "NSData+Base64.h"
-#import "NSDictionary+Extensions.h"
-#import <ImageIO/CGImageProperties.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <ImageIO/CGImageSource.h>
-#import <ImageIO/CGImageProperties.h>
-#import <ImageIO/CGImageDestination.h>
-#import <MobileCoreServices/UTCoreTypes.h>
-
-#define CDV_PHOTO_PREFIX @"cdv_photo_"
-
-static NSSet* org_apache_cordova_validArrowDirections;
-
-@interface CDVCamera ()
-
-@property (readwrite, assign) BOOL hasPendingOperation;
-
-@end
-
-@implementation CDVCamera
-
-+ (void)initialize
-{
- org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
-}
-
-@synthesize hasPendingOperation, pickerController, locationManager;
-
-- (BOOL)popoverSupported
-{
- return (NSClassFromString(@"UIPopoverController") != nil) &&
- (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
-}
-
-/* takePicture arguments:
- * INDEX ARGUMENT
- * 0 quality
- * 1 destination type
- * 2 source type
- * 3 targetWidth
- * 4 targetHeight
- * 5 encodingType
- * 6 mediaType
- * 7 allowsEdit
- * 8 correctOrientation
- * 9 saveToPhotoAlbum
- * 10 popoverOptions
- * 11 cameraDirection
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* arguments = command.arguments;
-
- self.hasPendingOperation = NO;
-
- NSString* sourceTypeString = [arguments objectAtIndex:2];
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
- if (sourceTypeString != nil) {
- sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
- }
-
- bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
- if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no camera available"];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool allowEdit = [[arguments objectAtIndex:7] boolValue];
- NSNumber* targetWidth = [arguments objectAtIndex:3];
- NSNumber* targetHeight = [arguments objectAtIndex:4];
- NSNumber* mediaValue = [arguments objectAtIndex:6];
- CDVMediaType mediaType = (mediaValue) ? [mediaValue intValue] : MediaTypePicture;
-
- CGSize targetSize = CGSizeMake(0, 0);
- if ((targetWidth != nil) && (targetHeight != nil)) {
- targetSize = CGSizeMake([targetWidth floatValue], [targetHeight floatValue]);
- }
-
- // If a popover is already open, close it; we only want one at a time.
- if (([[self pickerController] popoverController] != nil) && [[[self pickerController] popoverController] isPopoverVisible]) {
- [[[self pickerController] popoverController] dismissPopoverAnimated:YES];
- [[[self pickerController] popoverController] setDelegate:nil];
- [[self pickerController] setPopoverController:nil];
- }
-
- CDVCameraPicker* cameraPicker = [[CDVCameraPicker alloc] init];
- self.pickerController = cameraPicker;
-
- cameraPicker.delegate = self;
- cameraPicker.sourceType = sourceType;
- cameraPicker.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING - jm
- cameraPicker.callbackId = callbackId;
- cameraPicker.targetSize = targetSize;
- cameraPicker.cropToSize = NO;
- // we need to capture this state for memory warnings that dealloc this object
- cameraPicker.webView = self.webView;
- cameraPicker.popoverSupported = [self popoverSupported];
-
- cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue];
- cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue];
-
- cameraPicker.encodingType = ([arguments objectAtIndex:5]) ? [[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG;
-
- cameraPicker.quality = ([arguments objectAtIndex:0]) ? [[arguments objectAtIndex:0] intValue] : 50;
- cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
-
- if (sourceType == UIImagePickerControllerSourceTypeCamera) {
- // We only allow taking pictures (no video) in this API.
- cameraPicker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
-
- // We can only set the camera device if we're actually using the camera.
- NSNumber* cameraDirection = [command argumentAtIndex:11 withDefault:[NSNumber numberWithInteger:UIImagePickerControllerCameraDeviceRear]];
- cameraPicker.cameraDevice = (UIImagePickerControllerCameraDevice)[cameraDirection intValue];
- } else if (mediaType == MediaTypeAll) {
- cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
- } else {
- NSArray* mediaArray = [NSArray arrayWithObjects:(NSString*)(mediaType == MediaTypeVideo ? kUTTypeMovie : kUTTypeImage), nil];
- cameraPicker.mediaTypes = mediaArray;
- }
-
- if ([self popoverSupported] && (sourceType != UIImagePickerControllerSourceTypeCamera)) {
- if (cameraPicker.popoverController == nil) {
- cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController")alloc] initWithContentViewController:cameraPicker];
- }
- NSDictionary* options = [command.arguments objectAtIndex:10 withDefault:nil];
- [self displayPopover:options];
- } else {
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:cameraPicker animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:cameraPicker animated:YES];
- }
- }
- self.hasPendingOperation = YES;
-}
-
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command
-{
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
-
- [self displayPopover:options];
-}
-
-- (void)displayPopover:(NSDictionary*)options
-{
- int x = 0;
- int y = 32;
- int width = 320;
- int height = 480;
- UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
-
- if (options) {
- x = [options integerValueForKey:@"x" defaultValue:0];
- y = [options integerValueForKey:@"y" defaultValue:32];
- width = [options integerValueForKey:@"width" defaultValue:320];
- height = [options integerValueForKey:@"height" defaultValue:480];
- arrowDirection = [options integerValueForKey:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
- if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]) {
- arrowDirection = UIPopoverArrowDirectionAny;
- }
- }
-
- [[[self pickerController] popoverController] setDelegate:self];
- [[[self pickerController] popoverController] presentPopoverFromRect:CGRectMake(x, y, width, height)
- inView:[self.webView superview]
- permittedArrowDirections:arrowDirection
- animated:YES];
-}
-
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
-{
- if([navigationController isKindOfClass:[UIImagePickerController class]]){
- UIImagePickerController * cameraPicker = (UIImagePickerController*)navigationController;
-
- if(![cameraPicker.mediaTypes containsObject:(NSString*) kUTTypeImage]){
- [viewController.navigationItem setTitle:NSLocalizedString(@"Videos title", nil)];
- }
- }
-}
-
-- (void)cleanup:(CDVInvokedUrlCommand*)command
-{
- // empty the tmp directory
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* err = nil;
- BOOL hasErrors = NO;
-
- // clear contents of NSTemporaryDirectory
- NSString* tempDirectoryPath = NSTemporaryDirectory();
- NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
- NSString* fileName = nil;
- BOOL result;
-
- while ((fileName = [directoryEnumerator nextObject])) {
- // only delete the files we created
- if (![fileName hasPrefix:CDV_PHOTO_PREFIX]) {
- continue;
- }
- NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
- result = [fileMgr removeItemAtPath:filePath error:&err];
- if (!result && err) {
- NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
- hasErrors = YES;
- }
- }
-
- CDVPluginResult* pluginResult;
- if (hasErrors) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)popoverControllerDidDismissPopover:(id)popoverController
-{
- // [ self imagePickerControllerDidCancel:self.pickerController ]; '
- UIPopoverController* pc = (UIPopoverController*)popoverController;
-
- [pc dismissPopoverAnimated:YES];
- pc.delegate = nil;
- if (self.pickerController && self.pickerController.callbackId && self.pickerController.popoverController) {
- self.pickerController.popoverController = nil;
- NSString* callbackId = self.pickerController.callbackId;
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- self.hasPendingOperation = NO;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if (cameraPicker.popoverSupported && (cameraPicker.popoverController != nil)) {
- [cameraPicker.popoverController dismissPopoverAnimated:YES];
- cameraPicker.popoverController.delegate = nil;
- cameraPicker.popoverController = nil;
- } else {
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
-
- CDVPluginResult* result = nil;
-
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- // IMAGE TYPE
- if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- if (cameraPicker.returnType == DestinationTypeNativeUri) {
- NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
- } else {
- // get the image
- UIImage* image = nil;
- if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
-
- if (cameraPicker.correctOrientation) {
- image = [self imageCorrectedForCaptureOrientation:image];
- }
-
- 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];
- }
- }
-
- NSData* data = nil;
-
- if (cameraPicker.encodingType == EncodingTypePNG) {
- data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
- } else {
- data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
-
- NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
- if (controllerMetadata) {
- self.data = data;
- self.metadata = [[NSMutableDictionary alloc] init];
-
- NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
- if (EXIFDictionary) [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
-
- [[self locationManager] startUpdatingLocation];
- return;
- }
- }
-
- if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
- }
-
- 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:[data base64EncodedString]];
- }
- }
- }
- // NOT IMAGE TYPE (MOVIE)
- else {
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-// older api calls newer didFinishPickingMediaWithInfo
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage];
-
- [self imagePickerController:picker didFinishPickingMediaWithInfo:imageInfo];
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- // popoverControllerDidDismissPopover:(id)popoverController is called if popover is cancelled
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = targetSize.width;
- CGFloat targetHeight = targetSize.height;
- CGFloat scaleFactor = 0.0;
- CGFloat scaledWidth = targetWidth;
- CGFloat scaledHeight = targetHeight;
- CGPoint thumbnailPoint = CGPointMake(0.0, 0.0);
-
- if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- if (widthFactor > heightFactor) {
- scaleFactor = widthFactor; // scale to fit height
- } else {
- scaleFactor = heightFactor; // scale to fit width
- }
- scaledWidth = width * scaleFactor;
- scaledHeight = height * scaleFactor;
-
- // center the image
- if (widthFactor > heightFactor) {
- thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
- } else if (widthFactor < heightFactor) {
- thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
- }
- }
-
- UIGraphicsBeginImageContext(targetSize); // this will crop
-
- CGRect thumbnailRect = CGRectZero;
- thumbnailRect.origin = thumbnailPoint;
- thumbnailRect.size.width = scaledWidth;
- thumbnailRect.size.height = scaledHeight;
-
- [sourceImage drawInRect:thumbnailRect];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage
-{
- float rotation_radians = 0;
- bool perpendicular = false;
-
- switch ([anImage imageOrientation]) {
- case UIImageOrientationUp :
- rotation_radians = 0.0;
- break;
-
- case UIImageOrientationDown:
- rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
- break;
-
- case UIImageOrientationRight:
- rotation_radians = M_PI_2;
- perpendicular = true;
- break;
-
- case UIImageOrientationLeft:
- rotation_radians = -M_PI_2;
- perpendicular = true;
- break;
-
- default:
- break;
- }
-
- UIGraphicsBeginImageContext(CGSizeMake(anImage.size.width, anImage.size.height));
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- // Rotate around the center point
- CGContextTranslateCTM(context, anImage.size.width / 2, anImage.size.height / 2);
- CGContextRotateCTM(context, rotation_radians);
-
- CGContextScaleCTM(context, 1.0, -1.0);
- float width = perpendicular ? anImage.size.height : anImage.size.width;
- float height = perpendicular ? anImage.size.width : anImage.size.height;
- CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [anImage CGImage]);
-
- // Move the origin back since the rotation might've change it (if its 90 degrees)
- if (perpendicular) {
- CGContextTranslateCTM(context, -anImage.size.height / 2, -anImage.size.width / 2);
- }
-
- UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = frameSize.width;
- CGFloat targetHeight = frameSize.height;
- CGFloat scaleFactor = 0.0;
- CGSize scaledSize = frameSize;
-
- if (CGSizeEqualToSize(imageSize, frameSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- // opposite comparison to imageByScalingAndCroppingForSize in order to contain the image within the given bounds
- if (widthFactor > heightFactor) {
- scaleFactor = heightFactor; // scale to fit height
- } else {
- scaleFactor = widthFactor; // scale to fit width
- }
- scaledSize = CGSizeMake(MIN(width * scaleFactor, targetWidth), MIN(height * scaleFactor, targetHeight));
- }
-
- UIGraphicsBeginImageContext(scaledSize); // this will resize
-
- [sourceImage drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
-{
- self.hasPendingOperation = YES;
-
- NSString* boundary = @"----BOUNDARY_IS_I";
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
- [req setHTTPMethod:@"POST"];
-
- NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-type"];
-
- NSData* imageData = UIImagePNGRepresentation(anImage);
-
- // adding the body
- NSMutableData* postBody = [NSMutableData data];
-
- // first parameter an image
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
- [postBody appendData:imageData];
-
- // // second parameter information
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
-
- [req setHTTPBody:postBody];
-
- NSURLResponse* response;
- NSError* error;
- [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
-
- // NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
- // NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
-
- self.hasPendingOperation = NO;
-}
-
-
-- (CLLocationManager *)locationManager {
-
- if (locationManager != nil) {
- return locationManager;
- }
-
- locationManager = [[CLLocationManager alloc] init];
- [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
- [locationManager setDelegate:self];
-
- return locationManager;
-}
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
-{
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- NSMutableDictionary *GPSDictionary = [[NSMutableDictionary dictionary] init];
-
- CLLocationDegrees latitude = newLocation.coordinate.latitude;
- CLLocationDegrees longitude = newLocation.coordinate.longitude;
-
- // latitude
- if (latitude < 0.0) {
- latitude = latitude * -1.0f;
- [GPSDictionary setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- } else {
- [GPSDictionary setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:latitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
-
- // longitude
- if (longitude < 0.0) {
- longitude = longitude * -1.0f;
- [GPSDictionary setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- else {
- [GPSDictionary setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:longitude] forKey:(NSString*)kCGImagePropertyGPSLongitude];
-
- // altitude
- CGFloat altitude = newLocation.altitude;
- if (!isnan(altitude)){
- if (altitude < 0) {
- altitude = -altitude;
- [GPSDictionary setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- } else {
- [GPSDictionary setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude];
- }
-
- // Time and date
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"HH:mm:ss.SSSSSS"];
- [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSTimeStamp];
- [formatter setDateFormat:@"yyyy:MM:dd"];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSDateStamp];
-
- [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary];
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)imagePickerControllerReturnImageResult
-{
- CDVPluginResult* result = nil;
-
- if (self.metadata) {
- CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge_retained CFDataRef)self.data, NULL);
- CFStringRef sourceType = CGImageSourceGetType(sourceImage);
-
- CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL);
- CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata);
- CGImageDestinationFinalize(destinationImage);
-
- CFRelease(sourceImage);
- CFRelease(destinationImage);
- }
-
- if (self.pickerController.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[self data]], nil, nil, nil);
- }
-
- if (self.pickerController.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++, self.pickerController.encodingType == EncodingTypePNG ? @"png":@"jpg"];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- // save file
- if (![self.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:[self.data base64EncodedString]];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
- self.data = nil;
- self.metadata = nil;
-}
-
-@end
-
-@implementation CDVCameraPicker
-
-@synthesize quality, postUrl;
-@synthesize returnType;
-@synthesize callbackId;
-@synthesize popoverController;
-@synthesize targetSize;
-@synthesize correctOrientation;
-@synthesize saveToPhotoAlbum;
-@synthesize encodingType;
-@synthesize cropToSize;
-@synthesize webView;
-@synthesize popoverSupported;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDVExif.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVExif.h b/CordovaLib/Classes/CDVExif.h
deleted file mode 100644
index 3e8adbd..0000000
--- a/CordovaLib/Classes/CDVExif.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-#ifndef CordovaLib_ExifData_h
-#define CordovaLib_ExifData_h
-
-// exif data types
-typedef enum exifDataTypes {
- EDT_UBYTE = 1, // 8 bit unsigned integer
- EDT_ASCII_STRING, // 8 bits containing 7 bit ASCII code, null terminated
- EDT_USHORT, // 16 bit unsigned integer
- EDT_ULONG, // 32 bit unsigned integer
- EDT_URATIONAL, // 2 longs, first is numerator and second is denominator
- EDT_SBYTE,
- EDT_UNDEFINED, // 8 bits
- EDT_SSHORT,
- EDT_SLONG, // 32bit signed integer (2's complement)
- EDT_SRATIONAL, // 2 SLONGS, first long is numerator, second is denominator
- EDT_SINGLEFLOAT,
- EDT_DOUBLEFLOAT
-} ExifDataTypes;
-
-// maps integer code for exif data types to width in bytes
-static const int DataTypeToWidth[] = {1,1,2,4,8,1,1,2,4,8,4,8};
-
-static const int RECURSE_HORIZON = 8;
-#endif
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDVJpegHeaderWriter.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.h b/CordovaLib/Classes/CDVJpegHeaderWriter.h
deleted file mode 100644
index 3b43ef0..0000000
--- a/CordovaLib/Classes/CDVJpegHeaderWriter.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-#import <Foundation/Foundation.h>
-
-@interface CDVJpegHeaderWriter : NSObject {
- NSDictionary * SubIFDTagFormatDict;
- NSDictionary * IFD0TagFormatDict;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata
- withExifBlock: (NSString*) exifstr;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb
- withPlaces: (NSNumber*) width;
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber*) numb
- withPlaces: (NSNumber*) places;
-- (NSString*) decimalToUnsignedRational: (NSNumber*) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator;
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon;
-//- (void) expandContinuedFraction: (NSArray*) fractionlist;
-- (void) splitDouble: (double) val
- withIntComponent: (int*) rightside
- withFloatRemainder: (double*) leftside;
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator
- withDenominator: (NSNumber*) denominator
- asSigned: (Boolean) signedFlag;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-
-/*
-- (void) readExifMetaData : (NSData*) imgdata;
-- (void) spliceImageData : (NSData*) imgdata withExifData: (NSDictionary*) exifdata;
-- (void) locateExifMetaData : (NSData*) imgdata;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (void) createExifDataString : (NSDictionary*) datadict;
-- (NSString*) createDataElement : (NSString*) element
- withElementData: (NSString*) data
- withExternalDataBlock: (NSDictionary*) memblock;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-*/
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/Classes/CDVJpegHeaderWriter.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.m b/CordovaLib/Classes/CDVJpegHeaderWriter.m
deleted file mode 100644
index 93cafb8..0000000
--- a/CordovaLib/Classes/CDVJpegHeaderWriter.m
+++ /dev/null
@@ -1,547 +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.
- */
-
-#import "CDVJpegHeaderWriter.h"
-#include "CDVExif.h"
-
-/* macros for tag info shorthand:
- tagno : tag number
- typecode : data type
- components : number of components
- appendString (TAGINF_W_APPEND only) : string to append to data
- Exif date data format include an extra 0x00 to the end of the data
- */
-#define TAGINF(tagno, typecode, components) [NSArray arrayWithObjects: tagno, typecode, components, nil]
-#define TAGINF_W_APPEND(tagno, typecode, components, appendString) [NSArray arrayWithObjects: tagno, typecode, components, appendString, nil]
-
-const uint mJpegId = 0xffd8; // JPEG format marker
-const uint mExifMarker = 0xffe1; // APP1 jpeg header marker
-const uint mExif = 0x45786966; // ASCII 'Exif', first characters of valid exif header after size
-const uint mMotorallaByteAlign = 0x4d4d; // 'MM', motorola byte align, msb first or 'sane'
-const uint mIntelByteAlgin = 0x4949; // 'II', Intel byte align, lsb first or 'batshit crazy reverso world'
-const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a(MM) or 0x2a00(II), tiff version number
-
-
-@implementation CDVJpegHeaderWriter
-
-- (id) init {
- self = [super init];
- // supported tags for exif IFD
- IFD0TagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- // TAGINF(@"010e", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"ImageDescription",
- TAGINF_W_APPEND(@"0132", [NSNumber numberWithInt:EDT_ASCII_STRING], @20, @"00"), @"DateTime",
- TAGINF(@"010f", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Make",
- TAGINF(@"0110", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Model",
- TAGINF(@"0131", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Software",
- TAGINF(@"011a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"XResolution",
- TAGINF(@"011b", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"YResolution",
- // currently supplied outside of Exif data block by UIImagePickerControllerMediaMetadata, this is set manually in CDVCamera.m
- /* TAGINF(@"0112", [NSNumber numberWithInt:EDT_USHORT], @1), @"Orientation",
-
- // rest of the tags are supported by exif spec, but are not specified by UIImagePickerControllerMediaMedadata
- // should camera hardware supply these values in future versions, or if they can be derived, ImageHeaderWriter will include them gracefully
- TAGINF(@"0128", [NSNumber numberWithInt:EDT_USHORT], @1), @"ResolutionUnit",
- TAGINF(@"013e", [NSNumber numberWithInt:EDT_URATIONAL], @2), @"WhitePoint",
- TAGINF(@"013f", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"PrimaryChromaticities",
- TAGINF(@"0211", [NSNumber numberWithInt:EDT_URATIONAL], @3), @"YCbCrCoefficients",
- TAGINF(@"0213", [NSNumber numberWithInt:EDT_USHORT], @1), @"YCbCrPositioning",
- TAGINF(@"0214", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"ReferenceBlackWhite",
- TAGINF(@"8298", [NSNumber numberWithInt:EDT_URATIONAL], @0), @"Copyright",
-
- // offset to exif subifd, we determine this dynamically based on the size of the main exif IFD
- TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",*/
- nil];
-
-
- // supported tages for exif subIFD
- SubIFDTagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- //TAGINF(@"9000", [NSNumber numberWithInt:], @), @"ExifVersion",
- //TAGINF(@"9202",[NSNumber numberWithInt:EDT_URATIONAL],@1), @"ApertureValue",
- //TAGINF(@"9203",[NSNumber numberWithInt:EDT_SRATIONAL],@1), @"BrightnessValue",
- TAGINF(@"a001",[NSNumber numberWithInt:EDT_USHORT],@1), @"ColorSpace",
- TAGINF_W_APPEND(@"9004",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeDigitized",
- TAGINF_W_APPEND(@"9003",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeOriginal",
- TAGINF(@"a402", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureMode",
- TAGINF(@"8822", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureProgram",
- //TAGINF(@"829a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"ExposureTime",
- //TAGINF(@"829d", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FNumber",
- TAGINF(@"9209", [NSNumber numberWithInt:EDT_USHORT], @1), @"Flash",
- // FocalLengthIn35mmFilm
- TAGINF(@"a405", [NSNumber numberWithInt:EDT_USHORT], @1), @"FocalLenIn35mmFilm",
- //TAGINF(@"920a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FocalLength",
- //TAGINF(@"8827", [NSNumber numberWithInt:EDT_USHORT], @2), @"ISOSpeedRatings",
- TAGINF(@"9207", [NSNumber numberWithInt:EDT_USHORT],@1), @"MeteringMode",
- // specific to compressed data
- TAGINF(@"a002", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelXDimension",
- TAGINF(@"a003", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelYDimension",
- // data type undefined, but this is a DSC camera, so value is always 1, treat as ushort
- TAGINF(@"a301", [NSNumber numberWithInt:EDT_USHORT],@1), @"SceneType",
- TAGINF(@"a217",[NSNumber numberWithInt:EDT_USHORT],@1), @"SensingMethod",
- //TAGINF(@"9201", [NSNumber numberWithInt:EDT_SRATIONAL], @1), @"ShutterSpeedValue",
- // specifies location of main subject in scene (x,y,wdith,height) expressed before rotation processing
- //TAGINF(@"9214", [NSNumber numberWithInt:EDT_USHORT], @4), @"SubjectArea",
- TAGINF(@"a403", [NSNumber numberWithInt:EDT_USHORT], @1), @"WhiteBalance",
- nil];
- return self;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata withExifBlock: (NSString*) exifstr {
-
- CDVJpegHeaderWriter * exifWriter = [[CDVJpegHeaderWriter alloc] init];
-
- NSMutableData * exifdata = [NSMutableData dataWithCapacity: [exifstr length]/2];
- int idx;
- for (idx = 0; idx+1 < [exifstr length]; idx+=2) {
- NSRange range = NSMakeRange(idx, 2);
- NSString* hexStr = [exifstr substringWithRange:range];
- NSScanner* scanner = [NSScanner scannerWithString:hexStr];
- unsigned int intValue;
- [scanner scanHexInt:&intValue];
- [exifdata appendBytes:&intValue length:1];
- }
-
- NSMutableData * ddata = [NSMutableData dataWithCapacity: [jpegdata length]];
- NSMakeRange(0,4);
- int loc = 0;
- bool done = false;
- // read the jpeg data until we encounter the app1==0xFFE1 marker
- while (loc+1 < [jpegdata length]) {
- NSData * blag = [jpegdata subdataWithRange: NSMakeRange(loc,2)];
- if( [[blag description] isEqualToString : @"<ffe1>"]) {
- // read the APP1 block size bits
- NSString * the = [exifWriter hexStringFromData:[jpegdata subdataWithRange: NSMakeRange(loc+2,2)]];
- NSNumber * app1width = [exifWriter numericFromHexString:the];
- //consume the original app1 block
- [ddata appendData:exifdata];
- // advance our loc marker past app1
- loc += [app1width intValue] + 2;
- done = true;
- } else {
- if(!done) {
- [ddata appendData:blag];
- loc += 2;
- } else {
- break;
- }
- }
- }
- // copy the remaining data
- [ddata appendData:[jpegdata subdataWithRange: NSMakeRange(loc,[jpegdata length]-loc)]];
- return ddata;
-}
-
-
-
-/**
- * Create the Exif data block as a hex string
- * jpeg uses Application Markers (APP's) as markers for application data
- * APP1 is the application marker reserved for exif data
- *
- * (NSDictionary*) datadict - with subdictionaries marked '{TIFF}' and '{EXIF}' as returned by imagePickerController with a valid
- * didFinishPickingMediaWithInfo data dict, under key @"UIImagePickerControllerMediaMetadata"
- *
- * the following constructs a hex string to Exif specifications, and is therefore brittle
- * altering the order of arguments to the string constructors, modifying field sizes or formats,
- * and any other minor change will likely prevent the exif data from being read
- */
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict {
- NSMutableString * app1; // holds finalized product
- NSString * exifIFD; // exif information file directory
- NSString * subExifIFD; // subexif information file directory
-
- // FFE1 is the hex APP1 marker code, and will allow client apps to read the data
- NSString * app1marker = @"ffe1";
- // SSSS size, to be determined
- // EXIF ascii characters followed by 2bytes of zeros
- NSString * exifmarker = @"457869660000";
- // Tiff header: 4d4d is motorolla byte align (big endian), 002a is hex for 42
- NSString * tiffheader = @"4d4d002a";
- //first IFD offset from the Tiff header to IFD0. Since we are writing it, we know it's address 0x08
- NSString * ifd0offset = @"00000008";
- // current offset to next data area
- int currentDataOffset = 0;
-
- //data labeled as TIFF in UIImagePickerControllerMediaMetaData is part of the EXIF IFD0 portion of APP1
- exifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{TIFF}"] withFormatDict: IFD0TagFormatDict isIFD0:YES currentDataOffset:¤tDataOffset];
-
- //data labeled as EXIF in UIImagePickerControllerMediaMetaData is part of the EXIF Sub IFD portion of APP1
- subExifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{Exif}"] withFormatDict: SubIFDTagFormatDict isIFD0:NO currentDataOffset:¤tDataOffset];
- /*
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",exifIFD,[exifIFD length]);
-
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",subExifIFD,[subExifIFD length]);
- */
- // construct the complete app1 data block
- app1 = [[NSMutableString alloc] initWithFormat: @"%@%04x%@%@%@%@%@",
- app1marker,
- 16 + ([exifIFD length]/2) + ([subExifIFD length]/2) /*16+[exifIFD length]/2*/,
- exifmarker,
- tiffheader,
- ifd0offset,
- exifIFD,
- subExifIFD];
-
- return app1;
-}
-
-// returns hex string representing a valid exif information file directory constructed from the datadict and formatdict
-- (NSString*) createExifIFDFromDict : (NSDictionary*) datadict
- withFormatDict : (NSDictionary*) formatdict
- isIFD0 : (BOOL) ifd0flag
- currentDataOffset : (int*) dataoffset {
- NSArray * datakeys = [datadict allKeys]; // all known data keys
- NSArray * knownkeys = [formatdict allKeys]; // only keys in knowkeys are considered for entry in this IFD
- NSMutableArray * ifdblock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // all ifd entries
- NSMutableArray * ifddatablock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // data block entries
- // ifd0flag = NO; // ifd0 requires a special flag and has offset to next ifd appended to end
-
- // iterate through known provided data keys
- for (int i = 0; i < [datakeys count]; i++) {
- NSString * key = [datakeys objectAtIndex:i];
- // don't muck about with unknown keys
- if ([knownkeys indexOfObject: key] != NSNotFound) {
- // create new IFD entry
- NSString * entry = [self createIFDElement: key
- withFormat: [formatdict objectForKey:key]
- withElementData: [datadict objectForKey:key]];
- // create the IFD entry's data block
- NSString * data = [self createIFDElementDataWithFormat: [formatdict objectForKey:key]
- withData: [datadict objectForKey:key]];
- if (entry) {
- [ifdblock addObject:entry];
- if(!data) {
- [ifdblock addObject:@""];
- } else {
- [ifddatablock addObject:data];
- }
- }
- }
- }
-
- NSMutableString * exifstr = [[NSMutableString alloc] initWithCapacity: [ifdblock count] * 24];
- NSMutableString * dbstr = [[NSMutableString alloc] initWithCapacity: 100];
-
- int addr=*dataoffset; // current offset/address in datablock
- if (ifd0flag) {
- // calculate offset to datablock based on ifd file entry count
- addr += 14+(12*([ifddatablock count]+1)); // +1 for tag 0x8769, exifsubifd offset
- } else {
- // current offset + numSubIFDs (2-bytes) + 12*numSubIFDs + endMarker (4-bytes)
- addr += 2+(12*[ifddatablock count])+4;
- }
-
- for (int i = 0; i < [ifdblock count]; i++) {
- NSString * entry = [ifdblock objectAtIndex:i];
- NSString * data = [ifddatablock objectAtIndex:i];
-
- // check if the data fits into 4 bytes
- if( [data length] <= 8) {
- // concatenate the entry and the (4byte) data entry into the final IFD entry and append to exif ifd string
- [exifstr appendFormat : @"%@%@", entry, data];
- } else {
- [exifstr appendFormat : @"%@%08x", entry, addr];
- [dbstr appendFormat: @"%@", data];
- addr+= [data length] / 2;
- /*
- NSLog(@"=====data-length[%i]=======",[data length]);
- NSLog(@"addr-offset[%i]",addr);
- NSLog(@"entry[%@]",entry);
- NSLog(@"data[%@]",data);
- */
- }
- }
-
- // calculate IFD0 terminal offset tags, currently ExifSubIFD
- int entrycount = [ifdblock count];
- if (ifd0flag) {
- // 18 accounts for 8769's width + offset to next ifd, 8 accounts for start of header
- NSNumber * offset = [NSNumber numberWithInt:[exifstr length] / 2 + [dbstr length] / 2 + 18+8];
-
- [self appendExifOffsetTagTo: exifstr
- withOffset : offset];
- entrycount++;
- }
- *dataoffset = addr;
- return [[NSString alloc] initWithFormat: @"%04x%@%@%@",
- entrycount,
- exifstr,
- @"00000000", // offset to next IFD, 0 since there is none
- dbstr]; // lastly, the datablock
-}
-
-// Creates an exif formatted exif information file directory entry
-- (NSString*) createIFDElement: (NSString*) elementName withFormat: (NSArray*) formtemplate withElementData: (NSString*) data {
- //NSArray * fielddata = [formatdict objectForKey: elementName];// format data of desired field
- if (formtemplate) {
- // format string @"%@%@%@%@", tag number, data format, components, value
- NSNumber * dataformat = [formtemplate objectAtIndex:1];
- NSNumber * components = [formtemplate objectAtIndex:2];
- if([components intValue] == 0) {
- components = [NSNumber numberWithInt: [data length] * DataTypeToWidth[[dataformat intValue]-1]];
- }
-
- return [[NSString alloc] initWithFormat: @"%@%@%08x",
- [formtemplate objectAtIndex:0], // the field code
- [self formatNumberWithLeadingZeroes: dataformat withPlaces: @4], // the data type code
- [components intValue]]; // number of components
- }
- return NULL;
-}
-
-/**
- * appends exif IFD0 tag 8769 "ExifOffset" to the string provided
- * (NSMutableString*) str - string you wish to append the 8769 tag to: APP1 or IFD0 hex data string
- * // TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",
- */
-- (void) appendExifOffsetTagTo: (NSMutableString*) str withOffset : (NSNumber*) offset {
- NSArray * format = TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1);
-
- NSString * entry = [self createIFDElement: @"ExifOffset"
- withFormat: format
- withElementData: [offset stringValue]];
-
- NSString * data = [self createIFDElementDataWithFormat: format
- withData: [offset stringValue]];
- [str appendFormat:@"%@%@", entry, data];
-}
-
-// formats the Information File Directory Data to exif format
-- (NSString*) createIFDElementDataWithFormat: (NSArray*) dataformat withData: (NSString*) data {
- NSMutableString * datastr = nil;
- NSNumber * tmp = nil;
- NSNumber * formatcode = [dataformat objectAtIndex:1];
- NSUInteger formatItemsCount = [dataformat count];
- NSNumber * num = @0;
- NSNumber * denom = @0;
-
- switch ([formatcode intValue]) {
- case EDT_UBYTE:
- break;
- case EDT_ASCII_STRING:
- datastr = [[NSMutableString alloc] init];
- for (int i = 0; i < [data length]; i++) {
- [datastr appendFormat:@"%02x",[data characterAtIndex:i]];
- }
- if (formatItemsCount > 3) {
- // We have additional data to append.
- // currently used by Date format to append final 0x00 but can be used by other data types as well in the future
- [datastr appendString:[dataformat objectAtIndex:3]];
- }
- if ([datastr length] < 8) {
- NSString * format = [NSString stringWithFormat:@"%%0%dd", 8 - [datastr length]];
- [datastr appendFormat:format,0];
- }
- return datastr;
- case EDT_USHORT:
- return [[NSString alloc] initWithFormat : @"%@%@",
- [self formattedHexStringFromDecimalNumber: [NSNumber numberWithInt: [data intValue]] withPlaces: @4],
- @"0000"];
- case EDT_ULONG:
- tmp = [NSNumber numberWithUnsignedLong:[data intValue]];
- return [NSString stringWithFormat : @"%@",
- [self formattedHexStringFromDecimalNumber: tmp withPlaces: @8]];
- case EDT_URATIONAL:
- return [self decimalToUnsignedRational: [NSNumber numberWithDouble:[data doubleValue]]
- withResultNumerator: &num
- withResultDenominator: &denom];
- case EDT_SBYTE:
-
- break;
- case EDT_UNDEFINED:
- break; // 8 bits
- case EDT_SSHORT:
- break;
- case EDT_SLONG:
- break; // 32bit signed integer (2's complement)
- case EDT_SRATIONAL:
- break; // 2 SLONGS, first long is numerator, second is denominator
- case EDT_SINGLEFLOAT:
- break;
- case EDT_DOUBLEFLOAT:
- break;
- }
- return datastr;
-}
-
-//======================================================================================================================
-// Utility Methods
-//======================================================================================================================
-
-// creates a formatted little endian hex string from a number and width specifier
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb withPlaces: (NSNumber*) width {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:[width intValue]];
- NSString * formatstr = [[NSString alloc] initWithFormat: @"%%%@%dx", @"0", [width intValue]];
- [str appendFormat:formatstr, [numb intValue]];
- return str;
-}
-
-// format number as string with leading 0's
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber *) numb withPlaces: (NSNumber *) places {
- NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
- NSString *formatstr = [@"" stringByPaddingToLength:[places unsignedIntegerValue] withString:@"0" startingAtIndex:0];
- [formatter setPositiveFormat:formatstr];
- return [formatter stringFromNumber:numb];
-}
-
-// approximate a decimal with a rational by method of continued fraction
-// can be collasped into decimalToUnsignedRational after testing
-- (void) decimalToRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
-}
-
-// approximate a decimal with an unsigned rational by method of continued fraction
-- (NSString*) decimalToUnsignedRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- // generate partial fraction list
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
- return [self formatFractionList: fractionlist];
-}
-
-// recursive implementation of decimal approximation by continued fraction
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon {
- int whole;
- double remainder;
- // 1. split term
- [self splitDouble: val withIntComponent: &whole withFloatRemainder: &remainder];
- [fractionlist addObject: [NSNumber numberWithInt:whole]];
-
- // 2. calculate reciprocal of remainder
- if (!remainder) return; // early exit, exact fraction found, avoids recip/0
- double recip = 1 / remainder;
-
- // 3. exit condition
- if ([fractionlist count] > horizon) {
- return;
- }
-
- // 4. recurse
- [self continuedFraction:recip withFractionList: fractionlist withHorizon: horizon];
-
-}
-
-// expand continued fraction list, creating a single level rational approximation
--(void) expandContinuedFraction: (NSArray*) fractionlist
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- int i = 0;
- int den = 0;
- int num = 0;
- if ([fractionlist count] == 1) {
- *numerator = [NSNumber numberWithInt:[[fractionlist objectAtIndex:0] intValue]];
- *denominator = @1;
- return;
- }
-
- //begin at the end of the list
- i = [fractionlist count] - 1;
- num = 1;
- den = [[fractionlist objectAtIndex:i] intValue];
-
- while (i > 0) {
- int t = [[fractionlist objectAtIndex: i-1] intValue];
- num = t * den + num;
- if (i==1) {
- break;
- } else {
- t = num;
- num = den;
- den = t;
- }
- i--;
- }
- // set result parameters values
- *numerator = [NSNumber numberWithInt: num];
- *denominator = [NSNumber numberWithInt: den];
-}
-
-// formats expanded fraction list to string matching exif specification
-- (NSString*) formatFractionList: (NSArray *) fractionlist {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
-
- if ([fractionlist count] == 1){
- [str appendFormat: @"%08x00000001", [[fractionlist objectAtIndex:0] intValue]];
- }
- return str;
-}
-
-// format rational as
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator withDenominator: (NSNumber*) denominator asSigned: (Boolean) signedFlag {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
- if (signedFlag) {
- long num = [numerator longValue];
- long den = [denominator longValue];
- [str appendFormat: @"%08lx%08lx", num >= 0 ? num : ~ABS(num) + 1, num >= 0 ? den : ~ABS(den) + 1];
- } else {
- [str appendFormat: @"%08lx%08lx", [numerator unsignedLongValue], [denominator unsignedLongValue]];
- }
- return str;
-}
-
-// split a floating point number into two integer values representing the left and right side of the decimal
-- (void) splitDouble: (double) val withIntComponent: (int*) rightside withFloatRemainder: (double*) leftside {
- *rightside = val; // convert numb to int representation, which truncates the decimal portion
- *leftside = val - *rightside;
-}
-
-
-//
-- (NSString*) hexStringFromData : (NSData*) data {
- //overflow detection
- const unsigned char *dataBuffer = [data bytes];
- return [[NSString alloc] initWithFormat: @"%02x%02x",
- (unsigned char)dataBuffer[0],
- (unsigned char)dataBuffer[1]];
-}
-
-// convert a hex string to a number
-- (NSNumber*) numericFromHexString : (NSString *) hexstring {
- NSScanner * scan = NULL;
- unsigned int numbuf= 0;
-
- scan = [NSScanner scannerWithString:hexstring];
- [scan scanHexInt:&numbuf];
- return [NSNumber numberWithInt:numbuf];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 3c6ba71..3500567 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -36,15 +36,10 @@
30F5EBAB14CA26E700987760 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F5EBA914CA26E700987760 /* CDVCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E76876B156A90EE00EB6FA3 /* CDVLogger.m */; };
3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E76876C156A90EE00EB6FA3 /* CDVLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */; };
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516A16FD18190076A8B4 /* CDVExif.h */; settings = {ATTRIBUTES = (Public, ); }; };
7E14B5A81705050A0032169E /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E14B5A61705050A0032169E /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; };
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E14B5A71705050A0032169E /* CDVTimer.m */; };
8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD261090FBE7009987E8 /* CDVCamera.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD271090FBE7009987E8 /* CDVCamera.m */; };
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -117,16 +112,11 @@
686357DC14100B1600DF4CF2 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
68A32D7114102E1C006B237C /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; };
68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
- 68B7516A16FD18190076A8B4 /* CDVExif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVExif.h; path = Classes/CDVExif.h; sourceTree = "<group>"; };
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVJpegHeaderWriter.h; path = Classes/CDVJpegHeaderWriter.h; sourceTree = "<group>"; };
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVJpegHeaderWriter.m; path = Classes/CDVJpegHeaderWriter.m; sourceTree = "<group>"; };
7E14B5A61705050A0032169E /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVTimer.h; path = Classes/CDVTimer.h; sourceTree = "<group>"; };
7E14B5A71705050A0032169E /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVTimer.m; path = Classes/CDVTimer.m; sourceTree = "<group>"; };
8220B5C316D5427E00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
8852C43614B65FD800F0E735 /* CDVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVViewController.h; path = Classes/CDVViewController.h; sourceTree = "<group>"; };
8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
- 8887FD261090FBE7009987E8 /* CDVCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCamera.h; path = Classes/CDVCamera.h; sourceTree = "<group>"; };
- 8887FD271090FBE7009987E8 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCamera.m; path = Classes/CDVCamera.m; sourceTree = "<group>"; };
8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
@@ -253,13 +243,8 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 8887FD261090FBE7009987E8 /* CDVCamera.h */,
- 8887FD271090FBE7009987E8 /* CDVCamera.m */,
1F584B991385A28900ED25E8 /* CDVCapture.h */,
1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- 68B7516A16FD18190076A8B4 /* CDVExif.h */,
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */,
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD301090FBE7009987E8 /* CDVFile.h */,
@@ -320,9 +305,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */,
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */,
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */,
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
@@ -413,7 +395,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */,
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
@@ -441,7 +422,6 @@
30F3930C169F839700B22307 /* CDVJSON.m in Sources */,
EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */,
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */,
7E14B5A91705050A0032169E /* CDVTimer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6fa81c34/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 16e6919..38af0bc 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -58,9 +58,6 @@
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="Camera">
- <param name="ios-package" value="CDVCamera"/>
- </feature>
<feature name="File">
<param name="ios-package" value="CDVFile"/>
</feature>
[41/50] [abbrv] ios commit: added missing reference to
viewController.m
Posted by ag...@apache.org.
added missing reference to viewController.m
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/7569c3ef
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/7569c3ef
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/7569c3ef
Branch: refs/heads/master
Commit: 7569c3ef2c3a7768735506097a5e7e7a13be5329
Parents: 067bc70
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 20 22:06:45 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 22:06:45 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVViewController.m | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7569c3ef/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index b186326..db79332 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -23,6 +23,7 @@
#import "CDVConfigParser.h"
#import "CDVUserAgentUtil.h"
#import "CDVWebViewDelegate.h"
+#import <AVFoundation/AVFoundation.h>
#define degreesToRadian(x) (M_PI * (x) / 180.0)
[10/50] [abbrv] ios commit: updated cordovajs
Posted by ag...@apache.org.
updated cordovajs
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/60675886
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/60675886
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/60675886
Branch: refs/heads/master
Commit: 60675886e3e69e03d525700fb9958c8d0dca2978
Parents: 8159679
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:50:33 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 17:50:33 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/60675886/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index d5fdb7d..d4af23e 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.7.0rc1-119-gf0251c4
+// 2.7.0rc1-120-g8731b31
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-119-gf0251c4';
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-120-g8731b31';
// file: lib/scripts/require.js
var require,
@@ -524,8 +524,6 @@ var utils = require('cordova/utils'),
* onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
* onNativeReady* Internal event that indicates the Cordova native side is ready.
* onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady* Internal event fired when device properties are available.
- * onCordovaConnectionReady* Internal event fired when the connection property has been set.
* onDeviceReady* User event fired to indicate that Cordova is ready
* onResume User event fired to indicate a start/resume lifecycle event
* onPause User event fired to indicate a pause lifecycle event
@@ -728,9 +726,6 @@ channel.createSticky('onNativeReady');
// and it's time to run plugin constructors.
channel.createSticky('onCordovaReady');
-// Event to indicate that device properties are available
-channel.createSticky('onCordovaInfoReady');
-
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
channel.createSticky('onPluginsReady');
[48/50] [abbrv] ios commit: [CB-4025] iOS emulate command broken when
run inside the cordova folder
Posted by ag...@apache.org.
[CB-4025] iOS emulate command broken when run inside the cordova folder
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9e48d824
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9e48d824
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9e48d824
Branch: refs/heads/2.9.x
Commit: 9e48d8245e50d538f1e859b3c05b575c7e46c78a
Parents: d510386
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Jun 27 15:08:09 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Jun 27 15:08:09 2013 -0700
----------------------------------------------------------------------
bin/templates/project/cordova/emulate | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e48d824/bin/templates/project/cordova/emulate
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/emulate b/bin/templates/project/cordova/emulate
index b0ab99b..62b1f82 100755
--- a/bin/templates/project/cordova/emulate
+++ b/bin/templates/project/cordova/emulate
@@ -33,7 +33,7 @@ PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-APP_PATH=${1:-$PROJECT_PATH/build/$(xcodebuild -project $PROJECT_NAME.xcodeproj -arch i386 -target $PROJECT_NAME -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')}
+APP_PATH=${1:-$PROJECT_PATH/build/$(xcodebuild -project $PROJECT_PATH/$PROJECT_NAME.xcodeproj -arch i386 -target $PROJECT_NAME -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')}
DEVICE_FAMILY=${2:-${DEVICE_FAMILY:-iphone}}
[37/50] [abbrv] ios commit: updated cordova.js
Posted by ag...@apache.org.
updated cordova.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/925c7f4f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/925c7f4f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/925c7f4f
Branch: refs/heads/master
Commit: 925c7f4f9026c0f715954a6695db0f37b238c8a8
Parents: 362e4f1
Author: Steven Gill <st...@gmail.com>
Authored: Tue Jun 18 17:01:38 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:31:47 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 174 +--------------------------------------------
1 file changed, 3 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/925c7f4f/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index f5353c3..2cebb62 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1184,6 +1184,7 @@ module.exports = {
});
+<<<<<<< HEAD
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
@@ -3202,6 +3203,8 @@ modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
});
+=======
+>>>>>>> updated cordova.js
// file: lib/common/plugin/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
@@ -3412,71 +3415,6 @@ module.exports = function(successCallback, errorCallback, message, forceAsync) {
});
-// file: lib/ios/plugin/file/symbols.js
-define("cordova/plugin/file/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper'),
- symbolshelper = require('cordova/plugin/file/symbolshelper');
-
-symbolshelper(modulemapper.clobbers);
-modulemapper.merges('cordova/plugin/ios/Entry', 'Entry');
-
-});
-
-// file: lib/common/plugin/file/symbolshelper.js
-define("cordova/plugin/file/symbolshelper", function(require, exports, module) {
-
-module.exports = function(exportFunc) {
- exportFunc('cordova/plugin/DirectoryEntry', 'DirectoryEntry');
- exportFunc('cordova/plugin/DirectoryReader', 'DirectoryReader');
- exportFunc('cordova/plugin/Entry', 'Entry');
- exportFunc('cordova/plugin/File', 'File');
- exportFunc('cordova/plugin/FileEntry', 'FileEntry');
- exportFunc('cordova/plugin/FileError', 'FileError');
- exportFunc('cordova/plugin/FileReader', 'FileReader');
- exportFunc('cordova/plugin/FileSystem', 'FileSystem');
- 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/ios/plugin/ios/Entry.js
-define("cordova/plugin/ios/Entry", function(require, exports, module) {
-
-module.exports = {
- toURL:function() {
- // TODO: refactor path in a cross-platform way so we can eliminate
- // these kinds of platform-specific hacks.
- return "file://localhost" + this.fullPath;
- },
- toURI: function() {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- return "file://localhost" + this.fullPath;
- }
-};
-
-});
-
// file: lib/ios/plugin/ios/logger/plugininit.js
define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
@@ -3836,112 +3774,6 @@ modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
});
-// file: lib/ios/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.clobbers('cordova/plugin/MediaError', 'MediaError');
-
-});
-
-// file: lib/common/plugin/requestFileSystem.js
-define("cordova/plugin/requestFileSystem", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- FileError = require('cordova/plugin/FileError'),
- FileSystem = require('cordova/plugin/FileSystem'),
- exec = require('cordova/exec');
-
-/**
- * Request a file system in which to store application data.
- * @param type local file system type
- * @param size indicates how much storage space, in bytes, the application expects to need
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- */
-var requestFileSystem = function(type, size, successCallback, errorCallback) {
- argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
- var fail = function(code) {
- errorCallback && errorCallback(new FileError(code));
- };
-
- if (type < 0 || type > 3) {
- fail(FileError.SYNTAX_ERR);
- } else {
- // if successful, return a FileSystem object
- var success = function(file_system) {
- if (file_system) {
- if (successCallback) {
- // grab the name and root from the file system object
- var result = new FileSystem(file_system.name, file_system.root);
- successCallback(result);
- }
- }
- else {
- // no FileSystem object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
- exec(success, fail, "File", "requestFileSystem", [type, size]);
- }
-};
-
-module.exports = requestFileSystem;
-
-});
-
-// file: lib/common/plugin/resolveLocalFileSystemURI.js
-define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError'),
- exec = require('cordova/exec');
-
-/**
- * Look up file system Entry referred to by local URI.
- * @param {DOMString} uri URI referring to a local file or directory
- * @param successCallback invoked with Entry object corresponding to URI
- * @param errorCallback invoked if error occurs retrieving file system entry
- */
-module.exports = function(uri, successCallback, errorCallback) {
- argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
- // error callback
- var fail = function(error) {
- errorCallback && errorCallback(new FileError(error));
- };
- // sanity check for 'not:valid:filename'
- if(!uri || uri.split(":").length > 2) {
- setTimeout( function() {
- fail(FileError.ENCODING_ERR);
- },0);
- return;
- }
- // if successful, return either a file or directory entry
- var success = function(entry) {
- var result;
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
-};
-
-});
-
// file: lib/common/symbols.js
define("cordova/symbols", function(require, exports, module) {
[42/50] [abbrv] ios commit: re-enable video duration
Posted by ag...@apache.org.
re-enable video duration
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f721482d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f721482d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f721482d
Branch: refs/heads/2.9.x
Commit: f721482d299211a3d0da67c655a24be83b8e85ae
Parents: 3af6ca4
Author: Don Coleman <dc...@chariotsolutions.com>
Authored: Tue Jun 25 01:34:55 2013 -0400
Committer: Don Coleman <dc...@chariotsolutions.com>
Committed: Tue Jun 25 01:34:55 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVCapture.m | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f721482d/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
index 6b7ed44..884702d 100644
--- a/CordovaLib/Classes/CDVCapture.m
+++ b/CordovaLib/Classes/CDVCapture.m
@@ -204,9 +204,9 @@
options = [NSDictionary dictionary];
}
- // options could contain limit, duration and mode, only duration is supported (but is not due to apple bug)
+ // options could contain limit, duration and mode
// taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property
- // NSNumber* duration = [options objectForKey:@"duration"];
+ NSNumber* duration = [options objectForKey:@"duration"];
NSString* mediaType = nil;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
@@ -238,12 +238,12 @@
// iOS 3.0
pickerController.mediaTypes = [NSArray arrayWithObjects:mediaType, nil];
- /*if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
+ if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
if (duration) {
pickerController.videoMaximumDuration = [duration doubleValue];
}
//NSLog(@"pickerController.videoMaximumDuration = %f", pickerController.videoMaximumDuration);
- }*/
+ }
// iOS 4.0
if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
[12/50] [abbrv] ios commit: updated cordova.js
Posted by ag...@apache.org.
updated cordova.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/42644d0a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/42644d0a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/42644d0a
Branch: refs/heads/master
Commit: 42644d0a03bbd5a22ed6c61282f908e3d73bb0b4
Parents: 5c7efe0
Author: Steven Gill <st...@gmail.com>
Authored: Tue Jun 18 17:01:38 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Tue Jun 18 17:01:38 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 2167 --------------------------------------------
1 file changed, 2167 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/42644d0a/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index d4af23e..513a08e 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1136,2002 +1136,6 @@ module.exports = {
});
-// file: lib/common/plugin/CaptureAudioOptions.js
-define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureAudioOptions;
-
-});
-
-// file: lib/common/plugin/CaptureError.js
-define("cordova/plugin/CaptureError", function(require, exports, module) {
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
-
-});
-
-// file: lib/common/plugin/CaptureImageOptions.js
-define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
-};
-
-module.exports = CaptureImageOptions;
-
-});
-
-// file: lib/common/plugin/CaptureVideoOptions.js
-define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureVideoOptions;
-
-});
-
-// file: lib/common/plugin/ConfigurationData.js
-define("cordova/plugin/ConfigurationData", function(require, exports, module) {
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
-
-});
-
-// file: lib/common/plugin/DirectoryEntry.js
-define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or exclusively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
- var win = successCallback && function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or exclusively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
- var win = successCallback && function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
-
-});
-
-// file: lib/common/plugin/DirectoryReader.js
-define("cordova/plugin/DirectoryReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError') ;
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
-
-});
-
-// file: lib/common/plugin/Entry.js
-define("cordova/plugin/Entry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = !!isFile;
- this.isDirectory = !!isDirectory;
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
- var success = successCallback && function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- * @param metadataObject
- * {Object} keys and values to set
- */
-Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
- argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- // success callback
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.toURL();
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.remove', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getParent', arguments);
- var win = successCallback && function(result) {
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
-
-});
-
-// file: lib/common/plugin/File.js
-define("cordova/plugin/File", function(require, exports, module) {
-
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-
- // These store the absolute start and end for slicing the file.
- this.start = 0;
- this.end = this.size;
-};
-
-/**
- * Returns a "slice" of the file. Since Cordova Files don't contain the actual
- * content, this really returns a File with adjusted start and end.
- * Slices of slices are supported.
- * start {Number} The index at which to start the slice (inclusive).
- * end {Number} The index at which to end the slice (exclusive).
- */
-File.prototype.slice = function(start, end) {
- var size = this.end - this.start;
- var newStart = 0;
- var newEnd = size;
- if (arguments.length) {
- if (start < 0) {
- newStart = Math.max(size + start, 0);
- } else {
- newStart = Math.min(size, start);
- }
- }
-
- if (arguments.length >= 2) {
- if (end < 0) {
- newEnd = Math.max(size + end, 0);
- } else {
- newEnd = Math.min(end, size);
- }
- }
-
- var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size);
- newFile.start = this.start + newStart;
- newFile.end = this.start + newEnd;
- return newFile;
-};
-
-
-module.exports = File;
-
-});
-
-// file: lib/common/plugin/FileEntry.js
-define("cordova/plugin/FileEntry", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- } else {
- successCallback && successCallback(writer);
- }
- }, errorCallback);
-};
-
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = successCallback && function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
-
-});
-
-// file: lib/common/plugin/FileError.js
-define("cordova/plugin/FileError", function(require, exports, module) {
-
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;
-
-});
-
-// file: lib/common/plugin/FileReader.js
-define("cordova/plugin/FileReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper'),
- utils = require('cordova/utils'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent'),
- origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this._readyState = 0;
- this._error = null;
- this._result = null;
- this._fileName = '';
- this._realReader = origFileReader ? new origFileReader() : {};
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-utils.defineGetter(FileReader.prototype, 'readyState', function() {
- return this._fileName ? this._readyState : this._realReader.readyState;
-});
-
-utils.defineGetter(FileReader.prototype, 'error', function() {
- return this._fileName ? this._error: this._realReader.error;
-});
-
-utils.defineGetter(FileReader.prototype, 'result', function() {
- return this._fileName ? this._result: this._realReader.result;
-});
-
-function defineEvent(eventName) {
- utils.defineGetterSetter(FileReader.prototype, eventName, function() {
- return this._realReader[eventName] || null;
- }, function(value) {
- this._realReader[eventName] = value;
- });
-}
-defineEvent('onloadstart'); // When the read starts.
-defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
-defineEvent('onload'); // When the read has successfully completed.
-defineEvent('onerror'); // When the read has failed (see errors).
-defineEvent('onloadend'); // When the request has completed (either in success or failure).
-defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
-
-function initRead(reader, file) {
- // Already loading something
- if (reader.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- reader._result = null;
- reader._error = null;
- reader._readyState = FileReader.LOADING;
-
- if (typeof file.fullPath == 'string') {
- reader._fileName = file.fullPath;
- } else {
- reader._fileName = '';
- return true;
- }
-
- reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
-}
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- if (origFileReader && !this._fileName) {
- return this._realReader.abort();
- }
- this._result = null;
-
- if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
- return;
- }
-
- this._readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- if (initRead(this, file)) {
- return this._realReader.readAsText(file, encoding);
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
- var me = this;
- var execArgs = [this._fileName, enc, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // null result
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsText", execArgs);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsDataURL(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsDataURL", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsBinaryString(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsBinaryString", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsArrayBuffer(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsArrayBuffer", execArgs);
-};
-
-module.exports = FileReader;
-
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
-
-});
-
-// file: lib/common/plugin/FileTransfer.js
-define("cordova/plugin/FileTransfer", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-function newProgressEvent(result) {
- var pe = new ProgressEvent();
- pe.lengthComputable = result.lengthComputable;
- pe.loaded = result.loaded;
- pe.total = result.total;
- return pe;
-}
-
-function getBasicAuthHeader(urlString) {
- var header = null;
-
- if (window.btoa) {
- // parse the url using the Location object
- var url = document.createElement('a');
- url.href = urlString;
-
- var credentials = null;
- var protocol = url.protocol + "//";
- var origin = protocol + url.host;
-
- // check whether there are the username:password credentials in the url
- if (url.href.indexOf(origin) !== 0) { // credentials found
- var atIndex = url.href.indexOf("@");
- credentials = url.href.substring(protocol.length, atIndex);
- }
-
- if (credentials) {
- var authHeader = "Authorization";
- var authHeaderValue = "Basic " + window.btoa(credentials);
-
- header = {
- name : authHeader,
- value : authHeaderValue
- };
- }
- }
-
- return header;
-}
-
-var idCounter = 0;
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {
- this._id = ++idCounter;
- this.onprogress = null; // optional callback
-};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
- argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- var headers = null;
- var httpMethod = null;
- var basicAuthHeader = getBasicAuthHeader(server);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- headers = options.headers;
- httpMethod = options.httpMethod || "POST";
- if (httpMethod.toUpperCase() == "PUT"){
- httpMethod = "PUT";
- } else {
- httpMethod = "POST";
- }
- if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- var self = this;
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- self.onprogress(newProgressEvent(result));
- }
- } else {
- successCallback && successCallback(result);
- }
- };
- exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
- * @param options {FileDownloadOptions} Optional parameters such as headers
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
- argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
- var self = this;
-
- var basicAuthHeader = getBasicAuthHeader(source);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- var headers = null;
- if (options) {
- headers = options.headers || null;
- }
-
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- return self.onprogress(newProgressEvent(result));
- }
- } else if (successCallback) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- }
- };
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
-};
-
-/**
- * Aborts the ongoing file transfer on this object. The original error
- * callback for the file transfer will be called if necessary.
- */
-FileTransfer.prototype.abort = function() {
- exec(null, null, 'FileTransfer', 'abort', [this._id]);
-};
-
-module.exports = FileTransfer;
-
-});
-
-// file: lib/common/plugin/FileTransferError.js
-define("cordova/plugin/FileTransferError", function(require, exports, module) {
-
-/**
- * FileTransferError
- * @constructor
- */
-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;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-FileTransferError.ABORT_ERR = 4;
-
-module.exports = FileTransferError;
-
-});
-
-// file: lib/common/plugin/FileUploadOptions.js
-define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
-
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- * @param headers {Object} Keys are header names, values are header values. Multiple
- * headers of the same name are not supported.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
- this.headers = headers || null;
- this.httpMethod = httpMethod || null;
-};
-
-module.exports = FileUploadOptions;
-
-});
-
-// file: lib/common/plugin/FileUploadResult.js
-define("cordova/plugin/FileUploadResult", function(require, exports, module) {
-
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
-
-});
-
-// file: lib/common/plugin/FileWriter.js
-define("cordova/plugin/FileWriter", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param text to be written
- */
-FileWriter.prototype.write = function(text) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // position always increases by bytes written because file would be extended
- me.position += r;
- // The length of the file is now where we are done writing.
-
- me.length = me.position;
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "write", [this.fileName, text, this.position]);
-};
-
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound. If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
-FileWriter.prototype.seek = function(offset) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- if (!offset && offset !== 0) {
- return;
- }
-
- // See back from end of file.
- if (offset < 0) {
- this.position = Math.max(offset + this.length, 0);
- }
- // Offset is bigger than file size so set position
- // to the end of the file.
- else if (offset > this.length) {
- this.position = this.length;
- }
- // Offset is between 0 and file size so set the position
- // to start writing.
- else {
- this.position = offset;
- }
-};
-
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
-FileWriter.prototype.truncate = function(size) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":this}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Update the length of the file
- me.length = r;
- me.position = Math.min(me.position, r);
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "truncate", [this.fileName, size]);
-};
-
-module.exports = FileWriter;
-
-});
-
-// file: lib/common/plugin/Flags.js
-define("cordova/plugin/Flags", function(require, exports, module) {
-
-/**
- * Supplies arguments to methods that lookup or create files and directories.
- *
- * @param create
- * {boolean} file or directory if it doesn't exist
- * @param exclusive
- * {boolean} used with create; if true the command will fail if
- * target path exists
- */
-function Flags(create, exclusive) {
- this.create = create || false;
- this.exclusive = exclusive || false;
-}
-
-module.exports = Flags;
-
-});
-
-// file: lib/common/plugin/LocalFileSystem.js
-define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Represents a local file system.
- */
-var LocalFileSystem = function() {
-
-};
-
-LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
-LocalFileSystem.PERSISTENT = 1; //persistent
-
-module.exports = LocalFileSystem;
-
-});
-
-// file: lib/common/plugin/Media.js
-define("cordova/plugin/Media", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var mediaObjects = {};
-
-/**
- * This class provides access to the device media, interfaces to both sound and video
- *
- * @constructor
- * @param src The file name or url to play
- * @param successCallback The callback to be called when the file is done playing or recording.
- * successCallback()
- * @param errorCallback The callback to be called if there is an error.
- * errorCallback(int errorCode) - OPTIONAL
- * @param statusCallback The callback to be called when media status has changed.
- * statusCallback(int statusCode) - OPTIONAL
- */
-var Media = function(src, successCallback, errorCallback, statusCallback) {
- argscheck.checkArgs('SFFF', 'Media', arguments);
- this.id = utils.createUUID();
- mediaObjects[this.id] = this;
- this.src = src;
- this.successCallback = successCallback;
- this.errorCallback = errorCallback;
- this.statusCallback = statusCallback;
- this._duration = -1;
- this._position = -1;
- exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
-};
-
-// Media messages
-Media.MEDIA_STATE = 1;
-Media.MEDIA_DURATION = 2;
-Media.MEDIA_POSITION = 3;
-Media.MEDIA_ERROR = 9;
-
-// Media states
-Media.MEDIA_NONE = 0;
-Media.MEDIA_STARTING = 1;
-Media.MEDIA_RUNNING = 2;
-Media.MEDIA_PAUSED = 3;
-Media.MEDIA_STOPPED = 4;
-Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
-
-// "static" function to return existing objs.
-Media.get = function(id) {
- return mediaObjects[id];
-};
-
-/**
- * Start or resume playing audio file.
- */
-Media.prototype.play = function(options) {
- exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
-};
-
-/**
- * Stop playing audio file.
- */
-Media.prototype.stop = function() {
- var me = this;
- exec(function() {
- me._position = 0;
- }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
-};
-
-/**
- * Seek or jump to a new time in the track..
- */
-Media.prototype.seekTo = function(milliseconds) {
- var me = this;
- exec(function(p) {
- me._position = p;
- }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
-};
-
-/**
- * Pause playing audio file.
- */
-Media.prototype.pause = function() {
- exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
-};
-
-/**
- * Get duration of an audio file.
- * The duration is only set for audio that is playing, paused or stopped.
- *
- * @return duration or -1 if not known.
- */
-Media.prototype.getDuration = function() {
- return this._duration;
-};
-
-/**
- * Get position of audio.
- */
-Media.prototype.getCurrentPosition = function(success, fail) {
- var me = this;
- exec(function(p) {
- me._position = p;
- success(p);
- }, fail, "Media", "getCurrentPositionAudio", [this.id]);
-};
-
-/**
- * Start recording audio file.
- */
-Media.prototype.startRecord = function() {
- exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop recording audio file.
- */
-Media.prototype.stopRecord = function() {
- exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
-};
-
-/**
- * Release the resources.
- */
-Media.prototype.release = function() {
- exec(null, this.errorCallback, "Media", "release", [this.id]);
-};
-
-/**
- * Adjust the volume.
- */
-Media.prototype.setVolume = function(volume) {
- exec(null, null, "Media", "setVolume", [this.id, volume]);
-};
-
-/**
- * Audio has status update.
- * PRIVATE
- *
- * @param id The media object id (string)
- * @param msgType The 'type' of update this is
- * @param value Use of value is determined by the msgType
- */
-Media.onStatus = function(id, msgType, value) {
-
- var media = mediaObjects[id];
-
- if(media) {
- switch(msgType) {
- case Media.MEDIA_STATE :
- media.statusCallback && media.statusCallback(value);
- if(value == Media.MEDIA_STOPPED) {
- media.successCallback && media.successCallback();
- }
- break;
- case Media.MEDIA_DURATION :
- media._duration = value;
- break;
- case Media.MEDIA_ERROR :
- media.errorCallback && media.errorCallback(value);
- break;
- case Media.MEDIA_POSITION :
- media._position = Number(value);
- break;
- default :
- console.error && console.error("Unhandled Media.onStatus :: " + msgType);
- break;
- }
- }
- else {
- console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
- }
-
-};
-
-module.exports = Media;
-
-});
-
-// file: lib/common/plugin/MediaError.js
-define("cordova/plugin/MediaError", function(require, exports, module) {
-
-/**
- * This class contains information about any Media errors.
-*/
-/*
- According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
- We should never be creating these objects, we should just implement the interface
- which has 1 property for an instance, 'code'
-
- instead of doing :
- errorCallbackFunction( new MediaError(3,'msg') );
-we should simply use a literal :
- errorCallbackFunction( {'code':3} );
- */
-
- var _MediaError = window.MediaError;
-
-
-if(!_MediaError) {
- window.MediaError = _MediaError = function(code, msg) {
- this.code = (typeof code != 'undefined') ? code : null;
- this.message = msg || ""; // message is NON-standard! do not use!
- };
-}
-
-_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
-_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
-_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
-_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
-_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
-// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
-// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
-_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
-
-module.exports = _MediaError;
-
-});
-
-// file: lib/common/plugin/MediaFile.js
-define("cordova/plugin/MediaFile", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('cordova/plugin/File'),
- CaptureError = require('cordova/plugin/CaptureError');
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
- }
-};
-
-module.exports = MediaFile;
-
-});
-
-// file: lib/common/plugin/MediaFileData.js
-define("cordova/plugin/MediaFileData", function(require, exports, module) {
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
-
-});
-
-// file: lib/common/plugin/Metadata.js
-define("cordova/plugin/Metadata", function(require, exports, module) {
-
-/**
- * Information about the state of the file or directory
- *
- * {Date} modificationTime (readonly)
- */
-var Metadata = function(time) {
- this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
-};
-
-module.exports = Metadata;
-
-});
-
-// file: lib/common/plugin/ProgressEvent.js
-define("cordova/plugin/ProgressEvent", function(require, exports, module) {
-
-// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
-// Feature test: See if we can instantiate a native ProgressEvent;
-// if so, use that approach,
-// otherwise fill-in with our own implementation.
-//
-// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
-var ProgressEvent = (function() {
- /*
- var createEvent = function(data) {
- var event = document.createEvent('Events');
- event.initEvent('ProgressEvent', false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- if (data.target) {
- // TODO: cannot call <some_custom_object>.dispatchEvent
- // need to first figure out how to implement EventTarget
- }
- }
- return event;
- };
- try {
- var ev = createEvent({type:"abort",target:document});
- return function ProgressEvent(type, data) {
- data.type = type;
- return createEvent(data);
- };
- } catch(e){
- */
- return function ProgressEvent(type, dict) {
- this.type = type;
- this.bubbles = false;
- this.cancelBubble = false;
- this.cancelable = false;
- this.lengthComputable = false;
- this.loaded = dict && dict.loaded ? dict.loaded : 0;
- this.total = dict && dict.total ? dict.total : 0;
- this.target = dict && dict.target ? dict.target : null;
- };
- //}
-})();
-
-module.exports = ProgressEvent;
-
-});
-
-// file: lib/common/plugin/capture.js
-define("cordova/plugin/capture", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-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);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-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/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
@@ -3342,71 +1346,6 @@ module.exports = function(successCallback, errorCallback, message, forceAsync) {
});
-// file: lib/ios/plugin/file/symbols.js
-define("cordova/plugin/file/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper'),
- symbolshelper = require('cordova/plugin/file/symbolshelper');
-
-symbolshelper(modulemapper.clobbers);
-modulemapper.merges('cordova/plugin/ios/Entry', 'Entry');
-
-});
-
-// file: lib/common/plugin/file/symbolshelper.js
-define("cordova/plugin/file/symbolshelper", function(require, exports, module) {
-
-module.exports = function(exportFunc) {
- exportFunc('cordova/plugin/DirectoryEntry', 'DirectoryEntry');
- exportFunc('cordova/plugin/DirectoryReader', 'DirectoryReader');
- exportFunc('cordova/plugin/Entry', 'Entry');
- exportFunc('cordova/plugin/File', 'File');
- exportFunc('cordova/plugin/FileEntry', 'FileEntry');
- exportFunc('cordova/plugin/FileError', 'FileError');
- exportFunc('cordova/plugin/FileReader', 'FileReader');
- exportFunc('cordova/plugin/FileSystem', 'FileSystem');
- 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/ios/plugin/ios/Entry.js
-define("cordova/plugin/ios/Entry", function(require, exports, module) {
-
-module.exports = {
- toURL:function() {
- // TODO: refactor path in a cross-platform way so we can eliminate
- // these kinds of platform-specific hacks.
- return "file://localhost" + this.fullPath;
- },
- toURI: function() {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- return "file://localhost" + this.fullPath;
- }
-};
-
-});
-
// file: lib/ios/plugin/ios/logger/plugininit.js
define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
@@ -3766,112 +1705,6 @@ modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
});
-// file: lib/ios/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.clobbers('cordova/plugin/MediaError', 'MediaError');
-
-});
-
-// file: lib/common/plugin/requestFileSystem.js
-define("cordova/plugin/requestFileSystem", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- FileError = require('cordova/plugin/FileError'),
- FileSystem = require('cordova/plugin/FileSystem'),
- exec = require('cordova/exec');
-
-/**
- * Request a file system in which to store application data.
- * @param type local file system type
- * @param size indicates how much storage space, in bytes, the application expects to need
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- */
-var requestFileSystem = function(type, size, successCallback, errorCallback) {
- argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
- var fail = function(code) {
- errorCallback && errorCallback(new FileError(code));
- };
-
- if (type < 0 || type > 3) {
- fail(FileError.SYNTAX_ERR);
- } else {
- // if successful, return a FileSystem object
- var success = function(file_system) {
- if (file_system) {
- if (successCallback) {
- // grab the name and root from the file system object
- var result = new FileSystem(file_system.name, file_system.root);
- successCallback(result);
- }
- }
- else {
- // no FileSystem object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
- exec(success, fail, "File", "requestFileSystem", [type, size]);
- }
-};
-
-module.exports = requestFileSystem;
-
-});
-
-// file: lib/common/plugin/resolveLocalFileSystemURI.js
-define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError'),
- exec = require('cordova/exec');
-
-/**
- * Look up file system Entry referred to by local URI.
- * @param {DOMString} uri URI referring to a local file or directory
- * @param successCallback invoked with Entry object corresponding to URI
- * @param errorCallback invoked if error occurs retrieving file system entry
- */
-module.exports = function(uri, successCallback, errorCallback) {
- argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
- // error callback
- var fail = function(error) {
- errorCallback && errorCallback(new FileError(error));
- };
- // sanity check for 'not:valid:filename'
- if(!uri || uri.split(":").length > 2) {
- setTimeout( function() {
- fail(FileError.ENCODING_ERR);
- },0);
- return;
- }
- // if successful, return either a file or directory entry
- var success = function(entry) {
- var result;
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
-};
-
-});
-
// file: lib/common/symbols.js
define("cordova/symbols", function(require, exports, module) {
[16/50] [abbrv] ios commit: Updated RELEASENOTES for 2.9.0rc1
Posted by ag...@apache.org.
Updated RELEASENOTES for 2.9.0rc1
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/3af6ca42
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/3af6ca42
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/3af6ca42
Branch: refs/heads/2.9.x
Commit: 3af6ca42ae353742b24d1dc210aa9382a3bc8aa2
Parents: cfa5487
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Jun 20 14:09:03 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Jun 20 14:09:26 2013 -0700
----------------------------------------------------------------------
RELEASENOTES.md | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3af6ca42/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 9c50659..69a9886 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -24,6 +24,35 @@ Update these notes using: git log --pretty=format:'* %s' --topo-order --no-merge
Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
+### 2.9.0 (201306XX) ###
+
+* [CB-3469] Add a version macro for 2.8.0.
+* [CB-3469] Adding missing license found by RAT
+* [CB-2200] Remove device.name (deprecated)
+* [CB-3031] Fix for emulate script when project name has a space
+* [CB-3420] add hidden option to InAppBrowser
+* [CB-2840] Nil checks to avoid crash when network disconnected
+* [CB-3514] Remove partially-downloaded files when FileTransfer fails
+* [CB-2406] Add ArrayBuffer support to FileWriter.write
+* [CB-3757] camera.getPicture from photolib fails on iOS
+* [CB-3524] cordova/emulate and cordova/run silently fails when ios-sim is not installed
+* [CB-3526] typo in cordova/lib/install-emulator - does not check for ios-sim
+* [CB-3490] Update CordovaLib iOS Deployment Target in Project Setting to 5.0
+* [CB-3528] Update Plugin Upgrade Guide for iOS
+* [CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
+* [CB-3768] Build to phone failing on Xcode 5 DP1 (OS X Mavericks)
+* [CB-3833] Deprecation plugin tag upgrade step has malformed xml
+* [CB-3743] Remove compatibility headers folder
+* [CB-3619] ./cordova/run script does not always call ./cordova/build first
+* [CB-3463] bin/create should copy cordova.js into the project's CordovaLib
+* [CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1" (for navigation to an anchor on the same page)
+* [CB-3507] Wrong Linker Flag for project template
+* [CB-3458] remove all_load dependency. Use force load instead
+* Removing "build" from gitignore as one of our cli scripts is named build :)
+* Added/renamed CDVExifTests to test project.
+
+<br />
+
### 2.8.0 (201305XX) ###
* [CB-2840] Nil checks to avoid crash when network disconnected
[40/50] [abbrv] ios commit: removed media from ios source
Posted by ag...@apache.org.
removed media from ios source
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/067bc70c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/067bc70c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/067bc70c
Branch: refs/heads/master
Commit: 067bc70c22ca02ff389157031cabe4d0189b08a5
Parents: 62dfb55
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 20 21:48:53 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 21:48:53 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVSound.h | 116 ---
CordovaLib/Classes/CDVSound.m | 702 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 7 -
bin/templates/project/__TESTING__/config.xml | 3 -
5 files changed, 829 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/067bc70c/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 0c1779f..6cf592a 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -27,7 +27,6 @@
#import "CDVDebug.h"
#import "CDVPluginResult.h"
-#import "CDVSound.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
#import "CDVScreenOrientationDelegate.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/067bc70c/CordovaLib/Classes/CDVSound.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.h b/CordovaLib/Classes/CDVSound.h
deleted file mode 100644
index 8dcf98e..0000000
--- a/CordovaLib/Classes/CDVSound.h
+++ /dev/null
@@ -1,116 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <AudioToolbox/AudioServices.h>
-#import <AVFoundation/AVFoundation.h>
-
-#import "CDVPlugin.h"
-
-enum CDVMediaError {
- MEDIA_ERR_ABORTED = 1,
- MEDIA_ERR_NETWORK = 2,
- MEDIA_ERR_DECODE = 3,
- MEDIA_ERR_NONE_SUPPORTED = 4
-};
-typedef NSUInteger CDVMediaError;
-
-enum CDVMediaStates {
- MEDIA_NONE = 0,
- MEDIA_STARTING = 1,
- MEDIA_RUNNING = 2,
- MEDIA_PAUSED = 3,
- MEDIA_STOPPED = 4
-};
-typedef NSUInteger CDVMediaStates;
-
-enum CDVMediaMsg {
- MEDIA_STATE = 1,
- MEDIA_DURATION = 2,
- MEDIA_POSITION = 3,
- MEDIA_ERROR = 9
-};
-typedef NSUInteger CDVMediaMsg;
-
-@interface CDVAudioPlayer : AVAudioPlayer
-{
- NSString* mediaId;
-}
-@property (nonatomic, copy) NSString* mediaId;
-@end
-
-@interface CDVAudioRecorder : AVAudioRecorder
-{
- NSString* mediaId;
-}
-@property (nonatomic, copy) NSString* mediaId;
-@end
-
-@interface CDVAudioFile : NSObject
-{
- NSString* resourcePath;
- NSURL* resourceURL;
- CDVAudioPlayer* player;
- CDVAudioRecorder* recorder;
- NSNumber* volume;
-}
-
-@property (nonatomic, strong) NSString* resourcePath;
-@property (nonatomic, strong) NSURL* resourceURL;
-@property (nonatomic, strong) CDVAudioPlayer* player;
-@property (nonatomic, strong) NSNumber* volume;
-
-@property (nonatomic, strong) CDVAudioRecorder* recorder;
-
-@end
-
-@interface CDVSound : CDVPlugin <AVAudioPlayerDelegate, AVAudioRecorderDelegate>
-{
- NSMutableDictionary* soundCache;
- AVAudioSession* avSession;
-}
-@property (nonatomic, strong) NSMutableDictionary* soundCache;
-@property (nonatomic, strong) AVAudioSession* avSession;
-
-- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)seekToAudio:(CDVInvokedUrlCommand*)command;
-- (void)release:(CDVInvokedUrlCommand*)command;
-- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command;
-
-- (BOOL)hasAudioSession;
-
-// helper methods
-- (NSURL*)urlForRecording:(NSString*)resourcePath;
-- (NSURL*)urlForPlaying:(NSString*)resourcePath;
-- (NSURL*)urlForResource:(NSString*)resourcePath CDV_DEPRECATED(2.5, "Use specific api for playing or recording");
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId CDV_DEPRECATED(2.5, "Use updated audioFileForResource api");
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate forRecording:(BOOL)bRecord;
-- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId;
-- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message;
-
-- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command;
-- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command;
-
-- (void)setVolume:(CDVInvokedUrlCommand*)command;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/067bc70c/CordovaLib/Classes/CDVSound.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.m b/CordovaLib/Classes/CDVSound.m
deleted file mode 100644
index 71eab59..0000000
--- a/CordovaLib/Classes/CDVSound.m
+++ /dev/null
@@ -1,702 +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.
- */
-
-#import "CDVSound.h"
-#import "NSArray+Comparisons.h"
-#import "CDVJSON.h"
-
-#define DOCUMENTS_SCHEME_PREFIX @"documents://"
-#define HTTP_SCHEME_PREFIX @"http://"
-#define HTTPS_SCHEME_PREFIX @"https://"
-#define RECORDING_WAV @"wav"
-
-@implementation CDVSound
-
-@synthesize soundCache, avSession;
-
-- (NSURL*)urlForResource:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
-
- // first try to find HTTP:// or Documents:// resources
-
- if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]) {
- // if it is a http url, use it
- NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
- resourceURL = [NSURL URLWithString:resourcePath];
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // attempt to find file path in www directory
- filePath = [self.commandDelegate pathForResource:resourcePath];
- if (filePath != nil) {
- NSLog(@"Found resource '%@' in the web folder.", filePath);
- } else {
- filePath = resourcePath;
- NSLog(@"Will attempt to use file resource '%@'", filePath);
- }
- }
- // check that file exists for all but HTTP_SHEME_PREFIX
- if (filePath != nil) {
- // try to access file
- NSFileManager* fMgr = [[NSFileManager alloc] init];
- if (![fMgr fileExistsAtPath:filePath]) {
- resourceURL = nil;
- NSLog(@"Unknown resource '%@'", resourcePath);
- } else {
- // it's a valid file url, use it
- resourceURL = [NSURL fileURLWithPath:filePath];
- }
- }
- return resourceURL;
-}
-
-// Maps a url for a resource path for recording
-- (NSURL*)urlForRecording:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
-
- // first check for correct extension
- if ([[resourcePath pathExtension] caseInsensitiveCompare:RECORDING_WAV] != NSOrderedSame) {
- resourceURL = nil;
- NSLog(@"Resource for recording must have %@ extension", RECORDING_WAV);
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- // try to find Documents:// resources
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // if resourcePath is not from FileSystem put in tmp dir, else attempt to use provided resource path
- NSString* tmpPath = [NSTemporaryDirectory()stringByStandardizingPath];
- BOOL isTmp = [resourcePath rangeOfString:tmpPath].location != NSNotFound;
- BOOL isDoc = [resourcePath rangeOfString:docsPath].location != NSNotFound;
- if (!isTmp && !isDoc) {
- // put in temp dir
- filePath = [NSString stringWithFormat:@"%@/%@", tmpPath, resourcePath];
- } else {
- filePath = resourcePath;
- }
- }
-
- if (filePath != nil) {
- // create resourceURL
- resourceURL = [NSURL fileURLWithPath:filePath];
- }
- return resourceURL;
-}
-
-// Maps a url for a resource path for playing
-// "Naked" resource paths are assumed to be from the www folder as its base
-- (NSURL*)urlForPlaying:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
-
- // first try to find HTTP:// or Documents:// resources
-
- if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]) {
- // if it is a http url, use it
- NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
- resourceURL = [NSURL URLWithString:resourcePath];
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // attempt to find file path in www directory or LocalFileSystem.TEMPORARY directory
- filePath = [self.commandDelegate pathForResource:resourcePath];
- if (filePath == nil) {
- // see if this exists in the documents/temp directory from a previous recording
- NSString* testPath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], resourcePath];
- if ([[NSFileManager defaultManager] fileExistsAtPath:testPath]) {
- // inefficient as existence will be checked again below but only way to determine if file exists from previous recording
- filePath = testPath;
- NSLog(@"Will attempt to use file resource from LocalFileSystem.TEMPORARY directory");
- } else {
- // attempt to use path provided
- filePath = resourcePath;
- NSLog(@"Will attempt to use file resource '%@'", filePath);
- }
- } else {
- NSLog(@"Found resource '%@' in the web folder.", filePath);
- }
- }
- // check that file exists for all but HTTP_SHEME_PREFIX
- if (filePath != nil) {
- // create resourceURL
- resourceURL = [NSURL fileURLWithPath:filePath];
- // try to access file
- NSFileManager* fMgr = [NSFileManager defaultManager];
- if (![fMgr fileExistsAtPath:filePath]) {
- resourceURL = nil;
- NSLog(@"Unknown resource '%@'", resourcePath);
- }
- }
-
- return resourceURL;
-}
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId
-{
- // will maintain backwards compatibility with original implementation
- return [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO];
-}
-
-// Creates or gets the cached audio file resource object
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate forRecording:(BOOL)bRecord
-{
- BOOL bError = NO;
- CDVMediaError errcode = MEDIA_ERR_NONE_SUPPORTED;
- NSString* errMsg = @"";
- NSString* jsString = nil;
- CDVAudioFile* audioFile = nil;
- NSURL* resourceURL = nil;
-
- if ([self soundCache] == nil) {
- [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
- } else {
- audioFile = [[self soundCache] objectForKey:mediaId];
- }
- if (audioFile == nil) {
- // validate resourcePath and create
- if ((resourcePath == nil) || ![resourcePath isKindOfClass:[NSString class]] || [resourcePath isEqualToString:@""]) {
- bError = YES;
- errcode = MEDIA_ERR_ABORTED;
- errMsg = @"invalid media src argument";
- } else {
- audioFile = [[CDVAudioFile alloc] init];
- audioFile.resourcePath = resourcePath;
- audioFile.resourceURL = nil; // validate resourceURL when actually play or record
- [[self soundCache] setObject:audioFile forKey:mediaId];
- }
- }
- if (bValidate && (audioFile.resourceURL == nil)) {
- if (bRecord) {
- resourceURL = [self urlForRecording:resourcePath];
- } else {
- resourceURL = [self urlForPlaying:resourcePath];
- }
- if (resourceURL == nil) {
- bError = YES;
- errcode = MEDIA_ERR_ABORTED;
- errMsg = [NSString stringWithFormat:@"Cannot use audio file from resource '%@'", resourcePath];
- } else {
- audioFile.resourceURL = resourceURL;
- }
- }
-
- if (bError) {
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:errcode message:errMsg]];
- [self.commandDelegate evalJs:jsString];
- }
-
- return audioFile;
-}
-
-// returns whether or not audioSession is available - creates it if necessary
-- (BOOL)hasAudioSession
-{
- BOOL bSession = YES;
-
- if (!self.avSession) {
- NSError* error = nil;
-
- self.avSession = [AVAudioSession sharedInstance];
- if (error) {
- // is not fatal if can't get AVAudioSession , just log the error
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
- self.avSession = nil;
- bSession = NO;
- }
- }
- return bSession;
-}
-
-// helper function to create a error object string
-- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message
-{
- NSMutableDictionary* errorDict = [NSMutableDictionary dictionaryWithCapacity:2];
-
- [errorDict setObject:[NSNumber numberWithUnsignedInt:code] forKey:@"code"];
- [errorDict setObject:message ? message:@"" forKey:@"message"];
- return [errorDict JSONString];
-}
-
-- (void)create:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* resourcePath = [command.arguments objectAtIndex:1];
-
- CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:NO forRecording:NO];
-
- if (audioFile == nil) {
- NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media file with path %@", resourcePath];
- NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMessage]];
- [self.commandDelegate evalJs:jsString];
- } else {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }
-}
-
-- (void)setVolume:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSNumber* volume = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
-
- CDVAudioFile* audioFile;
- if ([self soundCache] == nil) {
- [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
- } else {
- audioFile = [[self soundCache] objectForKey:mediaId];
- audioFile.volume = volume;
- if (audioFile.player) {
- audioFile.player.volume = [volume floatValue];
- }
- [[self soundCache] setObject:audioFile forKey:mediaId];
- }
-
- // don't care for any callbacks
-}
-
-- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* resourcePath = [command.arguments objectAtIndex:1];
- NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-
- BOOL bError = NO;
- NSString* jsString = nil;
-
- CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO];
- if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
- if (audioFile.player == nil) {
- bError = [self prepareToPlay:audioFile withId:mediaId];
- }
- if (!bError) {
- // audioFile.player != nil or player was successfully created
- // get the audioSession and set the category to allow Playing when device is locked or ring/silent switch engaged
- if ([self hasAudioSession]) {
- NSError* __autoreleasing err = nil;
- NSNumber* playAudioWhenScreenIsLocked = [options objectForKey:@"playAudioWhenScreenIsLocked"];
- BOOL bPlayAudioWhenScreenIsLocked = YES;
- if (playAudioWhenScreenIsLocked != nil) {
- bPlayAudioWhenScreenIsLocked = [playAudioWhenScreenIsLocked boolValue];
- }
-
- NSString* sessionCategory = bPlayAudioWhenScreenIsLocked ? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient;
- [self.avSession setCategory:sessionCategory error:&err];
- if (![self.avSession setActive:YES error:&err]) {
- // other audio with higher priority that does not allow mixing could cause this to fail
- NSLog(@"Unable to play audio: %@", [err localizedFailureReason]);
- bError = YES;
- }
- }
- if (!bError) {
- NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
- NSNumber* loopOption = [options objectForKey:@"numberOfLoops"];
- NSInteger numberOfLoops = 0;
- if (loopOption != nil) {
- numberOfLoops = [loopOption intValue] - 1;
- }
- audioFile.player.numberOfLoops = numberOfLoops;
- if (audioFile.player.isPlaying) {
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- }
- if (audioFile.volume != nil) {
- audioFile.player.volume = [audioFile.volume floatValue];
- }
-
- [audioFile.player play];
- double position = round(audioFile.player.duration * 1000) / 1000;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
- [self.commandDelegate evalJs:jsString];
- }
- }
- if (bError) {
- /* I don't see a problem playing previously recorded audio so removing this section - BG
- NSError* error;
- // try loading it one more time, in case the file was recorded previously
- audioFile.player = [[ AVAudioPlayer alloc ] initWithContentsOfURL:audioFile.resourceURL error:&error];
- if (error != nil) {
- NSLog(@"Failed to initialize AVAudioPlayer: %@\n", error);
- audioFile.player = nil;
- } else {
- NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
- audioFile.player.numberOfLoops = numberOfLoops;
- [audioFile.player play];
- } */
- // error creating the session or player
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_NONE_SUPPORTED];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_NONE_SUPPORTED message:nil]];
- [self.commandDelegate evalJs:jsString];
- }
- }
- // else audioFile was nil - error already returned from audioFile for resource
- return;
-}
-
-- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId
-{
- BOOL bError = NO;
- NSError* __autoreleasing playerError = nil;
-
- // create the player
- NSURL* resourceURL = audioFile.resourceURL;
-
- if ([resourceURL isFileURL]) {
- audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:resourceURL error:&playerError];
- } else {
- NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:resourceURL];
- NSString* userAgent = [self.commandDelegate userAgent];
- if (userAgent) {
- [request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
- }
-
- NSURLResponse* __autoreleasing response = nil;
- NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&playerError];
- if (playerError) {
- NSLog(@"Unable to download audio from: %@", [resourceURL absoluteString]);
- } else {
- // bug in AVAudioPlayer when playing downloaded data in NSData - we have to download the file and play from disk
- CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* filePath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], uuidString];
- CFRelease(uuidString);
- CFRelease(uuidRef);
-
- [data writeToFile:filePath atomically:YES];
- NSURL* fileURL = [NSURL fileURLWithPath:filePath];
- audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&playerError];
- }
- }
-
- if (playerError != nil) {
- NSLog(@"Failed to initialize AVAudioPlayer: %@\n", [playerError localizedDescription]);
- audioFile.player = nil;
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- bError = YES;
- } else {
- audioFile.player.mediaId = mediaId;
- audioFile.player.delegate = self;
- bError = ![audioFile.player prepareToPlay];
- }
- return bError;
-}
-
-- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } // ignore if no media playing
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* jsString = nil;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSLog(@"Paused playing audio sample '%@'", audioFile.resourcePath);
- [audioFile.player pause];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_PAUSED];
- }
- // ignore if no media playing
-
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)seekToAudio:(CDVInvokedUrlCommand*)command
-{
- // args:
- // 0 = Media id
- // 1 = path to resource
- // 2 = seek to location in milliseconds
-
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- double position = [[command.arguments objectAtIndex:1] doubleValue];
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSString* jsString;
- double posInSeconds = position / 1000;
- if (posInSeconds >= audioFile.player.duration) {
- // The seek is past the end of file. Stop media and reset to beginning instead of seeking past the end.
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, 0.0, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- // NSLog(@"seekToEndJsString=%@",jsString);
- } else {
- audioFile.player.currentTime = posInSeconds;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%f);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, posInSeconds];
- // NSLog(@"seekJsString=%@",jsString);
- }
-
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)release:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- if (mediaId != nil) {
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- if (audioFile != nil) {
- if (audioFile.player && [audioFile.player isPlaying]) {
- [audioFile.player stop];
- }
- if (audioFile.recorder && [audioFile.recorder isRecording]) {
- [audioFile.recorder stop];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- self.avSession = nil;
- }
- [[self soundCache] removeObjectForKey:mediaId];
- NSLog(@"Media with id %@ released", mediaId);
- }
- }
-}
-
-- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
-#pragma unused(mediaId)
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- double position = -1;
-
- if ((audioFile != nil) && (audioFile.player != nil) && [audioFile.player isPlaying]) {
- position = round(audioFile.player.currentTime * 1000) / 1000;
- }
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:position];
- NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
-
- NSString* mediaId = [command.arguments objectAtIndex:0];
- CDVAudioFile* audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId:mediaId doValidation:YES forRecording:YES];
- NSString* jsString = nil;
- NSString* errorMsg = @"";
-
- if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
- NSError* __autoreleasing error = nil;
-
- if (audioFile.recorder != nil) {
- [audioFile.recorder stop];
- audioFile.recorder = nil;
- }
- // get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged
- if ([self hasAudioSession]) {
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
- if (![self.avSession setActive:YES error:&error]) {
- // other audio with higher priority that does not allow mixing could cause this to fail
- errorMsg = [NSString stringWithFormat:@"Unable to record audio: %@", [error localizedFailureReason]];
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- [self.commandDelegate evalJs:jsString];
- return;
- }
- }
-
- // create a new recorder for each start record
- audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:nil error:&error];
-
- bool recordingSuccess = NO;
- if (error == nil) {
- audioFile.recorder.delegate = self;
- audioFile.recorder.mediaId = mediaId;
- recordingSuccess = [audioFile.recorder record];
- if (recordingSuccess) {
- NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
- }
- }
-
- if ((error != nil) || (recordingSuccess == NO)) {
- if (error != nil) {
- errorMsg = [NSString stringWithFormat:@"Failed to initialize AVAudioRecorder: %@\n", [error localizedFailureReason]];
- } else {
- errorMsg = @"Failed to start recording using AVAudioRecorder";
- }
- audioFile.recorder = nil;
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- }
- } else {
- // file did not validate
- NSString* errorMsg = [NSString stringWithFormat:@"Could not record audio at '%@'", audioFile.resourcePath];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- }
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
- return;
-}
-
-- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if ((audioFile != nil) && (audioFile.recorder != nil)) {
- NSLog(@"Stopped recording audio sample '%@'", audioFile.resourcePath);
- [audioFile.recorder stop];
- // no callback - that will happen in audioRecorderDidFinishRecording
- }
- // ignore if no media recording
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
- CDVAudioRecorder* aRecorder = (CDVAudioRecorder*)recorder;
- NSString* mediaId = aRecorder.mediaId;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if (audioFile != nil) {
- NSLog(@"Finished recording audio sample '%@'", audioFile.resourcePath);
- }
- if (flag) {
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } else {
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag
-{
- CDVAudioPlayer* aPlayer = (CDVAudioPlayer*)player;
- NSString* mediaId = aPlayer.mediaId;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if (audioFile != nil) {
- NSLog(@"Finished playing audio sample '%@'", audioFile.resourcePath);
- }
- if (flag) {
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } else {
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)onMemoryWarning
-{
- [[self soundCache] removeAllObjects];
- [self setSoundCache:nil];
- [self setAvSession:nil];
-
- [super onMemoryWarning];
-}
-
-- (void)dealloc
-{
- [[self soundCache] removeAllObjects];
-}
-
-- (void)onReset
-{
- for (CDVAudioFile* audioFile in [[self soundCache] allValues]) {
- if (audioFile != nil) {
- if (audioFile.player != nil) {
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- }
- if (audioFile.recorder != nil) {
- [audioFile.recorder stop];
- }
- }
- }
-
- [[self soundCache] removeAllObjects];
-}
-
-@end
-
-@implementation CDVAudioFile
-
-@synthesize resourcePath;
-@synthesize resourceURL;
-@synthesize player, volume;
-@synthesize recorder;
-
-@end
-@implementation CDVAudioPlayer
-@synthesize mediaId;
-
-@end
-
-@implementation CDVAudioRecorder
-@synthesize mediaId;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/067bc70c/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index cd3908d..bf92ac3 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -40,7 +40,6 @@
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
- 8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -105,8 +104,6 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
- 8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
- 8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandQueue.h; path = Classes/CDVCommandQueue.h; sourceTree = "<group>"; };
EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCommandQueue.m; path = Classes/CDVCommandQueue.m; sourceTree = "<group>"; };
@@ -219,8 +216,6 @@
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
- 8887FD601090FBE7009987E8 /* CDVSound.h */,
- 8887FD611090FBE7009987E8 /* CDVSound.m */,
3E76876B156A90EE00EB6FA3 /* CDVLogger.m */,
3E76876C156A90EE00EB6FA3 /* CDVLogger.h */,
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */,
@@ -272,7 +267,6 @@
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
- 8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
@@ -356,7 +350,6 @@
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
- 8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/067bc70c/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 018490c..63ad462 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -52,9 +52,6 @@
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
- <feature name="Media">
- <param name="ios-package" value="CDVSound"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[50/50] [abbrv] ios commit: [CB-4045] Merge branch '3.0.0' into master
Posted by ag...@apache.org.
[CB-4045] Merge branch '3.0.0' into master
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/66aeb901
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/66aeb901
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/66aeb901
Branch: refs/heads/master
Commit: 66aeb901746c292f30742f6eca7a5471d1e9a0d8
Parents: 9e48d82 ce9a0d6
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jun 28 11:06:37 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jun 28 11:06:37 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 16 -
CordovaLib/Classes/CDVAccelerometer.h | 39 -
CordovaLib/Classes/CDVAccelerometer.m | 128 -
CordovaLib/Classes/CDVBattery.h | 40 -
CordovaLib/Classes/CDVBattery.m | 152 -
CordovaLib/Classes/CDVCamera.h | 102 -
CordovaLib/Classes/CDVCamera.m | 730 ---
CordovaLib/Classes/CDVCapture.h | 118 -
CordovaLib/Classes/CDVCapture.m | 845 ---
CordovaLib/Classes/CDVConnection.h | 34 -
CordovaLib/Classes/CDVConnection.m | 132 -
CordovaLib/Classes/CDVContact.h | 136 -
CordovaLib/Classes/CDVContact.m | 1752 -------
CordovaLib/Classes/CDVContacts.h | 151 -
CordovaLib/Classes/CDVContacts.m | 593 ---
CordovaLib/Classes/CDVDevice.h | 30 -
CordovaLib/Classes/CDVDevice.m | 89 -
CordovaLib/Classes/CDVExif.h | 43 -
CordovaLib/Classes/CDVFile.h | 107 -
CordovaLib/Classes/CDVFile.m | 1426 ------
CordovaLib/Classes/CDVFileTransfer.h | 82 -
CordovaLib/Classes/CDVFileTransfer.m | 730 ---
CordovaLib/Classes/CDVGlobalization.h | 150 -
CordovaLib/Classes/CDVGlobalization.m | 790 ---
CordovaLib/Classes/CDVInAppBrowser.h | 89 -
CordovaLib/Classes/CDVInAppBrowser.m | 818 ---
CordovaLib/Classes/CDVJpegHeaderWriter.h | 62 -
CordovaLib/Classes/CDVJpegHeaderWriter.m | 547 --
CordovaLib/Classes/CDVLocation.h | 104 -
CordovaLib/Classes/CDVLocation.m | 623 ---
CordovaLib/Classes/CDVNotification.h | 37 -
CordovaLib/Classes/CDVNotification.m | 130 -
CordovaLib/Classes/CDVReachability.h | 85 -
CordovaLib/Classes/CDVReachability.m | 260 -
CordovaLib/Classes/CDVShared.h | 33 +
CordovaLib/Classes/CDVShared.m | 59 +
CordovaLib/Classes/CDVSound.h | 116 -
CordovaLib/Classes/CDVSound.m | 702 ---
CordovaLib/Classes/CDVSplashScreen.h | 33 -
CordovaLib/Classes/CDVSplashScreen.m | 230 -
CordovaLib/Classes/CDVURLProtocol.m | 7 +-
CordovaLib/Classes/CDVViewController.m | 7 +-
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 156 +-
CordovaLib/cordova.js | 4816 +-----------------
.../__TESTING__.xcodeproj/project.pbxproj | 8 +-
.../Resources/Capture.bundle/controls_bg.png | Bin 955 -> 0 bytes
.../Resources/Capture.bundle/controls_bg@2x.png | Bin 971 -> 0 bytes
.../Capture.bundle/controls_bg@2x~ipad.png | Bin 2858 -> 0 bytes
.../Capture.bundle/controls_bg~ipad.png | Bin 969 -> 0 bytes
.../microphone-568h@2x~iphone.png | Bin 531673 -> 0 bytes
.../Resources/Capture.bundle/microphone.png | Bin 72226 -> 0 bytes
.../Resources/Capture.bundle/microphone@2x.png | Bin 282409 -> 0 bytes
.../Capture.bundle/microphone@2x~ipad.png | Bin 911582 -> 0 bytes
.../Capture.bundle/microphone~ipad.png | Bin 393975 -> 0 bytes
.../Resources/Capture.bundle/record_button.png | Bin 5852 -> 0 bytes
.../Capture.bundle/record_button@2x.png | Bin 13875 -> 0 bytes
.../Capture.bundle/record_button@2x~ipad.png | Bin 15822 -> 0 bytes
.../Capture.bundle/record_button~ipad.png | Bin 7547 -> 0 bytes
.../Resources/Capture.bundle/recording_bg.png | Bin 973 -> 0 bytes
.../Capture.bundle/recording_bg@2x.png | Bin 990 -> 0 bytes
.../Capture.bundle/recording_bg@2x~ipad.png | Bin 1026 -> 0 bytes
.../Capture.bundle/recording_bg~ipad.png | Bin 996 -> 0 bytes
.../Resources/Capture.bundle/stop_button.png | Bin 5514 -> 0 bytes
.../Resources/Capture.bundle/stop_button@2x.png | Bin 12965 -> 0 bytes
.../Capture.bundle/stop_button@2x~ipad.png | Bin 14474 -> 0 bytes
.../Capture.bundle/stop_button~ipad.png | Bin 7119 -> 0 bytes
bin/templates/project/__TESTING__/config.xml | 52 -
67 files changed, 322 insertions(+), 17067 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66aeb901/CordovaLib/Classes/CDVShared.h
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVShared.h
index 0000000,0b59a37..c54567a
mode 000000,100644..100644
--- a/CordovaLib/Classes/CDVShared.h
+++ b/CordovaLib/Classes/CDVShared.h
@@@ -1,0 -1,35 +1,33 @@@
+ /*
+ 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.
+ */
+
+ #import <Foundation/Foundation.h>
+ #import <CoreLocation/CoreLocation.h>
+
-
+ @interface NSError (JSONMethods)
+
+ - (NSString*)JSONRepresentation;
+
+ @end
+
+ @interface CLLocation (JSONMethods)
+
+ - (NSString*)JSONRepresentation;
+
+ @end
-
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66aeb901/CordovaLib/Classes/CDVShared.m
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVShared.m
index 0000000,8756c17..0617ece
mode 000000,100644..100644
--- a/CordovaLib/Classes/CDVShared.m
+++ b/CordovaLib/Classes/CDVShared.m
@@@ -1,0 -1,59 +1,59 @@@
+ /*
+ 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.
+ */
+
+ #import "CDVShared.h"
+
+ #pragma mark -
+ #pragma mark CLLocation(JSONMethods)
+
+ @implementation CLLocation (JSONMethods)
+
+ - (NSString*)JSONRepresentation
+ {
+ return [NSString stringWithFormat:
- @"{ timestamp: %.00f, \
++ @"{ timestamp: %.00f, \
+ coords: { latitude: %f, longitude: %f, altitude: %.02f, heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
+ }",
- [self.timestamp timeIntervalSince1970] * 1000.0,
- self.coordinate.latitude,
- self.coordinate.longitude,
- self.altitude,
- self.course,
- self.speed,
- self.horizontalAccuracy,
- self.verticalAccuracy
- ];
++ [self.timestamp timeIntervalSince1970] * 1000.0,
++ self.coordinate.latitude,
++ self.coordinate.longitude,
++ self.altitude,
++ self.course,
++ self.speed,
++ self.horizontalAccuracy,
++ self.verticalAccuracy
++ ];
+ }
+
+ @end
+
+ #pragma mark NSError(JSONMethods)
+
+ @implementation NSError (JSONMethods)
+
+ - (NSString*)JSONRepresentation
+ {
+ return [NSString stringWithFormat:
- @"{ code: %d, message: '%@'}",
- self.code,
- [self localizedDescription]
- ];
++ @"{ code: %d, message: '%@'}",
++ self.code,
++ [self localizedDescription]
++ ];
+ }
+
-@end
++@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66aeb901/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --cc CordovaLib/Classes/CDVViewController.m
index 94f4552,db79332..f7595f5
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@@ -280,11 -280,7 +280,6 @@@
* Fire up the GPS Service right away as it takes a moment for data to come back.
*/
- if ([enableLocation boolValue]) {
- NSLog(@"Deprecated: The 'EnableLocation' boolean property is deprecated in 2.5.0, and will be removed in 3.0.0. Use the 'onload' boolean attribute (of the CDVLocation plugin.");
- [[self.commandDelegate getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand new]];
- }
--
if (hideKeyboardFormAccessoryBar) {
__weak CDVViewController* weakSelf = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66aeb901/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --cc CordovaLib/cordova.js
index fd8aa39,c697796..56705b1
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@@ -1,5 -1,5 +1,5 @@@
// Platform: ios
- // 2.9.0-0-g83dc4bd
-// 2.7.0rc1-121-g0903b29
++// 2.7.0rc1-154-g98a62ff
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@@ -19,7 -19,7 +19,7 @@@
under the License.
*/
;(function() {
- var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-121-g0903b29';
++var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-154-g98a62ff';
// file: lib/scripts/require.js
var require,
@@@ -376,7 -376,7 +376,7 @@@ function checkArgs(spec, functionName,
if (errMsg) {
errMsg += ', but got ' + typeName + '.';
errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
-- // Don't log when running jake test.
++ // Don't log when running unit tests.
if (typeof jasmine == 'undefined') {
console.error(errMsg);
}
[38/50] [abbrv] ios commit: rebased off master, updated js
Posted by ag...@apache.org.
rebased off master, updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/e5ee1f28
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/e5ee1f28
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/e5ee1f28
Branch: refs/heads/master
Commit: e5ee1f281da7e19276a52c0a6b6366259b939f97
Parents: 925c7f4
Author: Steven Gill <st...@gmail.com>
Authored: Thu Jun 20 14:33:19 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:33:19 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 2161 +-------------------------------------------
1 file changed, 24 insertions(+), 2137 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e5ee1f28/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 2cebb62..c697796 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,29 +1,5 @@
// Platform: ios
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-// 2.9.0rc1-0-g002f33d
-=======
-// 2.7.0rc1-84-g62c5786
->>>>>>> updated cordova js file
-=======
-// 2.7.0rc1-100-g6a53312
->>>>>>> updated cordovajs, removed globalization and camera
-=======
-// 2.7.0rc1-101-gc6482ac
->>>>>>> updated js
-=======
-// 2.7.0rc1-116-gf0108ae
->>>>>>> updated cordovajs
-=======
-// 2.7.0rc1-119-gf0251c4
->>>>>>> updated js
-=======
-// 2.7.0rc1-120-g8731b31
->>>>>>> updated cordovajs
+// 2.7.0rc1-121-g0903b29
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -43,31 +19,7 @@
under the License.
*/
;(function() {
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
->>>>>>> updated cordova js file
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-100-g6a53312';
->>>>>>> updated cordovajs, removed globalization and camera
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-101-gc6482ac';
->>>>>>> updated js
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
->>>>>>> updated cordovajs
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-119-gf0251c4';
->>>>>>> updated js
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-120-g8731b31';
->>>>>>> updated cordovajs
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-121-g0903b29';
// file: lib/scripts/require.js
var require,
@@ -1184,2027 +1136,6 @@ module.exports = {
});
-<<<<<<< HEAD
-// file: lib/common/plugin/CaptureAudioOptions.js
-define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureAudioOptions;
-
-});
-
-// file: lib/common/plugin/CaptureError.js
-define("cordova/plugin/CaptureError", function(require, exports, module) {
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
-
-});
-
-// file: lib/common/plugin/CaptureImageOptions.js
-define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
-};
-
-module.exports = CaptureImageOptions;
-
-});
-
-// file: lib/common/plugin/CaptureVideoOptions.js
-define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureVideoOptions;
-
-});
-
-// file: lib/common/plugin/ConfigurationData.js
-define("cordova/plugin/ConfigurationData", function(require, exports, module) {
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
-
-});
-
-// file: lib/common/plugin/DirectoryEntry.js
-define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or exclusively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
- var win = successCallback && function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or exclusively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
- var win = successCallback && function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
-
-});
-
-// file: lib/common/plugin/DirectoryReader.js
-define("cordova/plugin/DirectoryReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError') ;
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
-
-});
-
-// file: lib/common/plugin/Entry.js
-define("cordova/plugin/Entry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = !!isFile;
- this.isDirectory = !!isDirectory;
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
- var success = successCallback && function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- * @param metadataObject
- * {Object} keys and values to set
- */
-Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
- argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- // success callback
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.toURL();
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.remove', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getParent', arguments);
- var win = successCallback && function(result) {
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
-
-});
-
-// file: lib/common/plugin/File.js
-define("cordova/plugin/File", function(require, exports, module) {
-
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-
- // These store the absolute start and end for slicing the file.
- this.start = 0;
- this.end = this.size;
-};
-
-/**
- * Returns a "slice" of the file. Since Cordova Files don't contain the actual
- * content, this really returns a File with adjusted start and end.
- * Slices of slices are supported.
- * start {Number} The index at which to start the slice (inclusive).
- * end {Number} The index at which to end the slice (exclusive).
- */
-File.prototype.slice = function(start, end) {
- var size = this.end - this.start;
- var newStart = 0;
- var newEnd = size;
- if (arguments.length) {
- if (start < 0) {
- newStart = Math.max(size + start, 0);
- } else {
- newStart = Math.min(size, start);
- }
- }
-
- if (arguments.length >= 2) {
- if (end < 0) {
- newEnd = Math.max(size + end, 0);
- } else {
- newEnd = Math.min(end, size);
- }
- }
-
- var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size);
- newFile.start = this.start + newStart;
- newFile.end = this.start + newEnd;
- return newFile;
-};
-
-
-module.exports = File;
-
-});
-
-// file: lib/common/plugin/FileEntry.js
-define("cordova/plugin/FileEntry", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- } else {
- successCallback && successCallback(writer);
- }
- }, errorCallback);
-};
-
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = successCallback && function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
-
-});
-
-// file: lib/common/plugin/FileError.js
-define("cordova/plugin/FileError", function(require, exports, module) {
-
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;
-
-});
-
-// file: lib/common/plugin/FileReader.js
-define("cordova/plugin/FileReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper'),
- utils = require('cordova/utils'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent'),
- origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this._readyState = 0;
- this._error = null;
- this._result = null;
- this._fileName = '';
- this._realReader = origFileReader ? new origFileReader() : {};
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-utils.defineGetter(FileReader.prototype, 'readyState', function() {
- return this._fileName ? this._readyState : this._realReader.readyState;
-});
-
-utils.defineGetter(FileReader.prototype, 'error', function() {
- return this._fileName ? this._error: this._realReader.error;
-});
-
-utils.defineGetter(FileReader.prototype, 'result', function() {
- return this._fileName ? this._result: this._realReader.result;
-});
-
-function defineEvent(eventName) {
- utils.defineGetterSetter(FileReader.prototype, eventName, function() {
- return this._realReader[eventName] || null;
- }, function(value) {
- this._realReader[eventName] = value;
- });
-}
-defineEvent('onloadstart'); // When the read starts.
-defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
-defineEvent('onload'); // When the read has successfully completed.
-defineEvent('onerror'); // When the read has failed (see errors).
-defineEvent('onloadend'); // When the request has completed (either in success or failure).
-defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
-
-function initRead(reader, file) {
- // Already loading something
- if (reader.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- reader._result = null;
- reader._error = null;
- reader._readyState = FileReader.LOADING;
-
- if (typeof file.fullPath == 'string') {
- reader._fileName = file.fullPath;
- } else {
- reader._fileName = '';
- return true;
- }
-
- reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
-}
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- if (origFileReader && !this._fileName) {
- return this._realReader.abort();
- }
- this._result = null;
-
- if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
- return;
- }
-
- this._readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- if (initRead(this, file)) {
- return this._realReader.readAsText(file, encoding);
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
- var me = this;
- var execArgs = [this._fileName, enc, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // null result
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsText", execArgs);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsDataURL(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsDataURL", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsBinaryString(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsBinaryString", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsArrayBuffer(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsArrayBuffer", execArgs);
-};
-
-module.exports = FileReader;
-
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
-
-});
-
-// file: lib/common/plugin/FileTransfer.js
-define("cordova/plugin/FileTransfer", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-function newProgressEvent(result) {
- var pe = new ProgressEvent();
- pe.lengthComputable = result.lengthComputable;
- pe.loaded = result.loaded;
- pe.total = result.total;
- return pe;
-}
-
-function getBasicAuthHeader(urlString) {
- var header = null;
-
- if (window.btoa) {
- // parse the url using the Location object
- var url = document.createElement('a');
- url.href = urlString;
-
- var credentials = null;
- var protocol = url.protocol + "//";
- var origin = protocol + url.host;
-
- // check whether there are the username:password credentials in the url
- if (url.href.indexOf(origin) !== 0) { // credentials found
- var atIndex = url.href.indexOf("@");
- credentials = url.href.substring(protocol.length, atIndex);
- }
-
- if (credentials) {
- var authHeader = "Authorization";
- var authHeaderValue = "Basic " + window.btoa(credentials);
-
- header = {
- name : authHeader,
- value : authHeaderValue
- };
- }
- }
-
- return header;
-}
-
-var idCounter = 0;
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {
- this._id = ++idCounter;
- this.onprogress = null; // optional callback
-};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
- argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- var headers = null;
- var httpMethod = null;
- var basicAuthHeader = getBasicAuthHeader(server);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- headers = options.headers;
- httpMethod = options.httpMethod || "POST";
- if (httpMethod.toUpperCase() == "PUT"){
- httpMethod = "PUT";
- } else {
- httpMethod = "POST";
- }
- if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- var self = this;
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- self.onprogress(newProgressEvent(result));
- }
- } else {
- successCallback && successCallback(result);
- }
- };
- exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
- * @param options {FileDownloadOptions} Optional parameters such as headers
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
- argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
- var self = this;
-
- var basicAuthHeader = getBasicAuthHeader(source);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- var headers = null;
- if (options) {
- headers = options.headers || null;
- }
-
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- return self.onprogress(newProgressEvent(result));
- }
- } else if (successCallback) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- }
- };
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
-};
-
-/**
- * Aborts the ongoing file transfer on this object. The original error
- * callback for the file transfer will be called if necessary.
- */
-FileTransfer.prototype.abort = function() {
- exec(null, null, 'FileTransfer', 'abort', [this._id]);
-};
-
-module.exports = FileTransfer;
-
-});
-
-// file: lib/common/plugin/FileTransferError.js
-define("cordova/plugin/FileTransferError", function(require, exports, module) {
-
-/**
- * FileTransferError
- * @constructor
- */
-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;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-FileTransferError.ABORT_ERR = 4;
-
-module.exports = FileTransferError;
-
-});
-
-// file: lib/common/plugin/FileUploadOptions.js
-define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
-
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- * @param headers {Object} Keys are header names, values are header values. Multiple
- * headers of the same name are not supported.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
- this.headers = headers || null;
- this.httpMethod = httpMethod || null;
-};
-
-module.exports = FileUploadOptions;
-
-});
-
-// file: lib/common/plugin/FileUploadResult.js
-define("cordova/plugin/FileUploadResult", function(require, exports, module) {
-
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
-
-});
-
-// file: lib/common/plugin/FileWriter.js
-define("cordova/plugin/FileWriter", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param data text or blob to be written
- */
-FileWriter.prototype.write = function(data) {
-
- var isBinary = false;
-
- // If we don't have Blob or ArrayBuffer support, don't bother.
- if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
-
- // Check to see if the incoming data is a blob
- if (data instanceof Blob) {
- var that=this;
- var fileReader = new FileReader();
- fileReader.onload = function() {
- // Call this method again, with the arraybuffer as argument
- FileWriter.prototype.write.call(that, this.result);
- };
- fileReader.readAsArrayBuffer(data);
- return;
- }
-
- // Mark data type for safer transport over the binary bridge
- isBinary = (data instanceof ArrayBuffer);
- }
-
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // position always increases by bytes written because file would be extended
- me.position += r;
- // The length of the file is now where we are done writing.
-
- me.length = me.position;
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "write", [this.fileName, data, this.position, isBinary]);
-};
-
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound. If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
-FileWriter.prototype.seek = function(offset) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- if (!offset && offset !== 0) {
- return;
- }
-
- // See back from end of file.
- if (offset < 0) {
- this.position = Math.max(offset + this.length, 0);
- }
- // Offset is bigger than file size so set position
- // to the end of the file.
- else if (offset > this.length) {
- this.position = this.length;
- }
- // Offset is between 0 and file size so set the position
- // to start writing.
- else {
- this.position = offset;
- }
-};
-
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
-FileWriter.prototype.truncate = function(size) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":this}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Update the length of the file
- me.length = r;
- me.position = Math.min(me.position, r);
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "truncate", [this.fileName, size]);
-};
-
-module.exports = FileWriter;
-
-});
-
-// file: lib/common/plugin/Flags.js
-define("cordova/plugin/Flags", function(require, exports, module) {
-
-/**
- * Supplies arguments to methods that lookup or create files and directories.
- *
- * @param create
- * {boolean} file or directory if it doesn't exist
- * @param exclusive
- * {boolean} used with create; if true the command will fail if
- * target path exists
- */
-function Flags(create, exclusive) {
- this.create = create || false;
- this.exclusive = exclusive || false;
-}
-
-module.exports = Flags;
-
-});
-
-// file: lib/common/plugin/LocalFileSystem.js
-define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Represents a local file system.
- */
-var LocalFileSystem = function() {
-
-};
-
-LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
-LocalFileSystem.PERSISTENT = 1; //persistent
-
-module.exports = LocalFileSystem;
-
-});
-
-// file: lib/common/plugin/Media.js
-define("cordova/plugin/Media", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var mediaObjects = {};
-
-/**
- * This class provides access to the device media, interfaces to both sound and video
- *
- * @constructor
- * @param src The file name or url to play
- * @param successCallback The callback to be called when the file is done playing or recording.
- * successCallback()
- * @param errorCallback The callback to be called if there is an error.
- * errorCallback(int errorCode) - OPTIONAL
- * @param statusCallback The callback to be called when media status has changed.
- * statusCallback(int statusCode) - OPTIONAL
- */
-var Media = function(src, successCallback, errorCallback, statusCallback) {
- argscheck.checkArgs('SFFF', 'Media', arguments);
- this.id = utils.createUUID();
- mediaObjects[this.id] = this;
- this.src = src;
- this.successCallback = successCallback;
- this.errorCallback = errorCallback;
- this.statusCallback = statusCallback;
- this._duration = -1;
- this._position = -1;
- exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
-};
-
-// Media messages
-Media.MEDIA_STATE = 1;
-Media.MEDIA_DURATION = 2;
-Media.MEDIA_POSITION = 3;
-Media.MEDIA_ERROR = 9;
-
-// Media states
-Media.MEDIA_NONE = 0;
-Media.MEDIA_STARTING = 1;
-Media.MEDIA_RUNNING = 2;
-Media.MEDIA_PAUSED = 3;
-Media.MEDIA_STOPPED = 4;
-Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
-
-// "static" function to return existing objs.
-Media.get = function(id) {
- return mediaObjects[id];
-};
-
-/**
- * Start or resume playing audio file.
- */
-Media.prototype.play = function(options) {
- exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
-};
-
-/**
- * Stop playing audio file.
- */
-Media.prototype.stop = function() {
- var me = this;
- exec(function() {
- me._position = 0;
- }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
-};
-
-/**
- * Seek or jump to a new time in the track..
- */
-Media.prototype.seekTo = function(milliseconds) {
- var me = this;
- exec(function(p) {
- me._position = p;
- }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
-};
-
-/**
- * Pause playing audio file.
- */
-Media.prototype.pause = function() {
- exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
-};
-
-/**
- * Get duration of an audio file.
- * The duration is only set for audio that is playing, paused or stopped.
- *
- * @return duration or -1 if not known.
- */
-Media.prototype.getDuration = function() {
- return this._duration;
-};
-
-/**
- * Get position of audio.
- */
-Media.prototype.getCurrentPosition = function(success, fail) {
- var me = this;
- exec(function(p) {
- me._position = p;
- success(p);
- }, fail, "Media", "getCurrentPositionAudio", [this.id]);
-};
-
-/**
- * Start recording audio file.
- */
-Media.prototype.startRecord = function() {
- exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop recording audio file.
- */
-Media.prototype.stopRecord = function() {
- exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
-};
-
-/**
- * Release the resources.
- */
-Media.prototype.release = function() {
- exec(null, this.errorCallback, "Media", "release", [this.id]);
-};
-
-/**
- * Adjust the volume.
- */
-Media.prototype.setVolume = function(volume) {
- exec(null, null, "Media", "setVolume", [this.id, volume]);
-};
-
-/**
- * Audio has status update.
- * PRIVATE
- *
- * @param id The media object id (string)
- * @param msgType The 'type' of update this is
- * @param value Use of value is determined by the msgType
- */
-Media.onStatus = function(id, msgType, value) {
-
- var media = mediaObjects[id];
-
- if(media) {
- switch(msgType) {
- case Media.MEDIA_STATE :
- media.statusCallback && media.statusCallback(value);
- if(value == Media.MEDIA_STOPPED) {
- media.successCallback && media.successCallback();
- }
- break;
- case Media.MEDIA_DURATION :
- media._duration = value;
- break;
- case Media.MEDIA_ERROR :
- media.errorCallback && media.errorCallback(value);
- break;
- case Media.MEDIA_POSITION :
- media._position = Number(value);
- break;
- default :
- console.error && console.error("Unhandled Media.onStatus :: " + msgType);
- break;
- }
- }
- else {
- console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
- }
-
-};
-
-module.exports = Media;
-
-});
-
-// file: lib/common/plugin/MediaError.js
-define("cordova/plugin/MediaError", function(require, exports, module) {
-
-/**
- * This class contains information about any Media errors.
-*/
-/*
- According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
- We should never be creating these objects, we should just implement the interface
- which has 1 property for an instance, 'code'
-
- instead of doing :
- errorCallbackFunction( new MediaError(3,'msg') );
-we should simply use a literal :
- errorCallbackFunction( {'code':3} );
- */
-
- var _MediaError = window.MediaError;
-
-
-if(!_MediaError) {
- window.MediaError = _MediaError = function(code, msg) {
- this.code = (typeof code != 'undefined') ? code : null;
- this.message = msg || ""; // message is NON-standard! do not use!
- };
-}
-
-_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
-_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
-_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
-_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
-_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
-// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
-// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
-_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
-
-module.exports = _MediaError;
-
-});
-
-// file: lib/common/plugin/MediaFile.js
-define("cordova/plugin/MediaFile", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('cordova/plugin/File'),
- CaptureError = require('cordova/plugin/CaptureError');
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
- }
-};
-
-module.exports = MediaFile;
-
-});
-
-// file: lib/common/plugin/MediaFileData.js
-define("cordova/plugin/MediaFileData", function(require, exports, module) {
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
-
-});
-
-// file: lib/common/plugin/Metadata.js
-define("cordova/plugin/Metadata", function(require, exports, module) {
-
-/**
- * Information about the state of the file or directory
- *
- * {Date} modificationTime (readonly)
- */
-var Metadata = function(time) {
- this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
-};
-
-module.exports = Metadata;
-
-});
-
-// file: lib/common/plugin/ProgressEvent.js
-define("cordova/plugin/ProgressEvent", function(require, exports, module) {
-
-// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
-// Feature test: See if we can instantiate a native ProgressEvent;
-// if so, use that approach,
-// otherwise fill-in with our own implementation.
-//
-// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
-var ProgressEvent = (function() {
- /*
- var createEvent = function(data) {
- var event = document.createEvent('Events');
- event.initEvent('ProgressEvent', false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- if (data.target) {
- // TODO: cannot call <some_custom_object>.dispatchEvent
- // need to first figure out how to implement EventTarget
- }
- }
- return event;
- };
- try {
- var ev = createEvent({type:"abort",target:document});
- return function ProgressEvent(type, data) {
- data.type = type;
- return createEvent(data);
- };
- } catch(e){
- */
- return function ProgressEvent(type, dict) {
- this.type = type;
- this.bubbles = false;
- this.cancelBubble = false;
- this.cancelable = false;
- this.lengthComputable = false;
- this.loaded = dict && dict.loaded ? dict.loaded : 0;
- this.total = dict && dict.total ? dict.total : 0;
- this.target = dict && dict.target ? dict.target : null;
- };
- //}
-})();
-
-module.exports = ProgressEvent;
-
-});
-
-// file: lib/common/plugin/capture.js
-define("cordova/plugin/capture", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-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);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-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');
-
-});
-
-=======
->>>>>>> updated cordova.js
// file: lib/common/plugin/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
@@ -4058,21 +1989,11 @@ require('cordova/channel').onNativeReady.fire();
}
}
- function scriptErrorCallback(err) {
- // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
- // this is currently just continuing.
- scriptCounter--;
- if (scriptCounter === 0) {
- onScriptLoadingComplete && onScriptLoadingComplete();
- }
- }
-
// Helper function to inject a <script> tag.
function injectScript(path) {
scriptCounter++;
var script = document.createElement("script");
script.onload = scriptLoadedCallback;
- script.onerror = scriptErrorCallback;
script.src = path;
document.head.appendChild(script);
}
@@ -4084,10 +2005,10 @@ require('cordova/channel').onNativeReady.fire();
context.cordova.require('cordova/channel').onPluginsReady.fire();
}
- // Handler for the cordova_plugins.js content.
+ // Handler for the cordova_plugins.json content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
- // Otherwise the onerror response handler will just call finishPluginLoading().
+ // Otherwise the XHR response handler will just call finishPluginLoading().
function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
@@ -4095,31 +2016,26 @@ require('cordova/channel').onNativeReady.fire();
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
- if (module) {
- try {
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- mapper.clobbers(module.id, module.clobbers[j]);
- }
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- mapper.merges(module.id, module.merges[k]);
- }
- }
-
- // Finally, if runs is truthy we want to simply require() the module.
- // This can be skipped if it had any merges or clobbers, though,
- // since the mapper will already have required the module.
- if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
- context.cordova.require(module.id);
- }
+ if (!module) continue;
+
+ if (module.clobbers && module.clobbers.length) {
+ for (var j = 0; j < module.clobbers.length; j++) {
+ mapper.clobbers(module.id, module.clobbers[j]);
}
- catch(err) {
- // error with module, most likely clobbers, should we continue?
+ }
+
+ if (module.merges && module.merges.length) {
+ for (var k = 0; k < module.merges.length; k++) {
+ mapper.merges(module.id, module.merges[k]);
}
}
+
+ // Finally, if runs is truthy we want to simply require() the module.
+ // This can be skipped if it had any merges or clobbers, though,
+ // since the mapper will already have required the module.
+ if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
+ context.cordova.require(module.id);
+ }
}
finishPluginLoading();
@@ -4142,33 +2058,6 @@ require('cordova/channel').onNativeReady.fire();
break;
}
}
-
- var plugins_json = path + 'cordova_plugins.json';
- var plugins_js = path + 'cordova_plugins.js';
-
- // One some phones (Windows) this xhr.open throws an Access Denied exception
- // So lets keep trying, but with a script tag injection technique instead of XHR
- var injectPluginScript = function injectPluginScript() {
- try {
- var script = document.createElement("script");
- script.onload = function(){
- var list = cordova.require("cordova/plugin_list");
- handlePluginsObject(list,path);
- };
- script.onerror = function() {
- // Error loading cordova_plugins.js, file not found or something
- // this is an acceptable error, pre-3.0.0, so we just move on.
- finishPluginLoading();
- };
- script.src = plugins_js;
- document.head.appendChild(script);
-
- } catch(err){
- finishPluginLoading();
- }
- }
-
-
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -4187,16 +2076,14 @@ require('cordova/channel').onNativeReady.fire();
}
};
xhr.onerror = function() {
- // In this case, the json file was not present, but XHR was allowed,
- // so we should still try the script injection technique with the js file
- // in case that is there.
- injectPluginScript();
+ finishPluginLoading();
};
+ var plugins_json = path + 'cordova_plugins.json';
try { // we commented we were going to try, so let us actually try and catch
xhr.open('GET', plugins_json, true); // Async
xhr.send();
} catch(err){
- injectPluginScript();
+ finishPluginLoading();
}
}(window));
[22/50] [abbrv] ios commit: removed various plugins from config.xml
and projet.pbxproj
Posted by ag...@apache.org.
removed various plugins from config.xml and projet.pbxproj
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c7750bbf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c7750bbf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c7750bbf
Branch: refs/heads/master
Commit: c7750bbf59cffec69091aa53c0a8f8e2c65e5b28
Parents: 9f1d0fd
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 18:19:06 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:23:51 2013 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 73 --------------------
bin/templates/project/__TESTING__/config.xml | 28 --------
2 files changed, 101 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c7750bbf/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index a4fcc39..3c6ba71 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,10 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */; };
- 1F3C04CE12BC247D004F9E10 /* CDVContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C04CC12BC247D004F9E10 /* CDVContact.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F3C04CF12BC247D004F9E10 /* CDVContact.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C04CD12BC247D004F9E10 /* CDVContact.m */; };
1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F584B991385A28900ED25E8 /* CDVCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F584B9A1385A28900ED25E8 /* CDVCapture.m */; };
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -22,13 +18,9 @@
30392E4E14F4FCAB00B9E0B8 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; };
3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */; };
- 3073E9E91656D37700957977 /* CDVInAppBrowser.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9E71656D37700957977 /* CDVInAppBrowser.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 3073E9EA1656D37700957977 /* CDVInAppBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 3073E9E81656D37700957977 /* CDVInAppBrowser.m */; };
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
- 30B39EBE13D0268B0009682A /* CDVSplashScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30B39EBF13D0268B0009682A /* CDVSplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */; };
30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C5F1DD15AF9E950052A00D /* CDVDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C5F1DE15AF9E950052A00D /* CDVDevice.m */; };
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -55,26 +47,15 @@
8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD271090FBE7009987E8 /* CDVCamera.m */; };
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
- 8887FD6A1090FBE7009987E8 /* CDVContacts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD2A1090FBE7009987E8 /* CDVContacts.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD6B1090FBE7009987E8 /* CDVContacts.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD2B1090FBE7009987E8 /* CDVContacts.m */; };
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD311090FBE7009987E8 /* CDVFile.m */; };
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
- 8887FD851090FBE7009987E8 /* CDVLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD461090FBE7009987E8 /* CDVLocation.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD861090FBE7009987E8 /* CDVLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD471090FBE7009987E8 /* CDVLocation.m */; };
- 8887FD8D1090FBE7009987E8 /* CDVNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD4E1090FBE7009987E8 /* CDVNotification.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD8E1090FBE7009987E8 /* CDVNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD4F1090FBE7009987E8 /* CDVNotification.m */; };
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD611090FBE7009987E8 /* CDVSound.m */; };
- 88BA573D109BB46F00FB5E78 /* CDVAccelerometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 88BA573E109BB46F00FB5E78 /* CDVAccelerometer.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */; };
- 9D76CF3C1625A4C50008A0F6 /* CDVGlobalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 9D76CF3D1625A4C50008A0F6 /* CDVGlobalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */; };
C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = C937A4541337599E002C4C79 /* CDVFileTransfer.h */; settings = {ATTRIBUTES = (Public, ); }; };
C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = C937A4551337599E002C4C79 /* CDVFileTransfer.m */; };
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -94,10 +75,6 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVBattery.h; path = Classes/CDVBattery.h; sourceTree = "<group>"; };
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVBattery.m; path = Classes/CDVBattery.m; sourceTree = "<group>"; };
- 1F3C04CC12BC247D004F9E10 /* CDVContact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVContact.h; path = Classes/CDVContact.h; sourceTree = "<group>"; };
- 1F3C04CD12BC247D004F9E10 /* CDVContact.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVContact.m; path = Classes/CDVContact.m; sourceTree = "<group>"; };
1F584B991385A28900ED25E8 /* CDVCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCapture.h; path = Classes/CDVCapture.h; sourceTree = "<group>"; };
1F584B9A1385A28900ED25E8 /* CDVCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCapture.m; path = Classes/CDVCapture.m; sourceTree = "<group>"; };
1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree = "<group>"; };
@@ -110,13 +87,9 @@
30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVAvailability.h; path = Classes/CDVAvailability.h; sourceTree = "<group>"; };
3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+Extensions.h"; path = "Classes/UIDevice+Extensions.h"; sourceTree = "<group>"; };
3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+Extensions.m"; path = "Classes/UIDevice+Extensions.m"; sourceTree = "<group>"; };
- 3073E9E71656D37700957977 /* CDVInAppBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInAppBrowser.h; path = Classes/CDVInAppBrowser.h; sourceTree = "<group>"; };
- 3073E9E81656D37700957977 /* CDVInAppBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInAppBrowser.m; path = Classes/CDVInAppBrowser.m; sourceTree = "<group>"; };
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
- 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSplashScreen.h; path = Classes/CDVSplashScreen.h; sourceTree = "<group>"; };
- 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSplashScreen.m; path = Classes/CDVSplashScreen.m; sourceTree = "<group>"; };
30C5F1DD15AF9E950052A00D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = Classes/CDVDevice.h; sourceTree = "<group>"; };
30C5F1DE15AF9E950052A00D /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = Classes/CDVDevice.m; sourceTree = "<group>"; };
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
@@ -156,26 +129,16 @@
8887FD271090FBE7009987E8 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCamera.m; path = Classes/CDVCamera.m; sourceTree = "<group>"; };
8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
- 8887FD2A1090FBE7009987E8 /* CDVContacts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVContacts.h; path = Classes/CDVContacts.h; sourceTree = "<group>"; };
- 8887FD2B1090FBE7009987E8 /* CDVContacts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVContacts.m; path = Classes/CDVContacts.m; sourceTree = "<group>"; };
8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
8887FD311090FBE7009987E8 /* CDVFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFile.m; path = Classes/CDVFile.m; sourceTree = "<group>"; };
8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInvokedUrlCommand.h; path = Classes/CDVInvokedUrlCommand.h; sourceTree = "<group>"; };
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
- 8887FD461090FBE7009987E8 /* CDVLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVLocation.h; path = Classes/CDVLocation.h; sourceTree = "<group>"; };
- 8887FD471090FBE7009987E8 /* CDVLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVLocation.m; path = Classes/CDVLocation.m; sourceTree = "<group>"; };
- 8887FD4E1090FBE7009987E8 /* CDVNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVNotification.h; path = Classes/CDVNotification.h; sourceTree = "<group>"; };
- 8887FD4F1090FBE7009987E8 /* CDVNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVNotification.m; path = Classes/CDVNotification.m; sourceTree = "<group>"; };
8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
8887FD5E1090FBE7009987E8 /* CDVReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVReachability.h; path = Classes/CDVReachability.h; sourceTree = "<group>"; };
8887FD5F1090FBE7009987E8 /* CDVReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVReachability.m; path = Classes/CDVReachability.m; sourceTree = "<group>"; };
8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
- 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVAccelerometer.h; path = Classes/CDVAccelerometer.h; sourceTree = "<group>"; };
- 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVAccelerometer.m; path = Classes/CDVAccelerometer.m; sourceTree = "<group>"; };
- 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVGlobalization.h; path = Classes/CDVGlobalization.h; sourceTree = "<group>"; };
- 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVGlobalization.m; path = Classes/CDVGlobalization.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
C937A4541337599E002C4C79 /* CDVFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFileTransfer.h; path = Classes/CDVFileTransfer.h; sourceTree = "<group>"; };
C937A4551337599E002C4C79 /* CDVFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFileTransfer.m; path = Classes/CDVFileTransfer.m; sourceTree = "<group>"; };
@@ -284,18 +247,12 @@
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */,
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */,
- 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */,
- 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
307A8F9C1385A2EC00E43782 /* CDVConnection.h */,
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */,
- 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */,
8887FD261090FBE7009987E8 /* CDVCamera.h */,
8887FD271090FBE7009987E8 /* CDVCamera.m */,
1F584B991385A28900ED25E8 /* CDVCapture.h */,
@@ -303,10 +260,6 @@
68B7516A16FD18190076A8B4 /* CDVExif.h */,
68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */,
68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */,
- 1F3C04CC12BC247D004F9E10 /* CDVContact.h */,
- 1F3C04CD12BC247D004F9E10 /* CDVContact.m */,
- 8887FD2A1090FBE7009987E8 /* CDVContacts.h */,
- 8887FD2B1090FBE7009987E8 /* CDVContacts.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD301090FBE7009987E8 /* CDVFile.h */,
@@ -315,20 +268,12 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
- 8887FD461090FBE7009987E8 /* CDVLocation.h */,
- 8887FD471090FBE7009987E8 /* CDVLocation.m */,
- 8887FD4E1090FBE7009987E8 /* CDVNotification.h */,
- 8887FD4F1090FBE7009987E8 /* CDVNotification.m */,
8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
8887FD611090FBE7009987E8 /* CDVSound.m */,
3E76876B156A90EE00EB6FA3 /* CDVLogger.m */,
3E76876C156A90EE00EB6FA3 /* CDVLogger.h */,
- 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */,
- 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */,
- 3073E9E71656D37700957977 /* CDVInAppBrowser.h */,
- 3073E9E81656D37700957977 /* CDVInAppBrowser.m */,
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */,
30F39309169F839700B22307 /* CDVJSON.h */,
30F3930A169F839700B22307 /* CDVJSON.m */,
@@ -379,25 +324,18 @@
68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */,
8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */,
8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
- 8887FD6A1090FBE7009987E8 /* CDVContacts.h in Headers */,
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
- 8887FD851090FBE7009987E8 /* CDVLocation.h in Headers */,
- 8887FD8D1090FBE7009987E8 /* CDVNotification.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
- 88BA573D109BB46F00FB5E78 /* CDVAccelerometer.h in Headers */,
- 1F3C04CE12BC247D004F9E10 /* CDVContact.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */,
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */,
30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
- 30B39EBE13D0268B0009682A /* CDVSplashScreen.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */,
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */,
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */,
8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */,
@@ -412,8 +350,6 @@
EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */,
EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */,
EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */,
- 9D76CF3C1625A4C50008A0F6 /* CDVGlobalization.h in Headers */,
- 3073E9E91656D37700957977 /* CDVInAppBrowser.h in Headers */,
3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */,
F858FBC6166009A8007DA594 /* CDVConfigParser.h in Headers */,
30F3930B169F839700B22307 /* CDVJSON.h in Headers */,
@@ -479,24 +415,17 @@
files = (
8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */,
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
- 8887FD6B1090FBE7009987E8 /* CDVContacts.m in Sources */,
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
- 8887FD861090FBE7009987E8 /* CDVLocation.m in Sources */,
- 8887FD8E1090FBE7009987E8 /* CDVNotification.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
- 88BA573E109BB46F00FB5E78 /* CDVAccelerometer.m in Sources */,
- 1F3C04CF12BC247D004F9E10 /* CDVContact.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */,
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */,
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
- 30B39EBF13D0268B0009682A /* CDVSplashScreen.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */,
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */,
@@ -508,8 +437,6 @@
EB80C2AD15DEA63D004D9E7B /* CDVEcho.m in Sources */,
EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */,
EB3B357D161F2A45003DBE7D /* CDVCommandDelegateImpl.m in Sources */,
- 9D76CF3D1625A4C50008A0F6 /* CDVGlobalization.m in Sources */,
- 3073E9EA1656D37700957977 /* CDVInAppBrowser.m in Sources */,
F858FBC7166009A8007DA594 /* CDVConfigParser.m in Sources */,
30F3930C169F839700B22307 /* CDVJSON.m in Sources */,
EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c7750bbf/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index db64661..aded8e0 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -52,58 +52,30 @@
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
-
- <feature name="Geolocation">
- <param name="ios-package" value="CDVLocation"/>
- </feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice"/>
</feature>
- <feature name="Accelerometer">
- <param name="ios-package" value="CDVAccelerometer"/>
- </feature>
- <feature name="Compass">
- <param name="ios-package" value="CDVLocation"/>
- </feature>
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
<feature name="Camera">
<param name="ios-package" value="CDVCamera"/>
</feature>
- <feature name="Contacts">
- <param name="ios-package" value="CDVContacts"/>
- </feature>
<feature name="File">
<param name="ios-package" value="CDVFile"/>
</feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection"/>
</feature>
- <feature name="Notification">
- <param name="ios-package" value="CDVNotification"/>
- </feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer"/>
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture"/>
</feature>
- <feature name="Battery">
- <param name="ios-package" value="CDVBattery"/>
- </feature>
- <feature name="SplashScreen">
- <param name="ios-package" value="CDVSplashScreen"/>
- </feature>
- <feature name="Echo">
- <param name="ios-package" value="CDVEcho"/>
- </feature>
<feature name="Globalization">
<param name="ios-package" value="CDVGlobalization"/>
</feature>
- <feature name="InAppBrowser">
- <param name="ios-package" value="CDVInAppBrowser"/>
- </feature>
<feature name="Logger">
<param name="ios-package" value="CDVLogger"/>
</feature>
[25/50] [abbrv] ios commit: updated cordova js file
Posted by ag...@apache.org.
updated cordova js file
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c28b0b88
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c28b0b88
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c28b0b88
Branch: refs/heads/master
Commit: c28b0b88983eabffc64fb9f566ef9f17b56cf08b
Parents: 165b8be
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 18:26:53 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Jun 20 14:24:34 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c28b0b88/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index b2fc871..4139a3d 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,9 @@
// Platform: ios
+<<<<<<< HEAD
// 2.9.0rc1-0-g002f33d
+=======
+// 2.7.0rc1-84-g62c5786
+>>>>>>> updated cordova js file
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +23,11 @@
under the License.
*/
;(function() {
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.9.0rc1-0-g002f33d';
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
+>>>>>>> updated cordova js file
// file: lib/scripts/require.js
var require,
[15/50] [abbrv] ios commit: Updated CDVAvailability version to 2.9.0
Posted by ag...@apache.org.
Updated CDVAvailability version to 2.9.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/cfa54877
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/cfa54877
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/cfa54877
Branch: refs/heads/2.9.x
Commit: cfa54877ab9263f670183bef7521bb1f8c5ace0e
Parents: db43c76
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Jun 19 15:20:22 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Jun 19 15:20:22 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVAvailability.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cfa54877/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAvailability.h b/CordovaLib/Classes/CDVAvailability.h
index 324237d..7e8157c 100644
--- a/CordovaLib/Classes/CDVAvailability.h
+++ b/CordovaLib/Classes/CDVAvailability.h
@@ -42,6 +42,7 @@
#define __CORDOVA_2_6_0 20600
#define __CORDOVA_2_7_0 20700
#define __CORDOVA_2_8_0 20800
+#define __CORDOVA_2_9_0 20900
#define __CORDOVA_NA 99999 /* not available */
/*
@@ -52,7 +53,7 @@
#endif
*/
#ifndef CORDOVA_VERSION_MIN_REQUIRED
- #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_8_0
+ #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_9_0
#endif
/*