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

svn at pcbsd.org svn at pcbsd.org
Thu Aug 30 13:45:46 PDT 2012


Author: kenmoore
Date: 2012-08-30 20:45:46 +0000 (Thu, 30 Aug 2012)
New Revision: 18725

Modified:
   pcbsd-projects/PCDM/main.cpp
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-config.cpp
   pcbsd-projects/PCDM/pcdm-gui.cpp
Log:
Change over most of the rest of PCDM's qDebug statements to use the new logging system, and finish fixing the log system.



Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp	2012-08-30 19:51:21 UTC (rev 18724)
+++ pcbsd-projects/PCDM/main.cpp	2012-08-30 20:45:46 UTC (rev 18725)
@@ -26,7 +26,7 @@
     for ( ;; )
     {
       QApplication a(argc,argv);
-      Backend::openLogFile("/var/logs/PCDM.log");
+      Backend::openLogFile("/usr/local/share/PCDM/PCDM.log");
       
       // Check what directory our app is in
       QString appDir;
@@ -91,7 +91,7 @@
            return 150;
          changeLang = lfile.readLine();
          lfile.close();
-         qDebug() << "Language switch requested for:" << changeLang;
+         Backend::log("Language switch requested for:" + changeLang);
          QFile::remove(TMPLANGFILE);
 
       } else {

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-30 19:51:21 UTC (rev 18724)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-30 20:45:46 UTC (rev 18725)
@@ -19,21 +19,21 @@
 QString Backend::getDesktopComment(QString xName){
   if(instXNameList.isEmpty()){ loadXSessionsData(); }
   int index = instXNameList.indexOf(xName);
-  if(index == -1){ qDebug() << "PCDM: Invalid Desktop Name:" << xName; return ""; }
+  if(index == -1){ Backend::log("PCDM: Invalid Desktop Name: " + xName); return ""; }
   return instXCommentList[index];
 }
 
 QString Backend::getDesktopIcon(QString xName){
   if(instXNameList.isEmpty()){ loadXSessionsData(); }
   int index = instXNameList.indexOf(xName);
-  if(index == -1){ qDebug() << "PCDM: Invalid Desktop Name:" << xName; return ""; }
+  if(index == -1){ Backend::log("PCDM: Invalid Desktop Name: " +xName); return ""; }
   return instXIconList[index];
 }
 
 QString Backend::getDesktopBinary(QString xName){
   if(instXNameList.isEmpty()){ loadXSessionsData(); }
   int index = instXNameList.indexOf(xName);
-  if(index == -1){ qDebug() << "PCDM: Invalid Desktop Name:" << xName; return ""; }
+  if(index == -1){ Backend::log("PCDM: Invalid Desktop Name: " + xName); return ""; }
   return instXBinList[index];
 }
 
@@ -68,40 +68,31 @@
 bool Backend::startUserLogin(QString username, QString password, QString xBinary){
   bool allowed = verifyUsernamePassword(username, password);
   if(allowed){
-    qDebug() << "Username/Password Authorized";
+    Backend::log("Username/Password Authorized");
     //Setup the system command to run the selected DE
     //QString cmd = "su -m "+username+" -c "+xBinary;
     startXSession(xBinary, username);
   }else{
-    qDebug() << "Username/Password not authorized";	  
+    Backend::log("Username/Password not authorized");	  
   }
   return allowed;
 }
 
 void Backend::startXSession(QString cmd, QString username){
-  /*
-  QFile xfile("/usr/local/bin/.pcdm-startup");
-  if(xfile.open(QIODevice::WriteOnly | QIODevice::Text)){
-    QTextStream out(&xfile);
-    out << "#!/bin/sh" << "\n\n";
-    out << cmd << "\n";
-    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("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();
-  qDebug() << "Debug Mode: not starting DE";
+  Backend::log("Current Envronment: " + environ.toStringList().join(" ") );
+  Backend::log("Debug Mode: not starting DE");
   //p->startDetached(cmd);
 
 }
@@ -189,7 +180,7 @@
    QString prog;
    prog = "setxkbmap"; 
    args << "-model" << model << "-layout" << layout << "-variant" << variant;
-   qDebug() << "setxkbmap:" << args;
+   Backend::log("setxkbmap: " + args.join(" "));
    kbp.start(prog, args);
    kbp.waitForFinished();
 }
@@ -227,7 +218,7 @@
 
 void Backend::log(QString line){
   QFile lFile(logFile);
-  lFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
+  lFile.open(QIODevice::Append);
   QTextStream out(&lFile);
   out << line << "\n";
   lFile.close();
@@ -270,7 +261,7 @@
 	  tmp[3] = Theme::objectIconPath("desktop");
 	}
 	instXIconList << tmp[3];
-	//qDebug() << "PCDM: Found xsession:" << tmp;
+	Backend::log( "PCDM: Found xsession: " + tmp.join(" ") );
       }
     }
   }
@@ -356,46 +347,46 @@
       if( ret == PAM_SUCCESS ){ result = TRUE; }
     
     }else{
-      qDebug() << "PAM Authentication Failed with error:" << ret;
+    	    Backend::log("PAM Authentication Failed with error: " + ret);
       switch( ret ){
       case PAM_ABORT:
-      	  qDebug() << " - PAM abort error";
+      	      Backend::log(" - PAM abort error");
       	  break;
       case PAM_AUTHINFO_UNAVAIL:
-      	      qDebug() << " - Authentication info unavailable";
+      	      Backend::log(" - Authentication info unavailable");
       	      break;
       case PAM_AUTH_ERR:
-      	      qDebug() << " - Authentication error";
+      	      Backend::log(" - Authentication error");
       	      break;
       case PAM_BUF_ERR:
-      	      qDebug() << " - Buffer error";
+      	      Backend::log(" - Buffer error");
       	      break;
       case PAM_CONV_ERR:
-      	      qDebug() << " - Conversion error";
+      	      Backend::log(" - Conversion error");
       	      break;
       case PAM_CRED_INSUFFICIENT:
-      	      qDebug() << " - Credentials insufficient";
+      	      Backend::log(" - Credentials insufficient");
       	      break;
       case PAM_MAXTRIES:
-      	      qDebug() << " - Maximum number of tries exceeded";
+      	      Backend::log(" - Maximum number of tries exceeded");
       	      break;
       case PAM_PERM_DENIED:
-      	      qDebug() << " - Permission denied";
+      	      Backend::log(" - Permission denied");
       	      break;
       case PAM_SERVICE_ERR:
-      	      qDebug() << " - Service error";
+      	      Backend::log(" - Service error");
       	      break;
       case PAM_SYMBOL_ERR:
-      	      qDebug() << " - Symbol error";
+      	      Backend::log(" - Symbol error");
       	      break;
       case PAM_SYSTEM_ERR:
-      	      qDebug() << " - System error";
+      	      Backend::log(" - System error");
       	      break;
       case PAM_USER_UNKNOWN:
-      	      qDebug() << " - Unknown user";
+      	      Backend::log(" - Unknown user");
       	      break;
       default:
-      	      qDebug() << " - Unrecognized authentication error";
+      	      Backend::log(" - Unrecognized authentication error");
       }
     }
     //Stop PAM   

Modified: pcbsd-projects/PCDM/pcdm-config.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-config.cpp	2012-08-30 19:51:21 UTC (rev 18724)
+++ pcbsd-projects/PCDM/pcdm-config.cpp	2012-08-30 20:45:46 UTC (rev 18725)
@@ -1,4 +1,5 @@
 #include "pcdm-config.h"
+#include "pcdm-backend.h"
 
 //Setup variables that save the current configuration data
 QStringList confStruct;
@@ -14,7 +15,7 @@
 }
 
 void Config::readConfigFile(QString filePath){
-  qDebug() << "PCDM: Reading a configuration file not implemented yet - using defaults";
+  Backend::log("PCDM: Reading a configuration file not implemented yet - using defaults");
   return;
 }
 
@@ -24,7 +25,7 @@
   if(QFile::exists(filePath)){
     readConfigFile(filePath);
   }else{
-    qDebug() << "PCDM: Configuration file" << filePath << " does not exist - using defaults";
+    Backend::log("PCDM: Configuration file " + filePath + " does not exist - using defaults");
   }
 }
 

Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp	2012-08-30 19:51:21 UTC (rev 18724)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp	2012-08-30 20:45:46 UTC (rev 18725)
@@ -122,79 +122,7 @@
     //Connect the signals/slots
     connect(loginW,SIGNAL(loginRequested(QString,QString)),this,SLOT(slotStartLogin(QString,QString)));
     connect(loginW,SIGNAL(escapePressed()),this,SLOT(slotShutdownComputer()));
-    
-    /*
-    //----Username Input collection
-    QString uLayout = Theme::objectIconStyle("user");
-    unameline = new QComboBox;
-    unameline->addItems(Backend::getSystemUsers());
-    unameline->setCurrentIndex(0); //select the first username on the list
-    unameline->setStyleSheet(Theme::objectStyleSheet("user"));
-    if(uLayout == "disabled"){
-      //Icon Disabled - just add widget to the grid
-      grid->addWidget( unameline, Theme::objectLocationRow("user"), \
-                      Theme::objectLocationColumn("user"), \
-                      Theme::objectLocationRowSpan("user"), \
-                      Theme::objectLocationColumnSpan("user"), Qt::AlignCenter); 
-    }else{
-      //Put the Icon and Widget in their own layout before adding to the main grid
-      int rI,rW,cI,cW;
-      if(uLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
-      if(uLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
-      if(uLayout=="left") { rI=0; cI=0; rW=0; cW=1; } //icon to the left
-      if(uLayout=="right"){ rI=0; cI=1; rW=0; cW=0; } //icon to the right
-      QGridLayout* ugrid = new QGridLayout;
-      QPixmap tmp( Theme::objectIconPath("user") );
-      QLabel* unameIcon = new QLabel; unameIcon->setPixmap(tmp.scaled(Theme::objectIconSize("user")));
-      ugrid->addWidget(unameline,rW,cW,Qt::AlignCenter);
-      ugrid->addWidget(unameIcon,rI,cI,Qt::AlignCenter);
 
-      grid->addLayout( ugrid, Theme::objectLocationRow("user"), \
-                      Theme::objectLocationColumn("user"), \
-                      Theme::objectLocationRowSpan("user"), \
-                      Theme::objectLocationColumnSpan("user"), Qt::AlignCenter);
-    }
-
-    //----Password Input collection
-    QString pLayout = Theme::objectIconStyle("password");
-    pwline = new QLineEdit; pwline->setEchoMode(QLineEdit::Password);
-    pwline->setStyleSheet(Theme::objectStyleSheet("password"));
-    if(pLayout == "disabled"){
-      //Icon Disabled - just add widget to the grid
-      grid->addWidget( pwline, Theme::objectLocationRow("password"), \
-                      Theme::objectLocationColumn("password"), \
-                      Theme::objectLocationRowSpan("password"), \
-                      Theme::objectLocationColumnSpan("password"), Qt::AlignCenter); 
-    }else{
-      //Put the Icon and Widget in their own layout before adding to the main grid
-      int rI,rW,cI,cW;
-      if(pLayout=="above"){ rI=0; cI=0; rW=1; cW=0; } //icon above
-      if(pLayout=="below"){ rI=1; cI=0; rW=0; cW=0; } //icon below
-      if(pLayout=="left") { rI=0; cI=0; rW=0; cW=1; } //icon to the left
-      if(pLayout=="right"){ rI=0; cI=1; rW=0; cW=0; } //icon to the right
-      QGridLayout* pgrid = new QGridLayout;
-      QPixmap tmp( Theme::objectIconPath("password") );
-      QLabel* pwIcon = new QLabel; pwIcon->setPixmap(tmp.scaled(Theme::objectIconSize("password")));
-      pgrid->addWidget(pwline,rW,cW,Qt::AlignCenter);
-      pgrid->addWidget(pwIcon,rI,cI,Qt::AlignCenter);
-
-      grid->addLayout( pgrid, Theme::objectLocationRow("password"), \
-                      Theme::objectLocationColumn("password"), \
-                      Theme::objectLocationRowSpan("password"), \
-                      Theme::objectLocationColumnSpan("password"), Qt::AlignCenter);
-    }
-
-    //----Login Button
-    QString lLayout = Theme::objectIconStyle("login");
-    QPushButton* pushlogin = new QPushButton(QIcon(Theme::objectIconPath("login")),tr("Login") );
-    pushlogin->setStyleSheet(Theme::objectStyleSheet("login"));
-    connect(pushlogin,SIGNAL(clicked()),this,SLOT(slotStartLogin()));
-    if(lLayout=="disabled"){ pushlogin->setIcon(QIcon("")); }  //Remove the icon
-    grid->addWidget( pushlogin, Theme::objectLocationRow("login"), \
-                      Theme::objectLocationColumn("login"), \
-                      Theme::objectLocationRowSpan("login"), \
-                      Theme::objectLocationColumnSpan("login"), Qt::AlignCenter); 
-*/
     //----Desktop Environment Switcher
     //Create the switcher
     bool horizontalDE = TRUE;
@@ -286,7 +214,7 @@
   int ret = verify.exec();
 
   if(ret == QMessageBox::Yes){
-    qDebug() << "PCDM: Shutting down computer";
+    Backend::log("PCDM: Shutting down computer");
     system("shutdown -p now");
     close();
   }
@@ -302,7 +230,7 @@
   int ret = verify.exec();
 
   if(ret == QMessageBox::Yes){
-    qDebug() << "PCDM: Restarting computer";
+    Backend::log("PCDM: Restarting computer");
     system("shutdown -r now");
     close();
   }
@@ -317,7 +245,7 @@
   //Open the selector
   wLoc = new widgetLocale();
   QLocale currLocale = this->locale();
-  qDebug() << "Current PCDM Locale:" << currLocale.name();
+  Backend::log("Current PCDM Locale: " + currLocale.name() );
   wLoc->setCurrentLocale(currLocale.name());
   wLoc->setWindowModality(Qt::ApplicationModal);
   wLoc->show();
@@ -334,7 +262,7 @@
     langCode = langCode.section("_",0,0);
     if(!QFile::exists(translationDir+"PCDM_"+langCode+".qm")){
       if(!QFile::exists(translationDir+"qt_"+langCode+".qm")){
-      	qDebug() << "Desired locale is not a valid translation:" << langCode;
+      	Backend::log("Desired locale is not a valid translation: " + langCode);
       	return;
       }else{
         translationFile = translationDir+"qt_"+langCode+".qm";	    
@@ -346,7 +274,7 @@
     translationFile = translationDir+"PCDM_"+langCode+".qm";
   }	
 	
-  qDebug() << "Changing localization to" << langCode;
+  Backend::log("Changing localization to " + langCode);
   
   // Now write out the lang code and close
   /*
@@ -364,16 +292,16 @@
   this->setLocale(locale);
   //this->setDefaultLocale(locale);
   //Change the translator
-  qDebug() << "Remove the translator";
+  Backend::log("Remove the translator");
   QCoreApplication::removeTranslator(m_translator);
-  qDebug() << "load the new translator";
+  Backend::log("load the new translator");
   if(m_translator->load(translationFile)){
     QCoreApplication::installTranslator(m_translator);	  
   }
   //Re-draw the interface
   //this->retranslateUi(this);
   
-  qDebug() << "Current Locale after change:"<<this->locale().name();
+  Backend::log("Current Locale after change: " + this->locale().name() );
 }
 
 void PCDMgui::slotChangeKeyboardLayout(){



More information about the Commits mailing list