diff --git a/config.xml b/config.xml index d7f6076..6d408d2 100755 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<widget id="com.form.parking.violation" version="2.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> +<widget id="com.form.parking.violation" version="2.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>Denúncia Estacionamento</name> <description> Formulário para queixa de estacionamento ilegal @@ -8,12 +8,12 @@ Caminhante </author> <content src="index.html" /> - <icon src="res/icon/universal/icon4_512x512_playstore.png" width="512" height="512" /> - <icon src="res/icon/universal/icon4_XHDPI_196x196_320dpi.png" width="196" height="196" density="xhdpi" /> - <icon src="res/icon/universal/icon4_XXXHDPI_192x192_640dpi.png" width="192" height="192" density="xxxhdpi" /> - <icon src="res/icon/universal/icon4_XXHDPI_144x144_480dpi.png" width="144" height="144" density="xxhdpi" /> - <icon src="res/icon/universal/icon4_HDPI_72x72_240dpi.png" width="72" height="72" density="hdpi" /> - <icon src="res/icon/universal/icon4_MDPI_48x48_160dpi.png" width="48" height="48" density="mdpi" /> + <icon height="512" src="res/icon/universal/icon4_512x512_playstore.png" width="512" /> + <icon density="xhdpi" height="196" src="res/icon/universal/icon4_XHDPI_196x196_320dpi.png" width="196" /> + <icon density="xxxhdpi" height="192" src="res/icon/universal/icon4_XXXHDPI_192x192_640dpi.png" width="192" /> + <icon density="xxhdpi" height="144" src="res/icon/universal/icon4_XXHDPI_144x144_480dpi.png" width="144" /> + <icon density="hdpi" height="72" src="res/icon/universal/icon4_HDPI_72x72_240dpi.png" width="72" /> + <icon density="mdpi" height="48" src="res/icon/universal/icon4_MDPI_48x48_160dpi.png" width="48" /> <access origin="*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> @@ -32,7 +32,6 @@ <allow-intent href="itms-apps:*" /> </platform> <engine name="android" spec="^6.2.0" /> - <plugin name="cordova-plugin-file" spec="^4.3.3" /> <plugin name="cordova-plugin-network-information" spec="^2.0.1" /> <plugin name="cordova-plugin-geolocation" spec="^2.4.3" /> <plugin name="cordova-plugin-email-composer" spec="^0.8.15" /> @@ -44,4 +43,7 @@ <plugin name="cordova-pdf-generator" spec="^2.0.3" /> <plugin name="cordova-plugin-statusbar" spec="^2.2.3" /> <plugin name="cordova-plugin-camera" spec="~4.0.3" /> + <plugin name="info.protonet.imageresizer" spec="~0.1.1" /> + <plugin name="cordova-plugin-file-transfer" spec="~1.7.1" /> + <plugin name="cordova-plugin-file" spec="~6.0.1" /> </widget> diff --git a/package-lock.json b/package-lock.json index e6cdf08..5c17731 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1061,11 +1061,6 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-4.0.3.tgz", "integrity": "sha1-c3Olk4MYyGzP2E43E+I4LRD+B2s=" }, - "cordova-plugin-compat": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/cordova-plugin-compat/-/cordova-plugin-compat-1.2.0.tgz", - "integrity": "sha1-C8ZXVyduvZIMASzpIOJ0F3V2Nz4=" - }, "cordova-plugin-device": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.2.tgz", @@ -1077,9 +1072,14 @@ "integrity": "sha512-DkGnlwGw25JKx/aICZT0X3N/Iew+btB/DLfjgEB2brjkj6N+lcognNPr40eltK7UWur3Ql8V4djm2EAuEbM7NQ==" }, "cordova-plugin-file": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-4.3.3.tgz", - "integrity": "sha1-AS6Xqhr7kfhJFuY0G1SDZtI96bk=" + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.1.tgz", + "integrity": "sha1-SWBrjBWlaI1HKPkuSnMloGHeB/U=" + }, + "cordova-plugin-file-transfer": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/cordova-plugin-file-transfer/-/cordova-plugin-file-transfer-1.7.1.tgz", + "integrity": "sha1-p12L4uvDu5sjxbG70ZkhTsJnWGs=" }, "cordova-plugin-geolocation": { "version": "2.4.3", diff --git a/package.json b/package.json index cce6146..736b91d 100755 --- a/package.json +++ b/package.json @@ -14,10 +14,10 @@ "cordova-android": "6.4.0", "cordova-pdf-generator": "2.0.8", "cordova-plugin-camera": "4.0.3", - "cordova-plugin-compat": "^1.2.0", "cordova-plugin-device": "^2.0.2", "cordova-plugin-email-composer": "^0.8.15", - "cordova-plugin-file": "^4.3.3", + "cordova-plugin-file": "6.0.1", + "cordova-plugin-file-transfer": "1.7.1", "cordova-plugin-geolocation": "^2.4.3", "cordova-plugin-image-resizer": "git+https://github.com/protonet/cordova-plugin-image-resizer.git", "cordova-plugin-inappbrowser": "^3.0.0", @@ -32,7 +32,6 @@ }, "cordova": { "plugins": { - "cordova-plugin-file": {}, "cordova-plugin-network-information": {}, "cordova-plugin-geolocation": {}, "cordova-plugin-email-composer": {}, @@ -46,7 +45,9 @@ "cordova-plugin-screen-orientation": {}, "cordova-pdf-generator": {}, "cordova-plugin-statusbar": {}, - "cordova-plugin-camera": {} + "cordova-plugin-camera": {}, + "cordova-plugin-file-transfer": {}, + "cordova-plugin-file": {} }, "platforms": [ "android" diff --git a/plugins/android.json b/plugins/android.json index 7b40165..3f4281d 100644 --- a/plugins/android.json +++ b/plugins/android.json @@ -7,9 +7,6 @@ "files": {} }, "installed_plugins": { - "cordova-plugin-file": { - "PACKAGE_NAME": "com.form.parking.violation" - }, "cordova-plugin-network-information": { "PACKAGE_NAME": "com.form.parking.violation" }, @@ -43,6 +40,12 @@ }, "cordova-plugin-camera": { "PACKAGE_NAME": "com.form.parking.violation" + }, + "cordova-plugin-file-transfer": { + "PACKAGE_NAME": "com.form.parking.violation" + }, + "cordova-plugin-file": { + "PACKAGE_NAME": "com.form.parking.violation" } }, "dependent_plugins": { diff --git a/plugins/cordova-plugin-compat/.editorconfig b/plugins/cordova-plugin-compat/.editorconfig deleted file mode 100644 index e640cd7..0000000 --- a/plugins/cordova-plugin-compat/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -# This file is for unifying the coding style of different editors and IDEs. -# editorconfig.org - -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.json] -indent_size = 2 diff --git a/plugins/cordova-plugin-compat/.jshintrc b/plugins/cordova-plugin-compat/.jshintrc deleted file mode 100644 index fe628be..0000000 --- a/plugins/cordova-plugin-compat/.jshintrc +++ /dev/null @@ -1,30 +0,0 @@ -{ - "asi": false, - "boss": false, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "eqnull": false, - "es5": false, - "evil": false, - "expr": false, - "forin": true, - "funcscope": false, - "jasmine": true, - "immed": true, - "indent": 4, - "latedef": true, - "loopfunc": false, - "maxerr": 7, - "newcap": true, - "node": true, - "nonew": true, - "plusplus": false, - "quotmark": "single", - "shadow": false, - "strict": false, - "supernew": false, - "trailing": true, - "undef": true, - "white": true -} diff --git a/plugins/cordova-plugin-compat/.npmignore b/plugins/cordova-plugin-compat/.npmignore deleted file mode 100644 index 5603150..0000000 --- a/plugins/cordova-plugin-compat/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -spec/ -tests/ diff --git a/plugins/cordova-plugin-compat/package.json b/plugins/cordova-plugin-compat/package.json deleted file mode 100644 index d5ff7e2..0000000 --- a/plugins/cordova-plugin-compat/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "_args": [ - [ - "cordova-plugin-compat@1.2.0", - "/home/jfolpf/form-for-parking-violation" - ] - ], - "_from": "cordova-plugin-compat@1.2.0", - "_id": "cordova-plugin-compat@1.2.0", - "_inBundle": false, - "_integrity": "sha1-C8ZXVyduvZIMASzpIOJ0F3V2Nz4=", - "_location": "/cordova-plugin-compat", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "cordova-plugin-compat@1.2.0", - "name": "cordova-plugin-compat", - "escapedName": "cordova-plugin-compat", - "rawSpec": "1.2.0", - "saveSpec": null, - "fetchSpec": "1.2.0" - }, - "_requiredBy": [ - "/" - ], - "_resolved": "https://registry.npmjs.org/cordova-plugin-compat/-/cordova-plugin-compat-1.2.0.tgz", - "_spec": "1.2.0", - "_where": "/home/jfolpf/form-for-parking-violation", - "author": { - "name": "Apache Software Foundation" - }, - "bugs": { - "url": "https://github.com/apache/cordova-plugin-compat/issues" - }, - "cordova": { - "id": "cordova-plugin-compat", - "platforms": [ - "android" - ] - }, - "description": "[DEPRECATED] This repo is for remaining backwards compatible with previous versions of Cordova.", - "engines": { - "cordovaDependencies": { - "<1.2.0": { - "cordova": ">=5.0.0" - }, - ">=1.2.0": { - "cordova": ">=5.0.0", - "cordova-android": "<6.3.0" - } - } - }, - "homepage": "http://github.com/apache/cordova-plugin-compat#readme", - "keywords": [ - "ecosystem:cordova", - "ecosystem:phonegap", - "cordova-android" - ], - "license": "Apache-2.0", - "name": "cordova-plugin-compat", - "repository": { - "type": "git", - "url": "git://github.com/apache/cordova-plugin-compat.git" - }, - "version": "1.2.0" -} diff --git a/plugins/cordova-plugin-compat/plugin.xml b/plugins/cordova-plugin-compat/plugin.xml deleted file mode 100644 index 9c41abb..0000000 --- a/plugins/cordova-plugin-compat/plugin.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<plugin - xmlns="http://cordova.apache.org/ns/plugins/1.0" id="cordova-plugin-compat" version="1.2.0"> - <name>Compat</name> - <description>[DEPRECATED] Cordova Compatibility Plugin</description> - <license>Apache 2.0</license> - <keywords>cordova,compat</keywords> - <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-compat.git</repo> - <engines> - <engine name="cordova" version=">=5.0.0"/> - <engine name="cordova-android" version=" - <6.3.0"/> - </engines> - <!-- android --> - <platform name="android"> - <source-file src="src/android/PermissionHelper.java" target-dir="src/org/apache/cordova" /> - <source-file src="src/android/BuildHelper.java" target-dir="src/org/apache/cordova" /> - </platform> - </plugin> \ No newline at end of file diff --git a/plugins/cordova-plugin-file-transfer/.appveyor.yml b/plugins/cordova-plugin-file-transfer/.appveyor.yml new file mode 100644 index 0000000..4cd6d53 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/.appveyor.yml @@ -0,0 +1,28 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml + +max_jobs: 1 + +shallow_clone: true + +init: + - git config --global core.autocrlf true + +image: + - Visual Studio 2017 + +environment: + nodejs_version: "4" + matrix: + - PLATFORM: windows-10-store + +install: + - npm cache clean -f + - node --version + - npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git + - npm install -g cordova + +build: off + +test_script: + - cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild diff --git a/plugins/cordova-plugin-file-transfer/.jscsrc b/plugins/cordova-plugin-file-transfer/.jscsrc new file mode 100644 index 0000000..2656b94 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/.jscsrc @@ -0,0 +1,23 @@ +{ + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "validateIndentation": 4, + "requireLineFeedAtFileEnd": true, + + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "requireSpaceAfterLineComment": true, + "requireCapitalizedConstructors": true, + + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do" + ] +} diff --git a/plugins/cordova-plugin-file-transfer/.jshintrc b/plugins/cordova-plugin-file-transfer/.jshintrc new file mode 100644 index 0000000..93c3c13 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/.jshintrc @@ -0,0 +1,19 @@ +{ + "browser": true + , "devel": true + , "bitwise": true + , "undef": true + , "trailing": true + , "quotmark": false + , "indent": 4 + , "unused": "vars" + , "latedef": "nofunc" + , "globals": { + "module": false, + "exports": false, + "require": false, + "FileTransferError": true, + "FileUploadResult": true, + "resolveLocalFileSystemURI": false + } +} diff --git a/plugins/cordova-plugin-file-transfer/.npmignore b/plugins/cordova-plugin-file-transfer/.npmignore new file mode 100644 index 0000000..ef71d04 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/.npmignore @@ -0,0 +1,15 @@ +#If ignorance is bliss, then somebody knock the smile off my face + +*.csproj.user +*.suo +*.cache +Thumbs.db +*.DS_Store + +*.bak +*.cache +*.log +*.swp +*.user + +node_modules diff --git a/plugins/cordova-plugin-file-transfer/.travis.yml b/plugins/cordova-plugin-file-transfer/.travis.yml new file mode 100644 index 0000000..08cf033 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/.travis.yml @@ -0,0 +1,71 @@ +sudo: false +addons: + jwt: + secure: hXzjjCvaueH+0Mm66ym6nE3jncWjjGIXIqhrqQUpWI7WTzcEXPFzA2ljyMNcMbPCcXSpq7u3oEBgZl5VUd+PWfBWKCFbcTu0KP1KP7s2GeTp/xvWWoxxRYfU8FhUh5ei/opSBBDhT9zqt85efHt09aqAzos0THLpYPGxFPknzY0= +env: + global: + - SAUCE_USERNAME=snay + - TRAVIS_NODE_VERSION="4.2" +matrix: + include: + - env: PLATFORM=ios-9.3 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=ios-10.0 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=android-4.4 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - build-tools-26.0.2 + - env: PLATFORM=android-5.1 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - build-tools-26.0.2 + - env: PLATFORM=android-6.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - build-tools-26.0.2 + - env: PLATFORM=android-7.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - build-tools-26.0.2 +before_install: +- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm + && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm + install $TRAVIS_NODE_VERSION +- node --version +- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi +- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi +- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26; + fi +- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic + && npm install && popd +- npm install -g cordova +install: +- npm install +script: +- npm test +- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce + --fileTransferServer http://sheltered-retreat-43956.herokuapp.com + --buildName travis-plugin-file-transfer-$TRAVIS_JOB_NUMBER diff --git a/plugins/cordova-plugin-file-transfer/package.json b/plugins/cordova-plugin-file-transfer/package.json new file mode 100644 index 0000000..cac7a9a --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/package.json @@ -0,0 +1,93 @@ +{ + "_from": "cordova-plugin-file-transfer", + "_id": "cordova-plugin-file-transfer@1.7.1", + "_inBundle": false, + "_integrity": "sha1-p12L4uvDu5sjxbG70ZkhTsJnWGs=", + "_location": "/cordova-plugin-file-transfer", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "cordova-plugin-file-transfer", + "name": "cordova-plugin-file-transfer", + "escapedName": "cordova-plugin-file-transfer", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/cordova-plugin-file-transfer/-/cordova-plugin-file-transfer-1.7.1.tgz", + "_shasum": "a75d8be2ebc3bb9b23c5b1bbd199214ec267586b", + "_spec": "cordova-plugin-file-transfer", + "_where": "/home/jfolpf/form-for-parking-violation", + "author": { + "name": "Apache Software Foundation" + }, + "bugs": { + "url": "https://issues.apache.org/jira/browse/CB" + }, + "bundleDependencies": false, + "cordova": { + "id": "cordova-plugin-file-transfer", + "platforms": [ + "android", + "amazon-fireos", + "ubuntu", + "blackberry10", + "ios", + "wp7", + "wp8", + "windows8", + "windows", + "firefoxos", + "browser" + ] + }, + "deprecated": false, + "description": "Cordova File Transfer Plugin", + "devDependencies": { + "jscs": "^2.6.0", + "jshint": "^2.8.0" + }, + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "homepage": "https://github.com/apache/cordova-plugin-file-transfer#readme", + "keywords": [ + "cordova", + "file", + "transfer", + "ecosystem:cordova", + "cordova-android", + "cordova-amazon-fireos", + "cordova-ubuntu", + "cordova-blackberry10", + "cordova-ios", + "cordova-wp7", + "cordova-wp8", + "cordova-windows8", + "cordova-windows", + "cordova-firefoxos", + "cordova-browser" + ], + "license": "Apache-2.0", + "name": "cordova-plugin-file-transfer", + "repository": { + "type": "git", + "url": "git+https://github.com/apache/cordova-plugin-file-transfer.git" + }, + "scripts": { + "lint": "jshint www && jshint src && jshint tests", + "style": "jscs tests/tests.js", + "test": "npm run lint && npm run style" + }, + "types": "./types/index.d.ts", + "version": "1.7.1" +} diff --git a/plugins/cordova-plugin-file-transfer/plugin.xml b/plugins/cordova-plugin-file-transfer/plugin.xml new file mode 100644 index 0000000..bfacbb1 --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/plugin.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + xmlns:android="http://schemas.android.com/apk/res/android" + id="cordova-plugin-file-transfer" + version="1.7.1"> + <name>File Transfer</name> + <description>Cordova File Transfer Plugin</description> + <license>Apache 2.0</license> + <keywords>cordova,file,transfer</keywords> + <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git</repo> + <issue>https://issues.apache.org/jira/browse/CB/component/12320650</issue> + + <dependency id="cordova-plugin-file" version=">=5.0.0" /> + + <js-module src="www/FileTransferError.js" name="FileTransferError"> + <clobbers target="window.FileTransferError" /> + </js-module> + + <js-module src="www/FileTransfer.js" name="FileTransfer"> + <clobbers target="window.FileTransfer" /> + </js-module> + + <!-- android --> + <platform name="android"> + <config-file target="res/xml/config.xml" parent="/*"> + <feature name="FileTransfer" > + <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer"/> + </feature> + </config-file> + + <config-file target="AndroidManifest.xml" parent="/*"> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + </config-file> + + <source-file src="src/android/FileTransfer.java" target-dir="src/org/apache/cordova/filetransfer" /> + <source-file src="src/android/FileProgressResult.java" target-dir="src/org/apache/cordova/filetransfer" /> + <source-file src="src/android/FileUploadResult.java" target-dir="src/org/apache/cordova/filetransfer" /> + </platform> + + <!-- amamzon-fireos --> + <platform name="amazon-fireos"> + <config-file target="res/xml/config.xml" parent="/*"> + <feature name="FileTransfer" > + <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer"/> + </feature> + </config-file> + + <config-file target="AndroidManifest.xml" parent="/*"> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + </config-file> + + <source-file src="src/amazon/FileTransfer.java" target-dir="src/org/apache/cordova/filetransfer" /> + <source-file src="src/android/FileProgressResult.java" target-dir="src/org/apache/cordova/filetransfer" /> + <source-file src="src/android/FileUploadResult.java" target-dir="src/org/apache/cordova/filetransfer" /> + </platform> + + <!-- ubuntu --> + <platform name="ubuntu"> + <header-file src="src/ubuntu/file-transfer.h" /> + <source-file src="src/ubuntu/file-transfer.cpp" /> + </platform> + + <!-- blackberry10 --> + <platform name="blackberry10"> + <config-file target="www/config.xml" parent="/widget"> + <feature name="FileTransfer" value="FileTransfer"></feature> + </config-file> + <js-module src="www/blackberry10/FileTransferProxy.js" name="FileTransferProxy" > + <runs /> + </js-module> + <js-module src="www/blackberry10/xhrFileTransfer.js" name="xhrFileTransfer" /> + <!-- + <js-module src="www/blackberry10/abort.js" name="abortProxy" /> + <js-module src="www/blackberry10/download.js" name="downloadProxy" /> + <js-module src="www/blackberry10/upload.js" name="uploadProxy" /> + --> + </platform> + + <!-- ios --> + <platform name="ios"> + <config-file target="config.xml" parent="/*"> + <feature name="FileTransfer"> + <param name="ios-package" value="CDVFileTransfer" /> + </feature> + </config-file> + <header-file src="src/ios/CDVFileTransfer.h" /> + <source-file src="src/ios/CDVFileTransfer.m" /> + + <framework src="AssetsLibrary.framework" /> + </platform> + + <!-- wp7 --> + <platform name="wp7"> + <config-file target="config.xml" parent="/*"> + <feature name="FileTransfer"> + <param name="wp-package" value="FileTransfer"/> + </feature> + </config-file> + + <source-file src="src/wp/FileTransfer.cs" /> + + <js-module src="www/wp7/base64.js" name="base64"> + <clobbers target="window.FileTransferBase64" /> + </js-module> + + </platform> + + <!-- wp8 --> + <platform name="wp8"> + <config-file target="config.xml" parent="/*"> + <feature name="FileTransfer"> + <param name="wp-package" value="FileTransfer"/> + </feature> + </config-file> + + <source-file src="src/wp/FileTransfer.cs" /> + + </platform> + + <!-- windows8 --> + <platform name="windows8"> + <js-module src="src/windows/FileTransferProxy.js" name="FileTransferProxy"> + <runs /> + </js-module> + </platform> + + <!-- windows --> + <platform name="windows"> + <js-module src="src/windows/FileTransferProxy.js" name="FileTransferProxy"> + <runs /> + </js-module> + </platform> + + <!-- firefoxOS --> + <platform name="firefoxos"> + <config-file target="config.xml" parent="/*"> + <permission name="systemXHR" privileged="true"/> + </config-file> + + <js-module src="www/firefoxos/FileTransferProxy.js" name="FileTransferProxy"> + <runs/> + </js-module> + </platform> + + <!-- browser --> + <platform name="browser"> + <js-module src="www/browser/FileTransfer.js" name="BrowserFileTransfer"> + <clobbers target="window.FileTransfer" /> + </js-module> + </platform> +</plugin> diff --git a/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp b/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp new file mode 100644 index 0000000..5b1adea --- /dev/null +++ b/plugins/cordova-plugin-file-transfer/src/ubuntu/file-transfer.cpp @@ -0,0 +1,265 @@ +/* + * + * Copyright 2013 Canonical Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +#include "file-transfer.h" +#include <plugins/cordova-plugin-file/file.h> +#include <cassert> + +static void SetHeaders(QNetworkRequest &request, const QVariantMap &headers) { + for (const QString &key: headers.keys()) { + QVariant val = *headers.find(key); + QString value = val.toString(); + if (val.userType() == QMetaType::QVariantList || val.userType() == QMetaType::QStringList) { + QList<QVariant> list = val.toList(); + for (QVariant v: list) { + if (value.size()) + value += ", "; + value += v.toString(); + } + } + request.setRawHeader(key.toUtf8(), value.toUtf8()); + } +} + +void FileTransfer::download(int scId, int ecId, const QString& url, const QString &target, bool /*trustAllHost*/, int id, const QVariantMap &headers) { + QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this)); + + assert(_id2request.find(id) == _id2request.end()); + + _id2request.insert(id, request); + + request->connect(request.data(), &FileTransferRequest::done, [&]() { + auto it = _id2request.find(id); + while (it != _id2request.end() && it.key() == id) { + if (it.value().data() == request.data()) { + _id2request.erase(it); + break; + } + it++; + } + }); + request->download(url, target, headers); +} + +void FileTransfer::upload(int scId, int ecId, const QString &fileURI, const QString& url, const QString& fileKey, const QString& fileName, const QString& mimeType, + const QVariantMap & params, bool /*trustAllHosts*/, bool /*chunkedMode*/, const QVariantMap &headers, int id, const QString &/*httpMethod*/) { + QSharedPointer<FileTransferRequest> request(new FileTransferRequest(_manager, scId, ecId, id, this)); + + assert(_id2request.find(id) == _id2request.end()); + + _id2request.insert(id, request); + + request->connect(request.data(), &FileTransferRequest::done, [&]() { + auto it = _id2request.find(id); + while (it != _id2request.end() && it.key() == id) { + if (it.value().data() == request.data()) { + _id2request.erase(it); + break; + } + it++; + } + }); + request->upload(url, fileURI, fileKey, fileName, mimeType, params, headers); +} + +void FileTransfer::abort(int scId, int ecId, int id) { + Q_UNUSED(scId) + Q_UNUSED(ecId) + + auto it = _id2request.find(id); + while (it != _id2request.end() && it.key() == id) { + (*it)->abort(); + it++; + } +} + +void FileTransferRequest::download(const QString& uri, const QString &targetURI, const QVariantMap &headers) { + QUrl url(uri); + QNetworkRequest request; + + QSharedPointer<CPlugin> filePlugin(_plugin->cordova()->getPlugin<File>()); + + if (!filePlugin.data()) + return; + + if (!url.isValid()) { + QVariantMap map; + map.insert("code", INVALID_URL_ERR); + map.insert("source", uri); + map.insert("target", targetURI); + _plugin->cb(_ecId, map); + emit done(); + return; + } + + request.setUrl(url); + if (url.password().size() || url.userName().size()) { + QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); + request.setRawHeader("Authorization", headerData.toLocal8Bit()); + } + SetHeaders(request, headers); + _reply = QSharedPointer<QNetworkReply>(_manager.get(request)); + + _reply->connect(_reply.data(), &QNetworkReply::finished, [this, targetURI, uri, filePlugin]() { + if (!_scId || _reply->error() != QNetworkReply::NoError) + return; + + QPair<bool, QFileInfo> f1(dynamic_cast<File*>(filePlugin.data())->resolveURI(targetURI)); + + QFile res(f1.second.absoluteFilePath()); + if (!f1.first || !res.open(QIODevice::WriteOnly)) { + QVariantMap map; + map.insert("code", INVALID_URL_ERR); + map.insert("source", uri); + map.insert("target", targetURI); + _plugin->cb(_ecId, map); + emit done(); + return; + } + res.write(_reply->readAll()); + + _plugin->cb(_scId, dynamic_cast<File*>(filePlugin.data())->file2map(f1.second)); + + emit done(); + }); + _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); + _reply->connect(_reply.data(), SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); +} + +void FileTransferRequest::upload(const QString& _url, const QString& fileURI, QString fileKey, QString fileName, QString mimeType, const QVariantMap ¶ms, const QVariantMap &headers) { + QUrl url(_url); + QNetworkRequest request; + + QSharedPointer<CPlugin> filePlugin(_plugin->cordova()->getPlugin<File>()); + + if (!filePlugin.data()) + return; + + if (!url.isValid()) { + QVariantMap map; + map.insert("code", INVALID_URL_ERR); + map.insert("source", fileURI); + map.insert("target", _url); + _plugin->cb(_ecId, map); + emit done(); + return; + } + + QPair<bool, QFileInfo> f1(dynamic_cast<File*>(filePlugin.data())->resolveURI(fileURI)); + QFile file(f1.second.absoluteFilePath()); + if (!f1.first || !file.open(QIODevice::ReadOnly)) { + QVariantMap map; + map.insert("code", FILE_NOT_FOUND_ERR); + map.insert("source", fileURI); + map.insert("target", _url); + _plugin->cb(_ecId, map); + emit done(); + return; + } + QString content{file.readAll()}; + + request.setUrl(url); + if (url.password().size() || url.userName().size()) { + QString headerData = "Basic " + (url.userName() + ":" + url.password()).toLocal8Bit().toBase64(); + request.setRawHeader("Authorization", headerData.toLocal8Bit()); + } + SetHeaders(request, headers); + + QString boundary = QString("CORDOVA-QT-%1A").arg(qrand()); + while (content.contains(boundary)) { + boundary += QString("B%1A").arg(qrand()); + } + + request.setHeader(QNetworkRequest::ContentTypeHeader, QString("multipart/form-data; boundary=") + boundary); + + fileKey.replace("\"", ""); + fileName.replace("\"", ""); + mimeType.replace("\"", ""); + QString part = "--" + boundary + "\r\n"; + + part += "Content-Disposition: form-data; name=\"" + fileKey +"\"; filename=\"" + fileName + "\"\r\n"; + part += "Content-Type: " + mimeType + "\r\n\r\n"; + part += content + "\r\n"; + + for (QString key: params.keys()) { + part += "--" + boundary + "\r\n"; + part += "Content-Disposition: form-data; name=\"" + key + "\";\r\n\r\n"; + part += params.find(key)->toString(); + part += "\r\n"; + } + + part += QString("--") + boundary + "--" + "\r\n"; + + _reply = QSharedPointer<QNetworkReply>(_manager.post(request, QByteArray(part.toUtf8()))); + + _reply->connect(_reply.data(), &QNetworkReply::finished, [this, content]() { + if (_reply->error() != QNetworkReply::NoError) + return; + int status = 200; + QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); + + if (statusCode.isValid()) { + status = statusCode.toInt(); + } + + QVariantMap map; + map.insert("responseCode", status); + map.insert("response", QString(_reply->readAll())); + map.insert("bytesSent", content.size()); + _plugin->cb(_scId, map); + emit done(); + }); + _reply->connect(_reply.data(), SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); + _reply->connect(_reply.data(), SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); +} + +void FileTransferRequest::abort() { + QVariantMap map; + map.insert("code", ABORT_ERR); + _plugin->cb(_ecId, map); + _scId = 0; + emit done(); +} + +void FileTransferRequest::error(QNetworkReply::NetworkError code) { + Q_UNUSED(code); + + int status = 404; + QVariant statusCode = _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); + if (statusCode.isValid()) { + status = statusCode.toInt(); + } + + QVariantMap map; + map.insert("http_status", status); + map.insert("body", QString(_reply->readAll())); + map.insert("code", CONNECTION_ERR); + _plugin->cb(_ecId, map); + emit done(); +} + +void FileTransferRequest::progress(qint64 bytesReceived, qint64 bytesTotal) { + QVariantMap map; + map.insert("lengthComputable", true); + map.insert("total", bytesTotal); + map.insert("loaded", bytesReceived); + + if (bytesReceived && bytesTotal && _scId) + _plugin->callbackWithoutRemove(_scId, CordovaInternal::format(map)); +} diff --git a/plugins/cordova-plugin-file/www/blackberry10/.jshintrc b/plugins/cordova-plugin-file-transfer/www/blackberry10/.jshintrc similarity index 100% rename from plugins/cordova-plugin-file/www/blackberry10/.jshintrc rename to plugins/cordova-plugin-file-transfer/www/blackberry10/.jshintrc diff --git a/plugins/cordova-plugin-file/.appveyor.yml b/plugins/cordova-plugin-file/.appveyor.yml new file mode 100644 index 0000000..4cd6d53 --- /dev/null +++ b/plugins/cordova-plugin-file/.appveyor.yml @@ -0,0 +1,28 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml + +max_jobs: 1 + +shallow_clone: true + +init: + - git config --global core.autocrlf true + +image: + - Visual Studio 2017 + +environment: + nodejs_version: "4" + matrix: + - PLATFORM: windows-10-store + +install: + - npm cache clean -f + - node --version + - npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git + - npm install -g cordova + +build: off + +test_script: + - cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild diff --git a/plugins/cordova-plugin-file/.eslintrc.yml b/plugins/cordova-plugin-file/.eslintrc.yml new file mode 100644 index 0000000..0cccb8c --- /dev/null +++ b/plugins/cordova-plugin-file/.eslintrc.yml @@ -0,0 +1,10 @@ +root: true +extends: semistandard +rules: + indent: + - error + - 4 + camelcase: off + padded-blocks: off + operator-linebreak: off + no-throw-literal: off \ No newline at end of file diff --git a/plugins/cordova-plugin-file/.travis.yml b/plugins/cordova-plugin-file/.travis.yml index b9af4c5..77dd88e 100644 --- a/plugins/cordova-plugin-file/.travis.yml +++ b/plugins/cordova-plugin-file/.travis.yml @@ -1,4 +1,78 @@ -language: node_js sudo: false -node_js: - - "4.2" +addons: + jwt: + secure: JYUSu0UCRC8cpcuh39sn9RqkGBFbG7Hcil3NTpTWbnDRbNrlZeCzDDSirSRD9rPC+M3AEmTo3zKHuWusjUSV4NWLoad/Yd0JXgSNKmxxdESlN6stxCn7oK1I7DwcSlW7capx/44fEjOZ5hajO4mjM/QYuu7+QOuaKvhP5jQjong= +env: + global: + - SAUCE_USERNAME=snay + - TRAVIS_NODE_VERSION="4.2" +matrix: + include: + - env: PLATFORM=browser-firefox + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=browser-safari + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=browser-edge + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=ios-9.3 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=ios-10.0 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=android-4.4 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - env: PLATFORM=android-5.1 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - env: PLATFORM=android-6.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - env: PLATFORM=android-7.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools +before_install: +- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm + && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm + install $TRAVIS_NODE_VERSION +- node --version +- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi +- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi +- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26; + fi +- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic + && npm install && popd +- npm install -g cordova +install: +- npm install +script: +- npm test +- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce + --buildName travis-plugin-file-$TRAVIS_JOB_NUMBER diff --git a/plugins/cordova-plugin-file/package.json b/plugins/cordova-plugin-file/package.json index fa38248..82fc38f 100644 --- a/plugins/cordova-plugin-file/package.json +++ b/plugins/cordova-plugin-file/package.json @@ -1,61 +1,62 @@ { - "_args": [ - [ - "cordova-plugin-file@4.3.3", - "/home/jfolpf/form-for-parking-violation" - ] - ], - "_from": "cordova-plugin-file@4.3.3", - "_id": "cordova-plugin-file@4.3.3", + "_from": "cordova-plugin-file@6.0.1", + "_id": "cordova-plugin-file@6.0.1", "_inBundle": false, - "_integrity": "sha1-AS6Xqhr7kfhJFuY0G1SDZtI96bk=", + "_integrity": "sha1-SWBrjBWlaI1HKPkuSnMloGHeB/U=", "_location": "/cordova-plugin-file", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "cordova-plugin-file@4.3.3", + "raw": "cordova-plugin-file@6.0.1", "name": "cordova-plugin-file", "escapedName": "cordova-plugin-file", - "rawSpec": "4.3.3", + "rawSpec": "6.0.1", "saveSpec": null, - "fetchSpec": "4.3.3" + "fetchSpec": "6.0.1" }, "_requiredBy": [ + "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-4.3.3.tgz", - "_spec": "4.3.3", + "_resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.1.tgz", + "_shasum": "49606b8c15a5688d4728f92e4a7325a061de07f5", + "_spec": "cordova-plugin-file@6.0.1", "_where": "/home/jfolpf/form-for-parking-violation", "author": { "name": "Apache Software Foundation" }, "bugs": { - "url": "https://github.com/apache/cordova-plugin-file/issues" + "url": "https://issues.apache.org/jira/browse/CB" }, + "bundleDependencies": false, "cordova": { "id": "cordova-plugin-file", "platforms": [ "android", - "amazon-fireos", - "ubuntu", + "browser", "ios", "osx", - "wp7", - "wp8", - "blackberry10", - "windows8", - "windows", - "firefoxos" + "windows" ] }, + "deprecated": false, "description": "Cordova File Plugin", "devDependencies": { - "jshint": "^2.6.0" + "eslint": "^3.19.0", + "eslint-config-semistandard": "^11.0.0", + "eslint-config-standard": "^10.2.1", + "eslint-plugin-import": "^2.3.0", + "eslint-plugin-node": "^5.0.0", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^3.0.1" }, "engines": { "cordovaDependencies": { "5.0.0": { + "cordova-android": ">=6.3.0" + }, + "7.0.0": { "cordova": ">100" } } @@ -66,16 +67,10 @@ "file", "ecosystem:cordova", "cordova-android", - "cordova-amazon-fireos", - "cordova-ubuntu", + "cordova-browser", "cordova-ios", "cordova-osx", - "cordova-wp7", - "cordova-wp8", - "cordova-blackberry10", - "cordova-windows8", - "cordova-windows", - "cordova-firefoxos" + "cordova-windows" ], "license": "Apache-2.0", "name": "cordova-plugin-file", @@ -84,9 +79,9 @@ "url": "git+https://github.com/apache/cordova-plugin-file.git" }, "scripts": { - "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests", - "test": "npm run jshint" + "eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests", + "test": "npm run eslint" }, "types": "./types/index.d.ts", - "version": "4.3.3" + "version": "6.0.1" } diff --git a/plugins/cordova-plugin-file/plugin.xml b/plugins/cordova-plugin-file/plugin.xml index d1662ce..ecd15e9 100644 --- a/plugins/cordova-plugin-file/plugin.xml +++ b/plugins/cordova-plugin-file/plugin.xml @@ -21,14 +21,17 @@ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-file" - version="4.3.3"> + version="6.0.1"> <name>File</name> <description>Cordova File Plugin</description> <license>Apache 2.0</license> <keywords>cordova,file</keywords> <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git</repo> <issue>https://issues.apache.org/jira/browse/CB/component/12320651</issue> - <dependency id="cordova-plugin-compat" version="^1.0.0" /> + + <engines> + <engine name="cordova-android" version=">=6.3.0" /> + </engines> <js-module src="www/DirectoryEntry.js" name="DirectoryEntry"> <clobbers target="window.DirectoryEntry" /> @@ -161,61 +164,6 @@ to config.xml in order for the application to find previously stored files. </js-module> </platform> - <!-- amazon-fireos --> - <platform name="amazon-fireos"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="File" > - <param name="android-package" value="org.apache.cordova.file.FileUtils"/> - <param name="onload" value="true" /> - </feature> - </config-file> - - <config-file target="AndroidManifest.xml" parent="/*"> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> - </config-file> - - <source-file src="src/android/EncodingException.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/FileExistsException.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/InvalidModificationException.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/NoModificationAllowedException.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/TypeMismatchException.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/FileUtils.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/DirectoryManager.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/LocalFilesystemURL.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/Filesystem.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/LocalFilesystem.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/ContentFilesystem.java" target-dir="src/org/apache/cordova/file" /> - <source-file src="src/android/AssetFilesystem.java" target-dir="src/org/apache/cordova/file" /> - - - <!-- android specific file apis --> - <js-module src="www/android/FileSystem.js" name="androidFileSystem"> - <merges target="window.FileSystem" /> - </js-module> - <js-module src="www/fileSystems-roots.js" name="fileSystems-roots"> - <runs/> - </js-module> - <js-module src="www/fileSystemPaths.js" name="fileSystemPaths"> - <merges target="cordova" /> - <runs/> - </js-module> - </platform> - - <!-- ubuntu --> - <platform name="ubuntu"> - <header-file src="src/ubuntu/file.h" /> - <source-file src="src/ubuntu/file.cpp" /> - <js-module src="www/ubuntu/FileSystem.js" name="ubuntuFileSystem1"> - <merges target="window.FileSystem" /> - </js-module> - <js-module src="www/ubuntu/FileWriter.js" name="FileWriter1"> - <merges target="window.FileWriter" /> - </js-module> - <js-module src="www/ubuntu/fileSystems-roots.js" name="fileSystems-roots"> - <runs/> - </js-module> - </platform> - <!-- ios --> <platform name="ios"> <config-file target="config.xml" parent="/*"> @@ -277,101 +225,6 @@ to config.xml in order for the application to find previously stored files. </js-module> </platform> - <!-- wp7 --> - <platform name="wp7"> - <config-file target="config.xml" parent="/*"> - <feature name="File"> - <param name="wp-package" value="File"/> - </feature> - </config-file> - - <source-file src="src/wp/File.cs" /> - - <!-- wp specific file apis --> - <js-module src="www/wp/FileUploadOptions.js" name="FileUploadOptions1"> - <merges target="window.FileUploadOptions" /> - </js-module> - - </platform> - - <!-- wp8 --> - <platform name="wp8"> - <config-file target="config.xml" parent="/*"> - <feature name="File"> - <param name="wp-package" value="File"/> - </feature> - </config-file> - - <source-file src="src/wp/File.cs" /> - - <!-- wp specific file apis --> - <js-module src="www/wp/FileUploadOptions.js" name="FileUploadOptions1"> - <merges target="window.FileUploadOptions" /> - </js-module> - - </platform> - - <!-- blackberry10 --> - <platform name="blackberry10"> - <config-file target="www/config.xml" parent="/widget"> - <feature name="File" value="File" /> - </config-file> - <js-module src="www/blackberry10/FileProxy.js" name="FileProxy" > - <runs /> - </js-module> - <js-module src="www/blackberry10/info.js" name="bb10FileSystemInfo"> - <runs /> - </js-module> - <js-module src="www/blackberry10/createEntryFromNative.js" name="bb10CreateEntryFromNative"> - <runs /> - </js-module> - <js-module src="www/blackberry10/requestAnimationFrame.js" name="bb10RequestAnimationFrame"> - <runs /> - </js-module> - <js-module src="www/blackberry10/FileSystem.js" name="bb10FileSystem"> - <merges target="window.FileSystem" /> - </js-module> - <js-module src="www/fileSystems-roots.js" name="fileSystems-roots"> - <runs/> - </js-module> - <js-module src="www/fileSystemPaths.js" name="fileSystemPaths"> - <merges target="cordova" /> - </js-module> - <js-module src="www/blackberry10/copyTo.js" name="copyToProxy" /> - <js-module src="www/blackberry10/getDirectory.js" name="getDirectoryProxy" /> - <js-module src="www/blackberry10/getFile.js" name="getFileProxy" /> - <js-module src="www/blackberry10/getFileMetadata.js" name="getFileMetadataProxy" /> - <js-module src="www/blackberry10/getMetadata.js" name="getMetadataProxy" /> - <js-module src="www/blackberry10/getParent.js" name="getParentProxy" /> - <js-module src="www/blackberry10/moveTo.js" name="moveToProxy" /> - <js-module src="www/blackberry10/readAsArrayBuffer.js" name="readAsArrayBufferProxy" /> - <js-module src="www/blackberry10/readAsBinaryString.js" name="readAsBinaryStringProxy" /> - <js-module src="www/blackberry10/readAsDataURL.js" name="readAsDataURLProxy" /> - <js-module src="www/blackberry10/readAsText.js" name="readAsTextProxy" /> - <js-module src="www/blackberry10/readEntries.js" name="readEntriesProxy" /> - <js-module src="www/blackberry10/remove.js" name="removeProxy" /> - <js-module src="www/blackberry10/removeRecursively.js" name="removeRecursivelyProxy" /> - <js-module src="www/blackberry10/resolveLocalFileSystemURI.js" name="resolveLocalFileSystemURIProxy" /> - <js-module src="www/blackberry10/requestAllFileSystems.js" name="requestAllFileSystemsProxy" /> - <js-module src="www/blackberry10/requestFileSystem.js" name="requestFileSystemProxy" /> - <js-module src="www/blackberry10/setMetadata.js" name="setMetadataProxy" /> - <js-module src="www/blackberry10/truncate.js" name="truncateProxy" /> - <js-module src="www/blackberry10/write.js" name="writeProxy" /> - <source-file src="src/blackberry10/index.js" target-dir="File" /> - </platform> - - <!-- windows8 --> - <platform name="windows8"> - <js-module src="src/windows/FileProxy.js" name="FileProxy"> - <runs /> - </js-module> - - <js-module src="www/fileSystemPaths.js" name="fileSystemPaths"> - <merges target="cordova" /> - <runs/> - </js-module> - </platform> - <!-- windows --> <platform name="windows"> <js-module src="src/windows/FileProxy.js" name="FileProxy"> @@ -384,23 +237,6 @@ to config.xml in order for the application to find previously stored files. </js-module> </platform> - <!-- firefox os --> - <platform name="firefoxos"> - <js-module src="src/firefoxos/FileProxy.js" name="FileProxy"> - <runs /> - </js-module> - - <js-module src="www/fileSystemPaths.js" name="fileSystemPaths"> - <merges target="cordova" /> - <runs/> - </js-module> - - <!-- Firefox OS specific file apis --> - <js-module src="www/firefoxos/FileSystem.js" name="firefoxFileSystem"> - <merges target="window.FileSystem" /> - </js-module> - </platform> - <platform name="browser"> <!-- File for Chrome --> <js-module src="www/browser/Preparing.js" name="Preparing"> diff --git a/plugins/cordova-plugin-file/src/ubuntu/file.cpp b/plugins/cordova-plugin-file/src/ubuntu/file.cpp deleted file mode 100644 index 395ab2d..0000000 --- a/plugins/cordova-plugin-file/src/ubuntu/file.cpp +++ /dev/null @@ -1,912 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "file.h" - -#include <QApplication> - -namespace { - class FileError { - public: - static const QString kEncodingErr; - static const QString kTypeMismatchErr; - static const QString kNotFoundErr; - static const QString kSecurityErr; - static const QString kAbortErr; - static const QString kNotReadableErr; - static const QString kNoModificationAllowedErr; - static const QString kInvalidStateErr; - static const QString kSyntaxErr; - static const QString kInvalidModificationErr; - static const QString kQuotaExceededErr; - static const QString kPathExistsErr; - }; - - bool checkFileName(const QString &name) { - if (name.contains(":")){ - return false; - } - return true; - } -}; - -const QString FileError::kEncodingErr("FileError.ENCODING_ERR"); -const QString FileError::kTypeMismatchErr("FileError.TYPE_MISMATCH_ERR"); -const QString FileError::kNotFoundErr("FileError.NOT_FOUND_ERR"); -const QString FileError::kSecurityErr("FileError.SECURITY_ERR"); -const QString FileError::kAbortErr("FileError.ABORT_ERR"); -const QString FileError::kNotReadableErr("FileError.NOT_READABLE_ERR"); -const QString FileError::kNoModificationAllowedErr("FileError.NO_MODIFICATION_ALLOWED_ERR"); -const QString FileError::kInvalidStateErr("FileError.INVALID_STATE_ERR"); -const QString FileError::kSyntaxErr("FileError.SYNTAX_ERR"); -const QString FileError::kInvalidModificationErr("FileError.INVALID_MODIFICATION_ERR"); -const QString FileError::kQuotaExceededErr("FileError.QUOTA_EXCEEDED_ERR"); -const QString FileError::kPathExistsErr("FileError.PATH_EXISTS_ERR"); - -File::File(Cordova *cordova) : - CPlugin(cordova), - _persistentDir(QString("%1/.local/share/%2/persistent").arg(QDir::homePath()).arg(QCoreApplication::applicationName())) { - QDir::root().mkpath(_persistentDir.absolutePath()); -} - -QVariantMap File::file2map(const QFileInfo &fileInfo) { - QVariantMap res; - - res.insert("name", fileInfo.fileName()); - QPair<QString, QString> r = GetRelativePath(fileInfo); - res.insert("fullPath", QString("/") + r.second); - res.insert("filesystemName", r.first); - - res.insert("nativeURL", QString("file://localhost") + fileInfo.absoluteFilePath()); - res.insert("isDirectory", (int)fileInfo.isDir()); - res.insert("isFile", (int)fileInfo.isFile()); - - return res; -} - -QVariantMap File::dir2map(const QDir &dir) { - return file2map(QFileInfo(dir.absolutePath())); -} - -QPair<QString, QString> File::GetRelativePath(const QFileInfo &fileInfo) { - QString fullPath = fileInfo.isDir() ? QDir::cleanPath(fileInfo.absoluteFilePath()) : fileInfo.absoluteFilePath(); - - QString relativePath1 = _persistentDir.relativeFilePath(fullPath); - QString relativePath2 = QDir::temp().relativeFilePath(fullPath); - - if (!(relativePath1[0] != '.' || relativePath2[0] != '.')) { - if (relativePath1.size() > relativePath2.size()) { - return QPair<QString, QString>("temporary", relativePath2); - } else { - return QPair<QString, QString>("persistent", relativePath1); - } - } - - if (relativePath1[0] != '.') - return QPair<QString, QString>("persistent", relativePath1); - return QPair<QString, QString>("temporary", relativePath2); -} - -void File::requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size) { - QDir dir; - - if (size >= 1000485760){ - this->callback(ecId, FileError::kQuotaExceededErr); - return; - } - - if (type == 0) - dir = QDir::temp(); - else - dir = _persistentDir; - - if (type > 1) { - this->callback(ecId, FileError::kSyntaxErr); - return; - } else { - QVariantMap res; - res.insert("root", dir2map(dir)); - if (type == 0) - res.insert("name", "temporary"); - else - res.insert("name", "persistent"); - - this->cb(scId, res); - } -} - -QPair<bool, QFileInfo> File::resolveURI(int ecId, const QString &uri) { - QPair<bool, QFileInfo> result; - - result.first = false; - - QUrl url = QUrl::fromUserInput(uri); - - if (url.scheme() == "file" && url.isValid()) { - result.first = true; - result.second = QFileInfo(url.path()); - return result; - } - - if (url.scheme() != "cdvfile") { - if (ecId) - this->callback(ecId, FileError::kTypeMismatchErr); - return result; - } - - QString path = url.path().replace("//", "/"); - //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable it here. - if (path.contains(":") || !url.isValid()){ - if (ecId) - this->callback(ecId, FileError::kEncodingErr); - return result; - } - if (!path.startsWith("/persistent/") && !path.startsWith("/temporary/")) { - if (ecId) - this->callback(ecId, FileError::kEncodingErr); - return result; - } - - result.first = true; - if (path.startsWith("/persistent/")) { - QString relativePath = path.mid(QString("/persistent/").size()); - result.second = QFileInfo(_persistentDir.filePath(relativePath)); - } else { - QString relativePath = path.mid(QString("/temporary/").size()); - result.second = QFileInfo(QDir::temp().filePath(relativePath)); - } - return result; -} - -QPair<bool, QFileInfo> File::resolveURI(const QString &uri) { - return resolveURI(0, uri); -} - - -void File::_getLocalFilesystemPath(int scId, int ecId, const QString& uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - this->cb(scId, f1.second.absoluteFilePath()); -} - -void File::resolveLocalFileSystemURI(int scId, int ecId, const QString &uri) { - if (uri[0] == '/' || uri[0] == '.') { - this->callback(ecId, FileError::kEncodingErr); - return; - } - - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFileInfo fileInfo = f1.second; - if (!fileInfo.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - this->cb(scId, file2map(fileInfo)); -} - -void File::getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, parentPath + "/" + rpath); - if (!f1.first) - return; - - bool create = options.value("create").toBool(); - bool exclusive = options.value("exclusive").toBool(); - QFile file(f1.second.absoluteFilePath()); - - // if create is false and the path represents a directory, return error - QFileInfo fileInfo = f1.second; - if ((!create) && fileInfo.isDir()) { - this->callback(ecId, FileError::kTypeMismatchErr); - return; - } - - // if file does exist, and create is true and exclusive is true, return error - if (file.exists()) { - if (create && exclusive) { - this->callback(ecId, FileError::kPathExistsErr); - return; - } - } - else { - // if file does not exist and create is false, return error - if (!create) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - file.open(QIODevice::WriteOnly); - file.close(); - - // Check if creation was successfull - if (!file.exists()) { - this->callback(ecId, FileError::kNoModificationAllowedErr); - return; - } - } - - this->cb(scId, file2map(QFileInfo(file))); -} - -void File::getDirectory(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, parentPath + "/" + rpath); - if (!f1.first) - return; - - bool create = options.value("create").toBool(); - bool exclusive = options.value("exclusive").toBool(); - QDir dir(f1.second.absoluteFilePath()); - - QFileInfo &fileInfo = f1.second; - if ((!create) && fileInfo.isFile()) { - this->callback(ecId, FileError::kTypeMismatchErr); - return; - } - - if (dir.exists()) { - if (create && exclusive) { - this->callback(ecId, FileError::kPathExistsErr); - return; - } - } - else { - if (!create) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - QString folderName = dir.dirName(); - dir.cdUp(); - dir.mkdir(folderName); - dir.cd(folderName); - - if (!dir.exists()) { - this->callback(ecId, FileError::kNoModificationAllowedErr); - return; - } - } - - this->cb(scId, dir2map(dir)); -} - -void File::removeRecursively(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QDir dir(f1.second.absoluteFilePath()); - if (File::rmDir(dir)) - this->cb(scId); - else - this->callback(ecId, FileError::kNoModificationAllowedErr); -} - -void File::write(int scId, int ecId, const QString &uri, const QString &_data, unsigned long long position, bool binary) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - - file.open(QIODevice::WriteOnly); - file.close(); - - if (!file.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - QFileInfo fileInfo(file); - if (!file.open(QIODevice::ReadWrite)) { - this->callback(ecId, FileError::kNoModificationAllowedErr); - return; - } - - if (!binary) { - QTextStream textStream(&file); - textStream.setCodec("UTF-8"); - textStream.setAutoDetectUnicode(true); - - if (!textStream.seek(position)) { - file.close(); - fileInfo.refresh(); - - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - textStream << _data; - textStream.flush(); - } else { - QByteArray data(_data.toUtf8()); - if (!file.seek(position)) { - file.close(); - fileInfo.refresh(); - - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - file.write(data.data(), data.length()); - } - - file.flush(); - file.close(); - fileInfo.refresh(); - - this->cb(scId, fileInfo.size() - position); -} - -void File::truncate(int scId, int ecId, const QString &uri, unsigned long long size) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - - if (!file.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - if (!file.resize(size)) { - this->callback(ecId, FileError::kNoModificationAllowedErr); - return; - } - - this->cb(scId, size); -} - -void File::getParent(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - QDir dir(f1.second.absoluteFilePath()); - - //can't cdup more than app's root - // Try to change into upper directory - if (dir != _persistentDir && dir != QDir::temp()){ - if (!dir.cdUp()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - } - this->cb(scId, dir2map(dir)); -} - -void File::remove(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - if (!f1.first) - return; - - QFileInfo &fileInfo = f1.second; - //TODO: fix - if (!fileInfo.exists() || (fileInfo.absoluteFilePath() == _persistentDir.absolutePath()) || (QDir::temp() == fileInfo.absoluteFilePath())) { - this->callback(ecId, FileError::kNoModificationAllowedErr); - return; - } - - if (fileInfo.isDir()) { - QDir dir(fileInfo.absoluteFilePath()); - if (dir.rmdir(dir.absolutePath())) { - this->cb(scId); - return; - } - } else { - QFile file(fileInfo.absoluteFilePath()); - if (file.remove()) { - this->cb(scId); - return; - } - } - - this->callback(ecId, FileError::kInvalidModificationErr); -} - -void File::getFileMetadata(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - QFileInfo &fileInfo = f1.second; - - if (!fileInfo.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - } else { - QMimeType mime = _db.mimeTypeForFile(fileInfo.fileName()); - - QString args = QString("{name: %1, fullPath: %2, type: %3, lastModifiedDate: new Date(%4), size: %5}") - .arg(CordovaInternal::format(fileInfo.fileName())).arg(CordovaInternal::format(fileInfo.absoluteFilePath())) - .arg(CordovaInternal::format(mime.name())).arg(fileInfo.lastModified().toMSecsSinceEpoch()) - .arg(fileInfo.size()); - - this->callback(scId, args); - } -} - -void File::getMetadata(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - QFileInfo &fileInfo = f1.second; - - if (!fileInfo.exists()) - this->callback(ecId, FileError::kNotFoundErr); - else { - QVariantMap obj; - obj.insert("modificationTime", fileInfo.lastModified().toMSecsSinceEpoch()); - obj.insert("size", fileInfo.isDir() ? 0 : fileInfo.size()); - this->cb(scId, obj); - } -} - -void File::readEntries(int scId, int ecId, const QString &uri) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - QDir dir(f1.second.absoluteFilePath()); - QString entriesList; - - if (!dir.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - for (const QFileInfo &fileInfo: dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { - entriesList += CordovaInternal::format(file2map(fileInfo)) + ","; - } - // Remove trailing comma - if (entriesList.size() > 0) - entriesList.remove(entriesList.size() - 1, 1); - - entriesList = "new Array(" + entriesList + ")"; - - this->callback(scId, entriesList); -} - -void File::readAsText(int scId, int ecId, const QString &uri, const QString &/*encoding*/, int sliceStart, int sliceEnd) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - - if (!file.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - if (!file.open(QIODevice::ReadOnly)) { - this->callback(ecId, FileError::kNotReadableErr); - return; - } - - QByteArray content = file.readAll(); - - if (sliceEnd == -1) - sliceEnd = content.size(); - if (sliceEnd < 0) { - sliceEnd++; - sliceEnd = std::max(0, content.size() + sliceEnd); - } - if (sliceEnd > content.size()) - sliceEnd = content.size(); - - if (sliceStart < 0) - sliceStart = std::max(0, content.size() + sliceStart); - if (sliceStart > content.size()) - sliceStart = content.size(); - - if (sliceStart > sliceEnd) - sliceEnd = sliceStart; - - //FIXME: encoding - content = content.mid(sliceStart, sliceEnd - sliceStart); - - this->cb(scId, content); -} - -void File::readAsArrayBuffer(int scId, int ecId, const QString &uri, int sliceStart, int sliceEnd) { - const QString str2array("\ - (function strToArray(str) { \ - var res = new Uint8Array(str.length); \ - for (var i = 0; i < str.length; i++) { \ - res[i] = str.charCodeAt(i); \ - } \ - return res; \ - })(\"%1\")"); - - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - - if (!file.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - if (!file.open(QIODevice::ReadOnly)) { - this->callback(ecId, FileError::kNotReadableErr); - return; - } - QString res; - QByteArray content = file.readAll(); - - if (sliceEnd == -1) - sliceEnd = content.size(); - if (sliceEnd < 0) { - sliceEnd++; - sliceEnd = std::max(0, content.size() + sliceEnd); - } - if (sliceEnd > content.size()) - sliceEnd = content.size(); - - if (sliceStart < 0) - sliceStart = std::max(0, content.size() + sliceStart); - if (sliceStart > content.size()) - sliceStart = content.size(); - - if (sliceStart > sliceEnd) - sliceEnd = sliceStart; - - content = content.mid(sliceStart, sliceEnd - sliceStart); - - res.reserve(content.length() * 6); - for (uchar c: content) { - res += "\\x"; - res += QString::number(c, 16).rightJustified(2, '0').toUpper(); - } - - this->callback(scId, str2array.arg(res)); -} - -void File::readAsBinaryString(int scId, int ecId, const QString &uri, int sliceStart, int sliceEnd) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - - if (!file.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - if (!file.open(QIODevice::ReadOnly)) { - this->callback(ecId, FileError::kNotReadableErr); - return; - } - QString res; - QByteArray content = file.readAll(); - - if (sliceEnd == -1) - sliceEnd = content.size(); - if (sliceEnd < 0) { - sliceEnd++; - sliceEnd = std::max(0, content.size() + sliceEnd); - } - if (sliceEnd > content.size()) - sliceEnd = content.size(); - - if (sliceStart < 0) - sliceStart = std::max(0, content.size() + sliceStart); - if (sliceStart > content.size()) - sliceStart = content.size(); - - if (sliceStart > sliceEnd) - sliceEnd = sliceStart; - - content = content.mid(sliceStart, sliceEnd - sliceStart); - - res.reserve(content.length() * 6); - for (uchar c: content) { - res += "\\x"; - res += QString::number(c, 16).rightJustified(2, '0').toUpper(); - } - this->callback(scId, "\"" + res + "\""); -} - -void File::readAsDataURL(int scId, int ecId, const QString &uri, int sliceStart, int sliceEnd) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, uri); - - if (!f1.first) - return; - - QFile file(f1.second.absoluteFilePath()); - QFileInfo &fileInfo = f1.second; - - if (!file.exists()) { - this->callback(ecId, FileError::kNotReadableErr); - return; - } - - if (!file.open(QIODevice::ReadOnly)) { - this->callback(ecId, FileError::kNotReadableErr); - return; - } - - QByteArray content = file.readAll(); - QString contentType(_db.mimeTypeForFile(fileInfo.fileName()).name()); - - if (sliceEnd == -1) - sliceEnd = content.size(); - if (sliceEnd < 0) { - sliceEnd++; - sliceEnd = std::max(0, content.size() + sliceEnd); - } - if (sliceEnd > content.size()) - sliceEnd = content.size(); - - if (sliceStart < 0) - sliceStart = std::max(0, content.size() + sliceStart); - if (sliceStart > content.size()) - sliceStart = content.size(); - - if (sliceStart > sliceEnd) - sliceEnd = sliceStart; - - content = content.mid(sliceStart, sliceEnd - sliceStart); - - this->cb(scId, QString("data:%1;base64,").arg(contentType) + content.toBase64()); -} - -bool File::rmDir(const QDir &dir) { - if (dir == _persistentDir || dir == QDir::temp()) {//can't remove root dir - return false; - } - bool result = true; - if (dir.exists()) { - // Iterate over entries and remove them - Q_FOREACH(const QFileInfo &fileInfo, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { - if (fileInfo.isDir()) { - result = rmDir(fileInfo.absoluteFilePath()); - } - else { - result = QFile::remove(fileInfo.absoluteFilePath()); - } - - if (!result) { - return result; - } - } - - // Finally remove the current dir - return dir.rmdir(dir.absolutePath()); - } - return result; -} - -bool File::copyFile(int scId, int ecId,const QString& sourceUri, const QString& destinationUri, const QString& newName) { - QPair<bool, QFileInfo> destDir = resolveURI(ecId, destinationUri); - QPair<bool, QFileInfo> sourceFile = resolveURI(ecId, sourceUri); - - if (!destDir.first || !sourceFile.first) - return false; - - if (!checkFileName(newName)) { - this->callback(ecId, FileError::kEncodingErr); - return false; - } - - if (destDir.second.isFile()) { - this->callback(ecId, FileError::kInvalidModificationErr); - return false; - } - - if (!destDir.second.isDir()) { - this->callback(ecId, FileError::kNotFoundErr); - return false; - } - - QFileInfo &fileInfo = sourceFile.second; - QString fileName((newName.isEmpty()) ? fileInfo.fileName() : newName); - QString destinationFile(QDir(destDir.second.absoluteFilePath()).filePath(fileName)); - if (QFile::copy(fileInfo.absoluteFilePath(), destinationFile)){ - this->cb(scId, file2map(QFileInfo(destinationFile))); - return true; - } - this->callback(ecId, FileError::kInvalidModificationErr); - return false; -} - -void File::copyDir(int scId, int ecId,const QString& sourceUri, const QString& destinationUri, const QString& newName) { - QPair<bool, QFileInfo> destDir = resolveURI(ecId, destinationUri); - QPair<bool, QFileInfo> sourceDir = resolveURI(ecId, sourceUri); - - if (!destDir.first || !sourceDir.first) - return; - if (!checkFileName(newName)) { - this->callback(ecId, FileError::kEncodingErr); - return; - } - - QString targetName = ((newName.isEmpty()) ? sourceDir.second.fileName() : newName); - QString target(QDir(destDir.second.absoluteFilePath()).filePath(targetName)); - - if (QFileInfo(target).isFile()){ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - // check: copy directory into itself - if (QDir(sourceDir.second.absoluteFilePath()).relativeFilePath(target)[0] != '.'){ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (!QDir(target).exists()){ - QDir(destDir.second.absoluteFilePath()).mkdir(target);; - } else{ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (copyFolder(sourceDir.second.absoluteFilePath(), target)){ - this->cb(scId, dir2map(QDir(target))); - return; - } - this->callback(ecId, FileError::kInvalidModificationErr); - return; -} - -void File::copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, source); - - if (!f1.first) - return; - - if (f1.second.isDir()) - copyDir(scId, ecId, source, destinationDir, newName); - else - copyFile(scId, ecId, source, destinationDir, newName); -} - -void File::moveFile(int scId, int ecId,const QString& sourceUri, const QString& destinationUri, const QString& newName) { - QPair<bool, QFileInfo> sourceFile = resolveURI(ecId, sourceUri); - QPair<bool, QFileInfo> destDir = resolveURI(ecId, destinationUri); - - if (!destDir.first || !sourceFile.first) - return; - if (!checkFileName(newName)) { - this->callback(ecId, FileError::kEncodingErr); - return; - } - - QString fileName = ((newName.isEmpty()) ? sourceFile.second.fileName() : newName); - QString target = QDir(destDir.second.absoluteFilePath()).filePath(fileName); - - if (sourceFile.second == QFileInfo(target)) { - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (!destDir.second.exists()) { - this->callback(ecId, FileError::kNotFoundErr); - return; - } - if (!destDir.second.isDir()){ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (QFileInfo(target).exists()) { - if (!QFile::remove(target)) { - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - } - - QFile::rename(sourceFile.second.absoluteFilePath(), target); - this->cb(scId, file2map(QFileInfo(target))); -} - -void File::moveDir(int scId, int ecId,const QString& sourceUri, const QString& destinationUri, const QString& newName){ - QPair<bool, QFileInfo> sourceDir = resolveURI(ecId, sourceUri); - QPair<bool, QFileInfo> destDir = resolveURI(ecId, destinationUri); - - if (!destDir.first || !sourceDir.first) - return; - if (!checkFileName(newName)) { - this->callback(ecId, FileError::kEncodingErr); - return; - } - - QString fileName = ((newName.isEmpty()) ? sourceDir.second.fileName() : newName); - QString target = QDir(destDir.second.absoluteFilePath()).filePath(fileName); - - if (!destDir.second.exists()){ - this->callback(ecId, FileError::kNotFoundErr); - return; - } - - if (destDir.second.isFile()){ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - // check: copy directory into itself - if (QDir(sourceDir.second.absoluteFilePath()).relativeFilePath(target)[0] != '.'){ - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (QFileInfo(target).exists() && !QDir(destDir.second.absoluteFilePath()).rmdir(fileName)) { - this->callback(ecId, FileError::kInvalidModificationErr); - return; - } - - if (copyFolder(sourceDir.second.absoluteFilePath(), target)) { - rmDir(sourceDir.second.absoluteFilePath()); - this->cb(scId, file2map(QFileInfo(target))); - } else { - this->callback(ecId, FileError::kNoModificationAllowedErr); - } -} - -void File::moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName) { - QPair<bool, QFileInfo> f1 = resolveURI(ecId, source); - - if (!f1.first) - return; - - if (f1.second.isDir()) - moveDir(scId, ecId, source, destinationDir, newName); - else - moveFile(scId, ecId, source, destinationDir, newName); -} - -bool File::copyFolder(const QString& sourceFolder, const QString& destFolder) { - QDir sourceDir(sourceFolder); - if (!sourceDir.exists()) - return false; - QDir destDir(destFolder); - if (!destDir.exists()){ - destDir.mkdir(destFolder); - } - QStringList files = sourceDir.entryList(QDir::Files); - for (int i = 0; i< files.count(); i++) - { - QString srcName = sourceFolder + "/" + files[i]; - QString destName = destFolder + "/" + files[i]; - QFile::copy(srcName, destName); - } - files.clear(); - files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - for (int i = 0; i< files.count(); i++) - { - QString srcName = sourceFolder + "/" + files[i]; - QString destName = destFolder + "/" + files[i]; - copyFolder(srcName, destName); - } - return true; -} diff --git a/plugins/fetch.json b/plugins/fetch.json index d3516d1..431478f 100644 --- a/plugins/fetch.json +++ b/plugins/fetch.json @@ -7,14 +7,6 @@ "is_top_level": false, "variables": {} }, - "cordova-plugin-file": { - "source": { - "type": "registry", - "id": "cordova-plugin-file@^4.3.3" - }, - "is_top_level": true, - "variables": {} - }, "cordova-plugin-network-information": { "source": { "type": "registry", @@ -118,5 +110,21 @@ }, "is_top_level": true, "variables": {} + }, + "cordova-plugin-file-transfer": { + "source": { + "type": "registry", + "id": "cordova-plugin-file-transfer@1.7.1" + }, + "is_top_level": true, + "variables": {} + }, + "cordova-plugin-file": { + "source": { + "type": "registry", + "id": "cordova-plugin-file@6.0.1" + }, + "is_top_level": true, + "variables": {} } } \ No newline at end of file diff --git a/www/js/authentication.js b/www/js/authentication.js index 71590bd..092f7ba 100644 --- a/www/js/authentication.js +++ b/www/js/authentication.js @@ -1,6 +1,6 @@ /* eslint camelcase: off */ -/* global app, $, cordova, alert, pdf, Blob, atob, IN_APP_BROWSER_AUTH */ +/* global app, $, cordova, alert, pdf, Blob, atob, FileTransfer, IN_APP_BROWSER_AUTH */ app.authentication = (function (thisModule) { var inAppBrowserRef @@ -32,8 +32,7 @@ app.authentication = (function (thisModule) { console.log('loadAuthentication()') - /* var url = app.main.urls.Chave_Movel_Digital.assinar_pdf */ - var url = 'https://www.thinkbroadband.com/download' + var url = app.main.urls.Chave_Movel_Digital.assinar_pdf var target = '_blank' var options = 'location=no,' + @@ -56,13 +55,32 @@ app.authentication = (function (thisModule) { function loadStartCallbackFunction (event) { console.log('%c ========== loadstart ========== ', 'background: yellow; color: blue') console.log(event.url) - $.get(event.url, function (data) { - console.log(data) - }) + + if (event.url.split('/').pop() === 'DocumentSigning.aspx') { + console.log('got DocumentSigning.aspx') + + var pdfFile = 'https://frtend.reg.cmd.autenticacao.gov.pt/Ama.Registry.Frontend/GetDocument.ashx' + var targetPath = cordova.file.documentsDirectory + 'doc.pdf' + var options = {} + var args = { + url: pdfFile, + targetPath: targetPath, + options: options + } + + // inAppBrowserRef.close() // close window or you get exception + + document.addEventListener('deviceready', function () { + setTimeout(function () { + downloadPdfFile(args) // call the function which will download the file 1s after the window is closed, just in case.. + }, 1000) + }) + } } - function loadedCallbackFunction () { - console.log('Authentication Window loaded') + function loadedCallbackFunction (event) { + console.log('%c ========== loadstop ========== ', 'background: yellow; color: blue') + // console.log(event.url) isAuthenticationWindowClosed = false @@ -95,6 +113,29 @@ app.authentication = (function (thisModule) { }) } + function downloadPdfFile (args) { + console.log('downloadPdfFile') + + var fileTransfer = new FileTransfer() + var uri = encodeURI(args.url) + + fileTransfer.download( + uri, // file's uri + args.targetPath, // where will be saved + function (entry) { + console.log('download complete: ' + entry.toURL()) + window.open(entry.toURL(), '_blank', 'location=no,closebuttoncaption=Cerrar,toolbar=yes,enableViewportScale=yes') + }, + function (error) { + console.log('download error source ' + error.source) + console.log('download error target ' + error.target) + console.log('upload error code' + error.code) + }, + true, + args.options + ) + } + function authenticationError () { $.jAlert({ 'title': 'Erro na obtenção da autenticação!', diff --git a/www/js/res/authTest.html b/www/js/res/authTest.html index 97250c6..e39e7ce 100644 --- a/www/js/res/authTest.html +++ b/www/js/res/authTest.html @@ -1,3 +1,311 @@ + +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8" content="" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> + <meta http-equiv="Pragma" content="no-cache" /> + <meta http-equiv="Expires" content="0" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="description" content="" /> + <meta name="author" content="" /> + <link rel="shortcut icon" type="image/icon" href="/Ama.Registry.Frontend/img/favicon.ico" /> + <title>AUTENTICAÇÃO.GOV</title> + <!-- Bootstrap core CSS --> + <link href="/Ama.Registry.Frontend/layoutBlueCC/dist/css/bootstrap.min.css" rel="stylesheet" /> + <!-- Custom styles --> + <link href="/Ama.Registry.Frontend/layoutCCC/css/custom.css" rel="stylesheet" /> + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> + <!-- [if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> + <!-- Bootstrap core JavaScript ================================================== --> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/jquery-1.11.3.min.js"></script> + <script type="text/javascript" src="/Ama.Registry.Frontend/layoutBlueCC/dist/js/bootstrap.min.js"></script> + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> + <script type="text/javascript" src="/Ama.Registry.Frontend/layoutBlueCC/dist/js/ie10-viewport-bug-workaround.js"></script> + + <link rel="stylesheet" href="/Ama.Registry.Frontend/css/bootstrap-pdf-viewer.css" /> + <link rel="stylesheet" href="/Ama.Registry.Frontend/css/Spinner/ladda-themeless.min.css" /> + <link rel="stylesheet" href="/Ama.Registry.Frontend/css/Spinner/prism.css" /> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/pdf.js"></script> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/bootstrap-pdf-viewer.js"></script> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/Spinner/spin.min.js"></script> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/Spinner/ladda.min.js"></script> + <script type="text/javascript" src="/Ama.Registry.Frontend/js/Spinner/prism.js"></script> + <script type="text/javascript"> + function UploadDoc() { + document.getElementById("uploadFile").value = document.getElementById("uploadBtn").files[0].name; + var buttonID = 'MainContent_btnUploadDoc'; + var button = document.getElementById(buttonID); + if (button) { button.style.display = 'inherit'; } + }; + var viewer; + $(function () { + viewer = new PDFViewer($('#viewer')); + + }); + + + </script> + <style type="text/css"> + .selected_row + { + background-color: #A1DCF2; + } + .fileUpload + { + position: relative; + overflow: hidden; + width: 100px; + } + .fileUpload input.upload + { + position: absolute; + top: 0; + right: 0; + margin: 0; + padding: 0; + font-size: 20px; + cursor: pointer; + opacity: 0; + filter: alpha(opacity=0); + } + td, th + { + height: 50px; + width: 80px; + } + td label + { + display: inline-block; + margin-right: 10px; + margin-left: 5px; + } + </style> + + <style type="text/css"> + .exitLink + { + font-size: 15px !important; + color: #FFF; + width: 45px; + } + .exitLink:hover + { + color: #E3E3E3; + } + </style> +</head> +<body> + <form method="post" action="DocumentSigning.aspx" id="form1" enctype="multipart/form-data"> +<div class="aspNetHidden"> +<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> +<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> +<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTQyODU3NjIwMQ9kFgJmD2QWAgIBDxYCHgdlbmN0eXBlBRNtdWx0aXBhcnQvZm9ybS1kYXRhFhJmDxYCHgdWaXNpYmxlaGQCAQ8WAh4FY2xhc3MFBmFjdGl2ZWQCBQ8WAh8BaBYCAgEPDxYCHgRUZXh0BQRTYWlyZGQCBg9kFhgCAw8WAh4JaW5uZXJodG1sBRtFc2NvbGhhIGRlIDxiciAvPiBEb2N1bWVudG9kAgUPFgIfBAUnUHLDqS1WaXN1YWxpemHDp8OjbyBkZSA8YnIgLz4gRG9jdW1lbnRvZAIHDxYCHwQFHkRldGFsaGVzIGRhIDxiciAvPiBBc3NpbmF0dXJhIGQCCQ8WAh8EBSJDb25maXJtYcOnw6NvIDxiciAvPiBkZSBBc3NpbmF0dXJhZAILDxYCHwQFG1BlZGlkbyA8YnIgLz4gZGUgQXNzaW5hdHVyYWQCDQ8WAh8EBRxEb3dubG9hZCBkbyA8YnIgLz4gRG9jdW1lbnRvZAIdD2QWAgIDDw8WAh8DZWRkAh8PZBYCAgMPDxYCHwNlZGQCIQ9kFgQCAQ8PFgIfAwUhRXNjb2xoYSB1bSBkb2N1bWVudG8gcGFyYSBhc3NpbmFyZGQCAw9kFgRmDw8WAh8DBQlQZXNxdWlzYXJkZAIBDw8WAh8DBRJDYXJyZWdhciBEb2N1bWVudG9kZAIjD2QWAmYPZBYGAgEPDxYCHwMFNFRlbSBhIGNlcnRlemEgcXVlICYjMjMzOyBlc3RlIG8gZG9jdW1lbnRvIGEgYXNzaW5hcj9kZAIDDw8WAh8DBQROw6NvZGQCBQ8PFgIfAwUDU2ltZGQCJQ9kFgoCAQ8PFgIfAwUjRGV0YWxoZXMgZGEgYXNzaW5hdHVyYSBkbyBkb2N1bWVudG9kZAIEDw8WAh8DBTlEZXNlamEgcXVlIGEgYXNzaW5hdHVyYSBlc3RlamEgdmlzJiMyMzc7dmVsIG5vIGRvY3VtZW50bz9kZAIGD2QWCgIBDw8WAh8DBSdRdWUgb3JpZW50YSYjMjMxOyYjMjI3O28gdGVtIG8gc2V1IFBERj9kZAIDDxBkZBYBAgFkAgUPDxYCHwMFBk1vdGl2b2RkAgkPDxYCHwMFBUxvY2FsZGQCDQ8PFgIfAwULUCYjMjI1O2dpbmFkZAIID2QWBAIBDw8WAh8DBTZFc2NvbGhhIGEgcG9zaSYjMjMxOyYjMjI3O28gZGEgYXNzaW5hdHVyYSBubyBkb2N1bWVudG9kZAIDDzwrABECARAWABYAFgAMFCsAAGQCCg9kFgICAQ8PFgIfAwUIU3VibWV0ZXJkZAInD2QWCAIBDw8WAh8DBRlCYWl4YXIgZG9jdW1lbnRvIGFzc2luYWRvZGQCAw8PFgIfAwU9U2UgbyBzZXUgZG93bmxvYWQgbiYjMjI3O28gY29tZSYjMjMxO2FyIGRlbnRybyBkZSAzIHNlZ3VuZG9zIGRkAgQPDxYCHwMFC2NsaXF1ZSBhcXVpZGQCBw9kFgICAQ8PFgIfAwUZQXNzaW5hciBvdXRyb3MgRG9jdW1lbnRvc2RkAgcPDxYCHwMFFlBvcnRhbCBkbyBDaWRhZCYjMjI3O29kZAIIDw8WAh8DBRxQb2wmIzIzNzt0aWNhIGRlIHByaXZhY2lkYWRlZGQCCQ8PFgIfAwUJQ29udGFjdG9zZGQCCw8PFgIfAwVnQU1BIC0gQWcmIzIzNDtuY2lhIHBhcmEgYSBNb2Rlcm5pemEmIzIzMTsmIzIyNztvIEFkbWluaXN0cmF0aXZhLCBJLlAuIC0gVG9kb3Mgb3MgZGlyZWl0b3MgcmVzZXJ2YWRvcyBAIGRkAgwPDxYCHwMFBDIwMTlkZBgBBSBjdGwwMCRNYWluQ29udGVudCRndlNpZ25Qb3NpdGlvbg9nZOZlk8EeHjh1x7ZWyh0sk3UEuoCZHGHxO0Bm1zsSkkjK" /> +</div> + +<script type="text/javascript"> +//<![CDATA[ +var theForm = document.forms['form1']; +if (!theForm) { + theForm = document.form1; +} +function __doPostBack(eventTarget, eventArgument) { + if (!theForm.onsubmit || (theForm.onsubmit() != false)) { + theForm.__EVENTTARGET.value = eventTarget; + theForm.__EVENTARGUMENT.value = eventArgument; + theForm.submit(); + } +} +//]]> +</script> + + +<script src="/Ama.Registry.Frontend/WebResource.axd?d=86Ns4HrxoJChWAkfB_Jon9qaR8UOTqUKqCKoGn7Hwoh16VkrwWc71A2DKKgANNPIeE8CMi_eG7ymtGfi5le6SDFXnrLuLWQy3b6JyEFVGGQ1&t=635195493660000000" type="text/javascript"></script> + +<div class="aspNetHidden"> + + <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAalYDyIZd2gOHcf+BkpP7/CYE73zgursDipA9Hd/gWIT+TBB6Lz+p1KeKtMpeP055udz7XTPXCAUXn8vy3i5jP2YRC1/zEKGzEc1JKew18ZhOcIZszcBUwJdQpOBbokLobv02ZcsvflBgKWdxHjK0YTNneSd5nMR40oNRN7gckT5w==" /> +</div> + <div class="white-line"> + </div> + <div class="header"> + </div> + + <div class="container container-page container-page-height"> + <div class="language-container"> + <ul class="nav navbar-nav navbar-right lang"> + <li id="PT" class="active"> + <a id="lnk_portuguese" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$lnk_portuguese", "", true, "", "", false, true))">Português</a></li> + <li id="EN"> + <a id="lnk_english" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$lnk_english", "", true, "", "", false, true))">English</a></li> + <li id="ES"> + <a id="lnk_spanish" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$lnk_spanish", "", true, "", "", false, true))">Castellano</a></li> + </ul> + </div> + <div class="fd"> + <div class="row logo"> + <a href="https://www.autenticacao.gov.pt/"> + <img src="/Ama.Registry.Frontend/layoutCCC/img/logo-ag.svg" alt="Autenticação.gov.pt" + class="img img-responsive logo-ie" /> + </a> + </div> + <!-- Menu --> + <div class="row"> + <div class="col-md-8 menu-bar"> + + + </div> + + </div> + <!-- Main component --> + <div role="tabpanel"> + <h1 class="margin40 titleCMD">Assinatura de Documentos com a Chave Móvel Digital</h1> + <!-- Tab panes --> + <div class="tab-content"> + <div role="tabpanel" class="tab-pane active" id="chave" style="margin-bottom: 50px"> + <div class="row"> + <div class="col-md-12"> + <div class="area-destaque"> + + <!-- progressbar --> + <div id="processBarDigitalSignAutentication" class="container-process-bar"> + + <p id="MainContent_pSixthStep" class="firstStepDigitalSignAutentic"> + Introdução + </p> + <p id="MainContent_pSecondStep" class="secondStepDigitalSignAutentic">Escolha de <br /> Documento</p> + <p id="MainContent_pThirdStep" class="thirdStepDigitalSignAutentic">Pré-Visualização de <br /> Documento</p> + <p id="MainContent_pFourthStep" class="fourthStepDigitalSignAutentic">Detalhes da <br /> Assinatura </p> + <p id="MainContent_pFifthStep" class="fifthStepDigitalSignAutentic">Confirmação <br /> de Assinatura</p> + <p id="MainContent_pFirstStep" class="sixtStepDigitalSignAutentic">Pedido <br /> de Assinatura</p> + <p id="MainContent_pLastStep" class="lastStepDigitalSignAutentic">Download do <br /> Documento</p> + <!-- progressbar balls --> + <p class="info-first-ball"> + <span class="process-first-ball"></span> + </p> + <p class="info-second-ball"> + <span id="MainContent_secondBallProcessBar" class="process-second-ball process-ball-blue"> + </span> + </p> + <p class="info-third-ball"> + <span id="MainContent_thirdBallProcessBar" class="process-third-ball"></span> + </p> + <p class="info-fourth-ball"> + <span id="MainContent_fourthBallProcessBar" class="process-fourth-ball"></span> + </p> + <p class="info-fifth-ball"> + <span id="MainContent_fifthBallProcessBar" class="process-fifth-ball"></span> + </p> + <p class="info-sixt-ball"> + <span id="MainContent_sixtBallProcessBar" class="process-sixt-ball "></span> + </p> + + <p class="info-last-ball"> + <span id="MainContent_lastBallProcessBar" class="process-last-ball"></span> + </p> + <div class="progress"> + <div id="MainContent_progressBarSize" class="progress-bar progress-bar-custom percentageColorProcessBar2" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"> + </div> + </div> + </div> + + + <div style="height: 10px;"> + </div> + + <div style="height: 270px;"> + <p class="texto-destaque" style="font-size: 20px;"> + <span id="MainContent_lblTitleChooseDoc">Escolha um documento para assinar</span> + </p> + <div id="MainContent_Div1"> + <div style="height: 15px;"> + </div> + <div class="fileUpload btn fileUploadContent" > + <span id="MainContent_lblSearch">Pesquisar</span> + <input id="uploadBtn" name="uploadBtn" accept= ".pdf" type="file" class="upload" onchange="UploadDoc()" /> + </div> + <input id="uploadFile" name="uploadFile" placeholder="Escolha um documento..." disabled="disabled" + class="imput-file-name" /> + <div style="height: 10px;"> + </div> + <input type="submit" name="ctl00$MainContent$btnUploadDoc" value="Carregar Documento" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnUploadDoc", "", true, "", "", false, false))" id="MainContent_btnUploadDoc" class="btn btn-primary" style="display:none" /> + </div><div id="MainContent_divBtnBack" class="col-md-3 margin40"> + <input type="submit" name="ctl00$MainContent$btnBackReg" value="VOLTAR" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnBackReg", "", true, "", "", false, false))" id="MainContent_btnBackReg" class="btn btn-primary" /> + </div> + </div> + + + + + + </div> + </div> + </div> + </div> + </div> + </div> + </div> + </div> + <div class="container footer"> + <div class="row margin-0"> + <div class="col-md-12 center"> + <a target="_blank" href="https://www.ama.gov.pt"> + <img src="/Ama.Registry.Frontend/layoutCCC/img/Logo_AMA.png" class="logo-ama" alt="Agência para a Modernização Administrativa" /></a> + <ul> + <li><a target="_blank" href="https://www.portaldocidadao.pt/"> + <span id="lblCitizenPortal">Portal do Cidadão</span></a></li> + <li><a target="_blank" href="https://cmd.autenticacao.gov.pt/Ama.Authentication.Frontend/PrivacyPolicy.aspx"> + <span id="lblPrivacyPolicy">Política de privacidade</span></a></li> + <li><a target="_blank" href="https://cmd.autenticacao.gov.pt/Ama.Authentication.Frontend/Contacts.aspx"> + <span id="lblContacts">Contactos</span></a></li> + <li><a target="_blank" href="https://cmd.autenticacao.gov.pt/Ama.Authentication.Frontend/Faqs.aspx"> + <span id="lblFaqs">Ajuda</span></a></li> + </ul> + <a target="_blank" href="https://www.facebook.com/ama.gov.pt"> + <img src="/Ama.Registry.Frontend/layoutCCC/img/fb_footer.png" alt="Facebook AMA" /></a> + <a target="_blank" href="https://pt.linkedin.com/company/ama---ag-ncia-para-a-moderniza-o-administrativa-ip"> + <img src="/Ama.Registry.Frontend/layoutCCC/img/li_footer.png" alt="LinkedIn AMA" /></a> + <a target="_blank" href="https://www.twitter.com/ama_gov_pt"> + <img src="/Ama.Registry.Frontend/layoutCCC/img/tw_footer.png" alt="Twitter AMA" /></a> + </div> + <div class="copyright"> + <div class="row"> + <div class="col-md-12"> + <span id="lblAmaDesc">AMA - Agência para a Modernização Administrativa, I.P. - Todos os direitos reservados @ </span> + <span id="lblCopyrightYear">2019</span> + <a href="https://www.ama.gov.pt" target="_blank">www.ama.gov.pt</a> | <a href="mailto:ama@ama.pt">ama@ama.pt</a> + </div> + </div> + </div> + </div> + </div> + </form> +</body> +</html> + + + + + + + + + + + + + + + + + + + + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> @@ -36,14 +344,8 @@ </script> </head> <body> - - <form method="post" action="ErrorPage.aspx?aspxerrorpath=%2fAma.Authentication.Frontend%2fProcesses%2fDigitalSignature%2fDigitalSignConfirmTan.aspx" id="form1"> - - <div class="aspNetHidden"> - - <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEyOTUxNzg1MDgPZBYCZg9kFgICAQ9kFg5mDxYCHgVjbGFzcwUGYWN0aXZlZAIDD2QWAgIBDw8WAh4EVGV4dAV5TiYjMjI3O28gZm9pIHBvc3MmIzIzNzt2ZWwgZWZldHVhciBhIG9wZXJhJiMyMzE7JiMyMjc7by4gUGVkaW1vcyBkZXNjdWxwYSBwZWxvIGluYyYjMjQzO21vZG8uIFRlbnRlIG5vdmFtZW50ZSBtYWlzIHRhcmRlLmRkAgQPDxYCHwEFCUVQT1JUVUdBTGRkAgUPDxYCHwEFHFBvbCYjMjM3O3RpY2EgZGUgcHJpdmFjaWRhZGVkZAIGDw8WAh8BBQlDb250YWN0b3NkZAIIDw8WAh8BBWdBTUEgLSBBZyYjMjM0O25jaWEgcGFyYSBhIE1vZGVybml6YSYjMjMxOyYjMjI3O28gQWRtaW5pc3RyYXRpdmEsIEkuUC4gLSBUb2RvcyBvcyBkaXJlaXRvcyByZXNlcnZhZG9zIEAgZGQCCQ8PFgIfAQUEMjAxOWRkZN2Q1vdJpEh4+2qgIoFA0Bttrd/eW4r6P+L5RQN7MNpJ" /> @@ -69,9 +371,6 @@ <div class="aspNetHidden"> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAROqm2rCQH0dIiUea28BzsEYE73zgursDipA9Hd/gWIT+TBB6Lz+p1KeKtMpeP055udz7XTPXCAUXn8vy3i5jP2hRbHf3ziK1TtZZM3etDlVwbAor2jPULrczQfECTXY74=" /> - - - </div> <div class="white-line"> </div> @@ -162,33 +461,3 @@ <h1 class="margin40 titleCMD">Chave Móvel Digital</h1> </form> </body> </html> - - - - - - - - - - - -============================================================================================= -============================================================================================= - - - - - - - - - - - - - - -https://frtend.reg.cmd.autenticacao.gov.pt/ErrorPage.aspx?aspxerrorpath=%2fAma.Authentication.Frontend%2fProcesses%2fDigitalSignature%2fDigitalSignConfirmTan.aspx - -https://frtend.reg.cmd.autenticacao.gov.pt/wEdAAROqm2rCQH0dIiUea28BzsEYE73zgursDipA9Hd/gWIT+TBB6Lz+p1KeKtMpeP055udz7XTPXCAUXn8vy3i5jP2hRbHf3ziK1TtZZM3etDlVwbAor2jPULrczQfECTXY74=