/[winpt]/trunk/Src/wptKeyEditCB.cpp
ViewVC logotype

Diff of /trunk/Src/wptKeyEditCB.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by twoaday, Mon Oct 17 08:49:30 2005 UTC revision 101 by twoaday, Fri Nov 25 10:56:05 2005 UTC
# Line 1  Line 1 
1  /* wptKeyEditCB.cpp - Key edit callback handling  /* wptKeyEditCB.cpp - Key edit callback handling
2   *      Copyright (C) 2005 Timo Schulz   *      Copyright (C) 2005 Timo Schulz
3   *      Copyright (C) 2005 g10 Code GmbH   *      Copyright (C) 2005 g10 Code GmbH
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
6   *   *
7   * WinPT is free software; you can redistribute it and/or   * WinPT is free software; you can redistribute it and/or
8   * modify it under the terms of the GNU General Public License   * modify it under the terms of the GNU General Public License
9   * as published by the Free Software Foundation; either version 2   * as published by the Free Software Foundation; either version 2
10   * of the License, or (at your option) any later version.   * of the License, or (at your option) any later version.
11   *     *  
12   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * General Public License for more details.   * General Public License for more details.
16   *   *
17   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
18   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
19   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20   */   */
21  #include <stdio.h>  #ifdef HAVE_CONFIG_H
22  #include <string.h>  #include <config.h>
23  #include <stdlib.h>  #endif
24  #include <assert.h>  
25  #include <windows.h>  #include <stdio.h>
26    #include <stdio.h>
27  #include "gpgme.h"  #include <string.h>
28  #include "wptCommonCtl.h"  #include <stdlib.h>
29  #include "wptContext.h"  #include <assert.h>
30  #include "wptKeyEdit.h"  #include <windows.h>
31  #include "wptErrors.h"  
32    #include "gpgme.h"
33    #include "wptCommonCtl.h"
34  /* 'keyserver' command handler. */  #include "wptContext.h"
35  static const char*  #include "wptKeyEdit.h"
36  cmd_keyserv_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)  #include "wptErrors.h"
37  {  
38      static char buf[32];  
39    /* 'keyserver' command handler. */
40      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  static const char*
41          ctx->cmd_sent = 1;  cmd_keyserv_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
42          sprintf (buf, "uid %d", ctx->uid_index);  {
43          return buf;      static char buf[32];
44      }  
45      if (!strcmp (key, "keyedit.prompt") && !ctx->cnt) {      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
46          ctx->cnt = 1;          ctx->cmd_sent = 1;
47          return "keyserver";          sprintf (buf, "uid %d", ctx->uid_index);
48      }          return buf;
49      if (!strcmp (key, "keyedit.add_keyserver"))      }
50          return ctx->url;      if (!strcmp (key, "keyedit.prompt") && !ctx->cnt) {
51      if ( !strcmp (key, "keyedit.confirm_keyserver"))          ctx->cnt = 1;
52          return "Y";          return "keyserver";
53      if (!strcmp (key, "passphrase.enter"))      }
54          return ctx->pass;      if (!strcmp (key, "keyedit.add_keyserver"))
55      if (!strcmp (key, "keyedit.prompt") && ctx->cnt == 1) {          return ctx->url;
56          ctx->reset ();      if ( !strcmp (key, "keyedit.confirm_keyserver"))
57          return "save";          return "Y";
58      }      if (!strcmp (key, "passphrase.enter"))
59            return ctx->pass;
60      return NULL;      if (!strcmp (key, "keyedit.prompt") && ctx->cnt == 1) {
61  }          ctx->reset ();
62            return "save";
63        }
64  static const char*  
65  cmd_sign_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)      return NULL;
66  {  }
67      static char buf[32];  
68    
69      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  static const char*
70          ctx->cmd_sent = 1;  cmd_sign_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
71          switch (ctx->type) {  {
72          case GPG_EDITKEY_SIGN: return "sign";      static char buf[32];
73          case GPG_EDITKEY_TSIGN: return "tsign";  
74          case GPG_EDITKEY_LSIGN: return "lsign";      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
75          case GPG_EDITKEY_NRSIGN: return"nrsign";          ctx->cmd_sent = 1;
76          case GPG_EDITKEY_NRLSIGN: return "nrlsign";          switch (ctx->getType ()) {
77          }          case GPG_EDITKEY_SIGN: return "sign";
78      }          case GPG_EDITKEY_TSIGN: return "tsign";
79      if (!strcmp (key, "sign_uid.class")) {          case GPG_EDITKEY_LSIGN: return "lsign";
80          sprintf (buf, "%d", ctx->sig_class);          case GPG_EDITKEY_NRSIGN: return"nrsign";
81          return buf;          case GPG_EDITKEY_NRLSIGN: return "nrlsign";
82      }          }
83      if (!strcmp (key, "sign_uid.expire"))      }
84          return "Y"; /* the sig expires when the key expires */      if (!strcmp (key, "sign_uid.class")) {
85      if (!strcmp (key, "siggen.valid"))          sprintf (buf, "%d", ctx->sig_class);
86          return ctx->exp_date;          return buf;
87      if (!strcmp (key, "trustsig_prompt.trust_value")) {      }
88          sprintf (buf, "%d", ctx->trust_id);      if (!strcmp (key, "sign_uid.expire"))
89          return buf;          return "Y"; /* the sig expires when the key expires */
90      }      if (!strcmp (key, "siggen.valid"))
91      if (!strcmp (key, "trustsig_prompt.trust_depth"))          return ctx->exp_date;
92          return ""; /* fixme */      if (!strcmp (key, "trustsig_prompt.trust_value")) {
93      if (!strcmp (key, "trustsig_prompt.trust_regexp"))          sprintf (buf, "%d", ctx->trust_id);
94          return ""; /* fixme */          return buf;
95      if (!strcmp (key, "sign_uid.local_promote_okay" ) )      }
96          return "Y";      if (!strcmp (key, "trustsig_prompt.trust_depth"))
97      if (!strcmp (key, "sign_uid.okay" ) )          return ""; /* fixme */
98          return "Y";      if (!strcmp (key, "trustsig_prompt.trust_regexp"))
99      if (!strcmp (key, "keyedit.sign_all.okay"))          return ""; /* fixme */
100          return "Y";      if (!strcmp (key, "sign_uid.local_promote_okay" ) )
101      if (!strcmp ( key, "passphrase.enter"))          return "Y";
102          return ctx->pass;      if (!strcmp (key, "sign_uid.okay" ) )
103      if (!strcmp (key, "keyedit.prompt")) {          return "Y";
104          ctx->reset ();      if (!strcmp (key, "keyedit.sign_all.okay"))
105          return "save";          return "Y";
106      }      if (!strcmp ( key, "passphrase.enter"))
107                return ctx->pass;
108      return NULL;      if (!strcmp (key, "keyedit.prompt")) {
109  }          ctx->reset ();
110            return "save";
111  /* 'trust' command handler. */      }
112  static const char*      
113  cmd_trust_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)      return NULL;
114  {  }
115      static char buf[4];  
116    /* 'trust' command handler. */
117      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  static const char*
118          ctx->cmd_sent = 1;  cmd_trust_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
119          return "trust";  {
120      }      static char buf[4];
121      if (!strcmp (key, "edit_ownertrust.set_ultimate.okay"))  
122          return "Y";      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
123      if (!strcmp (key, "edit_ownertrust.value" )) {          ctx->cmd_sent = 1;
124          sprintf (buf, "%d", ctx->trust_id);          return "trust";
125          return buf;      }
126      }      if (!strcmp (key, "edit_ownertrust.set_ultimate.okay"))
127      if (!strcmp (key, "keyedit.prompt")) {          return "Y";
128          ctx->reset ();      if (!strcmp (key, "edit_ownertrust.value" )) {
129          return "save";          sprintf (buf, "%d", ctx->trust_id);
130      }          return buf;
131        }
132      return NULL;      if (!strcmp (key, "keyedit.prompt")) {
133  }          ctx->reset ();
134            return "save";
135        }
136  /* 'adduid' command handler. */  
137  static const char*      return NULL;
138  cmd_adduid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)  }
139  {  
140      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  
141          ctx->cmd_sent = 1;  /* 'adduid' command handler. */
142          return "adduid";  static const char*
143      }  cmd_adduid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
144      if (!strcmp (key, "keygen.name"))  {
145          return ctx->name;      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
146      if (!strcmp (key, "keygen.email"))          ctx->cmd_sent = 1;
147          return ctx->email;          return "adduid";
148      if (!strcmp (key, "keygen.comment"))      }
149          return ctx->cmt? ctx->cmt : "";      if (!strcmp (key, "keygen.name"))
150      if (!strcmp (key, "passphrase.enter"))          return ctx->name;
151          return ctx->pass;      if (!strcmp (key, "keygen.email"))
152      if( !strcmp (key, "keyedit.prompt")) {          return ctx->email;
153          ctx->reset ();      if (!strcmp (key, "keygen.comment"))
154          return "save";          return ctx->cmt? ctx->cmt : "";
155      }      if (!strcmp (key, "passphrase.enter"))
156            return ctx->pass;
157      return NULL;      if( !strcmp (key, "keyedit.prompt")) {
158  }          ctx->reset ();
159            return "save";
160        }
161  static const char*  
162  cmd_deluid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key,      return NULL;
163                      int *r_step)  }
164  {  
165      static char buf[64];  
166      int step = *r_step;  static const char*
167    cmd_deluid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key,
168      if (step == 0 && !strcmp (key, "keyedit.prompt")) {                      int *r_step)
169          sprintf (buf, "uid %d", ctx->uid_index);  {
170          *r_step = step = 1;      static char buf[64];
171          return buf;      int step = *r_step;
172      }  
173      if (step == 1 && !strcmp (key, "keyedit.prompt")) {      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
174          *r_step = step = 2;          sprintf (buf, "uid %d", ctx->uid_index);
175          return "deluid";          *r_step = step = 1;
176      }          return buf;
177      if (step == 2 && !strcmp (key, "keyedit.remove.uid.okay")) {      }
178          *r_step = step = 3;      if (step == 1 && !strcmp (key, "keyedit.prompt")) {
179          return "Y";          *r_step = step = 2;
180      }          return "deluid";
181      if (step == 3 && !strcmp (key, "keyedit.prompt" )) {      }
182          *r_step = step = 0;      if (step == 2 && !strcmp (key, "keyedit.remove.uid.okay")) {
183          ctx->reset ();          *r_step = step = 3;
184          return "save";          return "Y";
185      }      }
186            if (step == 3 && !strcmp (key, "keyedit.prompt" )) {
187      return NULL;          *r_step = step = 0;
188  }          ctx->reset ();
189            return "save";
190        }
191  static const char *      
192  cmd_delsig_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char * key,      return NULL;
193                      int * r_step)  }
194  {  
195      static char buf[64];  
196      int step = *r_step;  static const char *
197    cmd_delsig_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char * key,
198      if (step == 0 && !strcmp (key, "keyedit.prompt")) {                      int * r_step)
199          sprintf (buf, "uid %d", ctx->uid_index);  {
200          *r_step = step = 1;      static char buf[64];
201          return buf;      int step = *r_step;
202      }  
203      if (step == 1 && !strcmp (key, "keyedit.prompt")) {      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
204          *r_step = step = 2;          sprintf (buf, "uid %d", ctx->uid_index);
205          return "delsig";          *r_step = step = 1;
206      }          return buf;
207      if (!strcmp (key, "keyedit.delsig.unknown") ||      }
208          !strcmp (key, "keyedit.delsig.valid")) {      if (step == 1 && !strcmp (key, "keyedit.prompt")) {
209          if (++ctx->cnt == ctx->sig_index)          *r_step = step = 2;
210              return "Y";          return "delsig";
211          else      }
212              return "N";      if (!strcmp (key, "keyedit.delsig.unknown") ||
213      }          !strcmp (key, "keyedit.delsig.valid")) {
214      if (ctx->sig_index == 0 &&          if (++ctx->cnt == ctx->sig_index)
215          !strcmp (key, "keyedit.delsig.selfsig"))              return "Y";
216          return "Y";          else
217      if (step == 2 && !strcmp (key, "keyedit.prompt")) {              return "N";
218          *r_step = step = 0;      }
219          ctx->reset ();      if (ctx->sig_index == 0 &&
220          return "save";          !strcmp (key, "keyedit.delsig.selfsig"))
221      }          return "Y";
222      return NULL;      if (step == 2 && !strcmp (key, "keyedit.prompt")) {
223  }          *r_step = step = 0;
224            ctx->reset ();
225            return "save";
226  /* 'delkey' command handler. */      }
227  static const char*      return NULL;
228  cmd_delkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  }
229                      const char *key, int *r_step )  
230  {  
231      static char buf[64];  /* 'delkey' command handler. */
232      int step = *r_step;  static const char*
233    cmd_delkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
234      if (step == 0 && !strcmp (key, "keyedit.prompt")) {                      const char *key, int *r_step )
235          sprintf (buf, "key %d", ctx->key_index);  {
236          *r_step = step = 1;      static char buf[64];
237          return buf;      int step = *r_step;
238      }  
239      if (step == 1 && !strcmp (key, "keyedit.prompt")) {      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
240          *r_step = step = 2;          sprintf (buf, "key %d", ctx->key_index);
241          return "delkey";          *r_step = step = 1;
242      }          return buf;
243      if (step == 2 && !strcmp (key, "keyedit.remove.subkey.okay")) {      }
244          *r_step = step = 3;      if (step == 1 && !strcmp (key, "keyedit.prompt")) {
245          return "Y";          *r_step = step = 2;
246      }          return "delkey";
247      if (step == 3 && !strcmp (key, "keyedit.prompt")) {      }
248          *r_step = step = 0;      if (step == 2 && !strcmp (key, "keyedit.remove.subkey.okay")) {
249          ctx->reset ();          *r_step = step = 3;
250          return "save";          return "Y";
251      }      }
252        if (step == 3 && !strcmp (key, "keyedit.prompt")) {
253      return NULL;          *r_step = step = 0;
254  }          ctx->reset ();
255            return "save";
256        }
257  /* 'addkey' command handler. */  
258  static const char*      return NULL;
259  cmd_addkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)  }
260  {  
261      static char buf[64];  
262    /* 'addkey' command handler. */
263      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  static const char*
264          ctx->cmd_sent = 1;  cmd_addkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
265          return "addkey";  {
266      }      static char buf[64];
267    
268      if (!strcmp (key, "passphrase.enter"))      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
269          return ctx->pass;          ctx->cmd_sent = 1;
270      if (!strcmp (key, "keygen.algo")) {          return "addkey";
271          _snprintf (buf, sizeof buf-1, "%d", ctx->pubkey_algo);      }
272          return buf;  
273      }        if (!strcmp (key, "passphrase.enter"))
274      if (!strcmp (key, "keygen.size")) {          return ctx->pass;
275          _snprintf (buf, sizeof buf-1, "%d", ctx->pubkey_size);      if (!strcmp (key, "keygen.algo")) {
276          return buf;          _snprintf (buf, sizeof buf-1, "%d", ctx->pubkey_algo);
277      }          return buf;
278      if (!strcmp (key, "keygen.valid")) {      }  
279          _snprintf (buf, sizeof buf-1, "%d", ctx->valid);      if (!strcmp (key, "keygen.size")) {
280          return buf;                  _snprintf (buf, sizeof buf-1, "%d", ctx->pubkey_size);
281      }          return buf;
282      if (!strcmp (key, "keyedit.prompt")) {      }
283          ctx->reset ();      if (!strcmp (key, "keygen.valid")) {
284          return "save";          _snprintf (buf, sizeof buf-1, "%d", ctx->valid);
285      }          return buf;        
286      return NULL;      }
287  }      if (!strcmp (key, "keyedit.prompt")) {
288            ctx->reset ();
289  /* 'passwd' command handler. */          return "save";
290  static const char*      }
291  cmd_passwd_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)      return NULL;
292  {  }
293      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  
294          ctx->cmd_sent = 1;  /* 'passwd' command handler. */
295          return "passwd";  static const char*
296      }  cmd_passwd_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
297      if( !strcmp (key, "passphrase.enter") && !ctx->cnt) {  {
298          ctx->cnt = 1;      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
299          return ctx->pass;          ctx->cmd_sent = 1;
300      }          return "passwd";
301      if( !strcmp (key, "passphrase.enter" ))      }
302          return ctx->new_pass;      if( !strcmp (key, "passphrase.enter") && !ctx->cnt) {
303      if( !strcmp (key, "change_passwd.empty.okay" ))          ctx->cnt = 1;
304          return ctx->flags?  "Y" : "N";          return ctx->pass;
305      if (!strcmp (key, "keyedit.prompt")) {      }
306          ctx->reset ();      if( !strcmp (key, "passphrase.enter" ))
307          return "save";          return ctx->new_pass;
308      }      if( !strcmp (key, "change_passwd.empty.okay" ))
309      return NULL;          return ctx->flags?  "Y" : "N";
310  }      if (!strcmp (key, "keyedit.prompt")) {
311            ctx->reset ();
312            return "save";
313  static const char*      }
314  cmd_setpref_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char * key)      return NULL;
315  {  }
316      static char buf[128];  
317    
318      /* XXX: check the code. */  static const char*
319  #if 0  cmd_setpref_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char * key)
320      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {  {
321          ctx->cmd_sent = 1;      /* XXX: check the code. */
322          return "";  #if 0
323      }      static char buf[128];
324      if (!strcmp ( key, "keyedit.prompt") && ctx->u.pref.id == 0) {      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
325          ctx->u.pref.id++;          ctx->cmd_sent = 1;
326          _snprintf (buf, sizeof buf-1, "setpref %s", ctx->u.pref.new_prefs);          return "";
327          return buf;      }
328      }      if (!strcmp ( key, "keyedit.prompt") && ctx->u.pref.id == 0) {
329      if (!strcmp ( key, "keyedit.prompt") && ctx->u.pref.id == 1) {          ctx->u.pref.id++;
330          ctx->u.pref.id++;          _snprintf (buf, sizeof buf-1, "setpref %s", ctx->u.pref.new_prefs);
331          return "updpref";          return buf;
332      }      }
333      if (!strcmp ( key, "keyedit.updpref.okay"))      if (!strcmp ( key, "keyedit.prompt") && ctx->u.pref.id == 1) {
334          return "Y";          ctx->u.pref.id++;
335      if (!strcmp (key, "passphrase.enter"))          return "updpref";
336          return ctx->u.pref.passwd;      }
337      if (!strcmp (key, "keyedit.prompt") && ctx->u.pref.id == 2) {      if (!strcmp ( key, "keyedit.updpref.okay"))
338          ctx->u.pref.id = 0;          return "Y";
339          ctx->reset ();      if (!strcmp (key, "passphrase.enter"))
340          return "save";          return ctx->u.pref.passwd;
341      }      if (!strcmp (key, "keyedit.prompt") && ctx->u.pref.id == 2) {
342  #endif          ctx->u.pref.id = 0;
343      return NULL;          ctx->reset ();
344  }          return "save";
345        }
346    #endif
347  /* 'primary' command handler. */      return NULL;
348  static const char*  }
349  cmd_primary_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  
350                       const char *key, int *r_step )  
351  {  /* 'primary' command handler. */
352      static char buf[64];  static const char*
353      int step = *r_step;  cmd_primary_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
354                         const char *key, int *r_step )
355      if (step == 0 && !strcmp (key, "keyedit.prompt")) {  {
356          sprintf (buf, "uid %d", ctx->uid_index);      static char buf[64];
357          *r_step = step = 1;      int step = *r_step;
358          return buf;  
359      }      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
360      if (step == 1 && !strcmp (key, "keyedit.prompt" )) {          sprintf (buf, "uid %d", ctx->uid_index);
361          *r_step = step = 2;          *r_step = step = 1;
362          return "primary";          return buf;
363      }      }
364      if (step == 2 && !strcmp (key, "passphrase.enter")) {      if (step == 1 && !strcmp (key, "keyedit.prompt" )) {
365          *r_step = step = 3;          *r_step = step = 2;
366          return ctx->pass;          return "primary";
367      }      }
368      if (step == 3 && !strcmp (key, "keyedit.prompt")) {      if (step == 2 && !strcmp (key, "passphrase.enter")) {
369          *r_step = step = 0;          *r_step = step = 3;
370          ctx->reset ();          return ctx->pass;
371          return "save";      }
372      }      if (step == 3 && !strcmp (key, "keyedit.prompt")) {
373      return NULL;          *r_step = step = 0;
374  }          ctx->reset ();
375            return "save";
376  /* 'expire' command handler. */      }
377  static const char*      return NULL;
378  cmd_expire_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  }
379                      const char *key, int *r_step )  
380  {  /* 'expire' command handler. */
381      static char buf[64];  static const char*
382      int step = *r_step;  cmd_expire_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
383                        const char *key, int *r_step )
384      if (step == 0 && !strcmp (key, "keyedit.prompt")) {  {
385          sprintf (buf, "key %d", ctx->key_index);      static char buf[64];
386          *r_step = step = 1;      int step = *r_step;
387          return buf;  
388      }      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
389      if (step == 1 && !strcmp (key, "keyedit.prompt")) {          sprintf (buf, "key %d", ctx->key_index);
390          *r_step = step = 2;          *r_step = step = 1;
391          return "expire";          return buf;
392      }      }
393      if( step == 2 && !strcmp ( key, "keygen.valid" ) ) {      if (step == 1 && !strcmp (key, "keyedit.prompt")) {
394          *r_step = step = 3;          *r_step = step = 2;
395          sprintf (buf, "%d", ctx->valid);          return "expire";
396          return buf;      }
397      }      if( step == 2 && !strcmp ( key, "keygen.valid" ) ) {
398      if (step == 3 && !strcmp (key, "passphrase.enter")) {          *r_step = step = 3;
399          *r_step = step = 4;          sprintf (buf, "%d", ctx->valid);
400          return ctx->pass;          return buf;
401      }      }
402      if (step == 4 && !strcmp (key, "keyedit.prompt")) {      if (step == 3 && !strcmp (key, "passphrase.enter")) {
403          *r_step = step = 0;          *r_step = step = 4;
404          ctx->reset ();          return ctx->pass;
405          return "save";      }
406      }      if (step == 4 && !strcmp (key, "keyedit.prompt")) {
407                *r_step = step = 0;
408      return NULL;          ctx->reset ();
409  }          return "save";
410        }
411        
412  /* 'revuid' command handler. */      return NULL;
413  const char*  }
414  cmd_revuid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  
415                      const char *key, int *r_step)  
416  {  /* 'revuid' command handler. */
417      static char buf[32];  const char*
418      int step = *r_step;  cmd_revuid_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
419                            const char *key, int *r_step)
420      if (step == 0 && !strcmp (key, "keyedit.prompt")) {  {
421          *r_step = step = 1;      static char buf[32];
422          sprintf (buf, "uid %d", ctx->uid_index);      int step = *r_step;
423          return buf;      
424      }      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
425      else if (step == 1 && !strcmp (key, "keyedit.prompt")) {          *r_step = step = 1;
426          *r_step = step = 2;          sprintf (buf, "uid %d", ctx->uid_index);
427          return "revuid";          return buf;
428      }      }
429      else if (step == 2 && !strcmp (key, "keyedit.revoke.uid.okay")) {      else if (step == 1 && !strcmp (key, "keyedit.prompt")) {
430          *r_step = step = 3;          *r_step = step = 2;
431          return "Y";          return "revuid";
432      }      }
433      else if (step == 3 && !strcmp (key, "ask_revocation_reason.code")) {      else if (step == 2 && !strcmp (key, "keyedit.revoke.uid.okay")) {
434          *r_step = step = 4;          *r_step = step = 3;
435          return "4";          return "Y";
436      }      }
437      else if (step == 4 && !strcmp (key, "ask_revocation_reason.text")) {      else if (step == 3 && !strcmp (key, "ask_revocation_reason.code")) {
438          *r_step = step = 5;          *r_step = step = 4;
439          return "";          return "4";
440      }      }
441      else if (step == 5 && !strcmp (key, "ask_revocation_reason.okay")) {      else if (step == 4 && !strcmp (key, "ask_revocation_reason.text")) {
442          *r_step = step = 6;          *r_step = step = 5;
443          return "Y";          return "";
444      }      }
445      else if (step == 6 && !strcmp (key, "passphrase.enter")) {      else if (step == 5 && !strcmp (key, "ask_revocation_reason.okay")) {
446          *r_step = step = 7;          *r_step = step = 6;
447          return ctx->pass;          return "Y";
448      }      }
449      else if (step == 7 && !strcmp (key, "keyedit.prompt")) {      else if (step == 6 && !strcmp (key, "passphrase.enter")) {
450          *r_step = step = 0;          *r_step = step = 7;
451          ctx->reset ();          return ctx->pass;
452          return "save";      }
453      }      else if (step == 7 && !strcmp (key, "keyedit.prompt")) {
454      return NULL;          *r_step = step = 0;
455  }          ctx->reset ();
456            return "save";
457        }
458  const char*      return NULL;
459  cmd_revsig_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  }
460                      const char *key, int *r_step)  
461  {  
462      static char buf[64];  const char*
463      int step = *r_step;  cmd_revsig_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
464                            const char *key, int *r_step)
465      if( step == 0 && !strcmp ( key, "keyedit.prompt" ) ) {  {
466          sprintf( buf, "uid %d", ctx->uid_index);      static char buf[64];
467          *r_step = step = 1;      int step = *r_step;
468          return buf;      
469      }      if( step == 0 && !strcmp ( key, "keyedit.prompt" ) ) {
470      if( step == 1 && !strcmp ( key, "keyedit.prompt" ) ) {          sprintf( buf, "uid %d", ctx->uid_index);
471          *r_step = step = 2;          *r_step = step = 1;
472          return "revsig";          return buf;
473      }      }
474      if( step == 2 && !strcmp (key, "ask_revoke_sig.one" ) ) {      if( step == 1 && !strcmp ( key, "keyedit.prompt" ) ) {
475          *r_step = step = 3;          *r_step = step = 2;
476          return "Y";          return "revsig";
477      }      }
478      if( step == 3 && !strcmp (key, "ask_revoke_sig.okay" ) ) {      if( step == 2 && !strcmp (key, "ask_revoke_sig.one" ) ) {
479          *r_step = step = 4;          *r_step = step = 3;
480          return "Y";          return "Y";
481      }      }
482      if( step == 4 && !strcmp ( key, "ask_revocation_reason.code" ) ) {      if( step == 3 && !strcmp (key, "ask_revoke_sig.okay" ) ) {
483          *r_step = step = 5;          *r_step = step = 4;
484          return "0";          return "Y";
485      }      }
486      if( step == 5 && !strcmp ( key, "ask_revocation_reason.text" ) ) {      if( step == 4 && !strcmp ( key, "ask_revocation_reason.code" ) ) {
487          *r_step = step = 6;          *r_step = step = 5;
488          return "";          return "0";
489      }      }
490      if( step == 6 && !strcmp (key, "ask_revocation_reason.okay" ) ) {      if( step == 5 && !strcmp ( key, "ask_revocation_reason.text" ) ) {
491          *r_step = step = 7;          *r_step = step = 6;
492          return "Y";          return "";
493      }      }
494      if( step == 7 && !strcmp (key, "passphrase.enter" ) ) {      if( step == 6 && !strcmp (key, "ask_revocation_reason.okay" ) ) {
495          *r_step = step = 8;          *r_step = step = 7;
496          return ctx->pass;          return "Y";
497      }      }
498      if( step == 8 && !strcmp ( key, "keyedit.prompt" ) ) {      if( step == 7 && !strcmp (key, "passphrase.enter" ) ) {
499          *r_step = step = 0;          *r_step = step = 8;
500          ctx->reset ();          return ctx->pass;
501          return "save";      }
502      }      if( step == 8 && !strcmp ( key, "keyedit.prompt" ) ) {
503                *r_step = step = 0;
504      return NULL;          ctx->reset ();
505  }          return "save";
506        }
507        
508  /* 'revoke' command handler. */      return NULL;
509  static const char *  }
510  cmd_revkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  
511                      const char * key, int *r_step)  
512  {  /* 'revoke' command handler. */
513      int step = *r_step;  static const char *
514      static char buf[64];  cmd_revkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
515                        const char * key, int *r_step)
516      if( step == 0 && !strcmp ( key, "keyedit.prompt" ) ) {  {
517          sprintf( buf, "key %d", ctx->key_index);      int step = *r_step;
518          *r_step = step = 1;      static char buf[64];
519          return buf;  
520      }      if( step == 0 && !strcmp ( key, "keyedit.prompt" ) ) {
521      if( step == 1 && !strcmp ( key, "keyedit.prompt" ) ) {          sprintf( buf, "key %d", ctx->key_index);
522          *r_step = step = 2;          *r_step = step = 1;
523          return "revkey";          return buf;
524      }      }
525      if( step == 2 && !strcmp (key, "keyedit.revoke.subkey.okay" ) ) {      if( step == 1 && !strcmp ( key, "keyedit.prompt" ) ) {
526          *r_step = step = 3;          *r_step = step = 2;
527          return "Y";          return "revkey";
528      }      }
529      if( step == 3 &&  !strcmp ( key, "ask_revocation_reason.code" ) ) {      if( step == 2 && !strcmp (key, "keyedit.revoke.subkey.okay" ) ) {
530          sprintf( buf, "%d", ctx->reason);          *r_step = step = 3;
531          *r_step = step = 4;          return "Y";
532          return buf;      }
533      }      if( step == 3 &&  !strcmp ( key, "ask_revocation_reason.code" ) ) {
534      if( step == 4 && !strcmp ( key, "ask_revocation_reason.text" ) ) {          sprintf( buf, "%d", ctx->reason);
535          *r_step = step = 5;          *r_step = step = 4;
536          return "";          return buf;
537      }      }
538      if( step == 5 && !strcmp (key, "ask_revocation_reason.okay" ) ) {      if( step == 4 && !strcmp ( key, "ask_revocation_reason.text" ) ) {
539          *r_step = step = 6;          *r_step = step = 5;
540          return "Y";          return "";
541      }      }
542      if( step == 6 && !strcmp (key, "passphrase.enter" ) ) {      if( step == 5 && !strcmp (key, "ask_revocation_reason.okay" ) ) {
543          *r_step = step = 7;          *r_step = step = 6;
544          return ctx->pass;          return "Y";
545      }      }
546      if( step == 7 && !strcmp ( key, "keyedit.prompt" ) ) {      if( step == 6 && !strcmp (key, "passphrase.enter" ) ) {
547          *r_step = step = 0;          *r_step = step = 7;
548          ctx->reset ();          return ctx->pass;
549          return "save";      }
550      }      if( step == 7 && !strcmp ( key, "keyedit.prompt" ) ) {
551      return NULL;          *r_step = step = 0;
552  }          ctx->reset ();
553            return "save";
554        }
555  /* 'addrevoker' command handler. */      return NULL;
556  static const char *  }
557  cmd_addrev_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,  
558                      const char * key, int * r_step)  
559  {  /* 'addrevoker' command handler. */
560      int step = *r_step;  static const char *
561    cmd_addrev_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
562      if (step == 0 && !strcmp (key, "keyedit.prompt")) {                      const char * key, int * r_step)
563          *r_step = step = 1;  {
564          return "addrevoker";      int step = *r_step;
565      }  
566      if (step == 1 && !strcmp (key, "keyedit.add_revoker")) {      /* If the isuser already signed the key, send an empty
567          *r_step = step = 2;         string and jump to quit. */
568          /* XXX: handle already-signed. */      if (ctx->getResult () & GPG_EDITRES_ALREADY_SIGNED
569          return ctx->name;          && *r_step != -1 && *r_step != 4) {
570      }          *r_step = step = -1;
571      if (step == 2 && !strcmp (key, "keyedit.add_revoker.okay")) {          return "";
572          *r_step = step = 3;      }
573          return "Y";      if (*r_step == -1) {
574      }          *r_step = step = 4;
575      if (step == 3 && !strcmp (key, "passphrase.enter")) {          return ""; /* empty value to abort. */
576          *r_step = step = 4;      }
577          return ctx->pass;      if (step == 0 && !strcmp (key, "keyedit.prompt")) {
578      }          *r_step = step = 1;
579      if (step == 4 && !strcmp (key, "keyedit.prompt")) {          return "addrevoker";
580          *r_step = step = 0;      }
581          ctx->reset ();      if (step == 1 && !strcmp (key, "keyedit.add_revoker")) {
582          return "save";          *r_step = step = 2;
583      }          return ctx->name;
584        }
585      return NULL;      if (step == 2 && !strcmp (key, "keyedit.add_revoker.okay")) {
586  }          *r_step = step = 3;
587            return "Y";
588        }
589  /* 'addphoto' command handler. */      if (step == 3 && !strcmp (key, "passphrase.enter")) {
590  static const char*          *r_step = step = 4;
591  cmd_addphoto_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)          return ctx->pass;
592  {      }
593      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {      if (step == 4 && !strcmp (key, "keyedit.prompt")) {
594          ctx->cmd_sent = 1;          *r_step = step = 0;
595          return "addphoto";          ctx->reset ();
596      }          return "save";
597      if (!strcmp (key, "photoid.jpeg.add"))      }
598          return ctx->url;  
599      if (!strcmp (key, "photoid.jpeg.size"))      return NULL;
600          return "Y";  }
601      if (!strcmp (key, "passphrase.enter"))  
602          return ctx->pass;  
603      if (!strcmp (key, "keyedit.prompt")) {        /* 'addphoto' command handler. */
604          ctx->reset ();  static const char*
605          return "save";  cmd_addphoto_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
606      }  {
607      return NULL;      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
608  }          ctx->cmd_sent = 1;
609            return "addphoto";
610  /* 'enable' and 'disable' command handler. */      }
611  static const char *      if (!strcmp (key, "photoid.jpeg.add"))
612  cmd_enable_disable_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,          return ctx->url;
613                              const char * key, int mode)      if (!strcmp (key, "photoid.jpeg.size"))
614  {          return "Y";
615      if (!strcmp (key, "keyedit.prompt") && !ctx->cmd_sent) {      if (!strcmp (key, "passphrase.enter"))
616          ctx->cmd_sent = 1;          return ctx->pass;
617          if (mode)      if (!strcmp (key, "keyedit.prompt")) {      
618              return "disable";          ctx->reset ();
619          return "enable";          return "save";
620      }      }
621      if (!strcmp (key, "keyedit.prompt")) {      return NULL;
622          ctx->reset ();  }
623          return "save";  
624      }  /* 'enable' and 'disable' command handler. */
625      return NULL;  static const char *
626  }  cmd_enable_disable_handler (GpgKeyEdit *ctx, gpgme_status_code_t code,
627                                const char * key, int mode)
628    {
629  /* edit key dispatch handler. */      if (!strcmp (key, "keyedit.prompt") && !ctx->cmd_sent) {
630  static gpgme_error_t                              ctx->cmd_sent = 1;
631  editkey_command_handler (void *opaque, gpgme_status_code_t code,          if (mode)
632                           const char *key, int fd)              return "disable";
633  {          return "enable";
634      static int step = 0;      }
635      const char *out = NULL;      if (!strcmp (key, "keyedit.prompt")) {
636      GpgKeyEdit *ke = (GpgKeyEdit *)opaque;          ctx->reset ();
637      HANDLE hd = (HANDLE)fd;          return "save";
638      DWORD n;      }
639            return NULL;
640      if (!ke)  }
641          return gpg_error (GPG_ERR_INV_ARG);  
642    
643      /*log_debug ("key=%s code=%d\r\n", key, code);*/  /* edit key dispatch handler. */
644      switch (code) {  static gpgme_error_t                    
645      case GPGME_STATUS_ALREADY_SIGNED:  editkey_command_handler (void *opaque, gpgme_status_code_t code,
646          ke->setResult (GPG_EDITRES_ALREADY_SIGNED);                           const char *key, int fd)
647          break;  {
648      case GPGME_STATUS_BAD_PASSPHRASE:      static int step = 0;
649          ke->setResult (GPG_EDITRES_BAD_PASSPHRASE);      const char *out = NULL;
650          break;      GpgKeyEdit *ke = (GpgKeyEdit *)opaque;
651      }      HANDLE hd = (HANDLE)fd;
652        DWORD n;
653      if (ke->getResult () & GPG_EDITRES_BAD_PASSPHRASE) {      
654          /* If the entered passphrase is bad, we supply empty      if (!ke)
655             passphrase to abort and send 'quit' as soon as possible. */          return gpg_error (GPG_ERR_INV_ARG);
656          if (!strcmp (key, "passphrase.enter"))  
657              WriteFile (hd, "\n", 1, &n, NULL);      /*log_debug ("key=%s code=%d\r\n", key, code);*/
658          if (!strcmp (key, "keyedit.prompt"))      switch (code) {
659              WriteFile (hd, "quit\n", 5, &n, NULL);      case GPGME_STATUS_ALREADY_SIGNED:
660      }          ke->setResult (GPG_EDITRES_ALREADY_SIGNED);
661                break;
662      switch (ke->type) {      case GPGME_STATUS_BAD_PASSPHRASE:
663      case GPG_EDITKEY_LSIGN:          ke->setResult (GPG_EDITRES_BAD_PASSPHRASE);
664      case GPG_EDITKEY_SIGN:          break;
665      case GPG_EDITKEY_NRSIGN:          
666      case GPG_EDITKEY_TSIGN:      default:
667      case GPG_EDITKEY_NRLSIGN:          break;
668          out = cmd_sign_handler (ke, code, key);      }
669          break;  
670                if (ke->getResult () & GPG_EDITRES_BAD_PASSPHRASE) {
671      case GPG_EDITKEY_TRUST:          /* If the entered passphrase is bad, we supply empty
672          out =  cmd_trust_handler (ke, code, key);             passphrase to abort and send 'quit' as soon as possible. */
673          break;          if (!strcmp (key, "passphrase.enter"))
674                        WriteFile (hd, "\n", 1, &n, NULL);
675      case GPG_EDITKEY_ADDUID:          if (!strcmp (key, "keyedit.prompt"))
676          out =  cmd_adduid_handler (ke, code, key);              WriteFile (hd, "quit\n", 5, &n, NULL);
677          break;      }
678                
679      case GPG_EDITKEY_DELUID:      switch (ke->getType ()) {
680          out =  cmd_deluid_handler (ke, code, key, &step);      case GPG_EDITKEY_LSIGN:
681          break;      case GPG_EDITKEY_SIGN:
682                case GPG_EDITKEY_NRSIGN:
683      case GPG_EDITKEY_DELSIG:      case GPG_EDITKEY_TSIGN:
684          out =  cmd_delsig_handler (ke, code, key, &step);      case GPG_EDITKEY_NRLSIGN:
685          break;          out = cmd_sign_handler (ke, code, key);
686            break;
687      case GPG_EDITKEY_DELKEY:          
688          out =  cmd_delkey_handler(ke, code, key, &step );      case GPG_EDITKEY_TRUST:
689          break;          out =  cmd_trust_handler (ke, code, key);
690                    break;
691      case GPG_EDITKEY_ADDKEY:          
692          out =  cmd_addkey_handler (ke, code, key);      case GPG_EDITKEY_ADDUID:
693          break;          out =  cmd_adduid_handler (ke, code, key);
694                    break;
695      case GPG_EDITKEY_PASSWD:          
696          out =  cmd_passwd_handler (ke, code, key);      case GPG_EDITKEY_DELUID:
697          break;          out =  cmd_deluid_handler (ke, code, key, &step);
698                    break;
699      case GPG_EDITKEY_PRIMARY:          
700          out =  cmd_primary_handler (ke, code, key, &step);      case GPG_EDITKEY_DELSIG:
701          break;          out =  cmd_delsig_handler (ke, code, key, &step);
702                    break;
703      case GPG_EDITKEY_EXPIRE:  
704          out =  cmd_expire_handler (ke, code, key, &step);      case GPG_EDITKEY_DELKEY:
705          break;          out =  cmd_delkey_handler(ke, code, key, &step );
706            break;
707      case GPG_EDITKEY_REVSIG:          
708          out =  cmd_revsig_handler (ke, code, key, &step);      case GPG_EDITKEY_ADDKEY:
709          break;          out =  cmd_addkey_handler (ke, code, key);
710            break;
711      case GPG_EDITKEY_REVKEY:          
712          out =  cmd_revkey_handler (ke, code, key, &step);      case GPG_EDITKEY_PASSWD:
713          break;          out =  cmd_passwd_handler (ke, code, key);
714                        break;
715      case GPG_EDITKEY_REVUID:          
716          out = cmd_revuid_handler (ke, code, key, &step);      case GPG_EDITKEY_PRIMARY:
717          break;          out =  cmd_primary_handler (ke, code, key, &step);
718            break;
719      case GPG_EDITKEY_ADDREV:          
720          out =  cmd_addrev_handler (ke, code, key, &step);      case GPG_EDITKEY_EXPIRE:
721          break;          out =  cmd_expire_handler (ke, code, key, &step);
722            break;
723      case GPG_EDITKEY_ADDPHOTO:  
724          out =  cmd_addphoto_handler (ke, code, key);      case GPG_EDITKEY_REVSIG:
725          break;          out =  cmd_revsig_handler (ke, code, key, &step);
726            break;
727      case GPG_EDITKEY_ENABLE:  
728      case GPG_EDITKEY_DISABLE:      case GPG_EDITKEY_REVKEY:
729          out = cmd_enable_disable_handler (ke, code, key,          out =  cmd_revkey_handler (ke, code, key, &step);
730                                            ke->type == GPG_EDITKEY_DISABLE? 1: 0);          break;
731          break;              
732        case GPG_EDITKEY_REVUID:
733      case GPG_EDITKEY_SETPREF:          out = cmd_revuid_handler (ke, code, key, &step);
734          out =  cmd_setpref_handler (ke, code, key);          break;
735          break;  
736        case GPG_EDITKEY_ADDREV:
737      case GPG_EDITKEY_KEYSERV:          out =  cmd_addrev_handler (ke, code, key, &step);
738          out =  cmd_keyserv_handler (ke, code, key);          break;
739          break;  
740      }      case GPG_EDITKEY_ADDPHOTO:
741            out =  cmd_addphoto_handler (ke, code, key);
742      if (out != NULL) {          break;
743          /* XXX: check return codes. */  
744          WriteFile (hd, out, strlen (out), &n, NULL);      case GPG_EDITKEY_ENABLE:
745          WriteFile (hd, "\n", 1, &n, NULL);      case GPG_EDITKEY_DISABLE:
746      }          out = cmd_enable_disable_handler (ke, code, key,
747      return 0;                                            ke->getType () == GPG_EDITKEY_DISABLE? 1: 0);
748  }          break;
749    
750        case GPG_EDITKEY_SETPREF:
751  /* Check if a GPG status code occured which marks the          out =  cmd_setpref_handler (ke, code, key);
752     current operation as failed.          break;
753     Return value: gpg error constant. */  
754  static gpgme_error_t      case GPG_EDITKEY_KEYSERV:
755  map_result (GpgKeyEdit *ke)          out =  cmd_keyserv_handler (ke, code, key);
756  {          break;
757      if (!ke->getResult ())      }
758          return gpg_error (GPG_ERR_NO_ERROR);  
759      if (ke->getResult () & GPG_EDITRES_BAD_PASSPHRASE)      if (out != NULL) {
760          return gpg_error (GPG_ERR_BAD_PASSPHRASE);          /* XXX: check return codes. */
761      return 0;          WriteFile (hd, out, strlen (out), &n, NULL);
762  }          WriteFile (hd, "\n", 1, &n, NULL);
763        }
764        return 0;
765  /* Wrapper around the gpgme edit interface.  }
766     @ctx context to use.  
767     @key key on which the operation should be performed.  
768     @ek  key edit context.  /* Check if a GPG status code occured which marks the
769     Return value: 0 on success. */     current operation as failed.
770  gpgme_error_t     Return value: gpg error constant. */
771  gpg_editkey (gpgme_ctx_t ctx, gpgme_key_t key, GpgKeyEdit *ek)  static gpgme_error_t
772  {  map_result (GpgKeyEdit *ke)
773      gpgme_error_t err;  {
774      gpgme_data_t out;      /* XXX Sometimes ALREADY_SIGNED indicates an failure. */
775          if (!ke->getResult ())
776      err = gpgme_data_new (&out);          return gpg_error (GPG_ERR_NO_ERROR);
777      if (err)      if (ke->getResult () & GPG_EDITRES_BAD_PASSPHRASE)
778          return err;          return gpg_error (GPG_ERR_BAD_PASSPHRASE);
779      err = gpgme_op_edit (ctx, key, editkey_command_handler, ek, out);      return 0;
780      if (!err)  }
781          err = map_result (ek);  
782    
783      gpgme_data_release (out);  /* Wrapper around the gpgme edit interface.
784      return err;     @ctx context to use.
785  }     @key key on which the operation should be performed.
786       @ek  key edit context.
787       Return value: 0 on success. */
788    gpgme_error_t
789    gpg_editkey (gpgme_ctx_t ctx, gpgme_key_t key, GpgKeyEdit *ek)
790    {
791        gpgme_error_t err;
792        gpgme_data_t out;
793      
794        err = gpgme_data_new (&out);
795        if (err)
796            return err;
797        err = gpgme_op_edit (ctx, key, editkey_command_handler, ek, out);
798        if (!err)
799            err = map_result (ek);
800    
801        gpgme_data_release (out);
802        return err;
803    }

Legend:
Removed from v.26  
changed lines
  Added in v.101

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26