Commit 5a8d6e65 authored by Volker Krause's avatar Volker Krause
Browse files

Remove conditional KCalendarCore usage

That is a required dependency meanwhile, so we don't need this anymore.
parent 10457390
Pipeline #198755 passed with stage
in 4 minutes and 33 seconds
......@@ -81,9 +81,6 @@ if (TARGET ZXing::ZXing OR TARGET ZXing::Core)
set(HAVE_ZXING ON)
endif()
if (TARGET KF5::CalendarCore)
set(HAVE_KCAL ON)
endif()
if (LIBXML2_FOUND)
set(HAVE_LIBXML2 ON)
endif()
......
......@@ -7,9 +7,7 @@
include(CMakeFindDependencyMacro)
find_dependency(Qt@QT_MAJOR_VERSION@Gui "@QT_REQUIRED_VERSION@")
find_dependency(KF5Mime "@KMIME_VERSION@")
if (@HAVE_KCAL@)
find_dependency(KF5CalendarCore "@KF5_MIN_VERSION@")
endif()
find_dependency(KF5CalendarCore "@KF5_MIN_VERSION@")
find_dependency(KF5Contacts "@KF5_MIN_VERSION@")
find_dependency(KPimPkPass "@PIM_PKPASS@")
......
......@@ -35,9 +35,7 @@ ecm_add_test(addressparsertest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KP
ecm_add_test(timefindertest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary)
ecm_add_test(postprocessortest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary)
ecm_add_test(extractorvalidatortest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary)
if (TARGET KF5::CalendarCore)
ecm_add_test(calendarhandlertest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary KF5::Contacts)
ecm_add_test(extractortest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary KPim::PkPass)
endif()
ecm_add_test(calendarhandlertest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary KF5::Contacts KF5::CalendarCore)
ecm_add_test(extractortest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary KPim::PkPass)
ecm_add_test(documentutiltest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary)
ecm_add_test(filetest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KPim::Itinerary KPim::PkPass)
......@@ -11,6 +11,7 @@ target_include_directories(kitinerary-extractor PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(kitinerary-extractor
KPimItinerary
KPim::PkPass
KF5::CalendarCore
)
option(KITINERARY_STANDALONE_CLI_EXTRACTOR "Build stand-alone command line extractor (this should be off, unless you are building the dedicated Flatpak for this" OFF)
......
......@@ -178,6 +178,7 @@ target_link_libraries(KPimItinerary
KF5::Archive
KF5::I18n
KF5::I18nLocaleData
KF5::CalendarCore
KF5::Codecs
KF5::Contacts
KPim::PkPass
......@@ -195,9 +196,6 @@ elseif (TARGET ZXing::Core)
target_link_libraries(KPimItinerary PRIVATE ZXing::Core)
endif()
if (HAVE_KCAL)
target_link_libraries(KPimItinerary PUBLIC KF5::CalendarCore)
endif()
if (HAVE_LIBXML2)
target_compile_definitions(KPimItinerary PRIVATE ${LIBXML2_DEFINITIONS})
target_include_directories(KPimItinerary PRIVATE ${LIBXML2_INCLUDE_DIR})
......
......@@ -24,11 +24,9 @@
#include <KItinerary/TrainTrip>
#include <KItinerary/Visit>
#if HAVE_KCAL
#include <KCalendarCore/Alarm>
#include <KCalendarCore/Calendar>
#include <KCalendarCore/Event>
#endif
#include <KContacts/Address>
......@@ -50,7 +48,6 @@ static QString formatAddressSingleLine(const PostalAddress &addr)
return LocationUtil::toAddress(addr).formatted(KContacts::AddressFormatStyle::SingleLineInternational);
}
#if HAVE_KCAL
using namespace KCalendarCore;
static void fillFlightReservation(const QVector<QVariant> &reservations, const KCalendarCore::Event::Ptr &event);
static void fillTrainReservation(const TrainReservation &reservation, const KCalendarCore::Event::Ptr &event);
......@@ -62,22 +59,14 @@ static void fillGeoPosition(const QVariant &place, const KCalendarCore::Event::P
static void fillFoodReservation(const FoodEstablishmentReservation &reservation, const KCalendarCore::Event::Ptr &event);
static void fillRentalCarReservation(const RentalCarReservation &reservation, const KCalendarCore::Event::Ptr &event);
static void fillTaxiReservation(const TaxiReservation &reservation, const KCalendarCore::Event::Ptr &event);
#endif
QVector<QSharedPointer<KCalendarCore::Event>> CalendarHandler::findEvents(const QSharedPointer<KCalendarCore::Calendar> &calendar, const QVariant &reservation)
{
#if HAVE_KCAL
return findEvents(calendar.data(), reservation);
#else
Q_UNUSED(calendar)
Q_UNUSED(reservation)
return {};
#endif
}
QVector<QSharedPointer<KCalendarCore::Event>> CalendarHandler::findEvents(KCalendarCore::Calendar *calendar, const QVariant &reservation)
{
#if HAVE_KCAL
if (!(JsonLd::canConvert<Reservation>(reservation) || JsonLd::canConvert<KItinerary::Event>(reservation)) || !calendar) {
return {};
}
......@@ -111,28 +100,17 @@ QVector<QSharedPointer<KCalendarCore::Event>> CalendarHandler::findEvents(KCalen
}
return results;
#else
Q_UNUSED(calendar)
Q_UNUSED(reservation)
return {};
#endif
}
QVector<QVariant> CalendarHandler::reservationsForEvent(const QSharedPointer<KCalendarCore::Event> &event)
{
#if HAVE_KCAL
const auto payload = event->customProperty("KITINERARY", "RESERVATION").toUtf8();
const auto json = QJsonDocument::fromJson(payload).array();
return JsonLdDocument::fromJson(json);
#else
Q_UNUSED(event)
return {};
#endif
}
bool CalendarHandler::canCreateEvent(const QVariant &reservation)
{
#if HAVE_KCAL
if (JsonLd::isA<FlightReservation>(reservation)) {
const auto f = reservation.value<FlightReservation>().reservationFor().value<Flight>();
if (f.departureTime().isValid() && f.arrivalTime().isValid()) {
......@@ -140,10 +118,6 @@ bool CalendarHandler::canCreateEvent(const QVariant &reservation)
}
}
return SortUtil::startDateTime(reservation).isValid();
#else
Q_UNUSED(reservation)
return false;
#endif
}
void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSharedPointer<KCalendarCore::Event> &event)
......@@ -152,7 +126,6 @@ void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSh
return;
}
#if HAVE_KCAL
// TODO pass reservationS into all functions below for multi-traveler support
const auto &reservation = reservations.at(0);
const int typeId = reservation.userType();
......@@ -190,12 +163,8 @@ void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSh
const auto payload = QJsonDocument(JsonLdDocument::toJson(reservations)).toJson(QJsonDocument::Compact);
event->setCustomProperty("KITINERARY", "RESERVATION", QString::fromUtf8(payload));
#else
Q_UNUSED(event)
#endif
}
#if HAVE_KCAL
static QString airportDisplayCode(const Airport &airport)
{
return airport.iataCode().isEmpty() ? airport.name() : airport.iataCode();
......@@ -525,4 +494,3 @@ static void fillTaxiReservation(const TaxiReservation &reservation, const KCalen
event->setDescription(description);
}
#endif
......@@ -33,7 +33,6 @@
#endif
#endif
#cmakedefine01 HAVE_KCAL
#cmakedefine01 HAVE_LIBXML2
#cmakedefine01 HAVE_PHONENUMBER
......
......@@ -11,9 +11,7 @@
#include <KItinerary/ExtractorRepository>
#if HAVE_KCAL
#include <kcalendarcore_version.h>
#endif
#include <QString>
......@@ -35,13 +33,7 @@ QString ExtractorCapabilities::capabilitiesString()
"PDF support : poppler (" KPOPPLER_VERSION_STRING ")\n"
"iCal support : "
#if HAVE_KCAL
"kcal (" KCALENDARCORE_VERSION_STRING ")"
#else
"not available"
#endif
"\n"
"iCal support : kcal (" KCALENDARCORE_VERSION_STRING ")\n"
"Barcode decoder : "
#if HAVE_ZXING
......
......@@ -4,7 +4,6 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "config-kitinerary.h"
#include "icaldocumentprocessor.h"
#include "logging.h"
......@@ -13,10 +12,8 @@
#include <KItinerary/ExtractorFilter>
#include <KItinerary/ExtractorResult>
#if HAVE_KCAL
#include <KCalendarCore/ICalFormat>
#include <KCalendarCore/MemoryCalendar>
#endif
#include <QJSEngine>
#include <QJSValue>
......@@ -52,7 +49,6 @@ bool IcalCalendarProcessor::canHandleData(const QByteArray &encodedData, QString
ExtractorDocumentNode IcalCalendarProcessor::createNodeFromData(const QByteArray &encodedData) const
{
#if HAVE_KCAL
KCalendarCore::Calendar::Ptr calendar(new KCalendarCore::MemoryCalendar(QTimeZone::systemTimeZone()));
KCalendarCore::ICalFormat format;
if (format.fromRawString(calendar, encodedData)) {
......@@ -63,48 +59,35 @@ ExtractorDocumentNode IcalCalendarProcessor::createNodeFromData(const QByteArray
} else {
qCDebug(Log) << "Failed to parse iCal content.";
}
#endif
return {};
}
void IcalCalendarProcessor::expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const
{
#if HAVE_KCAL
const auto cal = node.content<KCalendarCore::Calendar::Ptr>();
for (const auto &event : cal->events()) {
auto child = engine->documentNodeFactory()->createNode(QVariant::fromValue(event), u"internal/event");
node.appendChild(child);
}
#endif
}
bool IcalEventProcessor::matches(const ExtractorFilter &filter, const ExtractorDocumentNode &node) const
{
#if HAVE_KCAL
const auto event = node.content<KCalCore::Event::Ptr>();
return matchesGadget(filter, event.data());
#else
return false;
#endif
}
void IcalEventProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_unused]] const ExtractorEngine *engine) const
{
#if HAVE_KCAL
const auto event = node.content<KCalCore::Event::Ptr>();
const auto data = event->customProperty("KITINERARY", "RESERVATION");
if (!data.isEmpty()) {
node.addResult(QJsonDocument::fromJson(data.toUtf8()).array());
}
#endif
}
QJSValue IcalEventProcessor::contentToScriptValue(const ExtractorDocumentNode &node, QJSEngine *engine) const
{
#if HAVE_KCAL
return engine->toScriptValue(*node.content<KCalendarCore::Event::Ptr>().data());
#else
return {};
#endif
}
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