Scanner Menu: added "Quit" entry for application.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/24/head
Mavridis Philippe 4 years ago
parent 87b6ec150e
commit f9ecebbadf
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -16,6 +16,7 @@
#include "configdialog.h" #include "configdialog.h"
#include "tabwidget.h" #include "tabwidget.h"
#include "klamavconfig.h" #include "klamavconfig.h"
#include "klamonacc.h"
#include <tdelocale.h> #include <tdelocale.h>
@ -67,6 +68,12 @@ Klamav::Klamav()
EnableFreshklam->plug(conf_menu); EnableFreshklam->plug(conf_menu);
DisableFreshklam->plug(conf_menu); DisableFreshklam->plug(conf_menu);
EnableKlamOnAcc = new TDEAction(i18n("&Start On-Access Scanner"), "filefind", 0,this, SLOT(contextEnableKOA()),actionCollection(),"koa_enable");
DisableKlamOnAcc = new TDEAction(i18n("&Stop On-Access Scanner"), 0, 0, this, SLOT(contextDisableKOA()),actionCollection(),"koa_disable");
EnableKlamOnAcc->plug(conf_menu);
DisableKlamOnAcc->plug(conf_menu);
TQToolTip::add( _tray, i18n( "KlamAV - Virus Protection for TDE" ) ); TQToolTip::add( _tray, i18n( "KlamAV - Virus Protection for TDE" ) );
_tray->show(); _tray->show();
@ -92,6 +99,8 @@ Klamav::Klamav()
scanner_menu->insertSeparator(); scanner_menu->insertSeparator();
scanner_menu->insertItem( SmallIcon("xclock"), i18n("&Schedule scan..."), this, SLOT(slotScheduleScan()) ); scanner_menu->insertItem( SmallIcon("xclock"), i18n("&Schedule scan..."), this, SLOT(slotScheduleScan()) );
scanner_menu->insertItem( SmallIcon("configure"), i18n("&Options..."), this, SLOT(slotOptions()) ); scanner_menu->insertItem( SmallIcon("configure"), i18n("&Options..."), this, SLOT(slotOptions()) );
scanner_menu->insertSeparator();
scanner_menu->insertItem( SmallIcon("application-exit"), i18n("&Quit"), kapp, SLOT(quit()) );
tabs_menu = new TDEPopupMenu(this); tabs_menu = new TDEPopupMenu(this);
tabs_menu->setCheckable(true); tabs_menu->setCheckable(true);
@ -122,9 +131,9 @@ Klamav::Klamav()
connect(freshklam->search_button,SIGNAL(clicked()),SLOT(contextUpdateFK())); connect(freshklam->search_button,SIGNAL(clicked()),SLOT(contextUpdateFK()));
connect(freshklam->cancel_button,SIGNAL(clicked()),SLOT(contextDisableFK())); connect(freshklam->cancel_button,SIGNAL(clicked()),SLOT(contextDisableFK()));
kuarantine = new Kuarantine(this, "Quarantine"); kuarantine = new Kuarantine(this, "Quarantine");
updateTabState(1, true); // Quarantine tab updateTabState(1, true); // Quarantine tab
@ -135,19 +144,24 @@ Klamav::Klamav()
top->addWidget(tab); top->addWidget(tab);
// On-Access scanner
klamonacc = new KlamOnAcc(this);
connect( klamonacc, SIGNAL(stateUpdated()), this, SLOT(slotKOAStateUpdate()) );
slotKOAStateUpdate(); // initial state
connect(tab,SIGNAL(currentChanged ( TQWidget * ) ),klamdb,SLOT(shouldIShow(TQWidget *))); connect(tab,SIGNAL(currentChanged ( TQWidget * ) ),klamdb,SLOT(shouldIShow(TQWidget *)));
KStdAction::quit(this, SLOT(shuttingDown()), actionCollection()); KStdAction::quit(this, SLOT(shuttingDown()), actionCollection());
if (TDEApplication::kApplication()->isRestored()){ if (TDEApplication::kApplication()->isRestored()){
hide(); hide();
}else{ }else{
show(); show();
} }
if ((firstDownload) || (downloadDBForWizard)){ if ((firstDownload) || (downloadDBForWizard)){
kdDebug() << "firstdownload" << firstDownload << endl; kdDebug() << "firstdownload" << firstDownload << endl;
kdDebug() << "downloadDBForWizard" << downloadDBForWizard << endl; kdDebug() << "downloadDBForWizard" << downloadDBForWizard << endl;
@ -160,10 +174,11 @@ Klamav::Klamav()
setCaption(TQString("KlamAV %1 (Using ClamAV %2)").arg(KLAMAV_VERSION).arg(KlamavConfig::clamAVVersion())); setCaption(TQString("KlamAV %1 (Using ClamAV %2)").arg(KLAMAV_VERSION).arg(KlamavConfig::clamAVVersion()));
} }
Klamav::~Klamav() Klamav::~Klamav()
{ {
KlamavConfig::writeConfig(); klamonacc->stop();
KlamavConfig::writeConfig();
kapp->quit(); kapp->quit();
} }
@ -174,10 +189,10 @@ void Klamav::shuttingDown(){
} }
bool Klamav::queryClose() { bool Klamav::queryClose() {
if ( freshklam->isFreshklamAlive() || klamscan->scanGoingOn() ){ if ( freshklam->isFreshklamAlive() || klamscan->scanGoingOn() || klamonacc->isActive() ){
KMessageBox::information (this,i18n("<p>KlamAV will stay open in the system tray. <br><br>" KMessageBox::information (this,i18n("<p>KlamAV will stay open in the system tray. <br><br>"
" <b>Remember</b> - you can't quit KlamAV while <br> " " <b>Remember</b> - you can't quit KlamAV while <br> "
" scanning or auto-updating!</p>"),"KlamAV","dontshow"); " a scan, Fresklam or KlamOnAcc is active!</p>"),"KlamAV","dontshow");
hide(); hide();
return false; return false;
@ -185,14 +200,6 @@ bool Klamav::queryClose() {
return true; return true;
} }
void Klamav::clamdStopped() {
/* if (freshklam->isFreshklamAlive())
_tray->setPixmap(KSystemTray::loadIcon("klamavbwdl"));
else*/
_tray->setPixmap(KSystemTray::loadIcon("klamav_on_acc_disabled"));
}
void Klamav::updateTabState( int tabId, bool init ) { void Klamav::updateTabState( int tabId, bool init ) {
if( config->group() != "Tabs" ) if( config->group() != "Tabs" )
config->setGroup("Tabs"); config->setGroup("Tabs");
@ -329,6 +336,27 @@ void Klamav::slotToggleEvents() {
updateTabState(3, false); updateTabState(3, false);
} }
void Klamav::slotKOAStateUpdate()
{
kdDebug() << "slotKOAStateUpdate" << endl;
bool on = klamonacc->isActive();
bool enabled = klamonacc->isEnabled();
_tray->setPixmap(
KSystemTray::loadIcon(
(on ? "klamav_on_acc_enabled"
: "klamav_on_acc_disabled")
)
);
if(enabled) {
EnableKlamOnAcc->setEnabled(!on);
DisableKlamOnAcc->setEnabled(on);
} else {
EnableKlamOnAcc->setEnabled(false);
DisableKlamOnAcc->setEnabled(false);
}
}
void Klamav::contextUpdateFK() { void Klamav::contextUpdateFK() {
@ -341,12 +369,21 @@ void Klamav::contextEnableFK() {
} }
void Klamav::contextDisableFK() { void Klamav::contextDisableFK() {
freshklam->slotCancel(); freshklam->slotCancel();
// DisableFreshklam->setEnabled(FALSE); // DisableFreshklam->setEnabled(FALSE);
// EnableFreshklam->setEnabled(TRUE); // EnableFreshklam->setEnabled(TRUE);
} }
void Klamav::contextEnableKOA() {
klamonacc->start();
}
void Klamav::contextDisableKOA() {
klamonacc->stop();
}
void Klamav::showVirusBrowser() { void Klamav::showVirusBrowser() {
tab->setCurrentPage(5); tab->setCurrentPage(5);
} }
@ -355,11 +392,11 @@ void Klamav::firstRunWizard() {
FirstRunWizard wizard; FirstRunWizard wizard;
wizard.setCaption( i18n( "First-Run Wizard" )); wizard.setCaption( i18n( "First-Run Wizard" ));
TQString homepath = getenv("HOME"); TQString homepath = getenv("HOME");
TQString defaultdb = homepath + "/.klamav/database"; TQString defaultdb = homepath + "/.klamav/database";
TQString defaultquar = homepath + "/.klamav/quarantine"; TQString defaultquar = homepath + "/.klamav/quarantine";
// Execute wizard // Execute wizard
wizard.exec(); wizard.exec();
@ -367,7 +404,7 @@ void Klamav::firstRunWizard() {
TDEConfig* config = TDEGlobal::config(); TDEConfig* config = TDEGlobal::config();
config->setGroup("Freshklam"); config->setGroup("Freshklam");
TQString wizardDBPath = wizard.databasePath().path(-1); TQString wizardDBPath = wizard.databasePath().path(-1);
TQString wizardTQRPath = wizard.quarantinePath().path(-1); TQString wizardTQRPath = wizard.quarantinePath().path(-1);
@ -385,9 +422,9 @@ void Klamav::firstRunWizard() {
//Configure Quarantine Path //Configure Quarantine Path
TQStringList lastQuarLocations; TQStringList lastQuarLocations;
config->setGroup("Kuarantine"); config->setGroup("Kuarantine");
if ((wizardTQRPath != "") && (TQDir::cleanDirPath(wizardTQRPath) != defaultquar)){ if ((wizardTQRPath != "") && (TQDir::cleanDirPath(wizardTQRPath) != defaultquar)){
lastQuarLocations.prepend( TQString("%1").arg(wizardTQRPath)); lastQuarLocations.prepend( TQString("%1").arg(wizardTQRPath));
checkDir(wizardTQRPath); checkDir(wizardTQRPath);
@ -434,13 +471,12 @@ void Klamav::checkDir(TQString path){
TQFile f1( path ); TQFile f1( path );
if ((!klamavdir.exists()) || (f1.open( IO_ReadWrite ))) if ((!klamavdir.exists()) || (f1.open( IO_ReadWrite )))
KMessageBox::information(this, i18n("Either the directory %1 does not exist or you are not able to write to it. Either way, you will have to change it as it cannot be used. Sorry!").arg(path)); KMessageBox::information(this, i18n("Either the directory %1 does not exist or you are not able to write to it. Either way, you will have to change it as it cannot be used. Sorry!").arg(path));
f1.close(); f1.close();
} }
void Klamav::slotConfigKlamav( const TQCString& page ) void Klamav::slotConfigKlamav( const TQCString& page )
{ {
KlamavConfigDialog* dialog = (KlamavConfigDialog*) TDEConfigDialog::exists( "settings" ); KlamavConfigDialog* dialog = (KlamavConfigDialog*) TDEConfigDialog::exists( "settings" );
if( !dialog ) if( !dialog )

Loading…
Cancel
Save