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

svn at pcbsd.org svn at pcbsd.org
Thu Sep 20 11:52:56 PDT 2012


Author: kenmoore
Date: 2012-09-20 18:52:55 +0000 (Thu, 20 Sep 2012)
New Revision: 19429

Added:
   pcbsd-projects/PCDM/pcdm.conf
   pcbsd-projects/PCDM/pcdm.theme
Removed:
   pcbsd-projects/PCDM/pcdm.conf.sample
   pcbsd-projects/PCDM/sample.pcdm-theme
Modified:
   pcbsd-projects/PCDM/PCDM.qrc
   pcbsd-projects/PCDM/main.cpp
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
   pcbsd-projects/PCDM/pcdm-config.cpp
   pcbsd-projects/PCDM/pcdm-config.h
   pcbsd-projects/PCDM/pcdm-gui.cpp
Log:
Cleanup the PCDM files organization, and also finish setting up the pcdm.conf file and incorporating it into the program (just need to add the auto-login process, the hooks are now there in the configuration)



Modified: pcbsd-projects/PCDM/PCDM.qrc
===================================================================
--- pcbsd-projects/PCDM/PCDM.qrc	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/PCDM.qrc	2012-09-20 18:52:55 UTC (rev 19429)
@@ -25,4 +25,8 @@
     <file>images/openbox.png</file>
     <file>images/nodesktop.png</file>
   </qresource>
+  <qresource prefix="samples">
+    <file>pcdm.theme</file>
+    <file>pcdm.conf</file>
+  </qresource>
 </RCC>

Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/main.cpp	2012-09-20 18:52:55 UTC (rev 19429)
@@ -16,6 +16,7 @@
 {
 
   int returnCode;  
+  Backend::checkLocalDirs();  // Create and fill "/usr/local/share/PCDM" if needed
   Backend::openLogFile("/usr/local/share/PCDM/PCDM.log");   
   
     QString changeLang; 

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-20 18:52:55 UTC (rev 19429)
@@ -272,6 +272,17 @@
   lFile.close();
 }
 
+void Backend::checkLocalDirs(){
+  //Check for directories first
+  QDir mainDir("/usr/local/share/PCDM");
+  if(!mainDir.exists()){ mainDir.mkdir("/usr/local/share/PCDM"); }
+  if(!mainDir.exists("images")){ mainDir.mkdir("images"); }
+  //Check for sample files
+  if(!mainDir.exists("pcdm.conf.sample")){ QFile::copy(":samples/pcdm.conf","pcdm.conf.sample"); }
+  if(!mainDir.exists("pcdm.theme.sample")){ QFile::copy(":samples/pcdm.theme","pcdm.theme.sample"); }
+  
+}
+
 //****** PRIVATE FUNCTIONS ******
 
 void Backend::loadXSessionsData(){

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2012-09-20 18:52:55 UTC (rev 19429)
@@ -43,6 +43,7 @@
     static void log(QString);
     static void startXSession();  
     static QString getUserHomeDir(QString);
+    static void checkLocalDirs();
     
 private:	
     static void loadXSessionsData();

Modified: pcbsd-projects/PCDM/pcdm-config.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.cpp	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/pcdm-config.cpp	2012-09-20 18:52:55 UTC (rev 19429)
@@ -8,26 +8,54 @@
 //******** PRIVATE FUNCTIONS *************
 void Config::loadDefaults(){
   confStruct.clear();
-  confStruct << "/usr/local/share/PCDM/default.pcdm-theme";	// [0] Theme File Path
-  confStruct << "/usr/local/share/xsessions";			// [1] *.desktop files directory
-  confStruct << "/usr/local/share/pixmaps";			// [2] Images directory for *.desktop icons
-  confStruct << "/usr/local/share/pcbsd/xstartup";			// [3] Login Scripts Directory
+  confStruct << "/usr/local/share/PCDM/pcdm.theme";	// [0] Theme File Path
+  confStruct << "/usr/local/share/xsessions";		// [1] *.desktop files directory
+  confStruct << "/usr/local/share/pixmaps";		// [2] Images directory for *.desktop icons
+  confStruct << "FALSE";				// [3] Auto-login enabled
+  confStruct << "no-username";				// [4] Auto-login username
+  confStruct << "no-desktop";				// [5] Auto-login desktop environment
   return;
 }
 
 void Config::readConfigFile(QString filePath){
-  Backend::log("PCDM: Reading a configuration file not implemented yet - using defaults");
-  return;
+  QFile conf(filePath);
+  bool ok = conf.open(QIODevice::ReadOnly | QIODevice::Text);
+  if(!ok){ 
+    Backend::log("Could not open configuration file: "+filePath+"\nLoading default configuration");
+    if(filePath!=":samples/pcdm.conf"){ readConfigFile(":samples/pcdm.conf"); }
+    return;
+  }
+  QTextStream in(&conf);
+  while( !in.atEnd() ){
+    QString line = in.readLine().simplified();
+    //Skip comment lines
+    if(!line.startsWith("#")){
+      line = line.section("#",0,0).simplified(); //cut any comments off the end of the line
+      QString var = line.section("=",0,0).simplified(); // get the variable
+      QString val = line.section("=",1,1).simplified(); // get the value
+      
+      //Parse the Configuration File
+      if(var=="THEME_FILE"){ confStruct[0] = val; }
+      else if(var=="DE_STARTUP_DIR"){ confStruct[1] = val; }
+      else if(var=="DE_STARTUP_IMAGE_DIR"){ confStruct[2] = val; }
+      else if(var=="ENABLE_AUTO_LOGIN"){ confStruct[3] = val; }
+      else if(var=="AUTO_LOGIN_USER"){ confStruct[4] = val; }
+      else if(var=="AUTO_LOGIN_DESKTOP"){ confStruct[5] = val; }
+      else{}
+      
+    }
+  }
+  conf.close();
 }
 
 //******** PUBLIC FUNCTIONS **************
 void Config::loadConfigFile(QString filePath){
   loadDefaults();
-  if(QFile::exists(filePath)){
-    readConfigFile(filePath);
-  }else{
-    Backend::log("PCDM: Configuration file " + filePath + " does not exist - using defaults");
+  if(!QFile::exists(filePath)){
+    Backend::log("Configuration file does not exist: "+filePath+"\nLoading default configuration");
+    filePath=":samples/pcdm.conf";
   }
+  readConfigFile(filePath);
 }
 
 QString Config::themeFile(){
@@ -42,6 +70,16 @@
   return confStruct[2];
 }
 
-QString Config::loginScriptsDir(){
-  return confStruct[3];	
+bool Config::useAutoLogin(){
+  if(confStruct[3].toLower()=="true"){ return TRUE; }
+  else{ return FALSE; }	
 }
+
+QString Config::autoLoginUsername(){
+  return confStruct[4];	
+}
+
+QString Config::autoLoginDesktop(){
+  if(confStruct.startsWith("/")){  return confStruct[5]; } //already an absolute path
+  else{ return (confStruct[1]+"/"+confStruct[5]); } //prepend the xsessions directory path
+}

Modified: pcbsd-projects/PCDM/pcdm-config.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.h	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/pcdm-config.h	2012-09-20 18:52:55 UTC (rev 19429)
@@ -20,6 +20,9 @@
   static QString xSessionsDir();
   static QString xSessionsImageDir();
   static QString loginScriptsDir();
+  static bool useAutoLogin(); 		//returns whether auto-login is enabled
+  static QString autoLoginUsername();	//returns username to log into automatically
+  static QString autoLoginDesktop();	//return *.desktop file to startup automatically
   
 
 };

Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp	2012-09-20 17:09:28 UTC (rev 19428)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp	2012-09-20 18:52:55 UTC (rev 19429)
@@ -115,10 +115,10 @@
     loginW->setStyleSheet("pwview", Theme::objectStyleSheet("password"));
     loginW->setStyleSheet("user", Theme::objectStyleSheet("user"));
     //Add item to the grid
-    grid->addWidget( loginW, Theme::objectLocationRow("user"), \
-                      Theme::objectLocationColumn("user"), \
-                      Theme::objectLocationRowSpan("user"), \
-                      Theme::objectLocationColumnSpan("user"), Qt::AlignCenter);
+    grid->addWidget( loginW, Theme::objectLocationRow("login"), \
+                      Theme::objectLocationColumn("login"), \
+                      Theme::objectLocationRowSpan("login"), \
+                      Theme::objectLocationColumnSpan("login"), Qt::AlignCenter);
     //Connect the signals/slots
     connect(loginW,SIGNAL(loginRequested(QString,QString)),this,SLOT(slotStartLogin(QString,QString)));
     connect(loginW,SIGNAL(escapePressed()),this,SLOT(slotShutdownComputer()));



More information about the Commits mailing list