separate action handlers 08/151708/4
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Fri, 15 Sep 2017 10:13:14 +0000 (12:13 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Thu, 28 Sep 2017 16:21:25 +0000 (18:21 +0200)
Change-Id: I6aaefb5f030e5cc1bbadd0bc60269fe4c75e3e3c
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/system-recovery/recovery-rui.c
src/system-recovery/system-recovery.cfg.m4.in

index 33adecf..a2a5354 100644 (file)
@@ -81,6 +81,7 @@ static struct {
        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;
@@ -94,6 +95,7 @@ static color *rui_colors = 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)
@@ -334,7 +336,7 @@ static int menu_entry_parse(config_setting_t *root, void *data)
 
                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;
@@ -498,6 +500,14 @@ static int ruler_style_entry_parse(config_setting_t *root, void *data)
        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)
@@ -626,6 +636,7 @@ bool recovery_rui_init(config_t *cfg)
                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),
index 531c1c9..105d3aa 100644 (file)
@@ -2,11 +2,18 @@
 
 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 = {
@@ -118,15 +125,15 @@ menus = {
         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 = {
@@ -135,7 +142,7 @@ menus = {
         style = "common";
         item_selected = 1;
         item_default = 1;
-        actions = confirm_action(`reboot -f');
+        actions = confirm_action(`reboot');
        exit_after_action = 1;
     };
     safe = {
@@ -144,7 +151,7 @@ menus = {
         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 = {
@@ -156,7 +163,7 @@ menus = {
         actions = ({
             label = "Yes";
             screen_switch_to = "factory-run";
-            handler = "touch -f /opt/.factoryreset";
+            action_handler = "factory-reset";
         },{
             label = "No";
             screen_switch_to = "BACK";