Add email wallet backup using iframe

This commit is contained in:
Yemel Jardi 2014-07-17 16:53:38 -03:00
commit aa4af0a0e9
5 changed files with 26 additions and 7 deletions

View file

@ -9,7 +9,7 @@ BackupService.prototype.getName = function(wallet) {
return (wallet.name ? (wallet.name + '-') : '') + wallet.id;
};
BackupService.prototype.download = function(wallet) {
BackupService.prototype.download = function(wallet, scope) {
var ew = wallet.toEncryptedObj();
var partial = !wallet.publicKeyRing.isComplete();
var walletName = this.getName(wallet) + (partial ? '-Partial' : '');
@ -28,6 +28,17 @@ BackupService.prototype.download = function(wallet) {
wallet: ew
});
}
// throw an email intent if we are in the mobile version
if (window.xwalk && scope) {
var name = wallet.name ? wallet.name + ' ' : '';
var partial = partial ? 'Partial ' : '';
var subject = 'Copay - ' + name + 'Wallet ' + partial + 'Backup';
var body = 'This is the encrypted backup of the wallet ' + wallet.id + ':\n\n' + ew;
scope.mobileBackupURI = encodeURI('mailto:?subject=' + subject + '&body=' + body);
return;
}
// otherwise lean on the browser implementation
saveAs(blob, filename);
};