Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Feb 9, 2024
1 parent 7c20703 commit 804665b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.status()?
.success());

let proc_count = 1;//thread::available_parallelism().map_or(1, |x| x.get());
let proc_count = 1; //thread::available_parallelism().map_or(1, |x| x.get());

assert!(Command::new("make")
.args(["-f", "Makefile"])
Expand Down
59 changes: 32 additions & 27 deletions src/cpp/packet/retryrequestpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@

#include "retryrequestpacket.h"

#if QT_VERSION < 0x060000
#define typeId type
static QMetaType::Type typeId(const QVariant &v)
{
#if QT_VERSION >= 0x060000
return (QMetaType::Type)v.typeId();
#else
return v.type();
#endif
}

RetryRequestPacket::RetryRequestPacket() :
haveInspectInfo(false),
Expand Down Expand Up @@ -144,37 +149,37 @@ QVariant RetryRequestPacket::toVariant() const

bool RetryRequestPacket::fromVariant(const QVariant &in)
{
if(in.typeId() != QMetaType::QVariantHash)
if(typeId(in) != QMetaType::QVariantHash)
return false;

QVariantHash obj = in.toHash();

if(!obj.contains("requests") || obj["requests"].typeId() != QMetaType::QVariantList)
if(!obj.contains("requests") || typeId(obj["requests"]) != QMetaType::QVariantList)
return false;

requests.clear();
foreach(const QVariant &i, obj["requests"].toList())
{
if(i.typeId() != QMetaType::QVariantHash)
if(typeId(i) != QMetaType::QVariantHash)
return false;

QVariantHash vrequest = i.toHash();

Request r;

if(!vrequest.contains("rid") || vrequest["rid"].typeId() != QMetaType::QVariantHash)
if(!vrequest.contains("rid") || typeId(vrequest["rid"]) != QMetaType::QVariantHash)
return false;

QVariantHash vrid = vrequest["rid"].toHash();

QByteArray sender, id;

if(!vrid.contains("sender") || vrid["sender"].typeId() != QMetaType::QByteArray)
if(!vrid.contains("sender") || typeId(vrid["sender"]) != QMetaType::QByteArray)
return false;

sender = vrid["sender"].toByteArray();

if(!vrid.contains("id") || vrid["id"].typeId() != QMetaType::QByteArray)
if(!vrid.contains("id") || typeId(vrid["id"]) != QMetaType::QByteArray)
return false;

id = vrid["id"].toByteArray();
Expand All @@ -183,46 +188,46 @@ bool RetryRequestPacket::fromVariant(const QVariant &in)

if(vrequest.contains("https"))
{
if(vrequest["https"].typeId() != QMetaType::Bool)
if(typeId(vrequest["https"]) != QMetaType::Bool)
return false;

r.https = vrequest["https"].toBool();
}

if(vrequest.contains("peer-address"))
{
if(vrequest["peer-address"].typeId() != QMetaType::QByteArray)
if(typeId(vrequest["peer-address"]) != QMetaType::QByteArray)
return false;

r.peerAddress = QHostAddress(QString::fromUtf8(vrequest["peer-address"].toByteArray()));
}

if(vrequest.contains("debug"))
{
if(vrequest["debug"].typeId() != QMetaType::Bool)
if(typeId(vrequest["debug"]) != QMetaType::Bool)
return false;

r.debug = vrequest["debug"].toBool();
}

if(vrequest.contains("auto-cross-origin"))
{
if(vrequest["auto-cross-origin"].typeId() != QMetaType::Bool)
if(typeId(vrequest["auto-cross-origin"]) != QMetaType::Bool)
return false;

r.autoCrossOrigin = vrequest["auto-cross-origin"].toBool();
}

if(vrequest.contains("jsonp-callback"))
{
if(vrequest["jsonp-callback"].typeId() != QMetaType::QByteArray)
if(typeId(vrequest["jsonp-callback"]) != QMetaType::QByteArray)
return false;

r.jsonpCallback = vrequest["jsonp-callback"].toByteArray();

if(vrequest.contains("jsonp-extended-response"))
{
if(vrequest["jsonp-extended-response"].typeId() != QMetaType::Bool)
if(typeId(vrequest["jsonp-extended-response"]) != QMetaType::Bool)
return false;

r.jsonpExtendedResponse = vrequest["jsonp-extended-response"].toBool();
Expand Down Expand Up @@ -255,22 +260,22 @@ bool RetryRequestPacket::fromVariant(const QVariant &in)
requests += r;
}

if(!obj.contains("request-data") || obj["request-data"].typeId() != QMetaType::QVariantHash)
if(!obj.contains("request-data") || typeId(obj["request-data"]) != QMetaType::QVariantHash)
return false;
QVariantHash vrequestData = obj["request-data"].toHash();

if(!vrequestData.contains("method") || vrequestData["method"].typeId() != QMetaType::QByteArray)
if(!vrequestData.contains("method") || typeId(vrequestData["method"]) != QMetaType::QByteArray)
return false;
requestData.method = QString::fromLatin1(vrequestData["method"].toByteArray());

if(!vrequestData.contains("uri") || vrequestData["uri"].typeId() != QMetaType::QByteArray)
if(!vrequestData.contains("uri") || typeId(vrequestData["uri"]) != QMetaType::QByteArray)
return false;
requestData.uri = QUrl::fromEncoded(vrequestData["uri"].toByteArray(), QUrl::StrictMode);

requestData.headers.clear();
if(vrequestData.contains("headers"))
{
if(vrequestData["headers"].typeId() != QMetaType::QVariantList)
if(typeId(vrequestData["headers"]) != QMetaType::QVariantList)
return false;

foreach(const QVariant &i, vrequestData["headers"].toList())
Expand All @@ -279,47 +284,47 @@ bool RetryRequestPacket::fromVariant(const QVariant &in)
if(list.count() != 2)
return false;

if(list[0].typeId() != QMetaType::QByteArray || list[1].typeId() != QMetaType::QByteArray)
if(typeId(list[0]) != QMetaType::QByteArray || typeId(list[1]) != QMetaType::QByteArray)
return false;

requestData.headers += QPair<QByteArray, QByteArray>(list[0].toByteArray(), list[1].toByteArray());
}
}

if(!vrequestData.contains("body") || vrequestData["body"].typeId() != QMetaType::QByteArray)
if(!vrequestData.contains("body") || typeId(vrequestData["body"]) != QMetaType::QByteArray)
return false;
requestData.body = vrequestData["body"].toByteArray();

if(obj.contains("inspect"))
{
if(obj["inspect"].typeId() != QMetaType::QVariantHash)
if(typeId(obj["inspect"]) != QMetaType::QVariantHash)
return false;
QVariantHash vinspect = obj["inspect"].toHash();

if(!vinspect.contains("no-proxy") || vinspect["no-proxy"].typeId() != QMetaType::Bool)
if(!vinspect.contains("no-proxy") || typeId(vinspect["no-proxy"]) != QMetaType::Bool)
return false;
inspectInfo.doProxy = !vinspect["no-proxy"].toBool();

inspectInfo.sharingKey.clear();
if(vinspect.contains("sharing-key"))
{
if(vinspect["sharing-key"].typeId() != QMetaType::QByteArray)
if(typeId(vinspect["sharing-key"]) != QMetaType::QByteArray)
return false;

inspectInfo.sharingKey = vinspect["sharing-key"].toByteArray();
}

if(vinspect.contains("sid"))
{
if(vinspect["sid"].typeId() != QMetaType::QByteArray)
if(typeId(vinspect["sid"]) != QMetaType::QByteArray)
return false;

inspectInfo.sid = vinspect["sid"].toByteArray();
}

if(vinspect.contains("last-ids"))
{
if(vinspect["last-ids"].typeId() != QMetaType::QVariantHash)
if(typeId(vinspect["last-ids"]) != QMetaType::QVariantHash)
return false;

QVariantHash vlastIds = vinspect["last-ids"].toHash();
Expand All @@ -328,7 +333,7 @@ bool RetryRequestPacket::fromVariant(const QVariant &in)
{
it.next();

if(it.value().typeId() != QMetaType::QByteArray)
if(typeId(it.value()) != QMetaType::QByteArray)
return false;

QByteArray key = it.key().toUtf8();
Expand All @@ -344,7 +349,7 @@ bool RetryRequestPacket::fromVariant(const QVariant &in)

if(obj.contains("route"))
{
if(obj["route"].typeId() != QMetaType::QByteArray)
if(typeId(obj["route"]) != QMetaType::QByteArray)
return false;

route = obj["route"].toByteArray();
Expand Down

0 comments on commit 804665b

Please sign in to comment.