2011-07-20 14:11: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"
|
2011-07-20 14:11:15 +00:00
|
|
|
#include "playlist_viewer.h"
|
2006-03-29 16:21:42 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "keyboard.h"
|
|
|
|
#endif
|
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
|
|
|
|
* avoid allocating yet another path buffer on the stack (and save some
|
|
|
|
* code; the caller typically needs to create the full pathname anyway)...
|
|
|
|
*/
|
|
|
|
bool ft_play_playlist(char* pathname, char* dirname, char* filename)
|
|
|
|
{
|
2008-08-19 11:55:30 +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...
|
|
|
|
allow user to cancel the operation */
|
2008-05-01 10:13:12 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_start(0, 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
entries = tree_get_entries(c);
|
|
|
|
tree_lock_cache(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);
|
2005-01-17 11:39:46 +00:00
|
|
|
if (!entry)
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
(*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
|
2009-10-19 16:08:43 +00:00
|
|
|
#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 &&
|
2010-12-14 13:37:58 +00:00
|
|
|
(dptr->attr & FILE_ATTR_MASK) != FILE_ATTR_LUA) ||
|
|
|
|
(callback_show_item && !callback_show_item(entry->d_name, dptr->attr, c)))
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-08-03 09:49:25 +00:00
|
|
|
if ((len > c->cache.name_buffer_size - name_buffer_used - 1) ||
|
|
|
|
(files_in_dir >= c->cache.max_entries)) {
|
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;
|
2005-02-12 12:29:41 +00:00
|
|
|
dptr->time_write =
|
2010-09-01 21:29:34 +00:00
|
|
|
(long)info.wrtdate<<16 |
|
|
|
|
(long)info.wrttime; /* in one # */
|
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
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
static void ft_load_font(char *file)
|
|
|
|
{
|
|
|
|
#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))
|
|
|
|
{
|
|
|
|
case 0: /* main lcd */
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
|
|
|
font_load(NULL, file);
|
|
|
|
set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
|
|
|
|
break;
|
|
|
|
case 1: /* remote */
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
|
|
|
font_load_remoteui(file);
|
|
|
|
set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
splash(0, ID2P(LANG_WAIT));
|
|
|
|
font_load(NULL, file);
|
|
|
|
set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
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;
|
2005-01-17 11:39:46 +00:00
|
|
|
char buf[MAX_PATH];
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry* file = tree_get_entry_at(c, c->selected_item);
|
|
|
|
int file_attr = file->attr;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
if (c->currdir[1])
|
|
|
|
snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
|
|
|
|
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:
|
2011-07-20 14:11:15 +00:00
|
|
|
if (!bookmark_autoload(buf))
|
|
|
|
playlist_viewer_ex(buf);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_start(start_index, 0);
|
|
|
|
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
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
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;
|
|
|
|
#endif
|
|
|
|
#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;
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
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
|
|
|
#endif
|
|
|
|
|
2010-06-21 16:53:00 +00:00
|
|
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
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
|
|
|
|
|
|
|
|
/* plugin file */
|
2007-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_ROCK:
|
2009-10-28 23:31:42 +00:00
|
|
|
case FILE_ATTR_LUA:
|
2009-07-05 22:12:42 +00:00
|
|
|
{
|
2010-08-01 16:15:27 +00:00
|
|
|
char *plugin = buf, *argument = NULL, lua_path[MAX_PATH];
|
2009-07-05 22:12:42 +00:00
|
|
|
int ret;
|
2009-10-28 23:31:42 +00:00
|
|
|
|
2011-08-30 14:01:45 +00:00
|
|
|
if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) {
|
2010-08-01 16:15:27 +00:00
|
|
|
snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */
|
|
|
|
plugin = lua_path;
|
2009-10-28 23:31:42 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-10-28 23:31:42 +00:00
|
|
|
ret = plugin_load(plugin, argument);
|
2009-07-05 22:12:42 +00:00
|
|
|
switch (ret)
|
2005-01-17 11:39:46 +00:00
|
|
|
{
|
2009-07-05 22:12:42 +00:00
|
|
|
case PLUGIN_GOTO_WPS:
|
|
|
|
play = true;
|
|
|
|
break;
|
|
|
|
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-04-18 13:03:01 +00:00
|
|
|
case FILE_ATTR_CUE:
|
2007-02-14 14:40:24 +00:00
|
|
|
display_cuesheet_content(buf);
|
|
|
|
break;
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
default:
|
|
|
|
{
|
2008-05-12 17:52:50 +00:00
|
|
|
const char* plugin;
|
2006-03-19 08:40:31 +00:00
|
|
|
|
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);
|
2006-03-19 08:40:31 +00:00
|
|
|
plugin = filetype_get_plugin(file);
|
2005-01-17 11:39:46 +00:00
|
|
|
if (plugin)
|
|
|
|
{
|
2009-07-05 22:12:42 +00:00
|
|
|
switch (plugin_load(plugin,buf))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|