author | umopapisdn <umopapisdn> | 2002-11-01 21:29:35 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2002-11-01 21:29:35 (UTC) |
commit | 7ccfa11a1ccbb4cfb047bd1fa1eb19402d9c8dd6 (patch) (unidiff) | |
tree | bb2d0b7a66a188ffd7ad6f9729b9691aa8452682 | |
parent | 89567519b98853932093e06af4a28f6cc4cc8fd9 (diff) | |
download | opie-7ccfa11a1ccbb4cfb047bd1fa1eb19402d9c8dd6.zip opie-7ccfa11a1ccbb4cfb047bd1fa1eb19402d9c8dd6.tar.gz opie-7ccfa11a1ccbb4cfb047bd1fa1eb19402d9c8dd6.tar.bz2 |
* "Copy /etc/skel" option is now only available when adding a user.
* Documented some more of the source code.
-rw-r--r-- | noncore/settings/usermanager/passwd.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.h | 9 |
3 files changed, 51 insertions, 16 deletions
diff --git a/noncore/settings/usermanager/passwd.cpp b/noncore/settings/usermanager/passwd.cpp index 5063661..0a2bfba 100644 --- a/noncore/settings/usermanager/passwd.cpp +++ b/noncore/settings/usermanager/passwd.cpp | |||
@@ -48,12 +48,13 @@ char *Passwd::crypt_make_salt() { | |||
48 | result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077); | 48 | result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077); |
49 | result[1] = i64c(((x >> 12) ^ x) & 077); | 49 | result[1] = i64c(((x >> 12) ^ x) & 077); |
50 | result[2] = '\0'; | 50 | result[2] = '\0'; |
51 | return result; | 51 | return result; |
52 | } | 52 | } |
53 | 53 | ||
54 | // opens the files /etc/passwd & /etc/group and loads the contents into passwdStringList & groupStringList | ||
54 | bool Passwd::open() { | 55 | bool Passwd::open() { |
55 | int returnvalue=false; | 56 | int returnvalue=false; |
56 | 57 | ||
57 | QFile passwd_file("/etc/passwd"); | 58 | QFile passwd_file("/etc/passwd"); |
58 | QFile group_file("/etc/group"); | 59 | QFile group_file("/etc/group"); |
59 | passwdStringList.clear(); | 60 | passwdStringList.clear(); |
@@ -73,12 +74,13 @@ bool Passwd::open() { | |||
73 | } | 74 | } |
74 | passwd_file.close(); | 75 | passwd_file.close(); |
75 | } | 76 | } |
76 | return returnvalue; | 77 | return returnvalue; |
77 | } | 78 | } |
78 | 79 | ||
80 | // Writes back the contents of passwdStringList to /etc/passwd & groupStringList to /etc/group | ||
79 | bool Passwd::close() { | 81 | bool Passwd::close() { |
80 | int returnvalue=false; | 82 | int returnvalue=false; |
81 | QFile passwd_file("/etc/passwd"); | 83 | QFile passwd_file("/etc/passwd"); |
82 | QFile group_file("/etc/group"); | 84 | QFile group_file("/etc/group"); |
83 | if((passwd_file.open(IO_WriteOnly))) { | 85 | if((passwd_file.open(IO_WriteOnly))) { |
84 | if((group_file.open(IO_WriteOnly))) { | 86 | if((group_file.open(IO_WriteOnly))) { |
@@ -95,54 +97,60 @@ bool Passwd::close() { | |||
95 | } | 97 | } |
96 | passwd_file.close(); | 98 | passwd_file.close(); |
97 | } | 99 | } |
98 | return returnvalue; | 100 | return returnvalue; |
99 | } | 101 | } |
100 | 102 | ||
103 | // Splits a "passwd" line into the components and stores them in the pw_* variables. | ||
101 | void Passwd::splitPasswdEntry(QString &userString) { | 104 | void Passwd::splitPasswdEntry(QString &userString) { |
102 | userdataStringList=QStringList::split(":",userString,true); | 105 | userdataStringList=QStringList::split(":",userString,true); |
103 | QStringList::Iterator it=userdataStringList.begin(); | 106 | QStringList::Iterator it=userdataStringList.begin(); |
104 | pw_name=(*it++); | 107 | pw_name=(*it++); |
105 | pw_passwd=(*it++); | 108 | pw_passwd=(*it++); |
106 | pw_uid=(*it++).toInt(); | 109 | pw_uid=(*it++).toInt(); |
107 | pw_gid=(*it++).toInt(); | 110 | pw_gid=(*it++).toInt(); |
108 | pw_gecos=(*it++); | 111 | pw_gecos=(*it++); |
109 | pw_dir=(*it++); | 112 | pw_dir=(*it++); |
110 | pw_shell=(*it++); | 113 | pw_shell=(*it++); |
111 | } | 114 | } |
112 | 115 | ||
116 | // Splits a "group" line into the components and stores them in the gr_* variables. | ||
113 | void Passwd::splitGroupEntry(QString &groupString) { | 117 | void Passwd::splitGroupEntry(QString &groupString) { |
114 | groupdataStringList=QStringList::split(":",groupString,true); | 118 | groupdataStringList=QStringList::split(":",groupString,true); |
115 | QStringList::Iterator it=groupdataStringList.begin(); | 119 | QStringList::Iterator it=groupdataStringList.begin(); |
116 | gr_name=(*it++); | 120 | gr_name=(*it++); |
117 | it++; | 121 | it++; |
118 | gr_gid=(*it++).toInt(); | 122 | gr_gid=(*it++).toInt(); |
119 | gr_mem=QStringList::split(" ",(*it++)); | 123 | gr_mem=QStringList::split(" ",(*it++)); |
120 | } | 124 | } |
121 | 125 | ||
126 | // Find a user in the passwdStringList. Return true if found and also fill the pw_* variables. | ||
122 | bool Passwd::searchUser(QRegExp &userRegExp) { | 127 | bool Passwd::searchUser(QRegExp &userRegExp) { |
123 | QStringList tempStringList(passwdStringList.grep(userRegExp)); | 128 | QStringList tempStringList(passwdStringList.grep(userRegExp)); |
124 | if((tempStringList.isEmpty())) { | 129 | if((tempStringList.isEmpty())) { |
125 | return false; | 130 | return false; |
126 | } else { | 131 | } else { |
127 | userString=(*(tempStringList.begin())); | 132 | userString=(*(tempStringList.begin())); |
128 | splitPasswdEntry(userString); | 133 | splitPasswdEntry(userString); |
129 | } | 134 | } |
130 | return true; | 135 | return true; |
131 | } | 136 | } |
132 | 137 | ||
138 | // Find a user by login. | ||
133 | bool Passwd::findUser(const char *username) { | 139 | bool Passwd::findUser(const char *username) { |
134 | QRegExp userRegExp(QString("^%1\\:").arg(username)); | 140 | QRegExp userRegExp(QString("^%1\\:").arg(username)); |
135 | return searchUser(userRegExp); | 141 | return searchUser(userRegExp); |
136 | } | 142 | } |
137 | 143 | ||
144 | // Find a user by uid. | ||
138 | bool Passwd::findUser(int uid) { | 145 | bool Passwd::findUser(int uid) { |
139 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); | 146 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); |
140 | return searchUser(userRegExp); | 147 | return searchUser(userRegExp); |
141 | } | 148 | } |
142 | 149 | ||
150 | // Add a user to the passwdStringList, create home directory, and optionally create a group for the user. | ||
143 | bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup) { | 151 | bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup) { |
144 | QString tempString; | 152 | QString tempString; |
145 | if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid); | 153 | if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid); |
146 | pw_passwd = crypt(pw_passwd, crypt_make_salt()); | 154 | pw_passwd = crypt(pw_passwd, crypt_make_salt()); |
147 | tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell; | 155 | tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell; |
148 | passwdStringList.append(tempString); | 156 | passwdStringList.append(tempString); |
@@ -153,73 +161,82 @@ bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, | |||
153 | chown(pw_dir,pw_uid,pw_gid); | 161 | chown(pw_dir,pw_uid,pw_gid); |
154 | chmod(pw_dir,S_IRUSR|S_IWUSR|S_IXUSR); | 162 | chmod(pw_dir,S_IRUSR|S_IWUSR|S_IXUSR); |
155 | } | 163 | } |
156 | return 1; | 164 | return 1; |
157 | } | 165 | } |
158 | 166 | ||
167 | // Update info for a user in passwdStringList, take info from the pw_* fields. | ||
159 | bool Passwd::updateUser(QString login) { | 168 | bool Passwd::updateUser(QString login) { |
160 | QRegExp userRegExp(QString("^%1\\:").arg(login)); | 169 | QRegExp userRegExp(QString("^%1\\:").arg(login)); |
161 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { | 170 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { |
162 | if(userRegExp.find((*it),0)!=-1) { | 171 | if(userRegExp.find((*it),0)!=-1) { |
163 | *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell); | 172 | *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell); |
164 | return true; | 173 | return true; |
165 | } | 174 | } |
166 | } | 175 | } |
167 | return false; | 176 | return false; |
168 | } | 177 | } |
169 | 178 | ||
179 | // Delete a user from passwdStringList. | ||
170 | bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) { | 180 | bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) { |
171 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { | 181 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { |
172 | if(userRegExp.find((*it),0)!=-1) { | 182 | if(userRegExp.find((*it),0)!=-1) { |
173 | splitPasswdEntry(*it); | 183 | splitPasswdEntry(*it); |
174 | if(delGroup) this->delGroup(pw_gid); | 184 | if(delGroup) this->delGroup(pw_gid); |
175 | passwdStringList.remove(it); | 185 | passwdStringList.remove(it); |
176 | return true; | 186 | return true; |
177 | } | 187 | } |
178 | } | 188 | } |
179 | return false; | 189 | return false; |
180 | } | 190 | } |
181 | 191 | ||
192 | // Delete a user by login, and optionally also delete group. | ||
182 | bool Passwd::delUser(const char *username, bool delGroup) { | 193 | bool Passwd::delUser(const char *username, bool delGroup) { |
183 | QRegExp userRegExp(QString("^%1\\:").arg(username)); | 194 | QRegExp userRegExp(QString("^%1\\:").arg(username)); |
184 | return deleteUser(userRegExp,delGroup); | 195 | return deleteUser(userRegExp,delGroup); |
185 | } | 196 | } |
186 | 197 | ||
198 | // Delete a user by uid, and optionally also delete group. | ||
187 | bool Passwd::delUser(int uid, bool delGroup) { | 199 | bool Passwd::delUser(int uid, bool delGroup) { |
188 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); | 200 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); |
189 | return deleteUser(userRegExp,delGroup); | 201 | return deleteUser(userRegExp,delGroup); |
190 | } | 202 | } |
191 | 203 | ||
204 | // Locate a group in the groupStringList, fill out the gr_* variables and return "true" if found. | ||
192 | bool Passwd::searchGroup(QRegExp &groupRegExp) { | 205 | bool Passwd::searchGroup(QRegExp &groupRegExp) { |
193 | QStringList tempStringList(groupStringList.grep(groupRegExp)); | 206 | QStringList tempStringList(groupStringList.grep(groupRegExp)); |
194 | if((tempStringList.isEmpty())) { | 207 | if((tempStringList.isEmpty())) { |
195 | return false; | 208 | return false; |
196 | } else { | 209 | } else { |
197 | groupString=(*(tempStringList.begin())); | 210 | groupString=(*(tempStringList.begin())); |
198 | splitGroupEntry(groupString); | 211 | splitGroupEntry(groupString); |
199 | } | 212 | } |
200 | return true; | 213 | return true; |
201 | } | 214 | } |
202 | 215 | ||
216 | // Find a group by groupname. | ||
203 | bool Passwd::findGroup(const char *groupname) { | 217 | bool Passwd::findGroup(const char *groupname) { |
204 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); | 218 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); |
205 | return searchGroup(groupRegExp); | 219 | return searchGroup(groupRegExp); |
206 | } | 220 | } |
207 | 221 | ||
222 | // Find a group by gid. | ||
208 | bool Passwd::findGroup(int gid) { | 223 | bool Passwd::findGroup(int gid) { |
209 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); | 224 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); |
210 | return searchGroup(groupRegExp); | 225 | return searchGroup(groupRegExp); |
211 | } | 226 | } |
212 | 227 | ||
228 | // Add a group to groupStringList | ||
213 | bool Passwd::addGroup(QString gr_name, int gr_gid) { | 229 | bool Passwd::addGroup(QString gr_name, int gr_gid) { |
214 | QString tempString; | 230 | QString tempString; |
215 | tempString=gr_name+":*:"+QString::number(gr_gid)+":"; | 231 | tempString=gr_name+":*:"+QString::number(gr_gid)+":"; |
216 | groupStringList.append(tempString); | 232 | groupStringList.append(tempString); |
217 | return 1; | 233 | return 1; |
218 | } | 234 | } |
219 | 235 | ||
236 | // Update fields for a group in groupStringList, take info from the gr_* variables. | ||
220 | bool Passwd::updateGroup(int gid) { | 237 | bool Passwd::updateGroup(int gid) { |
221 | QRegExp groupRegExp(QString(":%1\\:").arg(QString::number(gid))); | 238 | QRegExp groupRegExp(QString(":%1\\:").arg(QString::number(gid))); |
222 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { | 239 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { |
223 | if(groupRegExp.find((*it),0)!=-1) { | 240 | if(groupRegExp.find((*it),0)!=-1) { |
224 | *it=QString(gr_name+":*:"+QString::number(gr_gid)+":"); | 241 | *it=QString(gr_name+":*:"+QString::number(gr_gid)+":"); |
225 | for(QStringList::Iterator member=gr_mem.begin(); member!=gr_mem.end(); ++member) { | 242 | for(QStringList::Iterator member=gr_mem.begin(); member!=gr_mem.end(); ++member) { |
@@ -229,46 +246,52 @@ bool Passwd::updateGroup(int gid) { | |||
229 | return true; | 246 | return true; |
230 | } | 247 | } |
231 | } | 248 | } |
232 | return false; | 249 | return false; |
233 | } | 250 | } |
234 | 251 | ||
252 | // Delete a group from groupStringList. | ||
235 | bool Passwd::deleteGroup(QRegExp &groupRegExp) { | 253 | bool Passwd::deleteGroup(QRegExp &groupRegExp) { |
236 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { | 254 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { |
237 | if(groupRegExp.find((*it),0)!=-1) { | 255 | if(groupRegExp.find((*it),0)!=-1) { |
238 | groupStringList.remove(it); | 256 | groupStringList.remove(it); |
239 | return true; | 257 | return true; |
240 | } | 258 | } |
241 | } | 259 | } |
242 | return false; | 260 | return false; |
243 | } | 261 | } |
244 | 262 | ||
263 | // Delete a group by groupname. | ||
245 | bool Passwd::delGroup(const char *groupname) { | 264 | bool Passwd::delGroup(const char *groupname) { |
246 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); | 265 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); |
247 | return deleteGroup(groupRegExp); | 266 | return deleteGroup(groupRegExp); |
248 | } | 267 | } |
249 | 268 | ||
269 | // Delete a group by gid. | ||
250 | bool Passwd::delGroup(int gid) { | 270 | bool Passwd::delGroup(int gid) { |
251 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); | 271 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); |
252 | return deleteGroup(groupRegExp); | 272 | return deleteGroup(groupRegExp); |
253 | } | 273 | } |
254 | 274 | ||
275 | // Add a user as a member to a group in groupStringList. | ||
255 | bool Passwd::addGroupMember(QString groupname, QString member) { | 276 | bool Passwd::addGroupMember(QString groupname, QString member) { |
256 | if(!(findGroup(groupname))) return false; | 277 | if(!(findGroup(groupname))) return false; |
257 | gr_mem << member; | 278 | gr_mem << member; |
258 | if(!(updateGroup(gr_gid))) return false; | 279 | if(!(updateGroup(gr_gid))) return false; |
259 | return true; | 280 | return true; |
260 | } | 281 | } |
261 | 282 | ||
283 | // Delete a user as a groupmember from a group in groupStringList. | ||
262 | bool Passwd::delGroupMember(QString groupname, QString member) { | 284 | bool Passwd::delGroupMember(QString groupname, QString member) { |
263 | if(!(findGroup(groupname))) return false; | 285 | if(!(findGroup(groupname))) return false; |
264 | for(QStringList::Iterator it=gr_mem.begin(); it!=gr_mem.end(); ++it) { | 286 | for(QStringList::Iterator it=gr_mem.begin(); it!=gr_mem.end(); ++it) { |
265 | if(*it==member) { | 287 | if(*it==member) { |
266 | gr_mem.remove(it); | 288 | gr_mem.remove(it); |
267 | it=gr_mem.end(); | 289 | it=gr_mem.end(); |
268 | } | 290 | } |
269 | } | 291 | } |
270 | if(!(updateGroup(gr_gid))) return false; | 292 | if(!(updateGroup(gr_gid))) return false; |
271 | return true; | 293 | return true; |
272 | } | 294 | } |
273 | 295 | ||
296 | // Global Object | ||
274 | Passwd *accounts; | 297 | Passwd *accounts; |
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 36bcf86..c82cc9d 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -29,13 +29,14 @@ using namespace Opie; | |||
29 | 29 | ||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | UserDialog::UserDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { | 35 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { |
36 | vm=viewmode; | ||
36 | QVBoxLayout *layout = new QVBoxLayout(this); | 37 | QVBoxLayout *layout = new QVBoxLayout(this); |
37 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 38 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
38 | layout->addWidget(myTabWidget); | 39 | layout->addWidget(myTabWidget); |
39 | setupTab1(); | 40 | setupTab1(); |
40 | setupTab2(); | 41 | setupTab2(); |
41 | 42 | ||
@@ -106,19 +107,19 @@ void UserDialog::setupTab1() { | |||
106 | 107 | ||
107 | // Primary Group | 108 | // Primary Group |
108 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 109 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
109 | groupLabel->setText("Primary group: "); | 110 | groupLabel->setText("Primary group: "); |
110 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 111 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
111 | 112 | ||
112 | // Copy /etc/skel | 113 | if(vm==VIEWMODE_NEW) { |
113 | QLabel *skelLabel=new QLabel(tabpage,"skel"); | 114 | // Copy /etc/skel |
114 | skelLabel->setText("Copy /etc/skel: "); | 115 | skelLabel=new QLabel(tabpage,"skel"); |
115 | skelCheckBox=new QCheckBox(tabpage); | 116 | skelLabel->setText("Copy /etc/skel: "); |
116 | skelCheckBox->setChecked(true); | 117 | skelCheckBox=new QCheckBox(tabpage); |
117 | //skelLabel->setDisabled(true); | 118 | skelCheckBox->setChecked(true); |
118 | //skelCheckBox->setDisabled(true); | 119 | } |
119 | 120 | ||
120 | // Widget layout | 121 | // Widget layout |
121 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 122 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
122 | layout->addWidget(picturePushButton); | 123 | layout->addWidget(picturePushButton); |
123 | layout->addSpacing(5); | 124 | layout->addSpacing(5); |
124 | layout->addLayout(hlayout); | 125 | layout->addLayout(hlayout); |
@@ -133,28 +134,32 @@ void UserDialog::setupTab1() { | |||
133 | vlayout1->addSpacing(5); | 134 | vlayout1->addSpacing(5); |
134 | vlayout1->addWidget(passwordLabel); | 135 | vlayout1->addWidget(passwordLabel); |
135 | vlayout1->addSpacing(5); | 136 | vlayout1->addSpacing(5); |
136 | vlayout1->addWidget(shellLabel); | 137 | vlayout1->addWidget(shellLabel); |
137 | vlayout1->addSpacing(5); | 138 | vlayout1->addSpacing(5); |
138 | vlayout1->addWidget(groupLabel); | 139 | vlayout1->addWidget(groupLabel); |
139 | vlayout1->addSpacing(5); | 140 | if(vm==VIEWMODE_NEW) { |
140 | vlayout1->addWidget(skelLabel); | 141 | vlayout1->addSpacing(5); |
142 | vlayout1->addWidget(skelLabel); | ||
143 | } | ||
141 | // Second column, data | 144 | // Second column, data |
142 | vlayout2->addWidget(loginLineEdit); | 145 | vlayout2->addWidget(loginLineEdit); |
143 | vlayout2->addSpacing(5); | 146 | vlayout2->addSpacing(5); |
144 | vlayout2->addWidget(uidLineEdit); | 147 | vlayout2->addWidget(uidLineEdit); |
145 | vlayout2->addSpacing(5); | 148 | vlayout2->addSpacing(5); |
146 | vlayout2->addWidget(gecosLineEdit); | 149 | vlayout2->addWidget(gecosLineEdit); |
147 | vlayout2->addSpacing(5); | 150 | vlayout2->addSpacing(5); |
148 | vlayout2->addWidget(passwordLineEdit); | 151 | vlayout2->addWidget(passwordLineEdit); |
149 | vlayout2->addSpacing(5); | 152 | vlayout2->addSpacing(5); |
150 | vlayout2->addWidget(shellComboBox); | 153 | vlayout2->addWidget(shellComboBox); |
151 | vlayout2->addSpacing(5); | 154 | vlayout2->addSpacing(5); |
152 | vlayout2->addWidget(groupComboBox); | 155 | vlayout2->addWidget(groupComboBox); |
153 | vlayout2->addSpacing(5); | 156 | if(vm==VIEWMODE_NEW) { |
154 | vlayout2->addWidget(skelCheckBox); | 157 | vlayout2->addSpacing(5); |
158 | vlayout2->addWidget(skelCheckBox); | ||
159 | } | ||
155 | hlayout->addLayout(vlayout1); | 160 | hlayout->addLayout(vlayout1); |
156 | hlayout->addLayout(vlayout2); | 161 | hlayout->addLayout(vlayout2); |
157 | 162 | ||
158 | myTabWidget->addTab(tabpage,"User Info"); | 163 | myTabWidget->addTab(tabpage,"User Info"); |
159 | } | 164 | } |
160 | 165 | ||
@@ -193,13 +198,14 @@ void UserDialog::setupTab2() { | |||
193 | */ | 198 | */ |
194 | bool UserDialog::addUser(int uid, int gid) { | 199 | bool UserDialog::addUser(int uid, int gid) { |
195 | QCheckListItem *temp; | 200 | QCheckListItem *temp; |
196 | QFile ozTest; | 201 | QFile ozTest; |
197 | int oz=false; | 202 | int oz=false; |
198 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 203 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
199 | UserDialog *adduserDialog=new UserDialog(); | 204 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
205 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | ||
200 | adduserDialog->setCaption(tr("Add User")); | 206 | adduserDialog->setCaption(tr("Add User")); |
201 | adduserDialog->userID=uid;// Set next available UID as default uid. | 207 | adduserDialog->userID=uid;// Set next available UID as default uid. |
202 | adduserDialog->groupID=gid;// Set next available GID as default gid. | 208 | adduserDialog->groupID=gid;// Set next available GID as default gid. |
203 | // Insert default group into groupComboBox | 209 | // Insert default group into groupComboBox |
204 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 210 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
205 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 211 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
@@ -295,13 +301,14 @@ bool UserDialog::delUser(const char *username) { | |||
295 | * | 301 | * |
296 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 302 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
297 | * | 303 | * |
298 | */ | 304 | */ |
299 | bool UserDialog::editUser(const char *username) { | 305 | bool UserDialog::editUser(const char *username) { |
300 | int invalid_group=0; | 306 | int invalid_group=0; |
301 | UserDialog *edituserDialog=new UserDialog();// Create Dialog | 307 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. |
308 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog | ||
302 | edituserDialog->setCaption(tr("Edit User")); | 309 | edituserDialog->setCaption(tr("Edit User")); |
303 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. | 310 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. |
304 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. | 311 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. |
305 | invalid_group=1; | 312 | invalid_group=1; |
306 | } | 313 | } |
307 | // Fill widgets with userinfo. | 314 | // Fill widgets with userinfo. |
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h index 133b35d..b7b925d 100644 --- a/noncore/settings/usermanager/userdialog.h +++ b/noncore/settings/usermanager/userdialog.h | |||
@@ -39,22 +39,27 @@ private: | |||
39 | 39 | ||
40 | QStringList groupMembers; | 40 | QStringList groupMembers; |
41 | QString pictureLocation; | 41 | QString pictureLocation; |
42 | QImage userImage; | 42 | QImage userImage; |
43 | int groupID; | 43 | int groupID; |
44 | int userID; | 44 | int userID; |
45 | 45 | int vm; | |
46 | enum VIEWMODE { | ||
47 | VIEWMODE_NEW, | ||
48 | VIEWMODE_EDIT | ||
49 | }; | ||
50 | |||
46 | void setupTab1(void); | 51 | void setupTab1(void); |
47 | void setupTab2(void); | 52 | void setupTab2(void); |
48 | void accept(void); | 53 | void accept(void); |
49 | 54 | ||
50 | private slots: | 55 | private slots: |
51 | void clickedPicture(void); | 56 | void clickedPicture(void); |
52 | 57 | ||
53 | public: | 58 | public: |
54 | UserDialog( QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); | 59 | UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); |
55 | ~UserDialog(); | 60 | ~UserDialog(); |
56 | static bool addUser(int uid, int gid); | 61 | static bool addUser(int uid, int gid); |
57 | static bool editUser(const char *username); | 62 | static bool editUser(const char *username); |
58 | static bool delUser(const char *username); | 63 | static bool delUser(const char *username); |
59 | }; | 64 | }; |
60 | 65 | ||