summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <kde@opensource.sf-tec.de>2012-03-19 17:28:43 (GMT)
committerRolf Eike Beer <kde@opensource.sf-tec.de>2012-03-19 17:28:43 (GMT)
commit68e727d9eb64e99bb4655dbcf90b789344f5f4ce (patch)
tree35bd858a37be61f4cef88e89b00f7b453ed77514
parent5bf78b98d39a789b596c755548bb6c0cc382e015 (diff)
allow encryption of multiple folders at once
Since we create an archive anyway there is no reason not to put multiple files or folders into it.
-rw-r--r--foldercompressjob.cpp9
-rw-r--r--foldercompressjob.h6
-rw-r--r--kgpg.cpp10
-rw-r--r--kgpgexternalactions.cpp2
4 files changed, 14 insertions, 13 deletions
diff --git a/foldercompressjob.cpp b/foldercompressjob.cpp
index 2a2b96c..b50d5ab 100644
--- a/foldercompressjob.cpp
+++ b/foldercompressjob.cpp
@@ -24,10 +24,10 @@
#include "transactions/kgpgencrypt.h"
-FolderCompressJob::FolderCompressJob(QObject *parent, const KUrl &source, const KUrl &dest, KTemporaryFile *tempfile, const QStringList &keys, const QStringList &options, const KGpgEncrypt::EncryptOptions encOptions, const int archive)
+FolderCompressJob::FolderCompressJob(QObject *parent, const KUrl::List &sources, const KUrl &dest, KTemporaryFile *tempfile, const QStringList &keys, const QStringList &options, const KGpgEncrypt::EncryptOptions encOptions, const int archive)
: KJob(parent),
m_description(i18n("Processing folder compression and encryption")),
- m_source(source),
+ m_sources(sources),
m_dest(dest),
m_tempfile(tempfile),
m_keys(keys),
@@ -81,13 +81,14 @@ FolderCompressJob::doWork()
return;
}
- arch->addLocalDirectory(m_source.path(), m_source.fileName());
+ foreach (const KUrl &url, m_sources)
+ arch->addLocalDirectory(url.path(), url.fileName());
arch->close();
delete arch;
setPercent(50);
- QDir outPath = m_source.path();
+ QDir outPath = m_sources.first().path();
outPath.cdUp();
m_options << QLatin1String("--output") << QDir::toNativeSeparators(outPath.path() + QDir::separator()) + m_dest.fileName();
diff --git a/foldercompressjob.h b/foldercompressjob.h
index 21c22d0..c4e7bec 100644
--- a/foldercompressjob.h
+++ b/foldercompressjob.h
@@ -34,7 +34,7 @@ class FolderCompressJob : public KJob {
FolderCompressJob(); // = delete C++0x
const QString m_description;
- const KUrl m_source;
+ const KUrl::List m_sources;
const KUrl m_dest;
KTemporaryFile * const m_tempfile;
const QStringList m_keys;
@@ -46,7 +46,7 @@ public:
/**
* @brief create a new KJob to compress and encrypt a folder
* @param parent object owning this job
- * @param source the source directories to include
+ * @param sources the source directories to include
* @param dest the name of the encrypted file
* @param tempfile the temporary file that should be used for archiving
* @param keys the public key ids to encrypt to
@@ -54,7 +54,7 @@ public:
* @param encOptions special options to pass to the GnuPG process
* @param archive the archive type to use
*/
- FolderCompressJob(QObject *parent, const KUrl &source, const KUrl &dest, KTemporaryFile *tempfile, const QStringList &keys, const QStringList &options, const KGpgEncrypt::EncryptOptions encOptions, const int archive);
+ FolderCompressJob(QObject *parent, const KUrl::List &sources, const KUrl &dest, KTemporaryFile *tempfile, const QStringList &keys, const QStringList &options, const KGpgEncrypt::EncryptOptions encOptions, const int archive);
/**
* @brief FolderCompressJob destructor
diff --git a/kgpg.cpp b/kgpg.cpp
index 3b51df1..7f8a78d 100644
--- a/kgpg.cpp
+++ b/kgpg.cpp
@@ -126,11 +126,6 @@ int KGpgApp::newInstance()
if (KMimeType::findByUrl(KUrl(*it))->name() == QLatin1String( "inode/directory" ))
directoryInside = true;
- if ((directoryInside) && (lst.count() > 1)) {
- KMessageBox::sorry(0, i18n("Unable to perform requested operation.\nPlease select only one folder, or several files, but do not mix files and folders."));
- return 0;
- }
-
w->droppedUrls = urlList;
if (args->isSet("e")) {
@@ -154,6 +149,11 @@ int KGpgApp::newInstance()
else
KMessageBox::sorry(0, i18n("Cannot verify folder."));
} else {
+ if (directoryInside && (lst.count() > 1)) {
+ KMessageBox::sorry(0, i18n("Unable to perform requested operation.\nPlease select only one folder, or several files, but do not mix files and folders."));
+ return 0;
+ }
+
if (w->droppedUrl.fileName().endsWith(QLatin1String(".sig"))) {
w->slotVerifyFile();
} else {
diff --git a/kgpgexternalactions.cpp b/kgpgexternalactions.cpp
index b086309..69b3653 100644
--- a/kgpgexternalactions.cpp
+++ b/kgpgexternalactions.cpp
@@ -183,7 +183,7 @@ void KGpgExternalActions::startFolderEncode()
delete over;
}
- FolderCompressJob *trayinfo = new FolderCompressJob(m_keysmanager, droppedUrls.first(), encryptedFile, kgpgfoldertmp, selec, encryptOptions, encOptions, compressionScheme);
+ FolderCompressJob *trayinfo = new FolderCompressJob(m_keysmanager, droppedUrls, encryptedFile, kgpgfoldertmp, selec, encryptOptions, encOptions, compressionScheme);
connect(trayinfo, SIGNAL(result(KJob*)), SLOT(slotFolderFinished(KJob*)));
KIO::getJobTracker()->registerJob(trayinfo);
trayinfo->start();