summaryrefslogtreecommitdiff
path: root/lib/bluetooth-agent.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2010-10-27 18:32:15 +0100
committerBastien Nocera <hadess@hadess.net>2010-10-27 20:56:03 +0100
commit40d9e4273341bbf908b5877c5f345897ca7e9db6 (patch)
tree4fdf3979e4e483272fc23e0db39fe09fc8018167 /lib/bluetooth-agent.c
parent256e5dfe41bfa7a66e5d73941d44557c3ed58710 (diff)
downloadgnome-bluetooth-40d9e4273341bbf908b5877c5f345897ca7e9db6.tar.gz
lib: Simplify agent finalization
Turns out that we were doing pretty much the same thing in unregister and in finalize.
Diffstat (limited to 'lib/bluetooth-agent.c')
-rw-r--r--lib/bluetooth-agent.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 52298b61..900d781b 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -322,21 +322,9 @@ static void bluetooth_agent_init(BluetoothAgent *agent)
static void bluetooth_agent_finalize(GObject *agent)
{
- BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
-
DBG("agent %p", agent);
- if (priv->adapter != NULL) {
- dbus_g_proxy_call(priv->adapter, "UnregisterAgent", NULL,
- DBUS_TYPE_G_OBJECT_PATH, priv->path,
- G_TYPE_INVALID, G_TYPE_INVALID);
-
- g_object_unref(priv->adapter);
- priv->adapter = NULL;
- }
-
- g_free(priv->path);
- g_free(priv->busname);
+ bluetooth_agent_unregister (BLUETOOTH_AGENT (agent));
G_OBJECT_CLASS(bluetooth_agent_parent_class)->finalize(agent);
}
@@ -472,13 +460,15 @@ gboolean bluetooth_agent_register(BluetoothAgent *agent, DBusGProxy *adapter)
gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
{
- BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+ BluetoothAgentPrivate *priv;
GError *error = NULL;
g_return_val_if_fail (BLUETOOTH_IS_AGENT (agent), FALSE);
DBG("agent %p", agent);
+ priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
+
if (priv->adapter == NULL)
return FALSE;
@@ -504,6 +494,9 @@ gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
g_free(priv->path);
priv->path = NULL;
+ g_free(priv->busname);
+ priv->busname = NULL;
+
return TRUE;
}