Skip to content

Commit

Permalink
windows xpcom
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.getfiregpg.org/firegpg@421 1e1cc2a3-b62a-0410-bc93-fb3b3b0a0737
  • Loading branch information
theglu committed Jun 26, 2008
1 parent 49c5a84 commit bf3fb25
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2008-06-26 Maximilien Cuony
* Url with numbers for google apps
* xpcom on windows seem ok.

2008-06-25 Maximilien Cuony
* Xpcom on linux implemented
Expand Down
2 changes: 1 addition & 1 deletion FireGPGCall/FireGPGCall.mak
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ OutDir=.\Debug
!ENDIF

NO_EXTERNAL_DEPS=1
f

!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("FireGPGCall.dep")
!INCLUDE "FireGPGCall.dep"
Expand Down
20 changes: 14 additions & 6 deletions FireGPGCall/FireGPGCallWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,27 @@ NS_IMETHODIMP FireGPGCall::Call(const char *path, const char *parameters, const
if (fSuccess == 0)
ErrorExit("Create process failed with");

//On attend qu'il attend.
WaitForInputIdle(hProcess,0);

WriteFile(hChildStdinWr, sdin, PL_strlen(sdin) , &dwWritten, NULL);

CloseHandle(hChildStdinWr);

int i = 0;
int secu = 0;

while( WaitForSingleObject(hProcess,0) != WAIT_OBJECT_0) { //Fin du processus (normaolement)

Sleep(250);

ReadFile( hChildStdoutRd, (char *)chBuf + i, BUFSIZE - i, &dwRead, NULL);
i += dwRead;
while(WaitForSingleObject(hProcess,0) == WAIT_TIMEOUT && secu <= 10) { //Fin du processus (normaolement) ou 2.5 s passées
secu++;
Sleep(250);
}



ReadFile( hChildStdoutRd, (char *)chBuf + i, BUFSIZE - i, &dwRead, NULL);
i += dwRead;

chBuf[i] = (char)'\0';

* _retval = (char*) nsMemory::Alloc(PL_strlen(chBuf) + 1);
Expand Down Expand Up @@ -123,7 +130,8 @@ INT CreateChildProcess(const char *parameters) {
siStartInfo.hStdError = hChildStdoutWr;
siStartInfo.hStdOutput = hChildStdoutWr;
siStartInfo.hStdInput = hChildStdinRd;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
siStartInfo.wShowWindow = SW_HIDE;

// Create the child process.
bFuncRetn = CreateProcess(NULL,
Expand Down
Binary file modified components/FireGPGCall.dll
Binary file not shown.
45 changes: 36 additions & 9 deletions content/cgpgaccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function Witch_GPGAccess () {
She return false if an erreor happend, or ture if all works.
*/
function loadXpcom () { return false;
function loadXpcom () {

try {
const cid = "@getfiregpg.org/XPCOM/FireGPGCall;1";
Expand Down Expand Up @@ -268,6 +268,8 @@ function updateXpcomState(newstate) {
*/
var GPGAccessCallerWindowsNoXpcom = function(parameters,charset) {

fireGPGDebug('"' + this.getGPGCommand() + '"' + " \"" + tmpStdOut + "\"" + parameters,'GPGAccessCallerWindowsNoXpcom');

var tmpStdOut = getTmpFile(null,'output');
var tmpRun = getTmpFileRunning();

Expand Down Expand Up @@ -315,8 +317,15 @@ var GPGAccessCallerWindowsNoXpcom = function(parameters,charset) {
*/
var GPGAccessCallerWindowsXpcom = function(parameters, sdtIn,charset) {

if (charset == undefined)
charset = "utf-8";

fireGPGDebug(this.getGPGCommand() + " " + this.getGPGCommand() + parameters + "[" + sdtIn + "]",'GPGAccessCallerWindowsXpcom');

var res = obj.Call(this.getGPGCommand()," " + this.getGPGCommand() + parameters ,sdtIn + "\n");

res = EnigConvertToUnicode(res, charset);

return res;

}
Expand All @@ -341,7 +350,7 @@ var GPGAccessCallerWindowsXpcom = function(parameters, sdtIn,charset) {
*/
var GPGAccessCallerUnixNoXpcom = function(parameters,charset) {


fireGPGDebug(this.getGPGCommand() + ' ' + tmpStdOut + parameters,'GPGAccessCallerUnixNoXpcom');

var tmpStdOut = getTmpFile(null,'output'); // Output from gpg
var tmpRun = getTmpFileRunning();
Expand Down Expand Up @@ -387,10 +396,17 @@ var GPGAccessCallerUnixNoXpcom = function(parameters,charset) {
<GPGAccessCallerUnixNoXpcom>
*/
var GPGAccessCallerUnixXpcom = function(parameters, sdtIn,charset) {
var GPGAccessCallerUnixXpcom = function(parameters, sdtIn, charset) {

if (charset == undefined)
charset = "utf-8";

fireGPGDebug(this.getGPGCommand() + " " + this.getGPGCommand() + parameters + "[" + sdtIn + "]",'GPGAccessCallerUnixXpcom');

var res = obj.Call(this.getGPGCommand()," " + this.getGPGCommand() + parameters ,sdtIn + "\n");

res = EnigConvertToUnicode(res, charset);

return res;
}

Expand Down Expand Up @@ -1116,7 +1132,20 @@ var GPGAccessWindowsXpcom = {

verify: GPGAccessWindowsNoXpcom.verify,

listkey:GPGAccessWindowsNoXpcom.listkey,
listkey: function(onlyPrivate) {
var mode = "--list-keys";

if (onlyPrivate == true)
mode = "--list-secret-keys";

result = this.runGnupg(this.getBaseArugments() + " --with-colons " + mode,"","ISO-8859-1");

var result2 = new GPGReturn();
result2.sdOut = result;

// We return result
return result2;
},

crypt: GPGAccessWindowsNoXpcom.crypt,

Expand Down Expand Up @@ -1153,8 +1182,6 @@ var GPGAccessWindowsXpcom = {
" --encrypt " + tmpInput,
password);

removeFile(tmpPASS); // DON'T MOVE THIS LINE !

// The crypted text
var crypttext = getFromFile(tmpOutput);
var result2 = new GPGReturn();
Expand Down Expand Up @@ -1431,13 +1458,13 @@ var GPGAccessUnixXpcom = {

verify: GPGAccessUnixNoXpcom.verify,

listkey:GPGAccessUnixNoXpcom.listkey,
listkey: GPGAccessWindowsXpcom.listkey,

crypt: GPGAccessUnixNoXpcom.crypt,

cryptAndSign: GPGAccessUnixNoXpcom.cryptAndSign,
cryptAndSign: GPGAccessWindowsXpcom.cryptAndSign,

decrypt: GPGAccessUnixNoXpcom.decrypt,
decrypt: GPGAccessWindowsXpcom.decrypt,

selfTest: GPGAccessUnixNoXpcom.selfTest,

Expand Down
6 changes: 4 additions & 2 deletions content/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ var oldKeyID = '';
*/
function fireGPGDebug(message, debugCode, fatal) {

return;
//return;

if (fatal)
Components.utils.reportError("FireGPG-debug: [" + debugCode + "]" + message);
else {

var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage("FireGPG-debug: [" + debugCode + "]" + message);
consoleService.logStringMessage("FireGPG-debug: [" + debugCode + "] " + message);

}

Expand Down Expand Up @@ -1112,9 +1112,11 @@ function EnigConvertToUnicode(text, charset) {
var unicodeConv = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].getService(Components.interfaces.nsIScriptableUnicodeConverter);

unicodeConv.charset = charset;

return unicodeConv.ConvertToUnicode(text);

} catch (ex) {
fireGPGDebug(ex,'EnigConvertToUnicode',true);
return text;
}
}
Expand Down

0 comments on commit bf3fb25

Please sign in to comment.