[PC-BSD Commits] r3113 - pcbsd/trunk/kcmPBMsource
svn at pcbsd.org
svn at pcbsd.org
Thu Dec 18 11:29:15 PST 2008
Author: kris
Date: 2008-12-18 11:29:14 -0800 (Thu, 18 Dec 2008)
New Revision: 3113
Added:
pcbsd/trunk/kcmPBMsource/folder.png
pcbsd/trunk/kcmPBMsource/updaterDialog.cpp
pcbsd/trunk/kcmPBMsource/updaterDialog.h
pcbsd/trunk/kcmPBMsource/updaterDialog.ui
pcbsd/trunk/kcmPBMsource/working.png
Removed:
pcbsd/trunk/kcmPBMsource/PBM
pcbsd/trunk/kcmPBMsource/compile
Modified:
pcbsd/trunk/kcmPBMsource/PBM.pro
pcbsd/trunk/kcmPBMsource/PBM.qrc
pcbsd/trunk/kcmPBMsource/pbm.cpp
pcbsd/trunk/kcmPBMsource/pbm.h
pcbsd/trunk/kcmPBMsource/pbm.ui
Log:
Added our new version of the Add / Remove Programs tool, which now performs the online updates for both the system and PBIs, and works with the slimmed down SystemUpdaterTray tool
Modified: pcbsd/trunk/kcmPBMsource/PBM.pro
===================================================================
--- pcbsd/trunk/kcmPBMsource/PBM.pro 2008-12-18 14:55:53 UTC (rev 3112)
+++ pcbsd/trunk/kcmPBMsource/PBM.pro 2008-12-18 19:29:14 UTC (rev 3113)
@@ -5,14 +5,15 @@
LIBS += -L/PCBSD/local/kde4/lib -lkdecore -lkio -lkdeui -Ikdelibs
-HEADERS += kcm.h notroot.h pbm.h
+HEADERS += kcm.h notroot.h pbm.h updaterDialog.h
-SOURCES += kcm.cpp pbi.cpp notroot.cpp pbm.cpp
+SOURCES += kcm.cpp pbi.cpp notroot.cpp pbm.cpp updaterDialog.cpp
RESOURCES += PBM.qrc
FORMS = pbm.ui \
- notroot.ui
+ notroot.ui \
+ updaterDialog.ui
IMAGES = application.png \
NewLogoSmall.png
@@ -23,7 +24,7 @@
TRANSLATIONS = PBM_en_US.ts
-QT += qt3support
+QT += qt3support webkit
INCLUDEPATH += /PCBSD/includes /PCBSD/local/kde4/include
Modified: pcbsd/trunk/kcmPBMsource/PBM.qrc
===================================================================
--- pcbsd/trunk/kcmPBMsource/PBM.qrc 2008-12-18 14:55:53 UTC (rev 3112)
+++ pcbsd/trunk/kcmPBMsource/PBM.qrc 2008-12-18 19:29:14 UTC (rev 3113)
@@ -1,5 +1,7 @@
<RCC>
<qresource>
+ <file>working.png</file>
+ <file>folder.png</file>
<file>NewLogoSmall.png</file>
<file>demo.png</file>
<file>application.png</file>
Property changes on: pcbsd/trunk/kcmPBMsource/folder.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pcbsd/trunk/kcmPBMsource/pbm.cpp
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.cpp 2008-12-18 14:55:53 UTC (rev 3112)
+++ pcbsd/trunk/kcmPBMsource/pbm.cpp 2008-12-18 19:29:14 UTC (rev 3113)
@@ -1,10 +1,5 @@
-//Added by qt3to4:
-#include <Q3TextStream>
-#include <Q3ValueList>
-#include <QPixmap>
-#include <QTimer>
/***************************************************************************
- * Copyright (C) 2006 - 2007 PC-BSD Software *
+ * Copyright (C) 2006 - 2008 PC-BSD Software *
* kris at pcbsd.com *
* tim at pcbsd.org *
* *
@@ -27,10 +22,45 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
* OTHER DEALINGS IN THE SOFTWARE. *
***************************************************************************/
+/* QT4 */
+#include <Q3TextStream>
+#include <Q3ValueList>
+#include <QPixmap>
+#include <QTimer>
+#include <QTextStream>
+#include <QWebView>
+#include <QSettings>
+#include <QFileDialog>
+
+/* Local includes */
#include "ui_pbm.h"
#include "pbm.h"
#include "pbi.h"
+#include "updaterDialog.h"
+#include "ui_updaterDialog.h"
+/* KDE */
+#include <kjob.h>
+#include <kio/job.h>
+#include <kio/copyjob.h>
+#include <kurl.h>
+
+
+/* Change this to switch the default patch tmpdir */
+#define PATCHTMPDIR_DEFAULT "/usr/local/tmp"
+
+/* The Update STATUS Flags */
+#define SYSTEM_UP2DATE 0
+#define SYSTEM_UPDATE_AVAIL 1
+#define SYSTEM_CHECKING4UPDATES 4
+#define SYSTEM_UPDATING 5
+#define CHECK_FAILED 6
+
+#define PBI_UPDATED 0
+#define PBI_UPDATES_AVAIL 1
+#define PBI_CHECKING4UPDATES 2
+#define PBI_UPDATING 3
+
void PBM::ProgramInit()
{
qDebug("Application starting...");
@@ -52,14 +82,9 @@
QTimer::singleShot( 300, this, SLOT(PopulateList()) );
connect(fileWatcher, SIGNAL(dirty(const QString&)), this, SLOT(PopulateList()));
- // Loads the username
- QFile whoami( "/Programs/.tmp/whoami" );
- if ( whoami.open( QIODevice::ReadOnly ) ) {
- Q3TextStream stream3( &whoami );
- while ( !stream3.atEnd() ) {
- RealUserName = stream3.readLine();
- }
- }
+
+ // Get the username of the person running X
+ RealUserName = getlogin();
// Load the Components
@@ -67,6 +92,63 @@
// Connect our Component List Widget
connect(componentListbox, SIGNAL( currentRowChanged(int) ), this, SLOT(componentSelectionChangedSlot(int) ) );
+
+ /**********************************************************************/
+ // Add our connections and calls for the System Updater Service
+
+ // Load the program preferences
+ //loadUpdaterPrefs();
+
+ programstatus = SYSTEM_UP2DATE;
+ pbistatus = PBI_UPDATED;
+
+ // Create the status dialog
+ UpdaterStatusDialog = new updaterStatus();
+ // If the dialog was closed, update the context menu
+ UpdaterStatusDialog->programInit();
+ UpdaterStatusDialog->setModal(true);
+
+ // Start the monitor service for system updates
+ QTimer::singleShot(1000, this, SLOT(slotStartUpdateCheck()));
+
+ // Start the monitor service for PBI updates
+ QTimer::singleShot(2000, this, SLOT(slotStartPBIUpdateCheck()));
+
+ // Initialize some of our various variables
+ firstDownload = 0;
+ totalSeconds = 0;
+ downloadSize = 0;
+ totalSteps = 0;
+ attemptedRedownload = 0;
+ firstInstall = 0;
+ requiresSysReboot = 0;
+
+ // Hide the colums we don't want shown to teh user
+ listViewPBIUpdates->setColumnWidthMode( 1, Q3ListView::Manual );
+ listViewPBIUpdates->hideColumn( 1 );
+ listViewSysUpdates->setColumnWidthMode( 1, Q3ListView::Manual );
+ listViewSysUpdates->hideColumn( 1 );
+
+ // Start connecting our buttons with signals
+ connect(buttonRescanForSysUpdates, SIGNAL( clicked() ), this, SLOT(slotRescanForUpdates()) );
+ // Connect the pushViewDetails button
+ connect( pushDetails, SIGNAL( clicked() ), this, SLOT( slotViewDetailsClicked() ) );
+ connect( pushSelectSysAll, SIGNAL( clicked() ), this, SLOT( slotSelectAllSys() ) );
+ connect( pushSelectPBIAll, SIGNAL( clicked() ), this, SLOT( slotSelectAllPBI() ) );
+
+ // Load the Updater Prefs
+ loadUpdaterPrefs();
+
+ // Connect the Custom Tmpdir Checkbox
+ connect( checkTMPDIR, SIGNAL( clicked() ), this, SLOT( slotCustomTmpClicked() ) );
+ connect( pushTMPDIR, SIGNAL( clicked() ), this, SLOT( slotSelectCustomTmp() ) );
+
+ // Connect slots to emit signal when settings change
+ connect( lineTMPDIR, SIGNAL( textChanged(const QString &) ), this, SLOT( slotConfigChanged() ) );
+
+ connect( pushInstallSysUpdates, SIGNAL( clicked() ), this, SLOT( slotInstallUpdatesClicked() ) );
+
+
}
@@ -703,3 +785,1898 @@
}
return totalSize;
}
+
+
+/***********************************************************************************/
+/* Code to perform the system updates / checks */
+/***********************************************************************************/
+
+void PBM::slotStartUpdateCheck()
+{
+ QString SysUrl;
+ QString PatchSet;
+ QString Version;
+ QString Arch, line;
+
+ // Check if the system is doing updates right now, if it is, ignore the request
+ if ( programstatus == SYSTEM_UPDATING || programstatus == SYSTEM_CHECKING4UPDATES) {
+ return;
+ }
+
+
+ // Clear out the system list view box
+ listViewSysUpdates->clear();
+
+ // Update our dialog that we are looking for updates right now
+ QString newMsg = "<font color=\"#ff0000\">Checking for updates...</font>";
+ //UpdaterLabel->setText(newMsg);
+ textSysUpdatesLabel->setText(newMsg);
+
+ // Set the status to checking for system updates
+ programstatus = SYSTEM_CHECKING4UPDATES;
+
+ // Run our KIO Job to fetch the system-update patch data for this version of PC-BSD
+
+ // First, get some variables to figure out the full patch URL
+ QFile file( "/PCBSD/SystemUpdater/conf/sysupdate.conf" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ if ( line.find("UPDATESERVER: " ) == 0)
+ {
+ line.replace("UPDATESERVER: ", "");
+ SysUrl = line;
+ }
+
+ if ( line.find("PATCHSET: " ) == 0)
+ {
+ line.replace("PATCHSET: ", "");
+ PatchSet = line;
+ }
+ }
+ file.close();
+ }
+
+ QString command = "pbreg get /PC-BSD/Version";
+ Version = getLineFromCommandOutput(command);
+
+ command = "uname -p";
+ Arch = getLineFromCommandOutput(command);
+ if ( Arch.indexOf("i386") != -1 )
+ {
+ Arch = "i386";
+ }
+ if ( Arch.indexOf("amd64") != -1 )
+ {
+ Arch = "amd64";
+ }
+
+ if ( SysUrl.isEmpty() || PatchSet.isEmpty() || Version.isEmpty() || Arch.isEmpty() )
+ {
+ // Bad patch file?
+ QMessageBox::information( 0, tr("Error!"), tr("Error parsing sysupdate.conf!!!"), QMessageBox::Ok );
+ return;
+ }
+
+ QString patchfile = "patch-" + PatchSet + "-" + Version + "-" + Arch + ".tgz";
+ sysPatchsetTmpFile = "/PCBSD/tmp/" + patchfile;
+ QString patchurl = SysUrl + "/" + patchfile;
+
+ // Start our KIO copy now
+ sysFetchJob = KIO::file_copy( patchurl, sysPatchsetTmpFile, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(sysFetchJob, SIGNAL(result(KJob *)), this, SLOT(slotSysUpdateCheckFinished() ) );
+
+}
+
+
+
+
+
+
+
+void PBM::slotSysUpdateCheckFinished() {
+
+ QString command = "pbreg get /PC-BSD/Version";
+ QString Version = getLineFromCommandOutput(command);
+
+ // Now traverse the directory, see if we have updates.
+ readSysUpdates = new Q3Process( this );
+ readSysUpdates->addArgument( "sh");
+ readSysUpdates->addArgument( "/PCBSD/SystemUpdater/bin/readSysUpdates.sh");
+ readSysUpdates->addArgument( Version );
+
+ // Check to see if the update download was successful and warn if not
+ if ( sysFetchJob->error() != 0 )
+ {
+
+ QMessageBox::warning( 0, tr("Update Error!"), tr("Could not contact the PC-BSD update server! Please check your internet connection or proxy settings under Configuration"), QMessageBox::Ok );
+
+ } else {
+ // Add the patchdata URL
+ readSysUpdates->addArgument(sysPatchsetTmpFile);
+ }
+
+ // Connect the exited signal and start the process
+ connect( readSysUpdates, SIGNAL(processExited()), this, SLOT(slotReadSystemUpdates() ) );
+ if ( ! readSysUpdates->start() ) {
+ QMessageBox::information( 0, tr("Error!"), tr("Error running updates2 script! "), QMessageBox::Ok );
+ }
+
+
+
+}
+
+
+
+
+// Read in the available system updates
+void PBM::slotReadSystemUpdates() {
+
+ QString line;
+ QString tmp;
+ int key = 0;
+ QString newMsg;
+
+ if ( readSysUpdates->exitStatus() == 0 )
+ {
+
+ // Clear out the system list view box
+ listViewSysUpdates->clear();
+
+ // Open our config file, and read in the data
+ QFile file( "/tmp/.pcbsdavailupdates" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ if ( line.find("PATCH:" ) == 0)
+ {
+ line.replace("PATCH: ", "");
+ loadPatchData(line, key);
+ newMsg = SysUpdateName[key] + " - " + SysUpdateSize[key] + "MB (" + SysUpdateDate[key] + ")";
+ Q3CheckListItem *item = new Q3CheckListItem ( listViewSysUpdates, newMsg, Q3CheckListItem::CheckBox ) ;
+ item->setText(1, tmp.setNum(key) );
+ //listViewSysUpdates->insertSysListBoxItem( newMsg, tmp.setNum(key), SysUpdateAlone[key], SysUpdateReboot[key] );
+ key++;
+ }
+
+
+
+ }
+ file.close();
+
+
+ }
+
+ programstatus = SYSTEM_UPDATE_AVAIL;
+ textSysUpdatesLabel->setText(tr("The following system updates are available:"));
+ UpdaterLabel->setText("");
+
+
+ } else {
+ // We have no updates available, indicate that now.
+ programstatus = SYSTEM_UP2DATE;
+ textSysUpdatesLabel->setText(tr("The system is fully updated!"));
+ // Clear out the system list view box
+ listViewSysUpdates->clear();
+ UpdaterLabel->setText("");
+
+ }
+
+
+
+
+
+}
+
+void PBM::loadPatchData(QString patchFile, int patchNum) {
+ QString line;
+
+ // Save the file name this patch is being read from, we'll need it during the install
+ SysUpdatePatchFile[patchNum]=patchFile;
+
+ // Open our config file, and read in the data
+ QFile file( "/PCBSD/SystemUpdater/system-updates/available/" + patchFile );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+
+ if ( line.find("Name:" ) == 0)
+ {
+ line.replace("Name: ", "");
+ SysUpdateName[patchNum] = line;
+ }
+
+ if ( line.find("Date:" ) == 0)
+ {
+ line.replace("Date: ", "");
+ SysUpdateDate[patchNum] = line;
+ }
+
+ if ( line.find("MD5:" ) == 0)
+ {
+ line.replace("MD5: ", "");
+ SysUpdateMD5[patchNum] = line;
+ }
+
+ if ( line.find("Size:" ) == 0)
+ {
+ line.replace("Size: ", "");
+ SysUpdateSize[patchNum] = line;
+ }
+
+ if ( line.find("URL:" ) == 0)
+ {
+ line.replace("URL: ", "");
+ SysUpdateURL[patchNum] = line;
+ }
+
+ if ( line.find("StandAlone:" ) == 0)
+ {
+ line.replace("StandAlone: ", "");
+ SysUpdateAlone[patchNum] = line;
+ }
+
+ if ( line.find("RequiresReboot:" ) == 0)
+ {
+ line.replace("RequiresReboot: ", "");
+ SysUpdateReboot[patchNum] = line;
+ }
+
+
+ if ( line.find("DetailsURL:" ) == 0)
+ {
+ line.replace("DetailsURL: ", "");
+ SysUpdateDetailsURL[patchNum] = line;
+ }
+
+ }
+
+ }
+
+
+
+}
+
+
+// Start our check to ensure we have enough free disk space for these patches
+void PBM::slotStartCheckAvailSysSpace()
+{
+ QString line, tmp, installLoc, CheckDFParts[50], command;
+ int i = 0, matchLength = 0, selectedPart = 0, z = 0, progSize = 0;
+ bool ok;
+
+ // Lets set the patch tmpdir variable now
+ if ( useCustomTmpDir )
+ {
+ patchTmpDir = customTmpDir;
+ } else {
+ patchTmpDir = PATCHTMPDIR_DEFAULT;
+ }
+
+ // Make sure this tmpdir exists
+ system("mkdir -p '" + patchTmpDir + "' >/dev/null 2>/dev/null");
+
+
+
+ // Get the output of the .df command
+ command = "df -m | grep -v '^devfs' | grep -v 'linprocfs' | grep -v '^Filesystem' | grep -v ' /proc' | grep -v ' /tmp' > '" + patchTmpDir + "/.dfoutput'";
+ FILE *filecmd = popen(command,"r");
+ pclose(filecmd);
+
+
+ // Figure out the size we'll need to install these patches
+ workingSysUpdates.clear();
+ QStringList ItemList;
+
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ ItemList += it.current()->text(1);
+ }
+ ++it;
+ }
+
+ workingSysUpdates = ItemList;
+
+ for ( QStringList::Iterator it = workingSysUpdates.begin(); it != workingSysUpdates.end(); ++it ) {
+ i = (*it).toInt();
+ progSize = progSize + SysUpdateSize[i].toInt();
+ }
+
+ // Tripple the space required so we have enough room to decompress and such
+ progSize = progSize * 3;
+
+
+ i = 0;
+ // Open our df file, and read it line-by-line
+ QFile file( patchTmpDir + "/.dfoutput" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ tmp = stream.readLine(); // line of text excluding '\n'
+ CheckDFParts[i] = tmp.simplifyWhiteSpace();
+
+ //QMessageBox::critical( 0, tr("DF"), "Read Line:" + CheckDFParts[i], QMessageBox::Ok);
+ i++;
+ }
+ // Make sure the last in our array is empty
+ CheckDFParts[i]="";
+ file.close();
+ file.remove();
+ }
+
+
+ if ( useCustomTmpDir )
+ {
+ installLoc = customTmpDir;
+ } else {
+ installLoc = PATCHTMPDIR_DEFAULT;
+ }
+
+ // Now determine which partition we have selected
+ i = 0;
+ while (! CheckDFParts[i].isEmpty() )
+ {
+ tmp = CheckDFParts[i];
+ tmp = tmp.section( ' ', 5, 5);
+ //QMessageBox::critical( 0, tr("DF"), "Read Line:" + tmp, QMessageBox::Ok);
+
+ // check if we have a potential match for the selected directory
+ if ( installLoc.find(tmp) == 0)
+ {
+ if ( matchLength <= tmp.length() )
+ {
+ // We have a new better match, save it
+ selectedPart = i;
+
+ // Save our new matchLength
+ matchLength = tmp.length();
+ }
+ }
+
+ i++;
+ }
+
+ // Now check if we have enough space here to install our patches
+ z = CheckDFParts[selectedPart].section(' ', 3, 3).toInt(&ok);
+ if ( ok)
+ {
+ if ( (z - progSize) <= 1 )
+ {
+ // Not enough room, warn the user how much they will need
+ QMessageBox::critical( 0, tr("System Updater"), tr("Error: Not enough free disk space for these updates! You will need " + tmp.setNum(progSize) + "MB to install the selected updates. Please select a different partition or free up some space to continue."), QMessageBox::Ok );
+ return;
+ } else {
+ // We have enough free space, lets do this
+ slotStartSystemUpdate();
+ }
+
+ } else {
+ QMessageBox::critical( 0, tr("ERROR:"), tr("Error determining remaining disk space!"), QMessageBox::Ok);
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+// Now start the actual update process
+void PBM::slotStartSystemUpdate()
+{
+ // The user is ready to start some system updates
+
+
+ // Lets set the patch tmpdir variable now
+ if ( useCustomTmpDir )
+ {
+ patchTmpDir = customTmpDir;
+ } else {
+ patchTmpDir = PATCHTMPDIR_DEFAULT;
+ }
+
+ // Make sure this tmpdir exists
+ system("mkdir -p '" + patchTmpDir + "' >/dev/null 2>/dev/null");
+
+ // Change the program status and update the tray icon
+ programstatus = SYSTEM_UPDATING;
+
+ // Clear out the reboot status flag
+ requiresSysReboot = 0;
+
+ // Get our list of items we need to update
+ workingSysUpdates.clear();
+ QStringList ItemList;
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ ItemList += it.current()->text(1);
+ }
+ ++it;
+ }
+
+ workingSysUpdates = ItemList;
+
+
+ // Clear out the old update list
+ UpdaterStatusDialog->clearWorkingItems();
+ UpdaterStatusDialog->setUpdatingSystem();
+ UpdaterStatusDialog->show();
+
+ // Add the items we will be updating to the statusDialog
+ int workingItem;
+ bool ok;
+ QString tmp;
+ currentSysWorkingItem = -1;
+ int rebootFlag = 0;
+
+ for ( QStringList::Iterator it = workingSysUpdates.begin(); it != workingSysUpdates.end(); ++it ) {
+ if (currentSysWorkingItem == -1 ) {
+ currentSysWorkingItem = (*it).toInt(&ok);
+ }
+
+ workingItem = (*it).toInt(&ok);
+ tmp=tr("Pending download");
+ UpdaterStatusDialog->insertStatusListBoxItem(SysUpdateName[workingItem], SysUpdateSize[workingItem] + "MB", tmp, (*it));
+ if (SysUpdateReboot[workingItem] == "YES" ) {
+ rebootFlag = 1;
+ }
+ }
+
+ if ( rebootFlag == 1 )
+ {
+
+ QMessageBox::warning( 0, tr("Online Update"), tr("One or more updates will require a reboot. You will be prompted to restart after the update is finished."), QMessageBox::Ok );
+ requiresSysReboot = 1;
+ }
+
+ // Start downloading the updates
+ firstDownload = 1;
+ attemptedRedownload = 0;
+ slotDownloadSysUpdate();
+
+
+}
+
+
+
+
+
+
+
+void PBM::slotDownloadSysUpdate()
+{
+ QString status, id, tmp, command;
+ bool startNewDownload = false, ok;
+ int getNextItem = 0;
+
+
+ // Check if we need to start the next download
+ if ( firstDownload == 0)
+ {
+
+ // Update the status on the previous download to finished
+ //status = tr("Install pending...");
+ //UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentSysWorkingItem) );
+
+ for ( QStringList::Iterator it = workingSysUpdates.begin(); it != workingSysUpdates.end(); ++it ) {
+
+ // If we just passed the last item grab the next one to start
+ if ( getNextItem == 1) {
+ currentSysWorkingItem = (*it).toInt(&ok);
+ startNewDownload = true;
+ break;
+ }
+
+ if (currentSysWorkingItem == (*it).toInt(&ok) ) {
+ getNextItem = 1;
+
+ }
+
+
+ }
+
+ // Now its time to start the install of the downloaded patches
+ if ( ! startNewDownload )
+ {
+ tmp = tr("Preparing to install...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus( tmp );
+ firstInstall =1;
+
+ // Add the items we will be updating to the statusDialog
+ int workingItem;
+ bool ok;
+ QString tmp;
+ currentSysWorkingItem = -1;
+
+ for ( QStringList::Iterator it = workingSysUpdates.begin(); it != workingSysUpdates.end(); ++it ) {
+ if (currentSysWorkingItem == -1 ) {
+ currentSysWorkingItem = (*it).toInt(&ok);
+ }
+
+ workingItem = (*it).toInt(&ok);
+ tmp=tr("Pending install");
+ id.setNum(workingItem);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+ }
+
+ // Start the installation now!
+ slotStartSysInstall();
+
+ return;
+ }
+
+ // Set our flag that this is the first attempt to download this file
+ attemptedRedownload = 0;
+
+ } else {
+ firstDownload = 0;
+ }
+
+
+
+ // Update the
+ if ( attemptedRedownload == 1 )
+ {
+
+ status=tr("Data verify failed... Attempting to re-download...");
+ } else {
+ status=tr("Downloading...");
+ }
+
+ id.setNum(currentSysWorkingItem);
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id);
+
+ // We have started the first download now, set our flag
+ //firstDownload = 0;
+
+
+ // Set our label showing whats going on
+ status = tr("Downloading updates...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus(status);
+
+ UpdaterStatusDialog->setProgressTotalSteps(100);
+
+ command = "rm '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma'";
+ FILE *file = popen(command,"r");
+ pclose(file);
+
+ // Make sure that any old patch is removed first
+ QFile tmpfile( patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma");
+ if ( tmpfile.exists() )
+ {
+ tmpfile.remove();
+ }
+
+
+ copyJob = KIO::file_copy(SysUpdateURL[currentSysWorkingItem], patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma", -1, KIO::HideProgressInfo | KIO::Overwrite);
+
+ connect(copyJob, SIGNAL(totalSize(KJob*, qulonglong)), UpdaterStatusDialog, SLOT(slotJobUpdateTotalSize( KJob*, qulonglong)));
+ connect(copyJob, SIGNAL(percent(KJob*, unsigned long)), UpdaterStatusDialog, SLOT(slotJobSetPercent(KJob*, unsigned long)));
+ connect(copyJob, SIGNAL(speed(KJob*, unsigned long)), UpdaterStatusDialog, SLOT(slotJobUpdateSpeed( KJob*, unsigned long)));
+ connect(copyJob, SIGNAL(processedSize(KJob*, qulonglong)), UpdaterStatusDialog, SLOT(slotJobUpdateProcessedSize( KJob*, qulonglong)));
+ connect(copyJob, SIGNAL(result(KJob *)), this, SLOT(slotStartCheckSysMD5()));
+
+
+}
+
+void PBM::slotStartCheckSysMD5()
+{
+
+ QString tmp;
+
+ // This function starts the internal checksum to ensure the update is intact
+
+ tmp = tr("Checking data integrity...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus( tmp );
+
+ // Make the checksum.sh script now
+ QFile file4( patchTmpDir + "/.syschecksum.sh" );
+ if ( file4.open( IO_WriteOnly ) ) {
+ QTextStream stream4( &file4 );
+ stream4 << "cat '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma' | md5 >&1";
+ file4.close();
+ }
+
+ checksumProc = new Q3Process( this );
+ checksumProc->addArgument( "sh" );
+ checksumProc->addArgument( patchTmpDir + "/.syschecksum.sh" );
+ //connect( checksumProc, SIGNAL(processExited()), this, SLOT( slotChecksumFinished() ) );
+ connect( checksumProc, SIGNAL(readyReadStdout()), this, SLOT(slotReadSysMD5() ) );
+ if ( !checksumProc->start() ) {
+ QMessageBox::information( 0, tr("Error!"), tr("Error running internal checksum Script! "), QMessageBox::Ok );
+ }
+
+
+ //QTimer::singleShot( 3000, this, SLOT(slotDownloadSysUpdate()) );
+
+}
+
+
+
+
+
+
+
+
+void PBM::slotReadSysMD5()
+{
+ QString tmp, id, command;
+
+ // Read the line, then check if it is a match
+ tmp = checksumProc->readLineStdout();
+
+ if ( tmp != SysUpdateMD5[currentSysWorkingItem] )
+ {
+
+ // Remove the bad patch
+ command = "rm '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma'";
+ FILE *file = popen(command,"r");
+ pclose(file);
+
+ if ( attemptedRedownload == 1 )
+ {
+
+ // Show the updater status dialog, so user can see any errors
+ UpdaterStatusDialog->show();
+
+ QMessageBox::critical( 0, tr("Online Update"), tr("An error occured while downloading. Please check your connection or try again later."), QMessageBox::Ok );
+
+ if ( UpdaterStatusDialog->isShown() )
+ {
+ UpdaterStatusDialog->hide();
+ }
+
+ programstatus = CHECK_FAILED;
+ // Try the update check again
+ slotStartUpdateCheck();
+ return;
+
+ }
+
+ attemptedRedownload = 1;
+
+
+
+ // Set our flag to re-try the same PBI
+ firstDownload = 1;
+ // Re-Start the next download
+ slotDownloadSysUpdate();
+
+
+ } else {
+
+ tmp=tr("Data verified... Preparing to Install...");
+ id.setNum(currentSysWorkingItem);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+
+ // Start the next download
+ slotDownloadSysUpdate();
+ }
+
+}
+
+
+
+
+
+
+
+// Start the actual install now
+void PBM::slotStartSysInstall()
+{
+ QString status, id, tmp;
+ bool startNewInstall = false, ok;
+ int getNextItem = 0;
+
+ // Check if we need to start the next install
+ if ( firstInstall == 0)
+ {
+
+ // Update the status on the previous download to finished
+ status = tr("Install complete!");
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentSysWorkingItem) );
+
+ for ( QStringList::Iterator it = workingSysUpdates.begin(); it != workingSysUpdates.end(); ++it ) {
+
+ // If we just passed the last item grab the next one to start
+ if ( getNextItem == 1) {
+ currentSysWorkingItem = (*it).toInt(&ok);
+ startNewInstall = true;
+ break;
+ }
+
+ if (currentSysWorkingItem == (*it).toInt(&ok) ) {
+ getNextItem = 1;
+
+ }
+
+
+ }
+
+ if ( ! startNewInstall )
+ {
+ // The updates are finished!
+
+ if ( requiresSysReboot == 1)
+ {
+ QMessageBox::information( 0, tr("Online Update"), tr("Updates successfully installed! Your system will need to reboot to finish."), QMessageBox::Ok);
+ } else {
+ QMessageBox::information( 0, tr("Online Update"), tr("Updates successfully installed!"), QMessageBox::Ok );
+ }
+
+ // Hide our Updater Status Dialog, all done with it!
+ UpdaterStatusDialog->hide();
+
+ // Reset the program status to recheck for any more updates
+ programstatus = CHECK_FAILED;
+
+ // Check for updates again now
+ slotStartUpdateCheck();
+
+ // Check if the user had any PBI's they wanted to install and do it
+ int updateChecked = 0;
+ QStringList ItemList;
+ Q3ListViewItemIterator it( listViewPBIUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ updateChecked = 1;
+ }
+ ++it;
+ }
+
+ if ( updateChecked == 1)
+ {
+ // We have some PBIs the user wants to upgrade, lets do it now!
+ slotStartPBIUpgrades();
+ }
+
+ return;
+ }
+
+
+ } else {
+ firstInstall = 0;
+ }
+
+ // Update the status
+ tmp=tr("Installing");
+ id.setNum(currentSysWorkingItem);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+
+ // Reset the progress bar
+ UpdaterStatusDialog->setProgressTotalSteps(5);
+ UpdaterStatusDialog->setProgressSteps(0);
+
+ tmp = tr("Starting installation...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus( tmp );
+
+
+ // Make the extract script now
+ QFile file4( patchTmpDir + "/.extractsys.sh" );
+ if ( file4.open( IO_WriteOnly ) ) {
+ QTextStream stream4( &file4 );
+ stream4 << "#!/bin/sh\n";
+ stream4 << "mkdir -p '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "'\n";
+ stream4 << "echo \"" + SysUpdatePatchFile[currentSysWorkingItem] + "\" > '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) +"/patchFile'\n";
+ stream4 << "lzma -so d '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma' | tar xvC '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "' -f - >&1";
+ file4.close();
+ }
+
+ // start the extraction process
+ extractProc = new Q3Process( this );
+ extractProc->addArgument( "sh" );
+ extractProc->addArgument( patchTmpDir + "/.extractsys.sh" );
+
+ connect( extractProc, SIGNAL(processExited()), this, SLOT(slotSysExtractFinished() ) );
+
+ if ( ! extractProc->start() ) {
+
+ QMessageBox::critical( 0, tr("Online Update"), tr("An error occured while extracting. Please try again later."), QMessageBox::Ok );
+ exit(15);
+ }
+
+
+}
+
+
+
+
+
+
+
+// The extraction finished for this patch, now install it or prep it for install at next restart
+void PBM::slotSysExtractFinished()
+{
+ QString tmp;
+
+ // Make the checksum.sh script now
+ QFile file4( patchTmpDir + "/.installsys.sh" );
+ if ( file4.open( IO_WriteOnly ) ) {
+ QTextStream stream4( &file4 );
+ stream4 << "#!/bin/sh\n";
+ stream4 << "rm '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + ".lzma'\n\n";
+ stream4 << "cd '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "'\n";
+ stream4 << "PATCHDIR=\"" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "\" ; export PATCHDIR\n";
+ stream4 << "cd \"${PATCHDIR}\"\n";
+ stream4 << "sh update.sh >&1 2>&1\n";
+ stream4 << "if [ \"$?\" = \"0\" ]\n";
+ stream4 << "then\n";
+ stream4 << " cp /PCBSD/SystemUpdater/system-updates/available/" + SysUpdatePatchFile[currentSysWorkingItem] + " /PCBSD/SystemUpdater/system-updates/installed/" + SysUpdatePatchFile[currentSysWorkingItem] + "\n";
+ stream4 << " rm -rf '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "'\n";
+ stream4 << " rm '" + patchTmpDir + "/.extractsys.sh'\n";
+ stream4 << " rm '" + patchTmpDir + "/.installsys.sh'\n";
+ stream4 << " rm '" + patchTmpDir + "/.syschecksum.sh'\n";
+ stream4 << " exit 0\n";
+ stream4 << "else\n";
+ stream4 << " rm -rf '" + patchTmpDir + "/patch" + tmp.setNum(currentSysWorkingItem) + "'\n";
+ stream4 << " rm '" + patchTmpDir + "/.extractsys.sh'\n";
+ stream4 << " rm '" + patchTmpDir + "/.installsys.sh'\n";
+ stream4 << " rm '" + patchTmpDir + "/.syschecksum.sh'\n";
+ stream4 << " exit 1\n";
+ stream4 << "fi\n";
+ file4.close();
+ }
+
+ // start the extraction process
+ installProc = new Q3Process( this );
+ installProc->addArgument( "sh" );
+ installProc->addArgument( patchTmpDir + "/.installsys.sh" );
+
+ connect( installProc, SIGNAL(processExited()), this, SLOT(slotSysInstallFinished() ) );
+ connect( installProc, SIGNAL(readyReadStdout ()), this, SLOT(slotReadInstallScriptOutput() ) );
+
+
+ if ( ! installProc->start() ) {
+ QMessageBox::critical( 0, tr("Online Update"), tr("An error occured while installing. Please try again later."), QMessageBox::Ok );
+ exit(15);
+ }
+
+}
+
+
+
+
+
+
+
+void PBM::slotSysInstallFinished()
+{
+ // Check if we need to run any other installs
+ slotStartSysInstall();
+}
+
+
+
+
+
+
+
+
+void PBM::slotReadInstallScriptOutput()
+{
+ // Function reads the output of script
+ // Script is able to set the number of steps for the progress bar
+ // Script is able to echo messages to be displayed in the progressTextDialog
+
+ QString tmp;
+ QString value;
+ bool ok;
+ int num;
+
+ while (installProc->canReadLineStdout() )
+ {
+ tmp = installProc->readLineStdout();
+
+ if ( tmp.find("TOTALSTEPS:" ) == 0)
+ {
+ value = tmp.replace("TOTALSTEPS: ", "");
+ num = value.toInt(&ok);
+ if ( ok ) {
+ UpdaterStatusDialog->setProgressTotalSteps(num);
+ }
+ }
+
+ if ( tmp.find("SETSTEPS:" ) == 0)
+ {
+ value = tmp.replace("SETSTEPS: ", "");
+ num = value.toInt(&ok);
+ if ( ok ) {
+ UpdaterStatusDialog->setProgressSteps(num);
+ }
+ }
+
+ if ( tmp.find("MSG:" ) == 0)
+ {
+ value = tmp.replace("MSG: ", "");
+ value.truncate(70);
+ UpdaterStatusDialog->setLabelSysUpdateStatus(value);
+ }
+
+ }
+
+}
+
+
+
+
+void PBM::slotOpenSysDetails(int id)
+{
+ QDialog *viewer = new QDialog(this);
+ QGridLayout *layout = new QGridLayout(viewer);
+ QWebView *view = new QWebView(viewer);
+
+ view->load(QUrl(SysUpdateDetailsURL[id]));
+ layout->addWidget(view);
+ view->setLayout(layout);
+ view->show();
+
+ viewer->setSizeGripEnabled(true);
+ viewer->resize(1024,600);
+ viewer->show();
+}
+
+
+
+
+
+
+QString PBM::getLineFromCommandOutput( QString command )
+{
+ FILE *file = popen(command,"r");
+
+ char buffer[100];
+
+ QString line = "";
+ char firstChar;
+
+ if ((firstChar = fgetc(file)) != -1){
+ line += firstChar;
+ line += fgets(buffer,100,file);
+ }
+
+
+ pclose(file);
+
+
+ return line;
+}
+
+void PBM::slotRescanForUpdates()
+{
+ // Start the monitor service for system updates
+ QTimer::singleShot(200, this, SLOT(slotStartUpdateCheck()));
+
+ // Start the monitor service for PBI updates
+ QTimer::singleShot(400, this, SLOT(slotStartPBIUpdateCheck()));
+
+}
+
+void PBM::slotViewDetailsClicked()
+{
+ if ( listViewSysUpdates->currentItem() != 0 )
+ {
+ bool ok;
+ int idnum = listViewSysUpdates->currentItem()->text(1).toInt(&ok);
+ slotOpenSysDetails(idnum);
+ }
+}
+
+void PBM::slotSelectAllSys()
+{
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ ( (Q3CheckListItem*)it.current() )->setOn(TRUE);
+ ++it;
+ }
+}
+
+void PBM::slotSelectAllPBI()
+{
+ Q3ListViewItemIterator it( listViewPBIUpdates );
+ while ( it.current() ) {
+ ( (Q3CheckListItem*)it.current() )->setOn(TRUE);
+ ++it;
+ }
+
+}
+
+
+void PBM::slotSaveUpdaterPrefs() {
+ // Save the user preferences for the System Updater
+ QSettings settings("PCBSD");
+
+ // Check if the user has enabled a custom tmpdir
+ useCustomTmpDir = checkTMPDIR->isChecked();
+ settings.writeEntry( "/PC-BSD/SystemUpdater/useCustomTmpDir", useCustomTmpDir );
+
+ // Load the custom tmpdir string
+ customTmpDir = lineTMPDIR->text();
+ settings.writeEntry( "/PC-BSD/SystemUpdater/customTmpDir", customTmpDir );
+
+ setUseCustomTmp( useCustomTmpDir );
+
+}
+
+void PBM::loadUpdaterPrefs() {
+ // Load the user preferences for the System Updater
+ QSettings settings("PCBSD");
+
+ // Check if we are using a custom tmpdir
+ useCustomTmpDir = settings.readBoolEntry( "/PC-BSD/SystemUpdater/useCustomTmpDir", false );
+ setUseCustomTmp( useCustomTmpDir );
+
+ // Load a custom tmpdir
+ customTmpDir= PATCHTMPDIR_DEFAULT;
+ customTmpDir = settings.value("/PC-BSD/SystemUpdater/customTmpDir", customTmpDir).toString();
+ lineTMPDIR->setText( customTmpDir );
+
+}
+
+void PBM::setUseCustomTmp( bool enabled )
+{
+ checkTMPDIR->setChecked(enabled);
+ lineTMPDIR->setEnabled(enabled);
+ pushTMPDIR->setEnabled(enabled);
+}
+
+
+void PBM::slotCustomTmpClicked()
+{
+ if ( checkTMPDIR->isChecked() )
+ {
+ lineTMPDIR->setEnabled(true);
+ pushTMPDIR->setEnabled(true);
+ } else {
+ lineTMPDIR->setEnabled(false);
+ pushTMPDIR->setEnabled(false);
+ }
+
+ slotSaveUpdaterPrefs();
+}
+
+void PBM::slotSelectCustomTmp()
+{
+
+ QString newDir = QFileDialog::getExistingDirectory(
+ "/",
+ this,
+ tr("Select Temp directory"),
+ tr("Select Temp directory"),
+ TRUE );
+
+ // Check if the user just hit cancel
+ if ( newDir.isEmpty() )
+ {
+ return;
+ }
+
+ lineTMPDIR->setText(newDir);
+ slotSaveUpdaterPrefs();
+}
+
+void PBM::slotInstallUpdatesClicked()
+{
+ // The user has requested to perform some updates!
+ // Lets first check for any selected system updates, and do them first.
+ int updateChecked = 0;
+
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ updateChecked =1;
+ }
+ ++it;
+ }
+
+ // We have a system update, lets check and then start the install for it
+ if ( updateChecked == 1) {
+ // Make sure we don't have any updates which need to be installed alone
+ slotCheckSysUpdatesFlags();
+
+ // Start the system update now!
+ slotStartSystemUpdate();
+ } else {
+ // No System updates were selected, lets check for any PBI updates and do that.
+ QStringList ItemList;
+ Q3ListViewItemIterator it( listViewPBIUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ updateChecked = 1;
+ }
+ ++it;
+ }
+
+ if ( updateChecked == 1)
+ {
+ // We have some PBIs the user wants to upgrade, lets do it now!
+ slotStartPBIUpgrades();
+ } else {
+ // User clicked to install, but no updates are checked!
+ QMessageBox::warning( this, tr("Error"), tr("You must select an update to install!") );
+ }
+ }
+
+}
+
+
+void PBM::slotCheckSysUpdatesFlags()
+{
+ QString tmp;
+ QString keyAlone = "", keyText="";
+ int otherItemsChecked = 0;
+ bool ok;
+
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ // Check if this item is set to standalone
+ if ( SysUpdateAlone[it.current()->text(1).toInt(&ok)] == "YES" && keyAlone.isEmpty() )
+ {
+ keyAlone = it.current()->text(1);
+ keyText = it.current()->text(0);
+ } else {
+ otherItemsChecked = 1;
+ }
+ }
+ ++it;
+ }
+
+ if (! keyAlone.isEmpty() && otherItemsChecked)
+ {
+ QMessageBox::warning( this, tr("Error!"), tr("The update '") + keyText + tr("' must be installed by itself. All other items will be unselected.") );
+
+ Q3ListViewItemIterator it( listViewSysUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ // Check if this item is set to standalone
+ if ( it.current()->text(1) != keyAlone )
+ {
+ ( (Q3CheckListItem*)it.current() )->setOn(FALSE);
+ }
+ }
+ ++it;
+ }
+
+
+ }
+
+}
+
+/***********************************************************************************/
+/* Code to perform the PBI updates / checks */
+/***********************************************************************************/
+
+void PBM::slotStartPBIUpdateCheck()
+{
+
+ if ( pbistatus == PBI_CHECKING4UPDATES || pbistatus == PBI_UPDATING )
+ {
+ return;
+ }
+
+QString newMsg = "<font color=\"#ff0000\">Checking for PBI updates...</font>";
+textPBIStatus->setText(newMsg);
+
+int i = -1;
+QString tmp, ProgDirName;
+
+
+ // Load all the PBIs from our list and only keep the ones with update URLs.
+ QFile file( "/Programs/.config/ProgList" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ QString line;
+
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ if (line.find("#" ) != 0)
+ {
+ if (line.find("ProgName:" ) == 0 )
+ {
+ i++;
+ PBIProgName[i] = line.replace("ProgName: ", "");
+ }
+ if ( line.find("ProgVer:") == 0)
+ {
+ PBIProgVer[i] = line.replace("ProgVer: ", "");
+ }
+ if ( line.find("DefaultIcon:") == 0)
+ {
+ PBIProgIcon[i] = line.replace("DefaultIcon: ", "");
+
+ tmp = PBIProgName[i];
+ tmp.replace(" ", "");
+ ProgDirName = tmp;
+ tmp = PBIProgVer[i];
+ tmp.replace(" ", "");
+ ProgDirName = ProgDirName + tmp;
+
+ QFile file2( "/Programs/" + ProgDirName + "/PBI.UpdateURL.sh" );
+ if ( ! file2.exists() ) {
+ PBIProgName[i]="";
+ PBIProgVer[i]="";
+ PBIProgIcon[i]="";
+ PBIProgUpdate[i] = 0;
+ i--;
+ } else {
+ // Set our status to 0, that we don't need to update this PBI so far
+ PBIProgUpdate[i] = 0;
+
+ }
+
+ }
+
+ }
+
+ }
+ file.close();
+
+ }
+
+
+
+ // Now start checking if these PBIs are up to date!
+ if ( ! PBIProgName[0].isEmpty() )
+ {
+ currentWorkingPBI = -1;
+ pbistatus = PBI_CHECKING4UPDATES;
+ QTimer::singleShot( 500, this, SLOT(slotPBICheckUpdate()) );
+ listViewPBIUpdates->clear();
+
+ } else {
+ // Indicate that no new PBIs are available
+ pbistatus = PBI_UPDATED;
+ textPBIStatus->setText(tr("All PBI's are current!"));
+ listViewPBIUpdates->clear();
+ }
+
+
+
+
+}
+
+
+
+
+
+
+// Start checking our list of PBIs which may be updatable
+void PBM::slotPBICheckUpdate()
+{
+
+ QString tmp, line;
+ QString progName, Arch, Version, PBIUrl;
+
+
+ // Jump to the next PBI in our list
+ currentWorkingPBI++;
+
+ // Check if we are done with checking for updates
+ if ( PBIProgName[currentWorkingPBI].isEmpty() )
+ {
+ // Go ahead and finish up the PBI update check now
+ slotPopulatePBIList();
+ return;
+ }
+
+ // set the PBI program name with no spaces in it
+ tmp = PBIProgName[currentWorkingPBI];
+ tmp.replace(" ", "");
+ progName = tmp;
+
+
+ // First, get some variables to figure out the full patch URL
+ QFile file( "/Programs/" + progName + PBIProgVer[currentWorkingPBI] + "/PBI.UpdateURL.sh" );
+ if ( file.open( IO_ReadOnly ) ) {
+ QTextStream stream( &file );
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ if ( line.find("PBIUpdateURL=\"" ) == 0)
+ {
+ line.replace("PBIUpdateURL=\"", "");
+ line.truncate(line.indexOf("\""));
+ PBIUrl = line;
+ //QMessageBox::critical( 0, tr("Online Update"), PBIUrl, QMessageBox::Ok );
+ }
+
+ }
+ file.close();
+ }
+
+ if ( PBIUrl.isEmpty() )
+ {
+ // No PBI update file for this program, jump to next program
+ QTimer::singleShot(1000, this, SLOT(slotPBICheckUpdate() ) );
+ return;
+ }
+
+
+ QString command = "pbreg get /PC-BSD/Version";
+ Version = getLineFromCommandOutput(command);
+
+ command = "uname -p";
+ Arch = getLineFromCommandOutput(command);
+ if ( Arch.indexOf("i386") != -1 )
+ {
+ Arch = "i386";
+ }
+ if ( Arch.indexOf("amd64") != -1 )
+ {
+ Arch = "amd64";
+ }
+
+ QString postData = "PBIName=" + progName + "&PBIVer=" + PBIProgVer[currentWorkingPBI] + "&PCBSDVER=" + Version + "&OSARCH=" + Arch;
+
+ checkPBIJob = KIO::http_post( PBIUrl, postData.utf8(), KIO::HideProgressInfo);
+ checkPBIJob->addMetaData("content-type", "Content-type: application/x-www-form-urlencoded" );
+
+ textPBIStatus->setText(tr("<font color=\"#ff0000\">Checking %1 for updates...</font>").arg(progName) );
+
+ connect(checkPBIJob, SIGNAL(result(KJob *)), this, SLOT(slotPBICheckUpdate() ) );
+ connect(checkPBIJob, SIGNAL(data(KIO::Job *, const QByteArray&)), this, SLOT(slotRecieveData(KIO::Job *, const QByteArray& ) ) );
+
+}
+
+void PBM::slotRecieveData(KIO::Job*, const QByteArray& data)
+{
+ QString output(data), line;
+ QStringList outputList;
+ if ( output.indexOf("Up2Date") == -1 && ! output.isEmpty())
+ {
+ outputList = QStringList::split("\n", output);
+ for ( int i = 0; i < outputList.size(); i++)
+ {
+ line = outputList.at(i);
+
+ if (line.find("NewVer:" ) == 0 )
+ {
+ PBIProgNewVer[currentWorkingPBI] = line.replace("NewVer: ", "");
+ }
+ if ( line.find("Mirror1:") == 0)
+ {
+ PBIProgURL1[currentWorkingPBI] = line.replace("Mirror1: ", "");
+ }
+ // Check for our other file locations
+ if ( line.find("Mirror2:") == 0)
+ {
+ PBIProgURL2[currentWorkingPBI] = line.replace("Mirror2: ", "");
+ }
+ if ( line.find("Mirror3:") == 0)
+ {
+ PBIProgURL3[currentWorkingPBI] = line.replace("Mirror3: ", "");
+ }
+ if ( line.find("FileLoc:") == 0)
+ {
+ PBIProgLoc[currentWorkingPBI] = line.replace("FileLoc: ", "");
+ }
+ if ( line.find("MD5:") == 0)
+ {
+ PBIProgMD5[currentWorkingPBI] = line.replace("MD5: ", "");
+ }
+ } // End of For loop reading line-by-line our data
+
+ // Check to ensure we have found all our variables
+ if ( ! PBIProgNewVer[currentWorkingPBI].isEmpty() && ! PBIProgURL1[currentWorkingPBI].isEmpty() && ! PBIProgURL2[currentWorkingPBI].isEmpty() && ! PBIProgURL3[currentWorkingPBI].isEmpty() && ! PBIProgLoc[currentWorkingPBI].isEmpty() && ! PBIProgMD5[currentWorkingPBI].isEmpty() )
+ {
+ // We have valid data! Set the flag that this PBI is in need of an update
+ PBIProgUpdate[currentWorkingPBI] = 1;
+ }
+ } // End of IF statement to find if this string has update data
+}
+
+
+
+// The update checking is finished, now see if we have any PBIs which need an update
+void PBM::slotPopulatePBIList()
+{
+ int i = 0, foundUpdates = 0;
+ QString text, tmp, newMsg, ProgDirName, iconPath;
+
+ while (! PBIProgName[i].isEmpty() )
+ {
+ // Add the PBI info to the GUI
+ if ( PBIProgUpdate[i] == 1 )
+ {
+ text=PBIProgName[i] + " " + PBIProgNewVer[i];
+
+ tmp = PBIProgName[i];
+ tmp.replace(" ", "");
+ ProgDirName = tmp;
+ tmp = PBIProgVer[i];
+ tmp.replace(" ", "");
+ ProgDirName = ProgDirName + tmp;
+ iconPath = "/Programs/" + ProgDirName + "/" + PBIProgIcon[i];
+
+ QPixmap defaultIcon;
+ Q3CheckListItem *item = new Q3CheckListItem ( listViewPBIUpdates, text, Q3CheckListItem::CheckBox ) ;
+ item->setText(1, tmp.setNum(i));
+
+ defaultIcon.convertFromImage(QImage(iconPath).smoothScale(32,32));
+
+ item->setPixmap ( 0, defaultIcon ) ;
+ listViewPBIUpdates->setColumnAlignment ( 0, Qt::AlignVCenter);
+
+ foundUpdates++;
+ }
+ i++;
+ }
+
+ if ( foundUpdates != 0 ) {
+ // Update our dialog that we are looking for PBI updates right now
+ pbistatus = PBI_UPDATES_AVAIL;
+ textPBIStatus->setText(tr("The following PBI updates are available:"));
+ } else {
+ pbistatus = PBI_UPDATED;
+ textPBIStatus->setText(tr("All PBI's are current!"));
+ listViewPBIUpdates->clear();
+ }
+
+
+}
+
+
+
+// The user has requested to start upgrading the PBIs, lets do it!
+void PBM::slotStartPBIUpgrades()
+{
+ // Change the program status and update the tray icon
+ programstatus = SYSTEM_UPDATING;
+ pbistatus = PBI_UPDATING;
+
+
+ // Lets set the patch tmpdir variable now
+ if ( useCustomTmpDir )
+ {
+ patchTmpDir = customTmpDir;
+ } else {
+ patchTmpDir = PATCHTMPDIR_DEFAULT;
+ }
+
+ // Make sure this tmpdir exists
+ system("mkdir -p '" + patchTmpDir + "' >/dev/null 2>/dev/null");
+
+ // Get our list of PBIs ready to be updated
+ workingPBIUpdates.clear();
+ QStringList ItemList;
+
+ Q3ListViewItemIterator it( listViewPBIUpdates);
+ while ( it.current() ) {
+ if ( ( (Q3CheckListItem*)it.current() )->isOn() )
+ {
+ ItemList += it.current()->text(1);
+ }
+ ++it;
+ }
+
+ workingPBIUpdates = ItemList;
+
+ // Clear out the old update list
+ UpdaterStatusDialog->clearWorkingItems();
+ UpdaterStatusDialog->setUpdatingPBI();
+ UpdaterStatusDialog->show();
+
+ // Add the items we will be updating to the statusDialog
+ int workingItem;
+ bool ok;
+ QString tmp, text;
+ currentWorkingPBI = -1;
+
+
+ for ( QStringList::Iterator it = workingPBIUpdates.begin(); it != workingPBIUpdates.end(); ++it ) {
+ if (currentWorkingPBI == -1 ) {
+ // Save the PBI we are currently working with
+ currentWorkingPBI = (*it).toInt(&ok);
+ // Set the flag that this PBI hasn't failed to download
+ PBIProgFailed[currentWorkingPBI] = 0;
+ }
+
+ workingItem = (*it).toInt(&ok);
+ tmp=tr("Pending download");
+
+ UpdaterStatusDialog->insertStatusListBoxItem(PBIProgName[workingItem], PBIProgNewVer[workingItem], tmp, (*it));
+ }
+
+
+ // Start downloading the PBI upgrades
+ firstDownload = 1;
+ attemptedRedownload = 0;
+
+ slotDownloadPBIUpdate();
+
+}
+
+// Start grabbing the filesize for this PBI and lets get them downloaded
+void PBM::slotDownloadPBIUpdate()
+{
+ QString status, id, tmp, URL;
+ bool startNewDownload = false, ok;
+ int getNextItem = 0;
+
+
+ // Check if we need to start the next download
+ if ( firstDownload == 0 || attemptedRedownload == 3)
+ {
+ // If the download failed with all 3 mirrors, issue an error
+ if ( attemptedRedownload == 3)
+ {
+ // Show the updater status dialog, so user can see any errors
+ UpdaterStatusDialog->show();
+
+ QMessageBox::critical( 0, tr("Online Update"), PBIProgName[currentWorkingPBI] + ": " + tr("An error occured while downloading. Please try again later."), QMessageBox::Ok );
+
+ // Set the status that this failed
+ tmp=tr("Failed Download!");
+ id.setNum(currentWorkingPBI);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+
+ // Set the failed flag for this PBI
+ PBIProgFailed[currentWorkingPBI] = 1;
+ }
+
+ // Update the status on the previous download to finished
+ //status = tr("Install pending...");
+ //UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentSysWorkingItem) );
+
+ for ( QStringList::Iterator it = workingPBIUpdates.begin(); it != workingPBIUpdates.end(); ++it ) {
+
+ // If we just passed the last item grab the next one to start
+ if ( getNextItem == 1) {
+ currentWorkingPBI = (*it).toInt(&ok);
+ startNewDownload = true;
+ PBIProgFailed[currentWorkingPBI] = 0;
+ break;
+ }
+
+ if (currentWorkingPBI == (*it).toInt(&ok) ) {
+ getNextItem = 1;
+ }
+
+
+ }
+
+ // Now its time to start the install of the downloaded patches
+ if ( ! startNewDownload )
+ {
+ tmp = tr("Preparing to install...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus( tmp );
+ firstInstall=1;
+
+ // Add the items we will be updating to the statusDialog
+ int workingItem;
+ bool ok;
+ QString tmp;
+ currentWorkingPBI = -1;
+
+ for ( QStringList::Iterator it = workingPBIUpdates.begin(); it != workingPBIUpdates.end(); ++it ) {
+ if (currentWorkingPBI == -1 ) {
+ currentWorkingPBI = (*it).toInt(&ok);
+ }
+
+ workingItem = (*it).toInt(&ok);
+ tmp=tr("Pending install");
+ id.setNum(workingItem);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+ }
+
+ slotStartPBIInstall();
+
+ return;
+ }
+
+ // Set our flag that this is the first attempt to download this file
+ attemptedRedownload = 0;
+
+ } else {
+ firstDownload = 0;
+ }
+
+
+
+ // Update the status if the attempted download worked
+ if ( attemptedRedownload != 0 )
+ {
+
+ status=tr("Download failed... Attempting to re-download...");
+ if ( attemptedRedownload == 1 ) {
+ URL = PBIProgURL2[currentWorkingPBI];
+ }
+ if (attemptedRedownload == 2) {
+ URL = PBIProgURL2[currentWorkingPBI];
+ }
+
+ } else {
+ status=tr("Downloading...");
+ URL = PBIProgURL1[currentWorkingPBI];
+ }
+
+ // Append the PBI location to our mirror URL now
+ URL = URL + PBIProgLoc[currentWorkingPBI];
+
+ id.setNum(currentWorkingPBI);
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id);
+
+ // We have started the first download now, set our flag
+ //firstDownload = 0;
+
+ // Set our label showing whats going on
+ status = tr("Downloading PBI upgrades...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus(status);
+
+ UpdaterStatusDialog->setProgressTotalSteps(100);
+
+ // Make sure that any old PBI is removed first
+ system("rm '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi' >/dev/null 2>/dev/null");
+ QFile tmpfile( patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi");
+ if ( tmpfile.exists() )
+ {
+ tmpfile.remove();
+ }
+
+ copyJob = KIO::file_copy(URL, patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi", -1, KIO::HideProgressInfo | KIO::Overwrite);
+
+ connect(copyJob, SIGNAL(totalSize(KJob*, qulonglong)), UpdaterStatusDialog, SLOT(slotJobUpdateTotalSize( KJob*, qulonglong)));
+ connect(copyJob, SIGNAL(percent(KJob*, unsigned long)), UpdaterStatusDialog, SLOT(slotJobSetPercent(KJob*, unsigned long)));
+ connect(copyJob, SIGNAL(speed(KJob*, unsigned long)), UpdaterStatusDialog, SLOT(slotJobUpdateSpeed( KJob*, unsigned long)));
+ connect(copyJob, SIGNAL(processedSize(KJob*, qulonglong)), UpdaterStatusDialog, SLOT(slotJobUpdateProcessedSize( KJob*, qulonglong)));
+ connect(copyJob, SIGNAL(result(KJob*)), this, SLOT(slotDownloadPBIDone()));
+
+}
+
+
+
+
+
+// Lets check to make sure the PBI download was good!
+void PBM::slotDownloadPBIDone()
+{
+ QString id, tmp;
+
+ if (copyJob->error() != 0)
+ {
+ // If the download didn't complete, set the status and try again with the next URL
+ firstDownload = 1;
+ attemptedRedownload++;
+ } else {
+ tmp=tr("Pending install");
+ id.setNum(currentWorkingPBI);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+ }
+
+ // Start the next download!
+ slotDownloadPBIUpdate();
+
+
+}
+
+
+
+// Start installing the PBIs now!
+void PBM::slotStartPBIInstall()
+{
+ QString status, id, tmp, ProgDirName, NewProgDirName;
+ bool startNewInstall = false, ok;
+ int getNextItem = 0;
+
+ // Check if we need to start the next install
+ if ( firstInstall == 0)
+ {
+
+ if ( upgradePBIProc->exitStatus() == 255)
+ {
+ QMessageBox::critical( 0, tr("Online Update"), tr("The updated version of %s failed the integrity check! Please try updating this PBI again later.", PBIProgName[currentWorkingPBI] ), QMessageBox::Ok );
+ // Update the status on the previous download to finished
+ status = tr("Failed!");
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+ } else if ( upgradePBIProc->exitStatus() == 256 ) {
+ QMessageBox::critical( 0, tr("Online Update"), tr("An error occured while upgrading %s You may need to re-install this PBI manually.", PBIProgName[currentWorkingPBI]), QMessageBox::Ok );
+ status = tr("Failed!");
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+ } else {
+ // Update the status on the previous download to finished
+ status = tr("Upgrade complete!");
+ UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+ }
+
+ for ( QStringList::Iterator it = workingPBIUpdates.begin(); it != workingPBIUpdates.end(); ++it ) {
+
+ // If we just passed the last item grab the next one to start
+ if ( getNextItem == 1) {
+ currentWorkingPBI = (*it).toInt(&ok);
+ startNewInstall = true;
+ break;
+ }
+
+ if (currentWorkingPBI == (*it).toInt(&ok) ) {
+ getNextItem = 1;
+
+ }
+
+
+ }
+
+ if ( ! startNewInstall )
+ {
+ // The updates are finished!
+
+ QMessageBox::information( 0, tr("Online Update"), tr("PBI Upgrades finished!"), QMessageBox::Ok );
+ if ( UpdaterStatusDialog->isShown() )
+ {
+ UpdaterStatusDialog->hide();
+ }
+ // Check for updates again now
+ programstatus = SYSTEM_UP2DATE;
+ pbistatus = PBI_UPDATED;
+ slotStartUpdateCheck();
+ slotStartPBIUpdateCheck();
+
+
+ return;
+ }
+
+
+ } else {
+ firstInstall = 0;
+ }
+
+ // Update the status
+ tmp=tr("Upgrading");
+ id.setNum(currentWorkingPBI);
+ UpdaterStatusDialog->updateStatusListBoxItem(tmp, id);
+
+ // Reset the progress bar
+ UpdaterStatusDialog->setProgressTotalSteps(3);
+ UpdaterStatusDialog->setProgressSteps(0);
+
+ tmp = tr("Performing PBI upgrades...");
+ UpdaterStatusDialog->setLabelSysUpdateStatus( tmp );
+
+
+ // Get the old PBI directory name
+ tmp = PBIProgName[currentWorkingPBI];
+ tmp.replace(" ", "");
+ ProgDirName = tmp;
+ tmp = PBIProgVer[currentWorkingPBI];
+ tmp.replace(" ", "");
+ ProgDirName = ProgDirName + tmp;
+
+ // Figure out the NEW PBI directory name
+ tmp = PBIProgName[currentWorkingPBI];
+ tmp.replace(" ", "");
+ NewProgDirName = tmp;
+ tmp = PBIProgNewVer[currentWorkingPBI];
+ tmp.replace(" ", "");
+ NewProgDirName = NewProgDirName + tmp;
+
+
+
+
+ // Make the checksum.sh script now
+ QFile file4( patchTmpDir + "/.upgradepbi.sh" );
+ if ( file4.open( IO_WriteOnly ) ) {
+ QTextStream stream4( &file4 );
+ stream4 << "#!/bin/sh\n";
+ stream4 << "DISPLAY="" ; export DISPLAY\n";
+ stream4 << "\n";
+ stream4 << "MD5=\"`cat '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi' | md5`\"\n";
+ stream4 << "if [ \"${MD5}\" != \"" + PBIProgMD5[currentWorkingPBI] + "\" ]\n";
+ stream4 << "then\n";
+ stream4 << " rm '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi'\n";
+ stream4 << " exit 255\n";
+ stream4 << "fi\n";
+ stream4 << "\n";
+ stream4 << "if [ -h '/Programs/" + ProgDirName + "' ]\n" ;
+ stream4 << "then\n";
+ stream4 << "PBIDIR=\"`ls -al /Programs/" + ProgDirName + " | cut -d '>' -f 2-6 | cut -d ' ' -f 2 | sed 's," + ProgDirName + ",,'`\"\n";
+ stream4 << "mkdir -p \"${PBIDIR}/" + NewProgDirName + "\"\n" ;
+ stream4 << "ln -s \"${PBIDIR}/" + NewProgDirName + "\" /Programs/" + NewProgDirName + "\n";
+ stream4 << "fi\n";
+ stream4 << "\n";
+ stream4 << "echo 'SETSTEPS: 1'\n";
+ stream4 << "echo 'MSG: Removing " + ProgDirName + "'\n";
+ stream4 << "pbidelete -remove " + ProgDirName + "\n";
+ stream4 << "\n";
+ stream4 << "echo 'SETSTEPS: 2'\n";
+ stream4 << "echo 'MSG: Installing " + NewProgDirName + "'\n";
+ stream4 << "chmod 755 '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi'\n";
+ stream4 << "'" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi' -text -accept\n";
+ stream4 << "if [ \"$?\" != \"0\" ]\n";
+ stream4 << "then\n";
+ stream4 << " rm '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi'\n";
+ stream4 << " rm '" + patchTmpDir + "/.upgradepbi.sh'\n";
+ stream4 << " exit 256\n";
+ stream4 << "fi\n";
+ stream4 << "echo 'SETSTEPS: 3'\n";
+ stream4 << "echo 'MSG: Finished installing " + NewProgDirName + "'\n";
+ stream4 << "rm '" + patchTmpDir + "/" + tmp.setNum(currentWorkingPBI) + ".pbi'\n";
+ stream4 << "rm '" + patchTmpDir + "/.upgradepbi.sh'\n";
+ stream4 << "exit 0\n";
+ file4.close();
+ }
+
+ // start the extraction process
+ upgradePBIProc = new Q3Process( this );
+ upgradePBIProc->addArgument( "sh" );
+ upgradePBIProc->addArgument( patchTmpDir + "/.upgradepbi.sh" );
+
+ connect( upgradePBIProc, SIGNAL(processExited()), this, SLOT(slotStartPBIInstall() ) );
+ connect( upgradePBIProc, SIGNAL(readyReadStdout()), this, SLOT(slotReadPBIStdout() ) );
+
+ if ( ! upgradePBIProc->start() ) {
+ QMessageBox::critical( 0, tr("Online Update"), tr("An error occured while upgrading. Please try again later."), QMessageBox::Ok );
+ exit(15);
+ }
+
+}
+
+// Read the output from the PBI install
+void PBM::slotReadPBIStdout()
+{
+
+ QString tmp;
+ QString value;
+ bool ok;
+ int num;
+
+ while (upgradePBIProc->canReadLineStdout() )
+ {
+ tmp = upgradePBIProc->readLineStdout();
+
+
+ if ( tmp.find("TOTALSTEPS:" ) == 0)
+ {
+ value = tmp.replace("TOTALSTEPS: ", "");
+ num = value.toInt(&ok);
+ if ( ok ) {
+ UpdaterStatusDialog->setProgressTotalSteps(num);
+ }
+ }
+
+ if ( tmp.find("SETSTEPS:" ) == 0)
+ {
+ value = tmp.replace("SETSTEPS: ", "");
+ num = value.toInt(&ok);
+ if ( ok ) {
+ UpdaterStatusDialog->setProgressSteps(num);
+ }
+ }
+
+ if ( tmp.find("MSG:" ) == 0)
+ {
+ value = tmp.replace("MSG: ", "");
+ value.truncate(70);
+ UpdaterStatusDialog->setLabelSysUpdateStatus(value);
+ }
+
+ }
+
+}
+
+
+void PBM::slotLaunchKDEProxyConfig()
+{
+ QString command;
+ command = "su " + RealUserName + " -c 'kcmshell4 proxy' &";
+ system(command);
+ QMessageBox::information( 0, tr("Proxy Configuration!"), tr("You will need to restart the system updater for any proxy changes to take effect!"), QMessageBox::Ok );
+}
+
+
Modified: pcbsd/trunk/kcmPBMsource/pbm.h
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.h 2008-12-18 14:55:53 UTC (rev 3112)
+++ pcbsd/trunk/kcmPBMsource/pbm.h 2008-12-18 19:29:14 UTC (rev 3113)
@@ -1,15 +1,28 @@
#ifndef PBM_H
#define PBM_H
+/* QT4 */
#include <qfile.h>
#include <qmessagebox.h>
#include <qdialog.h>
#include <kdirwatch.h>
#include <QListWidgetItem>
#include <Q3Process>
+
+/* Local Includes */
#include "ui_pbm.h"
#include "pbi.h"
+#include "updaterDialog.h"
+#include "ui_updaterDialog.h"
+
+/* KDE */
+#include <kjob.h>
+#include <kio/job.h>
+#include <kio/copyjob.h>
+#include <khtml_part.h>
+#include <khtmlview.h>
+
class PBM : public QDialog, private Ui::PBM
{
Q_OBJECT
@@ -39,11 +52,45 @@
void removeComponentFinishedSlot();
void installComponentFinishedSlot();
void CheckRootSlot();
-
-
+ void slotStartUpdateCheck();
+ void slotSysUpdateCheckFinished();
+ void slotReadSystemUpdates();
+ void slotStartPBIUpdateCheck();
+ void slotPBICheckUpdate();
+ void slotPopulatePBIList();
+ void slotRecieveData(KIO::Job*, const QByteArray& data);
+ void slotOpenSysDetails(int id);
+ void slotStartSystemUpdate();
+ void slotDownloadSysUpdate();
+ void slotStartCheckSysMD5();
+ void slotReadSysMD5();
+ void slotStartSysInstall();
+ void slotSysExtractFinished();
+ void slotSysInstallFinished();
+ void slotReadInstallScriptOutput();
+ void slotStartCheckAvailSysSpace();
+ void slotStartPBIUpgrades();
+ void slotDownloadPBIUpdate();
+ void slotDownloadPBIDone();
+ void slotStartPBIInstall();
+ void slotReadPBIStdout();
+ void slotLaunchKDEProxyConfig();
+ void slotRescanForUpdates();
+ void slotViewDetailsClicked();
+ void slotSelectAllSys();
+ void slotSelectAllPBI();
+ void slotSaveUpdaterPrefs();
+ void loadUpdaterPrefs();
+ void setUseCustomTmp( bool enabled );
+ void slotCustomTmpClicked();
+ void slotSelectCustomTmp();
+ void slotInstallUpdatesClicked();
+ void slotCheckSysUpdatesFlags();
private:
void RemoveFiles( PBI * pbi );
void loadComponents();
+
+ QString getLineFromCommandOutput( QString command );
QString bytesToHumanReadable( float bytes );
int getDirSize( QString path );
Q3Process *InfoWindow;
@@ -65,6 +112,64 @@
Q3Process *RemoveFile5;
KDirWatch *fileWatcher;
+ KJob *copyJob;
+ KJob *sysFetchJob;
+ KIO::TransferJob *checkPBIJob;
+ updaterStatus *UpdaterStatusDialog;
+ void loadPatchData(QString patchFile, int patchNum);
+ int programstatus;
+ int pbistatus;
+ int currentSysWorkingItem;
+ int currentWorkingPBI;
+ QStringList workingSysUpdates;
+ QStringList workingPBIUpdates;
+
+ int firstDownload;
+ long totalSeconds;
+ long downloadSize;
+ int totalSteps;
+ int attemptedRedownload;
+ int firstInstall;
+ int requiresSysReboot;
+ bool useCustomTmpDir;
+ QString patchTmpDir;
+ QString customTmpDir;
+ QString sysPatchsetTmpFile;
+
+ Q3Process *getUpdatesDir;
+ Q3Process *readSysUpdates;
+ Q3Process *listingProc;
+ Q3Process *checksumProc;
+ Q3Process *extractProc;
+ Q3Process *installProc;
+ Q3Process *getFreeSpaceProc;
+ Q3Process *checkPBIProc;
+ Q3Process *upgradePBIProc;
+
+ // System Updater Variables
+ QString SysUpdateName[150];
+ QString SysUpdatePatchFile[150];
+ QString SysUpdateDate[150];
+ QString SysUpdateMD5[150];
+ QString SysUpdateSize[150];
+ QString SysUpdateURL[150];
+ QString SysUpdateAlone[150];
+ QString SysUpdateReboot[150];
+ QString SysUpdateDetailsURL[150];
+
+
+
+ QString PBIProgName[900];
+ QString PBIProgVer[900];
+ QString PBIProgNewVer[900];
+ QString PBIProgIcon[900];
+ QString PBIProgURL1[900];
+ QString PBIProgURL2[900];
+ QString PBIProgURL3[900];
+ QString PBIProgMD5[900];
+ QString PBIProgLoc[900];
+ int PBIProgUpdate[900];
+ int PBIProgFailed[900];
signals:
} ;
Modified: pcbsd/trunk/kcmPBMsource/pbm.ui
===================================================================
--- pcbsd/trunk/kcmPBMsource/pbm.ui 2008-12-18 14:55:53 UTC (rev 3112)
+++ pcbsd/trunk/kcmPBMsource/pbm.ui 2008-12-18 19:29:14 UTC (rev 3113)
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>414</width>
- <height>480</height>
+ <width>479</width>
+ <height>622</height>
</rect>
</property>
<property name="windowTitle" >
@@ -22,17 +22,298 @@
<property name="currentIndex" >
<number>0</number>
</property>
+ <widget class="QWidget" name="tab_2" >
+ <attribute name="title" >
+ <string>Online Updates</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <layout class="QGridLayout" name="_2" >
+ <item row="1" column="0" colspan="3" >
+ <widget class="Q3ListView" name="listViewSysUpdates" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="resizePolicy" >
+ <enum>Q3ScrollView::Manual</enum>
+ </property>
+ <property name="selectionMode" >
+ <enum>Q3ListView::Single</enum>
+ </property>
+ <property name="allColumnsShowFocus" >
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator" >
+ <bool>false</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Available Updates</string>
+ </property>
+ <property name="clickable" >
+ <bool>true</bool>
+ </property>
+ <property name="resizable" >
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>ID</string>
+ </property>
+ <property name="clickable" >
+ <bool>true</bool>
+ </property>
+ <property name="resizable" >
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="3" >
+ <widget class="QLabel" name="textSysUpdatesLabel" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>The following system updates are available:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <spacer name="spacer2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>223</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QPushButton" name="pushSelectSysAll" >
+ <property name="text" >
+ <string>Select All</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="pushDetails" >
+ <property name="text" >
+ <string>View Details</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>451</width>
+ <height>13</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="_3" >
+ <item row="2" column="0" >
+ <widget class="QPushButton" name="pushSelectPBIAll" >
+ <property name="text" >
+ <string>Select All</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2" >
+ <widget class="QLabel" name="textPBIStatus" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>The following PBI updates are available:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="Q3ListView" name="listViewPBIUpdates" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode" >
+ <enum>Q3ListView::Single</enum>
+ </property>
+ <property name="allColumnsShowFocus" >
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Available Programs</string>
+ </property>
+ <property name="clickable" >
+ <bool>true</bool>
+ </property>
+ <property name="resizable" >
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>ID</string>
+ </property>
+ <property name="clickable" >
+ <bool>true</bool>
+ </property>
+ <property name="resizable" >
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <spacer name="spacer6" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>201</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QLabel" name="UpdaterLabel" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>438</width>
+ <height>17</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QPushButton" name="pushInstallSysUpdates" >
+ <property name="text" >
+ <string>Install selected updates</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="_4" >
+ <item>
+ <spacer name="spacer15" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonRescanForSysUpdates" >
+ <property name="text" >
+ <string>Check for Updates</string>
+ </property>
+ <property name="flat" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0" >
+ <spacer name="verticalSpacer_5" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
<widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>394</width>
- <height>433</height>
- </rect>
- </property>
<attribute name="title" >
- <string>Installed PBIs</string>
+ <string>PBI Manager</string>
</attribute>
<layout class="QGridLayout" >
<item row="0" column="0" >
@@ -138,14 +419,6 @@
</layout>
</widget>
<widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>394</width>
- <height>433</height>
- </rect>
- </property>
<attribute name="title" >
<string>System Components</string>
</attribute>
@@ -240,11 +513,123 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="tab_3" >
+ <attribute name="title" >
+ <string>Configuration</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QCheckBox" name="checkTMPDIR" >
+ <property name="text" >
+ <string>Specify custom temp directory for updates</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineTMPDIR" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushTMPDIR" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>28</width>
+ <height>28</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>28</width>
+ <height>28</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="PBM.qrc" >
+ <normaloff>:/folder.png</normaloff>:/folder.png</iconset>
+ </property>
+ <property name="iconSize" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <spacer name="verticalSpacer_4" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>428</width>
+ <height>17</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" >
+ <spacer name="verticalSpacer_3" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>459</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
+ <customwidgets>
+ <customwidget>
+ <class>Q3ListView</class>
+ <extends>Q3Frame</extends>
+ <header>q3listview.h</header>
+ </customwidget>
+ </customwidgets>
<includes>
<include location="local" >q3process.h</include>
<include location="global" >kdirwatch.h</include>
Property changes on: pcbsd/trunk/kcmPBMsource/working.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
More information about the Commits
mailing list