mirror of
https://github.com/mappu/miqt.git
synced 2024-12-23 01:18:37 +00:00
435 lines
14 KiB
C++
435 lines
14 KiB
C++
|
#include <QByteArray>
|
||
|
#include <QDtls>
|
||
|
#include <QDtlsClientVerifier>
|
||
|
#define WORKAROUND_INNER_CLASS_DEFINITION_QDtlsClientVerifier__GeneratorParameters
|
||
|
#include <QHostAddress>
|
||
|
#include <QList>
|
||
|
#include <QMetaObject>
|
||
|
#include <QObject>
|
||
|
#include <QSslCipher>
|
||
|
#include <QSslConfiguration>
|
||
|
#include <QSslError>
|
||
|
#include <QSslPreSharedKeyAuthenticator>
|
||
|
#include <QString>
|
||
|
#include <QByteArray>
|
||
|
#include <cstring>
|
||
|
#include <QUdpSocket>
|
||
|
#include <qdtls.h>
|
||
|
#include "gen_qdtls.h"
|
||
|
#include "_cgo_export.h"
|
||
|
|
||
|
QDtlsClientVerifier* QDtlsClientVerifier_new() {
|
||
|
return new QDtlsClientVerifier();
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier* QDtlsClientVerifier_new2(QObject* parent) {
|
||
|
return new QDtlsClientVerifier(parent);
|
||
|
}
|
||
|
|
||
|
QMetaObject* QDtlsClientVerifier_MetaObject(const QDtlsClientVerifier* self) {
|
||
|
return (QMetaObject*) self->metaObject();
|
||
|
}
|
||
|
|
||
|
void* QDtlsClientVerifier_Metacast(QDtlsClientVerifier* self, const char* param1) {
|
||
|
return self->qt_metacast(param1);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_Tr(const char* s) {
|
||
|
QString _ret = QDtlsClientVerifier::tr(s);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_TrUtf8(const char* s) {
|
||
|
QString _ret = QDtlsClientVerifier::trUtf8(s);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
bool QDtlsClientVerifier_SetCookieGeneratorParameters(QDtlsClientVerifier* self, QDtlsClientVerifier__GeneratorParameters* params) {
|
||
|
return self->setCookieGeneratorParameters(*params);
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier__GeneratorParameters* QDtlsClientVerifier_CookieGeneratorParameters(const QDtlsClientVerifier* self) {
|
||
|
return new QDtlsClientVerifier::GeneratorParameters(self->cookieGeneratorParameters());
|
||
|
}
|
||
|
|
||
|
bool QDtlsClientVerifier_VerifyClient(QDtlsClientVerifier* self, QUdpSocket* socket, struct miqt_string dgram, QHostAddress* address, uint16_t port) {
|
||
|
QByteArray dgram_QByteArray(dgram.data, dgram.len);
|
||
|
return self->verifyClient(socket, dgram_QByteArray, *address, static_cast<quint16>(port));
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_VerifiedHello(const QDtlsClientVerifier* self) {
|
||
|
QByteArray _qb = self->verifiedHello();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _qb.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _qb.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
unsigned char QDtlsClientVerifier_DtlsError(const QDtlsClientVerifier* self) {
|
||
|
QDtlsError _ret = self->dtlsError();
|
||
|
return static_cast<unsigned char>(_ret);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_DtlsErrorString(const QDtlsClientVerifier* self) {
|
||
|
QString _ret = self->dtlsErrorString();
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_Tr2(const char* s, const char* c) {
|
||
|
QString _ret = QDtlsClientVerifier::tr(s, c);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_Tr3(const char* s, const char* c, int n) {
|
||
|
QString _ret = QDtlsClientVerifier::tr(s, c, static_cast<int>(n));
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_TrUtf82(const char* s, const char* c) {
|
||
|
QString _ret = QDtlsClientVerifier::trUtf8(s, c);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtlsClientVerifier_TrUtf83(const char* s, const char* c, int n) {
|
||
|
QString _ret = QDtlsClientVerifier::trUtf8(s, c, static_cast<int>(n));
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
void QDtlsClientVerifier_Delete(QDtlsClientVerifier* self) {
|
||
|
delete self;
|
||
|
}
|
||
|
|
||
|
QDtls* QDtls_new(int mode) {
|
||
|
return new QDtls(static_cast<QSslSocket::SslMode>(mode));
|
||
|
}
|
||
|
|
||
|
QDtls* QDtls_new2(int mode, QObject* parent) {
|
||
|
return new QDtls(static_cast<QSslSocket::SslMode>(mode), parent);
|
||
|
}
|
||
|
|
||
|
QMetaObject* QDtls_MetaObject(const QDtls* self) {
|
||
|
return (QMetaObject*) self->metaObject();
|
||
|
}
|
||
|
|
||
|
void* QDtls_Metacast(QDtls* self, const char* param1) {
|
||
|
return self->qt_metacast(param1);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_Tr(const char* s) {
|
||
|
QString _ret = QDtls::tr(s);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_TrUtf8(const char* s) {
|
||
|
QString _ret = QDtls::trUtf8(s);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
bool QDtls_SetPeer(QDtls* self, QHostAddress* address, uint16_t port) {
|
||
|
return self->setPeer(*address, static_cast<quint16>(port));
|
||
|
}
|
||
|
|
||
|
bool QDtls_SetPeerVerificationName(QDtls* self, struct miqt_string name) {
|
||
|
QString name_QString = QString::fromUtf8(name.data, name.len);
|
||
|
return self->setPeerVerificationName(name_QString);
|
||
|
}
|
||
|
|
||
|
QHostAddress* QDtls_PeerAddress(const QDtls* self) {
|
||
|
return new QHostAddress(self->peerAddress());
|
||
|
}
|
||
|
|
||
|
uint16_t QDtls_PeerPort(const QDtls* self) {
|
||
|
quint16 _ret = self->peerPort();
|
||
|
return static_cast<uint16_t>(_ret);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_PeerVerificationName(const QDtls* self) {
|
||
|
QString _ret = self->peerVerificationName();
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
int QDtls_SslMode(const QDtls* self) {
|
||
|
QSslSocket::SslMode _ret = self->sslMode();
|
||
|
return static_cast<int>(_ret);
|
||
|
}
|
||
|
|
||
|
void QDtls_SetMtuHint(QDtls* self, uint16_t mtuHint) {
|
||
|
self->setMtuHint(static_cast<quint16>(mtuHint));
|
||
|
}
|
||
|
|
||
|
uint16_t QDtls_MtuHint(const QDtls* self) {
|
||
|
quint16 _ret = self->mtuHint();
|
||
|
return static_cast<uint16_t>(_ret);
|
||
|
}
|
||
|
|
||
|
bool QDtls_SetCookieGeneratorParameters(QDtls* self, QDtlsClientVerifier__GeneratorParameters* params) {
|
||
|
return self->setCookieGeneratorParameters(*params);
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier__GeneratorParameters* QDtls_CookieGeneratorParameters(const QDtls* self) {
|
||
|
return new QDtlsClientVerifier::GeneratorParameters(self->cookieGeneratorParameters());
|
||
|
}
|
||
|
|
||
|
bool QDtls_SetDtlsConfiguration(QDtls* self, QSslConfiguration* configuration) {
|
||
|
return self->setDtlsConfiguration(*configuration);
|
||
|
}
|
||
|
|
||
|
QSslConfiguration* QDtls_DtlsConfiguration(const QDtls* self) {
|
||
|
return new QSslConfiguration(self->dtlsConfiguration());
|
||
|
}
|
||
|
|
||
|
int QDtls_HandshakeState(const QDtls* self) {
|
||
|
QDtls::HandshakeState _ret = self->handshakeState();
|
||
|
return static_cast<int>(_ret);
|
||
|
}
|
||
|
|
||
|
bool QDtls_DoHandshake(QDtls* self, QUdpSocket* socket) {
|
||
|
return self->doHandshake(socket);
|
||
|
}
|
||
|
|
||
|
bool QDtls_HandleTimeout(QDtls* self, QUdpSocket* socket) {
|
||
|
return self->handleTimeout(socket);
|
||
|
}
|
||
|
|
||
|
bool QDtls_ResumeHandshake(QDtls* self, QUdpSocket* socket) {
|
||
|
return self->resumeHandshake(socket);
|
||
|
}
|
||
|
|
||
|
bool QDtls_AbortHandshake(QDtls* self, QUdpSocket* socket) {
|
||
|
return self->abortHandshake(socket);
|
||
|
}
|
||
|
|
||
|
bool QDtls_Shutdown(QDtls* self, QUdpSocket* socket) {
|
||
|
return self->shutdown(socket);
|
||
|
}
|
||
|
|
||
|
bool QDtls_IsConnectionEncrypted(const QDtls* self) {
|
||
|
return self->isConnectionEncrypted();
|
||
|
}
|
||
|
|
||
|
QSslCipher* QDtls_SessionCipher(const QDtls* self) {
|
||
|
return new QSslCipher(self->sessionCipher());
|
||
|
}
|
||
|
|
||
|
int QDtls_SessionProtocol(const QDtls* self) {
|
||
|
QSsl::SslProtocol _ret = self->sessionProtocol();
|
||
|
return static_cast<int>(_ret);
|
||
|
}
|
||
|
|
||
|
long long QDtls_WriteDatagramEncrypted(QDtls* self, QUdpSocket* socket, struct miqt_string dgram) {
|
||
|
QByteArray dgram_QByteArray(dgram.data, dgram.len);
|
||
|
qint64 _ret = self->writeDatagramEncrypted(socket, dgram_QByteArray);
|
||
|
return static_cast<long long>(_ret);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_DecryptDatagram(QDtls* self, QUdpSocket* socket, struct miqt_string dgram) {
|
||
|
QByteArray dgram_QByteArray(dgram.data, dgram.len);
|
||
|
QByteArray _qb = self->decryptDatagram(socket, dgram_QByteArray);
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _qb.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _qb.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
unsigned char QDtls_DtlsError(const QDtls* self) {
|
||
|
QDtlsError _ret = self->dtlsError();
|
||
|
return static_cast<unsigned char>(_ret);
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_DtlsErrorString(const QDtls* self) {
|
||
|
QString _ret = self->dtlsErrorString();
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_array QDtls_PeerVerificationErrors(const QDtls* self) {
|
||
|
QVector<QSslError> _ret = self->peerVerificationErrors();
|
||
|
// Convert QList<> from C++ memory to manually-managed C memory
|
||
|
QSslError** _arr = static_cast<QSslError**>(malloc(sizeof(QSslError*) * _ret.length()));
|
||
|
for (size_t i = 0, e = _ret.length(); i < e; ++i) {
|
||
|
_arr[i] = new QSslError(_ret[i]);
|
||
|
}
|
||
|
struct miqt_array _out;
|
||
|
_out.len = _ret.length();
|
||
|
_out.data = static_cast<void*>(_arr);
|
||
|
return _out;
|
||
|
}
|
||
|
|
||
|
void QDtls_IgnoreVerificationErrors(QDtls* self, struct miqt_array /* of QSslError* */ errorsToIgnore) {
|
||
|
QVector<QSslError> errorsToIgnore_QList;
|
||
|
errorsToIgnore_QList.reserve(errorsToIgnore.len);
|
||
|
QSslError** errorsToIgnore_arr = static_cast<QSslError**>(errorsToIgnore.data);
|
||
|
for(size_t i = 0; i < errorsToIgnore.len; ++i) {
|
||
|
errorsToIgnore_QList.push_back(*(errorsToIgnore_arr[i]));
|
||
|
}
|
||
|
self->ignoreVerificationErrors(errorsToIgnore_QList);
|
||
|
}
|
||
|
|
||
|
void QDtls_PskRequired(QDtls* self, QSslPreSharedKeyAuthenticator* authenticator) {
|
||
|
self->pskRequired(authenticator);
|
||
|
}
|
||
|
|
||
|
void QDtls_connect_PskRequired(QDtls* self, intptr_t slot) {
|
||
|
QDtls::connect(self, static_cast<void (QDtls::*)(QSslPreSharedKeyAuthenticator*)>(&QDtls::pskRequired), self, [=](QSslPreSharedKeyAuthenticator* authenticator) {
|
||
|
QSslPreSharedKeyAuthenticator* sigval1 = authenticator;
|
||
|
miqt_exec_callback_QDtls_PskRequired(slot, sigval1);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
void QDtls_HandshakeTimeout(QDtls* self) {
|
||
|
self->handshakeTimeout();
|
||
|
}
|
||
|
|
||
|
void QDtls_connect_HandshakeTimeout(QDtls* self, intptr_t slot) {
|
||
|
QDtls::connect(self, static_cast<void (QDtls::*)()>(&QDtls::handshakeTimeout), self, [=]() {
|
||
|
miqt_exec_callback_QDtls_HandshakeTimeout(slot);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_Tr2(const char* s, const char* c) {
|
||
|
QString _ret = QDtls::tr(s, c);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_Tr3(const char* s, const char* c, int n) {
|
||
|
QString _ret = QDtls::tr(s, c, static_cast<int>(n));
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_TrUtf82(const char* s, const char* c) {
|
||
|
QString _ret = QDtls::trUtf8(s, c);
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
struct miqt_string QDtls_TrUtf83(const char* s, const char* c, int n) {
|
||
|
QString _ret = QDtls::trUtf8(s, c, static_cast<int>(n));
|
||
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
||
|
QByteArray _b = _ret.toUtf8();
|
||
|
struct miqt_string _ms;
|
||
|
_ms.len = _b.length();
|
||
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
||
|
memcpy(_ms.data, _b.data(), _ms.len);
|
||
|
return _ms;
|
||
|
}
|
||
|
|
||
|
bool QDtls_SetPeer3(QDtls* self, QHostAddress* address, uint16_t port, struct miqt_string verificationName) {
|
||
|
QString verificationName_QString = QString::fromUtf8(verificationName.data, verificationName.len);
|
||
|
return self->setPeer(*address, static_cast<quint16>(port), verificationName_QString);
|
||
|
}
|
||
|
|
||
|
bool QDtls_DoHandshake2(QDtls* self, QUdpSocket* socket, struct miqt_string dgram) {
|
||
|
QByteArray dgram_QByteArray(dgram.data, dgram.len);
|
||
|
return self->doHandshake(socket, dgram_QByteArray);
|
||
|
}
|
||
|
|
||
|
void QDtls_Delete(QDtls* self) {
|
||
|
delete self;
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier__GeneratorParameters* QDtlsClientVerifier__GeneratorParameters_new() {
|
||
|
return new QDtlsClientVerifier::GeneratorParameters();
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier__GeneratorParameters* QDtlsClientVerifier__GeneratorParameters_new2(int a, struct miqt_string s) {
|
||
|
QByteArray s_QByteArray(s.data, s.len);
|
||
|
return new QDtlsClientVerifier::GeneratorParameters(static_cast<QCryptographicHash::Algorithm>(a), s_QByteArray);
|
||
|
}
|
||
|
|
||
|
QDtlsClientVerifier__GeneratorParameters* QDtlsClientVerifier__GeneratorParameters_new3(QDtlsClientVerifier__GeneratorParameters* param1) {
|
||
|
return new QDtlsClientVerifier::GeneratorParameters(*param1);
|
||
|
}
|
||
|
|
||
|
void QDtlsClientVerifier__GeneratorParameters_OperatorAssign(QDtlsClientVerifier__GeneratorParameters* self, QDtlsClientVerifier__GeneratorParameters* param1) {
|
||
|
self->operator=(*param1);
|
||
|
}
|
||
|
|
||
|
void QDtlsClientVerifier__GeneratorParameters_Delete(QDtlsClientVerifier__GeneratorParameters* self) {
|
||
|
delete self;
|
||
|
}
|
||
|
|