#include <gio/gunixfdlist.h>
#include <cynara-client.h>
#include <cynara-creds-gdbus.h>
+#include <systemd/sd-daemon.h>
#include "bluetooth-api.h"
#include "bluetooth-audio-api.h"
static gboolean __bt_is_sync_function(int service_function)
{
/*TODO: Keep adding sync methods with expect replies from bluetooth service */
- if (service_function == BT_ENABLE_ADAPTER
- || service_function == BT_DISABLE_ADAPTER
- || service_function == BT_GET_LOCAL_ADDRESS
+ if (service_function == BT_GET_LOCAL_ADDRESS
|| service_function == BT_GET_LOCAL_NAME
|| service_function == BT_GET_LOCAL_VERSION
|| service_function == BT_GET_BONDED_DEVICES
switch (function_name) {
case BT_ENABLE_ADAPTER: {
result = _bt_enable_adapter();
- /* Save invocation */
- if (result == BLUETOOTH_ERROR_NONE) {
- BT_DBG("_bt_enable_adapter scheduled successfully! save invocation context");
- sender = (char*)g_dbus_method_invocation_get_sender(context);
- _bt_save_invocation_context(context, result, sender,
- function_name, NULL);
- }
break;
}
case BT_DISABLE_ADAPTER: {
result = _bt_disable_adapter();
- /* Save invocation */
- if (result == BLUETOOTH_ERROR_NONE) {
- BT_DBG("_bt_disable_adapter scheduled successfully! save invocation context");
- sender = (char*)g_dbus_method_invocation_get_sender(context);
- _bt_save_invocation_context(context, result, sender,
- function_name, NULL);
- }
break;
}
case BT_RECOVER_ADAPTER:
return name_acquired;
}
+void _bt_service_unref_connection(void)
+{
+ BT_INFO("+");
+
+ if (bt_service_conn) {
+ g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
+ g_object_unref(bt_service_conn);
+ bt_service_conn = NULL;
+ }
+
+ BT_INFO("-");
+}
+
int _bt_service_register(void)
{
GDBusConnection *conn;
void _bt_service_unregister(void)
{
if (bt_service_conn) {
+ sd_notify(0, "STOPPING=1");
+
if (owner_sig_id > 0) {
g_dbus_connection_signal_unsubscribe(
bt_service_conn, owner_sig_id);
owner_sig_id = 0;
}
- __bt_service_register_object(bt_service_conn, NULL, FALSE);
- if (bt_service_conn) {
- g_object_unref(bt_service_conn);
- bt_service_conn = NULL;
- }
if (owner_id > 0) {
g_bus_unown_name(owner_id);
owner_id = 0;
}
+
+ __bt_service_register_object(bt_service_conn, NULL, FALSE);
}
}