[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim/KDE/4.11] pimsettingexporter: Fix export kjots
From:       Montel Laurent <montel () kde ! org>
Date:       2013-11-01 6:50:53
Message-ID: E1Vc8ZJ-0005lF-OB () scm ! kde ! org
[Download RAW message or body]

Git commit 4b4bf06abd9ec8bdf69a2a2d1f6064f02b54d63c by Montel Laurent.
Committed on 01/11/2013 at 06:50.
Pushed by mlaurent into branch 'KDE/4.11'.

Fix export kjots

M  +37   -0    pimsettingexporter/abstractimportexportjob.cpp
M  +1    -0    pimsettingexporter/abstractimportexportjob.h
M  +1    -1    pimsettingexporter/jot/exportjotjob.cpp

http://commits.kde.org/kdepim/4b4bf06abd9ec8bdf69a2a2d1f6064f02b54d63c

diff --git a/pimsettingexporter/abstractimportexportjob.cpp b/pimsettingexporter/abstractimportexportjob.cpp
index 0aafad7..d51db00 100644
--- a/pimsettingexporter/abstractimportexportjob.cpp
+++ b/pimsettingexporter/abstractimportexportjob.cpp
@@ -230,6 +230,43 @@ void AbstractImportExportJob::copyToFile(const KArchiveFile *archivefile, const
     }
 }
 
+void AbstractImportExportJob::backupResourceDirectory(const Akonadi::AgentInstance &agent, const QString &defaultPath)
+{
+    const QString identifier = agent.identifier();
+    const QString archivePath = defaultPath + identifier + QDir::separator();
+
+    KUrl url = Utils::resourcePath(agent);
+    if (!url.isEmpty()) {
+        QString filename = url.fileName();
+        if (QDir(url.path()).exists()) {
+            const bool fileAdded  = archive()->addLocalDirectory(url.path(), archivePath + filename);
+            if (fileAdded) {
+                const QString errorStr = Utils::storeResources(archive(), identifier, archivePath);
+                if (!errorStr.isEmpty())
+                    Q_EMIT error(errorStr);
+                Q_EMIT info(i18n("\"%1\" was backuped.",filename));
+
+                url = Utils::akonadiAgentConfigPath(identifier);
+                if (!url.isEmpty()) {
+                    filename = url.fileName();
+
+                    if (QDir(url.path()).exists()) {
+                        const bool fileAdded  = archive()->addLocalFile(url.path(), archivePath + filename);
+                        if (fileAdded)
+                            Q_EMIT info(i18n("\"%1\" was backuped.",filename));
+                        else
+                            Q_EMIT error(i18n("\"%1\" file cannot be added to backup file.",filename));
+                    }
+                }
+
+            } else {
+                Q_EMIT error(i18n("\"%1\" file cannot be added to backup file.",filename));
+            }
+        } else {
+            Q_EMIT error(QString::fromLatin1("Resource was not configured correctly, not archive it."));
+        }
+    }
+}
 
 void AbstractImportExportJob::backupResourceFile(const Akonadi::AgentInstance &agent, const QString &defaultPath)
 {
diff --git a/pimsettingexporter/abstractimportexportjob.h b/pimsettingexporter/abstractimportexportjob.h
index 087e42b..648ab6c 100644
--- a/pimsettingexporter/abstractimportexportjob.h
+++ b/pimsettingexporter/abstractimportexportjob.h
@@ -63,6 +63,7 @@ protected:
     void copyToFile(const KArchiveFile * archivefile, const QString &dest, const QString &filename, const QString &prefix);
     void initializeImportJob();
     void backupFile(const QString &filename, const QString &path, const QString &storedName);
+    void backupResourceDirectory(const Akonadi::AgentInstance &agent, const QString &defaultPath);
     void backupConfigFile(const QString &configFileName);
     int mergeConfigMessageBox(const QString &configName) const;
     bool overwriteConfigMessageBox(const QString &configName) const;
diff --git a/pimsettingexporter/jot/exportjotjob.cpp b/pimsettingexporter/jot/exportjotjob.cpp
index e145488..51a1af1 100644
--- a/pimsettingexporter/jot/exportjotjob.cpp
+++ b/pimsettingexporter/jot/exportjotjob.cpp
@@ -70,7 +70,7 @@ void ExportJotJob::backupResources()
     foreach( const Akonadi::AgentInstance &agent, list ) {
         const QString identifier = agent.identifier();
         if (identifier.contains(QLatin1String("akonadi_akonotes_resource_"))) {
-            backupResourceFile(agent, Utils::jotPath());
+            backupResourceDirectory(agent, Utils::jotPath());
         }
     }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic