1/* vi: ts=8 sts=4 sw=4
2 *
3 * This file is part of the KDE project, module kdesu.
4 * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
5 *
6 * This is free software; you can use this library under the GNU Library
7 * General Public License, version 2. See the file "COPYING.LIB" for the
8 * exact licensing terms.
9 */
10
11#ifndef __Stub_h_Included__
12#define __Stub_h_Included__
13
14#include <QtCore/QByteRef>
15#include <QtCore/QList>
16
17#include "process.h"
18
19#include <kdesu/kdesu_export.h>
20
21namespace KDESu {
22
23namespace KDESuPrivate { class KCookie; }
24
25
26/** \class StubProcess stub.h kdesu/stub.h
27 * Chat with kdesu_stub.
28 *
29 * StubProcess extends PtyProcess with functionality to chat with kdesu_stub.
30 */
31
32class KDESU_EXPORT StubProcess: public PtyProcess
33{
34public:
35 StubProcess();
36 ~StubProcess();
37
38 /**
39 * Set the command.
40 */
41 void setCommand(const QByteArray &command);
42
43 /**
44 * Set the target user.
45 */
46 void setUser(const QByteArray &user);
47
48 /**
49 * Set to "X only mode": Sycoca is not built and kdeinit is not launched.
50 */
51 void setXOnly(bool xonly);
52
53 /**
54 * Set the priority of the process. The priority value must be between 0
55 * and 100, 0 being the lowest priority. This value is mapped to the
56 * scheduler and system dependent priority range of the OS.
57 */
58 void setPriority(int prio);
59
60 /**
61 * Different schedulers. SchedNormal is the normal Unix timesharing
62 * scheduler, while SchedRealtime is a POSIX.1b realtime scheduler.
63 */
64 enum Scheduler { SchedNormal, SchedRealtime };
65
66 /**
67 * Set the scheduler type.
68 */
69 void setScheduler(int sched);
70
71protected:
72
73 /**
74 * Exchange all parameters with kdesu_stub.
75 */
76 int ConverseStub(int check);
77
78 /**
79 * This virtual function can be overloaded when special behavior is
80 * desired. By default, it returns the value returned by KCookie.
81 */
82 virtual QByteArray display();
83#ifdef Q_WS_X11
84 /**
85 * See display.
86 */
87 virtual QByteArray displayAuth();
88#endif
89 bool m_bXOnly;
90 int m_Priority;
91 int m_Scheduler;
92 QByteArray m_Command;
93 QByteArray m_User;
94 KDESuPrivate::KCookie *m_pCookie;
95
96private:
97 QByteArray commaSeparatedList(const QList<QByteArray> &);
98 void writeString(const QByteArray &str);
99
100protected:
101 virtual void virtual_hook( int id, void* data );
102private:
103 class StubProcessPrivate;
104 StubProcessPrivate * const d;
105};
106
107}
108
109#endif // __Stub_h_Included__
110