Hook up server probe/remove callbacks

This commit is contained in:
Marcel Holtmann 2008-03-12 19:21:33 +00:00
parent cf551c7e70
commit 9a3a941ae4
4 changed files with 32 additions and 0 deletions

View File

@ -378,6 +378,8 @@ int unregister_adapter_path(const char *path)
info("Unregister path: %s", path); info("Unregister path: %s", path);
__remove_servers(path);
dbus_connection_get_object_user_data(connection, path, dbus_connection_get_object_user_data(connection, path,
(void *) &adapter); (void *) &adapter);
@ -515,6 +517,8 @@ int hcid_dbus_register_device(uint16_t id)
DBUS_TYPE_STRING, &pptr, DBUS_TYPE_STRING, &pptr,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
__probe_servers(path);
return 0; return 0;
failed: failed:

View File

@ -213,3 +213,5 @@ int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
gboolean plugin_init(void); gboolean plugin_init(void);
void plugin_cleanup(void); void plugin_cleanup(void);
void __probe_servers(const char *adapter);
void __remove_servers(const char *adapter);

View File

@ -42,3 +42,27 @@ void bt_unregister_server(struct bt_server *server)
{ {
servers = g_slist_remove(servers, server); servers = g_slist_remove(servers, server);
} }
void __probe_servers(const char *adapter)
{
GSList *list;
for (list = servers; list; list = list->next) {
struct bt_server *server = list->data;
if (server->probe)
server->probe(adapter);
}
}
void __remove_servers(const char *adapter)
{
GSList *list;
for (list = servers; list; list = list->next) {
struct bt_server *server = list->data;
if (server->remove)
server->remove(adapter);
}
}

View File

@ -23,6 +23,8 @@
struct bt_server { struct bt_server {
const char *uuid; const char *uuid;
int (*probe) (const char *adapter);
void (*remove) (const char *adapter);
}; };
int bt_register_server(struct bt_server *server); int bt_register_server(struct bt_server *server);