summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/usermanager/passwd.cpp23
-rw-r--r--noncore/settings/usermanager/userdialog.cpp19
-rw-r--r--noncore/settings/usermanager/userdialog.h7
3 files changed, 42 insertions, 7 deletions
diff --git a/noncore/settings/usermanager/passwd.cpp b/noncore/settings/usermanager/passwd.cpp
index 5063661..0a2bfba 100644
--- a/noncore/settings/usermanager/passwd.cpp
+++ b/noncore/settings/usermanager/passwd.cpp
@@ -52,4 +52,5 @@ char *Passwd::crypt_make_salt() {
}
+// opens the files /etc/passwd & /etc/group and loads the contents into passwdStringList & groupStringList
bool Passwd::open() {
int returnvalue=false;
@@ -77,4 +78,5 @@ bool Passwd::open() {
}
+// Writes back the contents of passwdStringList to /etc/passwd & groupStringList to /etc/group
bool Passwd::close() {
int returnvalue=false;
@@ -99,4 +101,5 @@ bool Passwd::close() {
}
+// Splits a "passwd" line into the components and stores them in the pw_* variables.
void Passwd::splitPasswdEntry(QString &userString) {
userdataStringList=QStringList::split(":",userString,true);
@@ -111,4 +114,5 @@ void Passwd::splitPasswdEntry(QString &userString) {
}
+// Splits a "group" line into the components and stores them in the gr_* variables.
void Passwd::splitGroupEntry(QString &groupString) {
groupdataStringList=QStringList::split(":",groupString,true);
@@ -120,4 +124,5 @@ void Passwd::splitGroupEntry(QString &groupString) {
}
+// Find a user in the passwdStringList. Return true if found and also fill the pw_* variables.
bool Passwd::searchUser(QRegExp &userRegExp) {
QStringList tempStringList(passwdStringList.grep(userRegExp));
@@ -131,4 +136,5 @@ bool Passwd::searchUser(QRegExp &userRegExp) {
}
+// Find a user by login.
bool Passwd::findUser(const char *username) {
QRegExp userRegExp(QString("^%1\\:").arg(username));
@@ -136,4 +142,5 @@ bool Passwd::findUser(const char *username) {
}
+// Find a user by uid.
bool Passwd::findUser(int uid) {
QRegExp userRegExp(QString(":%1\\:").arg(uid));
@@ -141,4 +148,5 @@ bool Passwd::findUser(int uid) {
}
+// Add a user to the passwdStringList, create home directory, and optionally create a group for the user.
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) {
QString tempString;
@@ -157,4 +165,5 @@ bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid,
}
+// Update info for a user in passwdStringList, take info from the pw_* fields.
bool Passwd::updateUser(QString login) {
QRegExp userRegExp(QString("^%1\\:").arg(login));
@@ -168,4 +177,5 @@ bool Passwd::updateUser(QString login) {
}
+// Delete a user from passwdStringList.
bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) {
for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) {
@@ -180,4 +190,5 @@ bool Passwd::deleteUser(QRegExp &userRegExp, bool delGroup) {
}
+// Delete a user by login, and optionally also delete group.
bool Passwd::delUser(const char *username, bool delGroup) {
QRegExp userRegExp(QString("^%1\\:").arg(username));
@@ -185,4 +196,5 @@ bool Passwd::delUser(const char *username, bool delGroup) {
}
+// Delete a user by uid, and optionally also delete group.
bool Passwd::delUser(int uid, bool delGroup) {
QRegExp userRegExp(QString(":%1\\:").arg(uid));
@@ -190,4 +202,5 @@ bool Passwd::delUser(int uid, bool delGroup) {
}
+// Locate a group in the groupStringList, fill out the gr_* variables and return "true" if found.
bool Passwd::searchGroup(QRegExp &groupRegExp) {
QStringList tempStringList(groupStringList.grep(groupRegExp));
@@ -201,4 +214,5 @@ bool Passwd::searchGroup(QRegExp &groupRegExp) {
}
+// Find a group by groupname.
bool Passwd::findGroup(const char *groupname) {
QRegExp groupRegExp(QString("^%1\\:").arg(groupname));
@@ -206,4 +220,5 @@ bool Passwd::findGroup(const char *groupname) {
}
+// Find a group by gid.
bool Passwd::findGroup(int gid) {
QRegExp groupRegExp(QString(":%1\\:").arg(gid));
@@ -211,4 +226,5 @@ bool Passwd::findGroup(int gid) {
}
+// Add a group to groupStringList
bool Passwd::addGroup(QString gr_name, int gr_gid) {
QString tempString;
@@ -218,4 +234,5 @@ bool Passwd::addGroup(QString gr_name, int gr_gid) {
}
+// Update fields for a group in groupStringList, take info from the gr_* variables.
bool Passwd::updateGroup(int gid) {
QRegExp groupRegExp(QString(":%1\\:").arg(QString::number(gid)));
@@ -233,4 +250,5 @@ bool Passwd::updateGroup(int gid) {
}
+// Delete a group from groupStringList.
bool Passwd::deleteGroup(QRegExp &groupRegExp) {
for(QStringList::Iterator it=groupStringList.begin(); it!=groupStringList.end(); ++it) {
@@ -243,4 +261,5 @@ bool Passwd::deleteGroup(QRegExp &groupRegExp) {
}
+// Delete a group by groupname.
bool Passwd::delGroup(const char *groupname) {
QRegExp groupRegExp(QString("^%1\\:").arg(groupname));
@@ -248,4 +267,5 @@ bool Passwd::delGroup(const char *groupname) {
}
+// Delete a group by gid.
bool Passwd::delGroup(int gid) {
QRegExp groupRegExp(QString(":%1\\:").arg(gid));
@@ -253,4 +273,5 @@ bool Passwd::delGroup(int gid) {
}
+// Add a user as a member to a group in groupStringList.
bool Passwd::addGroupMember(QString groupname, QString member) {
if(!(findGroup(groupname))) return false;
@@ -260,4 +281,5 @@ bool Passwd::addGroupMember(QString groupname, QString member) {
}
+// Delete a user as a groupmember from a group in groupStringList.
bool Passwd::delGroupMember(QString groupname, QString member) {
if(!(findGroup(groupname))) return false;
@@ -272,3 +294,4 @@ bool Passwd::delGroupMember(QString groupname, QString member) {
}
+// Global Object
Passwd *accounts;
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 36bcf86..c82cc9d 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -33,5 +33,6 @@ using namespace Opie;
*
*/
-UserDialog::UserDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) {
+UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) {
+ vm=viewmode;
QVBoxLayout *layout = new QVBoxLayout(this);
myTabWidget=new QTabWidget(this,"User Tab Widget");
@@ -110,11 +111,11 @@ void UserDialog::setupTab1() {
groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
+ if(vm==VIEWMODE_NEW) {
// Copy /etc/skel
- QLabel *skelLabel=new QLabel(tabpage,"skel");
+ skelLabel=new QLabel(tabpage,"skel");
skelLabel->setText("Copy /etc/skel: ");
skelCheckBox=new QCheckBox(tabpage);
skelCheckBox->setChecked(true);
-// skelLabel->setDisabled(true);
-// skelCheckBox->setDisabled(true);
+ }
// Widget layout
@@ -137,6 +138,8 @@ void UserDialog::setupTab1() {
vlayout1->addSpacing(5);
vlayout1->addWidget(groupLabel);
+ if(vm==VIEWMODE_NEW) {
vlayout1->addSpacing(5);
vlayout1->addWidget(skelLabel);
+ }
// Second column, data
vlayout2->addWidget(loginLineEdit);
@@ -151,6 +154,8 @@ void UserDialog::setupTab1() {
vlayout2->addSpacing(5);
vlayout2->addWidget(groupComboBox);
+ if(vm==VIEWMODE_NEW) {
vlayout2->addSpacing(5);
vlayout2->addWidget(skelCheckBox);
+ }
hlayout->addLayout(vlayout1);
hlayout->addLayout(vlayout2);
@@ -197,5 +202,6 @@ bool UserDialog::addUser(int uid, int gid) {
int oz=false;
if(ODevice::inst()->system()==System_OpenZaurus) oz=true;
- UserDialog *adduserDialog=new UserDialog();
+ // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here.
+ UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW);
adduserDialog->setCaption(tr("Add User"));
adduserDialog->userID=uid; // Set next available UID as default uid.
@@ -299,5 +305,6 @@ bool UserDialog::delUser(const char *username) {
bool UserDialog::editUser(const char *username) {
int invalid_group=0;
- UserDialog *edituserDialog=new UserDialog(); // Create Dialog
+ // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here.
+ UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog
edituserDialog->setCaption(tr("Edit User"));
accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object.
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index 133b35d..b7b925d 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -43,4 +43,9 @@ private:
int groupID;
int userID;
+ int vm;
+ enum VIEWMODE {
+ VIEWMODE_NEW,
+ VIEWMODE_EDIT
+ };
void setupTab1(void);
@@ -52,5 +57,5 @@ private slots:
public:
- UserDialog( QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 );
+ UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 );
~UserDialog();
static bool addUser(int uid, int gid);