aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl-Heinz Zimmer <[email protected]>2002-04-17 15:00:53 +0000
committerKarl-Heinz Zimmer <[email protected]>2002-04-17 15:00:53 +0000
commit76cc7612bdb680590b35d07a62fefe7bd0e99a6e (patch)
tree3a7baefdd45ad90b1620f0799ef1310b178dc9bb
parentImplemented requesting certs (diff)
downloadgpgme-76cc7612bdb680590b35d07a62fefe7bd0e99a6e.tar.gz
gpgme-76cc7612bdb680590b35d07a62fefe7bd0e99a6e.zip
report both the error-Id and the error-text to the calling program when signing or encrypting of mails could not be done
-rw-r--r--gpgmeplug/cryptplug.h10
-rw-r--r--gpgmeplug/gpgmeplug.c38
2 files changed, 36 insertions, 12 deletions
diff --git a/gpgmeplug/cryptplug.h b/gpgmeplug/cryptplug.h
index fddaf179..db2d8c07 100644
--- a/gpgmeplug/cryptplug.h
+++ b/gpgmeplug/cryptplug.h
@@ -1420,10 +1420,12 @@ struct StructuringInfo {
\see StructuringInfo, free_StructuringInfo
*/
bool signMessage( const char* cleartext,
- const char** ciphertext,
+ char** ciphertext,
const size_t* cipherLen,
const char* certificate,
- struct StructuringInfo* structuring );
+ struct StructuringInfo* structuring,
+ int* errId,
+ char** errTxt );
/*! \ingroup groupSignAct
@@ -1515,7 +1517,9 @@ bool encryptMessage( const char* cleartext,
const char** ciphertext,
const size_t* cipherLen,
const char* addressee,
- struct StructuringInfo* structuring );
+ struct StructuringInfo* structuring,
+ int* errId,
+ char** errTxt );
/*! \ingroup groupCryptAct
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index 342c7bd3..65276b71 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -861,10 +861,12 @@ void storeNewCharPtr( char** dest, const char* src )
bool signMessage( const char* cleartext,
- const char** ciphertext,
+ char** ciphertext,
const size_t* cipherLen,
const char* certificate,
- struct StructuringInfo* structuring )
+ struct StructuringInfo* structuring,
+ int* errId,
+ char** errTxt )
{
GpgmeCtx ctx;
GpgmeError err;
@@ -905,7 +907,7 @@ bool signMessage( const char* cleartext,
}
gpgme_set_include_certs (ctx, sendCerts);
- /* PENDING(g10) Implement this
+ /* PENDING(g10) Implement this
gpgme_set_signature_algorithm( ctx, config.signatureAlgorithm )
--> This does not make sense. The algorithm is a property of
@@ -929,7 +931,7 @@ bool signMessage( const char* cleartext,
bOk = true;
strncpy((char*)*ciphertext, rSig, *cipherLen );
}
- ((char*)(*ciphertext))[*cipherLen] = '\0';
+ (*ciphertext)[*cipherLen] = '\0';
}
free( rSig );
}
@@ -937,8 +939,15 @@ bool signMessage( const char* cleartext,
else {
gpgme_data_release( sig );
*ciphertext = 0;
- /* erro handling missing to detect wther signing failed (hier
- fehlt eine Fehlerbehandlung, falls das Signieren schiefging) */
+ fprintf( stderr, "\ngpgme_op_sign() returned this error code: %i\n\n", err );
+ if( errId )
+ *errId = err;
+ if( errTxt ) {
+ const char* _errTxt = gpgme_strerror( err );
+ *errTxt = malloc( strlen( _errTxt ) + 1 );
+ if( *errTxt )
+ strcpy(*errTxt, _errTxt );
+ }
}
gpgme_data_release( data );
gpgme_release (ctx);
@@ -1251,7 +1260,9 @@ bool encryptMessage( const char* cleartext,
const char** ciphertext,
const size_t* cipherLen,
const char* certificate,
- struct StructuringInfo* structuring )
+ struct StructuringInfo* structuring,
+ int* errId,
+ char** errTxt )
{
GpgmeCtx ctx;
GpgmeError err;
@@ -1319,8 +1330,17 @@ bool encryptMessage( const char* cleartext,
err = gpgme_op_encrypt (ctx, rset, gPlaintext, gCiphertext );
- if( err )
- fprintf( stderr, "gpgme_op_encrypt() returned this error code: %i\n\n", err );
+ if( err ) {
+ fprintf( stderr, "\ngpgme_op_encrypt() returned this error code: %i\n\n", err );
+ if( errId )
+ *errId = err;
+ if( errTxt ) {
+ const char* _errTxt = gpgme_strerror( err );
+ *errTxt = malloc( strlen( _errTxt ) + 1 );
+ if( *errTxt )
+ strcpy(*errTxt, _errTxt );
+ }
+ }
gpgme_recipients_release (rset);
gpgme_data_release (gPlaintext);