From 6a09f0b403c3673fc8271db4faf51e9d20e2ebab Mon Sep 17 00:00:00 2001 From: David Jarvie <djarvie@kde.org> Date: Tue, 1 Sep 2015 23:09:53 +0100 Subject: [PATCH 09/74] 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. --- kalarm/Changelog | 3 +++ kalarm/commandoptions.cpp | 22 ++++++++++++---------- kalarm/commandoptions.h | 6 +++--- kalarm/kalarm.h | 4 ++-- kalarm/kalarmapp.cpp | 4 ++-- kalarm/kalarmapp.h | 4 ++-- kalarm/main.cpp | 4 ++-- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/kalarm/Changelog b/kalarm/Changelog index 01752daf45..b2154cf9ac 100644 --- a/kalarm/Changelog +++ b/kalarm/Changelog @@ -1,5 +1,8 @@ KAlarm Change Log +=== Version 2.10.13 --- 1 September 2015 === +- Fix conversion error in sub-repetition value from command line or D-Bus command. + === Version 2.10.12 (KDE 4.14.2) --- 30 September 2014 === - Make New Audio Alarm dialogue use sound file repeat preference setting. diff --git a/kalarm/commandoptions.cpp b/kalarm/commandoptions.cpp index c225629320..1ad489a7b2 100644 --- a/kalarm/commandoptions.cpp +++ b/kalarm/commandoptions.cpp @@ -1,7 +1,7 @@ /* * 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 @@ -315,9 +315,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(i18nc("@info:shell", "Invalid <icode>%1</icode> parameter for date-only alarm", QLatin1String("--interval"))); @@ -326,13 +326,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(i18nc("@info:shell", "Invalid <icode>%1</icode> and <icode>%2</icode> parameters: repetition is longer than <icode>%3</icode> interval", QLatin1String("--interval"), QLatin1String("--repeat"), QLatin1String("--recurrence"))); - mRepeatCount = count; - mRepeatInterval = interval; + mRepeatCount = count; } } else @@ -340,7 +341,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 @@ -561,7 +562,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) @@ -621,6 +622,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; diff --git a/kalarm/commandoptions.h b/kalarm/commandoptions.h index 32738db888..2d38aa6645 100644 --- a/kalarm/commandoptions.h +++ b/kalarm/commandoptions.h @@ -1,7 +1,7 @@ /* * 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 @@ -68,7 +68,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; } @@ -117,7 +117,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 diff --git a/kalarm/kalarm.h b/kalarm/kalarm.h index 7268018082..a573c35152 100644 --- a/kalarm/kalarm.h +++ b/kalarm/kalarm.h @@ -1,7 +1,7 @@ /* * kalarm.h - global header file * 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 @@ -28,7 +28,7 @@ #else #define VERSION_SUFFIX "-res" #endif -#define KALARM_VERSION "2.10.12" VERSION_SUFFIX +#define KALARM_VERSION "2.10.13" VERSION_SUFFIX #define KALARM_NAME "KAlarm" #define KALARM_DBUS_SERVICE "org.kde.kalarm" // D-Bus service name of KAlarm application diff --git a/kalarm/kalarmapp.cpp b/kalarm/kalarmapp.cpp index 3a170b0694..0c975a4ed8 100644 --- a/kalarm/kalarmapp.cpp +++ b/kalarm/kalarmapp.cpp @@ -1,7 +1,7 @@ /* * 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 @@ -1352,7 +1352,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, #ifdef USE_AKONADI uint mailFromID, const KCalCore::Person::List& mailAddresses, #else diff --git a/kalarm/kalarmapp.h b/kalarm/kalarmapp.h index f6cc4263d8..fea19c9bfc 100644 --- a/kalarm/kalarmapp.h +++ b/kalarm/kalarmapp.h @@ -1,7 +1,7 @@ /* * 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 @@ -91,7 +91,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, #ifdef USE_AKONADI uint mailFromID = 0, const KCalCore::Person::List& mailAddresses = KCalCore::Person::List(), #else diff --git a/kalarm/main.cpp b/kalarm/main.cpp index b42a9eac47..b2ef695203 100644 --- a/kalarm/main.cpp +++ b/kalarm/main.cpp @@ -1,7 +1,7 @@ /* * 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 @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) KAboutData aboutData(PROGRAM_NAME, 0, ki18n("KAlarm"), KALARM_VERSION, ki18n("Personal alarm message, command and email scheduler for KDE"), KAboutData::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"); -- 2.14.1