mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
Allow uid sand key election using a '*'.
This commit is contained in:
parent
35ab964c86
commit
999a909708
@ -592,12 +592,12 @@ line.
|
|||||||
@item uid @code{n}
|
@item uid @code{n}
|
||||||
@opindex keyedit:uid
|
@opindex keyedit:uid
|
||||||
Toggle selection of user ID or photographic user ID with index @code{n}.
|
Toggle selection of user ID or photographic user ID with index @code{n}.
|
||||||
Use 0 to deselect all.
|
Use @code{*} to select all and @code{0} to deselect all.
|
||||||
|
|
||||||
@item key @code{n}
|
@item key @code{n}
|
||||||
@opindex keyedit:key
|
@opindex keyedit:key
|
||||||
Toggle selection of subkey with index @code{n}.
|
Toggle selection of subkey with index @code{n}.
|
||||||
Use 0 to deselect all.
|
Use @code{*} to select all and @code{0} to deselect all.
|
||||||
|
|
||||||
@item sign
|
@item sign
|
||||||
@opindex keyedit:sign
|
@opindex keyedit:sign
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2009-09-04 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* keyedit.c (menu_select_uid): Use IDX ==-1 t select all.
|
||||||
|
(menu_select_key): Ditto.
|
||||||
|
(keyedit_menu) <cmdSELKEY, cmdSELUID>: Allow '*' to select all.
|
||||||
|
|
||||||
2009-09-03 Werner Koch <wk@g10code.com>
|
2009-09-03 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* keyedit.c (menu_adduid): Pass keyblock to generate_user_id.
|
* keyedit.c (menu_adduid): Pass keyblock to generate_user_id.
|
||||||
|
137
g10/keyedit.c
137
g10/keyedit.c
@ -1,6 +1,6 @@
|
|||||||
/* keyedit.c - keyedit stuff
|
/* keyedit.c - keyedit stuff
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||||
* 2008 Free Software Foundation, Inc.
|
* 2008, 2009 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -1743,12 +1743,22 @@ keyedit_menu( const char *username, strlist_t locusr,
|
|||||||
if(strlen(arg_string)==NAMEHASH_LEN*2)
|
if(strlen(arg_string)==NAMEHASH_LEN*2)
|
||||||
redisplay=menu_select_uid_namehash(cur_keyblock,arg_string);
|
redisplay=menu_select_uid_namehash(cur_keyblock,arg_string);
|
||||||
else
|
else
|
||||||
redisplay=menu_select_uid(cur_keyblock,arg_number);
|
{
|
||||||
|
if (*arg_string == '*'
|
||||||
|
&& (!arg_string[1] || spacep (arg_string+1)))
|
||||||
|
arg_number = -1; /* Select all. */
|
||||||
|
redisplay = menu_select_uid (cur_keyblock, arg_number);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdSELKEY:
|
case cmdSELKEY:
|
||||||
if( menu_select_key( cur_keyblock, arg_number ) )
|
{
|
||||||
|
if (*arg_string == '*'
|
||||||
|
&& (!arg_string[1] || spacep (arg_string+1)))
|
||||||
|
arg_number = -1; /* Select all. */
|
||||||
|
if (menu_select_key( cur_keyblock, arg_number))
|
||||||
redisplay = 1;
|
redisplay = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdCHECK:
|
case cmdCHECK:
|
||||||
@ -4437,51 +4447,62 @@ menu_set_notation(const char *string,KBNODE pub_keyblock,KBNODE sec_keyblock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************
|
/*
|
||||||
* Select one user id or remove all selection if index is 0.
|
* Select one user id or remove all selection if IDX is 0 or select
|
||||||
* Returns: True if the selection changed;
|
* all if IDX is -1. Returns: True if the selection changed.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
menu_select_uid( KBNODE keyblock, int idx )
|
menu_select_uid (KBNODE keyblock, int idx)
|
||||||
{
|
{
|
||||||
KBNODE node;
|
KBNODE node;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* first check that the index is valid */
|
if (idx == -1) /* Select all. */
|
||||||
if( idx ) {
|
{
|
||||||
for( i=0, node = keyblock; node; node = node->next ) {
|
for (node = keyblock; node; node = node->next)
|
||||||
if( node->pkt->pkttype == PKT_USER_ID ) {
|
if (node->pkt->pkttype == PKT_USER_ID)
|
||||||
if( ++i == idx )
|
node->flag |= NODFLG_SELUID;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( !node ) {
|
|
||||||
tty_printf(_("No user ID with index %d\n"), idx );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { /* reset all */
|
|
||||||
for (node = keyblock; node; node = node->next) {
|
|
||||||
if( node->pkt->pkttype == PKT_USER_ID )
|
|
||||||
node->flag &= ~NODFLG_SELUID;
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* and toggle the new index */
|
else if (idx) /* Toggle. */
|
||||||
for( i=0, node = keyblock; node; node = node->next ) {
|
{
|
||||||
if( node->pkt->pkttype == PKT_USER_ID ) {
|
for (i=0, node = keyblock; node; node = node->next)
|
||||||
if( ++i == idx ) {
|
{
|
||||||
if( (node->flag & NODFLG_SELUID) )
|
if (node->pkt->pkttype == PKT_USER_ID)
|
||||||
|
if (++i == idx)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!node)
|
||||||
|
{
|
||||||
|
tty_printf (_("No user ID with index %d\n"), idx );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0, node = keyblock; node; node = node->next)
|
||||||
|
{
|
||||||
|
if (node->pkt->pkttype == PKT_USER_ID)
|
||||||
|
{
|
||||||
|
if (++i == idx)
|
||||||
|
{
|
||||||
|
if ((node->flag & NODFLG_SELUID))
|
||||||
node->flag &= ~NODFLG_SELUID;
|
node->flag &= ~NODFLG_SELUID;
|
||||||
else
|
else
|
||||||
node->flag |= NODFLG_SELUID;
|
node->flag |= NODFLG_SELUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else /* Unselect all */
|
||||||
|
{
|
||||||
|
for (node = keyblock; node; node = node->next)
|
||||||
|
if (node->pkt->pkttype == PKT_USER_ID)
|
||||||
|
node->flag &= ~NODFLG_SELUID;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Search in the keyblock for a uid that matches namehash */
|
/* Search in the keyblock for a uid that matches namehash */
|
||||||
static int
|
static int
|
||||||
menu_select_uid_namehash( KBNODE keyblock, const char *namehash )
|
menu_select_uid_namehash( KBNODE keyblock, const char *namehash )
|
||||||
@ -4523,48 +4544,56 @@ menu_select_uid_namehash( KBNODE keyblock, const char *namehash )
|
|||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Select secondary keys
|
* Select secondary keys
|
||||||
* Returns: True if the selection changed;
|
* Returns: True if the selection changed.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
menu_select_key( KBNODE keyblock, int idx )
|
menu_select_key (KBNODE keyblock, int idx)
|
||||||
{
|
{
|
||||||
KBNODE node;
|
KBNODE node;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* first check that the index is valid */
|
if (idx == -1) /* Select all. */
|
||||||
if( idx ) {
|
{
|
||||||
for( i=0, node = keyblock; node; node = node->next ) {
|
for (node = keyblock; node; node = node->next)
|
||||||
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY)
|
||||||
if( ++i == idx )
|
node->flag |= NODFLG_SELKEY;
|
||||||
|
}
|
||||||
|
else if (idx) /* Toggle selection. */
|
||||||
|
{
|
||||||
|
for (i=0, node = keyblock; node; node = node->next)
|
||||||
|
{
|
||||||
|
if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY)
|
||||||
|
if (++i == idx)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
if (!node)
|
||||||
if( !node ) {
|
{
|
||||||
tty_printf(_("No subkey with index %d\n"), idx );
|
tty_printf (_("No subkey with index %d\n"), idx );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else { /* reset all */
|
for (i=0, node = keyblock; node; node = node->next)
|
||||||
for ( node = keyblock; node; node = node->next ) {
|
{
|
||||||
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY )
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY )
|
||||||
node->flag &= ~NODFLG_SELKEY;
|
if (++i == idx)
|
||||||
}
|
{
|
||||||
return 1;
|
if ((node->flag & NODFLG_SELKEY))
|
||||||
}
|
|
||||||
/* and set the new index */
|
|
||||||
for( i=0, node = keyblock; node; node = node->next ) {
|
|
||||||
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
|
||||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
|
||||||
if( ++i == idx ) {
|
|
||||||
if( (node->flag & NODFLG_SELKEY) )
|
|
||||||
node->flag &= ~NODFLG_SELKEY;
|
node->flag &= ~NODFLG_SELKEY;
|
||||||
else
|
else
|
||||||
node->flag |= NODFLG_SELKEY;
|
node->flag |= NODFLG_SELKEY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else /* Unselect all. */
|
||||||
|
{
|
||||||
|
for (node = keyblock; node; node = node->next)
|
||||||
|
if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|
||||||
|
|| node->pkt->pkttype == PKT_SECRET_SUBKEY)
|
||||||
|
node->flag &= ~NODFLG_SELKEY;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user