/[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 207 by twoaday, Fri Apr 28 10:28:24 2006 UTC revision 260 by twoaday, Wed Aug 16 10:01:30 2006 UTC
# Line 43  enum editkey_error_t { Line 43  enum editkey_error_t {
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)
# Line 119  cmd_sign_handler (GpgKeyEdit *ctx, gpgme Line 120  cmd_sign_handler (GpgKeyEdit *ctx, gpgme
120      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {      if (!ctx->cmd_sent && !strcmp (key, "keyedit.prompt")) {
121          ctx->cmd_sent = 1;          ctx->cmd_sent = 1;
122          switch (ctx->getType ()) {          switch (ctx->getType ()) {
123          case GPG_EDITKEY_SIGN:      return "sign";          case GPG_EDITKEY_SIGN:    return "sign";
124          case GPG_EDITKEY_TSIGN:     return "tsign";          case GPG_EDITKEY_TSIGN:   return "tsign";
125          case GPG_EDITKEY_LSIGN:     return "lsign";          case GPG_EDITKEY_LSIGN:   return "lsign";
126          case GPG_EDITKEY_NRSIGN:    return"nrsign";          case GPG_EDITKEY_NRSIGN:  return "nrsign";
127          case GPG_EDITKEY_NRLSIGN:   return "nrlsign";          case GPG_EDITKEY_NRLSIGN: return "nrlsign";
128          }          }
129      }      }
130      if (!strcmp (key, "sign_uid.class")) {      if (!strcmp (key, "sign_uid.class")) {
# Line 133  cmd_sign_handler (GpgKeyEdit *ctx, gpgme Line 134  cmd_sign_handler (GpgKeyEdit *ctx, gpgme
134      if (!strcmp (key, "sign_uid.expire"))      if (!strcmp (key, "sign_uid.expire"))
135          return "Y"; /* the sig expires when the key expires */          return "Y"; /* the sig expires when the key expires */
136      if (!strcmp (key, "siggen.valid"))      if (!strcmp (key, "siggen.valid"))
137          return ctx->exp_date;          return ctx->exp_date? ctx->exp_date : "0";
138      if (!strcmp (key, "trustsig_prompt.trust_value")) {      if (!strcmp (key, "trustsig_prompt.trust_value")) {
139          sprintf (buf, "%d", ctx->trust_id);          sprintf (buf, "%d", ctx->trust_id);
140          return buf;          return buf;
# Line 298  cmd_delkey_handler (GpgKeyEdit *ctx, gpg Line 299  cmd_delkey_handler (GpgKeyEdit *ctx, gpg
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    
# Line 341  cmd_passwd_handler (GpgKeyEdit *ctx, gpg Line 377  cmd_passwd_handler (GpgKeyEdit *ctx, gpg
377      }      }
378      if (ctx->cnt == 0 && !strcmp (key, "passphrase.enter")) {      if (ctx->cnt == 0 && !strcmp (key, "passphrase.enter")) {
379          ctx->cnt = 1;          ctx->cnt = 1;
380            /* it is possible that there is no old passphrase. */
381            if (!ctx->pass && ctx->flags)
382                return "";
383          return ctx->pass;          return ctx->pass;
384      }      }
385      if (!strcmp (key, "passphrase.enter" ))      if (!strcmp (key, "passphrase.enter" ))
# Line 357  cmd_passwd_handler (GpgKeyEdit *ctx, gpg Line 396  cmd_passwd_handler (GpgKeyEdit *ctx, gpg
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];      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      }      }
422  #endif      return buf;
     return NULL;  
423  }  }
424    
425    
# Line 396  cmd_primary_handler (GpgKeyEdit *ctx, gp Line 429  cmd_primary_handler (GpgKeyEdit *ctx, gp
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;
# Line 721  editkey_command_handler (void *opaque, g Line 754  editkey_command_handler (void *opaque, g
754          break;          break;
755    
756      case GPGME_STATUS_BAD_PASSPHRASE:      case GPGME_STATUS_BAD_PASSPHRASE:
757            log_debug ("editkey_command_handler: bad passphrase\n");
758          ke->setResult (EDITKEY_ERR_BAD_PASSPHRASE);          ke->setResult (EDITKEY_ERR_BAD_PASSPHRASE);
759          break;          break;
760    
# Line 761  editkey_command_handler (void *opaque, g Line 795  editkey_command_handler (void *opaque, g
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:
# Line 769  editkey_command_handler (void *opaque, g Line 803  editkey_command_handler (void *opaque, g
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:

Legend:
Removed from v.207  
changed lines
  Added in v.260

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26