Don't show error notifications for jobs cancelled by user

Modify applicationjobs dataengine so that "error" value
now contains job's error code and "errorText" error message.

This depends on commit 812d0b440e7f08e3acdd1c9bb95779bd871b75b3
to kjobwidgets.

REVIEW: 122928
wilder-5.14
David Rosca 11 years ago
parent 37ba29973a
commit 320331ae36
  1. 1
      applets/notifications/package/contents/ui/JobDelegate.qml
  2. 17
      applets/notifications/package/contents/ui/Jobs.qml
  3. 7
      dataengines/applicationjobs/kuiserverengine.cpp
  4. 1
      dataengines/applicationjobs/kuiserverengine.h
  5. 19
      kuiserver/jobview.cpp
  6. 9
      kuiserver/jobview.h

@ -174,7 +174,6 @@ Column {
visible: getData(jobsSource.data, "killable", 0) visible: getData(jobsSource.data, "killable", 0)
onClicked: { onClicked: {
cancelledJobs.push(modelData) // register that it was user-cancelled
var service = jobsSource.serviceForSource(modelData) var service = jobsSource.serviceForSource(modelData)
var operation = service.operationDescription("stop") var operation = service.operationDescription("stop")
service.startOperationCall(operation) service.startOperationCall(operation)

@ -30,8 +30,6 @@ Column {
property alias count: jobsRepeater.count property alias count: jobsRepeater.count
property var cancelledJobs: []
PlasmaCore.DataSource { PlasmaCore.DataSource {
id: jobsSource id: jobsSource
@ -49,9 +47,11 @@ Column {
return return
} }
var cancelledJobPos = cancelledJobs.indexOf(source) var error = runningJobs[source]["error"]
if (cancelledJobPos > -1) { var errorText = runningJobs[source]["errorText"]
cancelledJobs.splice(cancelledJobPos, 1)
// 1 = ERR_USER_CANCELED - don't show any notification at all
if (error == 1) {
return return
} }
@ -61,13 +61,10 @@ Column {
return return
} }
var errorText = runningJobs[source]["error"];
var error = errorText != ""
var summary = infoMessage ? i18nc("the job, which can be anything, has finished", "%1: Finished", infoMessage) : i18n("Job Finished") var summary = infoMessage ? i18nc("the job, which can be anything, has finished", "%1: Finished", infoMessage) : i18n("Job Finished")
if (error) { if (error) {
summary = infoMessage ? i18nc("the job, which can be anything, finished with error", "%1: Error", infoMessage) : i18n("Job Error") summary = infoMessage ? i18nc("the job, which can be anything, finished with error", "%1: Error", infoMessage) : i18n("Job Error")
message = errorText
} }
notifications.addNotification({ notifications.addNotification({
@ -75,7 +72,7 @@ Column {
appIcon: runningJobs[source]["appIconName"], appIcon: runningJobs[source]["appIconName"],
appName: runningJobs[source]["appName"], appName: runningJobs[source]["appName"],
summary: summary, summary: summary,
body: message, body: errorText || message,
isPersistent: true, isPersistent: true,
expireTimeout: 6000, expireTimeout: 6000,
urgency: 0, urgency: 0,

@ -89,7 +89,7 @@ void JobView::timerEvent(QTimerEvent *event)
void JobView::terminate(const QString &errorMessage) void JobView::terminate(const QString &errorMessage)
{ {
setData("error", errorMessage); setData(QStringLiteral("errorText"), errorMessage);
QTimer::singleShot(0, this, SLOT(finished())); QTimer::singleShot(0, this, SLOT(finished()));
} }
@ -128,6 +128,11 @@ void JobView::setSuspended(bool suspended)
} }
} }
void JobView::setError(uint errorCode)
{
setData(QStringLiteral("error"), errorCode);
}
int JobView::unitId(const QString &unit) int JobView::unitId(const QString &unit)
{ {
int id = 0; int id = 0;

@ -95,6 +95,7 @@ public:
void setCapabilities(int capabilities); void setCapabilities(int capabilities);
void setPercent(uint percent); void setPercent(uint percent);
void setSuspended(bool suspended); void setSuspended(bool suspended);
void setError(uint errorCode);
//vestigal, required to implement this dbus interface //vestigal, required to implement this dbus interface
void setDestUrl(const QDBusVariant &destUrl); void setDestUrl(const QDBusVariant &destUrl);

@ -33,6 +33,7 @@ JobView::JobView(uint jobId, QObject *parent)
: QObject(parent), : QObject(parent),
m_capabilities(-1), m_capabilities(-1),
m_percent(-1), m_percent(-1),
m_error(KJob::NoError),
m_totalAmount(0), m_totalAmount(0),
m_processAmount(0), m_processAmount(0),
m_jobId(jobId), m_jobId(jobId),
@ -57,10 +58,11 @@ void JobView::terminate(const QString &errorMessage)
typedef QPair<QString, QDBusAbstractInterface*> iFacePair; typedef QPair<QString, QDBusAbstractInterface*> iFacePair;
foreach(const iFacePair &pair, m_objectPaths) { foreach(const iFacePair &pair, m_objectPaths) {
qCDebug(KUISERVER) << "making async call of terminate for: " << pair.first; qCDebug(KUISERVER) << "making async call of terminate for: " << pair.first;
pair.second->asyncCall(QLatin1String("setError"), m_error);
pair.second->asyncCall(QLatin1String("terminate"), errorMessage); pair.second->asyncCall(QLatin1String("terminate"), errorMessage);
} }
m_error = errorMessage; m_errorText = errorMessage;
if (m_currentPendingCalls < 1) { if (m_currentPendingCalls < 1) {
// if hit it means a job exists for *something* but can't be terminated properly // if hit it means a job exists for *something* but can't be terminated properly
@ -285,11 +287,21 @@ int JobView::capabilities() const
return m_capabilities; return m_capabilities;
} }
QString JobView::error() const void JobView::setError(uint errorCode)
{
m_error = errorCode;
}
uint JobView::error() const
{ {
return m_error; return m_error;
} }
QString JobView::errorText() const
{
return m_errorText;
}
uint JobView::jobId() const uint JobView::jobId() const
{ {
return m_jobId; return m_jobId;
@ -415,7 +427,8 @@ void JobView::pendingCallFinished(RequestViewCallWatcher* watcher)
// forcibly set the percent (should be 100). Since the job missed out on that too. // forcibly set the percent (should be 100). Since the job missed out on that too.
client->asyncCall(QLatin1String("setPercent"), m_percent); client->asyncCall(QLatin1String("setPercent"), m_percent);
client->asyncCall(QLatin1String("terminate"), m_error); client->asyncCall(QLatin1String("setError"), m_error);
client->asyncCall(QLatin1String("terminate"), m_errorText);
if (m_currentPendingCalls < 1) { if (m_currentPendingCalls < 1) {
qCDebug(KUISERVER) << "no more async calls left pending..emitting finished so we can have ourselves deleted."; qCDebug(KUISERVER) << "no more async calls left pending..emitting finished so we can have ourselves deleted.";

@ -98,7 +98,10 @@ public:
void setCapabilities(int capabilities); void setCapabilities(int capabilities);
int capabilities() const; int capabilities() const;
QString error() const; void setError(uint errorCode);
uint error() const;
QString errorText() const;
uint state() const; uint state() const;
@ -201,7 +204,9 @@ private:
QString m_infoMessage; ///< The information message to be shown QString m_infoMessage; ///< The information message to be shown
QString m_error; ///< The error message of the job, set when it's terminated uint m_error; ///< The error code of the job, set when it's terminated
QString m_errorText; ///< The error message of the job, set when it's terminated
QString m_totalUnit; ///< The unit used in setTotalAmount QString m_totalUnit; ///< The unit used in setTotalAmount

Loading…
Cancel
Save