summaryrefslogtreecommitdiffstats
path: root/src/klamav.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/klamav.cpp')
-rw-r--r--src/klamav.cpp90
1 files changed, 63 insertions, 27 deletions
diff --git a/src/klamav.cpp b/src/klamav.cpp
index d4e4bb3..734858c 100644
--- a/src/klamav.cpp
+++ b/src/klamav.cpp
@@ -16,6 +16,7 @@
#include "configdialog.h"
#include "tabwidget.h"
#include "klamavconfig.h"
+#include "klamonacc.h"
#include <tdelocale.h>
@@ -67,6 +68,12 @@ Klamav::Klamav()
EnableFreshklam->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" ) );
_tray->show();
@@ -92,6 +99,8 @@ Klamav::Klamav()
scanner_menu->insertSeparator();
scanner_menu->insertItem( SmallIcon("xclock"), i18n("&Schedule scan..."), this, SLOT(slotScheduleScan()) );
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->setCheckable(true);
@@ -122,9 +131,9 @@ Klamav::Klamav()
connect(freshklam->search_button,SIGNAL(clicked()),SLOT(contextUpdateFK()));
connect(freshklam->cancel_button,SIGNAL(clicked()),SLOT(contextDisableFK()));
-
-
-
+
+
+
kuarantine = new Kuarantine(this, "Quarantine");
updateTabState(1, true); // Quarantine tab
@@ -135,19 +144,24 @@ Klamav::Klamav()
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 *)));
KStdAction::quit(this, SLOT(shuttingDown()), actionCollection());
-
+
if (TDEApplication::kApplication()->isRestored()){
hide();
}else{
show();
}
-
+
if ((firstDownload) || (downloadDBForWizard)){
kdDebug() << "firstdownload" << firstDownload << endl;
kdDebug() << "downloadDBForWizard" << downloadDBForWizard << endl;
@@ -160,10 +174,11 @@ Klamav::Klamav()
setCaption(TQString("KlamAV %1 (Using ClamAV %2)").arg(KLAMAV_VERSION).arg(KlamavConfig::clamAVVersion()));
}
-
+
Klamav::~Klamav()
{
- KlamavConfig::writeConfig();
+ klamonacc->stop();
+ KlamavConfig::writeConfig();
kapp->quit();
}
@@ -174,10 +189,10 @@ void Klamav::shuttingDown(){
}
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>"
" <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();
return false;
@@ -185,14 +200,6 @@ bool Klamav::queryClose() {
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 ) {
if( config->group() != "Tabs" )
config->setGroup("Tabs");
@@ -329,6 +336,27 @@ void Klamav::slotToggleEvents() {
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() {
@@ -341,12 +369,21 @@ void Klamav::contextEnableFK() {
}
void Klamav::contextDisableFK() {
-
+
freshklam->slotCancel();
// DisableFreshklam->setEnabled(FALSE);
// EnableFreshklam->setEnabled(TRUE);
}
+
+void Klamav::contextEnableKOA() {
+ klamonacc->start();
+}
+
+void Klamav::contextDisableKOA() {
+ klamonacc->stop();
+}
+
void Klamav::showVirusBrowser() {
tab->setCurrentPage(5);
}
@@ -355,11 +392,11 @@ void Klamav::firstRunWizard() {
FirstRunWizard wizard;
wizard.setCaption( i18n( "First-Run Wizard" ));
-
+
TQString homepath = getenv("HOME");
TQString defaultdb = homepath + "/.klamav/database";
TQString defaultquar = homepath + "/.klamav/quarantine";
-
+
// Execute wizard
wizard.exec();
@@ -367,7 +404,7 @@ void Klamav::firstRunWizard() {
TDEConfig* config = TDEGlobal::config();
config->setGroup("Freshklam");
-
+
TQString wizardDBPath = wizard.databasePath().path(-1);
TQString wizardTQRPath = wizard.quarantinePath().path(-1);
@@ -385,9 +422,9 @@ void Klamav::firstRunWizard() {
//Configure Quarantine Path
TQStringList lastQuarLocations;
-
+
config->setGroup("Kuarantine");
-
+
if ((wizardTQRPath != "") && (TQDir::cleanDirPath(wizardTQRPath) != defaultquar)){
lastQuarLocations.prepend( TQString("%1").arg(wizardTQRPath));
checkDir(wizardTQRPath);
@@ -434,13 +471,12 @@ void Klamav::checkDir(TQString path){
TQFile f1( path );
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));
- f1.close();
+ f1.close();
}
void Klamav::slotConfigKlamav( const TQCString& page )
{
-
KlamavConfigDialog* dialog = (KlamavConfigDialog*) TDEConfigDialog::exists( "settings" );
if( !dialog )