const char **rui_rulers;
const char **rui_description_styles;
const char **rui_descriptions;
+ const char **rui_action_handlers;
} rui_config_labels;
static rui_screen *rui_screens = NULL;
static rui_ruler **rui_rulers = NULL;
static rui_description_style *rui_description_styles = NULL;
static rui_description *rui_descriptions = NULL;
+static const char **rui_action_handlers = NULL;
/* naive search */
int find_string(const char **list, const char *s)
config_setting_lookup_string(node, "label", &menu->items[i]);
menu->actions[i].screen_switch_to = get_screen_id(node, "screen_switch_to");
- config_setting_lookup_string(node, "handler", &menu->actions[i].action_handler);
+ rui_lookup_setting_value(node, rui_action_handlers, (&menu->actions[i]), action_handler);
}
return 0;
return 0;
}
+static int action_handler_entry_parse(config_setting_t *root, void *data)
+{
+ const char **handler = data;
+
+ *handler = config_setting_get_string(root);
+ return 0;
+}
+
static int rui_config_group_init(config_t *cfg, const char *group_name,
int (*entry_init)(config_setting_t *root, void *out),
void **out, size_t entry_size, const char ***labels)
DECLARE_GROUP("screens", rui_screens, screen_entry_parse),
DECLARE_GROUP("images", rui_images, image_entry_parse),
DECLARE_GROUP("animations", rui_animations, animation_entry_parse),
+ DECLARE_GROUP("action_handlers", rui_action_handlers, action_handler_entry_parse),
DECLARE_GROUP("menus", rui_menus, menu_entry_parse),
DECLARE_GROUP("colors", rui_colors, color_entry_parse),
DECLARE_GROUP("menu_styles", rui_menu_styles, menu_style_entry_parse),
m4_define(`confirm_action',`({
label = "Yes";
- handler = "$1";
+ action_handler = "$1";
},{
label = "No";
screen_switch_to = "BACK";
})')m4_dnl
+
+action_handlers = {
+ reboot = "reboot -f";
+ factory-reset = "touch -f /opt/.factoryreset";
+ safeboot = "touch -f /opt/etc/.safeboot";
+}
+
headless_action = "factory-reset";
colors = {
actions = ({
label = "Reboot system now";
screen_switch_to = "reboot";
- // handler = ;
+ // action_handler = ;
},{
label = "Safe mode";
screen_switch_to = "safe";
- // handler = ;
+ // action_handler = ;
},{
label = "Phone reinitialisation";
screen_switch_to = "factory";
- // handler = ;
+ // action_handler = ;
});
};
reboot = {
style = "common";
item_selected = 1;
item_default = 1;
- actions = confirm_action(`reboot -f');
+ actions = confirm_action(`reboot');
exit_after_action = 1;
};
safe = {
style = "common";
item_selected = 1;
item_default = 1;
- actions = confirm_action(`touch -f /opt/etc/.safeboot');
+ actions = confirm_action(`safeboot');
exit_after_action = 1;
};
factory = {
actions = ({
label = "Yes";
screen_switch_to = "factory-run";
- handler = "touch -f /opt/.factoryreset";
+ action_handler = "factory-reset";
},{
label = "No";
screen_switch_to = "BACK";