// =============== // PRIVATE FUNCTIONS // =============== void TrayUI::updateTrayIcon(){ bool isworking = false; QString msg; if(SYSSTATUS==3 || PKGSTATUS==3 || WARDENSTATUS==3){ this->setIcon( QIcon(":/images/updating.png") ); isworking = true; }else if( SYSSTATUS==1 || PKGSTATUS==1 || WARDENSTATUS==1){ this->setIcon( QIcon(":/images/working.png") ); isworking = true; }else if( rebootNeeded() ){ this->setIcon( QIcon(":/images/restart.png") ); msg = tr("System Reboot Required"); }else if( noInternet ){ this->setIcon( QIcon(":/images/connecterror.png") ); }else if(SYSSTATUS==2){ this->setIcon( QIcon(":/images/sysupdates.png") ); msg = tr("System Updates Available"); }else if(PKGSTATUS==2){ this->setIcon( QIcon(":/images/pkgupdates.png") ); msg = tr("Package Updates Available"); }else if(WARDENSTATUS==2){ this->setIcon( QIcon(":/images/sysupdates.png") ); msg = tr("Jail Updates Available"); }else{ //everything up to date this->setIcon( QIcon(":/images/updated.png") ); } //Show a popup Notification if done working if(!isworking && wasworking && showNotifications->isChecked() && !msg.isEmpty()){ this->showMessage(tr("PC-BSD System Message"),msg,QSystemTrayIcon::Information, 2000); //2 sec notification } wasworking = isworking; //save this for later }
void TrayUI::updateToolTip(){ QString msg = tr("PC-BSD Update Manager")+"\n"; //Now generate the tooltip if(rebootNeeded()){ msg.append( "\n"+tr("System Reboot Required")); }else if(noInternet){ msg.append("\n"+tr("Error checking for updates")+"\n"+tr("Please make sure you have a working internet connection") ); }else if(PBISTATUS<=0 && SYSSTATUS<=0 && PKGSTATUS<=0 && WARDENSTATUS<=0){ msg.append("\n"+tr("Your system is fully updated") ); }else{ if(SYSSTATUS==2){ msg.append("\n"+tr("System Updates Available")); } else if(SYSSTATUS==1){ msg.append("\n"+tr("Checking for system updates...") ); } else if(SYSSTATUS==3){ msg.append("\n"+tr("System Updating...") ); } if(PKGSTATUS==2){ msg.append("\n"+tr("Package Updates Available") ); } else if(PKGSTATUS==1){ msg.append("\n"+tr("Checking for package updates...") ); } else if(PKGSTATUS==3){ msg.append("\n"+tr("Packages Updating...") ); } if(WARDENSTATUS==2){ msg.append("\n"+tr("Jail Updates Available") ); } else if(WARDENSTATUS==1){ msg.append("\n"+tr("Checking for jail updates...") ); } else if(WARDENSTATUS==3){ msg.append("\n"+tr("Jails Updating...") ); } if(PBISTATUS==2){ msg.append("\n"+tr("PBI Updates Available") ); } else if(PBISTATUS==1){ msg.append("\n"+tr("Checking for PBI updates") ); } else if(PBISTATUS==3){ msg.append("\n"+tr("PBI Updating...") ); } } this->setToolTip(msg); }
void TrayUI::startSYSCheck(){ if(rebootNeeded()){ return; } //do not start another check if a reboot is required first if(SYSSTATUS==1){ return; } //already checking for updates qDebug() << " -Starting System Check..."; QString cmd = "sudo pc-updatemanager check"; SYSSTATUS=1; //working QProcess::startDetached(cmd); }
void TrayUI::startWardenCheck(){ WARDENSTATUS=0; return; //Warden check command not currently working - just keep it invisible //------- if(rebootNeeded()){ return; } //do not start another check if a reboot is required first if(WARDENSTATUS==1){ return; } //already checking for updates qDebug() << " -Starting Warden Check..."; QString cmd = "warden checkup all"; WARDENSTATUS=1; //working QProcess::startDetached(cmd); }
void TrayUI::startSYSCheck(){ if(rebootNeeded()){ return; } //do not start another check if a reboot is required first if(SYSSTATUS==1){ return; } //already checking for updates qDebug() << " -Starting System Check..."; //QString cmd = "sudo pc-updatemanager check"; SYSSTATUS=1; //working //QProcess::startDetached(cmd); updateTrayIcon(); updateToolTip(); QString info = pcbsd::Utils::runShellCommand("syscache hasupdates").join(""); if(info.isEmpty() || info.contains("ERROR") ){ SYSSTATUS=0; } else if(info.toLower().simplified()=="true"){ SYSSTATUS=2; } else{ SYSSTATUS=0; } //no updates available }
void TrayUI::startWardenCheck(){ //WARDENSTATUS=0; //return; //Warden check command not currently working - just keep it invisible //------- if(rebootNeeded()){ return; } //do not start another check if a reboot is required first if(WARDENSTATUS==1){ return; } //already checking for updates qDebug() << " -Starting Warden Check..."; WARDENSTATUS=1; //working updateTrayIcon(); updateToolTip(); QStringList info = pcbsd::Utils::runShellCommand("syscache \"jail list\"").join("").split(", "); for(int i=0; i<info.length(); i++){ if(info[i].isEmpty()){ continue; } else if( info[i].contains("[ERROR]") ){ WARDENSTATUS=0; break;} //unknown jails - assume none so success //Check for updates in this jail info[i] = pcbsd::Utils::runShellCommand("syscache \"pkg "+info[i]+" hasupdates\"").join(""); if(info[i].toLower().simplified()=="true"){ WARDENSTATUS=2; break; } //updates available: stop checking others //keep checking if it gets here (no updates for this one) } if(WARDENSTATUS==1){ WARDENSTATUS=0; } //Nothing found - success }