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"
|
2002-06-25 13:26:04 +00:00
|
|
|
#include "wps.h"
|
2002-09-02 12:46:32 +00:00
|
|
|
#include "wps-display.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"
|
|
|
|
#include "dbtree.h"
|
2005-02-04 10:37:21 +00:00
|
|
|
#include "recorder/recording.h"
|
2005-02-05 19:57:19 +00:00
|
|
|
#include "rtc.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-30 13:49:32 +00:00
|
|
|
#include "widgets.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
#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-08-24 00:09:42 +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-08-24 00:09:42 +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 },
|
|
|
|
{ ".flac", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
|
|
|
|
{ ".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-04-07 21:07:04 +00:00
|
|
|
#endif
|
2005-08-24 00:09:42 +00:00
|
|
|
{ ".m3u", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
|
|
|
{ ".cfg", TREE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG },
|
|
|
|
{ ".wps", TREE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS },
|
|
|
|
{ ".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-08-24 00:09:42 +00:00
|
|
|
{ ".fnt", TREE_ATTR_FONT,Icon_Font, VOICE_EXT_FONT },
|
2003-12-07 16:57:43 +00:00
|
|
|
#endif
|
2005-08-24 00:09:42 +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-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-06-23 01:31:26 +00:00
|
|
|
static int curr_context = false;
|
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)
|
|
|
|
{
|
|
|
|
lcd_clear_display();
|
2004-09-10 20:51:12 +00:00
|
|
|
splash(HZ*2, true, str(LANG_NO_ROCKBOX_DIR));
|
2004-09-05 16:50:07 +00:00
|
|
|
lcd_clear_display();
|
2004-09-10 20:51:12 +00:00
|
|
|
splash(HZ*2, true, str(LANG_INSTALLATION_INCOMPLETE));
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
filetype_init();
|
|
|
|
check_rockboxdir();
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(tc.currdir, "/");
|
2005-06-29 17:39:18 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
lcd_double_height(false);
|
|
|
|
#endif
|
2004-09-10 20:51:12 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-01-17 11:39:46 +00:00
|
|
|
dirbrowse();
|
2004-09-05 16:50:07 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-05-16 12:53:40 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
2002-09-24 19:41:23 +00:00
|
|
|
/* pixel margins */
|
|
|
|
#define MARGIN_X (global_settings.scrollbar && \
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0) + \
|
2005-08-30 11:10:08 +00:00
|
|
|
(global_settings.show_icons && ICON_WIDTH > 0 ? ICON_WIDTH :0)
|
2002-09-24 19:41:23 +00:00
|
|
|
#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
|
|
|
|
|
|
|
|
/* position the entry-list starts at */
|
2003-12-12 13:34:27 +00:00
|
|
|
#define LINE_X 0
|
2002-09-24 19:41:23 +00:00
|
|
|
#define LINE_Y (global_settings.statusbar ? 1 : 0)
|
|
|
|
|
|
|
|
#define CURSOR_X (global_settings.scrollbar && \
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.filesindir > tree_max_on_screen ? 1 : 0)
|
2002-09-24 19:41:23 +00:00
|
|
|
#define CURSOR_Y 0 /* the cursor is not positioned in regard to
|
|
|
|
the margins, so this is the amount of lines
|
|
|
|
we add to the cursor Y position to position
|
|
|
|
it on a line */
|
2002-08-30 13:49:32 +00:00
|
|
|
|
|
|
|
#define ICON_WIDTH 6
|
|
|
|
|
|
|
|
#define SCROLLBAR_X 0
|
|
|
|
#define SCROLLBAR_Y lcd_getymargin()
|
|
|
|
#define SCROLLBAR_WIDTH 6
|
2002-05-16 12:53:40 +00:00
|
|
|
|
|
|
|
#else /* HAVE_LCD_BITMAP */
|
|
|
|
|
|
|
|
#define TREE_MAX_ON_SCREEN 2
|
|
|
|
#define TREE_MAX_LEN_DISPLAY 11 /* max length that fits on screen */
|
2002-09-03 07:53:51 +00:00
|
|
|
#define LINE_X 2 /* X position the entry-list starts at */
|
2002-08-30 13:49:32 +00:00
|
|
|
#define LINE_Y 0 /* Y position the entry-list starts at */
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2002-08-30 13:49:32 +00:00
|
|
|
#define CURSOR_X 0
|
2002-06-14 08:47:44 +00:00
|
|
|
#define CURSOR_Y 0 /* not really used for players */
|
2002-05-31 09:04:51 +00:00
|
|
|
|
2002-05-16 12:53:40 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
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)
|
2004-03-28 10:21:58 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
static void showfileline(int line, char* name, int attr, bool scroll)
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2003-06-05 09:38:26 +00:00
|
|
|
int xpos = LINE_X;
|
2004-03-17 14:46:06 +00:00
|
|
|
char* dotpos = NULL;
|
2003-06-05 09:38:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
if (!global_settings.show_icons)
|
|
|
|
xpos--;
|
|
|
|
#endif
|
|
|
|
|
2003-03-10 14:31:43 +00:00
|
|
|
/* if any file filter is on, strip the extension */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (*tc.dirfilter != SHOW_ID3DB &&
|
|
|
|
*tc.dirfilter != SHOW_ALL &&
|
|
|
|
!(attr & ATTR_DIRECTORY))
|
2003-01-24 10:56:59 +00:00
|
|
|
{
|
2004-03-17 14:46:06 +00:00
|
|
|
dotpos = strrchr(name, '.');
|
2003-03-10 14:31:43 +00:00
|
|
|
if (dotpos) {
|
|
|
|
*dotpos = 0;
|
|
|
|
}
|
2003-01-24 10:56:59 +00:00
|
|
|
}
|
2004-03-17 14:46:06 +00:00
|
|
|
|
|
|
|
if(scroll) {
|
2003-04-16 00:12:31 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-03-17 14:46:06 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
2005-08-30 11:10:08 +00:00
|
|
|
lcd_puts_scroll_style(xpos, line, name, STYLE_INVERT);
|
|
|
|
#else
|
|
|
|
lcd_puts_scroll(xpos, line, name);
|
2004-03-17 14:46:06 +00:00
|
|
|
#endif
|
|
|
|
} else
|
|
|
|
lcd_puts(xpos, line, name);
|
|
|
|
|
|
|
|
/* Restore the dot before the extension if it was removed */
|
|
|
|
if (dotpos)
|
|
|
|
*dotpos = '.';
|
2003-01-24 10:56:59 +00:00
|
|
|
}
|
|
|
|
|
2004-03-16 13:44:56 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
static int recalc_screen_height(void)
|
|
|
|
{
|
|
|
|
int fw, fh;
|
|
|
|
int height = LCD_HEIGHT;
|
|
|
|
|
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
lcd_getstringsize("A", &fw, &fh);
|
|
|
|
if(global_settings.statusbar)
|
|
|
|
height -= STATUSBAR_HEIGHT;
|
2005-01-13 19:37:34 +00:00
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2004-03-16 13:44:56 +00:00
|
|
|
if(global_settings.buttonbar)
|
|
|
|
height -= BUTTONBAR_HEIGHT;
|
2005-01-13 19:37:34 +00:00
|
|
|
#endif
|
2004-03-16 13:44:56 +00:00
|
|
|
|
|
|
|
return height / fh;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
static int showdir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
struct entry *dircache = tc.dircache;
|
2002-05-16 12:53:40 +00:00
|
|
|
int i;
|
2002-08-11 09:17:47 +00:00
|
|
|
int tree_max_on_screen;
|
2005-01-17 12:56:00 +00:00
|
|
|
int start = tc.dirstart;
|
2005-01-18 23:07:23 +00:00
|
|
|
bool id3db = *tc.dirfilter == SHOW_ID3DB;
|
2005-01-18 22:45:00 +00:00
|
|
|
bool newdir = false;
|
2002-09-12 13:33:59 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-07-19 21:46:37 +00:00
|
|
|
const char* icon;
|
2002-09-24 19:41:23 +00:00
|
|
|
int line_height;
|
2002-09-12 13:33:59 +00:00
|
|
|
int fw, fh;
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
lcd_getstringsize("A", &fw, &fh);
|
2004-03-16 13:44:56 +00:00
|
|
|
tree_max_on_screen = recalc_screen_height();
|
2002-08-11 09:17:47 +00:00
|
|
|
line_height = fh;
|
|
|
|
#else
|
2004-05-21 20:08:24 +00:00
|
|
|
int icon;
|
2002-08-11 09:17:47 +00:00
|
|
|
tree_max_on_screen = TREE_MAX_ON_SCREEN;
|
|
|
|
#endif
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
/* new file dir? load it */
|
|
|
|
if (id3db) {
|
2005-01-18 22:45:00 +00:00
|
|
|
if (tc.currtable != lasttable ||
|
|
|
|
tc.currextra != lastextra ||
|
|
|
|
tc.firstpos != lastfirstpos)
|
|
|
|
{
|
|
|
|
if (db_load(&tc) < 0)
|
|
|
|
return -1;
|
|
|
|
lasttable = tc.currtable;
|
|
|
|
lastextra = tc.currextra;
|
|
|
|
lastfirstpos = tc.firstpos;
|
|
|
|
newdir = true;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (strncmp(tc.currdir, lastdir, sizeof(lastdir)) || reload_dir) {
|
2005-05-14 23:48:18 +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);
|
|
|
|
newdir = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-12 22:52:19 +00:00
|
|
|
|
2005-01-18 22:45:00 +00:00
|
|
|
if (newdir && !id3db &&
|
|
|
|
(tc.dirfull || tc.filesindir == global_settings.max_files_in_dir) )
|
|
|
|
{
|
2002-10-15 12:25:57 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2005-01-17 11:39:46 +00:00
|
|
|
lcd_double_height(false);
|
2002-08-12 22:52:19 +00:00
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_SHOWDIR_ERROR_BUFFER));
|
|
|
|
lcd_puts(0,1,str(LANG_SHOWDIR_ERROR_FULL));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ*2);
|
|
|
|
lcd_clear_display();
|
2002-05-28 16:26:12 +00:00
|
|
|
}
|
2002-05-31 12:11:22 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
if (start == -1)
|
|
|
|
{
|
2002-09-09 17:32:15 +00:00
|
|
|
int diff_files;
|
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* use lastfile to determine start (default=0) */
|
2002-09-09 17:32:15 +00:00
|
|
|
start = 0;
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
for (i=0; i < tc.filesindir; i++)
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
struct entry *dircache = tc.dircache;
|
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
if (!strcasecmp(dircache[i].name, lastfile))
|
|
|
|
{
|
2002-09-09 17:32:15 +00:00
|
|
|
start = i;
|
2002-09-09 14:25:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-09-09 17:32:15 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
diff_files = tc.filesindir - start;
|
2002-09-09 17:32:15 +00:00
|
|
|
if (diff_files < tree_max_on_screen)
|
|
|
|
{
|
|
|
|
int oldstart = start;
|
|
|
|
|
|
|
|
start -= (tree_max_on_screen - diff_files);
|
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor = oldstart - start;
|
2002-09-09 17:32:15 +00:00
|
|
|
}
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirstart = start;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 07:53:58 +00:00
|
|
|
/* The cursor might point to an invalid line, for example if someone
|
|
|
|
deleted the last file in the dir */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (tc.filesindir)
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
while (start + tc.dircursor >= tc.filesindir)
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
if (start)
|
2003-04-14 07:53:58 +00:00
|
|
|
start--;
|
|
|
|
else
|
2005-01-17 11:39:46 +00:00
|
|
|
if (tc.dircursor)
|
|
|
|
tc.dircursor--;
|
2003-04-14 07:53:58 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirstart = start;
|
2003-04-14 07:53:58 +00:00
|
|
|
}
|
|
|
|
|
2002-10-15 12:25:57 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2003-01-24 10:56:59 +00:00
|
|
|
lcd_stop_scroll();
|
2002-05-31 11:16:25 +00:00
|
|
|
lcd_double_height(false);
|
|
|
|
#endif
|
2002-05-28 16:26:12 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-13 20:55:08 +00:00
|
|
|
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
|
2002-09-12 13:33:59 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
2002-05-28 16:26:12 +00:00
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2002-05-29 08:18:46 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
for ( i=start; i < start+tree_max_on_screen && i < tc.filesindir; i++ ) {
|
|
|
|
int line = i - start;
|
|
|
|
char* name;
|
|
|
|
int attr = 0;
|
|
|
|
|
|
|
|
if (id3db) {
|
2005-01-20 16:24:26 +00:00
|
|
|
name = ((char**)tc.dircache)[i * tc.dentry_size];
|
2005-01-17 11:39:46 +00:00
|
|
|
icon = db_get_icon(&tc);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct entry* dc = tc.dircache;
|
|
|
|
struct entry* e = &dc[i];
|
|
|
|
name = e->name;
|
|
|
|
attr = e->attr;
|
|
|
|
icon = filetype_get_icon(dircache[i].attr);
|
|
|
|
}
|
|
|
|
|
2003-06-29 16:33:04 +00:00
|
|
|
|
2004-05-21 20:08:24 +00:00
|
|
|
if (icon && global_settings.show_icons) {
|
2002-09-03 07:53:51 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-20 08:07:51 +00:00
|
|
|
int offset=0;
|
|
|
|
if ( line_height > 8 )
|
|
|
|
offset = (line_height - 8) / 2;
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(icon,
|
2005-08-30 11:10:08 +00:00
|
|
|
CURSOR_X * 6,
|
2005-07-06 22:58:02 +00:00
|
|
|
MARGIN_Y+(i-start)*line_height + offset, 6, 8);
|
2002-09-03 07:53:51 +00:00
|
|
|
#else
|
2004-05-21 20:08:24 +00:00
|
|
|
if (icon < 0 )
|
2005-08-24 00:09:42 +00:00
|
|
|
icon = Icon_Unknown;
|
2004-05-21 20:08:24 +00:00
|
|
|
lcd_putc(LINE_X-1, i-start, icon);
|
2002-05-16 12:53:40 +00:00
|
|
|
#endif
|
2002-09-03 20:47:23 +00:00
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
showfileline(line, name, attr, false); /* no scroll */
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2002-08-30 13:49:32 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-01-18 22:45:00 +00:00
|
|
|
if (global_settings.scrollbar && (tc.dirlength > tree_max_on_screen))
|
2002-08-30 13:49:32 +00:00
|
|
|
scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
|
2005-01-18 22:45:00 +00:00
|
|
|
tree_max_on_screen * line_height, tc.dirlength,
|
|
|
|
start + tc.firstpos,
|
|
|
|
start + tc.firstpos + tree_max_on_screen, VERTICAL);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
2004-10-09 20:54:15 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2005-05-16 11:50:46 +00:00
|
|
|
if (global_settings.buttonbar) {
|
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
|
|
|
buttonbar_set(str(LANG_DIRBROWSE_F1),
|
|
|
|
str(LANG_DIRBROWSE_F2),
|
|
|
|
str(LANG_DIRBROWSE_F3));
|
|
|
|
else
|
|
|
|
buttonbar_set("<<<", "", "");
|
2004-03-16 13:44:56 +00:00
|
|
|
buttonbar_draw();
|
|
|
|
}
|
2004-10-09 20:54:15 +00:00
|
|
|
#endif
|
2002-08-30 13:49:32 +00:00
|
|
|
#endif
|
2003-04-23 14:38:25 +00:00
|
|
|
status_draw(true);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
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
|
|
|
{
|
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);
|
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)
|
|
|
|
do_resume = true;
|
|
|
|
|
|
|
|
if (! do_resume) return;
|
|
|
|
|
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;
|
|
|
|
} else if (! just_powered_on) {
|
|
|
|
splash(HZ*2, true, str(LANG_NOTHING_TO_RESUME));
|
2002-08-16 14:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
void set_current_file(char *path)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
unsigned int i;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* separate directory from filename */
|
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);
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor = 0;
|
|
|
|
tc.dirstart = -1;
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
if (strncmp(tc.currdir,lastdir,sizeof(lastdir)))
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel = 0;
|
|
|
|
tc.dirpos[tc.dirlevel] = -1;
|
|
|
|
tc.cursorpos[tc.dirlevel] = 0;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2002-09-09 14:25:39 +00:00
|
|
|
/* use '/' to calculate dirlevel */
|
|
|
|
for (i=1; i<strlen(path)+1; i++)
|
|
|
|
{
|
|
|
|
if (path[i] == '/')
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel++;
|
|
|
|
tc.dirpos[tc.dirlevel] = -1;
|
|
|
|
tc.cursorpos[tc.dirlevel] = 0;
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2005-01-18 22:45:00 +00:00
|
|
|
db_load(&tc);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else
|
2005-06-23 01:31:26 +00:00
|
|
|
{
|
|
|
|
curr_context=CONTEXT_TREE;
|
2005-01-18 22:50:47 +00:00
|
|
|
ft_load(&tc, NULL);
|
2005-06-23 01:31:26 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
return currmode;
|
|
|
|
}
|
|
|
|
|
2005-04-26 19:23:47 +00:00
|
|
|
static void tree_prepare_usb(void *parameter)
|
|
|
|
{
|
|
|
|
(void) parameter;
|
2005-07-02 10:50:42 +00:00
|
|
|
rundb_shutdown();
|
2005-04-26 21:37:44 +00:00
|
|
|
tagdb_shutdown();
|
2005-04-26 19:23:47 +00:00
|
|
|
}
|
|
|
|
|
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];
|
2002-05-16 12:53:40 +00:00
|
|
|
int i;
|
2002-08-07 10:35:26 +00:00
|
|
|
int lasti=-1;
|
2005-02-12 12:20:10 +00:00
|
|
|
unsigned button;
|
2002-08-11 09:17:47 +00:00
|
|
|
int tree_max_on_screen;
|
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-23 14:28:16 +00:00
|
|
|
int lastdircursor=-1;
|
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 */
|
2003-01-24 10:56:59 +00:00
|
|
|
bool update_all = false; /* set this to true when the whole file list
|
|
|
|
has been refreshed on screen */
|
2005-02-12 12:20:10 +00:00
|
|
|
unsigned lastbutton = 0;
|
2005-01-17 11:39:46 +00:00
|
|
|
char* currdir = tc.currdir; /* just a shortcut */
|
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
|
|
|
|
curr_context=CONTEXT_TREE;
|
|
|
|
|
2002-09-12 13:33:59 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-03-16 13:44:56 +00:00
|
|
|
tree_max_on_screen = recalc_screen_height();
|
2002-08-11 09:17:47 +00:00
|
|
|
#else
|
|
|
|
tree_max_on_screen = TREE_MAX_ON_SCREEN;
|
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor=0;
|
|
|
|
tc.dirstart=0;
|
|
|
|
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) {
|
2003-11-04 16:47:05 +00:00
|
|
|
start_resume(true);
|
2005-01-21 15:42:47 +00:00
|
|
|
|
2005-02-04 10:37:21 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
if (global_settings.rec_startup && ! start_wps) {
|
|
|
|
/* We fake being in the menu structure by calling the appropriate */
|
|
|
|
/* parent when we drop out of each screen */
|
|
|
|
recording_screen();
|
|
|
|
rec_menu();
|
|
|
|
main_menu();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-01-21 15:42:47 +00:00
|
|
|
if (!start_wps) {
|
|
|
|
numentries = showdir();
|
|
|
|
if (numentries == -1)
|
|
|
|
return false; /* currdir is not a directory */
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-01-21 15:42:47 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && numentries==0)
|
|
|
|
{
|
|
|
|
splash(HZ*2, true, str(LANG_NO_FILES));
|
|
|
|
return false; /* No files found for rockbox_browser() */
|
|
|
|
}
|
|
|
|
update_all = true;
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-01-21 15:42:47 +00:00
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
|
|
|
|
while(1) {
|
2005-01-17 11:39:46 +00:00
|
|
|
struct entry *dircache = tc.dircache;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
2002-06-25 13:26:04 +00:00
|
|
|
bool restore = false;
|
2002-06-18 11:22:48 +00:00
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
button = button_get_w_tmo(HZ/5);
|
2003-06-29 22:39:35 +00:00
|
|
|
|
2005-03-31 10:50:15 +00:00
|
|
|
#ifdef BOOTFILE
|
2003-06-29 22:39:35 +00:00
|
|
|
if (boot_changed) {
|
2004-03-21 18:56:06 +00:00
|
|
|
bool stop = false;
|
2005-02-12 12:20:10 +00:00
|
|
|
unsigned int button;
|
2004-03-21 18:56:06 +00:00
|
|
|
|
2003-06-29 22:39:35 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_BOOT_CHANGED));
|
|
|
|
lcd_puts(0,1,str(LANG_REBOOT_NOW));
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
|
|
|
|
lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER));
|
|
|
|
lcd_update();
|
|
|
|
#endif
|
2004-03-21 18:56:06 +00:00
|
|
|
while (!stop) {
|
2004-07-26 16:06:59 +00:00
|
|
|
button = button_get(true);
|
|
|
|
switch (button) {
|
2004-09-19 21:58:37 +00:00
|
|
|
case TREE_RUN:
|
2005-06-12 20:18:37 +00:00
|
|
|
#ifdef TREE_RC_RUN
|
|
|
|
case TREE_RC_RUN:
|
|
|
|
#endif
|
2004-03-21 18:56:06 +00:00
|
|
|
rolo_load("/" BOOTFILE);
|
|
|
|
stop = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-10-05 13:24:34 +00:00
|
|
|
if(default_event_handler(button) ||
|
|
|
|
(button & BUTTON_REL))
|
2004-10-05 13:12:42 +00:00
|
|
|
stop = true;
|
2004-03-21 18:56:06 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2004-03-21 18:56:06 +00:00
|
|
|
}
|
|
|
|
|
2003-06-29 22:39:35 +00:00
|
|
|
restore = true;
|
|
|
|
boot_changed = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-07-27 20:55:39 +00:00
|
|
|
switch ( button ) {
|
2005-01-17 11:39:46 +00:00
|
|
|
#ifdef TREE_ENTER
|
|
|
|
case TREE_ENTER:
|
|
|
|
case TREE_ENTER | BUTTON_REPEAT:
|
2003-12-04 00:08:25 +00:00
|
|
|
#endif
|
2005-06-12 20:18:37 +00:00
|
|
|
#ifdef TREE_RC_RUN
|
|
|
|
case TREE_RC_RUN:
|
2005-01-17 11:39:46 +00:00
|
|
|
#endif
|
|
|
|
case TREE_RUN:
|
|
|
|
#ifdef TREE_RUN_PRE
|
2005-06-12 20:18:37 +00:00
|
|
|
if (((button == TREE_RUN)
|
|
|
|
#ifdef TREE_RC_RUN_PRE
|
|
|
|
|| (button == TREE_RC_RUN))
|
|
|
|
&& ((lastbutton != TREE_RC_RUN_PRE)
|
|
|
|
#endif
|
|
|
|
&& (lastbutton != TREE_RUN_PRE)))
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
if ( !numentries )
|
|
|
|
break;
|
2004-05-21 20:08:24 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
if (id3db)
|
2005-01-20 16:24:26 +00:00
|
|
|
i = db_enter(&tc);
|
|
|
|
else
|
|
|
|
i = ft_enter(&tc);
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-01-20 16:24:26 +00:00
|
|
|
/* maybe we have a new font */
|
|
|
|
tree_max_on_screen = recalc_screen_height();
|
2005-01-17 11:39:46 +00:00
|
|
|
#endif
|
|
|
|
/* make sure cursor is on screen */
|
|
|
|
while ( tc.dircursor > tree_max_on_screen )
|
|
|
|
{
|
|
|
|
tc.dircursor--;
|
|
|
|
tc.dirstart++;
|
2002-05-27 14:55:40 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TREE_EXIT:
|
|
|
|
case TREE_EXIT | BUTTON_REPEAT:
|
|
|
|
#ifdef TREE_RC_EXIT
|
|
|
|
case TREE_RC_EXIT:
|
|
|
|
#endif
|
2005-01-18 22:59:29 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && tc.dirlevel < 1) {
|
|
|
|
exit_func = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
if (!tc.dirlevel)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (id3db)
|
|
|
|
db_exit(&tc);
|
2004-05-21 20:08:24 +00:00
|
|
|
else
|
2005-05-17 18:28:32 +00:00
|
|
|
if (ft_exit(&tc) == 3)
|
2004-05-21 20:08:24 +00:00
|
|
|
exit_func = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
restore = true;
|
2002-05-16 12:53:40 +00:00
|
|
|
break;
|
2002-08-16 14:41:47 +00:00
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
#ifdef TREE_OFF
|
2005-06-22 23:24:45 +00:00
|
|
|
#if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
|
2004-09-19 21:58:37 +00:00
|
|
|
case TREE_OFF:
|
2005-01-17 11:39:46 +00:00
|
|
|
if (*tc.dirfilter < NUM_FILTER_MODES)
|
2004-10-12 11:00:19 +00:00
|
|
|
{
|
|
|
|
/* Stop the music if it is playing, else show the shutdown
|
|
|
|
screen */
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_status())
|
|
|
|
audio_stop();
|
2004-10-12 11:00:19 +00:00
|
|
|
else {
|
|
|
|
if (!charger_inserted()) {
|
|
|
|
shutdown_screen();
|
|
|
|
} else {
|
|
|
|
charging_splash();
|
|
|
|
}
|
|
|
|
restore = true;
|
2004-07-24 21:26:41 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
break;
|
2004-10-12 11:00:19 +00:00
|
|
|
#endif
|
2005-06-22 23:24:45 +00:00
|
|
|
#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
2004-09-19 21:58:37 +00:00
|
|
|
case TREE_OFF | BUTTON_REPEAT:
|
2003-12-04 00:08:25 +00:00
|
|
|
if (charger_inserted()) {
|
|
|
|
charging_splash();
|
|
|
|
restore = true;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-10 21:53:41 +00:00
|
|
|
#endif
|
2004-09-19 21:58:37 +00:00
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2002-08-06 18:11:00 +00:00
|
|
|
case TREE_PREV:
|
2002-08-07 20:51:37 +00:00
|
|
|
case TREE_PREV | BUTTON_REPEAT:
|
2004-09-19 21:58:37 +00:00
|
|
|
#ifdef TREE_RC_PREV
|
|
|
|
case TREE_RC_PREV:
|
|
|
|
case TREE_RC_PREV | BUTTON_REPEAT:
|
2003-12-12 13:34:27 +00:00
|
|
|
#endif
|
2005-01-18 22:45:00 +00:00
|
|
|
if (!tc.filesindir)
|
|
|
|
break;
|
|
|
|
|
2005-06-11 17:35:30 +00:00
|
|
|
/* start scrolling when at 1/3 of the screen */
|
|
|
|
if (tc.dircursor >=
|
|
|
|
tree_max_on_screen - (2 * tree_max_on_screen) / 3
|
|
|
|
|| (tc.dirstart == 0 && tc.dircursor > 0)) {
|
2005-01-18 22:45:00 +00:00
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, false);
|
|
|
|
tc.dircursor--;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (tc.dirstart || tc.firstpos) {
|
|
|
|
if (tc.dirstart)
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirstart--;
|
2002-07-22 22:45:20 +00:00
|
|
|
else {
|
2005-01-18 22:45:00 +00:00
|
|
|
if (tc.firstpos > max_files/2) {
|
|
|
|
tc.firstpos -= max_files/2;
|
|
|
|
tc.dirstart += max_files/2;
|
|
|
|
tc.dirstart--;
|
2002-07-22 22:45:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-01-18 22:45:00 +00:00
|
|
|
tc.dirstart = tc.firstpos - 1;
|
|
|
|
tc.firstpos = 0;
|
2002-07-22 22:45:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 22:45:00 +00:00
|
|
|
restore = true;
|
|
|
|
}
|
|
|
|
else {
|
2005-06-26 21:43:31 +00:00
|
|
|
if (button & BUTTON_REPEAT)
|
|
|
|
break;
|
2005-01-18 22:45:00 +00:00
|
|
|
if (numentries < tree_max_on_screen) {
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor,
|
|
|
|
false);
|
|
|
|
tc.dircursor = numentries - 1;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
else if (id3db && tc.dirfull) {
|
|
|
|
/* load last dir segment */
|
|
|
|
/* use max_files/2 in case names are longer than
|
|
|
|
AVERAGE_FILE_LENGTH */
|
|
|
|
tc.firstpos = tc.dirlength - max_files/2;
|
|
|
|
tc.dirstart = tc.firstpos;
|
|
|
|
tc.dircursor = tree_max_on_screen - 1;
|
|
|
|
numentries = showdir();
|
|
|
|
update_all = true;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tc.dirstart = numentries - tree_max_on_screen;
|
|
|
|
tc.dircursor = tree_max_on_screen - 1;
|
|
|
|
restore = true;
|
|
|
|
}
|
2002-07-22 22:45:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 22:45:00 +00:00
|
|
|
need_update = true;
|
2002-05-16 12:53:40 +00:00
|
|
|
break;
|
2002-05-16 14:48:40 +00:00
|
|
|
|
2002-06-12 08:59:48 +00:00
|
|
|
case TREE_NEXT:
|
2002-08-07 20:51:37 +00:00
|
|
|
case TREE_NEXT | BUTTON_REPEAT:
|
2004-09-19 21:58:37 +00:00
|
|
|
#ifdef TREE_RC_NEXT
|
|
|
|
case TREE_RC_NEXT:
|
|
|
|
case TREE_RC_NEXT | BUTTON_REPEAT:
|
2003-12-12 13:34:27 +00:00
|
|
|
#endif
|
2005-01-18 22:45:00 +00:00
|
|
|
if (!tc.filesindir)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (tc.dircursor + tc.dirstart + 1 < numentries ) {
|
2005-06-11 17:35:30 +00:00
|
|
|
/* start scrolling when at 2/3 of the screen */
|
|
|
|
if(tc.dircursor < (2 * tree_max_on_screen) / 3 ||
|
|
|
|
numentries - tc.dirstart <= tree_max_on_screen) {
|
2005-01-18 22:45:00 +00:00
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, false);
|
|
|
|
tc.dircursor++;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
2002-07-22 22:45:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-01-18 22:45:00 +00:00
|
|
|
tc.dirstart++;
|
|
|
|
restore = true;
|
2002-07-22 22:45:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 22:45:00 +00:00
|
|
|
else if (id3db && (tc.firstpos || tc.dirfull)) {
|
|
|
|
if (tc.dircursor + tc.dirstart + tc.firstpos + 1 >= tc.dirlength) {
|
|
|
|
/* wrap and load first dir segment */
|
2005-06-26 21:43:31 +00:00
|
|
|
if (button & BUTTON_REPEAT)
|
|
|
|
break;
|
2005-01-18 22:45:00 +00:00
|
|
|
tc.firstpos = tc.dirstart = tc.dircursor = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* load next dir segment */
|
|
|
|
tc.firstpos += tc.dirstart;
|
|
|
|
tc.dirstart = 0;
|
|
|
|
}
|
|
|
|
restore = true;
|
|
|
|
}
|
|
|
|
else {
|
2005-06-26 21:43:31 +00:00
|
|
|
if (button & BUTTON_REPEAT)
|
|
|
|
break;
|
2005-01-18 22:45:00 +00:00
|
|
|
if(numentries < tree_max_on_screen) {
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, false);
|
|
|
|
tc.dirstart = tc.dircursor = 0;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tc.dirstart = tc.dircursor = 0;
|
|
|
|
numentries = showdir();
|
|
|
|
update_all=true;
|
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
need_update = true;
|
2002-05-16 12:53:40 +00:00
|
|
|
break;
|
2002-05-21 14:30:54 +00:00
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
#ifdef TREE_PGUP
|
|
|
|
case TREE_PGUP:
|
|
|
|
case TREE_PGUP | BUTTON_REPEAT:
|
2005-01-18 22:45:00 +00:00
|
|
|
if (tc.dirstart) {
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirstart -= tree_max_on_screen;
|
|
|
|
if ( tc.dirstart < 0 )
|
|
|
|
tc.dirstart = 0;
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2005-01-18 22:45:00 +00:00
|
|
|
else if (tc.firstpos) {
|
|
|
|
if (tc.firstpos > max_files/2) {
|
|
|
|
tc.firstpos -= max_files/2;
|
|
|
|
tc.dirstart += max_files/2;
|
|
|
|
tc.dirstart -= tree_max_on_screen;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tc.dirstart = tc.firstpos - tree_max_on_screen;
|
|
|
|
tc.firstpos = 0;
|
|
|
|
}
|
|
|
|
}
|
2004-10-05 00:08:04 +00:00
|
|
|
else
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor = 0;
|
2004-10-05 00:08:04 +00:00
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TREE_PGDN:
|
|
|
|
case TREE_PGDN | BUTTON_REPEAT:
|
2005-01-17 11:39:46 +00:00
|
|
|
if ( tc.dirstart < numentries - tree_max_on_screen ) {
|
|
|
|
tc.dirstart += tree_max_on_screen;
|
2005-01-18 22:45:00 +00:00
|
|
|
if ( tc.dirstart > numentries - tree_max_on_screen )
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirstart = numentries - tree_max_on_screen;
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2005-01-18 22:45:00 +00:00
|
|
|
else if (id3db && tc.dirfull) {
|
|
|
|
/* load next dir segment */
|
|
|
|
tc.firstpos += tc.dirstart;
|
|
|
|
tc.dirstart = 0;
|
|
|
|
}
|
2004-10-05 00:08:04 +00:00
|
|
|
else
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor = numentries - tc.dirstart - 1;
|
2004-10-05 00:08:04 +00:00
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2002-09-03 20:47:23 +00:00
|
|
|
case TREE_MENU:
|
2005-06-12 16:10:17 +00:00
|
|
|
#ifdef TREE_RC_MENU
|
|
|
|
case TREE_RC_MENU:
|
|
|
|
#endif
|
2005-01-02 12:08:34 +00:00
|
|
|
#ifdef TREE_MENU_PRE
|
|
|
|
if (lastbutton != TREE_MENU_PRE)
|
|
|
|
break;
|
|
|
|
#endif
|
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
|
|
|
{
|
|
|
|
lcd_stop_scroll();
|
|
|
|
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
|
|
|
|
|
|
|
id3db = check_changed_id3mode(id3db);
|
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
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
case TREE_WPS:
|
2005-06-12 20:18:37 +00:00
|
|
|
#ifdef TREE_RC_WPS
|
|
|
|
case TREE_RC_WPS:
|
|
|
|
#endif
|
2004-10-05 00:08:04 +00:00
|
|
|
#ifdef TREE_WPS_PRE
|
2005-06-12 20:18:37 +00:00
|
|
|
if ((lastbutton != TREE_WPS_PRE)
|
|
|
|
#ifdef TREE_RC_WPS
|
|
|
|
&& (lastbutton != TREE_RC_WPS_PRE)
|
|
|
|
#endif
|
|
|
|
)
|
2004-10-05 00:08:04 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
/* 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;
|
2002-06-30 16:27:39 +00:00
|
|
|
|
2005-06-26 20:16:26 +00:00
|
|
|
#ifdef TREE_QUICK
|
|
|
|
case TREE_QUICK:
|
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-06-26 20:16:26 +00:00
|
|
|
if (quick_screen(curr_context, TREE_QUICK))
|
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
|
|
|
|
|
|
|
id3db = check_changed_id3mode(id3db);
|
2003-11-04 16:47:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-09-03 15:58:47 +00:00
|
|
|
|
2005-06-26 20:16:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUTTON_F3
|
2002-09-03 15:58:47 +00:00
|
|
|
case BUTTON_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
|
|
|
{
|
2005-06-23 01:31:26 +00:00
|
|
|
if (quick_screen(curr_context, BUTTON_F3))
|
2005-05-16 12:07:25 +00:00
|
|
|
reload_dir = true;
|
2004-03-16 13:44:56 +00:00
|
|
|
tree_max_on_screen = recalc_screen_height();
|
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
|
|
|
|
|
|
|
case TREE_CONTEXT:
|
2005-06-12 20:18:37 +00:00
|
|
|
#ifdef TREE_RC_CONTEXT
|
|
|
|
case TREE_RC_CONTEXT:
|
|
|
|
#endif
|
2004-10-05 00:08:04 +00:00
|
|
|
#ifdef TREE_CONTEXT2
|
|
|
|
case TREE_CONTEXT2:
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
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 {
|
2005-06-23 01:31:26 +00:00
|
|
|
if (id3db)
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2005-06-23 01:31:26 +00:00
|
|
|
switch (tc.currtable)
|
|
|
|
{
|
|
|
|
case allsongs:
|
|
|
|
case songs4album:
|
|
|
|
case songs4artist:
|
|
|
|
case searchsongs:
|
|
|
|
attr=TREE_ATTR_MPA;
|
2005-08-30 07:52:36 +00:00
|
|
|
db_get_filename(&tc, buf, sizeof(buf));
|
2005-06-23 01:31:26 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-30 07:52:36 +00:00
|
|
|
}
|
2005-06-23 01:31:26 +00:00
|
|
|
else
|
2005-08-30 07:52:36 +00:00
|
|
|
{
|
2005-01-20 16:24:26 +00:00
|
|
|
attr = dircache[tc.dircursor+tc.dirstart].attr;
|
2005-08-30 07:52:36 +00:00
|
|
|
|
|
|
|
if (currdir[1])
|
|
|
|
snprintf(buf, sizeof buf, "%s/%s",
|
|
|
|
currdir,
|
|
|
|
dircache[tc.dircursor+tc.dirstart].name);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof buf, "/%s",
|
|
|
|
dircache[tc.dircursor+tc.dirstart].name);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-10-28 09:11:42 +00:00
|
|
|
case BUTTON_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;
|
2004-10-06 21:37:46 +00:00
|
|
|
if (dircache[lasti].attr & ATTR_DIRECTORY)
|
|
|
|
{
|
|
|
|
DEBUGF("Playing directory thumbnail: %s", currdir);
|
2005-01-17 11:39:46 +00:00
|
|
|
res = ft_play_dirname(lasti);
|
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
|
2004-10-21 18:34:48 +00:00
|
|
|
{
|
2004-10-06 21:37:46 +00:00
|
|
|
DEBUGF("Playing file thumbnail: %s/%s%s\n",
|
2005-01-17 11:39:46 +00:00
|
|
|
currdir, dircache[lasti].name, file_thumbnail_ext);
|
2004-10-21 18:34:48 +00:00
|
|
|
/* no fallback necessary, we knew in advance
|
|
|
|
that the file exists */
|
2005-01-17 11:39:46 +00:00
|
|
|
ft_play_filename(currdir, dircache[lasti].name);
|
2004-03-28 10:21:58 +00:00
|
|
|
}
|
|
|
|
thumbnail_time = -1; /* job done */
|
|
|
|
}
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(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:
|
2005-05-14 23:48:18 +00:00
|
|
|
if (!id3db)
|
|
|
|
reload_dir = true;
|
|
|
|
/* 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-04-26 19:23:47 +00:00
|
|
|
if (default_event_handler_ex(button, tree_prepare_usb, NULL)
|
|
|
|
== SYS_USB_CONNECTED)
|
2004-10-24 23:19:13 +00:00
|
|
|
{
|
2005-04-26 21:37:44 +00:00
|
|
|
tagdb_init(); /* re-init database */
|
2005-07-02 10:50:42 +00:00
|
|
|
rundb_init();
|
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
|
|
|
lastbutton = button;
|
|
|
|
}
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
if (start_wps)
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2004-01-14 00:13:04 +00:00
|
|
|
lcd_stop_scroll();
|
|
|
|
if (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
|
|
|
|
else
|
|
|
|
if (!id3db) /* Try reload to catch 'no longer valid' case. */
|
|
|
|
reload_dir = true;
|
|
|
|
#endif
|
2004-01-14 00:13:04 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-03-16 13:44:56 +00:00
|
|
|
tree_max_on_screen = recalc_screen_height();
|
2004-01-14 00:13:04 +00:00
|
|
|
#endif
|
2005-01-20 14:00:20 +00:00
|
|
|
id3db = check_changed_id3mode(id3db);
|
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;
|
|
|
|
}
|
2003-03-07 08:10:10 +00:00
|
|
|
if (! reload_dir )
|
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dircursor = 0;
|
|
|
|
tc.dirstart = 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;
|
2005-01-26 22:48:25 +00:00
|
|
|
button_clear_queue(); /* clear button queue */
|
2002-09-03 20:47:23 +00:00
|
|
|
}
|
|
|
|
|
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 */
|
2003-04-14 07:53:58 +00:00
|
|
|
|
2004-03-17 11:57:25 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-03-17 07:43:19 +00:00
|
|
|
tree_max_on_screen = recalc_screen_height();
|
2004-03-17 11:57:25 +00:00
|
|
|
#endif
|
2005-05-16 11:50:46 +00:00
|
|
|
|
2002-08-08 10:46:10 +00:00
|
|
|
/* We need to adjust if the number of lines on screen have
|
|
|
|
changed because of a status bar change */
|
2005-01-17 11:39:46 +00:00
|
|
|
if(CURSOR_Y+LINE_Y+tc.dircursor>tree_max_on_screen) {
|
|
|
|
tc.dirstart++;
|
|
|
|
tc.dircursor--;
|
2002-08-08 10:46:10 +00:00
|
|
|
}
|
2002-09-30 19:05:03 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
/* the sub-screen might've ruined the margins */
|
|
|
|
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and
|
|
|
|
icon */
|
2003-06-29 16:33:04 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
2002-09-30 19:05:03 +00:00
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
numentries = showdir();
|
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;
|
|
|
|
}
|
2003-01-24 10:56:59 +00:00
|
|
|
update_all = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
put_cursorxy(CURSOR_X, CURSOR_Y + tc.dircursor, true);
|
2003-12-12 13:34:27 +00:00
|
|
|
|
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
|
|
|
}
|
2002-06-10 13:24:27 +00:00
|
|
|
|
2005-05-14 23:48:18 +00:00
|
|
|
if ( (numentries > 0) && need_update) {
|
2005-01-17 11:39:46 +00:00
|
|
|
i = tc.dirstart+tc.dircursor;
|
2002-08-07 10:35:26 +00:00
|
|
|
|
|
|
|
/* if MP3 filter is on, cut off the extension */
|
|
|
|
if(lasti!=i || restore) {
|
2005-01-17 11:39:46 +00:00
|
|
|
char* name;
|
|
|
|
int attr = 0;
|
2005-05-14 23:48:18 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
if (id3db)
|
2005-01-20 16:24:26 +00:00
|
|
|
name = ((char**)tc.dircache)[lasti * tc.dentry_size];
|
2005-01-17 11:39:46 +00:00
|
|
|
else {
|
|
|
|
struct entry* dc = tc.dircache;
|
|
|
|
struct entry* e = &dc[lasti];
|
|
|
|
name = e->name;
|
|
|
|
attr = e->attr;
|
|
|
|
}
|
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
lcd_stop_scroll();
|
2003-01-24 10:56:59 +00:00
|
|
|
|
|
|
|
/* So if lastdircursor and dircursor differ, and then full
|
|
|
|
screen was not refreshed, restore the previous line */
|
2005-01-17 11:39:46 +00:00
|
|
|
if ((lastdircursor != tc.dircursor) && !update_all ) {
|
|
|
|
showfileline(lastdircursor, name, attr, false); /* no scroll */
|
2003-01-24 10:56:59 +00:00
|
|
|
}
|
2003-01-23 14:28:16 +00:00
|
|
|
lasti=i;
|
2005-01-17 11:39:46 +00:00
|
|
|
lastdircursor=tc.dircursor;
|
2004-03-31 07:18:10 +00:00
|
|
|
thumbnail_time = -1; /* cancel whatever we were about to say */
|
2002-10-28 09:11:42 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
if (id3db)
|
2005-01-20 16:24:26 +00:00
|
|
|
name = ((char**)tc.dircache)[lasti * tc.dentry_size];
|
2005-01-17 11:39:46 +00:00
|
|
|
else {
|
|
|
|
struct entry* dc = tc.dircache;
|
|
|
|
struct entry* e = &dc[lasti];
|
|
|
|
name = e->name;
|
|
|
|
attr = e->attr;
|
|
|
|
}
|
|
|
|
showfileline(tc.dircursor, name, attr, true); /* scroll please */
|
2002-10-28 09:11:42 +00:00
|
|
|
need_update = true;
|
2004-03-27 00:11:01 +00:00
|
|
|
|
|
|
|
if (dircache[i].attr & ATTR_DIRECTORY) /* directory? */
|
|
|
|
{
|
|
|
|
/* play directory thumbnail */
|
2005-01-17 11:39:46 +00:00
|
|
|
switch (global_settings.talk_dir) {
|
|
|
|
case 1: /* dirs as numbers */
|
|
|
|
talk_id(VOICE_DIR, false);
|
|
|
|
talk_number(i+1, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* dirs spelled */
|
|
|
|
talk_spell(dircache[i].name, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* thumbnail clip */
|
|
|
|
/* "schedule" a thumbnail, to have a little dalay */
|
|
|
|
thumbnail_time = current_tick + HOVER_DELAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-04-04 19:08:44 +00:00
|
|
|
}
|
2004-03-27 00:11:01 +00:00
|
|
|
}
|
2004-10-21 18:34:48 +00:00
|
|
|
else /* file */
|
2004-04-04 19:08:44 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
switch (global_settings.talk_file) {
|
|
|
|
case 1: /* files as numbers */
|
|
|
|
ft_play_filenumber(i-tc.dirsindir+1,
|
|
|
|
dircache[i].attr & TREE_ATTR_MASK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* files spelled */
|
|
|
|
talk_spell(dircache[i].name, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* thumbnail clip */
|
|
|
|
/* "schedule" a thumbnail, to have a little delay */
|
|
|
|
if (dircache[i].attr & TREE_ATTR_THUMBNAIL)
|
|
|
|
thumbnail_time = current_tick + HOVER_DELAY;
|
|
|
|
else
|
|
|
|
/* spell the number as fallback */
|
|
|
|
talk_spell(dircache[i].name, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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-10-28 09:11:42 +00:00
|
|
|
|
|
|
|
if(need_update) {
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
need_update = false;
|
2003-01-24 10:56:59 +00:00
|
|
|
update_all = false;
|
2002-10-28 09:11:42 +00:00
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
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;
|
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;
|
2003-01-29 17:14:55 +00:00
|
|
|
DIR* dir;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2003-01-29 13:20:22 +00:00
|
|
|
/* check for user abort */
|
2003-12-12 13:34:27 +00:00
|
|
|
#ifdef BUTTON_STOP
|
2003-01-29 13:20:22 +00:00
|
|
|
if (button_get(false) == BUTTON_STOP)
|
|
|
|
#else
|
|
|
|
if (button_get(false) == BUTTON_OFF)
|
|
|
|
#endif
|
|
|
|
return true;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2003-01-29 17:14:55 +00:00
|
|
|
dir = opendir(dirname);
|
2003-01-29 13:20:22 +00:00
|
|
|
if(!dir)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
struct dirent *entry;
|
|
|
|
|
|
|
|
entry = readdir(dir);
|
|
|
|
if (!entry)
|
|
|
|
break;
|
|
|
|
if (entry->attribute & ATTR_DIRECTORY) {
|
2004-03-21 22:27:56 +00:00
|
|
|
int dirlen = strlen(dirname);
|
|
|
|
bool result;
|
|
|
|
|
2003-01-29 13:20:22 +00:00
|
|
|
if (!strcmp(entry->d_name, ".") ||
|
|
|
|
!strcmp(entry->d_name, ".."))
|
|
|
|
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 {
|
|
|
|
int x = strlen(entry->d_name);
|
2005-06-20 09:00:53 +00:00
|
|
|
int xl;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
/* add all supported audio files to playlists */
|
|
|
|
for (i=0; i < sizeof(filetypes); i++) {
|
|
|
|
if (filetypes[i].tree_attr == TREE_ATTR_MPA) {
|
|
|
|
xl=strlen(filetypes[i].extension);
|
|
|
|
if (!strcasecmp(&entry->d_name[x-xl],
|
|
|
|
filetypes[i].extension))
|
|
|
|
{
|
|
|
|
char buf[8];
|
|
|
|
write(fd, dirname, strlen(dirname));
|
|
|
|
write(fd, "/", 1);
|
|
|
|
write(fd, entry->d_name, x);
|
|
|
|
write(fd, "\n", 1);
|
|
|
|
|
|
|
|
plsize++;
|
|
|
|
snprintf(buf, sizeof buf, "%d", plsize);
|
2003-01-29 13:20:22 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-06-20 09:00:53 +00:00
|
|
|
lcd_puts(0,4,buf);
|
|
|
|
lcd_update();
|
2003-01-29 13:20:22 +00:00
|
|
|
#else
|
2005-06-20 09:00:53 +00:00
|
|
|
x = 10;
|
|
|
|
if (plsize > 999)
|
|
|
|
x=7;
|
|
|
|
else {
|
|
|
|
if (plsize > 99)
|
|
|
|
x=8;
|
|
|
|
else {
|
|
|
|
if (plsize > 9)
|
|
|
|
x=9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lcd_puts(x,0,buf);
|
|
|
|
#endif
|
2003-01-29 13:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
return abort;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool create_playlist(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
|
|
|
|
snprintf(filename, sizeof filename, "%s.m3u",
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.currdir[1] ? tc.currdir : "/root");
|
2003-01-29 13:20:22 +00:00
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_CREATING));
|
|
|
|
lcd_puts_scroll(0,1,filename);
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
fd = creat(filename,0);
|
2003-03-21 03:07:31 +00:00
|
|
|
if (fd < 0)
|
2003-01-29 13:20:22 +00:00
|
|
|
return false;
|
|
|
|
|
2005-06-20 09:00:53 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
cpu_boost(true);
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2005-06-20 10:39:47 +00:00
|
|
|
cpu_boost(false);
|
2005-06-20 09:00:53 +00:00
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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;
|
2003-09-29 21:26:53 +00:00
|
|
|
reload_dir = true;
|
|
|
|
|
|
|
|
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-01-19 15:01:31 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
/* initialize tree context struct */
|
|
|
|
memset(&tc, 0, sizeof(tc));
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
|
|
|
|
2005-04-26 21:37:44 +00:00
|
|
|
tagdb_init();
|
2005-07-02 10:50:42 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
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;
|
2004-01-14 00:13:04 +00:00
|
|
|
int len=strlen(resume_file);
|
|
|
|
|
|
|
|
if (!strcasecmp(&resume_file[len-4], ".m3u"))
|
|
|
|
{
|
2004-12-07 14:20:37 +00:00
|
|
|
/* Playlist playback */
|
2004-01-14 00:13:04 +00:00
|
|
|
char* slash;
|
|
|
|
// check that the file exists
|
|
|
|
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 */
|
|
|
|
if ((strcmp(strrchr(playlist_peek(index) + 1,'/') + 1,
|
|
|
|
filename)))
|
|
|
|
{
|
|
|
|
for ( i=0; i < playlist_amount(); i++ )
|
|
|
|
{
|
|
|
|
if ((strcmp(strrchr(playlist_peek(i) + 1,'/') + 1,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ft_play_dirname(int start_index)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char dirname_mp3_filename[MAX_PATH+1];
|
|
|
|
struct entry *dircache = tc.dircache;
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
2005-01-17 11:39:46 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
snprintf(dirname_mp3_filename, sizeof(dirname_mp3_filename), "%s/%s/%s",
|
2005-05-02 22:22:21 +00:00
|
|
|
tc.currdir[1] ? tc.currdir : "" , dircache[start_index].name,
|
|
|
|
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);
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_status() & AUDIO_STATUS_PLAY)
|
2005-01-17 11:39:46 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|