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

Diff of /trunk/Src/wptKeyEdit.cpp

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

revision 169 by twoaday, Fri Dec 30 13:56:10 2005 UTC revision 170 by twoaday, Mon Jan 30 12:42:57 2006 UTC
# Line 1  Line 1 
1  /* wptKeyEdit.cpp - GPG key edit abstraction  /* wptKeyEdit.cpp - GPG key edit abstraction
2   *      Copyright (C) 2005 Timo Schulz   *      Copyright (C) 2005, 2006 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.
# Line 224  list2_handler (void *opaque, gpgme_statu Line 224  list2_handler (void *opaque, gpgme_statu
224      return 0;      return 0;
225  }  }
226    
227    
228  /* Dummy handler to get the colon data and then quit. */  /* Dummy handler to get the colon data and then quit. */
229  static gpgme_error_t  static gpgme_error_t
230  list_handler (void *opaque, gpgme_status_code_t code, const char *key, int fd)  list_handler (void *opaque, gpgme_status_code_t code, const char *key, int fd)
# Line 284  leave: Line 285  leave:
285      return err;      return err;
286  }  }
287    
288    
289  /* Retrieve all user ID information of the key set via setKey  /* Retrieve all user ID information of the key set via setKey
290     in @r_inf. The result also contains the user ID number which     in @r_inf. The result also contains the user ID number which
291     is needed to securely delete the user-ID. */     is needed to securely delete the user-ID. */
# Line 323  leave: Line 325  leave:
325  }  }
326    
327    
328  /* Construct an object with the given key in @key. */  /* Clear object. */
329  GpgKeyEdit::GpgKeyEdit (gpgme_key_t _key)  void
330    GpgKeyEdit::clear (void)
331  {  {
332      this->key = _key;      pass = NULL;    
     pass = NULL;  
     type = 0;  
333      name = NULL;      name = NULL;
334      cmt = NULL;      cmt = NULL;
335      email = NULL;      email = NULL;
336        type = 0;
337      cnt = 0;      cnt = 0;
338      cmd_sent = 0;      cmd_sent = 0;
339      resval = 0;      resval = 0;
340        uid_index = sig_index = key_index = -1;
341    }
342    
343    
344    /* Construct an object with the given key in @key. */
345    GpgKeyEdit::GpgKeyEdit (gpgme_key_t _key)
346    {
347        clear ();
348        this->key = _key;
349      gpgme_new (&ctx); /* FIXME */      gpgme_new (&ctx); /* FIXME */
350  }  }
351    
352  /* Construct an object and fetch the key with the keyid @keyid. */  /* Construct an object and fetch the key with the keyid @keyid. */
353  GpgKeyEdit::GpgKeyEdit (const char *_keyid)  GpgKeyEdit::GpgKeyEdit (const char *_keyid)
354  {  {
355        clear ();
356      get_pubkey (_keyid, &this->key);      get_pubkey (_keyid, &this->key);
357      pass = NULL;      gpgme_new (&ctx); /* FIXME */    
     type = 0;  
     name = NULL;  
     cmt = NULL;  
     cnt = 0;  
     email = NULL;  
     cmd_sent = 0;  
     resval = 0;  
     gpgme_new (&ctx); /* FIXME */  
358  }  }
359    
360  /* Delete the given object. */  /* Delete the given object. */
# Line 466  GpgKeyEdit::signKey (int mode, int _sig_ Line 470  GpgKeyEdit::signKey (int mode, int _sig_
470      return gpg_editkey (this->ctx, this->key, this);      return gpg_editkey (this->ctx, this->key, this);
471  }  }
472    
473    
474    /* Sign a single user-id with the index @_uid_index.
475       All other parameters are equal to signKey().
476       Return value: 0 on success. */
477    gpgme_error_t
478    GpgKeyEdit::signUserid (int _uid_idx, int mode, int _sig_class,
479                            const char *_exp_date)
480    {
481        if (!this->key || !this->pass)
482            return gpg_error (GPG_ERR_INV_OBJ);
483        this->uid_index = _uid_idx;
484        type = mode;
485        this->exp_date = _exp_date;
486        this->sig_class = _sig_class;
487        return gpg_editkey (this->ctx, this->key, this);
488    }
489    
490    
491  /* Set the ownertrust of the key stored in the object  /* Set the ownertrust of the key stored in the object
492     to the trust value @trust.     to the trust value @trust.
493     Return value: 0 on success. */     Return value: 0 on success. */
# Line 754  GpgKeyEdit::setPreferredKeyserver (int _ Line 776  GpgKeyEdit::setPreferredKeyserver (int _
776      this->uid_index = _uid_index;      this->uid_index = _uid_index;
777      return gpg_editkey (this->ctx, this->key, this);      return gpg_editkey (this->ctx, this->key, this);
778  }  }
779    
780    
781    /* Return the saved user-id index. */
782    int
783    GpgKeyEdit::getUseridIndex (void)
784    {
785        return uid_index;
786    }
787    
788    
789    /* Return the saved key index. */  
790    int
791    GpgKeyEdit::getKeyIndex (void)
792    {
793        return key_index;
794    }
795    
796    
797    /* Return the saved sig index. */
798    int
799    GpgKeyEdit::getSigIndex (void)
800    {
801        return sig_index;
802    }

Legend:
Removed from v.169  
changed lines
  Added in v.170

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26