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

Annotation of /trunk/Src/wptKeyEdit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 129 - (hide annotations)
Fri Dec 30 13:56:10 2005 UTC (19 years, 2 months ago) by twoaday
File size: 17960 byte(s)
2005-12-27  Timo Schulz  <ts@g10code.com>
                                                                                
        * wptListView.cpp (listview_set_view): New.
        (listview_del_column): New.
        * wptW32API.cpp (get_locale_date): New.
        (get_menu_state): New.
        (force_foreground_window): New.
        * wptVerifyList.cpp (strtimestamp): Support for
        locale date formats.
        * wptGPGUtil.cpp (gpg_revoke_cert): Handle bad
        passphrases.
        * wptKeyEditCB.cpp (editkey_command_handler): Immediately
        return when a bad passphrase was submitted.
        * wptKeyRevokersDlg.cpp (keyrevokers_dlg_proc): Change
        column order.
        * wptKeylist.cpp (keylist_upd_col): New.
        * wptKeyManagerDlg.cpp (update_ui_items): Deactivate
        'Revocation' for public keys.
        (translate_menu_strings): s/Revoke/Revoke Cert.
        (modify_listview_columns): New.


1 werner 36 /* wptKeyEdit.cpp - GPG key edit abstraction
2     * Copyright (C) 2005 Timo Schulz
3     * Copyright (C) 2005 g10 Code GmbH
4     *
5     * This file is part of WinPT.
6     *
7     * WinPT is free software; you can redistribute it and/or
8     * modify it under the terms of the GNU General Public License
9     * as published by the Free Software Foundation; either version 2
10     * of the License, or (at your option) any later version.
11     *
12     * WinPT is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     * General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with WinPT; if not, write to the Free Software Foundation,
19     * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20     */
21    
22     #ifdef HAVE_CONFIG_H
23     #include <config.h>
24     #endif
25    
26     #include <windows.h>
27 werner 48 #include <time.h>
28 werner 36
29     #include "gpgme.h"
30     #include "wptCommonCtl.h"
31     #include "wptContext.h"
32     #include "wptKeyEdit.h"
33     #include "wptTypes.h"
34     #include "wptW32API.h"
35     #include "wptGPG.h"
36     #include "wptErrors.h"
37    
38    
39     /* Parse the colon status information of @line and store
40     the information in @rev.
41     Return value: 0 on success. */
42     static gpgme_error_t
43     rev_key_colon_handler (gpg_desig_rev_t *rev, char *line)
44     {
45     char *p, *pend;
46     gpg_desig_rev_t r, t;
47     int field = 0;
48    
49     if (!line || strlen (line) < 3)
50     return gpg_error (GPG_ERR_EOF);
51     if (strncmp (line, "rvk", 3))
52     return 0; /* skip this line. */
53    
54     log_debug ("rev_key: line=%s\r\n", line);
55    
56     r = (gpg_desig_rev_t)calloc (1, sizeof *r);
57     if (!r)
58     return gpg_error (GPG_ERR_ENOMEM);
59     if (!*rev)
60     *rev = r;
61     else {
62     for (t=*rev; t->next; t=t->next)
63     ;
64     t->next = r;
65     }
66    
67     p = strdup (line);
68     if (!p)
69     return gpg_error (GPG_ERR_ENOMEM);
70    
71     for (;;) {
72     field++;
73     pend = strsep (&p, ":");
74     if (pend == NULL)
75     break;
76     switch (field) {
77     case 4: r->pubkey_algo = (gpgme_pubkey_algo_t)atol (pend); break;
78     case 10: strncpy (r->fpr, pend, 40); r->fpr[40] = 0; break;
79     }
80     }
81     if (p)
82     free (p);
83     return 0;
84     }
85    
86    
87     /* Parse the colon data output of edit key from @line and
88     store the information in the @inf context.
89     Return value: 0 on success. */
90     static gpgme_error_t
91     uid_inf_colon_handler (gpg_uid_info_t *inf, char *line)
92     {
93     gpg_uid_info_t i, t;
94     char *p, *pend;
95     int field = 0, len = 0;
96    
97     if (!line || strlen (line) < 3 || strncmp (line, "uid", 3))
98     return gpg_error (GPG_ERR_EOF);
99    
100     i = (gpg_uid_info_t)calloc (1, sizeof *i);
101     if (!i)
102     return gpg_error (GPG_ERR_ENOMEM);
103     if (!*inf)
104     *inf = i;
105     else {
106     for (t=*inf; t->next; t=t->next)
107     ;
108     t->next = i;
109     }
110    
111     p = strdup (line);
112     if (!p)
113     return gpg_error (GPG_ERR_ENOMEM);;
114     for (;;) {
115     field++;
116     pend = strsep (&p, ":");
117     if (pend == NULL)
118     break;
119    
120     switch (field) {
121     case 2: /* trust info */
122     break;
123    
124     case 10: /* user ID */
125     i->name = (char *)calloc (1, strlen (pend)+1);
126     if (!i->name)
127     return gpg_error (GPG_ERR_ENOMEM);;
128     gpg_decode_c_string (pend, &i->name, strlen (pend)+ 1);
129     if (strchr (pend, '<') != NULL && strchr (pend, '>') != NULL) {
130     int pos = strchr (i->name, '<')- i->name + 1;
131     int end = strchr (i->name, '>') - i->name;
132     i->email = (char*) calloc (1, end-pos+2);
133     if (!i->email)
134     return gpg_error (GPG_ERR_ENOMEM);;
135     memcpy (i->email, i->name+pos, (end-pos));
136     }
137     break;
138    
139     case 13: /* preferences */
140     if (strstr (pend, "mdc")) {
141     len = strlen (pend) - 4; /* ,mdc */
142     if (strstr (pend, "no-ks-modify")) {
143     i->flags.no_ks_modify = 1;
144     len -= 13; /* ,no-ks-modify */
145     }
146     i->prefs = (char*)calloc (1, len+1);
147     if (!i->prefs)
148     return gpg_error (GPG_ERR_ENOMEM);
149     memcpy (i->prefs, pend, len);
150     i->prefs[len] = '\0';
151     i->flags.mdc = 1;
152     }
153     else {
154     i->prefs = strdup (pend);
155     if (!i->prefs)
156     return gpg_error (GPG_ERR_ENOMEM);
157     i->flags.mdc = 0;
158     }
159     break;
160    
161     case 14: /* index/flags */
162     i->index = atol (pend);
163     if (strchr (pend, 'r'))
164     i->flags.revoked = 1;
165     if (strchr (pend, 'p'))
166     i->flags.primary = 1;
167     break;
168     }
169     }
170     if (p)
171     free (p);
172     return 0;
173     }
174    
175    
176     /* Release the context in @inf. */
177     void
178     gpg_uid_info_release (gpg_uid_info_t list)
179     {
180     gpg_uid_info_t i;
181    
182     while (list) {
183     i = list->next;
184     if (list->name) {
185     if (list->name)
186     free (list->name);
187     list->name = NULL;
188     }
189     if (list->prefs) {
190     if (list->prefs)
191     free (list->prefs);
192     list->prefs = NULL;
193     }
194     free (list);
195     list = i;
196     }
197     }
198    
199    
200     /* Release the context in @rev. */
201     void
202     gpg_desig_rev_release (gpg_desig_rev_t rev)
203     {
204     gpg_desig_rev_t r;
205    
206     while (rev) {
207     r = rev->next;
208     free (rev);
209     rev = r;
210     }
211     }
212    
213    
214     static gpgme_error_t
215     list2_handler (void *opaque, gpgme_status_code_t code, const char *key, int fd)
216     {
217     DWORD n;
218     const char *s;
219    
220     if (!strcmp (key, "keyedit.prompt")) {
221     s = "quit\n";
222     WriteFile ((HANDLE)fd, s, strlen (s), &n, NULL);
223     }
224     return 0;
225     }
226    
227     /* Dummy handler to get the colon data and then quit. */
228     static gpgme_error_t
229     list_handler (void *opaque, gpgme_status_code_t code, const char *key, int fd)
230     {
231     static int step=0;
232     const char *s="";
233     DWORD n;
234    
235     if (!strcmp (key, "keyedit.prompt") && step == 0) {
236     step = 1;
237     s = "list\n";
238     WriteFile ((HANDLE)fd, s, strlen (s), &n, NULL);
239     }
240     else if (!strcmp (key, "keyedit.prompt") && step == 1) {
241     step = 0;
242     s = "quit\n";
243     WriteFile ((HANDLE)fd, s, strlen (s), &n, NULL);
244     }
245    
246     return 0;
247     }
248    
249    
250     /* Return all designated revokers for this key. If no revoker
251     was set, @r_rev is NULL.
252     Return value: 0 on success. */
253     gpgme_error_t
254     GpgKeyEdit::getDesignatedRevoker (gpg_desig_rev_t *r_rev)
255     {
256 twoaday 129 gpgme_data_t out = NULL;
257 werner 36 gpg_desig_rev_t rev = NULL;
258     gpgme_error_t err;
259     char buf[256];
260    
261     if (!this->key)
262     return gpg_error (GPG_ERR_INV_OBJ);
263    
264     err = gpgme_data_new (&out);
265     if (err)
266     goto leave;
267    
268     err = gpgme_op_edit (ctx, key, list2_handler, NULL, out);
269     if (err)
270     goto leave;
271    
272     gpgme_data_rewind (out);
273     while (gpg_data_readline (out, buf, sizeof (buf)-1) > 0)
274     rev_key_colon_handler (&rev, buf);
275     *r_rev = rev;
276    
277     leave:
278     if (out)
279     gpgme_data_release (out);
280     if (err) {
281     gpg_desig_rev_release (rev);
282     *r_rev = NULL;
283     }
284     return err;
285     }
286    
287     /* Retrieve all user ID information of the key set via setKey
288     in @r_inf. The result also contains the user ID number which
289     is needed to securely delete the user-ID. */
290     gpgme_error_t
291     GpgKeyEdit::getUseridInfo (gpg_uid_info_t *r_uinf)
292     {
293     gpgme_data_t out = NULL;
294     gpgme_error_t err;
295     gpg_uid_info_t inf = NULL;
296     char buf[256];
297    
298     if (!this->key)
299     return gpg_error (GPG_ERR_INV_OBJ);
300    
301     err = gpgme_data_new (&out);
302     if (err)
303     goto leave;
304    
305     err = gpgme_op_edit (ctx, key, list_handler, NULL, out);
306     if (err)
307     goto leave;
308    
309     gpgme_data_rewind (out);
310     while (gpg_data_readline (out, buf, sizeof (buf) -1) > 0)
311     uid_inf_colon_handler (&inf, buf);
312    
313     *r_uinf = inf;
314    
315     leave:
316     if (out)
317     gpgme_data_release (out);
318     if (err) {
319     gpg_uid_info_release (inf);
320     *r_uinf = NULL;
321     }
322     return err;
323     }
324    
325    
326     /* Construct an object with the given key in @key. */
327 twoaday 77 GpgKeyEdit::GpgKeyEdit (gpgme_key_t _key)
328 werner 36 {
329 twoaday 77 this->key = _key;
330 werner 36 pass = NULL;
331     type = 0;
332     name = NULL;
333     cmt = NULL;
334     email = NULL;
335     cnt = 0;
336     cmd_sent = 0;
337     resval = 0;
338     gpgme_new (&ctx); /* FIXME */
339     }
340    
341     /* Construct an object and fetch the key with the keyid @keyid. */
342 twoaday 69 GpgKeyEdit::GpgKeyEdit (const char *_keyid)
343 werner 36 {
344 twoaday 69 get_pubkey (_keyid, &this->key);
345 werner 36 pass = NULL;
346     type = 0;
347     name = NULL;
348     cmt = NULL;
349 twoaday 129 cnt = 0;
350 werner 36 email = NULL;
351     cmd_sent = 0;
352     resval = 0;
353     gpgme_new (&ctx); /* FIXME */
354     }
355    
356     /* Delete the given object. */
357     GpgKeyEdit::~GpgKeyEdit (void)
358     {
359     free_if_alloc (name);
360     free_if_alloc (cmt);
361     free_if_alloc (email);
362     gpgme_release (ctx);
363     }
364    
365    
366     /* Reset the state of the object. */
367     void
368     GpgKeyEdit::reset (void)
369     {
370     cmd_sent = 0;
371 twoaday 129 cnt = 0;
372     //resval = 0;
373 werner 36 }
374    
375    
376     /* Return true if type has a non-zero value. */
377     bool
378     GpgKeyEdit::isValid (void)
379     {
380     return type != 0;
381     }
382    
383    
384     /* Return the GPGME key. */
385     gpgme_key_t
386     GpgKeyEdit::getKey (void)
387     {
388     return key;
389     }
390    
391    
392     /* Set the GPGME callback to @cb. The hook value can be
393     given in @cb_value. */
394     void
395     GpgKeyEdit::setCallback (gpgme_progress_cb_t cb, void *cb_value)
396     {
397     gpgme_set_progress_cb (ctx, cb, cb_value);
398     }
399    
400     /* Set the passphrase to @pass. */
401     void
402 twoaday 69 GpgKeyEdit::setPassphrase (const char *_pass)
403 werner 36 {
404 twoaday 69 this->pass = _pass;
405 werner 36 }
406    
407     /* Set the current key to @key. */
408     void
409 twoaday 69 GpgKeyEdit::setKey (gpgme_key_t _key)
410 werner 36 {
411 twoaday 69 this->key = _key;
412 werner 36 }
413    
414     /* Set the keyid of the destination key to @keyid. */
415     void
416 twoaday 69 GpgKeyEdit::setKeyID (const char *_keyid)
417 werner 36 {
418 twoaday 69 if (!_keyid)
419 werner 36 return;
420 twoaday 69 get_pubkey (_keyid, &this->key);
421 werner 36 }
422    
423    
424     /* Set the local user for the operation to @locusr. */
425     void
426     GpgKeyEdit::setLocalUser (gpgme_key_t locusr)
427     {
428     gpgme_signers_add (ctx, locusr);
429     }
430    
431     /* Set the result of the operation to @val. */
432     void
433     GpgKeyEdit::setResult (int val)
434     {
435     resval |= val;
436     }
437    
438    
439     /* Return the result of the operation. */
440     int
441     GpgKeyEdit::getResult(void)
442     {
443     return resval;
444     }
445    
446    
447    
448     int
449     GpgKeyEdit::getType (void)
450     {
451     return type;
452     }
453    
454     /* Sign the key stored in the object with the
455     signing mode @mode and the signature class @sig_class.
456     Return value: 0 on success. */
457     gpgme_error_t
458 twoaday 69 GpgKeyEdit::signKey (int mode, int _sig_class, const char *_exp_date)
459 werner 36 {
460     if (!this->key || !this->pass)
461     return gpg_error (GPG_ERR_INV_OBJ);
462    
463     type = mode;
464 twoaday 69 this->exp_date = _exp_date;
465     this->sig_class = _sig_class;
466 werner 36 return gpg_editkey (this->ctx, this->key, this);
467     }
468    
469     /* Set the ownertrust of the key stored in the object
470     to the trust value @trust.
471     Return value: 0 on success. */
472     gpgme_error_t
473     GpgKeyEdit::setTrust (gpgme_validity_t trust)
474     {
475     if (!this->key)
476     return gpg_error (GPG_ERR_INV_OBJ);
477    
478     type = GPG_EDITKEY_TRUST;
479     this->trust_id = (int)trust;
480     return gpg_editkey (this->ctx, this->key, this);
481     }
482    
483     /* Add a user ID to the given key with the @name as the
484     name, @cmt as the comment (or NULL) and @email as the email.
485     Return value: 0 on success. */
486     gpgme_error_t
487 twoaday 77 GpgKeyEdit::addUserid (const char *_name, const char *_cmt, const char *_email)
488 werner 36 {
489     if (!this->key || !this->pass)
490     return gpg_error (GPG_ERR_INV_OBJ);
491    
492     type = GPG_EDITKEY_ADDUID;
493     free_if_alloc (this->name);
494 twoaday 77 this->name = m_strdup (_name);
495 werner 36 free_if_alloc (this->cmt);
496     this->cmt = NULL;
497 twoaday 129 if (_cmt != NULL)
498 twoaday 77 this->cmt = m_strdup (_cmt);
499 werner 36 free_if_alloc (this->email);
500 twoaday 77 this->email = m_strdup (_email);
501 werner 36 if (!this->email || !this->name)
502     BUG (NULL);
503     return gpg_editkey (this->ctx, this->key, this);
504     }
505    
506     /* Delete the user-ID with the index @uid_index of the given key.
507     Return value: 0 on success. */
508     gpgme_error_t
509 twoaday 69 GpgKeyEdit::delUserid (int _uid_index)
510 werner 36 {
511     if (!this->key)
512     return gpg_error (GPG_ERR_INV_OBJ);
513    
514     type = GPG_EDITKEY_DELUID;
515 twoaday 69 this->uid_index = _uid_index;
516 werner 36 return gpg_editkey (this->ctx, this->key, this);
517     }
518    
519     /* Delete the subkey with the index @key_index.
520     Return value: 0 on success. */
521     gpgme_error_t
522 twoaday 69 GpgKeyEdit::delKey (int _key_index)
523 werner 36 {
524     if (!this->key)
525     return gpg_error (GPG_ERR_INV_OBJ);
526    
527     type = GPG_EDITKEY_DELKEY;
528 twoaday 69 this->key_index = _key_index;
529 werner 36 return gpg_editkey (this->ctx, this->key, this);
530     }
531    
532     /* Add a new subkey to the given key.
533     The new key will have @pubkey_algo as the algorithm
534     and a size of @pubkey_size bits. If valid > 0, the
535     key expires in @valid days.
536     Return value: 0 on success. */
537     gpgme_error_t
538 twoaday 77 GpgKeyEdit::addSubkey (gpgme_pubkey_algo_t _pubkey_algo,
539     unsigned int _pubkey_size, long _valid)
540 werner 36 {
541     if (!this->key || !this->pass)
542     return gpg_error (GPG_ERR_INV_OBJ);
543    
544     type = GPG_EDITKEY_ADDKEY;
545 twoaday 77 this->pubkey_algo = _pubkey_algo;
546     this->pubkey_size = _pubkey_size;
547     this->valid = _valid;
548 werner 36 return gpg_editkey (this->ctx, this->key, this);
549     }
550    
551     /* Change the passphrase of the given key to @new_pass.
552     If allow_empty != 0, it is allowed to provide an empty passphrase.
553     Return value: 0 on success. */
554     gpgme_error_t
555 twoaday 69 GpgKeyEdit::changePassphrase (const char *_new_pass, int allow_empty)
556 werner 36 {
557     if (!this->key || !this->pass)
558     return gpg_error (GPG_ERR_INV_OBJ);
559    
560     type = GPG_EDITKEY_PASSWD;
561 twoaday 69 this->new_pass = _new_pass;
562 werner 36 this->flags = allow_empty? 1 : 0;
563     return gpg_editkey (this->ctx, this->key, this);
564     }
565    
566     /* Set the primary user-ID of the given key to user-ID with
567     the index @uid_index.
568     Return value: 0 on success. */
569     gpgme_error_t
570 twoaday 69 GpgKeyEdit::setPrimaryUserid (int _uid_index)
571 werner 36 {
572     if (!this->key || !this->pass)
573     return gpg_error (GPG_ERR_INV_OBJ);
574    
575     type = GPG_EDITKEY_PRIMARY;
576 twoaday 69 this->uid_index = _uid_index;
577 werner 36 return gpg_editkey (this->ctx, this->key, this);
578     }
579    
580     /* Set the expire date of the subkey with the index @key_index.
581     @exp_timestamp is used to calculate the days the key is valid.
582     if @exp_days is true, exp_timestamp is already converted to days.
583     Return value: 0 on success. */
584     gpgme_error_t
585 twoaday 129 GpgKeyEdit::setKeyExpireDate (int _key_index, long exp_timestamp,
586     bool exp_days)
587 werner 36 {
588     if (!this->key || !this->pass)
589     return gpg_error (GPG_ERR_INV_OBJ);
590     if (!exp_days && exp_timestamp > 0 && exp_timestamp < time (NULL))
591     return gpg_error (GPG_ERR_INV_ARG);
592    
593     type = GPG_EDITKEY_EXPIRE;
594     if (!exp_days && exp_timestamp > 0) {
595     valid = exp_timestamp - time (NULL);
596     valid /= 86400;
597     }
598     else
599     valid = exp_timestamp;
600 twoaday 69 this->key_index = _key_index;
601 werner 36 return gpg_editkey (this->ctx, this->key, this);
602     }
603    
604     /* Revoke the userid given by the index @uid_index.
605     Return value: 0 on success. */
606     gpgme_error_t
607 twoaday 69 GpgKeyEdit::revokeUserid (int _uid_index)
608 werner 36 {
609     if (!this->key || !this->pass)
610     return gpg_error (GPG_ERR_INV_OBJ);
611    
612     type = GPG_EDITKEY_REVUID;
613 twoaday 69 this->uid_index = _uid_index;
614 werner 36 return gpg_editkey (this->ctx, this->key, this);
615     }
616    
617    
618     /* Revoke a signature on the user-ID with the index @uid_index
619     and the signature index @sig_index.
620     Return value: 0 on success. */
621     gpgme_error_t
622 twoaday 69 GpgKeyEdit::revokeSignature (int _uid_index, int _sig_index)
623 werner 36 {
624     if (!this->key || !this->pass)
625     return gpg_error (GPG_ERR_INV_OBJ);
626    
627     type = GPG_EDITKEY_REVSIG;
628 twoaday 69 this->uid_index = _uid_index;
629     this->sig_index = _sig_index;
630 werner 36 return gpg_editkey (this->ctx, this->key, this);
631     }
632    
633    
634     /* Revoke the subkey with the index @key_index. Optionally
635     a reason can be provided in @reason with a text to describe
636     more details in @cmt.
637     Return value: 0 on success. */
638     gpgme_error_t
639 twoaday 69 GpgKeyEdit::revokeSubkey (int _key_index, int _reason, const char *_cmt)
640 werner 36 {
641     if (!this->key || !this->pass)
642     return gpg_error (GPG_ERR_INV_OBJ);
643    
644     type = GPG_EDITKEY_REVKEY;
645 twoaday 69 this->key_index = _key_index;
646     this->reason = _reason;
647 werner 36 free_if_alloc (this->cmt);
648     this->cmt = NULL;
649 twoaday 69 if (_cmt)
650     this->cmt = m_strdup (_cmt);
651 werner 36 return gpg_editkey (this->ctx, this->key, this);
652     }
653    
654    
655     /* Add a designated revoker to the key. @uid stores
656     the user-ID of the key who is allowed to be a
657     designated revoker.
658     Return value: 0 on success. */
659     gpgme_error_t
660     GpgKeyEdit::addDesignatedRevoker (const char *uid)
661     {
662     if (!this->key || !this->pass)
663     return gpg_error (GPG_ERR_INV_OBJ);
664    
665     type = GPG_EDITKEY_ADDREV;
666     free_if_alloc (this->name);
667     this->name = m_strdup (uid);
668     return gpg_editkey (this->ctx, this->key, this);
669     }
670    
671     /* Add a photo-ID to the key. The JPG image is given
672     in the file with the name @jpg_file.
673     Return value: 0 on success. */
674     gpgme_error_t
675     GpgKeyEdit::addPhotoid (const char *jpg_file)
676     {
677     if (!this->key || !this->pass)
678     return gpg_error (GPG_ERR_INV_OBJ);
679    
680     type = GPG_EDITKEY_ADDPHOTO;
681     this->url = jpg_file;
682     return gpg_editkey (this->ctx, this->key, this);
683     }
684    
685     /* Enable the given key. */
686     gpgme_error_t
687     GpgKeyEdit::enable (void)
688     {
689     if (!this->key)
690     return gpg_error (GPG_ERR_INV_OBJ);
691     type = GPG_EDITKEY_ENABLE;
692     return gpg_editkey (this->ctx, this->key, this);
693     }
694    
695     /* Disable the given key. */
696     gpgme_error_t
697     GpgKeyEdit::disable (void)
698     {
699     if (!this->key)
700     return gpg_error (GPG_ERR_INV_OBJ);
701     type = GPG_EDITKEY_DISABLE;
702     return gpg_editkey (this->ctx, this->key, this);
703     }
704    
705    
706 twoaday 119 /* Remove unusable parts from a key. */
707     gpgme_error_t
708     GpgKeyEdit::cleanKey (void)
709     {
710     if (!this->key)
711     return gpg_error (GPG_ERR_INV_OBJ);
712     type = GPG_EDITKEY_CLEAN;
713     return gpg_editkey (this->ctx, this->key, this);
714     }
715    
716    
717 werner 36 /* Update the user-ID preferences of the user-ID with the
718     index @uid_index to the prefs given in @new_prefs.
719     Return value: 0 on success. */
720     gpgme_error_t
721 twoaday 69 GpgKeyEdit::setUseridPreferences (int _uid_index, const char *new_prefs)
722 werner 36 {
723     if (!this->key || !this->pass)
724     return gpg_error (GPG_ERR_INV_OBJ);
725     return 0;
726     }
727    
728    
729     /* Delete a signature from the user-ID with the index @uid_index.
730     The index of the signature is given in @sig_index.
731     Return value: 0 on success. */
732     gpgme_error_t
733 twoaday 69 GpgKeyEdit::delUseridSignature (int _uid_index, int _sig_index)
734 werner 36 {
735     if (!this->key)
736     return gpg_error (GPG_ERR_INV_OBJ);
737     type = GPG_EDITKEY_DELSIG;
738 twoaday 69 this->uid_index = _uid_index;
739     this->sig_index = _sig_index;
740 werner 36 return gpg_editkey (this->ctx, this->key, this);
741     }
742    
743     /* Set the preferred keyserver for the given key to @url.
744     Return value: 0 on success. */
745     gpgme_error_t
746 twoaday 69 GpgKeyEdit::setPreferredKeyserver (int _uid_index, const char *_url)
747 werner 36 {
748     if (!this->key || !this->pass)
749     return gpg_error (GPG_ERR_INV_OBJ);
750     if (!url)
751     return gpg_error (GPG_ERR_INV_ARG);
752     type = GPG_EDITKEY_KEYSERV;
753 twoaday 69 this->url = _url;
754     this->uid_index = _uid_index;
755 werner 36 return gpg_editkey (this->ctx, this->key, this);
756     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26