diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/wps-display.c | 93 |
1 files changed, 41 insertions, 52 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index f8696a8d6b..6501942d05 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -368,7 +368,8 @@ static char* get_tag(struct mp3entry* cid3, | |||
368 | int buf_size, | 368 | int buf_size, |
369 | unsigned char* tag_len, | 369 | unsigned char* tag_len, |
370 | unsigned short* subline_time_mult, | 370 | unsigned short* subline_time_mult, |
371 | unsigned char* flags) | 371 | unsigned char* flags, |
372 | int *intval) | ||
372 | { | 373 | { |
373 | struct mp3entry *id3 = cid3; /* default to current song */ | 374 | struct mp3entry *id3 = cid3; /* default to current song */ |
374 | 375 | ||
@@ -380,6 +381,8 @@ static char* get_tag(struct mp3entry* cid3, | |||
380 | 381 | ||
381 | *tag_len = 2; | 382 | *tag_len = 2; |
382 | 383 | ||
384 | *intval = 0; | ||
385 | |||
383 | switch (tag[0]) | 386 | switch (tag[0]) |
384 | { | 387 | { |
385 | case 'I': /* ID3 Information */ | 388 | case 'I': /* ID3 Information */ |
@@ -587,57 +590,32 @@ static char* get_tag(struct mp3entry* cid3, | |||
587 | } | 590 | } |
588 | break; | 591 | break; |
589 | 592 | ||
590 | case 'm': /* playback repeat mode */ | 593 | case 'm': |
591 | switch (tag[1]) | 594 | switch (tag[1]) |
592 | { | 595 | { |
593 | case 'f': /* off */ | 596 | case 'm': /* playback repeat mode */ |
594 | if (global_settings.repeat_mode == REPEAT_OFF) | 597 | *intval = global_settings.repeat_mode + 1; |
595 | return "f"; | 598 | snprintf(buf, buf_size, "%d", *intval); |
596 | else | 599 | return buf; |
597 | return NULL; | 600 | |
598 | case 'a': /* all */ | ||
599 | if (global_settings.repeat_mode == REPEAT_ALL) | ||
600 | return "a"; | ||
601 | else | ||
602 | return NULL; | ||
603 | case 'o': /* one */ | ||
604 | if (global_settings.repeat_mode == REPEAT_ONE) | ||
605 | return "o"; | ||
606 | else | ||
607 | return NULL; | ||
608 | case 's': /* shuffle */ | ||
609 | if (global_settings.repeat_mode == REPEAT_SHUFFLE) | ||
610 | return "s"; | ||
611 | else | ||
612 | return NULL; | ||
613 | /* playback status */ | 601 | /* playback status */ |
614 | case 'p': /* play */ | 602 | case 'p': /* play */ |
615 | *flags |= WPS_REFRESH_DYNAMIC; | 603 | *flags |= WPS_REFRESH_DYNAMIC; |
616 | int status = audio_status(); | 604 | int status = audio_status(); |
605 | *intval = 1; | ||
617 | if (status == AUDIO_STATUS_PLAY && \ | 606 | if (status == AUDIO_STATUS_PLAY && \ |
618 | !(status & AUDIO_STATUS_PAUSE)) | 607 | !(status & AUDIO_STATUS_PAUSE)) |
619 | return "p"; | 608 | *intval = 2; |
620 | else | ||
621 | return NULL; | ||
622 | case 'u': /* pause*/ | ||
623 | *flags |= WPS_REFRESH_DYNAMIC; | ||
624 | if (audio_status() & AUDIO_STATUS_PAUSE && \ | 609 | if (audio_status() & AUDIO_STATUS_PAUSE && \ |
625 | (! status_get_ffmode())) | 610 | (! status_get_ffmode())) |
626 | return "u"; | 611 | *intval = 3; |
627 | else | ||
628 | return NULL; | ||
629 | case 'w': /* fast forward */ | ||
630 | *flags |= WPS_REFRESH_DYNAMIC; | ||
631 | if (status_get_ffmode() == STATUS_FASTFORWARD) | 612 | if (status_get_ffmode() == STATUS_FASTFORWARD) |
632 | return "w"; | 613 | *intval = 4; |
633 | else | ||
634 | return NULL; | ||
635 | case 'b': /* Fast backwards */ | ||
636 | *flags |= WPS_REFRESH_DYNAMIC; | ||
637 | if (status_get_ffmode() == STATUS_FASTBACKWARD) | 614 | if (status_get_ffmode() == STATUS_FASTBACKWARD) |
638 | return "b"; | 615 | *intval = 5; |
639 | else | 616 | snprintf(buf, buf_size, "%d", *intval); |
640 | return NULL; | 617 | return buf; |
618 | |||
641 | #if CONFIG_KEYPAD == IRIVER_H100_PAD | 619 | #if CONFIG_KEYPAD == IRIVER_H100_PAD |
642 | case 'h': /* hold */ | 620 | case 'h': /* hold */ |
643 | *flags |= WPS_REFRESH_DYNAMIC; | 621 | *flags |= WPS_REFRESH_DYNAMIC; |
@@ -758,14 +736,14 @@ static char* get_tag(struct mp3entry* cid3, | |||
758 | * | 736 | * |
759 | * fmt - string to skip it. Should point to somewhere after the leading | 737 | * fmt - string to skip it. Should point to somewhere after the leading |
760 | * "<" char (and before or at the last ">"). | 738 | * "<" char (and before or at the last ">"). |
761 | * to_else - if true, skip to the else part (after the "|", if any), else skip | 739 | * num - number of |'s to skip, or 0 to skip to the end (the ">"). |
762 | * to the end (the ">"). | ||
763 | * | 740 | * |
764 | * Returns the new position in fmt. | 741 | * Returns the new position in fmt. |
765 | */ | 742 | */ |
766 | static const char* skip_conditional(const char* fmt, bool to_else) | 743 | static const char* skip_conditional(const char* fmt, int num) |
767 | { | 744 | { |
768 | int level = 1; | 745 | int level = 1; |
746 | int count = num; | ||
769 | 747 | ||
770 | while (*fmt) | 748 | while (*fmt) |
771 | { | 749 | { |
@@ -775,15 +753,20 @@ static const char* skip_conditional(const char* fmt, bool to_else) | |||
775 | break; | 753 | break; |
776 | 754 | ||
777 | case '|': | 755 | case '|': |
778 | if (to_else && (1 == level)) | 756 | if(1 == level) { |
779 | return fmt; | 757 | if(num) { |
780 | 758 | count--; | |
759 | if(count == 0) | ||
760 | return fmt; | ||
761 | continue; | ||
762 | } | ||
763 | } | ||
781 | continue; | 764 | continue; |
782 | 765 | ||
783 | case '>': | 766 | case '>': |
784 | if (0 == --level) | 767 | if (0 == --level) |
785 | { | 768 | { |
786 | if (to_else) | 769 | if (num) |
787 | fmt--; | 770 | fmt--; |
788 | 771 | ||
789 | return fmt; | 772 | return fmt; |
@@ -845,6 +828,7 @@ static void format_display(char* buf, | |||
845 | char* value = NULL; | 828 | char* value = NULL; |
846 | int level = 0; | 829 | int level = 0; |
847 | unsigned char tag_length; | 830 | unsigned char tag_length; |
831 | int intval; | ||
848 | 832 | ||
849 | /* needed for images (ifdef is to kill a warning on player)*/ | 833 | /* needed for images (ifdef is to kill a warning on player)*/ |
850 | int n; | 834 | int n; |
@@ -877,7 +861,7 @@ static void format_display(char* buf, | |||
877 | case '>': | 861 | case '>': |
878 | if (level > 0) | 862 | if (level > 0) |
879 | { | 863 | { |
880 | fmt = skip_conditional(fmt, false); | 864 | fmt = skip_conditional(fmt, 0); |
881 | level--; | 865 | level--; |
882 | continue; | 866 | continue; |
883 | } | 867 | } |
@@ -1021,7 +1005,8 @@ static void format_display(char* buf, | |||
1021 | case '?': | 1005 | case '?': |
1022 | fmt++; | 1006 | fmt++; |
1023 | value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf), | 1007 | value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf), |
1024 | &tag_length, subline_time_mult, flags); | 1008 | &tag_length, subline_time_mult, flags, |
1009 | &intval); | ||
1025 | 1010 | ||
1026 | while (*fmt && ('<' != *fmt)) | 1011 | while (*fmt && ('<' != *fmt)) |
1027 | fmt++; | 1012 | fmt++; |
@@ -1031,14 +1016,18 @@ static void format_display(char* buf, | |||
1031 | 1016 | ||
1032 | /* No value, so skip to else part */ | 1017 | /* No value, so skip to else part */ |
1033 | if ((!value) || (!strlen(value))) | 1018 | if ((!value) || (!strlen(value))) |
1034 | fmt = skip_conditional(fmt, true); | 1019 | fmt = skip_conditional(fmt, 1); |
1020 | else | ||
1021 | if(intval > 1) /* enum */ | ||
1022 | fmt = skip_conditional(fmt, intval - 1); | ||
1035 | 1023 | ||
1036 | level++; | 1024 | level++; |
1037 | break; | 1025 | break; |
1038 | 1026 | ||
1039 | default: | 1027 | default: |
1040 | value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf), | 1028 | value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf), |
1041 | &tag_length, subline_time_mult, flags); | 1029 | &tag_length, subline_time_mult, flags, |
1030 | &intval); | ||
1042 | fmt += tag_length; | 1031 | fmt += tag_length; |
1043 | 1032 | ||
1044 | if (value) | 1033 | if (value) |