Commit 55c4c4f1 authored by Volker Krause's avatar Volker Krause
Browse files

Remove the need for an external context date for the UIC 918.3 parser

We can meanwhile extract that reliably from the U_HEAD block of the
UIC 918.3 data.
parent c391a0cb
Pipeline #52047 passed with stage
in 11 minutes and 10 seconds
......@@ -501,7 +501,7 @@ void ExtractorEnginePrivate::extractGeneric()
else if (!m_data.isEmpty()) {
if (Uic9183Parser::maybeUic9183(m_data)) {
QJsonArray res;
GenericUic918Extractor::extract(m_data, res, m_context->m_senderDate);
GenericUic918Extractor::extract(m_data, res);
m_genericResults.emplace_back(GenericExtractor::Result{res, m_data});
return;
} else if (VdvTicketParser::maybeVdvTicket(m_data)) {
......
......@@ -109,7 +109,7 @@ GenericExtractor::Result GenericPdfExtractor::extractImage(const PdfImage &img,
if (Uic9183Parser::maybeUic9183(b)) {
QJsonArray result;
GenericUic918Extractor::extract(b, result, m_contextDate);
GenericUic918Extractor::extract(b, result);
if (!result.isEmpty()) {
return GenericExtractor::Result{result, b};
}
......
......@@ -18,10 +18,9 @@
using namespace KItinerary;
void GenericUic918Extractor::extract(const QByteArray &data, QJsonArray &result, const QDateTime &contextDate)
void GenericUic918Extractor::extract(const QByteArray &data, QJsonArray &result)
{
Uic9183Parser p;
p.setContextDate(contextDate);
p.parse(data);
if (!p.isValid()) {
return;
......
......@@ -8,7 +8,6 @@
#define KITINERARY_GENERICUIC918EXTRACTOR_P_H
class QByteArray;
class QDateTime;
class QJsonArray;
namespace KItinerary {
......@@ -16,7 +15,7 @@ namespace KItinerary {
/** Generic UIC 918 ticket code extractor. */
namespace GenericUic918Extractor
{
void extract(const QByteArray &data, QJsonArray &result, const QDateTime &contextDate);
void extract(const QByteArray &data, QJsonArray &result);
}
}
......
......@@ -92,7 +92,6 @@ QString JsApi::Barcode::decodeDataMatrix(const QVariant &img) const
QVariant JsApi::Barcode::decodeUic9183(const QVariant &s) const
{
Uic9183Parser p;
p.setContextDate(m_contextDate);
p.parse(s.toByteArray());
if (!p.isValid()) {
return {};
......
......@@ -30,7 +30,6 @@ class Uic9183ParserPrivate : public QSharedData
public:
QByteArray m_data;
QByteArray m_payload;
QDateTime m_contextDt;
};
}
......@@ -67,9 +66,8 @@ QVariant Uic9183Parser::block(const QString &name) const
return QVariant::fromValue(findBlock(name.toUtf8().constData()));
}
void Uic9183Parser::setContextDate(const QDateTime &contextDt)
void Uic9183Parser::setContextDate(const QDateTime&)
{
d->m_contextDt = contextDt;
}
void Uic9183Parser::parse(const QByteArray &data)
......@@ -228,7 +226,8 @@ QVariant Uic9183Parser::ticketLayoutVariant() const
Rct2Ticket Uic9183Parser::rct2Ticket() const
{
Rct2Ticket rct2(ticketLayout());
rct2.setContextDate(d->m_contextDt);
const auto u_head = findBlock<Uic9183Head>();
rct2.setContextDate(u_head.issuingDateTime());
return rct2;
}
......
......@@ -56,7 +56,7 @@ public:
/** Date/time this ticket was first encountered.
* This is used to recover a missing year in the ticket data.
*/
void setContextDate(const QDateTime &contextDt);
[[deprecated("calling this is longer needed")]] void setContextDate(const QDateTime&);
void parse(const QByteArray &data);
bool isValid() const;
......
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