43 |
|
|
44 |
typedef gpgme_status_code_t status_code_t; |
typedef gpgme_status_code_t status_code_t; |
45 |
|
|
46 |
|
|
47 |
/* 'notation' command handler. */ |
/* 'notation' command handler. */ |
48 |
static const char* |
static const char* |
49 |
cmd_notation_handler (GpgKeyEdit *ctx, status_code_t code, const char *key) |
cmd_notation_handler (GpgKeyEdit *ctx, status_code_t code, const char *key) |
299 |
} |
} |
300 |
|
|
301 |
|
|
302 |
|
/* 'addcardkey' command handler. */ |
303 |
|
static const char* |
304 |
|
cmd_addcardkey_handler (GpgKeyEdit *ctx, status_code_t code, const char *key) |
305 |
|
{ |
306 |
|
static char buf[32]; |
307 |
|
|
308 |
|
/* XXX: actually we mix up things here, it would be better to |
309 |
|
implement this in CardEditCB but because the edit-key |
310 |
|
interface is used, we have to implement it here. */ |
311 |
|
if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) { |
312 |
|
ctx->cmd_sent = 1; |
313 |
|
return "addcardkey"; |
314 |
|
} |
315 |
|
if (!strcmp (key, "cardedit.genkeys.subkeytype")) { |
316 |
|
sprintf (buf, "%d", ctx->getKeyIndex ()); |
317 |
|
return buf; |
318 |
|
} |
319 |
|
if (!strcmp (key, "cardedit.genkeys.replace_key")) |
320 |
|
return "Y"; /* better issue an extra warning? */ |
321 |
|
if (!strcmp (key, "passphrase.adminpin.ask")) |
322 |
|
return ctx->pass; |
323 |
|
if (!strcmp (key, "passphrase.pin.ask")) |
324 |
|
return ctx->new_pass; |
325 |
|
if (!strcmp (key, "keygen.valid")) { |
326 |
|
sprintf (buf, "%d", ctx->getValidDays ()); |
327 |
|
return buf; |
328 |
|
} |
329 |
|
if (!strcmp (key, "keyedit.prompt")) { |
330 |
|
ctx->reset (); |
331 |
|
return "save"; |
332 |
|
} |
333 |
|
return NULL; |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
/* 'addkey' command handler. */ |
/* 'addkey' command handler. */ |
338 |
static const char* |
static const char* |
339 |
cmd_addkey_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key) |
cmd_addkey_handler (GpgKeyEdit *ctx, status_code_t code, const char *key) |
340 |
{ |
{ |
341 |
static char buf[64]; |
static char buf[64]; |
342 |
|
|
396 |
|
|
397 |
|
|
398 |
static const char* |
static const char* |
399 |
cmd_setpref_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char * key) |
cmd_setpref_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key) |
400 |
{ |
{ |
401 |
static char buf[128] = {0}; |
static char buf[128] = {0}; |
402 |
|
|
403 |
/* XXX: check the code. */ |
if (!strcmp (key, "keyedit.prompt") && !ctx->cmd_sent) { |
404 |
#if 0 |
_snprintf (buf, sizeof (buf)-1, "uid %d", ctx->getUseridIndex ()); |
|
if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) { |
|
405 |
ctx->cmd_sent = 1; |
ctx->cmd_sent = 1; |
406 |
return ""; |
ctx->cnt = 1; |
|
} |
|
|
if (!strcmp (key, "keyedit.prompt") && ctx->u.pref.id == 0) { |
|
|
ctx->u.pref.id++; |
|
|
_snprintf (buf, sizeof buf-1, "setpref %s", ctx->u.pref.new_prefs); |
|
407 |
return buf; |
return buf; |
408 |
} |
} |
409 |
if (!strcmp (key, "keyedit.prompt") && ctx->u.pref.id == 1) { |
if (!strcmp (key, "keyedit.prompt") && ctx->cnt == 1) { |
410 |
ctx->u.pref.id++; |
_snprintf (buf, sizeof buf-1, "setpref %s", ctx->new_prefs); |
411 |
return "updpref"; |
ctx->cnt = 2; |
412 |
|
return buf; |
413 |
} |
} |
414 |
if (!strcmp (key, "keyedit.updpref.okay")) |
if (!strcmp (key, "keyedit.setpref.okay")) |
415 |
return "Y"; |
return "Y"; |
416 |
if (!strcmp (key, "passphrase.enter")) |
if (!strcmp (key, "passphrase.enter")) |
417 |
return ctx->u.pref.passwd; |
return ctx->pass; |
418 |
if (!strcmp (key, "keyedit.prompt") && ctx->u.pref.id == 2) { |
if (!strcmp (key, "keyedit.prompt") && ctx->cnt == 2) { |
|
ctx->u.pref.id = 0; |
|
419 |
ctx->reset (); |
ctx->reset (); |
420 |
return "save"; |
return "save"; |
421 |
} |
} |
|
#endif |
|
422 |
return buf; |
return buf; |
423 |
} |
} |
424 |
|
|
429 |
const char *key) |
const char *key) |
430 |
{ |
{ |
431 |
static char buf[64]; |
static char buf[64]; |
432 |
|
|
433 |
if (ctx->cnt == 0 && !strcmp (key, "keyedit.prompt")) { |
if (ctx->cnt == 0 && !strcmp (key, "keyedit.prompt")) { |
434 |
sprintf (buf, "uid %d", ctx->getUseridIndex ()); |
sprintf (buf, "uid %d", ctx->getUseridIndex ()); |
435 |
ctx->cnt = 1; |
ctx->cnt = 1; |
795 |
break; |
break; |
796 |
|
|
797 |
case GPG_EDITKEY_DELSIG: |
case GPG_EDITKEY_DELSIG: |
798 |
out = cmd_delsig_handler (ke, code, key); |
out = cmd_delsig_handler (ke, code, key); |
799 |
break; |
break; |
800 |
|
|
801 |
case GPG_EDITKEY_DELKEY: |
case GPG_EDITKEY_DELKEY: |
803 |
break; |
break; |
804 |
|
|
805 |
case GPG_EDITKEY_ADDKEY: |
case GPG_EDITKEY_ADDKEY: |
806 |
out = cmd_addkey_handler (ke, code, key); |
out = cmd_addkey_handler (ke, code, key); |
807 |
|
break; |
808 |
|
|
809 |
|
case GPG_EDITKEY_ADDCARDKEY: |
810 |
|
out = cmd_addcardkey_handler (ke, code, key); |
811 |
break; |
break; |
812 |
|
|
813 |
case GPG_EDITKEY_PASSWD: |
case GPG_EDITKEY_PASSWD: |