ladishd: app list serialization; autolaunch on load
[ladish.git] / daemon / app_supervisor.c
blob1658b8494f9f421e0c36ea246a53326c8e86d851
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"
36 struct ladish_app
38 struct list_head siblings;
39 uint64_t id;
40 char * name;
41 char * commandline;
42 bool terminal;
43 uint8_t level;
44 pid_t pid;
45 bool zombie;
46 bool hidden;
47 bool autorun;
50 struct ladish_app_supervisor
52 char * name;
53 char * opath;
54 uint64_t version;
55 uint64_t next_id;
56 struct list_head applist;
59 bool ladish_app_supervisor_create(ladish_app_supervisor_handle * supervisor_handle_ptr, const char * opath, const char * name)
61 struct ladish_app_supervisor * supervisor_ptr;
63 supervisor_ptr = malloc(sizeof(struct ladish_app_supervisor));
64 if (supervisor_ptr == NULL)
66 log_error("malloc() failed to allocate struct ladish_app_supervisor");
67 return false;
70 supervisor_ptr->opath = strdup(opath);
71 if (supervisor_ptr->opath == NULL)
73 log_error("strdup() failed for app supervisor opath");
74 free(supervisor_ptr);
75 return false;
78 supervisor_ptr->name = strdup(name);
79 if (supervisor_ptr->name == NULL)
81 log_error("strdup() failed for app supervisor name");
82 free(supervisor_ptr->opath);
83 free(supervisor_ptr);
84 return false;
87 supervisor_ptr->version = 0;
88 supervisor_ptr->next_id = 1;
90 INIT_LIST_HEAD(&supervisor_ptr->applist);
92 *supervisor_handle_ptr = (ladish_app_supervisor_handle)supervisor_ptr;
94 return true;
97 struct ladish_app * ladish_app_supervisor_find_app_by_name(struct ladish_app_supervisor * supervisor_ptr, const char * name)
99 struct list_head * node_ptr;
100 struct ladish_app * app_ptr;
102 list_for_each(node_ptr, &supervisor_ptr->applist)
104 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
105 if (strcmp(app_ptr->name, name) == 0)
107 return app_ptr;
111 return NULL;
114 struct ladish_app * ladish_app_supervisor_find_app_by_id(struct ladish_app_supervisor * supervisor_ptr, uint64_t id)
116 struct list_head * node_ptr;
117 struct ladish_app * app_ptr;
119 list_for_each(node_ptr, &supervisor_ptr->applist)
121 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
122 if (app_ptr->id == id)
124 return app_ptr;
128 return NULL;
131 static
132 struct ladish_app *
133 add_app_internal(
134 struct ladish_app_supervisor * supervisor_ptr,
135 const char * name,
136 const char * commandline,
137 dbus_bool_t terminal,
138 dbus_bool_t autorun,
139 uint8_t level)
141 struct ladish_app * app_ptr;
142 dbus_bool_t running;
144 app_ptr = malloc(sizeof(struct ladish_app));
145 if (app_ptr == NULL)
147 log_error("malloc of struct ladish_app failed");
148 return NULL;
151 app_ptr->name = strdup(name);
152 if (app_ptr->name == NULL)
154 log_error("strdup() failed for app name");
155 free(app_ptr);
156 return NULL;
159 app_ptr->commandline = strdup(commandline);
160 if (app_ptr->commandline == NULL)
162 log_error("strdup() failed for app commandline");
163 free(app_ptr->name);
164 free(app_ptr);
165 return NULL;
168 app_ptr->terminal = terminal;
169 app_ptr->level = level;
170 app_ptr->pid = 0;
172 app_ptr->id = supervisor_ptr->next_id++;
173 app_ptr->zombie = false;
174 app_ptr->hidden = false;
175 app_ptr->autorun = autorun;
176 list_add_tail(&app_ptr->siblings, &supervisor_ptr->applist);
178 running = false;
179 dbus_signal_emit(
180 g_dbus_connection,
181 supervisor_ptr->opath,
182 IFACE_APP_SUPERVISOR,
183 "AppAdded",
184 "ttsbby",
185 &supervisor_ptr->version,
186 &app_ptr->id,
187 &app_ptr->name,
188 &running,
189 &terminal,
190 &app_ptr->level);
192 return app_ptr;
195 void remove_app_internal(struct ladish_app_supervisor * supervisor_ptr, struct ladish_app * app_ptr)
197 list_del(&app_ptr->siblings);
199 if (!app_ptr->hidden)
201 dbus_signal_emit(
202 g_dbus_connection,
203 supervisor_ptr->opath,
204 IFACE_APP_SUPERVISOR,
205 "AppRemoved",
206 "tt",
207 &supervisor_ptr->version,
208 &app_ptr->id);
211 free(app_ptr->name);
212 free(app_ptr->commandline);
213 free(app_ptr);
216 void emit_app_state_changed(struct ladish_app_supervisor * supervisor_ptr, struct ladish_app * app_ptr)
218 dbus_bool_t running;
219 dbus_bool_t terminal;
221 if (app_ptr->hidden)
223 return;
226 running = app_ptr->pid != 0;
227 terminal = app_ptr->terminal;
229 dbus_signal_emit(
230 g_dbus_connection,
231 supervisor_ptr->opath,
232 IFACE_APP_SUPERVISOR,
233 "AppStateChanged",
234 "tsbby",
235 &app_ptr->id,
236 &app_ptr->name,
237 &running,
238 &terminal,
239 &app_ptr->level);
242 #define supervisor_ptr ((struct ladish_app_supervisor *)supervisor_handle)
244 void ladish_app_supervisor_clear(ladish_app_supervisor_handle supervisor_handle)
246 struct list_head * node_ptr;
247 struct list_head * safe_node_ptr;
248 struct ladish_app * app_ptr;
250 list_for_each_safe(node_ptr, safe_node_ptr, &supervisor_ptr->applist)
252 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
253 if (app_ptr->pid != 0)
255 log_info("terminating '%s'...", app_ptr->name);
256 app_ptr->zombie = true;
257 kill(app_ptr->pid, SIGTERM);
259 else
261 log_info("removing '%s'", app_ptr->name);
262 remove_app_internal(supervisor_ptr, app_ptr);
267 void ladish_app_supervisor_destroy(ladish_app_supervisor_handle supervisor_handle)
269 ladish_app_supervisor_clear(supervisor_handle);
270 free(supervisor_ptr->name);
271 free(supervisor_ptr->opath);
272 free(supervisor_ptr);
275 bool ladish_app_supervisor_child_exit(ladish_app_supervisor_handle supervisor_handle, pid_t pid)
277 struct list_head * node_ptr;
278 struct ladish_app * app_ptr;
280 list_for_each(node_ptr, &supervisor_ptr->applist)
282 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
283 if (app_ptr->pid == pid)
285 log_info("exit of studio child '%s' detected.", app_ptr->name);
287 app_ptr->pid = 0;
288 if (app_ptr->zombie)
290 remove_app_internal(supervisor_ptr, app_ptr);
292 else
294 emit_app_state_changed(supervisor_ptr, app_ptr);
297 return true;
301 return false;
304 bool
305 ladish_app_supervisor_enum(
306 ladish_app_supervisor_handle supervisor_handle,
307 void * context,
308 bool (* callback)(void * context, const char * name, bool running, const char * command, bool terminal, uint8_t level))
310 struct list_head * node_ptr;
311 struct ladish_app * app_ptr;
313 list_for_each(node_ptr, &supervisor_ptr->applist)
315 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
317 if (app_ptr->hidden)
319 continue;
322 if (!callback(context, app_ptr->name, app_ptr->pid != 0, app_ptr->commandline, app_ptr->terminal, app_ptr->level))
324 return false;
328 return true;
331 bool
332 ladish_app_supervisor_add(
333 ladish_app_supervisor_handle supervisor_handle,
334 const char * name,
335 bool autorun,
336 const char * command,
337 bool terminal,
338 uint8_t level)
340 struct ladish_app * app_ptr;
342 app_ptr = add_app_internal(supervisor_ptr, name, command, terminal, autorun, level);
343 if (app_ptr == NULL)
345 log_error("add_app_internal() failed");
346 return false;
349 return true;
352 void ladish_app_supervisor_autorun(ladish_app_supervisor_handle supervisor_handle)
354 struct list_head * node_ptr;
355 struct ladish_app * app_ptr;
357 list_for_each(node_ptr, &supervisor_ptr->applist)
359 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
361 if (!app_ptr->autorun)
363 continue;
366 app_ptr->autorun = false;
368 log_info("autorun('%s', %s, '%s') called", app_ptr->name, app_ptr->terminal ? "terminal" : "shell", app_ptr->commandline);
370 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
372 log_error("Execution of '%s' failed", app_ptr->commandline);
373 return;
376 emit_app_state_changed(supervisor_ptr, app_ptr);
380 #undef supervisor_ptr
381 #define supervisor_ptr ((struct ladish_app_supervisor *)call_ptr->iface_context)
383 static void get_all(struct dbus_method_call * call_ptr)
385 DBusMessageIter iter, array_iter, struct_iter;
386 struct list_head * node_ptr;
387 struct ladish_app * app_ptr;
388 dbus_bool_t running;
389 dbus_bool_t terminal;
391 log_info("get_all called");
393 call_ptr->reply = dbus_message_new_method_return(call_ptr->message);
394 if (call_ptr->reply == NULL)
396 goto fail;
399 dbus_message_iter_init_append(call_ptr->reply, &iter);
401 if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT64, &supervisor_ptr->version))
403 goto fail_unref;
406 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(tsbby)", &array_iter))
408 goto fail_unref;
411 list_for_each(node_ptr, &supervisor_ptr->applist)
413 app_ptr = list_entry(node_ptr, struct ladish_app, siblings);
415 if (app_ptr->hidden)
417 continue;
420 log_info("app '%s' (%llu)", app_ptr->name, (unsigned long long)app_ptr->id);
422 if (!dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter))
424 goto fail_unref;
427 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_UINT64, &app_ptr->id))
429 goto fail_unref;
432 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &app_ptr->name))
434 goto fail_unref;
437 running = app_ptr->pid != 0;
438 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &running))
440 goto fail_unref;
443 terminal = app_ptr->terminal;
444 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BOOLEAN, &terminal))
446 goto fail_unref;
449 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_BYTE, &app_ptr->level))
451 goto fail_unref;
454 if (!dbus_message_iter_close_container(&array_iter, &struct_iter))
456 goto fail_unref;
460 if (!dbus_message_iter_close_container(&iter, &array_iter))
462 goto fail_unref;
465 return;
467 fail_unref:
468 dbus_message_unref(call_ptr->reply);
469 call_ptr->reply = NULL;
471 fail:
472 log_error("Ran out of memory trying to construct method return");
475 static void run_custom(struct dbus_method_call * call_ptr)
477 dbus_bool_t terminal;
478 const char * commandline;
479 const char * name_param;
480 char * name;
481 size_t len;
482 char * end;
483 unsigned int index;
484 struct ladish_app * app_ptr;
486 if (!dbus_message_get_args(
487 call_ptr->message,
488 &g_dbus_error,
489 DBUS_TYPE_BOOLEAN, &terminal,
490 DBUS_TYPE_STRING, &commandline,
491 DBUS_TYPE_STRING, &name_param,
492 DBUS_TYPE_INVALID))
494 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
495 dbus_error_free(&g_dbus_error);
496 return;
499 log_info("run_custom('%s', %s, '%s') called", name_param, terminal ? "terminal" : "shell", commandline);
501 if (*name_param)
503 /* allocate and copy app name */
504 len = strlen(name_param);
505 name = malloc(len + 100);
506 if (name == NULL)
508 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
509 return;
512 strcpy(name, name_param);
514 end = name + len;
516 else
518 /* allocate app name */
519 len = strlen(commandline) + 100;
520 name = malloc(len);
521 if (name == NULL)
523 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "malloc of app name failed");
524 return;
527 strcpy(name, commandline);
529 /* use first word as name */
530 end = name;
531 while (*end)
533 if (isspace(*end))
535 *end = 0;
536 break;
539 end++;
543 /* make the app name unique */
544 index = 2;
545 while (ladish_app_supervisor_find_app_by_name(supervisor_ptr, name) != NULL)
547 sprintf(end, "-%u", index);
548 index++;
551 app_ptr = add_app_internal(supervisor_ptr, name, commandline, terminal, false, 0);
552 if (app_ptr == NULL)
554 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "add_app_internal() failed");
555 free(name);
556 return;
559 if (!loader_execute(supervisor_ptr->name, name, "/", terminal, commandline, &app_ptr->pid))
561 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", commandline);
562 remove_app_internal(supervisor_ptr, app_ptr);
563 free(name);
564 return;
567 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
569 emit_app_state_changed(supervisor_ptr, app_ptr);
571 method_return_new_void(call_ptr);
574 static void start_app(struct dbus_method_call * call_ptr)
576 uint64_t id;
577 struct ladish_app * app_ptr;
579 if (!dbus_message_get_args(
580 call_ptr->message,
581 &g_dbus_error,
582 DBUS_TYPE_UINT64, &id,
583 DBUS_TYPE_INVALID))
585 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
586 dbus_error_free(&g_dbus_error);
587 return;
590 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
591 if (app_ptr == NULL)
593 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
594 return;
597 if (app_ptr->pid != 0)
599 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is already running", app_ptr->name);
600 return;
603 app_ptr->zombie = false;
604 if (!loader_execute(supervisor_ptr->name, app_ptr->name, "/", app_ptr->terminal, app_ptr->commandline, &app_ptr->pid))
606 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "Execution of '%s' failed", app_ptr->commandline);
607 return;
610 emit_app_state_changed(supervisor_ptr, app_ptr);
611 log_info("%s pid is %lu", app_ptr->name, (unsigned long)app_ptr->pid);
613 method_return_new_void(call_ptr);
616 static void stop_app(struct dbus_method_call * call_ptr)
618 uint64_t id;
619 struct ladish_app * app_ptr;
621 if (!dbus_message_get_args(
622 call_ptr->message,
623 &g_dbus_error,
624 DBUS_TYPE_UINT64, &id,
625 DBUS_TYPE_INVALID))
627 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
628 dbus_error_free(&g_dbus_error);
629 return;
632 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
633 if (app_ptr == NULL)
635 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
636 return;
639 if (app_ptr->pid == 0)
641 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
642 return;
645 kill(app_ptr->pid, SIGTERM);
647 method_return_new_void(call_ptr);
650 static void kill_app(struct dbus_method_call * call_ptr)
652 uint64_t id;
653 struct ladish_app * app_ptr;
655 if (!dbus_message_get_args(
656 call_ptr->message,
657 &g_dbus_error,
658 DBUS_TYPE_UINT64, &id,
659 DBUS_TYPE_INVALID))
661 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
662 dbus_error_free(&g_dbus_error);
663 return;
666 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
667 if (app_ptr == NULL)
669 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
670 return;
673 if (app_ptr->pid == 0)
675 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App %s is not running", app_ptr->name);
676 return;
679 kill(app_ptr->pid, SIGKILL);
681 method_return_new_void(call_ptr);
684 static void get_app_properties(struct dbus_method_call * call_ptr)
688 static void set_app_properties(struct dbus_method_call * call_ptr)
692 static void remove_app(struct dbus_method_call * call_ptr)
694 uint64_t id;
695 struct ladish_app * app_ptr;
697 if (!dbus_message_get_args(
698 call_ptr->message,
699 &g_dbus_error,
700 DBUS_TYPE_UINT64, &id,
701 DBUS_TYPE_INVALID))
703 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
704 dbus_error_free(&g_dbus_error);
705 return;
708 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
709 if (app_ptr == NULL)
711 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
712 return;
715 if (app_ptr->pid != 0)
717 app_ptr->zombie = true;
718 kill(app_ptr->pid, SIGTERM);
720 else
722 remove_app_internal(supervisor_ptr, app_ptr);
725 method_return_new_void(call_ptr);
728 static void is_app_running(struct dbus_method_call * call_ptr)
730 uint64_t id;
731 struct ladish_app * app_ptr;
732 dbus_bool_t running;
734 if (!dbus_message_get_args(
735 call_ptr->message,
736 &g_dbus_error,
737 DBUS_TYPE_UINT64, &id,
738 DBUS_TYPE_INVALID))
740 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message);
741 dbus_error_free(&g_dbus_error);
742 return;
745 app_ptr = ladish_app_supervisor_find_app_by_id(supervisor_ptr, id);
746 if (app_ptr == NULL)
748 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "App with ID %"PRIu64" not found", id);
749 return;
752 running = app_ptr->pid != 0;
754 method_return_new_single(call_ptr, DBUS_TYPE_BOOLEAN, &running);
757 #undef supervisor_ptr
759 METHOD_ARGS_BEGIN(GetAll, "Get list of apps")
760 METHOD_ARG_DESCRIBE_OUT("list_version", DBUS_TYPE_UINT64_AS_STRING, "Version of the list")
761 METHOD_ARG_DESCRIBE_OUT("apps_list", "a(tsbby)", "List of apps")
762 METHOD_ARGS_END
764 METHOD_ARGS_BEGIN(RunCustom, "Start application by supplying commandline")
765 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
766 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
767 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "Name")
768 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
769 METHOD_ARGS_END
771 METHOD_ARGS_BEGIN(StartApp, "Start application")
772 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
773 METHOD_ARGS_END
775 METHOD_ARGS_BEGIN(StopApp, "Stop application")
776 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
777 METHOD_ARGS_END
779 METHOD_ARGS_BEGIN(KillApp, "Kill application")
780 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
781 METHOD_ARGS_END
783 METHOD_ARGS_BEGIN(RemoveApp, "Remove application")
784 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
785 METHOD_ARGS_END
787 METHOD_ARGS_BEGIN(GetAppProperties, "Get properties of an application")
788 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
789 METHOD_ARG_DESCRIBE_OUT("name", DBUS_TYPE_STRING_AS_STRING, "")
790 METHOD_ARG_DESCRIBE_OUT("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
791 METHOD_ARG_DESCRIBE_OUT("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
792 METHOD_ARG_DESCRIBE_OUT("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
793 METHOD_ARGS_END
795 METHOD_ARGS_BEGIN(SetAppProperties, "Set properties of an application")
796 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
797 METHOD_ARG_DESCRIBE_IN("name", DBUS_TYPE_STRING_AS_STRING, "")
798 METHOD_ARG_DESCRIBE_IN("commandline", DBUS_TYPE_STRING_AS_STRING, "Commandline")
799 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
800 METHOD_ARG_DESCRIBE_IN("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
801 METHOD_ARGS_END
803 METHOD_ARGS_BEGIN(IsAppRunning, "Check whether application is running")
804 METHOD_ARG_DESCRIBE_IN("id", DBUS_TYPE_UINT64_AS_STRING, "id of app")
805 METHOD_ARG_DESCRIBE_IN("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether app is running")
806 METHOD_ARGS_END
809 METHODS_BEGIN
810 METHOD_DESCRIBE(GetAll, get_all)
811 METHOD_DESCRIBE(RunCustom, run_custom)
812 METHOD_DESCRIBE(StartApp, start_app)
813 METHOD_DESCRIBE(StopApp, stop_app)
814 METHOD_DESCRIBE(KillApp, kill_app)
815 METHOD_DESCRIBE(GetAppProperties, get_app_properties)
816 METHOD_DESCRIBE(SetAppProperties, set_app_properties)
817 METHOD_DESCRIBE(RemoveApp, remove_app)
818 METHOD_DESCRIBE(IsAppRunning, is_app_running)
819 METHODS_END
821 SIGNAL_ARGS_BEGIN(AppAdded, "")
822 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
823 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
824 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
825 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
826 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
827 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
828 SIGNAL_ARGS_END
830 SIGNAL_ARGS_BEGIN(AppRemoved, "")
831 SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
832 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
833 SIGNAL_ARGS_END
835 SIGNAL_ARGS_BEGIN(AppStateChanged, "")
836 SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
837 SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
838 SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")
839 SIGNAL_ARG_DESCRIBE("terminal", DBUS_TYPE_BOOLEAN_AS_STRING, "Whether to run in terminal")
840 SIGNAL_ARG_DESCRIBE("level", DBUS_TYPE_BYTE_AS_STRING, "Level")
841 SIGNAL_ARGS_END
843 SIGNALS_BEGIN
844 SIGNAL_DESCRIBE(AppAdded)
845 SIGNAL_DESCRIBE(AppRemoved)
846 SIGNAL_DESCRIBE(AppStateChanged)
847 SIGNALS_END
849 INTERFACE_BEGIN(g_iface_app_supervisor, IFACE_APP_SUPERVISOR)
850 INTERFACE_DEFAULT_HANDLER
851 INTERFACE_EXPOSE_METHODS
852 INTERFACE_EXPOSE_SIGNALS
853 INTERFACE_END