2009-11-30 01:22:58 +02:00
|
|
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
|
|
|
/*
|
|
|
|
* LADI Session Handler (ladish)
|
|
|
|
*
|
2010-04-04 00:31:14 +03:00
|
|
|
* Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
2009-11-30 01:22:58 +02:00
|
|
|
*
|
|
|
|
**************************************************************************
|
|
|
|
* This file contains interface to app supervisor object
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* LADI Session Handler is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* LADI Session Handler is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
* or write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef APP_SUPERVISOR_H__712E6589_DCB1_4CE9_9812_4F250D55E8A2__INCLUDED
|
|
|
|
#define APP_SUPERVISOR_H__712E6589_DCB1_4CE9_9812_4F250D55E8A2__INCLUDED
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
typedef struct ladish_app_supervisor_tag { int unused; } * ladish_app_supervisor_handle;
|
2010-05-04 23:48:23 +03:00
|
|
|
typedef struct ladish_app_tag { int unused; } * ladish_app_handle;
|
2009-11-30 01:22:58 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* create app supervisor */
|
2009-12-26 21:44:09 +02:00
|
|
|
bool
|
|
|
|
ladish_app_supervisor_create(
|
|
|
|
ladish_app_supervisor_handle * supervisor_handle_ptr,
|
|
|
|
const char * opath,
|
2009-12-26 22:46:20 +02:00
|
|
|
const char * name,
|
2010-04-04 22:05:25 +03:00
|
|
|
void * context,
|
|
|
|
void (* on_app_renamed)(void * context, const char * old_name, const char * new_app_name));
|
2009-12-26 21:44:09 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* destroy app supervisor */
|
2009-12-26 21:44:09 +02:00
|
|
|
void
|
|
|
|
ladish_app_supervisor_destroy(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle);
|
2009-11-30 01:22:58 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* mark that app has quit */
|
2009-12-26 21:44:09 +02:00
|
|
|
bool
|
|
|
|
ladish_app_supervisor_child_exit(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle,
|
|
|
|
pid_t pid);
|
2009-11-30 23:45:14 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* iterate apps */
|
2009-12-05 00:42:40 +02:00
|
|
|
bool
|
|
|
|
ladish_app_supervisor_enum(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle,
|
|
|
|
void * context,
|
2009-12-27 04:19:24 +02:00
|
|
|
bool (* callback)(void * context, const char * name, bool running, const char * command, bool terminal, uint8_t level, pid_t pid));
|
2009-12-05 00:42:40 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* It is not clear what this function is supposed to do */
|
2009-12-26 21:44:09 +02:00
|
|
|
void
|
|
|
|
ladish_app_supervisor_clear(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle);
|
2009-12-05 00:42:40 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* Add app; on success, app handle is returned; on failure, NULL is returned;
|
|
|
|
apps are added in stopped state; autorun parameter is just a hint for ladish_app_supervisor_autorun() */
|
2010-05-04 23:48:23 +03:00
|
|
|
ladish_app_handle
|
2009-12-05 00:42:40 +02:00
|
|
|
ladish_app_supervisor_add(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle,
|
|
|
|
const char * name,
|
|
|
|
bool autorun,
|
|
|
|
const char * command,
|
|
|
|
bool terminal,
|
|
|
|
uint8_t level);
|
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* Initiate stop of all apps owned by this supervisor */
|
2009-12-26 21:44:09 +02:00
|
|
|
void
|
|
|
|
ladish_app_supervisor_stop(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle);
|
2009-12-05 00:42:40 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* Start all apps that were added with autorun enabled */
|
2009-12-26 21:44:09 +02:00
|
|
|
void
|
|
|
|
ladish_app_supervisor_autorun(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle);
|
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* TODO: this should be renamed to match the fact that it returns app name and not app handle */
|
|
|
|
/* Implementing ladish_app_supervisor_find_app_by_pid() makes sense as well */
|
2009-12-26 21:44:09 +02:00
|
|
|
char *
|
|
|
|
ladish_app_supervisor_search_app(
|
|
|
|
ladish_app_supervisor_handle supervisor_handle,
|
|
|
|
pid_t pid);
|
2009-11-30 01:22:58 +02:00
|
|
|
|
2010-05-08 15:30:59 +03:00
|
|
|
/* TODO: This should be probably removed in favour of ladish_app_supervisor_get_opath(); it is used for debuging purposes only */
|
2010-04-04 00:31:14 +03:00
|
|
|
const char * ladish_app_supervisor_get_name(ladish_app_supervisor_handle supervisor_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* Get number of apps that are currently running */
|
2010-04-26 03:47:10 +03:00
|
|
|
unsigned int ladish_app_supervisor_get_running_app_count(ladish_app_supervisor_handle supervisor_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* TODO: ladish_app_supervisor_check_app_name() should be created and exported instead */
|
2010-05-04 23:48:23 +03:00
|
|
|
ladish_app_handle ladish_app_supervisor_find_app_by_name(ladish_app_supervisor_handle supervisor_handle, const char * name);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* find app by id; returns NULL if app is not found */
|
2010-05-05 01:09:42 +03:00
|
|
|
ladish_app_handle ladish_app_supervisor_find_app_by_id(ladish_app_supervisor_handle supervisor_handle, uint64_t id);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* the D-Bus object path for the supervisor */
|
2010-05-04 23:48:23 +03:00
|
|
|
const char * ladish_app_supervisor_get_opath(ladish_app_supervisor_handle supervisor_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* start an app; returns success status; app must be in stopped state */
|
2010-05-04 23:48:23 +03:00
|
|
|
bool ladish_app_supervisor_run(ladish_app_supervisor_handle supervisor_handle, ladish_app_handle app_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* remove an app; app must be in stopped state */
|
2010-05-04 23:48:23 +03:00
|
|
|
void ladish_app_supervisor_remove(ladish_app_supervisor_handle supervisor_handle, ladish_app_handle app_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* get commandline for app */
|
2010-05-05 01:09:42 +03:00
|
|
|
const char * ladish_app_get_commandline(ladish_app_handle app_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* check whether app is currently running */
|
2010-05-05 01:09:42 +03:00
|
|
|
bool ladish_app_is_running(ladish_app_handle app_handle);
|
2010-05-08 15:30:59 +03:00
|
|
|
|
|
|
|
/* get app name; the returned pointer is owned by the app supervisor */
|
2010-05-05 01:09:42 +03:00
|
|
|
const char * ladish_app_get_name(ladish_app_handle app_handle);
|
2010-04-04 00:31:14 +03:00
|
|
|
|
2009-12-26 21:44:09 +02:00
|
|
|
extern const struct dbus_interface_descriptor g_iface_app_supervisor;
|
2009-12-11 00:11:03 +02:00
|
|
|
|
2009-11-30 01:22:58 +02:00
|
|
|
#endif /* #ifndef APP_SUPERVISOR_H__712E6589_DCB1_4CE9_9812_4F250D55E8A2__INCLUDED */
|