forked from extern/egroupware
Encrypt toggle-button in compose to switch PGP encrypted mail on and off
This commit is contained in:
parent
9dc4cd76b3
commit
a480dfc022
@ -115,6 +115,15 @@ class mail_compose
|
|||||||
'hint' => 'Send',
|
'hint' => 'Send',
|
||||||
'toolbarDefault' => true
|
'toolbarDefault' => true
|
||||||
),
|
),
|
||||||
|
'pgp' => array(
|
||||||
|
'caption' => 'Encrypt',
|
||||||
|
'icon' => 'lock',
|
||||||
|
'group' => ++$group,
|
||||||
|
'onExecute' => 'javaScript:app.mail.togglePgpEncrypt',
|
||||||
|
'hint' => 'Send message PGP encrypted: requires keys from all recipients!',
|
||||||
|
'checkbox' => true,
|
||||||
|
'toolbarDefault' => true
|
||||||
|
),
|
||||||
'button[saveAsDraft]' => array(
|
'button[saveAsDraft]' => array(
|
||||||
'caption' => 'Save',
|
'caption' => 'Save',
|
||||||
'icon' => 'save',
|
'icon' => 'save',
|
||||||
|
116
mail/js/app.js
116
mail/js/app.js
@ -157,14 +157,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
jQuery('iframe#mail-index_messageIFRAME').on('load', function()
|
jQuery('iframe#mail-index_messageIFRAME').on('load', function()
|
||||||
{
|
{
|
||||||
// decrypt preview body if mailvelope is available
|
// decrypt preview body if mailvelope is available
|
||||||
if (typeof mailvelope !== 'undefined') {
|
self.mailvelopeAvailable(self.mailvelopeDisplay);
|
||||||
self.mailvelopeDisplay.call(self);
|
|
||||||
} else {
|
|
||||||
jQuery(window).on('mailvelope', function()
|
|
||||||
{
|
|
||||||
self.mailvelopeDisplay.call(self);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
self.mail_prepare_print();
|
self.mail_prepare_print();
|
||||||
});
|
});
|
||||||
var nm = this.et2.getWidgetById(this.nm_index);
|
var nm = this.et2.getWidgetById(this.nm_index);
|
||||||
@ -194,14 +187,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
jQuery('iframe#mail-display_mailDisplayBodySrc').on('load', function()
|
jQuery('iframe#mail-display_mailDisplayBodySrc').on('load', function()
|
||||||
{
|
{
|
||||||
// encrypt body if mailvelope is available
|
// encrypt body if mailvelope is available
|
||||||
if (typeof mailvelope !== 'undefined') {
|
self.mailvelopeAvailable(self.mailvelopeDisplay);
|
||||||
self.mailvelopeDisplay.call(self);
|
|
||||||
} else {
|
|
||||||
jQuery(window).on('mailvelope', function()
|
|
||||||
{
|
|
||||||
self.mailvelopeDisplay.call(self);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
self.mail_prepare_print();
|
self.mail_prepare_print();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -215,10 +201,9 @@ app.classes.mail = AppJS.extend(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'mail.compose':
|
case 'mail.compose':
|
||||||
if (typeof mailvelope !== 'undefined') {
|
if (this.et2.getWidgetById('composeToolbar')._actionManager.getActionById('pgp').checked)
|
||||||
this.mailvelopeCompose();
|
{
|
||||||
} else {
|
this.mailvelopeAvailable(this.mailvelopeCompose);
|
||||||
jQuery(window).on('mailvelope', jQuery.proxy(this.mailvelopeCompose, this));
|
|
||||||
}
|
}
|
||||||
// use a wrapper on a different url to be able to use a different fpm pool
|
// use a wrapper on a different url to be able to use a different fpm pool
|
||||||
et2.menuaction = 'mail_compose::ajax_send';
|
et2.menuaction = 'mail_compose::ajax_send';
|
||||||
@ -4349,9 +4334,10 @@ app.classes.mail = AppJS.extend(
|
|||||||
/**
|
/**
|
||||||
* Called on load of preview or display iframe, if mailvelope is available
|
* Called on load of preview or display iframe, if mailvelope is available
|
||||||
*
|
*
|
||||||
|
* @param {Keyring} _keyring Mailvelope keyring to use
|
||||||
* @ToDo signatures
|
* @ToDo signatures
|
||||||
*/
|
*/
|
||||||
mailvelopeDisplay: function()
|
mailvelopeDisplay: function(_keyring)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
var mailvelope = window.mailvelope;
|
var mailvelope = window.mailvelope;
|
||||||
@ -4360,19 +4346,12 @@ app.classes.mail = AppJS.extend(
|
|||||||
|
|
||||||
if (armored == "" || armored.indexOf('-----BEGIN PGP MESSAGE-----') === -1) return;
|
if (armored == "" || armored.indexOf('-----BEGIN PGP MESSAGE-----') === -1) return;
|
||||||
|
|
||||||
mailvelope.getKeyring('mailvelope').then(function(_keyring)
|
var container = iframe.parent()[0];
|
||||||
|
var container_selector = container.id ? '#'+container.id : 'div.mailDisplayContainer';
|
||||||
|
mailvelope.createDisplayContainer(container_selector, armored, _keyring).then(function()
|
||||||
{
|
{
|
||||||
var container = iframe.parent()[0];
|
// hide our iframe to give space for mailvelope iframe with encrypted content
|
||||||
var container_selector = container.id ? '#'+container.id : 'div.mailDisplayContainer';
|
iframe.hide();
|
||||||
mailvelope.createDisplayContainer(container_selector, armored, _keyring).then(function()
|
|
||||||
{
|
|
||||||
// hide our iframe to give space for mailvelope iframe with encrypted content
|
|
||||||
iframe.hide();
|
|
||||||
},
|
|
||||||
function(_err)
|
|
||||||
{
|
|
||||||
self.egw.message(_err.message, 'error');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
function(_err)
|
function(_err)
|
||||||
{
|
{
|
||||||
@ -4389,36 +4368,67 @@ app.classes.mail = AppJS.extend(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on compose, if mailvelope is available
|
* Called on compose, if mailvelope is available
|
||||||
|
*
|
||||||
|
* @param {Keyring} _keyring Mailvelope keyring to use
|
||||||
*/
|
*/
|
||||||
mailvelopeCompose: function()
|
mailvelopeCompose: function(_keyring)
|
||||||
{
|
{
|
||||||
var self = this;
|
|
||||||
var mailvelope = window.mailvelope;
|
|
||||||
|
|
||||||
delete this.mailvelope_editor;
|
delete this.mailvelope_editor;
|
||||||
mailvelope.getKeyring('mailvelope').then(function(_keyring)
|
|
||||||
|
// currently Mailvelope only supports plain-text, to this is unnecessary
|
||||||
|
var mimeType = this.et2.getWidgetById('mimeType');
|
||||||
|
var is_html = mimeType.get_value();
|
||||||
|
var container = is_html ? '.mailComposeHtmlContainer' : '.mailComposeTextContainer';
|
||||||
|
var editor = this.et2.getWidgetById(is_html ? 'mail_htmltext' : 'mail_plaintext');
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
mailvelope.createEditorContainer(container, _keyring, {
|
||||||
|
predefinedText: editor.get_value()
|
||||||
|
}).then(function(_editor)
|
||||||
{
|
{
|
||||||
var is_html = self.et2.getWidgetById('mimeType').get_value();
|
self.mailvelope_editor = _editor;
|
||||||
var container = is_html ? '.mailComposeHtmlContainer' : '.mailComposeTextContainer';
|
editor.set_disabled(true);
|
||||||
var editor = self.et2.getWidgetById(is_html ? 'mail_htmltext' : 'mail_plaintext');
|
mimeType.set_readonly(true);
|
||||||
mailvelope.createEditorContainer(container, _keyring, {
|
|
||||||
predefinedText: editor.get_value()
|
|
||||||
}).then(function(_editor)
|
|
||||||
{
|
|
||||||
self.mailvelope_editor = _editor;
|
|
||||||
editor.set_disabled(true);
|
|
||||||
},
|
|
||||||
function(_err)
|
|
||||||
{
|
|
||||||
self.egw.message(_err.message, 'error');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
function(_err)
|
function(_err)
|
||||||
{
|
{
|
||||||
self.egw.message(keyringId+': '+_err.message, 'error');
|
self.egw.message(_err.message, 'error');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch sending PGP encrypted mail on and off
|
||||||
|
*
|
||||||
|
* @param {object} _action toolbar action
|
||||||
|
*/
|
||||||
|
togglePgpEncrypt: function (_action)
|
||||||
|
{
|
||||||
|
if (_action.checked)
|
||||||
|
{
|
||||||
|
if (typeof mailvelope == 'undefined')
|
||||||
|
{
|
||||||
|
this.egw.message(this.egw.lang('You need to install Mailvelope plugin available for Chrome and Firefox and enable it for your domain.')+
|
||||||
|
"\n"+this.egw.lang('Download from %1','<a href="https://www.mailvelope.com/">mailvelope.com</a>'), 'info');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var mimeType = this.et2.getWidgetById('mimeType');
|
||||||
|
// currently Mailvelope only supports plain-text, switch to it if necessary
|
||||||
|
if (mimeType.get_value())
|
||||||
|
{
|
||||||
|
mimeType.set_value(false);
|
||||||
|
this.et2._inst.submit();
|
||||||
|
return; // ToDo: do that without reload
|
||||||
|
}
|
||||||
|
this.mailvelopeAvailable(this.mailvelopeCompose);
|
||||||
|
// ToDo: check recipients
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// switch Mailvelop off again
|
||||||
|
this.et2._inst.submit(); // ToDo: do that without reload
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the relevant widget to toolbar actions and submit
|
* Set the relevant widget to toolbar actions and submit
|
||||||
* @param {type} _action toolbar action
|
* @param {type} _action toolbar action
|
||||||
|
@ -825,5 +825,46 @@ var AppJS = Class.extend(
|
|||||||
egw.refresh(data.msg||'',ids[0],ids[1],'update');
|
egw.refresh(data.msg||'',ids[0],ids[1],'update');
|
||||||
}).sendRequest(true);
|
}).sendRequest(true);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Mailvelope is available, open (or create) "egroupware" keyring and call callback with it
|
||||||
|
*
|
||||||
|
* @param {function} _callback called if and only if mailvelope is available (context is this!)
|
||||||
|
*/
|
||||||
|
mailvelopeAvailable: function(_callback)
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
if (typeof mailvelope !== 'undefined')
|
||||||
|
{
|
||||||
|
self._mailvelopeOpenKeyring.call(self, _callback);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(window).on('mailvelope', function()
|
||||||
|
{
|
||||||
|
self._mailvelopeOpenKeyring.call(self, _callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open (or create) "egroupware" keyring and call callback with it
|
||||||
|
*
|
||||||
|
* @param {function} _callback called if and only if mailvelope is available (context is this!)
|
||||||
|
*/
|
||||||
|
_mailvelopeOpenKeyring: function(_callback)
|
||||||
|
{
|
||||||
|
var callback = _callback;
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
mailvelope.getKeyring('mailvelope').then(function(_keyring)
|
||||||
|
{
|
||||||
|
callback.call(self, _keyring);
|
||||||
|
},
|
||||||
|
function(_err)
|
||||||
|
{
|
||||||
|
self.egw.message(_err.message, 'error');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -109,9 +109,10 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
var parts = _msg.split(matches[0]);
|
var parts = _msg.split(matches[0]);
|
||||||
|
var href = html_entity_decode(matches[1]);
|
||||||
msg_div.text(parts[0]);
|
msg_div.text(parts[0]);
|
||||||
msg_div.append(jQuery(_wnd.document.createElement('a'))
|
msg_div.append(jQuery(_wnd.document.createElement('a'))
|
||||||
.attr('href', html_entity_decode(matches[1]))
|
.attr({href: href, target: href.indexOf(egw.webserverUrl) != 0 ? '_blank' : '_self'})
|
||||||
.text(matches[2]));
|
.text(matches[2]));
|
||||||
msg_div.append(jQuery(_wnd.document.createElement('span')).text(parts[1]));
|
msg_div.append(jQuery(_wnd.document.createElement('span')).text(parts[1]));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user