diff options
author | Mavridis Philippe <[email protected]> | 2021-02-10 23:03:30 +0200 |
---|---|---|
committer | Mavridis Philippe <[email protected]> | 2021-02-10 23:03:30 +0200 |
commit | 3747174d7835e7ea2332065c6948dbfbb1d26449 (patch) | |
tree | 0a23633dd2d6030956e72cb5a2d3fde73a06b84d /src/klamscan.cpp | |
parent | 6e18c223b2c9e5b598298824dd775117218b0c94 (diff) | |
download | klamav-3747174d7835e7ea2332065c6948dbfbb1d26449.tar.gz klamav-3747174d7835e7ea2332065c6948dbfbb1d26449.zip |
Moved pruneSelectedDirs() from Klamscan to the widget class itself.
This makes more sense and will permit to use this method in other
scenarios.
Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'src/klamscan.cpp')
-rw-r--r-- | src/klamscan.cpp | 109 |
1 files changed, 26 insertions, 83 deletions
diff --git a/src/klamscan.cpp b/src/klamscan.cpp index 2a945e3..0e0812e 100644 --- a/src/klamscan.cpp +++ b/src/klamscan.cpp @@ -44,7 +44,7 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) -/* scanInProgress = FALSE; +/* scanInProgress = FALSE; multiScan = FALSE; */ setDefaults(); TQBoxLayout *top = new TQVBoxLayout(this,10,10); @@ -54,9 +54,9 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) tabBrowser->setMargin(5); top->addWidget(tabBrowser); - + /* dblayout->addMultiCellWidget( tabBrowser, 0, 1, 1, 1 );*/ - + //TQGridLayout *layout = new TQGridLayout(this, 6, 3, 10, 4); TQWidget* privateLayoutWidget2 = new TQWidget( this, "dblayout" ); @@ -70,9 +70,9 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) layout->setRowStretch(2, 10); layout->addRowSpacing(4, 10); layout->setRowStretch(4, 0); - - - + + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); @@ -91,7 +91,7 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) //check_combo->setFixedSize(check_combo->size()); layout->addWidget(check_combo,0,1); - + recursive_box = new TQCheckBox(i18n("&Scan Folders Recursively"), privateLayoutWidget2); recursive_box->setMinimumWidth(recursive_box->sizeHint().width()); recursive_box->setChecked(true); @@ -129,7 +129,7 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) connect( recursive_box, SIGNAL(toggled(bool)),setup, SLOT(slotRecursiveToggled(bool)) ); - + TQHBox* controls = new TQHBox(tabBrowser); //controls->setSpacing(5); @@ -192,7 +192,7 @@ Klamscan::Klamscan(TQWidget *parent, const char *name) if( args->isSet( "scanthis" ) ) { slotScan(); } - + } @@ -212,10 +212,10 @@ bool Klamscan::scanGoingOn() { void Klamscan::scan( TQStringList filepattern ) { ScanViewer* homepage = new ScanViewer(this, "page"); - + connect( homepage, SIGNAL( scanFinished(TQWidget *) ), this, SLOT( slotManageButtons(TQWidget *) ) ); - + connect( homepage, SIGNAL( scanStartingAgain(TQWidget *) ), this, SLOT( slotManageButtons(TQWidget *) ) ); @@ -227,7 +227,7 @@ void Klamscan::scan( TQStringList filepattern ) { TQString suffix = TQString("%1 %2") .arg(today.toString("ddd MMMM d yyyy")) .arg(now.toString("hh:mm ap")); - + tabBrowser->addTab(homepage,suffix); tabBrowser->setCurrentPage(tabBrowser->count() - 1); @@ -242,7 +242,7 @@ void Klamscan::slotScan() TQStringList filepattern; TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - + if( args->isSet( "scanthis" ) ) { listOfUrlsToScan.clear(); for( int i = 0; i < args->count(); i++ ) { @@ -252,8 +252,8 @@ void Klamscan::slotScan() } prevdir = listOfUrlsToScan.first(); - }else{ - filepattern = pruneSelectedDirs(); + }else{ + filepattern = setup->pruneSelectedDirs(); } scan( filepattern ); @@ -289,20 +289,20 @@ void Klamscan::slotAdvOptions(){ /* KlamscanOptions *dialog = new KlamscanOptions( this, "settings"); - + dialog->show(); dialog->raise(); dialog->setActiveWindow();*/ tdemain->slotConfigKlamav( "Scanning Backend" ); - + } void Klamscan::slotSchedule(){ - TQStringList filepattern = pruneSelectedDirs(); + TQStringList filepattern = setup->pruneSelectedDirs(); if (filepattern.isEmpty()){ @@ -314,7 +314,7 @@ void Klamscan::slotSchedule(){ dialog->show(); dialog->raise(); dialog->setActiveWindow(); - + } @@ -323,7 +323,7 @@ void Klamscan::setDefaults(){ config = TDEGlobal::config(); config->setGroup("ScanPaths"); - + config->setGroup("Klamscan"); if ((config->readEntry("NoFilesToExtract")).isEmpty()) @@ -334,7 +334,7 @@ void Klamscan::setDefaults(){ // if ((config->readEntry("MBsToExtract")).isEmpty()) // config->writeEntry("MBsToExtract","10M"); -// +// // if ((config->readEntry("CompressionRatio")).isEmpty()) // config->writeEntry("CompressionRatio","250"); @@ -390,23 +390,23 @@ void Klamscan::scanURLs(const TQString &urls) //urlsToScan = temp; ScanViewer* homepage = new ScanViewer(this, "page"); - + connect( homepage, SIGNAL( scanFinished(TQWidget *) ), this, SLOT( slotManageButtons(TQWidget *) ) ); connect( homepage, SIGNAL( scanStartingAgain(TQWidget *) ), this, SLOT( slotManageButtons(TQWidget *) ) ); - + TQDate today = TQDate::currentDate(); TQTime now = TQTime::currentTime(); TQString suffix = TQString("%1 %2") .arg(today.toString("ddd MMMM d yyyy")) .arg(now.toString("hh:mm ap")); - + tabBrowser->addTab(homepage,suffix); tabBrowser->setCurrentPage(tabBrowser->count() - 1); CollectionDB::instance()->insertEvent("Manual Scan",TQString("Commencing Scan"),urlsToScan.join(" ")); - + homepage->slotScan(urlsToScan, check_combo->currentItem(),setup->recursive(),true); } @@ -458,7 +458,7 @@ void Klamscan::slotManageButtons(TQWidget * current){ m_tabsClose->setEnabled(false); return; } - + if (cur->scanGoingOn()){ play->setEnabled(false); stop->setEnabled(true); @@ -470,61 +470,4 @@ void Klamscan::slotManageButtons(TQWidget * current){ } -TQStringList Klamscan::pruneSelectedDirs(){ - - - //This gets rid of redundant sub-directories from the list of dirs to be scanned. - - TQStringList filepattern; - TQStringList listOfUrlsToScan = setup->dirs(); - listOfUrlsToScan.sort(); - TQString prev; - TQStringList prevdirs; - struct stat sb; - for (TQStringList::Iterator it = listOfUrlsToScan.begin(); it != listOfUrlsToScan.end(); it++ ){ - //kdDebug() << "dir: " << (*it) << endl; - (*it) = (*it).stripWhiteSpace(); - - // replace block devices with mountpoints - lstat( (*it).ascii(), &sb ); - if ( (sb.st_mode & S_IFMT) == S_IFBLK ) { - // This is actually from directorylist.cpp - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call( "properties", (*it) ); - - TQStringList properties; - reply.get( properties, "TQStringList" ); - - (*it) = * (properties.at(7) ); - } else { - (*it) = (*it) + "/"; - } - - if (prevdirs.isEmpty()){ - //kdDebug() << (*it) << endl; - filepattern.append(*it); - prevdirs.append((*it)); - }else{ - filepattern.append(*it); - bool shouldappend = true; - for (TQStringList::Iterator it2 = prevdirs.begin(); it2 != prevdirs.end(); it2++ ){ - if ((*it).contains(*it2)){ - //kdDebug() << (*it) << endl; - filepattern.remove((*it)); - shouldappend = false; - break; - } - } - if (shouldappend) - prevdirs.append((*it)); - } - } - - - - return filepattern; - -} - - #include "klamscan.moc" |