107 |
static const char * |
static const char * |
108 |
cmd_keyserv_handler (gpgme_editkey_t ctx, gpg_status_code_t code, const char * key) |
cmd_keyserv_handler (gpgme_editkey_t ctx, gpg_status_code_t code, const char * key) |
109 |
{ |
{ |
|
if( do_check( code, GET_LINE, key, "keyedit.prompt" ) ) |
|
|
|
|
110 |
if (do_check (code, GET_LINE, key, "keyedit.add_keyserver")) |
if (do_check (code, GET_LINE, key, "keyedit.add_keyserver")) |
111 |
return ctx->u.keyserv.url; |
return ctx->u.keyserv.url; |
112 |
if (do_check (code, GET_BOOL, key, "keyedit.confirm_keyserver")) |
if (do_check (code, GET_BOOL, key, "keyedit.confirm_keyserver")) |
647 |
|
|
648 |
case GPGME_EDITKEY_SETPREF: |
case GPGME_EDITKEY_SETPREF: |
649 |
return cmd_setpref_handler (ctx, code, key); |
return cmd_setpref_handler (ctx, code, key); |
650 |
|
|
651 |
|
case GPGME_EDITKEY_KEYSERV: |
652 |
|
return cmd_keyserv_handler (ctx, code, key); |
653 |
} |
} |
654 |
|
|
655 |
return NULL; |
return NULL; |
702 |
break; |
break; |
703 |
|
|
704 |
case GPGME_EDITKEY_LSIGN: |
case GPGME_EDITKEY_LSIGN: |
705 |
_gpgme_gpg_add_arg( ctx->gpg, "lsign" ); |
_gpgme_gpg_add_arg (ctx->gpg, "lsign"); |
706 |
break; |
break; |
707 |
|
|
708 |
case GPGME_EDITKEY_NRSIGN: |
case GPGME_EDITKEY_NRSIGN: |
718 |
break; |
break; |
719 |
|
|
720 |
case GPGME_EDITKEY_ADDKEY: |
case GPGME_EDITKEY_ADDKEY: |
721 |
_gpgme_gpg_add_arg( ctx->gpg, "addkey" ); |
_gpgme_gpg_add_arg (ctx->gpg, "addkey"); |
722 |
break; |
break; |
723 |
|
|
724 |
case GPGME_EDITKEY_DELUID: |
case GPGME_EDITKEY_DELUID: |
858 |
if (!inf) |
if (!inf) |
859 |
return; |
return; |
860 |
list = inf->list; |
list = inf->list; |
861 |
while (list) |
while (list) { |
|
{ |
|
862 |
i = list->next; |
i = list->next; |
863 |
if (list->name) |
if (list->name) { |
|
{ |
|
864 |
safe_free (list->name); |
safe_free (list->name); |
865 |
list->name = NULL; |
list->name = NULL; |
866 |
} |
} |
867 |
if (list->prefs) |
if (list->prefs) { |
|
{ |
|
868 |
safe_free (list->prefs); |
safe_free (list->prefs); |
869 |
list->prefs = NULL; |
list->prefs = NULL; |
870 |
} |
} |
879 |
{ |
{ |
880 |
char *p, *pend; |
char *p, *pend; |
881 |
int field = 0, len = 0; |
int field = 0, len = 0; |
882 |
struct user_id_info_s *i; |
struct user_id_info_s *i, *t; |
883 |
|
|
884 |
if (!line || strlen (line) < 3 || strncmp (line, "uid", 3)) |
if (!line || strlen (line) < 3 || strncmp (line, "uid", 3)) |
885 |
return; |
return; |
886 |
|
|
887 |
i = calloc( 1, sizeof *i ); |
i = calloc (1, sizeof *i); |
888 |
if( i == NULL ) |
if (!i) |
889 |
return; |
return; |
890 |
i->next = inf->list; |
if (!inf->list) |
891 |
inf->list = i; |
inf->list = i; |
892 |
|
else { |
893 |
|
for (t=inf->list; t->next; t=t->next) |
894 |
|
; |
895 |
|
t->next = i; |
896 |
|
} |
897 |
|
|
898 |
p = strdup( line ); |
p = strdup (line); |
899 |
if( p == NULL ) |
if (!p) |
900 |
return; |
return; |
901 |
while( 1 ) { |
while (1) { |
902 |
field++; |
field++; |
903 |
pend = strsep (&p, ":"); |
pend = strsep (&p, ":"); |
904 |
if (pend == NULL) |
if (pend == NULL) |
905 |
break; |
break; |
906 |
|
|
907 |
switch (field) |
switch (field) { |
|
{ |
|
908 |
case 2: /* trust info */ |
case 2: /* trust info */ |
909 |
break; |
break; |
910 |
|
|
912 |
i->name = calloc (1, strlen (pend)+1); |
i->name = calloc (1, strlen (pend)+1); |
913 |
if (!i->name) |
if (!i->name) |
914 |
return; |
return; |
915 |
_gpgme_decode_c_string (pend, &i->name, strlen (pend)+ 1); |
_gpgme_decode_c_string (pend, &i->name, strlen (pend)+ 1); |
916 |
|
if (strchr (pend, '<') != NULL) { |
917 |
|
int pos = strchr (i->name, '<')- i->name + 1; |
918 |
|
int end = strchr (i->name, '>') - i->name; |
919 |
|
i->email = calloc (1, end-pos+2); |
920 |
|
if (!i->email) |
921 |
|
return; |
922 |
|
memcpy (i->email, i->name+pos, (end-pos)); |
923 |
|
} |
924 |
break; |
break; |
925 |
|
|
926 |
case 13: /* preferences */ |
case 13: /* preferences */ |
927 |
if (strstr (pend, "mdc")) |
if (strstr (pend, "mdc")) { |
|
{ |
|
928 |
len = strlen (pend) - 4; /* ,mdc */ |
len = strlen (pend) - 4; /* ,mdc */ |
929 |
if (strstr (pend, "no-ks-modify")) |
if (strstr (pend, "no-ks-modify")) { |
|
{ |
|
930 |
i->flags.no_ks_modify = 1; |
i->flags.no_ks_modify = 1; |
931 |
len -= 13; /* ,no-ks-modify */ |
len -= 13; /* ,no-ks-modify */ |
932 |
} |
} |
933 |
i->prefs = calloc (1, len); |
i->prefs = calloc (1, len+1); |
934 |
if (!i->prefs) |
if (!i->prefs) |
935 |
return; |
return; |
936 |
memcpy (i->prefs, pend, len); |
memcpy (i->prefs, pend, len); |
941 |
i->prefs = strdup (pend); |
i->prefs = strdup (pend); |
942 |
if (!i->prefs) |
if (!i->prefs) |
943 |
return; |
return; |
944 |
i->flags.mdc = 0; |
i->flags.mdc = 0; |
945 |
} |
} |
946 |
break; |
break; |
947 |
|
|
948 |
case 14: /* idx/flags */ |
case 14: /* idx/flags */ |
949 |
i->idx = atol( pend ); |
i->idx = atol (pend); |
950 |
if( strchr( pend, 'r' ) ) |
if (strchr (pend, 'r')) |
951 |
i->flags.revoked = 1; |
i->flags.revoked = 1; |
952 |
if( strchr( pend, 'p' ) ) |
if (strchr( pend, 'p')) |
953 |
i->flags.primary = 1; |
i->flags.primary = 1; |
954 |
break; |
break; |
955 |
} |
} |
956 |
} |
} |
957 |
safe_free( p ); |
safe_free (p); |
958 |
} /* edit_key_colon_handler */ |
} /* edit_key_colon_handler */ |
959 |
|
|
960 |
|
|
961 |
static gpgme_error_t |
static gpgme_error_t |
962 |
editkey_get_info_start( gpgme_ctx_t ctx, const char *keyid, gpgme_data_t out ) |
editkey_get_info_start (gpgme_ctx_t ctx, const char *keyid, gpgme_data_t out) |
963 |
{ |
{ |
964 |
gpgme_error_t rc; |
gpgme_error_t rc; |
965 |
|
|
1009 |
return err; |
return err; |
1010 |
|
|
1011 |
err = editkey_get_info_start( ctx, keyid, out ); |
err = editkey_get_info_start( ctx, keyid, out ); |
1012 |
if( !err ) |
if (!err) { |
1013 |
{ |
gpgme_wait (ctx, 1); |
|
gpgme_wait( ctx, 1 ); |
|
1014 |
ctx->pending = 0; |
ctx->pending = 0; |
1015 |
} |
} |
1016 |
if (err) |
if (err) |
1017 |
return err; |
return err; |
1018 |
|
|
1019 |
err = gpgme_uid_info_new( &inf ); |
err = gpgme_uid_info_new (&inf); |
1020 |
if (err) |
if (err) |
1021 |
return err; |
return err; |
1022 |
|
|
1095 |
|
|
1096 |
|
|
1097 |
const char* |
const char* |
1098 |
gpgme_editkey_get_string_attr( gpgme_uidinfo_t inf, int what, int idx ) |
gpgme_editkey_get_string_attr (gpgme_uidinfo_t inf, int what, int idx) |
1099 |
{ |
{ |
1100 |
const char *val; |
const char *val=NULL; |
1101 |
struct user_id_info_s *i; |
struct user_id_info_s *i; |
1102 |
|
|
1103 |
if( !inf ) |
if( !inf ) |
1105 |
|
|
1106 |
switch( what ) { |
switch( what ) { |
1107 |
case GPGME_ATTR_NAME: |
case GPGME_ATTR_NAME: |
1108 |
for( i = inf->list; i && idx; i = i->next, idx-- ) |
for (i = inf->list; i && idx; i = i->next, idx--) |
1109 |
; |
; |
1110 |
if( i ) |
if (i) |
1111 |
val = i->name; |
val = i->name; |
1112 |
break; |
break; |
1113 |
|
|
1114 |
|
case GPGME_ATTR_EMAIL: |
1115 |
|
for (i=inf->list; i && idx; i = i->next, idx--) |
1116 |
|
; |
1117 |
|
if (i) |
1118 |
|
val = i->email; |
1119 |
|
break; |
1120 |
|
|
1121 |
case GPGME_ATTR_UID_PREFS: |
case GPGME_ATTR_UID_PREFS: |
1122 |
for( i = inf->list; i && idx; i = i->next, idx-- ) |
for (i = inf->list; i && idx; i = i->next, idx--) |
1123 |
; |
; |
1124 |
if( i ) |
if (i) |
1125 |
val = i->prefs; |
val = i->prefs; |
1126 |
break; |
break; |
1127 |
|
|