├── .gitignore
├── .gitmodules
├── LICENSE
├── Podfile
├── README.md
├── crosswalk-extension-cordova.podspec
├── crosswalk-extension-fingerprint.podspec
├── crosswalk-extension-iap.podspec
├── crosswalk-extension-presentation.podspec
├── demos
├── CordovaPluginDeviceDemo
│ ├── CordovaPluginDeviceDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── CordovaPluginDeviceDemo.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── CordovaPluginDeviceDemo
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ │ └── Main.storyboard
│ │ ├── CDVDevice.h
│ │ ├── CDVDevice.m
│ │ ├── CordovaViewController.swift
│ │ ├── Images.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── crosswalk_120x120.png
│ │ │ │ ├── crosswalk_152x152.png
│ │ │ │ ├── crosswalk_180x180.png
│ │ │ │ ├── crosswalk_29x29.png
│ │ │ │ ├── crosswalk_40x40.png
│ │ │ │ ├── crosswalk_58x58.png
│ │ │ │ ├── crosswalk_76x76.png
│ │ │ │ ├── crosswalk_80x80.png
│ │ │ │ └── crosswalk_87x87.png
│ │ ├── Info.plist
│ │ └── www
│ │ │ ├── cordova_plugins.js
│ │ │ ├── index.html
│ │ │ └── plugins
│ │ │ └── org.apache.cordova.device
│ │ │ └── www
│ │ │ └── device.js
│ ├── Podfile
│ └── manifest.plist
└── CordovaPluginFileDemo
│ ├── CordovaPluginFileDemo.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── CordovaPluginFileDemo.xcworkspace
│ └── contents.xcworkspacedata
│ ├── CordovaPluginFileDemo
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ │ └── Main.storyboard
│ ├── CordovaViewController.swift
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── crosswalk_120x120.png
│ │ │ ├── crosswalk_152x152.png
│ │ │ ├── crosswalk_180x180.png
│ │ │ ├── crosswalk_29x29.png
│ │ │ ├── crosswalk_40x40.png
│ │ │ ├── crosswalk_58x58.png
│ │ │ ├── crosswalk_76x76.png
│ │ │ ├── crosswalk_80x80.png
│ │ │ └── crosswalk_87x87.png
│ ├── Info.plist
│ ├── Plugins
│ │ ├── README
│ │ ├── org.apache.cordova.file
│ │ │ ├── CDVAssetLibraryFilesystem.h
│ │ │ ├── CDVAssetLibraryFilesystem.m
│ │ │ ├── CDVFile.h
│ │ │ ├── CDVFile.m
│ │ │ ├── CDVLocalFilesystem.h
│ │ │ └── CDVLocalFilesystem.m
│ │ └── org.apache.cordova.splashscreen
│ │ │ ├── CDVSplashScreen.h
│ │ │ └── CDVSplashScreen.m
│ └── www
│ │ ├── cordova_plugins.js
│ │ ├── index.html
│ │ └── plugins
│ │ ├── org.apache.cordova.file
│ │ └── www
│ │ │ ├── DirectoryEntry.js
│ │ │ ├── DirectoryReader.js
│ │ │ ├── Entry.js
│ │ │ ├── File.js
│ │ │ ├── FileEntry.js
│ │ │ ├── FileError.js
│ │ │ ├── FileReader.js
│ │ │ ├── FileSystem.js
│ │ │ ├── FileUploadOptions.js
│ │ │ ├── FileUploadResult.js
│ │ │ ├── FileWriter.js
│ │ │ ├── Flags.js
│ │ │ ├── LocalFileSystem.js
│ │ │ ├── Metadata.js
│ │ │ ├── ProgressEvent.js
│ │ │ ├── fileSystemPaths.js
│ │ │ ├── fileSystems-roots.js
│ │ │ ├── fileSystems.js
│ │ │ ├── ios
│ │ │ └── FileSystem.js
│ │ │ ├── requestFileSystem.js
│ │ │ └── resolveLocalFileSystemURI.js
│ │ └── org.apache.cordova.splashscreen
│ │ └── www
│ │ └── splashscreen.js
│ ├── Podfile
│ └── manifest.plist
├── extensions
├── Cordova
│ ├── Cordova.xcodeproj
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ ├── Cordova
│ │ ├── CDV.h
│ │ ├── CDVCommandDelegateImpl.h
│ │ ├── CDVViewController.h
│ │ ├── CDVViewController.m
│ │ ├── Cordova.h
│ │ ├── Cordova_Prefix.pch
│ │ ├── Info.plist
│ │ ├── XWalkCordovaExtension.h
│ │ ├── XWalkCordovaExtension.js
│ │ ├── XWalkCordovaExtension.m
│ │ ├── XWalkWebViewEngine.h
│ │ ├── XWalkWebViewEngine.m
│ │ └── extensions.plist
│ └── README.md
├── Fingerprint
│ ├── Fingerprint.xcodeproj
│ │ └── project.pbxproj
│ └── Fingerprint
│ │ ├── Fingerprint.h
│ │ ├── FingerprintExtension.h
│ │ ├── FingerprintExtension.m
│ │ ├── Info.plist
│ │ └── extensions.plist
├── InAppPurchase
│ ├── InAppPurchase.xcodeproj
│ │ └── project.pbxproj
│ ├── InAppPurchase
│ │ ├── InAppPurchase.h
│ │ ├── InAppPurchaseExtension.h
│ │ ├── InAppPurchaseExtension.js
│ │ ├── InAppPurchaseExtension.m
│ │ ├── Info.plist
│ │ ├── PaymentTransactionHelper.h
│ │ ├── PaymentTransactionHelper.m
│ │ ├── ProductsRequestHelper.h
│ │ ├── ProductsRequestHelper.m
│ │ ├── ReceiptHelper.h
│ │ ├── ReceiptHelper.m
│ │ └── extensions.plist
│ └── spec
│ │ └── iap.html
└── Presentation
│ ├── Presentation.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── Presentation
│ ├── Info.plist
│ ├── Presentation.h
│ ├── Presentation.js
│ ├── Presentation.swift
│ ├── PresentationSession.js
│ ├── PresentationSession.swift
│ ├── PresentationSessionHost.js
│ ├── PresentationSessionHost.swift
│ ├── RemoteViewController.swift
│ └── extensions.plist
│ └── README.md
└── iOSExtensions.xcworkspace
└── contents.xcworkspacedata
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | Build/
5 | *.pbxuser
6 | !default.pbxuser
7 | *.mode1v3
8 | !default.mode1v3
9 | *.mode2v3
10 | !default.mode2v3
11 | *.perspectivev3
12 | !default.perspectivev3
13 | xcuserdata
14 | *.xccheckout
15 | *.moved-aside
16 | DerivedData
17 | *.hmap
18 | *.ipa
19 | *.xcuserstate
20 | *.DS_Store
21 |
22 | # CocoaPods
23 | #
24 | # We recommend against adding the Pods directory to your .gitignore. However
25 | # you should judge for yourself, the pros and cons are mentioned at:
26 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
27 | #
28 | Pods
29 | Podfile.lock
30 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "third-party/cordova-ios"]
2 | path = third-party/cordova-ios
3 | url = https://github.com/apache/cordova-ios.git
4 | [submodule "third-party/sample-file"]
5 | path = third-party/sample-file
6 | url = https://github.com/Icenium/sample-file.git
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | //
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are
5 | // met:
6 | //
7 | // * Redistributions of source code must retain the above copyright
8 | // notice, this list of conditions and the following disclaimer.
9 | // * Redistributions in binary form must reproduce the above
10 | // copyright notice, this list of conditions and the following disclaimer
11 | // in the documentation and/or other materials provided with the
12 | // distribution.
13 | // * Neither the name of Intel Corporation nor the names of its
14 | // contributors may be used to endorse or promote products derived from
15 | // this software without specific prior written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | platform :ios, '8.1'
6 | use_frameworks!
7 |
8 | workspace 'iOSExtensions'
9 | xcodeproj 'extensions/Cordova/Cordova'
10 | xcodeproj 'extensions/Presentation/Presentation'
11 | xcodeproj 'extensions/InAppPurchase/InAppPurchase'
12 |
13 | pod 'crosswalk-ios', '~> 1.2'
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | The iOS Extension Crosswalk project implements the iOS Crosswalk APIs on top of the Crosswalk app runtime and its extension framework.
4 |
5 | This repository is going to hold all the officially published Crosswalk iOS extensions, as well as the extension demos and samples.
6 |
7 | # Extensions
8 |
9 | [Cordova](extensions/Cordova)
10 |
11 | [Presentation](extensions/Presentation)
12 |
13 | # Quickstart
14 |
15 | For hybrid developers, the easiest way to integrate Crosswalk extensions is using CocoaPods. You need to make sure you've already installed the CocoaPods on your computer. For the installation and usage of CocoaPods, please refer to: https://cocoapods.org/.
16 |
17 | Basically the only thing you need to do is to create a `Podfile` in your project directory, and add a line of pod dependency which you need to use:
18 |
19 | ```bash
20 | pod 'crosswalk-extension-cordova', '~> 1.1'
21 | ```
22 |
23 | And in your app's manifest.json, add a line in `xwalk_extensions` to load the extension:
24 |
25 | ```json
26 | 'xwalk_extensions': [
27 | 'xwalk.cordova'
28 | ],
29 | ```
30 |
31 | Please refer to the instruction of each extension for more details.
32 |
33 | # Development
34 |
35 | * Clone the repo with command:
36 |
37 | ```bash
38 | git clone https://github.com/crosswalk-project/ios-extensions-crosswalk.git
39 | ```
40 |
41 | * Initialize the repo with command:
42 |
43 | ```bash
44 | cd ios-extensions-crosswalk
45 | git submodule update --init --recursive
46 | ```
47 |
48 | * Install the pods for extension development with command:
49 |
50 | ```bash
51 | pod install
52 | ```
53 |
54 | * Open the `iOSExtension.xcworkspace`, build the extension targets.
55 |
56 | # Demos
57 |
58 | There are several demo applications to illustrate the usage of each extension, please refer to the directory [demos](demos) for more details.
59 |
60 | # License
61 |
62 | This project is available under the BSD license. See the [LICENSE](LICENSE) file for more info.
63 |
64 |
--------------------------------------------------------------------------------
/crosswalk-extension-cordova.podspec:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'crosswalk-extension-cordova'
7 | s.version = '1.1'
8 | s.summary = 'Cordova extension is a Crosswalk extension which enables Cordova plugins to integrate with Crosswalk runtime.'
9 | s.homepage = 'https://github.com/crosswalk-project/ios-extensions-crosswalk/tree/master/extensions/Cordova'
10 | s.license = { :type => 'BSD', :file => "LICENSE" }
11 | s.author = { 'Jonathan Dong' => 'jonathan.dong@intel.com' }
12 | s.source = { :git => 'https://github.com/crosswalk-project/ios-extensions-crosswalk.git', :tag => s.version.to_s, :submodules => true }
13 | s.social_media_url = 'https://twitter.com/xwalk_project'
14 |
15 | s.platform = :ios, '8.1'
16 | s.ios.deployment_target = '8.1'
17 | s.module_name = 'Cordova'
18 | s.dependency 'crosswalk-ios', '~> 1.2'
19 |
20 | s.source_files =[
21 | 'extensions/Cordova/Cordova/*.{h,m,swift}',
22 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVAvail*.*',
23 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVCommandDelegate.h',
24 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVCommandQueue.*',
25 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVInvoked*.*',
26 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVPlugin.*',
27 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVPlugin+Resources.*',
28 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDVPluginResult.*',
29 | 'third-party/cordova-ios/CordovaLib/Classes/Public/CDV[S,T,U,W]*.*',
30 | 'third-party/cordova-ios/CordovaLib/Classes/Public/NS*.*',
31 | 'third-party/cordova-ios/CordovaLib/Classes/Private/*.{h,m}',
32 | 'third-party/cordova-ios/CordovaLib/Classes/Private/**/*.{h,m}'
33 | ]
34 | s.resource = 'extensions/Cordova/Cordova/*.js', 'extensions/Cordova/Cordova/extensions.plist'
35 |
36 | end
37 |
--------------------------------------------------------------------------------
/crosswalk-extension-fingerprint.podspec:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2016 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'crosswalk-extension-fingerprint'
7 | s.version = '1.3'
8 | s.summary = 'Fingerprint extension is a Crosswalk extension which implements touchID authentication on iOS'
9 | s.homepage = 'https://github.com/crosswalk-project/ios-extensions-crosswalk/tree/master/extensions/Fingerprint'
10 | s.license = { :type => 'BSD', :file => "LICENSE" }
11 | s.author = { 'Minggang Wang' => 'minggang.wang@intel.com' }
12 | s.source = { :git => 'https://github.com/crosswalk-project/ios-extensions-crosswalk.git', :tag => s.version.to_s }
13 | s.social_media_url = 'https://twitter.com/xwalk_project'
14 |
15 | s.platform = :ios, '8.1'
16 | s.ios.deployment_target = '8.1'
17 | s.module_name = 'Fingerprint'
18 | s.dependency 'crosswalk-ios', '~> 1.2'
19 |
20 | s.source_files = 'extensions/Fingerprint/Fingerprint/*.{h,m,swift}'
21 | s.resource = 'extensions/Fingerprint/Fingerprint/*.js', 'extensions/Fingerprint/Fingerprint/extensions.plist'
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/crosswalk-extension-iap.podspec:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'crosswalk-extension-iap'
7 | s.version = '1.2'
8 | s.summary = 'IAP extension is a Crosswalk extension which implements the in-app purchase on iOS'
9 | s.homepage = 'https://github.com/crosswalk-project/ios-extensions-crosswalk/tree/master/extensions/InAppPurchase'
10 | s.license = { :type => 'BSD', :file => "LICENSE" }
11 | s.author = { 'Minggang Wang' => 'minggang.wang@intel.com' }
12 | s.source = { :git => 'https://github.com/crosswalk-project/ios-extensions-crosswalk.git', :tag => s.version.to_s }
13 | s.social_media_url = 'https://twitter.com/xwalk_project'
14 |
15 | s.platform = :ios, '8.1'
16 | s.ios.deployment_target = '8.1'
17 | s.module_name = 'InAppPurchase'
18 | s.dependency 'crosswalk-ios', '~> 1.2'
19 |
20 | s.source_files = 'extensions/InAppPurchase/InAppPurchase/*.{h,m,swift}'
21 | s.resource = 'extensions/InAppPurchase/InAppPurchase/*.js', 'extensions/InAppPurchase/InAppPurchase/extensions.plist'
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/crosswalk-extension-presentation.podspec:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'crosswalk-extension-presentation'
7 | s.version = '1.1'
8 | s.summary = 'Presentation extension is a Crosswalk extension which implements the W3C Presentation API: http://www.w3.org/TR/presentation-api/'
9 | s.homepage = 'https://github.com/crosswalk-project/ios-extensions-crosswalk/tree/master/extensions/Presentation'
10 | s.license = { :type => 'BSD', :file => "LICENSE" }
11 | s.author = { 'Jonathan Dong' => 'jonathan.dong@intel.com' }
12 | s.source = { :git => 'https://github.com/crosswalk-project/ios-extensions-crosswalk.git', :tag => s.version.to_s }
13 | s.social_media_url = 'https://twitter.com/xwalk_project'
14 |
15 | s.platform = :ios, '8.1'
16 | s.ios.deployment_target = '8.1'
17 | s.module_name = 'Presentation'
18 | s.dependency 'crosswalk-ios', '~> 1.2'
19 |
20 | s.source_files = 'extensions/Presentation/Presentation/*.{h,m,swift}'
21 | s.resource = 'extensions/Presentation/Presentation/*.js', 'extensions/Presentation/Presentation/extensions.plist'
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import UIKit
6 |
7 | @UIApplicationMain
8 | class AppDelegate: UIResponder, UIApplicationDelegate {
9 |
10 | var window: UIWindow?
11 |
12 |
13 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
14 | // Override point for customization after application launch.
15 | return true
16 | }
17 |
18 | func applicationWillResignActive(application: UIApplication) {
19 | // 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.
20 | // 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.
21 | }
22 |
23 | func applicationDidEnterBackground(application: UIApplication) {
24 | // 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.
25 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
26 | }
27 |
28 | func applicationWillEnterForeground(application: UIApplication) {
29 | // 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.
30 | }
31 |
32 | func applicationDidBecomeActive(application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationWillTerminate(application: UIApplication) {
37 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/CDVDevice.h:
--------------------------------------------------------------------------------
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
21 | #import
22 |
23 | @interface CDVDevice : CDVPlugin
24 | {}
25 |
26 | + (NSString*)cordovaVersion;
27 |
28 | - (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/CDVDevice.m:
--------------------------------------------------------------------------------
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 | #include
21 | #include
22 |
23 | #import
24 | #import "CDVDevice.h"
25 |
26 | @implementation UIDevice (ModelVersion)
27 |
28 | - (NSString*)modelVersion
29 | {
30 | size_t size;
31 |
32 | sysctlbyname("hw.machine", NULL, &size, NULL, 0);
33 | char* machine = malloc(size);
34 | sysctlbyname("hw.machine", machine, &size, NULL, 0);
35 | NSString* platform = [NSString stringWithUTF8String:machine];
36 | free(machine);
37 |
38 | return platform;
39 | }
40 |
41 | @end
42 |
43 | @interface CDVDevice () {}
44 | @end
45 |
46 | @implementation CDVDevice
47 |
48 | - (NSString*)uniqueAppInstanceIdentifier:(UIDevice*)device
49 | {
50 | NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
51 | static NSString* UUID_KEY = @"CDVUUID";
52 |
53 | NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
54 |
55 | if (app_uuid == nil) {
56 | CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
57 | CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
58 |
59 | app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString];
60 | [userDefaults setObject:app_uuid forKey:UUID_KEY];
61 | [userDefaults synchronize];
62 |
63 | CFRelease(uuidString);
64 | CFRelease(uuidRef);
65 | }
66 |
67 | return app_uuid;
68 | }
69 |
70 | - (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
71 | {
72 | NSDictionary* deviceProperties = [self deviceProperties];
73 | CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
74 |
75 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
76 | }
77 |
78 | - (NSDictionary*)deviceProperties
79 | {
80 | UIDevice* device = [UIDevice currentDevice];
81 | NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
82 |
83 | [devProps setObject:@"Apple" forKey:@"manufacturer"];
84 | [devProps setObject:[device modelVersion] forKey:@"model"];
85 | [devProps setObject:@"iOS" forKey:@"platform"];
86 | [devProps setObject:[device systemVersion] forKey:@"version"];
87 | [devProps setObject:[self uniqueAppInstanceIdentifier:device] forKey:@"uuid"];
88 | [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
89 |
90 | NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
91 | return devReturn;
92 | }
93 |
94 | + (NSString*)cordovaVersion
95 | {
96 | return CDV_VERSION;
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/CordovaViewController.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import Cordova
6 | import UIKit
7 | import WebKit
8 | import XWalkView
9 |
10 | class ViewController: CDVViewController {
11 | override func viewDidLoad() {
12 | super.viewDidLoad()
13 |
14 | var start_url = "index.html"
15 | var xwalk_extensions = ["Extension.load"]
16 | if let plistPath = NSBundle.mainBundle().pathForResource("manifest", ofType: "plist") {
17 | if let manifest = NSDictionary(contentsOfFile: plistPath) {
18 | start_url = manifest["start_url"] as? String ?? start_url
19 | xwalk_extensions = manifest["xwalk_extensions"] as? [String] ?? xwalk_extensions
20 | }
21 | }
22 |
23 | let webview = XWalkView(frame: view.frame, configuration: WKWebViewConfiguration())
24 | webview.navigationDelegate = self
25 | webview.scrollView.bounces = false
26 | view.addSubview(webview)
27 |
28 | for name in xwalk_extensions {
29 | var ext: AnyObject? = nil;
30 | if name == "xwalk.cordova" {
31 | ext = XWalkExtensionFactory.createExtension(name, initializer: "initWithViewController:", arguments: [self])
32 | } else {
33 | ext = XWalkExtensionFactory.createExtension(name)
34 | }
35 | if let validExtension: AnyObject = ext {
36 | webview.loadExtension(validExtension as! NSObject, namespace: name)
37 | }
38 | }
39 |
40 | if let root = NSBundle.mainBundle().resourceURL?.URLByAppendingPathComponent("www") {
41 | var error: NSError?
42 | let url = root.URLByAppendingPathComponent(start_url)
43 | if url.checkResourceIsReachableAndReturnError(&error) {
44 | webview.loadFileURL(url, allowingReadAccessToURL: root)
45 | } else {
46 | webview.loadHTMLString(error!.description, baseURL: nil)
47 | }
48 | }
49 | }
50 |
51 | override func prefersStatusBarHidden() -> Bool {
52 | return true
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "filename" : "crosswalk_58x58.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "idiom" : "iphone",
11 | "size" : "29x29",
12 | "filename" : "crosswalk_87x87.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "idiom" : "iphone",
17 | "size" : "40x40",
18 | "filename" : "crosswalk_80x80.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "idiom" : "iphone",
23 | "size" : "40x40",
24 | "filename" : "crosswalk_120x120.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "idiom" : "iphone",
29 | "size" : "60x60",
30 | "filename" : "crosswalk_120x120.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "filename" : "crosswalk_180x180.png",
37 | "scale" : "3x"
38 | },
39 | {
40 | "idiom" : "ipad",
41 | "size" : "29x29",
42 | "filename" : "crosswalk_29x29.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "idiom" : "ipad",
47 | "size" : "29x29",
48 | "filename" : "crosswalk_58x58.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "idiom" : "ipad",
53 | "size" : "40x40",
54 | "filename" : "crosswalk_40x40.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "idiom" : "ipad",
59 | "size" : "40x40",
60 | "filename" : "crosswalk_80x80.png",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "76x76",
66 | "filename" : "crosswalk_76x76.png",
67 | "scale" : "1x"
68 | },
69 | {
70 | "idiom" : "ipad",
71 | "size" : "76x76",
72 | "filename" : "crosswalk_152x152.png",
73 | "scale" : "2x"
74 | }
75 | ],
76 | "info" : {
77 | "version" : 1,
78 | "author" : "xcode"
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_120x120.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_152x152.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_180x180.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_29x29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_29x29.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_40x40.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_58x58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_58x58.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_76x76.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_80x80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_80x80.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_87x87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Images.xcassets/AppIcon.appiconset/crosswalk_87x87.png
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | UILaunchStoryboardName
24 | Main
25 | UIMainStoryboardFile
26 | Main
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/www/cordova_plugins.js:
--------------------------------------------------------------------------------
1 | cordova.define('cordova/plugin_list', function(require, exports, module) {
2 | module.exports = [
3 | {
4 | "file": "plugins/org.apache.cordova.device/www/device.js",
5 | "id": "org.apache.cordova.device.device",
6 | "clobbers": [
7 | "device"
8 | ]
9 | }
10 | ];
11 | module.exports.metadata =
12 | // TOP OF METADATA
13 | {
14 | "org.apache.cordova.device": "0.3.0"
15 | }
16 | // BOTTOM OF METADATA
17 | });
18 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/www/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
15 | Cordova device API plugin demo
16 |
17 |
18 |
This is the demo page for testing org.cordova.plugin.device.
19 |
20 |
Device Properties
21 |
22 |
23 |
Name
24 |
Value
25 |
26 |
27 |
28 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/CordovaPluginDeviceDemo/www/plugins/org.apache.cordova.device/www/device.js:
--------------------------------------------------------------------------------
1 | cordova.define("org.apache.cordova.device.device", function(require, exports, module) { /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | var argscheck = require('cordova/argscheck'),
23 | channel = require('cordova/channel'),
24 | utils = require('cordova/utils'),
25 | exec = require('cordova/exec'),
26 | cordova = require('cordova');
27 |
28 | channel.createSticky('onCordovaInfoReady');
29 | // Tell cordova channel to wait on the CordovaInfoReady event
30 | channel.waitForInitialization('onCordovaInfoReady');
31 |
32 | /**
33 | * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
34 | * phone, etc.
35 | * @constructor
36 | */
37 | function Device() {
38 | this.available = false;
39 | this.platform = null;
40 | this.version = null;
41 | this.uuid = null;
42 | this.cordova = null;
43 | this.model = null;
44 | this.manufacturer = null;
45 |
46 | var me = this;
47 |
48 | channel.onCordovaReady.subscribe(function() {
49 | me.getInfo(function(info) {
50 | //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
51 | //TODO: CB-5105 native implementations should not return info.cordova
52 | var buildLabel = cordova.version;
53 | me.available = true;
54 | me.platform = info.platform;
55 | me.version = info.version;
56 | me.uuid = info.uuid;
57 | me.cordova = buildLabel;
58 | me.model = info.model;
59 | me.manufacturer = info.manufacturer || 'unknown';
60 | channel.onCordovaInfoReady.fire();
61 | },function(e) {
62 | me.available = false;
63 | utils.alert("[ERROR] Error initializing Cordova: " + e);
64 | });
65 | });
66 | }
67 |
68 | /**
69 | * Get device info
70 | *
71 | * @param {Function} successCallback The function to call when the heading data is available
72 | * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
73 | */
74 | Device.prototype.getInfo = function(successCallback, errorCallback) {
75 | argscheck.checkArgs('fF', 'Device.getInfo', arguments);
76 | exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
77 | };
78 |
79 | module.exports = new Device();
80 |
81 | });
82 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/Podfile:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | # Use of this source code is governed by a BSD-style license that can be
3 | # found in the LICENSE file.
4 |
5 | platform :ios, '8.1'
6 | use_frameworks!
7 |
8 | pod 'crosswalk-extension-cordova', :path => '../../'
9 |
--------------------------------------------------------------------------------
/demos/CordovaPluginDeviceDemo/manifest.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | xwalk_extensions
6 |
7 | xwalk.cordova
8 |
9 | start_url
10 | index.html
11 | cordova_plugins
12 |
13 |
14 | class
15 | CDVDevice
16 | name
17 | Device
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import UIKit
6 |
7 | @UIApplicationMain
8 | class AppDelegate: UIResponder, UIApplicationDelegate {
9 |
10 | var window: UIWindow?
11 |
12 |
13 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
14 | // Override point for customization after application launch.
15 | return true
16 | }
17 |
18 | func applicationWillResignActive(application: UIApplication) {
19 | // 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.
20 | // 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.
21 | }
22 |
23 | func applicationDidEnterBackground(application: UIApplication) {
24 | // 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.
25 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
26 | }
27 |
28 | func applicationWillEnterForeground(application: UIApplication) {
29 | // 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.
30 | }
31 |
32 | func applicationDidBecomeActive(application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationWillTerminate(application: UIApplication) {
37 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/CordovaViewController.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Intel Corporation. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import Cordova
6 | import UIKit
7 | import WebKit
8 | import XWalkView
9 |
10 | class ViewController: CDVViewController {
11 | override func viewDidLoad() {
12 | super.viewDidLoad()
13 |
14 | var start_url = "index.html"
15 | var xwalk_extensions = ["Extension.load"]
16 | if let plistPath = NSBundle.mainBundle().pathForResource("manifest", ofType: "plist") {
17 | if let manifest = NSDictionary(contentsOfFile: plistPath) {
18 | start_url = manifest["start_url"] as? String ?? start_url
19 | xwalk_extensions = manifest["xwalk_extensions"] as? [String] ?? xwalk_extensions
20 | }
21 | }
22 |
23 | let webview = XWalkView(frame: view.frame, configuration: WKWebViewConfiguration())
24 | webview.navigationDelegate = self
25 | webview.scrollView.bounces = false
26 | view.addSubview(webview)
27 |
28 | for name in xwalk_extensions {
29 | var ext: AnyObject? = nil;
30 | if name == "xwalk.cordova" {
31 | ext = XWalkExtensionFactory.createExtension(name, initializer: "initWithViewController:", arguments: [self])
32 | } else {
33 | ext = XWalkExtensionFactory.createExtension(name)
34 | }
35 | if let validExtension: AnyObject = ext {
36 | webview.loadExtension(validExtension as! NSObject, namespace: name)
37 | }
38 | }
39 |
40 | if let root = NSBundle.mainBundle().resourceURL?.URLByAppendingPathComponent("www") {
41 | var error: NSError?
42 | let url = root.URLByAppendingPathComponent(start_url)
43 | if url.checkResourceIsReachableAndReturnError(&error) {
44 | webview.loadFileURL(url, allowingReadAccessToURL: root)
45 | } else {
46 | webview.loadHTMLString(error!.description, baseURL: nil)
47 | }
48 | }
49 | }
50 |
51 | override func prefersStatusBarHidden() -> Bool {
52 | return true
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "filename" : "crosswalk_58x58.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "idiom" : "iphone",
11 | "size" : "29x29",
12 | "filename" : "crosswalk_87x87.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "idiom" : "iphone",
17 | "size" : "40x40",
18 | "filename" : "crosswalk_80x80.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "idiom" : "iphone",
23 | "size" : "40x40",
24 | "filename" : "crosswalk_120x120.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "idiom" : "iphone",
29 | "size" : "60x60",
30 | "filename" : "crosswalk_120x120.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "filename" : "crosswalk_180x180.png",
37 | "scale" : "3x"
38 | },
39 | {
40 | "idiom" : "ipad",
41 | "size" : "29x29",
42 | "filename" : "crosswalk_29x29.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "idiom" : "ipad",
47 | "size" : "29x29",
48 | "filename" : "crosswalk_58x58.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "idiom" : "ipad",
53 | "size" : "40x40",
54 | "filename" : "crosswalk_40x40.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "idiom" : "ipad",
59 | "size" : "40x40",
60 | "filename" : "crosswalk_80x80.png",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "76x76",
66 | "filename" : "crosswalk_76x76.png",
67 | "scale" : "1x"
68 | },
69 | {
70 | "idiom" : "ipad",
71 | "size" : "76x76",
72 | "filename" : "crosswalk_152x152.png",
73 | "scale" : "2x"
74 | }
75 | ],
76 | "info" : {
77 | "version" : 1,
78 | "author" : "xcode"
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_120x120.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_152x152.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_180x180.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_29x29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_29x29.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_40x40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_40x40.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_58x58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_58x58.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_76x76.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_80x80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_80x80.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_87x87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crosswalk-project/ios-extensions-crosswalk/4cba9408d3f7316b8b78da1cf4c40f4f4671d038/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Images.xcassets/AppIcon.appiconset/crosswalk_87x87.png
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | Main
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Plugins/README:
--------------------------------------------------------------------------------
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 | Put the .h and .m files of your plugin here. The .js files of your plugin belong in the www folder.
21 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Plugins/org.apache.cordova.file/CDVAssetLibraryFilesystem.h:
--------------------------------------------------------------------------------
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 "CDVFile.h"
21 |
22 | extern NSString* const kCDVAssetsLibraryPrefix;
23 | extern NSString* const kCDVAssetsLibraryScheme;
24 |
25 | @interface CDVAssetLibraryFilesystem : NSObject {
26 | }
27 |
28 | - (id) initWithName:(NSString *)name;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Plugins/org.apache.cordova.file/CDVFile.h:
--------------------------------------------------------------------------------
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
21 | #import
22 |
23 | NSString* const kCDVAssetsLibraryPrefix;
24 | NSString* const kCDVFilesystemURLPrefix;
25 |
26 | enum CDVFileError {
27 | NO_ERROR = 0,
28 | NOT_FOUND_ERR = 1,
29 | SECURITY_ERR = 2,
30 | ABORT_ERR = 3,
31 | NOT_READABLE_ERR = 4,
32 | ENCODING_ERR = 5,
33 | NO_MODIFICATION_ALLOWED_ERR = 6,
34 | INVALID_STATE_ERR = 7,
35 | SYNTAX_ERR = 8,
36 | INVALID_MODIFICATION_ERR = 9,
37 | QUOTA_EXCEEDED_ERR = 10,
38 | TYPE_MISMATCH_ERR = 11,
39 | PATH_EXISTS_ERR = 12
40 | };
41 | typedef int CDVFileError;
42 |
43 | @interface CDVFilesystemURL : NSObject {
44 | NSURL *_url;
45 | NSString *_fileSystemName;
46 | NSString *_fullPath;
47 | }
48 |
49 | - (id) initWithString:(NSString*)strURL;
50 | - (id) initWithURL:(NSURL*)URL;
51 | + (CDVFilesystemURL *)fileSystemURLWithString:(NSString *)strURL;
52 | + (CDVFilesystemURL *)fileSystemURLWithURL:(NSURL *)URL;
53 |
54 | - (NSString *)absoluteURL;
55 |
56 | @property (atomic) NSURL *url;
57 | @property (atomic) NSString *fileSystemName;
58 | @property (atomic) NSString *fullPath;
59 |
60 | @end
61 |
62 | @interface CDVFilesystemURLProtocol : NSURLProtocol
63 | @end
64 |
65 | @protocol CDVFileSystem
66 | - (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url;
67 | - (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options;
68 | - (CDVPluginResult *)getParentForURL:(CDVFilesystemURL *)localURI;
69 | - (CDVPluginResult *)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;
70 | - (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI;
71 | - (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI;
72 | - (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI;
73 | - (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos;
74 | - (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend;
75 | - (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback;
76 | - (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback;
77 | - (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback;
78 |
79 | - (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url;
80 | - (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir;
81 |
82 | @property (nonatomic,strong) NSString *name;
83 | @property (nonatomic, copy) NSURL*(^urlTransformer)(NSURL*);
84 |
85 | @optional
86 | - (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURI;
87 | - (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path;
88 |
89 | @end
90 |
91 | @interface CDVFile : CDVPlugin {
92 | NSString* rootDocsPath;
93 | NSString* appDocsPath;
94 | NSString* appLibraryPath;
95 | NSString* appTempPath;
96 |
97 | NSMutableArray* fileSystems_;
98 | BOOL userHasAllowed;
99 | }
100 |
101 | - (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
102 | - (NSDictionary*)makeEntryForPath:(NSString*)fullPath fileSystemName:(NSString *)fsName isDirectory:(BOOL)isDir;
103 | - (NSDictionary *)makeEntryForURL:(NSURL *)URL;
104 | - (CDVFilesystemURL *)fileSystemURLforLocalPath:(NSString *)localPath;
105 |
106 | - (NSObject *)filesystemForURL:(CDVFilesystemURL *)localURL;
107 |
108 | /* Native Registration API */
109 | - (void)registerFilesystem:(NSObject *)fs;
110 | - (NSObject *)fileSystemByName:(NSString *)fsName;
111 |
112 | /* Exec API */
113 | - (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
114 | - (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
115 | - (void)getDirectory:(CDVInvokedUrlCommand*)command;
116 | - (void)getFile:(CDVInvokedUrlCommand*)command;
117 | - (void)getParent:(CDVInvokedUrlCommand*)command;
118 | - (void)removeRecursively:(CDVInvokedUrlCommand*)command;
119 | - (void)remove:(CDVInvokedUrlCommand*)command;
120 | - (void)copyTo:(CDVInvokedUrlCommand*)command;
121 | - (void)moveTo:(CDVInvokedUrlCommand*)command;
122 | - (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
123 | - (void)readEntries:(CDVInvokedUrlCommand*)command;
124 | - (void)readAsText:(CDVInvokedUrlCommand*)command;
125 | - (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
126 | - (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
127 | - (void)write:(CDVInvokedUrlCommand*)command;
128 | - (void)testFileExists:(CDVInvokedUrlCommand*)command;
129 | - (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
130 | - (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
131 | - (void)truncate:(CDVInvokedUrlCommand*)command;
132 | - (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
133 |
134 | /* Compatibilty with older File API */
135 | - (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
136 | - (NSDictionary *)getDirectoryEntry:(NSString *)target isDirectory:(BOOL)bDirRequest;
137 |
138 | /* Conversion between filesystem paths and URLs */
139 | - (NSString *)filesystemPathForURL:(CDVFilesystemURL *)URL;
140 |
141 | /* Internal methods for testing */
142 | - (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command;
143 |
144 | @property (nonatomic, strong) NSString* rootDocsPath;
145 | @property (nonatomic, strong) NSString* appDocsPath;
146 | @property (nonatomic, strong) NSString* appLibraryPath;
147 | @property (nonatomic, strong) NSString* appTempPath;
148 | @property (nonatomic, strong) NSString* persistentPath;
149 | @property (nonatomic, strong) NSString* temporaryPath;
150 | @property (nonatomic, strong) NSMutableArray* fileSystems;
151 |
152 | @property BOOL userHasAllowed;
153 |
154 | @end
155 |
156 | #define kW3FileTemporary @"temporary"
157 | #define kW3FilePersistent @"persistent"
158 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Plugins/org.apache.cordova.file/CDVLocalFilesystem.h:
--------------------------------------------------------------------------------
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 "CDVFile.h"
21 |
22 | @interface CDVLocalFilesystem : NSObject {
23 | NSString *_name;
24 | NSString *_fsRoot;
25 | }
26 |
27 | - (id) initWithName:(NSString *)name root:(NSString *)fsRoot;
28 | + (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
29 |
30 | @property (nonatomic,strong) NSString *fsRoot;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/Plugins/org.apache.cordova.splashscreen/CDVSplashScreen.h:
--------------------------------------------------------------------------------
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
21 | #import
22 |
23 | typedef struct {
24 | BOOL iPhone;
25 | BOOL iPad;
26 | BOOL iPhone5;
27 | BOOL iPhone6;
28 | BOOL iPhone6Plus;
29 | BOOL retina;
30 |
31 | } CDV_iOSDevice;
32 |
33 | @interface CDVSplashScreen : CDVPlugin {
34 | UIActivityIndicatorView* _activityView;
35 | UIImageView* _imageView;
36 | NSString* _curImageName;
37 | BOOL _visible;
38 | }
39 |
40 | - (void)show:(CDVInvokedUrlCommand*)command;
41 | - (void)hide:(CDVInvokedUrlCommand*)command;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/www/cordova_plugins.js:
--------------------------------------------------------------------------------
1 | cordova.define('cordova/plugin_list', function(require, exports, module) {
2 | module.exports = [
3 | {
4 | "file": "plugins/org.apache.cordova.file/www/DirectoryEntry.js",
5 | "id": "org.apache.cordova.file.DirectoryEntry",
6 | "clobbers": [
7 | "window.DirectoryEntry"
8 | ]
9 | },
10 | {
11 | "file": "plugins/org.apache.cordova.file/www/DirectoryReader.js",
12 | "id": "org.apache.cordova.file.DirectoryReader",
13 | "clobbers": [
14 | "window.DirectoryReader"
15 | ]
16 | },
17 | {
18 | "file": "plugins/org.apache.cordova.file/www/Entry.js",
19 | "id": "org.apache.cordova.file.Entry",
20 | "clobbers": [
21 | "window.Entry"
22 | ]
23 | },
24 | {
25 | "file": "plugins/org.apache.cordova.file/www/File.js",
26 | "id": "org.apache.cordova.file.File",
27 | "clobbers": [
28 | "window.File"
29 | ]
30 | },
31 | {
32 | "file": "plugins/org.apache.cordova.file/www/FileEntry.js",
33 | "id": "org.apache.cordova.file.FileEntry",
34 | "clobbers": [
35 | "window.FileEntry"
36 | ]
37 | },
38 | {
39 | "file": "plugins/org.apache.cordova.file/www/FileError.js",
40 | "id": "org.apache.cordova.file.FileError",
41 | "clobbers": [
42 | "window.FileError"
43 | ]
44 | },
45 | {
46 | "file": "plugins/org.apache.cordova.file/www/FileReader.js",
47 | "id": "org.apache.cordova.file.FileReader",
48 | "clobbers": [
49 | "window.FileReader"
50 | ]
51 | },
52 | {
53 | "file": "plugins/org.apache.cordova.file/www/FileSystem.js",
54 | "id": "org.apache.cordova.file.FileSystem",
55 | "clobbers": [
56 | "window.FileSystem"
57 | ]
58 | },
59 | {
60 | "file": "plugins/org.apache.cordova.file/www/FileUploadOptions.js",
61 | "id": "org.apache.cordova.file.FileUploadOptions",
62 | "clobbers": [
63 | "window.FileUploadOptions"
64 | ]
65 | },
66 | {
67 | "file": "plugins/org.apache.cordova.file/www/FileUploadResult.js",
68 | "id": "org.apache.cordova.file.FileUploadResult",
69 | "clobbers": [
70 | "window.FileUploadResult"
71 | ]
72 | },
73 | {
74 | "file": "plugins/org.apache.cordova.file/www/FileWriter.js",
75 | "id": "org.apache.cordova.file.FileWriter",
76 | "clobbers": [
77 | "window.FileWriter"
78 | ]
79 | },
80 | {
81 | "file": "plugins/org.apache.cordova.file/www/Flags.js",
82 | "id": "org.apache.cordova.file.Flags",
83 | "clobbers": [
84 | "window.Flags"
85 | ]
86 | },
87 | {
88 | "file": "plugins/org.apache.cordova.file/www/LocalFileSystem.js",
89 | "id": "org.apache.cordova.file.LocalFileSystem",
90 | "clobbers": [
91 | "window.LocalFileSystem"
92 | ],
93 | "merges": [
94 | "window"
95 | ]
96 | },
97 | {
98 | "file": "plugins/org.apache.cordova.file/www/Metadata.js",
99 | "id": "org.apache.cordova.file.Metadata",
100 | "clobbers": [
101 | "window.Metadata"
102 | ]
103 | },
104 | {
105 | "file": "plugins/org.apache.cordova.file/www/ProgressEvent.js",
106 | "id": "org.apache.cordova.file.ProgressEvent",
107 | "clobbers": [
108 | "window.ProgressEvent"
109 | ]
110 | },
111 | {
112 | "file": "plugins/org.apache.cordova.file/www/fileSystems.js",
113 | "id": "org.apache.cordova.file.fileSystems"
114 | },
115 | {
116 | "file": "plugins/org.apache.cordova.file/www/requestFileSystem.js",
117 | "id": "org.apache.cordova.file.requestFileSystem",
118 | "clobbers": [
119 | "window.requestFileSystem"
120 | ]
121 | },
122 | {
123 | "file": "plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js",
124 | "id": "org.apache.cordova.file.resolveLocalFileSystemURI",
125 | "merges": [
126 | "window"
127 | ]
128 | },
129 | {
130 | "file": "plugins/org.apache.cordova.file/www/ios/FileSystem.js",
131 | "id": "org.apache.cordova.file.iosFileSystem",
132 | "merges": [
133 | "FileSystem"
134 | ]
135 | },
136 | {
137 | "file": "plugins/org.apache.cordova.file/www/fileSystems-roots.js",
138 | "id": "org.apache.cordova.file.fileSystems-roots",
139 | "runs": true
140 | },
141 | {
142 | "file": "plugins/org.apache.cordova.file/www/fileSystemPaths.js",
143 | "id": "org.apache.cordova.file.fileSystemPaths",
144 | "merges": [
145 | "cordova"
146 | ],
147 | "runs": true
148 | },
149 | {
150 | "file": "plugins/org.apache.cordova.splashscreen/www/splashscreen.js",
151 | "id": "org.apache.cordova.splashscreen.SplashScreen",
152 | "clobbers": [
153 | "navigator.splashscreen"
154 | ]
155 | }
156 | ];
157 | module.exports.metadata =
158 | // TOP OF METADATA
159 | {
160 | "org.apache.cordova.file": "1.3.3",
161 | "org.apache.cordova.splashscreen": "1.0.0"
162 | }
163 | // BOTTOM OF METADATA
164 | });
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/www/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | File Sample
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
File Sample
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/www/plugins/org.apache.cordova.file/www/DirectoryEntry.js:
--------------------------------------------------------------------------------
1 | cordova.define("org.apache.cordova.file.DirectoryEntry", function(require, exports, module) { /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | var argscheck = require('cordova/argscheck'),
23 | utils = require('cordova/utils'),
24 | exec = require('cordova/exec'),
25 | Entry = require('./Entry'),
26 | FileError = require('./FileError'),
27 | DirectoryReader = require('./DirectoryReader');
28 |
29 | /**
30 | * An interface representing a directory on the file system.
31 | *
32 | * {boolean} isFile always false (readonly)
33 | * {boolean} isDirectory always true (readonly)
34 | * {DOMString} name of the directory, excluding the path leading to it (readonly)
35 | * {DOMString} fullPath the absolute full path to the directory (readonly)
36 | * {FileSystem} filesystem on which the directory resides (readonly)
37 | */
38 | var DirectoryEntry = function(name, fullPath, fileSystem, nativeURL) {
39 |
40 | // add trailing slash if it is missing
41 | if ((fullPath) && !/\/$/.test(fullPath)) {
42 | fullPath += "/";
43 | }
44 | // add trailing slash if it is missing
45 | if (nativeURL && !/\/$/.test(nativeURL)) {
46 | nativeURL += "/";
47 | }
48 | DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL);
49 | };
50 |
51 | utils.extend(DirectoryEntry, Entry);
52 |
53 | /**
54 | * Creates a new DirectoryReader to read entries from this directory
55 | */
56 | DirectoryEntry.prototype.createReader = function() {
57 | return new DirectoryReader(this.toInternalURL());
58 | };
59 |
60 | /**
61 | * Creates or looks up a directory
62 | *
63 | * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
64 | * @param {Flags} options to create or exclusively create the directory
65 | * @param {Function} successCallback is called with the new entry
66 | * @param {Function} errorCallback is called with a FileError
67 | */
68 | DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
69 | argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
70 | var fs = this.filesystem;
71 | var win = successCallback && function(result) {
72 | var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);
73 | successCallback(entry);
74 | };
75 | var fail = errorCallback && function(code) {
76 | errorCallback(new FileError(code));
77 | };
78 | exec(win, fail, "File", "getDirectory", [this.toInternalURL(), path, options]);
79 | };
80 |
81 | /**
82 | * Deletes a directory and all of it's contents
83 | *
84 | * @param {Function} successCallback is called with no parameters
85 | * @param {Function} errorCallback is called with a FileError
86 | */
87 | DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
88 | argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
89 | var fail = errorCallback && function(code) {
90 | errorCallback(new FileError(code));
91 | };
92 | exec(successCallback, fail, "File", "removeRecursively", [this.toInternalURL()]);
93 | };
94 |
95 | /**
96 | * Creates or looks up a file
97 | *
98 | * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
99 | * @param {Flags} options to create or exclusively create the file
100 | * @param {Function} successCallback is called with the new entry
101 | * @param {Function} errorCallback is called with a FileError
102 | */
103 | DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
104 | argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
105 | var fs = this.filesystem;
106 | var win = successCallback && function(result) {
107 | var FileEntry = require('./FileEntry');
108 | var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL);
109 | successCallback(entry);
110 | };
111 | var fail = errorCallback && function(code) {
112 | errorCallback(new FileError(code));
113 | };
114 | exec(win, fail, "File", "getFile", [this.toInternalURL(), path, options]);
115 | };
116 |
117 | module.exports = DirectoryEntry;
118 |
119 | });
120 |
--------------------------------------------------------------------------------
/demos/CordovaPluginFileDemo/CordovaPluginFileDemo/www/plugins/org.apache.cordova.file/www/DirectoryReader.js:
--------------------------------------------------------------------------------
1 | cordova.define("org.apache.cordova.file.DirectoryReader", function(require, exports, module) { /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | var exec = require('cordova/exec'),
23 | FileError = require('./FileError') ;
24 |
25 | /**
26 | * An interface that lists the files and directories in a directory.
27 | */
28 | function DirectoryReader(localURL) {
29 | this.localURL = localURL || null;
30 | this.hasReadEntries = false;
31 | }
32 |
33 | /**
34 | * Returns a list of entries from a directory.
35 | *
36 | * @param {Function} successCallback is called with a list of entries
37 | * @param {Function} errorCallback is called with a FileError
38 | */
39 | DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
40 | // If we've already read and passed on this directory's entries, return an empty list.
41 | if (this.hasReadEntries) {
42 | successCallback([]);
43 | return;
44 | }
45 | var reader = this;
46 | var win = typeof successCallback !== 'function' ? null : function(result) {
47 | var retVal = [];
48 | for (var i=0; i or
190 | *