diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-05-06 16:39:57 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-05-06 17:27:25 -0400 |
commit | ee840709d3d93376f9b5da6c34572424079304b8 (patch) | |
tree | 2357bb53651524d1cc5dd386fb32ddba15e7be0d /apps/open_plugin.c | |
parent | 30482bd9087444c434ee4c4cc1756ca9a402f5ad (diff) | |
download | rockbox-ee840709d3d93376f9b5da6c34572424079304b8.tar.gz rockbox-ee840709d3d93376f9b5da6c34572424079304b8.zip |
[Feature] Open plugins now recognizes known filetypes and can run them
now you can run your lua files without having to add the viewer to
the shortcut or if you want a bmp file to be displayed when you start
the device that can be done as well
Change-Id: Ia56b566789623a2ca78d9e4583086db6e2cd689b
Diffstat (limited to 'apps/open_plugin.c')
-rw-r--r-- | apps/open_plugin.c | 31 |
1 files changed, 22 insertions, 9 deletions
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() |