+2002-01-30 Marcus Brinkmann <marcus@g10code.de>
+
+ * gpgme.c (_gpgme_release_result): Call
+ _gpgme_release_delete_result.
+ * ops.h (_gpgme_release_delete_result): Add prototype.
+ * types.h (DeleteResult): New type.
+ * context.h (gpgme_context_s): Add DeleteResult to member result.
+
+ * delete.c (enum delete_problem): New type.
+ (struct delete_result_s): New structure.
+ (_gpgme_release_delete_result): New function.
+ (delete_status_handler): Implement more status codes.
+ (gpgme_op_delete): Return error on failure.
+
+ * import.c (MAX_IMPORTED_FIELDS): Bump up to 14.
+
2002-01-30 Marcus Brinkmann <marcus@g10code.de>
* import.c (struct import_result_s): New structure.
(import_status_handler): Implement.
* gpgme.c (_gpgme_release_result): Add call to
_gpgme_release_import_result.
- * ops.h (_gpgme_release_impoer_result): Add prototype.
+ * ops.h (_gpgme_release_import_result): Add prototype.
* types.h (ImportResult): New type.
* context.h (gpgme_context_s): Add ImportResult to member result.
EncryptResult encrypt;
PassphraseResult passphrase;
ImportResult import;
+ DeleteResult delete;
} result;
GpgmeData notation; /* last signature notation */
#include "ops.h"
#include "key.h"
+
+enum delete_problem
+ {
+ DELETE_No_Problem = 0,
+ DELETE_No_Such_Key = 1,
+ DELETE_Must_Delete_Secret_Key = 2
+ };
+
+
+struct delete_result_s
+{
+ enum delete_problem problem;
+};
+
+
+void
+_gpgme_release_delete_result (DeleteResult result)
+{
+ if (!result)
+ return;
+ xfree (result);
+}
+
+
static void
-delete_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
+delete_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
{
- if ( ctx->out_of_core )
- return;
+ if (ctx->out_of_core)
+ return;
+
+ if (!ctx->result.delete)
+ {
+ ctx->result.delete = xtrycalloc (1, sizeof *ctx->result.delete);
+ if (!ctx->result.delete)
+ {
+ ctx->out_of_core = 1;
+ return;
+ }
+ }
+
+ switch (code)
+ {
+ case STATUS_EOF:
+ break;
- switch (code) {
- case STATUS_EOF:
- break;
+ case STATUS_DELETE_PROBLEM:
+ ctx->result.delete->problem = atoi (args);
+ break;
- default:
- /* ignore all other codes */
- break;
+ default:
+ /* Ignore all other codes. */
+ break;
}
}
if (!err)
{
gpgme_wait (ctx, 1);
- /* FIXME: check for success */
+ if (ctx->result.delete)
+ {
+ switch (ctx->result.delete->problem)
+ {
+ case DELETE_No_Problem:
+ break;
+ case DELETE_No_Such_Key:
+ err = mk_error(Invalid_Key);
+ break;
+ case DELETE_Must_Delete_Secret_Key:
+ err = mk_error(Conflict);
+ break;
+ default:
+ err = mk_error(General_Error);
+ break;
+ }
+ }
}
return err;
}
_gpgme_release_encrypt_result (ctx->result.encrypt);
_gpgme_release_passphrase_result (ctx->result.passphrase);
_gpgme_release_import_result (ctx->result.import);
+ _gpgme_release_delete_result (ctx->result.delete);
memset (&ctx->result, 0, sizeof (ctx->result));
_gpgme_set_op_info (ctx, NULL);
}
static void
append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
{
-#define MAX_IMPORTED_FIELDS 13
+#define MAX_IMPORTED_FIELDS 14
static char *imported_fields[MAX_IMPORTED_FIELDS]
= { "keyid", "username", 0 };
static char *import_res_fields[MAX_IMPORTED_FIELDS]
/*-- import.c --*/
void _gpgme_release_import_result (ImportResult res);
+/*-- delete.c --*/
+void _gpgme_release_delete_result (DeleteResult res);
+
/*-- version.c --*/
const char *_gpgme_compare_versions (const char *my_version,
const char *req_version);
struct import_result_s;
typedef struct import_result_s *ImportResult;
-
-#endif /* TYPES_H */
-
-
-
+/*-- delete.c --*/
+struct delete_result_s;
+typedef struct delete_result_s *DeleteResult;
+#endif /* TYPES_H */