2002-05-16 12:53:40 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Daniel Stenberg
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2002-05-16 14:48:40 +00:00
|
|
|
#include <stdio.h>
|
2002-05-16 12:53:40 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2002-08-15 12:28:52 +00:00
|
|
|
#include "applimits.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "dir.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-08-31 04:58:35 +00:00
|
|
|
#include "backlight.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
2002-06-30 13:23:58 +00:00
|
|
|
#include "usb.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#include "tree.h"
|
2002-05-24 15:51:39 +00:00
|
|
|
#include "main_menu.h"
|
2002-05-29 16:38:19 +00:00
|
|
|
#include "sprintf.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2002-06-07 14:23:32 +00:00
|
|
|
#include "playlist.h"
|
2002-06-14 10:39:11 +00:00
|
|
|
#include "menu.h"
|
2005-11-17 20:14:59 +00:00
|
|
|
#include "gwps.h"
|
2002-06-27 09:12:29 +00:00
|
|
|
#include "settings.h"
|
2002-07-22 22:45:20 +00:00
|
|
|
#include "status.h"
|
2002-06-30 13:23:58 +00:00
|
|
|
#include "debug.h"
|
2002-08-26 13:21:14 +00:00
|
|
|
#include "ata.h"
|
2002-09-03 09:44:08 +00:00
|
|
|
#include "rolo.h"
|
2002-09-03 07:53:51 +00:00
|
|
|
#include "icons.h"
|
2002-09-18 14:08:05 +00:00
|
|
|
#include "lang.h"
|
2002-09-24 12:40:52 +00:00
|
|
|
#include "language.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "screens.h"
|
2003-01-15 14:52:53 +00:00
|
|
|
#include "keyboard.h"
|
2004-01-14 00:13:04 +00:00
|
|
|
#include "bookmark.h"
|
2003-03-12 20:21:30 +00:00
|
|
|
#include "onplay.h"
|
2003-05-09 16:01:21 +00:00
|
|
|
#include "buffer.h"
|
2003-06-29 16:33:04 +00:00
|
|
|
#include "plugin.h"
|
2003-12-04 00:08:25 +00:00
|
|
|
#include "power.h"
|
2004-03-12 10:20:33 +00:00
|
|
|
#include "action.h"
|
2004-03-27 00:11:01 +00:00
|
|
|
#include "talk.h"
|
2004-05-21 20:08:24 +00:00
|
|
|
#include "filetypes.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
#include "misc.h"
|
2005-01-17 11:39:46 +00:00
|
|
|
#include "filetree.h"
|
2006-03-26 11:33:42 +00:00
|
|
|
#include "tagtree.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2005-02-04 10:37:21 +00:00
|
|
|
#include "recorder/recording.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif
|
2005-02-05 19:57:19 +00:00
|
|
|
#include "rtc.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
#include "dircache.h"
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-03-26 11:33:42 +00:00
|
|
|
#include "tagcache.h"
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-11-18 02:07:02 +00:00
|
|
|
#include "yesno.h"
|
2006-07-01 23:48:30 +00:00
|
|
|
#include "gwps-common.h"
|
2006-08-05 20:19:10 +00:00
|
|
|
#include "eeprom_settings.h"
|
2006-10-19 09:42:58 +00:00
|
|
|
#include "scrobbler.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* gui api */
|
|
|
|
#include "list.h"
|
|
|
|
#include "statusbar.h"
|
|
|
|
#include "splash.h"
|
|
|
|
#include "buttonbar.h"
|
2005-11-02 00:55:46 +00:00
|
|
|
#include "textarea.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2006-11-13 00:45:21 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-05-21 11:00:02 +00:00
|
|
|
#include "backdrop.h"
|
|
|
|
#endif
|
|
|
|
|
2003-12-07 16:57:43 +00:00
|
|
|
/* a table for the know file types */
|
2004-08-01 23:34:44 +00:00
|
|
|
const struct filetype filetypes[] = {
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "mp3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "mp2", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "mpa", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-04-07 21:07:04 +00:00
|
|
|
/* Temporary hack to allow playlist creation */
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "mp1", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "ogg", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "wma", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "wav", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2006-02-01 16:42:02 +00:00
|
|
|
{ "flac",TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "ac3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "a52", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "mpc", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "wv", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-09-22 21:55:37 +00:00
|
|
|
{ "m4a", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-10-31 20:56:29 +00:00
|
|
|
{ "mp4", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-11-11 19:45:36 +00:00
|
|
|
{ "shn", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2006-02-01 16:42:02 +00:00
|
|
|
{ "aif", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ "aiff",TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2006-07-18 18:33:12 +00:00
|
|
|
{ "sid", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2006-09-25 16:13:05 +00:00
|
|
|
{ "adx", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
2005-04-07 21:07:04 +00:00
|
|
|
#endif
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "m3u", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
2006-09-10 10:59:51 +00:00
|
|
|
{ "m3u8", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "cfg", TREE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG },
|
|
|
|
{ "wps", TREE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS },
|
2005-11-17 20:14:59 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
{ "rwps", TREE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS },
|
2006-02-02 20:42:56 +00:00
|
|
|
#endif
|
2006-11-13 00:45:21 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-02-02 20:42:56 +00:00
|
|
|
{ "bmp", TREE_ATTR_BMP, Icon_Wps, VOICE_EXT_WPS },
|
2006-04-02 12:23:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TUNER
|
|
|
|
{ "fmr", TREE_ATTR_FMR, Icon_Preset, LANG_FMR },
|
2005-11-17 20:14:59 +00:00
|
|
|
#endif
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "lng", TREE_ATTR_LNG, Icon_Language, LANG_LANGUAGE },
|
|
|
|
{ "rock",TREE_ATTR_ROCK,Icon_Plugin, VOICE_EXT_ROCK },
|
2003-12-07 16:57:43 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "fnt", TREE_ATTR_FONT,Icon_Font, VOICE_EXT_FONT },
|
2006-03-29 16:21:42 +00:00
|
|
|
{ "kbd", TREE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD },
|
2003-12-07 16:57:43 +00:00
|
|
|
#endif
|
2005-09-02 15:05:35 +00:00
|
|
|
{ "bmark",TREE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK },
|
2005-03-31 10:50:15 +00:00
|
|
|
#ifdef BOOTFILE_EXT
|
2005-08-24 00:09:42 +00:00
|
|
|
{ BOOTFILE_EXT, TREE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ },
|
2003-12-07 16:57:43 +00:00
|
|
|
#endif /* #ifndef SIMULATOR */
|
|
|
|
};
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
struct gui_synclist tree_lists;
|
|
|
|
|
|
|
|
/* I put it here because other files doesn't use it yet,
|
|
|
|
* but should be elsewhere since it will be used mostly everywhere */
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
struct gui_buttonbar tree_buttonbar;
|
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
static struct tree_context tc;
|
|
|
|
|
|
|
|
bool boot_changed = false;
|
|
|
|
|
|
|
|
char lastfile[MAX_PATH];
|
2005-01-18 22:45:00 +00:00
|
|
|
static char lastdir[MAX_PATH];
|
|
|
|
static int lasttable, lastextra, lastfirstpos;
|
|
|
|
static int max_files = 0;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2003-01-15 14:52:53 +00:00
|
|
|
static bool reload_dir = false;
|
2002-05-28 16:26:12 +00:00
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
static bool start_wps = false;
|
2005-01-17 11:39:46 +00:00
|
|
|
static bool dirbrowse(void);
|
2005-10-28 00:00:00 +00:00
|
|
|
static int curr_context = false;/* id3db or tree*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* removes the extension of filename (if it doesn't start with a .)
|
|
|
|
* puts the result in buffer
|
|
|
|
*/
|
|
|
|
char * strip_extension(char * filename, char * buffer)
|
|
|
|
{
|
|
|
|
int dotpos;
|
|
|
|
char * dot=strrchr(filename, '.');
|
|
|
|
if(dot!=0 && filename[0]!='.')
|
|
|
|
{
|
|
|
|
dotpos = dot-filename;
|
|
|
|
strncpy(buffer, filename, dotpos);
|
|
|
|
buffer[dotpos]='\0';
|
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return(filename);
|
|
|
|
}
|
2005-10-29 02:33:19 +00:00
|
|
|
char * tree_get_filename(int selected_item, void * data, char *buffer)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
2005-10-28 00:00:00 +00:00
|
|
|
char *name;
|
|
|
|
int attr=0;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-10-29 02:33:19 +00:00
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
|
|
|
|
2006-04-15 13:57:15 +00:00
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
return tagtree_get_entry(&tc, selected_item)->name;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-04-15 13:57:15 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-04-15 13:57:15 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct entry* dc = local_tc->dircache;
|
2005-10-28 00:00:00 +00:00
|
|
|
struct entry* e = &dc[selected_item];
|
|
|
|
name = e->name;
|
|
|
|
attr = e->attr;
|
|
|
|
}
|
|
|
|
/* if any file filter is on, and if it's not a directory,
|
|
|
|
* strip the extension */
|
|
|
|
|
2005-10-29 02:33:19 +00:00
|
|
|
if ( (*(local_tc->dirfilter) != SHOW_ID3DB) && !(attr & ATTR_DIRECTORY)
|
|
|
|
&& (*(local_tc->dirfilter) != SHOW_ALL) )
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
return(strip_extension(name, buffer));
|
|
|
|
}
|
|
|
|
return(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-29 02:33:19 +00:00
|
|
|
void tree_get_fileicon(int selected_item, void * data, ICON * icon)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-10-29 02:33:19 +00:00
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
2005-10-28 00:00:00 +00:00
|
|
|
if (id3db) {
|
2006-03-26 11:33:42 +00:00
|
|
|
*icon = (ICON)tagtree_get_icon(&tc);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
struct entry* dc = local_tc->dircache;
|
2005-10-28 00:00:00 +00:00
|
|
|
struct entry* e = &dc[selected_item];
|
2005-12-05 22:44:42 +00:00
|
|
|
*icon = (ICON)filetype_get_icon(e->attr);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-01 21:05:43 +00:00
|
|
|
|
2004-09-10 20:51:12 +00:00
|
|
|
bool check_rockboxdir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2004-09-05 16:50:07 +00:00
|
|
|
DIR *dir = opendir(ROCKBOX_DIR);
|
|
|
|
if(!dir)
|
2006-04-01 13:36:33 +00:00
|
|
|
{ /* No need to localise this message.
|
|
|
|
If .rockbox is missing, it wouldn't work anyway */
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].clear_display();
|
2006-04-01 13:36:33 +00:00
|
|
|
gui_syncsplash(HZ*2, true, "No .rockbox directory");
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].clear_display();
|
2006-04-01 13:36:33 +00:00
|
|
|
gui_syncsplash(HZ*2, true, "Installation incomplete");
|
2004-09-10 20:51:12 +00:00
|
|
|
return false;
|
2004-09-05 16:50:07 +00:00
|
|
|
}
|
|
|
|
closedir(dir);
|
2004-09-10 20:51:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void browse_root(void)
|
|
|
|
{
|
2005-11-17 20:14:59 +00:00
|
|
|
gui_sync_wps_screen_init();
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2004-09-10 20:51:12 +00:00
|
|
|
filetype_init();
|
|
|
|
check_rockboxdir();
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, "/");
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-06-29 17:39:18 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].double_height(false);
|
2005-06-29 17:39:18 +00:00
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
gui_buttonbar_init(&tree_buttonbar);
|
|
|
|
/* since archos only have one screen, no need to create more than that */
|
|
|
|
gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) );
|
|
|
|
#endif
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1);
|
2005-11-16 17:23:49 +00:00
|
|
|
gui_synclist_set_icon_callback(&tree_lists,
|
|
|
|
global_settings.show_icons?&tree_get_fileicon:NULL);
|
2004-09-10 20:51:12 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-01-17 11:39:46 +00:00
|
|
|
dirbrowse();
|
2003-01-31 08:43:12 +00:00
|
|
|
#else
|
2005-01-17 11:39:46 +00:00
|
|
|
if (!dirbrowse()) {
|
2003-01-31 08:43:12 +00:00
|
|
|
DEBUGF("No filesystem found. Have you forgotten to create it?\n");
|
|
|
|
}
|
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2004-08-01 23:34:44 +00:00
|
|
|
void tree_get_filetypes(const struct filetype** types, int* count)
|
2004-05-21 20:08:24 +00:00
|
|
|
{
|
|
|
|
*types = filetypes;
|
|
|
|
*count = sizeof(filetypes) / sizeof(*filetypes);
|
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
struct tree_context* tree_get_context(void)
|
|
|
|
{
|
|
|
|
return &tc;
|
|
|
|
}
|
|
|
|
|
2004-03-28 10:21:58 +00:00
|
|
|
/* talkbox hovering delay, to avoid immediate disk activity */
|
2004-04-04 19:08:44 +00:00
|
|
|
#define HOVER_DELAY (HZ/2)
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Returns the position of a given file in the current directory
|
|
|
|
* returns -1 if not found
|
|
|
|
*/
|
|
|
|
int tree_get_file_position(char * filename)
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2006-03-26 11:33:42 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* use lastfile to determine the selected item (default=0) */
|
|
|
|
for (i=0; i < tc.filesindir; i++)
|
2003-01-24 10:56:59 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
struct entry* dc = tc.dircache;
|
|
|
|
struct entry* e = &dc[i];
|
|
|
|
if (!strcasecmp(e->name, filename))
|
|
|
|
return(i);
|
2003-01-24 10:56:59 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
return(-1);/* no file can match, returns undefined */
|
2004-03-16 13:44:56 +00:00
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Called when a new dir is loaded (for example when returning from other apps ...)
|
|
|
|
* also completely redraws the tree
|
|
|
|
*/
|
|
|
|
static int update_dir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2006-10-25 10:17:57 +00:00
|
|
|
bool changed = false;
|
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 23:07:23 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Checks for changes */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (id3db) {
|
2005-01-18 22:45:00 +00:00
|
|
|
if (tc.currtable != lasttable ||
|
|
|
|
tc.currextra != lastextra ||
|
2006-06-07 20:42:42 +00:00
|
|
|
tc.firstpos != lastfirstpos ||
|
|
|
|
reload_dir)
|
2005-01-18 22:45:00 +00:00
|
|
|
{
|
2006-03-26 11:33:42 +00:00
|
|
|
if (tagtree_load(&tc) < 0)
|
2005-01-18 22:45:00 +00:00
|
|
|
return -1;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-18 22:45:00 +00:00
|
|
|
lasttable = tc.currtable;
|
|
|
|
lastextra = tc.currextra;
|
|
|
|
lastfirstpos = tc.firstpos;
|
2005-10-28 00:00:00 +00:00
|
|
|
changed = true;
|
2005-01-18 22:45:00 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if the tc.currdir has been changed, reload it ...*/
|
2005-01-17 11:39:46 +00:00
|
|
|
if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) {
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
if (ft_load(&tc, NULL) < 0)
|
2005-01-17 11:39:46 +00:00
|
|
|
return -1;
|
2005-01-18 22:45:00 +00:00
|
|
|
strcpy(lastdir, tc.currdir);
|
2005-10-28 00:00:00 +00:00
|
|
|
changed = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if selected item is undefined */
|
|
|
|
if (tc.selected_item == -1)
|
2005-01-18 22:45:00 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
/* use lastfile to determine the selected item */
|
|
|
|
tc.selected_item = tree_get_file_position(lastfile);
|
2002-09-09 17:32:15 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If the file doesn't exists, select the first one (default) */
|
|
|
|
if(tc.selected_item < 0)
|
|
|
|
tc.selected_item = 0;
|
|
|
|
changed = true;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
if (changed)
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2006-10-25 10:17:57 +00:00
|
|
|
if(
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
!id3db &&
|
|
|
|
#endif
|
|
|
|
(tc.dirfull ||
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.filesindir == global_settings.max_files_in_dir) )
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2006-04-01 13:36:33 +00:00
|
|
|
gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL));
|
2002-09-03 20:47:23 +00:00
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-09-19 12:36:21 +00:00
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
if (global_settings.show_path_in_browser == SHOW_PATH_FULL
|
|
|
|
|| global_settings.show_path_in_browser == SHOW_PATH_CURRENT)
|
|
|
|
{
|
|
|
|
gui_synclist_set_title(&tree_lists, tagtree_get_title(&tc),
|
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Must clear the title as the list is reused */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-09-19 12:36:21 +00:00
|
|
|
{
|
2006-08-23 20:02:06 +00:00
|
|
|
if (global_settings.show_path_in_browser == SHOW_PATH_FULL)
|
|
|
|
{
|
|
|
|
gui_synclist_set_title(&tree_lists, tc.currdir,
|
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
|
|
|
}
|
|
|
|
else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT)
|
|
|
|
{
|
|
|
|
char *title = strrchr(tc.currdir, '/') + 1;
|
|
|
|
if (*title == '\0')
|
|
|
|
{
|
|
|
|
/* Display nothing for the root dir */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gui_synclist_set_title(&tree_lists, title,
|
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-15 12:23:55 +00:00
|
|
|
}
|
2006-08-23 20:02:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Must clear the title as the list is reused */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
|
|
|
}
|
2006-08-15 09:38:13 +00:00
|
|
|
}
|
2006-09-19 12:36:21 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
|
2005-11-16 17:23:49 +00:00
|
|
|
gui_synclist_set_icon_callback(&tree_lists,
|
|
|
|
global_settings.show_icons?&tree_get_fileicon:NULL);
|
2005-11-09 01:17:57 +00:00
|
|
|
if( tc.selected_item >= tc.filesindir)
|
|
|
|
tc.selected_item=tc.filesindir-1;
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_item(&tree_lists, tc.selected_item);
|
|
|
|
#ifdef HAS_BUTTONBAR
|
2005-05-16 11:50:46 +00:00
|
|
|
if (global_settings.buttonbar) {
|
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2006-08-07 21:24:22 +00:00
|
|
|
gui_buttonbar_set(&tree_buttonbar, str(LANG_SYSFONT_DIRBROWSE_F1),
|
|
|
|
str(LANG_SYSFONT_DIRBROWSE_F2),
|
|
|
|
str(LANG_SYSFONT_DIRBROWSE_F3));
|
2005-05-16 11:50:46 +00:00
|
|
|
else
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_buttonbar_set(&tree_buttonbar, "<<<", "", "");
|
|
|
|
gui_buttonbar_draw(&tree_buttonbar);
|
2004-03-16 13:44:56 +00:00
|
|
|
}
|
2004-10-09 20:54:15 +00:00
|
|
|
#endif
|
2006-07-01 10:31:50 +00:00
|
|
|
gui_synclist_draw(&tree_lists);
|
|
|
|
gui_syncstatusbar_draw(&statusbars, true);
|
2005-01-17 11:39:46 +00:00
|
|
|
return tc.filesindir;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
/* load tracks from specified directory to resume play */
|
2004-08-18 01:09:31 +00:00
|
|
|
void resume_directory(const char *dir)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-04-03 18:52:58 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2005-01-25 08:55:21 +00:00
|
|
|
if (ft_load(&tc, dir) < 0)
|
2003-07-01 21:05:43 +00:00
|
|
|
return;
|
|
|
|
lastdir[0] = 0;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
ft_build_playlist(&tc, 0);
|
2006-04-03 18:52:58 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-04-03 18:52:58 +00:00
|
|
|
if (id3db)
|
|
|
|
tagtree_load(&tc);
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the current working directory and also writes cwd to buf if
|
|
|
|
non-NULL. In case of error, returns NULL. */
|
|
|
|
char *getcwd(char *buf, int size)
|
|
|
|
{
|
|
|
|
if (!buf)
|
2005-01-17 11:39:46 +00:00
|
|
|
return tc.currdir;
|
2003-07-01 21:05:43 +00:00
|
|
|
else if (size > 0)
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
strncpy(buf, tc.currdir, size);
|
2003-07-01 21:05:43 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force a reload of the directory next time directory browser is called */
|
|
|
|
void reload_directory(void)
|
|
|
|
{
|
|
|
|
reload_dir = true;
|
|
|
|
}
|
|
|
|
|
2005-06-26 15:21:29 +00:00
|
|
|
static void start_resume(bool just_powered_on)
|
2002-08-16 14:41:47 +00:00
|
|
|
{
|
2005-06-29 12:23:09 +00:00
|
|
|
bool do_resume = false;
|
|
|
|
if ( global_settings.resume_index != -1 ) {
|
2002-08-16 14:41:47 +00:00
|
|
|
DEBUGF("Resume index %X offset %X\n",
|
|
|
|
global_settings.resume_index,
|
|
|
|
global_settings.resume_offset);
|
|
|
|
|
2005-06-29 12:23:09 +00:00
|
|
|
#ifdef HAVE_ALARM_MOD
|
|
|
|
if ( rtc_check_alarm_started(true) ) {
|
|
|
|
rtc_enable_alarm(false);
|
|
|
|
do_resume = true;
|
|
|
|
}
|
|
|
|
#endif
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2005-06-29 12:23:09 +00:00
|
|
|
/* always resume? */
|
|
|
|
if ( global_settings.resume || ! just_powered_on)
|
2006-09-26 10:03:56 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
|
|
|
{
|
|
|
|
if ( just_powered_on )
|
|
|
|
{
|
|
|
|
if ( !global_settings.unplug_autoresume
|
|
|
|
|| headphones_inserted() )
|
|
|
|
do_resume = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
do_resume = true;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
do_resume = true;
|
|
|
|
#endif
|
2005-06-29 12:23:09 +00:00
|
|
|
|
|
|
|
if (! do_resume) return;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
if (playlist_resume() != -1)
|
|
|
|
{
|
|
|
|
playlist_start(global_settings.resume_index,
|
|
|
|
global_settings.resume_offset);
|
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
start_wps = true;
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
2005-06-26 15:21:29 +00:00
|
|
|
else return;
|
2005-12-05 22:44:42 +00:00
|
|
|
}
|
|
|
|
else if (! just_powered_on) {
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_NOTHING_TO_RESUME));
|
2002-08-16 14:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Selects a file and update tree context properly */
|
2002-09-09 14:25:39 +00:00
|
|
|
void set_current_file(char *path)
|
|
|
|
{
|
|
|
|
char *name;
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-03-11 08:18:28 +00:00
|
|
|
/* in ID3DB mode it is a bad idea to call this function */
|
|
|
|
/* (only happens with `follow playlist') */
|
|
|
|
if( *tc.dirfilter == SHOW_ID3DB )
|
|
|
|
return;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-03-11 08:18:28 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* separate directory from filename */
|
2005-10-28 00:00:00 +00:00
|
|
|
/* gets the directory's name and put it into tc.currdir */
|
2002-09-17 07:42:21 +00:00
|
|
|
name = strrchr(path+1,'/');
|
2002-09-09 14:25:39 +00:00
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
*name = 0;
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, path);
|
2002-09-09 14:25:39 +00:00
|
|
|
*name = '/';
|
|
|
|
name++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, "/");
|
2002-09-09 14:25:39 +00:00
|
|
|
name = path+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(lastfile, name);
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* undefined item selected */
|
|
|
|
tc.selected_item = -1;
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If we changed dir we must recalculate the dirlevel
|
|
|
|
and adjust the selected history properly */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (strncmp(tc.currdir,lastdir,sizeof(lastdir)))
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.dirlevel = 0;
|
|
|
|
tc.selected_item_history[tc.dirlevel] = -1;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* use '/' to calculate dirlevel */
|
2005-10-28 00:00:00 +00:00
|
|
|
/* FIXME : strlen(path) : crazy oO better to store it at
|
|
|
|
the beginning */
|
|
|
|
int path_len = strlen(path) + 1;
|
|
|
|
for (i = 1; i < path_len; i++)
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
|
|
|
if (path[i] == '/')
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel++;
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.selected_item_history[tc.dirlevel] = -1;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-17 11:39:46 +00:00
|
|
|
static bool check_changed_id3mode(bool currmode)
|
|
|
|
{
|
|
|
|
if (currmode != (global_settings.dirfilter == SHOW_ID3DB)) {
|
|
|
|
currmode = global_settings.dirfilter == SHOW_ID3DB;
|
|
|
|
if (currmode) {
|
2005-06-23 01:31:26 +00:00
|
|
|
curr_context=CONTEXT_ID3DB;
|
2006-09-19 11:54:33 +00:00
|
|
|
tc.dirlevel = 0;
|
2006-03-26 11:33:42 +00:00
|
|
|
tagtree_load(&tc);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else
|
2005-06-23 01:31:26 +00:00
|
|
|
{
|
2006-09-19 11:54:33 +00:00
|
|
|
tc.dirlevel = 0;
|
2005-06-23 01:31:26 +00:00
|
|
|
curr_context=CONTEXT_TREE;
|
2005-01-18 22:50:47 +00:00
|
|
|
ft_load(&tc, NULL);
|
2006-08-16 04:31:37 +00:00
|
|
|
reload_dir = true;
|
2005-06-23 01:31:26 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
return currmode;
|
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* main loop, handles key events */
|
2005-01-17 11:39:46 +00:00
|
|
|
static bool dirbrowse(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2002-08-08 12:06:38 +00:00
|
|
|
int numentries=0;
|
2002-07-15 22:46:38 +00:00
|
|
|
char buf[MAX_PATH];
|
2005-10-28 00:00:00 +00:00
|
|
|
int lasti = -1;
|
2006-09-17 08:30:17 +00:00
|
|
|
unsigned button, returned_button;
|
2002-09-03 20:47:23 +00:00
|
|
|
bool reload_root = false;
|
2005-01-17 11:39:46 +00:00
|
|
|
int lastfilter = *tc.dirfilter;
|
2002-09-03 20:47:23 +00:00
|
|
|
bool lastsortcase = global_settings.sort_case;
|
2003-01-24 10:56:59 +00:00
|
|
|
bool need_update = true;
|
2003-09-29 21:26:53 +00:00
|
|
|
bool exit_func = false;
|
2004-03-28 10:21:58 +00:00
|
|
|
long thumbnail_time = -1; /* for delaying a thumbnail */
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
char* currdir = tc.currdir; /* just a shortcut */
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 23:07:23 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2003-01-24 10:56:59 +00:00
|
|
|
|
2005-06-23 01:31:26 +00:00
|
|
|
if (id3db)
|
|
|
|
curr_context=CONTEXT_ID3DB;
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-06-23 01:31:26 +00:00
|
|
|
curr_context=CONTEXT_TREE;
|
2005-10-28 00:00:00 +00:00
|
|
|
tc.selected_item = 0;
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel=0;
|
2005-01-18 22:45:00 +00:00
|
|
|
tc.firstpos=0;
|
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
|
|
|
lastfirstpos = 0;
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2005-02-04 10:37:21 +00:00
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES) {
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#ifndef SIMULATOR
|
2005-09-02 07:59:42 +00:00
|
|
|
if (global_settings.rec_startup) {
|
|
|
|
/* We fake being in the menu structure by calling
|
|
|
|
the appropriate parent when we drop out of each screen */
|
2006-08-31 19:28:58 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
/* Put in a 1 sec pause to slow bootup or the recording codecs
|
|
|
|
won't initialize */
|
|
|
|
sleep(HZ);
|
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
recording_screen(false);
|
2005-02-04 10:37:21 +00:00
|
|
|
rec_menu();
|
|
|
|
main_menu();
|
|
|
|
}
|
2005-09-02 07:59:42 +00:00
|
|
|
else
|
2005-02-04 10:37:21 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2005-09-02 07:59:42 +00:00
|
|
|
start_resume(true);
|
|
|
|
|
2005-02-04 10:37:21 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If we don't need to show the wps, draw the dir */
|
2005-01-21 15:42:47 +00:00
|
|
|
if (!start_wps) {
|
2005-10-28 00:00:00 +00:00
|
|
|
numentries = update_dir();
|
2005-01-21 15:42:47 +00:00
|
|
|
if (numentries == -1)
|
|
|
|
return false; /* currdir is not a directory */
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-21 15:42:47 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && numentries==0)
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_syncsplash(HZ*2, true, str(LANG_NO_FILES));
|
2005-01-21 15:42:47 +00:00
|
|
|
return false; /* No files found for rockbox_browser() */
|
|
|
|
}
|
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
|
|
|
|
while(1) {
|
2005-01-17 11:39:46 +00:00
|
|
|
struct entry *dircache = tc.dircache;
|
2002-06-25 13:26:04 +00:00
|
|
|
bool restore = false;
|
2005-03-31 10:50:15 +00:00
|
|
|
#ifdef BOOTFILE
|
2003-06-29 22:39:35 +00:00
|
|
|
if (boot_changed) {
|
2005-11-18 02:07:02 +00:00
|
|
|
char *lines[]={str(LANG_BOOT_CHANGED), str(LANG_REBOOT_NOW)};
|
|
|
|
struct text_message message={lines, 2};
|
|
|
|
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
|
|
|
|
rolo_load("/" BOOTFILE);
|
2003-06-29 22:39:35 +00:00
|
|
|
restore = true;
|
|
|
|
boot_changed = false;
|
|
|
|
}
|
|
|
|
#endif
|
2006-08-15 12:27:07 +00:00
|
|
|
button = get_action(CONTEXT_TREE,HZ/5);
|
2006-11-06 10:11:51 +00:00
|
|
|
returned_button = gui_synclist_do_button(&tree_lists, button,LIST_WRAP_UNLESS_HELD);
|
2006-10-04 20:12:51 +00:00
|
|
|
if (returned_button)
|
|
|
|
need_update = true;
|
2006-09-17 08:30:17 +00:00
|
|
|
if (returned_button == ACTION_STD_CANCEL)
|
|
|
|
button = ACTION_STD_CANCEL;
|
2003-06-29 22:39:35 +00:00
|
|
|
|
2002-07-27 20:55:39 +00:00
|
|
|
switch ( button ) {
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_OK:
|
2005-10-28 00:00:00 +00:00
|
|
|
/* nothing to do if no files to display */
|
|
|
|
if ( numentries == 0 )
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-03-26 11:33:42 +00:00
|
|
|
switch (id3db?tagtree_enter(&tc):ft_enter(&tc))
|
2006-10-25 10:17:57 +00:00
|
|
|
#else
|
|
|
|
switch (ft_enter(&tc))
|
|
|
|
#endif
|
2005-01-20 16:24:26 +00:00
|
|
|
{
|
|
|
|
case 1: reload_dir = true; break;
|
2005-05-17 18:28:32 +00:00
|
|
|
case 2: start_wps = true; break;
|
|
|
|
case 3: exit_func = true; break;
|
2005-01-20 16:24:26 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2005-01-18 22:59:29 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && tc.dirlevel < 1) {
|
|
|
|
exit_func = true;
|
|
|
|
break;
|
|
|
|
}
|
2006-08-15 21:27:04 +00:00
|
|
|
/* if we are in /, nothing to do */
|
2006-08-15 23:02:12 +00:00
|
|
|
if (tc.dirlevel == 0 && !strcmp(currdir,"/"))
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2006-10-25 10:17:57 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-08-15 21:27:04 +00:00
|
|
|
if (id3db)
|
|
|
|
tagtree_exit(&tc);
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-08-15 21:27:04 +00:00
|
|
|
if (ft_exit(&tc) == 3)
|
|
|
|
exit_func = true;
|
|
|
|
|
|
|
|
restore = true;
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_STOP:
|
2005-01-17 11:39:46 +00:00
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2004-10-12 11:00:19 +00:00
|
|
|
{
|
2005-10-28 21:57:30 +00:00
|
|
|
/* Stop the music if it is playing */
|
2006-03-19 08:40:31 +00:00
|
|
|
if(audio_status()) {
|
2006-07-15 14:10:59 +00:00
|
|
|
if (!global_settings.party_mode) {
|
2006-07-01 23:48:30 +00:00
|
|
|
if (global_settings.fade_on_stop)
|
|
|
|
fade(0);
|
2006-07-15 14:10:59 +00:00
|
|
|
bookmark_autobookmark();
|
2006-03-19 08:40:31 +00:00
|
|
|
audio_stop();
|
2006-07-04 16:43:44 +00:00
|
|
|
}
|
2006-03-19 08:40:31 +00:00
|
|
|
}
|
2006-06-06 22:23:52 +00:00
|
|
|
#if defined(CONFIG_CHARGING) && \
|
2006-02-07 16:41:29 +00:00
|
|
|
(CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
|
2006-04-10 03:51:17 +00:00
|
|
|
else {
|
2004-10-12 11:00:19 +00:00
|
|
|
if (!charger_inserted()) {
|
2005-09-14 09:07:05 +00:00
|
|
|
if(shutdown_screen())
|
|
|
|
reload_dir = true;
|
2004-10-12 11:00:19 +00:00
|
|
|
} else {
|
|
|
|
charging_splash();
|
|
|
|
}
|
|
|
|
restore = true;
|
2004-07-24 21:26:41 +00:00
|
|
|
}
|
2005-10-28 21:57:30 +00:00
|
|
|
#endif
|
2004-07-24 21:26:41 +00:00
|
|
|
}
|
2006-06-06 22:23:52 +00:00
|
|
|
#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
2006-08-17 08:57:38 +00:00
|
|
|
{
|
|
|
|
static int last_off = 0;
|
|
|
|
if (current_tick - last_off < 50) {
|
|
|
|
if (charger_inserted()) {
|
|
|
|
charging_splash();
|
|
|
|
restore = true;
|
|
|
|
}
|
2003-12-04 00:08:25 +00:00
|
|
|
}
|
2006-08-17 08:57:38 +00:00
|
|
|
last_off = current_tick;
|
|
|
|
}
|
2005-02-10 21:53:41 +00:00
|
|
|
#endif
|
2006-08-17 08:57:38 +00:00
|
|
|
break; /* case ACTION_TREE_STOP: */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_MENU:
|
2005-01-17 11:39:46 +00:00
|
|
|
/* don't enter menu from plugin browser */
|
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2003-11-04 16:47:05 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].stop_scroll();
|
2006-08-15 12:27:07 +00:00
|
|
|
action_signalscreenchange();
|
2003-11-04 16:47:05 +00:00
|
|
|
if (main_menu())
|
2005-05-16 12:07:25 +00:00
|
|
|
reload_dir = true;
|
2003-11-04 16:47:05 +00:00
|
|
|
restore = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-17 11:39:46 +00:00
|
|
|
id3db = check_changed_id3mode(id3db);
|
2006-03-27 13:06:54 +00:00
|
|
|
if(id3db)
|
|
|
|
reload_dir = true;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2003-11-04 16:47:05 +00:00
|
|
|
}
|
2005-05-16 11:50:46 +00:00
|
|
|
else /* use it as a quick exit instead */
|
|
|
|
exit_func = true;
|
2002-06-25 13:26:04 +00:00
|
|
|
break;
|
2002-05-21 14:30:54 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_WPS:
|
2004-10-05 00:08:04 +00:00
|
|
|
/* don't enter wps from plugin browser etc */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2002-09-29 22:24:00 +00:00
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
2002-09-29 22:24:00 +00:00
|
|
|
{
|
2004-10-05 00:08:04 +00:00
|
|
|
start_wps=true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_resume(false);
|
|
|
|
restore = true;
|
2003-07-08 09:19:12 +00:00
|
|
|
}
|
2002-06-27 01:20:08 +00:00
|
|
|
}
|
2002-05-21 14:30:54 +00:00
|
|
|
break;
|
2006-04-10 03:51:17 +00:00
|
|
|
#ifdef HAVE_QUICKSCREEN
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_QUICKSCREEN:
|
2005-01-17 11:39:46 +00:00
|
|
|
/* don't enter f2 from plugin browser */
|
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2003-11-04 16:47:05 +00:00
|
|
|
{
|
2005-11-22 21:55:05 +00:00
|
|
|
if (quick_screen_quick(button))
|
2005-05-16 12:07:25 +00:00
|
|
|
reload_dir = true;
|
2003-11-04 16:47:05 +00:00
|
|
|
restore = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-17 11:39:46 +00:00
|
|
|
id3db = check_changed_id3mode(id3db);
|
2006-03-26 11:33:42 +00:00
|
|
|
reload_dir = true;
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2003-11-04 16:47:05 +00:00
|
|
|
}
|
2006-04-03 06:08:24 +00:00
|
|
|
break;
|
2005-06-26 20:16:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef BUTTON_F3
|
2006-08-22 08:23:24 +00:00
|
|
|
case ACTION_F3:
|
2005-01-17 11:39:46 +00:00
|
|
|
/* don't enter f3 from plugin browser */
|
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2003-11-04 16:47:05 +00:00
|
|
|
{
|
2006-08-22 08:23:24 +00:00
|
|
|
if (quick_screen_f3(BUTTON_F3))
|
2005-05-16 12:07:25 +00:00
|
|
|
reload_dir = true;
|
2003-11-04 16:47:05 +00:00
|
|
|
restore = true;
|
|
|
|
}
|
2004-10-05 00:08:04 +00:00
|
|
|
break;
|
2002-08-20 19:39:55 +00:00
|
|
|
#endif
|
2004-10-05 00:08:04 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CONTEXT:
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
|
|
|
int onplay_result;
|
2005-01-20 16:24:26 +00:00
|
|
|
int attr = 0;
|
2004-10-05 00:08:04 +00:00
|
|
|
|
|
|
|
if(!numentries)
|
2005-06-23 01:31:26 +00:00
|
|
|
onplay_result = onplay(NULL, 0, curr_context);
|
2004-10-05 00:08:04 +00:00
|
|
|
else {
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-06-23 01:31:26 +00:00
|
|
|
if (id3db)
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2006-05-05 07:01:43 +00:00
|
|
|
if (tagtree_get_attr(&tc) == TREE_ATTR_MPA)
|
2005-06-23 01:31:26 +00:00
|
|
|
{
|
2006-05-05 07:01:43 +00:00
|
|
|
attr = TREE_ATTR_MPA;
|
|
|
|
tagtree_get_filename(&tc, buf, sizeof(buf));
|
2005-06-23 01:31:26 +00:00
|
|
|
}
|
2006-07-25 07:41:00 +00:00
|
|
|
else
|
|
|
|
attr = ATTR_DIRECTORY;
|
2005-08-30 07:52:36 +00:00
|
|
|
}
|
2005-06-23 01:31:26 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
attr = dircache[tc.selected_item].attr;
|
2005-08-30 07:52:36 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
if (currdir[1]) /* Not in / */
|
2005-08-30 07:52:36 +00:00
|
|
|
snprintf(buf, sizeof buf, "%s/%s",
|
|
|
|
currdir,
|
2005-10-28 00:00:00 +00:00
|
|
|
dircache[tc.selected_item].name);
|
|
|
|
else /* In / */
|
2005-08-30 07:52:36 +00:00
|
|
|
snprintf(buf, sizeof buf, "/%s",
|
2005-10-28 00:00:00 +00:00
|
|
|
dircache[tc.selected_item].name);
|
2005-08-30 07:52:36 +00:00
|
|
|
}
|
2005-06-23 01:31:26 +00:00
|
|
|
onplay_result = onplay(buf, attr, curr_context);
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
|
|
|
switch (onplay_result)
|
|
|
|
{
|
|
|
|
case ONPLAY_OK:
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_RELOAD_DIR:
|
|
|
|
reload_dir = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_START_PLAY:
|
|
|
|
start_wps = true;
|
|
|
|
break;
|
|
|
|
}
|
2004-05-21 20:08:24 +00:00
|
|
|
break;
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2002-08-07 10:35:26 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_NONE:
|
2004-03-28 10:21:58 +00:00
|
|
|
if (thumbnail_time != -1 &&
|
|
|
|
TIME_AFTER(current_tick, thumbnail_time))
|
|
|
|
{ /* a delayed hovering thumbnail is due now */
|
|
|
|
int res;
|
2006-05-07 06:16:17 +00:00
|
|
|
int attr;
|
|
|
|
char* name;
|
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-05-07 06:16:17 +00:00
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
attr = tagtree_get_attr(&tc);
|
|
|
|
name = tagtree_get_entry(&tc, lasti)->name;
|
|
|
|
}
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-05-07 06:16:17 +00:00
|
|
|
{
|
|
|
|
attr = dircache[lasti].attr;
|
|
|
|
name = dircache[lasti].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr & ATTR_DIRECTORY)
|
2004-10-06 21:37:46 +00:00
|
|
|
{
|
|
|
|
DEBUGF("Playing directory thumbnail: %s", currdir);
|
2006-07-05 23:33:20 +00:00
|
|
|
res = ft_play_dirname(name);
|
2004-10-06 21:37:46 +00:00
|
|
|
if (res < 0) /* failed, not existing */
|
|
|
|
{ /* say the number instead, as a fallback */
|
|
|
|
talk_id(VOICE_DIR, false);
|
|
|
|
talk_number(lasti+1, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
DEBUGF("Playing file thumbnail: %s/%s%s\n",
|
2006-05-07 06:16:17 +00:00
|
|
|
currdir, name,
|
2005-11-18 09:03:25 +00:00
|
|
|
file_thumbnail_ext);
|
2005-10-28 00:00:00 +00:00
|
|
|
/* no fallback necessary, we knew in advance
|
2004-10-21 18:34:48 +00:00
|
|
|
that the file exists */
|
2006-05-07 06:16:17 +00:00
|
|
|
ft_play_filename(currdir, name);
|
2004-03-28 10:21:58 +00:00
|
|
|
}
|
|
|
|
thumbnail_time = -1; /* job done */
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars, false);
|
2002-10-28 09:11:42 +00:00
|
|
|
break;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
2005-01-28 23:02:05 +00:00
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
case SYS_FS_CHANGED:
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-05-14 23:48:18 +00:00
|
|
|
if (!id3db)
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
reload_dir = true;
|
2005-05-14 23:48:18 +00:00
|
|
|
/* The 'dir no longer valid' situation will be caught later
|
|
|
|
* by checking the showdir() result. */
|
2005-01-28 23:02:05 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
2005-09-14 09:07:05 +00:00
|
|
|
if (default_event_handler(button) == SYS_USB_CONNECTED)
|
2004-10-24 23:19:13 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
if(*tc.dirfilter > NUM_FILTER_MODES)
|
2004-10-24 23:19:13 +00:00
|
|
|
/* leave sub-browsers after usb, doing otherwise
|
|
|
|
might be confusing to the user */
|
|
|
|
exit_func = true;
|
|
|
|
else
|
2005-05-16 11:50:46 +00:00
|
|
|
reload_dir = true;
|
2004-10-24 23:19:13 +00:00
|
|
|
}
|
2004-07-26 16:06:59 +00:00
|
|
|
break;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2002-06-10 13:24:27 +00:00
|
|
|
|
2002-08-26 13:21:14 +00:00
|
|
|
if ( button )
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2002-08-26 13:21:14 +00:00
|
|
|
ata_spin();
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
if (start_wps && audio_status() )
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2006-02-02 20:42:56 +00:00
|
|
|
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
screens[i].stop_scroll();
|
2006-05-21 11:00:02 +00:00
|
|
|
|
2005-11-17 20:14:59 +00:00
|
|
|
if (gui_wps_show() == SYS_USB_CONNECTED)
|
2005-05-16 11:50:46 +00:00
|
|
|
reload_dir = true;
|
2005-05-14 23:48:18 +00:00
|
|
|
#ifdef HAVE_HOTSWAP
|
2005-10-28 00:00:00 +00:00
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-05-14 23:48:18 +00:00
|
|
|
if (!id3db) /* Try reload to catch 'no longer valid' case. */
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2005-05-14 23:48:18 +00:00
|
|
|
reload_dir = true;
|
2006-05-24 19:05:29 +00:00
|
|
|
#endif
|
2006-11-13 00:45:21 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-05-24 19:05:29 +00:00
|
|
|
show_main_backdrop();
|
2004-01-14 00:13:04 +00:00
|
|
|
#endif
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-20 14:00:20 +00:00
|
|
|
id3db = check_changed_id3mode(id3db);
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2004-01-14 00:13:04 +00:00
|
|
|
restore = true;
|
|
|
|
start_wps=false;
|
|
|
|
}
|
|
|
|
|
2005-05-14 23:48:18 +00:00
|
|
|
check_rescan:
|
2002-09-03 20:47:23 +00:00
|
|
|
/* do we need to rescan dir? */
|
2003-03-07 08:10:10 +00:00
|
|
|
if (reload_dir || reload_root ||
|
2005-01-17 11:39:46 +00:00
|
|
|
lastfilter != *tc.dirfilter ||
|
2002-09-24 19:12:09 +00:00
|
|
|
lastsortcase != global_settings.sort_case)
|
2002-09-03 20:47:23 +00:00
|
|
|
{
|
|
|
|
if ( reload_root ) {
|
|
|
|
strcpy(currdir, "/");
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel = 0;
|
2005-04-26 19:23:47 +00:00
|
|
|
tc.currtable = 0;
|
|
|
|
tc.currextra = 0;
|
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
2002-09-03 20:47:23 +00:00
|
|
|
reload_root = false;
|
|
|
|
}
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2003-03-07 08:10:10 +00:00
|
|
|
if (! reload_dir )
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_item(&tree_lists, 0);
|
|
|
|
gui_synclist_draw(&tree_lists);
|
|
|
|
tc.selected_item = 0;
|
2003-03-07 08:10:10 +00:00
|
|
|
lastdir[0] = 0;
|
|
|
|
}
|
2003-09-29 21:26:53 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
lastfilter = *tc.dirfilter;
|
2002-09-03 20:47:23 +00:00
|
|
|
lastsortcase = global_settings.sort_case;
|
|
|
|
restore = true;
|
|
|
|
}
|
|
|
|
|
2003-09-29 21:26:53 +00:00
|
|
|
if (exit_func)
|
|
|
|
break;
|
|
|
|
|
2003-01-15 14:52:53 +00:00
|
|
|
if (restore || reload_dir) {
|
2002-06-25 13:26:04 +00:00
|
|
|
/* restore display */
|
2005-10-28 00:00:00 +00:00
|
|
|
numentries = update_dir();
|
2005-05-16 11:50:46 +00:00
|
|
|
if (currdir[1] && (numentries < 0))
|
2005-05-14 23:48:18 +00:00
|
|
|
{ /* not in root and reload failed */
|
|
|
|
reload_root = true; /* try root */
|
|
|
|
reload_dir = false;
|
|
|
|
goto check_rescan;
|
|
|
|
}
|
2002-10-28 09:11:42 +00:00
|
|
|
need_update = true;
|
2003-01-15 14:52:53 +00:00
|
|
|
reload_dir = false;
|
2002-06-25 13:26:04 +00:00
|
|
|
}
|
2006-03-26 11:33:42 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
if(need_update) {
|
2005-10-28 23:52:49 +00:00
|
|
|
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
|
2005-10-28 00:00:00 +00:00
|
|
|
need_update=false;
|
|
|
|
if ( numentries > 0 ) {
|
|
|
|
/* Voice the file if changed */
|
|
|
|
if(lasti != tc.selected_item || restore) {
|
2006-05-07 06:16:17 +00:00
|
|
|
int attr;
|
|
|
|
char* name;
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
lasti = tc.selected_item;
|
|
|
|
thumbnail_time = -1; /* Cancel whatever we were
|
|
|
|
about to say */
|
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-05-07 06:16:17 +00:00
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
attr = tagtree_get_attr(&tc);
|
|
|
|
name = tagtree_get_entry(&tc, tc.selected_item)->name;
|
|
|
|
}
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-05-07 06:16:17 +00:00
|
|
|
{
|
|
|
|
attr = dircache[tc.selected_item].attr;
|
|
|
|
name = dircache[tc.selected_item].name;
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Directory? */
|
2006-05-07 06:16:17 +00:00
|
|
|
if (attr & ATTR_DIRECTORY)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
/* play directory thumbnail */
|
|
|
|
switch (global_settings.talk_dir) {
|
|
|
|
case 1: /* dirs as numbers */
|
|
|
|
talk_id(VOICE_DIR, false);
|
|
|
|
talk_number(tc.selected_item+1, true);
|
|
|
|
break;
|
2002-06-10 13:24:27 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
case 2: /* dirs spelled */
|
2006-05-07 06:16:17 +00:00
|
|
|
talk_spell(name, false);
|
2005-10-28 00:00:00 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
case 3: /* thumbnail clip */
|
|
|
|
/* "schedule" a thumbnail, to have a little
|
|
|
|
delay */
|
|
|
|
thumbnail_time = current_tick + HOVER_DELAY;
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-04-04 19:08:44 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
else /* file */
|
|
|
|
{
|
|
|
|
switch (global_settings.talk_file) {
|
|
|
|
case 1: /* files as numbers */
|
|
|
|
ft_play_filenumber(
|
|
|
|
tc.selected_item-tc.dirsindir+1,
|
2006-05-07 06:16:17 +00:00
|
|
|
attr & TREE_ATTR_MASK);
|
2005-10-28 00:00:00 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
case 2: /* files spelled */
|
2006-05-07 06:16:17 +00:00
|
|
|
talk_spell(name, false);
|
2005-10-28 00:00:00 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
case 3: /* thumbnail clip */
|
|
|
|
/* "schedule" a thumbnail, to have a little
|
|
|
|
delay */
|
2006-05-07 06:16:17 +00:00
|
|
|
if (attr & TREE_ATTR_THUMBNAIL)
|
2005-10-28 00:00:00 +00:00
|
|
|
thumbnail_time = current_tick + HOVER_DELAY;
|
|
|
|
else
|
|
|
|
/* spell the number as fallback */
|
2006-05-07 06:16:17 +00:00
|
|
|
talk_spell(name, false);
|
2005-10-28 00:00:00 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-10-21 18:34:48 +00:00
|
|
|
}
|
2004-03-27 00:11:01 +00:00
|
|
|
}
|
2002-08-07 10:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2006-08-15 12:27:07 +00:00
|
|
|
action_signalscreenchange();
|
2003-01-31 08:43:12 +00:00
|
|
|
return true;
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
2003-01-29 13:20:22 +00:00
|
|
|
|
|
|
|
static int plsize = 0;
|
2006-03-04 22:32:25 +00:00
|
|
|
static long pltick;
|
2004-03-21 22:27:56 +00:00
|
|
|
static bool add_dir(char* dirname, int len, int fd)
|
2003-01-29 13:20:22 +00:00
|
|
|
{
|
|
|
|
bool abort = false;
|
2005-10-07 17:38:05 +00:00
|
|
|
DIRCACHED* dir;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2003-01-29 13:20:22 +00:00
|
|
|
/* check for user abort */
|
2006-08-15 12:27:07 +00:00
|
|
|
if (action_userabort(TIMEOUT_NOBLOCK))
|
2003-01-29 13:20:22 +00:00
|
|
|
return true;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
dir = opendir_cached(dirname);
|
2003-01-29 13:20:22 +00:00
|
|
|
if(!dir)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
while (true) {
|
2005-10-07 17:38:05 +00:00
|
|
|
struct dircache_entry *entry;
|
2003-01-29 13:20:22 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
entry = readdir_cached(dir);
|
2003-01-29 13:20:22 +00:00
|
|
|
if (!entry)
|
|
|
|
break;
|
|
|
|
if (entry->attribute & ATTR_DIRECTORY) {
|
2004-03-21 22:27:56 +00:00
|
|
|
int dirlen = strlen(dirname);
|
|
|
|
bool result;
|
|
|
|
|
2005-12-05 22:44:42 +00:00
|
|
|
if (!strcmp((char *)entry->d_name, ".") ||
|
|
|
|
!strcmp((char *)entry->d_name, ".."))
|
2003-01-29 13:20:22 +00:00
|
|
|
continue;
|
2004-03-21 22:27:56 +00:00
|
|
|
|
2003-03-11 09:57:46 +00:00
|
|
|
if (dirname[1])
|
2004-03-21 22:27:56 +00:00
|
|
|
snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name);
|
2003-03-11 09:57:46 +00:00
|
|
|
else
|
2004-03-21 22:27:56 +00:00
|
|
|
snprintf(dirname, len, "/%s", entry->d_name);
|
|
|
|
|
|
|
|
result = add_dir(dirname, len, fd);
|
|
|
|
dirname[dirlen] = '\0';
|
|
|
|
if (result) {
|
2003-01-29 13:20:22 +00:00
|
|
|
abort = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2005-12-05 22:44:42 +00:00
|
|
|
int x = strlen((char *)entry->d_name);
|
2005-06-20 09:00:53 +00:00
|
|
|
unsigned int i;
|
2005-12-05 22:44:42 +00:00
|
|
|
char *cp = strrchr((char *)entry->d_name,'.');
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-09-02 16:50:51 +00:00
|
|
|
if (cp) {
|
|
|
|
cp++;
|
|
|
|
|
|
|
|
/* add all supported audio files to playlists */
|
2006-03-04 22:32:25 +00:00
|
|
|
for (i=0; i < sizeof(filetypes)/sizeof(struct filetype); i++) {
|
2005-09-02 16:50:51 +00:00
|
|
|
if (filetypes[i].tree_attr == TREE_ATTR_MPA) {
|
2006-03-04 22:32:25 +00:00
|
|
|
if (!strcasecmp(cp, filetypes[i].extension)) {
|
2005-09-02 16:50:51 +00:00
|
|
|
char buf[8];
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2005-09-02 16:50:51 +00:00
|
|
|
write(fd, dirname, strlen(dirname));
|
|
|
|
write(fd, "/", 1);
|
|
|
|
write(fd, entry->d_name, x);
|
|
|
|
write(fd, "\n", 1);
|
|
|
|
|
|
|
|
plsize++;
|
2006-03-04 22:32:25 +00:00
|
|
|
if(TIME_AFTER(current_tick, pltick+HZ/4)) {
|
|
|
|
pltick = current_tick;
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2006-03-04 22:32:25 +00:00
|
|
|
snprintf(buf, sizeof buf, "%d", plsize);
|
2003-01-29 13:20:22 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-03-04 22:32:25 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].puts(0, 4, (unsigned char *)buf);
|
|
|
|
gui_textarea_update(&screens[i]);
|
|
|
|
}
|
2003-01-29 13:20:22 +00:00
|
|
|
#else
|
2006-03-04 22:32:25 +00:00
|
|
|
x = 10;
|
|
|
|
if (plsize > 999)
|
|
|
|
x=7;
|
2005-09-02 16:50:51 +00:00
|
|
|
else {
|
2006-03-04 22:32:25 +00:00
|
|
|
if (plsize > 99)
|
|
|
|
x=8;
|
|
|
|
else {
|
|
|
|
if (plsize > 9)
|
|
|
|
x=9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FOR_NB_SCREENS(i) {
|
|
|
|
screens[i].puts(x,0,buf);
|
2005-09-02 16:50:51 +00:00
|
|
|
}
|
2005-06-20 09:00:53 +00:00
|
|
|
#endif
|
2006-03-04 22:32:25 +00:00
|
|
|
}
|
2005-09-02 16:50:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-01-29 13:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-07 17:38:05 +00:00
|
|
|
closedir_cached(dir);
|
2003-01-29 13:20:22 +00:00
|
|
|
|
|
|
|
return abort;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool create_playlist(void)
|
|
|
|
{
|
|
|
|
int fd;
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2003-01-29 13:20:22 +00:00
|
|
|
char filename[MAX_PATH];
|
|
|
|
|
2006-03-04 22:32:25 +00:00
|
|
|
pltick = current_tick;
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2003-01-29 13:20:22 +00:00
|
|
|
snprintf(filename, sizeof filename, "%s.m3u",
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.currdir[1] ? tc.currdir : "/root");
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-11-02 00:55:46 +00:00
|
|
|
gui_textarea_clear(&screens[i]);
|
2005-12-05 22:44:42 +00:00
|
|
|
screens[i].puts(0, 0, str(LANG_CREATING));
|
|
|
|
screens[i].puts_scroll(0, 1, (unsigned char *)filename);
|
2005-10-28 00:00:00 +00:00
|
|
|
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
|
2005-11-02 00:55:46 +00:00
|
|
|
gui_textarea_update(&screens[i]);
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
}
|
2006-05-30 11:26:41 +00:00
|
|
|
fd = creat(filename, O_WRONLY);
|
2003-03-21 03:07:31 +00:00
|
|
|
if (fd < 0)
|
2003-01-29 13:20:22 +00:00
|
|
|
return false;
|
|
|
|
|
2006-11-11 05:33:24 +00:00
|
|
|
trigger_cpu_boost();
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s",
|
|
|
|
tc.currdir[1] ? tc.currdir : "/");
|
2003-01-29 13:20:22 +00:00
|
|
|
plsize = 0;
|
2004-03-21 22:27:56 +00:00
|
|
|
add_dir(filename, sizeof(filename), fd);
|
2003-01-29 13:20:22 +00:00
|
|
|
close(fd);
|
2005-06-20 09:00:53 +00:00
|
|
|
|
2003-01-29 13:20:22 +00:00
|
|
|
sleep(HZ);
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2003-03-21 03:07:31 +00:00
|
|
|
return true;
|
2003-01-29 13:20:22 +00:00
|
|
|
}
|
2003-05-09 16:01:21 +00:00
|
|
|
|
2005-08-17 17:53:54 +00:00
|
|
|
bool rockbox_browse(const char *root, int dirfilter)
|
2003-09-29 21:26:53 +00:00
|
|
|
{
|
2005-01-18 22:59:29 +00:00
|
|
|
static struct tree_context backup;
|
2006-08-14 18:19:56 +00:00
|
|
|
int last_context;
|
|
|
|
|
2005-01-18 22:59:29 +00:00
|
|
|
backup = tc;
|
2003-10-10 10:19:44 +00:00
|
|
|
reload_dir = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
memcpy(tc.currdir, root, sizeof(tc.currdir));
|
2004-01-18 21:26:34 +00:00
|
|
|
start_wps = false;
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirfilter = &dirfilter;
|
2006-08-14 18:19:56 +00:00
|
|
|
last_context = curr_context;
|
|
|
|
|
2005-01-18 22:59:29 +00:00
|
|
|
dirbrowse();
|
2003-09-29 21:26:53 +00:00
|
|
|
|
2005-01-18 22:59:29 +00:00
|
|
|
tc = backup;
|
2006-08-14 18:19:56 +00:00
|
|
|
curr_context = last_context;
|
|
|
|
|
2003-09-29 21:26:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-05-09 16:01:21 +00:00
|
|
|
void tree_init(void)
|
|
|
|
{
|
2005-01-17 12:56:00 +00:00
|
|
|
/* We copy the settings value in case it is changed by the user. We can't
|
|
|
|
use it until the next reboot. */
|
2005-01-18 22:45:00 +00:00
|
|
|
max_files = global_settings.max_files_in_dir;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
/* initialize tree context struct */
|
|
|
|
memset(&tc, 0, sizeof(tc));
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
|
|
|
|
|
|
|
tc.name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files;
|
|
|
|
tc.name_buffer = buffer_alloc(tc.name_buffer_size);
|
|
|
|
|
|
|
|
tc.dircache_size = max_files * sizeof(struct entry);
|
|
|
|
tc.dircache = buffer_alloc(tc.dircache_size);
|
2003-05-09 16:01:21 +00:00
|
|
|
}
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2004-12-07 14:20:37 +00:00
|
|
|
void bookmark_play(char *resume_file, int index, int offset, int seed,
|
|
|
|
char *filename)
|
2004-01-14 00:13:04 +00:00
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
int i;
|
2006-09-21 18:57:54 +00:00
|
|
|
char* suffix = strrchr(resume_file, '.');
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2006-09-21 18:57:54 +00:00
|
|
|
if (suffix != NULL &&
|
|
|
|
(!strcasecmp(suffix, ".m3u") || !strcasecmp(suffix, ".m3u8")))
|
2004-01-14 00:13:04 +00:00
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
/* Playlist playback */
|
2004-01-14 00:13:04 +00:00
|
|
|
char* slash;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* check that the file exists */
|
2004-01-14 00:13:04 +00:00
|
|
|
int fd = open(resume_file, O_RDONLY);
|
|
|
|
if(fd<0)
|
|
|
|
return;
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
slash = strrchr(resume_file,'/');
|
|
|
|
if (slash)
|
|
|
|
{
|
|
|
|
char* cp;
|
|
|
|
*slash=0;
|
|
|
|
|
|
|
|
cp=resume_file;
|
|
|
|
if (!cp[0])
|
|
|
|
cp="/";
|
|
|
|
|
|
|
|
if (playlist_create(cp, slash+1) != -1)
|
|
|
|
{
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_shuffle(seed, -1);
|
|
|
|
playlist_start(index,offset);
|
|
|
|
}
|
|
|
|
*slash='/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
/* Directory playback */
|
2004-01-14 00:13:04 +00:00
|
|
|
lastdir[0]='\0';
|
|
|
|
if (playlist_create(resume_file, NULL) != -1)
|
|
|
|
{
|
|
|
|
resume_directory(resume_file);
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_shuffle(seed, -1);
|
2004-12-07 14:20:37 +00:00
|
|
|
|
|
|
|
/* Check if the file is at the same spot in the directory,
|
|
|
|
else search for it */
|
2006-04-30 08:20:18 +00:00
|
|
|
if ((strcmp(strrchr(playlist_peek(index),'/') + 1,
|
2004-12-07 14:20:37 +00:00
|
|
|
filename)))
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
for ( i=0; i < playlist_amount(); i++ )
|
2004-12-07 14:20:37 +00:00
|
|
|
{
|
2006-04-30 08:20:18 +00:00
|
|
|
if ((strcmp(strrchr(playlist_peek(i),'/') + 1,
|
2004-12-07 14:20:37 +00:00
|
|
|
filename)) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < playlist_amount())
|
|
|
|
index = i;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2004-01-14 00:13:04 +00:00
|
|
|
playlist_start(index,offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
start_wps=true;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
int ft_play_filenumber(int pos, int attr)
|
|
|
|
{
|
|
|
|
/* try to find a voice ID for the extension, if known */
|
|
|
|
unsigned int j;
|
|
|
|
int ext_id = -1; /* default to none */
|
|
|
|
for (j=0; j<sizeof(filetypes)/sizeof(*filetypes); j++)
|
|
|
|
{
|
|
|
|
if (attr == filetypes[j].tree_attr)
|
|
|
|
{
|
|
|
|
ext_id = filetypes[j].voiceclip;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
talk_id(VOICE_FILE, false);
|
|
|
|
talk_number(pos, true);
|
|
|
|
talk_id(ext_id, true);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-07-05 23:33:20 +00:00
|
|
|
int ft_play_dirname(char* name)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char dirname_mp3_filename[MAX_PATH+1];
|
|
|
|
|
2006-08-01 22:02:47 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
2005-01-17 11:39:46 +00:00
|
|
|
return 0;
|
2006-08-01 22:02:47 +00:00
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
snprintf(dirname_mp3_filename, sizeof(dirname_mp3_filename), "%s/%s/%s",
|
2006-07-05 23:33:20 +00:00
|
|
|
tc.currdir[1] ? tc.currdir : "" , name,
|
2005-05-02 22:22:21 +00:00
|
|
|
dir_thumbnail_name);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
DEBUGF("Checking for %s\n", dirname_mp3_filename);
|
|
|
|
|
|
|
|
fd = open(dirname_mp3_filename, O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
DEBUGF("Failed to find: %s\n", dirname_mp3_filename);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
DEBUGF("Found: %s\n", dirname_mp3_filename);
|
|
|
|
|
|
|
|
talk_file(dirname_mp3_filename, false);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ft_play_filename(char *dir, char *file)
|
|
|
|
{
|
|
|
|
char name_mp3_filename[MAX_PATH+1];
|
|
|
|
|
2006-08-01 22:02:47 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
2005-01-17 11:39:46 +00:00
|
|
|
return;
|
2006-08-01 22:02:47 +00:00
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
if (strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
|
|
|
|
file_thumbnail_ext))
|
|
|
|
{ /* file has no .talk extension */
|
|
|
|
snprintf(name_mp3_filename, sizeof(name_mp3_filename),
|
|
|
|
"%s/%s%s", dir, file, file_thumbnail_ext);
|
|
|
|
|
|
|
|
talk_file(name_mp3_filename, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* it already is a .talk file, play this directly */
|
|
|
|
snprintf(name_mp3_filename, sizeof(name_mp3_filename),
|
|
|
|
"%s/%s", dir, file);
|
|
|
|
talk_id(LANG_VOICE_DIR_HOVER, false); /* prefix it */
|
|
|
|
talk_file(name_mp3_filename, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-14 09:07:05 +00:00
|
|
|
/* These two functions are called by the USB and shutdown handlers */
|
|
|
|
void tree_flush(void)
|
|
|
|
{
|
2006-10-19 09:42:58 +00:00
|
|
|
scrobbler_shutdown();
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-09-23 10:29:14 +00:00
|
|
|
tagcache_shutdown();
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-02-05 18:17:41 +00:00
|
|
|
playlist_shutdown();
|
2006-03-26 11:33:42 +00:00
|
|
|
|
2006-08-09 07:41:28 +00:00
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
|
|
|
tagcache_unload_ramcache();
|
|
|
|
#endif
|
2006-08-11 10:13:16 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
#ifdef HAVE_DIRCACHE
|
|
|
|
if (global_settings.dircache)
|
|
|
|
{
|
2006-08-11 10:13:16 +00:00
|
|
|
global_settings.dircache_size = dircache_get_cache_size();
|
2006-08-15 22:54:06 +00:00
|
|
|
# ifdef HAVE_EEPROM_SETTINGS
|
2006-08-05 20:19:10 +00:00
|
|
|
if (dircache_is_enabled() && firmware_settings.initialized)
|
|
|
|
dircache_save(DIRCACHE_FILE);
|
|
|
|
# endif
|
2005-10-20 08:33:59 +00:00
|
|
|
dircache_disable();
|
2005-10-07 17:38:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
global_settings.dircache_size = 0;
|
|
|
|
}
|
|
|
|
settings_save();
|
|
|
|
#endif
|
2005-09-14 09:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tree_restore(void)
|
|
|
|
{
|
2006-08-15 22:54:06 +00:00
|
|
|
#ifdef HAVE_EEPROM_SETTINGS
|
2006-08-09 07:41:28 +00:00
|
|
|
firmware_settings.disk_clean = false;
|
|
|
|
#endif
|
|
|
|
|
2006-08-11 10:13:16 +00:00
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
|
|
|
remove(TAGCACHE_STATEFILE);
|
|
|
|
#endif
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
#ifdef HAVE_DIRCACHE
|
2006-08-05 20:19:10 +00:00
|
|
|
remove(DIRCACHE_FILE);
|
2005-10-07 17:38:05 +00:00
|
|
|
if (global_settings.dircache)
|
2005-10-19 11:34:32 +00:00
|
|
|
{
|
|
|
|
/* Print "Scanning disk..." to the display. */
|
2005-10-28 00:00:00 +00:00
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
screens[i].putsxy((LCD_WIDTH/2) -
|
|
|
|
((strlen(str(LANG_DIRCACHE_BUILDING)) *
|
|
|
|
screens[i].char_width)/2),
|
|
|
|
LCD_HEIGHT-screens[i].char_height*3,
|
|
|
|
str(LANG_DIRCACHE_BUILDING));
|
2005-11-02 00:55:46 +00:00
|
|
|
gui_textarea_update(&screens[i]);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2005-11-02 12:05:33 +00:00
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
dircache_build(global_settings.dircache_size);
|
2005-11-02 12:05:33 +00:00
|
|
|
|
2005-10-19 11:34:32 +00:00
|
|
|
/* Clean the text when we are done. */
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-11-02 12:05:33 +00:00
|
|
|
{
|
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
}
|
2005-10-19 11:34:32 +00:00
|
|
|
}
|
2005-10-07 17:38:05 +00:00
|
|
|
#endif
|
2006-10-25 10:17:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2006-07-12 16:07:27 +00:00
|
|
|
tagcache_start_scan();
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-10-19 09:42:58 +00:00
|
|
|
scrobbler_init();
|
2005-09-14 09:07:05 +00:00
|
|
|
}
|