Commit 2dd9340b authored by David Jarvie's avatar David Jarvie
Browse files

Convert merged kalarmcal files for use within kalarm repo

parent 1681114a
/*
* akonadi.cpp - Akonadi object functions
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2011, 2019 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -39,3 +40,5 @@ bool setItemPayload(Akonadi::Item &item, const KAEvent &event, const QStringList
}
}
// vim: et sw=4:
/*
* akonadi.h - Akonadi object functions
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2011, 2019 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -12,6 +13,7 @@
#include "kalarmcal_export.h"
#include <QStringList>
namespace Akonadi
{
class Item;
......@@ -34,3 +36,4 @@ KALARMCAL_EXPORT bool setItemPayload(Akonadi::Item &item, const KAEvent &event,
}
// vim: et sw=4:
/*
* alarmtext.cpp - text/email alarm text conversion
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2004-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......
/*
* alarmtext.h - text/email alarm text conversion
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2004-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -198,5 +199,4 @@ private:
} // namespace KAlarmCal
// vim: et sw=4:
......@@ -11,7 +11,10 @@ macro(macro_unit_tests)
add_test(NAME ${_testname} COMMAND ${_testname})
ecm_mark_as_test(${_testname})
target_link_libraries(${_testname}
KF5AlarmCalendar
KF5::AkonadiCore
KF5::CalendarCore
KF5::Holidays
kalarmprivate
Qt${QT_MAJOR_VERSION}::DBus
Qt${QT_MAJOR_VERSION}::Test)
endforeach()
......
/*
* datetime.cpp - date/time with start-of-day time for date-only values
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2003-2019 David Jarvie <djarvie@kde.org>
* Program: kalarm
* SPDX-FileCopyrightText: 2003-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "datetime.h"
#include <QTimeZone>
......@@ -261,21 +263,11 @@ qint64 DateTime::toSecsSinceEpoch() const
return d->mDateTime.toSecsSinceEpoch();
}
uint DateTime::toTime_t() const
{
return d->mDateTime.toTime_t();
}
void DateTime::setSecsSinceEpoch(qint64 secs)
{
d->mDateTime.setSecsSinceEpoch(secs);
}
void DateTime::setTime_t(uint secs)
{
d->mDateTime.setTime_t(secs);
}
DateTime DateTime::addSecs(qint64 n) const
{
return DateTime(d->mDateTime.addSecs(n));
......
/*
* datetime.h - date/time with start-of-day time for date-only values
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2003-2019 David Jarvie <djarvie@kde.org>
* Program: kalarm
* SPDX-FileCopyrightText: 2003-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "kalarmcal_export.h"
#include "kadatetime.h"
#include "kalarmcal_export.h"
namespace KAlarmCal
{
......@@ -175,22 +175,12 @@ public:
* 1st January 1970 (as returned by time(2)). */
qint64 toSecsSinceEpoch() const;
/** Converts the time to a UTC time, measured in seconds since 00:00:00 UTC
* 1st January 1970 (as returned by time(2)). */
KALARMCAL_DEPRECATED uint toTime_t() const;
/** Sets the value to a specified date-time value.
* @param secs The date-time value expressed as the number of seconds elapsed
* since 1970-01-01 00:00:00 UTC.
*/
void setSecsSinceEpoch(qint64 secs);
/** Sets the value to a specified date-time value.
* @param secs The time_t date-time value, expressed as the number of seconds elapsed
* since 1970-01-01 00:00:00 UTC.
*/
KALARMCAL_DEPRECATED void setTime_t(uint secs);
/** Returns a DateTime value @p secs seconds later than the value of this object. */
DateTime addSecs(qint64 n) const;
......@@ -332,5 +322,4 @@ inline bool operator<=(const KADateTime &dt1, const DateTime &dt2)
} // namespace KAlarmCal
// vim: et sw=4:
/*
* identities.cpp - email identity functions
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2004-2019 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......
/*
* identities.h - email identity functions
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2004-2011 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -10,6 +11,7 @@
#pragma once
#include "kalarmcal_export.h"
#include <qglobal.h>
class QString;
......@@ -41,5 +43,4 @@ KALARMCAL_EXPORT uint identityUoid(const QString &identityUoidOrName);
}
// vim: et sw=4:
/*
* kacalendar.cpp - KAlarm kcal library calendar and event functions
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -11,12 +12,12 @@
#include "kaevent.h"
#include "version.h"
#include "kalarmcal_debug.h"
#include <KCalendarCore/Alarm>
#include <KCalendarCore/MemoryCalendar>
#include <klocalizedstring.h>
#include "kalarmcal_debug.h"
#include <KLocalizedString>
#include <QMap>
#include <QFile>
......
/*
* kacalendar.h - KAlarm kcal library calendar and event categorisation
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2005-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -138,5 +139,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(CalEvent::Types)
KALARMCAL_EXPORT QDebug operator<<(QDebug, KAlarmCal::CalEvent::Type);
// vim: et sw=4:
//#define SIMULATION
/*
This file is part of kalarmcal library, which provides access to KAlarm
calendar data. Qt5 version of KDE 4 kdelibs/kdecore/date/kdatetime.cpp.
SPDX-FileCopyrightText: 2005-2021 David Jarvie <djarvie@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
* kadatetime.cpp - represents a date and optional time with a time zone
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* It is the Qt5 version of KDE 4 kdelibs/kdecore/date/kdatetime.cpp.
* Program: kalarm
* SPDX-FileCopyrightText: 2005-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kadatetime.h"
......@@ -1147,15 +1149,6 @@ qint64 KADateTime::toSecsSinceEpoch() const
return qdt.toSecsSinceEpoch();
}
uint KADateTime::toTime_t() const
{
qint64 t = toSecsSinceEpoch();
if (static_cast<quint64>(t) >= uint(-1)) {
return uint(-1);
}
return static_cast<uint>(t);
}
void KADateTime::setSecsSinceEpoch(qint64 seconds)
{
QDateTime dt;
......@@ -1166,11 +1159,6 @@ void KADateTime::setSecsSinceEpoch(qint64 seconds)
d->setDtWithSpec(dt);
}
void KADateTime::setTime_t(qint64 seconds)
{
setSecsSinceEpoch(seconds);
}
void KADateTime::setDateOnly(bool dateOnly)
{
d->setDateOnly(dateOnly);
......
/*
This file is part of kalarmcal library, which provides access to KAlarm
calendar data. Qt5 version of KDE 4 kdelibs/kdecore/date/kdatetime.h.
SPDX-FileCopyrightText: 2005-2019 David Jarvie <djarvie@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* This is the Qt5 version of KDE 4 kdelibs/kdecore/date/kdatetime.h.
* Program: kalarm
* SPDX-FileCopyrightText: 2005-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
/** @file
......@@ -771,16 +772,6 @@ public:
*/
qint64 toSecsSinceEpoch() const;
/**
* Converts the time to a UTC time, measured in seconds since 00:00:00 UTC
* 1st January 1970 (as returned by time(2)).
*
* @return converted time, or @c uint(-1) if the date is out of range or invalid
* @see setTime_t()
* @deprecated Use toSecsSinceEpoch()
*/
KALARMCAL_DEPRECATED uint toTime_t() const;
/**
* Sets the time to a UTC time, specified as seconds since 00:00:00 UTC
* 1st January 1970 (as returned by time(2)).
......@@ -790,16 +781,6 @@ public:
*/
void setSecsSinceEpoch(qint64 seconds);
/**
* Sets the time to a UTC time, specified as seconds since 00:00:00 UTC
* 1st January 1970 (as returned by time(2)).
*
* @param seconds number of seconds since 00:00:00 UTC 1st January 1970
* @see toTime_t()
* @deprecated Use setSecsSinceEpoch()
*/
KALARMCAL_DEPRECATED void setTime_t(qint64 seconds);
/**
* Sets the instance either to being a date and time value, or a date-only
* value. If its status is changed to date-only, its time is set to
......@@ -1472,5 +1453,4 @@ KALARMCAL_EXPORT QDataStream &operator>>(QDataStream &in, KADateTime &dateTime);
Q_DECLARE_METATYPE(KAlarmCal::KADateTime)
Q_DECLARE_METATYPE(KAlarmCal::KADateTime::Spec)
// vim: et sw=4:
/*
* kaevent.cpp - represents KAlarm calendar events
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kaevent.h"
#include "akonadi.h" // for deprecated setItemPayload() only
#include "alarmtext.h"
#include "identities.h"
#include "version.h"
#include "kalarmcal_debug.h"
#include <KCalendarCore/MemoryCalendar>
#include <KHolidays/Holiday>
#include <KHolidays/HolidayRegion>
#include <klocalizedstring.h>
#include "kalarmcal_debug.h"
#include <KLocalizedString>
using namespace KCalendarCore;
using namespace KHolidays;
......@@ -492,13 +491,6 @@ KAEvent::KAEvent(const KADateTime &dt, const QString &name, const QString &messa
{
}
KAEvent::KAEvent(const KADateTime &dt, const QString &message,
const QColor &bg, const QColor &fg, const QFont &f,
SubAction action, int lateCancel, Flags flags, bool changesPending)
: d(new KAEventPrivate(dt, QString(), message, bg, fg, f, action, lateCancel, flags, changesPending))
{
}
KAEventPrivate::KAEventPrivate(const KADateTime &dateTime, const QString &name, const QString &text,
const QColor &bg, const QColor &fg, const QFont &font,
KAEvent::SubAction action, int lateCancel, KAEvent::Flags flags,
......@@ -1079,19 +1071,6 @@ void KAEventPrivate::copy(const KAEventPrivate &event)
}
}
// Deprecated
void KAEvent::set(const KCalendarCore::Event::Ptr &e)
{
*this = KAEvent(e);
}
// Deprecated
void KAEvent::set(const KADateTime &dt, const QString &message, const QColor &bg, const QColor &fg,
const QFont &f, SubAction act, int lateCancel, Flags flags, bool changesPending)
{
*this = KAEvent(dt, QString(), message, bg, fg, f, act, lateCancel, flags, changesPending);
}
/******************************************************************************
* Update an existing KCalendarCore::Event with the KAEventPrivate data.
* If 'setCustomProperties' is true, all the KCalendarCore::Event's existing
......@@ -1737,27 +1716,6 @@ Akonadi::Collection::Id KAEvent::collectionId() const
return d->mDisplaying ? -1 : d->mResourceId;
}
void KAEvent::setItemId(Akonadi::Item::Id id)
{
d->mItemId = id;
}
Akonadi::Item::Id KAEvent::itemId() const
{
return d->mItemId;
}
/******************************************************************************
* Initialise an Item with the event.
* Note that the event is not updated with the Item ID.
* Reply = true if successful,
* false if event's category does not match collection's mime types.
*/
bool KAEvent::setItemPayload(Akonadi::Item &item, const QStringList &collectionMimeTypes) const
{
return KAlarmCal::setItemPayload(item, *this, collectionMimeTypes);
}
void KAEvent::setCompatibility(KACalendar::Compat c)
{
d->mCompatibility = c;
......@@ -2096,11 +2054,6 @@ bool KAEvent::isTemplate() const
return d->mCategory == CalEvent::TEMPLATE;
}
QString KAEvent::templateName() const
{
return d->mName;
}
bool KAEvent::usingDefaultTime() const
{
return d->mTemplateAfterTime == 0;
......@@ -2603,11 +2556,6 @@ bool KAEvent::excludedByWorkTimeOrHoliday(const KADateTime &dt) const
return d->excludedByWorkTimeOrHoliday(dt);
}
bool KAEvent::isWorkingTime(const KADateTime &dt) const
{
return !excludedByWorkTimeOrHoliday(dt);
}
bool KAEventPrivate::excludedByWorkTimeOrHoliday(const KADateTime &dt) const
{
if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
......
/*
* kaevent.h - represents KAlarm calendar events
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -347,81 +348,17 @@ public:
const QColor &bg, const QColor &fg, const QFont &font,
SubAction action, int lateCancel, Flags flags, bool changesPending = false);
/** Construct an event and initialise with the specified parameters.
* @param dt start date/time. If @p dt is date-only, or if #ANY_TIME flag
* is specified, the event will be date-only.
* @param text alarm message (@p action = #MESSAGE);
* file to display (@p action = #FILE);
* command to execute (@p action = #COMMAND);
* email body (@p action = #EMAIL);
* audio file (@p action = #AUDIO).
* @param bg background color (for display alarms, ignored otherwise).
* @param fg foreground color (for display alarms, ignored otherwise).
* @param font font (for display alarms, ignored otherwise). Ignored if
* #DEFAULT_FONT flag is specified.
* @param action alarm action type.
* @param lateCancel late-cancellation period (minutes), else 0.
* @param flags OR of #Flag enum values.
* @param changesPending true to inhibit automatic calculations and data
* updates until further changes have been applied
* to the instance; call endChanges() when changes
* are complete.
* @deprecated Use the other constructor.
*/
KALARMCAL_DEPRECATED KAEvent(const KADateTime &dt, const QString &text, const QColor &bg, const QColor &fg,
const QFont &font, SubAction action, int lateCancel, Flags flags, bool changesPending = false);
/** Construct an event and initialise it from a KCalendarCore::Event.
*
* The initialisation is identical to that performed by set().
*/
explicit KAEvent(const KCalendarCore::Event::Ptr &);
/** Initialise the instance from a KCalendarCore::Event.
*
* It uses the following properties from KCalendarCore::Event:
* - Unique ID.
* - Summary.
* - Creation date/time.
* - Start date/time.
* - Recurrence rule.
* - Alarms.
* - Read only.
* - Custom properties. X-KDE-KALARM- properties are interpreted and used to
* set numerous KAEvent properties; non-KAlarm properties are simply stored.
* - Custom status if equal to "DISABLED".
* - Revision number.
* @deprecated Use constructor and operator=() instead.
*/
KALARMCAL_DEPRECATED void set(const KCalendarCore::Event::Ptr &);
KAEvent(const KAEvent &other);
~KAEvent();
KAEvent &operator=(const KAEvent &other);
/** Initialise the instance with the specified parameters.
* @param dt start date/time
* @param text alarm message (@p action = #MESSAGE);
* file to display (@p action = #FILE);
* command to execute (@p action = #COMMAND);
* email body (@p action = #EMAIL);
* audio file (@p action = #AUDIO)
* @param bg background color (for display alarms, ignored otherwise)
* @param fg background color (for display alarms, ignored otherwise)
* @param font font (for display alarms, ignored otherwise)
* @param action alarm action type
* @param lateCancel late-cancellation period (minutes), else 0
* @param flags OR of #Flag enum values
* @param changesPending true to inhibit automatic data updates until
* further changes have been applied to the instance;
* call endChanges() when changes are complete.
* @deprecated Use constructor and operator=() instead.
*/
KALARMCAL_DEPRECATED void set(const KADateTime &dt, const QString &text, const QColor &bg,
const QColor &fg, const QFont &font, SubAction action, int lateCancel,
Flags flags, bool changesPending = false);
/** Update an existing KCalendarCore::Event with the KAEvent data.
* @param event Event to update.
* @param u how to deal with the Event's UID.
......@@ -525,24 +462,6 @@ public:
/** Return the ID of the calendar resource which contains the event. */
ResourceId resourceId() const;
/** Set the ID of the Akonadi Item which contains the event.
* @deprecated KAlarmCal will no longer provide this functionality.
*/
KALARMCAL_DEPRECATED void setItemId(Akonadi::Item::Id id);
/** Return the ID of the Akonadi Item which contains the event.
* @deprecated KAlarmCal will no longer provide this functionality.
*/
KALARMCAL_DEPRECATED Akonadi::Item::Id itemId() const;
/** Initialise an Akonadi::Item with the event's data.
* Note that the event is not updated with the Item ID.
* @return @c true if successful; @c false if the event's category does not match the
* collection's mime types.
* @deprecated Use KAlarmCal::setItemPayload() instead.
*/
KALARMCAL_DEPRECATED bool setItemPayload(Akonadi::Item &, const QStringList &collectionMimeTypes) const;
/** Note the event's storage format compatibility compared to the current KAlarm calendar format. */
void setCompatibility(KACalendar::Compat c);
......@@ -803,7 +722,7 @@ public:
* @param name template's name
* @param afterTime number of minutes after default time to schedule alarm for, or
* -1 to not use 'time from now'
* @see isTemplate(), templateName()
* @see isTemplate(), name()
*/
void setTemplate(const QString &name, int afterTime = -1);
......@@ -812,13 +731,6 @@ public:
*/
bool isTemplate() const;
/** Return the alarm template's name.
* @return template name, or empty if not a template
* @see setTemplate()
* @deprecated Use name() instead.
*/
KALARMCAL_DEPRECATED QString templateName() const;
/** Return whether the alarm template does not specify a time.
* @return @c true if no time is specified, i.e. the normal default alarm time will
* be used, @c false if the template specifies a time.
......@@ -1067,12 +979,6 @@ public:
*/
bool workTimeOnly() const;
/** Check whether a date/time is during working hours and/or holidays, depending
* on the flags set for the specified event.
* @deprecated Use !excludedByWorkTimeOrHoliday() instead.
*/
KALARMCAL_DEPRECATED bool isWorkingTime(const KADateTime &dt) const;
/** Check whether a date/time conflicts with working hours and/or holiday
* restrictions for the alarm.
* @return true if the alarm is disabled from occurring at time @p dt
......@@ -1472,5 +1378,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KAlarmCal::KAEvent::Flags)
Q_DECLARE_OPERATORS_FOR_FLAGS(KAlarmCal::KAEvent::Comparison)
Q_DECLARE_METATYPE(KAlarmCal::KAEvent)
// vim: et sw=4:
/*
* karecurrence.cpp - recurrence with special yearly February 29th handling
* This file is part of kalarmcal library, which provides access to KAlarm
* This file is part of kalarmprivate library, which provides access to KAlarm
* calendar data.
* Program: kalarm
* SPDX-FileCopyrightText: 2005-2019 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -9,11 +10,11 @@
#include "karecurrence.h"