1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
* kioskrun.h
*
* Copyright (C) 2004 Waldo Bastian <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _KIOSKRUN_H_
#define _KIOSKRUN_H_
#include <tqdict.h>
#include <tqobject.h>
#include <tqregexp.h>
#include <tqstringlist.h>
#include <tqtimer.h>
#include <dcopclient.h>
#include <dcopref.h>
#include <kprogress.h>
class ImmutableStatus;
class TDEConfig;
class TDEProcess;
class KSimpleConfig;
class KioskGui;
class KioskRun : public TQObject
{
friend class KioskGui;
Q_OBJECT
public:
static KioskRun* self() { return s_self; }
void setKdeDirs(const TQStringList &dirs);
void setUser(const TQString &user);
TQString homeDir() { return m_homeDir; }
TQStringList kdeDirs() { return m_kdeDirs; }
TQString desktopPath() { return m_desktopPath; }
// Locate existing anywhere
TQString locate(const char *resource, const TQString &filename=TQString());
// Locate for saving
TQString locateSave(const char *resource, const TQString &filename=TQString());
// Locate for reading saved changed
TQString locateLocal(const char *resource, const TQString &filename=TQString());
// Prepare runtime environment for run()
bool prepare();
// Update sycoca database in runtime environment
void updateSycoca();
// Request sycoca update in install environment after flushing config files
void scheduleSycocaUpdate();
// Request sycoca update in install environment
void forceSycocaUpdate();
// Run a program inside the runtime test environment
TDEProcess* run(const TQString &cmd, const TQStringList &args=TQStringList());
// A DCOPRef to make dcop calls into the runtime test environment
DCOPRef dcopRef(const TQCString &appId, const TQCString &objId);
// A DCOPClient to make dcop calls into the runtime test environment
DCOPClient *dcopClient() { return m_dcopClient; }
// Open config file in the install directory
TDEConfig *configFile(const TQString &filename);
// Make config files temporary mutable.
void makeMutable(bool bMutable);
// Returns whether specific config group is immutable,
// or entire file if group is empty
bool isConfigImmutable(const TQString &filename, const TQString &group);
// Make specific config group immutable,
// or entire file if group is empty
void setConfigImmutable(const TQString &filename, const TQString &group, bool bImmutable);
// Close all opened config files.
bool flushConfigCache();
// Return all config files created by the user
TQStringList newConfigFiles();
// Merge new settings from the test directory into the installation directory
void mergeConfigFile(const TQString &filename);
// Lookup the setting for a custom action
bool lookupCustomAction(const TQString &action);
// Change the setting for a custom action
void setCustomAction(const TQString &action, bool checked);
// Create installation directory and its parent dirs
bool createDir(const TQString &dir);
// Install file
bool install(const TQString &file, const TQString &destination);
// Delete file
bool remove(const TQString &destination);
// Move file or directory
bool move(const TQString &source, const TQString &destination, const TQStringList &files);
// Delete directory in test home dir
void deleteDir(const TQString &);
// Open /etc/kderc for writing
KSimpleConfig *openKderc();
// Install new /etc/kderc
bool closeKderc();
// Read information of profile @p profile
void getProfileInfo(const TQString &profile, TQString &description, TQString &installDir, TQString &installUser);
// Store information for profile @p profile
bool setProfileInfo(const TQString &profile, const TQString &description, const TQString &installDir, const TQString &installUser, bool b=false, bool deleteFiles=true);
// Get new, non-existing, profile name
TQString newProfile();
// Delete profile @p profile
bool deleteProfile(const TQString &profile, bool deleteFiles = true);
// Get list of all existing profiles
TQStringList allProfiles();
// Maps a single group or user to a one or more profiles
typedef TQMap<TQString,TQStringList> ProfileMapping;
// Read mappings between groups/users and profiles
void getUserProfileMappings( ProfileMapping &groups, ProfileMapping &users, TQStringList &groupOrder);
// Store mappings between groups/users and profiles
bool setUserProfileMappings( const ProfileMapping &groups, const ProfileMapping &users, const TQStringList &groupOrder);
// Read profile prefix
TQString getProfilePrefix();
// Store profile prefix
bool setProfilePrefix(const TQString &prefix);
// Create upload directory
bool createRemoteDir(const KURL &dir);
// Create upload directory and all its parent dirs and be polite if ask = true
bool createRemoteDirRecursive(const KURL &dir, bool ask);
// Upload file
bool uploadRemote(const TQString &file, const KURL &dest);
protected:
KioskRun( TQObject* parent = 0, const char* name = 0);
~KioskRun();
bool setupRuntimeEnv();
void shutdownRuntimeEnv();
void setupConfigEnv();
void shutdownConfigEnv();
void applyEnvironment(TDEProcess *p);
TQString saveImmutableStatus(const TQString &filename);
bool restoreImmutableStatus(const TQString &filename, bool force);
void setCustomRestrictionFileBrowsing(bool restrict);
private:
static KioskRun* s_self;
TQString m_homeDir;
TQString m_configDir;
TQString m_desktopPath;
TQString m_user;
TQStringList m_kdeDirs;
TQStringList m_xdgDataDirs;
TQStringList m_xdgConfigDirs;
DCOPClient *m_dcopClient;
TDEInstance *m_instance;
TDEInstance *m_saveInstance;
TQDict<TDEConfig> m_saveConfigCache;
TQDict<ImmutableStatus> m_immutableStatusCache;
bool m_noRestrictions;
bool m_forceSycocaUpdate;
bool m_isRoot;
TQString m_kderc;
TQString m_localKderc;
KSimpleConfig *m_localKdercConfig;
};
class KioskRunProgressDialog : public KProgressDialog
{
Q_OBJECT
public:
KioskRunProgressDialog(TQWidget *parent, const char *name,
const TQString &caption, const TQString &text);
public slots:
void slotProgress();
void slotFinished();
private:
TQTimer m_timer;
int m_timeStep;
};
#endif
|