add .gitignore

This commit is contained in:
JoyWayer
2023-12-27 20:38:37 +08:00
parent b106a628a5
commit f6343426d6
515 changed files with 104217 additions and 199 deletions

60
.gitignore vendored Normal file
View File

@@ -0,0 +1,60 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/screenshots
#Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/

Binary file not shown.

View File

@@ -0,0 +1,15 @@
//
// AMapFoundationKit.h
// AMapFoundationKit
//
// Created by xiaoming han on 15/10/28.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <AMapFoundationKit/AMapFoundationVersion.h>
#import <AMapFoundationKit/AMapServices.h>
#import <AMapFoundationKit/AMapURLSearchConfig.h>
#import <AMapFoundationKit/AMapURLSearchType.h>
#import <AMapFoundationKit/AMapURLSearch.h>
#import <AMapFoundationKit/AMapUtility.h>

View File

@@ -0,0 +1,19 @@
//
// AMapFoundationVersion.h
// AMapFoundation
//
// Created by xiaoming han on 15/10/26.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifndef AMapFoundationVersion_h
#define AMapFoundationVersion_h
#define AMapFoundationVersionNumber 10403
FOUNDATION_EXTERN NSString * const AMapFoundationVersion;
FOUNDATION_EXTERN NSString * const AMapFoundationName;
#endif /* AMapFoundationVersion_h */

View File

@@ -0,0 +1,28 @@
//
// AMapSearchServices.h
// AMapSearchKit
//
// Created by xiaoming han on 15/6/18.
// Copyright (c) 2015年 xiaoming han. All rights reserved.
//
#import <Foundation/Foundation.h>
///高德SDK服务类
@interface AMapServices : NSObject
/**
* @brief 获取单例
*/
+ (AMapServices *)sharedServices;
///APIkey。设置key需要绑定对应的bundle id。
@property (nonatomic, copy) NSString *apiKey;
///是否开启HTTPS从1.3.3版本开始默认为YES。
@property (nonatomic, assign) BOOL enableHTTPS;
///是否启用崩溃日志上传。默认为YES, 只有在真机上设置有效。\n开启崩溃日志上传有助于我们更好的了解SDK的状况可以帮助我们持续优化和改进SDK。需要注意的是SDK内部是通过设置NSUncaughtExceptionHandler来捕获异常的如果您的APP中使用了其他收集崩溃日志的SDK或者自己有设置NSUncaughtExceptionHandler的话请保证 AMapServices 的初始化是在其他设置NSUncaughtExceptionHandler操作之后进行的我们的handler会再处理完异常后调用前一次设置的handler保证之前设置的handler会被执行。
@property (nonatomic, assign) BOOL crashReportEnabled;
@end

View File

@@ -0,0 +1,41 @@
//
// AMapURLSearch.h
// AMapFoundation
//
// Created by xiaoming han on 15/10/28.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AMapURLSearchConfig.h"
///调起高德地图URL进行搜索若是调起失败可使用`+ (void)getLatestAMapApp;`方法获取最新版高德地图app.
@interface AMapURLSearch : NSObject
/**
* @brief 打开高德地图AppStore页面
*/
+ (void)getLatestAMapApp;
/**
* @brief 调起高德地图app驾车导航.
* @param config 配置参数.
* @return 是否成功.若为YES则成功调起若为NO则无法调起.
*/
+ (BOOL)openAMapNavigation:(AMapNaviConfig *)config;
/**
* @brief 调起高德地图app进行路径规划.
* @param config 配置参数.
* @return 是否成功.
*/
+ (BOOL)openAMapRouteSearch:(AMapRouteConfig *)config;
/**
* @brief 调起高德地图app进行POI搜索.
* @param config 配置参数.
* @return 是否成功.
*/
+ (BOOL)openAMapPOISearch:(AMapPOIConfig *)config;
@end

View File

@@ -0,0 +1,79 @@
//
// MAMapURLSearchConfig.h
// MAMapKitNew
//
// Created by xiaoming han on 15/5/25.
// Copyright (c) 2015年 xiaoming han. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "AMapURLSearchType.h"
///导航配置信息
@interface AMapNaviConfig : NSObject
///应用返回的Scheme
@property (nonatomic, copy) NSString *appScheme;
///应用名称
@property (nonatomic, copy) NSString *appName;
///终点
@property (nonatomic, assign) CLLocationCoordinate2D destination;
///导航策略
@property (nonatomic, assign) AMapDrivingStrategy strategy;
@end
#pragma mark -
///路径搜索配置信息
@interface AMapRouteConfig : NSObject
///应用返回的Scheme
@property (nonatomic, copy) NSString *appScheme;
///应用名称
@property (nonatomic, copy) NSString *appName;
///起点坐标
@property (nonatomic, assign) CLLocationCoordinate2D startCoordinate;
///终点坐标
@property (nonatomic, assign) CLLocationCoordinate2D destinationCoordinate;
///驾车策略
@property (nonatomic, assign) AMapDrivingStrategy drivingStrategy;
///公交策略
@property (nonatomic, assign) AMapTransitStrategy transitStrategy;
///路径规划类型
@property (nonatomic, assign) AMapRouteSearchType routeType;
@end
#pragma mark -
///POI搜索配置信息
@interface AMapPOIConfig : NSObject
///应用返回的Scheme
@property (nonatomic, copy) NSString *appScheme;
///应用名称
@property (nonatomic, copy) NSString *appName;
///搜索关键字
@property (nonatomic, copy) NSString *keywords;
///左上角坐标
@property (nonatomic, assign) CLLocationCoordinate2D leftTopCoordinate;
///右下角坐标
@property (nonatomic, assign) CLLocationCoordinate2D rightBottomCoordinate;
@end

View File

@@ -0,0 +1,44 @@
//
// MAMapURLSearchType.h
// MAMapKitNew
//
// Created by xiaoming han on 15/5/25.
// Copyright (c) 2015年 xiaoming han. All rights reserved.
//
///驾车策略
typedef NS_ENUM(NSInteger, AMapDrivingStrategy)
{
AMapDrivingStrategyFastest = 0, ///<速度最快
AMapDrivingStrategyMinFare = 1, ///<避免收费
AMapDrivingStrategyShortest = 2, ///<距离最短
AMapDrivingStrategyNoHighways = 3, ///<不走高速
AMapDrivingStrategyAvoidCongestion = 4, ///<躲避拥堵
AMapDrivingStrategyAvoidHighwaysAndFare = 5, ///<不走高速且避免收费
AMapDrivingStrategyAvoidHighwaysAndCongestion = 6, ///<不走高速且躲避拥堵
AMapDrivingStrategyAvoidFareAndCongestion = 7, ///<躲避收费和拥堵
AMapDrivingStrategyAvoidHighwaysAndFareAndCongestion = 8 ///<不走高速躲避收费和拥堵
};
///公交策略
typedef NS_ENUM(NSInteger, AMapTransitStrategy)
{
AMapTransitStrategyFastest = 0,///<最快捷
AMapTransitStrategyMinFare = 1,///<最经济
AMapTransitStrategyMinTransfer = 2,///<最少换乘
AMapTransitStrategyMinWalk = 3,///<最少步行
AMapTransitStrategyMostComfortable = 4,///<最舒适
AMapTransitStrategyAvoidSubway = 5,///<不乘地铁
};
///路径规划类型
typedef NS_ENUM(NSInteger, AMapRouteSearchType)
{
AMapRouteSearchTypeDriving = 0, ///<驾车
AMapRouteSearchTypeTransit = 1, ///<公交
AMapRouteSearchTypeWalking = 2, ///<步行
};

View File

@@ -0,0 +1,49 @@
//
// AMapUtility.h
// AMapFoundation
//
// Created by xiaoming han on 15/10/27.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
//工具方法
/**
* @brief 如果字符串为nil则返回空字符串
*/
FOUNDATION_STATIC_INLINE NSString * AMapEmptyStringIfNil(NSString *s)
{
return s ? s : @"";
}
///坐标类型枚举
typedef NS_ENUM(NSUInteger, AMapCoordinateType)
{
AMapCoordinateTypeBaidu = 0, ///<Baidu
AMapCoordinateTypeMapBar, ///<MapBar
AMapCoordinateTypeMapABC, ///<MapABC
AMapCoordinateTypeSoSoMap, ///<SoSoMap
AMapCoordinateTypeAliYun, ///<AliYun
AMapCoordinateTypeGoogle, ///<Google
AMapCoordinateTypeGPS, ///<GPS
};
/**
* @brief 转换目标经纬度为高德坐标系
* @param coordinate 待转换的经纬度
* @param type 坐标系类型
* @return 高德坐标系经纬度
*/
FOUNDATION_EXTERN CLLocationCoordinate2D AMapCoordinateConvert(CLLocationCoordinate2D coordinate, AMapCoordinateType type);
/**
* @brief 判断目标经纬度是否在大陆以及港、澳地区。输入参数为高德坐标系。
* @param coordinate 待判断的目标经纬度
* @return 是否在大陆以及港、澳地区
*/
FOUNDATION_EXTERN BOOL AMapDataAvailableForCoordinate(CLLocationCoordinate2D coordinate);

View File

@@ -0,0 +1,6 @@
framework module AMapFoundationKit {
umbrella header "AMapFoundationKit.h"
export *
module * { export * }
}

View File

@@ -0,0 +1 @@
1.4.3+foundation.9a44998

View File

@@ -0,0 +1,6 @@
build/*
*.pbxuser
*.perspectivev3
*.mode1v3
javascripts/cordova-*.js

View File

@@ -0,0 +1,25 @@
/*
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.
*/
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DLog(...)
#endif
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

View File

@@ -0,0 +1,31 @@
/*
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.
*/
@interface NSArray (CDVJSONSerializingPrivate)
- (NSString*)cdv_JSONString;
@end
@interface NSDictionary (CDVJSONSerializingPrivate)
- (NSString*)cdv_JSONString;
@end
@interface NSString (CDVJSONSerializingPrivate)
- (id)cdv_JSONObject;
- (id)cdv_JSONFragment;
@end

View File

@@ -0,0 +1,91 @@
/*
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 "CDVJSON_private.h"
#import <Foundation/NSJSONSerialization.h>
@implementation NSArray (CDVJSONSerializingPrivate)
- (NSString*)cdv_JSONString
{
NSError* error = nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
options:0
error:&error];
if (error != nil) {
NSLog(@"NSArray JSONString error: %@", [error localizedDescription]);
return nil;
} else {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
@end
@implementation NSDictionary (CDVJSONSerializingPrivate)
- (NSString*)cdv_JSONString
{
NSError* error = nil;
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
options:NSJSONWritingPrettyPrinted
error:&error];
if (error != nil) {
NSLog(@"NSDictionary JSONString error: %@", [error localizedDescription]);
return nil;
} else {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
@end
@implementation NSString (CDVJSONSerializingPrivate)
- (id)cdv_JSONObject
{
NSError* error = nil;
id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
if (error != nil) {
NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
}
return object;
}
- (id)cdv_JSONFragment
{
NSError* error = nil;
id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingAllowFragments
error:&error];
if (error != nil) {
NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
}
return object;
}
@end

View File

@@ -0,0 +1,24 @@
/*
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.
*/
@interface CDVPlugin (Private)
- (instancetype)initWithWebViewEngine:(id <CDVWebViewEngineProtocol>)theWebViewEngine;
@end

View File

@@ -0,0 +1,26 @@
/*
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"
@interface CDVGestureHandler : CDVPlugin
@property (nonatomic, strong) UILongPressGestureRecognizer* lpgr;
@end

View File

@@ -0,0 +1,74 @@
/*
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 "CDVGestureHandler.h"
@implementation CDVGestureHandler
- (void)pluginInitialize
{
[self applyLongPressFix];
}
- (void)applyLongPressFix
{
// You can't suppress 3D Touch and still have regular longpress,
// so if this is false, let's not consider the 3D Touch setting at all.
if (![self.commandDelegate.settings objectForKey:@"suppresseslongpressgesture"] ||
![[self.commandDelegate.settings objectForKey:@"suppresseslongpressgesture"] boolValue]) {
return;
}
self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)];
self.lpgr.minimumPressDuration = 0.45f;
self.lpgr.allowableMovement = 100.0f;
// 0.45 is ok for 'regular longpress', 0.05-0.08 is required for '3D Touch longpress',
// but since this will also kill onclick handlers (not ontouchend) it's optional.
if ([self.commandDelegate.settings objectForKey:@"suppresses3dtouchgesture"] &&
[[self.commandDelegate.settings objectForKey:@"suppresses3dtouchgesture"] boolValue]) {
self.lpgr.minimumPressDuration = 0.05f;
}
NSArray *views = self.webView.subviews;
if (views.count == 0) {
NSLog(@"No webview subviews found, not applying the longpress fix.");
return;
}
for (int i=0; i<views.count; i++) {
UIView *webViewScrollView = views[i];
if ([webViewScrollView isKindOfClass:[UIScrollView class]]) {
NSArray *webViewScrollViewSubViews = webViewScrollView.subviews;
UIView *browser = webViewScrollViewSubViews[0];
[browser addGestureRecognizer:self.lpgr];
break;
}
}
}
- (void)handleLongPressGestures:(UILongPressGestureRecognizer*)sender
{
if ([sender isEqual:self.lpgr]) {
if (sender.state == UIGestureRecognizerStateBegan) {
NSLog(@"Ignoring a longpress in order to suppress the magnifying glass.");
}
}
}
@end

View File

@@ -0,0 +1,27 @@
/*
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"
@interface CDVHandleOpenURL : CDVPlugin
@property (nonatomic, strong) NSURL* url;
@property (nonatomic, assign) BOOL pageLoaded;
@end

View File

@@ -0,0 +1,86 @@
/*
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 "CDVHandleOpenURL.h"
#import "CDV.h"
@implementation CDVHandleOpenURL
- (void)pluginInitialize
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationLaunchedWithUrl:) name:CDVPluginHandleOpenURLNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationPageDidLoad:) name:CDVPageDidLoadNotification object:nil];
}
- (void)applicationLaunchedWithUrl:(NSNotification*)notification
{
NSURL* url = [notification object];
self.url = url;
// warm-start handler
if (self.pageLoaded) {
[self processOpenUrl:self.url pageLoaded:YES];
self.url = nil;
}
}
- (void)applicationPageDidLoad:(NSNotification*)notification
{
// cold-start handler
self.pageLoaded = YES;
if (self.url) {
[self processOpenUrl:self.url pageLoaded:YES];
self.url = nil;
}
}
- (void)processOpenUrl:(NSURL*)url pageLoaded:(BOOL)pageLoaded
{
__weak __typeof(self) weakSelf = self;
dispatch_block_t handleOpenUrl = ^(void) {
// calls into javascript global function 'handleOpenURL'
NSString* jsString = [NSString stringWithFormat:@"document.addEventListener('deviceready',function(){if (typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");}});", url.absoluteString];
[weakSelf.webViewEngine evaluateJavaScript:jsString completionHandler:nil];
};
if (!pageLoaded) {
NSString* jsString = @"document.readystate";
[self.webViewEngine evaluateJavaScript:jsString
completionHandler:^(id object, NSError* error) {
if ((error == nil) && [object isKindOfClass:[NSString class]]) {
NSString* readyState = (NSString*)object;
BOOL ready = [readyState isEqualToString:@"loaded"] || [readyState isEqualToString:@"complete"];
if (ready) {
handleOpenUrl();
} else {
self.url = url;
}
}
}];
} else {
handleOpenUrl();
}
}
@end

View File

@@ -0,0 +1,24 @@
/*
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"
@interface CDVIntentAndNavigationFilter : CDVPlugin <NSXMLParserDelegate>
@end

View File

@@ -0,0 +1,112 @@
/*
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 "CDVIntentAndNavigationFilter.h"
#import <Cordova/CDV.h>
@interface CDVIntentAndNavigationFilter ()
@property (nonatomic, readwrite) NSMutableArray* allowIntents;
@property (nonatomic, readwrite) NSMutableArray* allowNavigations;
@property (nonatomic, readwrite) CDVWhitelist* allowIntentsWhitelist;
@property (nonatomic, readwrite) CDVWhitelist* allowNavigationsWhitelist;
@end
@implementation CDVIntentAndNavigationFilter
#pragma mark NSXMLParserDelegate
- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{
if ([elementName isEqualToString:@"allow-navigation"]) {
[self.allowNavigations addObject:attributeDict[@"href"]];
}
if ([elementName isEqualToString:@"allow-intent"]) {
[self.allowIntents addObject:attributeDict[@"href"]];
}
}
- (void)parserDidStartDocument:(NSXMLParser*)parser
{
// file: url <allow-navigations> are added by default
self.allowNavigations = [[NSMutableArray alloc] initWithArray:@[ @"file://" ]];
// no intents are added by default
self.allowIntents = [[NSMutableArray alloc] init];
}
- (void)parserDidEndDocument:(NSXMLParser*)parser
{
self.allowIntentsWhitelist = [[CDVWhitelist alloc] initWithArray:self.allowIntents];
self.allowNavigationsWhitelist = [[CDVWhitelist alloc] initWithArray:self.allowNavigations];
}
- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
{
NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser columnNumber]);
}
#pragma mark CDVPlugin
- (void)pluginInitialize
{
if ([self.viewController isKindOfClass:[CDVViewController class]]) {
[(CDVViewController*)self.viewController parseSettingsWithParser:self];
}
}
- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString* allowIntents_whitelistRejectionFormatString = @"ERROR External navigation rejected - <allow-intent> not set for url='%@'";
NSString* allowNavigations_whitelistRejectionFormatString = @"ERROR Internal navigation rejected - <allow-navigation> not set for url='%@'";
NSURL* url = [request URL];
BOOL allowNavigationsPass = NO;
NSMutableArray* errorLogs = [NSMutableArray array];
switch (navigationType) {
case UIWebViewNavigationTypeLinkClicked:
// Note that the rejection strings will *only* print if
// it's a link click (and url is not whitelisted by <allow-*>)
if ([self.allowIntentsWhitelist URLIsAllowed:url logFailure:NO]) {
// the url *is* in a <allow-intent> tag, push to the system
[[UIApplication sharedApplication] openURL:url];
return NO;
} else {
[errorLogs addObject:[NSString stringWithFormat:allowIntents_whitelistRejectionFormatString, [url absoluteString]]];
}
// fall through, to check whether you can load this in the webview
default:
// check whether we can internally navigate to this url
allowNavigationsPass = [self.allowNavigationsWhitelist URLIsAllowed:url logFailure:NO];
// log all failures only when this last filter fails
if (!allowNavigationsPass){
[errorLogs addObject:[NSString stringWithFormat:allowNavigations_whitelistRejectionFormatString, [url absoluteString]]];
// this is the last filter and it failed, now print out all previous error logs
for (NSString* errorLog in errorLogs) {
NSLog(@"%@", errorLog);
}
}
return allowNavigationsPass;
}
}
@end

View File

@@ -0,0 +1,50 @@
/*
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"
#define kCDVLocalStorageErrorDomain @"kCDVLocalStorageErrorDomain"
#define kCDVLocalStorageFileOperationError 1
@interface CDVLocalStorage : CDVPlugin
@property (nonatomic, readonly, strong) NSMutableArray* backupInfo;
- (BOOL)shouldBackup;
- (BOOL)shouldRestore;
- (void)backup:(CDVInvokedUrlCommand*)command;
- (void)restore:(CDVInvokedUrlCommand*)command;
+ (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType;
// Visible for testing.
+ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
bundlePath:(NSString*)bundlePath
fileManager:(NSFileManager*)fileManager;
@end
@interface CDVBackupInfo : NSObject
@property (nonatomic, copy) NSString* original;
@property (nonatomic, copy) NSString* backup;
@property (nonatomic, copy) NSString* label;
- (BOOL)shouldBackup;
- (BOOL)shouldRestore;
@end

View File

@@ -0,0 +1,487 @@
/*
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 "CDVLocalStorage.h"
#import "CDV.h"
@interface CDVLocalStorage ()
@property (nonatomic, readwrite, strong) NSMutableArray* backupInfo; // array of CDVBackupInfo objects
@property (nonatomic, readwrite, weak) id <UIWebViewDelegate> webviewDelegate;
@end
@implementation CDVLocalStorage
@synthesize backupInfo, webviewDelegate;
- (void)pluginInitialize
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
name:UIApplicationWillResignActiveNotification object:nil];
BOOL cloudBackup = [@"cloud" isEqualToString : self.commandDelegate.settings[[@"BackupWebStorage" lowercaseString]]];
self.backupInfo = [[self class] createBackupInfoWithCloudBackup:cloudBackup];
}
#pragma mark -
#pragma mark Plugin interface methods
+ (NSMutableArray*)createBackupInfoWithTargetDir:(NSString*)targetDir backupDir:(NSString*)backupDir targetDirNests:(BOOL)targetDirNests backupDirNests:(BOOL)backupDirNests rename:(BOOL)rename
{
/*
This "helper" does so much work and has so many options it would probably be clearer to refactor the whole thing.
Basically, there are three database locations:
1. "Normal" dir -- LIB/<nested dires WebKit/LocalStorage etc>/<normal filenames>
2. "Caches" dir -- LIB/Caches/<normal filenames>
3. "Backup" dir -- DOC/Backups/<renamed filenames>
And between these three, there are various migration paths, most of which only consider 2 of the 3, which is why this helper is based on 2 locations and has a notion of "direction".
*/
NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:3];
NSString* original;
NSString* backup;
CDVBackupInfo* backupItem;
// ////////// LOCALSTORAGE
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0.localstorage":@"file__0.localstorage"];
backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
backup = [backup stringByAppendingPathComponent:(rename ? @"localstorage.appdata.db" : @"file__0.localstorage")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"localStorage database";
[backupInfo addObject:backupItem];
// ////////// WEBSQL MAIN DB
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/Databases.db":@"Databases.db"];
backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
backup = [backup stringByAppendingPathComponent:(rename ? @"websqlmain.appdata.db" : @"Databases.db")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"websql main database";
[backupInfo addObject:backupItem];
// ////////// WEBSQL DATABASES
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0":@"file__0"];
backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
backup = [backup stringByAppendingPathComponent:(rename ? @"websqldbs.appdata.db" : @"file__0")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"websql databases";
[backupInfo addObject:backupItem];
return backupInfo;
}
+ (NSMutableArray*)createBackupInfoWithCloudBackup:(BOOL)cloudBackup
{
// create backup info from backup folder to caches folder
NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* cacheFolder = [appLibraryFolder stringByAppendingPathComponent:@"Caches"];
NSString* backupsFolder = [appDocumentsFolder stringByAppendingPathComponent:@"Backups"];
// create the backups folder, if needed
[[NSFileManager defaultManager] createDirectoryAtPath:backupsFolder withIntermediateDirectories:YES attributes:nil error:nil];
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:backupsFolder] skip:!cloudBackup];
return [self createBackupInfoWithTargetDir:cacheFolder backupDir:backupsFolder targetDirNests:NO backupDirNests:NO rename:YES];
}
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL*)URL skip:(BOOL)skip
{
NSError* error = nil;
BOOL success = [URL setResourceValue:[NSNumber numberWithBool:skip] forKey:NSURLIsExcludedFromBackupKey error:&error];
if (!success) {
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
+ (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasing*)error
{
NSFileManager* fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:src]) {
NSString* errorString = [NSString stringWithFormat:@"%@ file does not exist.", src];
if (error != NULL) {
(*error) = [NSError errorWithDomain:kCDVLocalStorageErrorDomain
code:kCDVLocalStorageFileOperationError
userInfo:[NSDictionary dictionaryWithObject:errorString
forKey:NSLocalizedDescriptionKey]];
}
return NO;
}
// generate unique filepath in temp directory
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
CFRelease(uuidString);
CFRelease(uuidRef);
BOOL destExists = [fileManager fileExistsAtPath:dest];
// backup the dest
if (destExists && ![fileManager copyItemAtPath:dest toPath:tempBackup error:error]) {
return NO;
}
// remove the dest
if (destExists && ![fileManager removeItemAtPath:dest error:error]) {
return NO;
}
// create path to dest
if (!destExists && ![fileManager createDirectoryAtPath:[dest stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:error]) {
return NO;
}
// copy src to dest
if ([fileManager copyItemAtPath:src toPath:dest error:error]) {
// success - cleanup - delete the backup to the dest
if ([fileManager fileExistsAtPath:tempBackup]) {
[fileManager removeItemAtPath:tempBackup error:error];
}
return YES;
} else {
// failure - we restore the temp backup file to dest
[fileManager copyItemAtPath:tempBackup toPath:dest error:error];
// cleanup - delete the backup to the dest
if ([fileManager fileExistsAtPath:tempBackup]) {
[fileManager removeItemAtPath:tempBackup error:error];
}
return NO;
}
}
- (BOOL)shouldBackup
{
for (CDVBackupInfo* info in self.backupInfo) {
if ([info shouldBackup]) {
return YES;
}
}
return NO;
}
- (BOOL)shouldRestore
{
for (CDVBackupInfo* info in self.backupInfo) {
if ([info shouldRestore]) {
return YES;
}
}
return NO;
}
/* copy from webkitDbLocation to persistentDbLocation */
- (void)backup:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSError* __autoreleasing error = nil;
CDVPluginResult* result = nil;
NSString* message = nil;
for (CDVBackupInfo* info in self.backupInfo) {
if ([info shouldBackup]) {
[[self class] copyFrom:info.original to:info.backup error:&error];
if (callbackId) {
if (error == nil) {
message = [NSString stringWithFormat:@"Backed up: %@", info.label];
NSLog(@"%@", message);
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
} else {
message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) backup: %@", info.label, [error localizedDescription]];
NSLog(@"%@", message);
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
}
}
}
}
}
/* copy from persistentDbLocation to webkitDbLocation */
- (void)restore:(CDVInvokedUrlCommand*)command
{
NSError* __autoreleasing error = nil;
CDVPluginResult* result = nil;
NSString* message = nil;
for (CDVBackupInfo* info in self.backupInfo) {
if ([info shouldRestore]) {
[[self class] copyFrom:info.backup to:info.original error:&error];
if (error == nil) {
message = [NSString stringWithFormat:@"Restored: %@", info.label];
NSLog(@"%@", message);
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
} else {
message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) restore: %@", info.label, [error localizedDescription]];
NSLog(@"%@", message);
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
}
}
}
+ (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType
{
[self __verifyAndFixDatabaseLocations];
[self __restoreLegacyDatabaseLocationsWithBackupType:backupType];
}
+ (void)__verifyAndFixDatabaseLocations
{
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* bundlePath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
NSString* bundleIdentifier = [[mainBundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
NSString* appPlistPath = [bundlePath stringByAppendingPathComponent:[NSString stringWithFormat:@"Library/Preferences/%@.plist", bundleIdentifier]];
NSMutableDictionary* appPlistDict = [NSMutableDictionary dictionaryWithContentsOfFile:appPlistPath];
BOOL modified = [[self class] __verifyAndFixDatabaseLocationsWithAppPlistDict:appPlistDict
bundlePath:bundlePath
fileManager:[NSFileManager defaultManager]];
if (modified) {
BOOL ok = [appPlistDict writeToFile:appPlistPath atomically:YES];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"Fix applied for database locations?: %@", ok ? @"YES" : @"NO");
}
}
+ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
bundlePath:(NSString*)bundlePath
fileManager:(NSFileManager*)fileManager
{
NSString* libraryCaches = @"Library/Caches";
NSString* libraryWebKit = @"Library/WebKit";
NSArray* keysToCheck = [NSArray arrayWithObjects:
@"WebKitLocalStorageDatabasePathPreferenceKey",
@"WebDatabaseDirectory",
nil];
BOOL dirty = NO;
for (NSString* key in keysToCheck) {
NSString* value = [appPlistDict objectForKey:key];
// verify key exists, and path is in app bundle, if not - fix
if ((value != nil) && ![value hasPrefix:bundlePath]) {
// the pathSuffix to use may be wrong - OTA upgrades from < 5.1 to 5.1 do keep the old path Library/WebKit,
// while Xcode synced ones do change the storage location to Library/Caches
NSString* newBundlePath = [bundlePath stringByAppendingPathComponent:libraryCaches];
if (![fileManager fileExistsAtPath:newBundlePath]) {
newBundlePath = [bundlePath stringByAppendingPathComponent:libraryWebKit];
}
[appPlistDict setValue:newBundlePath forKey:key];
dirty = YES;
}
}
return dirty;
}
+ (void)__restoreLegacyDatabaseLocationsWithBackupType:(NSString*)backupType
{
// on iOS 6, if you toggle between cloud/local backup, you must move database locations. Default upgrade from iOS5.1 to iOS6 is like a toggle from local to cloud.
NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:0];
if ([backupType isEqualToString:@"cloud"]) {
#ifdef DEBUG
NSLog(@"\n\nStarted backup to iCloud! Please be careful."
"\nYour application might be rejected by Apple if you store too much data."
"\nFor more information please read \"iOS Data Storage Guidelines\" at:"
"\nhttps://developer.apple.com/icloud/documentation/data-storage/"
"\nTo disable web storage backup to iCloud, set the BackupWebStorage preference to \"local\" in the Cordova config.xml file\n\n");
#endif
// We would like to restore old backups/caches databases to the new destination (nested in lib folder)
[backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:appLibraryFolder backupDir:[appDocumentsFolder stringByAppendingPathComponent:@"Backups"] targetDirNests:YES backupDirNests:NO rename:YES]];
[backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:appLibraryFolder backupDir:[appLibraryFolder stringByAppendingPathComponent:@"Caches"] targetDirNests:YES backupDirNests:NO rename:NO]];
} else {
// For ios6 local backups we also want to restore from Backups dir -- but we don't need to do that here, since the plugin will do that itself.
[backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:[appLibraryFolder stringByAppendingPathComponent:@"Caches"] backupDir:appLibraryFolder targetDirNests:NO backupDirNests:YES rename:NO]];
}
NSFileManager* manager = [NSFileManager defaultManager];
for (CDVBackupInfo* info in backupInfo) {
if ([manager fileExistsAtPath:info.backup]) {
if ([info shouldRestore]) {
NSLog(@"Restoring old webstorage backup. From: '%@' To: '%@'.", info.backup, info.original);
[self copyFrom:info.backup to:info.original error:nil];
}
NSLog(@"Removing old webstorage backup: '%@'.", info.backup);
[manager removeItemAtPath:info.backup error:nil];
}
}
[[NSUserDefaults standardUserDefaults] setBool:[backupType isEqualToString:@"cloud"] forKey:@"WebKitStoreWebDataForBackup"];
}
#pragma mark -
#pragma mark Notification handlers
- (void)onResignActive
{
UIDevice* device = [UIDevice currentDevice];
NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
BOOL isMultitaskingSupported = [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported];
if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
exitsOnSuspend = [NSNumber numberWithBool:NO];
}
if (exitsOnSuspend) {
[self backup:nil];
} else if (isMultitaskingSupported) {
__block UIBackgroundTaskIdentifier backgroundTaskID = UIBackgroundTaskInvalid;
backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
backgroundTaskID = UIBackgroundTaskInvalid;
NSLog(@"Background task to backup WebSQL/LocalStorage expired.");
}];
CDVLocalStorage __weak* weakSelf = self;
[self.commandDelegate runInBackground:^{
[weakSelf backup:nil];
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
backgroundTaskID = UIBackgroundTaskInvalid;
}];
}
}
- (void)onAppTerminate
{
[self onResignActive];
}
- (void)onReset
{
[self restore:nil];
}
@end
#pragma mark -
#pragma mark CDVBackupInfo implementation
@implementation CDVBackupInfo
@synthesize original, backup, label;
- (BOOL)file:(NSString*)aPath isNewerThanFile:(NSString*)bPath
{
NSFileManager* fileManager = [NSFileManager defaultManager];
NSError* __autoreleasing error = nil;
NSDictionary* aPathAttribs = [fileManager attributesOfItemAtPath:aPath error:&error];
NSDictionary* bPathAttribs = [fileManager attributesOfItemAtPath:bPath error:&error];
NSDate* aPathModDate = [aPathAttribs objectForKey:NSFileModificationDate];
NSDate* bPathModDate = [bPathAttribs objectForKey:NSFileModificationDate];
if ((nil == aPathModDate) && (nil == bPathModDate)) {
return NO;
}
return [aPathModDate compare:bPathModDate] == NSOrderedDescending || bPathModDate == nil;
}
- (BOOL)item:(NSString*)aPath isNewerThanItem:(NSString*)bPath
{
NSFileManager* fileManager = [NSFileManager defaultManager];
BOOL aPathIsDir = NO, bPathIsDir = NO;
BOOL aPathExists = [fileManager fileExistsAtPath:aPath isDirectory:&aPathIsDir];
[fileManager fileExistsAtPath:bPath isDirectory:&bPathIsDir];
if (!aPathExists) {
return NO;
}
if (!(aPathIsDir && bPathIsDir)) { // just a file
return [self file:aPath isNewerThanFile:bPath];
}
// essentially we want rsync here, but have to settle for our poor man's implementation
// we get the files in aPath, and see if it is newer than the file in bPath
// (it is newer if it doesn't exist in bPath) if we encounter the FIRST file that is newer,
// we return YES
NSDirectoryEnumerator* directoryEnumerator = [fileManager enumeratorAtPath:aPath];
NSString* path;
while ((path = [directoryEnumerator nextObject])) {
NSString* aPathFile = [aPath stringByAppendingPathComponent:path];
NSString* bPathFile = [bPath stringByAppendingPathComponent:path];
BOOL isNewer = [self file:aPathFile isNewerThanFile:bPathFile];
if (isNewer) {
return YES;
}
}
return NO;
}
- (BOOL)shouldBackup
{
return [self item:self.original isNewerThanItem:self.backup];
}
- (BOOL)shouldRestore
{
return [self item:self.backup isNewerThanItem:self.original];
}
@end

View File

@@ -0,0 +1,41 @@
/*
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

View File

@@ -0,0 +1,400 @@
/*
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];
NSArray* allowedSchemes = [NSArray arrayWithObjects:@"mailto",@"tel",@"blob",@"sms",@"data", nil];
if([allowedSchemes containsObject:scheme]) {
return YES;
}
else {
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:
{
NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate: Navigation started when state=%ld", (long)_state];
NSLog(@"%@", description);
_loadCount = 0;
_state = STATE_WAITING_FOR_LOAD_START;
if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
NSError* error = [[NSError alloc] initWithDomain:@"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

View File

@@ -0,0 +1,27 @@
/*
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

View File

@@ -0,0 +1,197 @@
/*
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 "CDVUIWebViewNavigationDelegate.h"
#import "NSDictionary+CordovaPreferences.h"
#import <objc/message.h>
@interface CDVUIWebViewEngine ()
@property (nonatomic, strong, readwrite) UIView* engineWebView;
@property (nonatomic, strong, readwrite) id <UIWebViewDelegate> uiWebViewDelegate;
@property (nonatomic, strong, readwrite) CDVUIWebViewNavigationDelegate* navWebViewDelegate;
@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;
} else {
self.navWebViewDelegate = [[CDVUIWebViewNavigationDelegate alloc] initWithEnginePlugin:self];
self.uiWebViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self.navWebViewDelegate];
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];
}
- (BOOL) canLoadRequest:(NSURLRequest*)request
{
return (request != nil);
}
- (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 ([uiWebView 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

View File

@@ -0,0 +1,29 @@
/*
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 "CDVUIWebViewEngine.h"
@interface CDVUIWebViewNavigationDelegate : NSObject <UIWebViewDelegate>
@property (nonatomic, weak) CDVPlugin* enginePlugin;
- (instancetype)initWithEnginePlugin:(CDVPlugin*)enginePlugin;
@end

View File

@@ -0,0 +1,151 @@
/*
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 "CDVUIWebViewNavigationDelegate.h"
#import <Cordova/CDVViewController.h>
#import <Cordova/CDVCommandDelegateImpl.h>
#import <Cordova/CDVUserAgentUtil.h>
#import <objc/message.h>
@implementation CDVUIWebViewNavigationDelegate
- (instancetype)initWithEnginePlugin:(CDVPlugin*)theEnginePlugin
{
self = [super init];
if (self) {
self.enginePlugin = theEnginePlugin;
}
return self;
}
/**
When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
the device's data such as device ID, platform version, etc.
*/
- (void)webViewDidStartLoad:(UIWebView*)theWebView
{
NSLog(@"Resetting plugins due to page load.");
CDVViewController* vc = (CDVViewController*)self.enginePlugin.viewController;
[vc.commandQueue resetRequestId];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginResetNotification object:self.enginePlugin.webView]];
}
/**
Called when the webview finishes loading. This stops the activity view.
*/
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
NSLog(@"Finished load of: %@", theWebView.request.URL);
CDVViewController* vc = (CDVViewController*)self.enginePlugin.viewController;
// It's safe to release the lock even if this is just a sub-frame that's finished loading.
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
/*
* Hide the Top Activity THROBBER in the Battery Bar
*/
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:self.enginePlugin.webView]];
}
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
{
CDVViewController* vc = (CDVViewController*)self.enginePlugin.viewController;
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
NSString* message = [NSString stringWithFormat:@"Failed to load webpage with error: %@", [error localizedDescription]];
NSLog(@"%@", message);
NSURL* errorUrl = vc.errorURL;
if (errorUrl) {
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] relativeToURL:errorUrl];
NSLog(@"%@", [errorUrl absoluteString]);
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
}
}
- (BOOL)defaultResourcePolicyForURL:(NSURL*)url
{
/*
* If a URL is being loaded that's a file url, just load it internally
*/
if ([url isFileURL]) {
return YES;
}
return NO;
}
- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
CDVViewController* vc = (CDVViewController*)self.enginePlugin.viewController;
/*
* Execute any commands queued with cordova.exec() on the JS side.
* The part of the URL after gap:// is irrelevant.
*/
if ([[url scheme] isEqualToString:@"gap"]) {
[vc.commandQueue fetchCommandsFromJs];
// The delegate is called asynchronously in this case, so we don't have to use
// flushCommandQueueWithDelayedJs (setTimeout(0)) as we do with hash changes.
[vc.commandQueue executePending];
return NO;
}
/*
* Give plugins the chance to handle the url
*/
BOOL anyPluginsResponded = NO;
BOOL shouldAllowRequest = NO;
for (NSString* pluginName in vc.pluginObjects) {
CDVPlugin* plugin = [vc.pluginObjects objectForKey:pluginName];
SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
if ([plugin respondsToSelector:selector]) {
anyPluginsResponded = YES;
shouldAllowRequest = (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, request, navigationType));
if (!shouldAllowRequest) {
break;
}
}
}
if (anyPluginsResponded) {
return shouldAllowRequest;
}
/*
* Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
*/
BOOL shouldAllowNavigation = [self defaultResourcePolicyForURL:url];
if (shouldAllowNavigation) {
return YES;
} else {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
return NO;
}
@end

View File

@@ -0,0 +1,34 @@
/*
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 "CDVAvailability.h"
#import "CDVAvailabilityDeprecated.h"
#import "CDVAppDelegate.h"
#import "CDVPlugin.h"
#import "CDVPluginResult.h"
#import "CDVViewController.h"
#import "CDVCommandDelegate.h"
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
#import "CDVWhitelist.h"
#import "CDVPlugin.h"
#import "CDVPluginResult.h"
#import "CDVScreenOrientationDelegate.h"
#import "CDVTimer.h"
#import "CDVUserAgentUtil.h"

View File

@@ -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 <Foundation/Foundation.h>
#import "CDVViewController.h"
@interface CDVAppDelegate : NSObject <UIApplicationDelegate>{}
@property (nonatomic, strong) IBOutlet UIWindow* window;
@property (nonatomic, strong) IBOutlet CDVViewController* viewController;
@end

View File

@@ -0,0 +1,105 @@
/*
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 "CDVAppDelegate.h"
@implementation CDVAppDelegate
@synthesize window, viewController;
- (id)init
{
/** If you need to do any extra app-specific initialization, you can do it here
* -jm
**/
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
[NSURLCache setSharedURLCache:sharedCache];
self = [super init];
return self;
}
#pragma mark UIApplicationDelegate implementation
/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
*/
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
self.window.autoresizesSubviews = YES;
// only set if not already set in subclass
if (self.viewController == nil) {
self.viewController = [[CDVViewController alloc] init];
}
// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
// self.viewController.startPage = @"index.html";
// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
// this happens while we are running ( in the background, or from within our own app )
// only valid if 40x-Info.plist specifies a protocol to handle
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
if (!url) {
return NO;
}
// all plugins will get the notification, and their handlers will be called
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
return YES;
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
#else
- (UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
#endif
{
// iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).
NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return supportedInterfaceOrientations;
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
@end

View File

@@ -0,0 +1,102 @@
/*
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 "CDVAvailabilityDeprecated.h"
#define __CORDOVA_IOS__
#define __CORDOVA_0_9_6 906
#define __CORDOVA_1_0_0 10000
#define __CORDOVA_1_1_0 10100
#define __CORDOVA_1_2_0 10200
#define __CORDOVA_1_3_0 10300
#define __CORDOVA_1_4_0 10400
#define __CORDOVA_1_4_1 10401
#define __CORDOVA_1_5_0 10500
#define __CORDOVA_1_6_0 10600
#define __CORDOVA_1_6_1 10601
#define __CORDOVA_1_7_0 10700
#define __CORDOVA_1_8_0 10800
#define __CORDOVA_1_8_1 10801
#define __CORDOVA_1_9_0 10900
#define __CORDOVA_2_0_0 20000
#define __CORDOVA_2_1_0 20100
#define __CORDOVA_2_2_0 20200
#define __CORDOVA_2_3_0 20300
#define __CORDOVA_2_4_0 20400
#define __CORDOVA_2_5_0 20500
#define __CORDOVA_2_6_0 20600
#define __CORDOVA_2_7_0 20700
#define __CORDOVA_2_8_0 20800
#define __CORDOVA_2_9_0 20900
#define __CORDOVA_3_0_0 30000
#define __CORDOVA_3_1_0 30100
#define __CORDOVA_3_2_0 30200
#define __CORDOVA_3_3_0 30300
#define __CORDOVA_3_4_0 30400
#define __CORDOVA_3_4_1 30401
#define __CORDOVA_3_5_0 30500
#define __CORDOVA_3_6_0 30600
#define __CORDOVA_3_7_0 30700
#define __CORDOVA_3_8_0 30800
#define __CORDOVA_3_9_0 30900
#define __CORDOVA_3_9_1 30901
#define __CORDOVA_3_9_2 30902
#define __CORDOVA_4_0_0 40000
#define __CORDOVA_4_0_1 40001
#define __CORDOVA_4_1_0 40100
#define __CORDOVA_4_1_1 40101
/* coho:next-version,insert-before */
#define __CORDOVA_NA 99999 /* not available */
/*
#if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_4_0_0
// do something when its at least 4.0.0
#else
// do something else (non 4.0.0)
#endif
*/
#ifndef CORDOVA_VERSION_MIN_REQUIRED
/* coho:next-version-min-required,replace-after */
#define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_1_1
#endif
/*
Returns YES if it is at least version specified as NSString(X)
Usage:
if (IsAtLeastiOSVersion(@"5.1")) {
// do something for iOS 5.1 or greater
}
*/
#define IsAtLeastiOSVersion(X) ([[[UIDevice currentDevice] systemVersion] compare:X options:NSNumericSearch] != NSOrderedAscending)
/* Return the string version of the decimal version */
#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
(CORDOVA_VERSION_MIN_REQUIRED / 10000), \
(CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
(CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
// Enable this to log all exec() calls.
#define CDV_ENABLE_EXEC_LOGGING 0
#if CDV_ENABLE_EXEC_LOGGING
#define CDV_EXEC_LOG NSLog
#else
#define CDV_EXEC_LOG(...) do { \
} while (NO)
#endif

View File

@@ -0,0 +1,26 @@
/*
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>
#ifdef __clang__
#define CDV_DEPRECATED(version, msg) __attribute__((deprecated("Deprecated in Cordova " #version ". " msg)))
#else
#define CDV_DEPRECATED(version, msg) __attribute__((deprecated()))
#endif

View File

@@ -0,0 +1,51 @@
/*
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 "CDVAvailability.h"
#import "CDVInvokedUrlCommand.h"
@class CDVPlugin;
@class CDVPluginResult;
@class CDVWhitelist;
typedef NSURL* (^ UrlTransformerBlock)(NSURL*);
@protocol CDVCommandDelegate <NSObject>
@property (nonatomic, readonly) NSDictionary* settings;
@property (nonatomic, copy) UrlTransformerBlock urlTransformer;
- (NSString*)pathForResource:(NSString*)resourcepath;
- (id)getCommandInstance:(NSString*)pluginName;
// Sends a plugin result to the JS. This is thread-safe.
- (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId;
// Evaluates the given JS. This is thread-safe.
- (void)evalJs:(NSString*)js;
// Can be used to evaluate JS right away instead of scheduling it on the run-loop.
// This is required for dispatch resign and pause events, but should not be used
// without reason. Without the run-loop delay, alerts used in JS callbacks may result
// in dead-lock. This method must be called from the UI thread.
- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
// Runs the given block on a background thread using a shared thread-pool.
- (void)runInBackground:(void (^)())block;
// Returns the User-Agent of the associated UIWebView.
- (NSString*)userAgent;
@end

View File

@@ -0,0 +1,36 @@
/*
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 "CDVCommandDelegate.h"
@class CDVViewController;
@class CDVCommandQueue;
@interface CDVCommandDelegateImpl : NSObject <CDVCommandDelegate>{
@private
__weak CDVViewController* _viewController;
NSRegularExpression* _callbackIdPattern;
@protected
__weak CDVCommandQueue* _commandQueue;
BOOL _delayResponses;
}
- (id)initWithViewController:(CDVViewController*)viewController;
- (void)flushCommandQueueWithDelayedJs;
@end

View File

@@ -0,0 +1,186 @@
/*
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 "CDVCommandDelegateImpl.h"
#import "CDVJSON_private.h"
#import "CDVCommandQueue.h"
#import "CDVPluginResult.h"
#import "CDVViewController.h"
@implementation CDVCommandDelegateImpl
@synthesize urlTransformer;
- (id)initWithViewController:(CDVViewController*)viewController
{
self = [super init];
if (self != nil) {
_viewController = viewController;
_commandQueue = _viewController.commandQueue;
NSError* err = nil;
_callbackIdPattern = [NSRegularExpression regularExpressionWithPattern:@"[^A-Za-z0-9._-]" options:0 error:&err];
if (err != nil) {
// Couldn't initialize Regex
NSLog(@"Error: Couldn't initialize regex");
_callbackIdPattern = nil;
}
}
return self;
}
- (NSString*)pathForResource:(NSString*)resourcepath
{
NSBundle* mainBundle = [NSBundle mainBundle];
NSMutableArray* directoryParts = [NSMutableArray arrayWithArray:[resourcepath componentsSeparatedByString:@"/"]];
NSString* filename = [directoryParts lastObject];
[directoryParts removeLastObject];
NSString* directoryPartsJoined = [directoryParts componentsJoinedByString:@"/"];
NSString* directoryStr = _viewController.wwwFolderName;
if ([directoryPartsJoined length] > 0) {
directoryStr = [NSString stringWithFormat:@"%@/%@", _viewController.wwwFolderName, [directoryParts componentsJoinedByString:@"/"]];
}
return [mainBundle pathForResource:filename ofType:@"" inDirectory:directoryStr];
}
- (void)flushCommandQueueWithDelayedJs
{
_delayResponses = YES;
[_commandQueue executePending];
_delayResponses = NO;
}
- (void)evalJsHelper2:(NSString*)js
{
CDV_EXEC_LOG(@"Exec: evalling: %@", [js substringToIndex:MIN([js length], 160)]);
[_viewController.webViewEngine evaluateJavaScript:js completionHandler:^(id obj, NSError* error) {
// TODO: obj can be something other than string
if ([obj isKindOfClass:[NSString class]]) {
NSString* commandsJSON = (NSString*)obj;
if ([commandsJSON length] > 0) {
CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by chaining.");
}
[_commandQueue enqueueCommandBatch:commandsJSON];
[_commandQueue executePending];
}
}];
}
- (void)evalJsHelper:(NSString*)js
{
// Cycle the run-loop before executing the JS.
// For _delayResponses -
// This ensures that we don't eval JS during the middle of an existing JS
// function (possible since UIWebViewDelegate callbacks can be synchronous).
// For !isMainThread -
// It's a hard error to eval on the non-UI thread.
// For !_commandQueue.currentlyExecuting -
// This works around a bug where sometimes alerts() within callbacks can cause
// dead-lock.
// If the commandQueue is currently executing, then we know that it is safe to
// execute the callback immediately.
// Using (dispatch_get_main_queue()) does *not* fix deadlocks for some reason,
// but performSelectorOnMainThread: does.
if (_delayResponses || ![NSThread isMainThread] || !_commandQueue.currentlyExecuting) {
[self performSelectorOnMainThread:@selector(evalJsHelper2:) withObject:js waitUntilDone:NO];
} else {
[self evalJsHelper2:js];
}
}
- (BOOL)isValidCallbackId:(NSString*)callbackId
{
if ((callbackId == nil) || (_callbackIdPattern == nil)) {
return NO;
}
// Disallow if too long or if any invalid characters were found.
if (([callbackId length] > 100) || [_callbackIdPattern firstMatchInString:callbackId options:0 range:NSMakeRange(0, [callbackId length])]) {
return NO;
}
return YES;
}
- (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId
{
CDV_EXEC_LOG(@"Exec(%@): Sending result. Status=%@", callbackId, result.status);
// This occurs when there is are no win/fail callbacks for the call.
if ([@"INVALID" isEqualToString:callbackId]) {
return;
}
// This occurs when the callback id is malformed.
if (![self isValidCallbackId:callbackId]) {
NSLog(@"Invalid callback id received by sendPluginResult");
return;
}
int status = [result.status intValue];
BOOL keepCallback = [result.keepCallback boolValue];
NSString* argumentsAsJSON = [result argumentsAsJSON];
BOOL debug = NO;
#ifdef DEBUG
debug = YES;
#endif
NSString* js = [NSString stringWithFormat:@"cordova.require('cordova/exec').nativeCallback('%@',%d,%@,%d, %d)", callbackId, status, argumentsAsJSON, keepCallback, debug];
[self evalJsHelper:js];
}
- (void)evalJs:(NSString*)js
{
[self evalJs:js scheduledOnRunLoop:YES];
}
- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop
{
js = [NSString stringWithFormat:@"try{cordova.require('cordova/exec').nativeEvalAndFetch(function(){%@})}catch(e){console.log('exeption nativeEvalAndFetch : '+e);};", js];
if (scheduledOnRunLoop) {
[self evalJsHelper:js];
} else {
[self evalJsHelper2:js];
}
}
- (id)getCommandInstance:(NSString*)pluginName
{
return [_viewController getCommandInstance:pluginName];
}
- (void)runInBackground:(void (^)())block
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}
- (NSString*)userAgent
{
return [_viewController userAgent];
}
- (NSDictionary*)settings
{
return _viewController.settings;
}
@end

View File

@@ -0,0 +1,39 @@
/*
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>
@class CDVInvokedUrlCommand;
@class CDVViewController;
@interface CDVCommandQueue : NSObject
@property (nonatomic, readonly) BOOL currentlyExecuting;
- (id)initWithViewController:(CDVViewController*)viewController;
- (void)dispose;
- (void)resetRequestId;
- (void)enqueueCommandBatch:(NSString*)batchJSON;
- (void)fetchCommandsFromJs;
- (void)executePending;
- (BOOL)execute:(CDVInvokedUrlCommand*)command;
@end

View File

@@ -0,0 +1,194 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#include <objc/message.h>
#import "CDVCommandQueue.h"
#import "CDVViewController.h"
#import "CDVCommandDelegateImpl.h"
#import "CDVJSON_private.h"
#import "CDVDebug.h"
// Parse JS on the main thread if it's shorter than this.
static const NSInteger JSON_SIZE_FOR_MAIN_THREAD = 4 * 1024; // Chosen arbitrarily.
// Execute multiple commands in one go until this many seconds have passed.
static const double MAX_EXECUTION_TIME = .008; // Half of a 60fps frame.
@interface CDVCommandQueue () {
NSInteger _lastCommandQueueFlushRequestId;
__weak CDVViewController* _viewController;
NSMutableArray* _queue;
NSTimeInterval _startExecutionTime;
}
@end
@implementation CDVCommandQueue
- (BOOL)currentlyExecuting
{
return _startExecutionTime > 0;
}
- (id)initWithViewController:(CDVViewController*)viewController
{
self = [super init];
if (self != nil) {
_viewController = viewController;
_queue = [[NSMutableArray alloc] init];
}
return self;
}
- (void)dispose
{
// TODO(agrieve): Make this a zeroing weak ref once we drop support for 4.3.
_viewController = nil;
}
- (void)resetRequestId
{
_lastCommandQueueFlushRequestId = 0;
}
- (void)enqueueCommandBatch:(NSString*)batchJSON
{
if ([batchJSON length] > 0) {
NSMutableArray* commandBatchHolder = [[NSMutableArray alloc] init];
[_queue addObject:commandBatchHolder];
if ([batchJSON length] < JSON_SIZE_FOR_MAIN_THREAD) {
[commandBatchHolder addObject:[batchJSON cdv_JSONObject]];
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^() {
NSMutableArray* result = [batchJSON cdv_JSONObject];
@synchronized(commandBatchHolder) {
[commandBatchHolder addObject:result];
}
[self performSelectorOnMainThread:@selector(executePending) withObject:nil waitUntilDone:NO];
});
}
}
}
- (void)fetchCommandsFromJs
{
__weak CDVCommandQueue* weakSelf = self;
NSString* js = @"cordova.require('cordova/exec').nativeFetchMessages()";
[_viewController.webViewEngine evaluateJavaScript:js
completionHandler:^(id obj, NSError* error) {
if ((error == nil) && [obj isKindOfClass:[NSString class]]) {
NSString* queuedCommandsJSON = (NSString*)obj;
CDV_EXEC_LOG(@"Exec: Flushed JS->native queue (hadCommands=%d).", [queuedCommandsJSON length] > 0);
[weakSelf enqueueCommandBatch:queuedCommandsJSON];
// this has to be called here now, because fetchCommandsFromJs is now async (previously: synchronous)
[self executePending];
}
}];
}
- (void)executePending
{
// Make us re-entrant-safe.
if (_startExecutionTime > 0) {
return;
}
@try {
_startExecutionTime = [NSDate timeIntervalSinceReferenceDate];
while ([_queue count] > 0) {
NSMutableArray* commandBatchHolder = _queue[0];
NSMutableArray* commandBatch = nil;
@synchronized(commandBatchHolder) {
// If the next-up command is still being decoded, wait for it.
if ([commandBatchHolder count] == 0) {
break;
}
commandBatch = commandBatchHolder[0];
}
while ([commandBatch count] > 0) {
@autoreleasepool {
// Execute the commands one-at-a-time.
NSArray* jsonEntry = [commandBatch cdv_dequeue];
if ([commandBatch count] == 0) {
[_queue removeObjectAtIndex:0];
}
CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonEntry];
CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, command.className, command.methodName);
if (![self execute:command]) {
#ifdef DEBUG
NSString* commandJson = [jsonEntry cdv_JSONString];
static NSUInteger maxLogLength = 1024;
NSString* commandString = ([commandJson length] > maxLogLength) ?
[NSString stringWithFormat : @"%@[...]", [commandJson substringToIndex:maxLogLength]] :
commandJson;
DLog(@"FAILED pluginJSON = %@", commandString);
#endif
}
}
// Yield if we're taking too long.
if (([_queue count] > 0) && ([NSDate timeIntervalSinceReferenceDate] - _startExecutionTime > MAX_EXECUTION_TIME)) {
[self performSelector:@selector(executePending) withObject:nil afterDelay:0];
return;
}
}
}
} @finally
{
_startExecutionTime = 0;
}
}
- (BOOL)execute:(CDVInvokedUrlCommand*)command
{
if ((command.className == nil) || (command.methodName == nil)) {
NSLog(@"ERROR: Classname and/or methodName not found for command.");
return NO;
}
// Fetch an instance of this class
CDVPlugin* obj = [_viewController.commandDelegate getCommandInstance:command.className];
if (!([obj isKindOfClass:[CDVPlugin class]])) {
NSLog(@"ERROR: Plugin '%@' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.", command.className);
return NO;
}
BOOL retVal = YES;
double started = [[NSDate date] timeIntervalSince1970] * 1000.0;
// Find the proper selector to call.
NSString* methodName = [NSString stringWithFormat:@"%@:", command.methodName];
SEL normalSelector = NSSelectorFromString(methodName);
if ([obj respondsToSelector:normalSelector]) {
// [obj performSelector:normalSelector withObject:command];
((void (*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command);
} else {
// There's no method to call, so throw an error.
NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.className);
retVal = NO;
}
double elapsed = [[NSDate date] timeIntervalSince1970] * 1000.0 - started;
if (elapsed > 10) {
NSLog(@"THREAD WARNING: ['%@'] took '%f' ms. Plugin should use a background thread.", command.className, elapsed);
}
return retVal;
}
@end

View File

@@ -0,0 +1,30 @@
/*
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.
*/
@interface CDVConfigParser : NSObject <NSXMLParserDelegate>
{
NSString* featureName;
}
@property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
@property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames;
@property (nonatomic, readonly, strong) NSString* startPage;
@end

View File

@@ -0,0 +1,81 @@
/*
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 "CDVConfigParser.h"
@interface CDVConfigParser ()
@property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict;
@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
@property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
@property (nonatomic, readwrite, strong) NSString* startPage;
@end
@implementation CDVConfigParser
@synthesize pluginsDict, settings, startPage, startupPluginNames;
- (id)init
{
self = [super init];
if (self != nil) {
self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30];
self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
featureName = nil;
}
return self;
}
- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{
if ([elementName isEqualToString:@"preference"]) {
settings[[attributeDict[@"name"] lowercaseString]] = attributeDict[@"value"];
} else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with correct parameter set
featureName = [attributeDict[@"name"] lowercaseString];
} else if ((featureName != nil) && [elementName isEqualToString:@"param"]) {
NSString* paramName = [attributeDict[@"name"] lowercaseString];
id value = attributeDict[@"value"];
if ([paramName isEqualToString:@"ios-package"]) {
pluginsDict[featureName] = value;
}
BOOL paramIsOnload = ([paramName isEqualToString:@"onload"] && [@"true" isEqualToString : value]);
BOOL attribIsOnload = [@"true" isEqualToString :[attributeDict[@"onload"] lowercaseString]];
if (paramIsOnload || attribIsOnload) {
[self.startupPluginNames addObject:featureName];
}
} else if ([elementName isEqualToString:@"content"]) {
self.startPage = attributeDict[@"src"];
}
}
- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName
{
if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release
featureName = nil;
}
}
- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
{
NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser columnNumber]);
}
@end

View File

@@ -0,0 +1,52 @@
/*
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 CDVInvokedUrlCommand : NSObject {
NSString* _callbackId;
NSString* _className;
NSString* _methodName;
NSArray* _arguments;
}
@property (nonatomic, readonly) NSArray* arguments;
@property (nonatomic, readonly) NSString* callbackId;
@property (nonatomic, readonly) NSString* className;
@property (nonatomic, readonly) NSString* methodName;
+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
- (id)initWithArguments:(NSArray*)arguments
callbackId:(NSString*)callbackId
className:(NSString*)className
methodName:(NSString*)methodName;
- (id)initFromJson:(NSArray*)jsonEntry;
// Returns the argument at the given index.
// If index >= the number of arguments, returns nil.
// If the argument at the given index is NSNull, returns nil.
- (id)argumentAtIndex:(NSUInteger)index;
// Same as above, but returns defaultValue instead of nil.
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue;
// Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass;
@end

View File

@@ -0,0 +1,116 @@
/*
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 "CDVInvokedUrlCommand.h"
#import "CDVJSON_private.h"
@implementation CDVInvokedUrlCommand
@synthesize arguments = _arguments;
@synthesize callbackId = _callbackId;
@synthesize className = _className;
@synthesize methodName = _methodName;
+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry
{
return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry];
}
- (id)initFromJson:(NSArray*)jsonEntry
{
id tmp = [jsonEntry objectAtIndex:0];
NSString* callbackId = tmp == [NSNull null] ? nil : tmp;
NSString* className = [jsonEntry objectAtIndex:1];
NSString* methodName = [jsonEntry objectAtIndex:2];
NSMutableArray* arguments = [jsonEntry objectAtIndex:3];
return [self initWithArguments:arguments
callbackId:callbackId
className:className
methodName:methodName];
}
- (id)initWithArguments:(NSArray*)arguments
callbackId:(NSString*)callbackId
className:(NSString*)className
methodName:(NSString*)methodName
{
self = [super init];
if (self != nil) {
_arguments = arguments;
_callbackId = callbackId;
_className = className;
_methodName = methodName;
}
[self massageArguments];
return self;
}
- (void)massageArguments
{
NSMutableArray* newArgs = nil;
for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) {
id arg = [_arguments objectAtIndex:i];
if (![arg isKindOfClass:[NSDictionary class]]) {
continue;
}
NSDictionary* dict = arg;
NSString* type = [dict objectForKey:@"CDVType"];
if (!type || ![type isEqualToString:@"ArrayBuffer"]) {
continue;
}
NSString* data = [dict objectForKey:@"data"];
if (!data) {
continue;
}
if (newArgs == nil) {
newArgs = [NSMutableArray arrayWithArray:_arguments];
_arguments = newArgs;
}
[newArgs replaceObjectAtIndex:i withObject:[[NSData alloc] initWithBase64EncodedString:data options:0]];
}
}
- (id)argumentAtIndex:(NSUInteger)index
{
return [self argumentAtIndex:index withDefault:nil];
}
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue
{
return [self argumentAtIndex:index withDefault:defaultValue andClass:nil];
}
- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass
{
if (index >= [_arguments count]) {
return defaultValue;
}
id ret = [_arguments objectAtIndex:index];
if (ret == [NSNull null]) {
ret = defaultValue;
}
if ((aClass != nil) && ![ret isKindOfClass:aClass]) {
ret = defaultValue;
}
return ret;
}
@end

View File

@@ -0,0 +1,39 @@
/*
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

View File

@@ -0,0 +1,38 @@
/*
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

View File

@@ -0,0 +1,69 @@
/*
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

View File

@@ -0,0 +1,163 @@
/*
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

View File

@@ -0,0 +1,66 @@
/*
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 messageAsNSInteger:(NSInteger)theMessage;
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)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

View File

@@ -0,0 +1,186 @@
/*
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"
@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 base64EncodedStringWithOptions:0]
};
}
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 messageAsNSInteger:(NSInteger)theMessage
{
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInteger:theMessage]];
}
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage
{
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithUnsignedInteger: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

View File

@@ -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 <Foundation/Foundation.h>
@protocol CDVScreenOrientationDelegate <NSObject>
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
- (BOOL)shouldAutorotate;
@end

View File

@@ -0,0 +1,27 @@
/*
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

View File

@@ -0,0 +1,123 @@
/*
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

View File

@@ -0,0 +1,27 @@
/*
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 {}
@end

View File

@@ -0,0 +1,113 @@
/*
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 "CDVViewController.h"
// 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://";
@implementation CDVURLProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
{
NSURL* theUrl = [theRequest URL];
if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
return YES;
}
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 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 = [NSString stringWithFormat:@"Access not allowed to URL: %@", 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

View File

@@ -0,0 +1,27 @@
/*
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

View File

@@ -0,0 +1,122 @@
/*
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

View File

@@ -0,0 +1,85 @@
/*
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 "CDVScreenOrientationDelegate.h"
#import "CDVPlugin.h"
#import "CDVWebViewEngineProtocol.h"
@interface CDVViewController : UIViewController <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, readwrite, copy) NSString* configFile;
@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;
/**
The address of the lock token used for controlling access to setting the user-agent
*/
@property (nonatomic, readonly) NSInteger* userAgentLockToken;
- (UIView*)newCordovaViewWithFrame:(CGRect)bounds;
- (NSString*)appURLScheme;
- (NSURL*)errorURL;
- (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;
- (void)parseSettingsWithParser:(NSObject <NSXMLParserDelegate>*)delegate;
@end

View File

@@ -0,0 +1,671 @@
/*
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 <objc/message.h>
#import "CDV.h"
#import "CDVPlugin+Private.h"
#import "CDVUIWebViewDelegate.h"
#import "CDVConfigParser.h"
#import "CDVUserAgentUtil.h"
#import <AVFoundation/AVFoundation.h>
#import "NSDictionary+CordovaPreferences.h"
#import "CDVLocalStorage.h"
#import "CDVCommandDelegateImpl.h"
@interface CDVViewController () {
NSInteger _userAgentLockToken;
}
@property (nonatomic, readwrite, strong) NSXMLParser* configParser;
@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
@property (nonatomic, readwrite, strong) NSMutableDictionary* pluginObjects;
@property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
@property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
@property (nonatomic, readwrite, strong) NSArray* supportedOrientations;
@property (nonatomic, readwrite, strong) id <CDVWebViewEngineProtocol> webViewEngine;
@property (readwrite, assign) BOOL initialized;
@property (atomic, strong) NSURL* openURL;
@end
@implementation CDVViewController
@synthesize supportedOrientations;
@synthesize pluginObjects, pluginsMap, startupPluginNames;
@synthesize configParser, settings;
@synthesize wwwFolderName, startPage, initialized, openURL, baseUserAgent;
@synthesize commandDelegate = _commandDelegate;
@synthesize commandQueue = _commandQueue;
@synthesize webViewEngine = _webViewEngine;
@dynamic webView;
- (void)__init
{
if ((self != nil) && !self.initialized) {
_commandQueue = [[CDVCommandQueue alloc] initWithViewController:self];
_commandDelegate = [[CDVCommandDelegateImpl alloc] initWithViewController:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillTerminate:)
name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification object:nil];
// read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad, if its iPad) from -Info.plist
self.supportedOrientations = [self parseInterfaceOrientations:
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]];
[self printVersion];
[self printMultitaskingInfo];
[self printPlatformVersionWarning];
self.initialized = YES;
}
}
- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
[self __init];
return self;
}
- (id)initWithCoder:(NSCoder*)aDecoder
{
self = [super initWithCoder:aDecoder];
[self __init];
return self;
}
- (id)init
{
self = [super init];
[self __init];
return self;
}
- (void)printVersion
{
NSLog(@"Apache Cordova native platform version %@ is starting.", CDV_VERSION);
}
- (void)printPlatformVersionWarning
{
if (!IsAtLeastiOSVersion(@"8.0")) {
NSLog(@"CRITICAL: For Cordova 4.0.0 and above, you will need to upgrade to at least iOS 8.0 or greater. Your current version of iOS is %@.",
[[UIDevice currentDevice] systemVersion]
);
}
}
- (void)printMultitaskingInfo
{
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
backgroundSupported = device.multitaskingSupported;
}
NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
exitsOnSuspend = [NSNumber numberWithBool:NO];
}
NSLog(@"Multi-tasking -> Device: %@, App: %@", (backgroundSupported ? @"YES" : @"NO"), (![exitsOnSuspend intValue]) ? @"YES" : @"NO");
}
-(NSString*)configFilePath{
NSString* path = self.configFile ?: @"config.xml";
// if path is relative, resolve it against the main bundle
if(![path isAbsolutePath]){
NSString* absolutePath = [[NSBundle mainBundle] pathForResource:path ofType:nil];
if(!absolutePath){
NSAssert(NO, @"ERROR: %@ not found in the main bundle!", path);
}
path = absolutePath;
}
// Assert file exists
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSAssert(NO, @"ERROR: %@ does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.", path);
return nil;
}
return path;
}
- (void)parseSettingsWithParser:(NSObject <NSXMLParserDelegate>*)delegate
{
// read from config.xml in the app bundle
NSString* path = [self configFilePath];
NSURL* url = [NSURL fileURLWithPath:path];
self.configParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
if (self.configParser == nil) {
NSLog(@"Failed to initialize XML parser.");
return;
}
[self.configParser setDelegate:((id < NSXMLParserDelegate >)delegate)];
[self.configParser parse];
}
- (void)loadSettings
{
CDVConfigParser* delegate = [[CDVConfigParser alloc] init];
[self parseSettingsWithParser:delegate];
// Get the plugin dictionary, whitelist and settings from the delegate.
self.pluginsMap = delegate.pluginsDict;
self.startupPluginNames = delegate.startupPluginNames;
self.settings = delegate.settings;
// And the start folder/page.
if(self.wwwFolderName == nil){
self.wwwFolderName = @"www";
}
if(delegate.startPage && self.startPage == nil){
self.startPage = delegate.startPage;
}
if (self.startPage == nil) {
self.startPage = @"index.html";
}
// Initialize the plugin objects dict.
self.pluginObjects = [[NSMutableDictionary alloc] initWithCapacity:20];
}
- (NSURL*)appUrl
{
NSURL* appURL = nil;
if ([self.startPage rangeOfString:@"://"].location != NSNotFound) {
appURL = [NSURL URLWithString:self.startPage];
} else if ([self.wwwFolderName rangeOfString:@"://"].location != NSNotFound) {
appURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.wwwFolderName, self.startPage]];
} else if([self.wwwFolderName hasSuffix:@".bundle"]){
// www folder is actually a bundle
NSBundle* bundle = [NSBundle bundleWithPath:self.wwwFolderName];
appURL = [bundle URLForResource:self.startPage withExtension:nil];
} else {
// CB-3005 strip parameters from start page to check if page exists in resources
NSURL* startURL = [NSURL URLWithString:self.startPage];
NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]];
if (startFilePath == nil) {
appURL = nil;
} else {
appURL = [NSURL fileURLWithPath:startFilePath];
// CB-3005 Add on the query params or fragment.
NSString* startPageNoParentDirs = self.startPage;
NSRange r = [startPageNoParentDirs rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"?#"] options:0];
if (r.location != NSNotFound) {
NSString* queryAndOrFragment = [self.startPage substringFromIndex:r.location];
appURL = [NSURL URLWithString:queryAndOrFragment relativeToURL:appURL];
}
}
}
return appURL;
}
- (NSURL*)errorURL
{
NSURL* errorUrl = nil;
id setting = [self.settings cordovaSettingForKey:@"ErrorUrl"];
if (setting) {
NSString* errorUrlString = (NSString*)setting;
if ([errorUrlString rangeOfString:@"://"].location != NSNotFound) {
errorUrl = [NSURL URLWithString:errorUrlString];
} else {
NSURL* url = [NSURL URLWithString:(NSString*)setting];
NSString* errorFilePath = [self.commandDelegate pathForResource:[url path]];
if (errorFilePath) {
errorUrl = [NSURL fileURLWithPath:errorFilePath];
}
}
}
return errorUrl;
}
- (UIView*)webView
{
if (self.webViewEngine != nil) {
return self.webViewEngine.engineWebView;
}
return nil;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
// Load settings
[self loadSettings];
NSString* backupWebStorageType = @"cloud"; // default value
id backupWebStorage = [self.settings cordovaSettingForKey:@"BackupWebStorage"];
if ([backupWebStorage isKindOfClass:[NSString class]]) {
backupWebStorageType = backupWebStorage;
}
[self.settings setCordovaSetting:backupWebStorageType forKey:@"BackupWebStorage"];
[CDVLocalStorage __fixupDatabaseLocationsWithBackupType:backupWebStorageType];
// // Instantiate the WebView ///////////////
if (!self.webView) {
[self createGapView];
}
// /////////////////
/*
* Fire up CDVLocalStorage to work-around WebKit storage limitations: on all iOS 5.1+ versions for local-only backups, but only needed on iOS 5.1 for cloud backup.
With minimum iOS 7/8 supported, only first clause applies.
*/
if ([backupWebStorageType isEqualToString:@"local"]) {
NSString* localStorageFeatureName = @"localstorage";
if ([self.pluginsMap objectForKey:localStorageFeatureName]) { // plugin specified in config
[self.startupPluginNames addObject:localStorageFeatureName];
}
}
if ([self.startupPluginNames count] > 0) {
[CDVTimer start:@"TotalPluginStartup"];
for (NSString* pluginName in self.startupPluginNames) {
[CDVTimer start:pluginName];
[self getCommandInstance:pluginName];
[CDVTimer stop:pluginName];
}
[CDVTimer stop:@"TotalPluginStartup"];
}
// /////////////////
NSURL* appURL = [self appUrl];
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
_userAgentLockToken = lockToken;
[CDVUserAgentUtil setUserAgent:self.userAgent lockToken:lockToken];
if (appURL) {
NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
[self.webViewEngine loadRequest:appReq];
} else {
NSString* loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
NSLog(@"%@", loadErr);
NSURL* errorUrl = [self errorURL];
if (errorUrl) {
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [loadErr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] relativeToURL:errorUrl];
NSLog(@"%@", [errorUrl absoluteString]);
[self.webViewEngine loadRequest:[NSURLRequest requestWithURL:errorUrl]];
} else {
NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
[self.webViewEngine loadHTMLString:html baseURL:nil];
}
}
}];
}
- (NSArray*)parseInterfaceOrientations:(NSArray*)orientations
{
NSMutableArray* result = [[NSMutableArray alloc] init];
if (orientations != nil) {
NSEnumerator* enumerator = [orientations objectEnumerator];
NSString* orientationString;
while (orientationString = [enumerator nextObject]) {
if ([orientationString isEqualToString:@"UIInterfaceOrientationPortrait"]) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
} else if ([orientationString isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
} else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeLeft"]) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
} else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
}
}
}
// default
if ([result count] == 0) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
}
return result;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger ret = 0;
if ([self supportsOrientation:UIInterfaceOrientationPortrait]) {
ret = ret | (1 << UIInterfaceOrientationPortrait);
}
if ([self supportsOrientation:UIInterfaceOrientationPortraitUpsideDown]) {
ret = ret | (1 << UIInterfaceOrientationPortraitUpsideDown);
}
if ([self supportsOrientation:UIInterfaceOrientationLandscapeRight]) {
ret = ret | (1 << UIInterfaceOrientationLandscapeRight);
}
if ([self supportsOrientation:UIInterfaceOrientationLandscapeLeft]) {
ret = ret | (1 << UIInterfaceOrientationLandscapeLeft);
}
return ret;
}
- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation
{
return [self.supportedOrientations containsObject:[NSNumber numberWithInt:orientation]];
}
- (UIView*)newCordovaViewWithFrame:(CGRect)bounds
{
NSString* defaultWebViewEngineClass = @"CDVUIWebViewEngine";
NSString* webViewEngineClass = [self.settings cordovaSettingForKey:@"CordovaWebViewEngine"];
if (!webViewEngineClass) {
webViewEngineClass = defaultWebViewEngineClass;
}
// Find webViewEngine
if (NSClassFromString(webViewEngineClass)) {
self.webViewEngine = [[NSClassFromString(webViewEngineClass) alloc] initWithFrame:bounds];
// if a webView engine returns nil (not supported by the current iOS version) or doesn't conform to the protocol, or can't load the request, we use UIWebView
if (!self.webViewEngine || ![self.webViewEngine conformsToProtocol:@protocol(CDVWebViewEngineProtocol)] || ![self.webViewEngine canLoadRequest:[NSURLRequest requestWithURL:self.appUrl]]) {
self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass) alloc] initWithFrame:bounds];
}
} else {
self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass) alloc] initWithFrame:bounds];
}
if ([self.webViewEngine isKindOfClass:[CDVPlugin class]]) {
[self registerPlugin:(CDVPlugin*)self.webViewEngine withClassName:webViewEngineClass];
}
return self.webViewEngine.engineWebView;
}
- (NSString*)userAgent
{
if (_userAgent != nil) {
return _userAgent;
}
NSString* localBaseUserAgent;
if (self.baseUserAgent != nil) {
localBaseUserAgent = self.baseUserAgent;
} else if ([self.settings cordovaSettingForKey:@"OverrideUserAgent"] != nil) {
localBaseUserAgent = [self.settings cordovaSettingForKey:@"OverrideUserAgent"];
} else {
localBaseUserAgent = [CDVUserAgentUtil originalUserAgent];
}
NSString* appendUserAgent = [self.settings cordovaSettingForKey:@"AppendUserAgent"];
if (appendUserAgent) {
_userAgent = [NSString stringWithFormat:@"%@ %@", localBaseUserAgent, appendUserAgent];
} else {
// Use our address as a unique number to append to the User-Agent.
_userAgent = [NSString stringWithFormat:@"%@ (%lld)", localBaseUserAgent, (long long)self];
}
return _userAgent;
}
- (void)createGapView
{
CGRect webViewBounds = self.view.bounds;
webViewBounds.origin = self.view.bounds.origin;
UIView* view = [self newCordovaViewWithFrame:webViewBounds];
view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[self.view addSubview:view];
[self.view sendSubviewToBack:view];
}
- (void)didReceiveMemoryWarning
{
// iterate through all the plugin objects, and call hasPendingOperation
// if at least one has a pending operation, we don't call [super didReceiveMemoryWarning]
NSEnumerator* enumerator = [self.pluginObjects objectEnumerator];
CDVPlugin* plugin;
BOOL doPurge = YES;
while ((plugin = [enumerator nextObject])) {
if (plugin.hasPendingOperation) {
NSLog(@"Plugin '%@' has a pending operation, memory purge is delayed for didReceiveMemoryWarning.", NSStringFromClass([plugin class]));
doPurge = NO;
}
}
if (doPurge) {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload
{
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
[super viewDidUnload];
}
#pragma mark CordovaCommands
- (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
{
if ([plugin respondsToSelector:@selector(setViewController:)]) {
[plugin setViewController:self];
}
if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
[plugin setCommandDelegate:_commandDelegate];
}
[self.pluginObjects setObject:plugin forKey:className];
[plugin pluginInitialize];
}
- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName
{
if ([plugin respondsToSelector:@selector(setViewController:)]) {
[plugin setViewController:self];
}
if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
[plugin setCommandDelegate:_commandDelegate];
}
NSString* className = NSStringFromClass([plugin class]);
[self.pluginObjects setObject:plugin forKey:className];
[self.pluginsMap setValue:className forKey:[pluginName lowercaseString]];
[plugin pluginInitialize];
}
/**
Returns an instance of a CordovaCommand object, based on its name. If one exists already, it is returned.
*/
- (id)getCommandInstance:(NSString*)pluginName
{
// first, we try to find the pluginName in the pluginsMap
// (acts as a whitelist as well) if it does not exist, we return nil
// NOTE: plugin names are matched as lowercase to avoid problems - however, a
// possible issue is there can be duplicates possible if you had:
// "org.apache.cordova.Foo" and "org.apache.cordova.foo" - only the lower-cased entry will match
NSString* className = [self.pluginsMap objectForKey:[pluginName lowercaseString]];
if (className == nil) {
return nil;
}
id obj = [self.pluginObjects objectForKey:className];
if (!obj) {
obj = [[NSClassFromString(className)alloc] initWithWebViewEngine:_webViewEngine];
if (obj != nil) {
[self registerPlugin:obj withClassName:className];
} else {
NSLog(@"CDVPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);
}
}
return obj;
}
#pragma mark -
- (NSString*)appURLScheme
{
NSString* URLScheme = nil;
NSArray* URLTypes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleURLTypes"];
if (URLTypes != nil) {
NSDictionary* dict = [URLTypes objectAtIndex:0];
if (dict != nil) {
NSArray* URLSchemes = [dict objectForKey:@"CFBundleURLSchemes"];
if (URLSchemes != nil) {
URLScheme = [URLSchemes objectAtIndex:0];
}
}
}
return URLScheme;
}
#pragma mark -
#pragma mark UIApplicationDelegate impl
/*
This method lets your application know that it is about to be terminated and purged from memory entirely
*/
- (void)onAppWillTerminate:(NSNotification*)notification
{
// empty the tmp directory
NSFileManager* fileMgr = [[NSFileManager alloc] init];
NSError* __autoreleasing err = nil;
// clear contents of NSTemporaryDirectory
NSString* tempDirectoryPath = NSTemporaryDirectory();
NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
NSString* fileName = nil;
BOOL result;
while ((fileName = [directoryEnumerator nextObject])) {
NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
result = [fileMgr removeItemAtPath:filePath error:&err];
if (!result && err) {
NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
}
}
}
/*
This method is called to let your application know that it is about to move from the active to inactive state.
You should use this method to pause ongoing tasks, disable timer, ...
*/
- (void)onAppWillResignActive:(NSNotification*)notification
{
// NSLog(@"%@",@"applicationWillResignActive");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
}
/*
In iOS 4.0 and later, this method is called as part of the transition from the background to the inactive state.
You can use this method to undo many of the changes you made to your application upon entering the background.
invariably followed by applicationDidBecomeActive
*/
- (void)onAppWillEnterForeground:(NSNotification*)notification
{
// NSLog(@"%@",@"applicationWillEnterForeground");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resume');"];
/** Clipboard fix **/
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
NSString* string = pasteboard.string;
if (string) {
[pasteboard setValue:string forPasteboardType:@"public.text"];
}
}
// This method is called to let your application know that it moved from the inactive to active state.
- (void)onAppDidBecomeActive:(NSNotification*)notification
{
// NSLog(@"%@",@"applicationDidBecomeActive");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
}
/*
In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method
when the user quits an application that supports background execution.
*/
- (void)onAppDidEnterBackground:(NSNotification*)notification
{
// NSLog(@"%@",@"applicationDidEnterBackground");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause', null, true);" scheduledOnRunLoop:NO];
}
// ///////////////////////
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
[_commandQueue dispose];
[[self.pluginObjects allValues] makeObjectsPerformSelector:@selector(dispose)];
}
- (NSInteger*)userAgentLockToken
{
return &_userAgentLockToken;
}
@end

View File

@@ -0,0 +1,42 @@
/*
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>
#define kCDVWebViewEngineScriptMessageHandlers @"kCDVWebViewEngineScriptMessageHandlers"
#define kCDVWebViewEngineUIWebViewDelegate @"kCDVWebViewEngineUIWebViewDelegate"
#define kCDVWebViewEngineWKNavigationDelegate @"kCDVWebViewEngineWKNavigationDelegate"
#define kCDVWebViewEngineWKUIDelegate @"kCDVWebViewEngineWKUIDelegate"
#define kCDVWebViewEngineWebViewPreferences @"kCDVWebViewEngineWebViewPreferences"
@protocol CDVWebViewEngineProtocol <NSObject>
@property (nonatomic, strong, readonly) UIView* engineWebView;
- (id)loadRequest:(NSURLRequest*)request;
- (id)loadHTMLString:(NSString*)string baseURL:(NSURL*)baseURL;
- (void)evaluateJavaScript:(NSString*)javaScriptString completionHandler:(void (^)(id, NSError*))completionHandler;
- (NSURL*)URL;
- (BOOL)canLoadRequest:(NSURLRequest*)request;
- (instancetype)initWithFrame:(CGRect)frame;
- (void)updateWithInfo:(NSDictionary*)info;
@end

View File

@@ -0,0 +1,34 @@
/*
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>
extern NSString* const kCDVDefaultWhitelistRejectionString;
@interface CDVWhitelist : NSObject
@property (nonatomic, copy) NSString* whitelistRejectionFormatString;
- (id)initWithArray:(NSArray*)array;
- (BOOL)schemeIsAllowed:(NSString*)scheme;
- (BOOL)URLIsAllowed:(NSURL*)url;
- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure;
- (NSString*)errorStringForURL:(NSURL*)url;
@end

View File

@@ -0,0 +1,285 @@
/*
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 "CDVWhitelist.h"
NSString* const kCDVDefaultWhitelistRejectionString = @"ERROR whitelist rejection: url='%@'";
NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
@interface CDVWhitelistPattern : NSObject {
@private
NSRegularExpression* _scheme;
NSRegularExpression* _host;
NSNumber* _port;
NSRegularExpression* _path;
}
+ (NSString*)regexFromPattern:(NSString*)pattern allowWildcards:(bool)allowWildcards;
- (id)initWithScheme:(NSString*)scheme host:(NSString*)host port:(NSString*)port path:(NSString*)path;
- (bool)matches:(NSURL*)url;
@end
@implementation CDVWhitelistPattern
+ (NSString*)regexFromPattern:(NSString*)pattern allowWildcards:(bool)allowWildcards
{
NSString* regex = [NSRegularExpression escapedPatternForString:pattern];
if (allowWildcards) {
regex = [regex stringByReplacingOccurrencesOfString:@"\\*" withString:@".*"];
/* [NSURL path] has the peculiarity that a trailing slash at the end of a path
* will be omitted. This regex tweak compensates for that.
*/
if ([regex hasSuffix:@"\\/.*"]) {
regex = [NSString stringWithFormat:@"%@(\\/.*)?", [regex substringToIndex:([regex length] - 4)]];
}
}
return [NSString stringWithFormat:@"%@$", regex];
}
- (id)initWithScheme:(NSString*)scheme host:(NSString*)host port:(NSString*)port path:(NSString*)path
{
self = [super init]; // Potentially change "self"
if (self) {
if ((scheme == nil) || [scheme isEqualToString:@"*"]) {
_scheme = nil;
} else {
_scheme = [NSRegularExpression regularExpressionWithPattern:[CDVWhitelistPattern regexFromPattern:scheme allowWildcards:NO] options:NSRegularExpressionCaseInsensitive error:nil];
}
if ([host isEqualToString:@"*"] || host == nil) {
_host = nil;
} else if ([host hasPrefix:@"*."]) {
_host = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"([a-z0-9.-]*\\.)?%@", [CDVWhitelistPattern regexFromPattern:[host substringFromIndex:2] allowWildcards:false]] options:NSRegularExpressionCaseInsensitive error:nil];
} else {
_host = [NSRegularExpression regularExpressionWithPattern:[CDVWhitelistPattern regexFromPattern:host allowWildcards:NO] options:NSRegularExpressionCaseInsensitive error:nil];
}
if ((port == nil) || [port isEqualToString:@"*"]) {
_port = nil;
} else {
_port = [[NSNumber alloc] initWithInteger:[port integerValue]];
}
if ((path == nil) || [path isEqualToString:@"/*"]) {
_path = nil;
} else {
_path = [NSRegularExpression regularExpressionWithPattern:[CDVWhitelistPattern regexFromPattern:path allowWildcards:YES] options:0 error:nil];
}
}
return self;
}
- (bool)matches:(NSURL*)url
{
return (_scheme == nil || [_scheme numberOfMatchesInString:[url scheme] options:NSMatchingAnchored range:NSMakeRange(0, [[url scheme] length])]) &&
(_host == nil || ([url host] != nil && [_host numberOfMatchesInString:[url host] options:NSMatchingAnchored range:NSMakeRange(0, [[url host] length])])) &&
(_port == nil || [[url port] isEqualToNumber:_port]) &&
(_path == nil || [_path numberOfMatchesInString:[url path] options:NSMatchingAnchored range:NSMakeRange(0, [[url path] length])])
;
}
@end
@interface CDVWhitelist ()
@property (nonatomic, readwrite, strong) NSMutableArray* whitelist;
@property (nonatomic, readwrite, strong) NSMutableSet* permittedSchemes;
- (void)addWhiteListEntry:(NSString*)pattern;
@end
@implementation CDVWhitelist
@synthesize whitelist, permittedSchemes, whitelistRejectionFormatString;
- (id)initWithArray:(NSArray*)array
{
self = [super init];
if (self) {
self.whitelist = [[NSMutableArray alloc] init];
self.permittedSchemes = [[NSMutableSet alloc] init];
self.whitelistRejectionFormatString = kCDVDefaultWhitelistRejectionString;
for (NSString* pattern in array) {
[self addWhiteListEntry:pattern];
}
}
return self;
}
- (BOOL)isIPv4Address:(NSString*)externalHost
{
// an IPv4 address has 4 octets b.b.b.b where b is a number between 0 and 255.
// for our purposes, b can also be the wildcard character '*'
// we could use a regex to solve this problem but then I would have two problems
// anyways, this is much clearer and maintainable
NSArray* octets = [externalHost componentsSeparatedByString:@"."];
NSUInteger num_octets = [octets count];
// quick check
if (num_octets != 4) {
return NO;
}
// restrict number parsing to 0-255
NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setMinimum:[NSNumber numberWithUnsignedInteger:0]];
[numberFormatter setMaximum:[NSNumber numberWithUnsignedInteger:255]];
// iterate through each octet, and test for a number between 0-255 or if it equals '*'
for (NSUInteger i = 0; i < num_octets; ++i) {
NSString* octet = [octets objectAtIndex:i];
if ([octet isEqualToString:@"*"]) { // passes - check next octet
continue;
} else if ([numberFormatter numberFromString:octet] == nil) { // fails - not a number and not within our range, return
return NO;
}
}
return YES;
}
- (void)addWhiteListEntry:(NSString*)origin
{
if (self.whitelist == nil) {
return;
}
if ([origin isEqualToString:@"*"]) {
NSLog(@"Unlimited access to network resources");
self.whitelist = nil;
self.permittedSchemes = nil;
} else { // specific access
NSRegularExpression* parts = [NSRegularExpression regularExpressionWithPattern:@"^((\\*|[A-Za-z-]+):/?/?)?(((\\*\\.)?[^*/:]+)|\\*)?(:(\\d+))?(/.*)?" options:0 error:nil];
NSTextCheckingResult* m = [parts firstMatchInString:origin options:NSMatchingAnchored range:NSMakeRange(0, [origin length])];
if (m != nil) {
NSRange r;
NSString* scheme = nil;
r = [m rangeAtIndex:2];
if (r.location != NSNotFound) {
scheme = [origin substringWithRange:r];
}
NSString* host = nil;
r = [m rangeAtIndex:3];
if (r.location != NSNotFound) {
host = [origin substringWithRange:r];
}
// Special case for two urls which are allowed to have empty hosts
if (([scheme isEqualToString:@"file"] || [scheme isEqualToString:@"content"]) && (host == nil)) {
host = @"*";
}
NSString* port = nil;
r = [m rangeAtIndex:7];
if (r.location != NSNotFound) {
port = [origin substringWithRange:r];
}
NSString* path = nil;
r = [m rangeAtIndex:8];
if (r.location != NSNotFound) {
path = [origin substringWithRange:r];
}
if (scheme == nil) {
// XXX making it stupid friendly for people who forget to include protocol/SSL
[self.whitelist addObject:[[CDVWhitelistPattern alloc] initWithScheme:@"http" host:host port:port path:path]];
[self.whitelist addObject:[[CDVWhitelistPattern alloc] initWithScheme:@"https" host:host port:port path:path]];
} else {
[self.whitelist addObject:[[CDVWhitelistPattern alloc] initWithScheme:scheme host:host port:port path:path]];
}
if (self.permittedSchemes != nil) {
if ([scheme isEqualToString:@"*"]) {
self.permittedSchemes = nil;
} else if (scheme != nil) {
[self.permittedSchemes addObject:scheme];
}
}
}
}
}
- (BOOL)schemeIsAllowed:(NSString*)scheme
{
if ([scheme isEqualToString:@"http"] ||
[scheme isEqualToString:@"https"] ||
[scheme isEqualToString:@"ftp"] ||
[scheme isEqualToString:@"ftps"]) {
return YES;
}
return (self.permittedSchemes == nil) || [self.permittedSchemes containsObject:scheme];
}
- (BOOL)URLIsAllowed:(NSURL*)url
{
return [self URLIsAllowed:url logFailure:YES];
}
- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure
{
// Shortcut acceptance: Are all urls whitelisted ("*" in whitelist)?
if (whitelist == nil) {
return YES;
}
// Shortcut rejection: Check that the scheme is supported
NSString* scheme = [[url scheme] lowercaseString];
if (![self schemeIsAllowed:scheme]) {
if (logFailure) {
NSLog(@"%@", [self errorStringForURL:url]);
}
return NO;
}
// http[s] and ftp[s] should also validate against the common set in the kCDVDefaultSchemeName list
if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"ftp"] || [scheme isEqualToString:@"ftps"]) {
NSURL* newUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@", kCDVDefaultSchemeName, [url host], [[url path] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
// If it is allowed, we are done. If not, continue to check for the actual scheme-specific list
if ([self URLIsAllowed:newUrl logFailure:NO]) {
return YES;
}
}
// Check the url against patterns in the whitelist
for (CDVWhitelistPattern* p in self.whitelist) {
if ([p matches:url]) {
return YES;
}
}
if (logFailure) {
NSLog(@"%@", [self errorStringForURL:url]);
}
// if we got here, the url host is not in the white-list, do nothing
return NO;
}
- (NSString*)errorStringForURL:(NSURL*)url
{
return [NSString stringWithFormat:self.whitelistRejectionFormatString, [url absoluteString]];
}
@end

View File

@@ -0,0 +1,35 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NSDictionary (CordovaPreferences)
- (id)cordovaSettingForKey:(NSString*)key;
- (BOOL)cordovaBoolSettingForKey:(NSString*)key defaultValue:(BOOL)defaultValue;
- (CGFloat)cordovaFloatSettingForKey:(NSString*)key defaultValue:(CGFloat)defaultValue;
@end
@interface NSMutableDictionary (CordovaPreferences)
- (void)setCordovaSetting:(id)value forKey:(NSString*)key;
@end

View File

@@ -0,0 +1,63 @@
/*
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 "NSDictionary+CordovaPreferences.h"
#import <Foundation/Foundation.h>
@implementation NSDictionary (CordovaPreferences)
- (id)cordovaSettingForKey:(NSString*)key
{
return [self objectForKey:[key lowercaseString]];
}
- (BOOL)cordovaBoolSettingForKey:(NSString*)key defaultValue:(BOOL)defaultValue
{
BOOL value = defaultValue;
id prefObj = [self cordovaSettingForKey:key];
if (prefObj != nil) {
value = [(NSNumber*)prefObj boolValue];
}
return value;
}
- (CGFloat)cordovaFloatSettingForKey:(NSString*)key defaultValue:(CGFloat)defaultValue
{
CGFloat value = defaultValue;
id prefObj = [self cordovaSettingForKey:key];
if (prefObj != nil) {
value = [prefObj floatValue];
}
return value;
}
@end
@implementation NSMutableDictionary (CordovaPreferences)
- (void)setCordovaSetting:(id)value forKey:(NSString*)key
{
[self setObject:value forKey:[key lowercaseString]];
}
@end

View File

@@ -0,0 +1,29 @@
/*
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 NSMutableArray (QueueAdditions)
- (id)cdv_pop;
- (id)cdv_queueHead;
- (id)cdv_dequeue;
- (void)cdv_enqueue:(id)obj;
@end

View File

@@ -0,0 +1,58 @@
/*
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 "NSMutableArray+QueueAdditions.h"
@implementation NSMutableArray (QueueAdditions)
- (id)cdv_queueHead
{
if ([self count] == 0) {
return nil;
}
return [self objectAtIndex:0];
}
- (__autoreleasing id)cdv_dequeue
{
if ([self count] == 0) {
return nil;
}
id head = [self objectAtIndex:0];
if (head != nil) {
// [[head retain] autorelease]; ARC - the __autoreleasing on the return value should so the same thing
[self removeObjectAtIndex:0];
}
return head;
}
- (id)cdv_pop
{
return [self cdv_dequeue];
}
- (void)cdv_enqueue:(id)object
{
[self addObject:object];
}
@end

View File

@@ -0,0 +1,526 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
30193A501AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */; };
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */; };
3093E2231B16D6A3003F381A /* CDVIntentAndNavigationFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3093E2211B16D6A3003F381A /* CDVIntentAndNavigationFilter.h */; };
3093E2241B16D6A3003F381A /* CDVIntentAndNavigationFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3093E2221B16D6A3003F381A /* CDVIntentAndNavigationFilter.m */; };
7E7F69B61ABA35D8007546F4 /* CDVLocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CFB1AB9028C008C4574 /* CDVLocalStorage.h */; };
7E7F69B81ABA368F007546F4 /* CDVUIWebViewEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D001AB9028C008C4574 /* CDVUIWebViewEngine.h */; };
7E7F69B91ABA3692007546F4 /* CDVHandleOpenURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CF81AB9028C008C4574 /* CDVHandleOpenURL.h */; };
7ED95D021AB9028C008C4574 /* CDVDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CF21AB9028C008C4574 /* CDVDebug.h */; };
7ED95D031AB9028C008C4574 /* CDVJSON_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CF31AB9028C008C4574 /* CDVJSON_private.h */; };
7ED95D041AB9028C008C4574 /* CDVJSON_private.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95CF41AB9028C008C4574 /* CDVJSON_private.m */; };
7ED95D051AB9028C008C4574 /* CDVPlugin+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CF51AB9028C008C4574 /* CDVPlugin+Private.h */; };
7ED95D071AB9028C008C4574 /* CDVHandleOpenURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95CF91AB9028C008C4574 /* CDVHandleOpenURL.m */; };
7ED95D091AB9028C008C4574 /* CDVLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95CFC1AB9028C008C4574 /* CDVLocalStorage.m */; };
7ED95D0A1AB9028C008C4574 /* CDVUIWebViewDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CFE1AB9028C008C4574 /* CDVUIWebViewDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D0B1AB9028C008C4574 /* CDVUIWebViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95CFF1AB9028C008C4574 /* CDVUIWebViewDelegate.m */; };
7ED95D0D1AB9028C008C4574 /* CDVUIWebViewEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D011AB9028C008C4574 /* CDVUIWebViewEngine.m */; };
7ED95D351AB9029B008C4574 /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D0F1AB9029B008C4574 /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D361AB9029B008C4574 /* CDVAppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D101AB9029B008C4574 /* CDVAppDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D371AB9029B008C4574 /* CDVAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D111AB9029B008C4574 /* CDVAppDelegate.m */; };
7ED95D381AB9029B008C4574 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D121AB9029B008C4574 /* CDVAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D391AB9029B008C4574 /* CDVAvailabilityDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D131AB9029B008C4574 /* CDVAvailabilityDeprecated.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D3A1AB9029B008C4574 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D141AB9029B008C4574 /* CDVCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D3B1AB9029B008C4574 /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D151AB9029B008C4574 /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D3C1AB9029B008C4574 /* CDVCommandDelegateImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D161AB9029B008C4574 /* CDVCommandDelegateImpl.m */; };
7ED95D3D1AB9029B008C4574 /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D171AB9029B008C4574 /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D3E1AB9029B008C4574 /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D181AB9029B008C4574 /* CDVCommandQueue.m */; };
7ED95D3F1AB9029B008C4574 /* CDVConfigParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D191AB9029B008C4574 /* CDVConfigParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D401AB9029B008C4574 /* CDVConfigParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D1A1AB9029B008C4574 /* CDVConfigParser.m */; };
7ED95D411AB9029B008C4574 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D1B1AB9029B008C4574 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D421AB9029B008C4574 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D1C1AB9029B008C4574 /* CDVInvokedUrlCommand.m */; };
7ED95D431AB9029B008C4574 /* CDVPlugin+Resources.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D1D1AB9029B008C4574 /* CDVPlugin+Resources.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D441AB9029B008C4574 /* CDVPlugin+Resources.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D1E1AB9029B008C4574 /* CDVPlugin+Resources.m */; };
7ED95D451AB9029B008C4574 /* CDVPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D1F1AB9029B008C4574 /* CDVPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D461AB9029B008C4574 /* CDVPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D201AB9029B008C4574 /* CDVPlugin.m */; };
7ED95D471AB9029B008C4574 /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D211AB9029B008C4574 /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D481AB9029B008C4574 /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D221AB9029B008C4574 /* CDVPluginResult.m */; };
7ED95D491AB9029B008C4574 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D4A1AB9029B008C4574 /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D241AB9029B008C4574 /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D4B1AB9029B008C4574 /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D251AB9029B008C4574 /* CDVTimer.m */; };
7ED95D4C1AB9029B008C4574 /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D4D1AB9029B008C4574 /* CDVURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */; };
7ED95D4E1AB9029B008C4574 /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D4F1AB9029B008C4574 /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */; };
7ED95D501AB9029B008C4574 /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2A1AB9029B008C4574 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D511AB9029B008C4574 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D2B1AB9029B008C4574 /* CDVViewController.m */; };
7ED95D521AB9029B008C4574 /* CDVWebViewEngineProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2C1AB9029B008C4574 /* CDVWebViewEngineProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D531AB9029B008C4574 /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D2D1AB9029B008C4574 /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D541AB9029B008C4574 /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D2E1AB9029B008C4574 /* CDVWhitelist.m */; };
7ED95D571AB9029B008C4574 /* NSDictionary+CordovaPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D311AB9029B008C4574 /* NSDictionary+CordovaPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D581AB9029B008C4574 /* NSDictionary+CordovaPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D321AB9029B008C4574 /* NSDictionary+CordovaPreferences.m */; };
7ED95D591AB9029B008C4574 /* NSMutableArray+QueueAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D331AB9029B008C4574 /* NSMutableArray+QueueAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
7ED95D5A1AB9029B008C4574 /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7ED95D341AB9029B008C4574 /* NSMutableArray+QueueAdditions.m */; };
A3B082D41BB15CEA00D8DC35 /* CDVGestureHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = A3B082D21BB15CEA00D8DC35 /* CDVGestureHandler.h */; };
A3B082D51BB15CEA00D8DC35 /* CDVGestureHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A3B082D31BB15CEA00D8DC35 /* CDVGestureHandler.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUIWebViewNavigationDelegate.m; sourceTree = "<group>"; };
30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUIWebViewNavigationDelegate.h; sourceTree = "<group>"; };
30325A0B136B343700982B63 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
3093E2211B16D6A3003F381A /* CDVIntentAndNavigationFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVIntentAndNavigationFilter.h; sourceTree = "<group>"; };
3093E2221B16D6A3003F381A /* CDVIntentAndNavigationFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVIntentAndNavigationFilter.m; sourceTree = "<group>"; };
68A32D7114102E1C006B237C /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; };
7ED95CF21AB9028C008C4574 /* CDVDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVDebug.h; sourceTree = "<group>"; };
7ED95CF31AB9028C008C4574 /* CDVJSON_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVJSON_private.h; sourceTree = "<group>"; };
7ED95CF41AB9028C008C4574 /* CDVJSON_private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVJSON_private.m; sourceTree = "<group>"; };
7ED95CF51AB9028C008C4574 /* CDVPlugin+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CDVPlugin+Private.h"; sourceTree = "<group>"; };
7ED95CF81AB9028C008C4574 /* CDVHandleOpenURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVHandleOpenURL.h; sourceTree = "<group>"; };
7ED95CF91AB9028C008C4574 /* CDVHandleOpenURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVHandleOpenURL.m; sourceTree = "<group>"; };
7ED95CFB1AB9028C008C4574 /* CDVLocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVLocalStorage.h; sourceTree = "<group>"; };
7ED95CFC1AB9028C008C4574 /* CDVLocalStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVLocalStorage.m; sourceTree = "<group>"; };
7ED95CFE1AB9028C008C4574 /* CDVUIWebViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUIWebViewDelegate.h; sourceTree = "<group>"; };
7ED95CFF1AB9028C008C4574 /* CDVUIWebViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUIWebViewDelegate.m; sourceTree = "<group>"; };
7ED95D001AB9028C008C4574 /* CDVUIWebViewEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUIWebViewEngine.h; sourceTree = "<group>"; };
7ED95D011AB9028C008C4574 /* CDVUIWebViewEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUIWebViewEngine.m; sourceTree = "<group>"; };
7ED95D0F1AB9029B008C4574 /* CDV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDV.h; sourceTree = "<group>"; };
7ED95D101AB9029B008C4574 /* CDVAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVAppDelegate.h; sourceTree = "<group>"; };
7ED95D111AB9029B008C4574 /* CDVAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVAppDelegate.m; sourceTree = "<group>"; };
7ED95D121AB9029B008C4574 /* CDVAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVAvailability.h; sourceTree = "<group>"; };
7ED95D131AB9029B008C4574 /* CDVAvailabilityDeprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVAvailabilityDeprecated.h; sourceTree = "<group>"; };
7ED95D141AB9029B008C4574 /* CDVCommandDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVCommandDelegate.h; sourceTree = "<group>"; };
7ED95D151AB9029B008C4574 /* CDVCommandDelegateImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVCommandDelegateImpl.h; sourceTree = "<group>"; };
7ED95D161AB9029B008C4574 /* CDVCommandDelegateImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVCommandDelegateImpl.m; sourceTree = "<group>"; };
7ED95D171AB9029B008C4574 /* CDVCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVCommandQueue.h; sourceTree = "<group>"; };
7ED95D181AB9029B008C4574 /* CDVCommandQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVCommandQueue.m; sourceTree = "<group>"; };
7ED95D191AB9029B008C4574 /* CDVConfigParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVConfigParser.h; sourceTree = "<group>"; };
7ED95D1A1AB9029B008C4574 /* CDVConfigParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVConfigParser.m; sourceTree = "<group>"; };
7ED95D1B1AB9029B008C4574 /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVInvokedUrlCommand.h; sourceTree = "<group>"; };
7ED95D1C1AB9029B008C4574 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
7ED95D1D1AB9029B008C4574 /* CDVPlugin+Resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CDVPlugin+Resources.h"; sourceTree = "<group>"; };
7ED95D1E1AB9029B008C4574 /* CDVPlugin+Resources.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CDVPlugin+Resources.m"; sourceTree = "<group>"; };
7ED95D1F1AB9029B008C4574 /* CDVPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVPlugin.h; sourceTree = "<group>"; };
7ED95D201AB9029B008C4574 /* CDVPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVPlugin.m; sourceTree = "<group>"; };
7ED95D211AB9029B008C4574 /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVPluginResult.h; sourceTree = "<group>"; };
7ED95D221AB9029B008C4574 /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVPluginResult.m; sourceTree = "<group>"; };
7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
7ED95D241AB9029B008C4574 /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVTimer.h; sourceTree = "<group>"; };
7ED95D251AB9029B008C4574 /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVTimer.m; sourceTree = "<group>"; };
7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVURLProtocol.h; sourceTree = "<group>"; };
7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVURLProtocol.m; sourceTree = "<group>"; };
7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUserAgentUtil.h; sourceTree = "<group>"; };
7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUserAgentUtil.m; sourceTree = "<group>"; };
7ED95D2A1AB9029B008C4574 /* CDVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVViewController.h; sourceTree = "<group>"; };
7ED95D2B1AB9029B008C4574 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVViewController.m; sourceTree = "<group>"; };
7ED95D2C1AB9029B008C4574 /* CDVWebViewEngineProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVWebViewEngineProtocol.h; sourceTree = "<group>"; };
7ED95D2D1AB9029B008C4574 /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVWhitelist.h; sourceTree = "<group>"; };
7ED95D2E1AB9029B008C4574 /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVWhitelist.m; sourceTree = "<group>"; };
7ED95D311AB9029B008C4574 /* NSDictionary+CordovaPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+CordovaPreferences.h"; sourceTree = "<group>"; };
7ED95D321AB9029B008C4574 /* NSDictionary+CordovaPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+CordovaPreferences.m"; sourceTree = "<group>"; };
7ED95D331AB9029B008C4574 /* NSMutableArray+QueueAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+QueueAdditions.h"; sourceTree = "<group>"; };
7ED95D341AB9029B008C4574 /* NSMutableArray+QueueAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+QueueAdditions.m"; sourceTree = "<group>"; };
A3B082D21BB15CEA00D8DC35 /* CDVGestureHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVGestureHandler.h; sourceTree = "<group>"; };
A3B082D31BB15CEA00D8DC35 /* CDVGestureHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVGestureHandler.m; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D2AAC07C0554694100DB518D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
034768DFFF38A50411DB9C8B /* Products */ = {
isa = PBXGroup;
children = (
68A32D7114102E1C006B237C /* libCordova.a */,
);
name = Products;
sourceTree = CORDOVALIB;
};
0867D691FE84028FC02AAC07 /* CordovaLib */ = {
isa = PBXGroup;
children = (
7ED95D0E1AB9029B008C4574 /* Public */,
7ED95CF11AB9028C008C4574 /* Private */,
034768DFFF38A50411DB9C8B /* Products */,
30325A0B136B343700982B63 /* VERSION */,
);
name = CordovaLib;
sourceTree = "<group>";
};
3093E2201B16D6A3003F381A /* CDVIntentAndNavigationFilter */ = {
isa = PBXGroup;
children = (
3093E2211B16D6A3003F381A /* CDVIntentAndNavigationFilter.h */,
3093E2221B16D6A3003F381A /* CDVIntentAndNavigationFilter.m */,
);
path = CDVIntentAndNavigationFilter;
sourceTree = "<group>";
};
7ED95CF11AB9028C008C4574 /* Private */ = {
isa = PBXGroup;
children = (
AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */,
7ED95CF21AB9028C008C4574 /* CDVDebug.h */,
7ED95CF31AB9028C008C4574 /* CDVJSON_private.h */,
7ED95CF41AB9028C008C4574 /* CDVJSON_private.m */,
7ED95CF51AB9028C008C4574 /* CDVPlugin+Private.h */,
7ED95CF61AB9028C008C4574 /* Plugins */,
);
name = Private;
path = Classes/Private;
sourceTree = "<group>";
};
7ED95CF61AB9028C008C4574 /* Plugins */ = {
isa = PBXGroup;
children = (
A3B082D11BB15CEA00D8DC35 /* CDVGestureHandler */,
3093E2201B16D6A3003F381A /* CDVIntentAndNavigationFilter */,
7ED95CF71AB9028C008C4574 /* CDVHandleOpenURL */,
7ED95CFA1AB9028C008C4574 /* CDVLocalStorage */,
7ED95CFD1AB9028C008C4574 /* CDVUIWebViewEngine */,
);
path = Plugins;
sourceTree = "<group>";
};
7ED95CF71AB9028C008C4574 /* CDVHandleOpenURL */ = {
isa = PBXGroup;
children = (
7ED95CF81AB9028C008C4574 /* CDVHandleOpenURL.h */,
7ED95CF91AB9028C008C4574 /* CDVHandleOpenURL.m */,
);
path = CDVHandleOpenURL;
sourceTree = "<group>";
};
7ED95CFA1AB9028C008C4574 /* CDVLocalStorage */ = {
isa = PBXGroup;
children = (
7ED95CFB1AB9028C008C4574 /* CDVLocalStorage.h */,
7ED95CFC1AB9028C008C4574 /* CDVLocalStorage.m */,
);
path = CDVLocalStorage;
sourceTree = "<group>";
};
7ED95CFD1AB9028C008C4574 /* CDVUIWebViewEngine */ = {
isa = PBXGroup;
children = (
30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */,
30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */,
7ED95CFE1AB9028C008C4574 /* CDVUIWebViewDelegate.h */,
7ED95CFF1AB9028C008C4574 /* CDVUIWebViewDelegate.m */,
7ED95D001AB9028C008C4574 /* CDVUIWebViewEngine.h */,
7ED95D011AB9028C008C4574 /* CDVUIWebViewEngine.m */,
);
path = CDVUIWebViewEngine;
sourceTree = "<group>";
};
7ED95D0E1AB9029B008C4574 /* Public */ = {
isa = PBXGroup;
children = (
7ED95D0F1AB9029B008C4574 /* CDV.h */,
7ED95D101AB9029B008C4574 /* CDVAppDelegate.h */,
7ED95D111AB9029B008C4574 /* CDVAppDelegate.m */,
7ED95D121AB9029B008C4574 /* CDVAvailability.h */,
7ED95D131AB9029B008C4574 /* CDVAvailabilityDeprecated.h */,
7ED95D141AB9029B008C4574 /* CDVCommandDelegate.h */,
7ED95D151AB9029B008C4574 /* CDVCommandDelegateImpl.h */,
7ED95D161AB9029B008C4574 /* CDVCommandDelegateImpl.m */,
7ED95D171AB9029B008C4574 /* CDVCommandQueue.h */,
7ED95D181AB9029B008C4574 /* CDVCommandQueue.m */,
7ED95D191AB9029B008C4574 /* CDVConfigParser.h */,
7ED95D1A1AB9029B008C4574 /* CDVConfigParser.m */,
7ED95D1B1AB9029B008C4574 /* CDVInvokedUrlCommand.h */,
7ED95D1C1AB9029B008C4574 /* CDVInvokedUrlCommand.m */,
7ED95D1D1AB9029B008C4574 /* CDVPlugin+Resources.h */,
7ED95D1E1AB9029B008C4574 /* CDVPlugin+Resources.m */,
7ED95D1F1AB9029B008C4574 /* CDVPlugin.h */,
7ED95D201AB9029B008C4574 /* CDVPlugin.m */,
7ED95D211AB9029B008C4574 /* CDVPluginResult.h */,
7ED95D221AB9029B008C4574 /* CDVPluginResult.m */,
7ED95D231AB9029B008C4574 /* CDVScreenOrientationDelegate.h */,
7ED95D241AB9029B008C4574 /* CDVTimer.h */,
7ED95D251AB9029B008C4574 /* CDVTimer.m */,
7ED95D261AB9029B008C4574 /* CDVURLProtocol.h */,
7ED95D271AB9029B008C4574 /* CDVURLProtocol.m */,
7ED95D281AB9029B008C4574 /* CDVUserAgentUtil.h */,
7ED95D291AB9029B008C4574 /* CDVUserAgentUtil.m */,
7ED95D2A1AB9029B008C4574 /* CDVViewController.h */,
7ED95D2B1AB9029B008C4574 /* CDVViewController.m */,
7ED95D2C1AB9029B008C4574 /* CDVWebViewEngineProtocol.h */,
7ED95D2D1AB9029B008C4574 /* CDVWhitelist.h */,
7ED95D2E1AB9029B008C4574 /* CDVWhitelist.m */,
7ED95D311AB9029B008C4574 /* NSDictionary+CordovaPreferences.h */,
7ED95D321AB9029B008C4574 /* NSDictionary+CordovaPreferences.m */,
7ED95D331AB9029B008C4574 /* NSMutableArray+QueueAdditions.h */,
7ED95D341AB9029B008C4574 /* NSMutableArray+QueueAdditions.m */,
);
name = Public;
path = Classes/Public;
sourceTree = "<group>";
};
A3B082D11BB15CEA00D8DC35 /* CDVGestureHandler */ = {
isa = PBXGroup;
children = (
A3B082D21BB15CEA00D8DC35 /* CDVGestureHandler.h */,
A3B082D31BB15CEA00D8DC35 /* CDVGestureHandler.m */,
);
path = CDVGestureHandler;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
D2AAC07A0554694100DB518D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
7ED95D521AB9029B008C4574 /* CDVWebViewEngineProtocol.h in Headers */,
7ED95D491AB9029B008C4574 /* CDVScreenOrientationDelegate.h in Headers */,
7ED95D351AB9029B008C4574 /* CDV.h in Headers */,
A3B082D41BB15CEA00D8DC35 /* CDVGestureHandler.h in Headers */,
7ED95D3B1AB9029B008C4574 /* CDVCommandDelegateImpl.h in Headers */,
7ED95D3D1AB9029B008C4574 /* CDVCommandQueue.h in Headers */,
7ED95D531AB9029B008C4574 /* CDVWhitelist.h in Headers */,
7ED95D361AB9029B008C4574 /* CDVAppDelegate.h in Headers */,
7ED95D431AB9029B008C4574 /* CDVPlugin+Resources.h in Headers */,
7ED95D381AB9029B008C4574 /* CDVAvailability.h in Headers */,
7ED95D0A1AB9028C008C4574 /* CDVUIWebViewDelegate.h in Headers */,
7ED95D471AB9029B008C4574 /* CDVPluginResult.h in Headers */,
7ED95D591AB9029B008C4574 /* NSMutableArray+QueueAdditions.h in Headers */,
7ED95D411AB9029B008C4574 /* CDVInvokedUrlCommand.h in Headers */,
7ED95D571AB9029B008C4574 /* NSDictionary+CordovaPreferences.h in Headers */,
7ED95D451AB9029B008C4574 /* CDVPlugin.h in Headers */,
7ED95D4C1AB9029B008C4574 /* CDVURLProtocol.h in Headers */,
7ED95D3A1AB9029B008C4574 /* CDVCommandDelegate.h in Headers */,
7ED95D391AB9029B008C4574 /* CDVAvailabilityDeprecated.h in Headers */,
7ED95D4E1AB9029B008C4574 /* CDVUserAgentUtil.h in Headers */,
7ED95D4A1AB9029B008C4574 /* CDVTimer.h in Headers */,
7ED95D3F1AB9029B008C4574 /* CDVConfigParser.h in Headers */,
7ED95D501AB9029B008C4574 /* CDVViewController.h in Headers */,
7ED95D031AB9028C008C4574 /* CDVJSON_private.h in Headers */,
7ED95D021AB9028C008C4574 /* CDVDebug.h in Headers */,
7ED95D051AB9028C008C4574 /* CDVPlugin+Private.h in Headers */,
7E7F69B61ABA35D8007546F4 /* CDVLocalStorage.h in Headers */,
3093E2231B16D6A3003F381A /* CDVIntentAndNavigationFilter.h in Headers */,
7E7F69B81ABA368F007546F4 /* CDVUIWebViewEngine.h in Headers */,
7E7F69B91ABA3692007546F4 /* CDVHandleOpenURL.h in Headers */,
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
D2AAC07D0554694100DB518D /* CordovaLib */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CordovaLib" */;
buildPhases = (
D2AAC07A0554694100DB518D /* Headers */,
D2AAC07B0554694100DB518D /* Sources */,
D2AAC07C0554694100DB518D /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = CordovaLib;
productName = CordovaLib;
productReference = 68A32D7114102E1C006B237C /* libCordova.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
};
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CordovaLib" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
en,
);
mainGroup = 0867D691FE84028FC02AAC07 /* CordovaLib */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D2AAC07D0554694100DB518D /* CordovaLib */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D2AAC07B0554694100DB518D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7ED95D511AB9029B008C4574 /* CDVViewController.m in Sources */,
7ED95D581AB9029B008C4574 /* NSDictionary+CordovaPreferences.m in Sources */,
7ED95D371AB9029B008C4574 /* CDVAppDelegate.m in Sources */,
7ED95D0B1AB9028C008C4574 /* CDVUIWebViewDelegate.m in Sources */,
7ED95D3C1AB9029B008C4574 /* CDVCommandDelegateImpl.m in Sources */,
7ED95D041AB9028C008C4574 /* CDVJSON_private.m in Sources */,
7ED95D541AB9029B008C4574 /* CDVWhitelist.m in Sources */,
7ED95D421AB9029B008C4574 /* CDVInvokedUrlCommand.m in Sources */,
7ED95D4B1AB9029B008C4574 /* CDVTimer.m in Sources */,
7ED95D4F1AB9029B008C4574 /* CDVUserAgentUtil.m in Sources */,
7ED95D401AB9029B008C4574 /* CDVConfigParser.m in Sources */,
A3B082D51BB15CEA00D8DC35 /* CDVGestureHandler.m in Sources */,
7ED95D071AB9028C008C4574 /* CDVHandleOpenURL.m in Sources */,
30193A501AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m in Sources */,
7ED95D5A1AB9029B008C4574 /* NSMutableArray+QueueAdditions.m in Sources */,
7ED95D3E1AB9029B008C4574 /* CDVCommandQueue.m in Sources */,
7ED95D481AB9029B008C4574 /* CDVPluginResult.m in Sources */,
7ED95D441AB9029B008C4574 /* CDVPlugin+Resources.m in Sources */,
7ED95D4D1AB9029B008C4574 /* CDVURLProtocol.m in Sources */,
7ED95D0D1AB9028C008C4574 /* CDVUIWebViewEngine.m in Sources */,
7ED95D461AB9029B008C4574 /* CDVPlugin.m in Sources */,
7ED95D091AB9028C008C4574 /* CDVLocalStorage.m in Sources */,
3093E2241B16D6A3003F381A /* CDVIntentAndNavigationFilter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
1DEB921F08733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = CordovaLib_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SKIP_INSTALL = YES;
};
name = Debug;
};
1DEB922008733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = CordovaLib_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = Cordova;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SKIP_INSTALL = YES;
};
name = Release;
};
1DEB922308733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DDEBUG";
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
};
1DEB922408733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = NO;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CordovaLib" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB921F08733DC00010E9CD /* Debug */,
1DEB922008733DC00010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CordovaLib" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB922308733DC00010E9CD /* Debug */,
1DEB922408733DC00010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>D2AAC07D0554694100DB518D</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,22 @@
/*
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.
*/
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif

View File

@@ -0,0 +1 @@
4.1.1

1911
msext.xcodeproj/CordovaLib/cordova.js vendored Executable file

File diff suppressed because it is too large Load Diff

1403
msext.xcodeproj/project.pbxproj Normal file → Executable file

File diff suppressed because one or more lines are too long

10
msext.xcodeproj/project.xcworkspace/contents.xcworkspacedata generated Normal file → Executable file
View File

@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:msext.xcodeproj">
</FileRef>
<Group
location = "container:"
name = "niuniu">
<FileRef
location = "self:">
</FileRef>
</Group>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,24 @@
{
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : {
}
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "B724DA36-3662-410A-866B-AD7788BFCC0E",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : "msext\/msext\/Class\/SGGateway\/JSON\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "msext",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "msext.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "svn:\/\/192.168.1.8",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Subversion",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544"
}
]
}

View File

@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<Group
location = "group:CordovaLib"
name = "CordovaLib">
<Group
location = "group:Classes"
name = "Classes">
<Group
location = "group:Private"
name = "Private">
<FileRef
location = "group:CDVDebug.h">
</FileRef>
<FileRef
location = "group:CDVJSON_private.h">
</FileRef>
<FileRef
location = "group:CDVJSON_private.m">
</FileRef>
<FileRef
location = "group:CDVPlugin+Private.h">
</FileRef>
<Group
location = "group:Plugins"
name = "Plugins">
<Group
location = "group:CDVGestureHandler"
name = "CDVGestureHandler">
<FileRef
location = "group:CDVGestureHandler.h">
</FileRef>
<FileRef
location = "group:CDVGestureHandler.m">
</FileRef>
</Group>
<Group
location = "group:CDVHandleOpenURL"
name = "CDVHandleOpenURL">
<FileRef
location = "group:CDVHandleOpenURL.h">
</FileRef>
<FileRef
location = "group:CDVHandleOpenURL.m">
</FileRef>
</Group>
<Group
location = "group:CDVIntentAndNavigationFilter"
name = "CDVIntentAndNavigationFilter">
<FileRef
location = "group:CDVIntentAndNavigationFilter.h">
</FileRef>
<FileRef
location = "group:CDVIntentAndNavigationFilter.m">
</FileRef>
</Group>
<Group
location = "group:CDVLocalStorage"
name = "CDVLocalStorage">
<FileRef
location = "group:CDVLocalStorage.h">
</FileRef>
<FileRef
location = "group:CDVLocalStorage.m">
</FileRef>
</Group>
<Group
location = "group:CDVUIWebViewEngine"
name = "CDVUIWebViewEngine">
<FileRef
location = "group:CDVUIWebViewDelegate.h">
</FileRef>
<FileRef
location = "group:CDVUIWebViewDelegate.m">
</FileRef>
<FileRef
location = "group:CDVUIWebViewEngine.h">
</FileRef>
<FileRef
location = "group:CDVUIWebViewEngine.m">
</FileRef>
<FileRef
location = "group:CDVUIWebViewNavigationDelegate.h">
</FileRef>
<FileRef
location = "group:CDVUIWebViewNavigationDelegate.m">
</FileRef>
</Group>
</Group>
</Group>
<Group
location = "group:Public"
name = "Public">
<FileRef
location = "group:CDV.h">
</FileRef>
<FileRef
location = "group:CDVAppDelegate.h">
</FileRef>
<FileRef
location = "group:CDVAppDelegate.m">
</FileRef>
<FileRef
location = "group:CDVAvailability.h">
</FileRef>
<FileRef
location = "group:CDVAvailabilityDeprecated.h">
</FileRef>
<FileRef
location = "group:CDVCommandDelegate.h">
</FileRef>
<FileRef
location = "group:CDVCommandDelegateImpl.h">
</FileRef>
<FileRef
location = "group:CDVCommandDelegateImpl.m">
</FileRef>
<FileRef
location = "group:CDVCommandQueue.h">
</FileRef>
<FileRef
location = "group:CDVCommandQueue.m">
</FileRef>
<FileRef
location = "group:CDVConfigParser.h">
</FileRef>
<FileRef
location = "group:CDVConfigParser.m">
</FileRef>
<FileRef
location = "group:CDVInvokedUrlCommand.h">
</FileRef>
<FileRef
location = "group:CDVInvokedUrlCommand.m">
</FileRef>
<FileRef
location = "group:CDVPlugin+Resources.h">
</FileRef>
<FileRef
location = "group:CDVPlugin+Resources.m">
</FileRef>
<FileRef
location = "group:CDVPlugin.h">
</FileRef>
<FileRef
location = "group:CDVPlugin.m">
</FileRef>
<FileRef
location = "group:CDVPluginResult.h">
</FileRef>
<FileRef
location = "group:CDVPluginResult.m">
</FileRef>
<FileRef
location = "group:CDVScreenOrientationDelegate.h">
</FileRef>
<FileRef
location = "group:CDVTimer.h">
</FileRef>
<FileRef
location = "group:CDVTimer.m">
</FileRef>
<FileRef
location = "group:CDVURLProtocol.h">
</FileRef>
<FileRef
location = "group:CDVURLProtocol.m">
</FileRef>
<FileRef
location = "group:CDVUserAgentUtil.h">
</FileRef>
<FileRef
location = "group:CDVUserAgentUtil.m">
</FileRef>
<FileRef
location = "group:CDVViewController.h">
</FileRef>
<FileRef
location = "group:CDVViewController.m">
</FileRef>
<FileRef
location = "group:CDVWebViewEngineProtocol.h">
</FileRef>
<FileRef
location = "group:CDVWhitelist.h">
</FileRef>
<FileRef
location = "group:CDVWhitelist.m">
</FileRef>
<FileRef
location = "group:NSDictionary+CordovaPreferences.h">
</FileRef>
<FileRef
location = "group:NSDictionary+CordovaPreferences.m">
</FileRef>
<FileRef
location = "group:NSMutableArray+QueueAdditions.h">
</FileRef>
<FileRef
location = "group:NSMutableArray+QueueAdditions.m">
</FileRef>
</Group>
</Group>
<FileRef
location = "group:cordova.js">
</FileRef>
<FileRef
location = "group:CordovaLib.xcodeproj">
</FileRef>
<FileRef
location = "group:CordovaLib_Prefix.pch">
</FileRef>
<FileRef
location = "group:VERSION">
</FileRef>
</Group>
<FileRef
location = "container:">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,24 @@
{
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : {
}
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "B724DA36-3662-410A-866B-AD7788BFCC0E",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544" : "msext\/msext\/Class\/SGGateway\/JSON\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "msext",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "msext.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "svn:\/\/192.168.1.8",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Subversion",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "e99e2f3d-c644-414d-a7e0-0b2c783b4729++1544"
}
]
}

11
msext/AppDelegate.h Normal file → Executable file
View File

@@ -7,11 +7,18 @@
//
#import <UIKit/UIKit.h>
#import "CustomWindow.h"
#import "HTTPServer.h"
@class RootVC;
@class NewRootVC;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) CustomWindow *window;
@property (strong, nonatomic)RootVC *root;
@property (strong, nonatomic)NewRootVC *newroot;
@property (nonatomic,strong) HTTPServer *localHttpServer;
@property (nonatomic,copy) NSString *port;
@end

340
msext/AppDelegate.m Normal file → Executable file
View File

@@ -7,37 +7,369 @@
//
#import "AppDelegate.h"
@interface AppDelegate ()
#import "RootVC.h"
#import "NewRootVC.h"
#import "NavgationController.h"
#import "WXApi.h"
#import "WXApiManager.h"
#import "ZipArchive.h"
#import "GDataXMLNode.h"
#import "APIKey.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <Bugly/Bugly.h>
#import "RNCachingURLProtocol.h"
#import "JANALYTICSService.h"
#import "XianliaoApiManager.h"
@interface AppDelegate ()<BuglyDelegate>
{
BOOL flag;
}
@property (copy, nonatomic) NSString *gamedir;
@property (copy, nonatomic) NSString *gamestart;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
- (void)configureAPIKey
{
if ([APIKey length] == 0)
{
NSString *reason = [NSString stringWithFormat:@"apiKey为空请检查key是否正确设置。"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:reason delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
[AMapServices sharedServices].apiKey = (NSString *)APIKey;
}
- (void)setupBugly {
// Get the default config
BuglyConfig * config = [[BuglyConfig alloc] init];
// Open the debug mode to print the sdk log message.
// Default value is NO, please DISABLE it in your RELEASE version.
//#if DEBUG
// config.debugMode = YES;
//#endif
// Open the customized log record and report, BuglyLogLevelWarn will report Warn, Error log message.
// Default value is BuglyLogLevelSilent that means DISABLE it.
// You could change the value according to you need.
// config.reportLogLevel = BuglyLogLevelWarn;
// Open the STUCK scene data in MAIN thread record and report.
// Default value is NO
config.blockMonitorEnable = YES;
// Set the STUCK THRESHOLD time, when STUCK time > THRESHOLD it will record an event and report data when the app launched next time.
// Default value is 3.5 second.
config.blockMonitorTimeout = 1.5;
// Set the app channel to deployment
config.channel = @"Bugly";
config.delegate = self;
config.consolelogEnable = YES;
config.viewControllerTrackingEnable = YES;
// [Bugly startWithAppId:@"cff5401df0"];
// NOTE:Required
// Start the Bugly sdk with APP_ID and your config
[Bugly startWithAppId:@"222f47a4ea"
#if DEBUG
developmentDevice:YES
#endif
config:config];
// Set the customizd tag thats config in your APP registerd on the bugly.qq.com
// [Bugly setTag:1799];
[Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];
[Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"Process"];
// NOTE: This is only TEST code for BuglyLog , please UNCOMMENT it in your code.
// [self performSelectorInBackground:@selector(testLogOnBackground) withObject:nil];
}
#pragma mark - BuglyDelegate
- (NSString *)attachmentForException:(NSException *)exception {
NSLog(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
BLYLogError(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
return @"This is an attachment";
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self configureAPIKey];
[self setupBugly];
[XianliaoApiManager registerApp:@"U1jJq3wgWluyB660"];
// [XianliaoApiManager showLog:YES];
//sleep(3);
//[[Countly sharedInstance] start:@"378dfc689042938950dc59a1b98d4ca9a0c48eb0" withHost:@"http://ct.eobook.com"];
//
JANALYTICSLaunchConfig * config = [[JANALYTICSLaunchConfig alloc] init];
config.appKey = @"3752badf07677981decdb7c2";
config.channel = @"tongji";
[JANALYTICSService setupWithConfig:config];
[NSURLProtocol registerClass:[RNCachingURLProtocol class]];
//
NSString *pathagent=[FuncPublic getFilePath:@"gamedir" PathType:3];//
NSFileManager* fm=[NSFileManager defaultManager];
if([fm fileExistsAtPath:pathagent]){
NSArray *files = [fm subpathsAtPath: pathagent ];
NSLog(@"%@",[files objectAtIndex:0]);
self.gamedir= [files objectAtIndex:0];
}
if(1)
{
NSString *pathagent=[FuncPublic getFilePath:@"gamestart" PathType:3];//
NSFileManager* fm=[NSFileManager defaultManager];
if([fm fileExistsAtPath:pathagent]){
NSArray *files = [fm subpathsAtPath: pathagent ];
NSLog(@"%@",[files objectAtIndex:0]);
self.gamestart= [files objectAtIndex:0];
}
}
application.applicationSupportsShakeToEdit = YES;
NSString *path=nil;
path=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@/%@/version.xml",self.gamedir,self.gamestart] PathType:2];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"www/niuniu/version.xml" ofType:nil];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:data options:0 error:nil];
NSArray *array = [doc nodesForXPath:@"/game/version" error:nil];
//CityName
GDataXMLElement *element = [array firstObject];
NSLog(@"name=%@ value=%@",element.name,[element attributeForName:@"value"].stringValue);
if(1)
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
if ([fileManager fileExistsAtPath:filePath]) {
NSLog(@"文件abc.doc存在");
}else
{
NSString *booksDir=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
NSString *zipsDir=[FuncPublic getFilePath:@"zips" PathType:2];
NSString *imagesDir=[FuncPublic getFilePath:@"images" PathType:2];
NSString *cachesDir=[FuncPublic getFilePath:@"caches" PathType:2];
[fileManager createDirectoryAtPath:booksDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:zipsDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:imagesDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:cachesDir withIntermediateDirectories:YES attributes:nil error:nil];
}
[fileManager release];
}
//gameversion>[[element attributeForName:@"value"].stringValue intValue]||
if (data==nil) {
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *filePathwww=[FuncPublic getFilePath:@"gamehall.zip" PathType:3];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
// NSFileManager *fileManager = [[NSFileManager alloc] init];
ZipArchive *zip = [[ZipArchive alloc] init];
if ([zip UnzipOpenFile:filePathwww])
{
if ([zip UnzipFileTo: filePath overWrite:YES])
{
//
}
}
[zip UnzipCloseFile];
[zip release];
[fileManager release];
}
flag=YES;
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"])
{
//
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[FuncPublic SaveDefaultInfo:@"0" Key:@"getcompareCode"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"FirstBOOL"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"SecondBOOL"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"ThirdBOOL"];
self.gamestart= [FuncPublic filename:@"gamestart"];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@/%@/app_gamesname.js",self.gamedir,self.gamestart] PathType:2];
NSString *info=[NSString stringWithFormat:@"var app_gamesname=new Array('%@');",self.gamestart];
NSData *txtData=[info dataUsingEncoding:NSUTF8StringEncoding];
[[NSFileManager defaultManager]createFileAtPath:filePath contents:txtData attributes:nil];
}
[FuncPublic SaveDefaultInfo:@"1.0" Key:@"VersionInfo"];
self.window = [[[CustomWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
if([UIDevice currentDevice].systemVersion.floatValue >= 9.0f) {
_newroot = [[NewRootVC alloc] initWithNibName:@"NewRootVC" bundle:nil];
NavgationController* nav = [[NavgationController alloc] initWithRootViewController:_newroot Navtype:NavgationTypeMaskPortrait];
nav.navigationBarHidden = NO;
self.window.rootViewController = nav;
}else
{
_root = [[RootVC alloc] initWithNibName:@"RootVC" bundle:nil];
NavgationController* nav = [[NavgationController alloc] initWithRootViewController:_root Navtype:NavgationTypeMaskPortrait];
nav.navigationBarHidden = NO;
self.window.rootViewController = nav;
}
application.statusBarHidden=NO;
UIApplication *myApp = [UIApplication sharedApplication];
[myApp setStatusBarStyle: UIStatusBarStyleDefault];
[self.window makeKeyAndVisible];
[WXApi registerApp:@"wxa5fcff77c40d721c" enableMTA:YES];
//
UInt64 typeFlag = MMAPP_SUPPORT_TEXT | MMAPP_SUPPORT_PICTURE | MMAPP_SUPPORT_LOCATION | MMAPP_SUPPORT_VIDEO |MMAPP_SUPPORT_AUDIO | MMAPP_SUPPORT_WEBPAGE | MMAPP_SUPPORT_DOC | MMAPP_SUPPORT_DOCX | MMAPP_SUPPORT_PPT | MMAPP_SUPPORT_PPTX | MMAPP_SUPPORT_XLS | MMAPP_SUPPORT_XLSX | MMAPP_SUPPORT_PDF;
[WXApi registerAppSupportContentFlag:typeFlag];
// [self configLocalHttpServer];
return YES;
}
#pragma mark -- --
#pragma mark -
#pragma mark -
- (void)configLocalHttpServer{
_localHttpServer = [[HTTPServer alloc] init];
[_localHttpServer setType:@"_http.tcp"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = webPathtcp;
NSLog(@">>>>[WebFilePath:]%@",path);
if (![fileManager fileExistsAtPath:webPathtcp]){
NSLog(@">>>> File path error!");
}else{
NSString *webLocalPath = webPathtcp;
[_localHttpServer setDocumentRoot:webLocalPath];
NSLog(@">>webLocalPath:%@",webLocalPath);
[self startServer];
}
}
- (void)startServer
{
NSError *error;
if([_localHttpServer start:&error]){
NSLog(@"Started HTTP Server on port %hu", [_localHttpServer listeningPort]);
self.port = [NSString stringWithFormat:@"%d",[_localHttpServer listeningPort]];
}
else{
NSLog(@"Error starting HTTP Server: %@", error);
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *) error {
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
{
NSLog(@"系统内存不够,请清理应用数据,或者重启应用");
//[FuncPublic ShowAlert:@"系统内存不够,请重启应用"];
}
- (void)networkDidReceiveMessage:(NSNotification *)notification {
}
- (void)dealloc
{
[_window release];
//[_root release];
SG_RELEASE(_root);
SG_RELEASE(_newroot);
[super dealloc];
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
// return;
@try{
[[NSNotificationCenter defaultCenter] postNotificationName:@"enterForeground" object:nil];
} @catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
NSLog(@"enterForeground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// return;
if(flag)
{
flag=NO;
@try{
[[NSNotificationCenter defaultCenter] postNotificationName:@"applicationWillResignActive" object:nil];
} @catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
[self performSelector:@selector(OpenFlag) withObject:nil afterDelay:0.3];
NSLog(@"applicationWillResignActive");
}
}
-(void)OpenFlag
{
flag=YES;
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015年 chao. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="msext" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

Binary file not shown.

View File

@@ -0,0 +1,26 @@
//
// AMapGeoFenceError.h
// AMapLocationKit
//
// Created by eidan on 16/12/15.
// Copyright © 2016年 Amap. All rights reserved.
//
#ifndef AMapGeoFenceError_h
#define AMapGeoFenceError_h
///AMapGeoFence errorDomain
extern NSString * const AMapGeoFenceErrorDomain;
///地理围栏错误码
typedef NS_ENUM(NSInteger, AMapGeoFenceErrorCode) {
AMapGeoFenceErrorUnknown = 1, ///< 未知错误
AMapGeoFenceErrorInvalidParameter = 2, ///< 参数错误
AMapGeoFenceErrorFailureConnection = 3, ///< 网络连接异常
AMapGeoFenceErrorFailureAuth = 4, ///< 鉴权失败
AMapGeoFenceErrorNoValidFence = 5, ///< 无可用围栏
AMapGeoFenceErroFailureLocating = 6, ///< 定位错误
};
#endif /* AMapGeoFenceError_h */

View File

@@ -0,0 +1,211 @@
//
// AMapGeoFenceManager.h
// AMapLocationKit
//
// Created by hanxiaoming on 16/12/5.
// Copyright © 2016年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AMapGeoFenceRegionObj.h"
// 以下类涉及的坐标需要使用高德坐标系坐标(GCJ02)
@protocol AMapGeoFenceManagerDelegate;
///地理围栏监听状态类型
typedef NS_OPTIONS(NSUInteger, AMapGeoFenceActiveAction)
{
AMapGeoFenceActiveActionNone = 0, ///< 不进行监听
AMapGeoFenceActiveActionInside = 1 << 0, ///< 在范围内
AMapGeoFenceActiveActionOutside = 1 << 1, ///< 在范围外
AMapGeoFenceActiveActionStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
};
///地理围栏任务状态类型
typedef NS_OPTIONS(NSUInteger, AMapGeoFenceRegionActiveStatus)
{
AMapGeoFenceRegionActiveUNMonitor = 0, ///< 未注册
AMapGeoFenceRegionActiveMonitoring = 1 << 0, ///< 正在监控
AMapGeoFenceRegionActivePaused = 1 << 1, ///< 暂停监控
};
///地理围栏管理类since 2.3.0
@interface AMapGeoFenceManager : NSObject
///实现了 AMapGeoFenceManagerDelegate 协议的类指针。
@property (nonatomic, weak) id<AMapGeoFenceManagerDelegate> delegate;
///需要进行通知的行为默认为AMapGeoFenceActiveActionInside。
@property (nonatomic, assign) AMapGeoFenceActiveAction activeAction;
///指定定位是否会被系统自动暂停。默认为NO。
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
///检测是否存在虚拟定位风险默认为NO即不检测。 \n如果设置为YES检测到风险后会通过amapGeoFenceManager:didGeoFencesStatusChangedForRegion:customID:error: 的error给出风险提示error的格式为error.domain==AMapGeoFenceErrorDomain; error.code==AMapGeoFenceErroFailureLocating;
@property (nonatomic, assign) BOOL detectRiskOfFakeLocation;
/**
* @brief 添加一个圆形围栏
* @param center 围栏的中心点经纬度坐标
* @param radius 围栏的半径单位要求大于0
* @param customID 用户自定义ID可选SDK原值返回
*/
- (void)addCircleRegionForMonitoringWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius customID:(NSString *)customID;
/**
* @brief 根据经纬度坐标数据添加一个闭合的多边形围栏,点与点之间按顺序尾部相连, 第一个点与最后一个点相连
* @param coordinates 经纬度坐标点数据,coordinates对应的内存会拷贝,调用者负责该内存的释放
* @param count 经纬度坐标点的个数不可小于3个
* @param customID 用户自定义ID可选SDK原值返回
*/
- (void)addPolygonRegionForMonitoringWithCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSInteger)count customID:(NSString *)customID;
/**
* @brief 根据要查询的关键字类型城市等信息添加一个或者多个POI地理围栏
* @param keyword 要查询的关键字,多个关键字用“|”分割必填keyword和type两者至少必选其一
* @param type 要查询的POI类型多个类型用“|”分割必填keyword和type两者至少必选其一具体分类编码和规则详见 http://lbs.amap.com/api/webservice/guide/api/search/#text
* @param city 要查询的城市
* @param size 要查询的数据的条数,(0,25],传入<=0的值为10传入大于25的值为25默认10
* @param customID 用户自定义ID可选SDK原值返回
*/
- (void)addKeywordPOIRegionForMonitoringWithKeyword:(NSString *)keyword POIType:(NSString *)type city:(NSString *)city size:(NSInteger)size customID:(NSString *)customID;
/**
* @brief 根据要查询的点的经纬度搜索半径等信息添加一个或者多个POI围栏
* @param locationPoint 点的经纬度坐标,必填
* @param aroundRadius 查询半径,单位:米,(0,50000]超出范围取3000默认3000
* @param keyword 要查询的关键字,多个关键字用“|”分割,可选
* @param type 要查询的POI类型多个类型用“|”分割,可选
* @param size 要查询的数据的条数,(0,25],传入<=0的值为10传入大于25的值为25默认10
* @param customID 用户自定义ID可选SDK原值返回
*/
- (void)addAroundPOIRegionForMonitoringWithLocationPoint:(CLLocationCoordinate2D)locationPoint aroundRadius:(NSInteger)aroundRadius keyword:(NSString *)keyword POIType:(NSString *)type size:(NSInteger)size customID:(NSString *)customID;
/**
* @brief 根据要查询的行政区域关键字,添加一个或者多个行政区域围栏
* @param districtName 行政区域关键字必填只支持单个关键词语行政区名称、citycode、adcode规则详见 http://lbs.amap.com/api/webservice/guide/api/district/#district
* @param customID 用户自定义ID可选SDK原值返回
*/
- (void)addDistrictRegionForMonitoringWithDistrictName:(NSString *)districtName customID:(NSString *)customID;
/**
* @brief 获取指定围栏的运行状态
* @param region 要获取运行状态的围栏
* @return 返回指定围栏的运行状态
*/
- (AMapGeoFenceRegionActiveStatus)statusWithGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief 根据customID获得所有已经注册的围栏如果customID传nil则返回全部已注册围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @return 获得的围栏构成的数组如果没有结果返回nil
*/
- (NSArray *)geoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 根据customID获得所有正在监控的围栏如果customID传nil则返回全部正在监控的围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @return 获得的围栏构成的数组如果没有结果返回nil
*/
- (NSArray *)monitoringGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 根据customID获得所有已经暂停的围栏如果customID传nil则返回全部已经暂停的围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @return 获得的围栏构成的数组如果没有结果返回nil
*/
- (NSArray *)pausedGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 暂停指定customID的围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @return 返回被暂停围栏的数组如果没有围栏被暂停返回nil
*/
- (NSArray *)pauseGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 暂停指定围栏
* @param region 要暂停监控的围栏
* @return 返回指定围栏是否被暂停如果指定围栏没有注册则返回NO
*/
- (BOOL)pauseTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief 根据customID开始监控已经暂停的围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @return 返回开始监控的围栏构成的数组
*/
- (NSArray *)startGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 开始监控指定围栏
* @param region 要开始监控的围栏
* @return 返回指定围栏是否开始监控如果指定围栏没有注册则返回NO
*/
- (BOOL)startTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief 移除指定围栏
* @param region 要停止监控的围栏
*/
- (void)removeTheGeoFenceRegion:(AMapGeoFenceRegion *)region;
/**
* @brief 移除指定customID的围栏
* @param customID 用户执行添加围栏函数时传入的customID
*/
- (void)removeGeoFenceRegionsWithCustomID:(NSString *)customID;
/**
* @brief 移除所有围栏
*/
- (void)removeAllGeoFenceRegions;
@end
///地理围栏代理协议since 2.3.0,该协议定义了获取地理围栏相关回调方法,包括添加、状态改变等。
@protocol AMapGeoFenceManagerDelegate <NSObject>
@optional
/**
* @brief 添加地理围栏完成后的回调,成功与失败都会调用
* @param manager 地理围栏管理类
* @param regions 成功添加的一个或多个地理围栏构成的数组
* @param customID 用户执行添加围栏函数时传入的customID
* @param error 添加失败的错误信息
*/
- (void)amapGeoFenceManager:(AMapGeoFenceManager *)manager didAddRegionForMonitoringFinished:(NSArray <AMapGeoFenceRegion *> *)regions customID:(NSString *)customID error:(NSError *)error;
/**
* @brief 地理围栏状态改变时回调,当围栏状态的值发生改变,定位失败都会调用
* @param manager 地理围栏管理类
* @param region 状态改变的地理围栏
* @param customID 用户执行添加围栏函数时传入的customID
* @param error 错误信息,如定位相关的错误
*/
- (void)amapGeoFenceManager:(AMapGeoFenceManager *)manager didGeoFencesStatusChangedForRegion:(AMapGeoFenceRegion *)region customID:(NSString *)customID error:(NSError *)error;
@end

View File

@@ -0,0 +1,120 @@
//
// AMapGeoFenceRegionObj.h
// AMapLocationKit
//
// Created by hanxiaoming on 16/12/5.
// Copyright © 2016年 Amap. All rights reserved.
//
#import "AMapLocationCommonObj.h"
///AMapGeoFence Region State
typedef NS_ENUM(NSInteger, AMapGeoFenceRegionStatus)
{
AMapGeoFenceRegionStatusUnknown = 0, ///< 未知
AMapGeoFenceRegionStatusInside = 1, ///< 在范围内
AMapGeoFenceRegionStatusOutside = 2, ///< 在范围外
AMapGeoFenceRegionStatusStayed = 3, ///< 停留(在范围内超过10分钟)
};
typedef NS_ENUM(NSInteger, AMapGeoFenceRegionType)
{
AMapGeoFenceRegionTypeCircle = 0, /// 圆形地理围栏
AMapGeoFenceRegionTypePolygon = 1, /// 多边形地理围栏
AMapGeoFenceRegionTypePOI = 2, /// 兴趣点POI地理围栏
AMapGeoFenceRegionTypeDistrict = 3, /// 行政区划地理围栏
};
#pragma mark - AMapGeoFenceRegion
///地理围栏基类不可直接使用。since 2.3.0
@interface AMapGeoFenceRegion : NSObject<NSCopying>
///AMapGeoFenceRegion的唯一标识符
@property (nonatomic, copy, readonly) NSString *identifier;
///用户自定义ID可为nil。
@property (nonatomic, copy, readonly) NSString *customID;
///坐标点和围栏的关系,比如用户的位置和围栏的关系
@property (nonatomic, assign) AMapGeoFenceRegionStatus fenceStatus;
///用户自定义ID可为nil。
@property (nonatomic, assign) AMapGeoFenceRegionType regionType;
///缓存最近获取的定位信息可能会存在延时可为nil会在获取定位时更新
@property (nonatomic, copy) CLLocation *currentLocation;
@end
#pragma mark - AMapLocationCircleRegion
///圆形地理围栏since 2.3.0
@interface AMapGeoFenceCircleRegion : AMapGeoFenceRegion
///中心点的经纬度坐标
@property (nonatomic, readonly) CLLocationCoordinate2D center;
///半径,单位:米
@property (nonatomic, readonly) CLLocationDistance radius;
@end
#pragma mark -AMapGeoFencePolygonRegion
///多边形地理围栏since 2.3.0
@interface AMapGeoFencePolygonRegion : AMapGeoFenceRegion
///经纬度坐标点数据
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates;
///经纬度坐标点的个数
@property (nonatomic, readonly) NSInteger count;
@end
#pragma mark -AMapGeoFencePOIRegion
///兴趣点POI地理围栏since 2.3.0
@interface AMapGeoFencePOIRegion : AMapGeoFenceCircleRegion
///POI信息
@property (nonatomic, strong, readonly) AMapLocationPOIItem *POIItem;
@end
#pragma mark -AMapGeoFenceDistrictRegion
///行政区划地理围栏since 2.3.0
@interface AMapGeoFenceDistrictRegion : AMapGeoFenceRegion
///行政区域信息
@property (nonatomic, strong, readonly) AMapLocationDistrictItem *districtItem;
///行政区域轮廓坐标点,每个行政区可能有多个模块,每个模块的坐标点数组由AMapLocationPoint构成
@property (nonatomic, copy, readonly) NSArray <NSArray<AMapLocationPoint *> *> *polylinePoints;
@end

View File

@@ -0,0 +1,194 @@
//
// AMapLocationCommonObj.h
// AMapLocationKit
//
// Created by AutoNavi on 15/10/22.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
///AMapLocation errorDomain
extern NSString * const AMapLocationErrorDomain;
///AMapLocation errorCode
typedef NS_ENUM(NSInteger, AMapLocationErrorCode)
{
AMapLocationErrorUnknown = 1, ///<未知错误
AMapLocationErrorLocateFailed = 2, ///<定位错误
AMapLocationErrorReGeocodeFailed = 3, ///<逆地理错误
AMapLocationErrorTimeOut = 4, ///<超时
AMapLocationErrorCanceled = 5, ///<取消
AMapLocationErrorCannotFindHost = 6, ///<找不到主机
AMapLocationErrorBadURL = 7, ///<URL异常
AMapLocationErrorNotConnectedToInternet = 8,///<连接异常
AMapLocationErrorCannotConnectToHost = 9, ///<服务器连接失败
AMapLocationErrorRegionMonitoringFailure=10,///<地理围栏错误
AMapLocationErrorRiskOfFakeLocation = 11, ///<存在虚拟定位风险
};
///AMapLocation Region State
typedef NS_ENUM(NSInteger, AMapLocationRegionState)
{
AMapLocationRegionStateUnknow = 0, ///<未知
AMapLocationRegionStateInside = 1, ///<在范围内
AMapLocationRegionStateOutside = 2, ///<在范围外
};
///AMapLocation Region Language
typedef NS_ENUM(NSInteger, AMapLocationReGeocodeLanguage)
{
AMapLocationReGeocodeLanguageDefault = 0, ///<默认,根据地区选择语言
AMapLocationReGeocodeLanguageChinse = 1, ///<中文
AMapLocationReGeocodeLanguageEnglish = 2, ///<英文
};
///逆地理信息
@interface AMapLocationReGeocode : NSObject<NSCopying,NSCoding>
///格式化地址
@property (nonatomic, copy) NSString *formattedAddress;
///国家
@property (nonatomic, copy) NSString *country;
///省/直辖市
@property (nonatomic, copy) NSString *province;
///市
@property (nonatomic, copy) NSString *city;
///区
@property (nonatomic, copy) NSString *district;
///乡镇
@property (nonatomic, copy) NSString *township __attribute__((deprecated("该字段从v2.2.0版本起不再返回数据,建议您使用AMapSearchKit的逆地理功能获取.")));
///社区
@property (nonatomic, copy) NSString *neighborhood __attribute__((deprecated("该字段从v2.2.0版本起不再返回数据,建议您使用AMapSearchKit的逆地理功能获取.")));
///建筑
@property (nonatomic, copy) NSString *building __attribute__((deprecated("该字段从v2.2.0版本起不再返回数据,建议您使用AMapSearchKit的逆地理功能获取.")));
///城市编码
@property (nonatomic, copy) NSString *citycode;
///区域编码
@property (nonatomic, copy) NSString *adcode;
///街道名称
@property (nonatomic, copy) NSString *street;
///门牌号
@property (nonatomic, copy) NSString *number;
///兴趣点名称
@property (nonatomic, copy) NSString *POIName;
///所属兴趣点名称
@property (nonatomic, copy) NSString *AOIName;
@end
#pragma mark - AMapLocationPoint
///经纬度坐标点对象
@interface AMapLocationPoint : NSObject<NSCopying,NSCoding>
///纬度
@property (nonatomic, assign) CGFloat latitude;
///经度
@property (nonatomic, assign) CGFloat longitude;
/**
* @brief AMapNaviPoint类对象的初始化函数
* @param lat 纬度
* @param lon 经度
* @return AMapNaviPoint类对象id
*/
+ (AMapLocationPoint *)locationWithLatitude:(CGFloat)lat longitude:(CGFloat)lon;
@end
///POI信息
@interface AMapLocationPOIItem : NSObject <NSCopying, NSCoding>
///id
@property (nonatomic, copy) NSString *pId;
///名称
@property (nonatomic, copy) NSString *name;
///类型
@property (nonatomic, copy) NSString *type;
///类型编码
@property (nonatomic, copy) NSString *typeCode;
///地址信息
@property (nonatomic, copy) NSString *address;
///经纬度
@property (nonatomic, strong) AMapLocationPoint *location;
///电话号码
@property (nonatomic, copy) NSString *tel;
///省份
@property (nonatomic, copy) NSString *province;
///城市
@property (nonatomic, copy) NSString *city;
///区
@property (nonatomic, copy) NSString *district;
@end
///行政区域信息
@interface AMapLocationDistrictItem : NSObject <NSCopying, NSCoding>
///城市编码
@property (nonatomic, copy) NSString *cityCode;
///区域编码
@property (nonatomic, copy) NSString *districtCode;
///区名
@property (nonatomic, copy) NSString *district;
///行政区域轮廓坐标点,每个行政区可能有多个模块,每个模块的坐标点数组由AMapLocationPoint构成
@property (nonatomic, copy) NSArray <NSArray<AMapLocationPoint *> *> *polylinePoints;
@end
///AMapLocation CoordinateType
typedef NS_ENUM(NSUInteger, AMapLocationCoordinateType)
{
AMapLocationCoordinateTypeBaidu = 0, ///<Baidu
AMapLocationCoordinateTypeMapBar, ///<MapBar
AMapLocationCoordinateTypeMapABC, ///<MapABC
AMapLocationCoordinateTypeSoSoMap, ///<SoSoMap
AMapLocationCoordinateTypeAliYun, ///<AliYun
AMapLocationCoordinateTypeGoogle, ///<Google
AMapLocationCoordinateTypeGPS, ///<GPS
};
/**
* @brief 转换目标经纬度为高德坐标系
* @param coordinate 待转换的经纬度
* @param type 坐标系类型
* @return 高德坐标系经纬度
*/
FOUNDATION_EXTERN CLLocationCoordinate2D AMapLocationCoordinateConvert(CLLocationCoordinate2D coordinate, AMapLocationCoordinateType type);
/**
* @brief 判断目标经纬度是否在大陆以及港、澳地区。输入参数为高德坐标系。
* @param coordinate 待判断的目标经纬度
* @return 是否在大陆以及港、澳地区
*/
FOUNDATION_EXTERN BOOL AMapLocationDataAvailableForCoordinate(CLLocationCoordinate2D coordinate);

View File

@@ -0,0 +1,17 @@
//
// AMapLocationKit.h
// AMapLocationKit
//
// Created by AutoNavi on 15/10/22.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <AMapLocationKit/AMapLocationVersion.h>
#import <AMapLocationKit/AMapLocationManager.h>
#import <AMapLocationKit/AMapLocationCommonObj.h>
#import <AMapLocationKit/AMapLocationRegionObj.h>
#import <AMapLocationKit/AMapGeoFenceRegionObj.h>
#import <AMapLocationKit/AMapGeoFenceManager.h>
#import <AMapLocationKit/AMapGeoFenceError.h>

View File

@@ -0,0 +1,208 @@
//
// AMapLocationManager.h
// AMapLocationKit
//
// Created by AutoNavi on 15/10/22.
// Copyright © 2015年 Amap. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AMapLocationCommonObj.h"
#import "AMapLocationRegionObj.h"
/**
* @brief AMapLocatingCompletionBlock 单次定位返回Block
* @param location 定位信息
* @param regeocode 逆地理信息
* @param error 错误信息,参考 AMapLocationErrorCode
*/
typedef void (^AMapLocatingCompletionBlock)(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error);
@protocol AMapLocationManagerDelegate;
#pragma mark - AMapLocationManager
///AMapLocationManager类。初始化之前请设置 AMapServices 中的apikey(例如:[AMapServices sharedServices].apiKey = @"您的key"),否则将无法正常使用服务.
@interface AMapLocationManager : NSObject
///实现了 AMapLocationManagerDelegate 协议的类指针。
@property (nonatomic, weak) id<AMapLocationManagerDelegate> delegate;
///设定定位的最小更新距离。单位米,默认为 kCLDistanceFilterNone表示只要检测到设备位置发生变化就会更新位置信息。
@property(nonatomic, assign) CLLocationDistance distanceFilter;
///设定期望的定位精度。单位米,默认为 kCLLocationAccuracyBest。定位服务会尽可能去获取满足desiredAccuracy的定位结果但不保证一定会得到满足期望的结果。 \n注意设置为kCLLocationAccuracyBest或kCLLocationAccuracyBestForNavigation时单次定位会在达到locationTimeout设定的时间后将时间内获取到的最高精度的定位结果返回。
@property(nonatomic, assign) CLLocationAccuracy desiredAccuracy;
///指定定位是否会被系统自动暂停。默认为NO。
@property(nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态否则会抛出异常。由于iOS系统限制需要在定位未开始之前或定位停止之后修改该属性的值才会有效果。
@property(nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
///指定单次定位超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。注意: 单次定位超时时间从确定了定位权限(非kCLAuthorizationStatusNotDetermined状态)后开始计算。
@property(nonatomic, assign) NSInteger locationTimeout;
///指定单次定位逆地理超时时间,默认为5s。最小值是2s。注意单次定位请求前设置。
@property(nonatomic, assign) NSInteger reGeocodeTimeout;
///连续定位是否返回逆地理信息默认NO。
@property (nonatomic, assign) BOOL locatingWithReGeocode;
// 逆地址语言类型默认是AMapLocationRegionLanguageDefault
@property (nonatomic, assign) AMapLocationReGeocodeLanguage reGeocodeLanguage;
///获取被监控的region集合。
@property (nonatomic, readonly, copy) NSSet *monitoredRegions;
///检测是否存在虚拟定位风险默认为NO不检测。 \n注意:设置为YES时单次定位通过 AMapLocatingCompletionBlock 的error给出虚拟定位风险提示连续定位通过 amapLocationManager:didFailWithError: 方法的error给出虚拟定位风险提示。error格式为error.domain==AMapLocationErrorDomain; error.code==AMapLocationErrorRiskOfFakeLocation;
@property (nonatomic, assign) BOOL detectRiskOfFakeLocation;
/**
* @brief 设备是否支持方向识别
* @return YES:设备支持方向识别 ; NO:设备不支持支持方向识别
*/
+ (BOOL)headingAvailable;
/**
* @brief 开始获取设备朝向,如果设备支持方向识别,则会通过代理回调方法
*/
- (void)startUpdatingHeading;
/**
* @brief 停止获取设备朝向
*/
- (void)stopUpdatingHeading;
/**
* @brief 停止设备朝向校准显示
*/
- (void)dismissHeadingCalibrationDisplay;
/**
* @brief 单次定位。如果当前正在连续定位调用此方法将会失败返回NO。\n该方法将会根据设定的 desiredAccuracy 去获取定位信息。如果获取的定位信息精确度低于 desiredAccuracy 将会持续的等待定位信息直到超时后通过completionBlock返回精度最高的定位信息。\n可以通过 stopUpdatingLocation 方法去取消正在进行的单次定位请求。
* @param withReGeocode 是否带有逆地理信息(获取逆地理信息需要联网)
* @param completionBlock 单次定位完成后的Block
* @return 是否成功添加单次定位Request
*/
- (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode completionBlock:(AMapLocatingCompletionBlock)completionBlock;
/**
* @brief 开始连续定位。调用此方法会cancel掉所有的单次定位请求。
*/
- (void)startUpdatingLocation;
/**
* @brief 停止连续定位。调用此方法会cancel掉所有的单次定位请求可以用来取消单次定位。
*/
- (void)stopUpdatingLocation;
/**
* @brief 开始监控指定的region。如果已经存在相同identifier的region则之前的region将会被移除。对 AMapLocationCircleRegion 类实例将会优先监控radius小的region。
* @param region 要被监控的范围
*/
- (void)startMonitoringForRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 停止监控指定的region
* @param region 要停止监控的范围
*/
- (void)stopMonitoringForRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 查询一个region的当前状态。查询结果通过amapLocationManager:didDetermineState:forRegion:回调返回
* @param region 要查询的region
*/
- (void)requestStateForRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
@end
#pragma mark - AMapLocationManagerDelegate
///AMapLocationManagerDelegate 协议定义了发生错误时的错误回调方法,连续定位的回调方法等。
@protocol AMapLocationManagerDelegate <NSObject>
@optional
/**
* @brief 当定位发生错误时,会调用代理的此方法。
* @param manager 定位 AMapLocationManager 类。
* @param error 返回的错误,参考 CLError 。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didFailWithError:(NSError *)error;
/**
* @brief 连续定位回调函数.注意本方法已被废弃如果实现了amapLocationManager:didUpdateLocation:reGeocode:方法,则本方法将不会回调。
* @param manager 定位 AMapLocationManager 类。
* @param location 定位结果。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location;
/**
* @brief 连续定位回调函数.注意如果实现了本方法则定位信息不会通过amapLocationManager:didUpdateLocation:方法回调。
* @param manager 定位 AMapLocationManager 类。
* @param location 定位结果。
* @param reGeocode 逆地理信息。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode;
/**
* @brief 定位权限状态改变时回调函数
* @param manager 定位 AMapLocationManager 类。
* @param status 定位权限状态。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
/**
* @brief 是否显示设备朝向校准
* @param manager 定位 AMapLocationManager 类。
* @return 是否显示设备朝向校准
*/
- (BOOL)amapLocationManagerShouldDisplayHeadingCalibration:(AMapLocationManager *)manager;
/**
* @brief 设备方向改变时回调函数
* @param manager 定位 AMapLocationManager 类。
* @param newHeading 设备朝向。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading;
/**
* @brief 开始监控region回调函数
* @param manager 定位 AMapLocationManager 类。
* @param region 开始监控的region。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didStartMonitoringForRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 进入region回调函数
* @param manager 定位 AMapLocationManager 类。
* @param region 进入的region。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didEnterRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 离开region回调函数
* @param manager 定位 AMapLocationManager 类。
* @param region 离开的region。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didExitRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 查询region状态回调函数
* @param manager 定位 AMapLocationManager 类。
* @param state 查询的region的状态。
* @param region 查询的region。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager didDetermineState:(AMapLocationRegionState)state forRegion:(AMapLocationRegion *)region __attribute__((deprecated("请使用AMapGeoFenceManager")));
/**
* @brief 监控region失败回调函数
* @param manager 定位 AMapLocationManager 类。
* @param region 失败的region。
* @param error 错误信息,参考 AMapLocationErrorCode 。
*/
- (void)amapLocationManager:(AMapLocationManager *)manager monitoringDidFailForRegion:(AMapLocationRegion *)region withError:(NSError *)error __attribute__((deprecated("请使用AMapGeoFenceManager")));
@end

View File

@@ -0,0 +1,90 @@
//
// AMapLocationRegionObj.h
// AMapLocationKit
//
// Created by AutoNavi on 15/11/27.
// Copyright © 2015年 Amap. All rights reserved.
//
#import "AMapLocationCommonObj.h"
// 以下类涉及的坐标需要使用高德坐标系坐标(GCJ02)
#pragma mark - AMapLocationRegion
///AMapLocationRegion类该类提供范围类的基本信息并无具体实现不要直接使用。
@interface AMapLocationRegion : NSObject<NSCopying>
///AMapLocationRegion的identifier
@property (nonatomic, copy, readonly) NSString *identifier;
///当进入region范围时是否通知默认YES
@property (nonatomic, assign) BOOL notifyOnEntry;
///当离开region范围时是否通知默认YES
@property (nonatomic, assign) BOOL notifyOnExit;
/**
* @brief 初始化方法
* @param identifier 唯一标识符必填不可为nil
*/
- (instancetype)initWithIdentifier:(NSString *)identifier;
/**
* @brief 坐标点是否在范围内
* @param coordinate 要判断的坐标点
* @return 是否在范围内
*/
- (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate;
@end
#pragma mark - AMapLocationCircleRegion
///AMapLocationCircleRegion类定义一个圆形范围。
@interface AMapLocationCircleRegion : AMapLocationRegion
///中心点的经纬度坐标
@property (nonatomic, readonly) CLLocationCoordinate2D center;
///半径,单位:米
@property (nonatomic, readonly) CLLocationDistance radius;
/**
* @brief 根据中心点和半径生成圆形范围
* @param center 中心点的经纬度坐标
* @param radius 半径,单位:米
* @param identifier 唯一标识符必填不可为nil
* @return AMapLocationCircleRegion类实例
*/
- (instancetype)initWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius identifier:(NSString *)identifier;
@end
#pragma mark - AMapLocationPolygonRegion
///AMapLocationCircleRegion类定义一个闭合多边形范围点与点之间按顺序尾部相连, 第一个点与最后一个点相连。
@interface AMapLocationPolygonRegion : AMapLocationRegion
///经纬度坐标点数据
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates;
///经纬度坐标点的个数
@property (nonatomic, readonly) NSInteger count;
/**
* @brief 根据经纬度坐标数据生成闭合多边形范围
* @param coordinates 经纬度坐标点数据,coordinates对应的内存会拷贝,调用者负责该内存的释放
* @param count 经纬度坐标点的个数不可小于3个
* @param identifier 唯一标识符必填不可为nil
* @return AMapLocationCircleRegion类实例
*/
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSInteger)count identifier:(NSString *)identifier;
@end

View File

@@ -0,0 +1,26 @@
//
// AMapLoctionVersion.h
// AMapLocationKit
//
// Created by AutoNavi on 16/1/22.
// Copyright © 2016年 Amap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AMapFoundationKit/AMapFoundationVersion.h>
#ifndef AMapLoctionVersion_h
#define AMapLoctionVersion_h
#define AMapLocationVersionNumber 20600
#define AMapLocationFoundationVersionMinRequired 10400
// 依赖库版本检测
#if AMapFoundationVersionNumber < AMapLocationFoundationVersionMinRequired
#error "The AMapFoundationKit version is less than minimum required, please update! Any questions please to visit http://lbs.amap.com"
#endif
FOUNDATION_EXTERN NSString * const AMapLocationVersion;
FOUNDATION_EXTERN NSString * const AMapLocationName;
#endif /* AMapLoctionVersion_h */

View File

@@ -0,0 +1 @@
2.6.0+loc.1b6dee7

16
msext/Class/Common/APIKey.h Executable file
View File

@@ -0,0 +1,16 @@
//
// APIKey.h
// OfficialDemoLoc
//
// Created by AutoNavi on 15-9-14.
// Copyright (c) 2013年 AutoNavi. All rights reserved.
//
#ifndef OfficialDemoLoc_APIKey_h
#define OfficialDemoLoc_APIKey_h
/* 使用高德地图API请注册Key注册地址http://lbs.amap.com/console/key */
const static NSString *APIKey = @"b0d4a8e3fcbbcc0dd96283b7df6a4494";
#endif

View File

@@ -0,0 +1,125 @@
K 25
svn:wc:ra_dav:version-url
V 96
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest
END
ASIHTTPRequest.m
K 25
svn:wc:ra_dav:version-url
V 113
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIHTTPRequest.m
END
ASICacheDelegate.h
K 25
svn:wc:ra_dav:version-url
V 115
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASICacheDelegate.h
END
ASINetworkQueue.h
K 25
svn:wc:ra_dav:version-url
V 114
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASINetworkQueue.h
END
ASIDataDecompressor.h
K 25
svn:wc:ra_dav:version-url
V 118
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDataDecompressor.h
END
ASIAuthenticationDialog.h
K 25
svn:wc:ra_dav:version-url
V 122
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIAuthenticationDialog.h
END
ASIProgressDelegate.h
K 25
svn:wc:ra_dav:version-url
V 118
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIProgressDelegate.h
END
ASIDownloadCache.m
K 25
svn:wc:ra_dav:version-url
V 115
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDownloadCache.m
END
ASINetworkQueue.m
K 25
svn:wc:ra_dav:version-url
V 114
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASINetworkQueue.m
END
ASIDataDecompressor.m
K 25
svn:wc:ra_dav:version-url
V 118
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDataDecompressor.m
END
ASIAuthenticationDialog.m
K 25
svn:wc:ra_dav:version-url
V 122
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIAuthenticationDialog.m
END
ASIFormDataRequest.h
K 25
svn:wc:ra_dav:version-url
V 117
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIFormDataRequest.h
END
ASIFormDataRequest.m
K 25
svn:wc:ra_dav:version-url
V 117
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIFormDataRequest.m
END
ASIInputStream.h
K 25
svn:wc:ra_dav:version-url
V 113
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIInputStream.h
END
ASIHTTPRequestConfig.h
K 25
svn:wc:ra_dav:version-url
V 119
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIHTTPRequestConfig.h
END
ASIInputStream.m
K 25
svn:wc:ra_dav:version-url
V 113
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIInputStream.m
END
ASIHTTPRequestDelegate.h
K 25
svn:wc:ra_dav:version-url
V 121
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIHTTPRequestDelegate.h
END
ASIDataCompressor.h
K 25
svn:wc:ra_dav:version-url
V 116
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDataCompressor.h
END
ASIHTTPRequest.h
K 25
svn:wc:ra_dav:version-url
V 113
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIHTTPRequest.h
END
ASIDownloadCache.h
K 25
svn:wc:ra_dav:version-url
V 115
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDownloadCache.h
END
ASIDataCompressor.m
K 25
svn:wc:ra_dav:version-url
V 116
/svn/com.mouee.ios/!svn/ver/133/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest/ASIDataCompressor.m
END

View File

@@ -0,0 +1,708 @@
10
dir
158
https://192.168.1.108/svn/com.mouee.ios/release/trunk/MoueeIOS/Release/Release/ThirdParty/ASIHttpRequest
https://192.168.1.108/svn/com.mouee.ios
2012-08-25T07:41:16.910000Z
133
liwei
edcb6c81-38c0-4a4f-bab3-e02b3f82dc25
ASIHTTPRequest.m
file
2012-03-07T19:00:34.000000Z
e531997a6084a6d359b96e30128e010d
2012-08-25T07:41:16.910000Z
133
liwei
has-props
184635
ASICacheDelegate.h
file
2012-03-07T19:00:34.000000Z
d7eecaf775884aeec419c1dd6c912b75
2012-08-25T07:41:16.910000Z
133
liwei
has-props
5151
ASINetworkQueue.h
file
2012-03-07T19:00:34.000000Z
ac37fbe46f31892abdb9c43b6a249a84
2012-08-25T07:41:16.910000Z
133
liwei
has-props
4621
ASIDataDecompressor.h
file
2012-03-07T19:00:34.000000Z
b880ed0fc75896beb31676009dc308c6
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1699
ASIAuthenticationDialog.h
file
2012-03-07T19:00:34.000000Z
09ef51b980d0a69951c9c703722e97e8
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1107
ASIProgressDelegate.h
file
2012-03-07T19:00:34.000000Z
64de5fd485dbff9e73cce2a127dc32c3
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1656
ASIDownloadCache.m
file
2012-03-07T19:00:34.000000Z
042086ef61b2bf5f2a66b6e028287a89
2012-08-25T07:41:16.910000Z
133
liwei
has-props
17761
ASINetworkQueue.m
file
2012-03-07T19:00:34.000000Z
569c65f4d7e0c056c5b4ca01d947a741
2012-08-25T07:41:16.910000Z
133
liwei
has-props
11405
ASIDataDecompressor.m
file
2012-03-07T19:00:34.000000Z
8a44db8841a09d03799cd45e88ab50f8
2012-08-25T07:41:16.910000Z
133
liwei
has-props
6422
ASIAuthenticationDialog.m
file
2012-03-07T19:00:34.000000Z
22eb729c54171d2f7ca520c31cef8161
2012-08-25T07:41:16.910000Z
133
liwei
has-props
16202
ASIFormDataRequest.h
file
2012-03-07T19:00:34.000000Z
4908e5f063ee8462fbd762118d1170b8
2012-08-25T07:41:16.910000Z
133
liwei
has-props
2693
ASIFormDataRequest.m
file
2012-03-07T19:00:34.000000Z
87407eed67b1863eca711047c94f2edb
2012-08-25T07:41:16.910000Z
133
liwei
has-props
11266
ASIInputStream.h
file
2012-03-07T19:00:34.000000Z
7ca1696b1598349cc98a65f602df591c
2012-08-25T07:41:16.910000Z
133
liwei
has-props
969
ASIHTTPRequestConfig.h
file
2012-03-07T19:00:34.000000Z
5b18b6c019e4caef9a7062531a5e6fb3
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1297
ASIInputStream.m
file
2012-03-07T19:00:34.000000Z
0f064667b55c487982cfdd23134864cb
2012-08-25T07:41:16.910000Z
133
liwei
has-props
3122
ASIHTTPRequestDelegate.h
file
2012-03-07T19:00:34.000000Z
680deee08e40ed1ac50e18b33bd52347
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1598
ASIDataCompressor.h
file
2012-03-07T19:00:34.000000Z
a4028d2d356cda229eacaca26981622f
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1836
ASIHTTPRequest.h
file
2012-03-07T19:00:34.000000Z
bda45d2c138c16845bc900370fbb7bd4
2012-08-25T07:41:16.910000Z
133
liwei
has-props
45045
ASIDownloadCache.h
file
2012-03-07T19:00:34.000000Z
e597b80f6e26c3fe263612a879088e3d
2012-08-25T07:41:16.910000Z
133
liwei
has-props
1996
ASIDataCompressor.m
file
2012-03-07T19:00:34.000000Z
862e169e15d182c2ee3c5a3ace39c449
2012-08-25T07:41:16.910000Z
133
liwei
has-props
6755

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

View File

@@ -0,0 +1,5 @@
K 14
svn:executable
V 1
*
END

Some files were not shown because too many files have changed in this diff Show More