diff options
Diffstat (limited to 'plugins/de.appplant.cordova.plugin.email-composer')
11 files changed, 0 insertions, 2482 deletions
diff --git a/plugins/de.appplant.cordova.plugin.email-composer/CHANGELOG.md b/plugins/de.appplant.cordova.plugin.email-composer/CHANGELOG.md deleted file mode 100644 index 4c8908b0..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/CHANGELOG.md +++ /dev/null @@ -1,63 +0,0 @@ -## ChangeLog -#### Version 0.8.2 (01.03.2015) -- Added new namespace `cordova.plugins.email`<br> - **Note:** The former `plugin.email` namespace is now deprecated and will be removed with the next major release. -- [___change:___] Unified `absolute:` and `relative:` to `file:` -- [___change:___] Renamed `isServiceAvailable` to `isAvailable` -- [feature:] `app:` allows to specify target mail app on Android -- [feature:] `res:` prefix for native ressource attachments -- [enhancement:] Support attachments on Windows Phone 8.1 -- [enhancement:] `open` supports callbacks -- [enhancement:] `isHTML` can be used next `isHtml` -- [enhancement:] Set mime type to binary if unknown -- [bugfix:] Defaults were ignored - -#### Version 0.8.1 (06.04.2014) -- [enhancement:] Make use Cordovas NSData+Base64 extension. -- [enhancement:] Log error message if attachment path does not exist. -- [feature:] Add support for amazon fire -- [bugfix:] Fix INSTALL_FAILED_CONFLICTING_PROVIDER error -- [bugfix:] `relative://` attachment path wasnt working due to a missing permission. -- [bugfix:] `base64://` attachment path looked up in the wrong directory. -- [enhancement:] `relative://` supports now any file types and not only images. -- [___change:___] `relative://` URI's even for Android need a file extension. - -#### Version 0.8.0 (02.03.2014) -- [enhancement:] New `absolute://` and `relative://` attachment prefixes. -- [feature:] New `base64://` prefix to attach base64 encoded data streams. - -#### Version 0.7.2 (01.03.2014) -- [enhancement:] Attachments are added with their real name. - -#### Version 0.7.1 (17.12.2013) -- [bugfix:] Only the last attachment was added to the email composer on android. - -#### Version 0.7.0 (05.12.2013) -- Release under the Apache 2.0 license. -- [___change:___] Removed the `callback` property from the `open` interface. -- [___change:___] Renamed the properties `recipients`, `ccRecipients`, `bccRecipients`. -- [bugfix:] Plugin under WP8 throws an error, if recipients were given as arrays. -- [enhancement:] `open` does not block the ui thread on iOS & Android anymore. - -#### Version 0.6.0 (17.11.2013) -- Added WP8 support -- [***deprecated:***] The `callback` property will be removed with v0.7.0. - -#### Version 0.4.2 (17.11.2013) -- [feature:] Added alias `openDraft` to the `open` interface. - -#### Version 0.4.1 (03.11.2013) -- [bugfix]: On Android, the `isServiceAvailable()` interface has returned string values instead of boolean values. -- [bugfix]: Sometimes the device said that no email app is available because of the missing mime type. - -#### Version 0.4.0 (20.08.2013) -- Added Android support<br> - *Based on the EmailComposerWithAttachments Android plugin made by* ***guidosabatini*** - -#### Version 0.2.1 (15.08.2013) -- [bugfix]: Email was not send in HTML format, if the `isHtml` flag was set. -- [bugfix]: `email.open()` without a parameter throw an error. - -#### Version 0.2.0 (13.08.2013) -- Added iOS support<br> - *Based on the EmailComposer(WithAttachments) iOS plugin made by* ***Randy McMillan*** *and* ***guidosabatini***
\ No newline at end of file diff --git a/plugins/de.appplant.cordova.plugin.email-composer/LICENSE b/plugins/de.appplant.cordova.plugin.email-composer/LICENSE deleted file mode 100644 index c0bcf461..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2013-2015 appPlant UG - - 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.
\ No newline at end of file diff --git a/plugins/de.appplant.cordova.plugin.email-composer/README.md b/plugins/de.appplant.cordova.plugin.email-composer/README.md deleted file mode 100644 index ef01b5f0..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/README.md +++ /dev/null @@ -1,332 +0,0 @@ - -<p align="right"> - <a href="https://github.com/katzer/cordova-plugin-email-composer/tree/example">EXAMPLE :point_right:</a> -</p> - -Cordova Email Plugin -==================== - -<img width="260px" align="right" hspace="7" vspace="5" src="http://flashsimulations.com/wp-content/uploads/2011/12/air-ios-in-app-mail-app.png"> - -The plugin provides access to the standard interface that manages the editing and sending an email message. You can use this view controller to display a standard email view inside your application and populate the fields of that view with initial values, such as the subject, email recipients, body text, and attachments. The user can edit the initial contents you specify and choose to send the email or cancel the operation. - -Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent. - - -### Plugin's Purpose -The purpose of the plugin is to create an platform independent javascript interface for [Cordova][cordova] based mobile applications to access the specific email composition API on each platform. - - -## Overview -1. [Supported Platforms](#supported-platforms) -2. [Installation](#installation) -3. [ChangeLog](#changelog) -4. [Using the plugin](#using-the-plugin) -5. [Examples](#examples) -6. [Quirks](#quirks) - - -## Supported Platforms -- __iOS__ _(up to iOS8)_ -- __Android__ _(up to KitKat and L)_ -- __WP 8.0__ and __WP 8.1 Silverlight__ -- __Windows__ - - -## Installation -The plugin can either be installed from git repository, from local file system through the [Command-line Interface][CLI]. Or cloud based through [PhoneGap Build][PGB]. - -### Local development environment -From master: -```bash -# ~~ from master branch ~~ -cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git -``` -from a local folder: -```bash -# ~~ local folder ~~ -cordova plugin add de.appplant.cordova.plugin.email-composer --searchpath path/to/plugin -``` -or to use the last stable version: -```bash -# ~~ stable version ~~ -cordova plugin add de.appplant.cordova.plugin.email-composer@0.8.2 -``` - -### PhoneGap Build -Add the following xml to your config.xml to always use the latest version of this plugin: -```xml -<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.2" /> -``` -More informations can be found [here][PGB_plugin]. - - -## ChangeLog -#### Version 0.8.2 (01.03.2015) -- Added new namespace `cordova.plugins.email`<br> - **Note:** The former `plugin.email` namespace is now deprecated and will be removed with the next major release. -- [___change:___] Unified `absolute:` and `relative:` to `file:` -- [___change:___] Renamed `isServiceAvailable` to `isAvailable` -- [feature:] `app:` allows to specify target mail app on Android -- [feature:] `res:` prefix for native ressource attachments -- [enhancement:] Support attachments on Windows Phone 8.1 -- [enhancement:] `open` supports callbacks -- [enhancement:] `isHTML` can be used next `isHtml` -- [enhancement:] Set mime type to binary if unknown -- [bugfix:] Defaults were ignored - -#### Known issues -- _\<img\>_ tags do not work on Android. -- Callbacks for WP8/Windows platform are called immediately. -- _isAvailable_ does always return _true_ for WP8/Windows platform. -- The plugin may crash on WP8.1/Windows if an attachmant does not exist. - -#### Further informations -- See [CHANGELOG.md][changelog] to get the full changelog for the plugin. - - -## Using the plugin -The plugin creates the object ```cordova.plugins.email``` with following methods: - -1. [email.isAvailable][available] -2. [email.open][open] - -### Plugin initialization -The plugin and its methods are not available before the *deviceready* event has been fired. - -```javascript -document.addEventListener('deviceready', function () { - // cordova.plugins.email is now available -}, false); -``` - -### Determine if the device is capable to send emails -The ability to send emails can be revised through the `email.isAvailable` interface. The method takes a callback function, passed to which is a boolean property. Optionally the callback scope can be assigned as a second parameter. - -The Email service is only available on devices capable which are able to send emails. E.g. which have configured an email account and have installed an email app. You can use this function to hide email functionality from users who will be unable to use it. - -```javascript -cordova.plugins.email.isAvailable( - function (isAvailable) { - // alert('Service is not available') unless isAvailable; - } -); -``` - -### Open a pre-filled email draft -A pre-filled email draft can be opened through the `email.open` or `email.openDraft` interface. The method takes a hash as an argument to specify the email's properties. All properties are optional. Further more it accepts an callback function to be called after the email view has been dismissed. - -After opening the draft the user may have the possibilities to edit, delete or send the email. - -#### Further informations -- An [configured email account][available] is required to send emails. -- Attachments can be either base64 encoded datas, files from the the device storage or assets from within the *www* folder. -- The default value for *isHTML* is *true*. -- Its possible to [specify][email_app] the email app on Android. -- See the [examples][examples] for how to create and show an email draft. - -```javascript -cordova.plugins.email.open({ - to: Array, // email addresses for TO field - cc: Array, // email addresses for CC field - bcc: Array, // email addresses for BCC field - attachments: Array, // file paths or base64 data streams - subject: String, // subject of the email - body: String, // email body (for HTML, set isHtml to true) - isHtml: Boolean, // indicats if the body is HTML or plain text -}, callback, scope); -``` - - -## Examples - -### Open an email draft -The following example shows how to create and show an email draft pre-filled with different kind of properties. - -```javascript -cordova.plugins.email.open({ - to: 'max@mustermann.de', - cc: 'erika@mustermann.de', - bcc: ['john@doe.com', 'jane@doe.com'], - subject: 'Greetings', - body: 'How are you? Nice greetings from Leipzig' -}); -``` - -Of course its also possible to open a blank draft. -```javascript -cordova.plugins.email.open(); -``` - -### Send HTML encoded body -Its possible to send the email body either as text or HTML. In the case of HTML the `isHTML` properties needs to be set. - -```javascript -cordova.plugins.email.open({ - to: 'max@mustermann.de', - subject: 'Greetings', - body: '<h1>Nice greetings from Leipzig</h1>', - isHtml: true -}); -``` - -### Get informed when the view has been dismissed -The `open` method supports additional callback to get informed when the view has been dismissed. - -```javascript -cordova.plugins.email.open(properties, function () { - console.log('email view dismissed'); -}, this); -``` - -### Adding attachments -Attachments can be either base64 encoded datas, files from the the device storage or assets from within the *www* folder. - -#### Attach Base64 encoded content -The code below shows how to attach an base64 encoded image which will be added as a image with the name *icon.png*. - -```javascript -cordova.plugins.email.open({ - subject: 'Cordova Icon', - attachments: 'base64:icon.png//iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/...' -}); -``` - -#### Attach files from the device storage -The path to the files must be defined absolute from the root of the file system. - -```javascript -cordova.plugins.email.open({ - attachments: 'file:///storage/sdcard/icon.png', //=> Android -}); -``` - -#### Attach native app resources -Each app has a resource folder, e.g. the _res_ folder for Android apps or the _Resource_ folder for iOS apps. The following example shows how to attach the app icon from within the app's resource folder. - -```javascript -cordova.plugins.email.open({ - attachments: 'res://icon.png' //=> res/drawable/icon (Android) -}); -``` - -#### Attach assets from the www folder -The path to the files must be defined relative from the root of the mobile web app folder, which is located under the _www_ folder. - -```javascript -cordova.plugins.email.open({ - attachments: [ - 'file://img/logo.png', //=> assets/www/img/logo.png (Android) - 'file://css/index.css' //=> www/css/index.css (iOS) - ] -}); -``` - - -## Platform specifics - -### Specify email app -Its possible to specify the email app __on Android__ which shall open the draft for further editing. By default `email.open` does show a chooser with all available applications. - -The app can be specified by either an alias or its package name. The alias _gmail_ is available by default. - -```javascript -// Add app alias -cordova.plugins.email.addAlias('gmail', 'com.google.android.gm'); - -// Specify app by name or alias -cordova.plugins.email.open({ - app: 'gmail', - subject: 'Sent from Gmail' -}) -``` - - -## Quirks - -### HTML and CSS on Android -Even Android is capable to render HTML formatted mails, most native Mail clients like the standard app or Gmail only support rich formatted text while writing mails. That means that __CSS cannot be used__ (no _class_ and _style_ support). - -The following table gives an overview which tags and attributes can be used: - -<table> -<td width="60%"> - <ul> - <li><code><a href="..."></code></li> - <li><code><b></code></li> - <li><code><big></code></li> - <li><code><blockquote></code></li> - <li><code><br></code></li> - <li><code><cite></code></li> - <li><code><dfn></code></li> - <li><code><div align="..."></code></li> - <li><code><em></code></li> - <li><code><font size="..." color="..." face="..."></code></li> - <li><code><h1></code></li> - <li><code><h2></code></li> - <li><code><h3></code></li> - </ul> -</td> -<td width="40%"> - <ul> - <li><code><h4></code></li> - <li><code><h5></code></li> - <li><code><h6></code></li> - <li><code><i></code></li> - <li><code><img src="..."></code></li> - <li><code><p></code></li> - <li><code><small></code></li> - <li><code><strike></code></li> - <li><code><strong></code></li> - <li><code><sub></code></li> - <li><code><sup></code></li> - <li><code><tt></code></li> - <li><code><u></code></li> - </ul> -</td> -</table> - -### HTML, CSS and attachments on Windows Phone 8 -Attachments and HTML+CSS formatted body are not supported through the native API for Windows Phone 8.0 and Windows Phone 8.1 Silverlight. - -### Compile error on iOS -The error indicates, that the `MessageUI.framework` is not linked to your project. The framework is linked automatically when the plugin was installed, but may removed later. - -``` -Undefined symbols for architecture i386: - "_OBJC_CLASS_$_MFMailComposeViewController", referenced from: - objc-class-ref in APPEmailComposer.o -ld: symbol(s) not found for architecture i386 -clang: error: linker command failed with exit code 1 (use -v to see invocation) -``` - - -## Contributing - -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request - - -## License - -This software is released under the [Apache 2.0 License][apache2_license]. - -© 2013-2015 appPlant UG, Inc. All rights reserved - - -[cordova]: https://cordova.apache.org -[ios_guide]: http://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html -[wp8_guide]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394003.aspx -[CLI]: http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface -[PGB]: http://docs.build.phonegap.com/en_US/index.html -[PGB_plugin]: https://build.phonegap.com/plugins/2055 -[messageui_framework]: #compile-error-on-ios -[changelog]: https://github.com/katzer/cordova-plugin-email-composer/blob/master/CHANGELOG.md -[available]: #determine-if-the-device-is-capable-to-send-emails -[open]: #open-a-pre-filled-email-draft -[email_app]: #specify-email-app -[examples]: #examples -[apache2_license]: http://opensource.org/licenses/Apache-2.0 diff --git a/plugins/de.appplant.cordova.plugin.email-composer/plugin.xml b/plugins/de.appplant.cordova.plugin.email-composer/plugin.xml deleted file mode 100644 index 5fc8defb..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/plugin.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright 2013-2015 appPlant UG - - 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="de.appplant.cordova.plugin.email-composer" - version="0.8.2"> - - <name>EmailComposer</name> - - <description> - Provides access to the standard interface that manages - the editing and sending an email message - </description> - - <repo> - https://github.com/katzer/cordova-plugin-email-composer.git - </repo> - - <keywords> - appplant, email - </keywords> - - <license>Apache 2.0</license> - - <author>Sebastián Katzer</author> - - <engines> - <engine name="cordova" version=">=3.0.0" /> - </engines> - - <!-- interface --> - <js-module src="www/email_composer.js" name="EmailComposer"> - <clobbers target="cordova.plugins.email" /> - <clobbers target="plugin.email" /> - </js-module> - - <!-- ios --> - <platform name="ios"> - <config-file target="config.xml" parent="/*"> - <feature name="EmailComposer"> - <param name="ios-package" value="APPEmailComposer"/> - </feature> - </config-file> - - <header-file src="src/ios/APPEmailComposer.h" /> - <source-file src="src/ios/APPEmailComposer.m" /> - - <framework src="MessageUI.framework" weak="true" /> - </platform> - - <!-- android --> - <platform name="android"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="EmailComposer"> - <param name="android-package" - value="de.appplant.cordova.emailcomposer.EmailComposer"/> - </feature> - </config-file> - - <source-file - src="src/android/EmailComposer.java" - target-dir="src/de/appplant/cordova/emailcomposer" /> - - </platform> - - <!-- amazon-fireos --> - <platform name="amazon-fireos"> - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="EmailComposer"> - <param name="android-package" - value="de.appplant.cordova.emailcomposer.EmailComposer"/> - </feature> - </config-file> - - <source-file - src="src/android/EmailComposer.java" - target-dir="src/de/appplant/cordova/emailcomposer" /> - - </platform> - - <!-- wp8 --> - <platform name="wp8"> - <config-file target="config.xml" parent="/*"> - <feature name="EmailComposer"> - <param name="wp-package" value="EmailComposer"/> - </feature> - </config-file> - - <source-file src="src/wp8/EmailComposer.cs" /> - <source-file src="src/wp8/Options.cs" /> - </platform> - - <!-- windows --> - <platform name="windows"> - <js-module src="src/windows/EmailComposerProxy.js" name="EmailComposerProxy"> - <merges target="" /> - </js-module> - </platform> -</plugin> diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/android/EmailComposer.java b/plugins/de.appplant.cordova.plugin.email-composer/src/android/EmailComposer.java deleted file mode 100755 index ddda3104..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/android/EmailComposer.java +++ /dev/null @@ -1,574 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - 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. -*/ - -package de.appplant.cordova.emailcomposer; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.res.AssetManager; -import android.content.res.Resources; -import android.net.Uri; -import android.os.Build; -import android.text.Html; -import android.util.Base64; -import android.util.Log; - -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CallbackContext; -import org.apache.cordova.PluginResult; - -@SuppressWarnings("Convert2Diamond") -public class EmailComposer extends CordovaPlugin { - - // - static private final String STORAGE_FOLDER = "/email_composer"; - - // The callback context used when calling back into JavaScript - private CallbackContext command; - - /** - * Executes the request. - * - * This method is called from the WebView thread. - * To do a non-trivial amount of work, use: - * cordova.getThreadPool().execute(runnable); - * - * To run on the UI thread, use: - * cordova.getActivity().runOnUiThread(runnable); - * - * @param action The action to execute. - * @param args The exec() arguments in JSON form. - * @param callback The callback context used when calling - * back into JavaScript. - * @return Whether the action was valid. - */ - @Override - public boolean execute (String action, JSONArray args, - CallbackContext callback) throws JSONException { - - this.command = callback; - - if ("open".equals(action)) { - open(args); - - return true; - } - - if ("isAvailable".equals(action)) { - isAvailable(); - - return true; - } - - // Returning false results in a "MethodNotFound" error. - return false; - } - - /** - * Tells if the device has the capability to send emails. - */ - private void isAvailable () { - cordova.getThreadPool().execute(new Runnable() { - public void run() { - Boolean available = isEmailAccountConfigured(); - PluginResult result = new PluginResult(PluginResult.Status.OK, available); - - command.sendPluginResult(result); - } - }); - } - - /** - * Sends an intent to the email app. - * - * @param args - * The email properties like subject or body - * - * @throws JSONException - */ - private void open (JSONArray args) throws JSONException { - JSONObject properties = args.getJSONObject(0); - Intent draft = getDraftWithProperties(properties); - - final Intent chooser = Intent.createChooser(draft, "Open with"); - final EmailComposer plugin = this; - - cordova.getThreadPool().execute(new Runnable() { - public void run() { - cordova.startActivityForResult( - plugin, chooser, 0); - } - }); - } - - /** - * The intent with the containing email properties. - * - * @param params - * The email properties like subject or body - * @return - * The resulting intent - * - * @throws JSONException - */ - private Intent getDraftWithProperties (JSONObject params) throws JSONException { - Intent mail = new Intent(Intent.ACTION_SEND_MULTIPLE); - String app = params.optString("app", null); - - if (params.has("subject")) - setSubject(params.getString("subject"), mail); - if (params.has("body")) - setBody(params.getString("body"), params.optBoolean("isHtml"), mail); - if (params.has("to")) - setRecipients(params.getJSONArray("to"), mail); - if (params.has("cc")) - setCcRecipients(params.getJSONArray("cc"), mail); - if (params.has("bcc")) - setBccRecipients(params.getJSONArray("bcc"), mail); - if (params.has("attachments")) - setAttachments(params.getJSONArray("attachments"), mail); - - if (app != null && isAppInstalled(app)) { - mail.setPackage(app); - } - - mail.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - return mail; - } - - /** - * Setter for the subject. - * - * @param subject - * The subject - * @param draft - * The intent - */ - private void setSubject (String subject, Intent draft) { - draft.putExtra(Intent.EXTRA_SUBJECT, subject); - } - - /** - * Setter for the body. - * - * @param body - * The body - * @param isHTML - * Indicates the encoding - * (HTML or plain text) - * @param draft - * The intent - */ - private void setBody (String body, Boolean isHTML, Intent draft) { - if (isHTML) { - draft.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); - draft.setType("text/html"); - - if (Build.VERSION.SDK_INT > 15) { - draft.putExtra(Intent.EXTRA_HTML_TEXT, body); - } - } else { - draft.putExtra(Intent.EXTRA_TEXT, body); - draft.setType("text/plain"); - } - } - - /** - * Setter for the recipients. - * - * @param recipients - * List of email addresses - * @param draft - * The intent - * - * @throws JSONException - */ - private void setRecipients (JSONArray recipients, Intent draft) throws JSONException { - String[] receivers = new String[recipients.length()]; - - for (int i = 0; i < recipients.length(); i++) { - receivers[i] = recipients.getString(i); - } - - draft.putExtra(Intent.EXTRA_EMAIL, receivers); - } - - /** - * Setter for the cc recipients. - * - * @param recipients - * List of email addresses - * @param draft - * The intent - * - * @throws JSONException - */ - private void setCcRecipients (JSONArray recipients, Intent draft) throws JSONException { - String[] receivers = new String[recipients.length()]; - - for (int i = 0; i < recipients.length(); i++) { - receivers[i] = recipients.getString(i); - } - - draft.putExtra(Intent.EXTRA_CC, receivers); - } - - /** - * Setter for the bcc recipients. - * - * @param recipients - * List of email addresses - * @param draft - * The intent - * - * @throws JSONException - */ - private void setBccRecipients (JSONArray recipients, Intent draft) throws JSONException { - String[] receivers = new String[recipients.length()]; - - for (int i = 0; i < recipients.length(); i++) { - receivers[i] = recipients.getString(i); - } - - draft.putExtra(Intent.EXTRA_BCC, receivers); - } - - /** - * Setter for the attachments. - * - * @param attachments - * List of URIs - * @param draft - * The intent - * - * @throws JSONException - */ - private void setAttachments (JSONArray attachments, Intent draft) throws JSONException { - ArrayList<Uri> uris = new ArrayList<Uri>(); - - for (int i = 0; i < attachments.length(); i++) { - Uri uri = getUriForPath(attachments.getString(i)); - - uris.add(uri); - } - - draft.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); - } - - /** - * The URI for an attachment path. - * - * @param path - * The given path to the attachment - * - * @return - * The URI pointing to the given path - */ - private Uri getUriForPath (String path) { - if (path.startsWith("res:")) { - return getUriForResourcePath(path); - } else if (path.startsWith("file:///")) { - return getUriForAbsolutePath(path); - } else if (path.startsWith("file://")) { - return getUriForAssetPath(path); - } else if (path.startsWith("base64:")) { - return getUriForBase64Content(path); - } - - return Uri.parse(path); - } - - /** - * The URI for a file. - * - * @param path - * The given absolute path - * - * @return - * The URI pointing to the given path - */ - private Uri getUriForAbsolutePath (String path) { - String absPath = path.replaceFirst("file://", ""); - File file = new File(absPath); - - if (!file.exists()) { - Log.e("EmailComposer", "File not found: " + file.getAbsolutePath()); - } - - return Uri.fromFile(file); - } - - /** - * The URI for an asset. - * - * @param path - * The given asset path - * - * @return - * The URI pointing to the given path - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - private Uri getUriForAssetPath (String path) { - String resPath = path.replaceFirst("file:/", "www"); - String fileName = resPath.substring(resPath.lastIndexOf('/') + 1); - File dir = cordova.getActivity().getExternalCacheDir(); - - if (dir == null) { - Log.e("EmailComposer", "Missing external cache dir"); - return Uri.EMPTY; - } - - String storage = dir.toString() + STORAGE_FOLDER; - File file = new File(storage, fileName); - - new File(storage).mkdir(); - - try { - AssetManager assets = cordova.getActivity().getAssets(); - - FileOutputStream outStream = new FileOutputStream(file); - InputStream inputStream = assets.open(resPath); - - copyFile(inputStream, outStream); - outStream.flush(); - outStream.close(); - } catch (Exception e) { - Log.e("EmailComposer", "File not found: assets/" + resPath); - e.printStackTrace(); - } - - return Uri.fromFile(file); - } - - /** - * The URI for a resource. - * - * @param path - * The given relative path - * - * @return - * The URI pointing to the given path - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - private Uri getUriForResourcePath (String path) { - String resPath = path.replaceFirst("res://", ""); - String fileName = resPath.substring(resPath.lastIndexOf('/') + 1); - String resName = fileName.substring(0, fileName.lastIndexOf('.')); - String extension = resPath.substring(resPath.lastIndexOf('.')); - File dir = cordova.getActivity().getExternalCacheDir(); - - if (dir == null) { - Log.e("EmailComposer", "Missing external cache dir"); - return Uri.EMPTY; - } - - String storage = dir.toString() + STORAGE_FOLDER; - int resId = getResId(resPath); - File file = new File(storage, resName + extension); - - if (resId == 0) { - Log.e("EmailComposer", "File not found: " + resPath); - } - - new File(storage).mkdir(); - - try { - Resources res = cordova.getActivity().getResources(); - FileOutputStream outStream = new FileOutputStream(file); - InputStream inputStream = res.openRawResource(resId); - - copyFile(inputStream, outStream); - outStream.flush(); - outStream.close(); - } catch (Exception e) { - e.printStackTrace(); - } - - return Uri.fromFile(file); - } - - /** - * The URI for a base64 encoded content. - * - * @param content - * The given base64 encoded content - * - * @return - * The URI including the given content - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - private Uri getUriForBase64Content (String content) { - String resName = content.substring(content.indexOf(":") + 1, content.indexOf("//")); - String resData = content.substring(content.indexOf("//") + 2); - File dir = cordova.getActivity().getExternalCacheDir(); - byte[] bytes; - - try { - bytes = Base64.decode(resData, 0); - } catch (Exception ignored) { - Log.e("EmailComposer", "Invalid Base64 string"); - return Uri.EMPTY; - } - - if (dir == null) { - Log.e("EmailComposer", "Missing external cache dir"); - return Uri.EMPTY; - } - - String storage = dir.toString() + STORAGE_FOLDER; - File file = new File(storage, resName); - - new File(storage).mkdir(); - - try { - FileOutputStream outStream = new FileOutputStream(file); - - outStream.write(bytes); - outStream.flush(); - outStream.close(); - } catch (Exception e) { - e.printStackTrace(); - } - - return Uri.fromFile(file); - } - - /** - * Writes an InputStream to an OutputStream - * - * @param in - * The input stream - * @param out - * The output stream - */ - private void copyFile (InputStream in, OutputStream out) throws IOException { - byte[] buffer = new byte[1024]; - int read; - - while((read = in.read(buffer)) != -1){ - out.write(buffer, 0, read); - } - } - - /** - * @return - * The resource ID for the given resource. - */ - private int getResId (String resPath) { - Resources res = cordova.getActivity().getResources(); - int resId; - - String pkgName = getPackageName(); - String dirName = "drawable"; - String fileName = resPath; - - if (resPath.contains("/")) { - dirName = resPath.substring(0, resPath.lastIndexOf('/')); - fileName = resPath.substring(resPath.lastIndexOf('/') + 1); - } - - String resName = fileName.substring(0, fileName.lastIndexOf('.')); - - resId = res.getIdentifier(resName, dirName, pkgName); - - if (resId == 0) { - resId = res.getIdentifier(resName, "drawable", pkgName); - } - - return resId; - } - - /** - * If email apps are available. - * - * @return - * true if available, otherwise false - */ - private Boolean isEmailAccountConfigured () { - Uri uri = Uri.fromParts("mailto","max@mustermann.com", null); - Intent intent = new Intent(Intent.ACTION_SENDTO, uri); - PackageManager pm = cordova.getActivity().getPackageManager(); - int mailApps = pm.queryIntentActivities(intent, 0).size(); - Boolean available; - - available = mailApps > 0; - - return available; - } - - /** - * Ask the package manager if the app is installed on the device. - * - * @param id - * The app id - * - * @return - * true if yes otherwise false - */ - private boolean isAppInstalled(String id) { - PackageManager pm = cordova.getActivity().getPackageManager(); - - try { - pm.getPackageInfo(id, 0); - return true; - } catch(PackageManager.NameNotFoundException e) { - return false; - } - } - - /** - * The name for the package. - * - * @return - * The package name - */ - private String getPackageName () { - return cordova.getActivity().getPackageName(); - } - - /** - * Called when an activity you launched exits, giving you the reqCode you - * started it with, the resCode it returned, and any additional data from it. - * - * @param reqCode The request code originally supplied to startActivityForResult(), - * allowing you to identify who this result came from. - * @param resCode The integer result code returned by the child activity - * through its setResult(). - * @param intent An Intent, which can return result data to the caller - * (various data can be attached to Intent "extras"). - */ - @Override - public void onActivityResult(int reqCode, int resCode, Intent intent) { - command.success(); - } -} diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.h b/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.h deleted file mode 100644 index c7ea09b8..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import <Foundation/Foundation.h> -#import <MessageUI/MFMailComposeViewController.h> -#import <Cordova/CDVPlugin.h> - -@interface APPEmailComposer : CDVPlugin <MFMailComposeViewControllerDelegate> - -// Shows the email composer view with pre-filled data -- (void) open:(CDVInvokedUrlCommand*)command; -// Checks if the mail composer is able to send mails -- (void) isAvailable:(CDVInvokedUrlCommand*)command; - -@end diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.m b/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.m deleted file mode 100644 index 52bb66d7..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/ios/APPEmailComposer.m +++ /dev/null @@ -1,490 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import "APPEmailComposer.h" -#import "Cordova/NSData+Base64.h" -#import "Cordova/CDVAvailability.h" -#import <MobileCoreServices/MobileCoreServices.h> - -#include "TargetConditionals.h" - -@interface APPEmailComposer () - -@property (nonatomic, retain) CDVInvokedUrlCommand* command; - -@end - -@implementation APPEmailComposer - -#pragma mark - -#pragma mark Plugin interface methods - -/** - * Checks if the mail composer is able to send mails. - * - * @param callbackId - * The ID of the JS function to be called with the result - */ -- (void) isAvailable:(CDVInvokedUrlCommand*)command -{ - [self.commandDelegate runInBackground:^{ - bool canSendMail = [MFMailComposeViewController canSendMail]; - CDVPluginResult* result; - - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK - messageAsBool:canSendMail]; - - [self.commandDelegate sendPluginResult:result - callbackId:command.callbackId]; - }]; -} - -/** - * Shows the email composer view with pre-filled data. - * - * @param properties - * The email properties like subject, body, attachments - */ -- (void) open:(CDVInvokedUrlCommand*)command -{ - _command = command; - - if (TARGET_IPHONE_SIMULATOR && IsAtLeastiOSVersion(@"8.0")) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email-Composer Plug-in" - message:@"Plug-in cannot run on the iOS8 Simulator.\nPlease downgrade or use a physical device." - delegate:nil - cancelButtonTitle:@"OK" - otherButtonTitles:nil]; - [alert show]; - [self execCallback]; - return; - } - - [self.commandDelegate runInBackground:^{ - NSArray* args = command.arguments; - NSDictionary* properties = [args objectAtIndex:0]; - MFMailComposeViewController* draft; - - draft = [self getDraftWithProperties:properties]; - - if (!draft) { - [self execCallback]; - return; - } - - [self openDraft:draft]; - }]; -} - -#pragma mark - -#pragma mark MFMailComposeViewControllerDelegate methods - -/** - * Delegate will be called after the mail composer did finish an action - * to dismiss the view. - */ -- (void) mailComposeController:(MFMailComposeViewController*)controller - didFinishWithResult:(MFMailComposeResult)result - error:(NSError*)error -{ - [controller dismissViewControllerAnimated:YES completion:nil]; - - [self execCallback]; -} - -#pragma mark - -#pragma mark Plugin core methods - -/** - * Instantiates an email composer view. - * - * @param properties - * The email properties like subject, body, attachments - * - * @return - * The configured email composer view - */ -- (MFMailComposeViewController*) getDraftWithProperties:(NSDictionary*)properties -{ - // Falls das Gerät kein Email Interface unterstützt - if (![MFMailComposeViewController canSendMail]) { - return NULL; - } - - BOOL isHTML = [[properties objectForKey:@"isHtml"] boolValue]; - - MFMailComposeViewController* draft; - - draft = [[MFMailComposeViewController alloc] init]; - - // Subject - [self setSubject:[properties objectForKey:@"subject"] ofDraft:draft]; - // Body (as HTML) - [self setBody:[properties objectForKey:@"body"] ofDraft:draft isHTML:isHTML]; - // Recipients - [self setToRecipients:[properties objectForKey:@"to"] ofDraft:draft]; - // CC Recipients - [self setCcRecipients:[properties objectForKey:@"cc"] ofDraft:draft]; - // BCC Recipients - [self setBccRecipients:[properties objectForKey:@"bcc"] ofDraft:draft]; - // Attachments - [self setAttachments:[properties objectForKey:@"attachments"] ofDraft:draft]; - - draft.mailComposeDelegate = self; - - return draft; -} - -/** - * Displays the email draft. - * - * @param draft - * The email composer view - */ -- (void) openDraft:(MFMailComposeViewController*)draft -{ - [self.viewController presentViewController:draft - animated:YES - completion:NULL]; -} - -/** - * Sets the subject of the email draft. - * - * @param subject - * The subject of the email - * @param draft - * The email composer view - */ -- (void) setSubject:(NSString*)subject - ofDraft:(MFMailComposeViewController*)draft -{ - [draft setSubject:subject]; -} - -/** - * Sets the body of the email draft. - * - * @param body - * The body of the email - * @param isHTML - * Indicates if the body is an HTML encoded string - * @param draft - * The email composer view - */ -- (void) setBody:(NSString*)body ofDraft:(MFMailComposeViewController*)draft - isHTML:(BOOL)isHTML -{ - [draft setMessageBody:body isHTML:isHTML]; -} - -/** - * Sets the recipients of the email draft. - * - * @param recipients - * The recipients of the email - * @param draft - * The email composer view - */ -- (void) setToRecipients:(NSArray*)recipients - ofDraft:(MFMailComposeViewController*)draft -{ - [draft setToRecipients:recipients]; -} - -/** - * Sets the CC recipients of the email draft. - * - * @param ccRecipients - * The CC recipients of the email - * @param draft - * The email composer view - */ -- (void) setCcRecipients:(NSArray*)ccRecipients - ofDraft:(MFMailComposeViewController*)draft -{ - [draft setCcRecipients:ccRecipients]; -} - -/** - * Sets the BCC recipients of the email draft. - * - * @param bccRecipients - * The BCC recipients of the email - * @param draft - * The email composer view - */ -- (void) setBccRecipients:(NSArray*)bccRecipients - ofDraft:(MFMailComposeViewController*)draft -{ - [draft setBccRecipients:bccRecipients]; -} - -/** - * Sets the attachments of the email draft. - * - * @param attachments - * The attachments of the email - * @param draft - * The email composer view - */ -- (void) setAttachments:(NSArray*)attatchments - ofDraft:(MFMailComposeViewController*)draft -{ - if (attatchments) - { - for (NSString* path in attatchments) - { - NSData* data = [self getDataForAttachmentPath:path]; - - NSString* basename = [self getBasenameFromAttachmentPath:path]; - NSString* pathExt = [basename pathExtension]; - NSString* fileName = [basename pathComponents].lastObject; - NSString* mimeType = [self getMimeTypeFromFileExtension:pathExt]; - - // Couldn't find mimeType, must be some type of binary data - if (mimeType == nil) mimeType = @"application/octet-stream"; - - [draft addAttachmentData:data mimeType:mimeType fileName:fileName]; - } - } -} - -/** - * Returns the data for a given (relative) attachment path. - * - * @param path - * An absolute/relative path or the base64 data - * - * @return - * The data for the attachment - */ -- (NSData*) getDataForAttachmentPath:(NSString*)path -{ - if ([path hasPrefix:@"file:///"]) - { - return [self dataForAbsolutePath:path]; - } - else if ([path hasPrefix:@"res:"]) - { - return [self dataForResource:path]; - } - else if ([path hasPrefix:@"file://"]) - { - return [self dataForAsset:path]; - } - else if ([path hasPrefix:@"base64:"]) - { - return [self dataFromBase64:path]; - } - - NSFileManager* fileManager = [NSFileManager defaultManager]; - - if (![fileManager fileExistsAtPath:path]){ - NSLog(@"File not found: %@", path); - } - - return [fileManager contentsAtPath:path]; -} - -/** - * Retrieves the data for an absolute attachment path. - * - * @param path - * An absolute file path - * - * @return - * The data for the attachment - */ -- (NSData*) dataForAbsolutePath:(NSString*)path -{ - NSFileManager* fileManager = [NSFileManager defaultManager]; - NSString* absPath; - - absPath = [path stringByReplacingOccurrencesOfString:@"file://" - withString:@""]; - - if (![fileManager fileExistsAtPath:absPath]){ - NSLog(@"File not found: %@", absPath); - } - - NSData* data = [fileManager contentsAtPath:absPath]; - - return data; -} - -/** - * Retrieves the data for a resource path. - * - * @param path - * A relative file path - * - * @return - * The data for the attachment - */ -- (NSData*) dataForResource:(NSString*)path -{ - NSFileManager* fileManager = [NSFileManager defaultManager]; - NSString* absPath; - - NSBundle* mainBundle = [NSBundle mainBundle]; - NSString* bundlePath = [[mainBundle bundlePath] - stringByAppendingString:@"/"]; - - absPath = [path pathComponents].lastObject; - - absPath = [bundlePath stringByAppendingString:absPath]; - - if (![fileManager fileExistsAtPath:absPath]){ - NSLog(@"File not found: %@", absPath); - } - - NSData* data = [fileManager contentsAtPath:absPath]; - - return data; -} - -/** - * Retrieves the data for a asset path. - * - * @param path - * A relative www file path - * - * @return - * The data for the attachment - */ -- (NSData*) dataForAsset:(NSString*)path -{ - NSFileManager* fileManager = [NSFileManager defaultManager]; - NSString* absPath; - - NSBundle* mainBundle = [NSBundle mainBundle]; - NSString* bundlePath = [[mainBundle bundlePath] - stringByAppendingString:@"/"]; - - absPath = [path stringByReplacingOccurrencesOfString:@"file:/" - withString:@"www"]; - - absPath = [bundlePath stringByAppendingString:absPath]; - - if (![fileManager fileExistsAtPath:absPath]){ - NSLog(@"File not found: %@", absPath); - } - - NSData* data = [fileManager contentsAtPath:absPath]; - - return data; -} - -/** - * Retrieves the data for a base64 encoded string. - * - * @param base64String - * Base64 encoded string - * - * @return - * The data for the attachment - */ -- (NSData*) dataFromBase64:(NSString*)base64String -{ - NSUInteger length = [base64String length]; - NSRegularExpression *regex; - NSString *dataString; - - regex = [NSRegularExpression regularExpressionWithPattern:@"^base64:[^/]+.." - options:NSRegularExpressionCaseInsensitive - error:Nil]; - - dataString = [regex stringByReplacingMatchesInString:base64String - options:0 - range:NSMakeRange(0, length) - withTemplate:@""]; - - NSData* data = [NSData dataFromBase64String:dataString]; - - return data; -} - -#pragma mark - -#pragma mark Plugin helper methods - -/** - * Retrieves the mime type from the file extension. - * - * @param extension - * The file's extension - * - * @return - * The coresponding MIME type - */ -- (NSString*) getMimeTypeFromFileExtension:(NSString*)extension -{ - if (!extension) { - return nil; - } - - // Get the UTI from the file's extension - CFStringRef ext = (CFStringRef)CFBridgingRetain(extension); - CFStringRef type = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL); - - // Converting UTI to a mime type - return (NSString*)CFBridgingRelease(UTTypeCopyPreferredTagWithClass(type, kUTTagClassMIMEType)); -} - -/** - * Retrieves the attachments basename. - * - * @param path - * The file path or bas64 data of the attachment - * - * @return - * The attachments basename - */ -- (NSString*) getBasenameFromAttachmentPath:(NSString*)path -{ - if ([path hasPrefix:@"base64:"]) - { - NSString* pathWithoutPrefix; - - pathWithoutPrefix = [path stringByReplacingOccurrencesOfString:@"base64:" - withString:@""]; - - return [pathWithoutPrefix substringToIndex: - [pathWithoutPrefix rangeOfString:@"//"].location]; - } - - return path; - -} - -/** - * Invokes the callback without any parameter. - */ -- (void) execCallback -{ - CDVPluginResult *result = [CDVPluginResult - resultWithStatus:CDVCommandStatus_OK]; - - [self.commandDelegate sendPluginResult:result - callbackId:_command.callbackId]; -} - -@end diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/windows/EmailComposerProxy.js b/plugins/de.appplant.cordova.plugin.email-composer/src/windows/EmailComposerProxy.js deleted file mode 100644 index 382eb79a..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/windows/EmailComposerProxy.js +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - 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. -*/ - -/** - * Verifies if sending emails is supported on the device. - * - * @param {Function} success - * Success callback function - * @param {Function} error - * Error callback function - * @param {Array} args - * Interface arguments - */ -exports.isAvailable = function (success, error, args) { - success(true); -}; - -/** - * Displays the email composer pre-filled with data. - * - * @param {Function} success - * Success callback function - * @param {Function} error - * Error callback function - * @param {Array} args - * Interface arguments - */ -exports.open = function (success, error, args) { - var props = args[0], - email = exports.getDraftWithProperties(props); - - Windows.ApplicationModel.Email.EmailManager - .showComposeNewEmailAsync(email) - .done(success()); -}; - -/** - * The Email with the containing properties. - * - * @param {Object} props - * The email properties like subject or body - * @return {Windows.ApplicationModel.Email.EmailMessage} - * The resulting email draft - */ -exports.getDraftWithProperties = function (props) { - var mail = new Windows.ApplicationModel.Email.EmailMessage(); - - // subject - exports.setSubject(props.subject, mail); - // body - exports.setBody(props.body, props.isHtml, mail); - // To recipients - exports.setRecipients(props.to, mail); - // CC recipients - exports.setCcRecipients(props.cc, mail); - // BCC recipients - exports.setBccRecipients(props.bcc, mail); - // attachments - exports.setAttachments(props.attachments, mail); - - return mail; -}; - -/** - * Setter for the subject. - * - * @param {String} subject - * The subject - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setSubject = function (subject, draft) { - draft.subject = subject; -}; - -/** - * Setter for the body. - * - * @param {String} body - * The body - * @param isHTML - * Indicates the encoding - * (HTML or plain text) - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setBody = function (body, isHTML, draft) { - draft.body = body; -}; - -/** - * Setter for the recipients. - * - * @param {String[]} recipients - * List of mail addresses - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setRecipients = function (recipients, draft) { - recipients.forEach(function (address) { - draft.to.push( - new Windows.ApplicationModel.Email.EmailRecipient(address)); - }); -}; - -/** - * Setter for the cc recipients. - * - * @param {String[]} recipients - * List of mail addresses - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setCcRecipients = function (recipients, draft) { - recipients.forEach(function (address) { - draft.cc.push( - new Windows.ApplicationModel.Email.EmailRecipient(address)); - }); -}; - -/** - * Setter for the bcc recipients. - * - * @param {String[]} recipients - * List of mail addresses - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setBccRecipients = function (recipients, draft) { - recipients.forEach(function (address) { - draft.bcc.push( - new Windows.ApplicationModel.Email.EmailRecipient(address)); - }); -}; - -/** - * Setter for the attachments. - * - * @param {String[]} attachments - * List of URIs - * @param {Windows.ApplicationModel.Email.EmailMessage} draft - * The draft - */ -exports.setAttachments = function (attachments, draft) { - attachments.forEach(function (path) { - var uri = exports.getUriForPath(path), - name = uri.path.split('/').reverse()[0], - stream = Windows.Storage.Streams.RandomAccessStreamReference - .createFromUri(uri); - - draft.attachments.push( - new Windows.ApplicationModel.Email. - EmailAttachment(name, stream) - ); - }); -}; - -/** - * The URI for an attachment path. - * - * @param {String} path - * The given path to the attachment - * - * @return - * The URI pointing to the given path - */ -exports.getUriForPath = function (path) { - if (path.match(/^res:/)) { - return exports.getUriForResourcePath(path); - } else if (path.match(/^file:\/{3}/)) { - return exports.getUriForAbsolutePath(path); - } else if (path.match(/^file:/)) { - return exports.getUriForAssetPath(path); - } else if (path.match(/^base64:/)) { - return exports.getUriForBase64Content(path); - } - - return new Windows.Foundation.Uri(path); -}; - -/** - * The URI for a file. - * - * @param {String} path - * The given absolute path - * - * @return - * The URI pointing to the given path - */ -exports.getUriForAbsolutePath = function (path) { - return new Windows.Foundation.Uri(path); -}; - -/** - * The URI for an asset. - * - * @param {String} path - * The given asset path - * - * @return - * The URI pointing to the given path - */ -exports.getUriForAssetPath = function (path) { - var host = document.location.host, - protocol = document.location.protocol, - resPath = path.replace('file:/', '/www'), - rawUri = protocol + '//' + host + resPath; - - return new Windows.Foundation.Uri(rawUri); -}; - -/** - * The URI for a resource. - * - * @param {String} path - * The given relative path - * - * @return - * The URI pointing to the given path - */ -exports.getUriForResourcePath = function (path) { - var host = document.location.host, - protocol = document.location.protocol, - resPath = path.replace('res:/', '/images'), - rawUri = protocol + '//' + host + resPath; - - return new Windows.Foundation.Uri(rawUri); -}; - -/** - * The URI for a base64 encoded content. - * - * @param {String} content - * The given base64 encoded content - * - * @return - * The URI including the given content - */ -exports.getUriForBase64Content = function (content) { - var match = content.match(/^base64:([^\/]+)\/\/(.*)/), - base64 = match[2], - name = match[1], - buffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(base64), - rwplus = Windows.Storage.CreationCollisionOption.openIfExists, - folder = Windows.Storage.ApplicationData.current.temporaryFolder, - uri = new Windows.Foundation.Uri('ms-appdata:///temp/' + name); - - folder.createFileAsync(name, rwplus).done(function (file) { - Windows.Storage.FileIO.writeBufferAsync(file, buffer); - }); - - return uri; -}; - -require('cordova/exec/proxy').add('EmailComposer', exports); diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/EmailComposer.cs b/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/EmailComposer.cs deleted file mode 100644 index db0d613e..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/EmailComposer.cs +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - 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. -*/ - -using De.APPPlant.Cordova.Plugin.EmailComposer; -using Microsoft.Phone.Tasks; -using System; -using System.Linq; -using WPCordovaClassLib.Cordova; -using WPCordovaClassLib.Cordova.Commands; -using WPCordovaClassLib.Cordova.JSON; - -namespace Cordova.Extension.Commands -{ - /// <summary> - /// Implementes access to email composer task - /// http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394003(v=vs.105).aspx - /// </summary> - public class EmailComposer : BaseCommand - { - /// <summary> - /// Überprüft, ob Emails versendet werden können. - /// </summary> - public void isAvailable(string jsonArgs) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true)); - } - - /// <summary> - /// Öffnet den Email-Kontroller mit vorausgefüllten Daten. - /// </summary> - public void open(string jsonArgs) - { - string[] args = JsonHelper.Deserialize<string[]>(jsonArgs); - Options options = JsonHelper.Deserialize<Options>(args[0]); - EmailComposeTask draft = GetDraftWithProperties(options); - - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true)); - - OpenDraft(draft); - } - - /// </summary> - /// Erstellt den Email-Composer und fügt die übergebenen Eigenschaften ein. - /// </summary> - private EmailComposeTask GetDraftWithProperties(Options options) - { - EmailComposeTask draft = new EmailComposeTask(); - - SetSubject(options.Subject, draft); - SetBody(options.Body, options.IsHtml, draft); - SetTo(options.To, draft); - SetCc(options.Cc, draft); - SetBcc(options.Bcc, draft); - SetAttachments(options.Attachments, draft); - - return draft; - } - - /// </summary> - /// Zeigt den ViewController zum Versenden/Bearbeiten der Mail an. - /// </summary> - private void OpenDraft(EmailComposeTask draft) - { - draft.Show(); - } - - /// </summary> - /// Setzt den Subject der Mail. - /// </summary> - private void SetSubject(string subject, EmailComposeTask draft) - { - draft.Subject = subject; - } - - /// </summary> - /// Setzt den Body der Mail. - /// </summary> - private void SetBody(string body, Boolean isHTML, EmailComposeTask draft) - { - draft.Body = body; - } - - /// </summary> - /// Setzt die Empfänger der Mail. - /// </summary> - private void SetTo(string[] recipients, EmailComposeTask draft) - { - draft.To = string.Join(",", recipients); - } - - /// </summary> - /// Setzt die CC-Empfänger der Mail. - /// </summary> - private void SetCc(string[] recipients, EmailComposeTask draft) - { - draft.Cc = string.Join(",", recipients); - } - - /// </summary> - /// Setzt die BCC-Empfänger der Mail. - /// </summary> - private void SetBcc(string[] recipients, EmailComposeTask draft) - { - draft.Bcc = string.Join(",", recipients); - } - - /// </summary> - /// Fügt die Anhände zur Mail hinzu. - /// </summary> - private void SetAttachments(string[] attachments, EmailComposeTask draft) - { - // Not supported on WP8.0 and WP8.1 Silverlight - } - } -} diff --git a/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/Options.cs b/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/Options.cs deleted file mode 100644 index b7c7206e..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/src/wp8/Options.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - 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. -*/ - -using System; -using System.Linq; -using System.Runtime.Serialization; - -namespace De.APPPlant.Cordova.Plugin.EmailComposer -{ - /// <summary> - /// Represents email composer task options - /// </summary> - [DataContract] - class Options - { - /// <summary> - /// Represents the subject of the email - /// </summary> - [DataMember(IsRequired = false, Name = "subject")] - public string Subject { get; set; } - - /// <summary> - /// Represents the email body (could be HTML code, in this case set isHtml to true) - /// </summary> - [DataMember(IsRequired = false, Name = "body")] - public string Body { get; set; } - - /// <summary> - /// Indicats if the body is HTML or plain text - /// </summary> - [DataMember(IsRequired = false, Name = "isHtml")] - public bool IsHtml { get; set; } - - /// <summary> - /// Contains all the email addresses for TO field - /// </summary> - [DataMember(IsRequired = false, Name = "to")] - public string[] To { get; set; } - - /// <summary> - /// Contains all the email addresses for CC field - /// </summary> - [DataMember(IsRequired = false, Name = "cc")] - public string[] Cc { get; set; } - - /// <summary> - /// Contains all the email addresses for BCC field - /// </summary> - [DataMember(IsRequired = false, Name = "bcc")] - public string[] Bcc { get; set; } - - /// <summary> - /// Contains all full paths to the files you want to attach - /// </summary> - [DataMember(IsRequired = false, Name = "attachments")] - public string[] Attachments { get; set; } - } -} diff --git a/plugins/de.appplant.cordova.plugin.email-composer/www/email_composer.js b/plugins/de.appplant.cordova.plugin.email-composer/www/email_composer.js deleted file mode 100644 index 7fd86076..00000000 --- a/plugins/de.appplant.cordova.plugin.email-composer/www/email_composer.js +++ /dev/null @@ -1,186 +0,0 @@ -/* - Copyright 2013-2015 appPlant UG - - 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. -*/ - -var exec = require('cordova/exec'); - -/** - * List of all registered mail app aliases. - */ -exports.aliases = { - gmail: 'com.google.android.gm' -}; - -/** - * List of all available options with their default value. - * - * @return {Object} - */ -exports.getDefaults = function () { - return { - app: undefined, - subject: '', - body: '', - to: [], - cc: [], - bcc: [], - attachments: [], - isHtml: true - }; -}; - -/** - * Verifies if sending emails is supported on the device. - * - * @param {Function} callback - * A callback function to be called with the result - * @param {Object} scope - * The scope of the callback - */ -exports.isAvailable = function (callback, scope) { - var fn = this.createCallbackFn(callback, scope); - - exec(fn, null, 'EmailComposer', 'isAvailable', []); -}; - -/** - * Displays the email composer pre-filled with data. - * - * @param {Object} options - * Different properties of the email like the body, subject - * @param {Function} callback - * A callback function to be called with the result - * @param {Object?} scope - * The scope of the callback - */ -exports.open = function (options, callback, scope) { - var fn = this.createCallbackFn(callback, scope); - - options = this.mergeWithDefaults(options || {}); - - exec(fn, null, 'EmailComposer', 'open', [options]); -}; - -/** - * Adds a new mail app alias. - * - * @param {String} alias - * The alias name - * @param {String} package - * The package name - */ -exports.addAlias = function (alias, package) { - this.aliases[alias] = package; -} - -/** - * @depreacted - */ -exports.isServiceAvailable = function () { - console.log('`email.isServiceAvailable` is deprecated.' + - ' Please use `email.isAvailable` instead.'); - - this.isAvailable.apply(this, arguments); -}; - -/** - * Alias für `open()`. - */ -exports.openDraft = function () { - this.open.apply(this, arguments); -}; - -/** - * @private - * - * Merge settings with default values. - * - * @param {Object} options - * The custom options - * - * @retrun {Object} - * Default values merged - * with custom values - */ -exports.mergeWithDefaults = function (options) { - var defaults = this.getDefaults(); - - if (options.hasOwnProperty('isHTML')) { - options.isHtml = options.isHTML; - } - - if (options.hasOwnProperty('app')) { - var package = this.aliases[options.app]; - - options.app = package || options.app; - } - - for (var key in defaults) { - - if (!options.hasOwnProperty(key)) { - options[key] = defaults[key]; - continue; - } - - var custom_ = options[key], - default_ = defaults[key]; - - if (custom_ === null || custom_ === undefined) { - options[key] = default_; - continue; - } - - if (typeof default_ != typeof custom_) { - - if (typeof default_ == 'string') { - options[key] = custom_.join(''); - } - - else if (typeof default_ == 'object') { - options[key] = [custom_.toString()]; - } - } - } - - return options; -}; - -/** - * @private - * - * Creates a callback, which will be executed - * within a specific scope. - * - * @param {Function} callbackFn - * The callback function - * @param {Object} scope - * The scope for the function - * - * @return {Function} - * The new callback function - */ -exports.createCallbackFn = function (callbackFn, scope) { - if (typeof callbackFn != 'function') - return; - - return function () { - callbackFn.apply(scope || this, arguments); - }; -}; |
