Пример #1
0
Файл: actions.c Проект: ab/pwman
int 
action_list_move_item_down()
{
	Pw* curpw;
	PWList *curpwl;
	int worked = 0;

	// Do nothing if searching
	if(search_results != NULL) {
		return;
	}

	switch(uilist_get_highlighted_type()){
		case PW_ITEM:
			curpw = uilist_get_highlighted_item();
			worked = pwlist_change_item_order(curpw, current_pw_sublist, 0);
			break;
		case PW_SUBLIST:
			curpwl = uilist_get_highlighted_sublist();
			worked = pwlist_change_list_order(curpwl, 0);
			break;
		case PW_UPLEVEL:
		case PW_NULL:
		default:
			/* do nothing */
			break;
	}

	if(worked) {
		uilist_down();
	}
}
Пример #2
0
int
ui_run()
{
int		ch;
int		load_worked = 0;

#ifdef DEBUG
int		debug_i = 0;

#endif

	time_base = time(NULL);

	while (1) {
		can_resize = TRUE;
		if (should_resize) {
			ui_resize();
		}
		ch = getch();
		ui_statusline_clear();
		can_resize = FALSE;

		if ((time_base < (time(NULL) - (options->passphrase_timeout * 60)))
		    && options->passphrase_timeout != 0 && tolower(ch) != 'q') {
			folder_write_file();
			folder_free_all();

			ui_statusline_msg("Passphrase has timed out and you must enter it again.");
			getch();

			load_worked = folder_read_file();
			if (load_worked != 0) {
				ui_statusline_msg("Error - unable to re-load the password file!");
				break;
			}
			if (search_results != NULL)
				search_remove();

			time_base = time(NULL);
			continue;
		}
		switch (ch) {
		case 'Q':
		case 'q':
			if (search_results != NULL)
				search_remove();
			else if (action_list_at_top_level())
				return 0;
			break;

		case '?':
			ui_display_help();
			break;

		case KEY_PPAGE:
			uilist_page_up();
			break;

		case KEY_NPAGE:
			uilist_page_down();
			break;

		case KEY_UP:
		case 'k':
			uilist_up();
			break;

		case KEY_DOWN:
		case 'j':
			uilist_down();
			break;

		case 'A':
			if (!options->readonly)
				action_list_add_sublist();
			else
				statusline_readonly();
			break;

		case 'U':
			action_list_up_one_level();
			break;

		case 'r':
			if (!options->readonly) {
				action_list_rename();
				folder_write_file();
			} else {
				statusline_readonly();
			}
			break;

		case 'a':
			if (!options->readonly) {
				action_list_add_pw();
				folder_write_file();
			} else {
				statusline_readonly();
			}
			break;

		case 'e':
		case ' ':
		case 13:	/* return/enter key */
			action_list_select_item();
			break;

		case 'x':
			action_list_mark();
			break;

		case 'B':
			action_list_copy_username();
			break;

		case 'C':
			action_list_copy_pw();
			break;

		case 'd':
		case 0x14A:	/* DEL key */
			if (!options->readonly)
				action_list_delete_item();
			else 
				statusline_readonly();
			break;

		case 'm':
			if (!options->readonly)
				action_list_move_item();
			else
				statusline_readonly();
			break;

		case 'o':
			action_edit_options();
			break;

		case 0x17:	/* control-w */
			if (!options->readonly)
				folder_write_file();
			else
				statusline_readonly();
			break;

		case 0x12:	/* control-r */
			action_list_read_file();
			break;

		case 0x07:	/* control-g */
			pwgen_indep();
			break;

		case 0x06:	/* control-f */
			gnupg_forget_passphrase();
			break;

		case 0x0C:	/* control-l */
			ui_refresh_windows();
			break;

		case '/':
		case 'F':
			search_get();
			break;

		case 'f':
			filter_get();
			break;

		case 'E':
			action_list_export();
			break;

		case 'I':
			if (!options->readonly) {
				folder_import_passwd();
				uilist_refresh();
			} else {
				statusline_readonly();
			}
			break;

		case 'L':
			action_list_locate();
			break;

		case 'l':
			action_list_launch();
			break;

		case 0x0B:	/* control-k (up) */
		case '[':
			action_list_move_item_up();
			break;

		case 0x0A:	/* control-j (down) */
		case ']':
			action_list_move_item_down();
			break;

#ifdef DEBUG
		case '$':
			debug_i++;
			snprintf(msg, 80, "Name %d", debug_i);

			folder_add(current_pw_sublist, msg, "myhost", "myuser", "mypasswd", "mylaucnh");
			uilist_refresh();
			break;
#endif

		default:
			break;
		}
	}
	return 0;
}