Commit a789129e authored by Volker Krause's avatar Volker Krause
Browse files

Extend ERA SSB document processor to support multiple ticket versions

parent b04c7b10
......@@ -6,6 +6,7 @@
#include "ssbdocumentprocessor.h"
#include "era/ssbv1ticket.h"
#include "era/ssbv3ticket.h"
#include <KItinerary/ExtractorFilter>
......@@ -16,27 +17,38 @@ using namespace KItinerary;
bool SsbDocumentProcessor::canHandleData(const QByteArray &encodedData, [[maybe_unused]] QStringView fileName) const
{
return SSBv3Ticket::maybeSSB(encodedData);
return SSBv3Ticket::maybeSSB(encodedData) || SSBv1Ticket::maybeSSB(encodedData);
}
ExtractorDocumentNode SsbDocumentProcessor::createNodeFromData(const QByteArray &encodedData) const
{
ExtractorDocumentNode node;
if (SSBv3Ticket::maybeSSB(encodedData)) {
auto ticket = SSBv3Ticket(encodedData);
if (ticket.isValid()) {
node.setContent(ticket);
}
} else if (SSBv1Ticket::maybeSSB(encodedData)) {
auto ticket = SSBv1Ticket(encodedData);
if (ticket.isValid()) {
node.setContent(ticket);
}
}
return node;
}
bool SsbDocumentProcessor::matches(const ExtractorFilter &filter, const ExtractorDocumentNode &node) const
{
const auto ticket = node.content<SSBv3Ticket>();
const auto propIdx = SSBv3Ticket::staticMetaObject.indexOfProperty(filter.fieldName().toUtf8().constData());
const auto ticket = node.content();
const auto mo = QMetaType(ticket.userType()).metaObject();
if (!mo) {
return false;
}
const auto propIdx = mo->indexOfProperty(filter.fieldName().toUtf8().constData());
if (propIdx < 0) {
return false;
}
const auto prop = SSBv3Ticket::staticMetaObject.property(propIdx);
const auto value = prop.readOnGadget(&ticket);
const auto prop = mo->property(propIdx);
const auto value = prop.readOnGadget(ticket.constData());
return filter.matches(value.toString());
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment