2011-11-28 12:41:15 +00:00
|
|
|
/***************************************************************************
|
2005-01-17 11:39:46 +00:00
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-05-05 10:32:46 +00:00
|
|
|
* Copyright (C) 2005 by Björn Stenberg
|
2005-01-17 11:39:46 +00:00
|
|
|
*
|
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.
|
2005-01-17 11:39:46 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <file.h>
|
|
|
|
#include <dir.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <lcd.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <font.h>
|
2005-02-15 15:30:19 +00:00
|
|
|
#include <limits.h>
|
2005-01-17 11:39:46 +00:00
|
|
|
#include "bookmark.h"
|
|
|
|
#include "tree.h"
|
2011-08-30 14:01:45 +00:00
|
|
|
#include "core_alloc.h"
|
2005-01-17 11:39:46 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "filetypes.h"
|
|
|
|
#include "talk.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "rolo.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
#include "splash.h"
|
2007-02-14 14:40:24 +00:00
|
|
|
#include "cuesheet.h"
|
2008-04-28 10:22:05 +00:00
|
|
|
#include "filetree.h"
|
2008-05-01 10:13:12 +00:00
|
|
|
#include "misc.h"
|
2009-03-01 17:55:59 +00:00
|
|
|
#include "strnatcmp.h"
|
2006-03-29 16:21:42 +00:00
|
|
|
#include "keyboard.h"
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2007-02-18 02:04:47 +00:00
|
|
|
#if CONFIG_TUNER
|
2006-04-02 12:23:08 +00:00
|
|
|
#include "radio.h"
|
|
|
|
#endif
|
2009-08-03 15:06:30 +00:00
|
|
|
#include "wps.h"
|
2006-05-21 11:00:02 +00:00
|
|
|
|
2008-10-08 16:32:01 +00:00
|
|
|
static int compare_sort_dir; /* qsort key for sorting directories */
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
int ft_build_playlist(struct tree_context* c, int start_index)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int start=start_index;
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_lock_cache(c);
|
|
|
|
struct entry *entries = tree_get_entries(c);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
for(i = 0;i < c->filesindir;i++)
|
|
|
|
{
|
2011-08-03 09:49:25 +00:00
|
|
|
if((entries[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2011-08-03 09:49:25 +00:00
|
|
|
if (playlist_add(entries[i].name) < 0)
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Adjust the start index when se skip non-MP3 entries */
|
|
|
|
if(i < start)
|
|
|
|
start_index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_unlock_cache(c);
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
return start_index;
|
|
|
|
}
|
|
|
|
|
2007-10-30 17:38:21 +00:00
|
|
|
/* Start playback of a playlist, checking for bookmark autoload, modified
|
|
|
|
* playlists, etc., as required. Returns false if playback wasn't started,
|
|
|
|
* or started via bookmark autoload, true otherwise.
|
|
|
|
*
|
|
|
|
* Pointers to both the full pathname and the separated parts needed to
|
2021-04-18 18:00:41 +00:00
|
|
|
* avoid allocating yet another path buffer on the stack (and save some
|
2007-10-30 17:38:21 +00:00
|
|
|
* code; the caller typically needs to create the full pathname anyway)...
|
|
|
|
*/
|
2021-04-18 18:00:41 +00:00
|
|
|
bool ft_play_playlist(char* pathname, char* dirname, char* filename, bool skip_dyn_warning)
|
2007-10-30 17:38:21 +00:00
|
|
|
{
|
2021-04-18 18:00:41 +00:00
|
|
|
if (global_settings.party_mode && audio_status())
|
2007-10-30 17:38:21 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_PARTY_MODE));
|
2007-10-30 17:38:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bookmark_autoload(pathname))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2007-10-30 17:38:21 +00:00
|
|
|
|
|
|
|
/* about to create a new current playlist...
|
2021-04-18 18:00:41 +00:00
|
|
|
* allow user to cancel the operation.
|
|
|
|
* Do not show if skip_dyn_warning is true */
|
|
|
|
if (!skip_dyn_warning)
|
|
|
|
{
|
|
|
|
if (!warn_on_pl_erase())
|
|
|
|
return false;
|
|
|
|
}
|
2007-10-30 17:38:21 +00:00
|
|
|
|
|
|
|
if (playlist_create(dirname, filename) != -1)
|
|
|
|
{
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
{
|
|
|
|
playlist_shuffle(current_tick, -1);
|
|
|
|
}
|
2021-04-18 18:00:41 +00:00
|
|
|
|
2013-07-14 11:59:39 +00:00
|
|
|
playlist_start(0, 0, 0);
|
2007-10-30 17:38:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-18 18:00:41 +00:00
|
|
|
|
2007-10-30 17:38:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-03 09:49:25 +00:00
|
|
|
/* walk a directory and check all entries if a .talk file exists */
|
2005-01-17 11:39:46 +00:00
|
|
|
static void check_file_thumbnails(struct tree_context* c)
|
|
|
|
{
|
|
|
|
int i;
|
2007-07-20 17:06:55 +00:00
|
|
|
struct dirent *entry;
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* entries;
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR *dir;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-07-20 17:06:55 +00:00
|
|
|
dir = opendir(c->currdir);
|
2005-01-17 11:39:46 +00:00
|
|
|
if(!dir)
|
|
|
|
return;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* mark all files as non talking, except the .talk ones */
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_lock_cache(c);
|
2018-12-13 16:39:49 +00:00
|
|
|
entries = tree_get_entries(c);
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
for (i=0; i < c->filesindir; i++)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2011-08-03 09:49:25 +00:00
|
|
|
if (entries[i].attr & ATTR_DIRECTORY)
|
2005-01-17 11:39:46 +00:00
|
|
|
continue; /* we're not touching directories */
|
|
|
|
|
|
|
|
if (strcasecmp(file_thumbnail_ext,
|
2011-08-03 09:49:25 +00:00
|
|
|
&entries[i].name[strlen(entries[i].name)
|
2005-01-17 11:39:46 +00:00
|
|
|
- strlen(file_thumbnail_ext)]))
|
|
|
|
{ /* no .talk file */
|
2011-08-03 09:49:25 +00:00
|
|
|
entries[i].attr &= ~FILE_ATTR_THUMBNAIL; /* clear */
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* .talk file, we later let them speak themselves */
|
2011-08-03 09:49:25 +00:00
|
|
|
entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set */
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-07-20 17:06:55 +00:00
|
|
|
while((entry = readdir(dir)) != 0) /* walk directory */
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
|
|
|
int ext_pos;
|
2010-09-01 21:29:34 +00:00
|
|
|
struct dirinfo info = dir_get_info(dir, entry);
|
2005-12-05 22:44:42 +00:00
|
|
|
ext_pos = strlen((char *)entry->d_name) - strlen(file_thumbnail_ext);
|
2005-01-17 11:39:46 +00:00
|
|
|
if (ext_pos <= 0 /* too short to carry ".talk" */
|
2010-09-01 21:29:34 +00:00
|
|
|
|| (info.attribute & ATTR_DIRECTORY) /* no file */
|
2005-12-05 22:44:42 +00:00
|
|
|
|| strcasecmp((char *)&entry->d_name[ext_pos], file_thumbnail_ext))
|
2005-01-17 11:39:46 +00:00
|
|
|
{ /* or doesn't end with ".talk", no candidate */
|
2005-10-28 00:00:00 +00:00
|
|
|
continue;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
/* terminate the (disposable) name in dir buffer,
|
|
|
|
this truncates off the ".talk" without needing an extra buffer */
|
|
|
|
entry->d_name[ext_pos] = '\0';
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
/* search corresponding file in dir cache */
|
|
|
|
for (i=0; i < c->filesindir; i++)
|
|
|
|
{
|
2011-08-03 09:49:25 +00:00
|
|
|
if (!strcasecmp(entries[i].name, (char *)entry->d_name))
|
2005-01-17 11:39:46 +00:00
|
|
|
{ /* match */
|
2011-08-03 09:49:25 +00:00
|
|
|
entries[i].attr |= FILE_ATTR_THUMBNAIL; /* set the flag */
|
2005-01-17 11:39:46 +00:00
|
|
|
break; /* exit search loop, because we found it */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_unlock_cache(c);
|
2007-07-20 17:06:55 +00:00
|
|
|
closedir(dir);
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* support function for qsort() */
|
|
|
|
static int compare(const void* p1, const void* p2)
|
|
|
|
{
|
|
|
|
struct entry* e1 = (struct entry*)p1;
|
|
|
|
struct entry* e2 = (struct entry*)p2;
|
|
|
|
int criteria;
|
|
|
|
|
|
|
|
if (e1->attr & ATTR_DIRECTORY && e2->attr & ATTR_DIRECTORY)
|
|
|
|
{ /* two directories */
|
2008-10-08 16:32:01 +00:00
|
|
|
criteria = compare_sort_dir;
|
2005-01-17 12:29:27 +00:00
|
|
|
|
2007-03-17 00:55:23 +00:00
|
|
|
#ifdef HAVE_MULTIVOLUME
|
2005-01-17 12:29:27 +00:00
|
|
|
if (e1->attr & ATTR_VOLUME || e2->attr & ATTR_VOLUME)
|
|
|
|
{ /* a volume identifier is involved */
|
|
|
|
if (e1->attr & ATTR_VOLUME && e2->attr & ATTR_VOLUME)
|
2008-10-08 16:32:01 +00:00
|
|
|
criteria = SORT_ALPHA; /* two volumes: sort alphabetically */
|
2005-01-17 12:29:27 +00:00
|
|
|
else /* only one is a volume: volume first */
|
|
|
|
return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME);
|
|
|
|
}
|
2007-03-17 00:55:23 +00:00
|
|
|
#endif
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else if (!(e1->attr & ATTR_DIRECTORY) && !(e2->attr & ATTR_DIRECTORY))
|
|
|
|
{ /* two files */
|
|
|
|
criteria = global_settings.sort_file;
|
|
|
|
}
|
|
|
|
else /* dir and file, dir goes first */
|
2008-10-08 16:32:01 +00:00
|
|
|
return (e2->attr & ATTR_DIRECTORY) - (e1->attr & ATTR_DIRECTORY);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
switch(criteria)
|
|
|
|
{
|
2008-10-08 16:32:01 +00:00
|
|
|
case SORT_TYPE:
|
|
|
|
case SORT_TYPE_REVERSED:
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2007-04-18 13:03:01 +00:00
|
|
|
int t1 = e1->attr & FILE_ATTR_MASK;
|
|
|
|
int t2 = e2->attr & FILE_ATTR_MASK;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
if (!t1) /* unknown type */
|
2005-02-12 12:29:41 +00:00
|
|
|
t1 = INT_MAX; /* gets a high number, to sort after known */
|
2005-01-17 11:39:46 +00:00
|
|
|
if (!t2) /* unknown type */
|
2005-02-12 12:29:41 +00:00
|
|
|
t2 = INT_MAX; /* gets a high number, to sort after known */
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2008-10-08 16:32:01 +00:00
|
|
|
if (t1 != t2) /* if different */
|
|
|
|
return (t1 - t2) * (criteria == SORT_TYPE_REVERSED ? -1 : 1);
|
2005-01-17 11:39:46 +00:00
|
|
|
/* else fall through to alphabetical sorting */
|
|
|
|
}
|
|
|
|
|
2008-10-08 16:32:01 +00:00
|
|
|
case SORT_DATE:
|
|
|
|
case SORT_DATE_REVERSED:
|
|
|
|
/* Ignore SORT_TYPE */
|
|
|
|
if (criteria == SORT_DATE || criteria == SORT_DATE_REVERSED)
|
|
|
|
{
|
|
|
|
if (e1->time_write != e2->time_write)
|
|
|
|
return (e1->time_write - e2->time_write)
|
|
|
|
* (criteria == SORT_DATE_REVERSED ? -1 : 1);
|
|
|
|
/* else fall through to alphabetical sorting */
|
|
|
|
}
|
|
|
|
|
|
|
|
case SORT_ALPHA:
|
|
|
|
case SORT_ALPHA_REVERSED:
|
2009-03-01 17:55:59 +00:00
|
|
|
{
|
2005-11-02 22:32:04 +00:00
|
|
|
if (global_settings.sort_case)
|
2009-03-01 17:55:59 +00:00
|
|
|
{
|
|
|
|
if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
|
|
|
|
return strnatcmp(e1->name, e2->name)
|
|
|
|
* (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
|
|
|
|
else
|
|
|
|
return strncmp(e1->name, e2->name, MAX_PATH)
|
|
|
|
* (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
|
|
|
|
}
|
2005-11-02 22:32:04 +00:00
|
|
|
else
|
2009-03-01 17:55:59 +00:00
|
|
|
{
|
|
|
|
if (global_settings.interpret_numbers == SORT_INTERPRET_AS_NUMBER)
|
|
|
|
return strnatcasecmp(e1->name, e2->name)
|
|
|
|
* (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
|
|
|
|
else
|
|
|
|
return strncasecmp(e1->name, e2->name, MAX_PATH)
|
|
|
|
* (criteria == SORT_ALPHA_REVERSED ? -1 : 1);
|
|
|
|
}
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return 0; /* never reached */
|
|
|
|
}
|
|
|
|
|
2011-08-03 09:49:25 +00:00
|
|
|
/* load and sort directory into the tree's cache. returns NULL on failure. */
|
2005-01-18 22:50:47 +00:00
|
|
|
int ft_load(struct tree_context* c, const char* tempdir)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2011-05-04 18:33:12 +00:00
|
|
|
int files_in_dir = 0;
|
2005-01-17 12:56:00 +00:00
|
|
|
int name_buffer_used = 0;
|
2011-05-04 18:33:12 +00:00
|
|
|
struct dirent *entry;
|
2010-12-14 13:37:58 +00:00
|
|
|
bool (*callback_show_item)(char *, int, struct tree_context *) = NULL;
|
2007-07-20 17:06:55 +00:00
|
|
|
DIR *dir;
|
2005-01-18 22:50:47 +00:00
|
|
|
|
|
|
|
if (tempdir)
|
2007-07-20 17:06:55 +00:00
|
|
|
dir = opendir(tempdir);
|
2005-01-18 22:50:47 +00:00
|
|
|
else
|
2010-12-14 13:37:58 +00:00
|
|
|
{
|
2007-07-20 17:06:55 +00:00
|
|
|
dir = opendir(c->currdir);
|
2010-12-14 13:37:58 +00:00
|
|
|
callback_show_item = c->browse? c->browse->callback_show_item: NULL;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
if(!dir)
|
|
|
|
return -1; /* not a directory */
|
|
|
|
|
|
|
|
c->dirsindir = 0;
|
2005-01-18 22:45:00 +00:00
|
|
|
c->dirfull = false;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_lock_cache(c);
|
2011-05-04 18:33:12 +00:00
|
|
|
while ((entry = readdir(dir))) {
|
2005-01-17 11:39:46 +00:00
|
|
|
int len;
|
2010-09-01 21:29:34 +00:00
|
|
|
struct dirinfo info;
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* dptr = tree_get_entry_at(c, files_in_dir);
|
2020-08-24 17:22:00 +00:00
|
|
|
if (!dptr)
|
|
|
|
{
|
|
|
|
c->dirfull = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2020-08-24 17:22:00 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2010-09-01 21:29:34 +00:00
|
|
|
info = dir_get_info(dir, entry);
|
2005-12-05 22:44:42 +00:00
|
|
|
len = strlen((char *)entry->d_name);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
/* skip directories . and .. */
|
2010-09-01 21:29:34 +00:00
|
|
|
if ((info.attribute & ATTR_DIRECTORY) &&
|
2005-12-05 22:44:42 +00:00
|
|
|
(((len == 1) && (!strncmp((char *)entry->d_name, ".", 1))) ||
|
|
|
|
((len == 2) && (!strncmp((char *)entry->d_name, "..", 2))))) {
|
2005-01-17 11:39:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip FAT volume ID */
|
2010-09-01 21:29:34 +00:00
|
|
|
if (info.attribute & ATTR_VOLUME_ID) {
|
2005-01-17 11:39:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* filter out dotfiles and hidden files */
|
|
|
|
if (*c->dirfilter != SHOW_ALL &&
|
|
|
|
((entry->d_name[0]=='.') ||
|
2010-09-01 21:29:34 +00:00
|
|
|
(info.attribute & ATTR_HIDDEN))) {
|
2005-01-17 11:39:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-09-01 21:29:34 +00:00
|
|
|
dptr->attr = info.attribute;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
/* check for known file types */
|
2005-09-02 15:05:35 +00:00
|
|
|
if ( !(dptr->attr & ATTR_DIRECTORY) )
|
2005-12-05 22:44:42 +00:00
|
|
|
dptr->attr |= filetype_get_attr((char *)entry->d_name);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
/* filter out non-visible files */
|
2005-08-17 17:53:54 +00:00
|
|
|
if ((!(dptr->attr & ATTR_DIRECTORY) && (
|
2005-01-17 11:39:46 +00:00
|
|
|
(*c->dirfilter == SHOW_PLAYLIST &&
|
2007-04-18 13:03:01 +00:00
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
|
2005-01-17 11:39:46 +00:00
|
|
|
((*c->dirfilter == SHOW_MUSIC &&
|
2007-04-18 13:03:01 +00:00
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) &&
|
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
|
2005-08-17 17:53:54 +00:00
|
|
|
(*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
|
2007-04-18 13:03:01 +00:00
|
|
|
(*c->dirfilter == SHOW_WPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_WPS) ||
|
2009-10-19 16:08:43 +00:00
|
|
|
(*c->dirfilter == SHOW_FONT && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FONT) ||
|
|
|
|
(*c->dirfilter == SHOW_SBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_SBS) ||
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
|
|
|
(*c->dirfilter == SHOW_FMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMS) ||
|
|
|
|
#endif
|
2005-11-17 20:14:59 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2007-04-18 13:03:01 +00:00
|
|
|
(*c->dirfilter == SHOW_RWPS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RWPS) ||
|
2009-10-19 16:08:43 +00:00
|
|
|
(*c->dirfilter == SHOW_RSBS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RSBS) ||
|
2010-05-12 10:38:00 +00:00
|
|
|
#if CONFIG_TUNER
|
|
|
|
(*c->dirfilter == SHOW_RFMS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_RFMS) ||
|
|
|
|
#endif
|
2006-04-02 12:23:08 +00:00
|
|
|
#endif
|
2007-02-18 02:04:47 +00:00
|
|
|
#if CONFIG_TUNER
|
2007-04-18 13:03:01 +00:00
|
|
|
(*c->dirfilter == SHOW_FMR && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_FMR) ||
|
2005-11-17 20:14:59 +00:00
|
|
|
#endif
|
2010-12-15 12:47:30 +00:00
|
|
|
(*c->dirfilter == SHOW_M3U && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_M3U) ||
|
2007-04-18 13:03:01 +00:00
|
|
|
(*c->dirfilter == SHOW_CFG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_CFG) ||
|
|
|
|
(*c->dirfilter == SHOW_LNG && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LNG) ||
|
|
|
|
(*c->dirfilter == SHOW_MOD && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_MOD) ||
|
2009-10-28 23:31:42 +00:00
|
|
|
(*c->dirfilter == SHOW_PLUGINS && (dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_ROCK &&
|
2020-08-01 02:45:10 +00:00
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA &&
|
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_OPX) ||
|
2010-12-14 13:37:58 +00:00
|
|
|
(callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c)))
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-08-24 17:22:00 +00:00
|
|
|
if (len > c->cache.name_buffer_size - name_buffer_used - 1) {
|
2005-01-17 11:39:46 +00:00
|
|
|
/* Tell the world that we ran out of buffer space */
|
2005-01-18 22:45:00 +00:00
|
|
|
c->dirfull = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-05-04 18:33:12 +00:00
|
|
|
|
|
|
|
++files_in_dir;
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
dptr->name = core_get_data(c->cache.name_buffer_handle)+name_buffer_used;
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
dptr->time_write = info.mtime;
|
2005-12-05 22:44:42 +00:00
|
|
|
strcpy(dptr->name, (char *)entry->d_name);
|
2005-01-17 11:39:46 +00:00
|
|
|
name_buffer_used += len + 1;
|
|
|
|
|
|
|
|
if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */
|
2005-10-28 00:00:00 +00:00
|
|
|
c->dirsindir++;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2011-05-04 18:33:12 +00:00
|
|
|
c->filesindir = files_in_dir;
|
|
|
|
c->dirlength = files_in_dir;
|
2007-07-20 17:06:55 +00:00
|
|
|
closedir(dir);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2008-10-08 16:32:01 +00:00
|
|
|
compare_sort_dir = c->sort_dir;
|
2011-08-30 14:01:45 +00:00
|
|
|
qsort(tree_get_entries(c), files_in_dir, sizeof(struct entry), compare);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* If thumbnail talking is enabled, make an extra run to mark files with
|
2005-01-17 11:39:46 +00:00
|
|
|
associated thumbnails, so we don't do unsuccessful spinups later. */
|
2007-06-07 11:29:45 +00:00
|
|
|
if (global_settings.talk_file_clip)
|
2005-01-17 11:39:46 +00:00
|
|
|
check_file_thumbnails(c); /* map .talk to ours */
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
tree_unlock_cache(c);
|
2005-01-17 11:39:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-02-14 06:26:16 +00:00
|
|
|
static void ft_load_font(char *file)
|
|
|
|
{
|
2011-09-24 13:19:34 +00:00
|
|
|
int current_font_id;
|
|
|
|
enum screen_type screen = SCREEN_MAIN;
|
2010-02-14 06:26:16 +00:00
|
|
|
#if NB_SCREENS > 1
|
|
|
|
MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL,
|
|
|
|
ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN))
|
|
|
|
switch (do_menu(&menu, NULL, NULL, false))
|
|
|
|
{
|
2011-09-24 13:19:34 +00:00
|
|
|
case 0: /* main lcd */
|
|
|
|
screen = SCREEN_MAIN;
|
2010-02-14 06:26:16 +00:00
|
|
|
set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
|
|
|
|
break;
|
|
|
|
case 1: /* remote */
|
2011-09-24 13:19:34 +00:00
|
|
|
screen = SCREEN_REMOTE;
|
2010-02-14 06:26:16 +00:00
|
|
|
set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
|
|
|
|
#endif
|
2011-09-24 13:19:34 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2011-11-08 10:09:33 +00:00
|
|
|
current_font_id = screens[screen].getuifont();
|
2011-09-24 13:19:34 +00:00
|
|
|
if (current_font_id >= 0)
|
|
|
|
font_unload(current_font_id);
|
2011-11-20 18:03:39 +00:00
|
|
|
screens[screen].setuifont(
|
|
|
|
font_load_ex(file,0,global_settings.glyphs_to_cache));
|
2011-09-24 13:19:34 +00:00
|
|
|
viewportmanager_theme_changed(THEME_UI_VIEWPORT);
|
2020-07-17 14:31:31 +00:00
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
int ft_enter(struct tree_context* c)
|
|
|
|
{
|
2010-08-16 13:16:29 +00:00
|
|
|
int rc = GO_TO_PREVIOUS;
|
2021-10-20 20:05:21 +00:00
|
|
|
static char buf[MAX_PATH];
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* file = tree_get_entry_at(c, c->selected_item);
|
2018-12-14 12:04:39 +00:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
splashf(HZ, str(LANG_READ_FAILED), str(LANG_UNKNOWN));
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
int file_attr = file->attr;
|
2018-07-25 17:28:25 +00:00
|
|
|
int len;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
if (c->currdir[1])
|
2018-07-25 17:28:25 +00:00
|
|
|
{
|
|
|
|
len = snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
|
|
|
|
if ((unsigned) len > sizeof(buf))
|
|
|
|
splash(HZ, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
else
|
|
|
|
snprintf(buf,sizeof(buf),"/%s",file->name);
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
if (file_attr & ATTR_DIRECTORY) {
|
2005-01-17 11:39:46 +00:00
|
|
|
memcpy(c->currdir, buf, sizeof(c->currdir));
|
2005-10-28 00:00:00 +00:00
|
|
|
if ( c->dirlevel < MAX_DIR_LEVELS )
|
|
|
|
c->selected_item_history[c->dirlevel] = c->selected_item;
|
2005-01-17 11:39:46 +00:00
|
|
|
c->dirlevel++;
|
2005-10-28 00:00:00 +00:00
|
|
|
c->selected_item=0;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
int seed = current_tick;
|
|
|
|
bool play = false;
|
|
|
|
int start_index=0;
|
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
switch ( file_attr & FILE_ATTR_MASK ) {
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_M3U:
|
2021-04-18 18:00:41 +00:00
|
|
|
play = ft_play_playlist(buf, c->currdir, file->name, false);
|
2011-11-28 12:41:15 +00:00
|
|
|
|
|
|
|
if (play)
|
|
|
|
{
|
|
|
|
start_index = 0;
|
|
|
|
}
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_AUDIO:
|
2005-01-17 11:39:46 +00:00
|
|
|
if (bookmark_autoload(c->currdir))
|
|
|
|
break;
|
|
|
|
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2006-04-15 06:23:34 +00:00
|
|
|
|
2006-02-05 19:35:03 +00:00
|
|
|
/* about to create a new current playlist...
|
|
|
|
allow user to cancel the operation */
|
2008-05-01 10:13:12 +00:00
|
|
|
if (!warn_on_pl_erase())
|
|
|
|
break;
|
2006-02-05 19:35:03 +00:00
|
|
|
|
2008-08-19 11:55:30 +00:00
|
|
|
if (global_settings.party_mode && audio_status())
|
2006-08-10 09:50:45 +00:00
|
|
|
{
|
2006-03-19 08:40:31 +00:00
|
|
|
playlist_insert_track(NULL, buf,
|
2006-08-10 09:50:45 +00:00
|
|
|
PLAYLIST_INSERT_LAST, true, true);
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_QUEUE_LAST));
|
2006-03-19 08:40:31 +00:00
|
|
|
}
|
|
|
|
else if (playlist_create(c->currdir, NULL) != -1)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
start_index = ft_build_playlist(c, c->selected_item);
|
2005-01-17 11:39:46 +00:00
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
{
|
|
|
|
start_index = playlist_shuffle(seed, start_index);
|
|
|
|
|
|
|
|
/* when shuffling dir.: play all files
|
|
|
|
even if the file selected by user is
|
|
|
|
not the first one */
|
|
|
|
if (!global_settings.play_selected)
|
|
|
|
start_index = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-14 11:59:39 +00:00
|
|
|
playlist_start(start_index, 0, 0);
|
2005-01-17 11:39:46 +00:00
|
|
|
play = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-02-18 02:04:47 +00:00
|
|
|
#if CONFIG_TUNER
|
2006-04-02 12:23:08 +00:00
|
|
|
/* fmr preset file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_FMR:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2006-04-15 06:23:34 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
/* Preset inside the default folder. */
|
|
|
|
if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH)))
|
|
|
|
{
|
|
|
|
set_file(buf, global_settings.fmr_file, MAX_FILENAME);
|
|
|
|
radio_load_presets(global_settings.fmr_file);
|
|
|
|
}
|
2006-04-15 06:23:34 +00:00
|
|
|
/*
|
2006-04-02 12:23:08 +00:00
|
|
|
* Preset outside default folder, we can choose such only
|
2006-04-15 06:23:34 +00:00
|
|
|
* if we are out of the radio screen, so the check for the
|
|
|
|
* radio status isn't neccessary
|
2006-04-02 12:23:08 +00:00
|
|
|
*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
radio_load_presets(buf);
|
|
|
|
}
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_FM;
|
2006-04-15 06:23:34 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
break;
|
2010-05-12 10:38:00 +00:00
|
|
|
case FILE_ATTR_FMS:
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
|
|
|
set_file(buf, (char *)global_settings.fms_file, MAX_FILENAME);
|
|
|
|
settings_apply_skins();
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
case FILE_ATTR_RFMS:
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
|
|
|
set_file(buf, (char *)global_settings.rfms_file, MAX_FILENAME);
|
|
|
|
settings_apply_skins();
|
|
|
|
break;
|
|
|
|
#endif
|
2006-04-02 12:23:08 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-19 15:28:15 +00:00
|
|
|
case FILE_ATTR_SBS:
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2010-03-06 00:29:46 +00:00
|
|
|
set_file(buf, (char *)global_settings.sbs_file, MAX_FILENAME);
|
2009-10-19 15:28:15 +00:00
|
|
|
settings_apply_skins();
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
case FILE_ATTR_RSBS:
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2010-03-06 00:29:46 +00:00
|
|
|
set_file(buf, (char *)global_settings.rsbs_file, MAX_FILENAME);
|
2009-10-19 15:28:15 +00:00
|
|
|
settings_apply_skins();
|
|
|
|
break;
|
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
/* wps config file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_WPS:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2005-12-05 22:44:42 +00:00
|
|
|
set_file(buf, (char *)global_settings.wps_file,
|
2005-01-17 11:39:46 +00:00
|
|
|
MAX_FILENAME);
|
2009-08-16 20:12:17 +00:00
|
|
|
settings_apply_skins();
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
|
2005-12-04 12:11:08 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
|
2005-11-17 20:14:59 +00:00
|
|
|
/* remote-wps config file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_RWPS:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2005-12-05 22:44:42 +00:00
|
|
|
set_file(buf, (char *)global_settings.rwps_file,
|
2005-11-17 20:14:59 +00:00
|
|
|
MAX_FILENAME);
|
2009-08-16 20:12:17 +00:00
|
|
|
settings_apply_skins();
|
2005-11-17 20:14:59 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_CFG:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2007-01-23 13:40:44 +00:00
|
|
|
if (!settings_load_config(buf,true))
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_SETTINGS_LOADED));
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_BMARK:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2005-01-17 11:39:46 +00:00
|
|
|
bookmark_load(buf, false);
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_FILEBROWSER;
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_LNG:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2009-10-19 15:50:06 +00:00
|
|
|
if (lang_core_load(buf))
|
|
|
|
{
|
2009-10-19 16:01:05 +00:00
|
|
|
splash(HZ, ID2P(LANG_FAILED));
|
2009-10-19 15:50:06 +00:00
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
2009-10-19 15:50:06 +00:00
|
|
|
set_file(buf, (char *)global_settings.lang_file,
|
|
|
|
MAX_FILENAME);
|
|
|
|
talk_init(); /* use voice of same language */
|
|
|
|
viewportmanager_theme_changed(THEME_LANGUAGE);
|
2010-01-07 07:34:15 +00:00
|
|
|
settings_apply_skins();
|
2009-10-19 15:50:06 +00:00
|
|
|
splash(HZ, ID2P(LANG_LANGUAGE_LOADED));
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_FONT:
|
2010-02-14 06:26:16 +00:00
|
|
|
ft_load_font(buf);
|
2005-01-17 11:39:46 +00:00
|
|
|
break;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_KBD:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2006-03-29 16:21:42 +00:00
|
|
|
if (!load_kbd(buf))
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_KEYBOARD_LOADED));
|
2006-03-29 16:21:42 +00:00
|
|
|
set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2020-10-11 13:30:41 +00:00
|
|
|
#if defined(HAVE_ROLO)
|
2005-01-17 11:39:46 +00:00
|
|
|
/* firmware file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_MOD:
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_WAIT));
|
2011-08-14 15:13:00 +00:00
|
|
|
audio_hard_stop();
|
2005-01-17 11:39:46 +00:00
|
|
|
rolo_load(buf);
|
|
|
|
break;
|
|
|
|
#endif
|
2021-10-21 04:03:52 +00:00
|
|
|
case FILE_ATTR_CUE:
|
|
|
|
display_cuesheet_content(buf);
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
/* plugin file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_ROCK:
|
2009-07-05 22:12:42 +00:00
|
|
|
{
|
2021-10-20 20:05:21 +00:00
|
|
|
char *plugin = buf, *argument = NULL;
|
2008-08-19 11:55:30 +00:00
|
|
|
if (global_settings.party_mode && audio_status()) {
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_PARTY_MODE));
|
2006-03-19 08:40:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-10-21 04:03:52 +00:00
|
|
|
switch (plugin_load(plugin, argument))
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2009-07-05 22:12:42 +00:00
|
|
|
case PLUGIN_GOTO_WPS:
|
|
|
|
play = true;
|
|
|
|
break;
|
2020-08-01 02:45:10 +00:00
|
|
|
case PLUGIN_GOTO_PLUGIN:
|
|
|
|
rc = GO_TO_PLUGIN;
|
|
|
|
break;
|
2009-07-05 22:12:42 +00:00
|
|
|
case PLUGIN_USB_CONNECTED:
|
|
|
|
if(*c->dirfilter > NUM_FILTER_MODES)
|
|
|
|
/* leave sub-browsers after usb, doing
|
|
|
|
otherwise might be confusing to the user */
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_ROOT;
|
2009-07-05 22:12:42 +00:00
|
|
|
else
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_FILEBROWSER;
|
2009-07-05 22:12:42 +00:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
case PLUGIN_ERROR:
|
|
|
|
case PLUGIN_OK:
|
|
|
|
*/
|
|
|
|
default:
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-07-05 22:12:42 +00:00
|
|
|
}
|
2007-02-14 14:40:24 +00:00
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
default:
|
|
|
|
{
|
2008-05-12 17:52:50 +00:00
|
|
|
const char* plugin;
|
2021-10-20 20:05:21 +00:00
|
|
|
char plugin_path[MAX_PATH];
|
|
|
|
const char *argument = buf;
|
2008-08-19 11:55:30 +00:00
|
|
|
if (global_settings.party_mode && audio_status()) {
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ, ID2P(LANG_PARTY_MODE));
|
2006-03-19 08:40:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-15 06:23:34 +00:00
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* file = tree_get_entry_at(c, c->selected_item);
|
2018-12-14 12:04:39 +00:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
splashf(HZ, str(LANG_READ_FAILED), str(LANG_UNKNOWN));
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2021-10-20 20:05:21 +00:00
|
|
|
plugin = filetype_get_plugin(file, plugin_path, sizeof(plugin_path));
|
2005-01-17 11:39:46 +00:00
|
|
|
if (plugin)
|
|
|
|
{
|
2021-10-20 20:05:21 +00:00
|
|
|
switch (plugin_load(plugin, argument))
|
2009-07-05 22:12:42 +00:00
|
|
|
{
|
|
|
|
case PLUGIN_USB_CONNECTED:
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_FILEBROWSER;
|
2009-07-05 22:12:42 +00:00
|
|
|
break;
|
2020-08-01 02:45:10 +00:00
|
|
|
case PLUGIN_GOTO_PLUGIN:
|
|
|
|
rc = GO_TO_PLUGIN;
|
|
|
|
break;
|
2009-07-05 22:12:42 +00:00
|
|
|
case PLUGIN_GOTO_WPS:
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_WPS;
|
2009-07-05 22:12:42 +00:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
case PLUGIN_OK:
|
|
|
|
case PLUGIN_ERROR:
|
|
|
|
*/
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( play ) {
|
2005-06-29 12:23:09 +00:00
|
|
|
/* the resume_index must always be the index in the
|
|
|
|
shuffled list in case shuffle is enabled */
|
2007-01-24 02:19:22 +00:00
|
|
|
global_status.resume_index = start_index;
|
2012-12-09 20:04:17 +00:00
|
|
|
global_status.resume_crc32 =
|
|
|
|
playlist_get_filename_crc32(NULL, start_index);
|
2013-07-14 11:59:39 +00:00
|
|
|
global_status.resume_elapsed = 0;
|
2007-01-24 02:19:22 +00:00
|
|
|
global_status.resume_offset = 0;
|
|
|
|
status_save();
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_WPS;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (*c->dirfilter > NUM_FILTER_MODES &&
|
2009-05-11 22:50:48 +00:00
|
|
|
*c->dirfilter != SHOW_CFG &&
|
2005-01-17 11:39:46 +00:00
|
|
|
*c->dirfilter != SHOW_FONT &&
|
|
|
|
*c->dirfilter != SHOW_PLUGINS)
|
|
|
|
{
|
2010-08-16 13:16:29 +00:00
|
|
|
rc = GO_TO_ROOT;
|
2005-01-17 11:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ft_exit(struct tree_context* c)
|
|
|
|
{
|
|
|
|
extern char lastfile[]; /* from tree.c */
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
int rc = 0;
|
|
|
|
bool exit_func = false;
|
|
|
|
|
|
|
|
int i = strlen(c->currdir);
|
|
|
|
if (i>1) {
|
|
|
|
while (c->currdir[i-1]!='/')
|
|
|
|
i--;
|
|
|
|
strcpy(buf,&c->currdir[i]);
|
|
|
|
if (i==1)
|
|
|
|
c->currdir[i]=0;
|
|
|
|
else
|
|
|
|
c->currdir[i-1]=0;
|
|
|
|
|
|
|
|
if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
|
|
|
|
exit_func = true;
|
|
|
|
|
|
|
|
c->dirlevel--;
|
2005-10-28 00:00:00 +00:00
|
|
|
if ( c->dirlevel < MAX_DIR_LEVELS )
|
|
|
|
c->selected_item=c->selected_item_history[c->dirlevel];
|
2005-01-17 11:39:46 +00:00
|
|
|
else
|
2005-10-28 00:00:00 +00:00
|
|
|
c->selected_item=0;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if undefined position */
|
|
|
|
if (c->selected_item == -1)
|
2005-01-17 11:39:46 +00:00
|
|
|
strcpy(lastfile, buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*c->dirfilter > NUM_FILTER_MODES && c->dirlevel < 1)
|
|
|
|
exit_func = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exit_func)
|
2005-05-17 18:28:32 +00:00
|
|
|
rc = 3;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|