summaryrefslogtreecommitdiffstats
path: root/serial/port.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-05-17 18:09:14 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-05-17 18:09:14 +0000
commit23a6e61e8ceeb719a88788292390ad062712034d (patch)
treec4eb16daaa76d39ce71c169c5269340d1fbd239c /serial/port.c
parentdf7260b7a01d10f92849ca9a862a2a2d6ffac865 (diff)
serial: fixed DisconnectService and added port_remove_listener
Diffstat (limited to 'serial/port.c')
-rw-r--r--serial/port.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/serial/port.c b/serial/port.c
index 1ff26714..00bddab1 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -73,6 +73,19 @@ struct open_context {
static GSList *connected_nodes = NULL;
+static struct rfcomm_node *find_node_by_name(GSList *nodes, const char *name)
+{
+ GSList *l;
+
+ for (l = nodes; l != NULL; l = l->next) {
+ struct rfcomm_node *node = l->data;
+ if (!strcmp(node->name, name))
+ return node;
+ }
+
+ return NULL;
+}
+
static DBusHandlerResult port_connect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -187,6 +200,25 @@ int port_add_listener(DBusConnection *conn, int id, int fd,
(name_cb_t) connection_owner_exited, node);
}
+int port_remove_listener(const char *owner, const char *name)
+{
+ struct rfcomm_node *node;
+
+ node = find_node_by_name(connected_nodes, name);
+ if (!node)
+ return -ENOENT;
+ if (strcmp(node->owner, owner) != 0)
+ return -EPERM;
+
+ name_listener_remove(node->conn, owner,
+ (name_cb_t) connection_owner_exited, node);
+
+ connected_nodes = g_slist_remove(connected_nodes, node);
+ rfcomm_node_free(node);
+
+ return 0;
+}
+
int port_register(DBusConnection *conn, int id, const char *name, char *ppath)
{
char path[MAX_PATH_LENGTH];