Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[wiki-app] updates from Symbio

change scroll threshold to 1 pixel
clear history keyboard change
search list less than a page fix
Parental control screen (at first random key press) implementation.
Article filtering fine tuning

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
commit a8a9edd556c2543040f5ae85cc21c4907d891af5 1 parent d6ac6e7
@hxw hxw authored
View
42 wiki-app/history.c
@@ -23,6 +23,8 @@
#include <search.h>
#include <stdlib.h>
#include <file-io.h>
+#include <guilib.h>
+#include <lcd.h>
#include "history.h"
#include "search.h"
#include "msg.h"
@@ -75,6 +77,7 @@ void history_add(const long idx_article, const char *title)
history_tmp = history_list[i];
memrcpy((void*)&history_list[1],(void*)&history_list[0],sizeof(HISTORY)*i);
history_list[0]=history_tmp;
+ history_list[0].last_y_pos = 0;
bFound = 1;
}
else
@@ -290,3 +293,42 @@ void history_open_article(int new_selection)
strcpy(title, history_list[history_current + history_base].title);
display_link_article(idx_article);
}
+
+void draw_clear_history(void)
+{
+ int i;
+
+ memset(&framebuffer[181 * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, 27 * LCD_VRAM_WIDTH_PIXELS / 8);
+
+ framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 18] = 0xFE;
+ memset(&framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 19], 0, 4);
+ framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 23] = 0x07;
+
+ framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0xF8;
+ memset(&framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 25], 0, 4);
+ framebuffer[184 * LCD_VRAM_WIDTH_PIXELS / 8 + 29] = 0x1F;
+
+ for (i = 185; i <= 203; i++)
+ {
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 18] = 0xFC;
+ memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 19], 0, 4);
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 23] = 0x03;
+
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0xF0;
+ memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 25], 0, 4);
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 29] = 0x0F;
+ }
+
+ framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 18] = 0xFE;
+
+ memset(&framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 19], 0, 4);
+ framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 23] = 0x07;
+
+
+ framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0xF8;
+ memset(&framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 25], 0, 4);
+ framebuffer[204 * LCD_VRAM_WIDTH_PIXELS / 8 + 29] = 0x1F;
+
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, 185, "Clear History", 13, 1);
+ render_string(SUBTITLE_FONT_IDX, 156, 185, "Yes", 3, 0);
+ render_string(SUBTITLE_FONT_IDX, 206, 185, "No", 2, 0);
View
1  wiki-app/history.h
@@ -48,6 +48,7 @@ void history_open_article(int new_selection);
void history_reload();
void history_log_y_pos(const long y_pos);
long history_get_y_pos(const long idx_article);
+void draw_clear_history(void);
typedef struct _HISTORY {
long idx_article;
View
28 wiki-app/keyboard.c
@@ -116,7 +116,7 @@ static struct keyboard_key qwerty_num[] = {
KEY(216, 181, 239, 207, INTERNAL_NUMBER),
};
static struct keyboard_key password_char[] = {
- KEY(176, 81, 205, 105, 'Y'),
+ KEY(175, 81, 204, 105, 'Y'),
KEY(0, 126, 23, 152, 'q'),
KEY(0, 153, 23, 180, 'a'),
@@ -158,7 +158,7 @@ static struct keyboard_key password_char[] = {
KEY(216, 181, 239, 207, INTERNAL_NUMBER),
};
static struct keyboard_key password_num[] = {
- KEY(176, 81, 205, 105, 'Y'),
+ KEY(175, 81, 204, 105, 'Y'),
KEY(0, 126, 23, 152, '1'),
KEY(0, 153, 23, 180, '*'),
@@ -200,20 +200,20 @@ static struct keyboard_key password_num[] = {
KEY(216, 181, 239, 207, INTERNAL_NUMBER),
};
static struct keyboard_key clear_history[] = {
- KEY(144, 181, 191, 207, 'Y'),
- KEY(192, 181, 239, 207, 'N'),
+ KEY(147, 181, 192, 207, 'Y'),
+ KEY(193, 181, 238, 207, 'N'),
};
static struct keyboard_key restriction[] = {
- KEY(60, 138, 179, 160, 'Y'),
+ KEY(60, 148, 179, 170, 'Y'),
};
static struct keyboard_key filter_on_off[] = {
- KEY(42, 124, 195, 147, 'Y'),
- KEY(42, 153, 195, 176, 'N'),
+ KEY(44, 134, 195, 157, 'Y'),
+ KEY(44, 163, 195, 186, 'N'),
};
static struct keyboard_key filter_option[] = {
- KEY(42, 95, 195, 118, 'Y'),
- KEY(42, 124, 195, 147, 'N'),
- KEY(42, 153, 195, 176, 'P'),
+ KEY(44, 105, 195, 128, 'Y'),
+ KEY(44, 134, 195, 157, 'N'),
+ KEY(44, 163, 195, 187, 'P'),
};
/*
* The secret of the position and size of the keyboard
@@ -230,8 +230,8 @@ void keyboard_set_mode(int mode)
image_data = &image_data_char;
else if(kb_mode == KEYBOARD_NUM)
image_data = &image_data_num;
- else if(kb_mode == KEYBOARD_CLEAR_HISTORY)
- image_data = &image_data_clear_history;
+// else if(kb_mode == KEYBOARD_CLEAR_HISTORY)
+// image_data = &image_data_clear_history;
else
image_data = NULL;
@@ -251,8 +251,8 @@ void keyboard_paint()
image_data = &image_data_char;
else if(kb_mode == KEYBOARD_NUM || kb_mode == KEYBOARD_PASSWORD_NUM)
image_data = &image_data_num;
- else if(kb_mode == KEYBOARD_CLEAR_HISTORY)
- image_data = &image_data_clear_history;
+// else if(kb_mode == KEYBOARD_CLEAR_HISTORY)
+// image_data = &image_data_clear_history;
else
return;
View
74 wiki-app/keyboard_all_image.h
@@ -430,77 +430,3 @@ static struct guilib_image image_data_num = {
B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), },
};
-
-static struct guilib_image image_data_clear_history = {
- .width = 240,
- .height = 27,
- .data = {
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xf0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xf0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x1f),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f),
- B(0xff), B(0xe0), B(0xf3), B(0xff), B(0xff), B(0xff), B(0xf3), B(0xe6), B(0x7f), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x1c), B(0x38), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0xe1), B(0x80), B(0x00), B(0x0f), B(0xff), B(0xc0), B(0x73), B(0xff), B(0xff), B(0xff),
- B(0xf3), B(0xe6), B(0x7f), B(0xf3), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x0e), B(0x30), B(0x00), B(0x00), B(0x07), B(0xe0), B(0x00), B(0xe1), B(0x80), B(0x00), B(0x0f),
- B(0xff), B(0xce), B(0x33), B(0xff), B(0xff), B(0xff), B(0xf3), B(0xe7), B(0xff), B(0xf3), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x06), B(0x70), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0xf1), B(0x80), B(0x00), B(0x0f), B(0xff), B(0x9f), B(0x33), B(0xc3), B(0xc1), B(0xc9),
- B(0xf3), B(0xe6), B(0x70), B(0x60), B(0xe3), B(0xc9), B(0x3c), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x07), B(0xe3), B(0xc3), B(0xe0), B(0x07), B(0xe0), B(0x00), B(0xf9), B(0x8e), B(0x00), B(0x0f),
- B(0xff), B(0x9f), B(0xf3), B(0x81), B(0x9c), B(0xc1), B(0xf0), B(0x06), B(0x67), B(0x33), B(0xc1), B(0xc1),
- B(0x19), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x03), B(0xc7), B(0xe6), B(0x30), B(0x07),
- B(0xe0), B(0x00), B(0xd9), B(0x9f), B(0x00), B(0x0f), B(0xff), B(0x9f), B(0xf3), B(0x39), B(0x9c), B(0xc7),
- B(0xf0), B(0x06), B(0x67), B(0xf3), B(0x9c), B(0xc7), B(0x99), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x03), B(0xcc), B(0x66), B(0x00), B(0x07), B(0xe0), B(0x00), B(0xdd), B(0xb1), B(0x80), B(0x0f),
- B(0xff), B(0x9f), B(0xf3), B(0x00), B(0xc0), B(0xcf), B(0xf3), B(0xe6), B(0x60), B(0x73), B(0x9c), B(0xcf),
- B(0x99), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x01), B(0x8f), B(0xf7), B(0xe0), B(0x07),
- B(0xe0), B(0x00), B(0xcd), B(0xb1), B(0x80), B(0x0f), B(0xff), B(0x9f), B(0x33), B(0x3f), B(0x80), B(0xcf),
- B(0xf3), B(0xe6), B(0x78), B(0x33), B(0x9c), B(0xcf), B(0xc3), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x01), B(0x8c), B(0x01), B(0xf0), B(0x07), B(0xe0), B(0x00), B(0xcf), B(0xb1), B(0x80), B(0x0f),
- B(0xff), B(0xce), B(0x33), B(0x19), B(0x9c), B(0xcf), B(0xf3), B(0xe6), B(0x7f), B(0x33), B(0x9c), B(0xcf),
- B(0xc3), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x01), B(0x8e), B(0x66), B(0x30), B(0x07),
- B(0xe0), B(0x00), B(0xc7), B(0xb1), B(0x80), B(0x0f), B(0xff), B(0xc0), B(0x73), B(0x81), B(0x9c), B(0xcf),
- B(0xf3), B(0xe6), B(0x63), B(0x30), B(0xc1), B(0xcf), B(0xc3), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x01), B(0x87), B(0xe7), B(0x30), B(0x07), B(0xe0), B(0x00), B(0xc3), B(0x9f), B(0x00), B(0x0f),
- B(0xff), B(0xe0), B(0xf3), B(0xc3), B(0xc0), B(0xcf), B(0xf3), B(0xe6), B(0x70), B(0x78), B(0xe3), B(0xcf),
- B(0xe7), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x01), B(0x83), B(0xc3), B(0xe0), B(0x07),
- B(0xe0), B(0x00), B(0xc3), B(0x8e), B(0x00), B(0x0f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe7), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0x8f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0x8f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x07),
- B(0xe0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xf0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x0f), B(0xf0), B(0x00), B(0x00), B(0x00), B(0x00), B(0x1f),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff),
- B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), B(0xff), },
-};
View
15 wiki-app/lcd_buf_draw.c
@@ -487,8 +487,8 @@ void buf_draw_UTF8_str(unsigned char **pUTF8)
draw_restricted_mark(lcd_draw_buf.screen_buf);
if (article_link_count < MAX_ARTICLE_LINKS)
{
- articleLink[article_link_count].start_xy = (unsigned long)(211 | (3 << 8));
- articleLink[article_link_count].end_xy = (unsigned long)(230 | (23 << 8));
+ articleLink[article_link_count].start_xy = (unsigned long)(211 | (4 << 8));
+ articleLink[article_link_count].end_xy = (unsigned long)(230 | (24 << 8));
articleLink[article_link_count++].article_id = RESTRICTED_MARK_LINK;
}
}
@@ -1063,7 +1063,10 @@ int render_search_result_with_pcf(void)
static long offset_next = 0;
if (!more_search_results)
+ {
+ display_first_page = 1;
return rc;
+ }
guilib_fb_lock();
if (article_link_count == NUMBER_OF_FIRST_PAGE_RESULTS) // has not rendered any results beyond the first page
@@ -1465,11 +1468,17 @@ void open_article_link_with_link_number(int article_link_number)
{
long idx;
- invert_link(article_link_number);
if (article_link_number < 0 || articleLink[article_link_number].article_id <= 0)
return;
display_first_page = 0; // use this to disable scrolling until the first page of the linked article is loaded
idx = articleLink[article_link_number].article_id;
+ if (idx == RESTRICTED_MARK_LINK)
+ {
+#ifdef INCLUDED_FROM_KERNEL
+ delay_us(100000);
+#endif
+ invert_link(article_link_number);
+ }
display_link_article(idx);
}
#endif
View
380 wiki-app/restricted.c
@@ -18,14 +18,24 @@
#include "history.h"
#include "delay.h"
+#define BLACK_SPACE_START RESULT_START
+
enum restricted_screen_e {
RESTRICTED_SCREEN_FIRST_TIME_PASSWORD,
RESTRICTED_SCREEN_SET_PASSWORD,
RESTRICTED_SCREEN_CONFIRM_PASSWORD,
- RESTRICTED_SCREEN_CHECK_PASSWORD,
+ RESTRICTED_SCREEN_CHECK_PASSWORD,
RESTRICTED_SCREEN_FILTER_ON_OFF,
RESTRICTED_SCREEN_FILTER_OPTION,
+ RESTRICTED_SCREEN_CHANGE_PASSWORD,
+};
+
+enum filter_option_e {
+
+ FILTER_OPTION_TO_SET_NONE,
+ FILTER_OPTION_TO_SET_ON,
+ FILTER_OPTION_TO_SET_OFF,
};
extern int restricted_article;
@@ -35,34 +45,48 @@ extern int article_offset;
static char password_string[MAX_PASSWORD_LEN];
static char password1[MAX_PASSWORD_LEN];
static int password_str_len = 0;
-static int restricted_screen_mode;
+static int restricted_screen_mode;
+static int filter_option_to_set = FILTER_OPTION_TO_SET_NONE;
int restriction_filter_off = -1;
char restriction_pass1[20];
long saved_idx_article;
-void first_time_password()
+int init_filtering = 0;
+void first_time_password(int flag)
{
int i;
guilib_fb_lock();
- memset(&framebuffer[RESULT_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - RESULT_START)* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[(BLACK_SPACE_START - 6)* LCD_VRAM_WIDTH_PIXELS / 8], 0, 6 * LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[BLACK_SPACE_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - BLACK_SPACE_START)* LCD_VRAM_WIDTH_PIXELS / 8);
- framebuffer[139 * LCD_VRAM_WIDTH_PIXELS / 8 + 7] = 0xFC;
- memset(&framebuffer[139 * LCD_VRAM_WIDTH_PIXELS / 8 + 8], 0, 14);
- framebuffer[139 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x3F;
- for (i = 140; i <= 158; i++)
+ framebuffer[149 * LCD_VRAM_WIDTH_PIXELS / 8 + 7] = 0xFC;
+ memset(&framebuffer[149 * LCD_VRAM_WIDTH_PIXELS / 8 + 8], 0, 14);
+ framebuffer[149 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x3F;
+ for (i = 150; i <= 168; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 7] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 8], 0, 14);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x1F;
}
- framebuffer[159 * LCD_VRAM_WIDTH_PIXELS / 8 + 7] = 0xFC;
- memset(&framebuffer[159 * LCD_VRAM_WIDTH_PIXELS / 8 + 8], 0, 14);
- framebuffer[159 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x3F;
-
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 10, "This article is restricted due to", 33, 1);
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 30, "its adult content. Please set a", 32, 1);
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 50, "password in odrder to view it.", 30, 1);
- render_string(SUBTITLE_FONT_IDX, -1, 141, "Set Password", 12, 0);
+ framebuffer[169 * LCD_VRAM_WIDTH_PIXELS / 8 + 7] = 0xFC;
+ memset(&framebuffer[169 * LCD_VRAM_WIDTH_PIXELS / 8 + 8], 0, 14);
+ framebuffer[169 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x3F;
+
+ if (flag)
+ {
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 10, "Some Wikipedia entries may", 26, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 30, "not be suitable for minors.", 27, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 50, "Please set a password to", 24, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 70, "protect them from children.", 27, 1);
+ }
+ else
+ {
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 10, "This entry may not be suitable", 30, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 30, "for minors. Please set a", 24, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 50, "password to view or protect", 27, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 70, "it from children.", 17, 1);
+ }
+ render_string(SUBTITLE_FONT_IDX, -1, 151, "Set Password", 12, 0);
guilib_fb_unlock();
display_mode = DISPLAY_MODE_RESTRICTED;
keyboard_set_mode(KEYBOARD_RESTRICTED);
@@ -77,38 +101,39 @@ void enter_password_screen(char *msg)
keyboard_set_mode(KEYBOARD_PASSWORD_CHAR);
guilib_fb_lock();
keyboard_paint();
- memset(&framebuffer[RESULT_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF,
- (LCD_HEIGHT_LINES - RESULT_START - keyboard_height())* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[(BLACK_SPACE_START - 6)* LCD_VRAM_WIDTH_PIXELS / 8], 0, 6 * LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[BLACK_SPACE_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF,
+ (LCD_HEIGHT_LINES - BLACK_SPACE_START - keyboard_height())* LCD_VRAM_WIDTH_PIXELS / 8);
render_string(SUBTITLE_FONT_IDX, -1, 50, msg, strlen(msg), 1);
- framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xF8;
+ framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xFC;
memset(&framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 5], 0, 16);
- framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x0F;
+ framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x07;
- framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0xC0;
+ framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x80;
memset(&framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 23], 0, 2);
- framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x0F;
+ framebuffer[82 * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x1F;
for (i = 83; i <= 103; i++)
{
- framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xF0;
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5], 0, 16);
- framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x07;
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x03;
- framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x80;
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x00;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 23], 0, 2);
- framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x07;
+ framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x0F;
}
- framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xF8;
+ framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 4] = 0xFC;
memset(&framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 5], 0, 16);
- framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x0F;
+ framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 21] = 0x07;
- framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0xC0;
+ framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 22] = 0x80;
memset(&framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 23], 0, 2);
- framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x0F;
+ framebuffer[104 * LCD_VRAM_WIDTH_PIXELS / 8 + 25] = 0x1F;
- render_string(SUBTITLE_FONT_IDX, 182, 85, "ok", 2, 0);
+ render_string(SUBTITLE_FONT_IDX, 180, 85, "ok", 2, 0);
guilib_fb_unlock();
}
@@ -117,39 +142,40 @@ void filter_on_off(void)
int i;
guilib_fb_lock();
- memset(&framebuffer[RESULT_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - RESULT_START)* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[(BLACK_SPACE_START - 6)* LCD_VRAM_WIDTH_PIXELS / 8], 0, 6 * LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[BLACK_SPACE_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - BLACK_SPACE_START)* LCD_VRAM_WIDTH_PIXELS / 8);
- framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- for (i = 126; i <= 145; i++)
+ framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ for (i = 136; i <= 155; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x1F;
}
- framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
-
- framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- for (i = 155; i <= 174; i++)
+ framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+
+ framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ for (i = 165; i <= 184; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x1F;
}
- framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
-
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 10, "With filtering on, a password is", 32, 1);
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 30, "required each time a restricted", 31, 1);
- render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, RESULT_START + 50, "article is accessed.", 20, 1);
- render_string(SUBTITLE_FONT_IDX, -1, 127, "Keep Filter ON", 14, 0);
- render_string(SUBTITLE_FONT_IDX, -1, 156, "Keep Filter OFF", 15, 0);
+ framebuffer[185 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[185 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[185 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 10, "With filtering ON, a password", 29, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 30, "is required when restricted", 27, 1);
+ render_string(SUBTITLE_FONT_IDX, LCD_LEFT_MARGIN, BLACK_SPACE_START + 50, "articles are accessed.", 22, 1);
+ render_string(SUBTITLE_FONT_IDX, -1, 137, "Keep Filter ON", 14, 0);
+ render_string(SUBTITLE_FONT_IDX, -1, 166, "Keep Filter OFF", 15, 0);
guilib_fb_unlock();
keyboard_set_mode(KEYBOARD_FILTER_ON_OFF);
}
@@ -162,52 +188,53 @@ void filter_option(void)
keyboard_set_mode(KEYBOARD_FILTER_OPTION);
restricted_screen_mode = RESTRICTED_SCREEN_FILTER_OPTION;
guilib_fb_lock();
- memset(&framebuffer[RESULT_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - RESULT_START)* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[(BLACK_SPACE_START - 6)* LCD_VRAM_WIDTH_PIXELS / 8], 0, 6 * LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[BLACK_SPACE_START * LCD_VRAM_WIDTH_PIXELS / 8], 0xFF, (LCD_HEIGHT_LINES - BLACK_SPACE_START)* LCD_VRAM_WIDTH_PIXELS / 8);
- render_string(SUBTITLE_FONT_IDX, -1, 50, "Filter Opeion", 13, 1);
+ render_string(TITLE_FONT_IDX, -1, 60, "Filter Options", 14, 1);
- framebuffer[96 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[96 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[96 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- for (i = 97; i <= 116; i++)
+ framebuffer[106 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[106 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[106 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ for (i = 107; i <= 126; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x1F;
}
- framebuffer[117 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[117 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[117 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
-
- framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[125 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- for (i = 126; i <= 145; i++)
+ framebuffer[127 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[127 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[127 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+
+ framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[135 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ for (i = 136; i <= 155; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x1F;
}
- framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[146 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
-
- framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[154 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- for (i = 155; i <= 174; i++)
+ framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[156 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+
+ framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[164 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ for (i = 165; i <= 185; i++)
{
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xF8;
memset(&framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
framebuffer[i * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x1F;
}
- framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
- memset(&framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
- framebuffer[175 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
+ framebuffer[186 * LCD_VRAM_WIDTH_PIXELS / 8 + 5] = 0xFC;
+ memset(&framebuffer[186 * LCD_VRAM_WIDTH_PIXELS / 8 + 6], 0, 18);
+ framebuffer[186 * LCD_VRAM_WIDTH_PIXELS / 8 + 24] = 0x3F;
- render_string(SUBTITLE_FONT_IDX, -1, 98, "Turn Filter ON", 14, 0);
- render_string(SUBTITLE_FONT_IDX, -1, 127, "Turn Filter OFF", 15, 0);
- render_string(SUBTITLE_FONT_IDX, -1, 156, "Change Password", 15, 0);
+ render_string(SUBTITLE_FONT_IDX, -1, 108, "Turn Filter ON", 14, 0);
+ render_string(SUBTITLE_FONT_IDX, -1, 137, "Turn Filter OFF", 15, 0);
+ render_string(SUBTITLE_FONT_IDX, -1, 166, "Change Password", 15, 0);
guilib_fb_unlock();
keyboard_set_mode(KEYBOARD_FILTER_OPTION);
}
@@ -220,10 +247,13 @@ void save_password(int flag)
fd = wl_open("pedia.pas", WL_O_CREATE);
if (fd >= 0)
{
- SHA1Reset(&sha);
- SHA1Input(&sha, (const unsigned char *) password_string, password_str_len);
- SHA1Result(&sha);
- memcpy(restriction_pass1, sha.Message_Digest, 20);
+ if (password_str_len > 0)
+ {
+ SHA1Reset(&sha);
+ SHA1Input(&sha, (const unsigned char *) password_string, password_str_len);
+ SHA1Result(&sha);
+ memcpy(restriction_pass1, sha.Message_Digest, 20);
+ }
wl_write(fd, restriction_pass1, 20);
if (flag > 1)
{
@@ -247,13 +277,14 @@ void handle_password_key(char keycode)
case RESTRICTED_SCREEN_FIRST_TIME_PASSWORD:
case RESTRICTED_SCREEN_SET_PASSWORD:
case RESTRICTED_SCREEN_CONFIRM_PASSWORD:
- case RESTRICTED_SCREEN_CHECK_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("Enter password");
+ enter_password_screen("Set Password");
restricted_screen_mode = RESTRICTED_SCREEN_SET_PASSWORD;
}
else if (restricted_screen_mode == RESTRICTED_SCREEN_SET_PASSWORD && password_str_len > 0)
@@ -261,7 +292,10 @@ void handle_password_key(char keycode)
restricted_screen_mode = RESTRICTED_SCREEN_CONFIRM_PASSWORD;
strcpy(password1, password_string);
password_str_len = 0;
- enter_password_screen("Enter password again");
+ if (restriction_filter_off == -1)
+ enter_password_screen("Re-enter Password");
+ else
+ enter_password_screen("Re-enter new password");
}
else if (restricted_screen_mode == RESTRICTED_SCREEN_CONFIRM_PASSWORD && password_str_len > 0)
{
@@ -269,7 +303,7 @@ void handle_password_key(char keycode)
{
password_str_len = 0;
restricted_screen_mode = RESTRICTED_SCREEN_SET_PASSWORD;
- enter_password_screen("Not matched. Enter password");
+ enter_password_screen("Passwords do not match.");
}
else
{
@@ -283,22 +317,6 @@ void handle_password_key(char keycode)
{
check_password();
}
- } else if (keycode == 'N') {
- if (last_display_mode == DISPLAY_MODE_HISTORY)
- {
- article_offset = 0;
- article_buf_pointer = NULL;
- display_mode = DISPLAY_MODE_HISTORY;
- history_reload();
- keyboard_set_mode(KEYBOARD_NONE);
- }
- else
- {
- search_set_selection(-1);
- display_mode = DISPLAY_MODE_INDEX;
- keyboard_set_mode(KEYBOARD_CHAR);
- repaint_search();
- }
} else if (keycode == WL_KEY_BACKSPACE) {
password_remove_char();
} else if (is_supported_search_char(keycode)) {
@@ -308,32 +326,53 @@ void handle_password_key(char keycode)
case RESTRICTED_SCREEN_FILTER_ON_OFF:
if (keycode == 'Y') {
restriction_filter_off = 0;
- display_mode = DISPLAY_MODE_ARTICLE;
- display_retrieved_article(saved_idx_article);
+ if (init_filtering)
+ {
+ init_filtering = 0;
+ search_set_selection(-1);
+ display_mode = DISPLAY_MODE_INDEX;
+ keyboard_set_mode(KEYBOARD_CHAR);
+ 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);
- display_mode = DISPLAY_MODE_ARTICLE;
- display_retrieved_article(saved_idx_article);
+ if (init_filtering)
+ {
+ init_filtering = 0;
+ search_set_selection(-1);
+ display_mode = DISPLAY_MODE_INDEX;
+ keyboard_set_mode(KEYBOARD_CHAR);
+ repaint_search();
+ }
+ else
+ {
+ display_mode = DISPLAY_MODE_ARTICLE;
+ display_retrieved_article(saved_idx_article);
+ }
}
break;
case RESTRICTED_SCREEN_FILTER_OPTION:
if (keycode == 'Y') {
- restriction_filter_off = 0;
- save_password(1);
- last_display_mode = DISPLAY_MODE_ARTICLE;
- display_mode = DISPLAY_MODE_ARTICLE;
- display_retrieved_article(saved_idx_article);
+ filter_option_to_set = FILTER_OPTION_TO_SET_ON;
+ password_str_len = 0;
+ check_password();
}
else if (keycode == 'N') {
- restriction_filter_off = 1;
- save_password(2);
- last_display_mode = DISPLAY_MODE_ARTICLE;
- display_mode = DISPLAY_MODE_ARTICLE;
- display_retrieved_article(saved_idx_article);
+ filter_option_to_set = FILTER_OPTION_TO_SET_OFF;
+ password_str_len = 0;
+ check_password();
}
if (keycode == 'P') {
- first_time_password();
+ password_str_len = 0;
+ keyboard_set_mode(KEYBOARD_PASSWORD_CHAR);
+ enter_password_screen("Enter old password");
+ restricted_screen_mode = RESTRICTED_SCREEN_CHANGE_PASSWORD;
}
break;
default:
@@ -348,6 +387,8 @@ void check_password()
if (password_str_len <= 0)
{
+ if (restricted_screen_mode != RESTRICTED_SCREEN_FILTER_OPTION)
+ filter_option_to_set = FILTER_OPTION_TO_SET_NONE;
restricted_screen_mode = RESTRICTED_SCREEN_CHECK_PASSWORD;
enter_password_screen("Enter password");
}
@@ -360,17 +401,89 @@ void check_password()
if (memcmp(pass_sha1, restriction_pass1, 20))
{
password_str_len = 0;
- restricted_screen_mode = RESTRICTED_SCREEN_CHECK_PASSWORD;
- enter_password_screen("Incorrect. Enter password");
+ if (restricted_screen_mode != RESTRICTED_SCREEN_CHANGE_PASSWORD)
+ restricted_screen_mode = RESTRICTED_SCREEN_CHECK_PASSWORD;
+ enter_password_screen("Wrong. Please try again.");
}
else
{
- display_mode = DISPLAY_MODE_ARTICLE;
- display_retrieved_article(saved_idx_article);
+ if (restricted_screen_mode == RESTRICTED_SCREEN_CHANGE_PASSWORD)
+ {
+ password_str_len = 0;
+ keyboard_set_mode(KEYBOARD_PASSWORD_CHAR);
+ enter_password_screen("Enter new password");
+ restricted_screen_mode = RESTRICTED_SCREEN_SET_PASSWORD;
+ }
+ else if (filter_option_to_set == FILTER_OPTION_TO_SET_ON)
+ {
+ restriction_filter_off = 0;
+ save_password(1);
+ last_display_mode = DISPLAY_MODE_ARTICLE;
+ display_mode = DISPLAY_MODE_ARTICLE;
+ display_retrieved_article(saved_idx_article);
+ }
+ else if (filter_option_to_set == FILTER_OPTION_TO_SET_OFF)
+ {
+ restriction_filter_off = 1;
+ save_password(2);
+ last_display_mode = DISPLAY_MODE_ARTICLE;
+ display_mode = DISPLAY_MODE_ARTICLE;
+ display_retrieved_article(saved_idx_article);
+ }
+ else
+ {
+ display_mode = DISPLAY_MODE_ARTICLE;
+ display_retrieved_article(saved_idx_article);
+ }
}
}
}
+int init_article_filter(void)
+{
+ int fd;
+ int len;
+ char restriction_pass2[20];
+ SHA1Context sha;
+
+ if (restriction_filter_off == -1)
+ {
+ fd = wl_open("pedia.pas", WL_O_RDONLY);
+ if (fd >= 0)
+ {
+ len = wl_read(fd, restriction_pass1, 20);
+ if (len < 20)
+ memset(restriction_pass1, 0, 20);
+ else
+ {
+ len = wl_read(fd, restriction_pass2, 20);
+ if (len < 20)
+ memset(restriction_pass2, 0, 20);
+
+ SHA1Reset(&sha);
+ SHA1Input(&sha, (const unsigned char *) restriction_pass1, 20);
+ SHA1Result(&sha);
+ if (!memcmp(sha.Message_Digest, restriction_pass2, 20))
+ restriction_filter_off = 1;
+ else
+ restriction_filter_off = 0;
+ }
+ wl_close(fd);
+ }
+ }
+
+ if (restriction_filter_off == -1)
+ {
+ init_filtering = 1;
+ memset(&framebuffer[0], 0, (BLACK_SPACE_START - 1)* LCD_VRAM_WIDTH_PIXELS / 8);
+ render_string(TITLE_FONT_IDX, LCD_LEFT_MARGIN, LCD_TOP_MARGIN, "Parental Controls", 17, 0);
+ first_time_password(1);
+ return -1;
+ }
+ else
+ return 0;
+}
+
int check_restriction(long idx_article)
{
int fd;
@@ -379,6 +492,7 @@ int check_restriction(long idx_article)
SHA1Context sha;
char title[MAX_TITLE_SEARCH];
+ init_filtering = 0;
saved_idx_article = idx_article;
if (restriction_filter_off == -1)
{
@@ -409,16 +523,16 @@ int check_restriction(long idx_article)
if (restriction_filter_off == -1)
{
get_article_title_from_idx(saved_idx_article, title);
- memset(&framebuffer[0], 0, (RESULT_START - 1)* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[0], 0, (BLACK_SPACE_START - 1)* LCD_VRAM_WIDTH_PIXELS / 8);
render_string(TITLE_FONT_IDX, LCD_LEFT_MARGIN, LCD_TOP_MARGIN, title, strlen(title), 0);
- first_time_password();
+ first_time_password(0);
return -1;
} else if (restriction_filter_off)
return 0; // ok
else
{
get_article_title_from_idx(saved_idx_article, title);
- memset(&framebuffer[0], 0, (RESULT_START - 1)* LCD_VRAM_WIDTH_PIXELS / 8);
+ memset(&framebuffer[0], 0, (BLACK_SPACE_START - 1)* LCD_VRAM_WIDTH_PIXELS / 8);
render_string(TITLE_FONT_IDX, LCD_LEFT_MARGIN, LCD_TOP_MARGIN, title, strlen(title), 0);
password_str_len = 0;
check_password();
@@ -440,7 +554,7 @@ int password_add_char(char c)
c += 32;
password_string[password_str_len++] = c;
password_string[password_str_len] = '\0';
- render_string(SUBTITLE_FONT_IDX, 37, 85, password_string, strlen(password_string), 0);
+ render_string(SUBTITLE_FONT_IDX, 38, 85, password_string, strlen(password_string), 0);
return 0;
}
@@ -455,7 +569,7 @@ int password_remove_char(void)
return -1;
password_string[--password_str_len] = '\0';
- x = render_string(SUBTITLE_FONT_IDX, 37, 85, password_string, strlen(password_string), 0);
+ x = render_string(SUBTITLE_FONT_IDX, 38, 85, password_string, strlen(password_string), 0);
guilib_clear_area(x, 85, 172, 103);
return 0;
}
@@ -478,13 +592,13 @@ void draw_restricted_mark(char *screen_buf)
{
int x, y;
- for (y = 0; y < 24; y++)
+ for (y = 0; y < 25; y++)
{
for (x = 27; x < 30; x++)
{
- if (y < 4 || y == 23)
+ if (y < 5 || y == 24)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0;
- else if (y == 4 || y == 22)
+ else if (y == 5 || y == 23)
{
if (x == 27)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0x3F;
@@ -505,5 +619,5 @@ void draw_restricted_mark(char *screen_buf)
}
}
- buf_draw_bmf_char(screen_buf, (ucs4_t)'R', SUBTITLE_FONT_IDX - 1, 220, 5, 1);
+ buf_draw_bmf_char(screen_buf, (ucs4_t)'R', SUBTITLE_FONT_IDX - 1, 221, 6, 1);
}
View
1  wiki-app/restricted.h
@@ -15,5 +15,6 @@ int get_password_string_len(void);
void handle_password_key(char keycode);
void draw_restricted_mark(char *screen_buf);
void filter_option(void);
+int init_article_filter(void);
#endif /* _LCD_RESTRICTED_H */
View
27 wiki-app/wikilib.c
@@ -87,7 +87,7 @@ extern bool search_string_changed_remove;
int history_touch_pos_y_last;
int touch_search = 0,search_touch_pos_y_last=0;
bool article_moved = false;
-#define INITIAL_ARTICLE_SCROLL_PIXEL 2
+#define INITIAL_ARTICLE_SCROLL_PIXEL 1
int article_scroll_pixel = INITIAL_ARTICLE_SCROLL_PIXEL;
void repaint_search(void)
@@ -306,9 +306,11 @@ static void handle_cursor(struct wl_input_event *ev)
}
}
+extern int restricted_article;
static void handle_key_release(int keycode)
{
// static long idx_article = 0;
+ static int first_time_random = 0;
int mode;
keyboard_key_reset_invert(KEYBOARD_RESET_INVERT_NOW); // reset invert immediately
@@ -348,18 +350,25 @@ static void handle_key_release(int keycode)
} else if (history_get_count() > 0) {
keyboard_set_mode(KEYBOARD_CLEAR_HISTORY);
guilib_fb_lock();
- keyboard_paint();
+ //keyboard_paint();
+ draw_clear_history();
guilib_fb_unlock();
}
}
} else if (keycode == WL_INPUT_KEY_RANDOM) {
-
- article_offset = 0;
- article_buf_pointer = NULL;
- display_mode = DISPLAY_MODE_ARTICLE;
- last_display_mode = DISPLAY_MODE_INDEX;
- random_article();
-
+ if (first_time_random < 4)
+ first_time_random++;
+ if (first_time_random == 3)
+ {
+ first_time_random = 4;
+ if (init_article_filter())
+ return;
+ }
+ article_offset = 0;
+ 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) {
Please sign in to comment.
Something went wrong with that request. Please try again.