summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/main.cpp4
-rw-r--r--noncore/settings/usermanager/opie-usermanager.control2
-rw-r--r--noncore/settings/usermanager/userdialog.cpp60
-rw-r--r--noncore/settings/usermanager/userdialog.h70
-rw-r--r--noncore/settings/usermanager/usermanager.pro16
5 files changed, 76 insertions, 76 deletions
diff --git a/noncore/settings/usermanager/main.cpp b/noncore/settings/usermanager/main.cpp
index 515ea9a..d7147d1 100644
--- a/noncore/settings/usermanager/main.cpp
+++ b/noncore/settings/usermanager/main.cpp
@@ -1,14 +1,14 @@
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#include <qpe/qpeapplication.h> 11
12#include <opie/oapplicationfactory.h> 12#include <opie2/oapplicationfactory.h>
13 13
14OPIE_EXPORT_APP( OApplicationFactory<UserConfig> ) 14OPIE_EXPORT_APP( OApplicationFactory<UserConfig> )
diff --git a/noncore/settings/usermanager/opie-usermanager.control b/noncore/settings/usermanager/opie-usermanager.control
index 5061366..52930d2 100644
--- a/noncore/settings/usermanager/opie-usermanager.control
+++ b/noncore/settings/usermanager/opie-usermanager.control
@@ -1,10 +1,10 @@
1Package: opie-usermanager 1Package: opie-usermanager
2Files: plugins/application/libusermanager.so* bin/usermanager apps/Settings/usermanager.desktop pics/usermanager/* 2Files: plugins/application/libusermanager.so* bin/usermanager apps/Settings/usermanager.desktop pics/usermanager/*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Depends: task-opie-minimal 5Depends: task-opie-minimal, libopiecore2, libopieui2
6Architecture: arm 6Architecture: arm
7Maintainer: Ted Parnefors <zaurus@bredband.net> 7Maintainer: Ted Parnefors <zaurus@bredband.net>
8License: GPL 8License: GPL
9Description: User/Group manager for Opie. 9Description: User/Group manager for Opie.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 08de352..eb9a289 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -1,489 +1,489 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#include "userdialog.h" 10#include "userdialog.h"
11#include "passwd.h" 11#include "passwd.h"
12 12
13/* OPIE */ 13/* OPIE */
14#include <opie/odevice.h> 14#include <opie2/odevice.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16 16
17/* QT */ 17/* QT */
18#include <qlayout.h> 18#include <qlayout.h>
19#include <qlabel.h> 19#include <qlabel.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qfile.h> 21#include <qfile.h>
22 22
23/* STD */ 23/* STD */
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/wait.h> 25#include <sys/wait.h>
26#include <unistd.h> 26#include <unistd.h>
27#include <signal.h> 27#include <signal.h>
28 28
29 29
30using namespace Opie; 30using namespace Opie;
31 31
32 32
33/** 33/**
34 * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. 34 * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups.
35 * 35 *
36 */ 36 */
37UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) 37UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl)
38{ 38{
39 vm=viewmode; 39 vm=viewmode;
40 QVBoxLayout *layout = new QVBoxLayout(this); 40 QVBoxLayout *layout = new QVBoxLayout(this);
41 myTabWidget=new QTabWidget(this,"User Tab Widget"); 41 myTabWidget=new QTabWidget(this,"User Tab Widget");
42 layout->addWidget(myTabWidget); 42 layout->addWidget(myTabWidget);
43 setupTab1(); 43 setupTab1();
44 setupTab2(); 44 setupTab2();
45 45
46 accounts->groupStringList.sort(); 46 accounts->groupStringList.sort();
47 // And also fill the listview & the combobox with all available groups. 47 // And also fill the listview & the combobox with all available groups.
48 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) 48 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it)
49 { 49 {
50 accounts->splitGroupEntry(*it); 50 accounts->splitGroupEntry(*it);
51 if(accounts->gr_name.find(QRegExp("^#"),0)) 51 if(accounts->gr_name.find(QRegExp("^#"),0))
52 {// Skip commented lines. 52 { // Skip commented lines.
53 new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); 53 new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox);
54 groupComboBox->insertItem(accounts->gr_name); 54 groupComboBox->insertItem(accounts->gr_name);
55 } 55 }
56 } 56 }
57 QPEApplication::showDialog( this ); 57 QPEApplication::showDialog( this );
58} 58}
59 59
60/** 60/**
61 * Empty destructor. 61 * Empty destructor.
62 * 62 *
63 */ 63 */
64UserDialog::~UserDialog() 64UserDialog::~UserDialog()
65{} 65{}
66 66
67/** 67/**
68 * Creates the first tab, all userinfo is here. 68 * Creates the first tab, all userinfo is here.
69 * 69 *
70 */ 70 */
71void UserDialog::setupTab1() 71void UserDialog::setupTab1()
72{ 72{
73 QPixmap mypixmap; 73 QPixmap mypixmap;
74 QWidget *tabpage = new QWidget(myTabWidget,"page1"); 74 QWidget *tabpage = new QWidget(myTabWidget,"page1");
75 QVBoxLayout *layout = new QVBoxLayout(tabpage); 75 QVBoxLayout *layout = new QVBoxLayout(tabpage);
76 layout->setMargin(5); 76 layout->setMargin(5);
77 77
78 // Picture 78 // Picture
79 picturePushButton = new QPushButton(tabpage,"Label"); 79 picturePushButton = new QPushButton(tabpage,"Label");
80 picturePushButton->setMinimumSize(48,48); 80 picturePushButton->setMinimumSize(48,48);
81 picturePushButton->setMaximumSize(48,48); 81 picturePushButton->setMaximumSize(48,48);
82 picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. 82 picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon.
83 connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. 83 connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector.
84 84
85 // Login 85 // Login
86 QLabel *loginLabel=new QLabel(tabpage,"Login: "); 86 QLabel *loginLabel=new QLabel(tabpage,"Login: ");
87 loginLabel->setText("Login: "); 87 loginLabel->setText("Login: ");
88 loginLineEdit=new QLineEdit(tabpage,"Login: "); 88 loginLineEdit=new QLineEdit(tabpage,"Login: ");
89 89
90 // UID 90 // UID
91 QLabel *uidLabel=new QLabel(tabpage,"uid: "); 91 QLabel *uidLabel=new QLabel(tabpage,"uid: ");
92 uidLabel->setText("UserID: "); 92 uidLabel->setText("UserID: ");
93 uidLineEdit=new QLineEdit(tabpage,"uid: "); 93 uidLineEdit=new QLineEdit(tabpage,"uid: ");
94 uidLineEdit->setEnabled(false); 94 uidLineEdit->setEnabled(false);
95 95
96 // Username (gecos) 96 // Username (gecos)
97 QLabel *gecosLabel=new QLabel(tabpage,"gecos"); 97 QLabel *gecosLabel=new QLabel(tabpage,"gecos");
98 gecosLabel->setText("Username: "); 98 gecosLabel->setText("Username: ");
99 gecosLineEdit=new QLineEdit(tabpage,"gecos"); 99 gecosLineEdit=new QLineEdit(tabpage,"gecos");
100 100
101 // Password 101 // Password
102 QLabel *passwordLabel=new QLabel(tabpage,"password"); 102 QLabel *passwordLabel=new QLabel(tabpage,"password");
103 passwordLabel->setText("Password: "); 103 passwordLabel->setText("Password: ");
104 passwordLineEdit=new QLineEdit(tabpage,"password"); 104 passwordLineEdit=new QLineEdit(tabpage,"password");
105 passwordLineEdit->setEchoMode(QLineEdit::Password); 105 passwordLineEdit->setEchoMode(QLineEdit::Password);
106 106
107 // Shell 107 // Shell
108 QLabel *shellLabel=new QLabel(tabpage,"shell"); 108 QLabel *shellLabel=new QLabel(tabpage,"shell");
109 shellLabel->setText("Shell: "); 109 shellLabel->setText("Shell: ");
110 shellComboBox=new QComboBox(tabpage,"shell"); 110 shellComboBox=new QComboBox(tabpage,"shell");
111 shellComboBox->setEditable(true); 111 shellComboBox->setEditable(true);
112 shellComboBox->insertItem("/bin/sh"); 112 shellComboBox->insertItem("/bin/sh");
113 shellComboBox->insertItem("/bin/ash"); 113 shellComboBox->insertItem("/bin/ash");
114 shellComboBox->insertItem("/bin/false"); 114 shellComboBox->insertItem("/bin/false");
115 115
116 // Primary Group 116 // Primary Group
117 QLabel *groupLabel=new QLabel(tabpage,"group"); 117 QLabel *groupLabel=new QLabel(tabpage,"group");
118 groupLabel->setText("Primary group: "); 118 groupLabel->setText("Primary group: ");
119 groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); 119 groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
120 120
121 if(vm==VIEWMODE_NEW) 121 if(vm==VIEWMODE_NEW)
122 { 122 {
123 // Copy /etc/skel 123 // Copy /etc/skel
124 skelLabel=new QLabel(tabpage,"skel"); 124 skelLabel=new QLabel(tabpage,"skel");
125 skelLabel->setText("Copy /etc/skel: "); 125 skelLabel->setText("Copy /etc/skel: ");
126 skelCheckBox=new QCheckBox(tabpage); 126 skelCheckBox=new QCheckBox(tabpage);
127 skelCheckBox->setChecked(true); 127 skelCheckBox->setChecked(true);
128 } 128 }
129 129
130 // Widget layout 130 // Widget layout
131 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); 131 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout");
132 layout->addWidget(picturePushButton); 132 layout->addWidget(picturePushButton);
133 layout->addSpacing(5); 133 layout->addSpacing(5);
134 layout->addLayout(hlayout); 134 layout->addLayout(hlayout);
135 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); 135 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1");
136 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); 136 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2");
137 // First column, labels 137 // First column, labels
138 vlayout1->addWidget(loginLabel); 138 vlayout1->addWidget(loginLabel);
139 vlayout1->addSpacing(5); 139 vlayout1->addSpacing(5);
140 vlayout1->addWidget(uidLabel); 140 vlayout1->addWidget(uidLabel);
141 vlayout1->addSpacing(5); 141 vlayout1->addSpacing(5);
142 vlayout1->addWidget(gecosLabel); 142 vlayout1->addWidget(gecosLabel);
143 vlayout1->addSpacing(5); 143 vlayout1->addSpacing(5);
144 vlayout1->addWidget(passwordLabel); 144 vlayout1->addWidget(passwordLabel);
145 vlayout1->addSpacing(5); 145 vlayout1->addSpacing(5);
146 vlayout1->addWidget(shellLabel); 146 vlayout1->addWidget(shellLabel);
147 vlayout1->addSpacing(5); 147 vlayout1->addSpacing(5);
148 vlayout1->addWidget(groupLabel); 148 vlayout1->addWidget(groupLabel);
149 if(vm==VIEWMODE_NEW) 149 if(vm==VIEWMODE_NEW)
150 { 150 {
151 vlayout1->addSpacing(5); 151 vlayout1->addSpacing(5);
152 vlayout1->addWidget(skelLabel); 152 vlayout1->addWidget(skelLabel);
153 } 153 }
154 // Second column, data 154 // Second column, data
155 vlayout2->addWidget(loginLineEdit); 155 vlayout2->addWidget(loginLineEdit);
156 vlayout2->addSpacing(5); 156 vlayout2->addSpacing(5);
157 vlayout2->addWidget(uidLineEdit); 157 vlayout2->addWidget(uidLineEdit);
158 vlayout2->addSpacing(5); 158 vlayout2->addSpacing(5);
159 vlayout2->addWidget(gecosLineEdit); 159 vlayout2->addWidget(gecosLineEdit);
160 vlayout2->addSpacing(5); 160 vlayout2->addSpacing(5);
161 vlayout2->addWidget(passwordLineEdit); 161 vlayout2->addWidget(passwordLineEdit);
162 vlayout2->addSpacing(5); 162 vlayout2->addSpacing(5);
163 vlayout2->addWidget(shellComboBox); 163 vlayout2->addWidget(shellComboBox);
164 vlayout2->addSpacing(5); 164 vlayout2->addSpacing(5);
165 vlayout2->addWidget(groupComboBox); 165 vlayout2->addWidget(groupComboBox);
166 if(vm==VIEWMODE_NEW) 166 if(vm==VIEWMODE_NEW)
167 { 167 {
168 vlayout2->addSpacing(5); 168 vlayout2->addSpacing(5);
169 vlayout2->addWidget(skelCheckBox); 169 vlayout2->addWidget(skelCheckBox);
170 } 170 }
171 hlayout->addLayout(vlayout1); 171 hlayout->addLayout(vlayout1);
172 hlayout->addLayout(vlayout2); 172 hlayout->addLayout(vlayout2);
173 173
174 myTabWidget->addTab(tabpage,"User Info"); 174 myTabWidget->addTab(tabpage,"User Info");
175} 175}
176 176
177/** 177/**
178 * Creates the second tab containing additional groups for the user. 178 * Creates the second tab containing additional groups for the user.
179 * 179 *
180 */ 180 */
181void UserDialog::setupTab2() 181void UserDialog::setupTab2()
182{ 182{
183 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 183 QWidget *tabpage = new QWidget(myTabWidget,"page2");
184 QVBoxLayout *layout = new QVBoxLayout(tabpage); 184 QVBoxLayout *layout = new QVBoxLayout(tabpage);
185 layout->setMargin(5); 185 layout->setMargin(5);
186 186
187 // Additional groups 187 // Additional groups
188 groupsListView=new QListView(tabpage,"groups"); 188 groupsListView=new QListView(tabpage,"groups");
189 groupsListView->addColumn("Additional groups"); 189 groupsListView->addColumn("Additional groups");
190 groupsListView->setColumnWidthMode(0,QListView::Maximum); 190 groupsListView->setColumnWidthMode(0,QListView::Maximum);
191 groupsListView->setMultiSelection(false); 191 groupsListView->setMultiSelection(false);
192 groupsListView->setAllColumnsShowFocus(false); 192 groupsListView->setAllColumnsShowFocus(false);
193 193
194 layout->addSpacing(5); 194 layout->addSpacing(5);
195 // Grouplist 195 // Grouplist
196 layout->addWidget(groupsListView); 196 layout->addWidget(groupsListView);
197 197
198 myTabWidget->addTab(tabpage,"User Groups"); 198 myTabWidget->addTab(tabpage,"User Groups");
199} 199}
200 200
201/** 201/**
202 * Static function that creates the userinfo dialog. 202 * Static function that creates the userinfo dialog.
203 * The user will be prompted to add a user. 203 * The user will be prompted to add a user.
204 * 204 *
205 * @param uid This is a suggested available UID. 205 * @param uid This is a suggested available UID.
206 * @param gid This is a suggested available GID. 206 * @param gid This is a suggested available GID.
207 * 207 *
208 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. 208 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
209 * 209 *
210 */ 210 */
211bool UserDialog::addUser(int uid, int gid) 211bool UserDialog::addUser(int uid, int gid)
212{ 212{
213 QCheckListItem *temp; 213 QCheckListItem *temp;
214 QFile ozTest; 214 QFile ozTest;
215 int oz=false; 215 int oz=false;
216 if(ODevice::inst()->system()==System_OpenZaurus) oz=true; 216 if(ODevice::inst()->system()==System_OpenZaurus) oz=true;
217 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. 217 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here.
218 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); 218 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW);
219 adduserDialog->setCaption(tr("Add User")); 219 adduserDialog->setCaption(tr("Add User"));
220 adduserDialog->userID=uid;// Set next available UID as default uid. 220 adduserDialog->userID=uid; // Set next available UID as default uid.
221 adduserDialog->groupID=gid;// Set next available GID as default gid. 221 adduserDialog->groupID=gid; // Set next available GID as default gid.
222 // Insert default group into groupComboBox 222 // Insert default group into groupComboBox
223 adduserDialog->groupComboBox->insertItem("<create new group>",0); 223 adduserDialog->groupComboBox->insertItem("<create new group>",0);
224 adduserDialog->uidLineEdit->setText(QString::number(uid)); 224 adduserDialog->uidLineEdit->setText(QString::number(uid));
225 // If we're running on OZ, add new users to some default groups. 225 // If we're running on OZ, add new users to some default groups.
226 if(oz) 226 if(oz)
227 { 227 {
228 QListViewItemIterator iter( adduserDialog->groupsListView ); 228 QListViewItemIterator iter( adduserDialog->groupsListView );
229 for ( ; iter.current(); ++iter ) 229 for ( ; iter.current(); ++iter )
230 { 230 {
231 temp=(QCheckListItem*)iter.current(); 231 temp=(QCheckListItem*)iter.current();
232 if (temp->text()=="video") temp->setOn(true); 232 if (temp->text()=="video") temp->setOn(true);
233 if (temp->text()=="audio") temp->setOn(true); 233 if (temp->text()=="audio") temp->setOn(true);
234 if (temp->text()=="time") temp->setOn(true); 234 if (temp->text()=="time") temp->setOn(true);
235 if (temp->text()=="power") temp->setOn(true); 235 if (temp->text()=="power") temp->setOn(true);
236 if (temp->text()=="input") temp->setOn(true); 236 if (temp->text()=="input") temp->setOn(true);
237 if (temp->text()=="sharp") temp->setOn(true); 237 if (temp->text()=="sharp") temp->setOn(true);
238 if (temp->text()=="tty") temp->setOn(true); 238 if (temp->text()=="tty") temp->setOn(true);
239 } 239 }
240 } 240 }
241 // Show the dialog! 241 // Show the dialog!
242 if(!(adduserDialog->exec())) return false; 242 if(!(adduserDialog->exec())) return false;
243 if((adduserDialog->groupComboBox->currentItem()!=0)) 243 if((adduserDialog->groupComboBox->currentItem()!=0))
244 { 244 {
245 accounts->findGroup(adduserDialog->groupComboBox->currentText()); 245 accounts->findGroup(adduserDialog->groupComboBox->currentText());
246 adduserDialog->groupID=accounts->gr_gid; 246 adduserDialog->groupID=accounts->gr_gid;
247 qWarning(QString::number(accounts->gr_gid)); 247 qWarning(QString::number(accounts->gr_gid));
248 } 248 }
249 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), 249 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
250 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), 250 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
251 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) 251 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText())))
252 { 252 {
253 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); 253 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
254 return false; 254 return false;
255 } 255 }
256 256
257 // Add User to additional groups. 257 // Add User to additional groups.
258 QListViewItemIterator it( adduserDialog->groupsListView ); 258 QListViewItemIterator it( adduserDialog->groupsListView );
259 for ( ; it.current(); ++it ) 259 for ( ; it.current(); ++it )
260 { 260 {
261 temp=(QCheckListItem*)it.current(); 261 temp=(QCheckListItem*)it.current();
262 if (temp->isOn() ) 262 if (temp->isOn() )
263 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); 263 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
264 } 264 }
265 // Copy image to pics/users/ 265 // Copy image to pics/users/
266 if(!(adduserDialog->userImage.isNull())) 266 if(!(adduserDialog->userImage.isNull()))
267 { 267 {
268 QDir d; 268 QDir d;
269 if(!(d.exists("/opt/QtPalmtop/pics/users"))) 269 if(!(d.exists("/opt/QtPalmtop/pics/users")))
270 { 270 {
271 d.mkdir("/opt/QtPalmtop/pics/users"); 271 d.mkdir("/opt/QtPalmtop/pics/users");
272 } 272 }
273 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; 273 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
274 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); 274 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
275 adduserDialog->userImage.save(filename,"PNG"); 275 adduserDialog->userImage.save(filename,"PNG");
276 } 276 }
277 277
278 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? 278 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory?
279 accounts->findUser(adduserDialog->loginLineEdit->text()); 279 accounts->findUser(adduserDialog->loginLineEdit->text());
280 if(adduserDialog->skelCheckBox->isChecked()) 280 if(adduserDialog->skelCheckBox->isChecked())
281 { 281 {
282 QString command_cp; 282 QString command_cp;
283 QString command_chown; 283 QString command_chown;
284 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); 284 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1());
285 system(command_cp); 285 system(command_cp);
286 286
287 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? 287 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround?
288 system(command_cp); 288 system(command_cp);
289 289
290 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); 290 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1());
291 system(command_chown); 291 system(command_chown);
292 } 292 }
293 293
294 return true; 294 return true;
295} 295}
296 296
297/** 297/**
298 * Deletes the user account. 298 * Deletes the user account.
299 * 299 *
300 * @param username User to be deleted. 300 * @param username User to be deleted.
301 * 301 *
302 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 302 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
303 * 303 *
304 */ 304 */
305bool UserDialog::delUser(const char *username) 305bool UserDialog::delUser(const char *username)
306{ 306{
307 if((accounts->findUser(username))) 307 if((accounts->findUser(username)))
308 {// Does that user exist? 308 { // Does that user exist?
309 if(!(accounts->delUser(username))) 309 if(!(accounts->delUser(username)))
310 {// Delete the user. 310 { // Delete the user.
311 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); 311 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
312 } 312 }
313 } 313 }
314 else 314 else
315 { 315 {
316 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); 316 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
317 return false; 317 return false;
318 } 318 }
319 return true; 319 return true;
320} 320}
321 321
322/** 322/**
323 * This displays a confirmation dialog wether a user should be deleted or not. 323 * This displays a confirmation dialog wether a user should be deleted or not.
324 * (And also deletes the account) 324 * (And also deletes the account)
325 * 325 *
326 * @param username User to be deleted. 326 * @param username User to be deleted.
327 * 327 *
328 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 328 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
329 * 329 *
330 */ 330 */
331bool UserDialog::editUser(const char *username) 331bool UserDialog::editUser(const char *username)
332{ 332{
333 int invalid_group=0; 333 int invalid_group=0;
334 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. 334 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here.
335 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog 335 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog
336 edituserDialog->setCaption(tr("Edit User")); 336 edituserDialog->setCaption(tr("Edit User"));
337 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. 337 accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object.
338 if(!(accounts->findGroup(accounts->pw_gid))) 338 if(!(accounts->findGroup(accounts->pw_gid)))
339 {// Locate the user's primary group, and fill group variables in 'accounts' object. 339 { // Locate the user's primary group, and fill group variables in 'accounts' object.
340 invalid_group=1; 340 invalid_group=1;
341 } 341 }
342 // Fill widgets with userinfo. 342 // Fill widgets with userinfo.
343 edituserDialog->loginLineEdit->setText(accounts->pw_name); 343 edituserDialog->loginLineEdit->setText(accounts->pw_name);
344 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 344 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
345 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 345 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
346 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 346 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
347 edituserDialog->passwordLineEdit->setText("........"); 347 edituserDialog->passwordLineEdit->setText("........");
348 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. 348 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox.
349 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") 349 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false")
350 { 350 {
351 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); 351 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0);
352 edituserDialog->shellComboBox->setCurrentItem(0); 352 edituserDialog->shellComboBox->setCurrentItem(0);
353 } 353 }
354 // Select the primary group for this user. 354 // Select the primary group for this user.
355 for(int i=0;i<edituserDialog->groupComboBox->count();++i) 355 for(int i=0;i<edituserDialog->groupComboBox->count();++i)
356 { 356 {
357 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) 357 if(accounts->gr_name==edituserDialog->groupComboBox->text(i))
358 { 358 {
359 edituserDialog->groupComboBox->setCurrentItem(i); 359 edituserDialog->groupComboBox->setCurrentItem(i);
360 break; 360 break;
361 } 361 }
362 } 362 }
363 if(invalid_group) 363 if(invalid_group)
364 { 364 {
365 edituserDialog->groupComboBox->insertItem("<Undefined group>",0); 365 edituserDialog->groupComboBox->insertItem("<Undefined group>",0);
366 edituserDialog->groupComboBox->setCurrentItem(0); 366 edituserDialog->groupComboBox->setCurrentItem(0);
367 } 367 }
368 368
369 // Select the groups in the listview, to which the user belongs. 369 // Select the groups in the listview, to which the user belongs.
370 QCheckListItem *temp; 370 QCheckListItem *temp;
371 // 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. 371 // 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.
372 QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. 372 QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant.
373 QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. 373 QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of.
374 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 374 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
375 {// Iterate over all of them. 375 { // Iterate over all of them.
376 qWarning(*it); 376 qWarning(*it);
377 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. 377 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups.
378 for ( ; lvit.current(); ++lvit ) 378 for ( ; lvit.current(); ++lvit )
379 { 379 {
380 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) 380 if(lvit.current()->text(0)==(*it).left((*it).find(":")))
381 { 381 {
382 temp=(QCheckListItem*)lvit.current(); 382 temp=(QCheckListItem*)lvit.current();
383 temp->setOn(true);// If we find a line with that groupname, select it.; 383 temp->setOn(true); // If we find a line with that groupname, select it.;
384 } 384 }
385 } 385 }
386 } 386 }
387 userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) 387 userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.)
388 tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. 388 tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of.
389 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 389 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
390 {// Iterate over all of them. 390 { // Iterate over all of them.
391 qWarning(*it); 391 qWarning(*it);
392 QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. 392 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups.
393 for ( ; lvit.current(); ++lvit ) 393 for ( ; lvit.current(); ++lvit )
394 { 394 {
395 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) 395 if(lvit.current()->text(0)==(*it).left((*it).find(":")))
396 { 396 {
397 temp=(QCheckListItem*)lvit.current(); 397 temp=(QCheckListItem*)lvit.current();
398 temp->setOn(true);// If we find a line with that groupname, select it.; 398 temp->setOn(true); // If we find a line with that groupname, select it.;
399 } 399 }
400 } 400 }
401 } 401 }
402 402
403 if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! 403 if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG!
404 404
405 accounts->findUser(username);// Fill user variables in 'acccounts' object. 405 accounts->findUser(username); // Fill user variables in 'acccounts' object.
406 accounts->pw_name=edituserDialog->loginLineEdit->text(); 406 accounts->pw_name=edituserDialog->loginLineEdit->text();
407 // Has the password been changed ? Make a new "crypt":ed password. 407 // Has the password been changed ? Make a new "crypt":ed password.
408 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); 408 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt());
409 409
410 // Set all variables in accounts object, that will be used when calling 'updateUser()' 410 // Set all variables in accounts object, that will be used when calling 'updateUser()'
411 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); 411 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt();
412 if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) 412 if(accounts->findGroup(edituserDialog->groupComboBox->currentText()))
413 {// Fill all group variables in 'accounts' object. 413 { // Fill all group variables in 'accounts' object.
414 accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. 414 accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group.
415 } 415 }
416 accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); 416 accounts->pw_gecos=edituserDialog->gecosLineEdit->text();
417 accounts->pw_shell=edituserDialog->shellComboBox->currentText(); 417 accounts->pw_shell=edituserDialog->shellComboBox->currentText();
418 // Update userinfo, using the information stored in the user variables stored in the accounts object. 418 // Update userinfo, using the information stored in the user variables stored in the accounts object.
419 accounts->updateUser(username); 419 accounts->updateUser(username);
420 420
421 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) 421 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
422 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 422 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
423 { 423 {
424 accounts->delGroupMember((*it).left((*it).find(":")),username); 424 accounts->delGroupMember((*it).left((*it).find(":")),username);
425 } 425 }
426 426
427 // Add User to additional groups that he/she is a member of. 427 // Add User to additional groups that he/she is a member of.
428 QListViewItemIterator it( edituserDialog->groupsListView ); 428 QListViewItemIterator it( edituserDialog->groupsListView );
429 for ( ; it.current(); ++it ) 429 for ( ; it.current(); ++it )
430 { 430 {
431 temp=(QCheckListItem*)it.current(); 431 temp=(QCheckListItem*)it.current();
432 if ( temp->isOn() ) 432 if ( temp->isOn() )
433 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); 433 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text());
434 } 434 }
435 435
436 // Copy image to pics/users/ 436 // Copy image to pics/users/
437 if(!(edituserDialog->userImage.isNull())) 437 if(!(edituserDialog->userImage.isNull()))
438 { 438 {
439 QDir d; 439 QDir d;
440 if(!(d.exists("/opt/QtPalmtop/pics/users"))) 440 if(!(d.exists("/opt/QtPalmtop/pics/users")))
441 { 441 {
442 d.mkdir("/opt/QtPalmtop/pics/users"); 442 d.mkdir("/opt/QtPalmtop/pics/users");
443 } 443 }
444 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; 444 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
445 // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); 445 // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48);
446 edituserDialog->userImage.save(filename,"PNG"); 446 edituserDialog->userImage.save(filename,"PNG");
447 } 447 }
448 return true; 448 return true;
449} 449}
450 450
451/** 451/**
452 * "OK" has been clicked. Verify some information before closing the dialog. 452 * "OK" has been clicked. Verify some information before closing the dialog.
453 * 453 *
454 */ 454 */
455void UserDialog::accept() 455void UserDialog::accept()
456{ 456{
457 // Add checking... valid username? username taken? 457 // Add checking... valid username? username taken?
458 if(loginLineEdit->text().isEmpty()) 458 if(loginLineEdit->text().isEmpty())
459 { 459 {
460 QMessageBox::information(0,"Empty Login","Please enter a login."); 460 QMessageBox::information(0,"Empty Login","Please enter a login.");
461 return; 461 return;
462 } 462 }
463 QDialog::accept(); 463 QDialog::accept();
464} 464}
465 465
466/** 466/**
467 * This slot is called when the usericon is clicked, this loads (should) the iconselector. 467 * This slot is called when the usericon is clicked, this loads (should) the iconselector.
468 * 468 *
469 */ 469 */
470void UserDialog::clickedPicture() 470void UserDialog::clickedPicture()
471{ 471{
472 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); 472 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null);
473 if(!(filename.isEmpty())) 473 if(!(filename.isEmpty()))
474 { 474 {
475 userImage.reset(); 475 userImage.reset();
476 if(!(userImage.load(filename))) 476 if(!(userImage.load(filename)))
477 { 477 {
478 QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); 478 QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename);
479 } 479 }
480 else 480 else
481 { 481 {
482 // userImage=userImage.smoothScale(48,48); 482 // userImage=userImage.smoothScale(48,48);
483 QPixmap *picture; 483 QPixmap *picture;
484 picture=(QPixmap *)picturePushButton->pixmap(); 484 picture=(QPixmap *)picturePushButton->pixmap();
485 picture->convertFromImage(userImage,0); 485 picture->convertFromImage(userImage,0);
486 picturePushButton->update(); 486 picturePushButton->update();
487 } 487 }
488 } 488 }
489} 489}
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index 3272afc..a94e49b 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -1,67 +1,67 @@
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#ifndef USERDIALOG_H 9#ifndef USERDIALOG_H
10#define USERDIALOG_H 10#define USERDIALOG_H
11 11
12#include <qdialog.h> 12#include <qdialog.h>
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qtabwidget.h> 16#include <qtabwidget.h>
17#include <qpushbutton.h> 17#include <qpushbutton.h>
18#include <qcheckbox.h> 18#include <qcheckbox.h>
19#include <qlabel.h> 19#include <qlabel.h>
20 20
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22 22
23#include <opie/ofiledialog.h> 23#include <opie2/ofiledialog.h>
24 24
25class UserDialog : public QDialog 25class UserDialog : public QDialog
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28private: 28private:
29 QTabWidget *myTabWidget; 29 QTabWidget *myTabWidget;
30 QPushButton *picturePushButton; 30 QPushButton *picturePushButton;
31 QLineEdit *loginLineEdit; 31 QLineEdit *loginLineEdit;
32 QLineEdit *uidLineEdit; 32 QLineEdit *uidLineEdit;
33 QLineEdit *gecosLineEdit; 33 QLineEdit *gecosLineEdit;
34 QLineEdit *passwordLineEdit; 34 QLineEdit *passwordLineEdit;
35 QComboBox *shellComboBox; 35 QComboBox *shellComboBox;
36 QComboBox *groupComboBox; 36 QComboBox *groupComboBox;
37 QLabel *skelLabel; 37 QLabel *skelLabel;
38 QCheckBox *skelCheckBox; 38 QCheckBox *skelCheckBox;
39 QListView *groupsListView; 39 QListView *groupsListView;
40 40
41 QStringList groupMembers; 41 QStringList groupMembers;
42 QString pictureLocation; 42 QString pictureLocation;
43 QImage userImage; 43 QImage userImage;
44 int groupID; 44 int groupID;
45 int userID; 45 int userID;
46 int vm; 46 int vm;
47 enum VIEWMODE { 47 enum VIEWMODE {
48 VIEWMODE_NEW, 48 VIEWMODE_NEW,
49 VIEWMODE_EDIT 49 VIEWMODE_EDIT
50 }; 50 };
51 51
52 void setupTab1(void); 52 void setupTab1(void);
53 void setupTab2(void); 53 void setupTab2(void);
54 void accept(void); 54 void accept(void);
55 55
56private slots: 56private slots:
57 void clickedPicture(void); 57 void clickedPicture(void);
58 58
59public: 59public:
60 UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); 60 UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 );
61 ~UserDialog(); 61 ~UserDialog();
62 static bool addUser(int uid, int gid); 62 static bool addUser(int uid, int gid);
63 static bool editUser(const char *username); 63 static bool editUser(const char *username);
64 static bool delUser(const char *username); 64 static bool delUser(const char *username);
65}; 65};
66 66
67#endif 67#endif
diff --git a/noncore/settings/usermanager/usermanager.pro b/noncore/settings/usermanager/usermanager.pro
index 0b2f056..f20c9c3 100644
--- a/noncore/settings/usermanager/usermanager.pro
+++ b/noncore/settings/usermanager/usermanager.pro
@@ -1,10 +1,10 @@
1 #CONFIG = qt warn_on debug 1#CONFIG = qt warn_on debug
2 CONFIG = qt warn_on release quick-app 2CONFIG = qt warn_on release quick-app
3 HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h 3HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h
4 SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.cpp main.cpp 4SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.cpp main.cpp
5 INCLUDEPATH+= $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6 DEPENDPATH+= $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lqpe -lopie -lcrypt 7LIBS += -lqpe -lopiecore2 -lopieui2 -lcrypt
8 TARGET = usermanager 8TARGET = usermanager
9 9
10include ( $(OPIEDIR)/include.pro ) 10include ( $(OPIEDIR)/include.pro )