You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2015/03/19 17:56:22 UTC
[33/50] [abbrv] ios commit: CB-8690 - Group files into folders in
CordovaLib/Classes
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPlugin+Resources.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin+Resources.h b/CordovaLib/Classes/CDVPlugin+Resources.h
deleted file mode 100644
index cc43b16..0000000
--- a/CordovaLib/Classes/CDVPlugin+Resources.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 CDVPlugin (CDVPluginResources)
-
-/*
- This will return the localized string for a key in a .bundle that is named the same as your class
- For example, if your plugin class was called Foo, and you have a Spanish localized strings file, it will
- try to load the desired key from Foo.bundle/es.lproj/Localizable.strings
- */
-- (NSString*)pluginLocalizedString:(NSString*)key;
-
-/*
- This will return the image for a name in a .bundle that is named the same as your class
- For example, if your plugin class was called Foo, and you have an image called "bar",
- it will try to load the image from Foo.bundle/bar.png (and appropriately named retina versions)
- */
-- (UIImage*)pluginImageResource:(NSString*)name;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPlugin+Resources.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin+Resources.m b/CordovaLib/Classes/CDVPlugin+Resources.m
deleted file mode 100644
index 5690738..0000000
--- a/CordovaLib/Classes/CDVPlugin+Resources.m
+++ /dev/null
@@ -1,38 +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+Resources.h"
-
-@implementation CDVPlugin (CDVPluginResources)
-
-- (NSString*)pluginLocalizedString:(NSString*)key
-{
- NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:NSStringFromClass([self class]) ofType:@"bundle"]];
-
- return [bundle localizedStringForKey:(key) value:nil table:nil];
-}
-
-- (UIImage*)pluginImageResource:(NSString*)name
-{
- NSString* resourceIdentifier = [NSString stringWithFormat:@"%@.bundle/%@", NSStringFromClass([self class]), name];
-
- return [UIImage imageNamed:resourceIdentifier];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
deleted file mode 100644
index 54c8afd..0000000
--- a/CordovaLib/Classes/CDVPlugin.h
+++ /dev/null
@@ -1,69 +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 "CDVPluginResult.h"
-#import "NSMutableArray+QueueAdditions.h"
-#import "CDVCommandDelegate.h"
-#import "CDVWebViewEngineProtocol.h"
-
-@interface UIView (org_apache_cordova_UIView_Extension)
-
-@property (nonatomic, weak) UIScrollView* scrollView;
-
-@end
-
-extern NSString* const CDVPageDidLoadNotification;
-extern NSString* const CDVPluginHandleOpenURLNotification;
-extern NSString* const CDVPluginResetNotification;
-extern NSString* const CDVLocalNotification;
-extern NSString* const CDVRemoteNotification;
-extern NSString* const CDVRemoteNotificationError;
-
-@interface CDVPlugin : NSObject {}
-
-@property (nonatomic, readonly, weak) UIView* webView;
-@property (nonatomic, readonly, weak) id <CDVWebViewEngineProtocol> webViewEngine;
-
-@property (nonatomic, weak) UIViewController* viewController;
-@property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate;
-
-@property (readonly, assign) BOOL hasPendingOperation;
-
-- (void)pluginInitialize;
-
-- (void)handleOpenURL:(NSNotification*)notification;
-- (void)onAppTerminate;
-- (void)onMemoryWarning;
-- (void)onReset;
-- (void)dispose;
-
-/*
- // see initWithWebView implementation
- - (void) onPause {}
- - (void) onResume {}
- - (void) onOrientationWillChange {}
- - (void) onOrientationDidChange {}
- - (void)didReceiveLocalNotification:(NSNotification *)notification;
- */
-
-- (id)appDelegate;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
deleted file mode 100644
index ac3a8ee..0000000
--- a/CordovaLib/Classes/CDVPlugin.m
+++ /dev/null
@@ -1,163 +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 "CDVPlugin+Private.h"
-#import "CDVPlugin+Resources.h"
-#import "CDVViewController.h"
-#include <objc/message.h>
-
-@implementation UIView (org_apache_cordova_UIView_Extension)
-
-@dynamic scrollView;
-
-- (UIScrollView*)scrollView
-{
- SEL scrollViewSelector = NSSelectorFromString(@"scrollView");
-
- if ([self respondsToSelector:scrollViewSelector]) {
- return ((id (*)(id, SEL))objc_msgSend)(self, scrollViewSelector);
- }
-
- return nil;
-}
-
-@end
-
-NSString* const CDVPageDidLoadNotification = @"CDVPageDidLoadNotification";
-NSString* const CDVPluginHandleOpenURLNotification = @"CDVPluginHandleOpenURLNotification";
-NSString* const CDVPluginResetNotification = @"CDVPluginResetNotification";
-NSString* const CDVLocalNotification = @"CDVLocalNotification";
-NSString* const CDVRemoteNotification = @"CDVRemoteNotification";
-NSString* const CDVRemoteNotificationError = @"CDVRemoteNotificationError";
-
-@interface CDVPlugin ()
-
-@property (readwrite, assign) BOOL hasPendingOperation;
-@property (nonatomic, readwrite, weak) id <CDVWebViewEngineProtocol> webViewEngine;
-
-@end
-
-@implementation CDVPlugin
-@synthesize webViewEngine, viewController, commandDelegate, hasPendingOperation;
-@dynamic webView;
-
-// Do not override these methods. Use pluginInitialize instead.
-- (instancetype)initWithWebViewEngine:(id <CDVWebViewEngineProtocol>)theWebViewEngine
-{
- self = [super init];
- if (self) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:theWebViewEngine.engineWebView];
-
- self.webViewEngine = theWebViewEngine;
- }
- return self;
-}
-
-- (void)pluginInitialize
-{
- // You can listen to more app notifications, see:
- // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
-
- // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler
-
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
-
- // Added in 2.3.0
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
-
- // Added in 2.5.0
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad:) name:CDVPageDidLoadNotification object:self.webView];
-}
-
-- (void)dispose
-{
- viewController = nil;
- commandDelegate = nil;
-}
-
-- (UIView*)webView
-{
- if (self.webViewEngine != nil) {
- return self.webViewEngine.engineWebView;
- }
-
- return nil;
-}
-
-/*
-// NOTE: for onPause and onResume, calls into JavaScript must not call or trigger any blocking UI, like alerts
-- (void) onPause {}
-- (void) onResume {}
-- (void) onOrientationWillChange {}
-- (void) onOrientationDidChange {}
-*/
-
-/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void)handleOpenURL:(NSNotification*)notification
-{
- // override to handle urls sent to your app
- // register your url schemes in your App-Info.plist
-
- NSURL* url = [notification object];
-
- if ([url isKindOfClass:[NSURL class]]) {
- /* Do your thing! */
- }
-}
-
-/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void)onAppTerminate
-{
- // override this if you need to do any cleanup on app exit
-}
-
-- (void)onMemoryWarning
-{
- // override to remove caches, etc
-}
-
-- (void)onReset
-{
- // Override to cancel any long-running requests when the WebView navigates or refreshes.
-}
-
-- (void)dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self]; // this will remove all notification unless added using addObserverForName:object:queue:usingBlock:
-}
-
-- (id)appDelegate
-{
- return [[UIApplication sharedApplication] delegate];
-}
-
-// default implementation does nothing, ideally, we are not registered for notification if we aren't going to do anything.
-// - (void)didReceiveLocalNotification:(NSNotification *)notification
-// {
-// // UILocalNotification* localNotification = [notification object]; // get the payload as a LocalNotification
-// }
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPluginResult.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.h b/CordovaLib/Classes/CDVPluginResult.h
deleted file mode 100644
index 7377b12..0000000
--- a/CordovaLib/Classes/CDVPluginResult.h
+++ /dev/null
@@ -1,64 +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 "CDVAvailability.h"
-
-typedef enum {
- CDVCommandStatus_NO_RESULT = 0,
- CDVCommandStatus_OK,
- CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION,
- CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION,
- CDVCommandStatus_INSTANTIATION_EXCEPTION,
- CDVCommandStatus_MALFORMED_URL_EXCEPTION,
- CDVCommandStatus_IO_EXCEPTION,
- CDVCommandStatus_INVALID_ACTION,
- CDVCommandStatus_JSON_EXCEPTION,
- CDVCommandStatus_ERROR
-} CDVCommandStatus;
-
-@interface CDVPluginResult : NSObject {}
-
-@property (nonatomic, strong, readonly) NSNumber* status;
-@property (nonatomic, strong, readonly) id message;
-@property (nonatomic, strong) NSNumber* keepCallback;
-// This property can be used to scope the lifetime of another object. For example,
-// Use it to store the associated NSData when `message` is created using initWithBytesNoCopy.
-@property (nonatomic, strong) id associatedObject;
-
-- (CDVPluginResult*)init;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
-
-+ (void)setVerbose:(BOOL)verbose;
-+ (BOOL)isVerbose;
-
-- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback;
-
-- (NSString*)argumentsAsJSON;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
deleted file mode 100644
index f200c04..0000000
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ /dev/null
@@ -1,177 +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 "CDVPluginResult.h"
-#import "CDVJSON_private.h"
-#import "CDVDebug.h"
-#import "NSData+Base64.h"
-
-@interface CDVPluginResult ()
-
-- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage;
-
-@end
-
-@implementation CDVPluginResult
-@synthesize status, message, keepCallback, associatedObject;
-
-static NSArray* org_apache_cordova_CommandStatusMsgs;
-
-id messageFromArrayBuffer(NSData* data)
-{
- return @{
- @"CDVType" : @"ArrayBuffer",
- @"data" :[data cdv_base64EncodedString]
- };
-}
-
-id massageMessage(id message)
-{
- if ([message isKindOfClass:[NSData class]]) {
- return messageFromArrayBuffer(message);
- }
- return message;
-}
-
-id messageFromMultipart(NSArray* theMessages)
-{
- NSMutableArray* messages = [NSMutableArray arrayWithArray:theMessages];
-
- for (NSUInteger i = 0; i < messages.count; ++i) {
- [messages replaceObjectAtIndex:i withObject:massageMessage([messages objectAtIndex:i])];
- }
-
- return @{
- @"CDVType" : @"MultiPart",
- @"messages" : messages
- };
-}
-
-+ (void)initialize
-{
- org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects:@"No result",
- @"OK",
- @"Class not found",
- @"Illegal access",
- @"Instantiation error",
- @"Malformed url",
- @"IO error",
- @"Invalid action",
- @"JSON error",
- @"Error",
- nil];
-}
-
-- (CDVPluginResult*)init
-{
- return [self initWithStatus:CDVCommandStatus_NO_RESULT message:nil];
-}
-
-- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage
-{
- self = [super init];
- if (self) {
- status = [NSNumber numberWithInt:statusOrdinal];
- message = theMessage;
- keepCallback = [NSNumber numberWithBool:NO];
- }
- return self;
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal
-{
- return [[self alloc] initWithStatus:statusOrdinal message:nil];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInt:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithBool:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:messageFromArrayBuffer(theMessage)];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages
-{
- return [[self alloc] initWithStatus:statusOrdinal message:messageFromMultipart(theMessages)];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
-{
- NSDictionary* errDict = @{@"code" :[NSNumber numberWithInt:errorCode]};
-
- return [[self alloc] initWithStatus:statusOrdinal message:errDict];
-}
-
-- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback
-{
- [self setKeepCallback:[NSNumber numberWithBool:bKeepCallback]];
-}
-
-- (NSString*)argumentsAsJSON
-{
- id arguments = (self.message == nil ? [NSNull null] : self.message);
- NSArray* argumentsWrappedInArray = [NSArray arrayWithObject:arguments];
-
- NSString* argumentsJSON = [argumentsWrappedInArray cdv_JSONString];
-
- argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length] - 2)];
-
- return argumentsJSON;
-}
-
-static BOOL gIsVerbose = NO;
-+ (void)setVerbose:(BOOL)verbose
-{
- gIsVerbose = verbose;
-}
-
-+ (BOOL)isVerbose
-{
- return gIsVerbose;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVScreenOrientationDelegate.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVScreenOrientationDelegate.h b/CordovaLib/Classes/CDVScreenOrientationDelegate.h
deleted file mode 100644
index 7226205..0000000
--- a/CordovaLib/Classes/CDVScreenOrientationDelegate.h
+++ /dev/null
@@ -1,28 +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>
-
-@protocol CDVScreenOrientationDelegate <NSObject>
-
-- (NSUInteger)supportedInterfaceOrientations;
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
-- (BOOL)shouldAutorotate;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVTimer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVTimer.h b/CordovaLib/Classes/CDVTimer.h
deleted file mode 100644
index 6d31593..0000000
--- a/CordovaLib/Classes/CDVTimer.h
+++ /dev/null
@@ -1,27 +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 CDVTimer : NSObject
-
-+ (void)start:(NSString*)name;
-+ (void)stop:(NSString*)name;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVTimer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVTimer.m b/CordovaLib/Classes/CDVTimer.m
deleted file mode 100644
index 784e94d..0000000
--- a/CordovaLib/Classes/CDVTimer.m
+++ /dev/null
@@ -1,123 +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 "CDVTimer.h"
-
-#pragma mark CDVTimerItem
-
-@interface CDVTimerItem : NSObject
-
-@property (nonatomic, strong) NSString* name;
-@property (nonatomic, strong) NSDate* started;
-@property (nonatomic, strong) NSDate* ended;
-
-- (void)log;
-
-@end
-
-@implementation CDVTimerItem
-
-- (void)log
-{
- NSLog(@"[CDVTimer][%@] %fms", self.name, [self.ended timeIntervalSinceDate:self.started] * 1000.0);
-}
-
-@end
-
-#pragma mark CDVTimer
-
-@interface CDVTimer ()
-
-@property (nonatomic, strong) NSMutableDictionary* items;
-
-@end
-
-@implementation CDVTimer
-
-#pragma mark object methods
-
-- (id)init
-{
- if (self = [super init]) {
- self.items = [NSMutableDictionary dictionaryWithCapacity:6];
- }
-
- return self;
-}
-
-- (void)add:(NSString*)name
-{
- if ([self.items objectForKey:[name lowercaseString]] == nil) {
- CDVTimerItem* item = [CDVTimerItem new];
- item.name = name;
- item.started = [NSDate new];
- [self.items setObject:item forKey:[name lowercaseString]];
- } else {
- NSLog(@"Timer called '%@' already exists.", name);
- }
-}
-
-- (void)remove:(NSString*)name
-{
- CDVTimerItem* item = [self.items objectForKey:[name lowercaseString]];
-
- if (item != nil) {
- item.ended = [NSDate new];
- [item log];
- [self.items removeObjectForKey:[name lowercaseString]];
- } else {
- NSLog(@"Timer called '%@' does not exist.", name);
- }
-}
-
-- (void)removeAll
-{
- [self.items removeAllObjects];
-}
-
-#pragma mark class methods
-
-+ (void)start:(NSString*)name
-{
- [[CDVTimer sharedInstance] add:name];
-}
-
-+ (void)stop:(NSString*)name
-{
- [[CDVTimer sharedInstance] remove:name];
-}
-
-+ (void)clearAll
-{
- [[CDVTimer sharedInstance] removeAll];
-}
-
-+ (CDVTimer*)sharedInstance
-{
- static dispatch_once_t pred = 0;
- __strong static CDVTimer* _sharedObject = nil;
-
- dispatch_once(&pred, ^{
- _sharedObject = [[self alloc] init];
- });
-
- return _sharedObject;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUIWebViewDelegate.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUIWebViewDelegate.h b/CordovaLib/Classes/CDVUIWebViewDelegate.h
deleted file mode 100644
index d77f191..0000000
--- a/CordovaLib/Classes/CDVUIWebViewDelegate.h
+++ /dev/null
@@ -1,41 +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 "CDVAvailability.h"
-
-/**
- * Distinguishes top-level navigations from sub-frame navigations.
- * shouldStartLoadWithRequest is called for every request, but didStartLoad
- * and didFinishLoad is called only for top-level navigations.
- * Relevant bug: CB-2389
- */
-@interface CDVUIWebViewDelegate : NSObject <UIWebViewDelegate>{
- __weak NSObject <UIWebViewDelegate>* _delegate;
- NSInteger _loadCount;
- NSInteger _state;
- NSInteger _curLoadToken;
- NSInteger _loadStartPollCount;
-}
-
-- (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate;
-
-- (BOOL)request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(NSURLRequest*)originalRequest;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUIWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUIWebViewDelegate.m b/CordovaLib/Classes/CDVUIWebViewDelegate.m
deleted file mode 100644
index 01872f6..0000000
--- a/CordovaLib/Classes/CDVUIWebViewDelegate.m
+++ /dev/null
@@ -1,399 +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.
- */
-
-//
-// Testing shows:
-//
-// In all cases, webView.request.URL is the previous page's URL (or empty) during the didStartLoad callback.
-// When loading a page with a redirect:
-// 1. shouldStartLoading (requestURL is target page)
-// 2. didStartLoading
-// 3. shouldStartLoading (requestURL is redirect target)
-// 4. didFinishLoad (request.URL is redirect target)
-//
-// Note the lack of a second didStartLoading **
-//
-// When loading a page with iframes:
-// 1. shouldStartLoading (requestURL is main page)
-// 2. didStartLoading
-// 3. shouldStartLoading (requestURL is one of the iframes)
-// 4. didStartLoading
-// 5. didFinishLoad
-// 6. didFinishLoad
-//
-// Note there is no way to distinguish which didFinishLoad maps to which didStartLoad **
-//
-// Loading a page by calling window.history.go(-1):
-// 1. didStartLoading
-// 2. didFinishLoad
-//
-// Note the lack of a shouldStartLoading call **
-// Actually - this is fixed on iOS6. iOS6 has a shouldStart. **
-//
-// Loading a page by calling location.reload()
-// 1. shouldStartLoading
-// 2. didStartLoading
-// 3. didFinishLoad
-//
-// Loading a page with an iframe that fails to load:
-// 1. shouldStart (main page)
-// 2. didStart
-// 3. shouldStart (iframe)
-// 4. didStart
-// 5. didFailWithError
-// 6. didFinish
-//
-// Loading a page with an iframe that fails to load due to an invalid URL:
-// 1. shouldStart (main page)
-// 2. didStart
-// 3. shouldStart (iframe)
-// 5. didFailWithError
-// 6. didFinish
-//
-// This case breaks our logic since there is a missing didStart. To prevent this,
-// we check URLs in shouldStart and return NO if they are invalid.
-//
-// Loading a page with an invalid URL
-// 1. shouldStart (main page)
-// 2. didFailWithError
-//
-// TODO: Record order when page is re-navigated before the first navigation finishes.
-//
-
-#import "CDVUIWebViewDelegate.h"
-
-// #define VerboseLog NSLog
-#define VerboseLog(...) do { \
-} while (0)
-
-typedef enum {
- STATE_IDLE = 0,
- STATE_WAITING_FOR_LOAD_START = 1,
- STATE_WAITING_FOR_LOAD_FINISH = 2,
- STATE_IOS5_POLLING_FOR_LOAD_START = 3,
- STATE_IOS5_POLLING_FOR_LOAD_FINISH = 4,
- STATE_CANCELLED = 5
-} State;
-
-static NSString *stripFragment(NSString* url)
-{
- NSRange r = [url rangeOfString:@"#"];
-
- if (r.location == NSNotFound) {
- return url;
- }
- return [url substringToIndex:r.location];
-}
-
-@implementation CDVUIWebViewDelegate
-
-- (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate
-{
- self = [super init];
- if (self != nil) {
- _delegate = delegate;
- _loadCount = -1;
- _state = STATE_IDLE;
- }
- return self;
-}
-
-- (BOOL)request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(NSURLRequest*)originalRequest
-{
- if (originalRequest.URL && newRequest.URL) {
- NSString* originalRequestUrl = [originalRequest.URL absoluteString];
- NSString* newRequestUrl = [newRequest.URL absoluteString];
-
- NSString* baseOriginalRequestUrl = stripFragment(originalRequestUrl);
- NSString* baseNewRequestUrl = stripFragment(newRequestUrl);
- return [baseOriginalRequestUrl isEqualToString:baseNewRequestUrl];
- }
-
- return NO;
-}
-
-- (BOOL)isPageLoaded:(UIWebView*)webView
-{
- NSString* readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
-
- return [readyState isEqualToString:@"loaded"] || [readyState isEqualToString:@"complete"];
-}
-
-- (BOOL)isJsLoadTokenSet:(UIWebView*)webView
-{
- NSString* loadToken = [webView stringByEvaluatingJavaScriptFromString:@"window.__cordovaLoadToken"];
-
- return [[NSString stringWithFormat:@"%ld", (long)_curLoadToken] isEqualToString:loadToken];
-}
-
-- (void)setLoadToken:(UIWebView*)webView
-{
- _curLoadToken += 1;
- [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.__cordovaLoadToken=%ld", (long)_curLoadToken]];
-}
-
-- (NSString*)evalForCurrentURL:(UIWebView*)webView
-{
- return [webView stringByEvaluatingJavaScriptFromString:@"location.href"];
-}
-
-- (void)pollForPageLoadStart:(UIWebView*)webView
-{
- if (_state != STATE_IOS5_POLLING_FOR_LOAD_START) {
- return;
- }
- if (![self isJsLoadTokenSet:webView]) {
- VerboseLog(@"Polled for page load start. result = YES!");
- _state = STATE_IOS5_POLLING_FOR_LOAD_FINISH;
- [self setLoadToken:webView];
- if ([_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
- [_delegate webViewDidStartLoad:webView];
- }
- [self pollForPageLoadFinish:webView];
- } else {
- VerboseLog(@"Polled for page load start. result = NO");
- // Poll only for 1 second, and then fall back on checking only when delegate methods are called.
- ++_loadStartPollCount;
- if (_loadStartPollCount < (1000 * .05)) {
- [self performSelector:@selector(pollForPageLoadStart:) withObject:webView afterDelay:.05];
- }
- }
-}
-
-- (void)pollForPageLoadFinish:(UIWebView*)webView
-{
- if (_state != STATE_IOS5_POLLING_FOR_LOAD_FINISH) {
- return;
- }
- if ([self isPageLoaded:webView]) {
- VerboseLog(@"Polled for page load finish. result = YES!");
- _state = STATE_IDLE;
- if ([_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
- [_delegate webViewDidFinishLoad:webView];
- }
- } else {
- VerboseLog(@"Polled for page load finish. result = NO");
- [self performSelector:@selector(pollForPageLoadFinish:) withObject:webView afterDelay:.05];
- }
-}
-
-- (BOOL)shouldLoadRequest:(NSURLRequest*)request
-{
- NSString* scheme = [[request URL] scheme];
-
- if ([scheme isEqualToString:@"mailto"] || [scheme isEqualToString:@"tel"]) {
- return YES;
- }
-
- return [NSURLConnection canHandleRequest:request];
-}
-
-- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- BOOL shouldLoad = YES;
-
- if ([_delegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) {
- shouldLoad = [_delegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
- }
-
- VerboseLog(@"webView shouldLoad=%d (before) state=%d loadCount=%d URL=%@", shouldLoad, _state, _loadCount, request.URL);
-
- if (shouldLoad) {
- // When devtools refresh occurs, it blindly uses the same request object. If a history.replaceState() has occured, then
- // mainDocumentURL != URL even though it's a top-level navigation.
- BOOL isDevToolsRefresh = (request == webView.request);
- BOOL isTopLevelNavigation = isDevToolsRefresh || [request.URL isEqual:[request mainDocumentURL]];
- if (isTopLevelNavigation) {
- // Ignore hash changes that don't navigate to a different page.
- // webView.request does actually update when history.replaceState() gets called.
- if ([self request:request isEqualToRequestAfterStrippingFragments:webView.request]) {
- NSString* prevURL = [self evalForCurrentURL:webView];
- if ([prevURL isEqualToString:[request.URL absoluteString]]) {
- VerboseLog(@"Page reload detected.");
- } else {
- VerboseLog(@"Detected hash change shouldLoad");
- return shouldLoad;
- }
- }
-
- switch (_state) {
- case STATE_WAITING_FOR_LOAD_FINISH:
- // Redirect case.
- // We expect loadCount == 1.
- if (_loadCount != 1) {
- NSLog(@"CDVWebViewDelegate: Detected redirect when loadCount=%ld", (long)_loadCount);
- }
- break;
-
- case STATE_IDLE:
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- case STATE_CANCELLED:
- // Page navigation start.
- _loadCount = 0;
- _state = STATE_WAITING_FOR_LOAD_START;
- break;
-
- default:
- {
- _loadCount = 0;
- _state = STATE_WAITING_FOR_LOAD_START;
- NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate: Navigation started when state=%ld", (long)_state];
- NSLog(@"%@", description);
- if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
- NSError* error = [[NSError alloc] initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
- [_delegate webView:webView didFailLoadWithError:error];
- }
- }
- }
- } else {
- // Deny invalid URLs so that we don't get the case where we go straight from
- // webViewShouldLoad -> webViewDidFailLoad (messes up _loadCount).
- shouldLoad = shouldLoad && [self shouldLoadRequest:request];
- }
- VerboseLog(@"webView shouldLoad=%d (after) isTopLevelNavigation=%d state=%d loadCount=%d", shouldLoad, isTopLevelNavigation, _state, _loadCount);
- }
- return shouldLoad;
-}
-
-- (void)webViewDidStartLoad:(UIWebView*)webView
-{
- VerboseLog(@"webView didStartLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
- switch (_state) {
- case STATE_IDLE:
- break;
-
- case STATE_CANCELLED:
- fireCallback = YES;
- _state = STATE_WAITING_FOR_LOAD_FINISH;
- _loadCount += 1;
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- if (_loadCount != 0) {
- NSLog(@"CDVWebViewDelegate: Unexpected loadCount in didStart. count=%ld", (long)_loadCount);
- }
- fireCallback = YES;
- _state = STATE_WAITING_FOR_LOAD_FINISH;
- _loadCount = 1;
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- _loadCount += 1;
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
-
- default:
- NSLog(@"CDVWebViewDelegate: Unexpected didStart with state=%ld loadCount=%ld", (long)_state, (long)_loadCount);
- }
- VerboseLog(@"webView didStartLoad (after). state=%d loadCount=%d fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
- [_delegate webViewDidStartLoad:webView];
- }
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)webView
-{
- VerboseLog(@"webView didFinishLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
- switch (_state) {
- case STATE_IDLE:
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- NSLog(@"CDVWebViewDelegate: Unexpected didFinish while waiting for load start.");
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- if (_loadCount == 1) {
- fireCallback = YES;
- _state = STATE_IDLE;
- }
- _loadCount -= 1;
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
- }
- VerboseLog(@"webView didFinishLoad (after). state=%d loadCount=%d fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
- [_delegate webViewDidFinishLoad:webView];
- }
-}
-
-- (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error
-{
- VerboseLog(@"webView didFailLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
-
- switch (_state) {
- case STATE_IDLE:
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- if ([error code] == NSURLErrorCancelled) {
- _state = STATE_CANCELLED;
- } else {
- _state = STATE_IDLE;
- }
- fireCallback = YES;
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- if ([error code] != NSURLErrorCancelled) {
- if (_loadCount == 1) {
- _state = STATE_IDLE;
- fireCallback = YES;
- }
- _loadCount = -1;
- } else {
- fireCallback = YES;
- _state = STATE_CANCELLED;
- _loadCount -= 1;
- }
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
- }
- VerboseLog(@"webView didFailLoad (after). state=%d loadCount=%d, fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- [_delegate webView:webView didFailLoadWithError:error];
- }
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUIWebViewEngine.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUIWebViewEngine.h b/CordovaLib/Classes/CDVUIWebViewEngine.h
deleted file mode 100644
index 6a9ee77..0000000
--- a/CordovaLib/Classes/CDVUIWebViewEngine.h
+++ /dev/null
@@ -1,27 +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 "CDVWebViewEngineProtocol.h"
-
-@interface CDVUIWebViewEngine : CDVPlugin <CDVWebViewEngineProtocol>
-
-@property (nonatomic, strong, readonly) id <UIWebViewDelegate> uiWebViewDelegate;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUIWebViewEngine.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUIWebViewEngine.m b/CordovaLib/Classes/CDVUIWebViewEngine.m
deleted file mode 100644
index 3e01b08..0000000
--- a/CordovaLib/Classes/CDVUIWebViewEngine.m
+++ /dev/null
@@ -1,186 +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 "CDVUIWebViewEngine.h"
-#import "CDVUIWebViewDelegate.h"
-#import "NSDictionary+CordovaPreferences.h"
-
-#import <objc/message.h>
-
-@interface CDVUIWebViewEngine ()
-
-@property (nonatomic, strong, readwrite) UIView* engineWebView;
-@property (nonatomic, strong, readwrite) id <UIWebViewDelegate> uiWebViewDelegate;
-
-@end
-
-@implementation CDVUIWebViewEngine
-
-@synthesize engineWebView = _engineWebView;
-
-- (instancetype)initWithFrame:(CGRect)frame
-{
- self = [super init];
- if (self) {
- self.engineWebView = [[UIWebView alloc] initWithFrame:frame];
- NSLog(@"Using UIWebView");
- }
-
- return self;
-}
-
-- (void)pluginInitialize
-{
- // viewController would be available now. we attempt to set all possible delegates to it, by default
-
- UIWebView* uiWebView = (UIWebView*)_engineWebView;
-
- if ([self.viewController conformsToProtocol:@protocol(UIWebViewDelegate)]) {
- self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:(id <UIWebViewDelegate>)self.viewController];
- uiWebView.delegate = self.uiWebViewDelegate;
- }
-
- [self updateSettings:self.commandDelegate.settings];
-}
-
-- (void)evaluateJavaScript:(NSString*)javaScriptString completionHandler:(void (^)(id, NSError*))completionHandler
-{
- NSString* ret = [(UIWebView*)_engineWebView stringByEvaluatingJavaScriptFromString:javaScriptString];
-
- if (completionHandler) {
- completionHandler(ret, nil);
- }
-}
-
-- (id)loadRequest:(NSURLRequest*)request
-{
- [(UIWebView*)_engineWebView loadRequest:request];
- return nil;
-}
-
-- (id)loadHTMLString:(NSString*)string baseURL:(NSURL*)baseURL
-{
- [(UIWebView*)_engineWebView loadHTMLString:string baseURL:baseURL];
- return nil;
-}
-
-- (NSURL*)URL
-{
- return [[(UIWebView*)_engineWebView request] URL];
-}
-
-- (void)updateSettings:(NSDictionary*)settings
-{
- UIWebView* uiWebView = (UIWebView*)_engineWebView;
-
- uiWebView.scalesPageToFit = [settings cordovaBoolSettingForKey:@"EnableViewportScale" defaultValue:NO];
- uiWebView.allowsInlineMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowInlineMediaPlayback" defaultValue:NO];
- uiWebView.mediaPlaybackRequiresUserAction = [settings cordovaBoolSettingForKey:@"MediaPlaybackRequiresUserAction" defaultValue:YES];
- uiWebView.mediaPlaybackAllowsAirPlay = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];
- uiWebView.keyboardDisplayRequiresUserAction = [settings cordovaBoolSettingForKey:@"KeyboardDisplayRequiresUserAction" defaultValue:YES];
- uiWebView.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering" defaultValue:NO];
- uiWebView.gapBetweenPages = [settings cordovaFloatSettingForKey:@"GapBetweenPages" defaultValue:0.0];
- uiWebView.pageLength = [settings cordovaFloatSettingForKey:@"PageLength" defaultValue:0.0];
-
- id prefObj = nil;
-
- // By default, DisallowOverscroll is false (thus bounce is allowed)
- BOOL bounceAllowed = !([settings cordovaBoolSettingForKey:@"DisallowOverscroll" defaultValue:NO]);
-
- // prevent webView from bouncing
- if (!bounceAllowed) {
- if ([self.webView respondsToSelector:@selector(scrollView)]) {
- ((UIScrollView*)[uiWebView scrollView]).bounces = NO;
- } else {
- for (id subview in self.webView.subviews) {
- if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
- ((UIScrollView*)subview).bounces = NO;
- }
- }
- }
- }
-
- NSString* decelerationSetting = [settings cordovaSettingForKey:@"UIWebViewDecelerationSpeed"];
- if (![@"fast" isEqualToString:decelerationSetting]) {
- [uiWebView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal];
- }
-
- NSInteger paginationBreakingMode = 0; // default - UIWebPaginationBreakingModePage
- prefObj = [settings cordovaSettingForKey:@"PaginationBreakingMode"];
- if (prefObj != nil) {
- NSArray* validValues = @[@"page", @"column"];
- NSString* prefValue = [validValues objectAtIndex:0];
-
- if ([prefObj isKindOfClass:[NSString class]]) {
- prefValue = prefObj;
- }
-
- paginationBreakingMode = [validValues indexOfObject:[prefValue lowercaseString]];
- if (paginationBreakingMode == NSNotFound) {
- paginationBreakingMode = 0;
- }
- }
- uiWebView.paginationBreakingMode = paginationBreakingMode;
-
- NSInteger paginationMode = 0; // default - UIWebPaginationModeUnpaginated
- prefObj = [settings cordovaSettingForKey:@"PaginationMode"];
- if (prefObj != nil) {
- NSArray* validValues = @[@"unpaginated", @"lefttoright", @"toptobottom", @"bottomtotop", @"righttoleft"];
- NSString* prefValue = [validValues objectAtIndex:0];
-
- if ([prefObj isKindOfClass:[NSString class]]) {
- prefValue = prefObj;
- }
-
- paginationMode = [validValues indexOfObject:[prefValue lowercaseString]];
- if (paginationMode == NSNotFound) {
- paginationMode = 0;
- }
- }
- uiWebView.paginationMode = paginationMode;
-}
-
-- (void)updateWithInfo:(NSDictionary*)info
-{
- UIWebView* uiWebView = (UIWebView*)_engineWebView;
-
- id <UIWebViewDelegate> uiWebViewDelegate = [info objectForKey:kCDVWebViewEngineUIWebViewDelegate];
- NSDictionary* settings = [info objectForKey:kCDVWebViewEngineWebViewPreferences];
-
- if (uiWebViewDelegate &&
- [uiWebViewDelegate conformsToProtocol:@protocol(UIWebViewDelegate)]) {
- self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:(id <UIWebViewDelegate>)self.viewController];
- uiWebView.delegate = self.uiWebViewDelegate;
- }
-
- if (settings && [settings isKindOfClass:[NSDictionary class]]) {
- [self updateSettings:settings];
- }
-}
-
-// This forwards the methods that are in the header that are not implemented here.
-// Both WKWebView and UIWebView implement the below:
-// loadHTMLString:baseURL:
-// loadRequest:
-- (id)forwardingTargetForSelector:(SEL)aSelector
-{
- return _engineWebView;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVURLProtocol.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.h b/CordovaLib/Classes/CDVURLProtocol.h
deleted file mode 100644
index 5444f6d..0000000
--- a/CordovaLib/Classes/CDVURLProtocol.h
+++ /dev/null
@@ -1,29 +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 "CDVAvailability.h"
-
-@class CDVViewController;
-
-@interface CDVURLProtocol : NSURLProtocol {}
-
-+ (void)registerViewController:(CDVViewController*)viewController;
-+ (void)unregisterViewController:(CDVViewController*)viewController;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
deleted file mode 100644
index fce5783..0000000
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ /dev/null
@@ -1,213 +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 <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import "CDVURLProtocol.h"
-#import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
-#import "CDVViewController.h"
-
-static CDVWhitelist* gWhitelist = nil;
-// Contains a set of NSNumbers of addresses of controllers. It doesn't store
-// the actual pointer to avoid retaining.
-static NSMutableSet* gRegisteredControllers = nil;
-
-NSString* const kCDVAssetsLibraryPrefixes = @"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.
-static CDVViewController *viewControllerForRequest(NSURLRequest* request)
-{
- // The exec bridge explicitly sets the VC address in a header.
- // This works around the User-Agent not being set for file: URLs.
- NSString* addrString = [request valueForHTTPHeaderField:@"vc"];
-
- if (addrString == nil) {
- NSString* userAgent = [request valueForHTTPHeaderField:@"User-Agent"];
- if (userAgent == nil) {
- return nil;
- }
- NSUInteger bracketLocation = [userAgent rangeOfString:@"(" options:NSBackwardsSearch].location;
- if (bracketLocation == NSNotFound) {
- return nil;
- }
- addrString = [userAgent substringFromIndex:bracketLocation + 1];
- }
-
- long long viewControllerAddress = [addrString longLongValue];
- @synchronized(gRegisteredControllers) {
- if (![gRegisteredControllers containsObject:[NSNumber numberWithLongLong:viewControllerAddress]]) {
- return nil;
- }
- }
-
- return (__bridge CDVViewController*)(void*)viewControllerAddress;
-}
-
-@implementation CDVURLProtocol
-
-+ (void)registerPGHttpURLProtocol {}
-
-+ (void)registerURLProtocol {}
-
-// Called to register the URLProtocol, and to make it away of an instance of
-// a ViewController.
-+ (void)registerViewController:(CDVViewController*)viewController
-{
- if (gRegisteredControllers == nil) {
- [NSURLProtocol registerClass:[CDVURLProtocol class]];
- gRegisteredControllers = [[NSMutableSet alloc] initWithCapacity:8];
- // The whitelist doesn't change, so grab the first one and store it.
- gWhitelist = viewController.whitelist;
-
- // Note that we grab the whitelist from the first viewcontroller for now - but this will change
- // when we allow a registered viewcontroller to have its own whitelist (e.g InAppBrowser)
- // Differentiating the requests will be through the 'vc' http header below as used for the js->objc bridge.
- // The 'vc' value is generated by casting the viewcontroller object to a (long long) value (see CDVViewController::webViewDidFinishLoad)
- if (gWhitelist == nil) {
- NSLog(@"WARNING: NO whitelist has been set in CDVURLProtocol.");
- }
- }
-
- @synchronized(gRegisteredControllers) {
- [gRegisteredControllers addObject:[NSNumber numberWithLongLong:(long long)viewController]];
- }
-}
-
-+ (void)unregisterViewController:(CDVViewController*)viewController
-{
- @synchronized(gRegisteredControllers) {
- [gRegisteredControllers removeObject:[NSNumber numberWithLongLong:(long long)viewController]];
- }
-}
-
-+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
-{
- NSURL* theUrl = [theRequest URL];
- CDVViewController* viewController = viewControllerForRequest(theRequest);
-
- if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
- return YES;
- } else if (viewController != nil) {
- if ([[theUrl path] isEqualToString:@"/!gap_exec"]) {
- NSString* queuedCommandsJSON = [theRequest valueForHTTPHeaderField:@"cmds"];
- NSString* requestId = [theRequest valueForHTTPHeaderField:@"rc"];
- if (requestId == nil) {
- NSLog(@"!cordova request missing rc header");
- return NO;
- }
- BOOL hasCmds = [queuedCommandsJSON length] > 0;
- if (hasCmds) {
- SEL sel = @selector(enqueueCommandBatch:);
- [viewController.commandQueue performSelectorOnMainThread:sel withObject:queuedCommandsJSON waitUntilDone:NO];
- [viewController.commandQueue performSelectorOnMainThread:@selector(executePending) withObject:nil waitUntilDone:NO];
- } else {
- SEL sel = @selector(processXhrExecBridgePoke:);
- [viewController.commandQueue performSelectorOnMainThread:sel withObject:[NSNumber numberWithInteger:[requestId integerValue]] waitUntilDone:NO];
- }
- // Returning NO here would be 20% faster, but it spams WebInspector's console with failure messages.
- // If JS->Native bridge speed is really important for an app, they should use the iframe bridge.
- // Returning YES here causes the request to come through canInitWithRequest two more times.
- // For this reason, we return NO when cmds exist.
- return !hasCmds;
- }
- // we only care about http and https connections.
- // CORS takes care of http: trying to access file: URLs.
- if ([gWhitelist schemeIsAllowed:[theUrl scheme]]) {
- // if it FAILS the whitelist, we return TRUE, so we can fail the connection later
- return ![gWhitelist URLIsAllowed:theUrl];
- }
- }
-
- return NO;
-}
-
-+ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request
-{
- // NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd));
- return request;
-}
-
-- (void)startLoading
-{
- // NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd));
- NSURL* url = [[self request] URL];
-
- if ([[url path] isEqualToString:@"/!gap_exec"]) {
- [self sendResponseWithResponseCode:200 data:nil mimeType:nil];
- return;
- } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
- ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
- if (asset) {
- // We have the asset! Get the data and send it along.
- ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
- NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
- Byte* buffer = (Byte*)malloc((unsigned long)[assetRepresentation size]);
- NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:(NSUInteger)[assetRepresentation size] error:nil];
- NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
- [self sendResponseWithResponseCode:200 data:data mimeType:MIMEType];
- } else {
- // Retrieving the asset failed for some reason. Send an error.
- [self sendResponseWithResponseCode:404 data:nil mimeType:nil];
- }
- };
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
- // Retrieving the asset failed for some reason. Send an error.
- [self sendResponseWithResponseCode:401 data:nil mimeType:nil];
- };
-
- ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
- [assetsLibrary assetForURL:url resultBlock:resultBlock failureBlock:failureBlock];
- return;
- }
-
- NSString* body = [gWhitelist errorStringForURL:url];
- [self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSASCIIStringEncoding] mimeType:nil];
-}
-
-- (void)stopLoading
-{
- // do any cleanup here
-}
-
-+ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB
-{
- return NO;
-}
-
-- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data mimeType:(NSString*)mimeType
-{
- if (mimeType == nil) {
- mimeType = @"text/plain";
- }
-
- NSHTTPURLResponse* response = [[NSHTTPURLResponse alloc] initWithURL:[[self request] URL] statusCode:statusCode HTTPVersion:@"HTTP/1.1" headerFields:@{@"Content-Type" : mimeType}];
-
- [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
- if (data != nil) {
- [[self client] URLProtocol:self didLoadData:data];
- }
- [[self client] URLProtocolDidFinishLoading:self];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUserAgentUtil.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUserAgentUtil.h b/CordovaLib/Classes/CDVUserAgentUtil.h
deleted file mode 100644
index 4de382f..0000000
--- a/CordovaLib/Classes/CDVUserAgentUtil.h
+++ /dev/null
@@ -1,27 +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 CDVUserAgentUtil : NSObject
-+ (NSString*)originalUserAgent;
-+ (void)acquireLock:(void (^)(NSInteger lockToken))block;
-+ (void)releaseLock:(NSInteger*)lockToken;
-+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVUserAgentUtil.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVUserAgentUtil.m b/CordovaLib/Classes/CDVUserAgentUtil.m
deleted file mode 100644
index c3402d0..0000000
--- a/CordovaLib/Classes/CDVUserAgentUtil.m
+++ /dev/null
@@ -1,122 +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 "CDVUserAgentUtil.h"
-
-#import <UIKit/UIKit.h>
-
-// #define VerboseLog NSLog
-#define VerboseLog(...) do {} while (0)
-
-static NSString* const kCdvUserAgentKey = @"Cordova-User-Agent";
-static NSString* const kCdvUserAgentVersionKey = @"Cordova-User-Agent-Version";
-
-static NSString* gOriginalUserAgent = nil;
-static NSInteger gNextLockToken = 0;
-static NSInteger gCurrentLockToken = 0;
-static NSMutableArray* gPendingSetUserAgentBlocks = nil;
-
-@implementation CDVUserAgentUtil
-
-+ (NSString*)originalUserAgent
-{
- if (gOriginalUserAgent == nil) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppLocaleDidChange:)
- name:NSCurrentLocaleDidChangeNotification object:nil];
-
- NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
- NSString* localeStr = [[NSLocale currentLocale] localeIdentifier];
- // Record the model since simulator can change it without re-install (CB-5420).
- NSString* model = [UIDevice currentDevice].model;
- NSString* systemAndLocale = [NSString stringWithFormat:@"%@ %@ %@", model, systemVersion, localeStr];
-
- NSString* cordovaUserAgentVersion = [userDefaults stringForKey:kCdvUserAgentVersionKey];
- gOriginalUserAgent = [userDefaults stringForKey:kCdvUserAgentKey];
- BOOL cachedValueIsOld = ![systemAndLocale isEqualToString:cordovaUserAgentVersion];
-
- if ((gOriginalUserAgent == nil) || cachedValueIsOld) {
- UIWebView* sampleWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
- gOriginalUserAgent = [sampleWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
-
- [userDefaults setObject:gOriginalUserAgent forKey:kCdvUserAgentKey];
- [userDefaults setObject:systemAndLocale forKey:kCdvUserAgentVersionKey];
-
- [userDefaults synchronize];
- }
- }
- return gOriginalUserAgent;
-}
-
-+ (void)onAppLocaleDidChange:(NSNotification*)notification
-{
- // TODO: We should figure out how to update the user-agent of existing UIWebViews when this happens.
- // Maybe use the PDF bug (noted in setUserAgent:).
- gOriginalUserAgent = nil;
-}
-
-+ (void)acquireLock:(void (^)(NSInteger lockToken))block
-{
- if (gCurrentLockToken == 0) {
- gCurrentLockToken = ++gNextLockToken;
- VerboseLog(@"Gave lock %d", gCurrentLockToken);
- block(gCurrentLockToken);
- } else {
- if (gPendingSetUserAgentBlocks == nil) {
- gPendingSetUserAgentBlocks = [[NSMutableArray alloc] initWithCapacity:4];
- }
- VerboseLog(@"Waiting for lock");
- [gPendingSetUserAgentBlocks addObject:block];
- }
-}
-
-+ (void)releaseLock:(NSInteger*)lockToken
-{
- if (*lockToken == 0) {
- return;
- }
- NSAssert(gCurrentLockToken == *lockToken, @"Got token %ld, expected %ld", (long)*lockToken, (long)gCurrentLockToken);
-
- VerboseLog(@"Released lock %d", *lockToken);
- if ([gPendingSetUserAgentBlocks count] > 0) {
- void (^block)() = [gPendingSetUserAgentBlocks objectAtIndex:0];
- [gPendingSetUserAgentBlocks removeObjectAtIndex:0];
- gCurrentLockToken = ++gNextLockToken;
- NSLog(@"Gave lock %ld", (long)gCurrentLockToken);
- block(gCurrentLockToken);
- } else {
- gCurrentLockToken = 0;
- }
- *lockToken = 0;
-}
-
-+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken
-{
- NSAssert(gCurrentLockToken == lockToken, @"Got token %ld, expected %ld", (long)lockToken, (long)gCurrentLockToken);
- VerboseLog(@"User-Agent set to: %@", value);
-
- // Setting the UserAgent must occur before a UIWebView is instantiated.
- // It is read per instantiation, so it does not affect previously created views.
- // Except! When a PDF is loaded, all currently active UIWebViews reload their
- // User-Agent from the NSUserDefaults some time after the DidFinishLoad of the PDF bah!
- NSDictionary* dict = [[NSDictionary alloc] initWithObjectsAndKeys:value, @"UserAgent", nil];
- [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d58fa4aa/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
deleted file mode 100644
index e3ead2f..0000000
--- a/CordovaLib/Classes/CDVViewController.h
+++ /dev/null
@@ -1,87 +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 <Foundation/NSJSONSerialization.h>
-#import "CDVAvailability.h"
-#import "CDVInvokedUrlCommand.h"
-#import "CDVCommandDelegate.h"
-#import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
-#import "CDVScreenOrientationDelegate.h"
-#import "CDVPlugin.h"
-#import "CDVWebViewEngineProtocol.h"
-
-@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
- @protected
- id <CDVWebViewEngineProtocol> _webViewEngine;
- @protected
- id <CDVCommandDelegate> _commandDelegate;
- @protected
- CDVCommandQueue* _commandQueue;
- NSString* _userAgent;
-}
-
-@property (nonatomic, readonly, weak) IBOutlet UIView* webView;
-
-@property (nonatomic, readonly, strong) NSMutableDictionary* pluginObjects;
-@property (nonatomic, readonly, strong) NSDictionary* pluginsMap;
-@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
-@property (nonatomic, readonly, strong) NSXMLParser* configParser;
-@property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
-@property (nonatomic, readonly, assign) BOOL loadFromString;
-
-@property (nonatomic, readwrite, copy) NSString* wwwFolderName;
-@property (nonatomic, readwrite, copy) NSString* startPage;
-@property (nonatomic, readonly, strong) CDVCommandQueue* commandQueue;
-@property (nonatomic, readonly, strong) id <CDVWebViewEngineProtocol> webViewEngine;
-@property (nonatomic, readonly, strong) id <CDVCommandDelegate> commandDelegate;
-
-/**
- The complete user agent that Cordova will use when sending web requests.
- */
-@property (nonatomic, readonly) NSString* userAgent;
-
-/**
- The base user agent data that Cordova will use to build its user agent. If this
- property isn't set, Cordova will use the standard web view user agent as its
- base.
- */
-@property (nonatomic, readwrite, copy) NSString* baseUserAgent;
-
-+ (NSDictionary*)getBundlePlist:(NSString*)plistName;
-+ (NSString*)applicationDocumentsDirectory;
-
-- (void)printMultitaskingInfo;
-- (void)createGapView;
-- (UIView*)newCordovaViewWithFrame:(CGRect)bounds;
-
-- (void)javascriptAlert:(NSString*)text;
-- (NSString*)appURLScheme;
-
-- (NSArray*)parseInterfaceOrientations:(NSArray*)orientations;
-- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation;
-
-- (id)getCommandInstance:(NSString*)pluginName;
-- (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
-- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
-
-- (BOOL)URLisAllowed:(NSURL*)url;
-
-@end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org