Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Basic functions
[HAL daemon]

Basic functions in the HAL daemon. More...

Data Structures

struct  PendingUpdate_s
 Structure for queing updates. More...


Typedefs

typedef PendingUpdate_s PendingUpdate
 Structure for queing updates.


Functions

DBusHandlerResult filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
 Message handler for method invocations.

void property_atomic_update_begin ()
 Begin an atomic update - this is useful for updating several properties in one go.

void property_atomic_update_end ()
 End an atomic update.

void emit_condition (HalDevice *device, const char *condition_name, int first_arg_type,...)
 Emits a condition on a device; the device has to be in the GDL for this function to have effect.

void property_changed (HalDevice *device, const char *key, dbus_bool_t in_gdl, dbus_bool_t removed, dbus_bool_t added)
 Function in the HAL daemon that is called whenever a property on a device is changed.

void gdl_changed (HalDevice *device, dbus_bool_t is_added)
 Callback for the global device list has changed.

void new_capability (HalDevice *device, const char *capability, dbus_bool_t in_gdl)
 Callback for when a new capability is added to a device.

void usage ()
 Print out program usage.

int main (int argc, char *argv[])
 Entry point for HAL daemon.

void * xmalloc (unsigned int how_much)
 Memory allocation; aborts if no memory.

char * xstrdup (const char *str)
 String duplication; aborts if no memory.


Variables

int atomic_count = 0
 Counter for atomic updating.

int num_pending_updates = 0
 Number of updates pending.

PendingUpdatepending_updates_head = NULL
dbus_bool_t opt_become_daemon = TRUE
 If #TRUE, we will daemonize.

char * opt_run_as = NULL
 Run as specified username if not #NULL.


Detailed Description

Basic functions in the HAL daemon.


Function Documentation

void emit_condition HalDevice device,
const char *  condition_name,
int  first_arg_type,
... 
 

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.

Parameters:
device The device
condition_name Name of condition
first_arg_type Type of the first argument
... value of first argument, list of additional type-value pairs. Must be terminated with DBUS_TYPE_INVALID

Definition at line 1841 of file main.c.

References DIE, HalDevice, HalDevice_s::in_gdl, and HalDevice_s::udi.

Referenced by etc_mtab_process_all_block_devices(), force_unmount(), force_unmount_of_all_childs(), and link_detection_process().

DBusHandlerResult filter_function DBusConnection *  connection,
DBusMessage *  message,
void *  user_data
[static]
 

Message handler for method invocations.

All invocations on any object or interface is routed through this function.

Parameters:
connection D-BUS connection
message Message
user_data User data
Returns:
What to do with the message

Definition at line 1524 of file main.c.

References agent_device_matches(), agent_manager_commit_to_gdl(), agent_manager_new_device(), agent_manager_remove(), agent_merge_properties(), device_add_capability(), device_get_all_properties(), device_get_property(), device_get_property_type(), device_property_exists(), device_query_capability(), device_remove_property(), device_set_property(), manager_device_exists(), manager_find_device_by_capability(), manager_find_device_string_match(), manager_get_all_devices(), and osspec_filter_function().

Referenced by main().

void gdl_changed HalDevice device,
dbus_bool_t  is_added
[static]
 

Callback for the global device list has changed.

Parameters:
device Pointer a HalDevice object
is_added True iff device was added

Definition at line 1935 of file main.c.

References HalDevice, manager_send_signal_device_added(), manager_send_signal_device_removed(), and HalDevice_s::udi.

Referenced by main().

int main int  argc,
char *  argv[]
 

Entry point for HAL daemon.

Parameters:
argc Number of arguments
argv Array of arguments
Returns:
Exit code

Todo:
FIXME change logger to direct to syslog

Definition at line 1993 of file main.c.

References ds_add_cb_gdl_changed(), ds_add_cb_newcap(), ds_add_cb_property_changed(), ds_init(), filter_function(), gdl_changed(), logger_init(), new_capability(), opt_become_daemon, opt_run_as, osspec_init(), osspec_probe(), property_changed(), and usage().

void new_capability HalDevice device,
const char *  capability,
dbus_bool_t  in_gdl
[static]
 

Callback for when a new capability is added to a device.

Parameters:
device Pointer a HalDevice object
capability Capability added
in_gdl True iff the device object in visible in the global device list

Definition at line 1950 of file main.c.

References HalDevice, manager_send_signal_new_capability(), and HalDevice_s::udi.

Referenced by main().

void property_atomic_update_begin  ) 
 

Begin an atomic update - this is useful for updating several properties in one go.

Note that an atomic update is recursive - use with caution!

Definition at line 1720 of file main.c.

References atomic_count.

Referenced by ds_device_merge(), etc_mtab_process_all_block_devices(), force_unmount(), and link_detection_process().

void property_atomic_update_end  ) 
 

End an atomic update.

Note that an atomic update is recursive - use with caution!

Definition at line 1744 of file main.c.

References PendingUpdate_s::added, atomic_count, PendingUpdate_s::device, DIE, PendingUpdate_s::key, PendingUpdate_s::next, num_pending_updates, PendingUpdate, and PendingUpdate_s::removed.

Referenced by ds_device_merge(), etc_mtab_process_all_block_devices(), force_unmount(), and link_detection_process().

void property_changed HalDevice device,
const char *  key,
dbus_bool_t  in_gdl,
dbus_bool_t  removed,
dbus_bool_t  added
[static]
 

Function in the HAL daemon that is called whenever a property on a device is changed.

Will broadcast the changes using D-BUS signals.

Parameters:
device HalDevice object
key Property that has changed
in_gdl True iff the device object in visible in the global device list
removed True iff the property was removed
added True iff the property was added

Definition at line 1877 of file main.c.

References PendingUpdate_s::added, atomic_count, PendingUpdate_s::device, DIE, HalDevice, PendingUpdate_s::key, PendingUpdate_s::next, num_pending_updates, PendingUpdate, PendingUpdate_s::removed, HalDevice_s::udi, xmalloc(), and xstrdup().

Referenced by main().

void* xmalloc unsigned int  how_much  ) 
 

Memory allocation; aborts if no memory.

Parameters:
how_much Number of bytes to allocated
Returns:
Pointer to allocated storage

Definition at line 2184 of file main.c.

References DIE.

Referenced by ds_device_async_find_by_key_value_string(), ds_device_find_multiple_by_key_value_string(), ds_device_new(), and property_changed().

char* xstrdup const char *  str  ) 
 

String duplication; aborts if no memory.

Parameters:
how_much Number of bytes to allocated
Returns:
Pointer to allocated storage

Definition at line 2197 of file main.c.

References DIE.

Referenced by ds_device_async_find_by_key_value_string(), ds_device_new(), ds_device_set_udi(), ds_property_set_bool(), ds_property_set_double(), ds_property_set_int(), ds_property_set_string(), ds_query_capability(), and property_changed().


Generated on Sat Feb 7 22:11:50 2004 for HAL by doxygen 1.3.5