[PC-BSD Commits] r17727 - pcbsd-projects/PCDM

svn at pcbsd.org svn at pcbsd.org
Fri Jul 13 22:48:50 PDT 2012


Author: kenmoore
Date: 2012-07-14 05:48:49 +0000 (Sat, 14 Jul 2012)
New Revision: 17727

Modified:
   pcbsd-projects/PCDM/PCDM.pro
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
Log:
Add the ability for PCDM to detect the available usernames and display names for all real users of the system. Setup the UI to only show the display names for users.



Modified: pcbsd-projects/PCDM/PCDM.pro
===================================================================
--- pcbsd-projects/PCDM/PCDM.pro	2012-07-14 05:11:38 UTC (rev 17726)
+++ pcbsd-projects/PCDM/PCDM.pro	2012-07-14 05:48:49 UTC (rev 17727)
@@ -2,15 +2,18 @@
 TARGET = PCDM
 TARGET.path=/usr/local/bin
 TEMPLATE = app
+LIBS += -lpcbsd
 SOURCES += main.cpp \
            pcdm-gui.cpp \
     	   pcdm-backend.cpp \
     	   pcdm-themes.cpp \
            pcdm-config.cpp
+
 HEADERS += pcdm-gui.h \
     	   pcdm-backend.h \
 	   pcdm-themes.h \
            pcdm-config.h
+
 TRANSLATIONS =  i18n/PCDM_af.ts \
 		i18n/PCDM_ar.ts \
 		i18n/PCDM_az.ts \

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-07-14 05:11:38 UTC (rev 17726)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-07-14 05:48:49 UTC (rev 17727)
@@ -1,10 +1,7 @@
-#include <QApplication>
-#include <QFile>
-#include <QProcess>
-#include <QDebug>
-
 #include "pcdm-backend.h"
+#include "pcbsd-utils.h"
 
+QStringList usernameList, displaynameList;
 
 QStringList Backend::getAvailableDesktops(){
   qDebug() << "PCDM: Scanning for available desktop environments is not integrated yet";
@@ -12,6 +9,26 @@
 }
 
 QStringList Backend::getSystemUsers(){
-  qDebug() << "PCDM: Scanning for available usernames is not integrated yet";
-  return QStringList("");
+  if(usernameList.isEmpty()){
+    //get the names of all the directories in /usr/home (usernames)
+    QDir dir("/usr/home");
+    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
+    usernameList = dir.entryList();
+    //Also get the display names for each user
+    displaynameList.clear();
+    for(int i=0; i<usernameList.length(); i++){
+      QString cmd = "cat /etc/passwd";//| grep USERNAME | cut -d: -f5";
+      QString dsp = Utils::runShellCommandSearch( cmd, usernameList[i]).section(":",4,4).simplified();
+      //qDebug() << "Username:"<<usernameList[i]<<" Display Name:"<<dsp;
+      if(!dsp.isEmpty()){ displaynameList << dsp; }
+      else{ usernameList.removeAt(i); i--; } //make sure to remove the username if there is no entry in the passwd file for it
+    }
+  }
+  //qDebug() << "PCDM: Scanning for available usernames is not integrated yet";
+  return displaynameList;
 }
+
+QString getUsernameFromDisplayname(QString dspname){
+  int i = displaynameList.indexOf(dspname);
+  return usernameList[i];
+}

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2012-07-14 05:11:38 UTC (rev 17726)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2012-07-14 05:48:49 UTC (rev 17727)
@@ -1,21 +1,23 @@
-#ifndef PCDE_BACKEND_H
-#define PCDE_BACKEND_H
+#ifndef PCDM_BACKEND_H
+#define PCDM_BACKEND_H
 
 #include <QStringList>
 #include <QString>
-#include <QList>
 #include <QDebug>
-#include <QProcess>
+#include <QDir>
 
 #include "pcdm-config.h"
+#include "pcbsd-utils.h"
 
 class Backend {
 public:
     static QStringList getAvailableDesktops();
     static QStringList getSystemUsers();
 
+private:
+    static QString getUsernameFromDisplayname(QString);
 
 };
 
 
-#endif // BACKEND_H
+#endif // PCDM_BACKEND_H



More information about the Commits mailing list