Commit 76adaee8 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Import Akonadi Serializer plugin for KAlarm from kdepim-runtime

See commit cde643e6d840d591b6ae1b7f1a49488c495c4774 in kdepim-runtime
for details.
parent 7eba9639
......@@ -26,6 +26,7 @@ include(ECMCoverageOption)
set(KALARM_LIB_VERSION ${PIM_VERSION})
set(CALENDARCORE_LIB_VERSION "5.7.40")
set(CALENDARUTILS_LIB_VERSION "5.7.40")
set(HOLIDAY_LIB_VERSION "5.7.40")
set(IDENTITYMANAGER_LIB_VERSION "5.7.40")
set(AKONADI_LIB_VERSION "5.7.40")
......@@ -42,6 +43,7 @@ find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarCore ${CALENDARCORE_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5IdentityManagement ${IDENTITYMANAGER_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Holidays ${HOLIDAY_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED)
add_definitions(-DTRANSLATION_DOMAIN=\"libkalarmcal5\")
add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
......@@ -49,6 +51,7 @@ add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
########### Targets ###########
add_subdirectory(src)
add_subdirectory(serializers)
########### CMake Config Files ###########
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5AlarmCalendar")
......
org.kde.pim.kalarmcal kalarmcal (kalarmcal)
org.kde.pim.akonadi_serializer_kalarm kalarmcal (akonadi_serializer_kalarmcal)
add_definitions(-DTRANSLATION_DOMAIN=\"libkalarmcal5-serializer\")
set(akonadi_serializer_kalarm_SRCS
akonadi_serializer_kalarm.cpp
kaeventformatter.cpp
)
ecm_qt_declare_logging_category(akonadi_serializer_kalarm_SRCS
HEADER akonadi_serializer_kalarm_debug.h
IDENTIFIER AKONADI_SERIALIZER_KALARM_LOG
CATEGORY_NAME org.kde.pim.akonadi_serializer_kalarm
)
add_library(akonadi_serializer_kalarm MODULE ${akonadi_serializer_kalarm_SRCS})
target_link_libraries(akonadi_serializer_kalarm
KF5::AlarmCalendar
KF5::CalendarCore
KF5::CalendarUtils
KF5::AkonadiCore
)
install(TARGETS akonadi_serializer_kalarm
DESTINATION ${KDE_INSTALL_PLUGINDIR}
)
install(FILES akonadi_serializer_kalarm.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/akonadi/plugins/serializer
)
#!/bin/sh
$XGETTEXT `find . -name "*.cpp"` -o $podir/libkalarmcal5-serializer.pot
/*
* akonadi_serializer_kalarm.cpp - Akonadi resource serializer for KAlarm
* Copyright © 2009-2012 by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "akonadi_serializer_kalarm.h"
#include "kaeventformatter.h"
#include "akonadi_serializer_kalarm_debug.h"
#include "eventattribute.h"
#include "kacalendar.h"
#include "kaevent.h"
#include <AkonadiCore/item.h>
#include <AkonadiCore/abstractdifferencesreporter.h>
#include <AkonadiCore/attributefactory.h>
#include <klocale.h>
#include <qplugin.h>
using namespace Akonadi;
using namespace KAlarmCal;
// Convert from backend data stream to a KAEvent, and set it into the item's payload.
bool SerializerPluginKAlarm::deserialize(Item &item, const QByteArray &label, QIODevice &data, int version)
{
Q_UNUSED(version);
if (label != Item::FullPayload) {
return false;
}
KCalCore::Incidence::Ptr i = mFormat.fromString(QString::fromUtf8(data.readAll()));
if (!i) {
qCWarning(AKONADI_SERIALIZER_KALARM_LOG) << "Failed to parse incidence!";
data.seek(0);
qCWarning(AKONADI_SERIALIZER_KALARM_LOG) << QString::fromUtf8(data.readAll());
return false;
}
if (i->type() != KCalCore::Incidence::TypeEvent) {
qCWarning(AKONADI_SERIALIZER_KALARM_LOG) << "Incidence with uid" << i->uid() << "is not an Event!";
data.seek(0);
return false;
}
KAEvent event(i.staticCast<KCalCore::Event>());
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty() || !event.isValid()) {
qCWarning(AKONADI_SERIALIZER_KALARM_LOG) << "Event with uid" << event.id() << "contains no usable alarms!";
data.seek(0);
return false;
}
event.setItemId(item.id());
// Set additional event data contained in attributes
if (mRegistered.isEmpty()) {
AttributeFactory::registerAttribute<KAlarmCal::EventAttribute>();
mRegistered = QStringLiteral("x"); // set to any non-null string
}
const EventAttribute dummy;
if (item.hasAttribute(dummy.type())) {
Attribute *a = item.attribute(dummy.type());
if (!a) {
qCCritical(AKONADI_SERIALIZER_KALARM_LOG) << "deserialize(): Event with uid" << event.id() << "contains null attribute";
} else {
EventAttribute *evAttr = dynamic_cast<EventAttribute *>(a);
if (!evAttr) {
// Registering EventAttribute doesn't work in the serializer
// unless the application also registers it. This doesn't
// matter unless the application uses KAEvent class.
qCCritical(AKONADI_SERIALIZER_KALARM_LOG) << "deserialize(): Event with uid" << event.id()
<< "contains unknown type EventAttribute (application must call AttributeFactory::registerAttribute())";
} else {
KAEvent::CmdErrType err = evAttr->commandError();
event.setCommandError(err);
}
}
}
item.setMimeType(mime);
item.setPayload<KAEvent>(event);
return true;
}
// Convert an item's KAEvent payload to backend data stream.
void SerializerPluginKAlarm::serialize(const Item &item, const QByteArray &label, QIODevice &data, int &version)
{
Q_UNUSED(version);
if (label != Item::FullPayload || !item.hasPayload<KAEvent>()) {
return;
}
const KAEvent e = item.payload<KAEvent>();
KCalCore::Event::Ptr kcalEvent(new KCalCore::Event);
e.updateKCalEvent(kcalEvent, KAEvent::UID_SET);
QByteArray head = "BEGIN:VCALENDAR\nPRODID:";
head += KACalendar::icalProductId();
head += "\nVERSION:2.0\nX-KDE-KALARM-VERSION:";
head += KAEvent::currentCalendarVersionString();
head += '\n';
data.write(head);
data.write(mFormat.toString(kcalEvent.staticCast<KCalCore::Incidence>()).toUtf8());
data.write("\nEND:VCALENDAR");
}
void SerializerPluginKAlarm::compare(AbstractDifferencesReporter *reporter, const Item &left, const Item &right)
{
Q_ASSERT(reporter);
Q_ASSERT(left.hasPayload<KAEvent>());
Q_ASSERT(right.hasPayload<KAEvent>());
KAEvent eventL = left.payload<KAEvent>();
KAEvent eventR = right.payload<KAEvent>();
// Note that event attributes are not included, since they are not part of the payload
mValueL = KAEventFormatter(eventL, false);
mValueR = KAEventFormatter(eventR, false);
reporter->setLeftPropertyValueTitle(i18nc("@title:column", "Changed Alarm"));
reporter->setRightPropertyValueTitle(i18nc("@title:column", "Conflicting Alarm"));
reportDifference(reporter, KAEventFormatter::Id);
if (eventL.revision() != eventR.revision()) {
reportDifference(reporter, KAEventFormatter::Revision);
}
if (eventL.actionSubType() != eventR.actionSubType()) {
reportDifference(reporter, KAEventFormatter::AlarmType);
}
if (eventL.category() != eventR.category()) {
reportDifference(reporter, KAEventFormatter::AlarmCategory);
}
if (eventL.templateName() != eventR.templateName()) {
reportDifference(reporter, KAEventFormatter::TemplateName);
}
if (eventL.createdDateTime() != eventR.createdDateTime()) {
reportDifference(reporter, KAEventFormatter::CreatedTime);
}
if (eventL.startDateTime() != eventR.startDateTime()) {
reportDifference(reporter, KAEventFormatter::StartTime);
}
if (eventL.templateAfterTime() != eventR.templateAfterTime()) {
reportDifference(reporter, KAEventFormatter::TemplateAfterTime);
}
if (*eventL.recurrence() != *eventR.recurrence()) {
reportDifference(reporter, KAEventFormatter::Recurrence);
}
if (eventL.mainDateTime(true) != eventR.mainDateTime(true)) {
reportDifference(reporter, KAEventFormatter::NextRecurrence);
}
if (eventL.repetition() != eventR.repetition()) {
reportDifference(reporter, KAEventFormatter::SubRepetition);
}
if (eventL.repetition().interval() != eventR.repetition().interval()) {
reportDifference(reporter, KAEventFormatter::RepeatInterval);
}
if (eventL.repetition().count() != eventR.repetition().count()) {
reportDifference(reporter, KAEventFormatter::RepeatCount);
}
if (eventL.nextRepetition() != eventR.nextRepetition()) {
reportDifference(reporter, KAEventFormatter::NextRepetition);
}
if (eventL.holidaysExcluded() != eventR.holidaysExcluded()) {
reportDifference(reporter, KAEventFormatter::HolidaysExcluded);
}
if (eventL.workTimeOnly() != eventR.workTimeOnly()) {
reportDifference(reporter, KAEventFormatter::WorkTimeOnly);
}
if (eventL.lateCancel() != eventR.lateCancel()) {
reportDifference(reporter, KAEventFormatter::LateCancel);
}
if (eventL.autoClose() != eventR.autoClose()) {
reportDifference(reporter, KAEventFormatter::AutoClose);
}
if (eventL.copyToKOrganizer() != eventR.copyToKOrganizer()) {
reportDifference(reporter, KAEventFormatter::CopyKOrganizer);
}
if (eventL.enabled() != eventR.enabled()) {
reportDifference(reporter, KAEventFormatter::Enabled);
}
if (eventL.isReadOnly() != eventR.isReadOnly()) {
reportDifference(reporter, KAEventFormatter::ReadOnly);
}
if (eventL.toBeArchived() != eventR.toBeArchived()) {
reportDifference(reporter, KAEventFormatter::Archive);
}
if (eventL.customProperties() != eventR.customProperties()) {
reportDifference(reporter, KAEventFormatter::CustomProperties);
}
if (eventL.message() != eventR.message()) {
reportDifference(reporter, KAEventFormatter::MessageText);
}
if (eventL.fileName() != eventR.fileName()) {
reportDifference(reporter, KAEventFormatter::MessageFile);
}
if (eventL.fgColour() != eventR.fgColour()) {
reportDifference(reporter, KAEventFormatter::FgColour);
}
if (eventL.bgColour() != eventR.bgColour()) {
reportDifference(reporter, KAEventFormatter::BgColour);
}
if (eventL.font() != eventR.font()) {
reportDifference(reporter, KAEventFormatter::Font);
}
if (eventL.preAction() != eventR.preAction()) {
reportDifference(reporter, KAEventFormatter::PreAction);
}
if ((eventL.extraActionOptions() & KAEvent::CancelOnPreActError) != (eventR.extraActionOptions() & KAEvent::CancelOnPreActError)) {
reportDifference(reporter, KAEventFormatter::PreActionCancel);
}
if ((eventL.extraActionOptions() & KAEvent::DontShowPreActError) != (eventR.extraActionOptions() & KAEvent::DontShowPreActError)) {
reportDifference(reporter, KAEventFormatter::PreActionNoError);
}
if (eventL.postAction() != eventR.postAction()) {
reportDifference(reporter, KAEventFormatter::PostAction);
}
if (eventL.confirmAck() != eventR.confirmAck()) {
reportDifference(reporter, KAEventFormatter::ConfirmAck);
}
if (eventL.kmailSerialNumber() != eventR.kmailSerialNumber()) {
reportDifference(reporter, KAEventFormatter::KMailSerial);
}
if (eventL.beep() != eventR.beep()
|| eventL.speak() != eventR.speak()
|| eventL.audioFile() != eventR.audioFile()) {
reportDifference(reporter, KAEventFormatter::Sound);
}
if (eventL.repeatSound() != eventR.repeatSound()) {
reportDifference(reporter, KAEventFormatter::SoundRepeat);
}
if (eventL.soundVolume() != eventR.soundVolume()) {
reportDifference(reporter, KAEventFormatter::SoundVolume);
}
if (eventL.fadeVolume() != eventR.fadeVolume()) {
reportDifference(reporter, KAEventFormatter::SoundFadeVolume);
}
if (eventL.fadeSeconds() != eventR.fadeSeconds()) {
reportDifference(reporter, KAEventFormatter::SoundFadeTime);
}
if (eventL.reminderMinutes() != eventR.reminderMinutes()) {
reportDifference(reporter, KAEventFormatter::Reminder);
}
if (eventL.reminderOnceOnly() != eventR.reminderOnceOnly()) {
reportDifference(reporter, KAEventFormatter::ReminderOnce);
}
if (eventL.deferred() != eventR.deferred()) {
reportDifference(reporter, KAEventFormatter::DeferralType);
}
if (eventL.deferDateTime() != eventR.deferDateTime()) {
reportDifference(reporter, KAEventFormatter::DeferralTime);
}
if (eventL.deferDefaultMinutes() != eventR.deferDefaultMinutes()) {
reportDifference(reporter, KAEventFormatter::DeferDefault);
}
if (eventL.deferDefaultDateOnly() != eventR.deferDefaultDateOnly()) {
reportDifference(reporter, KAEventFormatter::DeferDefaultDate);
}
if (eventL.command() != eventR.command()) {
reportDifference(reporter, KAEventFormatter::Command);
}
if (eventL.logFile() != eventR.logFile()) {
reportDifference(reporter, KAEventFormatter::LogFile);
}
if (eventL.commandXterm() != eventR.commandXterm()) {
reportDifference(reporter, KAEventFormatter::CommandXTerm);
}
if (eventL.emailSubject() != eventR.emailSubject()) {
reportDifference(reporter, KAEventFormatter::EmailSubject);
}
if (eventL.emailFromId() != eventR.emailFromId()) {
reportDifference(reporter, KAEventFormatter::EmailFromId);
}
if (eventL.emailAddresses() != eventR.emailAddresses()) {
reportDifference(reporter, KAEventFormatter::EmailTo);
}
if (eventL.emailBcc() != eventR.emailBcc()) {
reportDifference(reporter, KAEventFormatter::EmailBcc);
}
if (eventL.emailMessage() != eventR.emailMessage()) {
reportDifference(reporter, KAEventFormatter::EmailBody);
}
if (eventL.emailAttachments() != eventR.emailAttachments()) {
reportDifference(reporter, KAEventFormatter::EmailAttachments);
}
KLocale *locale = KLocale::global();
reporter->addProperty(AbstractDifferencesReporter::ConflictMode, i18nc("@label", "Item revision"),
locale->convertDigits(QString::number(left.revision()), locale->digitSet()),
locale->convertDigits(QString::number(right.revision()), locale->digitSet()));
}
void SerializerPluginKAlarm::reportDifference(AbstractDifferencesReporter *reporter, KAEventFormatter::Parameter id)
{
if (mValueL.isApplicable(id) || mValueR.isApplicable(id)) {
reporter->addProperty(AbstractDifferencesReporter::ConflictMode, KAEventFormatter::label(id), mValueL.value(id), mValueR.value(id));
}
}
QString SerializerPluginKAlarm::extractGid(const Item &item) const
{
return item.hasPayload<KAEvent>() ? item.payload<KAEvent>().id() : QString();
}
[Misc]
Name=KAlarm Event Serializer
Name[ar]=مُسلسِل «منبّهك» للأحداث
Name[bs]=KAlarm događajni serializer
Name[ca]=Serialitzador d'esdeveniments del KAlarm
Name[ca@valencia]=Serialitzador d'esdeveniments del KAlarm
Name[da]=Serieordning af KAlarm-hændelser
Name[de]=Kalarm Ereignis-Serialisierung
Name[el]=Σειριακοποιητής γεγονότων KAlarm
Name[en_GB]=KAlarm Event Serialiser
Name[es]=Serializador de eventos de KAlarm
Name[et]=KAlarmi sündmuste jadasti
Name[fi]=KAlarm-tapahtumasarjoittaja
Name[fr]=Sérialiseur d'évènements KAlarm
Name[ga]=Srathóir Imeachtaí KAlarm
Name[gl]=Serializador de eventos de KAlarm
Name[hu]=KAlarm eseménykezelő
Name[ia]=Divulgator partial de evento de KAlarm
Name[it]=Serializzatore degli eventi di KAlarm
Name[ja]=KAlarm イベント用シリアライザ
Name[kk]=KAlarm оқиғалар тізбектеуіші
Name[km]=កម្មវិធី​បោះពុម្ព​ព្រឹត្តិការណ៍ KAlarm
Name[ko]=KAlarm 이벤트 시리얼라이저
Name[lt]=KAlarm įvykių serializatorius
Name[lv]=KAlarm notikumu serializētājs
Name[nb]=KAlarm hendelsesserialisator
Name[nds]=KAlarm-Begeefnis-Reegmoduul
Name[nl]=KAlarm gebeurtenissen in volgorde zetten
Name[nn]=Serialisator for KAlarm-hendingar
Name[pa]=ਕੇਅਲਾਰਮ ਈਵੈਂਟ ਸੀਰੀਅਲਾਈਜ਼ਰ
Name[pl]=Szeregowanie zdarzeń KAlarm
Name[pt]=Serializador de Eventos do KAlarm
Name[pt_BR]=Serializador de eventos do KAlarm
Name[ru]=Сохранение событий KAlarm
Name[sk]=Serializátor udalostí KAlarm
Name[sl]=Razvrščevalnik dogodkov KAlarm v zaporedje
Name[sr]=Серијализатор К‑алармових догађаја
Name[sr@ijekavian]=Серијализатор К‑алармових догађаја
Name[sr@ijekavianlatin]=Serijalizator K‑alarmovih događaja
Name[sr@latin]=Serijalizator K‑alarmovih događaja
Name[sv]=Kalarm händelseserialisering
Name[tr]=KAlarm Olay Sıralandırıcı
Name[uk]=Серіалізатор подій KAlarm
Name[x-test]=xxKAlarm Event Serializerxx
Name[zh_CN]=KAlarm 事件序列器
Name[zh_TW]=KAlarm 事件序列器
Comment=An Akonadi serializer plugin for KAlarm events
Comment[ar]=ملحقة سَلسَلة «أكونادي» لأحداث «منبّهك»
Comment[bs]=Akonadi serializirajući dodatak za KAlarm događaje
Comment[ca]=Un connector de serialització de l'Akonadi pels esdeveniments del KAlarm
Comment[ca@valencia]=Un connector de serialització de l'Akonadi pels esdeveniments del KAlarm
Comment[da]=Et Akonadi-plugin til serieordning af KAlarm-hændelser
Comment[de]=Akonadi-Modul zur Serialisierung von KAlarm-Ereignissen
Comment[el]=Ένα πρόσθετο σειριακοποιητή Akonadi για γεγονότα KAlarm
Comment[en_GB]=An Akonadi serialiser plugin for KAlarm events
Comment[es]=Un complemento serializador de Akonadi para eventos de KAlarm
Comment[et]=Akonadi KAlarmi sündmuste jadastamisplugin
Comment[fi]=Akonadi-sarjoitusliitännäinen KAlarmin tapahtumille
Comment[fr]=Un module externe Akonadi pour la sérialisation des évènements KAlarm
Comment[ga]=Breiseán srathóra Akonadi le haghaidh imeachtaí KAlarm
Comment[gl]=Un complemento serializador de Akonadi para os eventos de KAlarm
Comment[hu]=Akonadi modul KAlarm események kezeléséhez
Comment[ia]=Un plug-in de Akonadi pro divulgar partialmente eventos de alarmas in KAlarm
Comment[it]=Un'estensione di Akonadi per la serializzazione di eventi di KAlarm
Comment[ja]=KAlarm のイベントのための Akonadi シリアライザプラグイン
Comment[kk]=KAlarm оқиғалардың Akonadi тізбектеуіш плагині
Comment[km]=កម្មវិធី​ជំនួយ​​របស់​កម្មវិធី​បោះពុម្ព Akonadi សម្រាប់​ព្រឹត្តិការណ៍ KAlarm
Comment[ko]=KAlarm 이벤트를 위한 Akonadi 시리얼라이저 플러그인
Comment[lt]=Akonadi serializatoriaus papildinys KAlarm įvykiai
Comment[lv]=Akonadi KAlarm notikumu serializēšanas spraudnis
Comment[nb]=Et Akonadi programtillegg for serialisering av KAlarm-hendelser
Comment[nds]=Akonadi-Inreegmoduul för KAlarm-Begeefnissen
Comment[nl]=Een Akonadi-plugin voor het in volgorde zetten van KAlarm gebeurtenissen
Comment[nn]=Eit Akonadi-serialisatortillegg for KAlarm-hendingar
Comment[pl]=Wtyczka Akonadi do szeregowania zdarzeń KAlarm
Comment[pt]=Um 'plugin' de serialização do Akonadi para os eventos do KAlarm
Comment[pt_BR]=Um plugin de serialização do Akonadi para eventos do KAlarm
Comment[ru]=Модуль Akonadi сохранения событий KAlarm
Comment[sk]=Plugin serializátora Akonadi pre udalosti KAlarm
Comment[sl]=Akonadijev vstavek za razvrščanje predmetov dogodkov KAlarm v zaporedje
Comment[sr]=Аконадијев прикључак серијализатора за К‑алармове догађаје
Comment[sr@ijekavian]=Аконадијев прикључак серијализатора за К‑алармове догађаје
Comment[sr@ijekavianlatin]=Akonadijev priključak serijalizatora za K‑alarmove događaje
Comment[sr@latin]=Akonadijev priključak serijalizatora za K‑alarmove događaje
Comment[sv]=Ett insticksprogram till Akonadi för serialisering av Kalarm-händelser
Comment[tr]=KAlarm olayları için bir Akonadi sıralandırıcısı
Comment[uk]=Додаток серіалізації Akonadi для подій KAlarm
Comment[x-test]=xxAn Akonadi serializer plugin for KAlarm eventsxx
Comment[zh_CN]=用于操作 KAlarm 事件的 Akonadi 序列插件
Comment[zh_TW]=KAlarm 事件使用的 Akonadi 序列器外掛程式
[Plugin]
Type=application/x-vnd.kde.alarm,application/x-vnd.kde.alarm.active,application/x-vnd.kde.alarm.archived,application/x-vnd.kde.alarm.template
X-Akonadi-Class=default;KAlarmCal::KAEvent;
X-KDE-Library=akonadi_serializer_kalarm
X-KDE-ClassName=SerializerPluginKAlarm
/*
* akonadi_serializer_kalarm.h - Akonadi resource serializer for KAlarm
* Copyright © 2009-2014 by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef AKONADI_SERIALIZER_KALARM_H
#define AKONADI_SERIALIZER_KALARM_H
#include "kaeventformatter.h"
#include <AkonadiCore/itemserializerplugin.h>
#include <AkonadiCore/differencesalgorithminterface.h>
#include <AkonadiCore/gidextractorinterface.h>
#include <KCalCore/ICalFormat>
#include <QObject>
namespace Akonadi {
class Item;
class AbstractDifferencesReporter;
}
class SerializerPluginKAlarm : public QObject, public Akonadi::ItemSerializerPlugin, public Akonadi::DifferencesAlgorithmInterface, public Akonadi::GidExtractorInterface
{
Q_OBJECT
Q_INTERFACES(Akonadi::ItemSerializerPlugin)
Q_INTERFACES(Akonadi::DifferencesAlgorithmInterface)
Q_INTERFACES(Akonadi::GidExtractorInterface)
Q_PLUGIN_METADATA(IID "org.kde.akonadi.SerializerPluginKAlarm")
public:
bool deserialize(Akonadi::Item &item, const QByteArray &label, QIODevice &data, int version) override;
void serialize(const Akonadi::Item &item, const QByteArray &label, QIODevice &data, int &version) override;
void compare(Akonadi::AbstractDifferencesReporter *, const Akonadi::Item &left, const Akonadi::Item &right) override;
QString extractGid(const Akonadi::Item &item) const override;
private:
void reportDifference(Akonadi::AbstractDifferencesReporter *, KAEventFormatter::Parameter);
KCalCore::ICalFormat mFormat;
KAEventFormatter mValueL;
KAEventFormatter mValueR;
QString mRegistered;
};
#endif // AKONADI_SERIALIZER_KALARM_H
/*
* kaeventformatter.cpp - converts KAlarmCal::KAEvent properties to text
* Copyright © 2010,2011 by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#include "kaeventformatter.h"
#include "kacalendar.h"
#include "kaevent.h"
#include "datetime.h"
#include <kcalutils/incidenceformatter.h>
#include <kglobal.h>
#include <kdatetime.h>
#include <KLocale>
static QString trueFalse(bool value);
static QString number(unsigned long n);
static QString minutes(int n);
static QString minutesHoursDays(int minutes);
static QString dateTime(const KDateTime &);
KAEventFormatter::KAEventFormatter(const KAEvent &e, bool falseForUnspecified)
: mEvent(e)
{
if (falseForUnspecified) {
mUnspecifiedValue = trueFalse(false);
}
}
QString KAEventFormatter::label(Parameter param)
{
switch (param) {
case Id:
return i18nc("@label Unique identifier", "UID");
case AlarmType:
return i18nc("@label", "Alarm type");
case AlarmCategory:
return i18nc("@label", "Alarm status");
case TemplateName:
return i18nc("@label", "Template name");
case CreatedTime:
return i18nc("@label", "Creation time");
case StartTime:
return i18nc("@label", "Start time");
case TemplateAfterTime:
return i18nc("@label Start delay configured in an alarm template", "Template after time");
case Recurs:
return i18nc("@label", "Recurs");
case Recurrence: