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

mntd_hal.c

00001 /***************************************************************************
00002  * CVSID: $Id: mntd_hal.c,v 1.9 2004/05/26 19:12:40 stefanb Exp $
00003  *
00004  * mntd_hal.c : Watching HAL events for MNT daemon
00005  *
00006  * Copyright (C) 2004 Stefan Bambach, <stefan@bambach.biz>
00007  *
00008  * Licensed under the GNU General Public License 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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     // add volume to manager
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     // remove volume from manager
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     // store new volume capability to manager
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     // change volume property to manager
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     // add volume property to manager
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     // remove volume property from manager
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 

Generated on Thu May 27 23:27:28 2004 for Mntd by doxygen 1.3.5