diff options
-rw-r--r-- | apps/filetree.c | 25 | ||||
-rw-r--r-- | apps/filetypes.c | 39 |
2 files changed, 34 insertions, 30 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 66e4a68398..efe5e80a0f 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -629,33 +629,19 @@ int ft_enter(struct tree_context* c) | |||
629 | rolo_load(buf); | 629 | rolo_load(buf); |
630 | break; | 630 | break; |
631 | #endif | 631 | #endif |
632 | case FILE_ATTR_CUE: | ||
633 | display_cuesheet_content(buf); | ||
634 | break; | ||
632 | 635 | ||
633 | /* plugin file */ | 636 | /* plugin file */ |
634 | case FILE_ATTR_ROCK: | 637 | case FILE_ATTR_ROCK: |
635 | case FILE_ATTR_LUA: | ||
636 | case FILE_ATTR_OPX: | ||
637 | { | 638 | { |
638 | char *plugin = buf, *argument = NULL; | 639 | char *plugin = buf, *argument = NULL; |
639 | char plugin_path[MAX_PATH]; | ||
640 | int ret; | ||
641 | |||
642 | if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { | ||
643 | snprintf(plugin_path, sizeof(plugin_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ | ||
644 | plugin = plugin_path; | ||
645 | argument = buf; | ||
646 | } | ||
647 | else if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_OPX) { | ||
648 | snprintf(plugin_path, sizeof(plugin_path)-1, "%s/open_plugins.rock", VIEWERS_DIR); /* Use a #define here ? */ | ||
649 | plugin = plugin_path; | ||
650 | argument = buf; | ||
651 | } | ||
652 | |||
653 | if (global_settings.party_mode && audio_status()) { | 640 | if (global_settings.party_mode && audio_status()) { |
654 | splash(HZ, ID2P(LANG_PARTY_MODE)); | 641 | splash(HZ, ID2P(LANG_PARTY_MODE)); |
655 | break; | 642 | break; |
656 | } | 643 | } |
657 | ret = plugin_load(plugin, argument); | 644 | switch (plugin_load(plugin, argument)) |
658 | switch (ret) | ||
659 | { | 645 | { |
660 | case PLUGIN_GOTO_WPS: | 646 | case PLUGIN_GOTO_WPS: |
661 | play = true; | 647 | play = true; |
@@ -680,9 +666,6 @@ int ft_enter(struct tree_context* c) | |||
680 | } | 666 | } |
681 | break; | 667 | break; |
682 | } | 668 | } |
683 | case FILE_ATTR_CUE: | ||
684 | display_cuesheet_content(buf); | ||
685 | break; | ||
686 | 669 | ||
687 | default: | 670 | default: |
688 | { | 671 | { |
diff --git a/apps/filetypes.c b/apps/filetypes.c index 3724f57a9b..ed90be755f 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -536,10 +536,31 @@ char* filetype_get_plugin(const struct entry* file, char *buffer, size_t buffer_ | |||
536 | int index = find_attr(file->attr); | 536 | int index = find_attr(file->attr); |
537 | if (index < 0 || !buffer) | 537 | if (index < 0 || !buffer) |
538 | return NULL; | 538 | return NULL; |
539 | if (filetypes[index].plugin == NULL) | 539 | struct file_type *ft_indexed = &filetypes[index]; |
540 | |||
541 | /* attempt to find a suitable viewer by file extension */ | ||
542 | if(ft_indexed->plugin == NULL && ft_indexed->extension != NULL) | ||
543 | { | ||
544 | struct file_type *ft; | ||
545 | int i = filetype_count; | ||
546 | while (--i > index) | ||
547 | { | ||
548 | ft = &filetypes[i]; | ||
549 | if (ft->plugin == NULL || ft->extension == NULL) | ||
550 | continue; | ||
551 | else if (strcmp(ft->extension, ft_indexed->extension) == 0) | ||
552 | { | ||
553 | /*splashf(HZ*3, "Found %d %s %s", i, ft->extension, ft->plugin);*/ | ||
554 | ft_indexed = ft; | ||
555 | break; | ||
556 | } | ||
557 | } | ||
558 | } | ||
559 | if (ft_indexed->plugin == NULL) | ||
540 | return NULL; | 560 | return NULL; |
541 | snprintf(buffer, buffer_len, "%s/%s.%s", | 561 | |
542 | PLUGIN_DIR, filetypes[index].plugin, ROCK_EXTENSION); | 562 | snprintf(buffer, buffer_len, "%s/%s." ROCK_EXTENSION, |
563 | PLUGIN_DIR, ft_indexed->plugin); | ||
543 | return buffer; | 564 | return buffer; |
544 | } | 565 | } |
545 | 566 | ||
@@ -573,8 +594,8 @@ static int openwith_get_talk(int selected_item, void * data) | |||
573 | { | 594 | { |
574 | (void)data; | 595 | (void)data; |
575 | char viewer_filename[MAX_FILENAME]; | 596 | char viewer_filename[MAX_FILENAME]; |
576 | snprintf(viewer_filename, MAX_FILENAME, "%s.%s", | 597 | snprintf(viewer_filename, MAX_FILENAME, "%s." ROCK_EXTENSION, |
577 | filetypes[viewers[selected_item]].plugin, ROCK_EXTENSION); | 598 | filetypes[viewers[selected_item]].plugin); |
578 | talk_file_or_spell(PLUGIN_DIR, viewer_filename, | 599 | talk_file_or_spell(PLUGIN_DIR, viewer_filename, |
579 | NULL, false); | 600 | NULL, false); |
580 | return 0; | 601 | return 0; |
@@ -588,8 +609,8 @@ static int openwith_action_callback(int action, struct gui_synclist *lists) | |||
588 | { | 609 | { |
589 | char plugin[MAX_PATH]; | 610 | char plugin[MAX_PATH]; |
590 | i = viewers[gui_synclist_get_sel_pos(lists)]; | 611 | i = viewers[gui_synclist_get_sel_pos(lists)]; |
591 | snprintf(plugin, MAX_PATH, "%s/%s.%s", | 612 | snprintf(plugin, MAX_PATH, "%s/%s." ROCK_EXTENSION, |
592 | PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION); | 613 | PLUGIN_DIR, filetypes[i].plugin); |
593 | plugin_load(plugin, info->current_file); | 614 | plugin_load(plugin, info->current_file); |
594 | return ACTION_STD_CANCEL; | 615 | return ACTION_STD_CANCEL; |
595 | } | 616 | } |
@@ -630,7 +651,7 @@ int filetype_load_plugin(const char* plugin, const char* file) | |||
630 | } | 651 | } |
631 | if (i >= filetype_count) | 652 | if (i >= filetype_count) |
632 | return PLUGIN_ERROR; | 653 | return PLUGIN_ERROR; |
633 | snprintf(plugin_name, MAX_PATH, "%s/%s.%s", | 654 | snprintf(plugin_name, MAX_PATH, "%s/%s." ROCK_EXTENSION, |
634 | PLUGIN_DIR, filetypes[i].plugin, ROCK_EXTENSION); | 655 | PLUGIN_DIR, filetypes[i].plugin); |
635 | return plugin_load(plugin_name, file); | 656 | return plugin_load(plugin_name, file); |
636 | } | 657 | } |