author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/settings/usermanager/userdialog.cpp | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/settings/usermanager/userdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 5854fe0..3616507 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -1,61 +1,59 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "userdialog.h" | 10 | #include "userdialog.h" |
11 | #include "passwd.h" | 11 | #include "passwd.h" |
12 | 12 | ||
13 | /* OPIE */ | 13 | /* OPIE */ |
14 | #include <opie2/odebug.h> | ||
14 | #include <opie2/odevice.h> | 15 | #include <opie2/odevice.h> |
15 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | using namespace Opie::Core; | ||
18 | using namespace Opie::Ui; | ||
16 | 19 | ||
17 | /* QT */ | 20 | /* QT */ |
18 | #include <qlayout.h> | 21 | #include <qlayout.h> |
19 | #include <qlabel.h> | 22 | #include <qlabel.h> |
20 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
21 | #include <qfile.h> | 24 | #include <qfile.h> |
22 | 25 | ||
23 | /* STD */ | 26 | /* STD */ |
24 | #include <sys/types.h> | 27 | #include <sys/types.h> |
25 | #include <sys/wait.h> | 28 | #include <sys/wait.h> |
26 | #include <unistd.h> | 29 | #include <unistd.h> |
27 | #include <signal.h> | 30 | #include <signal.h> |
28 | 31 | ||
29 | |||
30 | using namespace Opie::Core; | ||
31 | |||
32 | |||
33 | /** | 32 | /** |
34 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 33 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
35 | * | 34 | * |
36 | */ | 35 | */ |
37 | using namespace Opie::Ui; | ||
38 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) | 36 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) |
39 | { | 37 | { |
40 | vm=viewmode; | 38 | vm=viewmode; |
41 | QVBoxLayout *layout = new QVBoxLayout(this); | 39 | QVBoxLayout *layout = new QVBoxLayout(this); |
42 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 40 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
43 | layout->addWidget(myTabWidget); | 41 | layout->addWidget(myTabWidget); |
44 | setupTab1(); | 42 | setupTab1(); |
45 | setupTab2(); | 43 | setupTab2(); |
46 | 44 | ||
47 | accounts->groupStringList.sort(); | 45 | accounts->groupStringList.sort(); |
48 | // And also fill the listview & the combobox with all available groups. | 46 | // And also fill the listview & the combobox with all available groups. |
49 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) | 47 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) |
50 | { | 48 | { |
51 | accounts->splitGroupEntry(*it); | 49 | accounts->splitGroupEntry(*it); |
52 | if(accounts->gr_name.find(QRegExp("^#"),0)) | 50 | if(accounts->gr_name.find(QRegExp("^#"),0)) |
53 | { // Skip commented lines. | 51 | { // Skip commented lines. |
54 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 52 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
55 | groupComboBox->insertItem(accounts->gr_name); | 53 | groupComboBox->insertItem(accounts->gr_name); |
56 | } | 54 | } |
57 | } | 55 | } |
58 | QPEApplication::showDialog( this ); | 56 | QPEApplication::showDialog( this ); |
59 | } | 57 | } |
60 | 58 | ||
61 | /** | 59 | /** |
@@ -224,49 +222,49 @@ bool UserDialog::addUser(int uid, int gid) | |||
224 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 222 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
225 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 223 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
226 | // If we're running on OZ, add new users to some default groups. | 224 | // If we're running on OZ, add new users to some default groups. |
227 | if(oz) | 225 | if(oz) |
228 | { | 226 | { |
229 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 227 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
230 | for ( ; iter.current(); ++iter ) | 228 | for ( ; iter.current(); ++iter ) |
231 | { | 229 | { |
232 | temp=(QCheckListItem*)iter.current(); | 230 | temp=(QCheckListItem*)iter.current(); |
233 | if (temp->text()=="video") temp->setOn(true); | 231 | if (temp->text()=="video") temp->setOn(true); |
234 | if (temp->text()=="audio") temp->setOn(true); | 232 | if (temp->text()=="audio") temp->setOn(true); |
235 | if (temp->text()=="time") temp->setOn(true); | 233 | if (temp->text()=="time") temp->setOn(true); |
236 | if (temp->text()=="power") temp->setOn(true); | 234 | if (temp->text()=="power") temp->setOn(true); |
237 | if (temp->text()=="input") temp->setOn(true); | 235 | if (temp->text()=="input") temp->setOn(true); |
238 | if (temp->text()=="sharp") temp->setOn(true); | 236 | if (temp->text()=="sharp") temp->setOn(true); |
239 | if (temp->text()=="tty") temp->setOn(true); | 237 | if (temp->text()=="tty") temp->setOn(true); |
240 | } | 238 | } |
241 | } | 239 | } |
242 | // Show the dialog! | 240 | // Show the dialog! |
243 | if(!(adduserDialog->exec())) return false; | 241 | if(!(adduserDialog->exec())) return false; |
244 | if((adduserDialog->groupComboBox->currentItem()!=0)) | 242 | if((adduserDialog->groupComboBox->currentItem()!=0)) |
245 | { | 243 | { |
246 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 244 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); |
247 | adduserDialog->groupID=accounts->gr_gid; | 245 | adduserDialog->groupID=accounts->gr_gid; |
248 | qWarning(QString::number(accounts->gr_gid)); | 246 | owarn << QString::number(accounts->gr_gid) << oendl; |
249 | } | 247 | } |
250 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 248 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
251 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 249 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
252 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) | 250 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) |
253 | { | 251 | { |
254 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 252 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
255 | return false; | 253 | return false; |
256 | } | 254 | } |
257 | 255 | ||
258 | // Add User to additional groups. | 256 | // Add User to additional groups. |
259 | QListViewItemIterator it( adduserDialog->groupsListView ); | 257 | QListViewItemIterator it( adduserDialog->groupsListView ); |
260 | for ( ; it.current(); ++it ) | 258 | for ( ; it.current(); ++it ) |
261 | { | 259 | { |
262 | temp=(QCheckListItem*)it.current(); | 260 | temp=(QCheckListItem*)it.current(); |
263 | if (temp->isOn() ) | 261 | if (temp->isOn() ) |
264 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 262 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
265 | } | 263 | } |
266 | // Copy image to pics/users/ | 264 | // Copy image to pics/users/ |
267 | if(!(adduserDialog->userImage.isNull())) | 265 | if(!(adduserDialog->userImage.isNull())) |
268 | { | 266 | { |
269 | QDir d; | 267 | QDir d; |
270 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) | 268 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) |
271 | { | 269 | { |
272 | d.mkdir("/opt/QtPalmtop/pics/users"); | 270 | d.mkdir("/opt/QtPalmtop/pics/users"); |
@@ -353,64 +351,64 @@ bool UserDialog::editUser(const char *username) | |||
353 | edituserDialog->shellComboBox->setCurrentItem(0); | 351 | edituserDialog->shellComboBox->setCurrentItem(0); |
354 | } | 352 | } |
355 | // Select the primary group for this user. | 353 | // Select the primary group for this user. |
356 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) | 354 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) |
357 | { | 355 | { |
358 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) | 356 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) |
359 | { | 357 | { |
360 | edituserDialog->groupComboBox->setCurrentItem(i); | 358 | edituserDialog->groupComboBox->setCurrentItem(i); |
361 | break; | 359 | break; |
362 | } | 360 | } |
363 | } | 361 | } |
364 | if(invalid_group) | 362 | if(invalid_group) |
365 | { | 363 | { |
366 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 364 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
367 | edituserDialog->groupComboBox->setCurrentItem(0); | 365 | edituserDialog->groupComboBox->setCurrentItem(0); |
368 | } | 366 | } |
369 | 367 | ||
370 | // Select the groups in the listview, to which the user belongs. | 368 | // Select the groups in the listview, to which the user belongs. |
371 | QCheckListItem *temp; | 369 | QCheckListItem *temp; |
372 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. | 370 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. |
373 | QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant. | 371 | QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant. |
374 | QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. | 372 | QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. |
375 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) | 373 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
376 | { // Iterate over all of them. | 374 | { // Iterate over all of them. |
377 | qWarning(*it); | 375 | owarn << *it << oendl; |
378 | QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. | 376 | QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. |
379 | for ( ; lvit.current(); ++lvit ) | 377 | for ( ; lvit.current(); ++lvit ) |
380 | { | 378 | { |
381 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) | 379 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) |
382 | { | 380 | { |
383 | temp=(QCheckListItem*)lvit.current(); | 381 | temp=(QCheckListItem*)lvit.current(); |
384 | temp->setOn(true); // If we find a line with that groupname, select it.; | 382 | temp->setOn(true); // If we find a line with that groupname, select it.; |
385 | } | 383 | } |
386 | } | 384 | } |
387 | } | 385 | } |
388 | userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.) | 386 | userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.) |
389 | tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. | 387 | tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. |
390 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) | 388 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
391 | { // Iterate over all of them. | 389 | { // Iterate over all of them. |
392 | qWarning(*it); | 390 | owarn << *it << oendl; |
393 | QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. | 391 | QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. |
394 | for ( ; lvit.current(); ++lvit ) | 392 | for ( ; lvit.current(); ++lvit ) |
395 | { | 393 | { |
396 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) | 394 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) |
397 | { | 395 | { |
398 | temp=(QCheckListItem*)lvit.current(); | 396 | temp=(QCheckListItem*)lvit.current(); |
399 | temp->setOn(true); // If we find a line with that groupname, select it.; | 397 | temp->setOn(true); // If we find a line with that groupname, select it.; |
400 | } | 398 | } |
401 | } | 399 | } |
402 | } | 400 | } |
403 | 401 | ||
404 | if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG! | 402 | if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG! |
405 | 403 | ||
406 | accounts->findUser(username); // Fill user variables in 'acccounts' object. | 404 | accounts->findUser(username); // Fill user variables in 'acccounts' object. |
407 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 405 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
408 | // Has the password been changed ? Make a new "crypt":ed password. | 406 | // Has the password been changed ? Make a new "crypt":ed password. |
409 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 407 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
410 | 408 | ||
411 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 409 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
412 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 410 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
413 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) | 411 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) |
414 | { // Fill all group variables in 'accounts' object. | 412 | { // Fill all group variables in 'accounts' object. |
415 | accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 413 | accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. |
416 | } | 414 | } |