00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <dbus/dbus.h>
00034 #include <dbus/dbus-glib.h>
00035
00036 #include <glib.h>
00037 #include <dbus/dbus-glib.h>
00038
00039 #include <libhal.h>
00040
00041 #include "mntd_hal.h"
00042 #include "errmanager.h"
00043 #include "main.h"
00044
00045
00046 static void mntd_hal_device_added(const char* udi);
00047 static void mntd_hal_device_removed(const char* udi);
00048 static void mntd_hal_device_new_capability(const char* udi, const char* capability);
00049 static void mntd_hal_property_changed(const char* udi, const char* key);
00050 static void mntd_hal_property_added(const char* udi, const char* key);
00051 static void mntd_hal_property_removed(const char* udi, const char* key);
00052 static void mntd_hal_mainloop_integration(DBusConnection* dbus_connection);
00053
00054
00055 LibHalFunctions hal_functions = {mntd_hal_mainloop_integration,
00056 mntd_hal_device_added,
00057 mntd_hal_device_removed,
00058 mntd_hal_device_new_capability,
00059 mntd_hal_property_changed,
00060 mntd_hal_property_added,
00061 mntd_hal_property_removed };
00062
00063
00073 #define DIE(expr) do {printf("*** [DIE] %s:%s():%d : ", __FILE__, __FUNCTION__, __LINE__); printf expr; printf("\n"); exit(1); } while(0)
00074
00075
00081 static void mntd_hal_device_added(const char* udi)
00082 {
00083
00084 g_assert(vols!=NULL);
00085 vols->add_volume(vols, udi);
00086 }
00087
00088
00094 static void mntd_hal_device_removed(const char* udi)
00095 {
00096
00097 g_assert(vols!=NULL);
00098 vols->remove_volume(vols, udi);
00099 }
00100
00101
00108 static void mntd_hal_device_new_capability(const char* udi, const char* capability)
00109 {
00110
00111 g_assert(vols!=NULL);
00112 vols->new_volume_capability(vols, udi, capability);
00113 }
00114
00115
00122 static void mntd_hal_property_changed(const char* udi, const char* key)
00123 {
00124
00125 g_assert(vols!=NULL);
00126 vols->change_volume_property(vols, udi, key);
00127 }
00128
00129
00136 static void mntd_hal_property_added(const char* udi, const char* key)
00137 {
00138
00139 g_assert(vols!=NULL);
00140 vols->add_volume_property(vols, udi, key);
00141 }
00142
00143
00150 static void mntd_hal_property_removed(const char* udi, const char* key)
00151 {
00152
00153 g_assert(vols!=NULL);
00154 vols->remove_volume_property(vols, udi, key);
00155 }
00156
00157
00163 static void mntd_hal_mainloop_integration(DBusConnection* dbus_connection)
00164 {
00165 dbus_connection_setup_with_g_main(dbus_connection, NULL);
00166 }
00167
00168
00172 void mntd_hal_init(void)
00173 {
00174 if(hal_initialize(&hal_functions, FALSE)) {
00175 MSG_ERR("hal_initialize failed (no dbus-daemon-1 running ?)\n");
00176 exit(1);
00177 }
00178 hal_device_property_watch_all();
00179 }
00180
00181
00185 void mntd_hal_shutdown(void)
00186 {
00187 hal_shutdown();
00188 }
00189
00190