mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-17 12:07:38 -04:00
Recode filetypes.c to remove its need for a static string buffer.
Functional changes: - filetypes.c handles the open with menu now instead of onplay.c - automatic plugin registration no longer works (did anyone know about you could do this?) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12959 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d71b531c25
commit
21165a3f3d
7 changed files with 268 additions and 770 deletions
965
apps/filetypes.c
965
apps/filetypes.c
File diff suppressed because it is too large
Load diff
|
@ -22,32 +22,24 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <tree.h>
|
#include <tree.h>
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
|
/* init the filetypes structs.
|
||||||
int filetype_get_attr(const char*);
|
uses audio buffer for storage, so call early in init... */
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
const unsigned char* filetype_get_icon(int);
|
|
||||||
#else
|
|
||||||
int filetype_get_icon(int);
|
|
||||||
#endif
|
|
||||||
char* filetype_get_plugin(const struct entry*);
|
|
||||||
void filetype_init(void);
|
void filetype_init(void);
|
||||||
bool filetype_supported(int);
|
|
||||||
int filetype_load_menu(struct menu_item*, int);
|
|
||||||
int filetype_load_plugin(const char*, char*);
|
|
||||||
|
|
||||||
struct file_type {
|
/* Return the attribute (TREE_ATTR_*) of the file */
|
||||||
#ifdef HAVE_LCD_BITMAP
|
int filetype_get_attr(const char* file);
|
||||||
const unsigned char* icon; /* the icon which shall be used for it, NULL if unknown */
|
ICON filetype_get_icon(int attr);
|
||||||
#else
|
/* return the plugin filename associated with the file */
|
||||||
int icon; /* the icon which shall be used for it, -1 if unknown */
|
char* filetype_get_plugin(const struct entry* file);
|
||||||
#endif
|
|
||||||
char* plugin; /* Which plugin to use, NULL if unknown */
|
/* returns true if the attr is supported */
|
||||||
bool no_extension;
|
bool filetype_supported(int attr);
|
||||||
};
|
|
||||||
|
/* List avialable viewers */
|
||||||
|
int filetype_list_viewers(const char* current_file);
|
||||||
|
|
||||||
|
/* start a plugin with file as the argument (called from onplay.c) */
|
||||||
|
int filetype_load_plugin(const char* plugin, char* file);
|
||||||
|
|
||||||
struct ext_type {
|
|
||||||
char* extension; /* extension for which the file type is recognized */
|
|
||||||
struct file_type* type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,9 +24,11 @@
|
||||||
* char-based displays and bitmap displays */
|
* char-based displays and bitmap displays */
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
typedef const unsigned char * ICON;
|
typedef const unsigned char * ICON;
|
||||||
|
typedef unsigned char * ICON_NO_CONST;
|
||||||
#define NOICON NULL
|
#define NOICON NULL
|
||||||
#else
|
#else
|
||||||
typedef long ICON;
|
typedef long ICON;
|
||||||
|
#define ICON_NO_CONST ICON
|
||||||
#define NOICON -1
|
#define NOICON -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
#include "filetypes.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
@ -258,6 +259,7 @@ static void init(void)
|
||||||
#endif
|
#endif
|
||||||
sleep(HZ/2);
|
sleep(HZ/2);
|
||||||
tree_init();
|
tree_init();
|
||||||
|
filetype_init();
|
||||||
playlist_init();
|
playlist_init();
|
||||||
|
|
||||||
#if CONFIG_CODEC != SWCODEC
|
#if CONFIG_CODEC != SWCODEC
|
||||||
|
@ -490,6 +492,7 @@ static void init(void)
|
||||||
status_init();
|
status_init();
|
||||||
playlist_init();
|
playlist_init();
|
||||||
tree_init();
|
tree_init();
|
||||||
|
filetype_init();
|
||||||
scrobbler_init();
|
scrobbler_init();
|
||||||
cuesheet_init();
|
cuesheet_init();
|
||||||
|
|
||||||
|
|
|
@ -125,28 +125,9 @@ static bool bookmark_menu(void)
|
||||||
|
|
||||||
static bool list_viewers(void)
|
static bool list_viewers(void)
|
||||||
{
|
{
|
||||||
struct menu_item menu[16];
|
int ret = filetype_list_viewers(selected_file);
|
||||||
int m, i, result;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
i=filetype_load_menu(menu,sizeof(menu)/sizeof(*menu));
|
|
||||||
if (i)
|
|
||||||
{
|
|
||||||
m = menu_init( menu, i, NULL, NULL, NULL, NULL );
|
|
||||||
result = menu_show(m);
|
|
||||||
menu_exit(m);
|
|
||||||
if (result >= 0)
|
|
||||||
ret = filetype_load_plugin((char *)menu[result].desc,selected_file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* FIX: translation! */
|
|
||||||
gui_syncsplash(HZ*2, (unsigned char *)"No viewers found");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == PLUGIN_USB_CONNECTED)
|
if (ret == PLUGIN_USB_CONNECTED)
|
||||||
onplay_result = ONPLAY_RELOAD_DIR;
|
onplay_result = ONPLAY_RELOAD_DIR;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,14 +56,16 @@
|
||||||
#define WPS_DIR ROCKBOX_DIR "/wps"
|
#define WPS_DIR ROCKBOX_DIR "/wps"
|
||||||
#define THEME_DIR ROCKBOX_DIR "/themes"
|
#define THEME_DIR ROCKBOX_DIR "/themes"
|
||||||
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
||||||
|
#define VIEWERS_DIR ROCKBOX_DIR "/viewers"
|
||||||
#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
|
#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
|
||||||
#define REC_BASE_DIR "/recordings"
|
#define REC_BASE_DIR "/recordings"
|
||||||
#define EQS_DIR ROCKBOX_DIR "/eqs"
|
#define EQS_DIR ROCKBOX_DIR "/eqs"
|
||||||
#define CODECS_DIR ROCKBOX_DIR"/codecs"
|
#define CODECS_DIR ROCKBOX_DIR"/codecs"
|
||||||
#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
|
#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
|
||||||
|
|
||||||
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
|
#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
|
||||||
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
|
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
|
||||||
|
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
|
||||||
|
|
||||||
#define MAX_FILENAME 32
|
#define MAX_FILENAME 32
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,6 @@ void browse_root(void)
|
||||||
{
|
{
|
||||||
gui_sync_wps_screen_init();
|
gui_sync_wps_screen_init();
|
||||||
|
|
||||||
filetype_init();
|
|
||||||
check_rockboxdir();
|
check_rockboxdir();
|
||||||
|
|
||||||
strcpy(tc.currdir, "/");
|
strcpy(tc.currdir, "/");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue