diff options
-rw-r--r-- | apps/open_plugin.c | 37 | ||||
-rw-r--r-- | apps/plugins/open_plugins.c | 10 |
2 files changed, 27 insertions, 20 deletions
diff --git a/apps/open_plugin.c b/apps/open_plugin.c index 46b6007ee2..1256db79f8 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c | |||
@@ -304,12 +304,8 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
304 | op_update_dat(op_entry, true); | 304 | op_update_dat(op_entry, true); |
305 | } | 305 | } |
306 | 306 | ||
307 | if (plugin) | 307 | while (plugin) |
308 | { | 308 | { |
309 | op_entry->hash = hash; | ||
310 | op_entry->lang_id = lang_id; | ||
311 | op_entry->checksum = open_plugin_csum + | ||
312 | (lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY); | ||
313 | /* name */ | 309 | /* name */ |
314 | if (path_basename(plugin, (const char **)&pos) == 0) | 310 | if (path_basename(plugin, (const char **)&pos) == 0) |
315 | pos = "\0"; | 311 | pos = "\0"; |
@@ -323,28 +319,33 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p | |||
323 | if(!parameter) | 319 | if(!parameter) |
324 | parameter = ""; | 320 | parameter = ""; |
325 | strmemccpy(op_entry->param, parameter, OPEN_PLUGIN_BUFSZ); | 321 | strmemccpy(op_entry->param, parameter, OPEN_PLUGIN_BUFSZ); |
326 | goto retnhash; | ||
327 | } | 322 | } |
328 | else if (len > OP_LEN && strcasecmp(&(pos[len-OP_LEN]), "." OP_EXT) == 0) | 323 | else if (len > OP_LEN && strcasecmp(&(pos[len-OP_LEN]), "." OP_EXT) == 0) |
329 | { | 324 | { |
325 | /* get the entry from the opx file */ | ||
330 | op_load_entry(0, OPEN_PLUGIN_LANG_IGNORE, op_entry, plugin); | 326 | op_load_entry(0, OPEN_PLUGIN_LANG_IGNORE, op_entry, plugin); |
331 | goto retnhash; | ||
332 | } | 327 | } |
328 | else | ||
329 | { | ||
330 | break; | ||
331 | } | ||
332 | op_entry->hash = hash; | ||
333 | op_entry->lang_id = lang_id; | ||
334 | op_entry->checksum = open_plugin_csum + | ||
335 | (lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY); | ||
336 | logf("OP add_path name: %s %s %s", | ||
337 | op_entry->name, op_entry->path, op_entry->param); | ||
338 | return hash; | ||
333 | } | 339 | } |
334 | 340 | ||
335 | logf("OP add_path Invalid, *Clearing entry*"); | 341 | logf("OP add_path Invalid, *Clearing entry*"); |
336 | if (lang_id != LANG_SHORTCUTS) /* from shortcuts menu */ | 342 | if (lang_id != LANG_SHORTCUTS) /* from shortcuts menu */ |
337 | splashf(HZ * 2, str(LANG_OPEN_PLUGIN_NOT_A_PLUGIN), pos); | 343 | splashf(HZ * 2, str(LANG_OPEN_PLUGIN_NOT_A_PLUGIN), pos); |
338 | op_clear_entry(op_entry); | 344 | op_clear_entry(op_entry); |
339 | hash = 0; | 345 | return 0; |
340 | |||
341 | retnhash: | ||
342 | logf("OP add_path name: %s %s %s", | ||
343 | op_entry->name, op_entry->path, op_entry->param); | ||
344 | return hash; | ||
345 | } | 346 | } |
346 | 347 | ||
347 | /* only displays directories and .rock files */ | 348 | /* only displays directories, .rock, and .opx files */ |
348 | static bool callback_show_item(char *name, int attr, struct tree_context *tc) | 349 | static bool callback_show_item(char *name, int attr, struct tree_context *tc) |
349 | { | 350 | { |
350 | (void)name; | 351 | (void)name; |
@@ -358,6 +359,10 @@ static bool callback_show_item(char *name, int attr, struct tree_context *tc) | |||
358 | { | 359 | { |
359 | return true; | 360 | return true; |
360 | } | 361 | } |
362 | else if(attr & FILE_ATTR_OPX) | ||
363 | { | ||
364 | return true; | ||
365 | } | ||
361 | return false; | 366 | return false; |
362 | } | 367 | } |
363 | 368 | ||
@@ -375,7 +380,7 @@ void open_plugin_browse(const char *key) | |||
375 | struct open_plugin_entry_t *op_entry = open_plugin_get_entry(); | 380 | struct open_plugin_entry_t *op_entry = open_plugin_get_entry(); |
376 | 381 | ||
377 | logf("OP browse key: %s name: %s", | 382 | logf("OP browse key: %s name: %s", |
378 | (key ? P2STR((unsigned char *)key):"No Key"), open_plugin_entry.name); | 383 | (key ? P2STR((unsigned char *)key):"No Key"), op_entry->name); |
379 | logf("OP browse %s %s", op_entry->path, op_entry->param); | 384 | logf("OP browse %s %s", op_entry->path, op_entry->param); |
380 | 385 | ||
381 | if (op_entry->path[0] == '\0' || !file_exists(op_entry->path)) | 386 | if (op_entry->path[0] == '\0' || !file_exists(op_entry->path)) |
@@ -399,7 +404,7 @@ void open_plugin_browse(const char *key) | |||
399 | /* open_plugin_load_entry() | 404 | /* open_plugin_load_entry() |
400 | * recall of the plugin path and parameters based on supplied key | 405 | * recall of the plugin path and parameters based on supplied key |
401 | * returns the index in OPEN_PLUGIN_DAT where the entry was found (>= 0) | 406 | * returns the index in OPEN_PLUGIN_DAT where the entry was found (>= 0) |
402 | * if the entry was found but has not been saved returns OPEN_PLUGIN_NEEDS_FLUSHED | 407 | * if the entry was found but has not been saved returns OPEN_PLUGIN_NEEDS_FLUSHED |
403 | * otherwise returns OPEN_PLUGIN_NOT_FOUND (< 0) if key was not found | 408 | * otherwise returns OPEN_PLUGIN_NOT_FOUND (< 0) if key was not found |
404 | */ | 409 | */ |
405 | int open_plugin_load_entry(const char *key) | 410 | int open_plugin_load_entry(const char *key) |
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index a4b19d558f..b608aff789 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c | |||
@@ -101,7 +101,7 @@ static bool op_entry_read(int fd, int selected_item, off_t data_sz) | |||
101 | { | 101 | { |
102 | rb->memset(&op_entry, 0, op_entry_sz); | 102 | rb->memset(&op_entry, 0, op_entry_sz); |
103 | op_entry.lang_id = -1; | 103 | op_entry.lang_id = -1; |
104 | return ((selected_item >= 0) && | 104 | return ((selected_item >= 0) && (fd >= 0) && |
105 | (rb->lseek(fd, selected_item * op_entry_sz, SEEK_SET) >= 0) && | 105 | (rb->lseek(fd, selected_item * op_entry_sz, SEEK_SET) >= 0) && |
106 | (rb->read(fd, &op_entry, data_sz) == data_sz) && op_entry_checksum() > 0); | 106 | (rb->read(fd, &op_entry, data_sz) == data_sz) && op_entry_checksum() > 0); |
107 | } | 107 | } |
@@ -196,7 +196,7 @@ static int op_entry_set_path(void) | |||
196 | 196 | ||
197 | struct browse_context browse = { | 197 | struct browse_context browse = { |
198 | .dirfilter = SHOW_ALL, | 198 | .dirfilter = SHOW_ALL, |
199 | .flags = BROWSE_SELECTONLY, | 199 | .flags = BROWSE_SELECTONLY | BROWSE_DIRFILTER, |
200 | .title = rb->str(LANG_ADD), | 200 | .title = rb->str(LANG_ADD), |
201 | .icon = Icon_Plugin, | 201 | .icon = Icon_Plugin, |
202 | .root = op_entry.path, | 202 | .root = op_entry.path, |
@@ -225,7 +225,7 @@ static int op_entry_set_param_path(void) | |||
225 | 225 | ||
226 | struct browse_context browse = { | 226 | struct browse_context browse = { |
227 | .dirfilter = SHOW_ALL, | 227 | .dirfilter = SHOW_ALL, |
228 | .flags = BROWSE_SELECTONLY, | 228 | .flags = BROWSE_SELECTONLY | BROWSE_DIRFILTER, |
229 | .title = rb->str(LANG_PARAMETER), | 229 | .title = rb->str(LANG_PARAMETER), |
230 | .icon = Icon_Plugin, | 230 | .icon = Icon_Plugin, |
231 | .root = tmp_buf, | 231 | .root = tmp_buf, |
@@ -412,6 +412,7 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
412 | { | 412 | { |
413 | rb->close(fd_tmp); | 413 | rb->close(fd_tmp); |
414 | rb->close(fd_dat); | 414 | rb->close(fd_dat); |
415 | fd_dat = -1; | ||
415 | rb->remove(OPEN_PLUGIN_DAT); | 416 | rb->remove(OPEN_PLUGIN_DAT); |
416 | rb->rename(OPEN_PLUGIN_DAT ".tmp", OPEN_PLUGIN_DAT); | 417 | rb->rename(OPEN_PLUGIN_DAT ".tmp", OPEN_PLUGIN_DAT); |
417 | } | 418 | } |
@@ -468,7 +469,7 @@ static void op_entry_remove(int selection) | |||
468 | static void op_entry_remove_empty(void) | 469 | static void op_entry_remove_empty(void) |
469 | { | 470 | { |
470 | bool resave = false; | 471 | bool resave = false; |
471 | if (fd_dat && rb->lseek(fd_dat, 0, SEEK_SET) == 0) | 472 | if (fd_dat >= 0 && rb->lseek(fd_dat, 0, SEEK_SET) == 0) |
472 | { | 473 | { |
473 | while (resave == false && | 474 | while (resave == false && |
474 | rb->read(fd_dat, &op_entry, op_entry_sz) == op_entry_sz) | 475 | rb->read(fd_dat, &op_entry, op_entry_sz) == op_entry_sz) |
@@ -489,6 +490,7 @@ static void op_entry_remove_empty(void) | |||
489 | { | 490 | { |
490 | rb->close(fd_tmp); | 491 | rb->close(fd_tmp); |
491 | rb->close(fd_dat); | 492 | rb->close(fd_dat); |
493 | fd_dat = -1; | ||
492 | rb->remove(OPEN_PLUGIN_DAT); | 494 | rb->remove(OPEN_PLUGIN_DAT); |
493 | rb->rename(OPEN_PLUGIN_DAT ".tmp", OPEN_PLUGIN_DAT); | 495 | rb->rename(OPEN_PLUGIN_DAT ".tmp", OPEN_PLUGIN_DAT); |
494 | } | 496 | } |