- Add certificate info dialog
This commit is contained in:
Hadi Nategh 2017-08-25 12:26:13 +02:00
parent 6cdcdf8180
commit 830bbd127c
2 changed files with 104 additions and 21 deletions

View File

@ -5817,6 +5817,8 @@ app.classes.mail = AppJS.extend(
set_smimeFlags: function (_data) set_smimeFlags: function (_data)
{ {
if (!_data) return; if (!_data) return;
var self = this;
var data = _data;
var attachmentArea = this.et2.getWidgetById('previewAttachmentArea'); var attachmentArea = this.et2.getWidgetById('previewAttachmentArea');
if (attachmentArea) attachmentArea.getDOMNode().classList.remove('loading'); if (attachmentArea) attachmentArea.getDOMNode().classList.remove('loading');
var smime_signature = this.et2.getWidgetById('smime_signature'); var smime_signature = this.et2.getWidgetById('smime_signature');
@ -5825,38 +5827,51 @@ app.classes.mail = AppJS.extend(
jQuery('.mailDisplayContainer'): jQuery('.mailDisplayContainer'):
jQuery(this.et2.getWidgetById('mailPreviewContainer').getDOMNode()); jQuery(this.et2.getWidgetById('mailPreviewContainer').getDOMNode());
smime_signature.set_disabled(!_data.signed); smime_signature.set_disabled(!data.signed);
smime_encryption.set_disabled(!_data.encrypted); smime_encryption.set_disabled(!data.encrypted);
if (!_data.signed) if (!data.signed)
{ {
this.smime_clear_flags([$mail_container]); this.smime_clear_flags([$mail_container]);
return;
} }
else if (_data.verify) else if (data.verify)
{ {
$mail_container.addClass('smime_cert_verified'); $mail_container.addClass((data.class='smime_cert_verified'));
smime_signature.set_class('smime_cert_verified'); smime_signature.set_class('smime_cert_verified');
smime_signature.set_statustext(_data.msg); smime_signature.set_statustext(data.msg);
} }
else if (!_data.verify && _data.cert) else if (!data.verify && data.cert)
{ {
$mail_container.addClass('smime_cert_notverified'); $mail_container.addClass((data.class='smime_cert_notverified'));
smime_signature.set_class('smime_cert_notverified'); smime_signature.set_class('smime_cert_notverified');
smime_signature.set_statustext(_data.msg); smime_signature.set_statustext(data.msg);
} }
else if (!_data.verify && !_data.cert) else if (!data.verify && !data.cert)
{ {
$mail_container.addClass('smime_cert_notvalid'); $mail_container.addClass((data.class='smime_cert_notvalid'));
smime_signature.set_class('smime_cert_notvalid'); smime_signature.set_class('smime_cert_notvalid');
smime_signature.set_statustext(_data.msg); smime_signature.set_statustext(data.msg);
} }
jQuery(smime_signature.getDOMNode(), smime_encryption.getDOMNode()).on('click',function(){
self.smime_certAddToContact(data,true);
});
jQuery(smime_encryption.getDOMNode()).on('click',function(){
self.smime_certAddToContact(data, true);
});
}, },
/**
* Reset flags classes and click handler
*
* @param {jQuery Object} _nodes
*/
smime_clear_flags: function (_nodes) smime_clear_flags: function (_nodes)
{ {
for(var i=0;i<_nodes.length;i++) for(var i=0;i<_nodes.length;i++)
{ {
var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid'; var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid';
_nodes[i].removeClass(smime_classes); _nodes[i].removeClass(smime_classes);
_nodes[i].off('click');
} }
}, },
@ -5865,19 +5880,43 @@ app.classes.mail = AppJS.extend(
* relevant contact in addressbook. * relevant contact in addressbook.
* *
* @param {type} _metadata * @param {type} _metadata
* @param {boolean} _display if set to true will only show close button
*/ */
smime_certAddToContact: function (_metadata) smime_certAddToContact: function (_metadata, _display)
{ {
if (!_metadata || _metadata.length < 1) return; if (!_metadata || _metadata.length < 1) return;
var self = this; var self = this;
et2_dialog.show_dialog(function(_button){ var content = jQuery.extend(true, {message:_metadata.msg}, _metadata);
if (_button == 2) var buttons = [
{text: this.egw.lang("Close"), id:"close"}
];
if (!_display)
{
buttons[1] = {
text: this.egw.lang("Add this certificate into contact"),
id: "contact",
image:"add",
"class": "ui-priority-primary",
"default": true
};
content.message2 = egw.lang('You may add this certificate into your contact, if you trust this signature.');
}
et2_createWidget("dialog",
{
callback: function(_button_id, _value)
{ {
self.egw.json('mail.mail_ui.ajax_smimeAddCertToContact', if (_button_id == 'contact' && _value)
_metadata,function(_message){egw.message(_message);}).sendRequest(true); {
} self.egw.json('mail.mail_ui.ajax_smimeAddCertToContact',
}, _metadata,function(_message){egw.message(_message);}).sendRequest(true);
this.egw.lang("There's a new certificate information for email %1. Would you like to update/add this certificate?\n %2",_metadata.email,_metadata.certHtml), }
this.egw.lang('Update cert for user %1', _metadata.email),{},et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw); },
title: egw.lang('Certificate info for email %1', _metadata.email),
buttons: buttons,
value:{content:content},
template: egw.webserverUrl+'/mail/templates/default/smimeCertAddToContact.xet',
resizable: false
}, et2_dialog._create_parent('mail'));
} }
}); });

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="mail.smimeCertAddToContact" template="" lang="" group="0" version="17.1">
<grid width="100%">
<columns>
<column width="120"/>
<column width="300"/>
<column width="20"/>
</columns>
<rows>
<row class="dialogHeader">
<description span="2" id="message"/>
<image src="smimeSignature" class="@class"/>
</row>
<row>
<description id="message2"/>
</row>
<row>
<description value="Certificate Info" label="%s:"/>
</row>
<row>
<description value="Signer's email" label="%s:"/>
<description id="email"/>
</row>
<row>
<tabbox id="tabs" class="et2_nowrap" width="100%" span="all" tab_height="200" align_tabs="v">
<tabs>
<tab id="brief" class="hideme"/>
<tab id="details" label="Certificate Details"/>
<tab id="certificate" label="Certificate in text"/>
</tabs>
<tabpanels>
<description/>
<description id="certHtml"/>
<description id="cert"/>
</tabpanels>
</tabbox>
</row>
</rows>
</grid>
</template>
</overlay>