diff options
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 168 |
1 files changed, 80 insertions, 88 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 659d974130..53e1efedd8 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -1071,6 +1071,68 @@ static const struct touchaction touchactions[] = { | |||
1071 | #endif | 1071 | #endif |
1072 | }; | 1072 | }; |
1073 | 1073 | ||
1074 | static int touchregion_setup_setting(struct skin_element *element, int param_no, | ||
1075 | struct touchregion *region) | ||
1076 | { | ||
1077 | int p = param_no; | ||
1078 | char *name = element->params[p++].data.text; | ||
1079 | int j; | ||
1080 | /* Find the setting */ | ||
1081 | for (j=0; j<nb_settings; j++) | ||
1082 | if (settings[j].cfg_name && | ||
1083 | !strcmp(settings[j].cfg_name, name)) | ||
1084 | break; | ||
1085 | if (j==nb_settings) | ||
1086 | return WPS_ERROR_INVALID_PARAM; | ||
1087 | region->setting_data.setting = (void*)&settings[j]; | ||
1088 | if (region->action == ACTION_SETTINGS_SET) | ||
1089 | { | ||
1090 | char* text; | ||
1091 | int temp; | ||
1092 | struct touchsetting *setting = | ||
1093 | ®ion->setting_data; | ||
1094 | if (element->params_count < p+1) | ||
1095 | return -1; | ||
1096 | #ifndef __PCTOOL__ | ||
1097 | text = element->params[p++].data.text; | ||
1098 | switch (settings[j].flags&F_T_MASK) | ||
1099 | { | ||
1100 | case F_T_CUSTOM: | ||
1101 | setting->value.text = text; | ||
1102 | break; | ||
1103 | case F_T_INT: | ||
1104 | case F_T_UINT: | ||
1105 | if (settings[j].cfg_vals == NULL) | ||
1106 | { | ||
1107 | setting->value.number = atoi(text); | ||
1108 | } | ||
1109 | else if (cfg_string_to_int(j, &temp, text)) | ||
1110 | { | ||
1111 | if (settings[j].flags&F_TABLE_SETTING) | ||
1112 | setting->value.number = | ||
1113 | settings[j].table_setting->values[temp]; | ||
1114 | else | ||
1115 | setting->value.number = temp; | ||
1116 | } | ||
1117 | else | ||
1118 | return -1; | ||
1119 | break; | ||
1120 | case F_T_BOOL: | ||
1121 | if (cfg_string_to_int(j, &temp, text)) | ||
1122 | { | ||
1123 | setting->value.number = temp; | ||
1124 | } | ||
1125 | else | ||
1126 | return -1; | ||
1127 | break; | ||
1128 | default: | ||
1129 | return -1; | ||
1130 | } | ||
1131 | #endif /* __PCTOOL__ */ | ||
1132 | } | ||
1133 | return p-param_no; | ||
1134 | } | ||
1135 | |||
1074 | static int parse_touchregion(struct skin_element *element, | 1136 | static int parse_touchregion(struct skin_element *element, |
1075 | struct wps_token *token, | 1137 | struct wps_token *token, |
1076 | struct wps_data *wps_data) | 1138 | struct wps_data *wps_data) |
@@ -1082,7 +1144,6 @@ static int parse_touchregion(struct skin_element *element, | |||
1082 | const char *action; | 1144 | const char *action; |
1083 | const char pb_string[] = "progressbar"; | 1145 | const char pb_string[] = "progressbar"; |
1084 | const char vol_string[] = "volume"; | 1146 | const char vol_string[] = "volume"; |
1085 | char temp[20]; | ||
1086 | 1147 | ||
1087 | /* format: %T([label,], x,y,width,height,action[, ...]) | 1148 | /* format: %T([label,], x,y,width,height,action[, ...]) |
1088 | * if action starts with & the area must be held to happen | 1149 | * if action starts with & the area must be held to happen |
@@ -1125,39 +1186,13 @@ static int parse_touchregion(struct skin_element *element, | |||
1125 | region->allow_while_locked = false; | 1186 | region->allow_while_locked = false; |
1126 | action = element->params[p++].data.text; | 1187 | action = element->params[p++].data.text; |
1127 | 1188 | ||
1128 | strcpy(temp, action); | 1189 | /* figure out the action */ |
1129 | action = temp; | ||
1130 | |||
1131 | switch (*action) | ||
1132 | { | ||
1133 | case '!': | ||
1134 | region->reverse_bar = true; | ||
1135 | action++; | ||
1136 | break; | ||
1137 | case '^': | ||
1138 | action++; | ||
1139 | region->allow_while_locked = true; | ||
1140 | break; | ||
1141 | } | ||
1142 | if(!strcmp(pb_string, action)) | 1190 | if(!strcmp(pb_string, action)) |
1143 | region->action = ACTION_TOUCH_SCROLLBAR; | 1191 | region->action = ACTION_TOUCH_SCROLLBAR; |
1144 | else if(!strcmp(vol_string, action)) | 1192 | else if(!strcmp(vol_string, action)) |
1145 | region->action = ACTION_TOUCH_VOLUME; | 1193 | region->action = ACTION_TOUCH_VOLUME; |
1146 | else | 1194 | else |
1147 | { | 1195 | { |
1148 | if (*action == '*') | ||
1149 | { | ||
1150 | action++; | ||
1151 | region->press_length = LONG_PRESS; | ||
1152 | } | ||
1153 | else if(*action == '&') | ||
1154 | { | ||
1155 | action++; | ||
1156 | region->press_length = REPEAT; | ||
1157 | } | ||
1158 | else | ||
1159 | region->press_length = PRESS; | ||
1160 | |||
1161 | imax = ARRAYLEN(touchactions); | 1196 | imax = ARRAYLEN(touchactions); |
1162 | for (i = 0; i < imax; i++) | 1197 | for (i = 0; i < imax; i++) |
1163 | { | 1198 | { |
@@ -1169,68 +1204,13 @@ static int parse_touchregion(struct skin_element *element, | |||
1169 | region->action == ACTION_SETTINGS_DEC || | 1204 | region->action == ACTION_SETTINGS_DEC || |
1170 | region->action == ACTION_SETTINGS_SET) | 1205 | region->action == ACTION_SETTINGS_SET) |
1171 | { | 1206 | { |
1207 | int val; | ||
1172 | if (element->params_count < p+1) | 1208 | if (element->params_count < p+1) |
1173 | { | ||
1174 | return WPS_ERROR_INVALID_PARAM; | 1209 | return WPS_ERROR_INVALID_PARAM; |
1175 | } | 1210 | val = touchregion_setup_setting(element, p, region); |
1176 | else | 1211 | if (val < 0) |
1177 | { | 1212 | return WPS_ERROR_INVALID_PARAM; |
1178 | char *name = element->params[p].data.text; | 1213 | p += val; |
1179 | int j; | ||
1180 | /* Find the setting */ | ||
1181 | for (j=0; j<nb_settings; j++) | ||
1182 | if (settings[j].cfg_name && | ||
1183 | !strcmp(settings[j].cfg_name, name)) | ||
1184 | break; | ||
1185 | if (j==nb_settings) | ||
1186 | return WPS_ERROR_INVALID_PARAM; | ||
1187 | region->setting_data.setting = (void*)&settings[j]; | ||
1188 | if (region->action == ACTION_SETTINGS_SET) | ||
1189 | { | ||
1190 | char* text; | ||
1191 | int temp; | ||
1192 | struct touchsetting *setting = | ||
1193 | ®ion->setting_data; | ||
1194 | if (element->params_count < p+2) | ||
1195 | return WPS_ERROR_INVALID_PARAM; | ||
1196 | #ifndef __PCTOOL__ | ||
1197 | text = element->params[p+1].data.text; | ||
1198 | switch (settings[j].flags&F_T_MASK) | ||
1199 | { | ||
1200 | case F_T_CUSTOM: | ||
1201 | setting->value.text = text; | ||
1202 | break; | ||
1203 | case F_T_INT: | ||
1204 | case F_T_UINT: | ||
1205 | if (settings[j].cfg_vals == NULL) | ||
1206 | { | ||
1207 | setting->value.number = atoi(text); | ||
1208 | } | ||
1209 | else if (cfg_string_to_int(j, &temp, text)) | ||
1210 | { | ||
1211 | if (settings[j].flags&F_TABLE_SETTING) | ||
1212 | setting->value.number = | ||
1213 | settings[j].table_setting->values[temp]; | ||
1214 | else | ||
1215 | setting->value.number = temp; | ||
1216 | } | ||
1217 | else | ||
1218 | return WPS_ERROR_INVALID_PARAM; | ||
1219 | break; | ||
1220 | case F_T_BOOL: | ||
1221 | if (cfg_string_to_int(j, &temp, text)) | ||
1222 | { | ||
1223 | setting->value.number = temp; | ||
1224 | } | ||
1225 | else | ||
1226 | return WPS_ERROR_INVALID_PARAM; | ||
1227 | break; | ||
1228 | default: | ||
1229 | return WPS_ERROR_INVALID_PARAM; | ||
1230 | } | ||
1231 | #endif /* __PCTOOL__ */ | ||
1232 | } | ||
1233 | } | ||
1234 | } | 1214 | } |
1235 | break; | 1215 | break; |
1236 | } | 1216 | } |
@@ -1238,6 +1218,18 @@ static int parse_touchregion(struct skin_element *element, | |||
1238 | if (region->action == ACTION_NONE) | 1218 | if (region->action == ACTION_NONE) |
1239 | return WPS_ERROR_INVALID_PARAM; | 1219 | return WPS_ERROR_INVALID_PARAM; |
1240 | } | 1220 | } |
1221 | while (p < element->params_count) | ||
1222 | { | ||
1223 | char* param = element->params[p++].data.text; | ||
1224 | if (!strcmp(param, "allow_while_locked")) | ||
1225 | region->allow_while_locked = true; | ||
1226 | else if (!strcmp(param, "reverse_bar")) | ||
1227 | region->reverse_bar = true; | ||
1228 | else if (!strcmp(param, "repeat_press")) | ||
1229 | region->press_length = REPEAT; | ||
1230 | else if (!strcmp(param, "long_press")) | ||
1231 | region->press_length = LONG_PRESS; | ||
1232 | } | ||
1241 | struct skin_token_list *item = new_skin_token_list_item(NULL, region); | 1233 | struct skin_token_list *item = new_skin_token_list_item(NULL, region); |
1242 | if (!item) | 1234 | if (!item) |
1243 | return WPS_ERROR_INVALID_PARAM; | 1235 | return WPS_ERROR_INVALID_PARAM; |