clients/ivi-shell-user-interface.c: Add 'command' config

Previously, commands could only be specified by their path,
so it was not possible to pass arguments.
Use the 'command' config first,
and if it is NULL, fall back to the existing 'path' config.

Signed-off-by: Gyeyoung Baek <gyeyoung976@gmail.com>

Co-authored-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Gyeyoung Baek 2024-12-04 17:37:16 +09:00 committed by Marius Vlad
parent 3866ecc5d3
commit 483a5a73cb
6 changed files with 57 additions and 6 deletions

View file

@ -143,6 +143,8 @@ hmi_homescreen_launcher {
uint32_t workspace_id;
char *icon;
char *path;
char **argv;
struct wl_list link;
};
@ -308,12 +310,10 @@ launcher_button(uint32_t surfaceId, struct wl_list *launcher_list)
struct hmi_homescreen_launcher *launcher = NULL;
wl_list_for_each(launcher, launcher_list, link) {
char *argv[] = { NULL };
if (surfaceId != launcher->icon_surface_id)
continue;
execute_process(launcher->path, argv);
execute_process(launcher->path, launcher->argv);
return 1;
}
@ -1065,6 +1065,32 @@ create_launchers(struct wlContextCommon *cmm, struct wl_list *launcher_list)
free(launchers);
}
static char **
parse_command(char *str)
{
char **argv;
char *saveptr;
char *token;
int i;
int count = 1;
for (i = 1; str[i]; i++)
if (str[i] == ' ' && str[i-1] != ' ')
count++;
argv = xcalloc(count + 1, sizeof(char*));
i = 0;
token = strtok_r(str, " ", &saveptr);
while (token != NULL) {
argv[i++] = token;
token = strtok_r(NULL, " ", &saveptr);
}
return argv;
}
/**
* Internal method to read out weston.ini to get configuration
*/
@ -1177,6 +1203,7 @@ hmi_homescreen_setting_create(void)
while (weston_config_next_section(config, &section, &name)) {
struct hmi_homescreen_launcher *launcher;
char *command;
if (strcmp(name, "ivi-launcher") != 0)
continue;
@ -1186,8 +1213,18 @@ hmi_homescreen_setting_create(void)
weston_config_section_get_string(section, "icon",
&launcher->icon, NULL);
weston_config_section_get_string(section, "path",
&launcher->path, NULL);
weston_config_section_get_string(section, "command",
&command, NULL);
if (command == NULL) {
weston_config_section_get_string(section, "path",
&launcher->path, NULL);
launcher->argv = NULL;
} else {
launcher->argv = parse_command(command);
launcher->path = launcher->argv[0];
}
weston_config_section_get_uint(section, "workspace-id",
&launcher->workspace_id, 0);
weston_config_section_get_uint(section, "icon-id",

View file

@ -33,6 +33,7 @@ home.png
icon_ivi_clickdot.png
icon_ivi_flower.png
icon_ivi_simple-egl.png
icon_ivi_simple-egl-vertical.png
icon_ivi_simple-shm.png
icon_ivi_smoke.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -9,6 +9,7 @@ install_data(
'icon_ivi_clickdot.png',
'icon_ivi_flower.png',
'icon_ivi_simple-egl.png',
'icon_ivi_simple-egl-vertical.png',
'icon_ivi_simple-shm.png',
'icon_ivi_smoke.png',
'icon_terminal.png',

View file

@ -96,3 +96,9 @@ workspace-id=3
icon-id=4010
icon=@westondatadir@/icon_ivi_smoke.png
path=@bindir@/weston-smoke
[ivi-launcher]
workspace-id=3
icon-id=4011
icon=@westondatadir@/icon_ivi_simple-egl-vertical.png
command=@bindir@/weston-simple-egl -v

View file

@ -133,7 +133,13 @@ fixture_setup(struct weston_test_harness *harness)
cfgln("workspace-id=%d", 3),
cfgln("icon-id=%d", 4010),
cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_smoke.png"),
cfgln("path=%s", BINDIR "/weston-smoke")
cfgln("path=%s", BINDIR "/weston-smoke"),
cfgln("[ivi-launcher]"),
cfgln("workspace-id=%d", 3),
cfgln("icon-id=%d", 4011),
cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_simple-egl-vertical.png"),
cfgln("command=%s", BINDIR "/weston-simple-egl -v")
);
return weston_test_harness_execute_as_client(harness, &setup);