diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 268ba8c2a5..7c889346a1 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -202,7 +202,7 @@ static const struct wps_tag all_tags[] = { | |||
202 | { WPS_TOKEN_BATTERY_CHARGER_CONNECTED,"bp", WPS_REFRESH_DYNAMIC, NULL }, | 202 | { WPS_TOKEN_BATTERY_CHARGER_CONNECTED,"bp", WPS_REFRESH_DYNAMIC, NULL }, |
203 | #endif | 203 | #endif |
204 | #ifdef HAVE_USB_POWER | 204 | #ifdef HAVE_USB_POWER |
205 | { WPS_TOKEN_USB_POWERED, "bu", WPS_REFRESH_DYNAMIC, NULL }, | 205 | { WPS_TOKEN_USB_POWERED, "bu", WPS_REFRESH_DYNAMIC, NULL }, |
206 | #endif | 206 | #endif |
207 | 207 | ||
208 | { WPS_TOKEN_RTC_PRESENT , "cc", WPS_REFRESH_STATIC, NULL }, | 208 | { WPS_TOKEN_RTC_PRESENT , "cc", WPS_REFRESH_STATIC, NULL }, |
@@ -447,8 +447,8 @@ static struct skin_token_list *new_skin_token_list_item(struct wps_token *token, | |||
447 | return NULL; | 447 | return NULL; |
448 | llitem->next = NULL; | 448 | llitem->next = NULL; |
449 | llitem->token = token; | 449 | llitem->token = token; |
450 | if (token_data) | 450 | if (token_data) |
451 | llitem->token->value.data = token_data; | 451 | llitem->token->value.data = token_data; |
452 | return llitem; | 452 | return llitem; |
453 | } | 453 | } |
454 | 454 | ||
@@ -515,7 +515,6 @@ static bool skin_start_new_line(struct skin_viewport *vp, int curr_token) | |||
515 | curr_line = line; | 515 | curr_line = line; |
516 | if (!vp->lines) | 516 | if (!vp->lines) |
517 | vp->lines = line; | 517 | vp->lines = line; |
518 | line_number++; | ||
519 | return true; | 518 | return true; |
520 | } | 519 | } |
521 | 520 | ||
@@ -582,7 +581,7 @@ static int parse_image_display(const char *wps_bufptr, | |||
582 | { | 581 | { |
583 | char label = wps_bufptr[0]; | 582 | char label = wps_bufptr[0]; |
584 | int subimage; | 583 | int subimage; |
585 | struct gui_img *img;; | 584 | struct gui_img *img;; |
586 | 585 | ||
587 | /* sanity check */ | 586 | /* sanity check */ |
588 | img = find_image(label, wps_data); | 587 | img = find_image(label, wps_data); |
@@ -616,7 +615,7 @@ static int parse_image_load(const char *wps_bufptr, | |||
616 | const char* id; | 615 | const char* id; |
617 | const char *newline; | 616 | const char *newline; |
618 | int x,y; | 617 | int x,y; |
619 | struct gui_img *img; | 618 | struct gui_img *img; |
620 | 619 | ||
621 | /* format: %x|n|filename.bmp|x|y| | 620 | /* format: %x|n|filename.bmp|x|y| |
622 | or %xl|n|filename.bmp|x|y| | 621 | or %xl|n|filename.bmp|x|y| |
@@ -642,14 +641,14 @@ static int parse_image_load(const char *wps_bufptr, | |||
642 | return WPS_ERROR_INVALID_PARAM; | 641 | return WPS_ERROR_INVALID_PARAM; |
643 | } | 642 | } |
644 | img = skin_buffer_alloc(sizeof(struct gui_img)); | 643 | img = skin_buffer_alloc(sizeof(struct gui_img)); |
645 | if (!img) | 644 | if (!img) |
646 | return WPS_ERROR_INVALID_PARAM; | 645 | return WPS_ERROR_INVALID_PARAM; |
647 | /* save a pointer to the filename */ | 646 | /* save a pointer to the filename */ |
648 | img->bm.data = (char*)filename; | 647 | img->bm.data = (char*)filename; |
649 | img->label = *id; | 648 | img->label = *id; |
650 | img->x = x; | 649 | img->x = x; |
651 | img->y = y; | 650 | img->y = y; |
652 | img->num_subimages = 1; | 651 | img->num_subimages = 1; |
653 | img->always_display = false; | 652 | img->always_display = false; |
654 | 653 | ||
655 | /* save current viewport */ | 654 | /* save current viewport */ |
@@ -671,10 +670,10 @@ static int parse_image_load(const char *wps_bufptr, | |||
671 | if (img->num_subimages <= 0) | 670 | if (img->num_subimages <= 0) |
672 | return WPS_ERROR_INVALID_PARAM; | 671 | return WPS_ERROR_INVALID_PARAM; |
673 | } | 672 | } |
674 | struct skin_token_list *item = new_skin_token_list_item(NULL, img); | 673 | struct skin_token_list *item = new_skin_token_list_item(NULL, img); |
675 | if (!item) | 674 | if (!item) |
676 | return WPS_ERROR_INVALID_PARAM; | 675 | return WPS_ERROR_INVALID_PARAM; |
677 | add_to_ll_chain(&wps_data->images, item); | 676 | add_to_ll_chain(&wps_data->images, item); |
678 | 677 | ||
679 | /* Skip the rest of the line */ | 678 | /* Skip the rest of the line */ |
680 | return skip_end_of_line(wps_bufptr); | 679 | return skip_end_of_line(wps_bufptr); |
@@ -935,8 +934,8 @@ static int parse_progressbar(const char *wps_bufptr, | |||
935 | struct progressbar *pb = skin_buffer_alloc(sizeof(struct progressbar)); | 934 | struct progressbar *pb = skin_buffer_alloc(sizeof(struct progressbar)); |
936 | struct skin_token_list *item = new_skin_token_list_item(token, pb); | 935 | struct skin_token_list *item = new_skin_token_list_item(token, pb); |
937 | 936 | ||
938 | if (!pb || !item) | 937 | if (!pb || !item) |
939 | return WPS_ERROR_INVALID_PARAM; | 938 | return WPS_ERROR_INVALID_PARAM; |
940 | 939 | ||
941 | struct viewport *vp = &curr_vp->vp; | 940 | struct viewport *vp = &curr_vp->vp; |
942 | #ifndef __PCTOOL__ | 941 | #ifndef __PCTOOL__ |
@@ -954,7 +953,7 @@ static int parse_progressbar(const char *wps_bufptr, | |||
954 | line = line->next; | 953 | line = line->next; |
955 | } | 954 | } |
956 | pb->have_bitmap_pb = false; | 955 | pb->have_bitmap_pb = false; |
957 | pb->bm.data = NULL; /* no bitmap specified */ | 956 | pb->bm.data = NULL; /* no bitmap specified */ |
958 | 957 | ||
959 | if (*wps_bufptr != '|') /* regular old style */ | 958 | if (*wps_bufptr != '|') /* regular old style */ |
960 | { | 959 | { |
@@ -1491,7 +1490,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1491 | int ret; | 1490 | int ret; |
1492 | int max_tokens = TOKEN_BLOCK_SIZE; | 1491 | int max_tokens = TOKEN_BLOCK_SIZE; |
1493 | size_t buf_free = 0; | 1492 | size_t buf_free = 0; |
1494 | line_number = 1; | 1493 | line_number = 0; |
1495 | level = -1; | 1494 | level = -1; |
1496 | 1495 | ||
1497 | /* allocate enough RAM for a reasonable skin, grow as needed. | 1496 | /* allocate enough RAM for a reasonable skin, grow as needed. |
@@ -1637,6 +1636,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1637 | fail = PARSE_FAIL_LIMITS_EXCEEDED; | 1636 | fail = PARSE_FAIL_LIMITS_EXCEEDED; |
1638 | break; | 1637 | break; |
1639 | } | 1638 | } |
1639 | line_number++; | ||
1640 | 1640 | ||
1641 | break; | 1641 | break; |
1642 | 1642 | ||
@@ -1659,15 +1659,15 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1659 | /* look if we already have that string */ | 1659 | /* look if we already have that string */ |
1660 | char *str; | 1660 | char *str; |
1661 | bool found = false; | 1661 | bool found = false; |
1662 | struct skin_token_list *list = data->strings; | 1662 | struct skin_token_list *list = data->strings; |
1663 | while (list) | 1663 | while (list) |
1664 | { | 1664 | { |
1665 | str = (char*)list->token->value.data; | 1665 | str = (char*)list->token->value.data; |
1666 | found = (strlen(str) == len && | 1666 | found = (strlen(str) == len && |
1667 | strncmp(string_start, str, len) == 0); | 1667 | strncmp(string_start, str, len) == 0); |
1668 | if (found) | 1668 | if (found) |
1669 | break; /* break here because the list item is | 1669 | break; /* break here because the list item is |
1670 | used if its found */ | 1670 | used if its found */ |
1671 | list = list->next; | 1671 | list = list->next; |
1672 | } | 1672 | } |
1673 | /* If a matching string is found, found is true and i is | 1673 | /* If a matching string is found, found is true and i is |
@@ -1676,21 +1676,21 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1676 | if (!found) | 1676 | if (!found) |
1677 | { | 1677 | { |
1678 | /* new string */ | 1678 | /* new string */ |
1679 | str = (char*)skin_buffer_alloc(len+1); | 1679 | str = (char*)skin_buffer_alloc(len+1); |
1680 | if (!str) | 1680 | if (!str) |
1681 | { | 1681 | { |
1682 | fail = PARSE_FAIL_LIMITS_EXCEEDED; | 1682 | fail = PARSE_FAIL_LIMITS_EXCEEDED; |
1683 | break; | 1683 | break; |
1684 | } | 1684 | } |
1685 | strlcpy(str, string_start, len+1); | 1685 | strlcpy(str, string_start, len+1); |
1686 | struct skin_token_list *item = | 1686 | struct skin_token_list *item = |
1687 | new_skin_token_list_item(&data->tokens[data->num_tokens], str); | 1687 | new_skin_token_list_item(&data->tokens[data->num_tokens], str); |
1688 | if(!item) | 1688 | if(!item) |
1689 | { | 1689 | { |
1690 | fail = PARSE_FAIL_LIMITS_EXCEEDED; | 1690 | fail = PARSE_FAIL_LIMITS_EXCEEDED; |
1691 | break; | 1691 | break; |
1692 | } | 1692 | } |
1693 | add_to_ll_chain(&data->strings, item); | 1693 | add_to_ll_chain(&data->strings, item); |
1694 | } | 1694 | } |
1695 | else | 1695 | else |
1696 | { | 1696 | { |
@@ -1775,13 +1775,13 @@ void skin_data_reset(struct wps_data *wps_data) | |||
1775 | #ifdef HAVE_LCD_BITMAP | 1775 | #ifdef HAVE_LCD_BITMAP |
1776 | static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir) | 1776 | static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir) |
1777 | { | 1777 | { |
1778 | (void)wps_data; /* only needed for remote targets */ | 1778 | (void)wps_data; /* only needed for remote targets */ |
1779 | bool loaded = false; | 1779 | bool loaded = false; |
1780 | char img_path[MAX_PATH]; | 1780 | char img_path[MAX_PATH]; |
1781 | get_image_filename(bitmap->data, bmpdir, | 1781 | get_image_filename(bitmap->data, bmpdir, |
1782 | img_path, sizeof(img_path)); | 1782 | img_path, sizeof(img_path)); |
1783 | 1783 | ||
1784 | /* load the image */ | 1784 | /* load the image */ |
1785 | int format; | 1785 | int format; |
1786 | #ifdef HAVE_REMOTE_LCD | 1786 | #ifdef HAVE_REMOTE_LCD |
1787 | if (curr_screen == SCREEN_REMOTE) | 1787 | if (curr_screen == SCREEN_REMOTE) |
@@ -1790,22 +1790,22 @@ static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char | |||
1790 | #endif | 1790 | #endif |
1791 | format = FORMAT_ANY|FORMAT_TRANSPARENT; | 1791 | format = FORMAT_ANY|FORMAT_TRANSPARENT; |
1792 | 1792 | ||
1793 | size_t max_buf; | 1793 | size_t max_buf; |
1794 | char* imgbuf = (char*)skin_buffer_grab(&max_buf); | 1794 | char* imgbuf = (char*)skin_buffer_grab(&max_buf); |
1795 | bitmap->data = imgbuf; | 1795 | bitmap->data = imgbuf; |
1796 | int ret = read_bmp_file(img_path, bitmap, max_buf, format, NULL); | 1796 | int ret = read_bmp_file(img_path, bitmap, max_buf, format, NULL); |
1797 | 1797 | ||
1798 | if (ret > 0) | 1798 | if (ret > 0) |
1799 | { | 1799 | { |
1800 | skin_buffer_increment(ret, true); | 1800 | skin_buffer_increment(ret, true); |
1801 | loaded = true; | 1801 | loaded = true; |
1802 | } | 1802 | } |
1803 | else | 1803 | else |
1804 | { | 1804 | { |
1805 | /* Abort if we can't load an image */ | 1805 | /* Abort if we can't load an image */ |
1806 | loaded = false; | 1806 | loaded = false; |
1807 | } | 1807 | } |
1808 | return loaded; | 1808 | return loaded; |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) | 1811 | static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) |
@@ -1820,20 +1820,20 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1820 | { | 1820 | { |
1821 | pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir); | 1821 | pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir); |
1822 | } | 1822 | } |
1823 | list = list->next; | 1823 | list = list->next; |
1824 | } | 1824 | } |
1825 | /* regular images */ | 1825 | /* regular images */ |
1826 | list = wps_data->images; | 1826 | list = wps_data->images; |
1827 | while (list) | 1827 | while (list) |
1828 | { | 1828 | { |
1829 | struct gui_img *img = (struct gui_img*)list->token->value.data; | 1829 | struct gui_img *img = (struct gui_img*)list->token->value.data; |
1830 | if (img->bm.data) | 1830 | if (img->bm.data) |
1831 | { | 1831 | { |
1832 | img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir); | 1832 | img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir); |
1833 | if (img->loaded) | 1833 | if (img->loaded) |
1834 | img->subimage_height = img->bm.height / img->num_subimages; | 1834 | img->subimage_height = img->bm.height / img->num_subimages; |
1835 | } | 1835 | } |
1836 | list = list->next; | 1836 | list = list->next; |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 1839 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |