/***************************************************************************
* CVSID: $Id$
*
* hald_runner.c - Interface to the hal runner helper daemon
*
* Copyright (C) 2006 Sjoerd Simons, <sjoerd@luon.net>
*
* Licensed under the Academic Free License version 2.1
*
* 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "hald.h"
#include "util.h"
#include "logger.h"
#include "hald_dbus.h"
#include "hald_runner.h"
typedef struct {
HalDevice *d;
} HelperData;
typedef struct
{
/* mapping from PID to RunningProcess */
static gboolean
{
}
return remove;
}
static void
{
}
void
{
}
static DBusHandlerResult
void *user_data)
{
/*HAL_INFO (("runner_server_message_handler: destination=%s obj_path=%s interface=%s method=%s",
dbus_message_get_destination (message),
dbus_message_get_path (message),
dbus_message_get_interface (message),
dbus_message_get_member (message)));*/
"org.freedesktop.HalRunner",
"StartedProcessExited")) {
dbus_error_init (&error);
/*HAL_INFO (("Previously started process with pid %d exited", pid));*/
}
}
}
return DBUS_HANDLER_RESULT_HANDLED;
}
static void
{
HAL_INFO (("unregistered"));
}
static void
void *data)
{
if (runner_connection == NULL) {
"/org/freedesktop",
&vtable,
NULL);
/* dbus_server_unref(server); */
}
}
static void
DIE (("Runner died"));
}
hald_runner_start_runner(void)
{
const char *hald_runner_path;
char *server_addr;
HAL_ERROR (("Cannot create D-BUS server for the runner"));
goto error;
}
argv[0] = "hald-runner";
if (hald_runner_path != NULL) {
env[1] = g_strdup_printf ("PATH=%s:" PACKAGE_LIBEXEC_DIR ":" PACKAGE_SCRIPT_DIR ":" PACKAGE_BIN_DIR, hald_runner_path);
} else {
}
/*env[2] = "DBUS_VERBOSE=1";*/
goto error;
}
while (runner_connection == NULL) {
/* Wait for the runner */
}
return TRUE;
return FALSE;
}
static gboolean
{
char *c;
/* periods aren't valid in the environment, so replace them with
* underscores. */
for (c = prop_upper; *c; c++) {
if (*c == '.')
*c = '_';
}
g_free (prop_upper);
return TRUE;
}
static void
}
static void
char *server_addr;
if (hald_is_verbose) {
}
if (hald_is_initialising) {
}
if (hald_use_syslog) {
}
#ifdef HAVE_POLKIT
#endif
char *sysname;
}
}
static void
int i;
}
}
static gboolean
gint x;
char **argv;
HAL_ERROR (("Error parsing commandline '%s': %s",
g_error_free (err);
return FALSE;
}
&array_iter))
DIE (("No memory"));
}
return TRUE;
}
static gboolean
const char *udi;
&array_iter);
return FALSE;
}
return TRUE;
}
/* Start a helper, returns true on a successfull start */
{
"/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"Start");
DIE(("No memory"));
goto error;
/* Wait for the reply, should be almost instantanious */
reply =
if (reply) {
if (ret) {
}
} else {
HAL_ERROR (("Error extracting out_pid from runner's Start()"));
}
}
return ret;
}
return FALSE;
}
static void
{
DBusMessage *m;
goto malformed;
if (!dbus_message_iter_init(m, &iter) ||
goto malformed;
if (!dbus_message_iter_next(&iter) ||
goto malformed;
while (dbus_message_iter_next(&iter) &&
const char *value;
}
g_object_unref (hb->d);
return;
/* Send a Fail callback on malformed messages */
HAL_ERROR (("Malformed or unexpected reply message"));
g_object_unref (hb->d);
}
/* Run a helper program using the commandline, with input as infomation on
* stdin */
void
"/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"Run");
DIE(("No memory"));
goto error;
DIE (("No memory"));
/* the connection was disconnected */
goto error;
return;
}
void
}
void
const char *udi;
"/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"Kill");
DIE(("No memory"));
/* Wait for the reply, should be almost instantanious */
reply =
if (reply) {
}
}
void
/* hald_runner has not yet started, just return */
if (runner_connection == NULL) {
return;
}
"/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"KillAll");
DIE(("No memory"));
/* Wait for the reply, should be almost instantanious */
reply =
if (reply) {
}
}