You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/01/21 01:58:10 UTC
git commit: Fixes for legacy support of deprecated PhoneGapDelegate -
in core plugins.
Updated Branches:
refs/heads/master 7d03c8f0e -> 0b70b14a7
Fixes for legacy support of deprecated PhoneGapDelegate - in core plugins.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/0b70b14a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/0b70b14a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/0b70b14a
Branch: refs/heads/master
Commit: 0b70b14a7c4f41db999415586ee1aaebe999a956
Parents: 7d03c8f
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Jan 20 16:57:59 2012 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Jan 20 16:57:59 2012 -0800
----------------------------------------------------------------------
PhoneGapLib/Classes/Capture.m | 6 +--
PhoneGapLib/Classes/PGCommandDelegate.h | 28 ++++++++++++++++
PhoneGapLib/Classes/PGPlugin.h | 2 +
PhoneGapLib/Classes/PGPlugin.m | 2 +-
PhoneGapLib/Classes/PGSplashScreen.m | 18 ++++++----
PhoneGapLib/Classes/PGViewController.h | 18 +---------
PhoneGapLib/Classes/PGViewController.m | 4 ++
PhoneGapLib/Classes/PhoneGapDelegate.h | 6 +--
PhoneGapLib/Classes/PhoneGapDelegate.m | 4 ++
PhoneGapLib/Classes/Sound.m | 2 +-
PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj | 6 +++
11 files changed, 63 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/Capture.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Capture.m b/PhoneGapLib/Classes/Capture.m
index 2cbd68e..4f9d1e2 100644
--- a/PhoneGapLib/Classes/Capture.m
+++ b/PhoneGapLib/Classes/Capture.m
@@ -362,8 +362,7 @@
if (!mimeType){
// try to determine mime type if not provided
- PGViewController* vc = (PGViewController*)self.viewController;
- id command = [vc getCommandInstance: @"com.phonegap.file"];
+ id command = [self.commandDelegate getCommandInstance: @"com.phonegap.file"];
bError = !([command isKindOfClass:[PGFile class]]);
if (!bError) {
PGFile* pgFile = (PGFile*)command;
@@ -450,8 +449,7 @@
[fileDict setObject: fullPath forKey:@"fullPath"];
// determine type
if(!type) {
- PGViewController* vc = (PGViewController*)self.viewController;
- id command = [vc getCommandInstance: @"com.phonegap.file"];
+ id command = [self.commandDelegate getCommandInstance: @"com.phonegap.file"];
if([command isKindOfClass:[PGFile class]]) {
PGFile* pgFile = (PGFile*)command;
NSString* mimeType = [pgFile getMimeTypeFromPath:fullPath];
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGCommandDelegate.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGCommandDelegate.h b/PhoneGapLib/Classes/PGCommandDelegate.h
new file mode 100644
index 0000000..6d1f4e4
--- /dev/null
+++ b/PhoneGapLib/Classes/PGCommandDelegate.h
@@ -0,0 +1,28 @@
+/*
+ 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 "InvokedUrlCommand.h"
+
+@protocol PGCommandDelegate <NSObject>
+
+- (NSString*) pathForResource:(NSString*)resourcepath;
+- (id) getCommandInstance:(NSString*)pluginName;
+- (BOOL) execute:(InvokedUrlCommand*)command;
+
+@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGPlugin.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGPlugin.h b/PhoneGapLib/Classes/PGPlugin.h
index 3964170..652e03e 100644
--- a/PhoneGapLib/Classes/PGPlugin.h
+++ b/PhoneGapLib/Classes/PGPlugin.h
@@ -21,6 +21,7 @@
#import <UIKit/UIKit.h>
#import "PluginResult.h"
#import "NSMutableArray+QueueAdditions.h"
+#import "PGCommandDelegate.h"
#define PGPluginHandleOpenURLNotification @"PGPluginHandleOpenURLNotification"
@@ -34,6 +35,7 @@ callerFileName:__FILE__ callerFunctionName:__PRETTY_FUNCTION__]) { return; }
@property (nonatomic, retain) UIWebView* webView;
@property (nonatomic, retain) NSDictionary* settings;
@property (nonatomic, retain) UIViewController* viewController;
+@property (nonatomic, retain) id<PGCommandDelegate> commandDelegate;
- (PGPlugin*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
- (PGPlugin*) initWithWebView:(UIWebView*)theWebView;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGPlugin.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGPlugin.m b/PhoneGapLib/Classes/PGPlugin.m
index e8c539b..65fec10 100644
--- a/PhoneGapLib/Classes/PGPlugin.m
+++ b/PhoneGapLib/Classes/PGPlugin.m
@@ -23,7 +23,7 @@
@implementation PGPlugin
-@synthesize webView, settings, viewController;
+@synthesize webView, settings, viewController, commandDelegate;
- (PGPlugin*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGSplashScreen.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGSplashScreen.m b/PhoneGapLib/Classes/PGSplashScreen.m
index 939ea0d..c4097c6 100644
--- a/PhoneGapLib/Classes/PGSplashScreen.m
+++ b/PhoneGapLib/Classes/PGSplashScreen.m
@@ -21,19 +21,23 @@
#import "PGSplashScreen.h"
#import "PGAppDelegate.h"
#import "PGViewController.h"
+#import "PhoneGapDelegate.h"
@implementation PGSplashScreen
- (void) __show:(BOOL)show
{
- PGViewController* vc = (PGViewController*)self.viewController;
- if (vc.imageView) {
- return;
- }
-
- vc.imageView.hidden = !show;
- vc.activityView.hidden = !show;
+ // Legacy support - once deprecated classes removed, clean this up
+ id delg = [self appDelegate];
+
+ if ([delg isKindOfClass:[PGAppDelegate class]]) {
+ ((PGAppDelegate*)delg).viewController.imageView.hidden = !show;
+ ((PGAppDelegate*)delg).viewController.activityView.hidden = !show;
+ } if ([delg isKindOfClass:[PhoneGapDelegate class]]) {
+ ((PhoneGapDelegate*)delg).imageView.hidden = !show;
+ ((PhoneGapDelegate*)delg).activityView.hidden = !show;
+ }
}
- (void) show:(NSArray*)arguments withDict:(NSMutableDictionary*)options
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGViewController.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.h b/PhoneGapLib/Classes/PGViewController.h
index 198c519..4ad1eed 100644
--- a/PhoneGapLib/Classes/PGViewController.h
+++ b/PhoneGapLib/Classes/PGViewController.h
@@ -21,21 +21,10 @@
#import "JSONKit.h"
#import "InvokedUrlCommand.h"
-
+#import "PGCommandDelegate.h"
#import "PGWhitelist.h"
-/* PGCommandDelegate */
-
-@protocol PGCommandDelegate <NSObject>
-
-- (id) getCommandInstance:(NSString*)pluginName;
-- (BOOL) execute:(InvokedUrlCommand*)command;
-
-@end
-
-/* PGViewController */
-
@interface PGViewController : UIViewController<UIWebViewDelegate, PGCommandDelegate> {
}
@@ -53,7 +42,7 @@
@property (nonatomic, readwrite, assign) BOOL useSplashScreen;
@property (nonatomic, readonly, retain) IBOutlet UIActivityIndicatorView* activityView;
@property (nonatomic, readonly, retain) UIImageView *imageView;
-@property (nonatomic, readwrite, assign) id<PGCommandDelegate> commandDelegate;
+@property (nonatomic, readwrite, retain) id<PGCommandDelegate> commandDelegate;
@property (nonatomic, readwrite, copy) NSString* wwwFolderName;
@property (nonatomic, readwrite, copy) NSString* startPage;
@@ -67,10 +56,7 @@
- (int) executeQueuedCommands;
- (void) flushCommandQueue;
-- (NSString*) pathForResource:(NSString*)resourcepath;
-- (id) getCommandInstance:(NSString*)pluginName;
- (void) javascriptAlert:(NSString*)text;
-- (BOOL) execute:(InvokedUrlCommand*)command;
- (NSString*) appURLScheme;
- (NSDictionary*) deviceProperties;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PGViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.m b/PhoneGapLib/Classes/PGViewController.m
index 44abb89..b07ed4f 100644
--- a/PhoneGapLib/Classes/PGViewController.m
+++ b/PhoneGapLib/Classes/PGViewController.m
@@ -713,6 +713,10 @@ BOOL gSplashScreenShown = NO;
[obj setViewController:self];
}
+ if ([obj isKindOfClass:[PGPlugin class]] && [obj respondsToSelector:@selector(setCommandDelegate:)]) {
+ [obj setCommandDelegate:self.commandDelegate];
+ }
+
if (obj != nil) {
[self.pluginObjects setObject:obj forKey:className];
[obj release];
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PhoneGapDelegate.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapDelegate.h b/PhoneGapLib/Classes/PhoneGapDelegate.h
index d1f491c..0476a25 100755
--- a/PhoneGapLib/Classes/PhoneGapDelegate.h
+++ b/PhoneGapLib/Classes/PhoneGapDelegate.h
@@ -19,6 +19,7 @@
#import <UIKit/UIKit.h>
#import "JSONKit.h"
+#import "PGCommandDelegate.h"
@class InvokedUrlCommand;
@class PhoneGapViewController;
@@ -27,7 +28,7 @@
@class Console;
@class PGWhitelist;
-__attribute__((deprecated)) @interface PhoneGapDelegate : NSObject <UIApplicationDelegate, UIWebViewDelegate>
+__attribute__((deprecated)) @interface PhoneGapDelegate : NSObject <UIApplicationDelegate, UIWebViewDelegate, PGCommandDelegate>
{
}
@@ -43,7 +44,6 @@ __attribute__((deprecated)) @interface PhoneGapDelegate : NSObject <UIApplicatio
+ (NSDictionary*)getBundlePlist:(NSString *)plistName;
+ (NSString*) wwwFolderName;
-+ (NSString*) pathForResource:(NSString*)resourcepath;
+ (NSString*) phoneGapVersion;
+ (NSString*) applicationDocumentsDirectory;
+ (NSString*) startPage;
@@ -51,9 +51,7 @@ __attribute__((deprecated)) @interface PhoneGapDelegate : NSObject <UIApplicatio
- (int)executeQueuedCommands;
- (void)flushCommandQueue;
-- (id) getCommandInstance:(NSString*)pluginName;
- (void) javascriptAlert:(NSString*)text;
-- (BOOL) execute:(InvokedUrlCommand*)command;
- (NSString*) appURLScheme;
- (NSDictionary*) deviceProperties;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/PhoneGapDelegate.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapDelegate.m b/PhoneGapLib/Classes/PhoneGapDelegate.m
index b259242..62172e3 100755
--- a/PhoneGapLib/Classes/PhoneGapDelegate.m
+++ b/PhoneGapLib/Classes/PhoneGapDelegate.m
@@ -213,6 +213,10 @@ static NSString *gapVersion;
[obj setViewController:self.viewController];
}
+ if ([obj isKindOfClass:[PGPlugin class]] && [obj respondsToSelector:@selector(setCommandDelegate:)]) {
+ [obj setCommandDelegate:self];
+ }
+
if (obj != nil) {
[self.pluginObjects setObject:obj forKey:className];
[obj release];
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/Classes/Sound.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Sound.m b/PhoneGapLib/Classes/Sound.m
index f262137..7037a92 100644
--- a/PhoneGapLib/Classes/Sound.m
+++ b/PhoneGapLib/Classes/Sound.m
@@ -47,7 +47,7 @@
NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
} else {
// attempt to find file path in www directory
- filePath = [(PGViewController*)self.viewController pathForResource:resourcePath];
+ filePath = [self.commandDelegate pathForResource:resourcePath];
if (filePath != nil) {
NSLog(@"Found resource '%@' in the web folder.", filePath);
}else {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/0b70b14a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
index a4f3dd2..49f5b37 100644
--- a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
+++ b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
@@ -118,6 +118,8 @@
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */; };
30E563D113E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
30E563D213E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */; };
+ 30F5EBAB14CA26E700987760 /* PGCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F5EBA914CA26E700987760 /* PGCommandDelegate.h */; };
+ 30F5EBAC14CA26E700987760 /* PGCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F5EBA914CA26E700987760 /* PGCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
686357B5141002F200DF4CF2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 686357B3141002F200DF4CF2 /* InfoPlist.strings */; };
686357B8141002F200DF4CF2 /* PluginResultJSONSerializationTests.h in Resources */ = {isa = PBXBuildFile; fileRef = 686357B7141002F200DF4CF2 /* PluginResultJSONSerializationTests.h */; };
686357BA141002F200DF4CF2 /* PluginResultJSONSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686357B9141002F200DF4CF2 /* PluginResultJSONSerializationTests.m */; };
@@ -223,6 +225,7 @@
30E33AF113A7E24B00594D64 /* PGPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGPlugin.m; path = Classes/PGPlugin.m; sourceTree = "<group>"; };
30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSMutableArray+QueueAdditions.h"; path = "Classes/NSMutableArray+QueueAdditions.h"; sourceTree = "<group>"; };
30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMutableArray+QueueAdditions.m"; path = "Classes/NSMutableArray+QueueAdditions.m"; sourceTree = "<group>"; };
+ 30F5EBA914CA26E700987760 /* PGCommandDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGCommandDelegate.h; path = Classes/PGCommandDelegate.h; sourceTree = "<group>"; };
686357A9141002F100DF4CF2 /* PhoneGapLibTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PhoneGapLibTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
686357AA141002F100DF4CF2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
686357AC141002F100DF4CF2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -413,6 +416,7 @@
888700D710922F56009987E8 /* Commands */ = {
isa = PBXGroup;
children = (
+ 30F5EBA914CA26E700987760 /* PGCommandDelegate.h */,
30C684921407044A004C1A8E /* PGURLProtocol.h */,
30C684931407044A004C1A8E /* PGURLProtocol.m */,
30C6847E1406CB38004C1A8E /* PGWhitelist.h */,
@@ -543,6 +547,7 @@
30E563D113E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
8852C43B14B65FD800F0E735 /* PGViewController.h in Headers */,
8852C44014B65FD800F0E735 /* UIGapView.h in Headers */,
+ 30F5EBAC14CA26E700987760 /* PGCommandDelegate.h in Headers */,
30B05DDA14BD24A10046A9AC /* PhoneGapDelegate.h in Headers */,
3047725C14C64D2700D535B5 /* NSDictionary+LowercaseKeys.h in Headers */,
30B05DDB14BD24A10046A9AC /* PhoneGapViewController.h in Headers */,
@@ -585,6 +590,7 @@
30B05D6F14BD22F10046A9AC /* PhoneGapDelegate.h in Headers */,
30B05D7114BD22F10046A9AC /* PhoneGapViewController.h in Headers */,
3047725B14C64D2700D535B5 /* NSDictionary+LowercaseKeys.h in Headers */,
+ 30F5EBAB14CA26E700987760 /* PGCommandDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};