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
This commit is contained in:
Ingo Klöcker 2023-01-03 12:15:19 +01:00
parent 2ba11f9bfb
commit 270d752300
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
17 changed files with 374 additions and 72 deletions

View File

@ -152,6 +152,10 @@ camelcase_headers= \
GpgCardJob
private_qgpgme_headers = \
changeexpiryjob_p.h \
encryptjob_p.h \
importjob_p.h \
listallkeysjob_p.h \
qgpgme_export.h \
protocol_p.h \
job_p.h \
@ -187,6 +191,7 @@ private_qgpgme_headers = \
qgpgmetofupolicyjob.h \
qgpgmegpgcardjob.h \
qgpgmequickjob.h \
signencryptjob_p.h \
threadedjobmixin.h \
util.h

View File

@ -36,27 +36,13 @@
#endif
#include "changeexpiryjob.h"
#include "job_p.h"
#include "changeexpiryjob_p.h"
#include <context.h>
using namespace GpgME;
using namespace QGpgME;
namespace
{
struct ChangeExpiryJobPrivate : public JobPrivate
{
ChangeExpiryJobPrivate()
{
}
~ChangeExpiryJobPrivate() override = default;
ChangeExpiryJob::Options m_options = ChangeExpiryJob::Default;
};
}
void ChangeExpiryJob::setOptions(ChangeExpiryJob::Options options)
{
auto d = jobPrivate<ChangeExpiryJobPrivate>(this);

View File

@ -0,0 +1,51 @@
/*
changeexpiryjob_p.h
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2021,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
QGpgME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __QGPGME_CHANGEEXPIRYJOB_P_H__
#define __QGPGME_CHANGEEXPIRYJOB_P_H__
#include "job_p.h"
#include "changeexpiryjob.h"
namespace QGpgME
{
struct ChangeExpiryJobPrivate : public JobPrivate
{
ChangeExpiryJob::Options m_options = ChangeExpiryJob::Default;
};
}
#endif // __QGPGME_CHANGEEXPIRYJOB_P_H__

View File

@ -36,18 +36,10 @@
#endif
#include "encryptjob.h"
#include "job_p.h"
#include "encryptjob_p.h"
using namespace QGpgME;
namespace
{
struct EncryptJobPrivate : public JobPrivate
{
QString m_fileName;
};
}
void EncryptJob::setFileName(const QString &fileName)
{
auto d = jobPrivate<EncryptJobPrivate>(this);

View File

@ -0,0 +1,49 @@
/*
encryptjob_p.h
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
QGpgME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __QGPGME_ENCRYPTJOB_P_H__
#define __QGPGME_ENCRYPTJOB_P_H__
#include "job_p.h"
namespace QGpgME
{
struct EncryptJobPrivate : public JobPrivate
{
QString m_fileName;
};
}
#endif // __QGPGME_ENCRYPTJOB_P_H__

View File

@ -36,29 +36,13 @@
#endif
#include "importjob.h"
#include "job_p.h"
#include "importjob_p.h"
#include <context.h>
using namespace GpgME;
using namespace QGpgME;
namespace
{
struct ImportJobPrivate : public JobPrivate
{
ImportJobPrivate()
{
}
~ImportJobPrivate() override = default;
QString m_importFilter;
Key::Origin m_keyOrigin = Key::OriginUnknown;
QString m_keyOriginUrl;
};
}
void QGpgME::ImportJob::setImportFilter(const QString &filter)
{
const auto d = jobPrivate<ImportJobPrivate>(this);

53
lang/qt/src/importjob_p.h Normal file
View File

@ -0,0 +1,53 @@
/*
importjob_p.h
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2021,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
QGpgME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __QGPGME_IMPORTJOB_P_H__
#define __QGPGME_IMPORTJOB_P_H__
#include "job_p.h"
#include <key.h>
namespace QGpgME
{
struct ImportJobPrivate : public JobPrivate
{
QString m_importFilter;
GpgME::Key::Origin m_keyOrigin = GpgME::Key::OriginUnknown;
QString m_keyOriginUrl;
};
}
#endif // __QGPGME_IMPORTJOB_P_H__

View File

@ -57,11 +57,6 @@ JobPrivate *getJobPrivate(const Job *job);
template <typename T>
static T *jobPrivate(const Job *job) {
auto d = getJobPrivate(job);
if (!d) {
std::unique_ptr<T> ref{new T};
d = ref.get();
setJobPrivate(job, std::move(ref));
}
return dynamic_cast<T *>(d);
}

View File

@ -36,22 +36,10 @@
#endif
#include "listallkeysjob.h"
#include "job_p.h"
#include "listallkeysjob_p.h"
using namespace QGpgME;
namespace
{
struct ListAllKeysJobPrivate : public JobPrivate
{
ListAllKeysJobPrivate() = default;
~ListAllKeysJobPrivate() override = default;
ListAllKeysJob::Options m_options = ListAllKeysJob::Default;
};
}
void ListAllKeysJob::setOptions(ListAllKeysJob::Options options)
{
auto d = jobPrivate<ListAllKeysJobPrivate>(this);

View File

@ -0,0 +1,51 @@
/*
listallkeysjob_p.h
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
QGpgME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __QGPGME_LISTALLKEYSJOB_P_H__
#define __QGPGME_LISTALLKEYSJOB_P_H__
#include "job_p.h"
#include "listallkeysjob.h"
namespace QGpgME
{
struct ListAllKeysJobPrivate : public JobPrivate
{
ListAllKeysJob::Options m_options = ListAllKeysJob::Default;
};
}
#endif // __QGPGME_LISTALLKEYSJOB_P_H__

View File

@ -5,7 +5,7 @@
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
Copyright (c) 2021 g10 Code GmbH
Copyright (c) 2021,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
@ -40,6 +40,8 @@
#include "qgpgmechangeexpiryjob.h"
#include "changeexpiryjob_p.h"
#include "context.h"
#include "key.h"
@ -48,9 +50,28 @@
using namespace QGpgME;
using namespace GpgME;
namespace
{
class QGpgMEChangeExpiryJobPrivate : public ChangeExpiryJobPrivate
{
QGpgMEChangeExpiryJob *q = nullptr;
public:
QGpgMEChangeExpiryJobPrivate(QGpgMEChangeExpiryJob *qq)
: q{qq}
{
}
~QGpgMEChangeExpiryJobPrivate() override = default;
};
}
QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob(Context *context)
: mixin_type(context)
{
setJobPrivate(this, std::unique_ptr<QGpgMEChangeExpiryJobPrivate>{new QGpgMEChangeExpiryJobPrivate{this}});
lateInitialization();
}

View File

@ -5,7 +5,7 @@
Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
Copyright (c) 2022 g10 Code GmbH
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
@ -40,6 +40,8 @@
#include "qgpgmeencryptjob.h"
#include "encryptjob_p.h"
#include "dataprovider.h"
#include "context.h"
@ -54,10 +56,29 @@
using namespace QGpgME;
using namespace GpgME;
namespace
{
class QGpgMEEncryptJobPrivate : public EncryptJobPrivate
{
QGpgMEEncryptJob *q = nullptr;
public:
QGpgMEEncryptJobPrivate(QGpgMEEncryptJob *qq)
: q{qq}
{
}
~QGpgMEEncryptJobPrivate() override = default;
};
}
QGpgMEEncryptJob::QGpgMEEncryptJob(Context *context)
: mixin_type(context),
mOutputIsBase64Encoded(false)
{
setJobPrivate(this, std::unique_ptr<QGpgMEEncryptJobPrivate>{new QGpgMEEncryptJobPrivate{this}});
lateInitialization();
}

View File

@ -5,6 +5,8 @@
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
Copyright (c) 2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@ -38,6 +40,8 @@
#include "qgpgmeimportjob.h"
#include "importjob_p.h"
#include "dataprovider.h"
#include <context.h>
@ -47,9 +51,28 @@
using namespace QGpgME;
using namespace GpgME;
namespace
{
class QGpgMEImportJobPrivate : public ImportJobPrivate
{
QGpgMEImportJob *q = nullptr;
public:
QGpgMEImportJobPrivate(QGpgMEImportJob *qq)
: q{qq}
{
}
~QGpgMEImportJobPrivate() override = default;
};
}
QGpgMEImportJob::QGpgMEImportJob(Context *context)
: mixin_type(context)
{
setJobPrivate(this, std::unique_ptr<QGpgMEImportJobPrivate>{new QGpgMEImportJobPrivate{this}});
lateInitialization();
}

View File

@ -5,7 +5,7 @@
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
Copyright (c) 2022 g10 Code GmbH
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
@ -40,6 +40,8 @@
#include "qgpgmelistallkeysjob.h"
#include "listallkeysjob_p.h"
#include "debug.h"
#include "key.h"
#include "context.h"
@ -59,10 +61,29 @@
using namespace QGpgME;
using namespace GpgME;
namespace
{
class QGpgMEListAllKeysJobPrivate : public ListAllKeysJobPrivate
{
QGpgMEListAllKeysJob *q = nullptr;
public:
QGpgMEListAllKeysJobPrivate(QGpgMEListAllKeysJob *qq)
: q{qq}
{
}
~QGpgMEListAllKeysJobPrivate() override = default;
};
}
QGpgMEListAllKeysJob::QGpgMEListAllKeysJob(Context *context)
: mixin_type(context),
mResult()
{
setJobPrivate(this, std::unique_ptr<QGpgMEListAllKeysJobPrivate>{new QGpgMEListAllKeysJobPrivate{this}});
lateInitialization();
}

View File

@ -5,7 +5,7 @@
Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB
Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
Copyright (c) 2022 g10 Code GmbH
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
@ -40,6 +40,8 @@
#include "qgpgmesignencryptjob.h"
#include "signencryptjob_p.h"
#include "dataprovider.h"
#include "context.h"
@ -55,10 +57,29 @@
using namespace QGpgME;
using namespace GpgME;
namespace
{
class QGpgMESignEncryptJobPrivate : public SignEncryptJobPrivate
{
QGpgMESignEncryptJob *q = nullptr;
public:
QGpgMESignEncryptJobPrivate(QGpgMESignEncryptJob *qq)
: q{qq}
{
}
~QGpgMESignEncryptJobPrivate() override = default;
};
}
QGpgMESignEncryptJob::QGpgMESignEncryptJob(Context *context)
: mixin_type(context),
mOutputIsBase64Encoded(false)
{
setJobPrivate(this, std::unique_ptr<QGpgMESignEncryptJobPrivate>{new QGpgMESignEncryptJobPrivate{this}});
lateInitialization();
}

View File

@ -36,18 +36,10 @@
#endif
#include "signencryptjob.h"
#include "job_p.h"
#include "signencryptjob_p.h"
using namespace QGpgME;
namespace
{
struct SignEncryptJobPrivate : public JobPrivate
{
QString m_fileName;
};
}
void SignEncryptJob::setFileName(const QString &fileName)
{
auto d = jobPrivate<SignEncryptJobPrivate>(this);

View File

@ -0,0 +1,49 @@
/*
signencryptjob_p.h
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2022,2023 g10 Code GmbH
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
QGpgME is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
QGpgME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __QGPGME_SIGNENCRYPTJOB_P_H__
#define __QGPGME_SIGNENCRYPTJOB_P_H__
#include "job_p.h"
namespace QGpgME
{
struct SignEncryptJobPrivate : public JobPrivate
{
QString m_fileName;
};
}
#endif // __QGPGME_SIGNENCRYPTJOB_P_H__