Commit daf9bb25 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

dbus: remove silly configuration option regarding unique name

Register both names unique and not. Fail if the unique name cannot be
obtained.
parent b740301c
...@@ -178,13 +178,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -178,13 +178,6 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
char psz_service_name[sizeof(DBUS_MPRIS_BUS_NAME) + 12];
if( var_InheritBool( p_intf, "dbus-unique-service-id" ) )
snprintf( psz_service_name, sizeof( psz_service_name ),
DBUS_MPRIS_BUS_NAME"-%d", getpid() );
else
strcpy( psz_service_name, DBUS_MPRIS_BUS_NAME );
DBusError error; DBusError error;
dbus_error_init( &error ); dbus_error_init( &error );
...@@ -204,16 +197,21 @@ static int Open( vlc_object_t *p_this ) ...@@ -204,16 +197,21 @@ static int Open( vlc_object_t *p_this )
dbus_connection_set_exit_on_disconnect( p_conn, FALSE ); dbus_connection_set_exit_on_disconnect( p_conn, FALSE );
/* register a well-known name on the bus */ /* register a well-known name on the bus */
dbus_bus_request_name( p_conn, psz_service_name, 0, &error ); char unique_service[sizeof (DBUS_MPRIS_BUS_NAME) + 10];
snprintf( unique_service, sizeof (unique_service),
DBUS_MPRIS_BUS_NAME"-%"PRIu32, (uint32_t)getpid() );
dbus_bus_request_name( p_conn, unique_service, 0, &error );
if( dbus_error_is_set( &error ) ) if( dbus_error_is_set( &error ) )
{ {
msg_Err( p_this, "Error requesting service %s: %s", msg_Err( p_this, "Error requesting service name %s: %s",
psz_service_name, error.message ); unique_service, error.message );
dbus_error_free( &error ); dbus_error_free( &error );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
msg_Info( p_intf, "listening on dbus as: %s", psz_service_name ); msg_Info( p_intf, "listening on dbus as: %s", unique_service );
dbus_bus_request_name( p_conn, DBUS_MPRIS_BUS_NAME, 0, NULL );
/* Register the entry point object path */ /* Register the entry point object path */
dbus_connection_register_object_path( p_conn, DBUS_MPRIS_OBJECT_PATH, dbus_connection_register_object_path( p_conn, DBUS_MPRIS_OBJECT_PATH,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment