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
This commit is contained in:
parent
23526c3ff2
commit
8b9fabf5d5
1
NEWS
1
NEWS
@ -12,6 +12,7 @@ Noteworthy changes in version 1.21.0 (unreleased)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
cpp: Data::setFlag NEW.
|
||||
cpp: Data::setSizeHint NEW.
|
||||
qt: Job::startIt NEW.
|
||||
|
||||
Noteworthy changes in version 1.20.0 (2023-04-20)
|
||||
-------------------------------------------------
|
||||
|
@ -142,6 +142,13 @@ GpgME::Context *QGpgME::Job::context(QGpgME::Job *job)
|
||||
return QGpgME::g_context_map.value (job, nullptr);
|
||||
}
|
||||
|
||||
GpgME::Error QGpgME::Job::startIt()
|
||||
{
|
||||
auto d = getJobPrivate(this);
|
||||
Q_ASSERT(d && "This Job class has no JobPrivate class");
|
||||
return d->startIt();
|
||||
}
|
||||
|
||||
void QGpgME::Job::startNow()
|
||||
{
|
||||
auto d = getJobPrivate(this);
|
||||
|
@ -95,6 +95,12 @@ public:
|
||||
*/
|
||||
static GpgME::Context *context(Job *job);
|
||||
|
||||
/** Starts the job.
|
||||
*
|
||||
* Starts the job with the values set for the concrete job.
|
||||
*/
|
||||
GpgME::Error startIt();
|
||||
|
||||
/** Starts a deferred job.
|
||||
*
|
||||
* The job needs to have been prepared for a deferred start by calling the
|
||||
|
@ -49,6 +49,8 @@ class JobPrivate
|
||||
public:
|
||||
virtual ~JobPrivate() {}
|
||||
|
||||
virtual GpgME::Error startIt() = 0;
|
||||
|
||||
virtual void startNow() = 0;
|
||||
};
|
||||
|
||||
|
@ -66,6 +66,12 @@ public:
|
||||
~QGpgMEChangeExpiryJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -64,6 +64,12 @@ public:
|
||||
~QGpgMEDecryptVerifyArchiveJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
~QGpgMEEncryptArchiveJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -72,6 +72,12 @@ public:
|
||||
~QGpgMEEncryptJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -67,6 +67,12 @@ public:
|
||||
~QGpgMEImportJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -77,6 +77,12 @@ public:
|
||||
~QGpgMEListAllKeysJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
~QGpgMESignArchiveJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -72,6 +72,12 @@ public:
|
||||
~QGpgMESignEncryptArchiveJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
@ -73,6 +73,12 @@ public:
|
||||
~QGpgMESignEncryptJobPrivate() override = default;
|
||||
|
||||
private:
|
||||
GpgME::Error startIt() override
|
||||
{
|
||||
Q_ASSERT(!"Not supported by this Job class.");
|
||||
return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
void startNow() override
|
||||
{
|
||||
q->run();
|
||||
|
Loading…
Reference in New Issue
Block a user