From 591f55e3d7dad5a02ffe1afb21a6759ac84342a6 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 14 Sep 2015 17:38:33 +0000 Subject: [PATCH] WIP mailvelope installation dialog --- .../templates/default/pgp_installation.xet | 10 ++++ phpgwapi/js/jsapi/app_base.js | 60 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 etemplate/templates/default/pgp_installation.xet diff --git a/etemplate/templates/default/pgp_installation.xet b/etemplate/templates/default/pgp_installation.xet new file mode 100644 index 0000000000..a7cc93e177 --- /dev/null +++ b/etemplate/templates/default/pgp_installation.xet @@ -0,0 +1,10 @@ + + + + + diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index 2e8bfd8964..c62ca1c652 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -971,6 +971,7 @@ var AppJS = Class.extend( } else { + egw.message('You need to install Mailvelope plugin available for Chrome and Firefox from mailvelope.com.Add your domain as "*.localhost" in options to list of email providers and enable API.', true); jQuery(window).on('mailvelope', function() { self.mailvelopeOpenKeyring().then(callback); @@ -1276,6 +1277,65 @@ var AppJS = Class.extend( }, + mailvelopeInstallationOffer: function () + { + var dialog = function(_content, _callback) + { + return et2_createWidget("dialog", { + callback: function(_button_id, _value) { + if (typeof _callback == "function") + { + _callback.call(this, _button_id, _value.value); + } + }, + title: egw.lang('PGP Encryption Installation'), + buttons: et2_dialog.BUTTONS_YES_NO, + dialog_type: 'info', + value: { + content: _content + }, + template: egw.webserverUrl+'/etemplate/templates/default/pgp_installation.xet', + class: "pgp_installation", + modal: true, + //resizable:false, + + }); + }; + var content = [{}]; + dialog(content, function(_button){ + if (_button == et2_dialog.YES_BUTTON) + { + if (typeof chrome != 'undefined' && typeof chrome.webstore != 'undefined') + { + chrome.webstore.install("https://chrome.google.com/webstore/detail/mailvelope/kajibbejlbohfaggdiogboambcijhkke", + function(){ + et2_dialog.alert(lang('Mailvelope addon installation succeded. Now you may configure the options.')); + return; + }, + function(){ + et2_dialog.alert(lang('Mailvelope addon installation faild! Please try agian.')); + }); + } + else if (typeof InstallTrigger != 'undefined' && InstallTrigger.enabled()) + { + InstallTrigger.install({mailvelope:"https://download.mailvelope.com/releases/latest/mailvelope.firefox.xpi"}, + function(_url, _status){ + if (_status == 0) + { + et2_dialog.alert(lang('Mailvelope addon installation succeded. Now you may configure the options.')); + return; + } + else + { + et2_dialog.alert(lang('Mailvelope addon installation faild! Please try agian.')); + } + }); + } + } + }); + + }, + /** * PGP begin and end tags */