2002-05-16 12:53:40 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Daniel Stenberg
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-05-16 12:53:40 +00:00
|
|
|
*
|
|
|
|
* 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 <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
2010-05-06 21:04:40 +00:00
|
|
|
#include "string-extra.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
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-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"
|
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"
|
2009-08-03 04:43:34 +00:00
|
|
|
#include "skin_engine/skin_engine.h"
|
2002-06-27 09:12:29 +00:00
|
|
|
#include "settings.h"
|
2002-06-30 13:23:58 +00:00
|
|
|
#include "debug.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.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 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-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"
|
2010-08-01 16:15:27 +00:00
|
|
|
#include "filefuncs.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-08-05 20:19:10 +00:00
|
|
|
#include "eeprom_settings.h"
|
2008-05-04 13:01:16 +00:00
|
|
|
#include "playlist_catalog.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* gui api */
|
|
|
|
#include "list.h"
|
|
|
|
#include "splash.h"
|
|
|
|
#include "buttonbar.h"
|
2008-05-03 12:30:40 +00:00
|
|
|
#include "quickscreen.h"
|
2009-09-20 00:04:39 +00:00
|
|
|
#include "appevents.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "root_menu.h"
|
2006-05-21 11:00:02 +00:00
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
static const struct filetype *filetypes;
|
|
|
|
static int filetypes_count;
|
2003-12-07 16:57:43 +00:00
|
|
|
|
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 */
|
2008-05-29 20:32:39 +00:00
|
|
|
#ifdef HAVE_BUTTONBAR
|
2010-01-09 17:42:54 +00:00
|
|
|
static struct gui_buttonbar tree_buttonbar;
|
2005-10-28 00:00:00 +00:00
|
|
|
#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];
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-01-18 22:45:00 +00:00
|
|
|
static int lasttable, lastextra, lastfirstpos;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
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-10-28 00:00:00 +00:00
|
|
|
static int curr_context = false;/* id3db or tree*/
|
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
static int dirbrowse(void);
|
|
|
|
static int ft_play_dirname(char* name);
|
|
|
|
static void ft_play_filename(char *dir, char *file);
|
2007-10-21 00:20:51 +00:00
|
|
|
static void say_filetype(int attr);
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* tree_get_filename(int selected_item, void *data,
|
|
|
|
char *buffer, size_t buffer_len)
|
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;
|
2007-08-13 23:11:30 +00:00
|
|
|
bool stripit = false;
|
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;
|
|
|
|
}
|
2007-08-13 23:11:30 +00:00
|
|
|
|
2007-08-14 21:02:44 +00:00
|
|
|
if(!(attr & ATTR_DIRECTORY))
|
2007-08-13 23:11:30 +00:00
|
|
|
{
|
2007-08-14 21:02:44 +00:00
|
|
|
switch(global_settings.show_filename_ext)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
/* show file extension: off */
|
|
|
|
stripit = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* show file extension: on */
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* show file extension: only unknown types */
|
|
|
|
stripit = filetype_supported(attr);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
/* show file extension: only when viewing all */
|
|
|
|
stripit = (*(local_tc->dirfilter) != SHOW_ID3DB) &&
|
|
|
|
(*(local_tc->dirfilter) != SHOW_ALL);
|
|
|
|
break;
|
|
|
|
}
|
2007-08-13 23:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(stripit)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2008-04-09 15:25:17 +00:00
|
|
|
return(strip_extension(buffer, buffer_len, name));
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
return(name);
|
|
|
|
}
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
static int tree_get_filecolor(int selected_item, void * data)
|
|
|
|
{
|
2007-06-19 09:53:58 +00:00
|
|
|
if (*tc.dirfilter == SHOW_ID3DB)
|
|
|
|
return -1;
|
2007-06-17 21:16:34 +00:00
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
|
|
|
struct entry* dc = local_tc->dircache;
|
|
|
|
struct entry* e = &dc[selected_item];
|
2007-06-17 23:10:01 +00:00
|
|
|
return filetype_get_color(e->name, e->attr);
|
2007-06-17 21:16:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2009-07-11 00:22:26 +00:00
|
|
|
static enum themable_icons tree_get_fileicon(int selected_item, void * data)
|
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) {
|
2007-04-16 09:14:36 +00:00
|
|
|
return tagtree_get_icon(&tc);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-10-25 10:17:57 +00:00
|
|
|
else
|
|
|
|
#endif
|
2007-02-27 11:09:09 +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];
|
2007-04-16 09:14:36 +00:00
|
|
|
return filetype_get_icon(e->attr);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-01 21:05:43 +00:00
|
|
|
|
2007-10-21 00:20:51 +00:00
|
|
|
static int tree_voice_cb(int selected_item, void * data)
|
|
|
|
{
|
|
|
|
struct tree_context * local_tc=(struct tree_context *)data;
|
|
|
|
char *name;
|
|
|
|
int attr=0;
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
bool id3db = *(local_tc->dirfilter) == SHOW_ID3DB;
|
|
|
|
|
|
|
|
if (id3db)
|
|
|
|
{
|
|
|
|
attr = tagtree_get_attr(local_tc);
|
|
|
|
name = tagtree_get_entry(local_tc, selected_item)->name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
struct entry* dc = local_tc->dircache;
|
|
|
|
struct entry* e = &dc[selected_item];
|
|
|
|
name = e->name;
|
|
|
|
attr = e->attr;
|
|
|
|
}
|
|
|
|
bool is_dir = (attr & ATTR_DIRECTORY);
|
|
|
|
bool did_clip = false;
|
|
|
|
/* First the .talk clip case */
|
|
|
|
if(is_dir)
|
|
|
|
{
|
|
|
|
if(global_settings.talk_dir_clip)
|
|
|
|
{
|
|
|
|
did_clip = true;
|
|
|
|
if(ft_play_dirname(name) <0)
|
|
|
|
/* failed, not existing */
|
|
|
|
did_clip = false;
|
|
|
|
}
|
|
|
|
} else { /* it's a file */
|
|
|
|
if (global_settings.talk_file_clip && (attr & FILE_ATTR_THUMBNAIL))
|
|
|
|
{
|
|
|
|
did_clip = true;
|
|
|
|
ft_play_filename(local_tc->currdir, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!did_clip)
|
|
|
|
{
|
|
|
|
/* say the number or spell if required or as a fallback */
|
|
|
|
switch (is_dir ? global_settings.talk_dir : global_settings.talk_file)
|
|
|
|
{
|
|
|
|
case 1: /* as numbers */
|
|
|
|
talk_id(is_dir ? VOICE_DIR : VOICE_FILE, false);
|
|
|
|
talk_number(selected_item+1 - (is_dir ? 0 : local_tc->dirsindir),
|
|
|
|
true);
|
2007-11-07 03:25:33 +00:00
|
|
|
if(global_settings.talk_filetype
|
|
|
|
&& !is_dir && *local_tc->dirfilter < NUM_FILTER_MODES)
|
2007-10-21 00:20:51 +00:00
|
|
|
say_filetype(attr);
|
|
|
|
break;
|
|
|
|
case 2: /* spelled */
|
2007-11-07 01:45:43 +00:00
|
|
|
talk_shutup();
|
2007-11-07 03:25:33 +00:00
|
|
|
if(global_settings.talk_filetype)
|
|
|
|
{
|
|
|
|
if(is_dir)
|
|
|
|
talk_id(VOICE_DIR, true);
|
|
|
|
else if(*local_tc->dirfilter < NUM_FILTER_MODES)
|
|
|
|
say_filetype(attr);
|
|
|
|
}
|
2007-11-07 01:45:43 +00:00
|
|
|
talk_spell(name, true);
|
2007-10-21 00:20:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-10 20:51:12 +00:00
|
|
|
bool check_rockboxdir(void)
|
2002-05-16 12:53:40 +00:00
|
|
|
{
|
2010-12-06 22:26:31 +00:00
|
|
|
if(!dir_exists(ROCKBOX_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();
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, "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();
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, "Installation incomplete");
|
2004-09-10 20:51:12 +00:00
|
|
|
return false;
|
2004-09-05 16:50:07 +00:00
|
|
|
}
|
2004-09-10 20:51:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-06-10 10:41:27 +00:00
|
|
|
/* do this really late in the init sequence */
|
|
|
|
void tree_gui_init(void)
|
2004-09-10 20:51:12 +00:00
|
|
|
{
|
|
|
|
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
|
2008-05-29 20:32:39 +00:00
|
|
|
#ifdef HAVE_BUTTONBAR
|
2005-10-28 00:00:00 +00:00
|
|
|
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
|
2008-03-26 03:35:24 +00:00
|
|
|
gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
|
2009-12-16 08:36:46 +00:00
|
|
|
gui_synclist_set_icon_callback(&tree_lists,
|
|
|
|
global_settings.show_icons?&tree_get_fileicon:NULL);
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-03-05 09:58:30 +00:00
|
|
|
gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
|
2007-06-17 21:16:34 +00:00
|
|
|
#endif
|
2002-05-16 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
|
2009-09-20 00:04:39 +00:00
|
|
|
/* drawer function for the GUI_EVENT_REDRAW callback */
|
|
|
|
void tree_drawlists(void)
|
|
|
|
{
|
2010-02-07 18:38:47 +00:00
|
|
|
/* band-aid to fix the bar/list redrawing properly after leaving a plugin */
|
|
|
|
send_event(GUI_EVENT_THEME_CHANGED, NULL);
|
|
|
|
/* end bandaid */
|
2009-09-20 00:04:39 +00:00
|
|
|
gui_synclist_draw(&tree_lists);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Returns the position of a given file in the current directory
|
|
|
|
* returns -1 if not found
|
|
|
|
*/
|
2006-12-25 14:01:47 +00:00
|
|
|
static 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
|
|
|
{
|
2007-11-20 13:53:29 +00:00
|
|
|
bool changed = false;
|
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;
|
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
|
2007-11-20 13:53:29 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if the tc.currdir has been changed, reload it ...*/
|
2007-11-20 13:53:29 +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
|
2007-02-27 11:09:09 +00:00
|
|
|
!id3db &&
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2011-05-04 18:33:12 +00:00
|
|
|
tc.dirfull )
|
2003-04-14 07:53:58 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(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)
|
|
|
|
{
|
2008-01-13 09:29:45 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-09-19 12:36:21 +00:00
|
|
|
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),
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-09-19 12:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Must clear the title as the list is reused */
|
|
|
|
gui_synclist_set_title(&tree_lists, NULL, NOICON);
|
|
|
|
}
|
2008-01-13 09:29:45 +00:00
|
|
|
#endif
|
2006-09-19 12:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
2006-10-25 10:17:57 +00:00
|
|
|
#endif
|
2006-09-19 12:36:21 +00:00
|
|
|
{
|
2008-01-13 09:29:45 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2010-12-14 13:37:58 +00:00
|
|
|
if (tc.browse && tc.browse->title)
|
2007-08-16 13:55:37 +00:00
|
|
|
{
|
2010-12-14 13:37:58 +00:00
|
|
|
int icon = tc.browse->icon;
|
|
|
|
if (icon == NOICON)
|
|
|
|
icon = filetype_get_icon(ATTR_DIRECTORY);
|
|
|
|
gui_synclist_set_title(&tree_lists, tc.browse->title, icon);
|
2007-08-16 13:55:37 +00:00
|
|
|
}
|
|
|
|
else if (global_settings.show_path_in_browser == SHOW_PATH_FULL)
|
2006-08-23 20:02:06 +00:00
|
|
|
{
|
|
|
|
gui_synclist_set_title(&tree_lists, tc.currdir,
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-23 20:02:06 +00:00
|
|
|
}
|
|
|
|
else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT)
|
|
|
|
{
|
|
|
|
char *title = strrchr(tc.currdir, '/') + 1;
|
|
|
|
if (*title == '\0')
|
|
|
|
{
|
2007-03-01 17:34:49 +00:00
|
|
|
/* Display "Files" for the root dir */
|
|
|
|
gui_synclist_set_title(&tree_lists, str(LANG_DIR_BROWSER),
|
2007-03-01 18:25:13 +00:00
|
|
|
filetype_get_icon(ATTR_DIRECTORY));
|
2006-08-23 20:02:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gui_synclist_set_title(&tree_lists, title,
|
2007-03-01 18:25:13 +00:00
|
|
|
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);
|
|
|
|
}
|
2008-01-13 09:29:45 +00:00
|
|
|
#endif
|
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);
|
2009-12-16 08:36:46 +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);
|
2008-05-29 20:32:39 +00:00
|
|
|
#ifdef HAVE_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);
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_speak_item(&tree_lists);
|
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
|
|
|
{
|
2010-02-07 18:38:47 +00:00
|
|
|
int dirfilter = *tc.dirfilter;
|
|
|
|
int ret;
|
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
|
2010-02-07 18:38:47 +00:00
|
|
|
/* make sure the dirfilter is sane. The only time it should be possible
|
|
|
|
* thats its not is when resume playlist is called from a plugin
|
|
|
|
*/
|
2009-02-25 05:41:31 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2010-02-07 18:38:47 +00:00
|
|
|
if (!id3db)
|
2009-02-25 05:41:31 +00:00
|
|
|
#endif
|
2010-02-07 18:38:47 +00:00
|
|
|
*tc.dirfilter = global_settings.dirfilter;
|
|
|
|
ret = ft_load(&tc, dir);
|
|
|
|
*tc.dirfilter = dirfilter;
|
|
|
|
if (ret < 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. */
|
2010-08-27 12:38:25 +00:00
|
|
|
char *getcwd(char *buf, getcwd_size_t size)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
|
|
|
if (!buf)
|
2005-01-17 11:39:46 +00:00
|
|
|
return tc.currdir;
|
2010-08-27 10:33:09 +00:00
|
|
|
else if (size)
|
2003-07-01 21:05:43 +00:00
|
|
|
{
|
2010-08-27 12:38:25 +00:00
|
|
|
if ((getcwd_size_t)strlcpy(buf, tc.currdir, size) < size)
|
2010-08-27 10:33:09 +00:00
|
|
|
return buf;
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
2010-08-27 10:33:09 +00:00
|
|
|
/* size == 0, or truncation in strlcpy */
|
|
|
|
return NULL;
|
2003-07-01 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Force a reload of the directory next time directory browser is called */
|
|
|
|
void reload_directory(void)
|
|
|
|
{
|
|
|
|
reload_dir = true;
|
|
|
|
}
|
|
|
|
|
2010-08-27 10:33:09 +00:00
|
|
|
char* get_current_file(char* buffer, size_t buffer_len)
|
2007-03-06 08:21:18 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
/* in ID3DB mode it is a bad idea to call this function */
|
|
|
|
/* (only happens with `follow playlist') */
|
|
|
|
if( *tc.dirfilter == SHOW_ID3DB )
|
2010-08-27 10:33:09 +00:00
|
|
|
return NULL;
|
2007-03-06 08:21:18 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct entry* dc = tc.dircache;
|
|
|
|
struct entry* e = &dc[tc.selected_item];
|
2010-08-27 10:33:09 +00:00
|
|
|
if (getcwd(buffer, buffer_len))
|
|
|
|
{
|
|
|
|
if (tc.dirlength)
|
|
|
|
{
|
2010-10-04 10:34:38 +00:00
|
|
|
if (buffer[strlen(buffer)-1] != '/')
|
|
|
|
strlcat(buffer, "/", buffer_len);
|
2010-08-27 10:33:09 +00:00
|
|
|
if (strlcat(buffer, e->name, buffer_len) >= buffer_len)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-03-06 08:21:18 +00:00
|
|
|
}
|
|
|
|
|
2007-08-05 12:14:07 +00:00
|
|
|
/* Allow apps to change our dirfilter directly (required for sub browsers)
|
|
|
|
if they're suddenly going to become a file browser for example */
|
|
|
|
void set_dirfilter(int l_dirfilter)
|
|
|
|
{
|
|
|
|
*tc.dirfilter = l_dirfilter;
|
|
|
|
}
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Selects a file and update tree context properly */
|
2010-10-22 12:50:14 +00:00
|
|
|
void set_current_file(const char *path)
|
2002-09-09 14:25:39 +00:00
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
const 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)
|
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
strlcpy(tc.currdir, path, name - path + 1);
|
2002-09-09 14:25:39 +00:00
|
|
|
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
|
|
|
|
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 */
|
2007-03-01 11:14:46 +00:00
|
|
|
for (i = 1; path[i] != '\0'; 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if (ft_load(&tc, NULL) >= 0)
|
|
|
|
{
|
|
|
|
tc.selected_item = tree_get_file_position(lastfile);
|
|
|
|
}
|
2002-09-09 14:25:39 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 10:17:57 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* main loop, handles key events */
|
2010-12-14 13:37:58 +00:00
|
|
|
static int 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];
|
2008-12-31 05:59:26 +00:00
|
|
|
int button, oldbutton;
|
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-09-29 21:26:53 +00:00
|
|
|
bool exit_func = false;
|
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;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (tc.selected_item < 0)
|
|
|
|
tc.selected_item = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-11-20 13:53:29 +00:00
|
|
|
tc.firstpos = 0;
|
2005-01-18 22:45:00 +00:00
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
|
|
|
lastfirstpos = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
2002-09-09 14:25:39 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
start_wps = false;
|
|
|
|
numentries = update_dir();
|
2007-10-21 00:20:51 +00:00
|
|
|
reload_dir = false;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (numentries == -1)
|
2007-10-19 06:11:13 +00:00
|
|
|
return GO_TO_PREVIOUS; /* currdir is not a directory */
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
if (*tc.dirfilter > NUM_FILTER_MODES && numentries==0)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, ID2P(LANG_NO_FILES));
|
2010-12-14 13:37:58 +00:00
|
|
|
return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
|
2005-01-21 15:42:47 +00:00
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2009-01-15 06:24:58 +00:00
|
|
|
gui_synclist_draw(&tree_lists);
|
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;
|
2007-03-01 11:14:46 +00:00
|
|
|
if (tc.dirlevel < 0)
|
2007-11-20 13:53:29 +00:00
|
|
|
tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
|
2005-03-31 10:50:15 +00:00
|
|
|
#ifdef BOOTFILE
|
2003-06-29 22:39:35 +00:00
|
|
|
if (boot_changed) {
|
2008-04-26 09:30:24 +00:00
|
|
|
static const char *lines[]={ID2P(LANG_BOOT_CHANGED), ID2P(LANG_REBOOT_NOW)};
|
|
|
|
static const struct text_message message={lines, 2};
|
2005-11-18 02:07:02 +00:00
|
|
|
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
|
2007-10-21 00:20:51 +00:00
|
|
|
button = get_action(CONTEXT_TREE,
|
|
|
|
list_do_action_timeout(&tree_lists, HZ/2));
|
2007-09-17 10:08:50 +00:00
|
|
|
oldbutton = button;
|
2007-10-21 00:20:51 +00:00
|
|
|
gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD);
|
2007-03-10 12:51:08 +00:00
|
|
|
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
|
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
|
|
|
|
2010-12-14 13:37:58 +00:00
|
|
|
if ((tc.browse->flags & BROWSE_SELECTONLY) &&
|
|
|
|
!(dircache[tc.selected_item].attr & ATTR_DIRECTORY))
|
|
|
|
{
|
|
|
|
tc.browse->flags |= BROWSE_SELECTED;
|
|
|
|
get_current_file(tc.browse->buf, tc.browse->bufsize);
|
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-08-16 13:16:29 +00:00
|
|
|
case GO_TO_FILEBROWSER: reload_dir = true; break;
|
|
|
|
case GO_TO_WPS:
|
|
|
|
return GO_TO_WPS;
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
case GO_TO_FM:
|
|
|
|
return GO_TO_FM;
|
|
|
|
#endif
|
|
|
|
case GO_TO_ROOT: 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;
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) ||
|
|
|
|
((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/"))))
|
|
|
|
{
|
2007-09-17 10:08:50 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
|
|
|
|
if (oldbutton == ACTION_TREE_PGLEFT)
|
2007-03-01 23:41:45 +00:00
|
|
|
break;
|
|
|
|
else
|
2007-09-17 10:08:50 +00:00
|
|
|
#endif
|
2007-03-01 23:41:45 +00:00
|
|
|
return GO_TO_ROOT;
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
|
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:
|
2007-04-09 13:39:37 +00:00
|
|
|
if (list_stop_handler())
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_MENU:
|
2007-03-01 13:01:14 +00:00
|
|
|
return GO_TO_ROOT;
|
2002-06-25 13:26:04 +00:00
|
|
|
break;
|
2002-05-21 14:30:54 +00:00
|
|
|
|
2007-08-02 12:13:20 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
case ACTION_STD_REC:
|
|
|
|
return GO_TO_RECSCREEN;
|
|
|
|
#endif
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_WPS:
|
2007-03-01 13:01:14 +00:00
|
|
|
return GO_TO_PREVIOUS_MUSIC;
|
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;
|
|
|
|
}
|
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
|
|
|
{
|
2008-04-03 13:38:24 +00:00
|
|
|
if (quick_screen_f3(ACTION_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
|
|
|
|
2010-05-09 02:07:42 +00:00
|
|
|
#ifdef HAVE_HOTKEY
|
2010-04-01 03:14:44 +00:00
|
|
|
case ACTION_TREE_HOTKEY:
|
2010-05-09 02:02:51 +00:00
|
|
|
if (!global_settings.hotkey_tree)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
2010-05-09 02:07:42 +00:00
|
|
|
#endif
|
2010-05-09 02:02:51 +00:00
|
|
|
case ACTION_STD_CONTEXT:
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2010-04-01 03:14:44 +00:00
|
|
|
bool hotkey = button == ACTION_TREE_HOTKEY;
|
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
|
|
|
|
2010-12-15 18:14:13 +00:00
|
|
|
if (tc.browse->flags & BROWSE_NO_CONTEXT_MENU)
|
2010-12-14 13:37:58 +00:00
|
|
|
break;
|
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
if(!numentries)
|
2010-04-01 03:14:44 +00:00
|
|
|
onplay_result = onplay(NULL, 0, curr_context, hotkey);
|
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
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
if (tagtree_get_attr(&tc) == FILE_ATTR_AUDIO)
|
2005-06-23 01:31:26 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
attr = FILE_ATTR_AUDIO;
|
2006-05-05 07:01:43 +00:00
|
|
|
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
|
|
|
}
|
2010-04-01 03:14:44 +00:00
|
|
|
onplay_result = onplay(buf, attr, curr_context, hotkey);
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
|
|
|
switch (onplay_result)
|
|
|
|
{
|
2007-03-01 11:14:46 +00:00
|
|
|
case ONPLAY_MAINMENU:
|
|
|
|
return GO_TO_ROOT;
|
|
|
|
|
2004-10-05 00:08:04 +00:00
|
|
|
case ONPLAY_OK:
|
|
|
|
restore = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_RELOAD_DIR:
|
|
|
|
reload_dir = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ONPLAY_START_PLAY:
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_WPS;
|
2004-10-05 00:08:04 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
if (start_wps)
|
|
|
|
return GO_TO_WPS;
|
2009-01-01 13:12:37 +00:00
|
|
|
if (button && !IS_SYSEVENT(button))
|
2004-10-05 00:08:04 +00:00
|
|
|
{
|
2008-11-01 16:14:28 +00:00
|
|
|
storage_spin();
|
2004-10-05 00:08:04 +00:00
|
|
|
}
|
2003-12-12 13:34:27 +00:00
|
|
|
|
2004-01-14 00:13:04 +00:00
|
|
|
|
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
|
|
|
{
|
2007-11-20 13:53:29 +00:00
|
|
|
if (reload_root) {
|
2002-09-03 20:47:23 +00:00
|
|
|
strcpy(currdir, "/");
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirlevel = 0;
|
2007-02-06 13:25:57 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2005-04-26 19:23:47 +00:00
|
|
|
tc.currtable = 0;
|
|
|
|
tc.currextra = 0;
|
|
|
|
lasttable = -1;
|
|
|
|
lastextra = -1;
|
2007-02-06 13:25:57 +00:00
|
|
|
#endif
|
2002-09-03 20:47:23 +00:00
|
|
|
reload_root = false;
|
|
|
|
}
|
2006-04-10 03:51:17 +00:00
|
|
|
|
2007-11-20 13:53:29 +00:00
|
|
|
if (!reload_dir)
|
2003-03-07 08:10:10 +00:00
|
|
|
{
|
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)
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_PREVIOUS;
|
2003-09-29 21:26:53 +00:00
|
|
|
|
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();
|
2007-10-21 00:20:51 +00:00
|
|
|
reload_dir = false;
|
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 */
|
|
|
|
goto check_rescan;
|
|
|
|
}
|
2002-08-07 10:35:26 +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
|
|
|
|
|
|
|
bool create_playlist(void)
|
|
|
|
{
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
|
2011-07-20 14:11:15 +00:00
|
|
|
if (tc.currdir[1])
|
|
|
|
snprintf(filename, sizeof filename, "%s.m3u8", tc.currdir);
|
|
|
|
else
|
|
|
|
snprintf(filename, sizeof filename, "%s/all.m3u8",
|
|
|
|
catalog_get_directory());
|
|
|
|
|
|
|
|
|
|
|
|
if (kbd_input(filename, MAX_PATH))
|
|
|
|
return false;
|
2008-08-15 08:27:39 +00:00
|
|
|
splashf(0, "%s %s", str(LANG_CREATING), filename);
|
2003-01-29 13:20:22 +00:00
|
|
|
|
2006-11-11 05:33:24 +00:00
|
|
|
trigger_cpu_boost();
|
2008-05-04 13:01:16 +00:00
|
|
|
catalog_add_to_a_playlist(tc.currdir, ATTR_DIRECTORY, true, filename);
|
2007-11-20 03:44:25 +00:00
|
|
|
cancel_cpu_boost();
|
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
|
|
|
|
2010-12-14 13:37:58 +00:00
|
|
|
void browse_context_init(struct browse_context *browse,
|
|
|
|
int dirfilter, unsigned flags,
|
|
|
|
char *title, enum themable_icons icon,
|
|
|
|
const char *root, const char *selected)
|
|
|
|
{
|
|
|
|
browse->dirfilter = dirfilter;
|
|
|
|
browse->flags = flags;
|
|
|
|
browse->callback_show_item = NULL;
|
|
|
|
browse->title = title;
|
|
|
|
browse->icon = icon;
|
|
|
|
browse->root = root;
|
|
|
|
browse->selected = selected;
|
|
|
|
browse->buf = NULL;
|
|
|
|
browse->bufsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NUM_TC_BACKUP 3
|
|
|
|
static struct tree_context backups[NUM_TC_BACKUP];
|
|
|
|
/* do not make backup if it is not recursive call */
|
|
|
|
static int backup_count = -1;
|
|
|
|
int rockbox_browse(struct browse_context *browse)
|
2003-09-29 21:26:53 +00:00
|
|
|
{
|
2010-10-22 12:50:14 +00:00
|
|
|
static char current[MAX_PATH];
|
2007-03-01 11:14:46 +00:00
|
|
|
int ret_val = 0;
|
2010-12-14 13:37:58 +00:00
|
|
|
int dirfilter = browse->dirfilter;
|
|
|
|
|
|
|
|
if (backup_count >= NUM_TC_BACKUP)
|
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
if (backup_count >= 0)
|
|
|
|
backups[backup_count] = tc;
|
|
|
|
backup_count++;
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.dirfilter = &dirfilter;
|
2008-10-08 16:32:01 +00:00
|
|
|
tc.sort_dir = global_settings.sort_dir;
|
2010-12-14 13:37:58 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
reload_dir = true;
|
2010-12-14 13:37:58 +00:00
|
|
|
if (*tc.dirfilter >= NUM_FILTER_MODES)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
int last_context;
|
2010-12-14 13:37:58 +00:00
|
|
|
|
|
|
|
tc.browse = browse;
|
2007-03-06 08:21:18 +00:00
|
|
|
tc.selected_item = 0;
|
2007-03-01 11:14:46 +00:00
|
|
|
tc.dirlevel = 0;
|
2010-12-14 13:37:58 +00:00
|
|
|
strlcpy(tc.currdir, browse->root, sizeof(tc.currdir));
|
2007-03-01 11:14:46 +00:00
|
|
|
start_wps = false;
|
|
|
|
last_context = curr_context;
|
2010-07-25 16:27:41 +00:00
|
|
|
|
2010-12-14 13:37:58 +00:00
|
|
|
if (browse->selected)
|
2009-06-22 17:37:36 +00:00
|
|
|
{
|
2010-12-14 13:37:58 +00:00
|
|
|
snprintf(current, sizeof(current), "%s/%s",
|
|
|
|
browse->root, browse->selected);
|
2009-06-22 17:37:36 +00:00
|
|
|
set_current_file(current);
|
|
|
|
/* set_current_file changes dirlevel, change it back */
|
|
|
|
tc.dirlevel = 0;
|
|
|
|
}
|
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
ret_val = dirbrowse();
|
|
|
|
curr_context = last_context;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dirfilter != SHOW_ID3DB)
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
2010-12-14 13:37:58 +00:00
|
|
|
tc.browse = browse;
|
|
|
|
strcpy(current, browse->root);
|
2010-10-22 12:50:14 +00:00
|
|
|
set_current_file(current);
|
2007-03-01 11:14:46 +00:00
|
|
|
ret_val = dirbrowse();
|
|
|
|
}
|
2010-12-14 13:37:58 +00:00
|
|
|
backup_count--;
|
|
|
|
if (backup_count >= 0)
|
|
|
|
tc = backups[backup_count];
|
2007-03-01 11:14:46 +00:00
|
|
|
return ret_val;
|
2003-09-29 21:26:53 +00:00
|
|
|
}
|
|
|
|
|
2007-06-10 10:41:27 +00:00
|
|
|
void tree_mem_init(void)
|
2003-05-09 16:01:21 +00:00
|
|
|
{
|
2005-01-17 11:39:46 +00:00
|
|
|
/* initialize tree context struct */
|
|
|
|
memset(&tc, 0, sizeof(tc));
|
|
|
|
tc.dirfilter = &global_settings.dirfilter;
|
2008-10-08 16:32:01 +00:00
|
|
|
tc.sort_dir = global_settings.sort_dir;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2011-04-30 11:00:26 +00:00
|
|
|
tc.name_buffer_size = AVERAGE_FILENAME_LENGTH *
|
|
|
|
global_settings.max_files_in_dir;
|
2005-01-17 11:39:46 +00:00
|
|
|
tc.name_buffer = buffer_alloc(tc.name_buffer_size);
|
|
|
|
|
2011-04-30 11:00:26 +00:00
|
|
|
tc.dircache_count = global_settings.max_files_in_dir;
|
|
|
|
tc.dircache = buffer_alloc(global_settings.max_files_in_dir *
|
|
|
|
sizeof(struct entry));
|
2007-04-18 13:03:01 +00:00
|
|
|
tree_get_filetypes(&filetypes, &filetypes_count);
|
2003-05-09 16:01:21 +00:00
|
|
|
}
|
2004-01-14 00:13:04 +00:00
|
|
|
|
2008-02-10 12:16:27 +00:00
|
|
|
bool bookmark_play(char *resume_file, int index, int offset, int seed,
|
2004-12-07 14:20:37 +00:00
|
|
|
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, '.');
|
2008-02-10 12:16:27 +00:00
|
|
|
bool started = false;
|
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 */
|
2008-04-16 19:51:43 +00:00
|
|
|
if(!file_exists(resume_file))
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2004-01-14 00:13:04 +00:00
|
|
|
|
|
|
|
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);
|
2008-02-10 12:16:27 +00:00
|
|
|
started = true;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
|
|
|
*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)
|
|
|
|
{
|
2010-08-11 19:01:50 +00:00
|
|
|
char filename_buf[MAX_PATH + 1];
|
2010-05-07 16:35:37 +00:00
|
|
|
const char* peek_filename;
|
2004-01-14 00:13:04 +00:00
|
|
|
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 */
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(index, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (peek_filename == NULL)
|
2010-04-09 20:08:48 +00:00
|
|
|
{
|
2010-04-09 23:19:13 +00:00
|
|
|
/* playlist has shrunk, search from the top */
|
|
|
|
index = 0;
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(index, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2010-04-09 20:08:48 +00:00
|
|
|
if (peek_filename == NULL)
|
|
|
|
return false;
|
|
|
|
}
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (strcmp(strrchr(peek_filename, '/') + 1, filename))
|
2004-12-07 14:20:37 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
for ( i=0; i < playlist_amount(); i++ )
|
2004-12-07 14:20:37 +00:00
|
|
|
{
|
2010-08-11 19:01:50 +00:00
|
|
|
peek_filename = playlist_peek(i, filename_buf,
|
|
|
|
sizeof(filename_buf));
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (peek_filename == NULL)
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2007-04-12 19:11:39 +00:00
|
|
|
|
|
|
|
if (!strcmp(strrchr(peek_filename, '/') + 1, filename))
|
2004-12-07 14:20:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < playlist_amount())
|
|
|
|
index = i;
|
|
|
|
else
|
2008-02-10 12:16:27 +00:00
|
|
|
return false;
|
2004-12-07 14:20:37 +00:00
|
|
|
}
|
2004-01-14 00:13:04 +00:00
|
|
|
playlist_start(index,offset);
|
2008-02-10 12:16:27 +00:00
|
|
|
started = true;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-10 12:16:27 +00:00
|
|
|
if (started)
|
|
|
|
start_wps = true;
|
|
|
|
return started;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2007-10-21 00:20:51 +00:00
|
|
|
static void say_filetype(int attr)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
|
|
|
/* try to find a voice ID for the extension, if known */
|
2007-04-18 13:03:01 +00:00
|
|
|
int j;
|
2007-10-21 00:20:51 +00:00
|
|
|
attr &= FILE_ATTR_MASK; /* file type */
|
2007-04-18 13:03:01 +00:00
|
|
|
for (j=0; j<filetypes_count; j++)
|
2005-01-17 11:39:46 +00:00
|
|
|
if (attr == filetypes[j].tree_attr)
|
|
|
|
{
|
2007-10-21 00:20:51 +00:00
|
|
|
talk_id(filetypes[j].voiceclip, true);
|
|
|
|
return;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
static int ft_play_dirname(char* name)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
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
|
|
|
|
2008-07-15 14:55:31 +00:00
|
|
|
if(talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
|
|
|
|
NULL, false))
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2008-07-15 14:55:31 +00:00
|
|
|
if(global_settings.talk_filetype)
|
|
|
|
talk_id(VOICE_DIR, true);
|
|
|
|
return 1;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2008-07-15 14:55:31 +00:00
|
|
|
else
|
|
|
|
return -1;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
static void ft_play_filename(char *dir, char *file)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
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
|
|
|
|
2008-09-02 08:15:44 +00:00
|
|
|
if (strlen(file) >= strlen(file_thumbnail_ext)
|
2008-07-15 14:55:31 +00:00
|
|
|
&& strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
|
|
|
|
file_thumbnail_ext))
|
|
|
|
/* file has no .talk extension */
|
|
|
|
talk_file(dir, NULL, file, file_thumbnail_ext,
|
|
|
|
NULL, false);
|
2005-01-17 11:39:46 +00:00
|
|
|
else
|
2008-07-15 14:55:31 +00:00
|
|
|
/* it already is a .talk file, play this directly, but prefix it. */
|
|
|
|
talk_file(dir, NULL, file, NULL,
|
|
|
|
TALK_IDARRAY(LANG_VOICE_DIR_HOVER), false);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
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-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-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
|
|
|
|
{
|
2007-01-24 02:19:22 +00:00
|
|
|
int old_val = global_status.dircache_size;
|
2006-12-12 10:45:34 +00:00
|
|
|
if (global_settings.dircache)
|
|
|
|
{
|
2007-10-07 12:05:48 +00:00
|
|
|
if (!dircache_is_initializing())
|
|
|
|
global_status.dircache_size = dircache_get_cache_size();
|
2006-08-15 22:54:06 +00:00
|
|
|
# ifdef HAVE_EEPROM_SETTINGS
|
2007-04-07 17:48:51 +00:00
|
|
|
if (firmware_settings.initialized)
|
|
|
|
dircache_save();
|
2006-08-05 20:19:10 +00:00
|
|
|
# endif
|
2006-12-12 10:45:34 +00:00
|
|
|
dircache_disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-01-24 02:19:22 +00:00
|
|
|
global_status.dircache_size = 0;
|
2006-12-12 10:45:34 +00:00
|
|
|
}
|
2007-01-24 02:19:22 +00:00
|
|
|
if (old_val != global_status.dircache_size)
|
|
|
|
status_save();
|
2005-10-07 17:38:05 +00:00
|
|
|
}
|
|
|
|
#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. */
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, str(LANG_SCANNING_DISK));
|
2005-11-02 12:05:33 +00:00
|
|
|
|
2007-01-24 02:19:22 +00:00
|
|
|
dircache_build(global_status.dircache_size);
|
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
|
2005-09-14 09:07:05 +00:00
|
|
|
}
|