Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Open_Plugins Add Features

Added an entry 'Add' to the main screen to lessen confusion

side note:
its actually a shortcut back to this plugin with flag '-add'
passed as a parameter

Change-Id: Ifeb0a1e5be99764b1d25d5a3b0e00f1449ec3d78

authored by

William Wilgus and committed by
William Wilgus
87ad55b0 f647cde3

+43 -12
+43 -12
apps/plugins/open_plugins.c
··· 51 51 /* we only need the names for the first menu so don't bother reading paths yet */ 52 52 const off_t op_name_sz = OPEN_PLUGIN_NAMESZ + (op_entry.name - (char*)&op_entry); 53 53 54 - static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter); 54 + static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key); 55 55 56 56 static bool _yesno_pop(const char* text) 57 57 { ··· 175 175 if (op_entry.path[0] == '\0') 176 176 rb->strcpy(op_entry.path, PLUGIN_DIR"/"); 177 177 178 - rb->browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, "", 178 + rb->browse_context_init(&browse, SHOW_ALL, BROWSE_SELECTONLY, rb->str(LANG_ADD), 179 179 Icon_Plugin, op_entry.path, NULL); 180 180 181 181 browse.buf = tmp_buf; ··· 289 289 return entries + 1; 290 290 } 291 291 292 - static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter) 292 + static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) 293 293 { 294 - int len; 294 + int len, extlen; 295 295 uint32_t hash; 296 296 char *pos = "";; 297 297 int fd_tmp = -1; 298 + use_key = (use_key == true && key != NULL); 298 299 299 300 if (key) 300 301 { ··· 313 314 if (plugin) 314 315 { 315 316 /* name */ 317 + if (use_key) 318 + { 319 + op_entry.lang_id = -1; 320 + rb->strlcpy(op_entry.name, key, OPEN_PLUGIN_NAMESZ); 321 + } 322 + 316 323 if (pathbasename(plugin, (const char **)&pos) == 0) 317 324 pos = "\0"; 318 325 if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) 319 326 rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); 320 327 321 328 len = rb->strlen(pos); 322 - if(len > 5 && rb->strcasecmp(&(pos[len-5]), "." ROCK_EXT) == 0) 329 + extlen = rb->strlen("." ROCK_EXT); 330 + if(len > extlen && rb->strcasecmp(&(pos[len-extlen]), "." ROCK_EXT) == 0) 323 331 { 324 332 fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); 325 333 if (fd_tmp < 0) ··· 398 406 else 399 407 key = op_entry.path; 400 408 401 - op_entry_add_path(key, op_entry.path, NULL); 409 + op_entry_add_path(key, op_entry.path, NULL, false); 402 410 } 403 411 } 404 412 ··· 681 689 if (param[0] == '\0') 682 690 param = NULL; 683 691 684 - op_entry_add_path(NULL, op_entry.path, param); 692 + op_entry_add_path(NULL, op_entry.path, param, false); 685 693 fd_dat = rb->open(OPEN_PLUGIN_DAT, O_RDWR, 0666); 686 694 } 687 695 } ··· 737 745 bool exit = false; 738 746 739 747 const int creat_flags = O_RDWR | O_CREAT; 748 + 749 + reopen_datfile: 740 750 fd_dat = rb->open(OPEN_PLUGIN_DAT, creat_flags, 0666); 741 751 if (!fd_dat) 742 752 exit = true; 743 753 744 754 items = rb->lseek(fd_dat, 0, SEEK_END) / op_entry_sz; 755 + if (parameter) 756 + { 757 + path = (char*)parameter; 758 + while (path[0] == ' ') 759 + path++; 760 + 761 + if (strncasecmp(path, "-add", 4) == 0) 762 + { 763 + parameter = NULL; 764 + op_entry_browse_add(-1); 765 + rb->close(fd_dat); 766 + goto reopen_datfile; 767 + } 768 + } 745 769 746 770 if (parameter) 747 771 { ··· 781 805 else 782 806 { 783 807 op_entry_read(fd_dat, selection, op_entry_sz); 784 - if (op_entry_add_path(parameter, parameter, "\0") > 0) 808 + if (op_entry_add_path(parameter, parameter, "\0", false) > 0) 785 809 { 786 810 selection = 0; 787 811 items++; ··· 792 816 } 793 817 }/* OP_EXT */ 794 818 } 795 - 796 - if (items == 0 && !exit) 819 + 820 + if (items < 1 && !exit) 797 821 { 798 - rb->plugin_open(rb->plugin_get_current_filename(), NULL); 822 + char* cur_filename = rb->plugin_get_current_filename(); 823 + 824 + if (op_entry_add_path(rb->str(LANG_ADD), cur_filename, "-add", true)) 825 + { 826 + rb->close(fd_dat); 827 + parameter = NULL; 828 + goto reopen_datfile; 829 + } 799 830 rb->close(fd_dat); 800 - return PLUGIN_GOTO_PLUGIN; 831 + return PLUGIN_ERROR; 801 832 } 802 833 803 834