[partition] Log DBus calls and switch to blocking calls to ensure they happen

This commit is contained in:
Adriaan de Groot 2022-03-01 14:03:04 +01:00
parent 7e51731167
commit 60630efa6a

View File

@ -45,6 +45,26 @@ kdedCall( const QString& method )
QStringLiteral( "org.kde.kded5" ), QStringLiteral( "/kded" ), QStringLiteral( "org.kde.kded5" ), method ); QStringLiteral( "org.kde.kded5" ), QStringLiteral( "/kded" ), QStringLiteral( "org.kde.kded5" ), method );
} }
/** @brief Log a response from call()
*
* Logs without a function header so it is simple to use from an existing
* logging-block. Assumes @p r is a reply or an error message.
*
* @internal
*/
static void
logDBusResponse( QDBusMessage&& r )
{
if ( r.type() == QDBusMessage::ReplyMessage )
{
cDebug() << Logger::SubEntry << r.type() << "reply" << r.arguments();
}
else
{
cDebug() << Logger::SubEntry << r.type() << "error" << r.errorMessage();
}
}
/** @brief Enables (or disables) automount for Solid /** @brief Enables (or disables) automount for Solid
* *
* If @p enable is @c true, enables automount. Otherwise, disables it. * If @p enable is @c true, enables automount. Otherwise, disables it.
@ -60,14 +80,14 @@ enableSolidAutoMount( QDBusConnection& dbus, bool enable )
{ {
auto msg = kdedCall( QStringLiteral( "setModuleAutoloading" ) ); auto msg = kdedCall( QStringLiteral( "setModuleAutoloading" ) );
msg.setArguments( { moduleName, QVariant( enable ) } ); msg.setArguments( { moduleName, QVariant( enable ) } );
dbus.call( msg, QDBus::NoBlock ); logDBusResponse( dbus.call( msg, QDBus::Block ) );
} }
// Stop module // Stop module
{ {
auto msg = kdedCall( enable ? QStringLiteral( "loadModule" ) : QStringLiteral( "unloadModule" ) ); auto msg = kdedCall( enable ? QStringLiteral( "loadModule" ) : QStringLiteral( "unloadModule" ) );
msg.setArguments( { moduleName } ); msg.setArguments( { moduleName } );
dbus.call( msg, QDBus::NoBlock ); logDBusResponse( dbus.call( msg, QDBus::Block ) );
} }
} }