Index: apps/plugins/CATEGORIES =================================================================== --- apps/plugins/CATEGORIES (revision 14238) +++ apps/plugins/CATEGORIES (working copy) @@ -1,3 +1,4 @@ +HTML_Parser,viewers alpine_cdc,apps battery_bench,apps blackjack,games Index: apps/plugins/viewers.config =================================================================== --- apps/plugins/viewers.config (revision 14238) +++ apps/plugins/viewers.config (working copy) @@ -1,3 +1,5 @@ +html,viewers/HTML_Parser,5 +htm,viewers/HTML_Parser,5 ch8,viewers/chip8,0 txt,viewers/viewer,1 nfo,viewers/viewer,1 Index: apps/plugins/calendar.c =================================================================== --- apps/plugins/calendar.c (revision 14238) +++ apps/plugins/calendar.c (working copy) @@ -25,6 +25,15 @@ PLUGIN_HEADER +#if CONFIG_KEYPAD == SANSA_E200_PAD +#define UP BUTTON_UP +#define DOWN BUTTON_DOWN +#define LEFT BUTTON_LEFT +#define RIGHT BUTTON_RIGHT +#define BUTTON_PLAY BUTTON_SELECT +#define BUTTON_ON BUTTON_POWER +#endif + static struct plugin_api* rb; static bool leap_year; @@ -109,7 +118,7 @@ char *Dayname[7] = {"M","T","W","T","F","S","S"}; int ws = 2; rb->lcd_getstringsize("A",&w,&h); - for (i = 0; i < 8;) + for (i = 0; i < 7;) { rb->lcd_putsxy(ws, 0 , Dayname[i++]); ws += space; @@ -218,7 +227,7 @@ for (k = 0; k < 7; k++) wday_has_memo[k] = false; memos_in_memory = 0; - fp = rb->open("/.rockbox/.memo",O_RDONLY); + fp = rb->open("/.rockbox/rocks/apps/.memo",O_RDONLY); if (fp > -1) { int count = rb->filesize(fp); @@ -315,7 +324,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown) { int fp,fq; - fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT); + fp = rb->open("/.rockbox/rocks/apps/.memo",O_RDONLY | O_CREAT); fq = rb->creat("/.rockbox/~temp"); if ( (fq != -1) && (fp != -1) ) { @@ -345,7 +354,7 @@ rb->write(fq,temp,1); } rb->close(fp); - fp = rb->creat("/.rockbox/.memo"); + fp = rb->creat("/.rockbox/rocks/apps/.memo"); rb->lseek(fp, 0, SEEK_SET); rb->lseek(fq, 0, SEEK_SET); for (i = 0; i < rb->filesize(fq); i++) @@ -420,27 +429,40 @@ if (memos_in_shown_memory > 0) { rb->lcd_puts(0,0,"Remove : Up"); - rb->lcd_puts(0,1,"Edit : Down"); + rb->lcd_puts(0,1,"Edit : Down"); rb->lcd_puts(0,2,"New :"); - rb->lcd_puts(2,3,"weekly : Left"); - rb->lcd_puts(2,4,"monthly : Play"); + rb->lcd_puts(2,3,"weekly : Left"); + rb->lcd_puts(2,4,"monthly : Play"); rb->lcd_puts(2,5,"annually : Right"); - rb->lcd_puts(2,6,"one off : On"); + rb->lcd_puts(2,6,"one off : On"); + #ifdef SANSA_E200 + rb->lcd_puts(2,7,"Return : Scroll Up"); + #endif + } else { rb->lcd_puts(0,0,"New :"); - rb->lcd_puts(2,1,"weekly : Left"); + rb->lcd_puts(2,1,"weekly : Left"); rb->lcd_puts(2,2,"monthly : Play"); - rb->lcd_puts(2,3,"anualy : Right"); + rb->lcd_puts(2,3,"anualy : Right"); rb->lcd_puts(2,4,"one off : On"); + #ifdef SANSA_E200 + rb->lcd_puts(2,5,"Return : Scroll Up"); + #endif } rb->lcd_update(); button = rb->button_get(true); switch (button) { + + #ifdef SANSA_E200 + case BUTTON_SCROLL_UP: + return false; + #else case BUTTON_OFF: return false; + #endif case BUTTON_LEFT: add_memo(shown,0); @@ -590,10 +612,13 @@ case BUTTON_PLAY: return edit_memo(lines_displayed, shown); - +#ifdef SANSA_E200 + case BUTTON_ON: + return false; +#else case BUTTON_OFF: return false; - +#endif default: if(rb->default_event_handler(button) == SYS_USB_CONNECTED) been_in_usb_mode = true; @@ -679,6 +704,33 @@ button = rb->button_get(true); switch (button) { + +#ifdef SANSA_E200 + + case BUTTON_ON: + return false; + + case BUTTON_DOWN: + case BUTTON_DOWN | BUTTON_REPEAT: + next_month(&shown, 0); + break; + + case BUTTON_UP: + case BUTTON_UP | BUTTON_REPEAT: + prev_month(&shown, 0); + break; + + case BUTTON_SCROLL_DOWN: + case BUTTON_SCROLL_DOWN | BUTTON_REPEAT: + next_day(&shown, 7); + break; + + case BUTTON_SCROLL_UP: + case BUTTON_SCROLL_UP | BUTTON_REPEAT: + prev_day(&shown, 7); + break; + +#else case BUTTON_OFF: return false; @@ -702,6 +754,8 @@ prev_day(&shown, 7); break; +#endif + case BUTTON_LEFT: case BUTTON_LEFT | BUTTON_REPEAT: prev_day(&shown, 1); Index: apps/plugins/SOURCES =================================================================== --- apps/plugins/SOURCES (revision 14238) +++ apps/plugins/SOURCES (working copy) @@ -1,4 +1,5 @@ /* plugins common to all models */ +HTML_Parser.c battery_bench.c chessclock.c credits.c Index: apps/plugins/HTML_Parser.c =================================================================== --- apps/plugins/HTML_Parser.c (revision 0) +++ apps/plugins/HTML_Parser.c (revision 0) @@ -0,0 +1,271 @@ +/***************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: HTML_Parser $ + * + * Copyright (C) 2007 Gerritt Gonzales + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * This program will parse html and htm files, suitable for reading + * in the text viewer. + * More formatting to come. + * Usage: Select a html or htm file, then select the txt file created + * for viewing. + ****************************************************************************/ + +#include "plugin.h" + +/* This macros must always be included. Should be placed at the top by + convention, although the actual position doesn't matter */ +PLUGIN_HEADER + +/* here is a global api struct pointer. while not strictly necessary, + it's nice not to have to pass the api pointer in all function calls + in the plugin */ +static struct plugin_api* rb; +#define plug_QUIT BUTTON_POWER +#define EXT_UNKNOWN -1 +#define EXT_l 0 +#define EXT_m 1 + +void cleanup(void *parameter){ + (void)parameter; + rb->backlight_set_timeout(rb->global_settings->backlight_timeout); +} + +static int getExt(char *filename){ + /* requires additional extention checking here */ + switch (filename[rb->strlen(filename)-1]){ + /*html*/ + case 'l': return EXT_l; + /*htm*/ + case 'm': return EXT_m; + /*anything else*/ + default: return EXT_UNKNOWN; + } + return EXT_UNKNOWN; /*error*/ +} + +int tag(int IN, int OUT){ + int inc=0; + int dec=0; + int size_of=1; + char buff[1]; + + dec=rb->read(IN, &buff[0], size_of); + inc=inc+dec; + if(dec==0){ + return inc; + } + + /* tag formatting here */ + /* looking for
and

tags also get by default*/ + if((buff[0]=='b') || (buff[0]=='B')){ + //check for r + dec=rb->read(IN, &buff[0], size_of); + inc=inc+dec; + if(dec==0){ + return inc; + } + if((buff[0]=='r') || (buff[0]=='R')){ + rb->write(OUT, "\n", 1); + } + if((buff[0]=='>')){ + /* Some possible formatting for the Bold tag */ + /* to much effort to look for the end tag */ + /* + rb->write(OUT, "\n", 1); + rb->write(OUT, "*", 1); + rb->write(OUT, "\n", 1); + */ + } + }else{ + /* some formatting for the

paragragh tag */ + if((buff[0]=='P') || (buff[0]=='p')){ + rb->write(OUT, "\n", 1); + rb->write(OUT, "\n", 1); + /* rb->write(OUT, " ", 1); */ + } + } + while (buff[0]!='>'){ + dec=rb->read(IN, &buff[0], size_of); + inc=inc+dec; + if(dec==0){ + return inc; + } + /* to deal with nested tags */ + /* this can have adverse affects on poorly tagged pages */ + /* a missed closing tag will leave the document missing characters */ + if(buff[0]=='<'){ + inc=inc+tag(IN, OUT); + } + } + return inc; +} + +int html_parse(char *param, char *newparam){ + int t; + int f=0; + int fd1=0; + int dec=0; + int inc=0; + int skipit=0; + int button; + int size_of=1; + int size_of_file=0; + char buffheader[26]; + char buff[1]; + + f = rb->open(param, O_RDONLY); + if(f < 0){ + rb->splash(HZ*2, "Can't open file %s", param); + }else{ + size_of_file=rb->filesize(f); + button = rb->button_get(false); + switch(button){ + case(plug_QUIT): + cleanup(NULL); + rb->close(f); + rb->lcd_clear_display(); + return PLUGIN_OK; + break; + default: + if (rb->default_event_handler_ex(button, cleanup, NULL) + == SYS_USB_CONNECTED) + return PLUGIN_USB_CONNECTED; + break; + } + fd1 = rb->open(newparam, O_CREAT|O_WRONLY|O_TRUNC); + rb->lcd_puts(0,6," * FILE Name:"); + rb->lcd_puts_scroll(0,7, newparam); + rb->lcd_update(); + /* build header */ + rb->snprintf(buffheader, 26, " \n\n"); + for(t=0; t< 26; t++){ + rb->write(fd1, &buffheader[t], 1); + } + while(incread(f, &buff[0], size_of); + if(dec>0){ + inc=inc+dec; + /* need to look for all the instances of &... ( , &, etc..) */ + /* another function for those. I need to look up HTML tagging info */ + + /* if a tag is found */ + if(buff[0]=='<'){ + /* formatting is in function tag() */ + inc=inc+tag(f, fd1); + }else{ + /* skip extra blank spaces */ + if(skipit>0 && buff[0]==' '){ + /* skipit */ + }else{ + /* Remove all newlines */ + /* Formatting will be done by HTML tag */ + /* if(skipit>0 && buff[0]=='\n'){*/ + if(buff[0]=='\n'){ + rb->write(fd1, " ", 1); + /* skipit */ + }else{ + /* Remove all carriage returns */ + if(buff[0]=='\r'){ + /* skipit */ + }else{ + rb->write(fd1, &buff[0], 1); + skipit=0; + } + } + /* if(buff[0]==' ' || buff[0]=='\n'){ */ + if(buff[0]==' '){ + skipit++; + } + } + } + } + } + } + rb->snprintf(buffheader, 26, "\n\n "); + for(t=0; t< 26; t++){ + rb->write(fd1, &buffheader[t], 1); + } + rb->close(f); + rb->close(fd1); + if(fd1<0){ + rb->splash(HZ*2, "Unable to write file!"); + } + + rb->button_get_w_tmo(250); + return 1; +} + +/* this is the plugin entry point */ +enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ + rb = api; + const char tempy[]={NULL}; + char newparameter[256]; + int length, button, w, h; + bool prev_show_statusbar; + + prev_show_statusbar = rb->global_settings->statusbar; + rb->global_settings->statusbar = false; + if (!parameter){ + rb->splash(HZ*2, "Select a file to convert and use Open With..."); + }else{ + rb->lcd_getstringsize("A",&w,&h); + length=rb->strlen((char*)parameter); + rb->snprintf(newparameter, length+1, "%s", (char*)parameter); + rb->lcd_puts(4,0," * HTML Parser *"); + rb->lcd_drawline(0,h+5,LCD_WIDTH-1,h+5); + rb->lcd_drawline(0,LCD_HEIGHT-h-7,LCD_WIDTH-1,LCD_HEIGHT-h-7); + rb->lcd_update(); + + button = rb->button_get(false); + switch(button){ + case(plug_QUIT): + cleanup(NULL); + rb->lcd_clear_display(); + return PLUGIN_OK; + break; + default: + if (rb->default_event_handler_ex(button, cleanup, NULL) + == SYS_USB_CONNECTED) + return PLUGIN_USB_CONNECTED; + break; + } + switch (getExt(parameter)){ + case EXT_l:rb->lcd_putsxy(0,(LCD_HEIGHT-h-5), "* Converting html to txt *"); + /* change ext to .pla */ + newparameter[rb->strlen(newparameter)-4]='t'; + newparameter[rb->strlen(newparameter)-3]='x'; + newparameter[rb->strlen(newparameter)-2]='t'; + newparameter[rb->strlen(newparameter)-1]=(char)*tempy; + /* function call here for conversion */ + html_parse(parameter, newparameter); + break; + case EXT_m:rb->lcd_putsxy(0,(LCD_HEIGHT-h-5), "* Converting htm to txt *"); + /* chnage ext to .pla */ + newparameter[rb->strlen(newparameter)-3]='t'; + newparameter[rb->strlen(newparameter)-2]='x'; + newparameter[rb->strlen(newparameter)-1]='t'; + newparameter[rb->strlen(newparameter)-0]=(char)*tempy; + /* function call here for conversion */ + html_parse(parameter, newparameter); + break; + case EXT_UNKNOWN:rb->splash(HZ*2, "Select a (.htm) or (.html) file"); + return PLUGIN_OK; + } + /* I would like to start the viewer here with the new file name */ + rb->set_current_file(newparameter); + } + rb->global_settings->statusbar = prev_show_statusbar; + return PLUGIN_OK; +} Index: apps/filetypes.c =================================================================== --- apps/filetypes.c (revision 14238) +++ apps/filetypes.c (working copy) @@ -43,7 +43,7 @@ /* max filetypes (plugins & icons stored here) */ #if CONFIG_CODEC == SWCODEC -#define MAX_FILETYPES 75 +#define MAX_FILETYPES 77 #else #define MAX_FILETYPES 48 #endif