summaryrefslogtreecommitdiffstats
path: root/serial
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-05-29 14:43:27 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-05-29 14:43:27 +0000
commitcc0f97ec2cb298bde87cd3753fd96f11ce41ff64 (patch)
treee02bb5f68ca60810d2793708939306174f4aa100 /serial
parent4baf1de49d3aad2837a968a18a7181d568ff9457 (diff)
Change name_listener API to libgdbus watch API
Diffstat (limited to 'serial')
-rw-r--r--serial/manager.c40
-rw-r--r--serial/port.c17
2 files changed, 25 insertions, 32 deletions
diff --git a/serial/manager.c b/serial/manager.c
index 095abf6b..3d5b6e88 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -79,6 +79,7 @@ struct pending_connect {
int id; /* RFCOMM device id */
int ntries; /* Open attempts */
int canceled; /* Operation canceled */
+ guint listener_id;
};
/* FIXME: Common file required */
@@ -189,35 +190,23 @@ static struct pending_connect *find_pending_connect_by_pattern(const char *bda,
return NULL;
}
-static void transaction_owner_exited(const char *name, void *data)
+static void transaction_owner_exited(void *data)
{
- GSList *l, *tmp = NULL;
- debug("transaction owner %s exited", name);
+ struct pending_connect *pc = data;
- /* Remove all pending calls that belongs to this owner */
- for (l = pending_connects; l != NULL; l = l->next) {
- struct pending_connect *pc = l->data;
- if (strcmp(name, dbus_message_get_sender(pc->msg)) != 0) {
- tmp = g_slist_append(tmp, pc);
- continue;
- }
+ debug("transaction owner exited");
- if (pc->id >= 0)
- rfcomm_release(pc->id);
+ if (pc->id >= 0)
+ rfcomm_release(pc->id);
- pending_connect_free(pc);
- }
+ pending_connects = g_slist_remove(pending_connects, pc);
- g_slist_free(pending_connects);
- pending_connects = tmp;
+ pending_connect_free(pc);
}
static void pending_connect_remove(struct pending_connect *pc)
{
- /* Remove the connection request owner */
- name_listener_remove(pc->conn, dbus_message_get_sender(pc->msg),
- (name_cb_t) transaction_owner_exited, NULL);
-
+ g_dbus_remove_watch(pc->conn, pc->listener_id);
pending_connects = g_slist_remove(pending_connects, pc);
pending_connect_free(pc);
}
@@ -463,8 +452,10 @@ static DBusHandlerResult connect_pending(DBusConnection *conn, DBusMessage *msg,
if (!g_slist_find(pending_connects, pc)) {
pending_connects = g_slist_append(pending_connects, pc);
- name_listener_add(conn, dbus_message_get_sender(msg),
- (name_cb_t) transaction_owner_exited, NULL);
+ pc->listener_id = g_dbus_add_disconnect_watch(conn,
+ dbus_message_get_sender(msg),
+ transaction_owner_exited, pc,
+ NULL);
}
str2ba(pc->adapter, &src);
@@ -634,8 +625,9 @@ static DBusHandlerResult search_uuid(DBusConnection *conn, DBusMessage *msg,
}
pending_connects = g_slist_append(pending_connects, pc);
- name_listener_add(conn, dbus_message_get_sender(msg),
- (name_cb_t) transaction_owner_exited, NULL);
+ pc->listener_id = g_dbus_add_disconnect_watch(conn,
+ dbus_message_get_sender(msg),
+ transaction_owner_exited, pc, NULL);
return DBUS_HANDLER_RESULT_HANDLED;
}
diff --git a/serial/port.c b/serial/port.c
index 0e2ad200..bacf093c 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -244,12 +244,12 @@ static void rfcomm_node_free(struct rfcomm_node *node)
g_free(node);
}
-static void connection_owner_exited(const char *name, void *user_data)
+static void connection_owner_exited(void *user_data)
{
struct rfcomm_node *node = user_data;
- debug("Connect requestor %s exited. Releasing %s node",
- name, node->device);
+ debug("Connect requestor exited. Releasing %s node",
+ node->device);
dbus_connection_emit_signal(node->conn, SERIAL_MANAGER_PATH,
SERIAL_MANAGER_INTERFACE, "ServiceDisconnected" ,
@@ -265,7 +265,7 @@ static gboolean rfcomm_disconnect_cb(GIOChannel *io,
{
debug("RFCOMM node %s was disconnected", node->device);
- name_listener_id_remove(node->listener_id);
+ g_dbus_remove_watch(node->conn, node->listener_id);
dbus_connection_emit_signal(node->conn, SERIAL_MANAGER_PATH,
SERIAL_MANAGER_INTERFACE, "ServiceDisconnected" ,
@@ -299,15 +299,16 @@ void port_add_listener(DBusConnection *conn, int16_t id, bdaddr_t *dst,
node->device = g_strdup(dev);
node->conn = dbus_connection_ref(conn);
node->owner = g_strdup(owner);
- node->io = g_io_channel_unix_new(fd);
+ node->io = g_io_channel_unix_new(fd);
node->io_id = g_io_add_watch(node->io, G_IO_ERR | G_IO_NVAL | G_IO_HUP,
(GIOFunc) rfcomm_disconnect_cb, node);
connected_nodes = g_slist_append(connected_nodes, node);
/* Service connection listener */
- node->listener_id = name_listener_add(conn, owner,
- connection_owner_exited, node);
+ node->listener_id = g_dbus_add_disconnect_watch(conn, owner,
+ connection_owner_exited, node,
+ NULL);
}
int port_remove_listener(const char *owner, const char *dev)
@@ -320,7 +321,7 @@ int port_remove_listener(const char *owner, const char *dev)
if (strcmp(node->owner, owner) != 0)
return -EPERM;
- name_listener_id_remove(node->listener_id);
+ g_dbus_remove_watch(node->conn, node->listener_id);
connected_nodes = g_slist_remove(connected_nodes, node);
rfcomm_node_free(node);