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

Merge branch 'release/20.08'

parents e5558fa0 d9031c53
Pipeline #33630 passed with stage
in 12 minutes and 6 seconds
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.15.40")
set(PIM_VERSION ${PIM_VERSION})
set(RELEASE_SERVICE_VERSION "20.11.80")
set(KALARM_VERSION "3.0.1")
set(KALARM_VERSION "3.0.2")
project(kalarm VERSION ${KALARM_VERSION})
......
KAlarm Change Log
=== Version 3.0.2 (KDE Applications 20.08.2) --- 9 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.
=== 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]
+ Don't show spurious error message when deleting alarm template [KDE Bug 425751]
......
......@@ -2272,7 +2272,7 @@ 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, const QObject* receiver, const char* slot)
ShellProcess* KAlarmApp::execCommandAlarm(const KAEvent& event, const KAAlarm& alarm, QObject* receiver, const char* slotOutput, const char* methodExited)
{
// doShellCommand() will error if the user is not authorised to run
// shell commands.
......@@ -2289,12 +2289,12 @@ ShellProcess* KAlarmApp::execCommandAlarm(const KAEvent& event, const KAAlarm& a
setEventCommandError(event, KAEvent::CMD_ERROR);
return nullptr;
}
return doShellCommand(tmpfile, event, &alarm, (flags | ProcData::TEMP_FILE), receiver, slot);
return doShellCommand(tmpfile, event, &alarm, (flags | ProcData::TEMP_FILE), receiver, slotOutput, methodExited);
}
else
{
qCDebug(KALARM_LOG) << "KAlarmApp::execCommandAlarm:" << command;
return doShellCommand(command, event, &alarm, flags, receiver, slot);
return doShellCommand(command, event, &alarm, flags, receiver, slotOutput, methodExited);
}
}
......@@ -2305,13 +2305,15 @@ ShellProcess* KAlarmApp::execCommandAlarm(const KAEvent& event, const KAAlarm& a
* derived from the remaining bits in 'flags'.
* 'flags' must contain the bit PRE_ACTION or POST_ACTION if and only if it is
* a pre- or post-alarm action respectively.
* To connect to the exited signal of the process, specify the name of a method
* to be called by supplying 'receiver' and 'methodExited' parameters.
* To connect to the output ready signals of the process, specify a slot to be
* called by supplying 'receiver' and 'slot' parameters.
*
* Note that if shell access is not authorised, the attempt to run the command
* will be errored.
*/
ShellProcess* KAlarmApp::doShellCommand(const QString& command, const KAEvent& event, const KAAlarm* alarm, int flags, const QObject* receiver, const char* slot)
ShellProcess* KAlarmApp::doShellCommand(const QString& command, const KAEvent& event, const KAAlarm* alarm, int flags, QObject* receiver, const char* slotOutput, const char* methodExited)
{
qCDebug(KALARM_LOG) << "KAlarmApp::doShellCommand:" << command << "," << event.id();
QIODevice::OpenMode mode = QIODevice::WriteOnly;
......@@ -2345,10 +2347,10 @@ ShellProcess* KAlarmApp::doShellCommand(const QString& command, const KAEvent& e
proc->setEnv(QStringLiteral("KALARM_UID"), event.id(), true);
proc->setOutputChannelMode(KProcess::MergedChannels); // combine stdout & stderr
connect(proc, &ShellProcess::shellExited, this, &KAlarmApp::slotCommandExited);
if ((flags & ProcData::DISP_OUTPUT) && receiver && slot)
if ((flags & ProcData::DISP_OUTPUT) && receiver && slotOutput)
{
connect(proc, SIGNAL(receivedStdout(ShellProcess*)), receiver, slot);
connect(proc, SIGNAL(receivedStderr(ShellProcess*)), receiver, slot);
connect(proc, SIGNAL(receivedStdout(ShellProcess*)), receiver, slotOutput);
connect(proc, SIGNAL(receivedStderr(ShellProcess*)), receiver, slotOutput);
}
if (mode == QIODevice::ReadWrite && !event.logFile().isEmpty())
{
......@@ -2376,6 +2378,11 @@ ShellProcess* KAlarmApp::doShellCommand(const QString& command, const KAEvent& e
pd->tempFiles += command;
if (!tmpXtermFile.isEmpty())
pd->tempFiles += tmpXtermFile;
if (receiver && methodExited)
{
pd->exitReceiver = receiver;
pd->exitMethod = methodExited;
}
mCommandProcesses.append(pd);
if (proc->start(mode))
return proc;
......@@ -2539,6 +2546,8 @@ void KAlarmApp::slotCommandExited(ShellProcess* proc)
if (executeAlarm)
execAlarm(*pd->event, *pd->alarm, pd->reschedule(), pd->allowDefer(), true);
mCommandProcesses.removeAt(i);
if (pd->exitReceiver && !pd->exitMethod.isEmpty())
QMetaObject::invokeMethod(pd->exitReceiver, pd->exitMethod.constData(), Qt::DirectConnection, Q_ARG(ShellProcess::Status, status));
delete pd;
break;
}
......
......@@ -67,7 +67,10 @@ class KAlarmApp : public QApplication
bool editNewAlarm(MainWindow* = nullptr);
void* execAlarm(KAEvent&, const KAAlarm&, bool reschedule, bool allowDefer = true, bool noPreAction = false);
ShellProcess* execCommandAlarm(const KAEvent&, const KAAlarm&, const QObject* receiver = nullptr, const char* slot = nullptr);
ShellProcess* execCommandAlarm(const KAEvent&, const KAAlarm&,
QObject* receiver = nullptr,
const char* slotOutput = nullptr,
const char* methodExited = nullptr);
void alarmCompleted(const KAEvent&);
void rescheduleAlarm(KAEvent& e, const KAAlarm& a) { rescheduleAlarm(e, a, true); }
void purgeAll() { purge(0); }
......@@ -162,6 +165,8 @@ class KAlarmApp : public QApplication
ShellProcess* process;
KAEvent* event;
KAAlarm* alarm;
QObject* exitReceiver {nullptr};
QByteArray exitMethod;
QPointer<QWidget> messageBoxParent;
QStringList tempFiles;
int flags;
......@@ -197,7 +202,9 @@ class KAlarmApp : public QApplication
bool cancelAlarm(KAEvent&, KAAlarm::Type, bool updateCalAndDisplay);
bool cancelReminderAndDeferral(KAEvent&);
ShellProcess* doShellCommand(const QString& command, const KAEvent&, const KAAlarm*,
int flags = 0, const QObject* receiver = nullptr, const char* slot = nullptr);
int flags = 0, QObject* receiver = nullptr,
const char* slotOutput = nullptr,
const char* methodExited = nullptr);
QString composeXTermCommand(const QString& command, const KAEvent&, const KAAlarm*,
int flags, QString& tempScriptFile) const;
QString createTempScriptFile(const QString& command, bool insertShell, const KAEvent&, const KAAlarm&) const;
......
......@@ -18,7 +18,6 @@
#include "resources/resources.h"
#include "lib/messagebox.h"
#include "lib/pushbutton.h"
#include "lib/shellprocess.h"
#include "lib/synchtimer.h"
#include "kalarm_debug.h"
......@@ -288,7 +287,8 @@ void MessageDisplayHelper::initTexts()
}
case KAEvent::COMMAND:
{
theApp()->execCommandAlarm(mEvent, mEvent.alarm(mAlarmType), this, SLOT(readProcessOutput(ShellProcess*)));
theApp()->execCommandAlarm(mEvent, mEvent.alarm(mAlarmType),
this, SLOT(readProcessOutput(ShellProcess*)), "commandCompleted");
break;
}
case KAEvent::EMAIL:
......@@ -514,6 +514,31 @@ void MessageDisplayHelper::readProcessOutput(ShellProcess* proc)
}
}
/******************************************************************************
* Called when the command which is providing the text for this display has
* completed. Check whether the command succeeded, even partially.
*/
void MessageDisplayHelper::commandCompleted(ShellProcess::Status status)
{
bool failed;
switch (status)
{
case ShellProcess::SUCCESS:
case ShellProcess::DIED:
failed = false;
break;
case ShellProcess::UNAUTHORISED:
case ShellProcess::NOT_FOUND:
case ShellProcess::START_FAIL:
case ShellProcess::INACTIVE:
default:
failed = true;
break;
}
Q_EMIT commandExited(!failed);
}
/******************************************************************************
* Save settings to the session managed config file, for restoration
* when the program is restored.
......
......@@ -12,6 +12,7 @@
#include "eventid.h"
#include "resources/resource.h"
#include "lib/file.h"
#include "lib/shellprocess.h"
#include <KAlarmCal/KAEvent>
......@@ -22,7 +23,6 @@
class KConfigGroup;
class QTemporaryFile;
class ShellProcess;
class AudioThread;
class PushButton;
class MessageDisplay;
......@@ -107,6 +107,9 @@ Q_SIGNALS:
*/
void textsChanged(DisplayTexts::TextIds, const QString& change = QString());
/** Signal emitted on completion of the command providing the alarm message text. */
void commandExited(bool success);
/** Signal emitted when the alarm should close, after the auto-close time. */
void autoCloseNow();
......@@ -120,6 +123,7 @@ private Q_SLOTS:
void slotSetRemainingTextDay() { setRemainingTextDay(true); }
void slotSetRemainingTextMinute() { setRemainingTextMinute(true); }
void readProcessOutput(ShellProcess*);
void commandCompleted(ShellProcess::Status);
private:
QString dateTimeToDisplay() const;
......
......@@ -139,6 +139,7 @@ MessageWindow::MessageWindow(const KAEvent* event, const KAAlarm& alarm, int fla
setUpDisplay();
connect(mHelper, &MessageDisplayHelper::textsChanged, this, &MessageWindow::textsChanged);
connect(mHelper, &MessageDisplayHelper::commandExited, this, &MessageWindow::commandCompleted);
// Set to save settings automatically, but don't save window size.
// File alarm window size is saved elsewhere.
......@@ -189,7 +190,7 @@ MessageWindow::MessageWindow()
getWorkAreaAndModal();
connect(mHelper, &MessageDisplayHelper::textsChanged, this, &MessageWindow::textsChanged);
#warning When restoring an error message, the window is blank
connect(mHelper, &MessageDisplayHelper::commandExited, this, &MessageWindow::commandCompleted);
mWindowList.append(this);
}
......@@ -724,6 +725,20 @@ void MessageWindow::textsChanged(MessageDisplayHelper::DisplayTexts::TextIds ids
}
}
/******************************************************************************
* Called when the command providing the alarm message text has exited.
* 'success' is true if the command did not fail completely.
*/
void MessageWindow::commandCompleted(bool success)
{
if (!success)
{
// The command failed completely. KAlarmApp will output an error
// message, so delete the empty window.
close();
}
}
/******************************************************************************
* Save settings to the session managed config file, for restoration
* when the program is restored.
......
......@@ -96,6 +96,7 @@ private Q_SLOTS:
void displayMainWindow();
void slotShowKMailMessage();
void enableButtons();
void commandCompleted(bool success);
void frameDrawn();
private:
......
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