Commit 5df287c4 authored by David Jarvie's avatar David Jarvie
Browse files

Add option to not show command alarm errors to user

parent 98ded68d
Pipeline #27511 passed with stage
in 12 minutes and 28 seconds
......@@ -134,7 +134,7 @@ Compliant with the iCalendar specification, KAlarm defines a number of custom fi
<tr><td></td><td><tt>SPEAK</tt></td><td>For an audio alarm in an event whose main alarm is a display or command alarm, specifies that the alarm text should be spoken</td></tr>
<tr><td class=cont></td><td class=cont><tt>EXECDEFER</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that the pre-alarm action should be executed when a deferred alarm triggers. Normally, it is executed only when the alarm proper triggers.</td></tr>
<tr><td class=cont></td><td class=cont><tt>ERRCANCEL</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that the alarm should be cancelled if the pre-alarm action fails</td></tr>
<tr><td class=cont></td><td class=cont><tt>ERRNOSHOW</tt></td><td class=cont>For a command alarm containing a pre-alarm action, indicates that there should be no error notification if the pre-alarm action fails</td></tr>
<tr><td class=cont></td><td class=cont><tt>ERRNOSHOW</tt></td><td class=cont>For a command alarm (which is either the main alarm, or contains a pre-alarm action), indicates that there should be no error notification if the command fails</td></tr>
<tr><td class=cont></td><td class=cont><tt>EMAILID;<em>uoid</em></tt></td><td class=cont>For an email alarm, holds the email ID (the KDE email UOID) to use in the 'From' field.</td></tr>
<tr><td colspan=2><tt>X-KDE-KALARM-NEXTREPEAT</tt></td><td>The single parameter holds the repetition count of the next due sub-repetition: 0 = the main recurrence, 1 = the first sub-repetition, etc.</td></tr>
<tr><td></td><td><tt><em>count</em></tt></td><td>Repetition number</td></tr>
......
......@@ -294,6 +294,7 @@ public:
bool mCommandScript{false}; // the command text is a script, not a shell command line
bool mCommandXterm{false}; // command alarm is to be executed in a terminal window
bool mCommandDisplay{false}; // command output is to be displayed in an alarm window
bool mCommandHideError{false}; // don't show command execution errors to user
bool mEmailBcc{false}; // blind copy the email to the user
bool mBeep{false}; // whether to beep when the alarm is displayed
bool mSpeak{false}; // whether to speak the message when the alarm is displayed
......@@ -523,6 +524,7 @@ KAEventPrivate::KAEventPrivate(const KADateTime &dateTime, const QString &text,
mCommandScript = flags & KAEvent::SCRIPT;
mCommandXterm = flags & KAEvent::EXEC_IN_XTERM;
mCommandDisplay = flags & KAEvent::DISPLAY_COMMAND;
mCommandHideError = flags & KAEvent::DONT_SHOW_ERROR;
mCopyToKOrganizer = flags & KAEvent::COPY_KORGANIZER;
mExcludeHolidays = flags & KAEvent::EXCL_HOLIDAYS;
mExcludeHolidayRegion = holidays();
......@@ -855,6 +857,9 @@ KAEventPrivate::KAEventPrivate(const KCalendarCore::Event::Ptr &event)
switch (data.action) {
case KAAlarm::COMMAND:
mCommandScript = data.commandScript;
if (data.extraActionOptions & KAEvent::DontShowPreActError) {
mCommandHideError = true;
}
if (!mCommandDisplay) {
break;
}
......@@ -1038,6 +1043,7 @@ void KAEventPrivate::copy(const KAEventPrivate &event)
mCommandScript = event.mCommandScript;
mCommandXterm = event.mCommandXterm;
mCommandDisplay = event.mCommandDisplay;
mCommandHideError = event.mCommandHideError;
mEmailBcc = event.mEmailBcc;
mBeep = event.mBeep;
mSpeak = event.mSpeak;
......@@ -1457,6 +1463,9 @@ Alarm::Ptr KAEventPrivate::initKCalAlarm(const KCalendarCore::Event::Ptr &event,
setProcedureAlarm(alarm, mText);
}
display = mCommandDisplay;
if (mCommandHideError) {
flags += DONT_SHOW_ERROR_FLAG;
}
break;
case KAEvent::EMAIL:
alarm->setEmailAlarm(mEmailSubject, mText, mEmailAddresses, mEmailAttachments);
......@@ -1606,6 +1615,9 @@ KAEvent::Flags KAEventPrivate::flags() const
if (mCommandDisplay) {
result |= KAEvent::DISPLAY_COMMAND;
}
if (mCommandHideError) {
result |= KAEvent::DONT_SHOW_ERROR;
}
if (mCopyToKOrganizer) {
result |= KAEvent::COPY_KORGANIZER;
}
......@@ -1869,6 +1881,11 @@ KAEvent::CmdErrType KAEvent::commandError() const
return d->mCommandError;
}
bool KAEvent::commandHideError() const
{
return d->mCommandHideError;
}
void KAEvent::setLogFile(const QString &logfile)
{
d->mLogFile = logfile;
......@@ -3670,11 +3687,12 @@ bool KAEventPrivate::compare(const KAEventPrivate& other, KAEvent::Comparison co
switch (mActionSubType) {
case KAEvent::COMMAND:
if (mCommandScript != other.mCommandScript
|| mCommandXterm != other.mCommandXterm
|| mCommandDisplay != other.mCommandDisplay
|| mCommandError != other.mCommandError
|| mLogFile != other.mLogFile)
if (mCommandScript != other.mCommandScript
|| mCommandXterm != other.mCommandXterm
|| mCommandDisplay != other.mCommandDisplay
|| mCommandError != other.mCommandError
|| mCommandHideError != other.mCommandHideError
|| mLogFile != other.mLogFile)
return false;
if (!mCommandDisplay) {
break;
......@@ -3841,6 +3859,7 @@ void KAEventPrivate::dumpDebug() const
qCDebug(KALARMCAL_LOG) << "-- mCommandScript:" << mCommandScript;
qCDebug(KALARMCAL_LOG) << "-- mCommandXterm:" << mCommandXterm;
qCDebug(KALARMCAL_LOG) << "-- mCommandDisplay:" << mCommandDisplay;
qCDebug(KALARMCAL_LOG) << "-- mCommandHideError:" << mCommandHideError;
qCDebug(KALARMCAL_LOG) << "-- mLogFile:" << mLogFile;
} else if (mActionSubType == KAEvent::EMAIL) {
qCDebug(KALARMCAL_LOG) << "-- mEmail: FromKMail:" << mEmailFromIdentity;
......
......@@ -208,7 +208,8 @@ public:
//!< if a holiday region has been set by setHolidays().
WORK_TIME_ONLY = 0x8000, //!< trigger the alarm only during working hours
DISPLAY_COMMAND = 0x10000, //!< display command output in the alarm window
REMINDER_ONCE = 0x20000 //!< only trigger the reminder on the first recurrence
REMINDER_ONCE = 0x20000, //!< only trigger the reminder on the first recurrence
DONT_SHOW_ERROR = 0x40000 //!< do not notify command alarm errors to user
// IMPORTANT: if any values are added to this list, ensure that the
// additional enum values in KAEventPrivate are also adjusted.
......@@ -616,6 +617,11 @@ public:
/** Return the command execution error for the last time the alarm triggered. */
CmdErrType commandError() const;
/** Return whether execution errors for the command should not to be shown to the user.
* @since 20.08
*/
bool commandHideError() const;
/** Set the log file to write command alarm output to.
* @param logfile log file path
*/
......
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