adding faulty plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/9b83bc3f Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/9b83bc3f Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/9b83bc3f Branch: refs/heads/future Commit: 9b83bc3f50f6295d03cd78232a688283433e4489 Parents: 51a1f11 Author: Anis Kadri <[email protected]> Authored: Mon Apr 1 17:04:47 2013 -0700 Committer: Anis Kadri <[email protected]> Committed: Mon Apr 1 17:04:47 2013 -0700 ---------------------------------------------------------------------- test/plugins/FaultyPlugin/plugin.xml | 73 ++++++++++++ .../FaultyPlugin/src/android/FaultyPlugin.java | 19 +++ test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h | 49 ++++++++ test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m | 86 +++++++++++++++ 4 files changed, 227 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9b83bc3f/test/plugins/FaultyPlugin/plugin.xml ---------------------------------------------------------------------- diff --git a/test/plugins/FaultyPlugin/plugin.xml b/test/plugins/FaultyPlugin/plugin.xml new file mode 100644 index 0000000..abdd53a --- /dev/null +++ b/test/plugins/FaultyPlugin/plugin.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2013 Anis Kadri + + Licensed 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. + +--> + +<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" + xmlns:android="http://schemas.android.com/apk/res/android" + id="com.phonegap.plugins.faultyplugin" + version="0.6.0"> + + <name>Faulty Plugin</name> + + <access origin="build.phonegap.com" /> + <access origin="s3.amazonaws.com" /> + + <!-- android --> + <platform name="android"> + <config-file target="AndroidManifest.xml" parent="/manifest/application"> + <activity android:name="com.phonegap.plugins.faultyplugin.FaultyPlugin" + android:label="@string/app_name"> + <intent-filter> + </intent-filter> + </activity> + </config-file> + + <!-- CDV < 2.0 --> + <config-file target="res/xml/plugins.xml" parent="/plugins"> + <plugin name="FaultyPlugin" + value="com.phonegap.plugins.faultyplugin.FaultyPlugin"/> + </config-file> + + <!-- CDV 2.0+ (for now) --> + <config-file target="res/xml/config.xml" parent="/cordova/plugins"> + <plugin name="FaultyPlugin" + value="com.phonegap.plugins.faultyplugin.FaultyPlugin"/> + </config-file> + + <source-file src="FaultyPlugin.java" + target-dir="src/com/phonegap/plugins/faultyplugin" /> + </platform> + + <!-- ios --> + <platform name="ios"> + <!-- /cordova/plugins no longer exists, it is now /widget/plugins --> + <!-- this should fail to install on ios --> + <config-file target="config.xml" parent="/cordova/plugins"> + <plugin name="FaultyPlugin" + value="FaultyPlugin"/> + </config-file> + + <header-file src="FaultyPlugin.h" /> + <source-file src="FaultyPlugin.m" /> + <!-- these files don't exist --> + <header-file src="FaultyPluginCommand.h" /> + <source-file src="FaultyPluginCommand.m" /> + + </platform> +</plugin> http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9b83bc3f/test/plugins/FaultyPlugin/src/android/FaultyPlugin.java ---------------------------------------------------------------------- diff --git a/test/plugins/FaultyPlugin/src/android/FaultyPlugin.java b/test/plugins/FaultyPlugin/src/android/FaultyPlugin.java new file mode 100644 index 0000000..5263b0c --- /dev/null +++ b/test/plugins/FaultyPlugin/src/android/FaultyPlugin.java @@ -0,0 +1,19 @@ +/* + * + * Copyright 2013 Anis Kadri + * + * Licensed 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. + * +*/ + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9b83bc3f/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h ---------------------------------------------------------------------- diff --git a/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h b/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h new file mode 100644 index 0000000..6a23ab6 --- /dev/null +++ b/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2013 Anis Kadri + * + * Licensed 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. + * +*/ + +// +// PhoneGap ! ChildBrowserCommand +// +// +// Created by Jesse MacFadyen on 10-05-29. +// Copyright 2010 Nitobi. All rights reserved. +// + +#import <Foundation/Foundation.h> +#ifdef PHONEGAP_FRAMEWORK + #import <PhoneGap/PGPlugin.h> +#else + #import "PGPlugin.h" +#endif +#import "ChildBrowserViewController.h" + + + +@interface ChildBrowserCommand : PGPlugin <ChildBrowserDelegate> { + + ChildBrowserViewController* childBrowser; +} + +@property (nonatomic, retain) ChildBrowserViewController *childBrowser; + + +- (void) showWebPage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +-(void) onChildLocationChange:(NSString*)newLoc; + +@end http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9b83bc3f/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m ---------------------------------------------------------------------- diff --git a/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m b/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m new file mode 100644 index 0000000..38aaf64 --- /dev/null +++ b/test/plugins/FaultyPlugin/src/ios/FaultyPlugin.m @@ -0,0 +1,86 @@ +// + +// +// +// Created by Jesse MacFadyen on 10-05-29. +// Copyright 2010 Nitobi. All rights reserved. +// Copyright (c) 2011, IBM Corporation +// Copyright 2011, Randy McMillan +// + +#import "ChildBrowserCommand.h" + +#ifdef PHONEGAP_FRAMEWORK + #import <PhoneGap/PhoneGapViewController.h> +#else + #import "PhoneGapViewController.h" +#endif + + +@implementation ChildBrowserCommand + +@synthesize childBrowser; + +- (void) showWebPage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url +{ + + if(childBrowser == NULL) + { + childBrowser = [[ ChildBrowserViewController alloc ] initWithScale:FALSE ]; + childBrowser.delegate = self; + } + +/* // TODO: Work in progress + NSString* strOrientations = [ options objectForKey:@"supportedOrientations"]; + NSArray* supportedOrientations = [strOrientations componentsSeparatedByString:@","]; +*/ + PhoneGapViewController* cont = (PhoneGapViewController*)[ super appViewController ]; + childBrowser.supportedOrientations = cont.supportedOrientations; + + if ([cont respondsToSelector:@selector(presentViewController)]) { + //Reference UIViewController.h Line:179 for update to iOS 5 difference - @RandyMcMillan + [cont presentViewController:childBrowser animated:YES completion:nil]; + } else { + [ cont presentModalViewController:childBrowser animated:YES ]; + } + + NSString *url = (NSString*) [arguments objectAtIndex:0]; + + [childBrowser loadURL:url ]; + +} + +-(void) close:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url +{ + [ childBrowser closeBrowser]; + +} + +-(void) onClose +{ + NSString* jsCallback = [NSString stringWithFormat:@"ChildBrowser._onClose();",@""]; + [self.webView stringByEvaluatingJavaScriptFromString:jsCallback]; +} + +-(void) onOpenInSafari +{ + NSString* jsCallback = [NSString stringWithFormat:@"ChildBrowser._onOpenExternal();",@""]; + [self.webView stringByEvaluatingJavaScriptFromString:jsCallback]; +} + + +-(void) onChildLocationChange:(NSString*)newLoc +{ + + NSString* tempLoc = [NSString stringWithFormat:@"%@",newLoc]; + NSString* encUrl = [tempLoc stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + + NSString* jsCallback = [NSString stringWithFormat:@"ChildBrowser._onLocationChange('%@');",encUrl]; + [self.webView stringByEvaluatingJavaScriptFromString:jsCallback]; + +} + + + + +@end
