@situm/cordova 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/CHANGELOG_UNRELEASED.md +28 -0
- package/Jenkinsfile +84 -0
- package/LICENSE +21 -0
- package/README.md +472 -0
- package/azure/common-steps.yaml +5 -0
- package/azure-pipelines.yml +336 -0
- package/docs/JSDoc/MapView.html +300 -0
- package/docs/JSDoc/MapViewControllerImpl.html +299 -0
- package/docs/JSDoc/Situm.html +5257 -0
- package/docs/JSDoc/android_Interfaces.js.html +825 -0
- package/docs/JSDoc/android_situm.js.html +380 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.eot +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.svg +288 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/docs/JSDoc/global.html +7538 -0
- package/docs/JSDoc/img/toast-ui.png +0 -0
- package/docs/JSDoc/index.html +90 -0
- package/docs/JSDoc/map-view-controller.js.html +307 -0
- package/docs/JSDoc/map-view.js.html +172 -0
- package/docs/JSDoc/scripts/jquery.min.js +2 -0
- package/docs/JSDoc/scripts/linenumber.js +30 -0
- package/docs/JSDoc/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/JSDoc/scripts/prettify/lang-css.js +2 -0
- package/docs/JSDoc/scripts/prettify/prettify.js +28 -0
- package/docs/JSDoc/scripts/tui-doc.js +200 -0
- package/docs/JSDoc/styles/bootstrap.min.css +6 -0
- package/docs/JSDoc/styles/custom.css +23 -0
- package/docs/JSDoc/styles/prettify-jsdoc.css +111 -0
- package/docs/JSDoc/styles/prettify-tomorrow.css +132 -0
- package/docs/JSDoc/styles/tui-doc.css +485 -0
- package/docs/conf.json +28 -0
- package/docs/getting-started.md +298 -0
- package/docs/imagotype-SITUM-transparent-90.png +0 -0
- package/docs/static/styles/custom.css +23 -0
- package/package.json +60 -0
- package/plugin.xml +102 -0
- package/scripts/update_changelog.sh +22 -0
- package/src/android/app/build.gradle +51 -0
- package/src/android/app/proguard-rules.pro +21 -0
- package/src/android/app/src/main/AndroidManifest.xml +11 -0
- package/src/android/app/src/main/java/es/situm/plugin/DateUtils.java +15 -0
- package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +919 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +968 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +109 -0
- package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/values/colors.xml +6 -0
- package/src/android/app/src/main/res/values/strings.xml +3 -0
- package/src/android/app/src/main/res/values/styles.xml +11 -0
- package/src/android/app/src/test/java/es/situm/plugin/PluginHelperTest.java +27 -0
- package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +1485 -0
- package/src/android/app/src/test/java/es/situm/plugin/angle/AngleCreator.java +46 -0
- package/src/android/app/src/test/java/es/situm/plugin/bounds/BoundsCreator.java +50 -0
- package/src/android/app/src/test/java/es/situm/plugin/building/BuildingCreator.java +76 -0
- package/src/android/app/src/test/java/es/situm/plugin/cartesianCoordinate/CartesianCoordinateCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/circle/CircleCreator.java +41 -0
- package/src/android/app/src/test/java/es/situm/plugin/coordinate/CoordinateCreator.java +32 -0
- package/src/android/app/src/test/java/es/situm/plugin/dimensions/DimensionsCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/directionsRequest/DirectionsRequestCreator.java +105 -0
- package/src/android/app/src/test/java/es/situm/plugin/event/EventCreator.java +108 -0
- package/src/android/app/src/test/java/es/situm/plugin/floor/FloorCreator.java +58 -0
- package/src/android/app/src/test/java/es/situm/plugin/indication/IndicationCreator.java +40 -0
- package/src/android/app/src/test/java/es/situm/plugin/location/LocationCreator.java +197 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationRequest/LocationRequestCreator.java +45 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationStatus/LocationStatusCreator.java +211 -0
- package/src/android/app/src/test/java/es/situm/plugin/navigationProgress/NavigationProgressCreator.java +154 -0
- package/src/android/app/src/test/java/es/situm/plugin/poi/PoiCreator.java +126 -0
- package/src/android/app/src/test/java/es/situm/plugin/poiCategory/PoiCategoryCreator.java +38 -0
- package/src/android/app/src/test/java/es/situm/plugin/point/PointCreator.java +200 -0
- package/src/android/app/src/test/java/es/situm/plugin/route/RouteCreator.java +142 -0
- package/src/android/app/src/test/java/es/situm/plugin/routeStep/RouteStepCreator.java +173 -0
- package/src/android/app/src/test/java/es/situm/plugin/situmConversionArea/SitumConversionAreaCreator.java +35 -0
- package/src/android/build.gradle +31 -0
- package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/android/gradle.properties +16 -0
- package/src/android/gradlew +172 -0
- package/src/android/gradlew.bat +84 -0
- package/src/android/settings.gradle +3 -0
- package/src/android/situm.gradle +19 -0
- package/src/ios/Classes/Private/CDVDebug.h +25 -0
- package/src/ios/Classes/Private/CDVJSON_private.h +31 -0
- package/src/ios/Classes/Private/CDVJSON_private.m +99 -0
- package/src/ios/Classes/Private/CDVPlugin+Private.h +24 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.m +70 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.m +86 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h +34 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m +153 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.h +50 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.m +487 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.m +37 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h +41 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m +399 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m +202 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h +29 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m +153 -0
- package/src/ios/Classes/Public/CDV.h +32 -0
- package/src/ios/Classes/Public/CDVAppDelegate.h +28 -0
- package/src/ios/Classes/Public/CDVAppDelegate.m +118 -0
- package/src/ios/Classes/Public/CDVAvailability.h +111 -0
- package/src/ios/Classes/Public/CDVAvailabilityDeprecated.h +26 -0
- package/src/ios/Classes/Public/CDVCommandDelegate.h +51 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.h +36 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.m +186 -0
- package/src/ios/Classes/Public/CDVCommandQueue.h +39 -0
- package/src/ios/Classes/Public/CDVCommandQueue.m +194 -0
- package/src/ios/Classes/Public/CDVConfigParser.h +30 -0
- package/src/ios/Classes/Public/CDVConfigParser.m +81 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.h +52 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.m +116 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.h +39 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.m +38 -0
- package/src/ios/Classes/Public/CDVPlugin.h +85 -0
- package/src/ios/Classes/Public/CDVPlugin.m +202 -0
- package/src/ios/Classes/Public/CDVPluginResult.h +66 -0
- package/src/ios/Classes/Public/CDVPluginResult.m +186 -0
- package/src/ios/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
- package/src/ios/Classes/Public/CDVTimer.h +27 -0
- package/src/ios/Classes/Public/CDVTimer.m +123 -0
- package/src/ios/Classes/Public/CDVURLProtocol.h +27 -0
- package/src/ios/Classes/Public/CDVURLProtocol.m +113 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.h +27 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.m +124 -0
- package/src/ios/Classes/Public/CDVViewController.h +92 -0
- package/src/ios/Classes/Public/CDVViewController.m +821 -0
- package/src/ios/Classes/Public/CDVWebViewEngineProtocol.h +42 -0
- package/src/ios/Classes/Public/CDVWhitelist.h +34 -0
- package/src/ios/Classes/Public/CDVWhitelist.m +285 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.h +29 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.m +58 -0
- package/src/ios/Cordova/Cordova.h +51 -0
- package/src/ios/Cordova/Info.plist +24 -0
- package/src/ios/Podfile +5 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.pbxproj +1324 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/xcshareddata/xcschemes/CordovaLib.xcscheme +100 -0
- package/src/ios/SitumCordovaPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin_Prefix.pch +22 -0
- package/src/ios/VERSION +1 -0
- package/src/ios/cordova.js +2432 -0
- package/src/ios/situmcordovaplugin/AppDelegate.h +22 -0
- package/src/ios/situmcordovaplugin/AppDelegate.m +98 -0
- package/src/ios/situmcordovaplugin/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/src/ios/situmcordovaplugin/Base.lproj/LaunchScreen.storyboard +25 -0
- package/src/ios/situmcordovaplugin/Base.lproj/Main.storyboard +24 -0
- package/src/ios/situmcordovaplugin/Constants.h +14 -0
- package/src/ios/situmcordovaplugin/Constants.m +14 -0
- package/src/ios/situmcordovaplugin/Info.plist +45 -0
- package/src/ios/situmcordovaplugin/SITUtils.h +7 -0
- package/src/ios/situmcordovaplugin/SITUtils.m +13 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.h +109 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +983 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.h +41 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.m +752 -0
- package/src/ios/situmcordovaplugin/ViewController.h +15 -0
- package/src/ios/situmcordovaplugin/ViewController.m +29 -0
- package/src/ios/situmcordovaplugin/main.m +16 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/.xccurrentversion +8 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/situmcordovaplugin.xcdatamodel/contents +4 -0
- package/src/ios/situmcordovaplugintests/AngleTests.m +53 -0
- package/src/ios/situmcordovaplugintests/BoundTests.m +51 -0
- package/src/ios/situmcordovaplugintests/BuildingTests.m +41 -0
- package/src/ios/situmcordovaplugintests/CartesianCoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/ConversionAreaTests.m +43 -0
- package/src/ios/situmcordovaplugintests/CoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/DimensionTests.m +43 -0
- package/src/ios/situmcordovaplugintests/EventTests.m +42 -0
- package/src/ios/situmcordovaplugintests/FloorTests.m +52 -0
- package/src/ios/situmcordovaplugintests/Info.plist +38 -0
- package/src/ios/situmcordovaplugintests/InputTests/DirectionsRequestTest.m +108 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCartesianCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputFloorTests.m +59 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputIndicationTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputLocationTests.m +163 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPoiCategoryTests.m +46 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPointTests.m +137 -0
- package/src/ios/situmcordovaplugintests/InputTests/LocationRequestTest.m +79 -0
- package/src/ios/situmcordovaplugintests/LocationStatusTests.m +60 -0
- package/src/ios/situmcordovaplugintests/LocationTests.m +114 -0
- package/src/ios/situmcordovaplugintests/NavigationProgressTests.m +50 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryIconTests.m +43 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryTests.m +42 -0
- package/src/ios/situmcordovaplugintests/PoiTests.m +83 -0
- package/src/ios/situmcordovaplugintests/PointTests.m +107 -0
- package/src/ios/situmcordovaplugintests/RouteStepTests.m +78 -0
- package/src/ios/situmcordovaplugintests/RouteTests.m +42 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.h +91 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.m +928 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.h +48 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.m +342 -0
- package/src/ios/situmcordovaplugintests/indicationTests.m +43 -0
- package/tests/common-resources/angle/angle1.json +6 -0
- package/tests/common-resources/angle/angle2.json +6 -0
- package/tests/common-resources/bounds/bounds1.json +18 -0
- package/tests/common-resources/bounds/bounds2.json +18 -0
- package/tests/common-resources/building/building1.json +64 -0
- package/tests/common-resources/cartesianCoordinate/cartesianCoordinate1.json +4 -0
- package/tests/common-resources/circle/circle1.json +17 -0
- package/tests/common-resources/coordinate/coordinate1.json +4 -0
- package/tests/common-resources/dimensions/dimensions1.json +4 -0
- package/tests/common-resources/directionsRequest/directionsRequest1.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest2.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest3.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest4.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest5.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest6.json +153 -0
- package/tests/common-resources/events/event1.json +66 -0
- package/tests/common-resources/floor/floor1.json +13 -0
- package/tests/common-resources/floor/floor2.json +13 -0
- package/tests/common-resources/indication/indication1.json +10 -0
- package/tests/common-resources/location/location1.json +48 -0
- package/tests/common-resources/location/location10.json +48 -0
- package/tests/common-resources/location/location2.json +48 -0
- package/tests/common-resources/location/location3.json +48 -0
- package/tests/common-resources/location/location4.json +48 -0
- package/tests/common-resources/location/location5.json +48 -0
- package/tests/common-resources/location/location6.json +48 -0
- package/tests/common-resources/location/location7.json +48 -0
- package/tests/common-resources/location/location8.json +48 -0
- package/tests/common-resources/location/location9.json +48 -0
- package/tests/common-resources/locationRequest/locationRequest1.json +6 -0
- package/tests/common-resources/locationRequest/locationRequest2.json +32 -0
- package/tests/common-resources/locationRequest/locationRequest3.json +33 -0
- package/tests/common-resources/locationRequest/locationRequest4.json +31 -0
- package/tests/common-resources/locationStatus/locationStatus1.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus10.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus11.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus12.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus13.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus2.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus3.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus4.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus5.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus6.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus7.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus8.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus9.json +4 -0
- package/tests/common-resources/navigationProgress/navigationProgress1.json +77 -0
- package/tests/common-resources/navigationProgress/navigationProgress2.json +77 -0
- package/tests/common-resources/poi/poi1.json +35 -0
- package/tests/common-resources/poi/poi2.json +35 -0
- package/tests/common-resources/poi/poi3.json +35 -0
- package/tests/common-resources/poi/poi4.json +38 -0
- package/tests/common-resources/poi/poi5.json +35 -0
- package/tests/common-resources/poiCategory/poiCategory1.json +7 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.json +1 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.png +0 -0
- package/tests/common-resources/point/point1.json +14 -0
- package/tests/common-resources/point/point2.json +14 -0
- package/tests/common-resources/point/point3.json +14 -0
- package/tests/common-resources/point/point4.json +14 -0
- package/tests/common-resources/point/point5.json +14 -0
- package/tests/common-resources/point/point6.json +14 -0
- package/tests/common-resources/point/point7.json +14 -0
- package/tests/common-resources/point/point8.json +14 -0
- package/tests/common-resources/route/route1.json +530 -0
- package/tests/common-resources/routeStep/routeStep1.json +35 -0
- package/tests/common-resources/routeStep/routeStep2.json +35 -0
- package/tests/common-resources/routeStep/routeStep3.json +35 -0
- package/tests/common-resources/routeStep/routeStep4.json +35 -0
- package/tests/common-resources/routeStep/routeStep5.json +35 -0
- package/tests/common-resources/situmConversionArea/situmConversionArea1.json +19 -0
- package/tests/js/resources/fetchBuildings.json +176 -0
- package/tests/js/resources/fetchEventsFromBuilding.json +201 -0
- package/tests/js/resources/fetchFloorsFromBuilding.json +34 -0
- package/tests/js/resources/fetchIndoorPOIsFromBuilding.json +574 -0
- package/tests/js/resources/fetchMapFromFloor.json +3 -0
- package/tests/js/resources/fetchOutdoorPOIsFromBuilding.json +68 -0
- package/tests/js/resources/fetchPoiCategories.json +72 -0
- package/tests/js/resources/fetchPoiCategoryIconNormal.json +3 -0
- package/tests/js/resources/fetchPoiCategoryIconSelected.json +3 -0
- package/tests/js/resources/requestDirections.json +1167 -0
- package/tests/js/resources/startPositioning/0_starting.json +4 -0
- package/tests/js/resources/startPositioning/1_preparingPositioningModel.json +4 -0
- package/tests/js/resources/startPositioning/2_startingPositioning.json +4 -0
- package/tests/js/resources/startPositioning/3_calculating.json +4 -0
- package/tests/js/resources/startPositioning/4_position.json +48 -0
- package/tests/js/resources/startPositioning/5_position.json +48 -0
- package/tests/js/test.js +416 -0
- package/tests/scripts/clean_android_resources.sh +3 -0
- package/tests/scripts/clean_ios_resources.sh +3 -0
- package/tests/scripts/copy_android_resources.sh +3 -0
- package/tests/scripts/copy_ios_resources.sh +3 -0
- package/tests/scripts/self-destruct.sh +1 -0
- package/www/android/Interfaces.js +742 -0
- package/www/android/situm.js +296 -0
- package/www/ios/situm.js +99 -0
- package/www/map-view-controller.js +223 -0
- package/www/map-view.js +88 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import "CDVPluginResult.h"
|
|
21
|
+
#import "CDVJSON_private.h"
|
|
22
|
+
#import "CDVDebug.h"
|
|
23
|
+
|
|
24
|
+
@interface CDVPluginResult ()
|
|
25
|
+
|
|
26
|
+
- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage;
|
|
27
|
+
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation CDVPluginResult
|
|
31
|
+
@synthesize status, message, keepCallback, associatedObject;
|
|
32
|
+
|
|
33
|
+
static NSArray* org_apache_cordova_CommandStatusMsgs;
|
|
34
|
+
|
|
35
|
+
id messageFromArrayBuffer(NSData* data)
|
|
36
|
+
{
|
|
37
|
+
return @{
|
|
38
|
+
@"CDVType" : @"ArrayBuffer",
|
|
39
|
+
@"data" :[data base64EncodedStringWithOptions:0]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
id massageMessage(id message)
|
|
44
|
+
{
|
|
45
|
+
if ([message isKindOfClass:[NSData class]]) {
|
|
46
|
+
return messageFromArrayBuffer(message);
|
|
47
|
+
}
|
|
48
|
+
return message;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
id messageFromMultipart(NSArray* theMessages)
|
|
52
|
+
{
|
|
53
|
+
NSMutableArray* messages = [NSMutableArray arrayWithArray:theMessages];
|
|
54
|
+
|
|
55
|
+
for (NSUInteger i = 0; i < messages.count; ++i) {
|
|
56
|
+
[messages replaceObjectAtIndex:i withObject:massageMessage([messages objectAtIndex:i])];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return @{
|
|
60
|
+
@"CDVType" : @"MultiPart",
|
|
61
|
+
@"messages" : messages
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
+ (void)initialize
|
|
66
|
+
{
|
|
67
|
+
org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects:@"No result",
|
|
68
|
+
@"OK",
|
|
69
|
+
@"Class not found",
|
|
70
|
+
@"Illegal access",
|
|
71
|
+
@"Instantiation error",
|
|
72
|
+
@"Malformed url",
|
|
73
|
+
@"IO error",
|
|
74
|
+
@"Invalid action",
|
|
75
|
+
@"JSON error",
|
|
76
|
+
@"Error",
|
|
77
|
+
nil];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (CDVPluginResult*)init
|
|
81
|
+
{
|
|
82
|
+
return [self initWithStatus:CDVCommandStatus_NO_RESULT message:nil];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage
|
|
86
|
+
{
|
|
87
|
+
self = [super init];
|
|
88
|
+
if (self) {
|
|
89
|
+
status = [NSNumber numberWithInt:statusOrdinal];
|
|
90
|
+
message = theMessage;
|
|
91
|
+
keepCallback = [NSNumber numberWithBool:NO];
|
|
92
|
+
}
|
|
93
|
+
return self;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal
|
|
97
|
+
{
|
|
98
|
+
return [[self alloc] initWithStatus:statusOrdinal message:nil];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage
|
|
102
|
+
{
|
|
103
|
+
return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage
|
|
107
|
+
{
|
|
108
|
+
return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage
|
|
112
|
+
{
|
|
113
|
+
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInt:theMessage]];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSInteger:(NSInteger)theMessage
|
|
117
|
+
{
|
|
118
|
+
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInteger:theMessage]];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage
|
|
122
|
+
{
|
|
123
|
+
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithUnsignedInteger:theMessage]];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage
|
|
127
|
+
{
|
|
128
|
+
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage
|
|
132
|
+
{
|
|
133
|
+
return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithBool:theMessage]];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
|
|
137
|
+
{
|
|
138
|
+
return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage
|
|
142
|
+
{
|
|
143
|
+
return [[self alloc] initWithStatus:statusOrdinal message:messageFromArrayBuffer(theMessage)];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages
|
|
147
|
+
{
|
|
148
|
+
return [[self alloc] initWithStatus:statusOrdinal message:messageFromMultipart(theMessages)];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
|
|
152
|
+
{
|
|
153
|
+
NSDictionary* errDict = @{@"code" :[NSNumber numberWithInt:errorCode]};
|
|
154
|
+
|
|
155
|
+
return [[self alloc] initWithStatus:statusOrdinal message:errDict];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback
|
|
159
|
+
{
|
|
160
|
+
[self setKeepCallback:[NSNumber numberWithBool:bKeepCallback]];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
- (NSString*)argumentsAsJSON
|
|
164
|
+
{
|
|
165
|
+
id arguments = (self.message == nil ? [NSNull null] : self.message);
|
|
166
|
+
NSArray* argumentsWrappedInArray = [NSArray arrayWithObject:arguments];
|
|
167
|
+
|
|
168
|
+
NSString* argumentsJSON = [argumentsWrappedInArray cdv_JSONString];
|
|
169
|
+
|
|
170
|
+
argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length] - 2)];
|
|
171
|
+
|
|
172
|
+
return argumentsJSON;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static BOOL gIsVerbose = NO;
|
|
176
|
+
+ (void)setVerbose:(BOOL)verbose
|
|
177
|
+
{
|
|
178
|
+
gIsVerbose = verbose;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
+ (BOOL)isVerbose
|
|
182
|
+
{
|
|
183
|
+
return gIsVerbose;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
|
|
22
|
+
@protocol CDVScreenOrientationDelegate <NSObject>
|
|
23
|
+
|
|
24
|
+
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
|
|
25
|
+
- (NSUInteger)supportedInterfaceOrientations;
|
|
26
|
+
#else
|
|
27
|
+
- (UIInterfaceOrientationMask)supportedInterfaceOrientations;
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
|
|
31
|
+
- (BOOL)shouldAutorotate;
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
|
|
22
|
+
@interface CDVTimer : NSObject
|
|
23
|
+
|
|
24
|
+
+ (void)start:(NSString*)name;
|
|
25
|
+
+ (void)stop:(NSString*)name;
|
|
26
|
+
|
|
27
|
+
@end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import "CDVTimer.h"
|
|
21
|
+
|
|
22
|
+
#pragma mark CDVTimerItem
|
|
23
|
+
|
|
24
|
+
@interface CDVTimerItem : NSObject
|
|
25
|
+
|
|
26
|
+
@property (nonatomic, strong) NSString* name;
|
|
27
|
+
@property (nonatomic, strong) NSDate* started;
|
|
28
|
+
@property (nonatomic, strong) NSDate* ended;
|
|
29
|
+
|
|
30
|
+
- (void)log;
|
|
31
|
+
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
@implementation CDVTimerItem
|
|
35
|
+
|
|
36
|
+
- (void)log
|
|
37
|
+
{
|
|
38
|
+
NSLog(@"[CDVTimer][%@] %fms", self.name, [self.ended timeIntervalSinceDate:self.started] * 1000.0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@end
|
|
42
|
+
|
|
43
|
+
#pragma mark CDVTimer
|
|
44
|
+
|
|
45
|
+
@interface CDVTimer ()
|
|
46
|
+
|
|
47
|
+
@property (nonatomic, strong) NSMutableDictionary* items;
|
|
48
|
+
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
@implementation CDVTimer
|
|
52
|
+
|
|
53
|
+
#pragma mark object methods
|
|
54
|
+
|
|
55
|
+
- (id)init
|
|
56
|
+
{
|
|
57
|
+
if (self = [super init]) {
|
|
58
|
+
self.items = [NSMutableDictionary dictionaryWithCapacity:6];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return self;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void)add:(NSString*)name
|
|
65
|
+
{
|
|
66
|
+
if ([self.items objectForKey:[name lowercaseString]] == nil) {
|
|
67
|
+
CDVTimerItem* item = [CDVTimerItem new];
|
|
68
|
+
item.name = name;
|
|
69
|
+
item.started = [NSDate new];
|
|
70
|
+
[self.items setObject:item forKey:[name lowercaseString]];
|
|
71
|
+
} else {
|
|
72
|
+
NSLog(@"Timer called '%@' already exists.", name);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void)remove:(NSString*)name
|
|
77
|
+
{
|
|
78
|
+
CDVTimerItem* item = [self.items objectForKey:[name lowercaseString]];
|
|
79
|
+
|
|
80
|
+
if (item != nil) {
|
|
81
|
+
item.ended = [NSDate new];
|
|
82
|
+
[item log];
|
|
83
|
+
[self.items removeObjectForKey:[name lowercaseString]];
|
|
84
|
+
} else {
|
|
85
|
+
NSLog(@"Timer called '%@' does not exist.", name);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
- (void)removeAll
|
|
90
|
+
{
|
|
91
|
+
[self.items removeAllObjects];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#pragma mark class methods
|
|
95
|
+
|
|
96
|
+
+ (void)start:(NSString*)name
|
|
97
|
+
{
|
|
98
|
+
[[CDVTimer sharedInstance] add:name];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
+ (void)stop:(NSString*)name
|
|
102
|
+
{
|
|
103
|
+
[[CDVTimer sharedInstance] remove:name];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
+ (void)clearAll
|
|
107
|
+
{
|
|
108
|
+
[[CDVTimer sharedInstance] removeAll];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
+ (CDVTimer*)sharedInstance
|
|
112
|
+
{
|
|
113
|
+
static dispatch_once_t pred = 0;
|
|
114
|
+
__strong static CDVTimer* _sharedObject = nil;
|
|
115
|
+
|
|
116
|
+
dispatch_once(&pred, ^{
|
|
117
|
+
_sharedObject = [[self alloc] init];
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return _sharedObject;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
#import "CDVAvailability.h"
|
|
22
|
+
|
|
23
|
+
@class CDVViewController;
|
|
24
|
+
|
|
25
|
+
@interface CDVURLProtocol : NSURLProtocol {}
|
|
26
|
+
|
|
27
|
+
@end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import <AssetsLibrary/ALAsset.h>
|
|
21
|
+
#import <AssetsLibrary/ALAssetRepresentation.h>
|
|
22
|
+
#import <AssetsLibrary/ALAssetsLibrary.h>
|
|
23
|
+
#import <MobileCoreServices/MobileCoreServices.h>
|
|
24
|
+
#import "CDVURLProtocol.h"
|
|
25
|
+
#import "CDVCommandQueue.h"
|
|
26
|
+
#import "CDVViewController.h"
|
|
27
|
+
|
|
28
|
+
// Contains a set of NSNumbers of addresses of controllers. It doesn't store
|
|
29
|
+
// the actual pointer to avoid retaining.
|
|
30
|
+
static NSMutableSet* gRegisteredControllers = nil;
|
|
31
|
+
|
|
32
|
+
NSString* const kCDVAssetsLibraryPrefixes = @"assets-library://";
|
|
33
|
+
|
|
34
|
+
@implementation CDVURLProtocol
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
|
|
38
|
+
{
|
|
39
|
+
NSURL* theUrl = [theRequest URL];
|
|
40
|
+
|
|
41
|
+
if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
|
|
42
|
+
return YES;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return NO;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request
|
|
49
|
+
{
|
|
50
|
+
// NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd));
|
|
51
|
+
return request;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)startLoading
|
|
55
|
+
{
|
|
56
|
+
// NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd));
|
|
57
|
+
NSURL* url = [[self request] URL];
|
|
58
|
+
|
|
59
|
+
if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
|
|
60
|
+
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
|
|
61
|
+
if (asset) {
|
|
62
|
+
// We have the asset! Get the data and send it along.
|
|
63
|
+
ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
|
|
64
|
+
NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
|
|
65
|
+
Byte* buffer = (Byte*)malloc((unsigned long)[assetRepresentation size]);
|
|
66
|
+
NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:(NSUInteger)[assetRepresentation size] error:nil];
|
|
67
|
+
NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
|
|
68
|
+
[self sendResponseWithResponseCode:200 data:data mimeType:MIMEType];
|
|
69
|
+
} else {
|
|
70
|
+
// Retrieving the asset failed for some reason. Send an error.
|
|
71
|
+
[self sendResponseWithResponseCode:404 data:nil mimeType:nil];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
|
|
75
|
+
// Retrieving the asset failed for some reason. Send an error.
|
|
76
|
+
[self sendResponseWithResponseCode:401 data:nil mimeType:nil];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
|
|
80
|
+
[assetsLibrary assetForURL:url resultBlock:resultBlock failureBlock:failureBlock];
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
NSString* body = [NSString stringWithFormat:@"Access not allowed to URL: %@", url];
|
|
85
|
+
[self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSASCIIStringEncoding] mimeType:nil];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)stopLoading
|
|
89
|
+
{
|
|
90
|
+
// do any cleanup here
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
+ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB
|
|
94
|
+
{
|
|
95
|
+
return NO;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data mimeType:(NSString*)mimeType
|
|
99
|
+
{
|
|
100
|
+
if (mimeType == nil) {
|
|
101
|
+
mimeType = @"text/plain";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
NSHTTPURLResponse* response = [[NSHTTPURLResponse alloc] initWithURL:[[self request] URL] statusCode:statusCode HTTPVersion:@"HTTP/1.1" headerFields:@{@"Content-Type" : mimeType}];
|
|
105
|
+
|
|
106
|
+
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
|
107
|
+
if (data != nil) {
|
|
108
|
+
[[self client] URLProtocol:self didLoadData:data];
|
|
109
|
+
}
|
|
110
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import <Foundation/Foundation.h>
|
|
21
|
+
|
|
22
|
+
@interface CDVUserAgentUtil : NSObject
|
|
23
|
+
+ (NSString*)originalUserAgent;
|
|
24
|
+
+ (void)acquireLock:(void (^)(NSInteger lockToken))block;
|
|
25
|
+
+ (void)releaseLock:(NSInteger*)lockToken;
|
|
26
|
+
+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken;
|
|
27
|
+
@end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import "CDVUserAgentUtil.h"
|
|
21
|
+
|
|
22
|
+
#import <UIKit/UIKit.h>
|
|
23
|
+
|
|
24
|
+
// #define VerboseLog NSLog
|
|
25
|
+
#define VerboseLog(...) do {} while (0)
|
|
26
|
+
|
|
27
|
+
static NSString* const kCdvUserAgentKey = @"Cordova-User-Agent";
|
|
28
|
+
static NSString* const kCdvUserAgentVersionKey = @"Cordova-User-Agent-Version";
|
|
29
|
+
|
|
30
|
+
static NSString* gOriginalUserAgent = nil;
|
|
31
|
+
static NSInteger gNextLockToken = 0;
|
|
32
|
+
static NSInteger gCurrentLockToken = 0;
|
|
33
|
+
static NSMutableArray* gPendingSetUserAgentBlocks = nil;
|
|
34
|
+
|
|
35
|
+
@implementation CDVUserAgentUtil
|
|
36
|
+
|
|
37
|
+
+ (NSString*)originalUserAgent
|
|
38
|
+
{
|
|
39
|
+
if (gOriginalUserAgent == nil) {
|
|
40
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppLocaleDidChange:)
|
|
41
|
+
name:NSCurrentLocaleDidChangeNotification object:nil];
|
|
42
|
+
|
|
43
|
+
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
|
44
|
+
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
|
|
45
|
+
NSString* localeStr = [[NSLocale currentLocale] localeIdentifier];
|
|
46
|
+
// Record the model since simulator can change it without re-install (CB-5420).
|
|
47
|
+
NSString* model = [UIDevice currentDevice].model;
|
|
48
|
+
// Record the version of the app so that we can bust the cache when it changes (CB-10078)
|
|
49
|
+
NSString* appVersion = [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"];
|
|
50
|
+
NSString* systemAndLocale = [NSString stringWithFormat:@"%@ %@ %@ %@", appVersion, model, systemVersion, localeStr];
|
|
51
|
+
|
|
52
|
+
NSString* cordovaUserAgentVersion = [userDefaults stringForKey:kCdvUserAgentVersionKey];
|
|
53
|
+
gOriginalUserAgent = [userDefaults stringForKey:kCdvUserAgentKey];
|
|
54
|
+
BOOL cachedValueIsOld = ![systemAndLocale isEqualToString:cordovaUserAgentVersion];
|
|
55
|
+
|
|
56
|
+
if ((gOriginalUserAgent == nil) || cachedValueIsOld) {
|
|
57
|
+
UIWebView* sampleWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
|
|
58
|
+
gOriginalUserAgent = [sampleWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
|
|
59
|
+
|
|
60
|
+
[userDefaults setObject:gOriginalUserAgent forKey:kCdvUserAgentKey];
|
|
61
|
+
[userDefaults setObject:systemAndLocale forKey:kCdvUserAgentVersionKey];
|
|
62
|
+
|
|
63
|
+
[userDefaults synchronize];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return gOriginalUserAgent;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
+ (void)onAppLocaleDidChange:(NSNotification*)notification
|
|
70
|
+
{
|
|
71
|
+
// TODO: We should figure out how to update the user-agent of existing UIWebViews when this happens.
|
|
72
|
+
// Maybe use the PDF bug (noted in setUserAgent:).
|
|
73
|
+
gOriginalUserAgent = nil;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
+ (void)acquireLock:(void (^)(NSInteger lockToken))block
|
|
77
|
+
{
|
|
78
|
+
if (gCurrentLockToken == 0) {
|
|
79
|
+
gCurrentLockToken = ++gNextLockToken;
|
|
80
|
+
VerboseLog(@"Gave lock %d", gCurrentLockToken);
|
|
81
|
+
block(gCurrentLockToken);
|
|
82
|
+
} else {
|
|
83
|
+
if (gPendingSetUserAgentBlocks == nil) {
|
|
84
|
+
gPendingSetUserAgentBlocks = [[NSMutableArray alloc] initWithCapacity:4];
|
|
85
|
+
}
|
|
86
|
+
VerboseLog(@"Waiting for lock");
|
|
87
|
+
[gPendingSetUserAgentBlocks addObject:block];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
+ (void)releaseLock:(NSInteger*)lockToken
|
|
92
|
+
{
|
|
93
|
+
if (lockToken == nil || *lockToken == 0) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
NSAssert(gCurrentLockToken == *lockToken, @"Got token %ld, expected %ld", (long)*lockToken, (long)gCurrentLockToken);
|
|
97
|
+
|
|
98
|
+
VerboseLog(@"Released lock %d", *lockToken);
|
|
99
|
+
if ([gPendingSetUserAgentBlocks count] > 0) {
|
|
100
|
+
void (^block)(NSInteger lockToken) = [gPendingSetUserAgentBlocks objectAtIndex:0];
|
|
101
|
+
[gPendingSetUserAgentBlocks removeObjectAtIndex:0];
|
|
102
|
+
gCurrentLockToken = ++gNextLockToken;
|
|
103
|
+
NSLog(@"Gave lock %ld", (long)gCurrentLockToken);
|
|
104
|
+
block(gCurrentLockToken);
|
|
105
|
+
} else {
|
|
106
|
+
gCurrentLockToken = 0;
|
|
107
|
+
}
|
|
108
|
+
*lockToken = 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken
|
|
112
|
+
{
|
|
113
|
+
NSAssert(gCurrentLockToken == lockToken, @"Got token %ld, expected %ld", (long)lockToken, (long)gCurrentLockToken);
|
|
114
|
+
VerboseLog(@"User-Agent set to: %@", value);
|
|
115
|
+
|
|
116
|
+
// Setting the UserAgent must occur before a UIWebView is instantiated.
|
|
117
|
+
// It is read per instantiation, so it does not affect previously created views.
|
|
118
|
+
// Except! When a PDF is loaded, all currently active UIWebViews reload their
|
|
119
|
+
// User-Agent from the NSUserDefaults some time after the DidFinishLoad of the PDF bah!
|
|
120
|
+
NSDictionary* dict = [[NSDictionary alloc] initWithObjectsAndKeys:value, @"UserAgent", nil];
|
|
121
|
+
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@end
|