Skip to content

Commit

Permalink
Clean up the devicelock DBUS
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Oct 22, 2013
1 parent f077757 commit ebcb3a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/usb_moded-devicelock.c
Expand Up @@ -38,6 +38,8 @@
#include "usb_moded-modes.h"

static DBusHandlerResult devicelock_unlocked_cb(DBusConnection *conn, DBusMessage *msg, void *user_data);

DBusConnection *dbus_conn_devicelock = NULL;

/** Checks if the device is locked.
*
Expand Down Expand Up @@ -77,7 +79,6 @@ int usb_moded_get_export_permission(void)
int start_devicelock_listener(void)
{
DBusError err = DBUS_ERROR_INIT;
DBusConnection *dbus_conn_devicelock = NULL;

if( (dbus_conn_devicelock = dbus_bus_get(DBUS_BUS_SYSTEM, &err)) == 0 )
{
Expand All @@ -95,13 +96,25 @@ int start_devicelock_listener(void)
log_err("adding system dbus filter for devicelock failed");
goto cleanup;
}
dbus_connection_setup_with_g_main(dbus_conn_devicelock, NULL);
//dbus_connection_setup_with_g_main(dbus_conn_devicelock, NULL);

cleanup:
dbus_error_free(&err);
return(1);
}

int stop_devicelock_listener(void)
{
if(dbus_conn_devicelock)
{
dbus_connection_remove_filter(dbus_conn_devicelock, devicelock_unlocked_cb, NULL);
dbus_bus_remove_match(dbus_conn_devicelock, MATCH_DEVICELOCK_SIGNALS, NULL);
dbus_connection_unref(dbus_conn_devicelock);
}

return 0;
}

static DBusHandlerResult devicelock_unlocked_cb(DBusConnection *conn, DBusMessage *msg, void *user_data)
{
DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-lock.h
Expand Up @@ -25,4 +25,4 @@
/*============================================================================= */
int usb_moded_get_export_permission(void);
int start_devicelock_listener(void);

int stop_devicelock_listener(void);

0 comments on commit ebcb3a0

Please sign in to comment.