author | umopapisdn <umopapisdn> | 2003-03-28 13:12:09 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-28 13:12:09 (UTC) |
commit | b271d575fa05cf570a1a829136517761bd47e69b (patch) (unidiff) | |
tree | e82c8e348b3b926fb365c42454d12a56dda0adc6 | |
parent | 8e8803488d2c11b12449e785802da4a5a9adad0f (diff) | |
download | opie-b271d575fa05cf570a1a829136517761bd47e69b.zip opie-b271d575fa05cf570a1a829136517761bd47e69b.tar.gz opie-b271d575fa05cf570a1a829136517761bd47e69b.tar.bz2 |
Bugfix: (bug #0000765) Lines in /etc/passwd & /etc/group starting with a "#" are comments and should not be editable.
-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 | |||
@@ -1,300 +1,305 @@ | |||
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 "passwd.h" | 10 | #include "passwd.h" |
11 | 11 | ||
12 | // Needed for crypt_make_salt(); | 12 | // Needed for crypt_make_salt(); |
13 | #include <sys/types.h> | 13 | #include <sys/types.h> |
14 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <time.h> | 16 | #include <time.h> |
17 | 17 | ||
18 | Passwd::Passwd() { | 18 | Passwd::Passwd() { |
19 | } | 19 | } |
20 | 20 | ||
21 | Passwd::~Passwd() { | 21 | Passwd::~Passwd() { |
22 | } | 22 | } |
23 | 23 | ||
24 | // This function is taken from 'busybox'. | 24 | // This function is taken from 'busybox'. |
25 | int Passwd::i64c(int i) | 25 | int Passwd::i64c(int i) |
26 | { | 26 | { |
27 | if (i <= 0) | 27 | if (i <= 0) |
28 | return ('.'); | 28 | return ('.'); |
29 | if (i == 1) | 29 | if (i == 1) |
30 | return ('/'); | 30 | return ('/'); |
31 | if (i >= 2 && i < 12) | 31 | if (i >= 2 && i < 12) |
32 | return ('0' - 2 + i); | 32 | return ('0' - 2 + i); |
33 | if (i >= 12 && i < 38) | 33 | if (i >= 12 && i < 38) |
34 | return ('A' - 12 + i); | 34 | return ('A' - 12 + i); |
35 | if (i >= 38 && i < 63) | 35 | if (i >= 38 && i < 63) |
36 | return ('a' - 38 + i); | 36 | return ('a' - 38 + i); |
37 | return ('z'); | 37 | return ('z'); |
38 | } | 38 | } |
39 | 39 | ||
40 | // This function is taken from 'busybox'. | 40 | // This function is taken from 'busybox'. |
41 | char *Passwd::crypt_make_salt() { | 41 | char *Passwd::crypt_make_salt() { |
42 | time_t now; | 42 | time_t now; |
43 | static unsigned long x; | 43 | static unsigned long x; |
44 | static char result[3]; | 44 | static char result[3]; |
45 | 45 | ||
46 | time(&now); | 46 | time(&now); |
47 | x += now + getpid() + clock(); | 47 | x += now + getpid() + clock(); |
48 | result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077); | 48 | result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077); |
49 | result[1] = i64c(((x >> 12) ^ x) & 077); | 49 | result[1] = i64c(((x >> 12) ^ x) & 077); |
50 | result[2] = '\0'; | 50 | result[2] = '\0'; |
51 | return result; | 51 | return result; |
52 | } | 52 | } |
53 | 53 | ||
54 | // opens the files /etc/passwd & /etc/group and loads the contents into passwdStringList & groupStringList | 54 | // opens the files /etc/passwd & /etc/group and loads the contents into passwdStringList & groupStringList |
55 | bool Passwd::open() { | 55 | bool Passwd::open() { |
56 | int returnvalue=false; | 56 | int returnvalue=false; |
57 | 57 | ||
58 | QFile passwd_file("/etc/passwd"); | 58 | QFile passwd_file("/etc/passwd"); |
59 | QFile group_file("/etc/group"); | 59 | QFile group_file("/etc/group"); |
60 | passwdStringList.clear(); | 60 | passwdStringList.clear(); |
61 | groupStringList.clear(); | 61 | groupStringList.clear(); |
62 | if((passwd_file.open(IO_ReadOnly))) { | 62 | if((passwd_file.open(IO_ReadOnly))) { |
63 | if((group_file.open(IO_ReadOnly))) { | 63 | if((group_file.open(IO_ReadOnly))) { |
64 | QTextStream ts_passwd(&passwd_file); | 64 | QTextStream ts_passwd(&passwd_file); |
65 | while(!(ts_passwd.eof())) { | 65 | while(!(ts_passwd.eof())) { |
66 | passwdStringList << ts_passwd.readLine(); | 66 | passwdStringList << ts_passwd.readLine(); |
67 | } | 67 | } |
68 | QTextStream ts_group(&group_file); | 68 | QTextStream ts_group(&group_file); |
69 | while(!(ts_group.eof())) { | 69 | while(!(ts_group.eof())) { |
70 | groupStringList << ts_group.readLine(); | 70 | groupStringList << ts_group.readLine(); |
71 | } | 71 | } |
72 | returnvalue=true; | 72 | returnvalue=true; |
73 | group_file.close(); | 73 | group_file.close(); |
74 | } | 74 | } |
75 | passwd_file.close(); | 75 | passwd_file.close(); |
76 | } | 76 | } |
77 | return returnvalue; | 77 | return returnvalue; |
78 | } | 78 | } |
79 | 79 | ||
80 | // Writes back the contents of passwdStringList to /etc/passwd & groupStringList to /etc/group | 80 | // Writes back the contents of passwdStringList to /etc/passwd & groupStringList to /etc/group |
81 | bool Passwd::close() { | 81 | bool Passwd::close() { |
82 | int returnvalue=false; | 82 | int returnvalue=false; |
83 | QFile passwd_file("/etc/passwd"); | 83 | QFile passwd_file("/etc/passwd"); |
84 | QFile group_file("/etc/group"); | 84 | QFile group_file("/etc/group"); |
85 | if((passwd_file.open(IO_WriteOnly))) { | 85 | if((passwd_file.open(IO_WriteOnly))) { |
86 | if((group_file.open(IO_WriteOnly))) { | 86 | if((group_file.open(IO_WriteOnly))) { |
87 | QTextStream ts_passwd(&passwd_file); | 87 | QTextStream ts_passwd(&passwd_file); |
88 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { | 88 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { |
89 | ts_passwd << (*it) + "\n"; | 89 | ts_passwd << (*it) + "\n"; |
90 | } | 90 | } |
91 | QTextStream ts_group(&group_file); | 91 | QTextStream ts_group(&group_file); |
92 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { | 92 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { |
93 | ts_group << (*it) + "\n"; | 93 | ts_group << (*it) + "\n"; |
94 | } | 94 | } |
95 | returnvalue=true; | 95 | returnvalue=true; |
96 | group_file.close(); | 96 | group_file.close(); |
97 | } | 97 | } |
98 | passwd_file.close(); | 98 | passwd_file.close(); |
99 | } | 99 | } |
100 | return returnvalue; | 100 | return returnvalue; |
101 | } | 101 | } |
102 | 102 | ||
103 | // Splits a "passwd" line into the components and stores them in the pw_* variables. | 103 | // Splits a "passwd" line into the components and stores them in the pw_* variables. |
104 | void Passwd::splitPasswdEntry(QString &userString) { | 104 | void Passwd::splitPasswdEntry(QString &userString) { |
105 | userdataStringList=QStringList::split(":",userString,true); | 105 | userdataStringList=QStringList::split(":",userString,true); |
106 | QStringList::Iterator it=userdataStringList.begin(); | 106 | QStringList::Iterator it=userdataStringList.begin(); |
107 | pw_name=(*it++); | 107 | pw_name=(*it++); |
108 | pw_passwd=(*it++); | 108 | pw_passwd=(*it++); |
109 | pw_uid=(*it++).toInt(); | 109 | pw_uid=(*it++).toInt(); |
110 | pw_gid=(*it++).toInt(); | 110 | pw_gid=(*it++).toInt(); |
111 | pw_gecos=(*it++); | 111 | pw_gecos=(*it++); |
112 | pw_dir=(*it++); | 112 | pw_dir=(*it++); |
113 | pw_shell=(*it++); | 113 | pw_shell=(*it++); |
114 | } | 114 | } |
115 | 115 | ||
116 | // Splits a "group" line into the components and stores them in the gr_* variables. | 116 | // Splits a "group" line into the components and stores them in the gr_* variables. |
117 | void Passwd::splitGroupEntry(QString &groupString) { | 117 | void Passwd::splitGroupEntry(QString &groupString) { |
118 | groupdataStringList=QStringList::split(":",groupString,true); | 118 | groupdataStringList=QStringList::split(":",groupString,true); |
119 | QStringList::Iterator it=groupdataStringList.begin(); | 119 | QStringList::Iterator it=groupdataStringList.begin(); |
120 | gr_name=(*it++); | 120 | gr_name=(*it++); |
121 | it++; | 121 | it++; |
122 | gr_gid=(*it++).toInt(); | 122 | gr_gid=(*it++).toInt(); |
123 | gr_mem=QStringList::split(",",(*it++)); | 123 | gr_mem=QStringList::split(",",(*it++)); |
124 | } | 124 | } |
125 | 125 | ||
126 | // Find a user in the passwdStringList. Return true if found and also fill the pw_* variables. | 126 | // Find a user in the passwdStringList. Return true if found and also fill the pw_* variables. |
127 | bool Passwd::searchUser(QRegExp &userRegExp) { | 127 | bool Passwd::searchUser(QRegExp &userRegExp) { |
128 | QStringList tempStringList(passwdStringList.grep(userRegExp)); | 128 | QStringList tempStringList(passwdStringList.grep(userRegExp)); |
129 | if((tempStringList.isEmpty())) { | 129 | if((tempStringList.isEmpty())) { |
130 | return false; | 130 | return false; |
131 | } else { | 131 | } else { |
132 | userString=(*(tempStringList.begin())); | 132 | userString=(*(tempStringList.begin())); |
133 | splitPasswdEntry(userString); | 133 | splitPasswdEntry(userString); |
134 | } | 134 | } |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
137 | 137 | ||
138 | // Find a user by login. | 138 | // Find a user by login. |
139 | bool Passwd::findUser(const char *username) { | 139 | bool Passwd::findUser(const char *username) { |
140 | QRegExp userRegExp(QString("^%1\\:").arg(username)); | 140 | QRegExp userRegExp(QString("^%1\\:").arg(username)); |
141 | return searchUser(userRegExp); | 141 | return searchUser(userRegExp); |
142 | } | 142 | } |
143 | 143 | ||
144 | // Find a user by uid. | 144 | // Find a user by uid. |
145 | bool Passwd::findUser(int uid) { | 145 | bool Passwd::findUser(int uid) { |
146 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); | 146 | QRegExp userRegExp(QString(":%1\\:").arg(uid)); |
147 | return searchUser(userRegExp); | 147 | return searchUser(userRegExp); |
148 | } | 148 | } |
149 | 149 | ||
150 | // Add a user to the passwdStringList, create home directory, and optionally create a group for the user. | 150 | // Add a user to the passwdStringList, create home directory, and optionally create a group for the user. |
151 | bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup) { | 151 | bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup) { |
152 | QString tempString; | 152 | QString tempString; |
153 | if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid); | 153 | if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid); |
154 | pw_passwd = crypt(pw_passwd, crypt_make_salt()); | 154 | pw_passwd = crypt(pw_passwd, crypt_make_salt()); |
155 | tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell; | 155 | tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell; |
156 | passwdStringList.append(tempString); | 156 | passwdStringList.append(tempString); |
157 | // Make home dir. | 157 | // Make home dir. |
158 | QDir d; | 158 | QDir d; |
159 | if(!(d.exists(pw_dir))) { | 159 | if(!(d.exists(pw_dir))) { |
160 | d.mkdir(pw_dir); | 160 | d.mkdir(pw_dir); |
161 | chown(pw_dir,pw_uid,pw_gid); | 161 | chown(pw_dir,pw_uid,pw_gid); |
162 | chmod(pw_dir,S_IRUSR|S_IWUSR|S_IXUSR); | 162 | chmod(pw_dir,S_IRUSR|S_IWUSR|S_IXUSR); |
163 | } | 163 | } |
164 | return 1; | 164 | return 1; |
165 | } | 165 | } |
166 | 166 | ||
167 | // Update info for a user in passwdStringList, take info from the pw_* fields. | 167 | // Update info for a user in passwdStringList, take info from the pw_* fields. |
168 | bool Passwd::updateUser(QString login) { | 168 | bool Passwd::updateUser(QString login) { |
169 | QRegExp userRegExp(QString("^%1\\:").arg(login)); | 169 | QRegExp userRegExp(QString("^%1\\:").arg(login)); |
170 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { | 170 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { |
171 | if(userRegExp.find((*it),0)!=-1) { | 171 | if(userRegExp.find((*it),0)!=-1) { |
172 | *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell); | 172 | *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell); |
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | return false; | 176 | return false; |
177 | } | 177 | } |
178 | 178 | ||
179 | // Delete a user from passwdStringList. | 179 | // Delete a user from passwdStringList. |
180 | bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) { | 180 | bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) { |
181 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { | 181 | for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { |
182 | if(userRegExp.find((*it),0)!=-1) { | 182 | if(userRegExp.find((*it),0)!=-1) { |
183 | splitPasswdEntry(*it); | 183 | splitPasswdEntry(*it); |
184 | if(delGroup) this->delGroup(pw_gid); | 184 | if(delGroup) this->delGroup(pw_gid); |
185 | passwdStringList.remove(it); | 185 | passwdStringList.remove(it); |
186 | return true; | 186 | return true; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | return false; | 189 | return false; |
190 | } | 190 | } |
191 | 191 | ||
192 | // Delete a user by login, and optionally also delete group. | 192 | // Delete a user by login, and optionally also delete group. |
193 | bool Passwd::delUser(const char *username, bool delGroup) { | 193 | 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) { |
230 | QString tempString; | 235 | QString tempString; |
231 | tempString=gr_name+":*:"+QString::number(gr_gid)+":"; | 236 | tempString=gr_name+":*:"+QString::number(gr_gid)+":"; |
232 | groupStringList.append(tempString); | 237 | groupStringList.append(tempString); |
233 | return 1; | 238 | return 1; |
234 | } | 239 | } |
235 | 240 | ||
236 | // Update fields for a group in groupStringList, take info from the gr_* variables. | 241 | // Update fields for a group in groupStringList, take info from the gr_* variables. |
237 | bool Passwd::updateGroup(int gid) { | 242 | bool Passwd::updateGroup(int gid) { |
238 | QRegExp groupRegExp(QString(":%1\\:").arg(QString::number(gid))); | 243 | QRegExp groupRegExp(QString(":%1\\:").arg(QString::number(gid))); |
239 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { | 244 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { |
240 | if(groupRegExp.find((*it),0)!=-1) { | 245 | if(groupRegExp.find((*it),0)!=-1) { |
241 | *it=QString(gr_name+":*:"+QString::number(gr_gid)+":"); | 246 | *it=QString(gr_name+":*:"+QString::number(gr_gid)+":"); |
242 | for(QStringList::Iterator member=gr_mem.begin(); member!=gr_mem.end();) { | 247 | for(QStringList::Iterator member=gr_mem.begin(); member!=gr_mem.end();) { |
243 | *it+=*member; | 248 | *it+=*member; |
244 | ++member; | 249 | ++member; |
245 | if(member!=gr_mem.end()) *it+=","; | 250 | if(member!=gr_mem.end()) *it+=","; |
246 | } | 251 | } |
247 | return true; | 252 | return true; |
248 | } | 253 | } |
249 | } | 254 | } |
250 | return false; | 255 | return false; |
251 | } | 256 | } |
252 | 257 | ||
253 | // Delete a group from groupStringList. | 258 | // Delete a group from groupStringList. |
254 | bool Passwd::deleteGroup(QRegExp &groupRegExp) { | 259 | bool Passwd::deleteGroup(QRegExp &groupRegExp) { |
255 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { | 260 | for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) { |
256 | if(groupRegExp.find((*it),0)!=-1) { | 261 | if(groupRegExp.find((*it),0)!=-1) { |
257 | groupStringList.remove(it); | 262 | groupStringList.remove(it); |
258 | return true; | 263 | return true; |
259 | } | 264 | } |
260 | } | 265 | } |
261 | return false; | 266 | return false; |
262 | } | 267 | } |
263 | 268 | ||
264 | // Delete a group by groupname. | 269 | // Delete a group by groupname. |
265 | bool Passwd::delGroup(const char *groupname) { | 270 | bool Passwd::delGroup(const char *groupname) { |
266 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); | 271 | QRegExp groupRegExp(QString("^%1\\:").arg(groupname)); |
267 | return deleteGroup(groupRegExp); | 272 | return deleteGroup(groupRegExp); |
268 | } | 273 | } |
269 | 274 | ||
270 | // Delete a group by gid. | 275 | // Delete a group by gid. |
271 | bool Passwd::delGroup(int gid) { | 276 | bool Passwd::delGroup(int gid) { |
272 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); | 277 | QRegExp groupRegExp(QString(":%1\\:").arg(gid)); |
273 | return deleteGroup(groupRegExp); | 278 | return deleteGroup(groupRegExp); |
274 | } | 279 | } |
275 | 280 | ||
276 | // Add a user as a member to a group in groupStringList. | 281 | // Add a user as a member to a group in groupStringList. |
277 | bool Passwd::addGroupMember(QString groupname, QString member) { | 282 | bool Passwd::addGroupMember(QString groupname, QString member) { |
278 | if(!(findGroup(groupname))) return false; | 283 | if(!(findGroup(groupname))) return false; |
279 | QRegExp memberRegExp(QString("^%1$").arg(member)); | 284 | QRegExp memberRegExp(QString("^%1$").arg(member)); |
280 | QStringList templist=gr_mem.grep(memberRegExp); | 285 | QStringList templist=gr_mem.grep(memberRegExp); |
281 | if(templist.isEmpty()) gr_mem << member; | 286 | if(templist.isEmpty()) gr_mem << member; |
282 | if(!(updateGroup(gr_gid))) return false; | 287 | if(!(updateGroup(gr_gid))) return false; |
283 | return true; | 288 | return true; |
284 | } | 289 | } |
285 | 290 | ||
286 | // Delete a user as a groupmember from a group in groupStringList. | 291 | // Delete a user as a groupmember from a group in groupStringList. |
287 | bool Passwd::delGroupMember(QString groupname, QString member) { | 292 | bool Passwd::delGroupMember(QString groupname, QString member) { |
288 | if(!(findGroup(groupname))) return false; | 293 | if(!(findGroup(groupname))) return false; |
289 | for(QStringList::Iterator it=gr_mem.begin(); it!=gr_mem.end(); ++it) { | 294 | for(QStringList::Iterator it=gr_mem.begin(); it!=gr_mem.end(); ++it) { |
290 | if(*it==member) { | 295 | if(*it==member) { |
291 | gr_mem.remove(it); | 296 | gr_mem.remove(it); |
292 | it=gr_mem.end(); | 297 | it=gr_mem.end(); |
293 | } | 298 | } |
294 | } | 299 | } |
295 | if(!(updateGroup(gr_gid))) return false; | 300 | if(!(updateGroup(gr_gid))) return false; |
296 | return true; | 301 | return true; |
297 | } | 302 | } |
298 | 303 | ||
299 | // Global Object | 304 | // Global Object |
300 | Passwd *accounts; | 305 | Passwd *accounts; |
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 | |||
@@ -1,432 +1,434 @@ | |||
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> | 17 | #include <stdlib.h> |
18 | 18 | ||
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <sys/types.h> | 20 | #include <sys/types.h> |
21 | #include <sys/wait.h> | 21 | #include <sys/wait.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <signal.h> | 23 | #include <signal.h> |
24 | 24 | ||
25 | #include "passwd.h" | 25 | #include "passwd.h" |
26 | 26 | ||
27 | #include <opie/odevice.h> | 27 | #include <opie/odevice.h> |
28 | using namespace Opie; | 28 | using namespace Opie; |
29 | 29 | ||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 32 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | UserDialog::UserDialog(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() { |
65 | QPixmap mypixmap; | 67 | QPixmap mypixmap; |
66 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 68 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
67 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 69 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
68 | layout->setMargin(5); | 70 | layout->setMargin(5); |
69 | 71 | ||
70 | // Picture | 72 | // Picture |
71 | picturePushButton = new QPushButton(tabpage,"Label"); | 73 | picturePushButton = new QPushButton(tabpage,"Label"); |
72 | picturePushButton->setMinimumSize(48,48); | 74 | picturePushButton->setMinimumSize(48,48); |
73 | picturePushButton->setMaximumSize(48,48); | 75 | picturePushButton->setMaximumSize(48,48); |
74 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. | 76 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. |
75 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. | 77 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. |
76 | 78 | ||
77 | // Login | 79 | // Login |
78 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); | 80 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); |
79 | loginLabel->setText("Login: "); | 81 | loginLabel->setText("Login: "); |
80 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | 82 | loginLineEdit=new QLineEdit(tabpage,"Login: "); |
81 | 83 | ||
82 | // UID | 84 | // UID |
83 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); | 85 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); |
84 | uidLabel->setText("UserID: "); | 86 | uidLabel->setText("UserID: "); |
85 | uidLineEdit=new QLineEdit(tabpage,"uid: "); | 87 | uidLineEdit=new QLineEdit(tabpage,"uid: "); |
86 | uidLineEdit->setEnabled(false); | 88 | uidLineEdit->setEnabled(false); |
87 | 89 | ||
88 | // Username (gecos) | 90 | // Username (gecos) |
89 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); | 91 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); |
90 | gecosLabel->setText("Username: "); | 92 | gecosLabel->setText("Username: "); |
91 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | 93 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); |
92 | 94 | ||
93 | // Password | 95 | // Password |
94 | QLabel *passwordLabel=new QLabel(tabpage,"password"); | 96 | QLabel *passwordLabel=new QLabel(tabpage,"password"); |
95 | passwordLabel->setText("Password: "); | 97 | passwordLabel->setText("Password: "); |
96 | passwordLineEdit=new QLineEdit(tabpage,"password"); | 98 | passwordLineEdit=new QLineEdit(tabpage,"password"); |
97 | passwordLineEdit->setEchoMode(QLineEdit::Password); | 99 | passwordLineEdit->setEchoMode(QLineEdit::Password); |
98 | 100 | ||
99 | // Shell | 101 | // Shell |
100 | QLabel *shellLabel=new QLabel(tabpage,"shell"); | 102 | QLabel *shellLabel=new QLabel(tabpage,"shell"); |
101 | shellLabel->setText("Shell: "); | 103 | shellLabel->setText("Shell: "); |
102 | shellComboBox=new QComboBox(tabpage,"shell"); | 104 | shellComboBox=new QComboBox(tabpage,"shell"); |
103 | shellComboBox->setEditable(true); | 105 | shellComboBox->setEditable(true); |
104 | shellComboBox->insertItem("/bin/sh"); | 106 | shellComboBox->insertItem("/bin/sh"); |
105 | shellComboBox->insertItem("/bin/ash"); | 107 | shellComboBox->insertItem("/bin/ash"); |
106 | shellComboBox->insertItem("/bin/false"); | 108 | shellComboBox->insertItem("/bin/false"); |
107 | 109 | ||
108 | // Primary Group | 110 | // Primary Group |
109 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 111 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
110 | groupLabel->setText("Primary group: "); | 112 | groupLabel->setText("Primary group: "); |
111 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 113 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
112 | 114 | ||
113 | if(vm==VIEWMODE_NEW) { | 115 | if(vm==VIEWMODE_NEW) { |
114 | // Copy /etc/skel | 116 | // Copy /etc/skel |
115 | skelLabel=new QLabel(tabpage,"skel"); | 117 | skelLabel=new QLabel(tabpage,"skel"); |
116 | skelLabel->setText("Copy /etc/skel: "); | 118 | skelLabel->setText("Copy /etc/skel: "); |
117 | skelCheckBox=new QCheckBox(tabpage); | 119 | skelCheckBox=new QCheckBox(tabpage); |
118 | skelCheckBox->setChecked(true); | 120 | skelCheckBox->setChecked(true); |
119 | } | 121 | } |
120 | 122 | ||
121 | // Widget layout | 123 | // Widget layout |
122 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 124 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
123 | layout->addWidget(picturePushButton); | 125 | layout->addWidget(picturePushButton); |
124 | layout->addSpacing(5); | 126 | layout->addSpacing(5); |
125 | layout->addLayout(hlayout); | 127 | layout->addLayout(hlayout); |
126 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 128 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
127 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 129 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
128 | // First column, labels | 130 | // First column, labels |
129 | vlayout1->addWidget(loginLabel); | 131 | vlayout1->addWidget(loginLabel); |
130 | vlayout1->addSpacing(5); | 132 | vlayout1->addSpacing(5); |
131 | vlayout1->addWidget(uidLabel); | 133 | vlayout1->addWidget(uidLabel); |
132 | vlayout1->addSpacing(5); | 134 | vlayout1->addSpacing(5); |
133 | vlayout1->addWidget(gecosLabel); | 135 | vlayout1->addWidget(gecosLabel); |
134 | vlayout1->addSpacing(5); | 136 | vlayout1->addSpacing(5); |
135 | vlayout1->addWidget(passwordLabel); | 137 | vlayout1->addWidget(passwordLabel); |
136 | vlayout1->addSpacing(5); | 138 | vlayout1->addSpacing(5); |
137 | vlayout1->addWidget(shellLabel); | 139 | vlayout1->addWidget(shellLabel); |
138 | vlayout1->addSpacing(5); | 140 | vlayout1->addSpacing(5); |
139 | vlayout1->addWidget(groupLabel); | 141 | vlayout1->addWidget(groupLabel); |
140 | if(vm==VIEWMODE_NEW) { | 142 | if(vm==VIEWMODE_NEW) { |
141 | vlayout1->addSpacing(5); | 143 | vlayout1->addSpacing(5); |
142 | vlayout1->addWidget(skelLabel); | 144 | vlayout1->addWidget(skelLabel); |
143 | } | 145 | } |
144 | // Second column, data | 146 | // Second column, data |
145 | vlayout2->addWidget(loginLineEdit); | 147 | vlayout2->addWidget(loginLineEdit); |
146 | vlayout2->addSpacing(5); | 148 | vlayout2->addSpacing(5); |
147 | vlayout2->addWidget(uidLineEdit); | 149 | vlayout2->addWidget(uidLineEdit); |
148 | vlayout2->addSpacing(5); | 150 | vlayout2->addSpacing(5); |
149 | vlayout2->addWidget(gecosLineEdit); | 151 | vlayout2->addWidget(gecosLineEdit); |
150 | vlayout2->addSpacing(5); | 152 | vlayout2->addSpacing(5); |
151 | vlayout2->addWidget(passwordLineEdit); | 153 | vlayout2->addWidget(passwordLineEdit); |
152 | vlayout2->addSpacing(5); | 154 | vlayout2->addSpacing(5); |
153 | vlayout2->addWidget(shellComboBox); | 155 | vlayout2->addWidget(shellComboBox); |
154 | vlayout2->addSpacing(5); | 156 | vlayout2->addSpacing(5); |
155 | vlayout2->addWidget(groupComboBox); | 157 | vlayout2->addWidget(groupComboBox); |
156 | if(vm==VIEWMODE_NEW) { | 158 | if(vm==VIEWMODE_NEW) { |
157 | vlayout2->addSpacing(5); | 159 | vlayout2->addSpacing(5); |
158 | vlayout2->addWidget(skelCheckBox); | 160 | vlayout2->addWidget(skelCheckBox); |
159 | } | 161 | } |
160 | hlayout->addLayout(vlayout1); | 162 | hlayout->addLayout(vlayout1); |
161 | hlayout->addLayout(vlayout2); | 163 | hlayout->addLayout(vlayout2); |
162 | 164 | ||
163 | myTabWidget->addTab(tabpage,"User Info"); | 165 | myTabWidget->addTab(tabpage,"User Info"); |
164 | } | 166 | } |
165 | 167 | ||
166 | /** | 168 | /** |
167 | * Creates the second tab containing additional groups for the user. | 169 | * Creates the second tab containing additional groups for the user. |
168 | * | 170 | * |
169 | */ | 171 | */ |
170 | void UserDialog::setupTab2() { | 172 | void UserDialog::setupTab2() { |
171 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 173 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
172 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 174 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
173 | layout->setMargin(5); | 175 | layout->setMargin(5); |
174 | 176 | ||
175 | // Additional groups | 177 | // Additional groups |
176 | groupsListView=new QListView(tabpage,"groups"); | 178 | groupsListView=new QListView(tabpage,"groups"); |
177 | groupsListView->addColumn("Additional groups"); | 179 | groupsListView->addColumn("Additional groups"); |
178 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 180 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
179 | groupsListView->setMultiSelection(false); | 181 | groupsListView->setMultiSelection(false); |
180 | groupsListView->setAllColumnsShowFocus(false); | 182 | groupsListView->setAllColumnsShowFocus(false); |
181 | 183 | ||
182 | layout->addSpacing(5); | 184 | layout->addSpacing(5); |
183 | // Grouplist | 185 | // Grouplist |
184 | layout->addWidget(groupsListView); | 186 | layout->addWidget(groupsListView); |
185 | 187 | ||
186 | myTabWidget->addTab(tabpage,"User Groups"); | 188 | myTabWidget->addTab(tabpage,"User Groups"); |
187 | } | 189 | } |
188 | 190 | ||
189 | /** | 191 | /** |
190 | * Static function that creates the userinfo dialog. | 192 | * Static function that creates the userinfo dialog. |
191 | * The user will be prompted to add a user. | 193 | * The user will be prompted to add a user. |
192 | * | 194 | * |
193 | * @param uid This is a suggested available UID. | 195 | * @param uid This is a suggested available UID. |
194 | * @param gid This is a suggested available GID. | 196 | * @param gid This is a suggested available GID. |
195 | * | 197 | * |
196 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. | 198 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. |
197 | * | 199 | * |
198 | */ | 200 | */ |
199 | bool UserDialog::addUser(int uid, int gid) { | 201 | bool UserDialog::addUser(int uid, int gid) { |
200 | QCheckListItem *temp; | 202 | QCheckListItem *temp; |
201 | QFile ozTest; | 203 | QFile ozTest; |
202 | int oz=false; | 204 | int oz=false; |
203 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 205 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
204 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. | 206 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
205 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | 207 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); |
206 | adduserDialog->setCaption(tr("Add User")); | 208 | adduserDialog->setCaption(tr("Add User")); |
207 | adduserDialog->userID=uid;// Set next available UID as default uid. | 209 | adduserDialog->userID=uid;// Set next available UID as default uid. |
208 | adduserDialog->groupID=gid;// Set next available GID as default gid. | 210 | adduserDialog->groupID=gid;// Set next available GID as default gid. |
209 | // Insert default group into groupComboBox | 211 | // Insert default group into groupComboBox |
210 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 212 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
211 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 213 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
212 | // If we're running on OZ, add new users to some default groups. | 214 | // If we're running on OZ, add new users to some default groups. |
213 | if(oz) { | 215 | if(oz) { |
214 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 216 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
215 | for ( ; iter.current(); ++iter ) { | 217 | for ( ; iter.current(); ++iter ) { |
216 | temp=(QCheckListItem*)iter.current(); | 218 | temp=(QCheckListItem*)iter.current(); |
217 | if (temp->text()=="video") temp->setOn(true); | 219 | if (temp->text()=="video") temp->setOn(true); |
218 | if (temp->text()=="audio") temp->setOn(true); | 220 | if (temp->text()=="audio") temp->setOn(true); |
219 | if (temp->text()=="time") temp->setOn(true); | 221 | if (temp->text()=="time") temp->setOn(true); |
220 | if (temp->text()=="power") temp->setOn(true); | 222 | if (temp->text()=="power") temp->setOn(true); |
221 | if (temp->text()=="input") temp->setOn(true); | 223 | if (temp->text()=="input") temp->setOn(true); |
222 | if (temp->text()=="sharp") temp->setOn(true); | 224 | if (temp->text()=="sharp") temp->setOn(true); |
223 | if (temp->text()=="tty") temp->setOn(true); | 225 | if (temp->text()=="tty") temp->setOn(true); |
224 | } | 226 | } |
225 | } | 227 | } |
226 | // Show the dialog! | 228 | // Show the dialog! |
227 | if(!(adduserDialog->exec())) return false; | 229 | if(!(adduserDialog->exec())) return false; |
228 | if((adduserDialog->groupComboBox->currentItem()!=0)) { | 230 | if((adduserDialog->groupComboBox->currentItem()!=0)) { |
229 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 231 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); |
230 | adduserDialog->groupID=accounts->gr_gid; | 232 | adduserDialog->groupID=accounts->gr_gid; |
231 | qWarning(QString::number(accounts->gr_gid)); | 233 | qWarning(QString::number(accounts->gr_gid)); |
232 | } | 234 | } |
233 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 235 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
234 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 236 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
235 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { | 237 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { |
236 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 238 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
237 | return false; | 239 | return false; |
238 | } | 240 | } |
239 | 241 | ||
240 | // Add User to additional groups. | 242 | // Add User to additional groups. |
241 | QListViewItemIterator it( adduserDialog->groupsListView ); | 243 | QListViewItemIterator it( adduserDialog->groupsListView ); |
242 | for ( ; it.current(); ++it ) { | 244 | for ( ; it.current(); ++it ) { |
243 | temp=(QCheckListItem*)it.current(); | 245 | temp=(QCheckListItem*)it.current(); |
244 | if (temp->isOn() ) | 246 | if (temp->isOn() ) |
245 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 247 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
246 | } | 248 | } |
247 | // Copy image to pics/users/ | 249 | // Copy image to pics/users/ |
248 | if(!(adduserDialog->userImage.isNull())) { | 250 | if(!(adduserDialog->userImage.isNull())) { |
249 | QDir d; | 251 | QDir d; |
250 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 252 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
251 | d.mkdir("/opt/QtPalmtop/pics/users"); | 253 | d.mkdir("/opt/QtPalmtop/pics/users"); |
252 | } | 254 | } |
253 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 255 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
254 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 256 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
255 | adduserDialog->userImage.save(filename,"PNG"); | 257 | adduserDialog->userImage.save(filename,"PNG"); |
256 | } | 258 | } |
257 | 259 | ||
258 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | 260 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? |
259 | accounts->findUser(adduserDialog->loginLineEdit->text()); | 261 | accounts->findUser(adduserDialog->loginLineEdit->text()); |
260 | if(adduserDialog->skelCheckBox->isChecked()) { | 262 | if(adduserDialog->skelCheckBox->isChecked()) { |
261 | QString command_cp; | 263 | QString command_cp; |
262 | QString command_chown; | 264 | QString command_chown; |
263 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | 265 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); |
264 | system(command_cp); | 266 | system(command_cp); |
265 | 267 | ||
266 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? | 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? |
267 | system(command_cp); | 269 | system(command_cp); |
268 | 270 | ||
269 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | 271 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); |
270 | system(command_chown); | 272 | system(command_chown); |
271 | } | 273 | } |
272 | 274 | ||
273 | return true; | 275 | return true; |
274 | } | 276 | } |
275 | 277 | ||
276 | /** | 278 | /** |
277 | * Deletes the user account. | 279 | * Deletes the user account. |
278 | * | 280 | * |
279 | * @param username User to be deleted. | 281 | * @param username User to be deleted. |
280 | * | 282 | * |
281 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 283 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
282 | * | 284 | * |
283 | */ | 285 | */ |
284 | bool UserDialog::delUser(const char *username) { | 286 | bool UserDialog::delUser(const char *username) { |
285 | if((accounts->findUser(username))) {// Does that user exist? | 287 | if((accounts->findUser(username))) {// Does that user exist? |
286 | if(!(accounts->delUser(username))) {// Delete the user. | 288 | if(!(accounts->delUser(username))) {// Delete the user. |
287 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); | 289 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); |
288 | } | 290 | } |
289 | } else { | 291 | } else { |
290 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); | 292 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); |
291 | return false; | 293 | return false; |
292 | } | 294 | } |
293 | return true; | 295 | return true; |
294 | } | 296 | } |
295 | 297 | ||
296 | /** | 298 | /** |
297 | * This displays a confirmation dialog wether a user should be deleted or not. | 299 | * This displays a confirmation dialog wether a user should be deleted or not. |
298 | * (And also deletes the account) | 300 | * (And also deletes the account) |
299 | * | 301 | * |
300 | * @param username User to be deleted. | 302 | * @param username User to be deleted. |
301 | * | 303 | * |
302 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 304 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
303 | * | 305 | * |
304 | */ | 306 | */ |
305 | bool UserDialog::editUser(const char *username) { | 307 | bool UserDialog::editUser(const char *username) { |
306 | int invalid_group=0; | 308 | int invalid_group=0; |
307 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. | 309 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. |
308 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog | 310 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog |
309 | edituserDialog->setCaption(tr("Edit User")); | 311 | edituserDialog->setCaption(tr("Edit User")); |
310 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. | 312 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. |
311 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. | 313 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. |
312 | invalid_group=1; | 314 | invalid_group=1; |
313 | } | 315 | } |
314 | // Fill widgets with userinfo. | 316 | // Fill widgets with userinfo. |
315 | edituserDialog->loginLineEdit->setText(accounts->pw_name); | 317 | edituserDialog->loginLineEdit->setText(accounts->pw_name); |
316 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); | 318 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); |
317 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); | 319 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); |
318 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. | 320 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. |
319 | edituserDialog->passwordLineEdit->setText("........"); | 321 | edituserDialog->passwordLineEdit->setText("........"); |
320 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. | 322 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. |
321 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { | 323 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { |
322 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); | 324 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); |
323 | edituserDialog->shellComboBox->setCurrentItem(0); | 325 | edituserDialog->shellComboBox->setCurrentItem(0); |
324 | } | 326 | } |
325 | // Select the primary group for this user. | 327 | // Select the primary group for this user. |
326 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { | 328 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { |
327 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { | 329 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { |
328 | edituserDialog->groupComboBox->setCurrentItem(i); | 330 | edituserDialog->groupComboBox->setCurrentItem(i); |
329 | break; | 331 | break; |
330 | } | 332 | } |
331 | } | 333 | } |
332 | if(invalid_group) { | 334 | if(invalid_group) { |
333 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
334 | edituserDialog->groupComboBox->setCurrentItem(0); | 336 | edituserDialog->groupComboBox->setCurrentItem(0); |
335 | } | 337 | } |
336 | 338 | ||
337 | // Select the groups in the listview, to which the user belongs. | 339 | // Select the groups in the listview, to which the user belongs. |
338 | QCheckListItem *temp; | 340 | QCheckListItem *temp; |
339 | // 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. | 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. |
340 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
341 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
342 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
343 | qWarning(*it); | 345 | qWarning(*it); |
344 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
345 | for ( ; lvit.current(); ++lvit ) { | 347 | for ( ; lvit.current(); ++lvit ) { |
346 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
347 | temp=(QCheckListItem*)lvit.current(); | 349 | temp=(QCheckListItem*)lvit.current(); |
348 | temp->setOn(true);// If we find a line with that groupname, select it.; | 350 | temp->setOn(true);// If we find a line with that groupname, select it.; |
349 | } | 351 | } |
350 | } | 352 | } |
351 | } | 353 | } |
352 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
353 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
354 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
355 | qWarning(*it); | 357 | qWarning(*it); |
356 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
357 | for ( ; lvit.current(); ++lvit ) { | 359 | for ( ; lvit.current(); ++lvit ) { |
358 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
359 | temp=(QCheckListItem*)lvit.current(); | 361 | temp=(QCheckListItem*)lvit.current(); |
360 | temp->setOn(true);// If we find a line with that groupname, select it.; | 362 | temp->setOn(true);// If we find a line with that groupname, select it.; |
361 | } | 363 | } |
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
365 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! | 367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! |
366 | 368 | ||
367 | accounts->findUser(username);// Fill user variables in 'acccounts' object. | 369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. |
368 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
369 | // Has the password been changed ? Make a new "crypt":ed password. | 371 | // Has the password been changed ? Make a new "crypt":ed password. |
370 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
371 | 373 | ||
372 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
373 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
374 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. |
375 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 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. |
376 | } | 378 | } |
377 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); | 379 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); |
378 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); | 380 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); |
379 | // Update userinfo, using the information stored in the user variables stored in the accounts object. | 381 | // Update userinfo, using the information stored in the user variables stored in the accounts object. |
380 | accounts->updateUser(username); | 382 | accounts->updateUser(username); |
381 | 383 | ||
382 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) | 384 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) |
383 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { | 385 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { |
384 | accounts->delGroupMember((*it).left((*it).find(":")),username); | 386 | accounts->delGroupMember((*it).left((*it).find(":")),username); |
385 | } | 387 | } |
386 | 388 | ||
387 | // Add User to additional groups that he/she is a member of. | 389 | // Add User to additional groups that he/she is a member of. |
388 | QListViewItemIterator it( edituserDialog->groupsListView ); | 390 | QListViewItemIterator it( edituserDialog->groupsListView ); |
389 | for ( ; it.current(); ++it ) { | 391 | for ( ; it.current(); ++it ) { |
390 | temp=(QCheckListItem*)it.current(); | 392 | temp=(QCheckListItem*)it.current(); |
391 | if ( temp->isOn() ) | 393 | if ( temp->isOn() ) |
392 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 394 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); |
393 | } | 395 | } |
394 | 396 | ||
395 | // Copy image to pics/users/ | 397 | // Copy image to pics/users/ |
396 | if(!(edituserDialog->userImage.isNull())) { | 398 | if(!(edituserDialog->userImage.isNull())) { |
397 | QDir d; | 399 | QDir d; |
398 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 400 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
399 | d.mkdir("/opt/QtPalmtop/pics/users"); | 401 | d.mkdir("/opt/QtPalmtop/pics/users"); |
400 | } | 402 | } |
401 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 403 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
402 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | 404 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); |
403 | edituserDialog->userImage.save(filename,"PNG"); | 405 | edituserDialog->userImage.save(filename,"PNG"); |
404 | } | 406 | } |
405 | return true; | 407 | return true; |
406 | } | 408 | } |
407 | 409 | ||
408 | /** | 410 | /** |
409 | * "OK" has been clicked. Verify some information before closing the dialog. | 411 | * "OK" has been clicked. Verify some information before closing the dialog. |
410 | * | 412 | * |
411 | */ | 413 | */ |
412 | void UserDialog::accept() { | 414 | void UserDialog::accept() { |
413 | // Add checking... valid username? username taken? | 415 | // Add checking... valid username? username taken? |
414 | if(loginLineEdit->text().isEmpty()) { | 416 | if(loginLineEdit->text().isEmpty()) { |
415 | QMessageBox::information(0,"Empty Login","Please enter a login."); | 417 | QMessageBox::information(0,"Empty Login","Please enter a login."); |
416 | return; | 418 | return; |
417 | } | 419 | } |
418 | QDialog::accept(); | 420 | QDialog::accept(); |
419 | } | 421 | } |
420 | 422 | ||
421 | /** | 423 | /** |
422 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. | 424 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. |
423 | * | 425 | * |
424 | */ | 426 | */ |
425 | void UserDialog::clickedPicture() { | 427 | void UserDialog::clickedPicture() { |
426 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); | 428 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); |
427 | if(!(filename.isEmpty())) { | 429 | if(!(filename.isEmpty())) { |
428 | userImage.reset(); | 430 | userImage.reset(); |
429 | if(!(userImage.load(filename))) { | 431 | if(!(userImage.load(filename))) { |
430 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 432 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
431 | } else { | 433 | } else { |
432 | // userImage=userImage.smoothScale(48,48); | 434 | // userImage=userImage.smoothScale(48,48); |
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 | |||
@@ -1,254 +1,258 @@ | |||
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> | 13 | #include <stdio.h> |
14 | 14 | ||
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | 18 | ||
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * The mainwindow constructor. | 22 | * The mainwindow constructor. |
23 | * | 23 | * |
24 | * @param QWidget *parent | 24 | * @param QWidget *parent |
25 | * @param const char *name | 25 | * @param const char *name |
26 | * @ param WFlags fl | 26 | * @ param WFlags fl |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 29 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
30 | setCaption(tr("OPIE User Manager")); | 30 | setCaption(tr("OPIE User Manager")); |
31 | 31 | ||
32 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 32 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
33 | accounts=new Passwd(); | 33 | accounts=new Passwd(); |
34 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 34 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
35 | 35 | ||
36 | // Create the toolbar. | 36 | // Create the toolbar. |
37 | QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); | 37 | QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); |
38 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 38 | 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"); | 39 | 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"); | 40 | 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"); | 41 | 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"); | 42 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); |
43 | userstext->setUsesTextLabel(true); | 43 | userstext->setUsesTextLabel(true); |
44 | toolbar->addSeparator(); | 44 | toolbar->addSeparator(); |
45 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 45 | 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"); | 46 | 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"); | 47 | 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"); | 48 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); |
49 | groupstext->setUsesTextLabel(true); | 49 | groupstext->setUsesTextLabel(true); |
50 | addToolBar(toolbar,"myToolBar"); | 50 | addToolBar(toolbar,"myToolBar"); |
51 | 51 | ||
52 | // Add a tabwidget and all the tabs. | 52 | // Add a tabwidget and all the tabs. |
53 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 53 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
54 | setupTabAccounts(); | 54 | setupTabAccounts(); |
55 | setupTabAllUsers(); | 55 | setupTabAllUsers(); |
56 | setupTabAllGroups(); | 56 | setupTabAllGroups(); |
57 | userPopupMenu.insertItem("Copy",0); | 57 | userPopupMenu.insertItem("Copy",0); |
58 | 58 | ||
59 | getUsers(); // Fill out the iconview & listview with all users. | 59 | getUsers(); // Fill out the iconview & listview with all users. |
60 | getGroups(); // Fill out the group listview with all groups. | 60 | getGroups(); // Fill out the group listview with all groups. |
61 | 61 | ||
62 | setCentralWidget(myTabWidget); | 62 | setCentralWidget(myTabWidget); |
63 | } | 63 | } |
64 | 64 | ||
65 | UserConfig::~UserConfig() { | 65 | UserConfig::~UserConfig() { |
66 | accounts->close(); | 66 | accounts->close(); |
67 | delete accounts; | 67 | delete accounts; |
68 | } | 68 | } |
69 | 69 | ||
70 | void UserConfig::setupTabAccounts() { | 70 | void UserConfig::setupTabAccounts() { |
71 | QWidget *tabpage = new QWidget(this); | 71 | QWidget *tabpage = new QWidget(this); |
72 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 72 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
73 | layout->setMargin(5); | 73 | layout->setMargin(5); |
74 | 74 | ||
75 | usersIconView=new QListView(tabpage,"users"); | 75 | usersIconView=new QListView(tabpage,"users"); |
76 | usersIconView->addColumn("Icon"); | 76 | usersIconView->addColumn("Icon"); |
77 | usersIconView->addColumn("Username"); | 77 | usersIconView->addColumn("Username"); |
78 | usersIconView->setAllColumnsShowFocus(true); | 78 | usersIconView->setAllColumnsShowFocus(true); |
79 | layout->addWidget(usersIconView); | 79 | layout->addWidget(usersIconView); |
80 | 80 | ||
81 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); | 81 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); |
82 | 82 | ||
83 | myTabWidget->addTab(tabpage,"Users"); | 83 | myTabWidget->addTab(tabpage,"Users"); |
84 | } | 84 | } |
85 | 85 | ||
86 | void UserConfig::setupTabAllUsers() { | 86 | void UserConfig::setupTabAllUsers() { |
87 | QWidget *tabpage = new QWidget(this); | 87 | QWidget *tabpage = new QWidget(this); |
88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
89 | layout->setMargin(5); | 89 | layout->setMargin(5); |
90 | 90 | ||
91 | usersListView=new QListView(tabpage,"allusers"); | 91 | usersListView=new QListView(tabpage,"allusers"); |
92 | usersListView->addColumn("UID"); | 92 | usersListView->addColumn("UID"); |
93 | usersListView->addColumn("Login"); | 93 | usersListView->addColumn("Login"); |
94 | usersListView->addColumn("Username"); | 94 | usersListView->addColumn("Username"); |
95 | layout->addWidget(usersListView); | 95 | layout->addWidget(usersListView); |
96 | usersListView->setSorting(1,1); | 96 | usersListView->setSorting(1,1); |
97 | usersListView->setAllColumnsShowFocus(true); | 97 | usersListView->setAllColumnsShowFocus(true); |
98 | 98 | ||
99 | myTabWidget->addTab(tabpage,"All Users"); | 99 | myTabWidget->addTab(tabpage,"All Users"); |
100 | } | 100 | } |
101 | 101 | ||
102 | void UserConfig::setupTabAllGroups() { | 102 | void UserConfig::setupTabAllGroups() { |
103 | QWidget *tabpage = new QWidget(this); | 103 | QWidget *tabpage = new QWidget(this); |
104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
105 | layout->setMargin(5); | 105 | layout->setMargin(5); |
106 | 106 | ||
107 | groupsListView=new QListView(tabpage,"groups"); | 107 | groupsListView=new QListView(tabpage,"groups"); |
108 | groupsListView->addColumn("GID"); | 108 | groupsListView->addColumn("GID"); |
109 | groupsListView->addColumn("Groupname"); | 109 | groupsListView->addColumn("Groupname"); |
110 | layout->addWidget(groupsListView); | 110 | layout->addWidget(groupsListView); |
111 | groupsListView->setSorting(1,1); | 111 | groupsListView->setSorting(1,1); |
112 | groupsListView->setAllColumnsShowFocus(true); | 112 | groupsListView->setAllColumnsShowFocus(true); |
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. |
155 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 157 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
156 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 158 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
157 | // If there were any changed also update the views. | 159 | // If there were any changed also update the views. |
158 | getUsers(); | 160 | getUsers(); |
159 | getGroups(); | 161 | getGroups(); |
160 | } | 162 | } |
161 | } else { | 163 | } else { |
162 | QMessageBox::information(this,"No selection.","No user has been selected."); | 164 | QMessageBox::information(this,"No selection.","No user has been selected."); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | if(myTabWidget->currentPageIndex()==1) {// All users | 167 | if(myTabWidget->currentPageIndex()==1) {// All users |
166 | if(usersListView->currentItem()) {// Anything changed!? | 168 | if(usersListView->currentItem()) {// Anything changed!? |
167 | username=usersListView->currentItem()->text(1);// Get the username. | 169 | username=usersListView->currentItem()->text(1);// Get the username. |
168 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 170 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
169 | // And again update the views if there were any changes. | 171 | // And again update the views if there were any changes. |
170 | getUsers(); | 172 | getUsers(); |
171 | getGroups(); | 173 | getGroups(); |
172 | } | 174 | } |
173 | } else { | 175 | } else { |
174 | QMessageBox::information(this,"No selection.","No user has been selected."); | 176 | QMessageBox::information(this,"No selection.","No user has been selected."); |
175 | } | 177 | } |
176 | } | 178 | } |
177 | } | 179 | } |
178 | 180 | ||
179 | void UserConfig::delUser() { | 181 | void UserConfig::delUser() { |
180 | QString username; | 182 | QString username; |
181 | 183 | ||
182 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 184 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
183 | if(usersIconView->currentItem()) {// Anything selected? | 185 | if(usersIconView->currentItem()) {// Anything selected? |
184 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. | 186 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
185 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 187 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
186 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 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(UserDialog::delUser(username)) {// Delete the user if possible. | 189 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
188 | // Update views. | 190 | // Update views. |
189 | getUsers(); | 191 | getUsers(); |
190 | getGroups(); | 192 | getGroups(); |
191 | } | 193 | } |
192 | } | 194 | } |
193 | } else { | 195 | } else { |
194 | QMessageBox::information(this,"No selection","No user has been selected."); | 196 | QMessageBox::information(this,"No selection","No user has been selected."); |
195 | } | 197 | } |
196 | } | 198 | } |
197 | if(myTabWidget->currentPageIndex()==1) {// All users | 199 | if(myTabWidget->currentPageIndex()==1) {// All users |
198 | if(usersListView->currentItem()) {// Anything changed!? | 200 | if(usersListView->currentItem()) {// Anything changed!? |
199 | username=usersListView->currentItem()->text(1);// Get the username. | 201 | username=usersListView->currentItem()->text(1);// Get the username. |
200 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 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(UserDialog::delUser(username)) {// Try to delete the user. | 203 | if(UserDialog::delUser(username)) {// Try to delete the user. |
202 | // Update views. | 204 | // Update views. |
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() { |
239 | const char *groupname; | 243 | const char *groupname; |
240 | if(groupsListView->currentItem()) {// Any group selected? | 244 | if(groupsListView->currentItem()) {// Any group selected? |
241 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. | 245 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. |
242 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { | 246 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { |
243 | // If confirmed, try to delete the group. | 247 | // If confirmed, try to delete the group. |
244 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. | 248 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. |
245 | } | 249 | } |
246 | } else { | 250 | } else { |
247 | QMessageBox::information(this,"No selection","No group has been selected."); | 251 | QMessageBox::information(this,"No selection","No group has been selected."); |
248 | } | 252 | } |
249 | } | 253 | } |
250 | 254 | ||
251 | void UserConfig::showUserMenu(QListViewItem *item) { | 255 | void UserConfig::showUserMenu(QListViewItem *item) { |
252 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); | 256 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); |
253 | qWarning("Pressed!"); | 257 | qWarning("Pressed!"); |
254 | } | 258 | } |