Exit after action 47/155547/5
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Fri, 13 Oct 2017 11:51:23 +0000 (13:51 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 16 Oct 2017 11:31:57 +0000 (13:31 +0200)
Change-Id: Ie2d1266e086c4523ad7ef7041102ef7f65d166f6
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/librui/rui-menu.c
src/librui/rui-menu.h
src/system-recovery/recovery-main.c
src/system-recovery/recovery-rui.c
src/system-recovery/system-recovery.cfg.m4.in

index e62128e..fb7698f 100644 (file)
@@ -88,6 +88,9 @@ int rui_menu_action_run(rui_menu *menu)
                ret = system(menu->actions[item_selected].action_handler);
                if (ret < 0)
                        return ret;
+
+               if (menu->actions[item_selected].exit_after_action)
+                       exit(0);
        }
 
        return 1; /* Repaint unconditionally. Just in case. */
index 881c03b..1bb051a 100644 (file)
@@ -43,6 +43,7 @@ struct rui_menu_t;
 typedef struct {
         int                     screen_switch_to;
         const char             *action_handler;
+       int                     exit_after_action;
 } rui_menu_action;
 
 typedef struct rui_menu_t {
index 3b3db54..1446b79 100644 (file)
@@ -88,6 +88,8 @@ char *get_action_from_file(void)
 
        ret = fscanf(fp, "%" STR(ACTION_BUFFER_SIZE) "s", buf);
        fclose(fp);
+       unlink(SYSTEM_RECOVERY_ACTION_FILE);
+
        if (ret != 1)
                return NULL;
 
index 7a99b4b..777f691 100644 (file)
@@ -390,6 +390,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_int(node, "exit_after_action", &menu->actions[i].exit_after_action);
                rui_lookup_setting_value(node, rui_action_handlers, (&menu->actions[i]), action_handler);
        }
 
index d1134aa..664c272 100644 (file)
@@ -3,6 +3,7 @@
 m4_define(`confirm_action',`({
             label = "Yes";
             action_handler = "$1";
+            exit_after_action = $2;
         },{
             label = "No";
             screen_switch_to = "BACK";
@@ -142,8 +143,7 @@ menus = {
         style = "common";
         item_selected = 1;
         item_default = 1;
-        actions = confirm_action(`reboot');
-       exit_after_action = 1;
+        actions = confirm_action(`reboot', 0);
     };
     safe = {
         pos_x = 0; // use M4 macros
@@ -151,8 +151,7 @@ menus = {
         style = "common";
         item_selected = 1;
         item_default = 1;
-        actions = confirm_action(`safeboot');
-       exit_after_action = 1;
+        actions = confirm_action(`safeboot', 1);
     };
     factory = {
         pos_x = 0; // use M4 macros
@@ -164,11 +163,11 @@ menus = {
             label = "Yes";
             screen_switch_to = "factory-run";
             action_handler = "factory-reset";
+            exit_after_action = 1;
         },{
             label = "No";
             screen_switch_to = "BACK";
         });
-       exit_after_action = 1;
     };
 };