summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Bauer <[email protected]>2017-11-16 17:13:57 +0100
committerWolfgang Bauer <[email protected]>2017-11-16 17:13:57 +0100
commitb1898d81f9d65622bb446e151e2cb42c60a2e420 (patch)
treef80c7f49d224cf032d8b51a4b86fee0852bca8a0
parent1d78410a557ae45fa55fedcf2b97103da988b334 (diff)
Migrate KDE4 config
Migrate config files from the KDE4 version to the new location. Also copy the data files (current downloads and transfer history).
-rw-r--r--main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index b2bb957..c90d111 100644
--- a/main.cpp
+++ b/main.cpp
@@ -9,6 +9,8 @@
version 2 of the License, or (at your option) any later version.
*/
+#include <Kdelibs4ConfigMigrator>
+#include <Kdelibs4Migration>
#include <kwindowsystem.h>
#include <klocale.h>
#include <kaboutdata.h>
@@ -151,6 +153,39 @@ int main(int argc, char *argv[])
KDBusService dbusService(KDBusService::Unique);
+ Kdelibs4ConfigMigrator migrate(QStringLiteral("kget"));
+ migrate.setConfigFiles(QStringList() << QStringLiteral("kgetrc")
+ << QStringLiteral("kget_bittorrentfactory.rc")
+ << QStringLiteral("kget_checksumsearchfactory.rc")
+ << QStringLiteral("kget_metalinkfactory.rc")
+ << QStringLiteral("kget_mirrorsearchfactory.rc")
+ << QStringLiteral("kget_mmsfactory.rc")
+ << QStringLiteral("kget_multisegkiofactory.rc")
+ << QStringLiteral("kget.notifyrc"));
+ if (migrate.migrate()) {
+ Kdelibs4Migration dataMigrator;
+ const QString sourceBasePath = dataMigrator.saveLocation("data", QStringLiteral("kget"));
+ const QString targetBasePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kget/");
+ QString targetFilePath;
+
+ QDir sourceDir(sourceBasePath);
+ QDir targetDir(targetBasePath);
+
+ if (sourceDir.exists()) {
+ if (!targetDir.exists()) {
+ QDir().mkpath(targetBasePath);
+ }
+ QStringList fileNames = sourceDir.entryList(
+ QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
+ foreach (const QString &fileName, fileNames) {
+ targetFilePath = targetBasePath + fileName;
+ if (!QFile::exists(targetFilePath)) {
+ QFile::copy(sourceBasePath + fileName, targetFilePath);
+ }
+ }
+ }
+ }
+
KGetApp kApp(&parser);
QObject::connect(&dbusService, &KDBusService::activateRequested, &kApp, &KGetApp::slotActivateRequested);