[PC-BSD Commits] r6335 - pcbsd/trunk/SystemUpdaterTray

svn at pcbsd.org svn at pcbsd.org
Wed Mar 3 09:04:30 PST 2010


Author: kris
Date: 2010-03-03 09:04:30 -0800 (Wed, 03 Mar 2010)
New Revision: 6335

Modified:
   pcbsd/trunk/SystemUpdaterTray/UpdaterTray.cpp
   pcbsd/trunk/SystemUpdaterTray/UpdaterTray.h
Log:

Updater tray now uses new option to determine when we need to re-scan for updates, set in the software manager



Modified: pcbsd/trunk/SystemUpdaterTray/UpdaterTray.cpp
===================================================================
--- pcbsd/trunk/SystemUpdaterTray/UpdaterTray.cpp	2010-03-03 17:03:58 UTC (rev 6334)
+++ pcbsd/trunk/SystemUpdaterTray/UpdaterTray.cpp	2010-03-03 17:04:30 UTC (rev 6335)
@@ -80,6 +80,9 @@
 QString PBIBuffer;
 QString updatePBITextList;
 
+// Updater frequency supplied by user
+qlonglong	updateFrequency;
+
 #define AUTOINACTIVE 0
 #define AUTODOWNLOAD 1
 #define AUTOFINISHED 2
@@ -92,6 +95,9 @@
   QString tmp, command;
   autoStatus = AUTOINACTIVE;
 
+  // Use built-in frequency until we load another
+  updateFrequency = -1;
+
   sysTimer = new QTimer(this);
   pbiTimer = new QTimer(this);
 
@@ -125,28 +131,56 @@
 
   // Start the monitor service for system updates
   QTimer::singleShot(1000, this, SLOT(slotScheduledSystemCheck()));
+
   // Start the monitor service for PBI updates
   QTimer::singleShot(2000, this, SLOT(slotScheduledPBICheck()));
 
-   // KPM 8-25-09 Disable PBI watcher for now, too many needless hits to update server for checking
-   // Watch our trigger file to see if the list of installed PBIs changes
-   //fileWatcher = KDirWatch::self();
-   //fileWatcher->addFile("/Programs/.config/ProgList");
-   //connect(fileWatcher, SIGNAL(dirty(const QString&)), this, SLOT(slotScheduledPBICheck() ));
-   
+  // Monitor if we need to start any update checks
+  QTimer::singleShot(500, this, SLOT(slotMonitorForChanges()));
 
-   // Watch our trigger file, to see if any updates have been changed
-   fileWatcherSys = KDirWatch::self();
-   fileWatcherSys->addFile("/PCBSD/SystemUpdater/conf/.last-update");
-   connect(fileWatcherSys, SIGNAL(dirty(const QString&)), this, SLOT(slotScheduledSystemCheck() ));
-  
-   // Watch our trigger file, to see if any automated updates are being downloaded
-   fileWatcherAutoUpdate = KDirWatch::self();
-   fileWatcherAutoUpdate->addFile(SYSTRIGGER);
-   connect(fileWatcherAutoUpdate, SIGNAL(dirty(const QString&)), this, SLOT(slotSetTimerReadAutoStatus() ));
+  // Watch our trigger file, to see if any automated updates are being downloaded
+  fileWatcherAutoUpdate = KDirWatch::self();
+  fileWatcherAutoUpdate->addFile(SYSTRIGGER);
+  connect(fileWatcherAutoUpdate, SIGNAL(dirty(const QString&)), this, SLOT(slotSetTimerReadAutoStatus() ));
 
+  // Watch our trigger file, to see if any automated updates are being downloaded
+  fileWatcherSys = KDirWatch::self();
+  fileWatcherSys->addFile("/PCBSD/SystemUpdater/conf/sysupdate.conf");
+  connect(fileWatcherSys, SIGNAL(dirty(const QString&)), this, SLOT(slotScheduledSystemCheck() ));
 }
 
+// Slot that watches for any config changes
+void UpdaterTray::slotMonitorForChanges()
+{
+  QString upstamp, userupstamp;
+  qlonglong oldfrequency;
+  bool needRescan = false;
+
+  QSettings settings("PCBSD");
+
+  // Load the update frequency
+  oldfrequency = updateFrequency;
+  updateFrequency = settings.value("/PC-BSD/SystemUpdater/checkUpdateFrequency", updateFrequency).toLongLong();
+  if ( oldfrequency != updateFrequency)
+    needRescan = true;
+
+
+  // Check if we need to re-scan for PBI / system updates
+  upstamp = settings.value( "/PC-BSD/SystemUpdater/updateStatusTimeStamp", QString() ).toString();
+  userupstamp = settings.value( "/PC-BSD/SystemUpdater/updateStatusUserTimeStamp", QString() ).toString();
+  if ( upstamp != userupstamp ) {
+    settings.setValue( "/PC-BSD/SystemUpdater/updateStatusUserTimeStamp", upstamp );
+    needRescan = true;
+  }
+
+  if ( needRescan ) {
+    slotScheduledSystemCheck();
+    slotScheduledPBICheck();
+  }
+
+  QTimer::singleShot(5000, this, SLOT(slotMonitorForChanges()));
+}
+
 void UpdaterTray::slotSetTimerReadAutoStatus()
 {
   QTimer::singleShot(1000, this, SLOT(slotAutoUpdateStatusChanged()));
@@ -234,7 +268,7 @@
    
     if ( checkSysUpdatesFrequently == TRUE) {
        // Set our timer to check again in 24 hours.
-       sysTimer->start( UPDATE_MSEC ); 
+       sysTimer->start( updateFrequency ); 
 
    slotStartUpdateCheck();
    }
@@ -592,6 +626,9 @@
   customTmpDir = PATCHTMPDIR_DEFAULT;
   customTmpDir = settings.value("/PC-BSD/SystemUpdater/customTmpDir", customTmpDir).toString();
 
+  // Load a custom tmpdir
+  updateFrequency = UPDATE_MSEC;
+  updateFrequency = settings.value("/PC-BSD/SystemUpdater/checkUpdateFrequency", updateFrequency).toLongLong();
 
 }
 
@@ -614,7 +651,7 @@
 {
     if ( checkPBIUpdatesFrequently == TRUE) {
        // Set our timer to check again in 24 hours.
-       pbiTimer->start( UPDATE_MSEC); 
+       pbiTimer->start( updateFrequency); 
     }
 
    slotStartPBIUpdateCheck();

Modified: pcbsd/trunk/SystemUpdaterTray/UpdaterTray.h
===================================================================
--- pcbsd/trunk/SystemUpdaterTray/UpdaterTray.h	2010-03-03 17:03:58 UTC (rev 6334)
+++ pcbsd/trunk/SystemUpdaterTray/UpdaterTray.h	2010-03-03 17:04:30 UTC (rev 6335)
@@ -43,6 +43,7 @@
    void slotSetTimerReadAutoStatus();
    void slotCheckAllUpdates();
    void slotReadPBIBuffer();
+   void slotMonitorForChanges();
    
 protected:
    



More information about the Commits mailing list