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

svn at pcbsd.org svn at pcbsd.org
Thu Aug 30 12:51:22 PDT 2012


Author: kenmoore
Date: 2012-08-30 19:51:21 +0000 (Thu, 30 Aug 2012)
New Revision: 18724

Modified:
   pcbsd-projects/PCDM/main.cpp
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
   pcbsd-projects/PCDM/startPCDM
Log:
Add in the ability for PCDM to log it error messages. This will work as a replacement for qDebug() in the program, once it gets tested properly here soon.



Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp	2012-08-30 18:41:58 UTC (rev 18723)
+++ pcbsd-projects/PCDM/main.cpp	2012-08-30 19:51:21 UTC (rev 18724)
@@ -26,7 +26,8 @@
     for ( ;; )
     {
       QApplication a(argc,argv);
-
+      Backend::openLogFile("/var/logs/PCDM.log");
+      
       // Check what directory our app is in
       QString appDir;
       if ( QFile::exists("/usr/local/bin/PCDM") ){
@@ -45,9 +46,9 @@
       if ( QFile::exists(appDir + "/i18n/PCDM_" + langCode + ".qm" ) ) {
         translator.load( QString("PCDM_") + langCode, appDir + "/i18n/" );
         a.installTranslator(&translator);
-        qDebug() << "Loaded Translation:" << appDir + "/i18n/PCDM_" + langCode + ".qm";
+        Backend::log("Loaded Translation:" + appDir + "/i18n/PCDM_" + langCode + ".qm");
       } else {
-        qDebug() << "Could not find: " << appDir + "/i18n/PCDM_" + langCode + ".qm";
+      	Backend::log("Could not find: " + appDir + "/i18n/PCDM_" + langCode + ".qm");
         langCode = "";
       }
 

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-30 18:41:58 UTC (rev 18723)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-30 19:51:21 UTC (rev 18724)
@@ -8,6 +8,7 @@
 #include "pcbsd-utils.h"
 
 QStringList displaynameList,usernameList,instXNameList,instXBinList,instXCommentList,instXIconList;
+QString logFile;
 
 QStringList Backend::getAvailableDesktops(){  
   if(instXNameList.isEmpty()){ loadXSessionsData(); }
@@ -87,11 +88,16 @@
     xfile.close();
   }
   */
+  //Get the user's home directory
+  
   //Create the external process
   QProcess* p = new QProcess(0);
   //Setup the process environment
   QProcessEnvironment environ = p->processEnvironment(); //current environment
-  
+  environ.insert("LOGNAME",username);
+  environ.insert("USERNAME",username);
+  //environ.insert("HOME",homeDir);
+  //environ.insert("PATH",environ->value("PATH")+":"+homeDir+"/bin");
   //p->setProcessEnvironment(environ);
   //Startup the process
   qDebug() << "Current Envronment:" << environ.toStringList();
@@ -212,6 +218,21 @@
     return _languages;
 }
 
+void Backend::openLogFile(QString logFilePath){
+  //If a log file exists, remove it
+  if(QFile::exists(logFilePath)){ QFile::remove(logFilePath); }
+  //save the path to the logfile
+  logFile = logFilePath;
+}
+
+void Backend::log(QString line){
+  QFile lFile(logFile);
+  lFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
+  QTextStream out(&lFile);
+  out << line << "\n";
+  lFile.close();
+}
+
 //****** PRIVATE FUNCTIONS ******
 
 void Backend::loadXSessionsData(){

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2012-08-30 18:41:58 UTC (rev 18723)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2012-08-30 19:51:21 UTC (rev 18724)
@@ -39,14 +39,15 @@
     static QStringList keyVariants(const QString &layout, QStringList &savedKeyVariants);
     static void changeKbMap(QString model, QString layout, QString variant);
     static QStringList languages();
+    static void openLogFile(QString);
+    static void log(QString);
     
 private:	
     static void loadXSessionsData();
     static QStringList readXSessionsFile(QString, QString);
     static bool verifyUsernamePassword(QString, QString);
-    static void startXSession(QString,QString);
+    static void startXSession(QString,QString);  
     
-    
 };
 
 

Modified: pcbsd-projects/PCDM/startPCDM
===================================================================
--- pcbsd-projects/PCDM/startPCDM	2012-08-30 18:41:58 UTC (rev 18723)
+++ pcbsd-projects/PCDM/startPCDM	2012-08-30 19:51:21 UTC (rev 18724)
@@ -1,13 +1,5 @@
 #!/bin/sh
-#Startup this function with the following command:
-#   xinit "/usr/local/bin/startPCDM" :8
-#
 
-#Start the normal PCDM GUI
-/usr/local/bin/PCDM
+#Start XOrg and the normal PCDM GUI
+xinit /usr/local/bin/PCDM -- :8
 
-#If a desktop session command has been created, run it then remove it
-if [ -f /usr/local/bin/.pcdm-startup ]; then
-  sh /usr/local/bin/.pcdm-startup
-  rm /usr/local/bin/.pcdm-startup
-fi



More information about the Commits mailing list