daemon: fix a2j handling
[ladish.git] / daemon / app_supervisor.c
blob043a77a2dd16c14b28d44af51c1c11f37a5b8e37
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of app supervisor object
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <ctype.h>
28 #include <sys/types.h>
29 #include <signal.h>
31 #include "app_supervisor.h"
32 #include "../dbus/error.h"
33 #include "../dbus_constants.h"
34 #include "loader.h"
35 #include "studio_internal.h"
37 struct ladish_app
39 struct list_head siblings;
40 uint64_t id;
41 char * name;
42 char * commandline;
43 bool terminal;
44 uint8_t level;
45 pid_t pid;
46 bool zombie;
47 bool hidden;
48 bool autorun;
51 struct ladish_app_supervisor
53 char * name;
54 char * opath;
55 uint64_t version;
56 uint64_t next_id;
57 struct list_head applist;
60 bool ladish_app_supervisor_create(ladish_app_supervisor_handle * supervisor_handle_ptr, const char * opath, const char * name)
62 struct ladish_app_supervisor * supervisor_ptr;
64 supervisor_ptr = malloc(sizeof(struct ladish_app_supervisor));
65 if (supervisor_ptr == NULL)
67 log_error("malloc() failed to allocate struct ladish_app_supervisor");
68 return false;
71 supervisor_ptr->opath = strdup(opath);
72 if (supervisor_ptr->opath == NULL)
74 log_error("strdup() failed for app supervisor opath");
75 free(supervisor_ptr);
76 return false;
79 supervisor_ptr->name = strdup(name);
80 if (supervisor_ptr->name == NULL)
82 log_error("strdup() failed for app supervisor name");
83 free(supervisor_ptr->opath);
84 free(supervisor_ptr);
85 return false;
88 supervisor_ptr->version = 0;
89 supervisor_ptr->next_id = 1;
91 INIT_LIST_HEAD(&supervisor_ptr->applist);
93 *supervisor_handle_ptr = (ladish_app_supervisor_handle)supervisor_ptr;
95 return true;
98 struct ladish_app * ladish_app_supervisor_find_app_by_name(struct ladish_app_supervisor * supervisor_ptr, const char * name)
100 struct list_head * node_ptr;
101 struct ladish_app * app_ptr;
103 list_for_each(node_ptr, &supervisor_ptr->applist)
105 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
106 if (strcmp(app_ptr->name, name) == 0)
108 return app_ptr;
112 return NULL;
115 struct ladish_app * ladish_app_supervisor_find_app_by_id(struct ladish_app_supervisor * supervisor_ptr, uint64_t id)
117 struct list_head * node_ptr;
118 struct ladish_app * app_ptr;
120 list_for_each(node_ptr, &supervisor_ptr->applist)
122 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
123 if (app_ptr->id == id)
125 return app_ptr;
129 return NULL;
132 static
133 struct ladish_app *
134 add_app_internal(
135 struct ladish_app_supervisor * supervisor_ptr,
136 const char * name,
137 const char * commandline,
138 dbus_bool_t terminal,
139 dbus_bool_t autorun,
140 uint8_t level)
142 struct ladish_app * app_ptr;
143 dbus_bool_t running;
145 app_ptr = malloc(sizeof(struct ladish_app));
146 if (app_ptr == NULL)
148 log_error("malloc of struct ladish_app failed");
149 return NULL;
152 app_ptr->name = strdup(name);
153 if (app_ptr->name == NULL)
155 log_error("strdup() failed for app name");
156 free(app_ptr);
157 return NULL;
160 app_ptr->commandline = strdup(commandline);
161 if (app_ptr->commandline == NULL)
163 log_error("strdup() failed for app commandline");
164 free(app_ptr->name);
165 free(app_ptr);
166 return NULL;
169 app_ptr->terminal = terminal;
170 app_ptr->level = level;
171 app_ptr->pid = 0;
173 app_ptr->id = supervisor_ptr->next_id++;
174 app_ptr->zombie = false;
175 app_ptr->hidden = false;
176 app_ptr->autorun = autorun;
177 list_add_tail(&app_ptr->siblings, &supervisor_ptr->applist);
179 running = false;
180 dbus_signal_emit(
181 g_dbus_connection,
182 supervisor_ptr->opath,
183 IFACE_APP_SUPERVISOR,
184 "AppAdded",
185 "ttsbby",
186 &supervisor_ptr->version,
187 &app_ptr->id,
188 &app_ptr->name,
189 &running,
190 &terminal,
191 &app_ptr->level);
193 return app_ptr;
196 void remove_app_internal(struct ladish_app_supervisor * supervisor_ptr, struct ladish_app * app_ptr)
198 list_del(&app_ptr->siblings);
200 if (!app_ptr->hidden)
202 dbus_signal_emit(
203 g_dbus_connection,
204 supervisor_ptr->opath,
205 IFACE_APP_SUPERVISOR,
206 "AppRemoved",
207 "tt",
208 &supervisor_ptr->version,
209 &app_ptr->id);
212 free(app_ptr->name);
213 free(app_ptr->commandline);
214 free(app_ptr);
217 void emit_app_state_changed(struct ladish_app_supervisor * supervisor_ptr, struct ladish_app * app_ptr)
219 dbus_bool_t running;
220 dbus_bool_t terminal;
222 if (app_ptr->hidden)
224 return;
227 running = app_ptr->pid != 0;
228 terminal = app_ptr->terminal;
230 dbus_signal_emit(
231 g_dbus_connection,
232 supervisor_ptr->opath,
233 IFACE_APP_SUPERVISOR,
234 "AppStateChanged",
235 "tsbby",
236 &app_ptr->id,
237 &app_ptr->name,
238 &running,
239 &terminal,
240 &app_ptr->level);
243 #define supervisor_ptr ((struct ladish_app_supervisor *)supervisor_handle)
245 void ladish_app_supervisor_clear(ladish_app_supervisor_handle supervisor_handle)
247 struct list_head * node_ptr;
248 struct list_head * safe_node_ptr;
249 struct ladish_app * app_ptr;
251 list_for_each_safe(node_ptr, safe_node_ptr, &supervisor_ptr->applist)
253 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
254 if (app_ptr->pid != 0)
256 log_info("terminating '%s'...", app_ptr->name);
257 app_ptr->zombie = true;
258 kill(app_ptr->pid, SIGTERM);
260 else
262 log_info("removing '%s'", app_ptr->name);
263 remove_app_internal(supervisor_ptr, app_ptr);
268 void ladish_app_supervisor_destroy(ladish_app_supervisor_handle supervisor_handle)
270 ladish_app_supervisor_clear(supervisor_handle);
271 free(supervisor_ptr->name);
272 free(supervisor_ptr->opath);
273 free(supervisor_ptr);
276 bool ladish_app_supervisor_child_exit(ladish_app_supervisor_handle supervisor_handle, pid_t pid)
278 struct list_head * node_ptr;
279 struct ladish_app * app_ptr;
281 list_for_each(node_ptr, &supervisor_ptr->applist)
283 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
284 if (app_ptr->pid == pid)
286 log_info("exit of studio child '%s' detected.", app_ptr->name);
288 app_ptr->pid = 0;
289 if (app_ptr->zombie)
291 remove_app_internal(supervisor_ptr, app_ptr);
293 else
295 emit_app_state_changed(supervisor_ptr, app_ptr);
298 return true;
302 return false;
305 bool
306 ladish_app_supervisor_enum(
307 ladish_app_supervisor_handle supervisor_handle,
308 void * context,
309 bool (* callback)(void * context, const char * name, bool running, const char * command, bool terminal, uint8_t level))
311 struct list_head * node_ptr;
312 struct ladish_app * app_ptr;
314 list_for_each(node_ptr, &supervisor_ptr->applist)
316 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
318 if (app_ptr->hidden)
320 continue;
323 if (!callback(context, app_ptr->name, app_ptr->pid != 0, app_ptr->commandline, app_ptr->terminal, app_ptr->level))
325 return false;
329 return true;
332 bool
333 ladish_app_supervisor_add(
334 ladish_app_supervisor_handle supervisor_handle,
335 const char * name,
336 bool autorun,
337 const char * command,
338 bool terminal,
339 uint8_t level)
341 struct ladish_app * app_ptr;
343 app_ptr = add_app_internal(supervisor_ptr, name, command, terminal, autorun, level);
344 if (app_ptr == NULL)
346 log_error("add_app_internal() failed");
347 return false;
350 return true;
353 void ladish_app_supervisor_autorun(ladish_app_supervisor_handle supervisor_handle)
355 struct list_head * node_ptr;
356 struct ladish_app * app_ptr;
358 list_for_each(node_ptr, &supervisor_ptr->applist)
360 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
362 if (!app_ptr->autorun)
364 continue;
367 app_ptr->autorun = false;
369 log_info("autorun('%s', %s, '%s') called", app_ptr->name, app_ptr->terminal ? "terminal" : "shell", app_ptr->commandline);
371 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
373 log_error("Execution of '%s' failed", app_ptr->commandline);
374 return;
377 emit_app_state_changed(supervisor_ptr, app_ptr);
381 void ladish_app_supervisor_stop(ladish_app_supervisor_handle supervisor_handle)
383 struct list_head * node_ptr;
384 struct ladish_app * app_ptr;
386 list_for_each(node_ptr, &supervisor_ptr->applist)
388 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
389 if (app_ptr->pid != 0)
391 app_ptr->autorun = true;
392 log_info("terminating '%s'...", app_ptr->name);
393 kill(app_ptr->pid, SIGTERM);
398 char * ladish_app_supervisor_search_app(ladish_app_supervisor_handle supervisor_handle, pid_t pid)
400 struct list_head * node_ptr;
401 struct ladish_app * app_ptr;
402 char * name;
404 list_for_each(node_ptr, &supervisor_ptr->applist)
406 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
407 if (app_ptr->pid == pid)
409 name = strdup(app_ptr->name);
410 if (name == NULL)
412 log_error("strdup() failed for '%s'", app_ptr->name);
415 return name;
419 return NULL;
422 #undef supervisor_ptr
423 #define supervisor_ptr ((struct ladish_app_supervisor *)call_ptr->iface_context)
425 static void get_all(struct dbus_method_call * call_ptr)
427 DBusMessageIter iter, array_iter, struct_iter;
428 struct list_head * node_ptr;
429 struct ladish_app * app_ptr;
430 dbus_bool_t running;
431 dbus_bool_t terminal;
433 log_info("get_all called");
435 call_ptr->reply = dbus_message_new_method_return(call_ptr->message);
436 if (call_ptr->reply == NULL)
438 goto fail;
441 dbus_message_iter_init_append(call_ptr->reply, &iter);
443 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT64, &supervisor_ptr->version))
445 goto fail_unref;
448 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(tsbby)", &array_iter))
450 goto fail_unref;
453 list_for_each(node_ptr, &supervisor_ptr->applist)
455 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
457 if (app_ptr->hidden)
459 continue;
462 log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id);
464 if (!dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter))
466 goto fail_unref;
469 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_UINT64, &app_ptr->id))
471 goto fail_unref;
474 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &app_ptr->name))
476 goto fail_unref;
479 running = app_ptr->pid != 0;
480 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &running))
482 goto fail_unref;
485 terminal = app_ptr->terminal;
486 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &terminal))
488 goto fail_unref;
491 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BYTE, &app_ptr->level))
493 goto fail_unref;
496 if (!dbus_message_iter_close_container(&array_iter, &struct_iter))
498 goto fail_unref;
502 if (!dbus_message_iter_close_container(&iter, &array_iter))
504 goto fail_unref;
507 return;
509 fail_unref:
510 dbus_message_unref(call_ptr->reply);
511 call_ptr->reply = NULL;
513 fail:
514 log_error("Ran out of memory trying to construct method return");
517 static void run_custom(struct dbus_method_call * call_ptr)
519 dbus_bool_t terminal;
520 const char * commandline;
521 const char * name_param;
522 char * name;
523 size_t len;
524 char * end;
525 unsigned int index;
526 struct ladish_app * app_ptr;
528 if (!dbus_message_get_args(
529 call_ptr->message,
530 &g_dbus_error,
531 DBUS_TYPE_BOOLEAN, &terminal,
532 DBUS_TYPE_STRING, &commandline,
533 DBUS_TYPE_STRING, &name_param,
534 DBUS_TYPE_INVALID))
536 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
537 dbus_error_free(&g_dbus_error);
538 return;
541 log_info("run_custom('%s', %s, '%s') called", name_param, terminal ? "terminal" : "shell", commandline);
543 if (*name_param)
545 /* allocate and copy app name */
546 len = strlen(name_param);
547 name = malloc(len + 100);
548 if (name == NULL)
550 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
551 return;
554 strcpy(name, name_param);
556 end = name + len;
558 else
560 /* allocate app name */
561 len = strlen(commandline) + 100;
562 name = malloc(len);
563 if (name == NULL)
565 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
566 return;
569 strcpy(name, commandline);
571 /* use first word as name */
572 end = name;
573 while (*end)
575 if (isspace(*end))
577 *end = 0;
578 break;
581 end++;
585 /* make the app name unique */
586 index = 2;
587 while (ladish_app_supervisor_find_app_by_name(supervisor_ptr, name) != NULL)
589 sprintf(end, "-%u", index);
590 index++;
593 app_ptr = add_app_internal(supervisor_ptr, name, commandline, terminal, true, 0);
595 free(name);
597 if (app_ptr == NULL)
599 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "add_app_internal() failed");
600 return;
603 if (studio_is_started())
605 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", terminal, commandline, &app_ptr->pid))
607 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", commandline);
608 remove_app_internal(supervisor_ptr, app_ptr);
609 return;
612 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
614 emit_app_state_changed(supervisor_ptr, app_ptr);
617 method_return_new_void(call_ptr);
620 static void start_app(struct dbus_method_call * call_ptr)
622 uint64_t id;
623 struct ladish_app * app_ptr;
625 if (!dbus_message_get_args(
626 call_ptr->message,
627 &g_dbus_error,
628 DBUS_TYPE_UINT64, &id,
629 DBUS_TYPE_INVALID))
631 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
632 dbus_error_free(&g_dbus_error);
633 return;
636 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
637 if (app_ptr == NULL)
639 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
640 return;
643 if (app_ptr->pid != 0)
645 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is already running", app_ptr->name);
646 return;
649 app_ptr->zombie = false;
650 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
652 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", app_ptr->commandline);
653 return;
656 emit_app_state_changed(supervisor_ptr, app_ptr);
657 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
659 method_return_new_void(call_ptr);
662 static void stop_app(struct dbus_method_call * call_ptr)
664 uint64_t id;
665 struct ladish_app * app_ptr;
667 if (!dbus_message_get_args(
668 call_ptr->message,
669 &g_dbus_error,
670 DBUS_TYPE_UINT64, &id,
671 DBUS_TYPE_INVALID))
673 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
674 dbus_error_free(&g_dbus_error);
675 return;
678 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
679 if (app_ptr == NULL)
681 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
682 return;
685 if (app_ptr->pid == 0)
687 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
688 return;
691 kill(app_ptr->pid, SIGTERM);
693 method_return_new_void(call_ptr);
696 static void kill_app(struct dbus_method_call * call_ptr)
698 uint64_t id;
699 struct ladish_app * app_ptr;
701 if (!dbus_message_get_args(
702 call_ptr->message,
703 &g_dbus_error,
704 DBUS_TYPE_UINT64, &id,
705 DBUS_TYPE_INVALID))
707 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
708 dbus_error_free(&g_dbus_error);
709 return;
712 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
713 if (app_ptr == NULL)
715 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
716 return;
719 if (app_ptr->pid == 0)
721 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
722 return;
725 kill(app_ptr->pid, SIGKILL);
727 method_return_new_void(call_ptr);
730 static void get_app_properties(struct dbus_method_call * call_ptr)
734 static void set_app_properties(struct dbus_method_call * call_ptr)
738 static void remove_app(struct dbus_method_call * call_ptr)
740 uint64_t id;
741 struct ladish_app * app_ptr;
743 if (!dbus_message_get_args(
744 call_ptr->message,
745 &g_dbus_error,
746 DBUS_TYPE_UINT64, &id,
747 DBUS_TYPE_INVALID))
749 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
750 dbus_error_free(&g_dbus_error);
751 return;
754 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
755 if (app_ptr == NULL)
757 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
758 return;
761 if (app_ptr->pid != 0)
763 app_ptr->zombie = true;
764 kill(app_ptr->pid, SIGTERM);
766 else
768 remove_app_internal(supervisor_ptr, app_ptr);
771 method_return_new_void(call_ptr);
774 static void is_app_running(struct dbus_method_call * call_ptr)
776 uint64_t id;
777 struct ladish_app * app_ptr;
778 dbus_bool_t running;
780 if (!dbus_message_get_args(
781 call_ptr->message,
782 &g_dbus_error,
783 DBUS_TYPE_UINT64, &id,
784 DBUS_TYPE_INVALID))
786 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
787 dbus_error_free(&g_dbus_error);
788 return;
791 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
792 if (app_ptr == NULL)
794 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
795 return;
798 running = app_ptr->pid != 0;
800 method_return_new_single(call_ptr, DBUS_TYPE_BOOLEAN, &running);
803 #undef supervisor_ptr
805 METHOD_ARGS_BEGIN(GetAll, "Get list of apps")
806 METHOD_ARG_DESCRIBE_OUT("list_version", DBUS_TYPE_UINT64_AS_STRING, "Version of the list")
807 METHOD_ARG_DESCRIBE_OUT("apps_list", "a(tsbby)", "List of apps")
808 METHOD_ARGS_END
810 METHOD_ARGS_BEGIN(RunCustom, "Start application by supplying commandline")
811 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
812 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
813 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "Name")
814 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
815 METHOD_ARGS_END
817 METHOD_ARGS_BEGIN(StartApp, "Start application")
818 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
819 METHOD_ARGS_END
821 METHOD_ARGS_BEGIN(StopApp, "Stop application")
822 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
823 METHOD_ARGS_END
825 METHOD_ARGS_BEGIN(KillApp, "Kill application")
826 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
827 METHOD_ARGS_END
829 METHOD_ARGS_BEGIN(RemoveApp, "Remove application")
830 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
831 METHOD_ARGS_END
833 METHOD_ARGS_BEGIN(GetAppProperties, "Get properties of an application")
834 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
835 METHOD_ARG_DESCRIBE_OUT("name", DBUS_TYPE_STRING_AS_STRING, "")
836 METHOD_ARG_DESCRIBE_OUT("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
837 METHOD_ARG_DESCRIBE_OUT("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
838 METHOD_ARG_DESCRIBE_OUT("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
839 METHOD_ARGS_END
841 METHOD_ARGS_BEGIN(SetAppProperties, "Set properties of an application")
842 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
843 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "")
844 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
845 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
846 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
847 METHOD_ARGS_END
849 METHOD_ARGS_BEGIN(IsAppRunning, "Check whether application is running")
850 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
851 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether app is running")
852 METHOD_ARGS_END
855 METHODS_BEGIN
856 METHOD_DESCRIBE(GetAll, get_all)
857 METHOD_DESCRIBE(RunCustom, run_custom)
858 METHOD_DESCRIBE(StartApp, start_app)
859 METHOD_DESCRIBE(StopApp, stop_app)
860 METHOD_DESCRIBE(KillApp, kill_app)
861 METHOD_DESCRIBE(GetAppProperties, get_app_properties)
862 METHOD_DESCRIBE(SetAppProperties, set_app_properties)
863 METHOD_DESCRIBE(RemoveApp, remove_app)
864 METHOD_DESCRIBE(IsAppRunning, is_app_running)
865 METHODS_END
867 SIGNAL_ARGS_BEGIN(AppAdded, "")
868 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
869 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
870 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
871 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
872 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
873 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
874 SIGNAL_ARGS_END
876 SIGNAL_ARGS_BEGIN(AppRemoved, "")
877 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
878 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
879 SIGNAL_ARGS_END
881 SIGNAL_ARGS_BEGIN(AppStateChanged, "")
882 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
883 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
884 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
885 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
886 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
887 SIGNAL_ARGS_END
889 SIGNALS_BEGIN
890 SIGNAL_DESCRIBE(AppAdded)
891 SIGNAL_DESCRIBE(AppRemoved)
892 SIGNAL_DESCRIBE(AppStateChanged)
893 SIGNALS_END
895 INTERFACE_BEGIN(g_iface_app_supervisor, IFACE_APP_SUPERVISOR)
896 INTERFACE_DEFAULT_HANDLER
897 INTERFACE_EXPOSE_METHODS
898 INTERFACE_EXPOSE_SIGNALS
899 INTERFACE_END