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

Remove the last bits of extraction code from ReservationManager

That's now all centralized in ApplicationController.
parent e373f2d1
......@@ -54,6 +54,7 @@ target_link_libraries(itinerary PUBLIC
KPublicTransport
KPim::Itinerary
KPim::PkPass
KF5::Mime
KF5::I18n
KF5::Contacts
KF5::CoreAddons
......@@ -97,7 +98,6 @@ if (ANDROID)
# so androiddeployqt picks them up
target_link_libraries(itinerary PUBLIC Qt::AndroidExtras KAndroidExtras)
target_link_libraries(itinerary-app PRIVATE
KF5::Mime
KF5::Archive
KF5::Kirigami2
Qt::Svg
......
......@@ -52,10 +52,10 @@
#include <QUrl>
#include <QUrlQuery>
#ifdef Q_OS_ANDROID
#include <KMime/Message>
#include <KMime/Types>
#ifdef Q_OS_ANDROID
#include <kandroidextras/activity.h>
#include <kandroidextras/contentresolver.h>
#include <kandroidextras/intent.h>
......@@ -248,7 +248,7 @@ void ApplicationController::importFromIntent(const KAndroidExtras::Intent &inten
msg.assemble();
qDebug().noquote() << msg.encodedContent();
m_resMgr->importReservation(&msg);
importReservation(&msg);
return;
}
......@@ -557,6 +557,13 @@ void ApplicationController::importPass(const QString &passId)
}
}
void ApplicationController::importMimeMessage(KMime::Message *msg)
{
ExtractorEngine engine;
engine.setContent(QVariant::fromValue<KMime::Content*>(msg), u"message/rfc822");
m_resMgr->importReservations(JsonLdDocument::fromJson(engine.extract()));
}
void ApplicationController::addDocument(const QString &batchId, const QUrl &url)
{
if (!url.isValid()) {
......
......@@ -23,6 +23,8 @@ class ExtractorDocumentNode;
class File;
}
namespace KMime { class Message; }
namespace KAndroidExtras {
class Intent;
}
......@@ -88,6 +90,7 @@ private:
bool importBundle(KItinerary::File *file);
bool importHealthCertificateRecursive(const KItinerary::ExtractorDocumentNode &node);
void importPass(const QString &passId);
void importMimeMessage(KMime::Message *msg);
static ApplicationController *s_instance;
......
......@@ -9,7 +9,6 @@
#include "reservationhelper.h"
#include "logging.h"
#include <KItinerary/ExtractorEngine>
#include <KItinerary/ExtractorPostprocessor>
#include <KItinerary/Event>
#include <KItinerary/Flight>
......@@ -19,10 +18,6 @@
#include <KItinerary/SortUtil>
#include <KItinerary/Visit>
#ifdef Q_OS_ANDROID
#include <KMime/Message>
#endif
#include <KLocalizedString>
#include <QDate>
......@@ -141,15 +136,6 @@ QString ReservationManager::batchesBasePath()
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/batches/");
}
#ifdef Q_OS_ANDROID
QVector<QString> ReservationManager::importReservation(KMime::Message *msg)
{
ExtractorEngine engine;
engine.setContent(QVariant::fromValue<KMime::Content*>(msg), u"message/rfc822");
return importReservations(JsonLdDocument::fromJson(engine.extract()));
}
#endif
QVector<QString> ReservationManager::importReservations(const QVector<QVariant> &resData)
{
ExtractorPostprocessor postproc;
......
......@@ -13,10 +13,6 @@
#include <QObject>
#include <QVariant>
namespace KMime { class Message; }
class PkPassManager;
class QUrl;
/** Manages JSON-LD reservation data.
......@@ -53,9 +49,6 @@ public:
* ids that previously existed, in case the extracted elements could be merged.
*/
QVector<QString> importReservations(const QVector<QVariant> &resData);
#ifdef Q_OS_ANDROID
QVector<QString> importReservation(KMime::Message *msg);
#endif
const std::vector<QString>& batches() const;
bool hasBatch(const QString &batchId) const;
......
Supports Markdown
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