~ubuntu-branches/ubuntu/wily/kdebase-workspace/wily

« back to all changes in this revision

Viewing changes to libs/ksysguard/processcore/helper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2011-04-03 16:54:55 UTC
  • mfrom: (1.1.55 upstream)
  • Revision ID: james.westby@ubuntu.com-20110403165455-8tnwxt82p21p15hh
Tags: 4:4.6.2a-0ubuntu1
* New upstream release
  - Update kde-sc-dev-latest version
  - Update kdebase-workspace-wallpapers.install,
    kde-window-manager.install and not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
/* The functions here run as ROOT.  So be careful.  DO NOT TRUST THE INPUTS TO BE SANE. */
32
32
#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return KAuth::ActionReply::HelperErrorReply;
33
33
KAuth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
34
 
    if(!parameters.contains("signal") || !parameters.contains("pidcount"))
35
 
        return KAuth::ActionReply::HelperErrorReply;
 
34
    KAuth::ActionReply errorReply(KAuth::ActionReply::HelperError);
 
35
    if(!parameters.contains("signal")) {
 
36
        errorReply.setErrorDescription("Internal error - no signal parameter was passed to the helper");
 
37
        errorReply.setErrorCode(1);
 
38
        return errorReply;
 
39
    }
 
40
    if(!parameters.contains("pidcount")) {
 
41
        errorReply.setErrorDescription("Internal error - no pidcount parameter was passed to the helper");
 
42
        errorReply.setErrorCode(2);
 
43
        return errorReply;
 
44
    }
36
45
 
37
46
    KSysGuard::ProcessesLocal processes;
38
47
    int signal = qvariant_cast<int>(parameters.value("signal"));
39
48
    bool success = true;
40
49
    int numProcesses = parameters.value("pidcount").toInt();
 
50
    QStringList errorList;
41
51
    for (int i = 0; i < numProcesses; ++i) {
42
52
        qlonglong pid = GET_PID(i);
43
 
        success = processes.sendSignal(pid, signal) && success;
 
53
        bool successForThisPid = processes.sendSignal(pid, signal);
 
54
        if (!successForThisPid)
 
55
            errorList << QString::number(pid);
 
56
        success = successForThisPid && success;
44
57
    }
45
 
    if(success)
 
58
    if(success) {
46
59
        return KAuth::ActionReply::SuccessReply;
47
 
    else
48
 
        return KAuth::ActionReply::HelperErrorReply;
 
60
    } else {
 
61
        errorReply.setErrorDescription(QString("Could not send signal to: ") + errorList.join(", "));
 
62
        errorReply.setErrorCode(0);
 
63
        return errorReply;
 
64
    }
49
65
}
50
66
 
51
67
KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {