Beispiel #1
0
static void handle_key_release(int keycode)
{
//	static long idx_article = 0;
	static int first_time_random = 0;
	int mode;

	finger_move_speed = 0;
	keyboard_key_reset_invert(KEYBOARD_RESET_INVERT_NOW); // reset invert immediately
	DP(DBG_WL, ("O handle_key_release()\n"));
	mode = keyboard_get_mode();
	if (keycode == WL_INPUT_KEY_POWER) {
#ifdef INCLUDED_FROM_KERNEL
		if (history_list_save(HISTORY_SAVE_POWER_OFF))
		{
			delay_us(200000);
		}
#endif
	} else if (keycode == WL_INPUT_KEY_SEARCH) {
		article_buf_pointer = NULL;
		/* back to search */
		if (display_mode == DISPLAY_MODE_INDEX) {
			toggle_soft_keyboard();
		} else {
			search_set_selection(-1);
			display_mode = DISPLAY_MODE_INDEX;
			keyboard_set_mode(KEYBOARD_CHAR);
			repaint_search();
		}
	} else if (keycode == WL_INPUT_KEY_HISTORY) {
		if (display_mode != DISPLAY_MODE_HISTORY) {
			article_buf_pointer = NULL;
			history_reload();
			display_mode = DISPLAY_MODE_HISTORY;
			keyboard_set_mode(KEYBOARD_NONE);
		} else {
			if (keyboard_get_mode() == KEYBOARD_CLEAR_HISTORY)
			{
				keyboard_set_mode(KEYBOARD_NONE);
				guilib_fb_lock();
				//keyboard_paint();
				draw_clear_history(1);
				guilib_fb_unlock();
			} else if (history_get_count() > 0) {
				keyboard_set_mode(KEYBOARD_CLEAR_HISTORY);
				guilib_fb_lock();
				//keyboard_paint();
				draw_clear_history(0);
				guilib_fb_unlock();
			}
		}
	} else if (keycode == WL_INPUT_KEY_RANDOM) {
		if (first_time_random < 4)
			first_time_random++;
		if (first_time_random == 3)
		{
			first_time_random = 4;
			if (init_article_filter())
				return;
		}
		article_buf_pointer = NULL;
		display_mode = DISPLAY_MODE_ARTICLE;
		last_display_mode = DISPLAY_MODE_INDEX;
		random_article();
	} else if (display_mode == DISPLAY_MODE_INDEX) {
		article_buf_pointer = NULL;
		if (keycode == WL_KEY_RETURN) {
			int cur_selection = search_current_selection();
			retrieve_article(cur_selection);
#ifdef PROFILER_ON
		} else if (keycode == WL_KEY_HASH) {
			/* activate if you want to run performance tests */
			/* perf_test(); */
			malloc_status_simple();
			prof_print();
#endif
		} else {
			handle_search_key(keycode);
		}
	} else if (display_mode == DISPLAY_MODE_ARTICLE) {
		article_buf_pointer = NULL;
		if (keycode == WL_KEY_BACKSPACE) {
			if (last_display_mode == DISPLAY_MODE_INDEX) {
				display_mode = DISPLAY_MODE_INDEX;
				repaint_search();
			} else if (last_display_mode == DISPLAY_MODE_HISTORY) {
				display_mode = DISPLAY_MODE_HISTORY;
				history_reload();
			}
		}
	}
}
Beispiel #2
0
void handle_password_key(char keycode)
{
	switch (restricted_screen_mode)
	{
	case RESTRICTED_SCREEN_FIRST_TIME_PASSWORD:
	case RESTRICTED_SCREEN_SET_PASSWORD:
	case RESTRICTED_SCREEN_CONFIRM_PASSWORD:
	case RESTRICTED_SCREEN_CHECK_PASSWORD:
	case RESTRICTED_SCREEN_CHANGE_PASSWORD:
		if (keycode == 'Y') {
			if (restricted_screen_mode == RESTRICTED_SCREEN_FIRST_TIME_PASSWORD)
			{
				password_str_len = 0;
				keyboard_set_mode(KEYBOARD_PASSWORD_CHAR);
				enter_password_screen(get_nls_text("set_password"));
				restricted_screen_mode = RESTRICTED_SCREEN_SET_PASSWORD;
			}
			else if (restricted_screen_mode == RESTRICTED_SCREEN_SET_PASSWORD && password_str_len > 0)
			{
				restricted_screen_mode = RESTRICTED_SCREEN_CONFIRM_PASSWORD;
				strcpy(password1, password_string);
				password_str_len = 0;
				if (restriction_filter_off == -1)
					enter_password_screen(get_nls_text("re_enter_password"));
				else
					enter_password_screen(get_nls_text("re_enter_new_password"));
			}
			else if (restricted_screen_mode == RESTRICTED_SCREEN_CONFIRM_PASSWORD && password_str_len > 0)
			{
				if (strcmp(password1, password_string))
				{
					password_str_len = 0;
					restricted_screen_mode = RESTRICTED_SCREEN_SET_PASSWORD;
					enter_password_screen(get_nls_text("passwords_not_match"));
				}
				else
				{
					restriction_filter_off = 0;
					save_password(1);
					restricted_screen_mode = RESTRICTED_SCREEN_FILTER_ON_OFF;
					filter_on_off();
				}
			}
			else if (password_str_len > 0)
			{
				check_password();
			}
		} else if (keycode == WL_KEY_BACKSPACE) {
			password_remove_char();
		} else if (is_supported_search_char(keycode)) {
			password_add_char(tolower(keycode));
		}
		break;
	case RESTRICTED_SCREEN_FILTER_ON_OFF:
		if (keycode == 'Y') {
			restriction_filter_off = 0;
			if (init_filtering)
			{
				init_filtering = 0;
				search_set_selection(-1);
				display_mode = DISPLAY_MODE_INDEX;
				keyboard_set_mode(wiki_default_keyboard());
				repaint_search();
			}
			else
			{
				display_mode = DISPLAY_MODE_ARTICLE;
				display_retrieved_article(saved_idx_article);
			}
		} else if (keycode == 'N') {
			restriction_filter_off = 1;
			save_password(2);
			if (init_filtering)
			{
				init_filtering = 0;
				search_set_selection(-1);
				display_mode = DISPLAY_MODE_INDEX;
				keyboard_set_mode(wiki_default_keyboard());
				repaint_search();
			}
			else
			{
				display_mode = DISPLAY_MODE_ARTICLE;
				display_retrieved_article(saved_idx_article);
			}
		}
		break;
	case RESTRICTED_SCREEN_FILTER_OPTION:
		if (keycode == 'Y') {
			filter_option_to_set = FILTER_OPTION_TO_SET_ON;
			password_str_len = 0;
			check_password();
		}
		else if (keycode == 'N') {
			filter_option_to_set = FILTER_OPTION_TO_SET_OFF;
			password_str_len = 0;
			check_password();
		}
		if (keycode == 'P') {
			password_str_len = 0;
			keyboard_set_mode(KEYBOARD_PASSWORD_CHAR);
			enter_password_screen(get_nls_text("enter_old_password"));
			restricted_screen_mode = RESTRICTED_SCREEN_CHANGE_PASSWORD;
		}
		break;
	default:
		break;
	}
}