sd/source/ui/remotecontrol/BluetoothServer.cxx | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
New commits: commit 4cd53be1fc6dd9dd5a981aff5098a96b9f545f35 Author: Michael Meeks <michael.me...@suse.com> Date: Mon Feb 18 14:40:24 2013 +0000 sdremote: start of listening for dynamic changes to adapters. Change-Id: Ifa04c8cc1859c98adca94ac0e57c7ebd85f2f31f diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index 32a15a4..4e2a6a1 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -491,13 +491,25 @@ void SAL_CALL BluetoothServer::run() return; } + // listen for connection state and power changes - we need to close + // and re-create our socket code on suspend / resume, enable/disable + DBusError aError; + dbus_error_init( &aError ); + dbus_bus_add_match( pConnection, "type='signal',interface='org.bluez.Manager'", &aError ); + if( !bluezRegisterServiceRecord( pConnection, mpImpl->mpService, bluetooth_service_record ) ) + { + dbus_connection_unref( pConnection ); return; + } int nSocket = bluezCreateListeningSocket(); if( nSocket < 0 ) + { + dbus_connection_unref( pConnection ); return; + } // ---------------- Socket code ---------------- @@ -535,7 +547,32 @@ void SAL_CALL BluetoothServer::run() SAL_INFO( "sdremote.bluetooth", "main-loop spin " << aDBusFD.revents << " " << aSocketFD.revents ); if( aDBusFD.revents ) - dbus_connection_read_write_dispatch( pConnection, 0 ); + { + dbus_connection_read_write( pConnection, 0 ); + DBusMessage *pMsg = dbus_connection_pop_message( pConnection ); + if( pMsg ) + { + if( dbus_message_is_signal( pMsg, "org.bluez.Manager", "AdapterRemoved" ) ) + { + SAL_WARN( "sdremote.bluetooth", "lost adapter - cleaning up sockets" ); + g_main_context_remove_poll( mpImpl->mpContext, &aSocketFD ); + close( nSocket ); + } + else if( dbus_message_is_signal( pMsg, "org.bluez.Manager", "AdapterAdded" ) ) + { + SAL_WARN( "sdremote.bluetooth", "gained adapter - re-generating sockets" ); + aSocketFD.fd = nSocket = bluezCreateListeningSocket(); + g_main_context_add_poll( mpImpl->mpContext, &aSocketFD, G_PRIORITY_DEFAULT ); + } + else + SAL_INFO( "sdremote.bluetooth", "unknown incoming dbus message, " + << " type: " << dbus_message_get_type( pMsg ) + << " path: '" << dbus_message_get_path( pMsg ) + << "' interface: '" << dbus_message_get_interface( pMsg ) + << "' member: '" << dbus_message_get_member( pMsg ) ); + } + dbus_message_unref( pMsg ); + } if( aSocketFD.revents ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits