[PC-BSD Commits] r4914 - pcbsd/trunk/lifePreserver

svn at pcbsd.org svn at pcbsd.org
Fri Nov 6 16:07:42 PST 2009


Author: kris
Date: 2009-11-06 16:07:42 -0800 (Fri, 06 Nov 2009)
New Revision: 4914

Added:
   pcbsd/trunk/lifePreserver/preserver.cpp
   pcbsd/trunk/lifePreserver/preserver.h
Modified:
   pcbsd/trunk/lifePreserver/lPreserve.pro
   pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
   pcbsd/trunk/lifePreserver/lifePreserverMain.h
   pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp
   pcbsd/trunk/lifePreserver/main.cpp
Log:

Updated life-preserver, setup a new PRESERVER class which will perform all the backend stuff for
accessing / setting preserver data



Modified: pcbsd/trunk/lifePreserver/lPreserve.pro
===================================================================
--- pcbsd/trunk/lifePreserver/lPreserve.pro	2009-11-06 14:30:05 UTC (rev 4913)
+++ pcbsd/trunk/lifePreserver/lPreserve.pro	2009-11-07 00:07:42 UTC (rev 4914)
@@ -5,9 +5,9 @@
 
 LIBS += -L/usr/local/kde4/lib -lkdecore -lkio -lkdeui -Ikdelibs
 
-HEADERS	+= lifePreserverMain.h lifePreserverWizard.h
+HEADERS	+= lifePreserverMain.h lifePreserverWizard.h preserver.h
 
-SOURCES	+= main.cpp lifePreserverMain.cpp lifePreserverWizard.cpp
+SOURCES	+= main.cpp lifePreserverMain.cpp lifePreserverWizard.cpp preserver.cpp
 
 RESOURCES += lPreserve.qrc
 

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-06 14:30:05 UTC (rev 4913)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.cpp	2009-11-07 00:07:42 UTC (rev 4914)
@@ -38,6 +38,7 @@
 #include "lifePreserverMain.h"
 #include "ui_lifePreserverWizard.h"
 #include "lifePreserverWizard.h"
+#include "preserver.h"
 #include "externals.h"
 
 /* KDE */
@@ -104,28 +105,19 @@
    close();
 }
 
-void lifePreserver::loadPreserverFromConf(QString confFilePath)
+void lifePreserver::loadPreserverFromConf(QString connectHost)
 {
-  QFile confFile(confFilePath);
-  if ( confFile.open( QIODevice::ReadOnly ) ) 
-  {
-     QTextStream stream( &confFile );
-     QString line;
-     while ( !stream.atEnd() ) {
-       line = stream.readLine(); // line of text excluding '\n'
-       // Check if we are on a profile line
-       if ( line.indexOf("host:") == 0  ) {
-         QString preserverHost = line.replace("host: ", "");
-         qDebug() << "Found Preserver: " << confFile.fileName();
-         QStringList itemTexts;
-         itemTexts << preserverHost << getPreserverLastBackup(preserverHost) << getPreserverFrequency(preserverHost)  << getPreserverStatus(preserverHost);
-         QTreeWidgetItem *newitem = new QTreeWidgetItem(treePreservers, itemTexts);
-         treePreservers->setCurrentItem(newitem);
-         slotCurrentTreePreserverChanged(newitem);
-        }
-     }
-  }
+  QString host, port;
+  PRESERVER myPreserver(connectHost);
+  host = myPreserver.getHost();
+  port.setNum(myPreserver.getPort());
 
+  QStringList itemTexts;
+  itemTexts << host << getPreserverLastBackup(host) << getPreserverFrequency(host)  << getPreserverStatus(host);
+  QTreeWidgetItem *newitem = new QTreeWidgetItem(treePreservers, itemTexts);
+  treePreservers->setCurrentItem(newitem);
+  slotCurrentTreePreserverChanged(newitem);
+
 }
 
 void lifePreserver::loadPreservers()
@@ -156,7 +148,7 @@
        if ( confFile.exists() )
        {
          // Load this preserver from its conf
-         loadPreserverFromConf(confFile.fileName());
+         loadPreserverFromConf(preserverDir);
        }
    }
 

Modified: pcbsd/trunk/lifePreserver/lifePreserverMain.h
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-06 14:30:05 UTC (rev 4913)
+++ pcbsd/trunk/lifePreserver/lifePreserverMain.h	2009-11-07 00:07:42 UTC (rev 4914)
@@ -42,7 +42,7 @@
    QString getPreserverLastBackup(QString host);
    QString getPreserverFrequency(QString host);
    QString getPreserverStatus(QString host);
-   void loadPreserverFromConf(QString confFilePath);
+   void loadPreserverFromConf(QString connectHost);
 
 signals:
 

Modified: pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp	2009-11-06 14:30:05 UTC (rev 4913)
+++ pcbsd/trunk/lifePreserver/lifePreserverWizard.cpp	2009-11-07 00:07:42 UTC (rev 4914)
@@ -35,6 +35,7 @@
 /* Local includes */
 #include "ui_lifePreserverWizard.h"
 #include "lifePreserverWizard.h"
+#include "preserver.h"
 #include "externals.h"
 
 /* KDE */
@@ -157,24 +158,10 @@
 void lifePreserverWizard::savePreserver()
 {
    QString connectString = lineUserName->text() + "@" + lineHostName->text();
+   PRESERVER myPreserver(connectString);
+   myPreserver.setHost(connectString);
+   myPreserver.setPort(22);
 
-   // Create our new Preserver Directory
-   QDir newPreserverDir;
-   newPreserverDir.setPath(LIFEPRESERVERSDIR + "/" + connectString);
-   if ( ! newPreserverDir.exists() )
-   {
-      newPreserverDir.mkpath(newPreserverDir.path());
-   }
-
-   // Save the config
-   QFile fileout( newPreserverDir.path() + "/settings.conf" );
-   if ( fileout.open( QIODevice::WriteOnly ) ) {
-       QTextStream streamout( &fileout );
-                   streamout << "host: " + connectString << "\n";
-                   streamout << "port: 22";
-       fileout.close();
-   }
-
 }
 
 bool lifePreserverWizard::doesPreserverExist()

Modified: pcbsd/trunk/lifePreserver/main.cpp
===================================================================
--- pcbsd/trunk/lifePreserver/main.cpp	2009-11-06 14:30:05 UTC (rev 4913)
+++ pcbsd/trunk/lifePreserver/main.cpp	2009-11-07 00:07:42 UTC (rev 4914)
@@ -3,6 +3,7 @@
 #include <kcmdlineargs.h>
 #include <qtranslator.h>
 #include <qlocale.h>
+#include "preserver.h"
 #include "lifePreserverMain.h"
 
 static const char description[] = I18N_NOOP("PC-BSD Life Preserver");



More information about the Commits mailing list