hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Tue Jul 17 08:42:50 PDT 2007
configure.in | 2 -
hald/hald.c | 85 +++++++++++++++--------------------------------------------
2 files changed, 23 insertions(+), 64 deletions(-)
New commits:
diff-tree 5509d85896d057d025d9a5a30c4042e9efb71ce8 (from d6c277cfb680e08c2b0689e103c5597c749df001)
Author: David Zeuthen <davidz at redhat.com>
Date: Tue Jul 17 11:42:53 2007 -0400
work with PK head
diff --git a/configure.in b/configure.in
index e78c1a8..52b67b7 100644
--- a/configure.in
+++ b/configure.in
@@ -14,7 +14,7 @@ AM_MAINTAINER_MODE
glib_module="glib-2.0 >= 2.6.0 gobject-2.0 > 2.6.0 dbus-glib-1 >= 0.61"
dbus_module="dbus-1 >= 0.61"
volume_id_module="libvolume_id >= 0.77"
-polkit_module="polkit >= 0.3"
+polkit_module="polkit >= 0.4"
# libtool versioning - this applies to libhal and libhal-storage
#
diff --git a/hald/hald.c b/hald/hald.c
index 394bb1e..438f02b 100644
--- a/hald/hald.c
+++ b/hald/hald.c
@@ -418,77 +418,38 @@ out:
#ifdef HAVE_POLKIT
-typedef struct
-{
- PolKitContextFileMonitorNotifyFunc notify_cb;
- gpointer user_data;
-} PolkitFMClosure;
-
-static void
-_polkit_fm_notify_func (HalFileMonitor *monitor,
- HalFileMonitorEvent event,
- const char *path,
- gpointer user_data)
+static gboolean
+_polkit_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
{
- PolkitFMClosure *closure = user_data;
- if (closure->notify_cb != NULL) {
- closure->notify_cb (pk_context,
- event, /* binary compatible */
- path,
- closure->user_data);
- }
+ int fd;
+ PolKitContext *pk_context = user_data;
+ fd = g_io_channel_unix_get_fd (channel);
+ polkit_context_io_func (pk_context, fd);
+ return TRUE;
}
-static int
-_polkit_fm_add_watch (PolKitContext *pk_context,
- const char *path,
- PolKitContextFileMonitorEvent event_mask,
- PolKitContextFileMonitorNotifyFunc notify_cb,
- gpointer user_data)
+static int
+_polkit_io_add_watch (PolKitContext *pk_context, int fd)
{
- unsigned int ret;
- HalFileMonitor *file_monitor;
- PolkitFMClosure *closure;
-
- ret = 0;
-
- file_monitor = osspec_get_file_monitor ();
- if (file_monitor == NULL)
+ guint id = 0;
+ GIOChannel *channel;
+ channel = g_io_channel_unix_new (fd);
+ if (channel == NULL)
+ goto out;
+ id = g_io_add_watch (channel, G_IO_IN, _polkit_io_watch_have_data, pk_context);
+ if (id == 0) {
+ g_io_channel_unref (channel);
goto out;
-
- closure = g_new0 (PolkitFMClosure, 1);
- closure->notify_cb = notify_cb;
- closure->user_data = user_data;
-
- /* TODO FIXME: ugh, we probably leak this... too bad. */
-
- ret = hal_file_monitor_add_notify (file_monitor,
- path,
- event_mask, /* binary compatible */
- _polkit_fm_notify_func,
- closure);
- if (ret == 0) {
- g_free (closure);
}
-
+ g_io_channel_unref (channel);
out:
- return (int) ret;
+ return id;
}
static void
-_polkit_fm_remove_watch (PolKitContext *pk_context,
- int watch_id)
+_polkit_io_remove_watch (PolKitContext *pk_context, int watch_id)
{
- HalFileMonitor *file_monitor;
-
- file_monitor = osspec_get_file_monitor ();
- if (file_monitor == NULL)
- goto out;
-
- hal_file_monitor_remove_notify (file_monitor, (guint) watch_id);
-
-out:
- ;
+ g_source_remove (watch_id);
}
static guint _polkit_cooloff_timer = 0;
@@ -784,9 +745,7 @@ main (int argc, char *argv[])
polkit_context_set_config_changed (pk_context,
_polkit_config_changed_cb,
NULL);
- polkit_context_set_file_monitor (pk_context,
- _polkit_fm_add_watch,
- _polkit_fm_remove_watch);
+ polkit_context_set_io_watch_functions (pk_context, _polkit_io_add_watch, _polkit_io_remove_watch);
if (!polkit_context_init (pk_context, &p_error))
DIE (("Could not init PolicyKit context: %s", polkit_error_get_error_message (p_error)));
#endif
More information about the hal-commit
mailing list