[PC-BSD Commits] r15974 - pcbsd/current/src-qt4/warden/src
svn at pcbsd.org
svn at pcbsd.org
Fri Mar 23 01:12:41 PDT 2012
Author: kris
Date: 2012-03-23 08:12:40 +0000 (Fri, 23 Mar 2012)
New Revision: 15974
Modified:
pcbsd/current/src-qt4/warden/src/dialogwarden.cpp
pcbsd/current/src-qt4/warden/src/dialogwarden.h
Log:
Load details of jails into GUI properly now, also auto-select the first
jail at startup
Modified: pcbsd/current/src-qt4/warden/src/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden/src/dialogwarden.cpp 2012-03-23 07:15:19 UTC (rev 15973)
+++ pcbsd/current/src-qt4/warden/src/dialogwarden.cpp 2012-03-23 08:12:40 UTC (rev 15974)
@@ -61,6 +61,13 @@
connect( statusTimer, SIGNAL(timeout()), this, SLOT( slotMonitorJailStatus() ) );
slotMonitorJailStatus();
+ // Start our monitor service for jail details
+ checkingDetails = false;
+ currentDetailsWorkingJail = "";
+ detailsTimer = new QTimer(this);
+ connect( detailsTimer, SIGNAL(timeout()), this, SLOT( slotMonitorJailDetails() ) );
+ slotMonitorJailDetails();
+
// Connect the rightclick slot
listJails->setContextMenuPolicy( Qt::CustomContextMenu);
@@ -141,8 +148,11 @@
cols << d[i] << d[i] << host;
else
cols << d[i] << d[i] << host;
- (void) new QTreeWidgetItem( listJails, cols );
+ QTreeWidgetItem *curItem = new QTreeWidgetItem( listJails, cols );
+ if ( ! listJails->currentItem() )
+ listJails->setCurrentItem(curItem);
+
// Save additional jail details into list
jD << d[i] << "Pending" << jType << jIPs;
jailDetails << jD;
@@ -150,6 +160,8 @@
} // end of loop
listJails->sortByColumn(1, Qt::AscendingOrder);
+ update();
+ slotCurrentJailChanged();
}
@@ -180,7 +192,119 @@
exit(0);
}
+void dialogWarden::slotCheckJailDetails()
+{
+ QString oldWorking = currentDetailsWorkingJail;
+ int found = 0;
+ // Mark that we are in the middle of checking the details
+ checkingDetails = true;
+
+ // Read in our iterator and start checking jail status
+ QTreeWidgetItemIterator it( listJails );
+ while (*it) {
+
+ if ( currentDetailsWorkingJail.isEmpty() ) {
+ currentDetailsWorkingJail = (*it)->text(0);
+ break;
+ }
+
+ if ( found == 1) {
+ currentDetailsWorkingJail = (*it)->text(0);
+ break;
+ }
+
+ if ( currentDetailsWorkingJail == (*it)->text(0) )
+ found = 1;
+
+ ++it;
+ }
+
+
+ // Are we ready to take a break?
+ if ( currentDetailsWorkingJail == oldWorking ) {
+ checkingDetails = false;
+ currentDetailsWorkingJail="";
+ return;
+ }
+ // Run the getUpdatesDir.sh script to rsync with master server
+ detailsProc = new QProcess( this );
+ QString program = ProgDir + "/scripts/backend/details.sh";
+ QStringList args;
+ args << currentDetailsWorkingJail;
+
+ qDebug() << "Checking for details to: " << currentDetailsWorkingJail;
+
+ // Connect the exited signal and start the process
+ connect( detailsProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotCheckDetailsReturn() ) );
+ detailsProc->start(program, args);
+}
+
+
+void dialogWarden::slotMonitorJailDetails()
+{
+ if ( checkingDetails == true) {
+ // Set our timer to check again
+ detailsTimer->start( 1000 * 60 * 10 );
+ } else {
+ currentDetailsWorkingJail = "";
+ slotCheckJailDetails();
+ // Set our timer to check again
+ detailsTimer->start( 1000 * 60 * 10 );
+ }
+
+}
+
+void dialogWarden::slotCheckDetailsReturn()
+{
+ QString line, size, ports, connections;
+
+ // Read the output and parse KPM
+ while ( detailsProc->canReadLine() )
+ {
+ line = detailsProc->readLine().simplified();
+ if ( line.indexOf("Disk Usage: ") == 0 ) {
+ line.replace("Disk Usage: ", "");
+ size = line;
+ continue;
+ }
+ if ( line.indexOf("Active Ports: ") == 0 ) {
+ line.replace("Active Ports: ", "");
+ ports = line;
+ continue;
+ }
+ if ( line.indexOf("Current Connections: ") == 0 ) {
+ line.replace("Current Connections: ", "");
+ connections = line;
+ continue;
+ }
+ }
+
+ // Now save details into our array
+ for (int i=0; i < jailDetails.count(); ++i) {
+ if ( jailDetails.at(i).at(0) != currentDetailsWorkingJail )
+ continue;
+ if ( jailDetails.at(i).at(1) == "Pending" ) {
+ QStringList tmpList = jailDetails.at(i);
+ tmpList << size << ports << connections;
+ tmpList.replace(1, "Complete");
+ jailDetails.replace(i, tmpList);
+ } else {
+ QStringList tmpList = jailDetails.at(i);
+ tmpList.replace(4, size);
+ tmpList.replace(5, ports);
+ tmpList.replace(6, connections);
+ jailDetails.replace(i, tmpList);
+ }
+ }
+
+ // See if we can update the GUI details
+ refreshJailDetailsView();
+
+ // Check the next jail, if there are any more left.
+ slotCheckJailDetails();
+}
+
void dialogWarden::slotCheckJailStatus()
{
QString oldWorking = currentStatusWorkingJail;
@@ -796,14 +920,11 @@
}
}
-void dialogWarden::slotCurrentJailChanged()
+void dialogWarden::refreshJailDetailsView()
{
if ( ! listJails->currentItem() )
return;
- groupJailTab->setTitle(tr("Working on jail:") + " " + listJails->currentItem()->text(0));
- groupJailTab->setEnabled(true);
-
// Load the details for this jail
for (int i=0; i < jailDetails.count(); ++i) {
if ( jailDetails.at(i).at(0) != listJails->currentItem()->text(0) )
@@ -817,13 +938,27 @@
if ( jailDetails.at(i).at(1) == "Pending" )
break;
+ labelSize->setText(jailDetails.at(i).at(4));
+ labelPorts->setText(jailDetails.at(i).at(5));
+ labelConnections->setText(jailDetails.at(i).at(6));
// Done loading all details
break;
-
}
- // Stop any pkg widget activity
+}
+
+void dialogWarden::slotCurrentJailChanged()
+{
+ if ( ! listJails->currentItem() )
+ return;
+
+ groupJailTab->setTitle(tr("Working on jail:") + " " + listJails->currentItem()->text(0));
+ groupJailTab->setEnabled(true);
+
+ refreshJailDetailsView();
+
+ // Stop any metaWidget activity
if ( widgetPackages->layout() != 0 )
pkgWidget->stop();
Modified: pcbsd/current/src-qt4/warden/src/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden/src/dialogwarden.h 2012-03-23 07:15:19 UTC (rev 15973)
+++ pcbsd/current/src-qt4/warden/src/dialogwarden.h 2012-03-23 08:12:40 UTC (rev 15974)
@@ -30,9 +30,15 @@
void readConfig();
void slotOpenConfig();
void slotExit();
+
void slotCheckJailStatus();
void slotMonitorJailStatus();
void slotCheckStatusReturn();
+
+ void slotCheckJailDetails();
+ void slotMonitorJailDetails();
+ void slotCheckDetailsReturn();
+
void slotJailRightClicked();
void slotStopJail();
void slotStartJail();
@@ -61,6 +67,7 @@
void slotCurrentJailChanged();
private:
+ void refreshJailDetailsView();
void runCommand( QString command );
QString ProgDir;
QString WorldSrc;
@@ -70,13 +77,18 @@
QString JailDir;
dialogConfig *configDialog;
QString currentStatusWorkingJail;
+ QString currentDetailsWorkingJail;
bool checkingStatus;
+ bool checkingDetails;
QTimer *statusTimer;
+ QTimer *detailsTimer;
QProcess *statusProc;
+ QProcess *detailsProc;
QString popupip;
QMenu *popup;
dialogImport *importDialog;
dialogWorking *workingDialog;
+ QProcess *getDetailsProc;
QProcess *stopJailProc;
QProcess *startJailProc;
QProcess *exportJailProc;
More information about the Commits
mailing list