Diffstat (limited to 'noncore/settings/usermanager/userdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 3654639..75a96a6 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -197,99 +197,102 @@ void UserDialog::setupTab2() | |||
197 | 197 | ||
198 | myTabWidget->addTab(tabpage,"User Groups"); | 198 | myTabWidget->addTab(tabpage,"User Groups"); |
199 | } | 199 | } |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Static function that creates the userinfo dialog. | 202 | * Static function that creates the userinfo dialog. |
203 | * The user will be prompted to add a user. | 203 | * The user will be prompted to add a user. |
204 | * | 204 | * |
205 | * @param uid This is a suggested available UID. | 205 | * @param uid This is a suggested available UID. |
206 | * @param gid This is a suggested available GID. | 206 | * @param gid This is a suggested available GID. |
207 | * | 207 | * |
208 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. | 208 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. |
209 | * | 209 | * |
210 | */ | 210 | */ |
211 | bool UserDialog::addUser(int uid, int gid) | 211 | bool UserDialog::addUser(int uid, int gid) |
212 | { | 212 | { |
213 | QCheckListItem *temp; | 213 | QCheckListItem *temp; |
214 | QFile ozTest; | 214 | QFile ozTest; |
215 | int oz=false; | 215 | int oz=false; |
216 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 216 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
217 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. | 217 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
218 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | 218 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); |
219 | adduserDialog->setCaption(tr("Add User")); | 219 | adduserDialog->setCaption(tr("Add User")); |
220 | adduserDialog->userID=uid; // Set next available UID as default uid. | 220 | adduserDialog->userID=uid; // Set next available UID as default uid. |
221 | adduserDialog->groupID=gid; // Set next available GID as default gid. | 221 | adduserDialog->groupID=gid; // Set next available GID as default gid. |
222 | // Insert default group into groupComboBox | 222 | // Insert default group into groupComboBox |
223 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 223 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
224 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 224 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
225 | // If we're running on OZ, add new users to some default groups. | 225 | // If we're running on OZ, add new users to some default groups. |
226 | if(oz) | 226 | if(oz) |
227 | { | 227 | { |
228 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 228 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
229 | for ( ; iter.current(); ++iter ) | 229 | for ( ; iter.current(); ++iter ) |
230 | { | 230 | { |
231 | temp=(QCheckListItem*)iter.current(); | 231 | temp=(QCheckListItem*)iter.current(); |
232 | if (temp->text()=="video") temp->setOn(true); | 232 | if (temp->text()=="video") temp->setOn(true); |
233 | if (temp->text()=="audio") temp->setOn(true); | 233 | if (temp->text()=="audio") temp->setOn(true); |
234 | if (temp->text()=="time") temp->setOn(true); | 234 | if (temp->text()=="time") temp->setOn(true); |
235 | if (temp->text()=="power") temp->setOn(true); | 235 | if (temp->text()=="power") temp->setOn(true); |
236 | if (temp->text()=="input") temp->setOn(true); | 236 | if (temp->text()=="input") temp->setOn(true); |
237 | if (temp->text()=="sharp") temp->setOn(true); | 237 | if (temp->text()=="sharp") temp->setOn(true); |
238 | if (temp->text()=="tty") temp->setOn(true); | 238 | if (temp->text()=="tty") temp->setOn(true); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | // Show the dialog! | 241 | // Show the dialog! |
242 | if(!(adduserDialog->exec())) return false; | 242 | if(!(adduserDialog->exec())) return false; |
243 | if((adduserDialog->groupComboBox->currentItem()!=0)) | 243 | if((adduserDialog->groupComboBox->currentItem()!=0)) |
244 | { | 244 | { |
245 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 245 | // making the call findGroup() puts the group info in the accounts gr_gid |
246 | adduserDialog->groupID=accounts->gr_gid; | 246 | if (accounts->findGroup(adduserDialog->groupComboBox->currentText())) |
247 | owarn << QString::number(accounts->gr_gid) << oendl; | 247 | { |
248 | adduserDialog->groupID=accounts->gr_gid; | ||
249 | owarn << QString::number(accounts->gr_gid) << oendl; | ||
250 | } | ||
248 | } | 251 | } |
249 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 252 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
250 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 253 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
251 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) | 254 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) |
252 | { | 255 | { |
253 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 256 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
254 | return false; | 257 | return false; |
255 | } | 258 | } |
256 | 259 | ||
257 | // Add User to additional groups. | 260 | // Add User to additional groups. |
258 | QListViewItemIterator it( adduserDialog->groupsListView ); | 261 | QListViewItemIterator it( adduserDialog->groupsListView ); |
259 | for ( ; it.current(); ++it ) | 262 | for ( ; it.current(); ++it ) |
260 | { | 263 | { |
261 | temp=(QCheckListItem*)it.current(); | 264 | temp=(QCheckListItem*)it.current(); |
262 | if (temp->isOn() ) | 265 | if (temp->isOn() ) |
263 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 266 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
264 | } | 267 | } |
265 | // Copy image to pics/users/ | 268 | // Copy image to pics/users/ |
266 | if(!(adduserDialog->userImage.isNull())) | 269 | if(!(adduserDialog->userImage.isNull())) |
267 | { | 270 | { |
268 | QDir d; | 271 | QDir d; |
269 | if(!(d.exists(QPEApplication::qpeDir() + "pics/users"))) | 272 | if(!(d.exists(QPEApplication::qpeDir() + "pics/users"))) |
270 | { | 273 | { |
271 | d.mkdir(QPEApplication::qpeDir() + "pics/users"); | 274 | d.mkdir(QPEApplication::qpeDir() + "pics/users"); |
272 | } | 275 | } |
273 | QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png"; | 276 | QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png"; |
274 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 277 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
275 | adduserDialog->userImage.save(filename,"PNG"); | 278 | adduserDialog->userImage.save(filename,"PNG"); |
276 | } | 279 | } |
277 | 280 | ||
278 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | 281 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? |
279 | accounts->findUser(adduserDialog->loginLineEdit->text()); | 282 | accounts->findUser(adduserDialog->loginLineEdit->text()); |
280 | if(adduserDialog->skelCheckBox->isChecked()) | 283 | if(adduserDialog->skelCheckBox->isChecked()) |
281 | { | 284 | { |
282 | QString command_cp; | 285 | QString command_cp; |
283 | QString command_chown; | 286 | QString command_chown; |
284 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | 287 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); |
285 | system(command_cp); | 288 | system(command_cp); |
286 | 289 | ||
287 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround? | 290 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround? |
288 | system(command_cp); | 291 | system(command_cp); |
289 | 292 | ||
290 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | 293 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); |
291 | system(command_chown); | 294 | system(command_chown); |
292 | } | 295 | } |
293 | 296 | ||
294 | return true; | 297 | return true; |
295 | } | 298 | } |