static guint bus_id;
static GDBusConnection *system_gconn = NULL;
-static GDBusConnection *session_gconn = NULL;
-
#define DBUS_TIMEOUT 20 * 1000 /* 20 Seconds */
return private_gconn;
}
-GDBusConnection *g_bus_get_private_session_conn(void)
-{
- GError *error = NULL;
- char *address;
- GDBusConnection *private_gconn = NULL;
-
- address = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SESSION, NULL, &error);
- if (address == NULL) {
- if (error) {
- BT_ERR("Failed to get bus address: %s", error->message);
- g_clear_error(&error);
- }
- return NULL;
- }
-
- private_gconn = g_dbus_connection_new_for_address_sync(address,
- G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
- G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
- NULL, /* GDBusAuthObserver */
- NULL,
- &error);
- if (!private_gconn) {
- if (error) {
- BT_ERR("Unable to connect to dbus: %s", error->message);
- g_clear_error(&error);
- }
- return NULL;
- }
-
- return private_gconn;
-}
-
GDBusConnection *_bt_gdbus_init_system_gconn(void)
{
dbus_threads_init_default();
return system_gconn;
}
-GDBusConnection *_bt_gdbus_init_session_gconn(void)
-{
- dbus_threads_init_default();
-
- if (session_gconn != NULL)
- return session_gconn;
-
- session_gconn = g_bus_get_private_session_conn();
-
- return session_gconn;
-}
-
GDBusConnection *_bt_gdbus_get_system_gconn(void)
{
return system_gconn;
}
-GDBusConnection *_bt_gdbus_get_session_gconn(void)
-{
-
-
- if (session_gconn == NULL) {
- session_gconn = _bt_gdbus_init_session_gconn();
- } else if (g_dbus_connection_is_closed(session_gconn)) {
- session_gconn = g_bus_get_private_session_conn();
- }
-
- return session_gconn;
-}
-
-
void _bt_print_device_address_t(const bluetooth_device_address_t *addr)
{
BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", addr->addr[0], addr->addr[1], addr->addr[2],
g_object_unref(system_gconn);
system_gconn = NULL;
}
-
- if (session_gconn) {
- g_object_unref(session_gconn);
- session_gconn = NULL;
- }
return BLUETOOTH_ERROR_NONE;
}
return BLUETOOTH_ERROR_INTERNAL;
}
- connection_type = _bt_gdbus_get_session_gconn();
+ connection_type = _bt_gdbus_get_system_gconn();
if (connection_type == NULL)
return BLUETOOTH_ERROR_INTERNAL;
return BLUETOOTH_ERROR_INTERNAL;
}
- connection_type = _bt_gdbus_get_session_gconn();
+ connection_type = _bt_gdbus_get_system_gconn();
event_list = g_slist_remove(event_list, (void *)cb_data);
{
GDBusConnection *connection_type;
- connection_type = _bt_gdbus_get_session_gconn();
+ connection_type = _bt_gdbus_get_system_gconn();
if (connection_type == NULL) {
BT_ERR("Unable to get the bus");
return;
{
GDBusConnection *connection_type;
- connection_type = _bt_gdbus_get_session_gconn();
+ connection_type = _bt_gdbus_get_system_gconn();
if (connection_type != NULL && owner_sig_id != -1) {
g_dbus_connection_signal_unsubscribe(connection_type,
owner_sig_id);
GDBusProxy *proxy;
GError *err = NULL;
-// service_gconn = _bt_gdbus_get_system_gconn();
- service_gconn = _bt_gdbus_get_session_gconn();
+ service_gconn = _bt_gdbus_get_system_gconn();
if (!service_gconn)
return NULL;
GDBusConnection *_bt_gdbus_get_system_gconn(void);
-GDBusConnection *_bt_gdbus_init_session_gconn(void);
-
-GDBusConnection *_bt_gdbus_get_session_gconn(void);
-
-
GVariant *_bt_get_managed_objects(void);
void _bt_convert_device_path_to_address(const char *device_path,
GError *err = NULL;
int result;
- conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
NULL, NULL, NULL,
ENDIF(LIBNOTIFY_SUPPORT)
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service.in ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service DESTINATION share/dbus-1/services)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service DESTINATION share/dbus-1/system-services)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-pair-blacklist DESTINATION /opt/var/lib/bluetooth/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
ENDIF (TIZEN_WEARABLE)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/session.d)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
<allow own="org.projectx.bt_event"/>
<allow own="org.projectx.bluetooth.share"/>
<allow own="org.bluez.ag_agent"/>
- <allow own="org.bluez.Agent1"/>
<allow own="org.tizen.csd.Call.Instance"/>
</policy>
<policy group="root">
<allow own="org.projectx.bt_event"/>
<allow own="org.projectx.bluetooth.share"/>
<allow own="org.bluez.ag_agent"/>
- <allow own="org.bluez.Agent1"/>
- <allow own="org.tizen.csd.Call.Instance"/>
- </policy>
- <policy group="user">
- <allow own="org.projectx.bt"/>
- <allow own="org.projectx.bt_event"/>
- <allow own="org.projectx.bluetooth.share"/>
- <allow own="org.bluez.ag_agent"/>
- <allow own="org.bluez.Agent1"/>
<allow own="org.tizen.csd.Call.Instance"/>
</policy>
<policy at_console="true">
case BT_LE_IPSP_DEINIT:
case BT_LE_IPSP_CONNECT:
case BT_LE_IPSP_DISCONNECT:
- case BT_PASSKEY_REPLY:
- case BT_PASSKEY_CONFIRMATION_REPLY:
ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
BT_PRIVILEGE_PLATFORM);
GError *err = NULL;
int result;
- conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
NULL, NULL, NULL,
return BLUETOOTH_ERROR_INTERNAL;
}
- conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
if (conn == NULL) {
BT_ERR("conn == NULL");
[D-BUS Service]
Name=org.projectx.bt
Exec=/bin/false
+User=root
SystemdService=bluetooth-frwk.service
[Unit]
Description=Bluetooth service
+After=multi-user.target
[Service]
+User=owner
+Group=users
+SupplementaryGroups=priv_mediastorage priv_externalstorage
Type=dbus
BusName=org.projectx.bt
ExecStart=/usr/bin/bt-service
KillMode=process
+Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5001/dbus/user_bus_socket
[Install]
-WantedBy=default.target
+WantedBy=multi-user.target
%else
%define _servicefile packaging/bluetooth-frwk-mobile.service
%endif
-%define _servicedir default.target.wants
+%define _servicedir multi-user.target.wants
%endif
%if "%{?profile}" == "wearable"
#mkdir -p %{buildroot}%{_libdir}/systemd/user
#install -m 0644 packaging/bluetooth-frwk-tv.service %{buildroot}%{_libdir}/systemd/user
-mkdir -p %{buildroot}/usr/lib/systemd/user/%{_servicedir}
-install -m 0644 %{_servicefile} %{buildroot}/usr/lib/systemd/user/bluetooth-frwk.service
-ln -s ../bluetooth-frwk.service %{buildroot}/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service
+mkdir -p %{buildroot}%{_unitdir}/%{_servicedir}
+install -m 0644 %{_servicefile} %{buildroot}%{_unitdir}/bluetooth-frwk.service
+ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
%if %{with bluetooth_frwk_libnotify} || %{with bluetooth_frwk_libnotification}
mkdir -p %{buildroot}%{_datadir}/icons/default
%defattr(-, root, root)
%{_libdir}/libbluetooth-api.so.*
%{_datadir}/license/bluetooth-frwk
-/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service
-/usr/lib/systemd/user/bluetooth-frwk.service
+%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service
%files devel
%defattr(-, root, root)
%files service
%manifest %{name}.manifest
%defattr(-, root, root)
-%{_datadir}/dbus-1/services/org.projectx.bt.service
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service
%{_bindir}/bt-service
#%{_libdir}/systemd/user/bluetooth-frwk-tv.service
-/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service
-%{_sysconfdir}/dbus-1/session.d/bluetooth-frwk-service.conf
+%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
+%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf
%{_bindir}/bluetooth-frwk-test
#%{_bindir}/bluetooth-gatt-test
#%{_bindir}/bluetooth-advertising-test