Update of /cvsroot/mahogany/M/src/modules/crypt
In directory sc8-pr-cvs1:/tmp/cvs-serv5802/src/modules/crypt
Modified Files:
PGPEngine.cpp
Log Message:
decrypting PGP messages seems to work as well now
Index: PGPEngine.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/crypt/PGPEngine.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- PGPEngine.cpp 3 Dec 2002 02:52:09 -0000 1.2
+++ PGPEngine.cpp 3 Dec 2002 13:31:33 -0000 1.3
@@ -518,9 +518,15 @@
char buf[4096];
- while ( !process.IsDone() )
+ bool outEof = false,
+ errEof = false;
+ while ( !process.IsDone() || !outEof || !errEof )
{
wxYield();
- if ( out->CanRead() )
+ if ( out->GetLastError() == wxSTREAM_EOF )
+ {
+ outEof = true;
+ }
+ else if ( out->CanRead() )
{
buf[out->Read(buf, WXSIZEOF(buf)).LastRead()] = '\0';
@@ -529,5 +535,9 @@
}
- if ( err->CanRead() )
+ if ( err->GetLastError() == wxSTREAM_EOF )
+ {
+ errEof = true;
+ }
+ else if ( err->CanRead() )
{
String line = errText.ReadLine();
@@ -541,4 +551,7 @@
}
+ if ( *pc )
+ pc++; // skip the space/TAB
+
if ( code == _T("GOODSIG") ||
code == _T("VALIDSIG") ||
@@ -573,9 +586,12 @@
{
// skip the key id
- for ( pc++; *pc && !isspace(*pc); pc++ )
- ;
+ while ( *pc && !isspace(*pc) )
+ pc++;
+
+ if ( *pc )
+ pc++;
// remember the user
- user = ++pc;
+ user = pc;
}
else if ( code == _T("NEED_PASSPHRASE") )
@@ -596,9 +612,4 @@
break;
}
-
- String pass2 = pass;
- pass2 += wxTextFile::GetEOL();
-
- in->Write(pass2.c_str(), pass2.length());
}
else if ( code == _T("GOOD_PASSPHRASE") )
@@ -615,9 +626,4 @@
user.c_str());
}
- else if ( code == _T("NO_SECKEY") )
- {
- wxLogWarning(_("Secret key for the user \"%s\" not available."),
- user.c_str());
- }
else if ( code == _T("DECRYPTION_FAILED") )
{
@@ -628,8 +634,34 @@
code == _T("GET_HIDDEN") )
{
- // TODO: give gpg whatever it's asking for, otherwise
- // we'd deadlock!
+ // give gpg whatever it's asking for, otherwise we'd deadlock!
+ if ( code == _T("GET_HIDDEN") )
+ {
+ if ( strcmp(pc, _T("passphrase.enter")) == 0 )
+ {
+ // we're being asked for a passphrase
+ String pass2 = pass;
+ pass2 += wxTextFile::GetEOL();
+
+ in->Write(pass2.c_str(), pass2.length());
+ }
+ else
+ {
+ // TODO
+ FAIL_MSG( _T("unexpected GET_HIDDEN") );
+ }
+ }
+ else
+ {
+ // TODO
+ FAIL_MSG( _T("unexpected GET_XXX") );
+ }
+ }
+ else if ( code == _T("NO_PUBKEY") )
+ {
+ wxLogWarning(_("Failed to check signature: public key \"%s\" "
+ "not available."), pc);
}
else if ( code == _T("ENC_TO") ||
+ code == _T("NO_SECKEY") ||
code == _T("BEGIN_DECRYPTION") ||
code == _T("END_DECRYPTION") ||
@@ -649,4 +681,10 @@
ASSERT_MSG( status != MAX_ERROR, _T("GNUPG didn't return the status?") );
+
+ // we must wait until the process terminates because its termination handler
+ // access process object which is going to be destroyed when we exit this
+ // scope
+ while ( !process.IsDone() )
+ wxYield();
return status;
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates