Skip to content

Commit

Permalink
Change export pubkey to work with async plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehuff committed Aug 16, 2015
1 parent 1886b45 commit c59c3b1
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,18 794,41 @@ webpg.background = {

case 'export':
if (request.keyid) {
response = webpg.plugin.gpgExportPublicKey(request.keyid).result;
webpg.plugin.gpgExportPublicKey(request.keyid, function(res) {
if (res.type && res.type === "export-progress") {
var data = JSON.parse(res.data);
webpg.utils.tabs.sendRequest(sender.tab, {
"msg": "insertPublicKey", "data": data.result,
"iframe_id": request.iframe_id
});
}
});
break;
} else if (request.recipients) {
response = "";
for (var keyid in request.recipients)
response = webpg.plugin.gpgExportPublicKey(
request.recipients[keyid]).result "\n";
for (var keyid in request.recipients) {
webpg.plugin.gpgExportPublicKey(
request.recipients[keyid],
function(res) {
if (res.type && res.type === "export-progress") {
var data = JSON.parse(res.data);
response = data.result "\n";
} else if (res === "complete") {
webpg.utils.tabs.sendRequest(sender.tab, {
"msg": "insertPublicKey", "data": response,
"iframe_id": request.iframe_id
});
}
}
);
}
} else {
response = "";
webpg.utils.tabs.sendRequest(sender.tab, {
"msg": "insertPublicKey", "data": response,
"iframe_id": request.iframe_id
});
}
webpg.utils.tabs.sendRequest(sender.tab, {
"msg": "insertPublicKey", "data": response,
"iframe_id": request.iframe_id});
break;

case 'removeiframe':
Expand Down

0 comments on commit c59c3b1

Please sign in to comment.