-rw-r--r-- | noncore/settings/usermanager/opie-usermanager.control | 2 | ||||
-rw-r--r-- | noncore/settings/usermanager/passwd.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/usermanager/usermanager.cpp | 26 |
4 files changed, 28 insertions, 17 deletions
diff --git a/noncore/settings/usermanager/opie-usermanager.control b/noncore/settings/usermanager/opie-usermanager.control index f971fdc..e1c7762 100644 --- a/noncore/settings/usermanager/opie-usermanager.control +++ b/noncore/settings/usermanager/opie-usermanager.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/usermanager apps/Settings/usermanager.desktop pics/usermanager/* | 1 | Files: bin/usermanager apps/Settings/usermanager.desktop pics/usermanager/* |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/settings | 3 | Section: opie/settings |
4 | Version: $QPE_VERSION-$SUB_VERSION | 4 | Version: $QPE_VERSION-$SUB_VERSION |
5 | Depends: opie-base | 5 | Depends: opie-base |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Maintainer: Ted Parnefors <zaurus@bredband.net> | 7 | Maintainer: Ted Parnefors <zaurus@bredband.net> |
8 | License: GPL | 8 | License: GPL |
9 | Description: User/Group manager for OPIE. | 9 | Description: User/Group manager for Opie. |
diff --git a/noncore/settings/usermanager/passwd.cpp b/noncore/settings/usermanager/passwd.cpp index 1e98778..f8e6d17 100644 --- a/noncore/settings/usermanager/passwd.cpp +++ b/noncore/settings/usermanager/passwd.cpp | |||
@@ -194,36 +194,41 @@ bool Passwd::delUser(const char *username, bool delGroup) { | |||
194 | QRegExp userRegExp(QString("^%1\\:").arg(username)); | 194 | QRegExp userRegExp(QString("^%1\\:").arg(username)); |
195 | return deleteUser(userRegExp,delGroup); | 195 | return deleteUser(userRegExp,delGroup); |
196 | } | 196 | } |
197 | 197 | ||
198 | // Delete a user by uid, and optionally also delete group. | 198 | // Delete a user by uid, and optionally also delete group. |
199 | bool Passwd::delUser(int uid, bool delGroup) { | 199 | bool Passwd::delUser(int uid, bool delGroup) { |
200 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); | 200 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); |
201 | return deleteUser(userRegExp,delGroup); | 201 | return deleteUser(userRegExp,delGroup); |
202 | } | 202 | } |
203 | 203 | ||
204 | // Locate a group in the groupStringList, fill out the gr_* variables and return "true" if found. | 204 | // Locate a group in the groupStringList, fill out the gr_* variables and return "true" if found. |
205 | bool Passwd::searchGroup(QRegExp &groupRegExp) { | 205 | bool Passwd::searchGroup(QRegExp &groupRegExp) { |
206 | QStringList tempStringList(groupStringList.grep(groupRegExp)); | 206 | QStringList tempStringList(groupStringList.grep(groupRegExp)); |
207 | if((tempStringList.isEmpty())) { | 207 | if((tempStringList.isEmpty())) { |
208 | return false; | 208 | return false; |
209 | } else { | 209 | } else { |
210 | groupString=(*(tempStringList.begin())); | 210 | for(QStringList::Iterator it=tempStringList.begin(); it!=tempStringList.end(); it++) { |
211 | splitGroupEntry(groupString); | 211 | groupString=*it; |
212 | if(!groupString.find(QRegExp("^#"),0)) {// Skip commented lines. | ||
213 | splitGroupEntry(groupString); | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
212 | } | 217 | } |
213 | return true; | 218 | return false; |
214 | } | 219 | } |
215 | 220 | ||
216 | // Find a group by groupname. | 221 | // Find a group by groupname. |
217 | bool Passwd::findGroup(const char *groupname) { | 222 | bool Passwd::findGroup(const char *groupname) { |
218 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); | 223 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); |
219 | return searchGroup(groupRegExp); | 224 | return searchGroup(groupRegExp); |
220 | } | 225 | } |
221 | 226 | ||
222 | // Find a group by gid. | 227 | // Find a group by gid. |
223 | bool Passwd::findGroup(int gid) { | 228 | bool Passwd::findGroup(int gid) { |
224 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); | 229 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); |
225 | return searchGroup(groupRegExp); | 230 | return searchGroup(groupRegExp); |
226 | } | 231 | } |
227 | 232 | ||
228 | // Add a group to groupStringList | 233 | // Add a group to groupStringList |
229 | bool Passwd::addGroup(QString gr_name, int gr_gid) { | 234 | bool Passwd::addGroup(QString gr_name, int gr_gid) { |
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 0d2122b..c06f639 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -31,34 +31,36 @@ using namespace Opie; | |||
31 | /** | 31 | /** |
32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { | 35 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { |
36 | vm=viewmode; | 36 | vm=viewmode; |
37 | QVBoxLayout *layout = new QVBoxLayout(this); | 37 | QVBoxLayout *layout = new QVBoxLayout(this); |
38 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 38 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
39 | layout->addWidget(myTabWidget); | 39 | layout->addWidget(myTabWidget); |
40 | setupTab1(); | 40 | setupTab1(); |
41 | setupTab2(); | 41 | setupTab2(); |
42 | 42 | ||
43 | accounts->groupStringList.sort(); | 43 | accounts->groupStringList.sort(); |
44 | // And also fill the listview & the combobox with all available groups. | 44 | // And also fill the listview & the combobox with all available groups. |
45 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { | 45 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { |
46 | accounts->splitGroupEntry(*it); | 46 | accounts->splitGroupEntry(*it); |
47 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 47 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
48 | groupComboBox->insertItem(accounts->gr_name); | 48 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
49 | groupComboBox->insertItem(accounts->gr_name); | ||
50 | } | ||
49 | } | 51 | } |
50 | showMaximized(); | 52 | showMaximized(); |
51 | } | 53 | } |
52 | 54 | ||
53 | /** | 55 | /** |
54 | * Empty destructor. | 56 | * Empty destructor. |
55 | * | 57 | * |
56 | */ | 58 | */ |
57 | UserDialog::~UserDialog() { | 59 | UserDialog::~UserDialog() { |
58 | } | 60 | } |
59 | 61 | ||
60 | /** | 62 | /** |
61 | * Creates the first tab, all userinfo is here. | 63 | * Creates the first tab, all userinfo is here. |
62 | * | 64 | * |
63 | */ | 65 | */ |
64 | void UserDialog::setupTab1() { | 66 | void UserDialog::setupTab1() { |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 57efa71..1946013 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -113,42 +113,44 @@ void UserConfig::setupTabAllGroups() { | |||
113 | 113 | ||
114 | myTabWidget->addTab(tabpage,"All Groups"); | 114 | myTabWidget->addTab(tabpage,"All Groups"); |
115 | } | 115 | } |
116 | void UserConfig::getUsers() { | 116 | void UserConfig::getUsers() { |
117 | QString mytext; | 117 | QString mytext; |
118 | QPixmap mypixmap; | 118 | QPixmap mypixmap; |
119 | QListViewItem *listviewitem; | 119 | QListViewItem *listviewitem; |
120 | 120 | ||
121 | // Empty the iconview & the listview. | 121 | // Empty the iconview & the listview. |
122 | usersIconView->clear(); | 122 | usersIconView->clear(); |
123 | usersListView->clear(); | 123 | usersListView->clear(); |
124 | 124 | ||
125 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 125 | // 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; | 126 | availableUID=500; |
127 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 127 | 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.) | 128 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 129 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 130 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 131 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
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. | 132 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default 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. |
134 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | ||
135 | } | ||
136 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | ||
137 | listviewitem->setPixmap(0,mypixmap); | ||
134 | } | 138 | } |
135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | 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. |
136 | listviewitem->setPixmap(0,mypixmap); | ||
137 | } | 140 | } |
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. | ||
139 | } | 141 | } |
140 | usersIconView->sort(); | 142 | usersIconView->sort(); |
141 | } | 143 | } |
142 | 144 | ||
143 | void UserConfig::addUser() { | 145 | void UserConfig::addUser() { |
144 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 146 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
145 | getUsers(); // Update users views. | 147 | getUsers(); // Update users views. |
146 | getGroups(); // Update groups view. | 148 | getGroups(); // Update groups view. |
147 | } | 149 | } |
148 | } | 150 | } |
149 | 151 | ||
150 | void UserConfig::editUser() { | 152 | void UserConfig::editUser() { |
151 | QString username; | 153 | QString username; |
152 | if(myTabWidget->currentPageIndex()==0) {// Users | 154 | if(myTabWidget->currentPageIndex()==0) {// Users |
153 | if(usersIconView->currentItem()) {// Any icon selected? | 155 | if(usersIconView->currentItem()) {// Any icon selected? |
154 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. | 156 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
@@ -203,36 +205,38 @@ void UserConfig::delUser() { | |||
203 | getUsers(); | 205 | getUsers(); |
204 | getGroups(); | 206 | getGroups(); |
205 | } | 207 | } |
206 | } | 208 | } |
207 | } else { | 209 | } else { |
208 | QMessageBox::information(this,"No selection","No user has been selected."); | 210 | QMessageBox::information(this,"No selection","No user has been selected."); |
209 | } | 211 | } |
210 | } | 212 | } |
211 | 213 | ||
212 | } | 214 | } |
213 | 215 | ||
214 | void UserConfig::getGroups() { | 216 | void UserConfig::getGroups() { |
215 | groupsListView->clear();// Empty the listview. | 217 | groupsListView->clear();// Empty the listview. |
216 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. | 218 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. |
217 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. | 219 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. |
218 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). | 220 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). |
219 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); | 221 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
220 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. | 222 | 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. | ||
224 | } | ||
221 | } | 225 | } |
222 | } | 226 | } |
223 | 227 | ||
224 | void UserConfig::addGroup() { | 228 | void UserConfig::addGroup() { |
225 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. | 229 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. |
226 | } | 230 | } |
227 | 231 | ||
228 | void UserConfig::editGroup() { | 232 | void UserConfig::editGroup() { |
229 | int gid; | 233 | int gid; |
230 | if(groupsListView->currentItem()) {// Any group selected? | 234 | if(groupsListView->currentItem()) {// Any group selected? |
231 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. | 235 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. |
232 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. | 236 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. |
233 | } else { | 237 | } else { |
234 | QMessageBox::information(this,"No selection","No group has been selected."); | 238 | QMessageBox::information(this,"No selection","No group has been selected."); |
235 | } | 239 | } |
236 | } | 240 | } |
237 | 241 | ||
238 | void UserConfig::delGroup() { | 242 | void UserConfig::delGroup() { |