Commit 0af657fa authored by David Jarvie's avatar David Jarvie

Fix error in sub-repetition value from command line or D-Bus

Fix conversion error in sub-repetition value entered in command line
or D-Bus command.

Forward port commit 6a09f0b403c3673fc8271db4faf51e9d20e2ebab
(KDE/4.14 branch).
parent 13d3faa8
KAlarm Change Log
=== Version 2.11.1 --- 1 September 2015 ===
- Fix conversion error in sub-repetition value from command line or D-Bus command.
=== Version 2.11.0 --- July 2015 ===
- Use KDE Frameworks.
......
/*
* commandoptions.cpp - extract command line options
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2015 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -307,9 +307,9 @@ CommandOptions::CommandOptions()
count = -1;
// Get the recurrence interval
int interval;
int intervalOfType;
KARecurrence::Type recurType;
if (!convInterval(mArgs->getOption("interval").toLocal8Bit(), recurType, interval, !haveRecurrence))
if (!convInterval(mArgs->getOption("interval").toLocal8Bit(), recurType, intervalOfType, !haveRecurrence))
setErrorParameter("--interval");
else if (mAlarmTime.isDateOnly() && recurType == KARecurrence::MINUTELY)
setError(xi18nc("@info:shell", "Invalid <icode>%1</icode> parameter for date-only alarm", QStringLiteral("--interval")));
......@@ -318,13 +318,14 @@ CommandOptions::CommandOptions()
{
if (mRecurrence)
{
// There is a also a recurrence specified, so set up a sub-repetition
int longestInterval = mRecurrence->longestInterval();
if (count * interval > longestInterval)
// There is a also a recurrence specified, so set up a sub-repetition.
// In this case, 'intervalOfType' is in minutes.
mRepeatInterval = KCalCore::Duration(intervalOfType * 60);
KCalCore::Duration longestInterval = mRecurrence->longestInterval();
if (mRepeatInterval * count > longestInterval)
setError(xi18nc("@info:shell", "Invalid <icode>%1</icode> and <icode>%2</icode> parameters: repetition is longer than <icode>%3</icode> interval",
QLatin1String("--interval"), QStringLiteral("--repeat"), QStringLiteral("--recurrence")));
mRepeatCount = count;
mRepeatInterval = interval;
mRepeatCount = count;
}
}
else
......@@ -332,7 +333,7 @@ CommandOptions::CommandOptions()
// There is no other recurrence specified, so convert the repetition
// parameters into a KCal::Recurrence
mRecurrence = new KARecurrence;
mRecurrence->set(recurType, interval, count, mAlarmTime, endTime);
mRecurrence->set(recurType, intervalOfType, count, mAlarmTime, endTime);
}
}
else
......@@ -553,7 +554,7 @@ void CommandOptions::checkEditType(EditAlarmDlg::Type type1, EditAlarmDlg::Type
/******************************************************************************
* Convert a non-zero positive time interval command line parameter.
* 'timeInterval' receives the count for the recurType. If 'allowMonthYear' is
* false, weeks are converted to days in 'timeInterval'.
* false, weeks and days are converted to minutes.
* Reply = true if successful.
*/
static bool convInterval(const QByteArray& timeParam, KARecurrence::Type& recurType, int& timeInterval, bool allowMonthYear)
......@@ -613,6 +614,7 @@ static bool convInterval(const QByteArray& timeParam, KARecurrence::Type& recurT
// fall through to DAILY
case KARecurrence::DAILY:
interval *= 24*60;
recurType = KARecurrence::MINUTELY;
break;
default:
break;
......
/*
* commandoptions.h - extract command line options
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2015 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -62,7 +62,7 @@ class CommandOptions
KDateTime alarmTime() const { return mAlarmTime; }
KARecurrence* recurrence() const { return mRecurrence; }
int subRepeatCount() const { return mRepeatCount; }
int subRepeatInterval() const { return mRepeatInterval; }
KCalCore::Duration subRepeatInterval() const { return mRepeatInterval; }
int lateCancel() const { return mLateCancel; }
QColor bgColour() const { return mBgColour; }
QColor fgColour() const { return mFgColour; }
......@@ -103,7 +103,7 @@ class CommandOptions
KDateTime mAlarmTime; // NEW: alarm time
KARecurrence* mRecurrence; // NEW: recurrence
int mRepeatCount; // NEW: sub-repetition count
int mRepeatInterval; // NEW: sub-repetition interval
KCalCore::Duration mRepeatInterval; // NEW: sub-repetition interval
int mLateCancel; // NEW: late-cancellation interval
QColor mBgColour; // NEW: background colour
QColor mFgColour; // NEW: foreground colour
......
......@@ -24,7 +24,7 @@
#undef QT3_SUPPORT
#define VERSION_SUFFIX "-5ak"
#define KALARM_VERSION "2.11.0" VERSION_SUFFIX
#define KALARM_VERSION "2.11.1" VERSION_SUFFIX
#define KALARM_NAME "KAlarm"
#define KALARM_DBUS_SERVICE "org.kde.kalarm" // D-Bus service name of KAlarm application
......
/*
* kalarmapp.cpp - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2014 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2015 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -1280,7 +1280,7 @@ void KAlarmApp::setSpreadWindowsState(bool spread)
bool KAlarmApp::scheduleEvent(KAEvent::SubAction action, const QString& text, const KDateTime& dateTime,
int lateCancel, KAEvent::Flags flags, const QColor& bg, const QColor& fg,
const QFont& font, const QString& audioFile, float audioVolume, int reminderMinutes,
const KARecurrence& recurrence, int repeatInterval, int repeatCount,
const KARecurrence& recurrence, KCalCore::Duration repeatInterval, int repeatCount,
uint mailFromID, const KCalCore::Person::List& mailAddresses,
const QString& mailSubject, const QStringList& mailAttachments)
{
......
/*
* kalarmapp.h - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2014 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2015 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -87,7 +87,7 @@ class KAlarmApp : public KUniqueApplication
int lateCancel, KAEvent::Flags flags, const QColor& bg, const QColor& fg,
const QFont&, const QString& audioFile, float audioVolume,
int reminderMinutes, const KARecurrence& recurrence,
int repeatInterval, int repeatCount,
KCalCore::Duration repeatInterval, int repeatCount,
uint mailFromID = 0, const KCalCore::Person::List& mailAddresses = KCalCore::Person::List(),
const QString& mailSubject = QString(),
const QStringList& mailAttachments = QStringList());
......
/*
* main.cpp
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2015 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
K4AboutData aboutData(PROGRAM_NAME, 0, ki18n("KAlarm"), KALARM_VERSION,
ki18n("Personal alarm message, command and email scheduler for KDE"),
K4AboutData::License_GPL,
ki18n("Copyright 2001-2014, David Jarvie"), KLocalizedString(), "http://www.astrojar.org.uk/kalarm");
ki18n("Copyright 2001-2015, David Jarvie"), KLocalizedString(), "http://www.astrojar.org.uk/kalarm");
aboutData.addAuthor(ki18n("David Jarvie"), KLocalizedString(), "djarvie@kde.org");
aboutData.setOrganizationDomain("kde.org");
......
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