mirror of
https://github.com/QuasarApp/qca.git
synced 2025-05-11 02: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:
parent
974f8ec8d0
commit
0c3db8a062
@ -98,9 +98,13 @@ myTypeName = QCA::methodReturnType( testClass.metaObject(), QByteArray( "boolMet
|
|||||||
\relates SyncThread
|
\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,
|
QCA_EXPORT QByteArray methodReturnType(const QMetaObject * obj,
|
||||||
const QByteArray & method,
|
const QByteArray & method,
|
||||||
const QList<QByteArray> argTypes);
|
const QList<QByteArray> argTypes);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convenience method to invoke a method by name, using a variant
|
Convenience method to invoke a method by name, using a variant
|
||||||
|
@ -32,6 +32,13 @@ namespace gpgQCAPlugin {
|
|||||||
SProcess::SProcess(QObject *parent)
|
SProcess::SProcess(QObject *parent)
|
||||||
: QProcess(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()
|
SProcess::~SProcess()
|
||||||
@ -44,6 +51,7 @@ void SProcess::setInheritPipeList(const QList<int> &list)
|
|||||||
pipeList = list;
|
pipeList = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
void SProcess::setupChildProcess()
|
void SProcess::setupChildProcess()
|
||||||
{
|
{
|
||||||
// set the pipes to be inheritable
|
// 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));
|
::fcntl(pipeList[n], F_SETFD, (::fcntl(pipeList[n], F_GETFD) & ~FD_CLOEXEC));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,10 @@ public:
|
|||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
void setInheritPipeList(const QList<int> &);
|
void setInheritPipeList(const QList<int> &);
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
protected:
|
protected:
|
||||||
void setupChildProcess() override;
|
void setupChildProcess() override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> pipeList;
|
QList<int> pipeList;
|
||||||
|
@ -335,7 +335,11 @@ static CertificateInfo get_cert_name(X509_NAME *name)
|
|||||||
CertificateInfo p9_info;
|
CertificateInfo p9_info;
|
||||||
try_get_name_item(name, NID_pkcs9_emailAddress, EmailLegacy, &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);
|
QMapIterator<CertificateInfoType, QString> it(p9_info);
|
||||||
|
#endif
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
if (!emails.contains(it.value()))
|
if (!emails.contains(it.value()))
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "qcaprovider.h"
|
#include "qcaprovider.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@ -1343,7 +1345,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain)
|
|||||||
name = name.toLower();
|
name = name.toLower();
|
||||||
|
|
||||||
// ensure the cert field contains valid characters only
|
// 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;
|
return false;
|
||||||
|
|
||||||
// hack into parts, and require at least 1 part
|
// hack into parts, and require at least 1 part
|
||||||
|
@ -541,7 +541,12 @@ static bool configIsValid(const QVariantMap &config)
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
const QVariant &v = it.value();
|
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)
|
if (v.type() != QVariant::String && v.type() != QVariant::Int && v.type() != QVariant::Bool)
|
||||||
|
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -848,7 +848,7 @@ public:
|
|||||||
result.resize(at * sizeof(ushort));
|
result.resize(at * sizeof(ushort));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (c < 0x20)
|
} else if (c.unicode() < 0x20)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (at >= CONSOLEPROMPT_INPUT_MAX)
|
if (at >= CONSOLEPROMPT_INPUT_MAX)
|
||||||
|
@ -342,7 +342,7 @@ public:
|
|||||||
, loop(nullptr)
|
, loop(nullptr)
|
||||||
, agent(nullptr)
|
, agent(nullptr)
|
||||||
, fixer(nullptr)
|
, fixer(nullptr)
|
||||||
, m(QMutex::NonRecursive)
|
, m()
|
||||||
, w()
|
, w()
|
||||||
, orig_thread(nullptr)
|
, orig_thread(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -27,11 +27,15 @@
|
|||||||
|
|
||||||
namespace QCA {
|
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(
|
QByteArray methodReturnType(
|
||||||
const QMetaObject * obj,
|
const QMetaObject * obj,
|
||||||
const QByteArray & method,
|
const QByteArray & method,
|
||||||
const QList<QByteArray> argTypes) // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param)
|
const QList<QByteArray> argTypes) // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param)
|
||||||
// TODO make argTypes const & when we break ABI
|
// TODO make argTypes const & when we break ABI
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
for (int n = 0; n < obj->methodCount(); ++n) {
|
for (int n = 0; n < obj->methodCount(); ++n) {
|
||||||
QMetaMethod m = obj->method(n);
|
QMetaMethod m = obj->method(n);
|
||||||
@ -45,9 +49,17 @@ QByteArray methodReturnType(
|
|||||||
if (m.parameterTypes() != argTypes)
|
if (m.parameterTypes() != argTypes)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
return m.returnType();
|
||||||
|
#else
|
||||||
return m.typeName();
|
return m.typeName();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
return QMetaType::UnknownType;
|
||||||
|
#else
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invokeMethodWithVariants(QObject * obj,
|
bool invokeMethodWithVariants(QObject * obj,
|
||||||
@ -61,10 +73,17 @@ bool invokeMethodWithVariants(QObject * obj,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
QList<QByteArray> argTypes;
|
QList<QByteArray> argTypes;
|
||||||
for (int n = 0; n < args.count(); ++n)
|
for (int n = 0; n < args.count(); ++n) {
|
||||||
argTypes += args[n].typeName();
|
argTypes += args[n].typeName();
|
||||||
|
}
|
||||||
|
|
||||||
// get return type
|
// 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;
|
int metatype = QMetaType::Void;
|
||||||
const QByteArray retTypeName = methodReturnType(obj->metaObject(), method, argTypes);
|
const QByteArray retTypeName = methodReturnType(obj->metaObject(), method, argTypes);
|
||||||
if (!retTypeName.isEmpty() && retTypeName != "void") {
|
if (!retTypeName.isEmpty() && retTypeName != "void") {
|
||||||
@ -72,6 +91,7 @@ bool invokeMethodWithVariants(QObject * obj,
|
|||||||
if (metatype == QMetaType::UnknownType) // lookup failed
|
if (metatype == QMetaType::UnknownType) // lookup failed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QGenericArgument arg[10];
|
QGenericArgument arg[10];
|
||||||
for (int n = 0; n < args.count(); ++n)
|
for (int n = 0; n < args.count(); ++n)
|
||||||
@ -81,7 +101,11 @@ bool invokeMethodWithVariants(QObject * obj,
|
|||||||
QVariant retval;
|
QVariant retval;
|
||||||
|
|
||||||
if (metatype != QMetaType::Void) {
|
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);
|
retval = QVariant(metatype, (const void *)nullptr);
|
||||||
|
#endif
|
||||||
retarg = QGenericReturnArgument(retval.typeName(), retval.data());
|
retarg = QGenericReturnArgument(retval.typeName(), retval.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRegExp>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
QStringList splitWithQuotes(const QString &in, char c);
|
QStringList splitWithQuotes(const QString &in, char c);
|
||||||
|
@ -105,6 +105,43 @@ void MetaTypeUnitTest::returnTypeTest()
|
|||||||
TestClass1 testClass1;
|
TestClass1 testClass1;
|
||||||
QList<QByteArray> args;
|
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...
|
// returns a null type name because that is what void does...
|
||||||
QCOMPARE(QByteArray("void"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args));
|
QCOMPARE(QByteArray("void"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("voidMethod"), args));
|
||||||
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args));
|
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("qstringMethod"), args));
|
||||||
@ -140,6 +177,7 @@ void MetaTypeUnitTest::returnTypeTest()
|
|||||||
|
|
||||||
args << "int";
|
args << "int";
|
||||||
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args));
|
QCOMPARE(QByteArray("QString"), QCA::methodReturnType(testClass1.metaObject(), QByteArray("elevenArgs"), args));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaTypeUnitTest::invokeMethodTest()
|
void MetaTypeUnitTest::invokeMethodTest()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user