2003-03-12 20:21:30 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Bj<EFBFBD>rn Stenberg
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
2003-04-01 20:58:31 +00:00
|
|
|
|
#include "debug.h"
|
2003-03-12 21:40:47 +00:00
|
|
|
|
#include "sprintf.h"
|
2003-03-12 20:21:30 +00:00
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "dir.h"
|
|
|
|
|
#include "file.h"
|
|
|
|
|
#include "mpeg.h"
|
|
|
|
|
#include "menu.h"
|
|
|
|
|
#include "lang.h"
|
|
|
|
|
#include "playlist.h"
|
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
#include "keyboard.h"
|
2003-04-01 20:58:31 +00:00
|
|
|
|
#include "mp3data.h"
|
|
|
|
|
#include "id3.h"
|
|
|
|
|
#include "screens.h"
|
2003-03-24 13:17:43 +00:00
|
|
|
|
#include "tree.h"
|
2003-05-09 16:01:21 +00:00
|
|
|
|
#include "buffer.h"
|
2003-07-01 21:05:43 +00:00
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "status.h"
|
2004-01-26 17:05:21 +00:00
|
|
|
|
#include "playlist_viewer.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
|
#include "talk.h"
|
2003-07-01 21:05:43 +00:00
|
|
|
|
#include "onplay.h"
|
2004-05-21 20:08:24 +00:00
|
|
|
|
#include "filetypes.h"
|
2004-07-13 13:57:14 +00:00
|
|
|
|
#include "plugin.h"
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
|
|
|
|
static char* selected_file = NULL;
|
2003-07-01 21:05:43 +00:00
|
|
|
|
static int selected_file_attr = 0;
|
|
|
|
|
static int onplay_result = ONPLAY_OK;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
2004-05-21 20:08:24 +00:00
|
|
|
|
static bool list_viewers(void)
|
|
|
|
|
{
|
|
|
|
|
struct menu_item menu[8];
|
|
|
|
|
int m, i, result;
|
2004-07-13 13:57:14 +00:00
|
|
|
|
int ret = 0;
|
2004-05-21 20:08:24 +00:00
|
|
|
|
|
|
|
|
|
i=filetype_load_menu(menu,sizeof(menu)/sizeof(*menu));
|
|
|
|
|
if (i)
|
|
|
|
|
{
|
|
|
|
|
m = menu_init( menu, i, NULL, NULL, NULL, NULL );
|
|
|
|
|
result = menu_show(m);
|
2004-07-01 06:35:39 +00:00
|
|
|
|
menu_exit(m);
|
2004-05-21 20:08:24 +00:00
|
|
|
|
if (result >= 0)
|
2004-07-13 13:57:14 +00:00
|
|
|
|
ret = filetype_load_plugin(menu[result].desc,selected_file);
|
2004-05-21 20:08:24 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
splash(HZ*2, true, "No viewers found");
|
|
|
|
|
}
|
2004-07-13 13:57:14 +00:00
|
|
|
|
|
|
|
|
|
if(ret == PLUGIN_USB_CONNECTED)
|
|
|
|
|
onplay_result = ONPLAY_RELOAD_DIR;
|
|
|
|
|
|
2004-05-21 20:08:24 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
|
/* For playlist options */
|
|
|
|
|
struct playlist_args {
|
|
|
|
|
int position;
|
|
|
|
|
bool queue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bool add_to_playlist(int position, bool queue)
|
2003-03-12 20:21:30 +00:00
|
|
|
|
{
|
2003-07-01 21:05:43 +00:00
|
|
|
|
bool new_playlist = !(mpeg_status() & MPEG_STATUS_PLAY);
|
|
|
|
|
|
|
|
|
|
if (new_playlist)
|
|
|
|
|
playlist_create(NULL, NULL);
|
|
|
|
|
|
2003-12-07 16:57:43 +00:00
|
|
|
|
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
|
2004-01-26 17:05:21 +00:00
|
|
|
|
playlist_insert_track(NULL, selected_file, position, queue);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
else if (selected_file_attr & ATTR_DIRECTORY)
|
2003-07-02 15:54:44 +00:00
|
|
|
|
{
|
|
|
|
|
bool recurse = false;
|
|
|
|
|
|
|
|
|
|
if (global_settings.recursive_dir_insert != RECURSE_ASK)
|
|
|
|
|
recurse = (bool)global_settings.recursive_dir_insert;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Ask if user wants to recurse directory */
|
|
|
|
|
bool exit = false;
|
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts_scroll(0,0,str(LANG_RECURSE_DIRECTORY_QUESTION));
|
|
|
|
|
lcd_puts_scroll(0,1,selected_file);
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
|
|
|
|
|
lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
while (!exit) {
|
|
|
|
|
int btn = button_get(true);
|
|
|
|
|
switch (btn) {
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
recurse = true;
|
2003-07-02 15:54:44 +00:00
|
|
|
|
exit = true;
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* ignore button releases */
|
|
|
|
|
if (!(btn & BUTTON_REL))
|
|
|
|
|
exit = true;
|
|
|
|
|
break;
|
2003-07-02 15:54:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-26 17:05:21 +00:00
|
|
|
|
playlist_insert_directory(NULL, selected_file, position, queue,
|
2004-09-19 21:58:37 +00:00
|
|
|
|
recurse);
|
2003-07-02 15:54:44 +00:00
|
|
|
|
}
|
2003-12-07 16:57:43 +00:00
|
|
|
|
else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
2004-01-26 17:05:21 +00:00
|
|
|
|
playlist_insert_playlist(NULL, selected_file, position, queue);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
|
|
|
|
|
if (new_playlist && (playlist_amount() > 0))
|
|
|
|
|
{
|
|
|
|
|
/* nothing is currently playing so begin playing what we just
|
|
|
|
|
inserted */
|
|
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
|
playlist_shuffle(current_tick, -1);
|
|
|
|
|
playlist_start(0,0);
|
|
|
|
|
status_draw(false);
|
|
|
|
|
onplay_result = ONPLAY_START_PLAY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-26 17:05:21 +00:00
|
|
|
|
static bool view_playlist(void)
|
|
|
|
|
{
|
|
|
|
|
bool was_playing = mpeg_status() & MPEG_STATUS_PLAY;
|
|
|
|
|
bool result;
|
|
|
|
|
|
|
|
|
|
result = playlist_viewer_ex(selected_file);
|
|
|
|
|
|
|
|
|
|
if (!was_playing && (mpeg_status() & MPEG_STATUS_PLAY) &&
|
|
|
|
|
onplay_result == ONPLAY_OK)
|
|
|
|
|
/* playlist was started from viewer */
|
|
|
|
|
onplay_result = ONPLAY_START_PLAY;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
|
/* Sub-menu for playlist options */
|
|
|
|
|
static bool playlist_options(void)
|
|
|
|
|
{
|
2004-03-16 13:44:56 +00:00
|
|
|
|
struct menu_item items[7];
|
2004-01-26 17:05:21 +00:00
|
|
|
|
struct playlist_args args[7]; /* increase these 2 if you add entries! */
|
|
|
|
|
int m, i=0, pstart=0, result;
|
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
|
|
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_VIEW);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[i].function = view_playlist;
|
2004-01-26 17:05:21 +00:00
|
|
|
|
i++;
|
|
|
|
|
pstart++;
|
|
|
|
|
}
|
2003-07-01 21:05:43 +00:00
|
|
|
|
|
|
|
|
|
if (mpeg_status() & MPEG_STATUS_PLAY)
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_INSERT);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT;
|
|
|
|
|
args[i].queue = false;
|
|
|
|
|
i++;
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_INSERT_FIRST);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT_FIRST;
|
|
|
|
|
args[i].queue = false;
|
|
|
|
|
i++;
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_INSERT_LAST);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT_LAST;
|
|
|
|
|
args[i].queue = false;
|
|
|
|
|
i++;
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_QUEUE);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT;
|
|
|
|
|
args[i].queue = true;
|
|
|
|
|
i++;
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_QUEUE_FIRST);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT_FIRST;
|
|
|
|
|
args[i].queue = true;
|
|
|
|
|
i++;
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_QUEUE_LAST);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT_LAST;
|
|
|
|
|
args[i].queue = true;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2003-12-07 16:57:43 +00:00
|
|
|
|
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
2003-07-01 21:05:43 +00:00
|
|
|
|
(selected_file_attr & ATTR_DIRECTORY))
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_INSERT);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
args[i].position = PLAYLIST_INSERT;
|
|
|
|
|
args[i].queue = false;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 13:44:56 +00:00
|
|
|
|
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
2003-07-01 21:05:43 +00:00
|
|
|
|
result = menu_show(m);
|
2004-01-26 17:05:21 +00:00
|
|
|
|
if (result >= 0 && result < pstart)
|
2004-03-16 13:44:56 +00:00
|
|
|
|
ret = items[result].function();
|
2004-01-26 17:05:21 +00:00
|
|
|
|
else if (result >= pstart)
|
|
|
|
|
ret = add_to_playlist(args[result].position, args[result].queue);
|
2003-07-01 21:05:43 +00:00
|
|
|
|
menu_exit(m);
|
|
|
|
|
|
2004-01-26 17:05:21 +00:00
|
|
|
|
return ret;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-08 06:38:56 +00:00
|
|
|
|
|
|
|
|
|
/* helper function to remove a non-empty directory */
|
|
|
|
|
static int remove_dir(char* dirname, int len)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
DIR* dir;
|
|
|
|
|
int dirlen = strlen(dirname);
|
|
|
|
|
|
|
|
|
|
dir = opendir(dirname);
|
|
|
|
|
if (!dir)
|
|
|
|
|
return -1; /* open error */
|
|
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
|
{
|
|
|
|
|
struct dirent* entry;
|
|
|
|
|
/* walk through the directory content */
|
|
|
|
|
entry = readdir(dir);
|
|
|
|
|
if (!entry)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* append name to current directory */
|
|
|
|
|
snprintf(dirname+dirlen, len-dirlen, "/%s", entry->d_name);
|
|
|
|
|
|
|
|
|
|
if (entry->attribute & ATTR_DIRECTORY)
|
|
|
|
|
{ /* remove a subdirectory */
|
|
|
|
|
if (!strcmp(entry->d_name, ".") ||
|
|
|
|
|
!strcmp(entry->d_name, ".."))
|
|
|
|
|
continue; /* skip these */
|
|
|
|
|
|
|
|
|
|
result = remove_dir(dirname, len); /* recursion */
|
|
|
|
|
if (result)
|
|
|
|
|
break; /* or better continue, delete what we can? */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ /* remove a file */
|
|
|
|
|
result = remove(dirname);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{ /* remove the now empty directory */
|
|
|
|
|
dirname[dirlen] = '\0'; /* terminate to original length */
|
|
|
|
|
|
2004-04-16 09:00:07 +00:00
|
|
|
|
result = rmdir(dirname);
|
2004-04-08 06:38:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* share code for file and directory deletion, saves space */
|
|
|
|
|
static bool delete_handler(bool is_dir)
|
2003-03-12 20:21:30 +00:00
|
|
|
|
{
|
|
|
|
|
bool exit = false;
|
2004-04-08 06:38:56 +00:00
|
|
|
|
int res;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,str(LANG_REALLY_DELETE));
|
|
|
|
|
lcd_puts_scroll(0,1,selected_file);
|
2003-06-25 08:25:29 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
|
|
|
|
|
lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER));
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-03-24 13:17:43 +00:00
|
|
|
|
lcd_update();
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
|
|
|
|
while (!exit) {
|
|
|
|
|
int btn = button_get(true);
|
|
|
|
|
switch (btn) {
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
if (is_dir)
|
|
|
|
|
{
|
|
|
|
|
char pathname[MAX_PATH]; /* space to go deep */
|
|
|
|
|
strncpy(pathname, selected_file, sizeof pathname);
|
|
|
|
|
res = remove_dir(pathname, sizeof(pathname));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
res = remove(selected_file);
|
|
|
|
|
}
|
2004-04-08 06:38:56 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
if (!res) {
|
|
|
|
|
onplay_result = ONPLAY_RELOAD_DIR;
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,str(LANG_DELETED));
|
|
|
|
|
lcd_puts_scroll(0,1,selected_file);
|
|
|
|
|
lcd_update();
|
|
|
|
|
sleep(HZ);
|
|
|
|
|
exit = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
default:
|
|
|
|
|
/* ignore button releases */
|
2004-10-06 19:29:24 +00:00
|
|
|
|
if (!(btn & BUTTON_REL))
|
2004-09-19 21:58:37 +00:00
|
|
|
|
exit = true;
|
|
|
|
|
break;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-08 06:38:56 +00:00
|
|
|
|
|
|
|
|
|
static bool delete_file(void)
|
|
|
|
|
{
|
|
|
|
|
return delete_handler(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool delete_dir(void)
|
|
|
|
|
{
|
|
|
|
|
return delete_handler(true);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-12 20:21:30 +00:00
|
|
|
|
static bool rename_file(void)
|
|
|
|
|
{
|
|
|
|
|
char newname[MAX_PATH];
|
|
|
|
|
char* ptr = strrchr(selected_file, '/') + 1;
|
|
|
|
|
int pathlen = (ptr - selected_file);
|
|
|
|
|
strncpy(newname, selected_file, sizeof newname);
|
|
|
|
|
if (!kbd_input(newname + pathlen, (sizeof newname)-pathlen)) {
|
|
|
|
|
if (!strlen(selected_file+pathlen) ||
|
|
|
|
|
(rename(selected_file, newname) < 0)) {
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,str(LANG_RENAME));
|
|
|
|
|
lcd_puts(0,1,str(LANG_FAILED));
|
|
|
|
|
lcd_update();
|
|
|
|
|
sleep(HZ*2);
|
|
|
|
|
}
|
|
|
|
|
else
|
2003-07-01 21:05:43 +00:00
|
|
|
|
onplay_result = ONPLAY_RELOAD_DIR;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-11 10:43:53 +00:00
|
|
|
|
bool create_dir(void)
|
|
|
|
|
{
|
|
|
|
|
char dirname[MAX_PATH];
|
|
|
|
|
char *cwd;
|
|
|
|
|
int rc;
|
|
|
|
|
int pathlen;
|
|
|
|
|
|
|
|
|
|
cwd = getcwd(NULL, 0);
|
|
|
|
|
memset(dirname, 0, sizeof dirname);
|
|
|
|
|
|
|
|
|
|
snprintf(dirname, sizeof dirname, "%s/",
|
|
|
|
|
cwd[1] ? cwd : "");
|
|
|
|
|
|
|
|
|
|
pathlen = strlen(dirname);
|
|
|
|
|
rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
|
|
|
|
|
if(rc < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
rc = mkdir(dirname, 0);
|
|
|
|
|
if(rc < 0) {
|
|
|
|
|
splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
|
|
|
|
|
} else {
|
|
|
|
|
onplay_result = ONPLAY_RELOAD_DIR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-12 20:21:30 +00:00
|
|
|
|
int onplay(char* file, int attr)
|
|
|
|
|
{
|
2004-05-21 20:08:24 +00:00
|
|
|
|
struct menu_item items[6]; /* increase this if you add entries! */
|
2003-03-12 20:21:30 +00:00
|
|
|
|
int m, i=0, result;
|
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
|
onplay_result = ONPLAY_OK;
|
|
|
|
|
|
2004-03-11 10:43:53 +00:00
|
|
|
|
if(file)
|
2003-04-10 21:01:22 +00:00
|
|
|
|
{
|
2004-03-11 10:43:53 +00:00
|
|
|
|
selected_file = file;
|
|
|
|
|
selected_file_attr = attr;
|
|
|
|
|
|
|
|
|
|
if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
|
|
|
|
(attr & ATTR_DIRECTORY) ||
|
|
|
|
|
((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_PLAYINDICES_PLAYLIST);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[i].function = playlist_options;
|
2004-03-11 10:43:53 +00:00
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_RENAME);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[i].function = rename_file;
|
2003-04-10 21:01:22 +00:00
|
|
|
|
i++;
|
2004-03-11 10:43:53 +00:00
|
|
|
|
|
|
|
|
|
if (!(attr & ATTR_DIRECTORY))
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_DELETE);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[i].function = delete_file;
|
2004-03-11 10:43:53 +00:00
|
|
|
|
i++;
|
|
|
|
|
}
|
2004-04-08 06:38:56 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_DELETE_DIR);
|
2004-04-08 06:38:56 +00:00
|
|
|
|
items[i].function = delete_dir;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2004-07-30 06:24:38 +00:00
|
|
|
|
|
|
|
|
|
if (!(attr & ATTR_DIRECTORY))
|
|
|
|
|
{
|
|
|
|
|
items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH);
|
|
|
|
|
items[i].function = list_viewers;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2003-04-10 21:01:22 +00:00
|
|
|
|
}
|
2003-03-12 20:21:30 +00:00
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
items[i].desc = ID2P(LANG_CREATE_DIR);
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[i].function = create_dir;
|
2003-04-10 21:01:22 +00:00
|
|
|
|
i++;
|
2003-04-02 08:20:51 +00:00
|
|
|
|
|
2003-03-12 20:21:30 +00:00
|
|
|
|
/* DIY menu handling, since we want to exit after selection */
|
2004-03-16 13:44:56 +00:00
|
|
|
|
m = menu_init( items, i, NULL, NULL, NULL, NULL );
|
2003-03-12 20:21:30 +00:00
|
|
|
|
result = menu_show(m);
|
|
|
|
|
if (result >= 0)
|
2004-03-16 13:44:56 +00:00
|
|
|
|
items[result].function();
|
2003-03-12 20:21:30 +00:00
|
|
|
|
menu_exit(m);
|
|
|
|
|
|
2003-07-01 21:05:43 +00:00
|
|
|
|
return onplay_result;
|
2003-03-12 20:21:30 +00:00
|
|
|
|
}
|