KDESu

stubprocess.h
1 /*
2  This file is part of the KDE project, module kdesu.
3  SPDX-FileCopyrightText: 1999, 2000 Geert Jansen <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 #ifndef KDESUSTUBPROCESS_H
9 #define KDESUSTUBPROCESS_H
10 
11 #include "ptyprocess.h"
12 
13 #include <kdesu/kdesu_export.h>
14 
15 #include <QByteArray>
16 #include <QList>
17 
18 namespace KDESu
19 {
20 namespace KDESuPrivate
21 {
22 class KCookie;
23 }
24 class StubProcessPrivate;
25 
26 /** \class StubProcess stubprocess.h KDESu/StubProcess
27  * Chat with kdesu_stub.
28  *
29  * StubProcess extends PtyProcess with functionality to chat with kdesu_stub.
30  */
31 
32 class KDESU_EXPORT StubProcess : public PtyProcess
33 {
34 public:
35  /**
36  * Different schedulers. SchedNormal is the normal Unix timesharing
37  * scheduler, while SchedRealtime is a POSIX.1b realtime scheduler.
38  */
39  enum Scheduler {
40  SchedNormal,
41  SchedRealtime,
42  };
43 
44  StubProcess();
45  ~StubProcess() override;
46 
47  /**
48  * Set the command.
49  */
50  void setCommand(const QByteArray &command);
51 
52  /**
53  * Set the target user.
54  */
55  void setUser(const QByteArray &user);
56 
57  /**
58  * Set to "X only mode": Sycoca is not built and kdeinit is not launched.
59  */
60  void setXOnly(bool xonly);
61 
62  /**
63  * Set the priority of the process. The priority value must be between 0
64  * and 100, 0 being the lowest priority. This value is mapped to the
65  * scheduler and system dependent priority range of the OS.
66  */
67  void setPriority(int prio);
68 
69  /**
70  * Set the scheduler type.
71  */
72  void setScheduler(int sched);
73 
74 protected:
75  void virtual_hook(int id, void *data) override;
76 
77  /**
78  * Exchange all parameters with kdesu_stub.
79  */
80  int converseStub(int check);
81 
82  /**
83  * This virtual function can be overloaded when special behavior is
84  * desired. By default, it returns the value returned by KCookie.
85  */
86  virtual QByteArray display();
87 
88  /**
89  * See display.
90  */
91  virtual QByteArray displayAuth();
92 
93  // KF6 TODO: move to StubProcessPrivate
94  bool m_XOnly;
95  int m_priority;
96  int m_scheduler;
97  QByteArray m_command;
98  QByteArray m_user;
99  KDESuPrivate::KCookie *m_cookie;
100 
101 private:
102  QByteArray commaSeparatedList(const QList<QByteArray> &lst);
103  void writeString(const QByteArray &str);
104 
105 protected:
106  explicit StubProcess(StubProcessPrivate &dd);
107 
108 private:
109  Q_DECLARE_PRIVATE_D(PtyProcess::d, StubProcess)
110 #if KDESU_BUILD_DEPRECATED_SINCE(5, 79)
111  // Unused, kept for ABI compatibility
112  const void *__kdesu_d_do_not_use;
113 #endif
114 };
115 
116 }
117 
118 #endif // KDESUSTUBPROCESS_H
Scheduler
Different schedulers.
Definition: stubprocess.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:48:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.