implement more app list IPC code

This commit is contained in:
Nedko Arnaudov 2009-12-04 15:15:14 +02:00
parent 67a1dd5013
commit 094d7ba9d7
4 changed files with 529 additions and 11 deletions

View File

@ -25,6 +25,8 @@
*/
#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include "app_supervisor.h"
#include "../dbus/error.h"
@ -37,6 +39,8 @@ struct ladish_app
uint64_t id;
char * name;
char * commandline;
bool terminal;
uint8_t level;
pid_t pid;
};
@ -104,6 +108,23 @@ struct ladish_app * ladish_app_supervisor_find_app_by_name(struct ladish_app_sup
return NULL;
}
struct ladish_app * ladish_app_supervisor_find_app_by_id(struct ladish_app_supervisor * supervisor_ptr, uint64_t id)
{
struct list_head * node_ptr;
struct ladish_app * app_ptr;
list_for_each(node_ptr, &supervisor_ptr->applist)
{
app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
if (app_ptr->id == id)
{
return app_ptr;
}
}
return NULL;
}
#define supervisor_ptr ((struct ladish_app_supervisor *)supervisor_handle)
void ladish_app_supervisor_destroy(ladish_app_supervisor_handle supervisor_handle)
@ -135,7 +156,18 @@ bool ladish_app_supervisor_child_exit(ladish_app_supervisor_handle supervisor_ha
if (app_ptr->pid == pid)
{
log_info("exit of studio child '%s' detected.", app_ptr->name);
list_del(&app_ptr->siblings);
dbus_signal_emit(
g_dbus_connection,
supervisor_ptr->opath,
IFACE_APP_SUPERVISOR,
"AppRemoved",
"tt",
&supervisor_ptr->version,
&app_ptr->id);
free(app_ptr->name);
free(app_ptr->commandline);
free(app_ptr);
@ -154,6 +186,8 @@ static void get_all(struct dbus_method_call * call_ptr)
DBusMessageIter iter, array_iter, struct_iter;
struct list_head * node_ptr;
struct ladish_app * app_ptr;
dbus_bool_t running;
dbus_bool_t terminal;
log_info("get_all called");
@ -170,7 +204,7 @@ static void get_all(struct dbus_method_call * call_ptr)
goto fail_unref;
}
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ts)", &array_iter))
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(tsbby)", &array_iter))
{
goto fail_unref;
}
@ -179,6 +213,8 @@ static void get_all(struct dbus_method_call * call_ptr)
{
app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id);
if (!dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter))
{
goto fail_unref;
@ -189,12 +225,28 @@ static void get_all(struct dbus_method_call * call_ptr)
goto fail_unref;
}
log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id);
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &app_ptr->name))
{
goto fail_unref;
}
running = app_ptr->pid != 0;
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &running))
{
goto fail_unref;
}
terminal = app_ptr->terminal;
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &terminal))
{
goto fail_unref;
}
if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BYTE, &app_ptr->level))
{
goto fail_unref;
}
if (!dbus_message_iter_close_container(&array_iter, &struct_iter))
{
goto fail_unref;
@ -226,6 +278,7 @@ static void run_custom(struct dbus_method_call * call_ptr)
char * end;
unsigned int index;
struct ladish_app * app_ptr;
dbus_bool_t running;
if (!dbus_message_get_args(
call_ptr->message,
@ -326,28 +379,260 @@ static void run_custom(struct dbus_method_call * call_ptr)
log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
running = true;
terminal = app_ptr->terminal;
dbus_signal_emit(
g_dbus_connection,
supervisor_ptr->opath,
IFACE_APP_SUPERVISOR,
"AppAdded",
"ttsbby",
&supervisor_ptr->version,
&app_ptr->id,
&app_ptr->name,
&running,
&terminal,
&app_ptr->level);
method_return_new_void(call_ptr);
}
static void start_app(struct dbus_method_call * call_ptr)
{
uint64_t id;
struct ladish_app * app_ptr;
if (!dbus_message_get_args(
call_ptr->message,
&g_dbus_error,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_INVALID))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return;
}
app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
if (app_ptr == NULL)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
return;
}
if (app_ptr->pid != 0)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is already running", app_ptr->name);
return;
}
if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", app_ptr->commandline);
return;
}
log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
method_return_new_void(call_ptr);
}
static void stop_app(struct dbus_method_call * call_ptr)
{
uint64_t id;
struct ladish_app * app_ptr;
if (!dbus_message_get_args(
call_ptr->message,
&g_dbus_error,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_INVALID))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return;
}
app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
if (app_ptr == NULL)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
return;
}
if (app_ptr->pid == 0)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
return;
}
kill(app_ptr->pid, SIGTERM);
method_return_new_void(call_ptr);
}
static void kill_app(struct dbus_method_call * call_ptr)
{
uint64_t id;
struct ladish_app * app_ptr;
if (!dbus_message_get_args(
call_ptr->message,
&g_dbus_error,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_INVALID))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return;
}
app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
if (app_ptr == NULL)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
return;
}
if (app_ptr->pid == 0)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
return;
}
kill(app_ptr->pid, SIGKILL);
method_return_new_void(call_ptr);
}
static void get_app_properties(struct dbus_method_call * call_ptr)
{
}
static void set_app_properties(struct dbus_method_call * call_ptr)
{
}
static void remove_app(struct dbus_method_call * call_ptr)
{
}
static void is_app_running(struct dbus_method_call * call_ptr)
{
uint64_t id;
struct ladish_app * app_ptr;
dbus_bool_t running;
if (!dbus_message_get_args(
call_ptr->message,
&g_dbus_error,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_INVALID))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return;
}
app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
if (app_ptr == NULL)
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
return;
}
running = app_ptr->pid != 0;
method_return_new_single(call_ptr, DBUS_TYPE_BOOLEAN, &running);
}
#undef supervisor_ptr
METHOD_ARGS_BEGIN(GetAll, "Get list of running apps")
METHOD_ARG_DESCRIBE_OUT("list_version", "t", "Version of the list")
METHOD_ARG_DESCRIBE_OUT("apps_list", "a(ts)", "List of running apps")
METHOD_ARGS_BEGIN(GetAll, "Get list of apps")
METHOD_ARG_DESCRIBE_OUT("list_version", DBUS_TYPE_UINT64_AS_STRING, "Version of the list")
METHOD_ARG_DESCRIBE_OUT("apps_list", "a(tsbby)", "List of apps")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(RunCustom, "Start application by supplying commandline")
METHOD_ARG_DESCRIBE_IN("terminal", "b", "Whether to run in terminal")
METHOD_ARG_DESCRIBE_IN("commandline", "s", "Commandline")
METHOD_ARG_DESCRIBE_IN("name", "s", "Name")
METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "Name")
METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(StartApp, "Start application")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(StopApp, "Stop application")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(KillApp, "Kill application")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(GetAppProperties, "Get properties of an application")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARG_DESCRIBE_OUT("name", DBUS_TYPE_STRING_AS_STRING, "")
METHOD_ARG_DESCRIBE_OUT("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
METHOD_ARG_DESCRIBE_OUT("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
METHOD_ARG_DESCRIBE_OUT("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(SetAppProperties, "Set properties of an application")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "")
METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
METHOD_ARGS_END
METHOD_ARGS_BEGIN(IsAppRunning, "Check whether application is running")
METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether app is running")
METHOD_ARGS_END
METHODS_BEGIN
METHOD_DESCRIBE(GetAll, get_all)
METHOD_DESCRIBE(RunCustom, run_custom)
METHOD_DESCRIBE(StartApp, start_app)
METHOD_DESCRIBE(StopApp, stop_app)
METHOD_DESCRIBE(KillApp, kill_app)
METHOD_DESCRIBE(GetAppProperties, get_app_properties)
METHOD_DESCRIBE(SetAppProperties, set_app_properties)
METHOD_DESCRIBE(KillApp, remove_app)
METHOD_DESCRIBE(IsAppRunning, is_app_running)
METHODS_END
SIGNAL_ARGS_BEGIN(AppAdded, "")
SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
SIGNAL_ARGS_END
SIGNAL_ARGS_BEGIN(AppRemoved, "")
SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARGS_END
SIGNAL_ARGS_BEGIN(AppStateChanged, "")
SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
SIGNAL_ARGS_END
SIGNALS_BEGIN
SIGNAL_DESCRIBE(AppAdded)
SIGNAL_DESCRIBE(AppRemoved)
SIGNAL_DESCRIBE(AppStateChanged)
SIGNALS_END
INTERFACE_BEGIN(g_iface_app_supervisor, IFACE_APP_SUPERVISOR)

View File

@ -34,9 +34,197 @@ struct ladish_app_supervisor_proxy
char * service;
char * object;
uint64_t version;
void * context;
void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level);
void (* app_removed)(void * context, uint64_t id);
};
bool ladish_app_supervisor_proxy_create(const char * service, const char * object, ladish_app_supervisor_proxy_handle * handle_ptr)
static const char * g_signals[] =
{
"AppAdded",
"AppRemoved",
"AppStateChanged",
NULL
};
#define proxy_ptr ((struct ladish_app_supervisor_proxy *)proxy)
static
DBusHandlerResult
message_hook(
DBusConnection * connection,
DBusMessage * message,
void * proxy)
{
const char * object_path;
uint64_t new_list_version;
uint64_t id;
const char * name;
dbus_bool_t running;
dbus_bool_t terminal;
uint8_t level;
object_path = dbus_message_get_path(message);
if (object_path == NULL || strcmp(object_path, proxy_ptr->object) != 0)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppAdded"))
{
if (!dbus_message_get_args(
message,
&g_dbus_error,
DBUS_TYPE_UINT64, &new_list_version,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_BOOLEAN, &running,
DBUS_TYPE_BOOLEAN, &terminal,
DBUS_TYPE_BYTE, &level,
DBUS_TYPE_INVALID))
{
log_error("dbus_message_get_args() failed to extract AppAdded signal arguments (%s)", g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
//log_info("AppAdded signal received. id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level);
proxy_ptr->app_added(proxy_ptr->context, id, name, running, terminal, level);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppRemoved"))
{
if (!dbus_message_get_args(
message,
&g_dbus_error,
DBUS_TYPE_UINT64, &new_list_version,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_INVALID))
{
log_error("dbus_message_get_args() failed to extract AppRemoved signal arguments (%s)", g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
//log_info("AppRemoved signal received, id=%"PRIu64, id);
proxy_ptr->app_removed(proxy_ptr->context, id);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus_message_is_signal(message, IFACE_APP_SUPERVISOR, "AppStateChanged"))
{
if (!dbus_message_get_args(
message,
&g_dbus_error,
DBUS_TYPE_UINT64, &new_list_version,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_BOOLEAN, &running,
DBUS_TYPE_BOOLEAN, &terminal,
DBUS_TYPE_BYTE, &level,
DBUS_TYPE_INVALID))
{
log_error("dbus_message_get_args() failed to extract AppStateChanged signal arguments (%s)", g_dbus_error.message);
dbus_error_free(&g_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
log_info("AppStateChanged signal received");
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
#undef proxy_ptr
static void refresh_internal(struct ladish_app_supervisor_proxy * proxy_ptr, bool force)
{
DBusMessage* reply_ptr;
DBusMessageIter iter;
dbus_uint64_t version;
const char * reply_signature;
DBusMessageIter array_iter;
DBusMessageIter struct_iter;
uint64_t id;
const char * name;
dbus_bool_t running;
dbus_bool_t terminal;
uint8_t level;
log_info("refresh_internal() called");
version = proxy_ptr->version;
if (!dbus_call(proxy_ptr->service, proxy_ptr->object, IFACE_APP_SUPERVISOR, "GetAll", "t", &version, NULL, &reply_ptr))
{
log_error("GetAll() failed.");
return;
}
reply_signature = dbus_message_get_signature(reply_ptr);
if (strcmp(reply_signature, "ta(tsbby)") != 0)
{
log_error("GetAll() reply signature mismatch. '%s'", reply_signature);
goto unref;
}
dbus_message_iter_init(reply_ptr, &iter);
//log_info_msg("version " + (char)dbus_message_iter_get_arg_type(&iter));
dbus_message_iter_get_basic(&iter, &version);
dbus_message_iter_next(&iter);
if (!force && version <= proxy_ptr->version)
{
goto unref;
}
//log_info("got new list version %llu", (unsigned long long)version);
proxy_ptr->version = version;
for (dbus_message_iter_recurse(&iter, &array_iter);
dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_INVALID;
dbus_message_iter_next(&array_iter))
{
dbus_message_iter_recurse(&array_iter, &struct_iter);
dbus_message_iter_get_basic(&struct_iter, &id);
dbus_message_iter_next(&struct_iter);
dbus_message_iter_get_basic(&struct_iter, &name);
dbus_message_iter_next(&struct_iter);
dbus_message_iter_get_basic(&struct_iter, &running);
dbus_message_iter_next(&struct_iter);
dbus_message_iter_get_basic(&struct_iter, &terminal);
dbus_message_iter_next(&struct_iter);
dbus_message_iter_get_basic(&struct_iter, &level);
dbus_message_iter_next(&struct_iter);
//log_info("App id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level);
proxy_ptr->app_added(proxy_ptr->context, id, name, running, terminal, level);
dbus_message_iter_next(&struct_iter);
}
unref:
dbus_message_unref(reply_ptr);
}
bool
ladish_app_supervisor_proxy_create(
const char * service,
const char * object,
void * context,
void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level),
void (* app_removed)(void * context, uint64_t id),
ladish_app_supervisor_proxy_handle * handle_ptr)
{
struct ladish_app_supervisor_proxy * proxy_ptr;
@ -63,6 +251,24 @@ bool ladish_app_supervisor_proxy_create(const char * service, const char * objec
proxy_ptr->version = 0;
proxy_ptr->context = context;
proxy_ptr->app_added = app_added;
proxy_ptr->app_removed = app_removed;
if (!dbus_register_object_signal_handler(
g_dbus_connection,
proxy_ptr->service,
proxy_ptr->object,
IFACE_APP_SUPERVISOR,
g_signals,
message_hook,
proxy_ptr))
{
return false;
}
refresh_internal(proxy_ptr, true);
*handle_ptr = (ladish_app_supervisor_proxy_handle)proxy_ptr;
return true;
@ -81,6 +287,15 @@ fail:
void ladish_app_supervisor_proxy_destroy(ladish_app_supervisor_proxy_handle proxy)
{
dbus_unregister_object_signal_handler(
g_dbus_connection,
proxy_ptr->service,
proxy_ptr->object,
IFACE_APP_SUPERVISOR,
g_signals,
message_hook,
proxy_ptr);
free(proxy_ptr->object);
free(proxy_ptr->service);
free(proxy_ptr);

View File

@ -31,7 +31,15 @@
typedef struct ladish_app_supervisor_proxy_tag { int unused; } * ladish_app_supervisor_proxy_handle;
bool ladish_app_supervisor_proxy_create(const char * service, const char * object, ladish_app_supervisor_proxy_handle * proxy_ptr);
bool
ladish_app_supervisor_proxy_create(
const char * service,
const char * object,
void * context,
void (* app_added)(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level),
void (* app_removed)(void * context, uint64_t id),
ladish_app_supervisor_proxy_handle * proxy_ptr);
void ladish_app_supervisor_proxy_destroy(ladish_app_supervisor_proxy_handle proxy);
bool ladish_app_supervisor_proxy_run_custom(ladish_app_supervisor_proxy_handle proxy, const char * command, const char * name, bool run_in_terminal);

View File

@ -52,6 +52,16 @@ void view_init(void)
g_current_view = NULL;
}
static void app_added(void * context, uint64_t id, const char * name, bool running, bool terminal, uint8_t level)
{
log_info("app added. id=%"PRIu64", name='%s', %srunning, %s, level %u", id, name, running ? "" : "not ", terminal ? "terminal" : "shell", (unsigned int)level);
}
static void app_removed(void * context, uint64_t id)
{
log_info("app removed. id=%"PRIu64, id);
}
bool
create_view(
const char * name,
@ -80,7 +90,7 @@ create_view(
if (app_supervisor_supported)
{
if (!ladish_app_supervisor_proxy_create(service, object, &view_ptr->app_supervisor))
if (!ladish_app_supervisor_proxy_create(service, object, view_ptr, app_added, app_removed, &view_ptr->app_supervisor))
{
goto free_name;
}