Changeset 7964857


Ignore:
Timestamp:
10/01/14 08:50:39 (3 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.1
Children:
ceb3cf9
Parents:
edc653f3
Message:

Update pc-systemupdatertray to use syscache for fetching information about packages/jails (still runs pc-systemupdatemanager directly for system update checking)

Location:
src-qt4/pc-systemupdatertray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-systemupdatertray/TrayUI.cpp

    rc6fceaef r7964857  
    202202  if(PKGSTATUS==1){ return; } //already checking for updates 
    203203  qDebug() << " -Starting Package Check..."; 
    204   QString cmd = "sudo pc-updatemanager pkgcheck"; 
    205204  PKGSTATUS=1; //working 
    206   QProcess::startDetached(cmd);   
     205  updateTrayIcon(); 
     206  updateToolTip(); 
     207  QString info = pcbsd::Utils::runShellCommand("syscache \"pkg #system hasupdates\"").join(""); 
     208  if(info.isEmpty() || info.contains("ERROR") ){ PKGSTATUS=0; noInternet=true; } 
     209  else if(info.toLower().simplified()=="true"){ PKGSTATUS=2; noInternet=false; } 
     210  else{ PKGSTATUS=0; noInternet=false; } //no updates available 
    207211} 
    208212 
     
    223227  if(WARDENSTATUS==1){ return; } //already checking for updates 
    224228  qDebug() << " -Starting Warden Check..."; 
    225   QString cmd = "warden checkup all"; 
    226229  WARDENSTATUS=1; //working 
    227   QProcess::startDetached(cmd); 
     230  updateTrayIcon(); 
     231  updateToolTip(); 
     232   
     233  QStringList info = pcbsd::Utils::runShellCommand("syscache \"jail list\"").join("").split(", "); 
     234  for(int i=0; i<info.length(); i++){ 
     235    if(info[i].isEmpty()){ continue; } 
     236    else if( info[i].contains("[ERROR]") ){ WARDENSTATUS=0; break;} //unknown jails - assume none so success 
     237    //Check for updates in this jail 
     238    info[i] = pcbsd::Utils::runShellCommand("syscache \"pkg "+info[i]+" hasupdates\"").join(""); 
     239    if(info[i].toLower().simplified()=="true"){ WARDENSTATUS=2; break; } //updates available: stop checking others 
     240    //keep checking if it gets here (no updates for this one) 
     241  } 
     242  if(WARDENSTATUS==1){ WARDENSTATUS=0; } //Nothing found - success 
    228243} 
    229244 
     
    256271void TrayUI::checkForUpdates(){ 
    257272  //Simplification function to start all checks 
     273    startSYSCheck(); //put this first since it starts a detached process 
    258274    startPKGCheck(); 
    259     startSYSCheck(); 
    260275    startWardenCheck(); 
    261276    updateTrayIcon(); 
     
    270285  if(PKGSTATUS<0){ startPKGCheck(); } 
    271286  if(WARDENSTATUS<0){ startWardenCheck(); } 
     287  updateTrayIcon(); 
     288  updateToolTip();   
    272289  QTimer::singleShot(60000, watcher, SLOT(checkFlags()) ); //make sure to manually check 1 minute from now 
    273290} 
     
    307324          break; 
    308325        case SystemFlags::PkgUpdate: 
    309           if(msg==SystemFlags::UpdateAvailable){ PKGSTATUS=2; } 
    310           else if(msg==SystemFlags::Working){ PKGSTATUS=1; } 
    311           else if(msg==SystemFlags::Success){ PKGSTATUS=0; } 
     326          if(msg==SystemFlags::Working){ PKGSTATUS=1; } 
    312327          else if(msg==SystemFlags::Updating){ PKGSTATUS=3; } 
    313           else if(msg==SystemFlags::Error){ PKGSTATUS=0; noInternet=true; } 
    314           else{ startPKGCheck(); } //unknown - check it 
     328          else{ startPKGCheck(); } //check it 
    315329          break; 
    316330        case SystemFlags::SysUpdate: 
     
    323337          break;         
    324338        case SystemFlags::WardenUpdate: 
    325           if(msg==SystemFlags::UpdateAvailable){ WARDENSTATUS=2; } 
    326           else if(msg==SystemFlags::Working){ WARDENSTATUS=1; } 
    327           else if(msg==SystemFlags::Success){ WARDENSTATUS=0; } 
     339          if(msg==SystemFlags::Working){ WARDENSTATUS=1; } 
    328340          else if(msg==SystemFlags::Updating){ WARDENSTATUS=3; } 
    329           else if(msg==SystemFlags::Error){ WARDENSTATUS=0; noInternet=true; } 
    330           else{ startWardenCheck(); } //unknown - check it 
     341          else{ startWardenCheck(); } //check it 
    331342          break;         
    332343  } 
    333   qDebug() << "System Status Change:" << SYSSTATUS << PKGSTATUS <<WARDENSTATUS; 
     344  qDebug() << "System Status Change:" << SYSSTATUS << PKGSTATUS << WARDENSTATUS << noInternet; 
    334345  //Update the tray icon 
    335346  updateTrayIcon(); 
  • src-qt4/pc-systemupdatertray/TrayUI.h

    re0f0922 r7964857  
    1515//libpcbsd includes 
    1616#include <pcbsd-sysFlags.h> 
     17#include <pcbsd-utils.h> 
    1718 
    1819class TrayUI : public QSystemTrayIcon{ 
Note: See TracChangeset for help on using the changeset viewer.