diff --git a/src/agent.c b/src/agent.c
index 36e96e9..8cf37b1 100644
--- a/src/agent.c
+++ b/src/agent.c
#include "log.h"
+#include "dbus-common.h"
#include "adapter.h"
#include "device.h"
#include "agent.h"
GDestroyNotify destroy;
};
-static DBusConnection *connection = NULL;
-
static void agent_release(struct agent *agent)
{
DBusMessage *message;
return;
}
- g_dbus_send_message(connection, message);
+ g_dbus_send_message(btd_get_dbus_connection(), message);
}
static int send_cancel_request(struct agent_request *req)
return -ENOMEM;
}
- g_dbus_send_message(connection, message);
+ g_dbus_send_message(btd_get_dbus_connection(), message);
return 0;
}
}
if (!agent->exited) {
- g_dbus_remove_watch(connection, agent->listener_id);
+ g_dbus_remove_watch(btd_get_dbus_connection(),
+ agent->listener_id);
agent_release(agent);
}
agent->remove_cb = cb;
agent->remove_cb_data = remove_cb_data;
- agent->listener_id = g_dbus_add_disconnect_watch(connection, name,
- agent_exited, agent,
- NULL);
+ agent->listener_id =
+ g_dbus_add_disconnect_watch(btd_get_dbus_connection(), name,
+ agent_exited, agent, NULL);
return agent;
}
DBUS_TYPE_STRING, &uuid,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
- &req->call, REQUEST_TIMEOUT) == FALSE) {
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ req->msg, &req->call,
+ REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
}
dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
DBUS_TYPE_STRING, &mode,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
DBUS_TYPE_UINT32, &passkey,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
DBUS_TYPE_UINT16, &entered,
DBUS_TYPE_INVALID);
- if (!g_dbus_send_message(connection, message)) {
+ if (!g_dbus_send_message(btd_get_dbus_connection(), message)) {
error("D-Bus send failed");
return -1;
}
DBUS_TYPE_STRING, &pincode,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(connection, req->msg,
+ if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
return TRUE;
}
-
-void agent_exit(void)
-{
- dbus_connection_unref(connection);
- connection = NULL;
-}
-
-void agent_init(void)
-{
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-}
diff --git a/src/agent.h b/src/agent.h
index a729633..8fb4758 100644
--- a/src/agent.h
+++ b/src/agent.h
uint8_t agent_get_io_capability(struct agent *agent);
gboolean agent_matches(struct agent *agent, const char *name, const char *path);
-
-void agent_init(void);
-void agent_exit(void);
diff --git a/src/main.c b/src/main.c
index 7593b15..f8c9369 100644
--- a/src/main.c
+++ b/src/main.c
parse_config(config);
- agent_init();
-
if (option_udev == FALSE) {
if (connect_dbus() < 0) {
error("Unable to get on D-Bus");
stop_sdp_server();
- agent_exit();
-
g_main_loop_unref(event_loop);
if (config)