diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-03-07 08:22:01 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-03-07 08:22:01 -0500 |
commit | 0dce97372987a0b25446c33c7bfd616780d9d7c0 (patch) | |
tree | 6bdfc7a0d52f6822080d94fba2095b12cf7a5d46 /apps | |
parent | 207514fb2578cfac611b4ab98b251d1524a55efe (diff) | |
download | rockbox-0dce97372987a0b25446c33c7bfd616780d9d7c0.tar.gz rockbox-0dce97372987a0b25446c33c7bfd616780d9d7c0.zip |
OpenPlugins Allow opx shortcuts
Allow opx shortcuts to be run through the shortcut menu
Change-Id: I6597b9485dfb224766c442257c4d9c8ac02eece4
Diffstat (limited to 'apps')
-rw-r--r-- | apps/open_plugin.c | 33 | ||||
-rw-r--r-- | apps/plugins/open_plugins.c | 16 |
2 files changed, 36 insertions, 13 deletions
diff --git a/apps/open_plugin.c b/apps/open_plugin.c index 61778e1ce7..7448018ed9 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c | |||
@@ -27,6 +27,11 @@ | |||
27 | #include "splash.h" | 27 | #include "splash.h" |
28 | #include "lang.h" | 28 | #include "lang.h" |
29 | 29 | ||
30 | #define ROCK_EXT "rock" | ||
31 | #define ROCK_LEN 5 | ||
32 | #define OP_EXT "opx" | ||
33 | #define OP_LEN 4 | ||
34 | |||
30 | struct open_plugin_entry_t open_plugin_entry; | 35 | struct open_plugin_entry_t open_plugin_entry; |
31 | 36 | ||
32 | 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); |
@@ -34,9 +39,11 @@ static const int op_entry_sz = sizeof(struct open_plugin_entry_t); | |||
34 | uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter) | 39 | uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter) |
35 | { | 40 | { |
36 | int len; | 41 | int len; |
42 | bool is_valid = false; | ||
37 | uint32_t hash; | 43 | uint32_t hash; |
38 | char *pos; | 44 | char *pos; |
39 | int fd = 0; | 45 | int fd = 0; |
46 | int fd1 = 0; | ||
40 | 47 | ||
41 | /*strlcpy(plug_entry.key, key, sizeof(plug_entry.key));*/ | 48 | /*strlcpy(plug_entry.key, key, sizeof(plug_entry.key));*/ |
42 | open_plugin_entry.lang_id = P2ID((unsigned char*)key); | 49 | open_plugin_entry.lang_id = P2ID((unsigned char*)key); |
@@ -52,12 +59,9 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
52 | pos = "\0"; | 59 | pos = "\0"; |
53 | 60 | ||
54 | len = strlcpy(open_plugin_entry.name, pos, OPEN_PLUGIN_NAMESZ); | 61 | len = strlcpy(open_plugin_entry.name, pos, OPEN_PLUGIN_NAMESZ); |
55 | 62 | if (len > ROCK_LEN && strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) | |
56 | if(len > 5 && strcasecmp(&(pos[len-5]), ".rock") == 0) | ||
57 | { | 63 | { |
58 | fd = open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); | 64 | is_valid = true; |
59 | if (!fd) | ||
60 | return 0; | ||
61 | 65 | ||
62 | /* path */ | 66 | /* path */ |
63 | strlcpy(open_plugin_entry.path, plugin, OPEN_PLUGIN_BUFSZ); | 67 | strlcpy(open_plugin_entry.path, plugin, OPEN_PLUGIN_BUFSZ); |
@@ -66,9 +70,26 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
66 | strlcpy(open_plugin_entry.param, parameter, OPEN_PLUGIN_BUFSZ); | 70 | strlcpy(open_plugin_entry.param, parameter, OPEN_PLUGIN_BUFSZ); |
67 | else | 71 | else |
68 | open_plugin_entry.param[0] = '\0'; | 72 | open_plugin_entry.param[0] = '\0'; |
73 | } | ||
74 | else if (len > OP_LEN && strcasecmp(&(pos[len-OP_LEN]), "." OP_EXT) == 0) | ||
75 | { | ||
76 | is_valid = true; | ||
77 | /* path */ | ||
78 | strlcpy(open_plugin_entry.path, | ||
79 | VIEWERS_DATA_DIR "/open_plugins." ROCK_EXT, OPEN_PLUGIN_BUFSZ); | ||
80 | /* parameter */ | ||
81 | strlcpy(open_plugin_entry.param, plugin, OPEN_PLUGIN_BUFSZ); | ||
69 | 82 | ||
70 | write(fd, &open_plugin_entry, op_entry_sz); | 83 | write(fd, &open_plugin_entry, op_entry_sz); |
71 | } | 84 | } |
85 | |||
86 | if (is_valid) | ||
87 | { | ||
88 | fd = open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
89 | if (!fd) | ||
90 | return 0; | ||
91 | write(fd, &open_plugin_entry, op_entry_sz); | ||
92 | } | ||
72 | else | 93 | else |
73 | { | 94 | { |
74 | if (open_plugin_entry.lang_id != LANG_SHORTCUTS) | 95 | if (open_plugin_entry.lang_id != LANG_SHORTCUTS) |
@@ -77,7 +98,7 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
77 | } | 98 | } |
78 | } | 99 | } |
79 | 100 | ||
80 | int fd1 = open(OPEN_PLUGIN_DAT, O_RDONLY); | 101 | fd1 = open(OPEN_PLUGIN_DAT, O_RDONLY); |
81 | if (fd1) | 102 | if (fd1) |
82 | { | 103 | { |
83 | while (read(fd1, &open_plugin_entry, op_entry_sz) == op_entry_sz) | 104 | while (read(fd1, &open_plugin_entry, op_entry_sz) == op_entry_sz) |
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index 0e636a7097..f9133f91bb 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c | |||
@@ -36,7 +36,10 @@ | |||
36 | #include "../open_plugin.h" | 36 | #include "../open_plugin.h" |
37 | 37 | ||
38 | #define ROCK_EXT "rock" | 38 | #define ROCK_EXT "rock" |
39 | #define ROCK_LEN 5 | ||
40 | |||
39 | #define OP_EXT "opx" | 41 | #define OP_EXT "opx" |
42 | #define OP_LEN 4 | ||
40 | 43 | ||
41 | #define OP_PLUGIN_RESTART (PLUGIN_GOTO_PLUGIN | 0x8000) | 44 | #define OP_PLUGIN_RESTART (PLUGIN_GOTO_PLUGIN | 0x8000) |
42 | 45 | ||
@@ -106,7 +109,7 @@ static int op_entry_read_opx(const char *path) | |||
106 | int len; | 109 | int len; |
107 | 110 | ||
108 | len = rb->strlen(path); | 111 | len = rb->strlen(path); |
109 | if(len > 4 && rb->strcasecmp(&((path)[len-4]), "." OP_EXT) == 0) | 112 | if(len > OP_LEN && rb->strcasecmp(&((path)[len-OP_LEN]), "." OP_EXT) == 0) |
110 | { | 113 | { |
111 | fd_opx = rb->open(path, O_RDONLY); | 114 | fd_opx = rb->open(path, O_RDONLY); |
112 | if (fd_opx) | 115 | if (fd_opx) |
@@ -136,8 +139,8 @@ static void op_entry_export(int selection) | |||
136 | if( !rb->kbd_input( filename, MAX_PATH, NULL ) ) | 139 | if( !rb->kbd_input( filename, MAX_PATH, NULL ) ) |
137 | { | 140 | { |
138 | len = rb->strlen(filename); | 141 | len = rb->strlen(filename); |
139 | if(len > 4 && filename[len] != PATH_SEPCH && | 142 | if(len > OP_LEN && filename[len] != PATH_SEPCH && |
140 | rb->strcasecmp(&((filename)[len-4]), "." OP_EXT) != 0) | 143 | rb->strcasecmp(&((filename)[len-OP_LEN]), "." OP_EXT) != 0) |
141 | { | 144 | { |
142 | rb->strcat(filename, "." OP_EXT); | 145 | rb->strcat(filename, "." OP_EXT); |
143 | } | 146 | } |
@@ -291,7 +294,7 @@ static int op_entry_transfer(int fd, int fd_tmp, | |||
291 | 294 | ||
292 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) | 295 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) |
293 | { | 296 | { |
294 | int len, extlen; | 297 | int len; |
295 | uint32_t hash; | 298 | uint32_t hash; |
296 | char *pos = "";; | 299 | char *pos = "";; |
297 | int fd_tmp = -1; | 300 | int fd_tmp = -1; |
@@ -326,8 +329,7 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
326 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); | 329 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); |
327 | 330 | ||
328 | len = rb->strlen(pos); | 331 | len = rb->strlen(pos); |
329 | extlen = rb->strlen("." ROCK_EXT); | 332 | if(len > ROCK_LEN && rb->strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) |
330 | if(len > extlen && rb->strcasecmp(&(pos[len-extlen]), "." ROCK_EXT) == 0) | ||
331 | { | 333 | { |
332 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); | 334 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); |
333 | if (fd_tmp < 0) | 335 | if (fd_tmp < 0) |
@@ -478,7 +480,7 @@ static int op_entry_run(void) | |||
478 | char* param; | 480 | char* param; |
479 | if (op_entry.hash != 0 && op_entry.path[0] != '\0') | 481 | if (op_entry.hash != 0 && op_entry.path[0] != '\0') |
480 | { | 482 | { |
481 | rb->splash(1, ID2P(LANG_OPEN_PLUGIN)); | 483 | //rb->splash(1, ID2P(LANG_OPEN_PLUGIN)); |
482 | path = op_entry.path; | 484 | path = op_entry.path; |
483 | param = op_entry.param; | 485 | param = op_entry.param; |
484 | if (param[0] == '\0') | 486 | if (param[0] == '\0') |