diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetree.c | 2 | ||||
-rw-r--r-- | apps/filetypes.c | 4 | ||||
-rw-r--r-- | apps/filetypes.h | 2 | ||||
-rw-r--r-- | apps/open_plugin.c | 31 | ||||
-rw-r--r-- | apps/plugin.c | 1 | ||||
-rw-r--r-- | apps/plugin.h | 1 | ||||
-rw-r--r-- | apps/plugins/imageviewer/imageviewer.c | 4 | ||||
-rw-r--r-- | apps/plugins/open_plugins.c | 24 |
8 files changed, 49 insertions, 20 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 594a0bd6f1..9550adbac2 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -755,7 +755,7 @@ int ft_enter(struct tree_context* c) | |||
755 | return rc; | 755 | return rc; |
756 | } | 756 | } |
757 | 757 | ||
758 | plugin = filetype_get_plugin(file, plugin_path, sizeof(plugin_path)); | 758 | plugin = filetype_get_plugin(file->attr, plugin_path, sizeof(plugin_path)); |
759 | if (plugin) | 759 | if (plugin) |
760 | { | 760 | { |
761 | #ifdef PLUGINS_RUN_IN_BROWSER /* Stay in the filetree to run a plugin */ | 761 | #ifdef PLUGINS_RUN_IN_BROWSER /* Stay in the filetree to run a plugin */ |
diff --git a/apps/filetypes.c b/apps/filetypes.c index bda7018381..e992b86060 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -604,9 +604,9 @@ int filetype_get_icon(int attr) | |||
604 | return filetypes[index].icon; | 604 | return filetypes[index].icon; |
605 | } | 605 | } |
606 | 606 | ||
607 | char* filetype_get_plugin(const struct entry* file, char *buffer, size_t buffer_len) | 607 | char* filetype_get_plugin(int attr, char *buffer, size_t buffer_len) |
608 | { | 608 | { |
609 | int index = find_attr(file->attr); | 609 | int index = find_attr(attr); |
610 | if (index < 0 || !buffer) | 610 | if (index < 0 || !buffer) |
611 | return NULL; | 611 | return NULL; |
612 | struct file_type *ft_indexed = &filetypes[index]; | 612 | struct file_type *ft_indexed = &filetypes[index]; |
diff --git a/apps/filetypes.h b/apps/filetypes.h index 2886fa2850..36d9009a87 100644 --- a/apps/filetypes.h +++ b/apps/filetypes.h | |||
@@ -74,7 +74,7 @@ int filetype_get_color(const char* name, int attr); | |||
74 | #endif | 74 | #endif |
75 | int filetype_get_icon(int attr); | 75 | int filetype_get_icon(int attr); |
76 | /* return the plugin filename associated with the file */ | 76 | /* return the plugin filename associated with the file */ |
77 | char* filetype_get_plugin(const struct entry* file, char *buffer, size_t buffer_len); | 77 | char* filetype_get_plugin(int attr, char *buffer, size_t buffer_len); |
78 | 78 | ||
79 | /* returns true if the attr is supported */ | 79 | /* returns true if the attr is supported */ |
80 | bool filetype_supported(int attr); | 80 | bool filetype_supported(int attr); |
diff --git a/apps/open_plugin.c b/apps/open_plugin.c index afe59b38e3..e10463d260 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c | |||
@@ -26,16 +26,12 @@ | |||
26 | #include "pathfuncs.h" | 26 | #include "pathfuncs.h" |
27 | #include "splash.h" | 27 | #include "splash.h" |
28 | #include "lang.h" | 28 | #include "lang.h" |
29 | #include "filetypes.h" | ||
29 | 30 | ||
30 | /* Define LOGF_ENABLE to enable logf output in this file */ | 31 | /* Define LOGF_ENABLE to enable logf output in this file */ |
31 | /*#define LOGF_ENABLE*/ | 32 | /*#define LOGF_ENABLE*/ |
32 | #include "logf.h" | 33 | #include "logf.h" |
33 | 34 | ||
34 | #define ROCK_EXT "rock" | ||
35 | #define ROCK_LEN sizeof(ROCK_EXT) | ||
36 | #define OP_EXT "opx" | ||
37 | #define OP_LEN sizeof(OP_EXT) | ||
38 | |||
39 | static const uint32_t open_plugin_csum = OPEN_PLUGIN_CHECKSUM; | 35 | static const uint32_t open_plugin_csum = OPEN_PLUGIN_CHECKSUM; |
40 | 36 | ||
41 | static const int op_entry_sz = sizeof(struct open_plugin_entry_t); | 37 | static const int op_entry_sz = sizeof(struct open_plugin_entry_t); |
@@ -279,7 +275,6 @@ struct open_plugin_entry_t * open_plugin_get_entry(void) | |||
279 | */ | 275 | */ |
280 | uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter) | 276 | uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter) |
281 | { | 277 | { |
282 | size_t len; | ||
283 | uint32_t hash; | 278 | uint32_t hash; |
284 | int32_t lang_id; | 279 | int32_t lang_id; |
285 | char *pos = "\0"; | 280 | char *pos = "\0"; |
@@ -306,12 +301,15 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
306 | 301 | ||
307 | while (plugin) | 302 | while (plugin) |
308 | { | 303 | { |
304 | int fattr = filetype_get_attr(plugin); | ||
305 | |||
309 | /* name */ | 306 | /* name */ |
310 | if (path_basename(plugin, (const char **)&pos) == 0) | 307 | if (path_basename(plugin, (const char **)&pos) == 0) |
311 | pos = "\0"; | 308 | pos = "\0"; |
312 | 309 | ||
313 | len = strlcpy(op_entry->name, pos, OPEN_PLUGIN_NAMESZ); | 310 | strlcpy(op_entry->name, pos, OPEN_PLUGIN_NAMESZ); |
314 | if (len > ROCK_LEN && strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) | 311 | |
312 | if (fattr == FILE_ATTR_ROCK) | ||
315 | { | 313 | { |
316 | /* path */ | 314 | /* path */ |
317 | strmemccpy(op_entry->path, plugin, OPEN_PLUGIN_BUFSZ); | 315 | strmemccpy(op_entry->path, plugin, OPEN_PLUGIN_BUFSZ); |
@@ -320,11 +318,21 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
320 | parameter = ""; | 318 | parameter = ""; |
321 | strmemccpy(op_entry->param, parameter, OPEN_PLUGIN_BUFSZ); | 319 | strmemccpy(op_entry->param, parameter, OPEN_PLUGIN_BUFSZ); |
322 | } | 320 | } |
323 | else if (len > OP_LEN && strcasecmp(&(pos[len-OP_LEN]), "." OP_EXT) == 0) | 321 | else if (fattr == FILE_ATTR_OPX) |
324 | { | 322 | { |
325 | /* get the entry from the opx file */ | 323 | /* get the entry from the opx file */ |
326 | op_load_entry(0, OPEN_PLUGIN_LANG_IGNORE, op_entry, plugin); | 324 | op_load_entry(0, OPEN_PLUGIN_LANG_IGNORE, op_entry, plugin); |
327 | } | 325 | } |
326 | else if(!parameter) | ||
327 | { | ||
328 | strmemccpy(op_entry->param, plugin, OPEN_PLUGIN_BUFSZ); | ||
329 | plugin = filetype_get_plugin(fattr, op_entry->path, OPEN_PLUGIN_BUFSZ); | ||
330 | if (!plugin) | ||
331 | { | ||
332 | logf("OP no plugin found to run %s", op_entry->param); | ||
333 | break; | ||
334 | } | ||
335 | } | ||
328 | else | 336 | else |
329 | { | 337 | { |
330 | break; | 338 | break; |
@@ -349,6 +357,8 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
349 | static bool callback_show_item(char *name, int attr, struct tree_context *tc) | 357 | static bool callback_show_item(char *name, int attr, struct tree_context *tc) |
350 | { | 358 | { |
351 | (void)name; | 359 | (void)name; |
360 | (void)tc; | ||
361 | #if 0 | ||
352 | if(attr & ATTR_DIRECTORY) | 362 | if(attr & ATTR_DIRECTORY) |
353 | { | 363 | { |
354 | if (strstr(tc->currdir, PLUGIN_DIR) != NULL) | 364 | if (strstr(tc->currdir, PLUGIN_DIR) != NULL) |
@@ -364,6 +374,9 @@ static bool callback_show_item(char *name, int attr, struct tree_context *tc) | |||
364 | return true; | 374 | return true; |
365 | } | 375 | } |
366 | return false; | 376 | return false; |
377 | #endif | ||
378 | return attr & ATTR_DIRECTORY || | ||
379 | (filetype_supported(attr) && (attr & FILE_ATTR_AUDIO) == 0); | ||
367 | } | 380 | } |
368 | 381 | ||
369 | /* open_plugin_browse() | 382 | /* open_plugin_browse() |
diff --git a/apps/plugin.c b/apps/plugin.c index bd93cb8b5c..931b8f1fd4 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -837,6 +837,7 @@ static const struct plugin_api rockbox_api = { | |||
837 | #endif | 837 | #endif |
838 | playlist_get_first_index, | 838 | playlist_get_first_index, |
839 | playlist_get_display_index, | 839 | playlist_get_display_index, |
840 | filetype_get_plugin, | ||
840 | }; | 841 | }; |
841 | 842 | ||
842 | static int plugin_buffer_handle; | 843 | static int plugin_buffer_handle; |
diff --git a/apps/plugin.h b/apps/plugin.h index 24eb28b2bd..df519f28cf 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -974,6 +974,7 @@ struct plugin_api { | |||
974 | #endif | 974 | #endif |
975 | int (*playlist_get_first_index)(const struct playlist_info* playlist); | 975 | int (*playlist_get_first_index)(const struct playlist_info* playlist); |
976 | int (*playlist_get_display_index)(void); | 976 | int (*playlist_get_display_index)(void); |
977 | char* (*filetype_get_plugin)(int attr, char *buffer, size_t buffer_len); | ||
977 | }; | 978 | }; |
978 | 979 | ||
979 | /* plugin header */ | 980 | /* plugin header */ |
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c index d1a512c4fd..9d5aea7f15 100644 --- a/apps/plugins/imageviewer/imageviewer.c +++ b/apps/plugins/imageviewer/imageviewer.c | |||
@@ -1033,7 +1033,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
1033 | long greysize; /* helper */ | 1033 | long greysize; /* helper */ |
1034 | #endif | 1034 | #endif |
1035 | 1035 | ||
1036 | if(!parameter) return PLUGIN_ERROR; | 1036 | if(!parameter) {rb->splash(HZ*2, "No file"); return PLUGIN_ERROR; } |
1037 | 1037 | ||
1038 | rb->strcpy(np_file, parameter); | 1038 | rb->strcpy(np_file, parameter); |
1039 | if (get_image_type(np_file, false) == IMAGE_UNKNOWN) | 1039 | if (get_image_type(np_file, false) == IMAGE_UNKNOWN) |
@@ -1051,8 +1051,6 @@ enum plugin_status plugin_start(const void* parameter) | |||
1051 | 1051 | ||
1052 | get_pic_list(); | 1052 | get_pic_list(); |
1053 | 1053 | ||
1054 | if(!entries) return PLUGIN_ERROR; | ||
1055 | |||
1056 | #ifdef USEGSLIB | 1054 | #ifdef USEGSLIB |
1057 | if (!grey_init(buf, buf_size, GREY_ON_COP, | 1055 | if (!grey_init(buf, buf_size, GREY_ON_COP, |
1058 | LCD_WIDTH, LCD_HEIGHT, &greysize)) | 1056 | LCD_WIDTH, LCD_HEIGHT, &greysize)) |
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index b608aff789..9d58433fdf 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c | |||
@@ -118,8 +118,7 @@ static int op_entry_read_opx(const char *path) | |||
118 | int fd_opx; | 118 | int fd_opx; |
119 | int len; | 119 | int len; |
120 | 120 | ||
121 | len = rb->strlen(path); | 121 | if(rb->filetype_get_attr(path) == FILE_ATTR_OPX) |
122 | if(len > OP_LEN && rb->strcasecmp(&((path)[len-OP_LEN]), "." OP_EXT) == 0) | ||
123 | { | 122 | { |
124 | fd_opx = rb->open(path, O_RDONLY); | 123 | fd_opx = rb->open(path, O_RDONLY); |
125 | if (fd_opx >= 0) | 124 | if (fd_opx >= 0) |
@@ -317,6 +316,7 @@ static int op_entry_transfer(int fd, int fd_tmp, | |||
317 | 316 | ||
318 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) | 317 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) |
319 | { | 318 | { |
319 | char buf[MAX_PATH]; | ||
320 | int len; | 320 | int len; |
321 | uint32_t hash; | 321 | uint32_t hash; |
322 | uint32_t newhash; | 322 | uint32_t newhash; |
@@ -339,8 +339,11 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
339 | else | 339 | else |
340 | hash = op_entry.hash; | 340 | hash = op_entry.hash; |
341 | 341 | ||
342 | |||
343 | |||
342 | if (plugin) | 344 | if (plugin) |
343 | { | 345 | { |
346 | int fattr = rb->filetype_get_attr(plugin); | ||
344 | /* name */ | 347 | /* name */ |
345 | if (use_key) | 348 | if (use_key) |
346 | { | 349 | { |
@@ -353,8 +356,21 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
353 | if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) | 356 | if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) |
354 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); | 357 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); |
355 | 358 | ||
356 | len = rb->strlen(pos); | 359 | |
357 | if(len > ROCK_LEN && rb->strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) | 360 | |
361 | if ((!parameter || parameter[0] == '\0') && fattr != FILE_ATTR_ROCK && fattr != FILE_ATTR_OPX) | ||
362 | { | ||
363 | rb->strlcpy(op_entry.param, plugin, OPEN_PLUGIN_BUFSZ); | ||
364 | parameter = op_entry.param; | ||
365 | plugin = rb->filetype_get_plugin(fattr, buf, sizeof(buf)); | ||
366 | if (!plugin) | ||
367 | { | ||
368 | rb->splashf(HZ * 2, rb->str(LANG_OPEN_PLUGIN_NOT_A_PLUGIN), pos); | ||
369 | return 0; | ||
370 | } | ||
371 | } | ||
372 | |||
373 | if(fattr == FILE_ATTR_ROCK) | ||
358 | { | 374 | { |
359 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); | 375 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); |
360 | if (fd_tmp < 0) | 376 | if (fd_tmp < 0) |