Index: main_menu.c =================================================================== RCS file: /cvsroot/rockbox/apps/main_menu.c,v retrieving revision 1.55 diff -b -u -r1.55 main_menu.c --- main_menu.c 31 Aug 2002 23:07:11 -0000 1.55 +++ main_menu.c 2 Sep 2002 09:33:59 -0000 @@ -35,6 +35,11 @@ #include "powermgmt.h" #include "sound_menu.h" +/*For the seeking stuffs*/ +#include +#include +/************************/ + #ifdef HAVE_LCD_BITMAP #include "bmp.h" #include "icons.h" @@ -49,6 +54,122 @@ #endif /* End HAVE_LCD_BITMAP */ +/*Change made by FX Houard... Seeking stuffs*/ + +Menu seek(void) +{ + char *indir="/";/*Well, I don't know yet how the UI will send current dir + name to the function. So, for the moment, i put it bye + hand.*/ + DIR directory=opendir(indir);/*The directory used for seek*/ + /*Here (or somewhere else), should be a user interface to input the + pattern*/ + seek_next("the u",directory);/*No user input yet, so, just for test + issue...*/ + seek_next("the u",directory);/*this way, you get the second corresponding + item*/ + return MENU_OK; +} +void seek_next(char *pattern, DIR dir) +{ + char delimitor = ' ';/* would be nice to define a never-user char to do it + so the user input interface would have a delimitor + char, different from ' '*/ + char token[strlen(pattern)]; + char *token_ptr; + struct dirent entry; + struct mp3entry id3; + char full_path[MAX_PATH];/*Needed to have the full name of file. + Maybe someone has a better idea ?*/ + bool not_wrong=true;/*Sorry, I'm a bad coder*/ + bool done=false;/*Well, i'm really a bad coder*/ + strcpy(token, pattern);// Needed because of the use of strtok + token_ptr=strtok(token, &delimitor); + + while (!done) // This loop scan files + { + not_wrong=true; /*means that the file tested has not yet being + identified as a wrong one*/ + strncpy(full_path,"/",MAX_PATH); + full_path[0]='/'; + entry=*readdir(dir); + strcat(full_path,entry.d_name); + id3.title=NULL; + id3.artist=NULL; + id3.album=NULL; + + if(!mp3info(&id3,full_path)) //We fill the id3 with the -euh- the id3... + { + + while ( not_wrong && (token_ptr != NULL))/* In This loop we scan + the different tokens*/ + { + not_wrong=false; + if (id3.title!=NULL && !not_wrong) + { + if (strcasestr(id3.title,token_ptr)!=NULL ) + { + token_ptr=strtok(NULL,&delimitor); + not_wrong=true; + } + } + if (id3.artist!=NULL && !not_wrong) + { + if (strcasestr(id3.artist,token_ptr)!=NULL) + { + token_ptr=strtok(NULL,&delimitor); + not_wrong=true; + + } + } + if (id3.album!=NULL && !not_wrong) + { + if (strcasestr(id3.album,token_ptr)!=NULL) + { + token_ptr=strtok(NULL,&delimitor); + not_wrong=true; + } + } + if (!not_wrong) + { + if (strcasestr(entry.d_name,token_ptr)!=NULL) + { + token_ptr=strtok(NULL,&delimitor); + not_wrong=true; + } + } + + } + } + if (token_ptr==NULL)/* the token-loop has ended, and + the file is good!*/ + { + + done= true; + } + else + { + strcpy(token,pattern);/*let's re-start from the beginning*/ + token_ptr=strtok(token,&delimitor); + + } + + + } + /*Here we should add a user interface, wich would enable to play the + file, or to search next one*/ + + lcd_clear_display(); + lcd_puts(0,0,entry.d_name); + lcd_puts(0,1,id3.title); + lcd_puts(0,2,id3.artist); + lcd_puts(0,3,id3.album); + lcd_update(); + sleep (500); + +}; +/*End of the seeking stuff body*/ + int show_logo( void ) { #ifdef HAVE_LCD_BITMAP @@ -203,6 +324,8 @@ /* main menu */ struct menu_items items[] = { + /*to test seeking stuff, uncomment this*/ + //{ "Seek Test", seek }, { "Sound Settings", sound_menu }, { "General Settings", settings_menu }, #ifdef HAVE_LCD_BITMAP