Commit Graph

323 Commits

Author SHA1 Message Date
Ingo Klöcker
1c2459a592
qt: Support reading signed/encrypted archives directly from a file
* lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h (DecryptVerifyArchiveJob): Add
member functions setInputFile, inputFile.
* lang/qt/src/decryptverifyarchivejob_p.h
(DecryptVerifyArchiveJobPrivate): Add member m_inputFilePath.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp (decrypt_verify): Move
creation of indata to decrypt_verify_from_io_device.
(decrypt_verify_from_io_device, decrypt_verify_from_file_name): New.
(QGpgMEDecryptVerifyArchiveJob::start): Use
decrypt_verify_from_io_device instead of decrypt_verify.
(QGpgMEDecryptVerifyArchiveJobPrivate::startIt): Start the job with the
values from member variables.

* lang/qt/tests/run-decryptverifyarchivejob.cpp (createInput): Remove.
(main): Remove creation of input. Make the job read the archive directly
from the given archive name.
--

This makes it possible to tell gpgtar to read the signed/encrypted
archive directly from a specified file bypassing GpgME's Data IO.

GnuPG-bug-id: 6530
2023-06-21 15:25:11 +02:00
Ingo Klöcker
e608315392
qt: Support writing signed/encrypted archives directly to a file
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h
(EncryptArchiveJob): Add member functions setRecipients, recipients,
setInputPaths, inputPaths, setOutputFile, outputFile,
setEncryptionFlags, encryptionFlags.
* lang/qt/src/encryptarchivejob_p.h (EncryptArchiveJobPrivate): Add
members m_recipients, m_inputPaths, m_outputFilePath, m_encryptionFlags.
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Move creation of
outdata to encrypt_to_io_device.
(encrypt_to_io_device, encrypt_to_filename): New.
(QGpgMEEncryptArchiveJob::start): Use encrypt_to_io_device instead of
encrypt.
(QGpgMEEncryptArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign): Move creation of
outdata to sign_to_io_device.
(sign_to_io_device, sign_to_filename): New.
(QGpgMESignArchiveJob::start): Use sign_to_io_device instead of sign.
(QGpgMESignArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Move
creation of outdata to sign_encrypt_to_io_device.
(sign_encrypt_to_io_device, sign_encrypt_to_filename): New.
(QGpgMESignEncryptArchiveJob::start): Use sign_encrypt_to_io_device
instead of sign_encrypt.
(QGpgMESignEncryptArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h
(SignArchiveJob): Add member functions setSigner, signers,
setInputPaths, inputPaths, setOutputFile, outputFile.
* lang/qt/src/signarchivejob_p.h (SignArchiveJobPrivate): Add
members m_signers, m_inputPaths, m_outputFilePath.
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h (SignEncryptArchiveJob): Add
member functions setSigner, signers, setRecipients, recipients,
setInputPaths, inputPaths, setOutputFile, outputFile,
setEncryptionFlags, encryptionFlags.
* lang/qt/src/signencryptarchivejob_p.h (SignEncryptArchiveJobPrivate):
Add members m_signers, m_recipients, m_inputPaths, m_outputFilePath,
m_encryptionFlags.

* lang/qt/tests/run-encryptarchivejob.cpp (createOutput): Remove.
(checkOutputFilePath): New.
(main): Create file output writing to stdout if no archive name (or "-")
is given. Exit if file with given archive name already exists. Make
the jobs write the created archive directly to the given archive name.
* lang/qt/tests/run-signarchivejob.cpp (createOutput): Remove.
(checkOutputFilePath): New.
(main): Create file output writing to stdout if no archive name (or "-")
is given. Exit if file with given archive name already exists. Make
the jobs write the created archive directly to the given archive name.
--

This makes it possible to tell gpgtar to write the created archive
directly to a specified file bypassing GpgME's Data IO.

GnuPG-bug-id: 6530
2023-06-19 18:21:46 +02:00
Ingo Klöcker
8b9fabf5d5
qt: Add a generic hook to start a job
* lang/qt/src/job.cpp, lang/qt/src/job.h (Job::startIt): New method.
* lang/qt/src/job_p.h (JobPrivate::startIt): New pure virtual method.
* lang/qt/src/qgpgmechangeexpiryjob.cpp
(QGpgMEChangeExpiryJobPrivate::startIt): New.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJobPrivate::startIt):
New.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJobPrivate::startIt):
New.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignencryptjob.cpp
(QGpgMESignEncryptJobPrivate::startIt): New.
--

startIt() starts a job if the necessary values have been set before.
This makes it possible to extend jobs with additional ways to start them
without having to worry about overloading existing virtual start()
methods. This will be used first for the different archive jobs.

GnuPG-bug-id: 6530
2023-06-19 18:08:47 +02:00
Ingo Klöcker
23526c3ff2
qt: Make the run methods of ThreadedJobMixin public
* lang/qt/src/threadedjobmixin.h (ThreadedJobMixin::run): Make all
overloads public.
--

This allows calling the run() functions from the JobPrivate subclasses.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Ingo Klöcker
4655b2dc6b
qt: Rename JobPrivate::start to JobPrivate::startNow
* lang/qt/src/job_p.h (JobPrivate::start): Rename to startNow.
* lang/qt/src/job.cpp (Job::startNow): Adapt function call.
* lang/qt/src/qgpgmechangeexpiryjob.cpp
(QGpgMEChangeExpiryJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJobPrivate::start):
Rename to startNow.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJobPrivate::start):
Rename to startNow.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignencryptjob.cpp
(QGpgMESignEncryptJobPrivate::start): Rename to startNow.
--

Using the same name for the public and the private method avoids
confusion.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Ingo Klöcker
6f6b35df50
qt: Return const pointer to JobPrivate class for const pointer to Job
* lang/qt/src/job.cpp, lang/qt/src/job_p.h (getJobPrivate): Replace with
two overloads for non-const pointer and const pointer to Job.
* lang/qt/src/job_p.h (jobPrivate): Replace with two template functions
for non-const pointer and const pointer to Job.
--

This helps avoid changing values stored in the JobPrivate class in
const functions (e.g. getters) of Job classes.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Andre Heinecke
5811d069d3
qt, cpp: Support larger size-hint on 32 bit builds
* NEWS: Mention this.
* lang/cpp/src/data.h, lang/cpp/src/data.cpp (Data::setSizeHint): New.
* lang/qt/src/qgpgmedecryptjob.cpp,
 lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
 lang/qt/src/qgpgmedecryptverifyjob.cpp,
 lang/qt/src/qgpgmeencryptjob.cpp,
 lang/qt/src/qgpgmesignencryptjob.cpp,
 lang/qt/src/qgpgmesignjob.cpp,
 lang/qt/src/qgpgmeverifydetachedjob.cpp,
 lang/qt/src/qgpgmeverifyopaquejob.cpp: Set size for input IODevice.

--
This fixes the case where the old detection of the size of QIOdevice
using seek would overflow and instead explicitly uses QIODevice::size
to check for the size and pass it through as an uint64.

GnuPG-Bug-Id: T6534
2023-06-16 14:33:19 +02:00
Ingo Klöcker
73e46b3465
qt: Add signals for file-based and data-based progress
* lang/qt/src/decryptverifyarchivejob.h (DecryptVerifyArchiveJob): Add
signals fileProgress and dataProgress.
* lang/qt/src/encryptarchivejob.h (EncryptArchiveJob): Ditto.
* lang/qt/src/signarchivejob.h (SignArchiveJob): Ditto.
* lang/qt/src/signencryptarchivejob.h (SignEncryptArchiveJob): Ditto.
* lang/qt/src/job_p.h (emitArchiveProgressSignals): New.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJob::QGpgMEDecryptVerifyArchiveJob): Emit
appropriate signal when receiving Job::rawProgress signal.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJob::QGpgMEEncryptArchiveJob): Ditto.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJob::QGpgMESignArchiveJob): Ditto.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJob::QGpgMESignEncryptArchiveJob): Ditto.
--

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Ingo Klöcker
ccff6a96fc
qt: Remove commented out code
--

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Ingo Klöcker
ea6f15ed60
qt: Add simple and extended progress signals replacing old signal
* lang/qt/src/job.h (Job): Add signals jobProgress and rawProgress.
Deprecate signal progress.
* lang/qt/src/multideletejob.cpp (MultiDeleteJob::slotResult): Emit
new progress signals.
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp
(QGpgMERefreshSMIMEKeysJob::slotStatus): Ditto.
* lang/qt/src/threadedjobmixin.h (ThreadedJobMixin::showProgress): Use
modern overload of QMetaObject::invokeMethod to forward the progress
signal and add the value of what. Add forwarding of progress to the new
signals.

* lang/qt/tests/t-encrypt.cpp (EncryptionTest::testProgress): Test
the new signals instead of the deprecated one.
--

The new signal jobProgress omits the what value which is useless for
most consumers. The new signal rawProgress makes all information
provided by the backend available to consumers. The latter is not
really meant to be used by users of gpgme. It will be used by the
archive jobs to provide more user-friendly signals.

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Ingo Klöcker
7098c14b23
tests: Stop daemons after setting up test environment
* lang/python/tests/Makefile.am, lang/qt/tests/Makefile.am,
tests/gpg/Makefile.am, tests/json/Makefile.am (pubring-stamp): Call
`gpgconf --kill all` after importing test keys.
--

This ensures that no gpg-agents or other daemons are running after
"make".
2023-02-09 09:33:07 +01:00
Ingo Klöcker
52fd0bcde4
qt,tests: Add test for the previous commit
* lang/qt/tests/t-decryptverify.cpp: New.
* lang/qt/tests/Makefile.am: Add new test.
--

GnuPG-bug-id: 6342
2023-02-02 12:11:30 +01:00
Ingo Klöcker
c407728064
qt: Add job for extracting encrypted and signed archives
* lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h,
lang/qt/src/decryptverifyarchivejob_p.h,
lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
lang/qt/src/qgpgmedecryptverifyarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function decryptVerifyArchiveJob
* lang/qt/src/protocol_p.h (Protocol::decryptVerifyArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-decryptverifyarchivejob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

GnuPG-bug-id: 6342
2023-02-02 12:11:29 +01:00
Ingo Klöcker
55c948866f
qt: Allow checking if the sign/encrypt archive jobs are supported
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h
(isSupported): New.
* lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h
(isSupported): New.
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h (isSupported): New.

* lang/qt/tests/run-encryptarchivejob.cpp (main),
lang/qt/tests/run-signarchivejob.cpp (main): Check if jobs are
supported.
--

GnuPG-bug-id: 6342
2023-02-02 09:47:11 +01:00
Ingo Klöcker
343fb33bf0
qt: Fix build without installed gpgme++ headers
* lang/qt/src/filelistdataprovider.cpp: Include error.h without
folder prefix.
--

GnuPG-bug-id: 6342
2023-01-31 21:13:07 +01:00
Ingo Klöcker
d3a8c2c8b6
qt: Remove unused and commented-out code
* lang/qt/src/qgpgmeencryptarchivejob.cpp,
lang/qt/src/qgpgmeencryptarchivejob.h (QGpgMEEncryptArchiveJob):
Remove member function resultHook and member mResult.
* lang/qt/src/qgpgmesignarchivejob.cpp,
lang/qt/src/qgpgmesignarchivejob.h (QGpgMESignArchiveJob):
Remove member function resultHook and member mResult.
--

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
8c4436e73a
qt: Add job for creating encrypted signed archives
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h,
lang/qt/src/signencryptarchivejob_p.h,
lang/qt/src/qgpgmesignencryptarchivejob.cpp,
lang/qt/src/qgpgmesignencryptarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function signEncryptArchiveJob
* lang/qt/src/protocol_p.h (Protocol::signEncryptArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-encryptarchivejob.cpp (displayName): Remove.
(CommandLineOptions): Initialize member armor. Add member sign.
(parseCommandLine): Update application description. Add and parse option
-s/--sign.
(main): Use SignEncryptArchiveJob if sign option is set.
--

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
2b98585c89
qt,tests: Avoid leaking Context
* lang/qt/tests/t-import.cpp: Wrap Context*s in unique_ptr.
--

This fixes leaks found with -fsanitize=address.
2023-01-31 12:01:33 +01:00
Ingo Klöcker
8d672b3b7e
qt: Add job for creating signed archives
* lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h,
lang/qt/src/signarchivejob_p.h,
lang/qt/src/qgpgmesignarchivejob.cpp,
lang/qt/src/qgpgmesignarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function signArchiveJob
* lang/qt/src/protocol_p.h (Protocol::signArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-signarchivejob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

GnuPG-bug-id: 6342
2023-01-30 12:56:54 +01:00
Ingo Klöcker
7afd135cce
qt: Add job for creating encrypted archives
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h,
lang/qt/src/encryptarchivejob_p.h,
lang/qt/src/qgpgmeencryptarchivejob.cpp,
lang/qt/src/qgpgmeencryptarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function encryptArchiveJob
* lang/qt/src/protocol_p.h (Protocol::encryptArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-encryptarchivejob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

GnuPG-bug-id: 6342
2023-01-27 12:20:53 +01:00
Ingo Klöcker
275a3a2c16
qt: Add data provider for list of file names
* lang/qt/src/Makefile.am: Add new files and corresponding camel-case
header.
* lang/qt/src/dataprovider.h: Include interface from gpgme++ when
not building.
* lang/qt/src/filelistdataprovider.cpp,
lang/qt/src/filelistdataprovider.h: New.
--

The new data provider simplifies providing a nul-separated list of
UTF-8-encoded filenames, e.g. for creating signed or encrypted
archives. It is a simple read-only proxy for QByteArrayDataProvider.

GnuPG-bug-id: 6342
2023-01-27 12:17:09 +01:00
Ingo Klöcker
64da77620a
qt: Fix comparisons of integer expressions of different signedness
* lang/qt/tests/t-import.cpp (ImportTest::testImportWithImportFilter):
Make integer literal unsigned.
--
2023-01-05 20:33:45 +01:00
Ingo Klöcker
e16c368758
qt: Replace Q_DECL_OVERRIDE with override
* lang/qt/src/defaultkeygenerationjob.h,
lang/qt/src/hierarchicalkeylistjob.h, lang/qt/src/multideletejob.h,
lang/qt/src/protocol_p.h, lang/qt/src/qgpgmeadduseridjob.h,
lang/qt/src/qgpgmechangeexpiryjob.h,
lang/qt/src/qgpgmechangeownertrustjob.h,
lang/qt/src/qgpgmechangepasswdjob.h, lang/qt/src/qgpgmedecryptjob.h,
lang/qt/src/qgpgmedecryptverifyjob.h, lang/qt/src/qgpgmedeletejob.h,
lang/qt/src/qgpgmedownloadjob.h, lang/qt/src/qgpgmeencryptjob.h,
lang/qt/src/qgpgmeexportjob.h, lang/qt/src/qgpgmegpgcardjob.h,
lang/qt/src/qgpgmeimportfromkeyserverjob.h,
lang/qt/src/qgpgmeimportjob.h, lang/qt/src/qgpgmekeyformailboxjob.h,
lang/qt/src/qgpgmekeygenerationjob.h, lang/qt/src/qgpgmekeylistjob.h,
lang/qt/src/qgpgmelistallkeysjob.h, lang/qt/src/qgpgmenewcryptoconfig.h,
lang/qt/src/qgpgmequickjob.h, lang/qt/src/qgpgmerefreshsmimekeysjob.h,
lang/qt/src/qgpgmesignencryptjob.h, lang/qt/src/qgpgmesignjob.h,
lang/qt/src/qgpgmesignkeyjob.h, lang/qt/src/qgpgmetofupolicyjob.h,
lang/qt/src/qgpgmeverifydetachedjob.h,
lang/qt/src/qgpgmeverifyopaquejob.h, lang/qt/src/qgpgmewkdlookupjob.h,
lang/qt/src/qgpgmewkspublishjob.h, lang/qt/src/threadedjobmixin.h,
lang/qt/tests/t-support.h: Replace Q_DECL_OVERRIDE with override
--

We require C++11 since a long time.
2023-01-05 18:03:33 +01:00
Ingo Klöcker
398375a0ab
qt: Allow deferred start of import job
* lang/qt/src/importjob.h (ImportJob::startLater): New pure virtual
method.
* lang/qt/src/qgpgmeimportjob.cpp, lang/qt/src/qgpgmeimportjob.h
(QGpgMEImportJob::startLater): New method.

* lang/qt/tests/t-import.cpp (ImportTest::testDeferredStart): New.
--

This makes it possible to prepare an import job for a deferred start.

GnuPG-bug-id: 6323
2023-01-05 14:24:31 +01:00
Ingo Klöcker
18c2c0b250
qt: Support deferred start of jobs
* lang/qt/src/job.cpp, lang/qt/src/job.h (Job::startNow): New method.
* lang/qt/src/job_p.h (JobPrivate::start): New pure virtual method.
* lang/qt/src/qgpgmechangeexpiryjob.cpp
(QGpgMEChangeExpiryJobPrivate::start): New.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJobPrivate::start):
New.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJobPrivate::start): New.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJobPrivate::start): New.
* lang/qt/src/qgpgmesignencryptjob.cpp
(QGpgMESignEncryptJobPrivate::start): New.
* lang/qt/src/threadedjobmixin.h (Thread::hasFunction): New method.
(ThreadedJobMixin::run, ThreadedJobMixin::setWorkerFunction): New
methods.
--

startNow() starts a deferred job for which the worker function has been
set before.

GnuPG-bug-id: 6323
2023-01-04 12:16:04 +01:00
Ingo Klöcker
270d752300
qt: Explicitly instantiate private job classes
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/changeexpiryjob_p.h, lang/qt/src/encryptjob_p.h,
lang/qt/src/importjob_p.h, lang/qt/src/listallkeysjob_p.h,
lang/qt/src/signencryptjob_p.h: New.
* lang/qt/src/changeexpiryjob.cpp, lang/qt/src/encryptjob.cpp,
lang/qt/src/importjob.cpp, lang/qt/src/listallkeysjob.cpp,
lang/qt/src/signencryptjob.cpp: Move JobPrivate subclasses to the new
private header files.
* lang/qt/src/job_p.h (jobPrivate): Remove lazy instantiation of private
job classes.
* lang/qt/src/qgpgmechangeexpiryjob.cpp (class
QGpgMEChangeExpiryJobPrivate): New.
(QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob): Instantiate private job
class.
* lang/qt/src/qgpgmeencryptjob.cpp (class
QGpgMEEncryptJobPrivate): New.
(QGpgMEEncryptJob::QGpgMEEncryptJob): Instantiate private job
class.
* lang/qt/src/qgpgmeimportjob.cpp (class
QGpgMEImportJobPrivate): New.
(QGpgMEImportJob::QGpgMEImportJob): Instantiate private job
class.
* lang/qt/src/qgpgmelistallkeysjob.cpp (class
QGpgMEListAllKeysJobPrivate): New.
(QGpgMEListAllKeysJob::QGpgMEListAllKeysJob): Instantiate private job
class.
* lang/qt/src/qgpgmesignencryptjob.cpp (class
QGpgMESignEncryptJobPrivate): New.
(QGpgMESignEncryptJob::QGpgMESignEncryptJob): Instantiate private job
class.
--

We need private job classes corresponding to the concrete leaf classes.
This makes the lazy instantiation of the private classes by the job
interface classes impossible.

GnuPG-bug-id: 6323
2023-01-04 11:37:11 +01:00
Ingo Klöcker
d04d7b174f
qt: Write path values with Unix directory separators
* lang/qt/src/qgpgmenewcryptoconfig.cpp
(QGpgMENewCryptoConfigEntry::setURLValue): Remove conversion to native
directory separators.
--

Even on Windows Unix directory separators work with all API calls. And
some path values also allow "URLs" like tcp://1.2.3.4:10001 which must
use '/'.

GnuPG-bug-id: 4518
2022-12-06 08:12:00 +01:00
Ingo Klöcker
b6593bda1f
qt: Allow disabling automatic trust database check on key listing
* lang/qt/src/Makefile.am (qgpgme_sources): Add listallkeysjob.cpp.
* lang/qt/src/listallkeysjob.cpp: New.
* lang/qt/src/listallkeysjob.h (enum ListAllKeysJob::Option,
typedef ListAllKeysJob::Options, ListAllKeysJob::setOptions,
ListAllKeysJob::options): New.
* lang/qt/src/qgpgmelistallkeysjob.cpp (list_keys): Set context flag
"no-auto-check-trustdb" if requested.
(QGpgMEListAllKeysJob::start, QGpgMEListAllKeysJob::exec): Add options
to call of list_keys.
--

GnuPG-bug-id: 6261
2022-11-04 10:44:07 +01:00
Ingo Klöcker
e6a1b241b4
build,qt: Clean up all generated files
* lang/qt/src/Makefile.am (CLEANFILES): Add QGpgmeConfig-w32.cmake.in
and QGpgmeQt6Config-w32.cmake.in.
--
2022-10-11 11:00:15 +02:00
Ingo Klöcker
b2fb26baea
qt,tests: Port test to QRegularExpression.
* lang/qt/tests/t-trustsignatures.cpp: Use QRegularExpression instead of
QRegExp.
--

This allows building with Qt 6 without Core5Compat.
2022-10-11 11:00:15 +02:00
Ingo Klöcker
4938c24a46
qt: Remove obsolete code.
* lang/qt/src/qgpgmenewcryptoconfig.cpp (struct Select1St): Remove.
--

This struct was never used in this implementation of the crypto config
classes and it causes a build error with Qt 6 where QPair is an alias
for std::pair.
2022-10-11 11:00:15 +02:00
Ingo Klöcker
8d019bbb8d
build,qt: Allow building QGpgME for Qt 6
* configure.ac: Look for Qt 5 and/or Qt 6. Require C++17 if Qt 6 binding
is built. Build cmake files QGpgmeConfig* for Qt 5 and QGpgmeQt6Config*
for Qt 6.
(available_languages): Add "qt5" and "qt6".
(WANT_QT5, WANT_QT6): New conditionals.
* lang/qt/src/Makefile.am: Keep building libqgpgme for Qt 5. Build
libqgpgmeqt6 for Qt 6.
* lang/qt/tests/Makefile.am: Build tests for Qt 5 or Qt 6.
* lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in,
lang/qt/src/QGpgmeQt6Config.cmake.in.in,
lang/qt/src/QGpgmeQt6ConfigVersion.cmake.in, m4/qt6.m4: New.
--

This makes it possible to build QGpgME optionally for Qt 6.4.0 or later.
By default or if the language "qt" is enabled, then QGpgME is built
either for Qt 5 (if found) or Qt 6. A build for Qt 5 or Qt 6 can be
requested by explicitly enabling the language "qt5" or "qt6". Building
QGpgME for Qt 5 and Qt 6 simultaneously is not supported.
2022-10-11 11:00:14 +02:00
Ingo Klöcker
8e908029ff
build,qt: Explicitly namespace a few Qt variables for Qt5
m4/qt.m4: Rename to
m4/qt5.m4: this.
(FIND_QT): Rename to FIND_QT5.
(GPGME_QT): Change variable prefix to GPGME_QT5.
(GPGME_QTTEST: Change variable prefix to GPGME_QT5TEST.
configure.ac, lang/qt/src/Makefile.am, lang/qt/tests/Makefile.am:
Adjust accordingly.
--

In preparation to adding support for building qgpgme for Qt6, add the
version number to a few variables to avoid confusion.
2022-10-10 14:46:39 +02:00
Ingo Klöcker
83176ad7d3 qt: Fix building with C++11
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp
(QGpgMERefreshSMIMEKeysJob::start): Replace 'auto' in lambda with the
actual type.
* lang/qt/src/qgpgmesignkeyjob.cpp (class TrustSignatureProperties): Add
default c'tor and c'tor initializing all members.
* lang/qt/src/util.cpp (toFingerprints): Replace 'auto' in lambda with
the actual type.
* lang/qt/tests/run-exportjob.cpp (createExportJob): Replace 'auto'
return type with actual type.
--

This fixes compilation with strict C++11.

GnuPG-bug-id: 6141
2022-08-22 14:39:22 +02:00
Ingo Klöcker
0566180684 qt: Fix building with Qt6
* lang/qt/src/util.cpp, lang/qt/src/util.h: Replace forward declaration
with include.
--

Based on patch by Laurent Montel
2022-08-22 09:30:14 +02:00
Ingo Klöcker
2e7a61b898 qt,tests: Make test pass on 32-bit systems
* lang/qt/tests/t-addexistingsubkey.cpp
(AddExistingSubkeyJobTest::testAddExistingSubkeyWithExpiration): Handle
negative expiration date.
--

On 32-bit systems the expiration date of the test key overflows. This
will cause the AddExistingSubkeyJob to fail. We expect it to fail with
an "invalid time" error.

GnuPG-bug-id: 6137
2022-08-18 10:55:09 +02:00
Ingo Klöcker
f2b48de26b qt,tests: Make sure expiration time is interpreted as unsigned number
* lang/qt/tests/t-addexistingsubkey.cpp,
lang/qt/tests/t-changeexpiryjob.cpp: Convert expiration time to
uint_least32_t.
--

This doesn't change the outcome of the tests (they also pass without
this change because of the expiration dates of the test keys), but it's
still good practise to treat the expiration time as an unsigned number
if the assertions check that the expiration time is in some range.

GnuPG-bug-id: 6137
2022-08-17 15:22:29 +02:00
Ingo Klöcker
81d4b7f2d7 qt,tests: Log the actual error code if the assertion fails
* lang/qt/tests/t-addexistingsubkey.cpp (
AddExistingSubkeyJobTest::testAddExistingSubkeyAsync,
AddExistingSubkeyJobTest::testAddExistingSubkeySync,
AddExistingSubkeyJobTest::testAddExistingSubkeyWithExpiration): Use
QCOMPARE instead of QVERIFY for asserting equality.
--

GnuPG-bug-id: 6137
2022-08-17 14:56:13 +02:00
Ingo Klöcker
c977424a1d qt: Make sure expiration time is interpreted as unsigned number
* lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp (add_subkey): Convert
expiration time to uint_least32_t.
--

This fixes the corresponding test on 32-bit systems where time_t (the
return type of expirationTime()) is a signed 32-bit integer type.

GnuPG-bug-id: 6137
2022-08-17 14:52:04 +02:00
Andre Heinecke
586846209b
Qt: Fix working with no gpgconf in CryptoConfig
* lang/qt/src/cryptoconfig.cpp (CryptoConfig::entry): Add nullptr
  checks.

--
This fixes a crash when gpgconf is not found. When every return
value is NULL.

GnuPG-Bug-Id: T6131
2022-08-11 11:39:10 +02:00
Ingo Klöcker
5d91182c95 qt: Add missing include
* lang/qt/tests/t-revokekey.cpp: Include QDebug.
--

Doesn't seem to matter with Qt 5.15.5, but seems to be needed for older
versions of Qt.
2022-08-10 12:00:10 +02:00
Ingo Klöcker
db7d79063f qt: Add job to set the primary user ID of OpenPGP keys
* lang/qt/src/qgpgmesetprimaryuseridjob.cpp,
lang/qt/src/qgpgmesetprimaryuseridjob.h,
lang/qt/src/setprimaryuseridjob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function setPrimaryUserIDJob.
* lang/qt/src/protocol_p.h (Protocol::setPrimaryUserIDJob): New.
* lang/qt/src/job.cpp, lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/t-setprimaryuserid.cpp: New.
* lang/qt/tests/Makefile.am: Add new test.
--

GnuPG-bug-id: 5938
2022-08-09 14:52:42 +02:00
Ingo Klöcker
c3b183831d qt: Remove job for refreshing OpenPGP keys
* lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp,
lang/qt/src/qgpgmerefreshopenpgpkeysjob.h,
lang/qt/src/refreshopenpgpkeysjob.h: Remove.
* lang/qt/src/Makefile.am, lang/qt/src/job.cpp: Update accordingly.
* lang/qt/src/protocol.h (class Protocol): Remove pure virtual member
function refreshOpenPGPKeysJob.
* lang/qt/src/protocol_p.h (Protocol::refreshOpenPGPKeysJob): Remove.

* lang/qt/tests/run-refreshkeysjob.cpp (main): Use ReceiveKeysJob for
OpenPGP keys.
--

The RefreshOpenPGPKeysJob did more than it was intended to do, e.g. it
imported new keys with the email addresses of the key to be refreshed
via the configured auto-key-locate methods, but only a refresh from the
key servers is wanted. For this we can use the ReceiveKeysJob.

This commit mostly reverts the commits
e12861f18c
c64a8daf50

The changes are source- and binary-compatible to the last release.

GnuPG-bug-id: 5951
2022-08-04 12:06:15 +02:00
Ingo Klöcker
5436b309fe qt: Allow setting the file name of signed and encrypted data
* lang/qt/src/Makefile.am (qgpgme_sources): Add signencryptjob.cpp.
* lang/qt/src/signencryptjob.cpp: New.
* lang/qt/src/signencryptjob.h (class SignEncryptJob): Add member
functions setFileName, fileName.
* lang/qt/src/qgpgmesignencryptjob.cpp (sign_encrypt): Set file name of
input.
(sign_encrypt_qba, QGpgMESignEncryptJob::exec,
QGpgMESignEncryptJob::start): Pass file name to sign_encrypt resp.
sign_encrypt_qba.
--

This makes it possible to store the original name of a signed and
encrypted file in the resulting data.

GnuPG-bug-id: 6056
2022-07-05 18:13:01 +02:00
Ingo Klöcker
bc10169724 qt: Allow setting the file name of encrypted data
* lang/qt/src/Makefile.am (qgpgme_sources): Add encryptjob.cpp.
* lang/qt/src/encryptjob.cpp: New.
* lang/qt/src/encryptjob.h (class EncryptJob): Add member functions
setFileName, fileName.
* lang/qt/src/qgpgmeencryptjob.cpp (encrypt): Set file name of input.
(encrypt_qba, QGpgMEEncryptJob::exec, QGpgMEEncryptJob::start): Pass
file name to encrypt resp. encrypt_qba.
--

This makes it possible to store the original name of an encrypted file
in the encryption result.

GnuPG-bug-id: 6056
2022-07-05 18:10:08 +02:00
Ingo Klöcker
31423945d2 qt: Fix filename of cmake config files for w32
* lang/qt/src/Makefile.am (EXTRA_DIST): Add
QGpgmeConfig-w32.cmake.in.in.
--
2022-07-04 17:10:31 +02:00
Laurent Montel
d42323f902 qt: Add #include <QStringList> needed for building against qt6
* lang/qt/src/downloadjob.h, lang/qt/src/exportjob.h,
lang/qt/src/keylistjob.h lang/qt/src/refreshkeysjob.h: in qt6 we need
to use #include <QStringList>
--

It fixes some compile qt6 compile error.

Signed-off-by: Laurent Montel <montel@kde.org>
2022-07-04 16:58:59 +02:00
Ingo Klöcker
fd813f5c39 qt,tests: Allow 1-day-offset for expiration date
* lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration):
Assert that the expiration date is either 2106-02-05 or 2106-02-04.

--

This avoids a test failure if the test is run at 00:xx:xx in a location
that uses DST.

GnuPG-bug-id: 5991
2022-06-10 12:03:39 +02:00
Ingo Klöcker
7870fdbfef qt: Prevent u32 overflow when calculating expiration date
* lang/qt/src/qgpgmesignkeyjob.cpp (sign_key): Change maxAllowedDate to
2106-02-05. Change log-level from warning to debug.
* lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration):
Remove check for warning. Adapt assertion.
--

Capping the expiration date at 2106-02-05 prevents a u32 overflow when
adding the number of days until the maximal date to the current time.

GnuPG-bug-id: 5991
2022-06-10 11:54:03 +02:00
Ingo Klöcker
918afc809d Revert "tests: Avoid problems with local time across a day boundary."
This reverts commit 5ba0e454a3.
2022-06-09 15:43:24 +02:00