[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/libs/ksysguard/processui
From:       John Tapsell <john.tapsell () kdemail ! net>
Date:       2009-08-31 22:57:52
Message-ID: 1251759472.680789.16127.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1017928 by johnflux:

Use new processcore helper for kauth support


 M  +16 -27    ksysguardprocesslist.cpp  
 M  +0 -3      ksysguardprocesslist.h  


--- trunk/KDE/kdebase/workspace/libs/ksysguard/processui/ksysguardprocesslist.cpp \
#1017927:1017928 @@ -45,6 +45,7 @@
 #include <signal.h> //For SIGTERM
 
 #include <kapplication.h>
+#include <kauth.h>
 #include <kaction.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -72,6 +73,8 @@
 #include "modeltest.h"
 #endif
 
+Q_DECLARE_METATYPE( QList<long long> );
+
 class ProgressBarItemDelegate : public QStyledItemDelegate
 {
     public:
@@ -1170,8 +1173,6 @@
         return false;
     }
 
-    //We must use kdesu to kill the process
-
     QStringList arguments;
     arguments << "--attach" << QString::number(window()->winId()) << \
"--noignorebutton";  if(unchanged_pids.size() == 1) {
@@ -1207,31 +1208,24 @@
         }
     }
     if(unkilled_pids.isEmpty()) return true;
-    if(!d->mModel.isLocalhost()) return false; //We can't use kdesu to kill \
non-localhost processes +    if(!d->mModel.isLocalhost()) return false; //We can't \
elevate privileges to kill non-localhost processes  
-    QString su = KStandardDirs::findExe("kdesu");
-    if(su.isEmpty()) return false;  //Cannot find kdesu
+    KAuth::Action action("org.kde.ksysguardprocesslisthelper.sendsignal");
+    action.addArgument("signal", sig);
+    action.addArgument("pids", qVariantFromValue(unkilled_pids));
+    KAuth::ActionReply reply = action.execute();
 
-    kDebug() << "running " << su;
-    //We must use kdesu to kill the process
-    QStringList arguments;
-    arguments << "--attach" << QString::number(window()->winId()) << \
                "--noignorebutton";
-    arguments << "--" << "kill";
-    if(sig != SIGTERM) {
-        arguments << ('-' + QString::number(sig));
+    if (reply == KAuth::ActionReply::SuccessReply) {
+        updateList();
+        return true;
     }
-
-    for (int i = 0; i < unkilled_pids.size(); ++i) {
-        arguments << QString::number(unkilled_pids.at(i));
+    else {
+        KMessageBox::sorry(this, i18n("You do not have the permission to kill the \
process and there " +                    "was a problem trying to run as root.  Error \
%1 (%1)", reply.errorCode(), reply.errorDescription())); +        return false;
     }
-
-    QProcess *killProcess = new QProcess(NULL);
-    connect(killProcess, SIGNAL(error(QProcess::ProcessError)), this, \
                SLOT(killFailed()));
-    connect(killProcess, SIGNAL(finished( int, QProcess::ExitStatus) ), this, \
                SLOT(updateList()));
-    killProcess->start(su, arguments);
-    return true;  //assume it ran successfully :(  We cannot seem to actually check \
                if it did.  There must be a better solution
-
 }
+
 void KSysGuardProcessList::killSelectedProcesses()
 {
     QModelIndexList selectedIndexes = \
d->mUi->treeView->selectionModel()->selectedRows(); @@ -1281,11 +1275,6 @@
     KMessageBox::sorry(this, i18n("You do not have the permission to renice the \
process and there "  "was a problem trying to run as root."));
 }
-void KSysGuardProcessList::killFailed()
-{
-    KMessageBox::sorry(this, i18n("You do not have the permission to kill the \
                process and there "
-                "was a problem trying to run as root."));
-}
 void KSysGuardProcessList::ioniceFailed()
 {
     KMessageBox::sorry(this, i18n("You do not have the permission to set the I/O \
                priority and there "
--- trunk/KDE/kdebase/workspace/libs/ksysguard/processui/ksysguardprocesslist.h \
#1017927:1017928 @@ -183,9 +183,6 @@
         /** Display a context menu for the selected processes allowing the user to \
kill etc the process */  void showProcessContextMenu(const QPoint &point);
 
-        /** Handle the situation where killing a process has failed - usually due to \
                insufficient rights */
-        void killFailed();
-
         /** Handle the situation where renicing a process has failed - usually due \
to insufficient rights */  void reniceFailed();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic