reserver: update from upstream git

This commit is contained in:
Lennart Poettering 2009-08-17 03:41:14 +02:00
parent 8208214882
commit c579cb56e9

View file

@ -38,6 +38,7 @@ struct rm_monitor {
char *device_name; char *device_name;
char *service_name; char *service_name;
char *match;
DBusConnection *connection; DBusConnection *connection;
@ -51,6 +52,13 @@ struct rm_monitor {
#define SERVICE_PREFIX "org.freedesktop.ReserveDevice1." #define SERVICE_PREFIX "org.freedesktop.ReserveDevice1."
#define SERVICE_FILTER \
"type='signal'," \
"sender='" DBUS_SERVICE_DBUS "'," \
"interface='" DBUS_INTERFACE_DBUS "'," \
"member='NameOwnerChanged'," \
"arg0='%s'"
static DBusHandlerResult filter_handler( static DBusHandlerResult filter_handler(
DBusConnection *c, DBusConnection *c,
DBusMessage *s, DBusMessage *s,
@ -175,11 +183,13 @@ int rm_watch(
m->filtering = 1; m->filtering = 1;
dbus_bus_add_match(m->connection, if (!(m->match = malloc(sizeof(SERVICE_FILTER) - 2 + strlen(m->service_name)))) {
"type='signal'," r = -ENOMEM;
"sender='" DBUS_SERVICE_DBUS "'," goto fail;
"interface='" DBUS_INTERFACE_DBUS "'," }
"member='NameOwnerChanged'", error);
sprintf(m->match, SERVICE_FILTER, m->service_name);
dbus_bus_add_match(m->connection, m->match, error);
if (dbus_error_is_set(error)) { if (dbus_error_is_set(error)) {
r = -EIO; r = -EIO;
@ -220,10 +230,8 @@ void rm_release(rm_monitor *m) {
if (m->matching) if (m->matching)
dbus_bus_remove_match( dbus_bus_remove_match(
m->connection, m->connection,
"type='signal'," m->match,
"sender='" DBUS_SERVICE_DBUS "'," NULL);
"interface='" DBUS_INTERFACE_DBUS "',"
"member='NameOwnerChanged'", NULL);
if (m->filtering) if (m->filtering)
dbus_connection_remove_filter( dbus_connection_remove_filter(
@ -233,6 +241,7 @@ void rm_release(rm_monitor *m) {
free(m->device_name); free(m->device_name);
free(m->service_name); free(m->service_name);
free(m->match);
if (m->connection) if (m->connection)
dbus_connection_unref(m->connection); dbus_connection_unref(m->connection);