[PC-BSD Commits] r18855 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Wed Sep 5 08:57:39 PDT 2012
Author: kenmoore
Date: 2012-09-05 15:57:39 +0000 (Wed, 05 Sep 2012)
New Revision: 18855
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 refresh loop for PCDM, this should allow us to set PCDM to restart whenever the desktop environment finishes.
Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp 2012-09-05 14:07:36 UTC (rev 18854)
+++ pcbsd-projects/PCDM/main.cpp 2012-09-05 15:57:39 UTC (rev 18855)
@@ -14,76 +14,75 @@
int main(int argc, char *argv[])
{
- int returnCode;
+ bool Debug_Mode = TRUE;
+ bool runRestartLoop = TRUE;
+ int returnCode;
+
+ while(runRestartLoop){
QString changeLang;
-
- //Load the configuration file
+ // Load the configuration file
Config::loadConfigFile("/usr/local/share/PCDM/pcdm.conf");
- //Load the Desired Theme
+ // Load the Desired Theme
Theme::loadTheme(Config::themeFile());
+ // Startup the main application
+ QApplication a(argc,argv);
+ Backend::openLogFile("/usr/local/share/PCDM/PCDM.log");
+ // Check what directory our app is in
+ QString appDir;
+ if ( QFile::exists("/usr/local/bin/PCDM") ){
+ appDir = "/usr/local/share/PCDM";
+ } else {
+ appDir = QCoreApplication::applicationDirPath();
+ }
+ // Load the translator
+ QTranslator translator;
+ QLocale mylocale;
+ QString langCode = mylocale.name();
+ //Check for a language change detected
+ if ( ! changeLang.isEmpty() )
+ langCode = changeLang;
+ //Load the proper locale for the translator
+ if ( QFile::exists(appDir + "/i18n/PCDM_" + langCode + ".qm" ) ) {
+ translator.load( QString("PCDM_") + langCode, appDir + "/i18n/" );
+ a.installTranslator(&translator);
+ Backend::log("Loaded Translation:" + appDir + "/i18n/PCDM_" + langCode + ".qm");
+ } else {
+ Backend::log("Could not find: " + appDir + "/i18n/PCDM_" + langCode + ".qm");
+ langCode = "";
+ }
- // Start a loop to watch for language changes
- for ( ;; )
- {
- QApplication a(argc,argv);
- Backend::openLogFile("/usr/local/share/PCDM/PCDM.log");
-
- // Check what directory our app is in
- QString appDir;
- if ( QFile::exists("/usr/local/bin/PCDM") ){
- appDir = "/usr/local/share/PCDM";
- } else {
- appDir = QCoreApplication::applicationDirPath();
- }
-
- QTranslator translator;
- QLocale mylocale;
- QString langCode = mylocale.name();
+ // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
+ QSplashScreen splash;
+ if(Theme::useSplashscreen()){
+ splash.setPixmap( QPixmap(Theme::splashscreen()) ); //load the splashscreen file
+ }
+ splash.show();
- if ( ! changeLang.isEmpty() )
- langCode = changeLang;
- if ( QFile::exists(appDir + "/i18n/PCDM_" + langCode + ".qm" ) ) {
- translator.load( QString("PCDM_") + langCode, appDir + "/i18n/" );
- a.installTranslator(&translator);
- Backend::log("Loaded Translation:" + appDir + "/i18n/PCDM_" + langCode + ".qm");
- } else {
- Backend::log("Could not find: " + appDir + "/i18n/PCDM_" + langCode + ".qm");
- langCode = "";
- }
+ PCDMgui w;
- // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
- QSplashScreen splash;
- if(Theme::useSplashscreen()){
- splash.setPixmap( QPixmap(Theme::splashscreen()) ); //load the splashscreen file
- }
- //QSplashScreen splash(pixmap);
- splash.show();
-
-
- PCDMgui w;
-
//Set the proper size on the Application
- if(Theme::isFullScreen() ){
- w.setWindowFlags(w.windowFlags() ^Qt::WindowSoftkeysVisibleHint);
- w.setWindowState(Qt::WindowFullScreen);
- }else{
- //Get the screen and desired geometries
- QRect dimensions = QApplication::desktop()->screenGeometry();
- int wid = dimensions.width(); // returns desktop width
- int hig = dimensions.height(); // returns desktop height
- int thHig = Theme::windowHeight(); // desired height
- int thWid = Theme::windowWidth(); //desired width
- //Sanity check the desired geometry versus the actual screen resolution
- if(thHig > hig){ thHig = hig; }
- if(thWid > wid){ thWid = wid; }
- // Center the Application
- w.setGeometry((wid/2) - (thWid/2), (hig/2) - (thHig/2), thWid, thHig);
- }
+ if(Theme::isFullScreen() ){
+ w.setWindowFlags(w.windowFlags() ^Qt::WindowSoftkeysVisibleHint);
+ w.setWindowState(Qt::WindowFullScreen);
+ }else{
+ //Get the screen and desired geometries
+ QRect dimensions = QApplication::desktop()->screenGeometry();
+ int wid = dimensions.width(); // returns desktop width
+ int hig = dimensions.height(); // returns desktop height
+ int thHig = Theme::windowHeight(); // desired height
+ int thWid = Theme::windowWidth(); //desired width
+ //Sanity check the desired geometry versus the actual screen resolution
+ if(thHig > hig){ thHig = hig; }
+ if(thWid > wid){ thWid = wid; }
+ // Center the Application
+ w.setGeometry((wid/2) - (thWid/2), (hig/2) - (thHig/2), thWid, thHig);
+ }
- w.show();
- splash.finish(&w);
+ w.show();
+ splash.finish(&w);
+ /*
returnCode = a.exec();
if ( QFile::exists(TMPLANGFILE) ) {
QFile lfile(TMPLANGFILE);
@@ -97,8 +96,12 @@
} else {
break;
}
-
+ */
+
+ //Check for whether to stay in the restart loop or not
+ if(Debug_Mode){
+ runRestartLoop = FALSE;
}
-
- return returnCode;
+ }
+ return returnCode;
}
Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp 2012-09-05 14:07:36 UTC (rev 18854)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp 2012-09-05 15:57:39 UTC (rev 18855)
@@ -9,6 +9,7 @@
QStringList displaynameList,usernameList,instXNameList,instXBinList,instXCommentList,instXIconList;
QString logFile;
+QString saveX,saveUsername;
QStringList Backend::getAvailableDesktops(){
if(instXNameList.isEmpty()){ loadXSessionsData(); }
@@ -69,32 +70,48 @@
bool allowed = verifyUsernamePassword(username, password);
if(allowed){
Backend::log("Username/Password Authorized");
- //Setup the system command to run the selected DE
- //QString cmd = "su -m "+username+" -c "+xBinary;
- startXSession(xBinary, username);
+ saveX=xBinary;
+ saveUsername=username;
}else{
- Backend::log("Username/Password not authorized");
+ Backend::log("Username/Password not authorized");
+ saveX.clear();
+ saveUsername.clear();
}
return allowed;
}
-void Backend::startXSession(QString cmd, QString username){
+void Backend::startXSession(){
+ //Check that there is a username/session that needs to be started
+ if( saveX.isEmpty() || saveUsername.isEmpty() ){
+ Backend::log("No information to start XSession - skipping");
+ return;
+ }
+ //Use the saved information and clear it
+ QString username = saveUsername;
+ QString cmd = saveX;
+ saveUsername.clear();
+ saveX.clear();
+
//Get the user's home directory
//Create the external process
QProcess* p = new QProcess(0);
//Setup the process environment
QProcessEnvironment environ = QProcessEnvironment::systemEnvironment(); //current environment
- //environ.insert("LOGNAME",username);
- //environ.insert("USERNAME",username);
+ Backend::log("System Environment: " + environ.toStringList().join(" ") );
+ environ.insert("LOGNAME",username);
+ environ.insert("USERNAME",username);
//environ.insert("HOME",homeDir);
//environ.insert("PATH",environ->value("PATH")+":"+homeDir+"/bin");
- //p->setProcessEnvironment(environ);
+ p->setProcessEnvironment(environ);
//Startup the process
- Backend::log("Current Environment: " + environ.toStringList().join(" ") );
+ Backend::log("Modified Environment: " + environ.toStringList().join(" ") );
Backend::log("Debug Mode: not starting DE");
- //p->startDetached(cmd);
-
+ p->start(cmd);
+ //Wait for the process to start before continuing
+ p->waitForStarted();
+ //Now Wait for the process to finish
+ p->waitForFinished(-1); //do not time-out
}
QString Backend::getUsernameFromDisplayname(QString dspname){
Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h 2012-09-05 14:07:36 UTC (rev 18854)
+++ pcbsd-projects/PCDM/pcdm-backend.h 2012-09-05 15:57:39 UTC (rev 18855)
@@ -41,12 +41,13 @@
static QStringList languages();
static void openLogFile(QString);
static void log(QString);
+ static void startXSession();
private:
static void loadXSessionsData();
static QStringList readXSessionsFile(QString, QString);
static bool verifyUsernamePassword(QString, QString);
- static void startXSession(QString,QString);
+
};
Modified: pcbsd-projects/PCDM/startPCDM
===================================================================
--- pcbsd-projects/PCDM/startPCDM 2012-09-05 14:07:36 UTC (rev 18854)
+++ pcbsd-projects/PCDM/startPCDM 2012-09-05 15:57:39 UTC (rev 18855)
@@ -1,4 +1,6 @@
#!/bin/sh
+# use the following command to startup this program
+# xinit /usr/local/bin/startPCDM -- :8
#Start XOrg and the normal PCDM GUI
xinit /usr/local/bin/PCDM -- :8
More information about the Commits
mailing list