summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c113
1 files changed, 82 insertions, 31 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index c70a9759ee..4655bf0dff 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -62,6 +62,7 @@
62#endif 62#endif
63 63
64#include "backdrop.h" 64#include "backdrop.h"
65#include "statusbar-skinned.h"
65 66
66#define WPS_ERROR_INVALID_PARAM -1 67#define WPS_ERROR_INVALID_PARAM -1
67 68
@@ -92,22 +93,6 @@ static struct skin_line *curr_line;
92 93
93static int follow_lang_direction = 0; 94static int follow_lang_direction = 0;
94 95
95#ifdef HAVE_LCD_BITMAP
96
97#if LCD_DEPTH > 1
98#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */
99#else
100#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */
101#endif
102
103#define PROGRESSBAR_BMP MAX_IMAGES
104#define BACKDROP_BMP (MAX_BITMAPS-1)
105
106/* pointers to the bitmap filenames in the WPS source */
107static const char *bmp_names[MAX_BITMAPS];
108
109#endif /* HAVE_LCD_BITMAP */
110
111#if defined(DEBUG) || defined(SIMULATOR) 96#if defined(DEBUG) || defined(SIMULATOR)
112/* debugging function */ 97/* debugging function */
113extern void print_debug_info(struct wps_data *data, int fail, int line); 98extern void print_debug_info(struct wps_data *data, int fail, int line);
@@ -925,20 +910,29 @@ static int parse_image_special(const char *wps_bufptr,
925 (void)token; 910 (void)token;
926 const char *pos = NULL; 911 const char *pos = NULL;
927 const char *newline; 912 const char *newline;
913 bool error = false;
928 914
929 pos = strchr(wps_bufptr + 1, '|'); 915 pos = strchr(wps_bufptr + 1, '|');
930 newline = strchr(wps_bufptr, '\n'); 916 newline = strchr(wps_bufptr, '\n');
917
918 error = (pos > newline);
919
931 920
932 if (pos > newline)
933 return WPS_ERROR_INVALID_PARAM;
934#if LCD_DEPTH > 1 921#if LCD_DEPTH > 1
935 if (token->type == WPS_TOKEN_IMAGE_BACKDROP) 922 if (token->type == WPS_TOKEN_IMAGE_BACKDROP)
936 { 923 {
937 /* format: %X|filename.bmp| */ 924 /* format: %X|filename.bmp| or %Xd */
938 bmp_names[BACKDROP_BMP] = wps_bufptr + 1; 925 if (*(wps_bufptr) == 'd')
926 {
927 wps_data->backdrop = NULL;
928 return skip_end_of_line(wps_bufptr);
929 }
930 else if (!error)
931 wps_data->backdrop = (char*)wps_bufptr + 1;
939 } 932 }
940#endif 933#endif
941 934 if (error)
935 return WPS_ERROR_INVALID_PARAM;
942 /* Skip the rest of the line */ 936 /* Skip the rest of the line */
943 return skip_end_of_line(wps_bufptr); 937 return skip_end_of_line(wps_bufptr);
944} 938}
@@ -1657,6 +1651,14 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
1657 return false; 1651 return false;
1658 skin_buffer_increment(max_tokens * sizeof(struct wps_token), false); 1652 skin_buffer_increment(max_tokens * sizeof(struct wps_token), false);
1659 data->num_tokens = 0; 1653 data->num_tokens = 0;
1654
1655#if LCD_DEPTH > 1
1656 /* Backdrop defaults to the setting unless %X is used, so set it now */
1657 if (global_settings.backdrop_file[0])
1658 {
1659 data->backdrop = "-";
1660 }
1661#endif
1660 1662
1661 while (*wps_bufptr && !fail) 1663 while (*wps_bufptr && !fail)
1662 { 1664 {
@@ -1899,6 +1901,9 @@ static void skin_data_reset(struct wps_data *wps_data)
1899 wps_data->images = NULL; 1901 wps_data->images = NULL;
1900 wps_data->progressbars = NULL; 1902 wps_data->progressbars = NULL;
1901#endif 1903#endif
1904#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
1905 wps_data->backdrop = NULL;
1906#endif
1902#ifdef HAVE_TOUCHSCREEN 1907#ifdef HAVE_TOUCHSCREEN
1903 wps_data->touchregions = NULL; 1908 wps_data->touchregions = NULL;
1904#endif 1909#endif
@@ -1996,12 +2001,51 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
1996 } 2001 }
1997 2002
1998#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) 2003#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
1999 if (bmp_names[BACKDROP_BMP]) 2004 /* Backdrop load scheme:
2005 * 1) %X|filename|
2006 * 2) load the backdrop from settings
2007 */
2008 if (wps_data->backdrop)
2000 { 2009 {
2001 char img_path[MAX_PATH]; 2010 char img_path[MAX_PATH];
2002 get_image_filename(bmp_names[BACKDROP_BMP], bmpdir, 2011 bool loaded = false;
2003 img_path, sizeof(img_path)); 2012 size_t buf_size;
2004 screens[curr_screen].backdrop_load(BACKDROP_SKIN_WPS, img_path); 2013#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
2014 if (curr_screen == SCREEN_REMOTE)
2015 buf_size = REMOTE_LCD_BACKDROP_BYTES;
2016 else
2017#endif
2018 buf_size = LCD_BACKDROP_BYTES;
2019 if (wps_data->backdrop[0] == '-')
2020 {
2021#if NB_SCREENS > 1
2022 if (curr_screen == SCREEN_REMOTE)
2023 {
2024 wps_data->backdrop = NULL;
2025 return true;
2026 }
2027 else
2028#endif
2029 {
2030 if (!global_settings.backdrop_file[0])
2031 {
2032 wps_data->backdrop = NULL;
2033 return true;
2034 }
2035 snprintf(img_path, sizeof(img_path), "%s/%s.bmp",
2036 BACKDROP_DIR, global_settings.backdrop_file);
2037 }
2038 }
2039 else
2040 {
2041 get_image_filename(wps_data->backdrop, bmpdir,
2042 img_path, sizeof(img_path));
2043 }
2044 char *buffer = skin_buffer_alloc(buf_size);
2045 if (!buffer)
2046 return false;
2047 loaded = screens[curr_screen].backdrop_load(img_path, buffer);
2048 wps_data->backdrop = loaded ? buffer : NULL;
2005 } 2049 }
2006#endif /* has backdrop support */ 2050#endif /* has backdrop support */
2007 2051
@@ -2059,7 +2103,18 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2059 2103
2060 if (!isfile) 2104 if (!isfile)
2061 { 2105 {
2062 return wps_parse(wps_data, buf, false); 2106 if (wps_parse(wps_data, buf, false))
2107 {
2108#ifdef HAVE_LCD_BITMAP
2109 /* load the backdrop */
2110 if (!load_skin_bitmaps(wps_data, BACKDROP_DIR)) {
2111 skin_data_reset(wps_data);
2112 return false;
2113 }
2114#endif
2115 return true;
2116 }
2117 return false;
2063 } 2118 }
2064 else 2119 else
2065 { 2120 {
@@ -2093,11 +2148,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2093 if (start <= 0) 2148 if (start <= 0)
2094 return false; 2149 return false;
2095 2150
2096#ifdef HAVE_LCD_BITMAP
2097 /* Set all filename pointers to NULL */
2098 memset(bmp_names, 0, sizeof(bmp_names));
2099#endif
2100
2101 /* parse the WPS source */ 2151 /* parse the WPS source */
2102 if (!wps_parse(wps_data, wps_buffer, true)) { 2152 if (!wps_parse(wps_data, wps_buffer, true)) {
2103 skin_data_reset(wps_data); 2153 skin_data_reset(wps_data);
@@ -2116,6 +2166,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
2116 /* load the bitmaps that were found by the parsing */ 2166 /* load the bitmaps that were found by the parsing */
2117 if (!load_skin_bitmaps(wps_data, bmpdir)) { 2167 if (!load_skin_bitmaps(wps_data, bmpdir)) {
2118 skin_data_reset(wps_data); 2168 skin_data_reset(wps_data);
2169 wps_data->wps_loaded = false;
2119 return false; 2170 return false;
2120 } 2171 }
2121#endif 2172#endif