{
GDBusConnection *gconn;
- gconn = __get_gdbus_connection();
+ gconn = _bt_init_system_gdbus_conn();
if (gconn == NULL)
return;
g_dbus_connection_unregister_object(gconn, object_id);
+
+ /* TODO: bus_id needs to be un-owned if all of path is unregistered */
+}
+
+static GDBusNodeInfo *_bt_get_gdbus_node(GDBusConnection *gconn, const gchar *xml_data, const char *bus_name)
+{
+ if (bus_id == 0) {
+ char *name = g_strdup(bus_name);
+ BT_DBG("well-known name: %s", name);
+ bus_id = g_bus_own_name_on_connection(gconn,
+ name, G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL);
+ BT_DBG("Got bus id %d", bus_id);
+ g_free(name);
+ }
+
+ return g_dbus_node_info_new_for_xml(xml_data, NULL);
}
int _bt_register_new_conn(const char *path, bt_new_connection_cb cb)
GDBusNodeInfo *node_info;
int id;
GError *error = NULL;
+ char *bus_name;
- gconn = __get_gdbus_connection();
+ gconn = _bt_init_system_gdbus_conn();
if (gconn == NULL)
return -1;
- node_info = _bt_get_gdbus_node(rfcomm_agent_xml);
- if (node_info == NULL)
+ bus_name = g_strdup_printf("org.bt.frwk.p%d", getpid());
+
+ node_info = _bt_get_gdbus_node(gconn, rfcomm_agent_xml, bus_name);
+ if (node_info == NULL) {
+ g_free(bus_name);
return -1;
+ }
+ g_free(bus_name);
id = g_dbus_connection_register_object(gconn, path,
node_info->interfaces[0],
int id;
GError *error = NULL;
- gconn = __get_gdbus_connection();
+ gconn = _bt_init_system_gdbus_conn();
if (gconn == NULL)
return -1;
- node_info = _bt_get_gdbus_node_ex(rfcomm_agent_xml, bus_name);
-
+ node_info = _bt_get_gdbus_node(gconn, rfcomm_agent_xml, bus_name);
if (node_info == NULL)
return -1;
return;
}
-GDBusNodeInfo * _bt_get_gdbus_node(const gchar *xml_data)
-{
- if (bus_id == 0) {
- char *name = g_strdup_printf("org.bt.frwk.p%d", getpid());
-
- bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- name,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
- BT_DBG("Got bus id %d", bus_id);
- g_free(name);
- }
-
- return g_dbus_node_info_new_for_xml(xml_data, NULL);
-}
-
-GDBusNodeInfo * _bt_get_gdbus_node_ex(const gchar *xml_data, const char *bus_name)
-{
- if (bus_id == 0) {
- char *name = g_strdup(bus_name);
- bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- name,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
- BT_DBG("Got bus id %d", bus_id);
- g_free(name);
- }
-
- return g_dbus_node_info_new_for_xml(xml_data, NULL);
-}
-
int _bt_connect_profile(char *address, char *uuid, void *cb,
gpointer func_data)
{
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
- <!-- service name(org.bt.frwk.p<pid>) is changeable by pid -->
<allow own_prefix="org.bt.frwk"/>
- <allow send_interface="org.bluez.Profile1" send_member="NewConnection"/>
- <allow send_interface="org.bluez.Profile1" send_member="RequestDisconnection"/>
+ <allow send_destination_prefix="org.bt.frwk"/>
<allow own_prefix="org.frwk.gatt_service"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.freedesktop.DBus.Properties"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.freedesktop.DBus.ObjectManager"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattCharacteristic1"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattDescriptor1"/>
+ <allow send_destination_prefix="org.frwk.gatt_service"/>
</policy>
<policy group="network_fw">
- <!-- service name(org.bt.frwk.p<pid>) is changeable by pid -->
<allow own_prefix="org.bt.frwk"/>
- <allow send_interface="org.bluez.Profile1" send_member="NewConnection"/>
- <allow send_interface="org.bluez.Profile1" send_member="RequestDisconnection"/>
+ <allow send_destination_prefix="org.bt.frwk"/>
<allow own_prefix="org.frwk.gatt_service"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.freedesktop.DBus.Properties"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.freedesktop.DBus.ObjectManager"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattCharacteristic1"/>
- <allow send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattDescriptor1"/>
+ <allow send_destination_prefix="org.frwk.gatt_service"/>
</policy>
<policy context="default">
<deny own_prefix="org.bt.frwk"/>
- <deny send_interface="org.bluez.Profile1" send_member="NewConnection"/>
- <deny send_interface="org.bluez.Profile1" send_member="RequestDisconnection"/>
+ <deny send_destination_prefix="org.bt.frwk"/>
<deny own_prefix="org.frwk.gatt_service"/>
<deny send_destination_prefix="org.frwk.gatt_service"/>
</policy>