summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-15 16:00:49 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-15 16:00:49 (GMT)
commitefcd7fa495002d5711a05a568fa2d25e1ace56df (patch)
tree04e57b032ffa9f9aef6ca360f05e1072899658b4
parent373b0c2a04ad71b96b571923b57051b294f2b627 (diff)
Port away from KIO::NetAccess
-rw-r--r--app/fileoperations.cpp4
-rw-r--r--app/gvcore.cpp7
-rw-r--r--app/mainwindow.cpp1
-rw-r--r--lib/mimetypeutils.cpp1
-rw-r--r--tests/auto/testutils.cpp35
5 files changed, 30 insertions, 18 deletions
diff --git a/app/fileoperations.cpp b/app/fileoperations.cpp
index ca21ac6..c554287 100644
--- a/app/fileoperations.cpp
+++ b/app/fileoperations.cpp
@@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <KIO/DeleteJob>
#include <KIO/Job>
#include <KIO/JobUiDelegate>
-#include <KIO/NetAccess>
#include <KLocalizedString>
#include <KJobWidgets>
@@ -214,7 +213,8 @@ void rename(const QUrl &oldUrl, QWidget* parent)
newUrl = newUrl.adjusted(QUrl::RemoveFilename);
newUrl.setPath(newUrl.path() + name);
KIO::SimpleJob* job = KIO::rename(oldUrl, newUrl, KIO::HideProgressInfo);
- if (!KIO::NetAccess::synchronousRun(job, parent)) {
+ KJobWidgets::setWindow(job, parent);
+ if (!job->exec()) {
job->ui()->showErrorMessage();
return;
}
diff --git a/app/gvcore.cpp b/app/gvcore.cpp
index adf75f6..376f48c 100644
--- a/app/gvcore.cpp
+++ b/app/gvcore.cpp
@@ -29,7 +29,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <KFileDialog>
#include <KColorScheme>
#include <KImageIO>
-#include <KIO/NetAccess>
+#include <KIO/StatJob>
+#include <KJobWidgets>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardDirs>
@@ -255,7 +256,9 @@ void GvCore::saveAs(const QUrl &url)
}
// Check for overwrite
- if (KIO::NetAccess::exists(saveAsUrl, KIO::NetAccess::DestinationSide, d->mMainWindow)) {
+ KIO::StatJob *statJob = KIO::stat(saveAsUrl, KIO::StatJob::DestinationSide, 0);
+ KJobWidgets::setWindow(statJob, d->mMainWindow);
+ if (statJob->exec()) {
int answer = KMessageBox::warningContinueCancel(
d->mMainWindow,
xi18nc("@info",
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 01125b0..96fa1e1 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -37,7 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
// KDE
-#include <KIO/NetAccess>
#include <KActionCategory>
#include <KActionCollection>
#include <KFileDialog>
diff --git a/lib/mimetypeutils.cpp b/lib/mimetypeutils.cpp
index 580f942..c3a58db 100644
--- a/lib/mimetypeutils.cpp
+++ b/lib/mimetypeutils.cpp
@@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KFileItem>
#include <KIO/Job>
#include <KIO/JobClasses>
-#include <KIO/NetAccess>
// Local
#include <archiveutils.h>
diff --git a/tests/auto/testutils.cpp b/tests/auto/testutils.cpp
index 8adb126..bfbfdb2 100644
--- a/tests/auto/testutils.cpp
+++ b/tests/auto/testutils.cpp
@@ -25,14 +25,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// KDE
#include <KDebug>
-#include <KIO/NetAccess>
+#include <KIO/StatJob>
+#include <KIO/DeleteJob>
+#include <KIO/MkdirJob>
+#include <KIO/FileCopyJob>
+#include <KJobWidgets>
#include <KStandardDirs>
#include <QStandardPaths>
QUrl setUpRemoteTestDir(const QString& testFile)
{
QWidget* authWindow = 0;
- bool ok;
if (qgetenv("GV_REMOTE_TESTS_BASE_URL").isEmpty()) {
kWarning() << "Environment variable GV_REMOTE_TESTS_BASE_URL not set: remote tests disabled";
return QUrl();
@@ -42,12 +45,19 @@ QUrl setUpRemoteTestDir(const QString& testFile)
baseUrl = baseUrl.adjusted(QUrl::StripTrailingSlash);
baseUrl.setPath(baseUrl.path() + "/gwenview-remote-tests");
- if (KIO::NetAccess::exists(baseUrl, KIO::NetAccess::DestinationSide, authWindow)) {
- KIO::NetAccess::del(baseUrl, authWindow);
+ KIO::StatJob *statJob = KIO::stat(baseUrl, KIO::StatJob::DestinationSide, 0);
+ KJobWidgets::setWindow(statJob, authWindow);
+
+ if (statJob->exec()) {
+ KIO::DeleteJob *deleteJob = KIO::del(baseUrl);
+ KJobWidgets::setWindow(deleteJob, authWindow);
+ deleteJob->exec();
}
- ok = KIO::NetAccess::mkdir(baseUrl, authWindow);
- if (!ok) {
- kFatal() << "Could not create dir" << baseUrl << ":" << KIO::NetAccess::lastErrorString();
+
+ KIO::MkdirJob *mkdirJob = KIO::mkdir(baseUrl);
+ KJobWidgets::setWindow(mkdirJob, authWindow);
+ if (!mkdirJob->exec()) {
+ kFatal() << "Could not create dir" << baseUrl << ":" << mkdirJob->errorString();
return QUrl();
}
@@ -55,9 +65,10 @@ QUrl setUpRemoteTestDir(const QString& testFile)
QUrl dstUrl = baseUrl;
dstUrl = dstUrl.adjusted(QUrl::StripTrailingSlash);
dstUrl.setPath(dstUrl.path() + '/' + testFile);
- ok = KIO::NetAccess::file_copy(urlForTestFile(testFile), dstUrl, authWindow);
- if (!ok) {
- kFatal() << "Could not copy" << testFile << "to" << dstUrl << ":" << KIO::NetAccess::lastErrorString();
+ KIO::FileCopyJob *copyJob = KIO::file_copy(urlForTestFile(testFile), dstUrl);
+ KJobWidgets::setWindow(copyJob, authWindow);
+ if (!copyJob->exec()) {
+ kFatal() << "Could not copy" << testFile << "to" << dstUrl << ":" << copyJob->errorString();
return QUrl();
}
}
@@ -90,8 +101,8 @@ void purgeUserConfiguration()
QString confDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
QVERIFY(confDir.endsWith(".qttest/share")); // Better safe than sorry
if (QFileInfo(confDir).isDir()) {
- bool ok = KIO::NetAccess::del(QUrl::fromLocalFile(confDir), 0);
- QVERIFY(ok);
+ KIO::DeleteJob *deleteJob = KIO::del(QUrl::fromLocalFile(confDir));
+ QVERIFY(deleteJob->exec());
}
QFile kdebugrc(KStandardDirs::locateLocal("config", "kdebugrc"));