From: Chanwoo Choi Date: Thu, 17 Aug 2023 10:44:15 +0000 (+0900) Subject: plugin-api: deviced: power: Add syscommon_plugin_deviced_power_convert_to_power_state() X-Git-Tag: accepted/tizen/unified/20230821.162308~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=913842514c326300feb34b50eba6e8e56e3b9719;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git plugin-api: deviced: power: Add syscommon_plugin_deviced_power_convert_to_power_state() syscommon_plugin_deviced_power_convert_to_power_state() plugin api converts the power action string to DEVICED_POWER_STATE_* enumeration. Change-Id: I14fb07cfa64527fceba58116977b32986c14edda Signed-off-by: Chanwoo Choi --- diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h index 4f05328..95394c1 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h @@ -73,6 +73,26 @@ enum { #define DEVICED_POWER_STATE_INDEX(state) (__builtin_ctzll(state)) +static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(const char *str) +{ + if (MATCH(str, "start")) + return DEVICED_POWER_STATE_START; + else if (MATCH(str, "sleep")) + return DEVICED_POWER_STATE_SLEEP; + else if (MATCH(str, "normal")) + return DEVICED_POWER_STATE_NORMAL; + else if (MATCH(str, "poweroff")) + return DEVICED_POWER_STATE_POWEROFF; + else if (MATCH(str, "reboot")) + return DEVICED_POWER_STATE_REBOOT; + else if (MATCH(str, "exit")) + return DEVICED_POWER_STATE_EXIT; + else if (MATCH(str, "current")) + return DEVICED_POWER_STATE_ALL; + + return DEVICED_POWER_STATE_UNDEFINED; +} + #ifdef __cplusplus } #endif