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)
onClicked: {
cancelledJobs.push(modelData) // register that it was user-cancelled
var service = jobsSource.serviceForSource(modelData)
var operation = service.operationDescription("stop")
service.startOperationCall(operation)

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

@ -89,7 +89,7 @@ void JobView::timerEvent(QTimerEvent *event)
void JobView::terminate(const QString &errorMessage)
{
setData("error", errorMessage);
setData(QStringLiteral("errorText"), errorMessage);
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 id = 0;

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

@ -33,6 +33,7 @@ JobView::JobView(uint jobId, QObject *parent)
: QObject(parent),
m_capabilities(-1),
m_percent(-1),
m_error(KJob::NoError),
m_totalAmount(0),
m_processAmount(0),
m_jobId(jobId),
@ -57,10 +58,11 @@ void JobView::terminate(const QString &errorMessage)
typedef QPair<QString, QDBusAbstractInterface*> iFacePair;
foreach(const iFacePair &pair, m_objectPaths) {
qCDebug(KUISERVER) << "making async call of terminate for: " << pair.first;
pair.second->asyncCall(QLatin1String("setError"), m_error);
pair.second->asyncCall(QLatin1String("terminate"), errorMessage);
}
m_error = errorMessage;
m_errorText = errorMessage;
if (m_currentPendingCalls < 1) {
// 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;
}
QString JobView::error() const
void JobView::setError(uint errorCode)
{
m_error = errorCode;
}
uint JobView::error() const
{
return m_error;
}
QString JobView::errorText() const
{
return m_errorText;
}
uint JobView::jobId() const
{
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.
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) {
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);
int capabilities() const;
QString error() const;
void setError(uint errorCode);
uint error() const;
QString errorText() const;
uint state() const;
@ -201,7 +204,9 @@ private:
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

Loading…
Cancel
Save