From ee840709d3d93376f9b5da6c34572424079304b8 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 6 May 2024 16:39:57 -0400 Subject: [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 --- apps/plugins/imageviewer/imageviewer.c | 4 +--- apps/plugins/open_plugins.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'apps/plugins') 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) long greysize; /* helper */ #endif - if(!parameter) return PLUGIN_ERROR; + if(!parameter) {rb->splash(HZ*2, "No file"); return PLUGIN_ERROR; } rb->strcpy(np_file, parameter); if (get_image_type(np_file, false) == IMAGE_UNKNOWN) @@ -1051,8 +1051,6 @@ enum plugin_status plugin_start(const void* parameter) get_pic_list(); - if(!entries) return PLUGIN_ERROR; - #ifdef USEGSLIB if (!grey_init(buf, buf_size, GREY_ON_COP, 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) int fd_opx; int len; - len = rb->strlen(path); - if(len > OP_LEN && rb->strcasecmp(&((path)[len-OP_LEN]), "." OP_EXT) == 0) + if(rb->filetype_get_attr(path) == FILE_ATTR_OPX) { fd_opx = rb->open(path, O_RDONLY); if (fd_opx >= 0) @@ -317,6 +316,7 @@ static int op_entry_transfer(int fd, int fd_tmp, static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) { + char buf[MAX_PATH]; int len; uint32_t hash; uint32_t newhash; @@ -339,8 +339,11 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha else hash = op_entry.hash; + + if (plugin) { + int fattr = rb->filetype_get_attr(plugin); /* name */ if (use_key) { @@ -353,8 +356,21 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); - len = rb->strlen(pos); - if(len > ROCK_LEN && rb->strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) + + + if ((!parameter || parameter[0] == '\0') && fattr != FILE_ATTR_ROCK && fattr != FILE_ATTR_OPX) + { + rb->strlcpy(op_entry.param, plugin, OPEN_PLUGIN_BUFSZ); + parameter = op_entry.param; + plugin = rb->filetype_get_plugin(fattr, buf, sizeof(buf)); + if (!plugin) + { + rb->splashf(HZ * 2, rb->str(LANG_OPEN_PLUGIN_NOT_A_PLUGIN), pos); + return 0; + } + } + + if(fattr == FILE_ATTR_ROCK) { fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd_tmp < 0) -- cgit v1.2.3