summaryrefslogtreecommitdiff
path: root/apps/gui/wps_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps_parser.c')
-rw-r--r--apps/gui/wps_parser.c86
1 files changed, 82 insertions, 4 deletions
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index 390df56cbb..290f370fe7 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -121,7 +121,7 @@ struct wps_tag {
121 unsigned char refresh_type; 121 unsigned char refresh_type;
122 const wps_tag_parse_func parse_func; 122 const wps_tag_parse_func parse_func;
123}; 123};
124 124static int skip_end_of_line(const char *wps_bufptr);
125/* prototypes of all special parse functions : */ 125/* prototypes of all special parse functions : */
126static int parse_timeout(const char *wps_bufptr, 126static int parse_timeout(const char *wps_bufptr,
127 struct wps_token *token, struct wps_data *wps_data); 127 struct wps_token *token, struct wps_data *wps_data);
@@ -131,7 +131,7 @@ static int parse_dir_level(const char *wps_bufptr,
131 struct wps_token *token, struct wps_data *wps_data); 131 struct wps_token *token, struct wps_data *wps_data);
132static int parse_setting(const char *wps_bufptr, 132static int parse_setting(const char *wps_bufptr,
133 struct wps_token *token, struct wps_data *wps_data); 133 struct wps_token *token, struct wps_data *wps_data);
134 134
135#ifdef HAVE_LCD_BITMAP 135#ifdef HAVE_LCD_BITMAP
136static int parse_viewport_display(const char *wps_bufptr, 136static int parse_viewport_display(const char *wps_bufptr,
137 struct wps_token *token, struct wps_data *wps_data); 137 struct wps_token *token, struct wps_data *wps_data);
@@ -156,7 +156,18 @@ static int parse_albumart_load(const char *wps_bufptr,
156static int parse_albumart_conditional(const char *wps_bufptr, 156static int parse_albumart_conditional(const char *wps_bufptr,
157 struct wps_token *token, struct wps_data *wps_data); 157 struct wps_token *token, struct wps_data *wps_data);
158#endif /* HAVE_ALBUMART */ 158#endif /* HAVE_ALBUMART */
159 159#ifdef HAVE_TOUCHSCREEN
160static int parse_touchregion(const char *wps_bufptr,
161 struct wps_token *token, struct wps_data *wps_data);
162#else
163static int fulline_tag_not_supported(const char *wps_bufptr,
164 struct wps_token *token, struct wps_data *wps_data)
165{
166 (void)token; (void)wps_data;
167 return skip_end_of_line(wps_bufptr);
168}
169#define parse_touchregion fulline_tag_not_supported
170#endif
160#ifdef CONFIG_RTC 171#ifdef CONFIG_RTC
161#define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC 172#define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC
162#else 173#else
@@ -337,7 +348,10 @@ static const struct wps_tag all_tags[] = {
337#endif 348#endif
338 349
339 { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting }, 350 { WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting },
340 351
352 { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout },
353 { WPS_NO_TOKEN, "T", 0, parse_touchregion },
354
341 { WPS_TOKEN_UNKNOWN, "", 0, NULL } 355 { WPS_TOKEN_UNKNOWN, "", 0, NULL }
342 /* the array MUST end with an empty string (first char is \0) */ 356 /* the array MUST end with an empty string (first char is \0) */
343}; 357};
@@ -1142,6 +1156,70 @@ static int parse_albumart_conditional(const char *wps_bufptr,
1142}; 1156};
1143#endif /* HAVE_ALBUMART */ 1157#endif /* HAVE_ALBUMART */
1144 1158
1159#ifdef HAVE_TOUCHSCREEN
1160
1161struct touchaction {char* s; int action;};
1162static struct touchaction touchactions[] = {
1163 {"play", ACTION_WPS_PLAY }, {"stop", ACTION_WPS_STOP },
1164 {"prev", ACTION_WPS_SKIPPREV }, {"next", ACTION_WPS_SKIPNEXT },
1165 {"menu", ACTION_WPS_MENU }, {"browse", ACTION_WPS_BROWSE }
1166};
1167static int parse_touchregion(const char *wps_bufptr,
1168 struct wps_token *token, struct wps_data *wps_data)
1169{
1170 (void)token;
1171 unsigned i;
1172 struct touchregion *region;
1173 const char *ptr = wps_bufptr;
1174 const char *action;
1175 int x,y,w,h;
1176
1177 /* format: %T|x|y|width|height|action|
1178 * action is one of:
1179 * play - play/pause playback
1180 * stop - stop playback, exit the wps
1181 * prev - prev track
1182 * next - next track
1183 * ffwd
1184 * rwd
1185 * menu - go back to the main menu
1186 * browse - go back to the file/db browser
1187 */
1188
1189 if ((wps_data->touchregion_count +1 >= MAX_TOUCHREGIONS) || (*ptr != '|'))
1190 return WPS_ERROR_INVALID_PARAM;
1191 ptr++;
1192
1193 if (!(ptr = parse_list("dddds", NULL, '|', ptr, &x, &y, &w, &h, &action)))
1194 return WPS_ERROR_INVALID_PARAM;
1195
1196 /* Check there is a terminating | */
1197 if (*ptr != '|')
1198 return WPS_ERROR_INVALID_PARAM;
1199
1200 /* should probably do some bounds checking here with the viewport... but later */
1201 region = &wps_data->touchregion[wps_data->touchregion_count];
1202 region->action = ACTION_NONE;
1203 region->x = x;
1204 region->y = y;
1205 region->width = w;
1206 region->height = h;
1207 region->wvp = &wps_data->viewports[wps_data->num_viewports];
1208 i = 0;
1209 while ((region->action == ACTION_NONE) &&
1210 (i < sizeof(touchactions)/sizeof(*touchactions)))
1211 {
1212 if (!strncmp(touchactions[i].s, action, strlen(touchactions[i].s)))
1213 region->action = touchactions[i].action;
1214 i++;
1215 }
1216 if (region->action == ACTION_NONE)
1217 return WPS_ERROR_INVALID_PARAM;
1218 wps_data->touchregion_count++;
1219 return skip_end_of_line(wps_bufptr);
1220}
1221#endif
1222
1145/* Parse a generic token from the given string. Return the length read */ 1223/* Parse a generic token from the given string. Return the length read */
1146static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) 1224static int parse_token(const char *wps_bufptr, struct wps_data *wps_data)
1147{ 1225{