aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gpgme.texi5
-rw-r--r--gpgme/ChangeLog10
-rw-r--r--gpgme/engine-gpgsm.c4
-rw-r--r--gpgme/import.c16
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/gpgsm/t-import.c16
7 files changed, 56 insertions, 5 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 3c9cee8d..fcf65e30 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-26 Werner Koch <[email protected]>
+
+ * gpgme.texi (Importing Keys): Document the return value -1 of
+ gpgme_op_import.
+
2002-06-20 Werner Koch <[email protected]>
* gpgme.texi (Verify): Explain the new whatidx variable.
diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 9f07ee92..24e9f928 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -1900,8 +1900,9 @@ More information about the import is available with
The function returns @code{GPGME_No_Error} if the import was completed
successfully, @code{GPGME_Invalid_Value} if @var{keydata} if @var{ctx}
-or @var{keydata} is not a valid pointer, and @code{GPGME_No_Data} if
-@var{keydata} is an empty data buffer.
+or @var{keydata} is not a valid pointer, @code{GPGME_No_Data} if
+@var{keydata} is an empty data buffer, and @code{GPGME_EOF} if the
+operation was completed successfully but no data was actually imported.
@end deftypefun
@deftypefun GpgmeError gpgme_op_import_start (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{keydata}})
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index 35550fc0..4ae40468 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-26 Werner Koch <[email protected]>
+
+ * engine-gpgsm.c (map_assuan_error): Map No_Data_Available to EOF.
+
+ * import.c (append_xml_impinfo): Kludge to print fingerprint
+ instead of keyid for use with gpgsm.
+ (import_status_handler): Set a flag to know whether any import
+ occured.
+ (gpgme_op_import): Reurn -1 if no certificate ewas imported.
+
2002-06-25 Werner Koch <[email protected]>
* engine-gpgsm.c (_gpgme_gpgsm_set_io_cbs) [ENABLE_GPGSM]: Fixed
diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c
index 2dfdf35e..67f1e7c5 100644
--- a/gpgme/engine-gpgsm.c
+++ b/gpgme/engine-gpgsm.c
@@ -220,8 +220,10 @@ map_assuan_error (AssuanError err)
case ASSUAN_Unsupported_Algorithm:
return mk_error (Not_Implemented); /* XXX Argh. */
- /* These are errors internal to GPGME. */
case ASSUAN_No_Data_Available:
+ return mk_error (EOF);
+
+ /* These are errors internal to GPGME. */
case ASSUAN_No_Input:
case ASSUAN_No_Output:
case ASSUAN_Invalid_Command:
diff --git a/gpgme/import.c b/gpgme/import.c
index 493b3017..754bdb94 100644
--- a/gpgme/import.c
+++ b/gpgme/import.c
@@ -32,6 +32,7 @@
struct import_result_s
{
+ int any_imported;
GpgmeData xmlinfo;
};
@@ -55,6 +56,8 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
#define MAX_IMPORTED_FIELDS 14
static const char *const imported_fields[MAX_IMPORTED_FIELDS]
= { "keyid", "username", 0 };
+ static const char *const imported_fields_x509[MAX_IMPORTED_FIELDS]
+ = { "fpr", 0 };
static const char *const import_res_fields[MAX_IMPORTED_FIELDS]
= { "count", "no_user_id", "imported", "imported_rsa",
"unchanged", "n_uids", "n_subk", "n_sigs", "s_sigsn_revoc",
@@ -88,6 +91,11 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
*args++ = '\0';
}
}
+
+ /* gpgsm does not print a useful user ID and uses a fingerprint
+ instead of the key ID. */
+ if (code == STATUS_IMPORTED && field[0] && strlen (field[0]) > 16)
+ field_name = imported_fields_x509;
}
/* Initialize the data buffer if necessary. */
@@ -116,7 +124,7 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
for (i = 0; field_name[i]; i++)
{
_gpgme_data_append_string (dh, " <");
- _gpgme_data_append_string (dh, field_name[i]);
+ _gpgme_data_append_string (dh, field_name[i]);
_gpgme_data_append_string (dh, ">");
_gpgme_data_append_string (dh, field[i]);
_gpgme_data_append_string (dh, "</");
@@ -152,6 +160,7 @@ import_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
break;
case STATUS_IMPORTED:
+ ctx->result.import->any_imported = 1;
case STATUS_IMPORT_RES:
append_xml_impinfo (&ctx->result.import->xmlinfo, code, args);
break;
@@ -211,7 +220,7 @@ gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata)
*
* Import all key material from @keydata into the key database.
*
- * Return value: o on success or an error code.
+ * Return value: 0 on success or an error code.
**/
GpgmeError
gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata)
@@ -219,5 +228,8 @@ gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata)
GpgmeError err = _gpgme_op_import_start (ctx, 1, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
+ if (!err && (!ctx->result.import || !ctx->result.import->any_imported))
+ err = -1; /* Nothing at all imported. */
return err;
}
+
diff --git a/tests/ChangeLog b/tests/ChangeLog
index adbcc480..f22e1abe 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-26 Werner Koch <[email protected]>
+
+ * gpgsm/t-import.c (print_op_info): New.
+ (main): Print operation info.
+
2002-06-25 Werner Koch <[email protected]>
* gpgsm/Makefile.am (DISTCLEANFILES): new.
diff --git a/tests/gpgsm/t-import.c b/tests/gpgsm/t-import.c
index f62ff003..974cdd93 100644
--- a/tests/gpgsm/t-import.c
+++ b/tests/gpgsm/t-import.c
@@ -57,6 +57,20 @@ make_filename (const char *fname)
return buf;
}
+static void
+print_op_info (GpgmeCtx c)
+{
+ char *s = gpgme_get_op_info (c, 0);
+
+ if (!s)
+ puts ("<!-- no operation info available -->");
+ else {
+ puts (s);
+ free (s);
+ }
+}
+
+
int
main (int argc, char **argv)
{
@@ -76,6 +90,7 @@ main (int argc, char **argv)
fail_if_err (err);
err = gpgme_op_import (ctx, in);
+ print_op_info (ctx);
fail_if_err (err);
gpgme_data_release (in);
@@ -84,6 +99,7 @@ main (int argc, char **argv)
fail_if_err (err);
err = gpgme_op_import (ctx, in);
+ print_op_info (ctx);
fail_if_err (err);
gpgme_data_release (in);