diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-27 12:57:08 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-27 12:57:08 +0200 |
commit | a4901950324eb47ef5ce09264170281413d4218c (patch) | |
tree | 1a371c95401375c91d643e1f498f79d3354b3ba9 /src/gui | |
parent | 50ab62b75d50f28c90d9eea1f786d90aa20cdfe1 (diff) | |
download | weechat-a4901950324eb47ef5ce09264170281413d4218c.zip |
core: add secured data with optional encryption in file sec.conf
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 57 | ||||
-rw-r--r-- | src/gui/gui-key.c | 1 | ||||
-rw-r--r-- | src/gui/gui-main.h | 3 |
3 files changed, 61 insertions, 0 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 88a4a1e6f..0cc13acee 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -64,6 +64,63 @@ int gui_term_lines = 0; /* + * Gets a password from user (called on startup, when GUI is not initialized). + * + * The result is stored in "password" with max "size" bytes (including the + * final '\0'). + */ + +void +gui_main_get_password (const char *prompt1, const char *prompt2, + const char *prompt3, + char *password, int size) +{ + int i, ch; + + initscr (); + cbreak (); + noecho (); + + clear(); + + mvprintw (0, 0, "%s", prompt1); + mvprintw (1, 0, "%s", prompt2); + mvprintw (2, 0, "%s", prompt3); + mvprintw (3, 0, "=> "); + refresh (); + + memset (password, '\0', size); + i = 0; + while (i < size - 1) + { + ch = getch (); + if (ch == '\n') + break; + if (ch == 127) + { + if (i > 0) + { + i--; + password[i] = '\0'; + mvprintw (3, 3 + i, " "); + move (3, 3 + i); + } + } + else + { + password[i] = ch; + mvprintw (3, 3 + i, "*"); + i++; + } + refresh (); + } + password[i] = '\0'; + + refresh (); + endwin (); +} + +/* * Pre-initializes GUI (called before gui_init). */ diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 63308b105..771f6135d 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -1125,6 +1125,7 @@ gui_key_focus_command (const char *key, int context, else { command = string_replace_with_callback (commands[i], + "${", "}", &gui_key_focus_command_replace_cb, hashtable, &errors); diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h index d46289073..cf3b5d4af 100644 --- a/src/gui/gui-main.h +++ b/src/gui/gui-main.h @@ -22,6 +22,9 @@ /* main functions (GUI dependent) */ +extern void gui_main_get_password (const char *prompt1, const char *prompt2, + const char *prompt3, + char *password, int size); extern void gui_main_loop (); extern void gui_main_pre_init (int *argc, char **argv[]); extern void gui_main_init (); |