File indexing completed on 2024-04-28 05:31:40

0001 /*
0002     SPDX-FileCopyrightText: 2007 John Tapsell <tapsell@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef PROCESSES_REMOTE_P_H_
0008 #define PROCESSES_REMOTE_P_H_
0009 
0010 #include "processes_base_p.h"
0011 #include <QSet>
0012 class Process;
0013 namespace KSysGuard
0014 {
0015 /**
0016  * This is used to connect to a remote host
0017  */
0018 class ProcessesRemote : public AbstractProcesses
0019 {
0020     Q_OBJECT
0021 public:
0022     ProcessesRemote(const QString &hostname);
0023     ~ProcessesRemote() override;
0024     QSet<long> getAllPids() override;
0025     long getParentPid(long pid) override;
0026     bool updateProcessInfo(long pid, Process *process) override;
0027     Processes::Error sendSignal(long pid, int sig) override;
0028     Processes::Error setNiceness(long pid, int priority) override;
0029     Processes::Error setScheduler(long pid, int priorityClass, int priority) override;
0030     long long totalPhysicalMemory() override;
0031     Processes::Error setIoNiceness(long pid, int priorityClass, int priority) override;
0032     bool supportsIoNiceness() override;
0033     long numberProcessorCores() override;
0034     void updateAllProcesses(Processes::UpdateFlags updateFlags) override;
0035 
0036 Q_SIGNALS:
0037     /** For a remote machine, we rely on being able to communicate with ksysguardd.
0038      *  This must be dealt with by the program including this widget.  It must listen to our
0039      *  'runCommand' signal, and run the given command, with the given id. */
0040     void runCommand(const QString &command, int id);
0041 
0042 public Q_SLOTS:
0043     /** For a remote machine, we rely on being able to communicate with ksysguardd.
0044      *  The programming using this must call this slot when an answer is received from ksysguardd,
0045      *  in response to a runCommand request.  The id identifies the answer */
0046     void answerReceived(int id, const QList<QByteArray> &answer);
0047     /** Called soon after */
0048     void setup();
0049 
0050 protected:
0051     enum { PsInfo, Ps, UsedMemory, FreeMemory, Kill, Renice, Ionice };
0052 
0053 private:
0054     /**
0055      * You can use this for whatever data you want.  Be careful about preserving state in between getParentPid and updateProcessInfo calls
0056      * if you chose to do that. getParentPid may be called several times for different pids before the relevant updateProcessInfo calls are made.
0057      * This is because the tree structure has to be sorted out first.
0058      */
0059     class Private;
0060     Private *d;
0061 };
0062 }
0063 #endif