[maemo-commits] [maemo-commits] r17751 - in projects/haf/trunk/hildon-thumbnail: . daemon
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Mar 20 12:15:50 EET 2009
- Previous message: [maemo-commits] r17750 - projects/haf/trunk/dbus/debian
- Next message: [maemo-commits] r17752 - in projects/haf/trunk/dbus/debian: . patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2009-03-20 12:15:48 +0200 (Fri, 20 Mar 2009) New Revision: 17751 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/config.h.in projects/haf/trunk/hildon-thumbnail/configure.ac projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h Log: 2009-03-20 Philip Van Hoof <pvanhoof at codeminded.be> * config.h.in * configure.ac * daemon/thumb-hal.c * daemon/thumb-hal.h: Removed necessity for libhal, replaced it with GIO's pre-unmount event handling Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-03-20 10:10:41 UTC (rev 17750) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-03-20 10:15:48 UTC (rev 17751) @@ -1,3 +1,11 @@ +2009-03-20 Philip Van Hoof <pvanhoof at codeminded.be> + + * config.h.in + * configure.ac + * daemon/thumb-hal.c + * daemon/thumb-hal.h: Removed necessity for libhal, replaced it with + GIO's pre-unmount event handling + 2009-03-18 Philip Van Hoof <pvanhoof at codeminded.be> * daemon/plugins/gdk-pixbuf-plugin.c: Bug# 91658 fixed Modified: projects/haf/trunk/hildon-thumbnail/config.h.in =================================================================== --- projects/haf/trunk/hildon-thumbnail/config.h.in 2009-03-20 10:10:41 UTC (rev 17750) +++ projects/haf/trunk/hildon-thumbnail/config.h.in 2009-03-20 10:15:48 UTC (rev 17751) @@ -3,9 +3,6 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H -/* Define if we have HAL */ -#undef HAVE_HAL - /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H Modified: projects/haf/trunk/hildon-thumbnail/configure.ac =================================================================== --- projects/haf/trunk/hildon-thumbnail/configure.ac 2009-03-20 10:10:41 UTC (rev 17750) +++ projects/haf/trunk/hildon-thumbnail/configure.ac 2009-03-20 10:15:48 UTC (rev 17751) @@ -47,40 +47,7 @@ AM_CONDITIONAL(HAVE_MGTK, test "$have_gtk" = "yes") -################################################################## -# Check for HAL -################################################################## -HAL_REQUIRED=0.5 -AC_ARG_ENABLE(hal, - AS_HELP_STRING([--disable-hal], - [disable HAL support for AC power detection]),, - [enable_hal=yes]) - -if test "x$enable_hal" = "xyes"; then - PKG_CHECK_MODULES(HAL, - [hal >= $HAL_REQUIRED hal-storage], - [have_hal=yes] , - [have_hal=no]) - AC_SUBST(HAL_CFLAGS) - AC_SUBST(HAL_LIBS) - - if test "x$have_hal" = "xyes"; then - AC_DEFINE(HAVE_HAL, [], [Define if we have HAL]) - fi -else - have_hal="no (disabled)" -fi - -if test "x$enable_hal" = "xyes"; then - if test "x$have_hal" != "xyes"; then - AC_MSG_ERROR([Couldn't find HAL >= $HAL_REQUIRED and HAL storage.]) - fi -fi - -AM_CONDITIONAL(HAVE_HAL, test "x$have_hal" = "xyes") - - #################################################################### # DBus Service #################################################################### Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c 2009-03-20 10:10:41 UTC (rev 17750) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c 2009-03-20 10:15:48 UTC (rev 17751) @@ -3,108 +3,32 @@ #include "thumb-hal.h" #include "config.h" -#ifdef HAVE_HAL +static GVolumeMonitor *monitor; -#include <libhal.h> -#include <libhal-storage.h> - -static LibHalContext *context; - -#define PROP_IS_MOUNTED "volume.is_mounted" - - static void -hal_device_removed_cb (LibHalContext *context, const gchar *udi) +on_pre_unmount (GVolumeMonitor *volume_monitor, + GMount *mount, + gpointer user_data) { - /* We instantly exit the process whenever an unmount occurs. We are an - * activatable service so this is ok. The reason why we do this is to - * make sure that we release all file descriptors, so that the unmount - * can cleanly succeed at all times (if we were building a thumbnail for - * a file on the device being unmounted, then that's bad luck for that - * thumbnail). */ - - exit (0); -} - -static void -hal_device_property_modified_cb (LibHalContext *context, - const char *udi, - const char *key, - dbus_bool_t is_removed, - dbus_bool_t is_added) -{ - gboolean is_mounted; - - if (strcmp (key, PROP_IS_MOUNTED) != 0) { - return; + GDrive *drive = g_mount_get_drive (mount); + if (g_drive_is_media_removable (drive)) { + g_object_unref (drive); + exit (0); } - - is_mounted = libhal_device_get_property_bool (context, - udi, - key, - NULL); - - if (is_mounted) - hal_device_removed_cb (context, udi); + g_object_unref (drive); } - -#endif - void thumb_hal_init (void) { -#ifdef HAVE_HAL - DBusError error; - DBusConnection *connection; + monitor = g_volume_monitor_get (); - dbus_error_init (&error); - - connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); - if (dbus_error_is_set (&error)) { - g_critical ("Could not get the system DBus connection, %s", - error.message); - dbus_error_free (&error); - return; - } - - dbus_connection_setup_with_g_main (connection, NULL); - - context = libhal_ctx_new (); - - if (!context) { - g_critical ("Could not create HAL context"); - return; - } - - libhal_ctx_set_user_data (context, NULL); - libhal_ctx_set_dbus_connection (context, connection); - - if (!libhal_ctx_init (context, &error)) { - if (dbus_error_is_set (&error)) { - g_critical ("Could not initialize the HAL context, %s", - error.message); - dbus_error_free (&error); - } else { - g_critical ("Could not initialize the HAL context, " - "no error, is hald running?"); - } - - libhal_ctx_free (context); - return; - } - - - libhal_ctx_set_device_removed (context, hal_device_removed_cb); - libhal_ctx_set_device_property_modified (context, hal_device_property_modified_cb); -#endif + g_signal_connect (G_OBJECT (monitor), "mount-pre-unmount", + G_CALLBACK (on_pre_unmount), NULL); } void thumb_hal_shutdown (void) { -#ifdef HAVE_HAL - libhal_ctx_set_user_data (context, NULL); - libhal_ctx_free (context); -#endif + g_object_unref (monitor); } Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h 2009-03-20 10:10:41 UTC (rev 17750) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h 2009-03-20 10:15:48 UTC (rev 17751) @@ -2,6 +2,7 @@ #define __THUMB_HAL_H__ #include <glib-object.h> +#include <gio/gio.h> G_BEGIN_DECLS
- Previous message: [maemo-commits] r17750 - projects/haf/trunk/dbus/debian
- Next message: [maemo-commits] r17752 - in projects/haf/trunk/dbus/debian: . patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]