2002-01-30 Marcus Brinkmann <marcus@g10code.de>
authorMarcus Brinkmann <mb@g10code.com>
Wed, 30 Jan 2002 22:45:22 +0000 (22:45 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Wed, 30 Jan 2002 22:45:22 +0000 (22:45 +0000)
* 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.

trunk/gpgme/ChangeLog
trunk/gpgme/context.h
trunk/gpgme/delete.c
trunk/gpgme/gpgme.c
trunk/gpgme/import.c
trunk/gpgme/ops.h
trunk/gpgme/types.h

index 010c21eb6825970fe16f76e6846f6f4914ffb5fe..8b47b092e510fc93d841d11cd223fb07ec5da243 100644 (file)
@@ -1,3 +1,19 @@
+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.
@@ -6,7 +22,7 @@
        (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.
 
index 02d395458ae75075167203bceee75839c32ae300..ae2460bd73a7b961ce6981dbef73bd3a37e1e870 100644 (file)
@@ -69,6 +69,7 @@ struct gpgme_context_s {
         EncryptResult encrypt;
         PassphraseResult passphrase;
         ImportResult import;
+        DeleteResult delete;
     } result;
 
     GpgmeData notation;    /* last signature notation */
index a5f122fb62e1ce50ca786eb5c3414397a768e82d..23044c4f33bd04002bb235a4138cf7ea2666921e 100644 (file)
 #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;
     }
 }
 
@@ -108,7 +147,23 @@ gpgme_op_delete (GpgmeCtx ctx, const GpgmeKey key, int allow_secret)
   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;
 }
index 25e6b6170eac9fd91f8ee46373742934db54846a..d528f8f0223c2e9399c85dcdb8720bd39667f548 100644 (file)
@@ -87,6 +87,7 @@ _gpgme_release_result (GpgmeCtx ctx)
   _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);
 }
index 81990572cc11a40d671477ae122e498c79e98ded..f038091ae24fc7c850d6a2cbb89c2800d48eb23d 100644 (file)
@@ -52,7 +52,7 @@ _gpgme_release_import_result (ImportResult result)
 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]
index dcdeba7e39a1d4c971a2a49c3c906fe103792961..ed6e5db9dbd4595c4216de2b3ecdb507a3a320c8 100644 (file)
@@ -98,6 +98,9 @@ GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx);
 /*-- 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);
index 71dab9a49237e2675970b21cb9b8cdbbe5509eec..38f58f992ba521cb96b6314b03c8d6c7a74b1186 100644 (file)
@@ -80,10 +80,9 @@ typedef struct passphrase_result_s *PassphraseResult;
 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 */