properly handle ladishd crashes
[ladish.git] / daemon / app_supervisor.c
blob1ac693631e2fbdd5d8677fa45553745e1bb94ad1
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 char * name_buffer;
524 size_t len;
525 char * end;
526 unsigned int index;
527 struct ladish_app * app_ptr;
529 if (!dbus_message_get_args(
530 call_ptr->message,
531 &g_dbus_error,
532 DBUS_TYPE_BOOLEAN, &terminal,
533 DBUS_TYPE_STRING, &commandline,
534 DBUS_TYPE_STRING, &name_param,
535 DBUS_TYPE_INVALID))
537 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
538 dbus_error_free(&g_dbus_error);
539 return;
542 log_info("run_custom('%s', %s, '%s') called", name_param, terminal ? "terminal" : "shell", commandline);
544 if (*name_param)
546 /* allocate and copy app name */
547 len = strlen(name_param);
548 name_buffer = malloc(len + 100);
549 if (name_buffer == NULL)
551 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
552 return;
555 name = name_buffer;
557 strcpy(name, name_param);
559 end = name + len;
561 else
563 /* allocate app name */
564 len = strlen(commandline) + 100;
565 name_buffer = malloc(len);
566 if (name_buffer == NULL)
568 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
569 return;
572 strcpy(name_buffer, commandline);
574 /* use first word as name */
575 end = name_buffer;
576 while (*end)
578 if (isspace(*end))
580 *end = 0;
581 break;
584 end++;
587 name = strrchr(name_buffer, '/');
588 if (name == NULL)
590 name = name_buffer;
592 else
594 name++;
598 /* make the app name unique */
599 index = 2;
600 while (ladish_app_supervisor_find_app_by_name(supervisor_ptr, name) != NULL)
602 sprintf(end, "-%u", index);
603 index++;
606 app_ptr = add_app_internal(supervisor_ptr, name, commandline, terminal, true, 0);
608 free(name_buffer);
610 if (app_ptr == NULL)
612 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "add_app_internal() failed");
613 return;
616 if (studio_is_started())
618 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", terminal, commandline, &app_ptr->pid))
620 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", commandline);
621 remove_app_internal(supervisor_ptr, app_ptr);
622 return;
625 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
627 emit_app_state_changed(supervisor_ptr, app_ptr);
630 method_return_new_void(call_ptr);
633 static void start_app(struct dbus_method_call * call_ptr)
635 uint64_t id;
636 struct ladish_app * app_ptr;
638 if (!dbus_message_get_args(
639 call_ptr->message,
640 &g_dbus_error,
641 DBUS_TYPE_UINT64, &id,
642 DBUS_TYPE_INVALID))
644 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
645 dbus_error_free(&g_dbus_error);
646 return;
649 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
650 if (app_ptr == NULL)
652 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
653 return;
656 if (app_ptr->pid != 0)
658 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is already running", app_ptr->name);
659 return;
662 app_ptr->zombie = false;
663 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
665 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", app_ptr->commandline);
666 return;
669 emit_app_state_changed(supervisor_ptr, app_ptr);
670 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
672 method_return_new_void(call_ptr);
675 static void stop_app(struct dbus_method_call * call_ptr)
677 uint64_t id;
678 struct ladish_app * app_ptr;
680 if (!dbus_message_get_args(
681 call_ptr->message,
682 &g_dbus_error,
683 DBUS_TYPE_UINT64, &id,
684 DBUS_TYPE_INVALID))
686 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
687 dbus_error_free(&g_dbus_error);
688 return;
691 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
692 if (app_ptr == NULL)
694 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
695 return;
698 if (app_ptr->pid == 0)
700 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
701 return;
704 kill(app_ptr->pid, SIGTERM);
706 method_return_new_void(call_ptr);
709 static void kill_app(struct dbus_method_call * call_ptr)
711 uint64_t id;
712 struct ladish_app * app_ptr;
714 if (!dbus_message_get_args(
715 call_ptr->message,
716 &g_dbus_error,
717 DBUS_TYPE_UINT64, &id,
718 DBUS_TYPE_INVALID))
720 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
721 dbus_error_free(&g_dbus_error);
722 return;
725 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
726 if (app_ptr == NULL)
728 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
729 return;
732 if (app_ptr->pid == 0)
734 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
735 return;
738 kill(app_ptr->pid, SIGKILL);
740 method_return_new_void(call_ptr);
743 static void get_app_properties(struct dbus_method_call * call_ptr)
747 static void set_app_properties(struct dbus_method_call * call_ptr)
751 static void remove_app(struct dbus_method_call * call_ptr)
753 uint64_t id;
754 struct ladish_app * app_ptr;
756 if (!dbus_message_get_args(
757 call_ptr->message,
758 &g_dbus_error,
759 DBUS_TYPE_UINT64, &id,
760 DBUS_TYPE_INVALID))
762 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
763 dbus_error_free(&g_dbus_error);
764 return;
767 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
768 if (app_ptr == NULL)
770 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
771 return;
774 if (app_ptr->pid != 0)
776 app_ptr->zombie = true;
777 kill(app_ptr->pid, SIGTERM);
779 else
781 remove_app_internal(supervisor_ptr, app_ptr);
784 method_return_new_void(call_ptr);
787 static void is_app_running(struct dbus_method_call * call_ptr)
789 uint64_t id;
790 struct ladish_app * app_ptr;
791 dbus_bool_t running;
793 if (!dbus_message_get_args(
794 call_ptr->message,
795 &g_dbus_error,
796 DBUS_TYPE_UINT64, &id,
797 DBUS_TYPE_INVALID))
799 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
800 dbus_error_free(&g_dbus_error);
801 return;
804 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
805 if (app_ptr == NULL)
807 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
808 return;
811 running = app_ptr->pid != 0;
813 method_return_new_single(call_ptr, DBUS_TYPE_BOOLEAN, &running);
816 #undef supervisor_ptr
818 METHOD_ARGS_BEGIN(GetAll, "Get list of apps")
819 METHOD_ARG_DESCRIBE_OUT("list_version", DBUS_TYPE_UINT64_AS_STRING, "Version of the list")
820 METHOD_ARG_DESCRIBE_OUT("apps_list", "a(tsbby)", "List of apps")
821 METHOD_ARGS_END
823 METHOD_ARGS_BEGIN(RunCustom, "Start application by supplying commandline")
824 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
825 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
826 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "Name")
827 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
828 METHOD_ARGS_END
830 METHOD_ARGS_BEGIN(StartApp, "Start application")
831 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
832 METHOD_ARGS_END
834 METHOD_ARGS_BEGIN(StopApp, "Stop application")
835 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
836 METHOD_ARGS_END
838 METHOD_ARGS_BEGIN(KillApp, "Kill application")
839 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
840 METHOD_ARGS_END
842 METHOD_ARGS_BEGIN(RemoveApp, "Remove application")
843 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
844 METHOD_ARGS_END
846 METHOD_ARGS_BEGIN(GetAppProperties, "Get properties of an application")
847 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
848 METHOD_ARG_DESCRIBE_OUT("name", DBUS_TYPE_STRING_AS_STRING, "")
849 METHOD_ARG_DESCRIBE_OUT("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
850 METHOD_ARG_DESCRIBE_OUT("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
851 METHOD_ARG_DESCRIBE_OUT("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
852 METHOD_ARGS_END
854 METHOD_ARGS_BEGIN(SetAppProperties, "Set properties of an application")
855 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
856 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "")
857 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
858 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
859 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
860 METHOD_ARGS_END
862 METHOD_ARGS_BEGIN(IsAppRunning, "Check whether application is running")
863 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
864 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether app is running")
865 METHOD_ARGS_END
868 METHODS_BEGIN
869 METHOD_DESCRIBE(GetAll, get_all)
870 METHOD_DESCRIBE(RunCustom, run_custom)
871 METHOD_DESCRIBE(StartApp, start_app)
872 METHOD_DESCRIBE(StopApp, stop_app)
873 METHOD_DESCRIBE(KillApp, kill_app)
874 METHOD_DESCRIBE(GetAppProperties, get_app_properties)
875 METHOD_DESCRIBE(SetAppProperties, set_app_properties)
876 METHOD_DESCRIBE(RemoveApp, remove_app)
877 METHOD_DESCRIBE(IsAppRunning, is_app_running)
878 METHODS_END
880 SIGNAL_ARGS_BEGIN(AppAdded, "")
881 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
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 SIGNAL_ARGS_BEGIN(AppRemoved, "")
890 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
891 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
892 SIGNAL_ARGS_END
894 SIGNAL_ARGS_BEGIN(AppStateChanged, "")
895 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
896 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
897 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
898 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
899 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
900 SIGNAL_ARGS_END
902 SIGNALS_BEGIN
903 SIGNAL_DESCRIBE(AppAdded)
904 SIGNAL_DESCRIBE(AppRemoved)
905 SIGNAL_DESCRIBE(AppStateChanged)
906 SIGNALS_END
908 INTERFACE_BEGIN(g_iface_app_supervisor, IFACE_APP_SUPERVISOR)
909 INTERFACE_DEFAULT_HANDLER
910 INTERFACE_EXPOSE_METHODS
911 INTERFACE_EXPOSE_SIGNALS
912 INTERFACE_END