Added "Forget master password" mainwindow menu entry.

This commit is contained in:
Andrej Kacian 2016-02-07 20:07:03 +01:00
parent fb564a461e
commit f181179416
4 changed files with 27 additions and 1 deletions

View file

@ -46,6 +46,7 @@
#include "import.h"
#include "export.h"
#include "edittags.h"
#include "password.h"
#include "prefs_common.h"
#include "prefs_actions.h"
#include "prefs_filtering.h"
@ -428,6 +429,8 @@ static void sync_cb ( GtkAction *action,
static void forget_session_passwords_cb (GtkAction *action,
gpointer data );
static void forget_master_password_cb (GtkAction *action,
gpointer data );
static gboolean mainwindow_focus_in_event (GtkWidget *widget,
GdkEventFocus *focus,
@ -776,6 +779,7 @@ static GtkActionEntry mainwin_entries[] =
{"Tools/NetworkLog", NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) },
/* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
{"Tools/ForgetSessionPasswords", NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) },
{"Tools/ForgetMasterPassword", NULL, N_("Forget _master password"), NULL, NULL, G_CALLBACK(forget_master_password_cb) },
/* Configuration menu */
{"Configuration/ChangeAccount", NULL, N_("C_hange current account") },
@ -1850,6 +1854,7 @@ MainWindow *main_window_create()
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetMasterPassword", "Tools/ForgetMasterPassword", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator9", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
/* Configuration menu */
@ -3091,6 +3096,10 @@ SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
break;
}
}
if (master_password_is_entered()) {
UPDATE_STATE(M_MASTER_PASSWORD);
}
#undef UPDATE_STATE
return state;
@ -3131,7 +3140,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
gint i;
gboolean mimepart_selected = FALSE;
#define N_ENTRIES 84
#define N_ENTRIES 85
static struct {
const gchar *entry;
SensitiveCondMask cond;
@ -3224,6 +3233,7 @@ do { \
FILL_TABLE("Menu/Tools/Execute", M_DELAY_EXEC);
FILL_TABLE("Menu/Tools/Expunge", M_DELETED_EXISTS);
FILL_TABLE("Menu/Tools/ForgetSessionPasswords", M_SESSION_PASSWORDS);
FILL_TABLE("Menu/Tools/ForgetMasterPassword", M_MASTER_PASSWORD);
FILL_TABLE("Menu/Tools/DeleteDuplicates/SelFolder", M_MSG_EXIST, M_ALLOW_DELETE);
FILL_TABLE("Menu/Configuration", M_UNLOCKED);
@ -5320,6 +5330,15 @@ static void forget_session_passwords_cb(GtkAction *action, gpointer data)
fgtn), fgtn, accs);
}
static void forget_master_password_cb(GtkAction *action, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
main_window_lock(mainwin);
master_password_forget();
main_window_unlock(mainwin);
}
void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
{
summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);

View file

@ -64,6 +64,7 @@ typedef enum
M_HAVE_MULTI_ACCOUNT,
M_FOLDER_SELECTED,
M_SESSION_PASSWORDS,
M_MASTER_PASSWORD,
M_DELETED_EXISTS,
M_NOT_TRASH,
M_HIDE_READ_THREADS,

View file

@ -117,6 +117,11 @@ const gboolean master_password_is_correct(const gchar *input)
return FALSE;
}
gboolean master_password_is_entered()
{
return (_master_password == NULL) ? FALSE : TRUE;
}
void master_password_forget()
{
/* If master password is currently in memory (entered by user),

View file

@ -29,6 +29,7 @@
#ifndef PASSWORD_CRYPTO_OLD
const gboolean master_password_is_set();
const gboolean master_password_is_correct(const gchar *input);
gboolean master_password_is_entered();
void master_password_forget();
void master_password_change(const gchar *newp);
#endif