diff --git a/src/backend/corebackendmanager.cpp b/src/backend/corebackendmanager.cpp index 195bbf6..04cc7b2 100644 --- a/src/backend/corebackendmanager.cpp +++ b/src/backend/corebackendmanager.cpp @@ -1,7 +1,7 @@ /************************************************************************* * Copyright (C) 2010 by Volker Lanz * * Copyright (C) 2015 by Teo Mrnjavac * - * Copyright (C) 2016 by Andrius Štikonas * + * Copyright (C) 2016-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -38,8 +37,6 @@ CoreBackendManager::CoreBackendManager() : m_Backend(nullptr) { - m_KAuthThread = new QThread(); - kauthThread()->start(); } CoreBackendManager* CoreBackendManager::self() diff --git a/src/backend/corebackendmanager.h b/src/backend/corebackendmanager.h index d6b843a..a754252 100644 --- a/src/backend/corebackendmanager.h +++ b/src/backend/corebackendmanager.h @@ -1,5 +1,6 @@ /************************************************************************* * Copyright (C) 2010 by Volker Lanz * + * Copyright (C) 2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -26,7 +27,6 @@ #include #include -class QThread; class QString; class QStringList; class KPluginMetaData; @@ -81,13 +81,6 @@ public: return m_Backend; } - /** - * @return a pointer to the thread where ExternalCommand will start KAuth job - */ - QThread* kauthThread() { - return m_KAuthThread; - } - /** * @return a pointer to the currently loaded backend */ @@ -110,7 +103,6 @@ private: private: CoreBackend *m_Backend; - QThread *m_KAuthThread; KAuth::ExecuteJob *m_job; QString m_Uuid; diff --git a/src/jobs/checkfilesystemjob.cpp b/src/jobs/checkfilesystemjob.cpp index 55110f2..7b7cd92 100644 --- a/src/jobs/checkfilesystemjob.cpp +++ b/src/jobs/checkfilesystemjob.cpp @@ -25,7 +25,6 @@ #include "util/report.h" #include -#include #include diff --git a/src/jobs/job.cpp b/src/jobs/job.cpp index 453521b..8ba23ae 100644 --- a/src/jobs/job.cpp +++ b/src/jobs/job.cpp @@ -1,6 +1,6 @@ /************************************************************************* * Copyright (C) 2008, 2009, 2010 by Volker Lanz * - * Copyright (C) 2016 by Andrius Štikonas * + * Copyright (C) 2016-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -42,10 +42,10 @@ Job::Job() : bool Job::copyBlocks(Report& report, CopyTarget& target, CopySource& source) { m_Report = &report; - ExternalCommand copyCmd(source, target, QProcess::SeparateChannels); + ExternalCommand copyCmd; connect(©Cmd, &ExternalCommand::progress, this, &Job::progress, Qt::QueuedConnection); connect(©Cmd, &ExternalCommand::reportSignal, this, &Job::updateReport, Qt::QueuedConnection); - if (copyCmd.startCopyBlocks() && copyCmd.exitCode() == 0) { + if (copyCmd.copyBlocks(source, target)) { return true; } diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index 533cde1..8cfe5b3 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -1,6 +1,6 @@ /************************************************************************* * Copyright (C) 2008 by Volker Lanz * - * Copyright (C) 2016 by Andrius Štikonas * + * Copyright (C) 2016-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -39,28 +39,7 @@ #include #include - -ExternalCommand::ExternalCommand(CopySource& source, CopyTarget& target,const QProcess::ProcessChannelMode processChannelMode) : - m_ExitCode(-1), - m_Source(&source), - m_Target(&target) -{ - setup(processChannelMode); -} - -/** Starts copyBlocks command. -*/ -bool ExternalCommand::startCopyBlocks() -{ - this->moveToThread(CoreBackendManager::self()->kauthThread()); - QTimer::singleShot(0, this, &ExternalCommand::copyBlocks); - QEventLoop loop; - connect(this, &ExternalCommand::finished, &loop, &QEventLoop::quit); - loop.exec(); - return true; -} - -bool ExternalCommand::copyBlocks() +bool ExternalCommand::copyBlocks(CopySource& source, CopyTarget& target) { bool rval = true; const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy @@ -77,7 +56,7 @@ bool ExternalCommand::copyBlocks() QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); iface.setTimeout(10 * 24 * 3600 * 1000); // 10 days if (iface.isValid()) { - QDBusPendingCall pcall= iface.asyncCall(QStringLiteral("copyblocks"), CoreBackendManager::self()->Uuid(), m_Source->path(), m_Source->firstByte(), m_Source->length(), m_Target->path(), m_Target->firstByte(), blockSize); + QDBusPendingCall pcall= iface.asyncCall(QStringLiteral("copyblocks"), CoreBackendManager::self()->Uuid(), source.path(), source.firstByte(), source.length(), target.path(), target.firstByte(), blockSize); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); QEventLoop loop; @@ -90,7 +69,6 @@ bool ExternalCommand::copyBlocks() QDBusPendingReply reply = *watcher; rval = reply.argumentAt<0>(); } - emit finished(); setExitCode(!rval); }; @@ -190,15 +168,14 @@ bool ExternalCommand::start(int timeout) m_Output = reply.value()[QStringLiteral("output")].toByteArray(); setExitCode(reply.value()[QStringLiteral("exitCode")].toInt()); + rval = true; } - - emit finished(); - rval = true; }; connect(watcher, &QDBusPendingCallWatcher::finished, exitLoop); loop.exec(); } + return rval; } diff --git a/src/util/externalcommand.h b/src/util/externalcommand.h index 01b02bf..cf9e41e 100644 --- a/src/util/externalcommand.h +++ b/src/util/externalcommand.h @@ -1,5 +1,6 @@ /************************************************************************* * Copyright (C) 2008 by Volker Lanz * + * Copyright (C) 2016-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -49,10 +50,9 @@ class LIBKPMCORE_EXPORT ExternalCommand : public QObject public: explicit ExternalCommand(const QString& cmd = QString(), const QStringList& args = QStringList(), const QProcess::ProcessChannelMode processChannelMode = QProcess::MergedChannels); explicit ExternalCommand(Report& report, const QString& cmd = QString(), const QStringList& args = QStringList(), const QProcess::ProcessChannelMode processChannelMode = QProcess::MergedChannels); - explicit ExternalCommand(CopySource& source, CopyTarget& target, QProcess::ProcessChannelMode processChannelMode = QProcess::MergedChannels); public: - bool copyBlocks(); + bool copyBlocks(CopySource& source, CopyTarget& target); void setCommand(const QString& cmd) { m_Command = cmd; } /**< @param cmd the command to run */ const QString& command() const { return m_Command; } /**< @return the command to run */ @@ -86,7 +86,6 @@ public: Q_SIGNALS: void progress(int); - void finished(); void reportSignal(const QVariantMap&); public Q_SLOTS: @@ -110,8 +109,6 @@ private: int m_ExitCode; QByteArray m_Output; QByteArray m_Input; - CopySource *m_Source; - CopyTarget *m_Target; }; #endif diff --git a/src/util/externalcommandhelper.h b/src/util/externalcommandhelper.h index caf0935..0a7590f 100644 --- a/src/util/externalcommandhelper.h +++ b/src/util/externalcommandhelper.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2017 by Andrius Štikonas * + * Copyright (C) 2017-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as *