Skip to content

Commit

Permalink
Dont block interface when using keyservers
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.getfiregpg.org/firegpg@577 1e1cc2a3-b62a-0410-bc93-fb3b3b0a0737
  • Loading branch information
theglu committed Jul 11, 2009
1 parent bda8c55 commit 9a85120
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 17 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -2,6 +2,7 @@
* FS#308
* FS#3
* Doing some cleaning up in the code, including license..
* Don't block interface when using keyservers

2009-07-09 Maximilien Cuony
* Improving gmail detection
Expand Down
113 changes: 97 additions & 16 deletions content/Core/cgpg.js
Expand Up @@ -1824,13 +1824,35 @@ var FireGPG = {
//Boite pour attendre la boite d'attente
var wait_box2 = window.open("chrome://firegpg/content/Dialogs/Keymanager/wait2.xul", "waitBox2", "chrome,centerscreen,resizable=0,minimizable=0,modal");

// We get the result
try {
var result = this.GPGAccess.searchKeyInServer(search,getKeyServer());
} catch (e) { } //To be sure to close the wait_box

backgroundTask = {
run: function() {
this.result == null;
// We get the result
try {
this.result = this.GPGAccess.searchKeyInServer(this.search,getKeyServer());
} catch (e) { } //To be sure to close the wait_box
}
}

backgroundTask.GPGAccess = this.GPGAccess;
backgroundTask.search = search;

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.newThread(0);
thread.dispatch(backgroundTask, thread.DISPATCH_NORMAL);

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.currentThread;
while (backgroundTask.result == null)
thread.processNextEvent(true);

wait_box.close();

result = backgroundTask.result;

// We get informations from GPG
result = EnigConvertGpgToUnicode(result.sdOut);

Expand Down Expand Up @@ -1957,13 +1979,34 @@ var FireGPG = {
//Boite pour attendre la boite d'attente
var wait_box2 = window.open("chrome://firegpg/content/Dialogs/Keymanager/wait2.xul", "waitBox2", "chrome,centerscreen,resizable=0,minimizable=0,modal");

// We get the result
try {
var result = this.GPGAccess.retriveKeyFromServer(keyId,getKeyServer());
} catch (e) { } //To be sure to close the wait_box
backgroundTask = {
run: function() {
this.result == null;
// We get the result
try {
this.result = this.GPGAccess.retriveKeyFromServer(this.keyId,getKeyServer());
} catch (e) { } //To be sure to close the wait_box
}
}

backgroundTask.GPGAccess = this.GPGAccess;
backgroundTask.keyId = keyId;

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.newThread(0);
thread.dispatch(backgroundTask, thread.DISPATCH_NORMAL);

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.currentThread;
while (backgroundTask.result == null)
thread.processNextEvent(true);

wait_box.close();

result = backgroundTask.result;


if (result.sdOut.indexOf('IMPORT_OK') > 0) {

Expand Down Expand Up @@ -2003,13 +2046,34 @@ var FireGPG = {
//Boite pour attendre la boite d'attente
var wait_box2 = window.open("chrome://firegpg/content/Dialogs/Keymanager/wait2.xul", "waitBox2", "chrome,centerscreen,resizable=0,minimizable=0,modal");

// We get the result
try {
var result = this.GPGAccess.sendKeyToServer(keyId,getKeyServer());
} catch (e) { } //To be sure to close the wait_box

backgroundTask = {
run: function() {
this.result == null;
// We get the result
try {
this.result = this.GPGAccess.sendKeyToServer(this.keyId,getKeyServer());
} catch (e) { } //To be sure to close the wait_box
}
}

backgroundTask.GPGAccess = this.GPGAccess;
backgroundTask.keyId = keyId;

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.newThread(0);
thread.dispatch(backgroundTask, thread.DISPATCH_NORMAL);

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.currentThread;
while (backgroundTask.result == null)
thread.processNextEvent(true);

wait_box.close();

result = backgroundTask.result;

if (result.sdOut) {

Expand Down Expand Up @@ -2048,15 +2112,32 @@ var FireGPG = {
//Boite pour attendre la boite d'attente
var wait_box2 = window.open("chrome://firegpg/content/Dialogs/Keymanager/wait2.xul", "waitBox2", "chrome,centerscreen,resizable=0,minimizable=0,modal");

backgroundTask = {
run: function() {
this.result == null;
// We get the result
try {
this.result = this.GPGAccess.refrechFromServer(getKeyServer());
} catch (e) { } //To be sure to close the wait_box
}
}

backgroundTask.GPGAccess = this.GPGAccess;

var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.newThread(0);
thread.dispatch(backgroundTask, thread.DISPATCH_NORMAL);

// We get the result
try {
var result = this.GPGAccess.refrechFromServer(getKeyServer());
} catch (e) { } //To be sure to close the wait_box
var thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.currentThread;
while (backgroundTask.result == null)
thread.processNextEvent(true);

wait_box.close();

result = backgroundTask.result;

if (result.sdOut) {

Expand Down
2 changes: 1 addition & 1 deletion content/Dialogs/Keymanager/keymanager.xul
Expand Up @@ -45,7 +45,7 @@ under the terms of any one of the MPL, the GPL or the LGPL.
<!DOCTYPE prefwindow SYSTEM "chrome://firegpg/locale/keymanager.dtd">
<dialog id="key-dialog" title="&keymanager;" orient="vertical" autostretch="always"
onload="onLoad(this); sizeToContent(); this.innerHeight = this.innerHeight + 500;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" buttons="accept">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" buttons="accept" disabled="disabled">


<vbox flex="1" >
Expand Down
6 changes: 6 additions & 0 deletions content/Dialogs/Keymanager/searchkey.js
Expand Up @@ -85,8 +85,14 @@ function rebuildList() {
if (trim(search) == "")
return;

document.getElementById('search-button').disabled = 'disabled';
document.getElementById('import-button').disabled = 'disabled';

keylistcall = FireGPG.searchKeyInServer(search);

document.getElementById('search-button').disabled = '';
document.getElementById('import-button').disabled = '';

if (keylistcall.result == RESULT_SUCCESS)
gpg_keys = keylistcall.keylist;
else
Expand Down

0 comments on commit 9a85120

Please sign in to comment.