Simplify test conditions

Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21241
This commit is contained in:
Shubham Jangra 2019-05-17 23:02:19 +05:30
parent 997f425030
commit 73a21e6739
2 changed files with 9 additions and 20 deletions

View File

@ -136,7 +136,7 @@ bool ExternalCommand::start(int timeout)
cmd = QStandardPaths::findExecutable(command(), { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") });
if (!QDBusConnection::systemBus().isConnected()) {
qWarning() << "Could not connect to DBus system bus";
qWarning() << QDBusConnection::systemBus().lastError().message();
return false;
}
@ -189,7 +189,7 @@ bool ExternalCommand::copyBlocks(const CopySource& source, CopyTarget& target)
const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy
if (!QDBusConnection::systemBus().isConnected()) {
qWarning() << "Could not connect to DBus system bus";
qWarning() << QDBusConnection::systemBus().lastError().message();
return false;
}
@ -250,7 +250,7 @@ bool ExternalCommand::writeData(Report& commandReport, const QByteArray& buffer,
bool rval = true;
if (!QDBusConnection::systemBus().isConnected()) {
qWarning() << "Could not connect to DBus system bus";
qWarning() << QDBusConnection::systemBus().lastError().message();
return false;
}
@ -377,9 +377,10 @@ void ExternalCommand::setExitCode(int i)
bool ExternalCommand::startHelper()
{
if (!QDBusConnection::systemBus().isConnected()) {
qWarning() << "Could not connect to DBus system bus";
qWarning() << QDBusConnection::systemBus().lastError().message();
return false;
}
QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus());
if (iface.isValid()) {
exit(0);
@ -470,11 +471,8 @@ quint64 ExternalCommand::getNonce(QDBusInterface& iface)
void DBusThread::run()
{
if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface"))) {
qWarning() << QDBusConnection::systemBus().lastError().message();
return;
}
if (!QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) {
if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) ||
!QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) {
qWarning() << QDBusConnection::systemBus().lastError().message();
return;
}

View File

@ -45,18 +45,9 @@
ActionReply ExternalCommandHelper::init(const QVariantMap& args)
{
ActionReply reply;
if (!QDBusConnection::systemBus().isConnected()) {
qWarning() << "Could not connect to DBus system bus";
reply.addData(QStringLiteral("success"), false);
return reply;
}
if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.helperinterface"))) {
qWarning() << QDBusConnection::systemBus().lastError().message();
reply.addData(QStringLiteral("success"), false);
return reply;
}
if (!QDBusConnection::systemBus().registerObject(QStringLiteral("/Helper"), this, QDBusConnection::ExportAllSlots)) {
if (!QDBusConnection::systemBus().isConnected() || !QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.helperinterface")) ||
!QDBusConnection::systemBus().registerObject(QStringLiteral("/Helper"), this, QDBusConnection::ExportAllSlots)) {
qWarning() << QDBusConnection::systemBus().lastError().message();
reply.addData(QStringLiteral("success"), false);
return reply;