kde-plasma

This commit is contained in:
Rmys
2025-01-21 15:46:21 +03:00
parent 366d8c1820
commit 4a2b60c149
135 changed files with 3886 additions and 23672 deletions
@@ -3,7 +3,7 @@ index 9fef4ec..939d055 100644
--- a/processcore/CMakeLists.txt
+++ b/processcore/CMakeLists.txt
@@ -41,18 +41,18 @@ install( FILES processes.h process.h DESTINATION ${INCLUDE_INSTALL_DIR}/ksysguar
#------ KAuth stuff
#------ kauth stuff
# Auth example helper
-# set(ksysguardprocesslist_helper_srcs
@@ -28,7 +28,7 @@ index 9fef4ec..939d055 100644
+
+add_executable(ksysguardprocesslist_helper ${ksysguardprocesslist_helper_srcs})
+target_link_libraries(ksysguardprocesslist_helper Qt5::Core KF5::Auth KF5::I18n)
+install(TARGETS ksysguardprocesslist_helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
+install(TARGETS ksysguardprocesslist_helper DESTINATION ${kauth_HELPER_INSTALL_DIR})
+
+kauth_install_helper_files(ksysguardprocesslist_helper org.kde.ksysguard.processlisthelper root)
+kauth_install_actions(org.kde.ksysguard.processlisthelper actions.actions)
@@ -43,7 +43,7 @@ index 6c1f570..c34ab1e 100644
#include "helper.h"
#include "processes_local_p.h"
+using namespace KAuth;
+using namespace kauth;
+
KSysGuardProcessListHelper::KSysGuardProcessListHelper()
{
@@ -51,9 +51,9 @@ index 6c1f570..c34ab1e 100644
}
/* The functions here run as ROOT. So be careful. DO NOT TRUST THE INPUTS TO BE SANE. */
-#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return KAuth::ActionReply::HelperErrorReply;
-KAuth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
- KAuth::ActionReply errorReply(KAuth::ActionReply::HelperError);
-#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return kauth::ActionReply::HelperErrorReply;
-kauth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
- kauth::ActionReply errorReply(kauth::ActionReply::HelperError);
+#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toULongLong(); if(pid < 0) return ActionReply(ActionReply::HelperErrorType);
+ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters) {
+ ActionReply reply(ActionReply::HelperErrorType);
@@ -75,11 +75,11 @@ index 6c1f570..c34ab1e 100644
}
KSysGuard::ProcessesLocal processes;
@@ -56,17 +58,17 @@ KAuth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters
@@ -56,17 +58,17 @@ kauth::ActionReply KSysGuardProcessListHelper::sendsignal(QVariantMap parameters
success = successForThisPid && success;
}
if(success) {
- return KAuth::ActionReply::SuccessReply;
- return kauth::ActionReply::SuccessReply;
+ return ActionReply::SuccessReply();
} else {
- errorReply.setErrorDescription(QString("Could not send signal to: ") + errorList.join(", "));
@@ -91,64 +91,64 @@ index 6c1f570..c34ab1e 100644
}
}
-KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
-kauth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
+ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
if(!parameters.contains("nicevalue") || !parameters.contains("pidcount"))
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
KSysGuard::ProcessesLocal processes;
int niceValue = qvariant_cast<int>(parameters.value("nicevalue"));
@@ -77,14 +79,14 @@ KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
@@ -77,14 +79,14 @@ kauth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
success = processes.setNiceness(pid, niceValue) && success;
}
if(success)
- return KAuth::ActionReply::SuccessReply;
- return kauth::ActionReply::SuccessReply;
+ return ActionReply::SuccessReply();
else
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
}
-KAuth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
-kauth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
+ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters) {
if(!parameters.contains("ioScheduler") || !parameters.contains("ioSchedulerPriority") || !parameters.contains("pidcount"))
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
KSysGuard::ProcessesLocal processes;
int ioScheduler = qvariant_cast<int>(parameters.value("ioScheduler"));
@@ -96,14 +98,14 @@ KAuth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap par
@@ -96,14 +98,14 @@ kauth::ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap par
success = processes.setIoNiceness(pid, ioScheduler, ioSchedulerPriority) && success;
}
if(success)
- return KAuth::ActionReply::SuccessReply;
- return kauth::ActionReply::SuccessReply;
+ return ActionReply::SuccessReply();
else
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
}
-KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
-kauth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
+ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
if(!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount"))
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
KSysGuard::ProcessesLocal processes;
int cpuScheduler = qvariant_cast<int>(parameters.value("cpuScheduler"));
@@ -116,9 +118,9 @@ KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap pa
@@ -116,9 +118,9 @@ kauth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap pa
success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success;
}
if(success)
- return KAuth::ActionReply::SuccessReply;
- return kauth::ActionReply::SuccessReply;
+ return ActionReply::SuccessReply();
else
- return KAuth::ActionReply::HelperErrorReply;
- return kauth::ActionReply::HelperErrorReply;
+ return ActionReply(ActionReply::HelperErrorType);
}
KAUTH_HELPER_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper)
kauth_HELPER_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper)
diff --git a/processcore/processes_linux_p.cpp b/processcore/processes_linux_p.cpp
index 65b8dfd..0cff0e8 100644
--- a/processcore/processes_linux_p.cpp
@@ -180,8 +180,8 @@ index 1651a0a..ba9d8c9 100644
int totalRowCount(const QModelIndex &parent) const;
/** Helper function to setup 'action' with the given pids */
- void setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const;
+ void setupKAuthAction(KAuth::Action &action, const QList<long long> & pids) const;
- void setupkauthAction(kauth::Action *action, const QList<long long> & pids) const;
+ void setupkauthAction(kauth::Action &action, const QList<long long> & pids) const;
/** fire a timer event if we are set to use our internal timer*/
void fireTimerEvent();
@@ -189,8 +189,8 @@ index 1651a0a..ba9d8c9 100644
return total;
}
-void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const
+void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action &action, const QList<long long> & pids) const
-void KSysGuardProcessListPrivate::setupkauthAction(kauth::Action *action, const QList<long long> & pids) const
+void KSysGuardProcessListPrivate::setupkauthAction(kauth::Action &action, const QList<long long> & pids) const
{
- action->setHelperId("org.kde.ksysguard.processlisthelper");
+ action.setHelperId("org.kde.ksysguard.processlisthelper");
@@ -208,23 +208,23 @@ index 1651a0a..ba9d8c9 100644
@@ -1023,23 +1026,19 @@ bool KSysGuardProcessList::reniceProcesses(const QList<long long> &pids, int nic
#warning KAuth needs porting, but docu is not adjusted, no idea how to do it
#warning kauth needs porting, but docu is not adjusted, no idea how to do it
-#if 0
- KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.renice");
- kauth::Action *action = new kauth::Action("org.kde.ksysguard.processlisthelper.renice");
- action->setParentWidget(window());
+ KAuth::Action action("org.kde.ksysguard.processlisthelper.renice");
+ kauth::Action action("org.kde.ksysguard.processlisthelper.renice");
+ action.setParentWidget(window());
d->setupKAuthAction( action, unreniced_pids);
d->setupkauthAction( action, unreniced_pids);
- action->addArgument("nicevalue", niceValue);
- KAuth::ActionReply reply = action->execute();
- kauth::ActionReply reply = action->execute();
+ action.addArgument("nicevalue", niceValue);
+ KAuth::ExecuteJob *job = action.execute();
+ kauth::ExecuteJob *job = action.execute();
- if (reply == KAuth::ActionReply::SuccessReply) {
- if (reply == kauth::ActionReply::SuccessReply) {
+ if (job->exec()) {
updateList();
- delete action;
- } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- } else if (reply != kauth::ActionReply::UserCancelled && reply != kauth::ActionReply::AuthorizationDenied) {
+ } else if (!job->exec()) {
KMessageBox::sorry(this, i18n("You do not have the permission to renice the process and there "
- "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
@@ -239,27 +239,27 @@ index 1651a0a..ba9d8c9 100644
@@ -1189,26 +1188,22 @@ bool KSysGuardProcessList::changeIoScheduler(const QList< long long> &pids, KSys
if(!d->mModel.isLocalhost()) return false; //We can't use kauth to affect non-localhost processes
#warning KAuth needs porting, but docu is not adjusted, no idea how to do it
#warning kauth needs porting, but docu is not adjusted, no idea how to do it
-#if 0
- KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.changeioscheduler");
- kauth::Action *action = new kauth::Action("org.kde.ksysguard.processlisthelper.changeioscheduler");
- action->setParentWidget(window());
+ KAuth::Action action("org.kde.ksysguard.processlisthelper.changeioscheduler");
+ kauth::Action action("org.kde.ksysguard.processlisthelper.changeioscheduler");
+ action.setParentWidget(window());
d->setupKAuthAction( action, unchanged_pids);
d->setupkauthAction( action, unchanged_pids);
- action->addArgument("ioScheduler", (int)newIoSched);
- action->addArgument("ioSchedulerPriority", newIoSchedPriority);
+ action.addArgument("ioScheduler", (int)newIoSched);
+ action.addArgument("ioSchedulerPriority", newIoSchedPriority);
- KAuth::ActionReply reply = action->execute();
+ KAuth::ExecuteJob *job = action.execute();
- kauth::ActionReply reply = action->execute();
+ kauth::ExecuteJob *job = action.execute();
- if (reply == KAuth::ActionReply::SuccessReply) {
- if (reply == kauth::ActionReply::SuccessReply) {
+ if (job->exec()) {
updateList();
- delete action;
- } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- } else if (reply != kauth::ActionReply::UserCancelled && reply != kauth::ActionReply::AuthorizationDenied) {
+ } else if (!job->exec()) {
KMessageBox::sorry(this, i18n("You do not have the permission to change the I/O priority of the process and there "
- "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
@@ -272,27 +272,27 @@ index 1651a0a..ba9d8c9 100644
}
@@ -1226,24 +1221,20 @@ bool KSysGuardProcessList::changeCpuScheduler(const QList< long long> &pids, KSy
if(!d->mModel.isLocalhost()) return false; //We can't use KAuth to affect non-localhost processes
if(!d->mModel.isLocalhost()) return false; //We can't use kauth to affect non-localhost processes
#warning KAuth needs porting, but docu is not adjusted, no idea how to do it
#warning kauth needs porting, but docu is not adjusted, no idea how to do it
-#if 0
- KAuth::Action *action = new KAuth::Action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
- kauth::Action *action = new kauth::Action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
- action->setParentWidget(window());
+ KAuth::Action action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
+ kauth::Action action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
+ action.setParentWidget(window());
d->setupKAuthAction( action, unchanged_pids);
d->setupkauthAction( action, unchanged_pids);
- action->addArgument("cpuScheduler", (int)newCpuSched);
- action->addArgument("cpuSchedulerPriority", newCpuSchedPriority);
- KAuth::ActionReply reply = action->execute();
- kauth::ActionReply reply = action->execute();
+ action.addArgument("cpuScheduler", (int)newCpuSched);
+ action.addArgument("cpuSchedulerPriority", newCpuSchedPriority);
+ KAuth::ExecuteJob *job = action.execute();
+ kauth::ExecuteJob *job = action.execute();
- if (reply == KAuth::ActionReply::SuccessReply) {
- if (reply == kauth::ActionReply::SuccessReply) {
+ if (job->exec()) {
updateList();
- delete action;
- } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- } else if (reply != kauth::ActionReply::UserCancelled && reply != kauth::ActionReply::AuthorizationDenied) {
+ } else if (!job->exec()) {
KMessageBox::sorry(this, i18n("You do not have the permission to change the CPU Scheduler for the process and there "
- "was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
@@ -307,26 +307,26 @@ index 1651a0a..ba9d8c9 100644
@@ -1262,26 +1253,20 @@ bool KSysGuardProcessList::killProcesses(const QList< long long> &pids, int sig)
if(!d->mModel.isLocalhost()) return false; //We can't elevate privileges to kill non-localhost processes
#warning KAuth needs porting, but docu is not adjusted, no idea how to do it
#warning kauth needs porting, but docu is not adjusted, no idea how to do it
-#if 0
KAuth::Action action("org.kde.ksysguard.processlisthelper.sendsignal");
kauth::Action action("org.kde.ksysguard.processlisthelper.sendsignal");
action.setParentWidget(window());
- d->setupKAuthAction( &action, unkilled_pids);
- d->setupkauthAction( &action, unkilled_pids);
+ //action.setHelperId("org.kde.ksysguard.processlisthelper");
+ d->setupKAuthAction( action, unkilled_pids);
+ d->setupkauthAction( action, unkilled_pids);
action.addArgument("signal", sig);
- KAuth::ActionReply reply = action.execute();
+ KAuth::ExecuteJob *job = action.execute();
- kauth::ActionReply reply = action.execute();
+ kauth::ExecuteJob *job = action.execute();
- if (reply == KAuth::ActionReply::SuccessReply) {
- if (reply == kauth::ActionReply::SuccessReply) {
+ if (job->exec()) {
updateList();
- } else if (reply.type() == KAuth::ActionReply::HelperError) {
- } else if (reply.type() == kauth::ActionReply::HelperError) {
- if (reply.errorCode() > 0)
- KMessageBox::sorry(this, i18n("You do not have the permission to kill the process and there "
- "was a problem trying to run as root. %1", reply.errorDescription()));
- return false;
- } else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
- } else if (reply != kauth::ActionReply::UserCancelled && reply != kauth::ActionReply::AuthorizationDenied) {
+ } else if (!job->exec()) {
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 %2", reply.errorCode(), reply.errorDescription()));