author | ar <ar> | 2003-12-22 17:29:18 (UTC) |
---|---|---|
committer | ar <ar> | 2003-12-22 17:29:18 (UTC) |
commit | f0a4320f43abb1a24f80d6de1a94d39453945355 (patch) (unidiff) | |
tree | 5ad5cd96bb659152a67c0f8b43726091615109e8 | |
parent | 34194d7d8957b77fbc032efa5b89ef56e322d35f (diff) | |
download | opie-f0a4320f43abb1a24f80d6de1a94d39453945355.zip opie-f0a4320f43abb1a24f80d6de1a94d39453945355.tar.gz opie-f0a4320f43abb1a24f80d6de1a94d39453945355.tar.bz2 |
- remove stdlib.h and stdio.h
-rw-r--r-- | noncore/settings/usermanager/groupdialog.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/usermanager/usermanager.cpp | 1 |
3 files changed, 3 insertions, 9 deletions
diff --git a/noncore/settings/usermanager/groupdialog.cpp b/noncore/settings/usermanager/groupdialog.cpp index b595d31..76810be 100644 --- a/noncore/settings/usermanager/groupdialog.cpp +++ b/noncore/settings/usermanager/groupdialog.cpp | |||
@@ -1,106 +1,104 @@ | |||
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 "groupdialog.h" | 10 | #include "groupdialog.h" |
11 | 11 | ||
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | #include <qlayout.h> | 13 | #include <qlayout.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | 15 | ||
16 | #include <stdlib.h> | ||
17 | |||
18 | #include "passwd.h" | 16 | #include "passwd.h" |
19 | 17 | ||
20 | GroupDialog::GroupDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { | 18 | GroupDialog::GroupDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { |
21 | // GID | 19 | // GID |
22 | QLabel *gidLabel=new QLabel(this,"gid: "); | 20 | QLabel *gidLabel=new QLabel(this,"gid: "); |
23 | gidLabel->setText("GroupID: "); | 21 | gidLabel->setText("GroupID: "); |
24 | gidLineEdit=new QLineEdit(this,"gid: "); | 22 | gidLineEdit=new QLineEdit(this,"gid: "); |
25 | gidLineEdit->setEnabled(false); | 23 | gidLineEdit->setEnabled(false); |
26 | 24 | ||
27 | // Groupname | 25 | // Groupname |
28 | QLabel *groupnameLabel=new QLabel(this,"groupname"); | 26 | QLabel *groupnameLabel=new QLabel(this,"groupname"); |
29 | groupnameLabel->setText("Groupname: "); | 27 | groupnameLabel->setText("Groupname: "); |
30 | groupnameLineEdit=new QLineEdit(this,"groupname"); | 28 | groupnameLineEdit=new QLineEdit(this,"groupname"); |
31 | 29 | ||
32 | // Widget layout | 30 | // Widget layout |
33 | QVBoxLayout *layout=new QVBoxLayout(this); | 31 | QVBoxLayout *layout=new QVBoxLayout(this); |
34 | layout->setMargin(5); | 32 | layout->setMargin(5); |
35 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 33 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
36 | layout->addLayout(hlayout); | 34 | layout->addLayout(hlayout); |
37 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 35 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
38 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 36 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
39 | // First column, labels | 37 | // First column, labels |
40 | vlayout1->addWidget(gidLabel); | 38 | vlayout1->addWidget(gidLabel); |
41 | vlayout1->addWidget(groupnameLabel); | 39 | vlayout1->addWidget(groupnameLabel); |
42 | // Second column, data | 40 | // Second column, data |
43 | vlayout2->addWidget(gidLineEdit); | 41 | vlayout2->addWidget(gidLineEdit); |
44 | vlayout2->addWidget(groupnameLineEdit); | 42 | vlayout2->addWidget(groupnameLineEdit); |
45 | hlayout->addLayout(vlayout1); | 43 | hlayout->addLayout(vlayout1); |
46 | hlayout->addLayout(vlayout2); | 44 | hlayout->addLayout(vlayout2); |
47 | layout->addSpacing(5); | 45 | layout->addSpacing(5); |
48 | 46 | ||
49 | //showMaximized(); | 47 | //showMaximized(); |
50 | } | 48 | } |
51 | 49 | ||
52 | GroupDialog::~GroupDialog() { | 50 | GroupDialog::~GroupDialog() { |
53 | } | 51 | } |
54 | 52 | ||
55 | bool GroupDialog::addGroup(int gid) { | 53 | bool GroupDialog::addGroup(int gid) { |
56 | GroupDialog *addgroupDialog=new GroupDialog();// Make a groupinfo dialog. | 54 | GroupDialog *addgroupDialog=new GroupDialog();// Make a groupinfo dialog. |
57 | addgroupDialog->setCaption(tr("Add Group"));// Set the caption. | 55 | addgroupDialog->setCaption(tr("Add Group"));// Set the caption. |
58 | addgroupDialog->gidLineEdit->setText(QString::number(gid));// Set the next available gid. | 56 | addgroupDialog->gidLineEdit->setText(QString::number(gid));// Set the next available gid. |
59 | if(!(addgroupDialog->exec())) return false;// View the dialog, and only continue if 'ok' was pressed. | 57 | if(!(addgroupDialog->exec())) return false;// View the dialog, and only continue if 'ok' was pressed. |
60 | if(!(accounts->addGroup(addgroupDialog->groupnameLineEdit->text(),addgroupDialog->gidLineEdit->text().toInt()))) {// Try to add the group. | 58 | if(!(accounts->addGroup(addgroupDialog->groupnameLineEdit->text(),addgroupDialog->gidLineEdit->text().toInt()))) {// Try to add the group. |
61 | QMessageBox::information(0,"Ooops!","Something went wrong.\nUnable to add group."); | 59 | QMessageBox::information(0,"Ooops!","Something went wrong.\nUnable to add group."); |
62 | return false; | 60 | return false; |
63 | } | 61 | } |
64 | return true; | 62 | return true; |
65 | } | 63 | } |
66 | 64 | ||
67 | bool GroupDialog::editGroup(int gid) { | 65 | bool GroupDialog::editGroup(int gid) { |
68 | GroupDialog *addgroupDialog=new GroupDialog();// Create the groupinfo dialog. | 66 | GroupDialog *addgroupDialog=new GroupDialog();// Create the groupinfo dialog. |
69 | accounts->findGroup(gid);// Locate the group in the database, and fill out the variables in 'accounts'. | 67 | accounts->findGroup(gid);// Locate the group in the database, and fill out the variables in 'accounts'. |
70 | // Fill out the widgets with previous data for this group. | 68 | // Fill out the widgets with previous data for this group. |
71 | addgroupDialog->setCaption(tr("Edit Group")); | 69 | addgroupDialog->setCaption(tr("Edit Group")); |
72 | addgroupDialog->gidLineEdit->setText(QString::number(accounts->gr_gid)); | 70 | addgroupDialog->gidLineEdit->setText(QString::number(accounts->gr_gid)); |
73 | addgroupDialog->groupnameLineEdit->setText(accounts->gr_name); | 71 | addgroupDialog->groupnameLineEdit->setText(accounts->gr_name); |
74 | if(!(addgroupDialog->exec())) return false;// View the dialog, and only continue if 'ok' was pressed. | 72 | if(!(addgroupDialog->exec())) return false;// View the dialog, and only continue if 'ok' was pressed. |
75 | accounts->findGroup(gid);// Locate the group, and fill out the variables in 'accounts' with all info about the group. | 73 | accounts->findGroup(gid);// Locate the group, and fill out the variables in 'accounts' with all info about the group. |
76 | accounts->gr_name=addgroupDialog->groupnameLineEdit->text();// Change the name | 74 | accounts->gr_name=addgroupDialog->groupnameLineEdit->text();// Change the name |
77 | accounts->gr_gid=addgroupDialog->gidLineEdit->text().toInt();// Change the GID. (Unneeded as its disabled right now.) | 75 | accounts->gr_gid=addgroupDialog->gidLineEdit->text().toInt();// Change the GID. (Unneeded as its disabled right now.) |
78 | accounts->updateGroup(gid);// Update the database with the variables (gr_name,gr_gid,gr_mem) in 'accounts'. | 76 | accounts->updateGroup(gid);// Update the database with the variables (gr_name,gr_gid,gr_mem) in 'accounts'. |
79 | return true; | 77 | return true; |
80 | } | 78 | } |
81 | 79 | ||
82 | bool GroupDialog::delGroup(const char *groupname) { | 80 | bool GroupDialog::delGroup(const char *groupname) { |
83 | if((accounts->findGroup(groupname))) {// Does this group exist? | 81 | if((accounts->findGroup(groupname))) {// Does this group exist? |
84 | if(!(accounts->delGroup(groupname))) {// Try to delete it. | 82 | if(!(accounts->delGroup(groupname))) {// Try to delete it. |
85 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete group: "+QString(groupname)+"."); | 83 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete group: "+QString(groupname)+"."); |
86 | } | 84 | } |
87 | } else { | 85 | } else { |
88 | QMessageBox::information(0,"Invalid Groupname","That groupname ("+QString(groupname)+")does not exist."); | 86 | QMessageBox::information(0,"Invalid Groupname","That groupname ("+QString(groupname)+")does not exist."); |
89 | return false; | 87 | return false; |
90 | } | 88 | } |
91 | return true; | 89 | return true; |
92 | } | 90 | } |
93 | 91 | ||
94 | void GroupDialog::accept() { | 92 | void GroupDialog::accept() { |
95 | // Check if gid is already taken. | 93 | // Check if gid is already taken. |
96 | //if((accounts->findGroup(gidLineEdit->text().toInt()))) { | 94 | //if((accounts->findGroup(gidLineEdit->text().toInt()))) { |
97 | // QMessageBox::information(this,"GroupID taken","That GroupID is already taken."); | 95 | // QMessageBox::information(this,"GroupID taken","That GroupID is already taken."); |
98 | // return; | 96 | // return; |
99 | //} | 97 | //} |
100 | // Check if groupname is already taken. | 98 | // Check if groupname is already taken. |
101 | if((accounts->findGroup(groupnameLineEdit->text()))) { | 99 | if((accounts->findGroup(groupnameLineEdit->text()))) { |
102 | QMessageBox::information(0,"Groupname taken","That groupname is already taken."); | 100 | QMessageBox::information(0,"Groupname taken","That groupname is already taken."); |
103 | return;// Don't close the dialog. | 101 | return;// Don't close the dialog. |
104 | } | 102 | } |
105 | QDialog::accept(); | 103 | QDialog::accept(); |
106 | } | 104 | } |
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 19b0e84..d87a005 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -1,378 +1,375 @@ | |||
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 | 11 | ||
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | 16 | ||
17 | #include <stdlib.h> | ||
18 | |||
19 | #include <stdio.h> | ||
20 | #include <sys/types.h> | 17 | #include <sys/types.h> |
21 | #include <sys/wait.h> | 18 | #include <sys/wait.h> |
22 | #include <unistd.h> | 19 | #include <unistd.h> |
23 | #include <signal.h> | 20 | #include <signal.h> |
24 | 21 | ||
25 | #include "passwd.h" | 22 | #include "passwd.h" |
26 | 23 | ||
27 | #include <opie/odevice.h> | 24 | #include <opie/odevice.h> |
28 | using namespace Opie; | 25 | using namespace Opie; |
29 | 26 | ||
30 | 27 | ||
31 | /** | 28 | /** |
32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 29 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
33 | * | 30 | * |
34 | */ | 31 | */ |
35 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { | 32 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { |
36 | vm=viewmode; | 33 | vm=viewmode; |
37 | QVBoxLayout *layout = new QVBoxLayout(this); | 34 | QVBoxLayout *layout = new QVBoxLayout(this); |
38 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 35 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
39 | layout->addWidget(myTabWidget); | 36 | layout->addWidget(myTabWidget); |
40 | setupTab1(); | 37 | setupTab1(); |
41 | setupTab2(); | 38 | setupTab2(); |
42 | 39 | ||
43 | accounts->groupStringList.sort(); | 40 | accounts->groupStringList.sort(); |
44 | // And also fill the listview & the combobox with all available groups. | 41 | // And also fill the listview & the combobox with all available groups. |
45 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { | 42 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { |
46 | accounts->splitGroupEntry(*it); | 43 | accounts->splitGroupEntry(*it); |
47 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 44 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
48 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 45 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
49 | groupComboBox->insertItem(accounts->gr_name); | 46 | groupComboBox->insertItem(accounts->gr_name); |
50 | } | 47 | } |
51 | } | 48 | } |
52 | showMaximized(); | 49 | showMaximized(); |
53 | } | 50 | } |
54 | 51 | ||
55 | /** | 52 | /** |
56 | * Empty destructor. | 53 | * Empty destructor. |
57 | * | 54 | * |
58 | */ | 55 | */ |
59 | UserDialog::~UserDialog() { | 56 | UserDialog::~UserDialog() { |
60 | } | 57 | } |
61 | 58 | ||
62 | /** | 59 | /** |
63 | * Creates the first tab, all userinfo is here. | 60 | * Creates the first tab, all userinfo is here. |
64 | * | 61 | * |
65 | */ | 62 | */ |
66 | void UserDialog::setupTab1() { | 63 | void UserDialog::setupTab1() { |
67 | QPixmap mypixmap; | 64 | QPixmap mypixmap; |
68 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 65 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
69 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 66 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
70 | layout->setMargin(5); | 67 | layout->setMargin(5); |
71 | 68 | ||
72 | // Picture | 69 | // Picture |
73 | picturePushButton = new QPushButton(tabpage,"Label"); | 70 | picturePushButton = new QPushButton(tabpage,"Label"); |
74 | picturePushButton->setMinimumSize(48,48); | 71 | picturePushButton->setMinimumSize(48,48); |
75 | picturePushButton->setMaximumSize(48,48); | 72 | picturePushButton->setMaximumSize(48,48); |
76 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. | 73 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. |
77 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. | 74 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. |
78 | 75 | ||
79 | // Login | 76 | // Login |
80 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); | 77 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); |
81 | loginLabel->setText("Login: "); | 78 | loginLabel->setText("Login: "); |
82 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | 79 | loginLineEdit=new QLineEdit(tabpage,"Login: "); |
83 | 80 | ||
84 | // UID | 81 | // UID |
85 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); | 82 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); |
86 | uidLabel->setText("UserID: "); | 83 | uidLabel->setText("UserID: "); |
87 | uidLineEdit=new QLineEdit(tabpage,"uid: "); | 84 | uidLineEdit=new QLineEdit(tabpage,"uid: "); |
88 | uidLineEdit->setEnabled(false); | 85 | uidLineEdit->setEnabled(false); |
89 | 86 | ||
90 | // Username (gecos) | 87 | // Username (gecos) |
91 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); | 88 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); |
92 | gecosLabel->setText("Username: "); | 89 | gecosLabel->setText("Username: "); |
93 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | 90 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); |
94 | 91 | ||
95 | // Password | 92 | // Password |
96 | QLabel *passwordLabel=new QLabel(tabpage,"password"); | 93 | QLabel *passwordLabel=new QLabel(tabpage,"password"); |
97 | passwordLabel->setText("Password: "); | 94 | passwordLabel->setText("Password: "); |
98 | passwordLineEdit=new QLineEdit(tabpage,"password"); | 95 | passwordLineEdit=new QLineEdit(tabpage,"password"); |
99 | passwordLineEdit->setEchoMode(QLineEdit::Password); | 96 | passwordLineEdit->setEchoMode(QLineEdit::Password); |
100 | 97 | ||
101 | // Shell | 98 | // Shell |
102 | QLabel *shellLabel=new QLabel(tabpage,"shell"); | 99 | QLabel *shellLabel=new QLabel(tabpage,"shell"); |
103 | shellLabel->setText("Shell: "); | 100 | shellLabel->setText("Shell: "); |
104 | shellComboBox=new QComboBox(tabpage,"shell"); | 101 | shellComboBox=new QComboBox(tabpage,"shell"); |
105 | shellComboBox->setEditable(true); | 102 | shellComboBox->setEditable(true); |
106 | shellComboBox->insertItem("/bin/sh"); | 103 | shellComboBox->insertItem("/bin/sh"); |
107 | shellComboBox->insertItem("/bin/ash"); | 104 | shellComboBox->insertItem("/bin/ash"); |
108 | shellComboBox->insertItem("/bin/false"); | 105 | shellComboBox->insertItem("/bin/false"); |
109 | 106 | ||
110 | // Primary Group | 107 | // Primary Group |
111 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 108 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
112 | groupLabel->setText("Primary group: "); | 109 | groupLabel->setText("Primary group: "); |
113 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 110 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
114 | 111 | ||
115 | if(vm==VIEWMODE_NEW) { | 112 | if(vm==VIEWMODE_NEW) { |
116 | // Copy /etc/skel | 113 | // Copy /etc/skel |
117 | skelLabel=new QLabel(tabpage,"skel"); | 114 | skelLabel=new QLabel(tabpage,"skel"); |
118 | skelLabel->setText("Copy /etc/skel: "); | 115 | skelLabel->setText("Copy /etc/skel: "); |
119 | skelCheckBox=new QCheckBox(tabpage); | 116 | skelCheckBox=new QCheckBox(tabpage); |
120 | skelCheckBox->setChecked(true); | 117 | skelCheckBox->setChecked(true); |
121 | } | 118 | } |
122 | 119 | ||
123 | // Widget layout | 120 | // Widget layout |
124 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 121 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
125 | layout->addWidget(picturePushButton); | 122 | layout->addWidget(picturePushButton); |
126 | layout->addSpacing(5); | 123 | layout->addSpacing(5); |
127 | layout->addLayout(hlayout); | 124 | layout->addLayout(hlayout); |
128 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 125 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
129 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 126 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
130 | // First column, labels | 127 | // First column, labels |
131 | vlayout1->addWidget(loginLabel); | 128 | vlayout1->addWidget(loginLabel); |
132 | vlayout1->addSpacing(5); | 129 | vlayout1->addSpacing(5); |
133 | vlayout1->addWidget(uidLabel); | 130 | vlayout1->addWidget(uidLabel); |
134 | vlayout1->addSpacing(5); | 131 | vlayout1->addSpacing(5); |
135 | vlayout1->addWidget(gecosLabel); | 132 | vlayout1->addWidget(gecosLabel); |
136 | vlayout1->addSpacing(5); | 133 | vlayout1->addSpacing(5); |
137 | vlayout1->addWidget(passwordLabel); | 134 | vlayout1->addWidget(passwordLabel); |
138 | vlayout1->addSpacing(5); | 135 | vlayout1->addSpacing(5); |
139 | vlayout1->addWidget(shellLabel); | 136 | vlayout1->addWidget(shellLabel); |
140 | vlayout1->addSpacing(5); | 137 | vlayout1->addSpacing(5); |
141 | vlayout1->addWidget(groupLabel); | 138 | vlayout1->addWidget(groupLabel); |
142 | if(vm==VIEWMODE_NEW) { | 139 | if(vm==VIEWMODE_NEW) { |
143 | vlayout1->addSpacing(5); | 140 | vlayout1->addSpacing(5); |
144 | vlayout1->addWidget(skelLabel); | 141 | vlayout1->addWidget(skelLabel); |
145 | } | 142 | } |
146 | // Second column, data | 143 | // Second column, data |
147 | vlayout2->addWidget(loginLineEdit); | 144 | vlayout2->addWidget(loginLineEdit); |
148 | vlayout2->addSpacing(5); | 145 | vlayout2->addSpacing(5); |
149 | vlayout2->addWidget(uidLineEdit); | 146 | vlayout2->addWidget(uidLineEdit); |
150 | vlayout2->addSpacing(5); | 147 | vlayout2->addSpacing(5); |
151 | vlayout2->addWidget(gecosLineEdit); | 148 | vlayout2->addWidget(gecosLineEdit); |
152 | vlayout2->addSpacing(5); | 149 | vlayout2->addSpacing(5); |
153 | vlayout2->addWidget(passwordLineEdit); | 150 | vlayout2->addWidget(passwordLineEdit); |
154 | vlayout2->addSpacing(5); | 151 | vlayout2->addSpacing(5); |
155 | vlayout2->addWidget(shellComboBox); | 152 | vlayout2->addWidget(shellComboBox); |
156 | vlayout2->addSpacing(5); | 153 | vlayout2->addSpacing(5); |
157 | vlayout2->addWidget(groupComboBox); | 154 | vlayout2->addWidget(groupComboBox); |
158 | if(vm==VIEWMODE_NEW) { | 155 | if(vm==VIEWMODE_NEW) { |
159 | vlayout2->addSpacing(5); | 156 | vlayout2->addSpacing(5); |
160 | vlayout2->addWidget(skelCheckBox); | 157 | vlayout2->addWidget(skelCheckBox); |
161 | } | 158 | } |
162 | hlayout->addLayout(vlayout1); | 159 | hlayout->addLayout(vlayout1); |
163 | hlayout->addLayout(vlayout2); | 160 | hlayout->addLayout(vlayout2); |
164 | 161 | ||
165 | myTabWidget->addTab(tabpage,"User Info"); | 162 | myTabWidget->addTab(tabpage,"User Info"); |
166 | } | 163 | } |
167 | 164 | ||
168 | /** | 165 | /** |
169 | * Creates the second tab containing additional groups for the user. | 166 | * Creates the second tab containing additional groups for the user. |
170 | * | 167 | * |
171 | */ | 168 | */ |
172 | void UserDialog::setupTab2() { | 169 | void UserDialog::setupTab2() { |
173 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 170 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
174 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 171 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
175 | layout->setMargin(5); | 172 | layout->setMargin(5); |
176 | 173 | ||
177 | // Additional groups | 174 | // Additional groups |
178 | groupsListView=new QListView(tabpage,"groups"); | 175 | groupsListView=new QListView(tabpage,"groups"); |
179 | groupsListView->addColumn("Additional groups"); | 176 | groupsListView->addColumn("Additional groups"); |
180 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 177 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
181 | groupsListView->setMultiSelection(false); | 178 | groupsListView->setMultiSelection(false); |
182 | groupsListView->setAllColumnsShowFocus(false); | 179 | groupsListView->setAllColumnsShowFocus(false); |
183 | 180 | ||
184 | layout->addSpacing(5); | 181 | layout->addSpacing(5); |
185 | // Grouplist | 182 | // Grouplist |
186 | layout->addWidget(groupsListView); | 183 | layout->addWidget(groupsListView); |
187 | 184 | ||
188 | myTabWidget->addTab(tabpage,"User Groups"); | 185 | myTabWidget->addTab(tabpage,"User Groups"); |
189 | } | 186 | } |
190 | 187 | ||
191 | /** | 188 | /** |
192 | * Static function that creates the userinfo dialog. | 189 | * Static function that creates the userinfo dialog. |
193 | * The user will be prompted to add a user. | 190 | * The user will be prompted to add a user. |
194 | * | 191 | * |
195 | * @param uid This is a suggested available UID. | 192 | * @param uid This is a suggested available UID. |
196 | * @param gid This is a suggested available GID. | 193 | * @param gid This is a suggested available GID. |
197 | * | 194 | * |
198 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. | 195 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. |
199 | * | 196 | * |
200 | */ | 197 | */ |
201 | bool UserDialog::addUser(int uid, int gid) { | 198 | bool UserDialog::addUser(int uid, int gid) { |
202 | QCheckListItem *temp; | 199 | QCheckListItem *temp; |
203 | QFile ozTest; | 200 | QFile ozTest; |
204 | int oz=false; | 201 | int oz=false; |
205 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 202 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
206 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. | 203 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
207 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | 204 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); |
208 | adduserDialog->setCaption(tr("Add User")); | 205 | adduserDialog->setCaption(tr("Add User")); |
209 | adduserDialog->userID=uid;// Set next available UID as default uid. | 206 | adduserDialog->userID=uid;// Set next available UID as default uid. |
210 | adduserDialog->groupID=gid;// Set next available GID as default gid. | 207 | adduserDialog->groupID=gid;// Set next available GID as default gid. |
211 | // Insert default group into groupComboBox | 208 | // Insert default group into groupComboBox |
212 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 209 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
213 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 210 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
214 | // If we're running on OZ, add new users to some default groups. | 211 | // If we're running on OZ, add new users to some default groups. |
215 | if(oz) { | 212 | if(oz) { |
216 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 213 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
217 | for ( ; iter.current(); ++iter ) { | 214 | for ( ; iter.current(); ++iter ) { |
218 | temp=(QCheckListItem*)iter.current(); | 215 | temp=(QCheckListItem*)iter.current(); |
219 | if (temp->text()=="video") temp->setOn(true); | 216 | if (temp->text()=="video") temp->setOn(true); |
220 | if (temp->text()=="audio") temp->setOn(true); | 217 | if (temp->text()=="audio") temp->setOn(true); |
221 | if (temp->text()=="time") temp->setOn(true); | 218 | if (temp->text()=="time") temp->setOn(true); |
222 | if (temp->text()=="power") temp->setOn(true); | 219 | if (temp->text()=="power") temp->setOn(true); |
223 | if (temp->text()=="input") temp->setOn(true); | 220 | if (temp->text()=="input") temp->setOn(true); |
224 | if (temp->text()=="sharp") temp->setOn(true); | 221 | if (temp->text()=="sharp") temp->setOn(true); |
225 | if (temp->text()=="tty") temp->setOn(true); | 222 | if (temp->text()=="tty") temp->setOn(true); |
226 | } | 223 | } |
227 | } | 224 | } |
228 | // Show the dialog! | 225 | // Show the dialog! |
229 | if(!(adduserDialog->exec())) return false; | 226 | if(!(adduserDialog->exec())) return false; |
230 | if((adduserDialog->groupComboBox->currentItem()!=0)) { | 227 | if((adduserDialog->groupComboBox->currentItem()!=0)) { |
231 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 228 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); |
232 | adduserDialog->groupID=accounts->gr_gid; | 229 | adduserDialog->groupID=accounts->gr_gid; |
233 | qWarning(QString::number(accounts->gr_gid)); | 230 | qWarning(QString::number(accounts->gr_gid)); |
234 | } | 231 | } |
235 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 232 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
236 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 233 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
237 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { | 234 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { |
238 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 235 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
239 | return false; | 236 | return false; |
240 | } | 237 | } |
241 | 238 | ||
242 | // Add User to additional groups. | 239 | // Add User to additional groups. |
243 | QListViewItemIterator it( adduserDialog->groupsListView ); | 240 | QListViewItemIterator it( adduserDialog->groupsListView ); |
244 | for ( ; it.current(); ++it ) { | 241 | for ( ; it.current(); ++it ) { |
245 | temp=(QCheckListItem*)it.current(); | 242 | temp=(QCheckListItem*)it.current(); |
246 | if (temp->isOn() ) | 243 | if (temp->isOn() ) |
247 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 244 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
248 | } | 245 | } |
249 | // Copy image to pics/users/ | 246 | // Copy image to pics/users/ |
250 | if(!(adduserDialog->userImage.isNull())) { | 247 | if(!(adduserDialog->userImage.isNull())) { |
251 | QDir d; | 248 | QDir d; |
252 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 249 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
253 | d.mkdir("/opt/QtPalmtop/pics/users"); | 250 | d.mkdir("/opt/QtPalmtop/pics/users"); |
254 | } | 251 | } |
255 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 252 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
256 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 253 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
257 | adduserDialog->userImage.save(filename,"PNG"); | 254 | adduserDialog->userImage.save(filename,"PNG"); |
258 | } | 255 | } |
259 | 256 | ||
260 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | 257 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? |
261 | accounts->findUser(adduserDialog->loginLineEdit->text()); | 258 | accounts->findUser(adduserDialog->loginLineEdit->text()); |
262 | if(adduserDialog->skelCheckBox->isChecked()) { | 259 | if(adduserDialog->skelCheckBox->isChecked()) { |
263 | QString command_cp; | 260 | QString command_cp; |
264 | QString command_chown; | 261 | QString command_chown; |
265 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | 262 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); |
266 | system(command_cp); | 263 | system(command_cp); |
267 | 264 | ||
268 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? | 265 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? |
269 | system(command_cp); | 266 | system(command_cp); |
270 | 267 | ||
271 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | 268 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); |
272 | system(command_chown); | 269 | system(command_chown); |
273 | } | 270 | } |
274 | 271 | ||
275 | return true; | 272 | return true; |
276 | } | 273 | } |
277 | 274 | ||
278 | /** | 275 | /** |
279 | * Deletes the user account. | 276 | * Deletes the user account. |
280 | * | 277 | * |
281 | * @param username User to be deleted. | 278 | * @param username User to be deleted. |
282 | * | 279 | * |
283 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 280 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
284 | * | 281 | * |
285 | */ | 282 | */ |
286 | bool UserDialog::delUser(const char *username) { | 283 | bool UserDialog::delUser(const char *username) { |
287 | if((accounts->findUser(username))) {// Does that user exist? | 284 | if((accounts->findUser(username))) {// Does that user exist? |
288 | if(!(accounts->delUser(username))) {// Delete the user. | 285 | if(!(accounts->delUser(username))) {// Delete the user. |
289 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); | 286 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); |
290 | } | 287 | } |
291 | } else { | 288 | } else { |
292 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); | 289 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); |
293 | return false; | 290 | return false; |
294 | } | 291 | } |
295 | return true; | 292 | return true; |
296 | } | 293 | } |
297 | 294 | ||
298 | /** | 295 | /** |
299 | * This displays a confirmation dialog wether a user should be deleted or not. | 296 | * This displays a confirmation dialog wether a user should be deleted or not. |
300 | * (And also deletes the account) | 297 | * (And also deletes the account) |
301 | * | 298 | * |
302 | * @param username User to be deleted. | 299 | * @param username User to be deleted. |
303 | * | 300 | * |
304 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 301 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
305 | * | 302 | * |
306 | */ | 303 | */ |
307 | bool UserDialog::editUser(const char *username) { | 304 | bool UserDialog::editUser(const char *username) { |
308 | int invalid_group=0; | 305 | int invalid_group=0; |
309 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. | 306 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. |
310 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog | 307 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog |
311 | edituserDialog->setCaption(tr("Edit User")); | 308 | edituserDialog->setCaption(tr("Edit User")); |
312 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. | 309 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. |
313 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. | 310 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. |
314 | invalid_group=1; | 311 | invalid_group=1; |
315 | } | 312 | } |
316 | // Fill widgets with userinfo. | 313 | // Fill widgets with userinfo. |
317 | edituserDialog->loginLineEdit->setText(accounts->pw_name); | 314 | edituserDialog->loginLineEdit->setText(accounts->pw_name); |
318 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); | 315 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); |
319 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); | 316 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); |
320 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. | 317 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. |
321 | edituserDialog->passwordLineEdit->setText("........"); | 318 | edituserDialog->passwordLineEdit->setText("........"); |
322 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. | 319 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. |
323 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { | 320 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { |
324 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); | 321 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); |
325 | edituserDialog->shellComboBox->setCurrentItem(0); | 322 | edituserDialog->shellComboBox->setCurrentItem(0); |
326 | } | 323 | } |
327 | // Select the primary group for this user. | 324 | // Select the primary group for this user. |
328 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { | 325 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { |
329 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { | 326 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { |
330 | edituserDialog->groupComboBox->setCurrentItem(i); | 327 | edituserDialog->groupComboBox->setCurrentItem(i); |
331 | break; | 328 | break; |
332 | } | 329 | } |
333 | } | 330 | } |
334 | if(invalid_group) { | 331 | if(invalid_group) { |
335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 332 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
336 | edituserDialog->groupComboBox->setCurrentItem(0); | 333 | edituserDialog->groupComboBox->setCurrentItem(0); |
337 | } | 334 | } |
338 | 335 | ||
339 | // Select the groups in the listview, to which the user belongs. | 336 | // Select the groups in the listview, to which the user belongs. |
340 | QCheckListItem *temp; | 337 | QCheckListItem *temp; |
341 | // 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. | 338 | // 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. |
342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 339 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 340 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 341 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
345 | qWarning(*it); | 342 | qWarning(*it); |
346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 343 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
347 | for ( ; lvit.current(); ++lvit ) { | 344 | for ( ; lvit.current(); ++lvit ) { |
348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 345 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
349 | temp=(QCheckListItem*)lvit.current(); | 346 | temp=(QCheckListItem*)lvit.current(); |
350 | temp->setOn(true);// If we find a line with that groupname, select it.; | 347 | temp->setOn(true);// If we find a line with that groupname, select it.; |
351 | } | 348 | } |
352 | } | 349 | } |
353 | } | 350 | } |
354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 351 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 352 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 353 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
357 | qWarning(*it); | 354 | qWarning(*it); |
358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 355 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
359 | for ( ; lvit.current(); ++lvit ) { | 356 | for ( ; lvit.current(); ++lvit ) { |
360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 357 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
361 | temp=(QCheckListItem*)lvit.current(); | 358 | temp=(QCheckListItem*)lvit.current(); |
362 | temp->setOn(true);// If we find a line with that groupname, select it.; | 359 | temp->setOn(true);// If we find a line with that groupname, select it.; |
363 | } | 360 | } |
364 | } | 361 | } |
365 | } | 362 | } |
366 | 363 | ||
367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! | 364 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! |
368 | 365 | ||
369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. | 366 | accounts->findUser(username);// Fill user variables in 'acccounts' object. |
370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 367 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
371 | // Has the password been changed ? Make a new "crypt":ed password. | 368 | // Has the password been changed ? Make a new "crypt":ed password. |
372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 369 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
373 | 370 | ||
374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 371 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 372 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 373 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. |
377 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 374 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. |
378 | } | 375 | } |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 5c90525..5411995 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -1,258 +1,257 @@ | |||
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 "usermanager.h" | 10 | #include "usermanager.h" |
11 | 11 | ||
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | #include <stdio.h> | ||
14 | 13 | ||
15 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
16 | #include <qfile.h> | 15 | #include <qfile.h> |
17 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
18 | 17 | ||
19 | #include <qregexp.h> | 18 | #include <qregexp.h> |
20 | 19 | ||
21 | /** | 20 | /** |
22 | * The mainwindow constructor. | 21 | * The mainwindow constructor. |
23 | * | 22 | * |
24 | * @param QWidget *parent | 23 | * @param QWidget *parent |
25 | * @param const char *name | 24 | * @param const char *name |
26 | * @ param WFlags fl | 25 | * @ param WFlags fl |
27 | * | 26 | * |
28 | */ | 27 | */ |
29 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 28 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
30 | setCaption(tr("Opie User Manager")); | 29 | setCaption(tr("Opie User Manager")); |
31 | 30 | ||
32 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 31 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
33 | accounts=new Passwd(); | 32 | accounts=new Passwd(); |
34 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 33 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
35 | 34 | ||
36 | // Create the toolbar. | 35 | // Create the toolbar. |
37 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); | 36 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); |
38 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 37 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? |
39 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); | 38 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); |
40 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); | 39 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); |
41 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | 40 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); |
42 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | 41 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); |
43 | userstext->setUsesTextLabel(true); | 42 | userstext->setUsesTextLabel(true); |
44 | toolbar->addSeparator(); | 43 | toolbar->addSeparator(); |
45 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 44 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); |
46 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); | 45 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); |
47 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | 46 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); |
48 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | 47 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); |
49 | groupstext->setUsesTextLabel(true); | 48 | groupstext->setUsesTextLabel(true); |
50 | addToolBar(toolbar,"myToolBar"); | 49 | addToolBar(toolbar,"myToolBar"); |
51 | 50 | ||
52 | // Add a tabwidget and all the tabs. | 51 | // Add a tabwidget and all the tabs. |
53 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 52 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
54 | setupTabAccounts(); | 53 | setupTabAccounts(); |
55 | setupTabAllUsers(); | 54 | setupTabAllUsers(); |
56 | setupTabAllGroups(); | 55 | setupTabAllGroups(); |
57 | userPopupMenu.insertItem("Copy",0); | 56 | userPopupMenu.insertItem("Copy",0); |
58 | 57 | ||
59 | getUsers(); // Fill out the iconview & listview with all users. | 58 | getUsers(); // Fill out the iconview & listview with all users. |
60 | getGroups(); // Fill out the group listview with all groups. | 59 | getGroups(); // Fill out the group listview with all groups. |
61 | 60 | ||
62 | setCentralWidget(myTabWidget); | 61 | setCentralWidget(myTabWidget); |
63 | } | 62 | } |
64 | 63 | ||
65 | UserConfig::~UserConfig() { | 64 | UserConfig::~UserConfig() { |
66 | accounts->close(); | 65 | accounts->close(); |
67 | delete accounts; | 66 | delete accounts; |
68 | } | 67 | } |
69 | 68 | ||
70 | void UserConfig::setupTabAccounts() { | 69 | void UserConfig::setupTabAccounts() { |
71 | QWidget *tabpage = new QWidget(this); | 70 | QWidget *tabpage = new QWidget(this); |
72 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
73 | layout->setMargin(5); | 72 | layout->setMargin(5); |
74 | 73 | ||
75 | usersIconView=new QListView(tabpage,"users"); | 74 | usersIconView=new QListView(tabpage,"users"); |
76 | usersIconView->addColumn("Icon"); | 75 | usersIconView->addColumn("Icon"); |
77 | usersIconView->addColumn("Username"); | 76 | usersIconView->addColumn("Username"); |
78 | usersIconView->setAllColumnsShowFocus(true); | 77 | usersIconView->setAllColumnsShowFocus(true); |
79 | layout->addWidget(usersIconView); | 78 | layout->addWidget(usersIconView); |
80 | 79 | ||
81 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); | 80 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); |
82 | 81 | ||
83 | myTabWidget->addTab(tabpage,"Users"); | 82 | myTabWidget->addTab(tabpage,"Users"); |
84 | } | 83 | } |
85 | 84 | ||
86 | void UserConfig::setupTabAllUsers() { | 85 | void UserConfig::setupTabAllUsers() { |
87 | QWidget *tabpage = new QWidget(this); | 86 | QWidget *tabpage = new QWidget(this); |
88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 87 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
89 | layout->setMargin(5); | 88 | layout->setMargin(5); |
90 | 89 | ||
91 | usersListView=new QListView(tabpage,"allusers"); | 90 | usersListView=new QListView(tabpage,"allusers"); |
92 | usersListView->addColumn("UID"); | 91 | usersListView->addColumn("UID"); |
93 | usersListView->addColumn("Login"); | 92 | usersListView->addColumn("Login"); |
94 | usersListView->addColumn("Username"); | 93 | usersListView->addColumn("Username"); |
95 | layout->addWidget(usersListView); | 94 | layout->addWidget(usersListView); |
96 | usersListView->setSorting(1,1); | 95 | usersListView->setSorting(1,1); |
97 | usersListView->setAllColumnsShowFocus(true); | 96 | usersListView->setAllColumnsShowFocus(true); |
98 | 97 | ||
99 | myTabWidget->addTab(tabpage,"All Users"); | 98 | myTabWidget->addTab(tabpage,"All Users"); |
100 | } | 99 | } |
101 | 100 | ||
102 | void UserConfig::setupTabAllGroups() { | 101 | void UserConfig::setupTabAllGroups() { |
103 | QWidget *tabpage = new QWidget(this); | 102 | QWidget *tabpage = new QWidget(this); |
104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 103 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
105 | layout->setMargin(5); | 104 | layout->setMargin(5); |
106 | 105 | ||
107 | groupsListView=new QListView(tabpage,"groups"); | 106 | groupsListView=new QListView(tabpage,"groups"); |
108 | groupsListView->addColumn("GID"); | 107 | groupsListView->addColumn("GID"); |
109 | groupsListView->addColumn("Groupname"); | 108 | groupsListView->addColumn("Groupname"); |
110 | layout->addWidget(groupsListView); | 109 | layout->addWidget(groupsListView); |
111 | groupsListView->setSorting(1,1); | 110 | groupsListView->setSorting(1,1); |
112 | groupsListView->setAllColumnsShowFocus(true); | 111 | groupsListView->setAllColumnsShowFocus(true); |
113 | 112 | ||
114 | myTabWidget->addTab(tabpage,"All Groups"); | 113 | myTabWidget->addTab(tabpage,"All Groups"); |
115 | } | 114 | } |
116 | void UserConfig::getUsers() { | 115 | void UserConfig::getUsers() { |
117 | QString mytext; | 116 | QString mytext; |
118 | QPixmap mypixmap; | 117 | QPixmap mypixmap; |
119 | QListViewItem *listviewitem; | 118 | QListViewItem *listviewitem; |
120 | 119 | ||
121 | // Empty the iconview & the listview. | 120 | // Empty the iconview & the listview. |
122 | usersIconView->clear(); | 121 | usersIconView->clear(); |
123 | usersListView->clear(); | 122 | usersListView->clear(); |
124 | 123 | ||
125 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 124 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
126 | availableUID=500; | 125 | availableUID=500; |
127 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 126 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { |
128 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 127 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
129 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 128 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
130 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
131 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
132 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
133 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. | 132 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. |
134 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | 133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. |
135 | } | 134 | } |
136 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | 135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
137 | listviewitem->setPixmap(0,mypixmap); | 136 | listviewitem->setPixmap(0,mypixmap); |
138 | } | 137 | } |
139 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. | 138 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. |
140 | } | 139 | } |
141 | } | 140 | } |
142 | usersIconView->sort(); | 141 | usersIconView->sort(); |
143 | } | 142 | } |
144 | 143 | ||
145 | void UserConfig::addUser() { | 144 | void UserConfig::addUser() { |
146 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 145 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
147 | getUsers(); // Update users views. | 146 | getUsers(); // Update users views. |
148 | getGroups(); // Update groups view. | 147 | getGroups(); // Update groups view. |
149 | } | 148 | } |
150 | } | 149 | } |
151 | 150 | ||
152 | void UserConfig::editUser() { | 151 | void UserConfig::editUser() { |
153 | QString username; | 152 | QString username; |
154 | if(myTabWidget->currentPageIndex()==0) {// Users | 153 | if(myTabWidget->currentPageIndex()==0) {// Users |
155 | if(usersIconView->currentItem()) {// Any icon selected? | 154 | if(usersIconView->currentItem()) {// Any icon selected? |
156 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. | 155 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
157 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 156 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
158 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 157 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
159 | // If there were any changed also update the views. | 158 | // If there were any changed also update the views. |
160 | getUsers(); | 159 | getUsers(); |
161 | getGroups(); | 160 | getGroups(); |
162 | } | 161 | } |
163 | } else { | 162 | } else { |
164 | QMessageBox::information(this,"No selection.","No user has been selected."); | 163 | QMessageBox::information(this,"No selection.","No user has been selected."); |
165 | } | 164 | } |
166 | } | 165 | } |
167 | if(myTabWidget->currentPageIndex()==1) {// All users | 166 | if(myTabWidget->currentPageIndex()==1) {// All users |
168 | if(usersListView->currentItem()) {// Anything changed!? | 167 | if(usersListView->currentItem()) {// Anything changed!? |
169 | username=usersListView->currentItem()->text(1);// Get the username. | 168 | username=usersListView->currentItem()->text(1);// Get the username. |
170 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 169 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
171 | // And again update the views if there were any changes. | 170 | // And again update the views if there were any changes. |
172 | getUsers(); | 171 | getUsers(); |
173 | getGroups(); | 172 | getGroups(); |
174 | } | 173 | } |
175 | } else { | 174 | } else { |
176 | QMessageBox::information(this,"No selection.","No user has been selected."); | 175 | QMessageBox::information(this,"No selection.","No user has been selected."); |
177 | } | 176 | } |
178 | } | 177 | } |
179 | } | 178 | } |
180 | 179 | ||
181 | void UserConfig::delUser() { | 180 | void UserConfig::delUser() { |
182 | QString username; | 181 | QString username; |
183 | 182 | ||
184 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 183 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
185 | if(usersIconView->currentItem()) {// Anything selected? | 184 | if(usersIconView->currentItem()) {// Anything selected? |
186 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. | 185 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
187 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 186 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
188 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 187 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
189 | if(UserDialog::delUser(username)) {// Delete the user if possible. | 188 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
190 | // Update views. | 189 | // Update views. |
191 | getUsers(); | 190 | getUsers(); |
192 | getGroups(); | 191 | getGroups(); |
193 | } | 192 | } |
194 | } | 193 | } |
195 | } else { | 194 | } else { |
196 | QMessageBox::information(this,"No selection","No user has been selected."); | 195 | QMessageBox::information(this,"No selection","No user has been selected."); |
197 | } | 196 | } |
198 | } | 197 | } |
199 | if(myTabWidget->currentPageIndex()==1) {// All users | 198 | if(myTabWidget->currentPageIndex()==1) {// All users |
200 | if(usersListView->currentItem()) {// Anything changed!? | 199 | if(usersListView->currentItem()) {// Anything changed!? |
201 | username=usersListView->currentItem()->text(1);// Get the username. | 200 | username=usersListView->currentItem()->text(1);// Get the username. |
202 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 201 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
203 | if(UserDialog::delUser(username)) {// Try to delete the user. | 202 | if(UserDialog::delUser(username)) {// Try to delete the user. |
204 | // Update views. | 203 | // Update views. |
205 | getUsers(); | 204 | getUsers(); |
206 | getGroups(); | 205 | getGroups(); |
207 | } | 206 | } |
208 | } | 207 | } |
209 | } else { | 208 | } else { |
210 | QMessageBox::information(this,"No selection","No user has been selected."); | 209 | QMessageBox::information(this,"No selection","No user has been selected."); |
211 | } | 210 | } |
212 | } | 211 | } |
213 | 212 | ||
214 | } | 213 | } |
215 | 214 | ||
216 | void UserConfig::getGroups() { | 215 | void UserConfig::getGroups() { |
217 | groupsListView->clear();// Empty the listview. | 216 | groupsListView->clear();// Empty the listview. |
218 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. | 217 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. |
219 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. | 218 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. |
220 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). | 219 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). |
221 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 220 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
222 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); | 221 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); |
223 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. | 222 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. |
224 | } | 223 | } |
225 | } | 224 | } |
226 | } | 225 | } |
227 | 226 | ||
228 | void UserConfig::addGroup() { | 227 | void UserConfig::addGroup() { |
229 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. | 228 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. |
230 | } | 229 | } |
231 | 230 | ||
232 | void UserConfig::editGroup() { | 231 | void UserConfig::editGroup() { |
233 | int gid; | 232 | int gid; |
234 | if(groupsListView->currentItem()) {// Any group selected? | 233 | if(groupsListView->currentItem()) {// Any group selected? |
235 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. | 234 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. |
236 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. | 235 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. |
237 | } else { | 236 | } else { |
238 | QMessageBox::information(this,"No selection","No group has been selected."); | 237 | QMessageBox::information(this,"No selection","No group has been selected."); |
239 | } | 238 | } |
240 | } | 239 | } |
241 | 240 | ||
242 | void UserConfig::delGroup() { | 241 | void UserConfig::delGroup() { |
243 | const char *groupname; | 242 | const char *groupname; |
244 | if(groupsListView->currentItem()) {// Any group selected? | 243 | if(groupsListView->currentItem()) {// Any group selected? |
245 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. | 244 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. |
246 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { | 245 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { |
247 | // If confirmed, try to delete the group. | 246 | // If confirmed, try to delete the group. |
248 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. | 247 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. |
249 | } | 248 | } |
250 | } else { | 249 | } else { |
251 | QMessageBox::information(this,"No selection","No group has been selected."); | 250 | QMessageBox::information(this,"No selection","No group has been selected."); |
252 | } | 251 | } |
253 | } | 252 | } |
254 | 253 | ||
255 | void UserConfig::showUserMenu(QListViewItem *item) { | 254 | void UserConfig::showUserMenu(QListViewItem *item) { |
256 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); | 255 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); |
257 | qWarning("Pressed!"); | 256 | qWarning("Pressed!"); |
258 | } | 257 | } |