2005-01-17 11:39:46 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2005-01-17 16:06:07 +00:00
|
|
|
|
* Copyright (C) 2005 by Bj<EFBFBD>rn Stenberg
|
2005-01-17 11:39:46 +00:00
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
#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"
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "filetypes.h"
|
|
|
|
|
#include "talk.h"
|
|
|
|
|
#include "playlist.h"
|
2005-11-17 20:14:59 +00:00
|
|
|
|
#include "gwps.h"
|
2005-01-17 11:39:46 +00:00
|
|
|
|
#include "lang.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "screens.h"
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
#include "rolo.h"
|
2005-01-17 12:56:00 +00:00
|
|
|
|
#include "sprintf.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
|
#include "dircache.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
|
#include "splash.h"
|
2006-02-05 19:35:03 +00:00
|
|
|
|
#include "yesno.h"
|
2007-02-14 14:40:24 +00:00
|
|
|
|
#include "cuesheet.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
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
|
#ifdef CONFIG_TUNER
|
|
|
|
|
#include "radio.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-03-31 08:47:02 +00:00
|
|
|
|
#ifndef SIMULATOR
|
2005-01-17 11:39:46 +00:00
|
|
|
|
static int boot_size = 0;
|
|
|
|
|
static int boot_cluster;
|
2005-03-31 08:47:02 +00:00
|
|
|
|
#endif
|
2006-05-21 11:00:02 +00:00
|
|
|
|
|
2006-11-13 00:45:21 +00:00
|
|
|
|
#if LCD_DEPTH > 1
|
2006-05-21 11:00:02 +00:00
|
|
|
|
#include "backdrop.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
extern bool boot_changed;
|
|
|
|
|
|
|
|
|
|
int ft_build_playlist(struct tree_context* c, int start_index)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int start=start_index;
|
|
|
|
|
|
|
|
|
|
struct entry *dircache = c->dircache;
|
|
|
|
|
|
|
|
|
|
for(i = 0;i < c->filesindir;i++)
|
|
|
|
|
{
|
|
|
|
|
if((dircache[i].attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
|
|
|
|
|
{
|
|
|
|
|
DEBUGF("Adding %s\n", dircache[i].name);
|
|
|
|
|
if (playlist_add(dircache[i].name) < 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Adjust the start index when se skip non-MP3 entries */
|
|
|
|
|
if(i < start)
|
|
|
|
|
start_index--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return start_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* walk a directory and check all dircache entries if a .talk file exists */
|
|
|
|
|
static void check_file_thumbnails(struct tree_context* c)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
struct dircache_entry *entry;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
struct entry* dircache = c->dircache;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
DIRCACHED *dir;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
|
dir = opendir_cached(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 */
|
|
|
|
|
for (i=0; i < c->filesindir; i++)
|
2005-01-17 11:39:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (dircache[i].attr & ATTR_DIRECTORY)
|
|
|
|
|
continue; /* we're not touching directories */
|
|
|
|
|
|
|
|
|
|
if (strcasecmp(file_thumbnail_ext,
|
|
|
|
|
&dircache[i].name[strlen(dircache[i].name)
|
|
|
|
|
- strlen(file_thumbnail_ext)]))
|
|
|
|
|
{ /* no .talk file */
|
|
|
|
|
dircache[i].attr &= ~TREE_ATTR_THUMBNAIL; /* clear */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ /* .talk file, we later let them speak themselves */
|
|
|
|
|
dircache[i].attr |= TREE_ATTR_THUMBNAIL; /* set */
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
2005-10-07 17:38:05 +00:00
|
|
|
|
while((entry = readdir_cached(dir)) != 0) /* walk directory */
|
2005-01-17 11:39:46 +00:00
|
|
|
|
{
|
|
|
|
|
int ext_pos;
|
|
|
|
|
|
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" */
|
|
|
|
|
|| (entry->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++)
|
|
|
|
|
{
|
2005-12-05 22:44:42 +00:00
|
|
|
|
if (!strcasecmp(dircache[i].name, (char *)entry->d_name))
|
2005-01-17 11:39:46 +00:00
|
|
|
|
{ /* match */
|
|
|
|
|
dircache[i].attr |= TREE_ATTR_THUMBNAIL; /* set the flag */
|
|
|
|
|
break; /* exit search loop, because we found it */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-07 17:38:05 +00:00
|
|
|
|
closedir_cached(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 */
|
|
|
|
|
criteria = global_settings.sort_dir;
|
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)
|
|
|
|
|
criteria = 0; /* two volumes: sort alphabetically */
|
|
|
|
|
else /* only one is a volume: volume first */
|
|
|
|
|
return (e2->attr & ATTR_VOLUME) - (e1->attr & ATTR_VOLUME);
|
|
|
|
|
}
|
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 */
|
|
|
|
|
return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY );
|
|
|
|
|
|
|
|
|
|
switch(criteria)
|
|
|
|
|
{
|
|
|
|
|
case 3: /* sort type */
|
|
|
|
|
{
|
|
|
|
|
int t1 = e1->attr & TREE_ATTR_MASK;
|
|
|
|
|
int t2 = e2->attr & TREE_ATTR_MASK;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
if (t1 - t2) /* if different */
|
|
|
|
|
return t1 - t2;
|
|
|
|
|
/* else fall through to alphabetical sorting */
|
|
|
|
|
}
|
2005-11-02 22:32:04 +00:00
|
|
|
|
case 0: /* sort alphabetically asc */
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (global_settings.sort_case)
|
|
|
|
|
return strncmp(e1->name, e2->name, MAX_PATH);
|
|
|
|
|
else
|
|
|
|
|
return strncasecmp(e1->name, e2->name, MAX_PATH);
|
|
|
|
|
|
2005-11-02 22:32:04 +00:00
|
|
|
|
case 4: /* sort alphabetically desc */
|
|
|
|
|
if (global_settings.sort_case)
|
|
|
|
|
return strncmp(e2->name, e1->name, MAX_PATH);
|
|
|
|
|
else
|
|
|
|
|
return strncasecmp(e2->name, e1->name, MAX_PATH);
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
case 1: /* sort date */
|
|
|
|
|
return e1->time_write - e2->time_write;
|
|
|
|
|
|
|
|
|
|
case 2: /* sort date, newest first */
|
|
|
|
|
return e2->time_write - e1->time_write;
|
|
|
|
|
}
|
|
|
|
|
return 0; /* never reached */
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
|
/* load and sort directory into dircache. 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
|
|
|
|
{
|
|
|
|
|
int i;
|
2005-01-17 12:56:00 +00:00
|
|
|
|
int name_buffer_used = 0;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
DIRCACHED *dir;
|
2005-01-18 22:50:47 +00:00
|
|
|
|
|
|
|
|
|
if (tempdir)
|
2005-10-07 17:38:05 +00:00
|
|
|
|
dir = opendir_cached(tempdir);
|
2005-01-18 22:50:47 +00:00
|
|
|
|
else
|
2005-10-07 17:38:05 +00:00
|
|
|
|
dir = opendir_cached(c->currdir);
|
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
|
|
|
|
|
|
|
|
|
for ( i=0; i < global_settings.max_files_in_dir; i++ ) {
|
|
|
|
|
int len;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
struct dircache_entry *entry = readdir_cached(dir);
|
2005-01-18 22:45:00 +00:00
|
|
|
|
struct entry* dptr =
|
|
|
|
|
(struct entry*)(c->dircache + i * sizeof(struct entry));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (!entry)
|
|
|
|
|
break;
|
|
|
|
|
|
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 .. */
|
|
|
|
|
if ((entry->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
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip FAT volume ID */
|
|
|
|
|
if (entry->attribute & ATTR_VOLUME_ID) {
|
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* filter out dotfiles and hidden files */
|
|
|
|
|
if (*c->dirfilter != SHOW_ALL &&
|
|
|
|
|
((entry->d_name[0]=='.') ||
|
|
|
|
|
(entry->attribute & ATTR_HIDDEN))) {
|
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dptr->attr = entry->attribute;
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
2005-03-31 10:50:15 +00:00
|
|
|
|
#ifdef BOOTFILE
|
2005-01-17 11:39:46 +00:00
|
|
|
|
/* memorize/compare details about the boot file */
|
|
|
|
|
if ((c->currdir[1] == 0) && !strcasecmp(entry->d_name, BOOTFILE)) {
|
|
|
|
|
if (boot_size) {
|
|
|
|
|
if ((entry->size != boot_size) ||
|
|
|
|
|
(entry->startcluster != boot_cluster))
|
|
|
|
|
boot_changed = true;
|
|
|
|
|
}
|
|
|
|
|
boot_size = entry->size;
|
|
|
|
|
boot_cluster = entry->startcluster;
|
|
|
|
|
}
|
2005-03-31 08:47:02 +00:00
|
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
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 &&
|
|
|
|
|
(dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) ||
|
|
|
|
|
((*c->dirfilter == SHOW_MUSIC &&
|
|
|
|
|
(dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MPA) &&
|
|
|
|
|
(dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_M3U) ||
|
2005-08-17 17:53:54 +00:00
|
|
|
|
(*c->dirfilter == SHOW_SUPPORTED && !filetype_supported(dptr->attr)))) ||
|
2005-01-17 11:39:46 +00:00
|
|
|
|
(*c->dirfilter == SHOW_WPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) ||
|
2005-11-17 20:14:59 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
(*c->dirfilter == SHOW_RWPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_RWPS) ||
|
2006-04-02 12:23:08 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_TUNER
|
|
|
|
|
(*c->dirfilter == SHOW_FMR && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FMR) ||
|
2005-11-17 20:14:59 +00:00
|
|
|
|
#endif
|
2005-01-17 11:39:46 +00:00
|
|
|
|
(*c->dirfilter == SHOW_CFG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) ||
|
|
|
|
|
(*c->dirfilter == SHOW_LNG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) ||
|
|
|
|
|
(*c->dirfilter == SHOW_MOD && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MOD) ||
|
|
|
|
|
(*c->dirfilter == SHOW_FONT && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FONT) ||
|
2005-08-17 17:53:54 +00:00
|
|
|
|
(*c->dirfilter == SHOW_PLUGINS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_ROCK))
|
2005-01-17 11:39:46 +00:00
|
|
|
|
{
|
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len > c->name_buffer_size - name_buffer_used - 1) {
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
dptr->name = &c->name_buffer[name_buffer_used];
|
2005-02-12 12:29:41 +00:00
|
|
|
|
dptr->time_write =
|
|
|
|
|
(long)entry->wrtdate<<16 |
|
|
|
|
|
(long)entry->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
|
|
|
|
}
|
|
|
|
|
c->filesindir = i;
|
2005-01-18 22:45:00 +00:00
|
|
|
|
c->dirlength = i;
|
2005-10-07 17:38:05 +00:00
|
|
|
|
closedir_cached(dir);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
|
|
qsort(c->dircache,i,sizeof(struct entry),compare);
|
|
|
|
|
|
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. */
|
|
|
|
|
if (global_settings.talk_file == 3)
|
|
|
|
|
check_file_thumbnails(c); /* map .talk to ours */
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ft_enter(struct tree_context* c)
|
|
|
|
|
{
|
|
|
|
|
int rc = 0;
|
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
struct entry *dircache = c->dircache;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
struct entry* file = &dircache[c->selected_item];
|
2005-01-17 11:39:46 +00:00
|
|
|
|
bool reload_dir = false;
|
|
|
|
|
bool start_wps = false;
|
|
|
|
|
bool exit_func = false;
|
|
|
|
|
|
|
|
|
|
if (c->currdir[1])
|
|
|
|
|
snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name);
|
|
|
|
|
else
|
|
|
|
|
snprintf(buf,sizeof(buf),"/%s",file->name);
|
|
|
|
|
|
|
|
|
|
if (file->attr & ATTR_DIRECTORY) {
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
switch ( file->attr & TREE_ATTR_MASK ) {
|
|
|
|
|
case TREE_ATTR_M3U:
|
2006-03-19 08:40:31 +00:00
|
|
|
|
if (global_settings.party_mode) {
|
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_PARTY_MODE));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (bookmark_autoload(buf))
|
|
|
|
|
break;
|
|
|
|
|
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
|
|
|
|
|
2006-02-05 19:35:03 +00:00
|
|
|
|
/* about to create a new current playlist...
|
|
|
|
|
allow user to cancel the operation */
|
2006-03-19 12:09:41 +00:00
|
|
|
|
if (global_settings.warnon_erase_dynplaylist &&
|
2006-02-05 19:35:03 +00:00
|
|
|
|
playlist_modified(NULL))
|
|
|
|
|
{
|
|
|
|
|
char *lines[]={str(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
|
|
|
|
struct text_message message={lines, 1};
|
|
|
|
|
|
|
|
|
|
if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (playlist_create(c->currdir, file->name) != -1)
|
|
|
|
|
{
|
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
|
playlist_shuffle(seed, -1);
|
|
|
|
|
start_index = 0;
|
|
|
|
|
playlist_start(start_index,0);
|
|
|
|
|
play = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TREE_ATTR_MPA:
|
|
|
|
|
if (bookmark_autoload(c->currdir))
|
|
|
|
|
break;
|
|
|
|
|
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
|
|
|
|
|
2006-02-05 19:35:03 +00:00
|
|
|
|
/* about to create a new current playlist...
|
|
|
|
|
allow user to cancel the operation */
|
2006-04-15 06:23:34 +00:00
|
|
|
|
if (global_settings.warnon_erase_dynplaylist &&
|
|
|
|
|
!global_settings.party_mode &&
|
2006-02-05 19:35:03 +00:00
|
|
|
|
playlist_modified(NULL))
|
|
|
|
|
{
|
|
|
|
|
char *lines[]={str(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
|
|
|
|
struct text_message message={lines, 1};
|
|
|
|
|
|
|
|
|
|
if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-10 09:50:45 +00:00
|
|
|
|
if (global_settings.party_mode)
|
|
|
|
|
{
|
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);
|
2006-03-19 12:09:41 +00:00
|
|
|
|
gui_syncsplash(HZ, true, str(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;
|
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
|
#ifdef CONFIG_TUNER
|
|
|
|
|
/* fmr preset file */
|
|
|
|
|
case TREE_ATTR_FMR:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
|
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
|
|
|
|
|
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);
|
2007-02-08 10:36:49 +00:00
|
|
|
|
if(!in_radio_screen())
|
2006-08-28 22:38:41 +00:00
|
|
|
|
radio_screen();
|
2006-04-02 12:23:08 +00:00
|
|
|
|
}
|
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);
|
|
|
|
|
radio_screen();
|
|
|
|
|
}
|
2006-04-15 06:23:34 +00:00
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
/* wps config file */
|
|
|
|
|
case TREE_ATTR_WPS:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2006-11-13 00:45:21 +00:00
|
|
|
|
#if LCD_DEPTH > 1
|
2006-05-21 11:00:02 +00:00
|
|
|
|
unload_wps_backdrop();
|
|
|
|
|
#endif
|
2005-12-09 01:11:14 +00:00
|
|
|
|
wps_data_load(gui_wps[0].data, buf, true);
|
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);
|
|
|
|
|
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 */
|
|
|
|
|
case TREE_ATTR_RWPS:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2005-12-09 01:11:14 +00:00
|
|
|
|
wps_data_load(gui_wps[1].data, buf, true);
|
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);
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
case TREE_ATTR_CFG:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(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;
|
2006-04-01 13:36:33 +00:00
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_SETTINGS_LOADED));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TREE_ATTR_BMARK:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
bookmark_load(buf, false);
|
|
|
|
|
reload_dir = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TREE_ATTR_LNG:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if(!lang_load(buf)) {
|
2005-12-05 22:44:42 +00:00
|
|
|
|
set_file(buf, (char *)global_settings.lang_file,
|
2005-01-17 11:39:46 +00:00
|
|
|
|
MAX_FILENAME);
|
|
|
|
|
talk_init(); /* use voice of same language */
|
2005-11-16 15:12:15 +00:00
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_LANGUAGE_LOADED));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
case TREE_ATTR_FONT:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
font_load(buf);
|
2005-12-05 22:44:42 +00:00
|
|
|
|
set_file(buf, (char *)global_settings.font_file, MAX_FILENAME);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
break;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
|
|
|
|
case TREE_ATTR_KBD:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2006-03-29 16:21:42 +00:00
|
|
|
|
if (!load_kbd(buf))
|
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_KEYBOARD_LOADED));
|
|
|
|
|
set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME);
|
|
|
|
|
break;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
/* firmware file */
|
|
|
|
|
case TREE_ATTR_MOD:
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
2005-01-17 11:39:46 +00:00
|
|
|
|
rolo_load(buf);
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* plugin file */
|
|
|
|
|
case TREE_ATTR_ROCK:
|
2006-03-19 08:40:31 +00:00
|
|
|
|
if (global_settings.party_mode) {
|
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_PARTY_MODE));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-15 06:23:34 +00:00
|
|
|
|
gui_syncsplash(0, true, str(LANG_WAIT));
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (plugin_load(buf,NULL) == PLUGIN_USB_CONNECTED)
|
|
|
|
|
{
|
|
|
|
|
if(*c->dirfilter > NUM_FILTER_MODES)
|
|
|
|
|
/* leave sub-browsers after usb, doing
|
|
|
|
|
otherwise might be confusing to the user */
|
|
|
|
|
exit_func = true;
|
|
|
|
|
else
|
2005-05-17 18:28:32 +00:00
|
|
|
|
reload_dir = true;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2007-02-14 14:40:24 +00:00
|
|
|
|
case TREE_ATTR_CUE:
|
|
|
|
|
display_cuesheet_content(buf);
|
|
|
|
|
break;
|
|
|
|
|
|
2005-01-17 11:39:46 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
2006-03-19 08:40:31 +00:00
|
|
|
|
char* plugin;
|
|
|
|
|
|
|
|
|
|
if (global_settings.party_mode) {
|
|
|
|
|
gui_syncsplash(HZ, true, str(LANG_PARTY_MODE));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-04-15 06:23:34 +00:00
|
|
|
|
|
2006-03-19 08:40:31 +00:00
|
|
|
|
plugin = filetype_get_plugin(file);
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (plugin)
|
|
|
|
|
{
|
|
|
|
|
if (plugin_load(plugin,buf) == PLUGIN_USB_CONNECTED)
|
2005-05-17 18:28:32 +00:00
|
|
|
|
reload_dir = true;
|
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();
|
2005-01-17 11:39:46 +00:00
|
|
|
|
|
|
|
|
|
start_wps = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (*c->dirfilter > NUM_FILTER_MODES &&
|
|
|
|
|
*c->dirfilter != SHOW_FONT &&
|
|
|
|
|
*c->dirfilter != SHOW_PLUGINS)
|
|
|
|
|
{
|
|
|
|
|
exit_func = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reload_dir)
|
|
|
|
|
rc = 1;
|
|
|
|
|
if (start_wps)
|
2005-05-17 18:28:32 +00:00
|
|
|
|
rc = 2;
|
2005-01-17 11:39:46 +00:00
|
|
|
|
if (exit_func)
|
2005-05-17 18:28:32 +00:00
|
|
|
|
rc = 3;
|
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;
|
|
|
|
|
}
|