summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-security.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-08-20 21:41:59 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-08-20 21:41:59 +0000
commitec3ac41ca8876f36cc8869ab1c384980f793c40f (patch)
tree54cfad49658e334487dd602dd9cd5219e23454f8 /hcid/dbus-security.c
parentbe52c05a25c0cbadcd605b24d66d0c0b682aee18 (diff)
Preliminary support for passkey agent timeouts
Diffstat (limited to 'hcid/dbus-security.c')
-rw-r--r--hcid/dbus-security.c73
1 files changed, 50 insertions, 23 deletions
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index 91a03e5d..c9c6763f 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -39,7 +39,8 @@
#include "dbus.h"
#include "hcid.h"
-#define TIMEOUT (30 * 1000) /* 30 seconds */
+#define REQUEST_TIMEOUT (30 * 1000) /* 30 seconds */
+#define AGENT_TIMEOUT (1 * 10 * 1000) /* 3 minutes */
static struct passkey_agent *default_agent = NULL;
@@ -64,6 +65,9 @@ static void passkey_agent_free(struct passkey_agent *agent)
free(req);
}
+ if (agent->timeout)
+ g_timeout_remove(agent->timeout);
+
if (!agent->exited)
release_agent(agent);
@@ -81,6 +85,45 @@ static void passkey_agent_free(struct passkey_agent *agent)
free(agent);
}
+static void agent_exited(const char *name, struct hci_dbus_data *adapter)
+{
+ struct slist *cur, *next;
+
+ debug("Passkey agent %s exited without calling Unregister", name);
+
+ for (cur = adapter->passkey_agents; cur != NULL; cur = next) {
+ struct passkey_agent *agent = cur->data;
+
+ next = cur->next;
+
+ if (strcmp(agent->name, name))
+ continue;
+
+ agent->exited = 1;
+
+ adapter->passkey_agents = slist_remove(adapter->passkey_agents, agent);
+ passkey_agent_free(agent);
+ }
+}
+
+static gboolean agent_timeout(struct passkey_agent *agent)
+{
+ struct hci_dbus_data *pdata = agent->pdata;
+
+ debug("Passkey Agent at %s, %s timed out", agent->name, agent->path);
+
+ if (pdata)
+ pdata->passkey_agents = slist_remove(pdata->passkey_agents, agent);
+
+ name_listener_remove(agent->conn, agent->name, (name_cb_t)agent_exited, pdata);
+
+ agent->timeout = 0;
+
+ passkey_agent_free(agent);
+
+ return FALSE;
+}
+
static void default_agent_exited(const char *name, void *data)
{
debug("%s exited without unregistering the default passkey agent", name);
@@ -167,27 +210,6 @@ static int agent_cmp(const struct passkey_agent *a, const struct passkey_agent *
return 0;
}
-static void agent_exited(const char *name, struct hci_dbus_data *adapter)
-{
- struct slist *cur, *next;
-
- debug("Passkey agent %s exited without calling Unregister", name);
-
- for (cur = adapter->passkey_agents; cur != NULL; cur = next) {
- struct passkey_agent *agent = cur->data;
-
- next = cur->next;
-
- if (strcmp(agent->name, name))
- continue;
-
- agent->exited = 1;
-
- adapter->passkey_agents = slist_remove(adapter->passkey_agents, agent);
- passkey_agent_free(agent);
- }
-}
-
static DBusHandlerResult register_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -233,6 +255,11 @@ static DBusHandlerResult register_agent(DBusConnection *conn,
if (!slist_find(adapter->passkey_agents, &ref, (cmp_func_t)agent_cmp))
name_listener_add(conn, ref.name, (name_cb_t)agent_exited, adapter);
+ /* Because of bugs in glib-ectonomy.c this doesn't work yet */
+#if 0
+ agent->timeout = g_timeout_add(AGENT_TIMEOUT, (GSourceFunc)agent_timeout, agent);
+#endif
+
adapter->passkey_agents = slist_append(adapter->passkey_agents, agent);
return send_reply_and_unref(conn, reply);
@@ -486,7 +513,7 @@ static int call_passkey_agent(DBusConnection *conn,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(conn, message,
- &req->call, TIMEOUT) == FALSE) {
+ &req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
goto failed;
}