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
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 <tree.h>
|
||||
#include <menu.h>
|
||||
|
||||
int filetype_get_attr(const char*);
|
||||
#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*);
|
||||
/* init the filetypes structs.
|
||||
uses audio buffer for storage, so call early in init... */
|
||||
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 {
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
const unsigned char* icon; /* the icon which shall be used for it, NULL if unknown */
|
||||
#else
|
||||
int icon; /* the icon which shall be used for it, -1 if unknown */
|
||||
#endif
|
||||
char* plugin; /* Which plugin to use, NULL if unknown */
|
||||
bool no_extension;
|
||||
};
|
||||
/* Return the attribute (TREE_ATTR_*) of the file */
|
||||
int filetype_get_attr(const char* file);
|
||||
ICON filetype_get_icon(int attr);
|
||||
/* return the plugin filename associated with the file */
|
||||
char* filetype_get_plugin(const struct entry* file);
|
||||
|
||||
/* returns true if the attr is supported */
|
||||
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
|
||||
|
|
|
@ -24,9 +24,11 @@
|
|||
* char-based displays and bitmap displays */
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
typedef const unsigned char * ICON;
|
||||
typedef unsigned char * ICON_NO_CONST;
|
||||
#define NOICON NULL
|
||||
#else
|
||||
typedef long ICON;
|
||||
#define ICON_NO_CONST ICON
|
||||
#define NOICON -1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "kernel.h"
|
||||
#include "button.h"
|
||||
#include "tree.h"
|
||||
#include "filetypes.h"
|
||||
#include "panic.h"
|
||||
#include "menu.h"
|
||||
#include "system.h"
|
||||
|
@ -258,6 +259,7 @@ static void init(void)
|
|||
#endif
|
||||
sleep(HZ/2);
|
||||
tree_init();
|
||||
filetype_init();
|
||||
playlist_init();
|
||||
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
|
@ -490,6 +492,7 @@ static void init(void)
|
|||
status_init();
|
||||
playlist_init();
|
||||
tree_init();
|
||||
filetype_init();
|
||||
scrobbler_init();
|
||||
cuesheet_init();
|
||||
|
||||
|
|
|
@ -125,28 +125,9 @@ static bool bookmark_menu(void)
|
|||
|
||||
static bool list_viewers(void)
|
||||
{
|
||||
struct menu_item menu[16];
|
||||
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");
|
||||
}
|
||||
|
||||
int ret = filetype_list_viewers(selected_file);
|
||||
if (ret == PLUGIN_USB_CONNECTED)
|
||||
onplay_result = ONPLAY_RELOAD_DIR;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,14 +56,16 @@
|
|||
#define WPS_DIR ROCKBOX_DIR "/wps"
|
||||
#define THEME_DIR ROCKBOX_DIR "/themes"
|
||||
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
||||
#define VIEWERS_DIR ROCKBOX_DIR "/viewers"
|
||||
#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
|
||||
#define REC_BASE_DIR "/recordings"
|
||||
#define EQS_DIR ROCKBOX_DIR "/eqs"
|
||||
#define CODECS_DIR ROCKBOX_DIR"/codecs"
|
||||
#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
|
||||
|
||||
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
|
||||
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
|
||||
#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
|
||||
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
|
||||
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
|
||||
|
||||
#define MAX_FILENAME 32
|
||||
|
||||
|
|
|
@ -259,7 +259,6 @@ void browse_root(void)
|
|||
{
|
||||
gui_sync_wps_screen_init();
|
||||
|
||||
filetype_init();
|
||||
check_rockboxdir();
|
||||
|
||||
strcpy(tc.currdir, "/");
|
||||
|
|
Loading…
Reference in New Issue