Commit d8034092 authored by David Jarvie's avatar David Jarvie
Browse files

Merge branch 'release/20.08'

parents 28738080 e2661f25
Pipeline #33835 passed with stage
in 12 minutes and 23 seconds
KAlarm Change Log
=== Version 3.0.2 (KDE Applications 20.08.2) --- 9 September 2020 ===
=== Version 3.0.2 (KDE Applications 20.08.2) --- 10 September 2020 ===
+ If command generating text for display alarm fails, only display error message,
not the display alarm, and don't redisplay the alarm on every restart.
+ Fix next trigger time shown as "Never" after using Try button for command display alarm, if command fails.
=== Version 3.0.1 (KDE Applications 20.08.1) --- 24 August 2020 ===
+ Fix inability to create alarms from templates, or load templates in edit dialogue [KDE Bug 425751]
......
......@@ -1166,7 +1166,7 @@ void EditAlarmDlg::slotTry()
event.setEventId(mEventId);
}
type_aboutToTry();
void* result = theApp()->execAlarm(event, event.firstAlarm(), false, false);
void* result = theApp()->execAlarm(event, event.firstAlarm(), KAlarmApp::NoRecordCmdError);
type_executedTry(text, result);
}
}
......
......@@ -979,7 +979,7 @@ void KAlarmApp::processQueue()
switch (action)
{
case QueuedAction::Trigger:
execAlarm(entry.event, entry.event.firstAlarm(), false);
execAlarm(entry.event, entry.event.firstAlarm());
break;
case QueuedAction::Handle:
{
......@@ -1624,7 +1624,7 @@ bool KAlarmApp::scheduleEvent(KAEvent::SubAction action, const QString& text, co
if (!mInitialised)
mActionQueue.enqueue(ActionQEntry(event, QueuedAction::Trigger));
else
execAlarm(event, event.firstAlarm(), false);
execAlarm(event, event.firstAlarm());
// If it's a recurring alarm, reschedule it for its next occurrence
if (!event.recurs()
|| event.setNextOccurrence(now) == KAEvent::NO_OCCURRENCE)
......@@ -1880,7 +1880,7 @@ bool KAlarmApp::handleEvent(const EventId& id, QueuedAction action, bool findUni
// If there is an alarm to execute, do this last after rescheduling/cancelling
// any others. This ensures that the updated event is only saved once to the calendar.
if (alarmToExecute.isValid())
execAlarm(event, alarmToExecute, true, !alarmToExecute.repeatAtLogin());
execAlarm(event, alarmToExecute, Reschedule | (alarmToExecute.repeatAtLogin() ? NoExecFlag : AllowDefer));
else
{
if (action == QueuedAction::Trigger)
......@@ -1890,7 +1890,7 @@ bool KAlarmApp::handleEvent(const EventId& id, QueuedAction action, bool findUni
// identical messages, for example.
const KAAlarm alarm = event.firstAlarm();
if (alarm.isValid())
execAlarm(event, alarm, false);
execAlarm(event, alarm);
}
if (updateCalAndDisplay)
KAlarm::updateEvent(event); // update the window lists and calendar file
......@@ -2094,13 +2094,13 @@ bool KAlarmApp::cancelReminderAndDeferral(KAEvent& event)
* = -1 if execution has not completed
* = 0 if the alarm is disabled, or if an error message was output.
*/
void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule, bool allowDefer, bool noPreAction)
void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, ExecAlarmFlags flags)
{
if (!mAlarmsEnabled || !event.enabled())
{
// The event (or all events) is disabled
qCDebug(KALARM_LOG) << "KAlarmApp::execAlarm:" << event.id() << ": disabled";
if (reschedule)
if (flags & Reschedule)
rescheduleAlarm(event, alarm, true);
return nullptr;
}
......@@ -2115,8 +2115,8 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
{
// execCommandAlarm() will error if the user is not authorised
// to run shell commands.
result = execCommandAlarm(event, alarm);
if (reschedule)
result = execCommandAlarm(event, alarm, flags & NoRecordCmdError);
if (flags & Reschedule)
rescheduleAlarm(event, alarm, true);
break;
}
......@@ -2132,7 +2132,7 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
const bool replaceReminder = !reminder && disp && (disp->alarmType() & KAAlarm::REMINDER_ALARM);
if (!reminder
&& (!event.deferred() || (event.extraActionOptions() & KAEvent::ExecPreActOnDeferral))
&& (replaceReminder || !disp) && !noPreAction
&& (replaceReminder || !disp) && !(flags & NoPreAction)
&& !event.preAction().isEmpty())
{
// It's not a reminder alarm, and it's not a deferred alarm unless the
......@@ -2156,8 +2156,8 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
// shell commands.
const QString command = event.preAction();
qCDebug(KALARM_LOG) << "KAlarmApp::execAlarm: Pre-DISPLAY command:" << command;
const int flags = (reschedule ? ProcData::RESCHEDULE : 0) | (allowDefer ? ProcData::ALLOW_DEFER : 0);
if (doShellCommand(command, event, &alarm, (flags | ProcData::PRE_ACTION)))
const int pdFlags = (flags & Reschedule ? ProcData::RESCHEDULE : 0) | (flags & AllowDefer ? ProcData::ALLOW_DEFER : 0);
if (doShellCommand(command, event, &alarm, (pdFlags | ProcData::PRE_ACTION)))
{
ResourcesCalendar::setAlarmPending(event);
return result; // display the message after the command completes
......@@ -2167,7 +2167,7 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
{
// Cancel the rest of the alarm execution
qCDebug(KALARM_LOG) << "KAlarmApp::execAlarm:" << event.id() << ": pre-action failed: cancelled";
if (reschedule)
if (flags & Reschedule)
rescheduleAlarm(event, alarm, true);
return nullptr;
}
......@@ -2177,8 +2177,10 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
if (!disp)
{
// There isn't already a message for this event
const int flags = (reschedule ? 0 : MessageDisplay::NO_RESCHEDULE) | (allowDefer ? 0 : MessageDisplay::NO_DEFER);
(new MessageWindow(&event, alarm, flags))->show();
const int mdFlags = (flags & Reschedule ? 0 : MessageDisplay::NO_RESCHEDULE)
| (flags & AllowDefer ? 0 : MessageDisplay::NO_DEFER)
| (flags & NoRecordCmdError ? MessageDisplay::NoRecordCmdError : 0);
(new MessageWindow(&event, alarm, mdFlags))->show();
}
else if (replaceReminder)
{
......@@ -2208,7 +2210,7 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
{
qCDebug(KALARM_LOG) << "KAlarmApp::execAlarm: EMAIL to:" << event.emailAddresses(QStringLiteral(","));
QStringList errmsgs;
KAMail::JobData data(event, alarm, reschedule, (reschedule || allowDefer));
KAMail::JobData data(event, alarm, flags & Reschedule, flags & (Reschedule | AllowDefer));
data.queued = true;
int ans = KAMail::send(data, errmsgs);
if (ans)
......@@ -2223,7 +2225,7 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
{
result = (void*)-1; // email has been queued
}
if (reschedule)
if (flags & Reschedule)
rescheduleAlarm(event, alarm, true);
break;
}
......@@ -2235,8 +2237,8 @@ void* KAlarmApp::execAlarm(KAEvent& event, const KAAlarm& alarm, bool reschedule
if (!disp)
{
// There isn't already a message for this event.
const int flags = (reschedule ? 0 : MessageDisplay::NO_RESCHEDULE) | MessageDisplay::ALWAYS_HIDE;
disp = new MessageWindow(&event, alarm, flags);
const int mdFlags = (flags & Reschedule ? 0 : MessageDisplay::NO_RESCHEDULE) | MessageDisplay::ALWAYS_HIDE;
disp = new MessageWindow(&event, alarm, mdFlags);
}
else
{
......@@ -2272,12 +2274,14 @@ void KAlarmApp::emailSent(KAMail::JobData& data, const QStringList& errmsgs, boo
* To connect to the output ready signals of the process, specify a slot to be
* called by supplying 'receiver' and 'slot' parameters.
*/
ShellProcess* KAlarmApp::execCommandAlarm(const KAEvent& event, const KAAlarm& alarm, QObject* receiver, const char* slotOutput, const char* methodExited)
ShellProcess* KAlarmApp::execCommandAlarm(const KAEvent& event, const KAAlarm& alarm, bool noRecordError,
QObject* receiver, const char* slotOutput, const char* methodExited)
{
// doShellCommand() will error if the user is not authorised to run
// shell commands.
const int flags = (event.commandXterm() ? ProcData::EXEC_IN_XTERM : 0)
| (event.commandDisplay() ? ProcData::DISP_OUTPUT : 0);
| (event.commandDisplay() ? ProcData::DISP_OUTPUT : 0)
| (noRecordError ? ProcData::NO_RECORD_ERROR : 0);
const QString command = event.cleanText();
if (event.commandScript())
{
......@@ -2544,7 +2548,12 @@ void KAlarmApp::slotCommandExited(ShellProcess* proc)
if (pd->preAction())
ResourcesCalendar::setAlarmPending(*pd->event, false);
if (executeAlarm)
execAlarm(*pd->event, *pd->alarm, pd->reschedule(), pd->allowDefer(), true);
{
execAlarm(*pd->event, *pd->alarm, (pd->reschedule() ? Reschedule : NoExecFlag)
| (pd->allowDefer() ? AllowDefer : NoExecFlag)
| (pd->noRecordCmdErr() ? NoRecordCmdError : NoExecFlag)
| NoPreAction);
}
mCommandProcesses.removeAt(i);
if (pd->exitReceiver && !pd->exitMethod.isEmpty())
QMetaObject::invokeMethod(pd->exitReceiver, pd->exitMethod.constData(), Qt::DirectConnection, Q_ARG(ShellProcess::Status, status));
......@@ -2589,7 +2598,8 @@ void KAlarmApp::commandErrorMsg(const ShellProcess* proc, const KAEvent& event,
}
// Record the alarm's error status
setEventCommandError(event, cmderr);
if (!(flags & ProcData::NO_RECORD_ERROR))
setEventCommandError(event, cmderr);
if (!dontShowAgain.isEmpty())
{
......
......@@ -36,6 +36,17 @@ class KAlarmApp : public QApplication
{
Q_OBJECT
public:
/** Flags for execAlarm(). */
enum ExecAlarmFlag
{
NoExecFlag = 0,
Reschedule = 0x01, // reschedule the alarm after executing it
AllowDefer = 0x02, // allow the alarm to be deferred
NoRecordCmdError = 0x04, // don't record command errors
NoPreAction = 0x08
};
Q_DECLARE_FLAGS(ExecAlarmFlags, ExecAlarmFlag)
~KAlarmApp() override;
/** Create the unique instance. */
......@@ -66,8 +77,8 @@ class KAlarmApp : public QApplication
bool trayIconDisplayed() const { return mTrayWindow; }
bool editNewAlarm(MainWindow* = nullptr);
void* execAlarm(KAEvent&, const KAAlarm&, bool reschedule, bool allowDefer = true, bool noPreAction = false);
ShellProcess* execCommandAlarm(const KAEvent&, const KAAlarm&,
void* execAlarm(KAEvent&, const KAAlarm&, ExecAlarmFlags flags = NoExecFlag);
ShellProcess* execCommandAlarm(const KAEvent&, const KAAlarm&, bool noRecordError = false,
QObject* receiver = nullptr,
const char* slotOutput = nullptr,
const char* methodExited = nullptr);
......@@ -154,14 +165,15 @@ class KAlarmApp : public QApplication
ProcData(ShellProcess*, KAEvent*, KAAlarm*, int flags = 0);
~ProcData();
enum { PRE_ACTION = 0x01, POST_ACTION = 0x02, RESCHEDULE = 0x04, ALLOW_DEFER = 0x08,
TEMP_FILE = 0x10, EXEC_IN_XTERM = 0x20, DISP_OUTPUT = 0x40 };
bool preAction() const { return flags & PRE_ACTION; }
bool postAction() const { return flags & POST_ACTION; }
bool reschedule() const { return flags & RESCHEDULE; }
bool allowDefer() const { return flags & ALLOW_DEFER; }
bool tempFile() const { return flags & TEMP_FILE; }
bool execInXterm() const { return flags & EXEC_IN_XTERM; }
bool dispOutput() const { return flags & DISP_OUTPUT; }
TEMP_FILE = 0x10, EXEC_IN_XTERM = 0x20, DISP_OUTPUT = 0x40, NO_RECORD_ERROR = 0x80 };
bool preAction() const { return flags & PRE_ACTION; }
bool postAction() const { return flags & POST_ACTION; }
bool reschedule() const { return flags & RESCHEDULE; }
bool allowDefer() const { return flags & ALLOW_DEFER; }
bool tempFile() const { return flags & TEMP_FILE; }
bool execInXterm() const { return flags & EXEC_IN_XTERM; }
bool dispOutput() const { return flags & DISP_OUTPUT; }
bool noRecordCmdErr() const { return flags & NO_RECORD_ERROR; }
ShellProcess* process;
KAEvent* event;
KAAlarm* alarm;
......@@ -249,6 +261,8 @@ class KAlarmApp : public QApplication
inline KAlarmApp* theApp() { return KAlarmApp::instance(); }
Q_DECLARE_OPERATORS_FOR_FLAGS(KAlarmApp::ExecAlarmFlags)
#endif // KALARMAPP_H
// vim: et sw=4:
......@@ -27,11 +27,14 @@ using namespace KAlarmCal;
class MessageDisplay
{
public:
enum { // flags for constructor
NO_RESCHEDULE = 0x01, // don't reschedule the event once it has displayed
NO_DEFER = 0x02, // don't display an option to defer
ALWAYS_HIDE = 0x04, // never show the window (e.g. for audio-only alarms)
NO_INIT_VIEW = 0x08 // for internal MessageDisplayHelper use only
/** Flags for constructor. */
enum
{
NO_RESCHEDULE = 0x01, // don't reschedule the event once it has displayed
NO_DEFER = 0x02, // don't display an option to defer
NoRecordCmdError = 0x04, // don't record error executing command
ALWAYS_HIDE = 0x08, // never show the window (e.g. for audio-only alarms)
NO_INIT_VIEW = 0x10 // for internal MessageDisplayHelper use only
};
virtual ~MessageDisplay();
......
......@@ -92,9 +92,10 @@ MessageDisplayHelper::MessageDisplayHelper(MessageDisplay* parent, const KAEvent
, mNoPostAction(alarm.type() & KAAlarm::REMINDER_ALARM)
, mBeep(event->beep())
, mSpeak(event->speak())
, mNoRecordCmdError(flags & MessageDisplay::NoRecordCmdError)
, mRescheduleEvent(!(flags & MessageDisplay::NO_RESCHEDULE))
{
qCDebug(KALARM_LOG) << "MessageDisplayHelper:" << (void*)this << "event" << mEventId;
qCDebug(KALARM_LOG) << "MessageDisplayHelper:" << mEventId;
if (alarm.type() & KAAlarm::REMINDER_ALARM)
{
if (event->reminderMinutes() < 0)
......@@ -146,7 +147,7 @@ MessageDisplayHelper::MessageDisplayHelper(MessageDisplay* parent, const KAEvent
, mErrorWindow(true)
, mNoPostAction(true)
{
qCDebug(KALARM_LOG) << "MessageDisplayHelper: errmsg";
qCDebug(KALARM_LOG) << "MessageDisplayHelper(errmsg)";
mInstanceList.append(this);
}
......@@ -157,7 +158,7 @@ MessageDisplayHelper::MessageDisplayHelper(MessageDisplay* parent, const KAEvent
MessageDisplayHelper::MessageDisplayHelper(MessageDisplay* parent)
: mParent(parent)
{
qCDebug(KALARM_LOG) << "MessageDisplayHelper:" << (void*)this << "restore";
qCDebug(KALARM_LOG) << "MessageDisplayHelper(): restore";
mInstanceList.append(this);
}
......@@ -166,7 +167,7 @@ MessageDisplayHelper::MessageDisplayHelper(MessageDisplay* parent)
*/
MessageDisplayHelper::~MessageDisplayHelper()
{
qCDebug(KALARM_LOG) << "~MessageDisplayHelper" << (void*)this << mEventId;
qCDebug(KALARM_LOG) << "~MessageDisplayHelper" << mEventId;
if (AudioThread::mAudioOwner == this && !mAudioThread.isNull())
mAudioThread->quit();
mErrorMessages.remove(mEventId);
......@@ -287,7 +288,7 @@ void MessageDisplayHelper::initTexts()
}
case KAEvent::COMMAND:
{
theApp()->execCommandAlarm(mEvent, mEvent.alarm(mAlarmType),
theApp()->execCommandAlarm(mEvent, mEvent.alarm(mAlarmType), mNoRecordCmdError,
this, SLOT(readProcessOutput(ShellProcess*)), "commandCompleted");
break;
}
......
......@@ -70,6 +70,8 @@ public:
MessageDisplayHelper(MessageDisplay* parent, const KAEvent*, const KAAlarm&, int flags);
MessageDisplayHelper(MessageDisplay* parent, const KAEvent*, const DateTime& alarmDateTime,
const QStringList& errmsgs, const QString& dontShowAgain);
MessageDisplayHelper(const MessageDisplayHelper&) = delete;
MessageDisplayHelper& operator=(const MessageDisplayHelper&) = delete;
~MessageDisplayHelper() override;
void setSilenceButton(PushButton* b) { mSilenceButton = b; }
void repeat(const KAAlarm&);
......@@ -176,10 +178,9 @@ public:
private:
DisplayTexts mTexts; // texts to display in alarm message
QTemporaryFile* mTempFile {nullptr}; // temporary file used to display image/HTML
bool mNoRecordCmdError {false}; // don't record command alarm errors
bool mInitialised {false}; // initTexts() has been called to create the alarm's texts
bool mRescheduleEvent {false}; // true to delete event after message has been displayed
//friend class MessageDisplay;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(MessageDisplayHelper::DisplayTexts::TextIds)
......
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