void SystemFlagWatcher::watcherNotification(){ //qDebug() << "Watcher found change"; QDir dir(FLAGDIR); if(!dir.exists()){ return; } //flag directory does not exist yet - do nothing QDateTime oldCDT = CDT.addSecs(-1); //Always backup one second to make sure we get concurrently set flags CDT = QDateTime::currentDateTime(); //Update the last time flags were checked QFileInfoList flags = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot, QDir::Time); for(int i=0; i<flags.length(); i++){ if(oldCDT < flags[i].lastModified()){ QString contents = quickRead(flags[i].absoluteFilePath()); SystemFlags::SYSMESSAGE msg; if(contents==MWORKING){ msg = SystemFlags::Working; } else if(contents==MERROR){ msg = SystemFlags::Error; } else if(contents==MSUCCESS){ msg = SystemFlags::Success; } else if(contents==MUPDATE){ msg = SystemFlags::UpdateAvailable; } else if(contents==MUPDATING){ msg = SystemFlags::Updating; } else{ continue; } //invalid message - skip this flag //New flag - check which one and emit the proper signal if(flags[i].fileName().startsWith(NETWORKRESTARTED) ){ emit FlagChanged(SystemFlags::NetRestart, msg); }else if(flags[i].fileName().startsWith(PKGUPDATEAVAILABLE) ){ emit FlagChanged(SystemFlags::PkgUpdate, msg); }else if(flags[i].fileName().startsWith(SYSUPDATEAVAILABLE) ){ emit FlagChanged(SystemFlags::SysUpdate, msg); }else if(flags[i].fileName().startsWith(WARDENUPDATEAVAILABLE) ){ emit FlagChanged(SystemFlags::WardenUpdate, msg); } } } if(chktime->isActive()){ chktime->stop(); } chktime->start(); //restart the default timer }
void SystemFlagWatcher::watcherNotification() { //Does not specify the contents of a flag just yet - KenMoore 3/12/14 QDir dir(FLAGDIR); if(!dir.exists()) { return; //flag directory does not exist yet - do nothing } QFileInfoList flags = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot, QDir::Time); for(int i=0; i<flags.length(); i++) { if(CDT < flags[i].lastModified()) { QString contents = quickRead(flags[i].absoluteFilePath()); //add this later //New flag - check which one and emit the proper signal if(flags[i].fileName().startsWith(NETWORKRESTARTED) ) { emit FlagChanged(SystemFlags::NetRestart, contents); } else if(flags[i].fileName().startsWith(PKGUPDATEAVAILABLE) ) { emit FlagChanged(SystemFlags::PkgUpdate, contents); } else if(flags[i].fileName().startsWith(SYSUPDATEAVAILABLE) ) { emit FlagChanged(SystemFlags::SysUpdate, contents); } else if(flags[i].fileName().startsWith(PBIUPDATEAVAILABLE) ) { emit FlagChanged(SystemFlags::PbiUpdate, contents); } } } CDT = QDateTime::currentDateTime(); //Now update the last time flags were checked }