mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
Mailvelope backup/restore integration WIP:
- Fix documentation - Fix menus name - Add icons to menus - Add some info messaging
This commit is contained in:
parent
ec6d16b7e6
commit
2f4a1624e3
@ -987,7 +987,7 @@ var AppJS = Class.extend(
|
|||||||
*/
|
*/
|
||||||
mailvelopeSyncHandlerObj: {
|
mailvelopeSyncHandlerObj: {
|
||||||
/**
|
/**
|
||||||
* function called by Mailvelope to upload encrypted private key backup
|
* function called by Mailvelope to upload a public keyring
|
||||||
* @param {UploadSyncHandler} _uploadObj
|
* @param {UploadSyncHandler} _uploadObj
|
||||||
* @property {string} etag entity tag for the uploaded encrypted keyring, or null if initial upload
|
* @property {string} etag entity tag for the uploaded encrypted keyring, or null if initial upload
|
||||||
* @property {AsciiArmored} keyringMsg encrypted keyring as PGP armored message
|
* @property {AsciiArmored} keyringMsg encrypted keyring as PGP armored message
|
||||||
@ -999,7 +999,7 @@ var AppJS = Class.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function called by Mailvelope to download encrypted private key backup
|
* function called by Mailvelope to download a public keyring
|
||||||
*
|
*
|
||||||
* @param {object} _downloadObj
|
* @param {object} _downloadObj
|
||||||
* @property {string} etag entity tag for the current local keyring, or null if no local eTag
|
* @property {string} etag entity tag for the current local keyring, or null if no local eTag
|
||||||
@ -1011,19 +1011,19 @@ var AppJS = Class.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function called by Mailvelope to upload a public keyring backup
|
* function called by Mailvelope to upload an encrypted private key backup
|
||||||
*
|
*
|
||||||
* @param {BackupSyncPacket} _backup
|
* @param {BackupSyncPacket} _backup
|
||||||
* @property {AsciiArmored} backup encrypted public keyring as PGP armored message
|
* @property {AsciiArmored} backup an encrypted private key as PGP armored message
|
||||||
* @returns {Promise.<undefined, Error>}
|
* @returns {Promise.<undefined, Error>}
|
||||||
*/
|
*/
|
||||||
backup: function(_backup)
|
backup: function(_backup)
|
||||||
{
|
{
|
||||||
return new Promise(function(_resolve,_reject){
|
return new Promise(function(_resolve,_reject){
|
||||||
// Store backup sync packet into .pubKring_PGP file in user directory
|
// Store backup sync packet into .PK_PGP file in user directory
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
method:'PUT',
|
method:'PUT',
|
||||||
url: egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.pubKring_PGP',
|
url: egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.PK_PGP',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify(_backup),
|
data: JSON.stringify(_backup),
|
||||||
success:function(){
|
success:function(){
|
||||||
@ -1037,7 +1037,7 @@ var AppJS = Class.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function called by Mailvelope to restore a public keyring backup
|
* function called by Mailvelope to restore an encrypted private key backup
|
||||||
* @returns {Promise.<BackupSyncPacket, Error>}
|
* @returns {Promise.<BackupSyncPacket, Error>}
|
||||||
* @todo
|
* @todo
|
||||||
*/
|
*/
|
||||||
@ -1047,10 +1047,11 @@ var AppJS = Class.extend(
|
|||||||
var resolve = _resolve;
|
var resolve = _resolve;
|
||||||
var reject = _reject;
|
var reject = _reject;
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url:egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.pubKring_PGP',
|
url:egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.PK_PGP',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success: function(_backup){
|
success: function(_backup){
|
||||||
resolve(JSON.parse(_backup));
|
resolve(JSON.parse(_backup));
|
||||||
|
egw.message('Your key has been restored successfully.');
|
||||||
},
|
},
|
||||||
error: function(_err){
|
error: function(_err){
|
||||||
reject(_err);
|
reject(_err);
|
||||||
@ -1076,7 +1077,7 @@ var AppJS = Class.extend(
|
|||||||
_mailvelopeBackupFileOperator: function(_url, _cmd, _successCallback, _errorCallback, _data)
|
_mailvelopeBackupFileOperator: function(_url, _cmd, _successCallback, _errorCallback, _data)
|
||||||
{
|
{
|
||||||
var ajaxObj = {
|
var ajaxObj = {
|
||||||
url: _url || egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.pubKring_PGP',
|
url: _url || egw.webserverUrl+'/webdav.php/home/'+egw.user('account_lid')+'/.PK_PGP',
|
||||||
method: _cmd,
|
method: _cmd,
|
||||||
success: _successCallback,
|
success: _successCallback,
|
||||||
error: _errorCallback
|
error: _errorCallback
|
||||||
@ -1112,6 +1113,7 @@ var AppJS = Class.extend(
|
|||||||
var self = this;
|
var self = this;
|
||||||
var selector = _selector || 'body';
|
var selector = _selector || 'body';
|
||||||
var initSetup = _initSetup;
|
var initSetup = _initSetup;
|
||||||
|
jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]').remove();
|
||||||
return new Promise(function(_resolve, _reject)
|
return new Promise(function(_resolve, _reject)
|
||||||
{
|
{
|
||||||
var resolve = _resolve;
|
var resolve = _resolve;
|
||||||
@ -1127,13 +1129,6 @@ var AppJS = Class.extend(
|
|||||||
_keyring.createKeyBackupContainer(selector, options).then(function(_popupId){
|
_keyring.createKeyBackupContainer(selector, options).then(function(_popupId){
|
||||||
var $backup_selector = jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]');
|
var $backup_selector = jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]');
|
||||||
$backup_selector.css({position:'absolute', "z-index":1});
|
$backup_selector.css({position:'absolute', "z-index":1});
|
||||||
// add a close button, so we know when to offer storing public key to AB
|
|
||||||
jQuery('<button class="et2_button et2_button_text" id="mailvelope_close_settings">'+self.egw.lang('Close')+'</button>')
|
|
||||||
.css({position: 'absolute', top: 8, right: 8, "z-index":2})
|
|
||||||
.click(function(){
|
|
||||||
$backup_selector.remove();
|
|
||||||
this.remove();
|
|
||||||
}).appendTo(selector);
|
|
||||||
resolve(_popupId);
|
resolve(_popupId);
|
||||||
},
|
},
|
||||||
function(_err){
|
function(_err){
|
||||||
@ -1148,7 +1143,7 @@ var AppJS = Class.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete backup keyring from filesystem
|
* Delete backup key from filesystem
|
||||||
*/
|
*/
|
||||||
mailvelopeDeleteBackup: function()
|
mailvelopeDeleteBackup: function()
|
||||||
{
|
{
|
||||||
@ -1158,14 +1153,14 @@ var AppJS = Class.extend(
|
|||||||
if (_button_id == et2_dialog.YES_BUTTON )
|
if (_button_id == et2_dialog.YES_BUTTON )
|
||||||
{
|
{
|
||||||
self._mailvelopeBackupFileOperator(undefined, 'DELETE', function(){
|
self._mailvelopeBackupFileOperator(undefined, 'DELETE', function(){
|
||||||
self.egw.message(self.egw.lang('The keyring backup has been deleted.'));
|
self.egw.message(self.egw.lang('The key backup has been deleted.'));
|
||||||
}, function(_err){
|
}, function(_err){
|
||||||
self.egw.message(self.egw.lang('Was not able to delete keyring backup because %1',_err));
|
self.egw.message(self.egw.lang('Was not able to delete key backup because %1',_err));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
self.egw.lang('Are you sure, you would like to delete the backup keyring?'),
|
self.egw.lang('Are you sure, you would like to delete the backup key?'),
|
||||||
self.egw.lang('Delete backup keyring'),
|
self.egw.lang('Delete backup key'),
|
||||||
{}, et2_dialog.BUTTONS_YES_CANCEL, et2_dialog.QUESTION_MESSAGE, undefined, self.egw);
|
{}, et2_dialog.BUTTONS_YES_CANCEL, et2_dialog.QUESTION_MESSAGE, undefined, self.egw);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1181,6 +1176,8 @@ var AppJS = Class.extend(
|
|||||||
var self = this;
|
var self = this;
|
||||||
var restorePassword = _restorePassword;
|
var restorePassword = _restorePassword;
|
||||||
var selector = _selector || 'body';
|
var selector = _selector || 'body';
|
||||||
|
//Clear the
|
||||||
|
jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]').remove();
|
||||||
return new Promise(function(_resolve, _reject){
|
return new Promise(function(_resolve, _reject){
|
||||||
var resolve = _resolve;
|
var resolve = _resolve;
|
||||||
var reject = _reject;
|
var reject = _reject;
|
||||||
@ -1195,13 +1192,6 @@ var AppJS = Class.extend(
|
|||||||
_keyring.restoreBackupContainer(selector, options).then(function(_restoreId){
|
_keyring.restoreBackupContainer(selector, options).then(function(_restoreId){
|
||||||
var $restore_selector = jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]');
|
var $restore_selector = jQuery('iframe[src^="chrome-extension"],iframe[src^="about:blank?mvelo"]');
|
||||||
$restore_selector.css({position:'absolute', "z-index":1});
|
$restore_selector.css({position:'absolute', "z-index":1});
|
||||||
// add a close button, so we know when to offer storing public key to AB
|
|
||||||
jQuery('<button class="et2_button et2_button_text" id="mailvelope_close_settings">'+self.egw.lang('Close')+'</button>')
|
|
||||||
.css({position: 'absolute', top: 8, right: 8, "z-index":2})
|
|
||||||
.click(function(){
|
|
||||||
$restore_selector.remove();
|
|
||||||
this.remove();
|
|
||||||
}).appendTo(selector);
|
|
||||||
resolve(_restoreId);
|
resolve(_restoreId);
|
||||||
},
|
},
|
||||||
function(_err){
|
function(_err){
|
||||||
@ -1228,13 +1218,13 @@ var AppJS = Class.extend(
|
|||||||
// Header row should be empty item 0
|
// Header row should be empty item 0
|
||||||
{},
|
{},
|
||||||
// Restore Keyring item 1
|
// Restore Keyring item 1
|
||||||
{id:"Restore Keyring", image:"lock", onclick:"app."+appname+".mailvelopeCreateRestoreDialog('#_mvelo')"},
|
{label:"Restore key" ,image:"lock", onclick:"app."+appname+".mailvelopeCreateRestoreDialog('#_mvelo')"},
|
||||||
// Restore pass phrase item 2
|
// Restore pass phrase item 2
|
||||||
{id:"Restore Password", image:"password", onclick:"app."+appname+".mailvelopeCreateRestoreDialog('#_mvelo', true)"},
|
{label:"Restore password",image:"password", onclick:"app."+appname+".mailvelopeCreateRestoreDialog('#_mvelo', true)"},
|
||||||
// Delete backup keyring item 3
|
// Delete backup Key item 3
|
||||||
{id:"Delete backup", image:"delete", onclick:"app."+appname+".mailvelopeDeleteBackup"},
|
{label:"Delete backup", image:"delete", onclick:"app."+appname+".mailvelopeDeleteBackup"},
|
||||||
// Backup keyring item 4
|
// Backup Key item 4
|
||||||
{id:"Backup Keyring", image:"save", onclick:"app."+appname+".mailvelopeCreateBackupDialog('#_mvelo', false)"}
|
{label:"Backup Key", image:"save", onclick:"app."+appname+".mailvelopeCreateBackupDialog('#_mvelo', false)"}
|
||||||
];
|
];
|
||||||
|
|
||||||
var dialog = function(_content, _callback)
|
var dialog = function(_content, _callback)
|
||||||
@ -1258,6 +1248,8 @@ var AppJS = Class.extend(
|
|||||||
modal:true
|
modal:true
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
if (typeof mailvelope != 'undefined')
|
||||||
|
{
|
||||||
mailvelope.getKeyring('egroupware').then(function(_keyring)
|
mailvelope.getKeyring('egroupware').then(function(_keyring)
|
||||||
{
|
{
|
||||||
self._mailvelopeBackupFileOperator(undefined, 'GET', function(_data){
|
self._mailvelopeBackupFileOperator(undefined, 'GET', function(_data){
|
||||||
@ -1273,7 +1265,11 @@ var AppJS = Class.extend(
|
|||||||
function(){
|
function(){
|
||||||
mailvelope.createKeyring('egroupware').then(function(){dialog(menu);});
|
mailvelope.createKeyring('egroupware').then(function(){dialog(menu);});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.mailvelopeInstallationOffer();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mailvelopeInstallationOffer: function ()
|
mailvelopeInstallationOffer: function ()
|
||||||
@ -1332,7 +1328,6 @@ var AppJS = Class.extend(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user