2005-08-20 19:56:01 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Jonas Haggqvist
|
|
|
|
*
|
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-08-20 19:56:01 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "plugin.h"
|
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2006-01-15 18:20:18 +00:00
|
|
|
|
2010-12-28 14:42:30 +00:00
|
|
|
static int files, dirs, audiofiles, m3ufiles, imagefiles, videofiles, largestdir;
|
2005-08-20 19:56:01 +00:00
|
|
|
static int lasttick;
|
2010-05-06 21:04:40 +00:00
|
|
|
static bool cancel;
|
2005-08-20 19:56:01 +00:00
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == PLAYER_PAD
|
|
|
|
#define STATS_STOP BUTTON_STOP
|
2006-07-28 07:35:45 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == RECORDER_PAD) \
|
2007-01-14 13:48:09 +00:00
|
|
|
|| (CONFIG_KEYPAD == ONDIO_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
|
2006-07-28 07:35:45 +00:00
|
|
|
#define STATS_STOP BUTTON_OFF
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define STATS_STOP BUTTON_OFF
|
|
|
|
#define STATS_STOP_REMOTE BUTTON_RC_STOP
|
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2005-12-14 01:31:37 +00:00
|
|
|
#define STATS_STOP BUTTON_MENU
|
2006-07-28 07:35:45 +00:00
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YH_PAD)
|
2006-01-12 00:35:50 +00:00
|
|
|
#define STATS_STOP BUTTON_PLAY
|
2006-07-28 07:35:45 +00:00
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-01-18 11:09:06 +00:00
|
|
|
#define STATS_STOP BUTTON_POWER
|
2006-07-28 07:35:45 +00:00
|
|
|
#define STATS_STOP_REMOTE BUTTON_RC_PLAY
|
|
|
|
|
2006-02-24 15:42:52 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
2007-05-19 23:38:09 +00:00
|
|
|
#define STATS_STOP BUTTON_POWER
|
2006-07-28 07:35:45 +00:00
|
|
|
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
2008-12-12 19:50:49 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_C200_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
|
2011-11-16 14:08:01 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_M200_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CONNECT_PAD)
|
2006-10-26 13:38:09 +00:00
|
|
|
#define STATS_STOP BUTTON_POWER
|
|
|
|
|
2009-01-04 23:33:15 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
2009-04-10 17:28:26 +00:00
|
|
|
#define STATS_STOP BUTTON_HOME
|
2009-01-04 23:33:15 +00:00
|
|
|
|
2006-08-03 20:17:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
|
|
|
|
2007-10-23 15:40:51 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE500_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
2009-04-11 07:23:56 +00:00
|
|
|
#define STATS_STOP_REMOTE BUTTON_RC_DOWN
|
2008-02-17 12:23:02 +00:00
|
|
|
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
|
|
|
|
CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
|
2008-02-17 12:23:02 +00:00
|
|
|
#define STATS_STOP BUTTON_BACK
|
2008-03-01 22:55:09 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == MROBE100_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
2009-07-26 14:26:14 +00:00
|
|
|
#define STATS_STOP_REMOTE BUTTON_RC_DOWN
|
2008-03-01 22:55:09 +00:00
|
|
|
|
2008-03-22 10:24:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define STATS_STOP BUTTON_REC
|
|
|
|
#define STATS_STOP_REMOTE BUTTON_RC_REC
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2008-03-22 22:03:34 +00:00
|
|
|
#define STATS_STOP BUTTON_POWER
|
2008-10-07 16:38:28 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO67_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
2008-03-22 22:03:34 +00:00
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define STATS_STOP BUTTON_BACK
|
|
|
|
|
2010-11-02 14:36:08 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == PHILIPS_HDD6330_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
|
2009-12-02 01:56:39 +00:00
|
|
|
#define STATS_STOP BUTTON_POWER
|
|
|
|
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX777_PAD
|
|
|
|
#define STATS_STOP BUTTON_POWER
|
2009-04-07 23:41:44 +00:00
|
|
|
|
2010-02-11 22:40:17 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define STATS_STOP BUTTON_REC
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define STATS_STOP BUTTON_REC
|
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
#define STATS_STOP BUTTON_REC
|
|
|
|
|
2011-10-02 15:50:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
|
|
|
|
#define STATS_STOP BUTTON_BACK
|
|
|
|
|
2008-03-01 22:55:09 +00:00
|
|
|
#else
|
|
|
|
#error No keymap defined!
|
2006-04-02 20:47:42 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-28 14:42:30 +00:00
|
|
|
/* we don't have yet a filetype attribute for image files */
|
2011-09-17 17:20:27 +00:00
|
|
|
static const char *image_exts[] = {"bmp","jpg","jpe","jpeg","png","ppm"};
|
2010-12-28 14:42:30 +00:00
|
|
|
|
|
|
|
/* neither for video ones */
|
2011-09-17 17:20:27 +00:00
|
|
|
static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"};
|
2010-12-28 14:42:30 +00:00
|
|
|
|
2011-09-17 17:20:27 +00:00
|
|
|
static void prn(const char *str, int y)
|
2006-04-02 20:47:42 +00:00
|
|
|
{
|
2007-04-06 22:55:00 +00:00
|
|
|
rb->lcd_puts(0,y,str);
|
2006-04-02 20:47:42 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2007-04-06 22:55:00 +00:00
|
|
|
rb->lcd_remote_puts(0,y,str);
|
2006-04-02 20:47:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
2005-08-20 19:56:01 +00:00
|
|
|
|
2011-09-17 17:20:27 +00:00
|
|
|
static void update_screen(void)
|
2005-08-20 19:56:01 +00:00
|
|
|
{
|
2007-07-31 12:57:22 +00:00
|
|
|
char buf[32];
|
2007-04-06 22:55:00 +00:00
|
|
|
|
2005-08-20 19:56:01 +00:00
|
|
|
rb->lcd_clear_display();
|
2006-04-02 20:47:42 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
rb->lcd_remote_clear_display();
|
|
|
|
#endif
|
2007-04-06 22:55:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2010-12-28 14:42:30 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Total Files: %d", files);
|
2006-04-02 20:47:42 +00:00
|
|
|
prn(buf,0);
|
2010-12-28 14:42:30 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Audio: %d", audiofiles);
|
2007-04-06 22:55:00 +00:00
|
|
|
prn(buf,1);
|
2010-12-28 14:42:30 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Playlists: %d", m3ufiles);
|
2007-04-06 22:55:00 +00:00
|
|
|
prn(buf,2);
|
2010-12-28 14:42:30 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Images: %d", imagefiles);
|
2007-07-31 12:57:22 +00:00
|
|
|
prn(buf,3);
|
2010-12-28 14:42:30 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Videos: %d", videofiles);
|
|
|
|
prn(buf,4);
|
|
|
|
rb->snprintf(buf, sizeof(buf), "Directories: %d", dirs);
|
|
|
|
prn(buf,5);
|
|
|
|
rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d", largestdir);
|
|
|
|
prn(buf,6);
|
2005-08-20 19:56:01 +00:00
|
|
|
#else
|
|
|
|
rb->snprintf(buf, sizeof(buf), "Files:%5d", files);
|
2006-04-02 20:47:42 +00:00
|
|
|
prn(buf,0);
|
2005-08-20 19:56:01 +00:00
|
|
|
rb->snprintf(buf, sizeof(buf), "Dirs: %5d", dirs);
|
2006-04-02 20:47:42 +00:00
|
|
|
prn(buf,1);
|
2005-08-20 19:56:01 +00:00
|
|
|
#endif
|
2007-04-06 22:55:00 +00:00
|
|
|
|
|
|
|
rb->lcd_update();
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
rb->lcd_remote_update();
|
|
|
|
#endif
|
2005-08-20 19:56:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-17 17:20:27 +00:00
|
|
|
static void traversedir(char* location, char* name)
|
2005-08-20 19:56:01 +00:00
|
|
|
{
|
|
|
|
int button;
|
|
|
|
struct dirent *entry;
|
|
|
|
DIR* dir;
|
|
|
|
char fullpath[MAX_PATH];
|
2007-07-31 12:57:22 +00:00
|
|
|
int files_in_dir = 0;
|
2005-08-20 19:56:01 +00:00
|
|
|
|
|
|
|
rb->snprintf(fullpath, sizeof(fullpath), "%s/%s", location, name);
|
|
|
|
dir = rb->opendir(fullpath);
|
|
|
|
if (dir) {
|
|
|
|
entry = rb->readdir(dir);
|
|
|
|
while (entry) {
|
2010-05-06 21:04:40 +00:00
|
|
|
if (cancel)
|
2005-08-20 19:56:01 +00:00
|
|
|
break;
|
|
|
|
/* Skip .. and . */
|
|
|
|
if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
|
|
|
|
{
|
2010-09-01 21:29:34 +00:00
|
|
|
struct dirinfo info = rb->dir_get_info(dir, entry);
|
|
|
|
if (info.attribute & ATTR_DIRECTORY) {
|
2005-08-20 19:56:01 +00:00
|
|
|
traversedir(fullpath, entry->d_name);
|
2006-04-02 20:47:42 +00:00
|
|
|
dirs++;
|
2005-08-20 19:56:01 +00:00
|
|
|
}
|
2006-04-02 20:47:42 +00:00
|
|
|
else {
|
2010-12-28 14:42:30 +00:00
|
|
|
files_in_dir++; files++;
|
|
|
|
|
|
|
|
/* get the filetype from the filename */
|
2010-12-28 14:34:38 +00:00
|
|
|
int attr = rb->filetype_get_attr(entry->d_name);
|
2010-12-28 14:42:30 +00:00
|
|
|
switch (attr & FILE_ATTR_MASK)
|
|
|
|
{
|
|
|
|
case FILE_ATTR_AUDIO:
|
|
|
|
audiofiles++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ATTR_M3U:
|
|
|
|
m3ufiles++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-12-28 14:34:38 +00:00
|
|
|
{
|
2010-12-28 14:42:30 +00:00
|
|
|
/* use hardcoded filetype_exts to count
|
|
|
|
* image and video files until we get
|
|
|
|
* new attributes added to filetypes.h */
|
|
|
|
char *ptr = rb->strrchr(entry->d_name,'.');
|
|
|
|
if(ptr) {
|
|
|
|
unsigned i;
|
|
|
|
ptr++;
|
|
|
|
for(i=0;i<ARRAYLEN(image_exts);i++) {
|
|
|
|
if(!rb->strcasecmp(ptr,image_exts[i])) {
|
|
|
|
imagefiles++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= ARRAYLEN(image_exts)) {
|
|
|
|
/* not found above - try video files */
|
|
|
|
for(i=0;i<ARRAYLEN(video_exts);i++) {
|
|
|
|
if(!rb->strcasecmp(ptr,video_exts[i])) {
|
|
|
|
videofiles++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* default: */
|
|
|
|
} /* switch */
|
2006-04-02 20:47:42 +00:00
|
|
|
}
|
2005-08-20 19:56:01 +00:00
|
|
|
}
|
2010-12-28 14:42:30 +00:00
|
|
|
|
2005-08-20 19:56:01 +00:00
|
|
|
if (*rb->current_tick - lasttick > (HZ/2)) {
|
|
|
|
update_screen();
|
|
|
|
lasttick = *rb->current_tick;
|
|
|
|
button = rb->button_get(false);
|
2006-04-02 20:47:42 +00:00
|
|
|
if (button == STATS_STOP
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|| button == STATS_STOP_REMOTE
|
|
|
|
#endif
|
|
|
|
) {
|
2010-05-06 21:04:40 +00:00
|
|
|
cancel = true;
|
2005-08-20 19:56:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = rb->readdir(dir);
|
|
|
|
}
|
|
|
|
rb->closedir(dir);
|
|
|
|
}
|
2007-07-31 12:57:22 +00:00
|
|
|
if (largestdir < files_in_dir)
|
|
|
|
largestdir = files_in_dir;
|
2005-08-20 19:56:01 +00:00
|
|
|
}
|
|
|
|
|
2010-12-28 14:34:38 +00:00
|
|
|
/* this is the plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2005-08-20 19:56:01 +00:00
|
|
|
{
|
|
|
|
int button;
|
|
|
|
|
|
|
|
(void)parameter;
|
|
|
|
|
|
|
|
files = 0;
|
|
|
|
dirs = 0;
|
2010-12-28 14:42:30 +00:00
|
|
|
audiofiles = 0;
|
|
|
|
m3ufiles = 0;
|
|
|
|
imagefiles = 0;
|
|
|
|
videofiles = 0;
|
2007-07-31 12:57:22 +00:00
|
|
|
largestdir = 0;
|
2010-05-06 21:04:40 +00:00
|
|
|
cancel = false;
|
2005-08-20 19:56:01 +00:00
|
|
|
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ, "Counting...");
|
2005-08-20 19:56:01 +00:00
|
|
|
update_screen();
|
|
|
|
lasttick = *rb->current_tick;
|
|
|
|
|
|
|
|
traversedir("", "");
|
2010-05-06 21:04:40 +00:00
|
|
|
if (cancel) {
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ, "Aborted");
|
2005-08-20 19:56:01 +00:00
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
2005-09-02 22:25:25 +00:00
|
|
|
update_screen();
|
2006-04-02 20:47:42 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
rb->remote_backlight_on();
|
|
|
|
#endif
|
|
|
|
rb->backlight_on();
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ, "Done");
|
2005-08-20 19:56:01 +00:00
|
|
|
update_screen();
|
|
|
|
while (1) {
|
2008-06-29 06:48:07 +00:00
|
|
|
button = rb->button_get(true);
|
2005-08-20 19:56:01 +00:00
|
|
|
switch (button) {
|
2006-04-02 20:47:42 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
case STATS_STOP_REMOTE:
|
|
|
|
#endif
|
2005-08-20 19:56:01 +00:00
|
|
|
case STATS_STOP:
|
|
|
|
return PLUGIN_OK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
|
|
|
|
return PLUGIN_USB_CONNECTED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-06-29 06:48:07 +00:00
|
|
|
return PLUGIN_OK;
|
2005-08-20 19:56:01 +00:00
|
|
|
}
|