4
0
mirror of https://github.com/QuasarApp/qca.git synced 2025-05-07 00:09:33 +00:00

Start Qt 6 port

Still a few occurrences of QRegExp and QTextCodec need to be replaced
in order to drop the dependency on the Core5Compat module. Besides this
QCA builds fine with Qt 6.1 and passes all tests.
This commit is contained in:
Tobias Junghans 2021-05-10 09:55:38 +02:00 committed by Albert Astals Cid
parent 974f8ec8d0
commit 0c3db8a062
11 changed files with 95 additions and 6 deletions
include/QtCrypto
plugins
qca-gnupg/gpgproc
qca-ossl
src
tools/mozcerts
unittest/metatype

@ -98,9 +98,13 @@ myTypeName = QCA::methodReturnType( testClass.metaObject(), QByteArray( "boolMet
\relates SyncThread
*/
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QCA_EXPORT int methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> &argTypes);
#else
QCA_EXPORT QByteArray methodReturnType(const QMetaObject * obj,
const QByteArray & method,
const QList<QByteArray> argTypes);
#endif
/**
Convenience method to invoke a method by name, using a variant

@ -32,6 +32,13 @@ namespace gpgQCAPlugin {
SProcess::SProcess(QObject *parent)
: QProcess(parent)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
setChildProcessModifier([this]() {
// set the pipes to be inheritable
for (int n = 0; n < pipeList.count(); ++n)
::fcntl(pipeList[n], F_SETFD, (::fcntl(pipeList[n], F_GETFD) & ~FD_CLOEXEC));
});
#endif
}
SProcess::~SProcess()
@ -44,6 +51,7 @@ void SProcess::setInheritPipeList(const QList<int> &list)
pipeList = list;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void SProcess::setupChildProcess()
{
// set the pipes to be inheritable
@ -51,5 +59,6 @@ void SProcess::setupChildProcess()
::fcntl(pipeList[n], F_SETFD, (::fcntl(pipeList[n], F_GETFD) & ~FD_CLOEXEC));
}
#endif
#endif
}

@ -34,8 +34,10 @@ public:
#ifdef Q_OS_UNIX
void setInheritPipeList(const QList<int> &);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
protected:
void setupChildProcess() override;
#endif
private:
QList<int> pipeList;

@ -334,8 +334,12 @@ static CertificateInfo get_cert_name(X509_NAME *name)
{
CertificateInfo p9_info;
try_get_name_item(name, NID_pkcs9_emailAddress, EmailLegacy, &p9_info);
const QList<QString> emails = info.values(Email);
const QList<QString> emails = info.values(Email);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMultiMapIterator<CertificateInfoType, QString> it(p9_info);
#else
QMapIterator<CertificateInfoType, QString> it(p9_info);
#endif
while (it.hasNext()) {
it.next();
if (!emails.contains(it.value()))
@ -1613,7 +1617,7 @@ static const auto DsaDeleter = [](DSA *pointer) {
static bool make_dlgroup(const QByteArray &seed, int bits, int counter, DLParams *params)
{
int ret_counter;
int ret_counter;
std::unique_ptr<DSA, decltype(DsaDeleter)> dsa(DSA_new(), DsaDeleter);
if (!dsa)
return false;

@ -25,6 +25,8 @@
#include "qcaprovider.h"
#include <QFile>
#include <QRegExp>
#include <QRegularExpression>
#include <QTextStream>
#include <QUrl>
@ -1343,7 +1345,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain)
name = name.toLower();
// ensure the cert field contains valid characters only
if (QRegExp(QLatin1String("[^a-z0-9\\.\\*\\-]")).indexIn(name) >= 0)
if (QRegularExpression(QStringLiteral("[^a-z0-9\\.\\*\\-]")).match(name).hasMatch())
return false;
// hack into parts, and require at least 1 part

@ -541,7 +541,12 @@ static bool configIsValid(const QVariantMap &config)
while (it.hasNext()) {
it.next();
const QVariant &v = it.value();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (v.typeId() != QMetaType::QString && v.typeId() != QMetaType::Int && v.typeId() != QMetaType::Bool)
#else
if (v.type() != QVariant::String && v.type() != QVariant::Int && v.type() != QVariant::Bool)
#endif
return false;
}
return true;

@ -848,7 +848,7 @@ public:
result.resize(at * sizeof(ushort));
}
return true;
} else if (c < 0x20)
} else if (c.unicode() < 0x20)
return true;
if (at >= CONSOLEPROMPT_INPUT_MAX)

@ -342,7 +342,7 @@ public:
, loop(nullptr)
, agent(nullptr)
, fixer(nullptr)
, m(QMutex::NonRecursive)
, m()
, w()
, orig_thread(nullptr)
{

@ -27,11 +27,15 @@
namespace QCA {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> &argTypes)
#else
QByteArray methodReturnType(
const QMetaObject * obj,
const QByteArray & method,
const QList<QByteArray> argTypes) // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param)
// TODO make argTypes const & when we break ABI
#endif
{
for (int n = 0; n < obj->methodCount(); ++n) {
QMetaMethod m = obj->method(n);
@ -45,9 +49,17 @@ QByteArray methodReturnType(
if (m.parameterTypes() != argTypes)
continue;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return m.returnType();
#else
return m.typeName();
#endif
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QMetaType::UnknownType;
#else
return QByteArray();
#endif
}
bool invokeMethodWithVariants(QObject * obj,
@ -61,10 +73,17 @@ bool invokeMethodWithVariants(QObject * obj,
return false;
QList<QByteArray> argTypes;
for (int n = 0; n < args.count(); ++n)
for (int n = 0; n < args.count(); ++n) {
argTypes += args[n].typeName();
}
// get return type
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const auto metatype = methodReturnType(obj->metaObject(), method, argTypes);
if (metatype == QMetaType::UnknownType) {
return false;
}
#else
int metatype = QMetaType::Void;
const QByteArray retTypeName = methodReturnType(obj->metaObject(), method, argTypes);
if (!retTypeName.isEmpty() && retTypeName != "void") {
@ -72,6 +91,7 @@ bool invokeMethodWithVariants(QObject * obj,
if (metatype == QMetaType::UnknownType) // lookup failed
return false;
}
#endif
QGenericArgument arg[10];
for (int n = 0; n < args.count(); ++n)
@ -81,7 +101,11 @@ bool invokeMethodWithVariants(QObject * obj,
QVariant retval;
if (metatype != QMetaType::Void) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
retval = QVariant(QMetaType {metatype}, (const void *)nullptr);
#else
retval = QVariant(metatype, (const void *)nullptr);
#endif
retarg = QGenericReturnArgument(retval.typeName(), retval.data());
}

@ -23,6 +23,7 @@
#include <QCoreApplication>
#include <QFile>
#include <QRegExp>
#include <QTextStream>
QStringList splitWithQuotes(const QString &in, char c);

@ -105,6 +105,43 @@ void MetaTypeUnitTest::returnTypeTest()
TestClass1 testClass1;
QList<QByteArray> args;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// returns a null type name because that is what void does...
QCOMPARE(QMetaType::Void, QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args));
QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args));
// returns a null type, because args don't match
QCOMPARE(QMetaType::UnknownType, QCA::methodReturnType(testClass1.metaObject(), QByteArray("boolMethod"), args));
args << "QString";
QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("returnArg"), args));
QCOMPARE(QMetaType::Bool, QCA::methodReturnType(testClass1.metaObject(), QByteArray("boolMethod"), args));
args.clear();
args << "QByteArray";
QCOMPARE(QMetaType::QByteArray, QCA::methodReturnType(testClass1.metaObject(), QByteArray("returnArg"), args));
args.clear();
args << "QString"
<< "int"
<< "int"
<< "int"
<< "int"
<< "int"
<< "int"
<< "int"
<< "int";
// wrong number of arguments - has 9, needs 10
QCOMPARE(QMetaType::UnknownType, QCA::methodReturnType(testClass1.metaObject(), QByteArray("tenArgs"), args));
// match
args << "int";
QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("tenArgs"), args));
args << "int";
QCOMPARE(QMetaType::QString, QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args));
#else
// returns a null type name because that is what void does...
QCOMPARE(QByteArray("void"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args));
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args));
@ -140,6 +177,7 @@ void MetaTypeUnitTest::returnTypeTest()
args << "int";
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args));
#endif
}
void MetaTypeUnitTest::invokeMethodTest()