/***************************************************************************
* CVSID: $Id$
*
* dbus.c : D-BUS interface of HAL daemon
*
* Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
*
* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "hald.h"
#include "hald_dbus.h"
#include "device.h"
#include "device_store.h"
#include "device_info.h"
#include "logger.h"
#include "osspec.h"
#include "util.h"
#include "hald_runner.h"
static void
const char *error_name,
/**
* @defgroup DaemonErrors Error conditions
* @ingroup HalDaemon
* @brief Various error messages the HAL daemon can raise
* @{
*/
/** Raise HAL error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param error_name D-Bus error name
* @param format printf-style format for error message
*/
static void
const char *error_name,
char *format, ...)
{
HAL_WARNING ((buf));
DIE (("No memory"));
DIE (("No memory"));
}
/** Raise the org.freedesktop.Hal.NoSuchDevice error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param udi Unique device id given
*/
static void
{
"org.freedesktop.Hal.NoSuchDevice",
"No device with id %s",
);
}
/** Raise the org.freedesktop.Hal.NoSuchProperty error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param device_id Id of the device
* @param key Key of the property that didn't exist
*/
static void
{
"org.freedesktop.Hal.NoSuchProperty",
"No property %s on device with id %s",
);
}
/** Raise the org.freedesktop.Hal.TypeMismatch error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param device_id Id of the device
* @param key Key of the property
*/
static void
{
"org.freedesktop.Hal.TypeMismatch",
"Type mismatch setting property %s on device with id %s",
);
}
/** Raise the org.freedesktop.Hal.SyntaxError error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param method_name Name of the method that was invoked with
* the wrong signature
*/
static void
{
"org.freedesktop.Hal.SyntaxError",
"There is a syntax error in the invocation of the method %s",
);
}
/** Raise the org.freedesktop.Hal.DeviceNotLocked error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param device device which isn't locked
*/
static void
{
"org.freedesktop.Hal.DeviceNotLocked",
"The device %s is not locked",
);
}
/** Raise the org.freedesktop.Hal.DeviceAlreadyLocked error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param device device which isn't locked
*/
static void
{
const char *reason;
HAL_WARNING (("Device %s is already locked: %s",
"org.freedesktop.Hal.DeviceAlreadyLocked",
reason);
DIE (("No memory"));
}
/** Raise the org.freedesktop.Hal.BranchAlreadyClaimed error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param udi branch which isn't claimed
*/
static void
{
const char *claim_service;
HAL_WARNING (("Branch %s is already claimed by: %s",
"org.freedesktop.Hal.BranchAlreadyClaimed",
DIE (("No memory"));
}
/** Raise the org.freedesktop.Hal.BranchNotClaimed error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param udi branch which isn't claimed
*/
static void
{
"org.freedesktop.Hal.BranchNotClaimed",
"The branch %s is not claimed",
);
}
/** Raise the org.freedesktop.Hal.PermissionDenied error
*
* @param connection D-Bus connection
* @param in_reply_to message to report error on
* @param message what you're not allowed to do
*/
static void
const char *reason)
{
"org.freedesktop.Hal.PermissionDenied",
"Permission denied: %s",
);
}
/** @} */
/**
* @defgroup ManagerInterface D-BUS interface org.freedesktop.Hal.Manager
* @ingroup HalDaemon
* @brief D-BUS interface for querying device objects
*
* @{
*/
static gboolean
{
const char *udi;
return TRUE;
}
/** Get all devices.
*
* <pre>
* array{object_reference} Manager.GetAllDevices()
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
DIE (("No memory"));
&iter_array);
&iter_array);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
typedef struct {
const char *key;
const char *value;
static gboolean
{
const char *dev_value;
return TRUE;
const char *udi;
&udi);
}
return TRUE;
}
static gboolean
{
const char *dev_value;
/* skip devices in the TDL that hasn't got a real UDI yet */
sizeof ("/org/freedesktop/Hal/devices/temp")) == 0)
return TRUE;
return TRUE;
const char *udi;
&udi);
}
return TRUE;
}
/** Find devices in the GDL where a single string property matches a given
* value. Also returns devices in the TDL that has a non-tmp UDI.
*
* <pre>
* array{object_reference} Manager.FindDeviceStringMatch(string key,
* string value)
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *key;
const char *value;
HAL_TRACE (("entering"));
dbus_error_init (&error);
"Manager.FindDeviceStringMatch");
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
&iter_array);
&info);
/* Also returns devices in the TDL that has a non-tmp UDI */
&info);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
typedef struct {
const char *capability;
static gboolean
{
}
return TRUE;
}
/** Find devices in the GDL with a given capability.
*
* <pre>
* array{object_reference} Manager.FindDeviceByCapability(string capability)
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *capability;
HAL_TRACE (("entering"));
dbus_error_init (&error);
"Manager.FindDeviceByCapability");
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
&iter_array);
&info);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Determine if a device exists.
*
* <pre>
* bool Manager.DeviceExists(string udi)
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
dbus_bool_t b;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (d == NULL)
b = d != NULL;
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Send signal DeviceAdded(string udi) on the org.freedesktop.Hal.Manager
* interface on the object /org/freedesktop/Hal/Manager.
*
* @param device The HalDevice added
*/
void
{
if (dbus_connection == NULL)
goto out;
"org.freedesktop.Hal.Manager",
"DeviceAdded");
DIE (("error broadcasting message"));
out:
;
}
/** Send signal DeviceRemoved(string udi) on the org.freedesktop.Hal.Manager
* interface on the object /org/freedesktop/Hal/Manager.
*
* @param device The HalDevice removed
*/
void
{
if (dbus_connection == NULL)
goto out;
"org.freedesktop.Hal.Manager",
"DeviceRemoved");
DIE (("error broadcasting message"));
out:
;
}
/** Send signal NewCapability(string udi, string capability) on the
* org.freedesktop.Hal.Manager interface on the object
* /org/freedesktop/Hal/Manager.
*
* @param udi Unique Device Id
* @param capability Capability
*/
void
const char *capability)
{
if (dbus_connection == NULL)
goto out;
"org.freedesktop.Hal.Manager",
"NewCapability");
DIE (("error broadcasting message"));
out:
;
}
/** @} */
/**
* @defgroup DeviceInterface D-BUS interface org.freedesktop.Hal.Device
* @ingroup HalDaemon
* @brief D-BUS interface for generic device operations
* @{
*/
static gboolean
{
const char *key;
int type;
NULL,
key = hal_property_get_key (p);
type = hal_property_get_type (p);
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
{
const char *v;
v = hal_property_get_string (p);
&iter_var);
&v);
&iter_var);
break;
}
case HAL_PROPERTY_TYPE_INT32:
{
dbus_int32_t v;
v = hal_property_get_int (p);
&iter_var);
&v);
&iter_var);
break;
}
case HAL_PROPERTY_TYPE_UINT64:
{
v = hal_property_get_uint64 (p);
&iter_var);
&v);
&iter_var);
break;
}
case HAL_PROPERTY_TYPE_DOUBLE:
{
double v;
v = hal_property_get_double (p);
&iter_var);
&v);
&iter_var);
break;
}
{
dbus_bool_t v;
v = hal_property_get_bool (p);
&iter_var);
&v);
&iter_var);
break;
}
{
&iter_var);
&iter_array);
const char *v;
&v);
}
&iter_array);
&iter_var);
break;
}
default:
break;
}
return TRUE;
}
/** Get all properties on a device.
*
* <pre>
* map{string, any} Device.GetAllProperties()
*
* raises org.freedesktop.Hal.NoSuchDevice
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
&iter_dict);
&iter_dict);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
#ifdef sun
static dbus_bool_t
{
}
#endif /* sun */
static dbus_bool_t
{
unsigned long user_uid;
const char *user_base_svc;
if (user_base_svc == NULL) {
HAL_WARNING (("Cannot determine base service of caller"));
goto out;
}
dbus_error_init (&error);
dbus_error_free (&error);
goto out;
}
#ifdef sun
"org.freedesktop.Hal.Device",
"Rescan")) {
if (user_at_console(user_uid)) {
goto out;
}
}
#endif
goto out;
}
out:
return ret;
}
/** Set multiple properties on a device in an atomic fashion.
*
* <pre>
* Device.GetAllProperties(map{string, any} properties)
*
* raises org.freedesktop.Hal.NoSuchDevice
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
static DBusHandlerResult
device_set_multiple_properties (DBusConnection *connection, DBusMessage *message, dbus_bool_t local_interface)
{
HalDevice *d;
const char *udi;
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
/* update atomically */
{
const char *key;
int change_type;
switch (change_type) {
case DBUS_TYPE_ARRAY:
/* TODO: error */
}
const char *v;
}
break;
case DBUS_TYPE_STRING:
{
const char *v;
dbus_message_iter_get_basic (&var_iter, &v);
break;
}
case DBUS_TYPE_INT32:
{
dbus_int32_t v;
dbus_message_iter_get_basic (&var_iter, &v);
break;
}
case DBUS_TYPE_UINT64:
{
dbus_message_iter_get_basic (&var_iter, &v);
break;
}
case DBUS_TYPE_DOUBLE:
{
double v;
dbus_message_iter_get_basic (&var_iter, &v);
break;
}
case DBUS_TYPE_BOOLEAN:
{
gboolean v;
dbus_message_iter_get_basic (&var_iter, &v);
break;
}
default:
/* TODO: error */
break;
}
/* TODO: error out on rc==FALSE? */
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Get a property on a device.
*
* <pre>
* any Device.GetProperty(string key)
* string Device.GetPropertyString(string key)
* int Device.GetPropertyInteger(string key)
* bool Device.GetPropertyBoolean(string key)
* double Device.GetPropertyDouble(string key)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.NoSuchProperty
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
char *key;
int type;
HalProperty *p;
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
p = hal_device_property_find (d, key);
if (p == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
type = hal_property_get_type (p);
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
{
const char *s;
s = hal_property_get_string (p);
break;
}
case HAL_PROPERTY_TYPE_INT32:
{
dbus_int32_t i;
i = hal_property_get_int (p);
break;
}
case HAL_PROPERTY_TYPE_UINT64:
{
ul = hal_property_get_uint64 (p);
break;
}
case HAL_PROPERTY_TYPE_DOUBLE:
{
double d;
d = hal_property_get_double (p);
break;
}
{
dbus_bool_t b;
b = hal_property_get_bool (p);
break;
}
{
GSList *l;
&iter_array);
}
}
break;
default:
break;
}
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Get the type of a property on a device.
*
* <pre>
* int Device.GetPropertyType(string key)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.NoSuchProperty
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
char *key;
HalProperty *p;
dbus_int32_t i;
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
p = hal_device_property_find (d, key);
if (p == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
i = hal_property_get_type (p);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Set a property on a device.
*
* <pre>
* void Device.SetProperty(string key, any value)
* void Device.SetPropertyString(string key, string value)
* void Device.SetPropertyInteger(string key, int value)
* void Device.SetPropertyBoolean(string key, bool value)
* void Device.SetPropertyDouble(string key, double value)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.NoSuchProperty
* org.freedesktop.Hal.TypeMismatch
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
device_set_property (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
const char *udi;
char *key;
int type;
HAL_TRACE (("entering"));
if (type != DBUS_TYPE_STRING) {
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
/** @todo check permissions of the sender vs property to be modified */
switch (type) {
case DBUS_TYPE_STRING:
{
const char *v;
dbus_message_iter_get_basic (&iter, &v);
break;
}
case DBUS_TYPE_INT32:
{
dbus_int32_t v;
dbus_message_iter_get_basic (&iter, &v);
break;
}
case DBUS_TYPE_UINT64:
{
dbus_message_iter_get_basic (&iter, &v);
break;
}
case DBUS_TYPE_DOUBLE:
{
double v;
dbus_message_iter_get_basic (&iter, &v);
break;
}
case DBUS_TYPE_BOOLEAN:
{
dbus_bool_t v;
dbus_message_iter_get_basic (&iter, &v);
break;
}
default:
break;
}
if (!rc) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** This function is used to modify the Capabilities property. The reason
* for having a dedicated function is that the HAL daemon will broadcast
* a signal on the Manager interface to tell applications that the device
* have got a new capability.
*
* This is useful as capabilities can be merged after the device is created.
* One example of this is networking cards under Linux 2.6; the net.ethernet
* capability is not merged when the device is initially found by looking in
*
* Note that the signal is emitted every time this method is invoked even
* though the capability already existed. This is useful in the above
* scenario when the PCI class says ethernet networking card but we yet
* don't have enough information to fill in the net.* and net.ethernet.*
*
* <pre>
* void Device.AddCapability(string capability)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* raises org.freedesktop.Hal.PermissionDenied,
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
device_add_capability (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
const char *udi;
const char *capability;
HalDevice *d;
HAL_TRACE (("entering"));
return DBUS_HANDLER_RESULT_HANDLED;
}
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/* TODO: docs */
static DBusHandlerResult
device_string_list_append_prepend (DBusConnection * connection, DBusMessage * message, dbus_bool_t do_prepend)
{
const char *udi;
const char *key;
const char *value;
HalDevice *d;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (do_prepend)
else
if (!ret) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/* TODO: docs */
static DBusHandlerResult
{
const char *udi;
const char *key;
const char *value;
HalDevice *d;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (!ret) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Remove a property on a device.
*
* <pre>
* void Device.RemoveProperty(string key)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.NoSuchProperty
* org.freedesktop.Hal.PermissionDenied
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
device_remove_property (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
const char *udi;
char *key;
HalDevice *d;
HAL_TRACE (("entering"));
return DBUS_HANDLER_RESULT_HANDLED;
}
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (!hal_device_property_remove (d, key)) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Determine if a property exists
*
* <pre>
* bool Device.PropertyExists(string key)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *udi;
char *key;
HalDevice *d;
dbus_bool_t b;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
b = hal_device_has_property (d, key);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Determine if a device has a capability
*
* <pre>
* bool Device.QueryCapability(string capability_name)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *udi;
char *capability;
HalDevice *d;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
break;
}
}
}
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Grab an advisory lock on a device.
*
* <pre>
* bool Device.Lock(string reason)
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.DeviceAlreadyLocked
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *udi;
HalDevice *d;
char *reason;
const char *sender;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
if (already_locked) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
hal_device_property_set_string (d, "info.locked.dbus_name",
sender);
if (services_with_locks == NULL) {
}
g_object_ref (d));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Release an advisory lock on a device.
*
* <pre>
* bool Device.Unlock()
*
* raises org.freedesktop.Hal.NoSuchDevice,
* org.freedesktop.Hal.DeviceNotLocked,
* org.freedesktop.Hal.PermissionDenied
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
const char *udi;
HalDevice *d;
const char *sender;
HAL_TRACE (("entering"));
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
if (!rc) {
return DBUS_HANDLER_RESULT_HANDLED;
}
d, "info.locked.dbus_name")) != 0) {
char *reason;
"lock on %s", sender,
hal_device_get_udi (d));
return DBUS_HANDLER_RESULT_HANDLED;
}
else {
HAL_WARNING (("Service '%s' was not in the list of services "
"with locks!", sender));
}
hal_device_property_remove (d, "info.locked");
hal_device_property_remove (d, "info.locked.reason");
hal_device_property_remove (d, "info.locked.dbus_name");
/* FIXME? Pointless? */
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Claim a branch.
*
* <pre>
* bool Manager.ClaimBranch(string udi, string claim_service)
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
const char *claim_service;
const char *sender;
unsigned long uid;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
if (already_claimed) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
dbus_error_init (&error);
dbus_error_free (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (services_with_claims == NULL) {
}
g_object_ref (d));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Unclaim a branch.
*
* <pre>
* bool Manager.UnclaimBranch(string udi)
* </pre>
*
* @param connection D-BUS connection
* @param message Message
* @return What to do with the message
*/
{
HalDevice *d;
const char *udi;
const char *claim_service;
const char *sender;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
if (!already_claimed) {
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
d, "info.claimed.dbus_name")) != 0) {
char *reason;
"claim on %s", sender,
hal_device_get_udi (d));
return DBUS_HANDLER_RESULT_HANDLED;
}
else {
HAL_WARNING (("Service '%s' was not in the list of services "
"with claims!", sender));
}
hal_device_property_remove (d, "info.claimed.dbus_name");
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/** Counter for atomic updating */
static int atomic_count = 0;
/** Number of updates pending */
static int num_pending_updates = 0;
/** Structure for queing updates */
typedef struct PendingUpdate_s {
/** Begin an atomic update - this is useful for updating several properties
* in one go.
*
* Note that an atomic update is recursive - use with caution!
*/
void
{
atomic_count++;
}
/** End an atomic update.
*
* Note that an atomic update is recursive - use with caution!
*/
void
{
--atomic_count;
if (atomic_count < 0) {
atomic_count = 0;
}
if (atomic_count == 0 && num_pending_updates > 0) {
for (pu_iter = pending_updates_head;
int num_updates_this;
/* see if we've already processed this */
goto already_processed;
/* count number of updates for this device */
num_updates_this = 0;
}
/* prepare message */
"org.freedesktop.Hal.Device",
"PropertyModified");
&iter_array);
NULL,
&iter_struct);
(&iter_struct,
(&iter_struct,
(&iter_struct,
/* signal this is already processed */
}
}
}
if (dbus_connection != NULL) {
DIE (("error broadcasting message"));
}
} /* for all updates */
num_pending_updates = 0;
}
}
void
{
/*
HAL_INFO(("Entering, udi=%s, key=%s, in_gdl=%s, removed=%s added=%s",
device->udi, key,
in_gdl ? "true" : "false",
removed ? "true" : "false",
added ? "true" : "false"));
*/
if (atomic_count > 0) {
} else {
dbus_int32_t i;
if (dbus_connection == NULL)
goto out;
"org.freedesktop.Hal.Device",
"PropertyModified");
i = 1;
&iter_array);
NULL,
&iter_struct);
DIE (("error broadcasting message"));
}
out:
;
}
/** Emits a condition on a device; the device has to be in the GDL for
* this function to have effect.
*
* Is intended for non-continuous events on the device like
* ProcesserOverheating, BlockDeviceGotDevice, e.g. conditions that
* are exceptional and may not be inferred by looking at properties
* (though some may).
*
* This function accepts a number of parameters that are passed along
* in the D-BUS message. The recipient is supposed to extract the parameters
* himself, by looking at the HAL specification.
*
* @param udi The UDI for this device
* @param condition_name Name of condition
* @param first_arg_type Type of the first argument
* @param ... value of first argument, list of additional
* type-value pairs. Must be terminated with
* DBUS_TYPE_INVALID
*/
void
device_send_signal_condition (HalDevice *device, const char *condition_name, const char *condition_details)
{
if (dbus_connection == NULL)
goto out;
"org.freedesktop.Hal.Device",
"Condition");
DIE (("error broadcasting message"));
out:
return;
}
static gboolean
{
HAL_INFO (("entering!"));
if (hald_dbus_init ())
return FALSE;
else
return TRUE;
}
static void
{
char *old_service_name;
char *new_service_name;
HalDevice *d;
HAL_ERROR (("Invalid NameOwnerChanged signal from bus!"));
return;
}
if (services_with_locks != NULL) {
if (d != NULL) {
hal_device_property_remove (d, "info.locked");
hal_device_property_remove (d, "info.locked.reason");
hal_device_property_remove (d, "info.locked.dbus_name");
}
}
if (services_with_claims != NULL) {
if (d != NULL) {
hal_device_property_remove (d, "info.claimed.dbus_name");
}
}
}
static DBusHandlerResult
{
const char *udi;
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
{
const char *udi;
HAL_TRACE (("entering"));
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
device_emit_condition (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
const char *udi;
const char *condition_name;
const char *condition_details;
HAL_TRACE (("entering"));
if (!local_interface) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
typedef struct
{
char *interface_name;
char *introspection_xml;
char *udi;
static DBusHandlerResult
device_claim_interface (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
const char *udi;
const char *interface_name;
const char *introspection_xml;
HAL_TRACE (("entering"));
if (!local_interface) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
HAL_INFO (("Local connection 0x%x to handle interface '%s' on udi '%s'",
udi));
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
{
const char *udi;
HAL_TRACE (("entering"));
if (!local_interface) {
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
if (hal_device_inc_num_ready_addons (device)) {
if (hal_device_are_all_addons_ready (device)) {
}
}
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/*
* Create new device in tdl. Return temporary udi.
*/
manager_new_device (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
HalDevice *d;
int i;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
d = hal_device_new ();
for (i = 0; i < 1000000 ; i++) {
udi = g_strdup_printf ("/org/freedesktop/Hal/devices/tmp%05x", ((unsigned) tv.tv_usec & 0xfffff)) + i;
}
if (!udi) {
return DBUS_HANDLER_RESULT_HANDLED;
}
hal_device_set_udi (d, udi);
hal_device_store_add (hald_get_tdl (), d);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/*
* Callout helper.
*/
static void
{
if (!hal_device_store_remove (hald_get_gdl (), d)) {
HAL_WARNING (("Error removing device"));
}
}
/*
* Remove device. Looks in gdl and tdl.
*/
{
HalDevice *d;
char *udi;
int in_tdl = 0;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
if (d == NULL) {
in_tdl = 1;
}
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
/* FIXME:
* run "info.callouts.remove" ?
* delete in gdl ?
* (auto) stop "info.addons" ?
*/
if (!in_tdl) {
}
g_object_unref (d);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
/*
* Callout helper.
*/
static void
{
}
/*
* Preprobing helper.
*/
static void
{
if (hal_device_property_get_bool (d, "info.ignore")) {
/* Leave the device here with info.ignore==TRUE so we won't pick up children
* Also remove category and all capabilities
*/
hal_device_property_remove (d, "info.category");
hal_device_property_remove (d, "info.capabilities");
HAL_INFO (("Preprobing merged info.ignore==TRUE"));
return;
}
/* Merge properties from .fdi files */
}
/*
* Move device from tdl to gdl. Runs helpers and callouts.
*/
manager_commit_to_gdl (DBusConnection * connection, DBusMessage * message, dbus_bool_t local_interface)
{
HalDevice *d;
dbus_error_init (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
DIE (("No memory"));
/* look it up in tdl */
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
/* sanity check & avoid races */
/* lose it */
hal_device_store_remove (hald_get_tdl (), d);
g_object_unref (d);
raise_error (connection, message, "org.freedesktop.Hal.DeviceExists", "CommitToGdl: Device exists: %s", udi);
return DBUS_HANDLER_RESULT_HANDLED;
}
/* set new udi */
hal_device_property_remove (d, "info.udi");
hal_device_set_udi (d, udi);
/* FIXME:
* 'RequireEnable' property?
* fdi "preprobe"?
* run "info.callouts.preprobe"?
* remove "info.ignore" devices?
* fdi "information"?
* fdi "policy"?
* run "info.callouts.add"?
* tdl -> gdl?
* (auto) start "info.addons"?
*/
/* Process preprobe fdi files */
/* move from tdl to gdl */
hal_device_store_remove (hald_get_tdl (), d);
hal_device_store_add (hald_get_gdl (), d);
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
typedef struct {
char *udi;
char *execpath;
char **extra_env;
char *mstdin;
char *member;
char *interface;
static void
static void
{
/* hald_runner_run_method() assumes ownership of mi->message.. so we don't free it here */
}
/* returns FALSE if we don't actually invoke anything */
static gboolean
{
HalDevice *d;
if (d == NULL)
if (d != NULL) {
/* no timeout */
TRUE,
0,
} else {
HAL_WARNING (("In-queue method call on non-existant device"));
}
return ret;
}
{
}
}
}
return ret;
}
static void
hald_exec_method_process_queue (const char *udi);
static void
{
if (udi_to_method_queue == NULL) {
NULL);
}
HAL_INFO (("enqueue"));
} else {
HAL_INFO (("no need to enqueue"));
}
}
static void
{
/* clean the top of the list */
HAL_INFO (("No more methods in queue"));
}
/* if method was Volume.Unmount() then refresh mount state */
HalDevice *d;
if (d == NULL) {
}
if (d != NULL) {
} else {
}
}
}
/* process the rest of the list */
HAL_INFO (("Execing next method in queue"));
if (!hald_exec_method_do_invocation (mi)) {
/* the device went away before we got to it... */
}
}
}
}
static void
{
}
}
if (exit_type != HALD_RUN_SUCCESS) {
reply = dbus_message_new_error (message, "org.freedesktop.Hal.Device.UnknownError", "An unknown error occured");
DIE (("No memory"));
}
if (!is_valid_interface_name (exp_name)) {
/*
* error name may be invalid,
* if so we need a generic HAL error name;
* otherwise, dbus will be messed up.
*/
invalid_name = TRUE;
exp_name = "org.freedesktop.Hal.Device.UnknownError";
}
/* error name may be invalid - assume caller fucked up and use a generic HAL error name */
reply = dbus_message_new_error (message, "org.freedesktop.Hal.Device.UnknownError", "An unknown error occured");
DIE (("No memory"));
}
}
DIE (("No memory"));
}
} else {
DIE (("No memory"));
DIE (("No memory"));
}
}
if (invalid_name)
g_free (exp_detail);
}
static DBusHandlerResult
{
int type;
/* add calling uid */
if (local_interface) {
extra_env[0] = "HAL_METHOD_INVOKED_BY_UID=0";
} else {
const char *sender;
unsigned long uid;
dbus_error_init (&error);
if (!dbus_error_is_set (&error)) {
extra_env[0] = uid_export;
}
"HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME=%s", sender);
}
}
extra_env[0] = "HAL_METHOD_INVOKED_BY_UID=nobody";
/* prepare stdin with parameters */
switch (type) {
case DBUS_TYPE_BYTE:
{
unsigned char value;
break;
}
case DBUS_TYPE_INT16:
{
break;
}
case DBUS_TYPE_UINT16:
{
break;
}
case DBUS_TYPE_INT32:
{
break;
}
case DBUS_TYPE_UINT32:
{
break;
}
case DBUS_TYPE_INT64:
{
break;
}
case DBUS_TYPE_UINT64:
{
break;
}
case DBUS_TYPE_DOUBLE:
{
double value;
break;
}
case DBUS_TYPE_BOOLEAN:
{
break;
}
case DBUS_TYPE_STRING:
{
char *value;
break;
}
case DBUS_TYPE_ARRAY:
{
goto error;
const char *value;
}
break;
}
default:
goto error;
}
}
return DBUS_HANDLER_RESULT_HANDLED;
}
static gboolean
{
return TRUE;
}
static DBusHandlerResult
{
const char *path;
char *xml_string;
HAL_TRACE (("entering do_introspect"));
xml = g_string_new ("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
"<node>\n"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n");
" <node name=\"org\"/>\n");
" <node name=\"freedesktop\"/>\n");
" <node name=\"Hal\"/>\n");
" <node name=\"Manager\"/>\n"
" <node name=\"devices\"/>\n");
xml);
" <interface name=\"org.freedesktop.Hal.Manager\">\n"
" <method name=\"GetAllDevices\">\n"
" <arg name=\"devices\" direction=\"out\" type=\"ao\"/>\n"
" </method>\n"
" <method name=\"DeviceExists\">\n"
" <arg name=\"does_it_exist\" direction=\"out\" type=\"b\"/>\n"
" <arg name=\"udi\" direction=\"in\" type=\"o\"/>\n"
" </method>\n"
" <method name=\"FindDeviceStringMatch\">\n"
" <arg name=\"devices\" direction=\"out\" type=\"ao\"/>\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"FindDeviceByCapability\">\n"
" <arg name=\"devices\" direction=\"out\" type=\"ao\"/>\n"
" <arg name=\"capability\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"ClaimBranch\">\n"
" <arg name=\"udi\" direction=\"in\" type=\"o\"/>\n"
" <arg name=\"claim_service\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"result\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"UnclaimBranch\">\n"
" <arg name=\"udi\" direction=\"in\" type=\"o\"/>\n"
" <arg name=\"result\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"NewDevice\">\n"
" <arg name=\"temporary_udi\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"Remove\">\n"
" <arg name=\"udi\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"CommitToGdl\">\n"
" <arg name=\"temporary_udi\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"global_udi\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n");
} else {
HalDevice *d;
if (d == NULL)
if (d == NULL) {
return DBUS_HANDLER_RESULT_HANDLED;
}
" <interface name=\"org.freedesktop.Hal.Device\">\n"
" <method name=\"GetAllProperties\">\n"
" <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n"
" </method>\n"
" <method name=\"SetMultipleProperties\">\n"
" <arg name=\"properties\" direction=\"in\" type=\"a{sv}\"/>\n"
" </method>\n"
" <method name=\"GetProperty\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"v\"/>\n"
" </method>\n"
" <method name=\"GetPropertyString\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"GetPropertyStringList\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"as\"/>\n"
" </method>\n"
" <method name=\"GetPropertyInteger\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"i\"/>\n"
" </method>\n"
" <method name=\"GetPropertyBoolean\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"GetPropertyDouble\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"out\" type=\"d\"/>\n"
" </method>\n"
" <method name=\"SetProperty\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"v\"/>\n"
" </method>\n"
" <method name=\"SetPropertyString\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"SetPropertyStringList\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"as\"/>\n"
" </method>\n"
" <method name=\"SetPropertyInteger\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"i\"/>\n"
" </method>\n"
" <method name=\"SetPropertyBoolean\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"SetPropertyDouble\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"d\"/>\n"
" </method>\n"
" <method name=\"RemoveProperty\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"GetPropertyType\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"type\" direction=\"out\" type=\"i\"/>\n"
" </method>\n"
" <method name=\"PropertyExists\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"does_it_exist\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"AddCapability\">\n"
" <arg name=\"capability\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"QueryCapability\">\n"
" <arg name=\"capability\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"does_it_have_capability\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"Lock\">\n"
" <arg name=\"reason\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"acquired_lock\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"Unlock\">\n"
" <arg name=\"released_lock\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"StringListAppend\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"StringListPrepend\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"StringListRemove\">\n"
" <arg name=\"key\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"value\" direction=\"in\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"EmitCondition\">\n"
" <arg name=\"condition_name\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"condition_details\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"rc\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"Rescan\">\n"
" <arg name=\"call_had_sideeffect\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"Reprobe\">\n"
" <arg name=\"call_had_sideeffect\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"ClaimInterface\">\n"
" <arg name=\"interface_name\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"introspection_xml\" direction=\"in\" type=\"s\"/>\n"
" <arg name=\"rc\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"AddonIsReady\">\n"
" <arg name=\"rc\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" </interface>\n");
GSList *i;
char *method_names_prop;
char *method_signatures_prop;
char *method_argnames_prop;
GSList *j;
GSList *k;
GSList *l;
/* consult local list */
if (method_names == NULL) {
GSList *i;
}
}
}
const char *name;
const char *sig;
const char *argnames;
char **args;
unsigned int n;
unsigned int m;
switch (sig[n]) {
case 'a':
HAL_WARNING (("Broken signature for method %s "
"on interface %s for object %s",
continue;
}
xml,
" <arg name=\"%s\" direction=\"in\" type=\"a%c\"/>\n",
n++;
break;
default:
xml,
" <arg name=\"%s\" direction=\"in\" type=\"%c\"/>\n",
break;
}
}
xml = g_string_append (
xml,
" <arg name=\"return_code\" direction=\"out\" type=\"i\"/>\n");
xml = g_string_append (
xml,
" </method>\n");
}
}
}
g_free (xml_string);
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
}
static void
void *user_data)
{
/*HAL_INFO (("in reply_from_fwd_message : user_data = 0x%x", user_data));*/
if (dbus_connection != NULL)
}
static DBusHandlerResult
{
/*HAL_INFO (("connection=0x%x obj_path=%s interface=%s method=%s local_interface=%d",
connection,
dbus_message_get_path (message),
dbus_message_get_interface (message),
dbus_message_get_member (message),
local_interface));*/
"org.freedesktop.Hal.Manager",
"GetAllDevices") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"DeviceExists") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"FindDeviceStringMatch") &&
"/org/freedesktop/Hal/Manager") == 0) {
message);
} else if (dbus_message_is_method_call
(message, "org.freedesktop.Hal.Manager",
"FindDeviceByCapability")
"/org/freedesktop/Hal/Manager") == 0) {
message);
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"ClaimBranch") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"UnclaimBranch") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"NewDevice") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"Remove") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Manager",
"CommitToGdl") &&
"/org/freedesktop/Hal/Manager") == 0) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetAllProperties")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetMultipleProperties")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetProperty")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyString")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyStringList")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyInteger")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyBoolean")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyDouble")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetProperty")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetPropertyString")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetPropertyInteger")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetPropertyBoolean")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"SetPropertyDouble")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"RemoveProperty")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"GetPropertyType")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"PropertyExists")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"AddCapability")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"QueryCapability")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"Lock")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"Unlock")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"StringListAppend")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"StringListPrepend")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"StringListRemove")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"Rescan")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"Reprobe")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"EmitCondition")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"ClaimInterface")) {
#if 0
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"ReleaseInterface")) {
#endif
} else if (dbus_message_is_method_call (message,
"org.freedesktop.Hal.Device",
"AddonIsReady")) {
} else if (dbus_message_is_method_call (message,
"org.freedesktop.DBus.Introspectable",
"Introspect")) {
} else {
const char *interface;
const char *udi;
const char *method;
const char *signature;
HalDevice *d;
/* check for device-specific interfaces that individual objects may support */
d = NULL;
if (d == NULL)
}
GSList *i;
/*HAL_INFO (("forwarding method to connection 0x%x", hih->connection));*/
/* send a copy of the message */
copy,
/*-1*/ 8000)) {
/* TODO: handle error */
} else {
/*HAL_INFO (("connection=%x message=%x", connection, message));*/
(void *) message,
NULL);
}
return DBUS_HANDLER_RESULT_HANDLED;
}
}
}
GSList *i;
char *s;
method_names = hal_device_property_get_strlist (d, s);
g_free (s);
const char *execpath;
const char *sig;
g_free (s);
g_free (s);
HAL_INFO (("OK for method '%s' with signature '%s' on interface '%s' for UDI '%s' and execpath '%s'", method, signature, interface, udi, execpath));
}
}
}
}
}
}
}
}
/** Message handler for method invocations. All invocations on any object
* or interface is routed through this function.
*
* @param connection D-BUS connection
* @param message Message
* @param user_data User data
* @return What to do with the message
*/
{
/* this is a local message; e.g. from libdbus in this process */
HAL_INFO (("Got disconnected from the system message bus; "
"retrying to reconnect every 3000 ms"));
} else if (dbus_message_is_signal (message,
"NameOwnerChanged")) {
} else
return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
void *user_data)
{
/*HAL_INFO (("local_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)));*/
/* cheat, and handle AddMatch since libhal will try to invoke this method */
DIE (("No memory"));
DIE (("No memory"));
return DBUS_HANDLER_RESULT_HANDLED;
GSList *i;
GSList *j;
HAL_INFO (("Client to local_server was disconnected"));
for (i = helper_interface_handlers; i != NULL; i = j) {
j = g_slist_next (i);
}
}
return DBUS_HANDLER_RESULT_HANDLED;
/* it's a signal, just forward it onto the system message bus */
if (dbus_connection != NULL) {
}
} else {
}
return DBUS_HANDLER_RESULT_HANDLED;
}
static void
{
HAL_INFO (("unregistered"));
}
static void
void *data)
{
HAL_INFO (("dbus_connection_get_is_connected = %d", dbus_connection_get_is_connected (new_connection)));
/*dbus_connection_add_filter (new_connection, server_filter_function, NULL, NULL);*/
"/org/freedesktop",
&vtable,
NULL);
}
char *
hald_dbus_local_server_addr (void)
{
if (local_server == NULL)
return NULL;
return dbus_server_get_address (local_server);
}
hald_dbus_local_server_init (void)
{
char *server_addr;
/* setup a server listening on a socket so we can do point to point
* connections for programs spawned by hald
*/
dbus_error_init (&error);
HAL_ERROR (("Cannot create D-BUS server"));
goto out;
}
out:
return ret;
}
hald_dbus_init (void)
{
HAL_INFO (("entering"));
if (dbus_connection == NULL) {
return FALSE;
}
0, &dbus_error);
if (dbus_error_is_set (&dbus_error)) {
HAL_ERROR (("dbus_bus_request_name(): %s",
return FALSE;
}
"type='signal'"
",member='NameOwnerChanged'",
NULL);
return TRUE;
}
/** @} */