cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject cordova-plugin-camera git commit: CB-8032 - Camera Plugin - Add nativeURL external method support for CDVFileSystem->makeEntryForPath:isDirectory: (closes #57)
Date Sat, 10 Jan 2015 00:25:24 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master 482f2ac2c -> 376bec2b9


CB-8032 - Camera Plugin - Add nativeURL external method support for CDVFileSystem->makeEntryForPath:isDirectory:
(closes #57)


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/376bec2b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/376bec2b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/376bec2b

Branch: refs/heads/master
Commit: 376bec2b96699c32ef6d646e1c5aec954d12d3c9
Parents: 482f2ac
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Dec 11 16:42:02 2014 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Fri Jan 9 16:24:31 2015 -0800

----------------------------------------------------------------------
 src/ios/CDVCamera.m | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/376bec2b/src/ios/CDVCamera.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index 857c9b1..290e350 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -30,6 +30,7 @@
 #import <ImageIO/CGImageProperties.h>
 #import <ImageIO/CGImageDestination.h>
 #import <MobileCoreServices/UTCoreTypes.h>
+#import <objc/message.h>
 
 #define CDV_PHOTO_PREFIX @"cdv_photo_"
 
@@ -84,6 +85,24 @@ static NSSet* org_apache_cordova_validArrowDirections;
 
 @synthesize hasPendingOperation, pickerController, locationManager;
 
+- (NSURL*) urlTransformer:(NSURL*)url
+{
+    NSURL* urlToTransform = url;
+    
+    // for backwards compatibility - we check if this property is there
+    SEL sel = NSSelectorFromString(@"urlTransformer");
+    if ([self.commandDelegate respondsToSelector:sel]) {
+        // grab the block from the commandDelegate
+        NSURL* (^urlTransformer)(NSURL*) = ((id(*)(id, SEL))objc_msgSend)(self.commandDelegate,
sel);
+        // if block is not null, we call it
+        if (urlTransformer) {
+            urlToTransform = urlTransformer(url);
+        }
+    }
+    
+    return urlToTransform;
+}
+
 - (BOOL)usesGeolocation
 {
     id useGeo = [self.commandDelegate.settings objectForKey:[@"CameraUsesGeolocation" lowercaseString]];
@@ -336,7 +355,8 @@ static NSSet* org_apache_cordova_validArrowDirections;
     switch (options.destinationType) {
         case DestinationTypeNativeUri:
         {
-            NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL]
absoluteString];
+            NSURL* url = (NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL];
+            NSString* nativeUri = [[self urlTransformer:url] absoluteString];
             result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
             saveToPhotoAlbum = NO;
         }
@@ -355,7 +375,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
                 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]];
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[self
urlTransformer:[NSURL fileURLWithPath:filePath]] absoluteString]];
                 }
             }
         }
@@ -562,7 +582,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
                 result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION
messageAsString:[err localizedDescription]];
             }
             else {
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL
fileURLWithPath:filePath] absoluteString]];
+                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[self
urlTransformer:[NSURL fileURLWithPath:filePath]] absoluteString]];
             }
         }
             break;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message