[PC-BSD Commits] r15595 - pcbsd/current/src-qt4/pc-usermanager

svn at pcbsd.org svn at pcbsd.org
Sat Feb 25 08:29:42 PST 2012


Author: tim
Date: 2012-02-25 16:29:42 +0000 (Sat, 25 Feb 2012)
New Revision: 15595

Modified:
   pcbsd/current/src-qt4/pc-usermanager/maindlgcode.cpp
   pcbsd/current/src-qt4/pc-usermanager/simpledlgcode.cpp
   pcbsd/current/src-qt4/pc-usermanager/user.cpp
   pcbsd/current/src-qt4/pc-usermanager/user.h
   pcbsd/current/src-qt4/pc-usermanager/usermanagerback.cpp
Log:
Implemented feature request #577. When removing a user, UserManager will now ask if it should delete the user's home directory (default no).

Modified: pcbsd/current/src-qt4/pc-usermanager/maindlgcode.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/maindlgcode.cpp	2012-02-25 13:26:56 UTC (rev 15594)
+++ pcbsd/current/src-qt4/pc-usermanager/maindlgcode.cpp	2012-02-25 16:29:42 UTC (rev 15595)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim McCormick   *
+ *   Copyright (C) 2007, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -205,6 +205,14 @@
 void mainDlgCode::removeUser()
 {
     QString username = userList->currentItem()->text();
+    User *user = back->getUser(username);
+    QString home = user->getHome();
+    int answer = QMessageBox::question(this,
+                                       tr("Delete Home Directory?"),
+                                       tr("Delete the home directory for ") + username + " (" + home + ")?" ,
+                                       QMessageBox::Yes | QMessageBox::No,
+                                       QMessageBox::No);
+    if(answer == QMessageBox::Yes) user->setDeleteHome(true);
     back->deleteUser(username);
 }
 

Modified: pcbsd/current/src-qt4/pc-usermanager/simpledlgcode.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/simpledlgcode.cpp	2012-02-25 13:26:56 UTC (rev 15594)
+++ pcbsd/current/src-qt4/pc-usermanager/simpledlgcode.cpp	2012-02-25 16:29:42 UTC (rev 15595)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim McCormick   *
+ *   Copyright (C) 2007, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -157,7 +157,16 @@
 
 void SimpleDlgCode::removeUser()
 {
-    back->deleteUser(userList->currentItem()->text().section(" ", 0, 0));
+    QString username = userList->currentItem()->text().section(" ", 0, 0);
+    User *user = back->getUser(username);
+    QString home = user->getHome();
+    int answer = QMessageBox::question(this,
+                                       tr("Delete Home Directory?"),
+                                       tr("Delete the home directory for ") + username + " (" + home + ")?" ,
+                                       QMessageBox::Yes | QMessageBox::No,
+                                       QMessageBox::No);
+    if(answer == QMessageBox::Yes) user->setDeleteHome(true);
+    back->deleteUser(username);
 }
 
 void SimpleDlgCode::addUser()

Modified: pcbsd/current/src-qt4/pc-usermanager/user.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/user.cpp	2012-02-25 13:26:56 UTC (rev 15594)
+++ pcbsd/current/src-qt4/pc-usermanager/user.cpp	2012-02-25 16:29:42 UTC (rev 15595)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005 - 2007 by Tim McCormick   *
+ *   Copyright (C) 2005, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -36,6 +36,7 @@
     fullname = "Not set";
     status = 0;
     password = "";
+    deleteHome = false;
 }
 
 User::User(QString username, int uid, int gid, QString home, QString shell, QString fullname) {
@@ -156,3 +157,19 @@
 {
     this->status = status;
 }
+
+/**
+ * @param deleteHome is true if the home directory should be deleted
+ */
+void User::setDeleteHome(bool deleteHome)
+{
+    this->deleteHome = deleteHome;
+}
+
+/**
+  * @return true if the home directory should be deleted
+  */
+bool User::getDeleteHome()
+{
+    return deleteHome;
+}

Modified: pcbsd/current/src-qt4/pc-usermanager/user.h
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/user.h	2012-02-25 13:26:56 UTC (rev 15594)
+++ pcbsd/current/src-qt4/pc-usermanager/user.h	2012-02-25 16:29:42 UTC (rev 15595)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005 - 2007 by Tim McCormick   *
+ *   Copyright (C) 2005, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -53,6 +53,8 @@
     virtual void setDeleted();
     virtual uint getStatus();
     virtual void setStatus(uint status);
+    virtual void setDeleteHome(bool deleteHome);
+    virtual bool getDeleteHome();
     
 private:
     QString username;
@@ -63,6 +65,7 @@
     QString fullname;
     uint status; // 0 = No change, 1 = Changes, 2 = New, 3 = Deleted
     QString password;
+    bool deleteHome;
 };
 
 #endif // INC_USER_H

Modified: pcbsd/current/src-qt4/pc-usermanager/usermanagerback.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/usermanagerback.cpp	2012-02-25 13:26:56 UTC (rev 15594)
+++ pcbsd/current/src-qt4/pc-usermanager/usermanagerback.cpp	2012-02-25 16:29:42 UTC (rev 15595)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005 - 2007 by Tim McCormick   *
+ *   Copyright (C) 2005, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -402,7 +402,7 @@
                 qDebug() << "Deleting user " << userIt->getUsername();
                 args << "userdel";
                 args << userIt->getUsername();
-                args << "-r";
+                if(userIt->getDeleteHome()) args << "-r";
 		QProcess::execute("pw", args);
                 break;
         }



More information about the Commits mailing list