@ -39,9 +39,9 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
: TQWidget ( parent , name )
: TQWidget ( parent , name )
{
{
scanInProgress = TRUE ;
scanInProgress = TRUE ;
multiScan = FALSE ;
multiScan = FALSE ;
//TQGridLayout *layout = new TQGridLayout(this, 6, 3, 10, 4);
//TQGridLayout *layout = new TQGridLayout(this, 6, 3, 10, 4);
layout = new TQGridLayout ( this , 6 , 3 , 10 , 4 ) ;
layout = new TQGridLayout ( this , 6 , 3 , 10 , 4 ) ;
layout - > setColStretch ( 0 , 10 ) ;
layout - > setColStretch ( 0 , 10 ) ;
@ -53,9 +53,9 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
layout - > setRowStretch ( 2 , 10 ) ;
layout - > setRowStretch ( 2 , 10 ) ;
layout - > addRowSpacing ( 4 , 10 ) ;
layout - > addRowSpacing ( 4 , 10 ) ;
layout - > setRowStretch ( 4 , 0 ) ;
layout - > setRowStretch ( 4 , 0 ) ;
resultview = new TQListView ( this ) ;
resultview = new TQListView ( this ) ;
resultview - > setShowSortIndicator ( true ) ;
resultview - > setShowSortIndicator ( true ) ;
@ -77,24 +77,24 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
menu = new TQPopupMenu ( resultview ) ;
menu = new TQPopupMenu ( resultview ) ;
connect ( resultview , SIGNAL ( contextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) ,
connect ( resultview , SIGNAL ( contextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) ,
this , SLOT ( slotRMB ( TQListViewItem * , const TQPoint & , int ) ) ) ;
this , SLOT ( slotRMB ( TQListViewItem * , const TQPoint & , int ) ) ) ;
status_frame = new TQFrame ( this ) ;
status_frame = new TQFrame ( this ) ;
status_frame - > setFrameStyle ( TQFrame : : Panel | TQFrame : : Sunken ) ;
status_frame - > setFrameStyle ( TQFrame : : Panel | TQFrame : : Sunken ) ;
TQBoxLayout * status_layout = new TQHBoxLayout ( status_frame , 2 ) ;
TQBoxLayout * status_layout = new TQHBoxLayout ( status_frame , 2 ) ;
status_label = new TQLabel ( " " , status_frame ) ;
status_label = new TQLabel ( " " , status_frame ) ;
status_layout - > addWidget ( status_label , 10 ) ;
status_layout - > addWidget ( status_label , 10 ) ;
//matches_label = new TQLabel(status_frame);
//matches_label = new TQLabel(status_frame);
//TQFontMetrics ml_fm(matches_label->fontMetrics());
//TQFontMetrics ml_fm(matches_label->fontMetrics());
//matches_label->setFixedWidth(ml_fm.width(i18n("9999 viruses/errors found")));
//matches_label->setFixedWidth(ml_fm.width(i18n("9999 viruses/errors found")));
//matches_label->setFixedHeight(ml_fm.lineSpacing());
//matches_label->setFixedHeight(ml_fm.lineSpacing());
//status_layout->addWidget(matches_label, 0);
//status_layout->addWidget(matches_label, 0);
status_layout - > activate ( ) ;
status_layout - > activate ( ) ;
status_frame - > adjustSize ( ) ;
status_frame - > adjustSize ( ) ;
status_frame - > setMinimumSize ( status_frame - > size ( ) ) ;
status_frame - > setMinimumSize ( status_frame - > size ( ) ) ;
@ -103,7 +103,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
status2_frame = new TQFrame ( this ) ;
status2_frame = new TQFrame ( this ) ;
status2_frame - > setFrameStyle ( TQFrame : : Panel | TQFrame : : Sunken ) ;
status2_frame - > setFrameStyle ( TQFrame : : Panel | TQFrame : : Sunken ) ;
status2_layout = new TQHBoxLayout ( status2_frame , 2 ) ;
status2_layout = new TQHBoxLayout ( status2_frame , 2 ) ;
status2_label = new TQLabel ( i18n ( " Files scanned: 0 " ) , status2_frame ) ;
status2_label = new TQLabel ( i18n ( " Files scanned: 0 " ) , status2_frame ) ;
status2_layout - > addWidget ( status2_label , 10 ) ;
status2_layout - > addWidget ( status2_label , 10 ) ;
status2_label - > hide ( ) ;
status2_label - > hide ( ) ;
@ -135,7 +135,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
matches2_label - > setFixedWidth ( ml_fm2 . width ( i18n ( " 9999 viruses/problems found " ) ) ) ;
matches2_label - > setFixedWidth ( ml_fm2 . width ( i18n ( " 9999 viruses/problems found " ) ) ) ;
matches2_label - > setFixedHeight ( ml_fm2 . lineSpacing ( ) ) ;
matches2_label - > setFixedHeight ( ml_fm2 . lineSpacing ( ) ) ;
status2_layout - > addWidget ( matches2_label , 0 ) ;
status2_layout - > addWidget ( matches2_label , 0 ) ;
TQToolTip : : add ( matches2_label , i18n ( " cf. 'Flanderseses' - Homer Simpson. This childish joke will be removed when KlamAV is more mature. " ) ) ;
TQToolTip : : add ( matches2_label , i18n ( " cf. 'Flanderseses' - Homer Simpson. This childish joke will be removed when KlamAV is more mature. " ) ) ;
status2_layout - > activate ( ) ;
status2_layout - > activate ( ) ;
@ -144,7 +144,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name)
layout - > addMultiCellWidget ( status2_frame , 4 , 4 , 0 , 2 ) ;
layout - > addMultiCellWidget ( status2_frame , 4 , 4 , 0 , 2 ) ;
layout - > activate ( ) ;
layout - > activate ( ) ;
@ -209,7 +209,7 @@ void ScanViewer::processOutput()
filesscanned + + ;
filesscanned + + ;
if ( ! ( showProgress ) )
if ( ! ( showProgress ) )
status2_label - > setText ( i18n ( " Files scanned: %1 " ) . arg ( filesscanned ) ) ;
status2_label - > setText ( i18n ( " Files scanned: %1 " ) . arg ( filesscanned ) ) ;
//}else if ((pos = buf.section('\n',j,j).find("ERROR:")) != -1){
//}else if ((pos = buf.section('\n',j,j).find("ERROR:")) != -1){
} else if ( ( pos = ( item2 . find ( " ERROR: " ) ) ) ! = - 1 ) {
} else if ( ( pos = ( item2 . find ( " ERROR: " ) ) ) ! = - 1 ) {
TQString tmpVirusName = item2 . mid ( ( fnameEndPoint + 1 ) , ( item2 . length ( ) - ( fnameEndPoint + 1 ) ) ) ;
TQString tmpVirusName = item2 . mid ( ( fnameEndPoint + 1 ) , ( item2 . length ( ) - ( fnameEndPoint + 1 ) ) ) ;
@ -241,7 +241,7 @@ void ScanViewer::processOutput()
" - Access Denied! " ) . arg ( tmpFName ) ) ;
" - Access Denied! " ) . arg ( tmpFName ) ) ;
CollectionDB : : instance ( ) - > insertEvent ( " Error Found " , " Access Denied " , tmpFName ) ;
CollectionDB : : instance ( ) - > insertEvent ( " Error Found " , " Access Denied " , tmpFName ) ;
//}else if ((pos = buf.section('\n',j,j).find(": Can't open")) != -1){
//}else if ((pos = buf.section('\n',j,j).find(": Can't open")) != -1){
} else if ( ( pos = ( item2 . find ( " : Can't open " ) ) ) ! = - 1 ) {
} else if ( ( pos = ( item2 . find ( " : Can't open " ) ) ) ! = - 1 ) {
//status2_label->setText(i18n("Files scanned: %1").arg(++filesscanned));
//status2_label->setText(i18n("Files scanned: %1").arg(++filesscanned));
filesscanned + + ;
filesscanned + + ;
@ -280,9 +280,9 @@ void ScanViewer::processOutput()
void ScanViewer : : slotScan ( const TQStringList & filepattern , int mode , bool recursive , bool dcopscan )
void ScanViewer : : slotScan ( const TQStringList & filepattern , int mode , bool recursive , bool dcopscan )
{
{
//KMessageBox::information (this, filepattern);
//KMessageBox::information (this, filepattern);
TDECmdLineArgs * args = TDECmdLineArgs : : parsedArgs ( ) ;
TDECmdLineArgs * args = TDECmdLineArgs : : parsedArgs ( ) ;
if ( ( args - > isSet ( " scanthis " ) ) | | ( dcopscan ) ) {
if ( ( args - > isSet ( " scanthis " ) ) | | ( dcopscan ) ) {
calculateTime = FALSE ;
calculateTime = FALSE ;
showProgress = FALSE ;
showProgress = FALSE ;
@ -341,13 +341,16 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
//kdDebug() << filepattern << endl;
//kdDebug() << filepattern << endl;
prog - > setTotalSteps ( cnt ) ;
prog - > setTotalSteps ( cnt ) ;
kdDebug ( ) < < " COUNT " < < cnt < < endl ;
kdDebug ( ) < < " COUNT " < < cnt < < endl ;
config = TDEGlobal : : config ( ) ;
config = TDEGlobal : : config ( ) ;
config - > setGroup ( " KlamavBackend " ) ;
clamdscan = config - > readBoolEntry ( " ScannerClamdscan " , false ) ;
slotClear ( ) ;
slotClear ( ) ;
QuarantineList . clear ( ) ;
QuarantineList . clear ( ) ;
errorsEncountered = FALSE ;
errorsEncountered = FALSE ;
filesscanned = 0 ;
filesscanned = 0 ;
//status2_label->setText(i18n("Scan in Progress..."));
//status2_label->setText(i18n("Scan in Progress..."));
@ -363,17 +366,17 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
db = * ita ;
db = * ita ;
}
}
}
}
////kdDebug() << "here 2" << endl;
////kdDebug() << "here 2" << endl;
TQString dbpath ;
TQString dbpath ;
TQString excludes ;
TQString excludes ;
TQString options ;
TQString options ; // can not be used for clamdscan
if ( ! ( db . isEmpty ( ) ) )
if ( ! ( db . isEmpty ( ) ) )
dbpath = TQString ( " -d %1 " ) . arg ( db ) ;
dbpath = TQString ( " -d %1 " ) . arg ( db ) ;
config - > setGroup ( " Klamscan " ) ;
config - > setGroup ( " Klamscan " ) ;
if ( config - > readEntry ( " ExcludeQuarantine " ) = = " Yes " ) {
if ( config - > readEntry ( " ExcludeQuarantine " ) = = " Yes " ) {
config - > setGroup ( " Kuarantine " ) ;
config - > setGroup ( " Kuarantine " ) ;
TQStringList lastQuarLocations = config - > readListEntry ( " KuarantineLocations " ) ;
TQStringList lastQuarLocations = config - > readListEntry ( " KuarantineLocations " ) ;
@ -384,7 +387,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
excludes + = TQString ( " --exclude=%1 " ) . arg ( quarloc ) ;
excludes + = TQString ( " --exclude=%1 " ) . arg ( quarloc ) ;
}
}
//if ((recursive_box->isChecked() && !(multiScan)) || (multi_recursive && multiScan))
//if ((recursive_box->isChecked() && !(multiScan)) || (multi_recursive && multiScan))
if ( recursive )
if ( recursive )
options + = " -r " ;
options + = " -r " ;
@ -397,7 +400,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
// if (KlamavConfig::mBsToExtract() > 0)
// if (KlamavConfig::mBsToExtract() > 0)
// options += "--max-space=" + TQString("%1").arg(KlamavConfig::mBsToExtract()) + " ";
// options += "--max-space=" + TQString("%1").arg(KlamavConfig::mBsToExtract()) + " ";
//
//
// if (KlamavConfig::compressionRatio() > 0)
// if (KlamavConfig::compressionRatio() > 0)
// options += "--max-ratio=" + TQString("%1").arg(KlamavConfig::compressionRatio()) + " ";
// options += "--max-ratio=" + TQString("%1").arg(KlamavConfig::compressionRatio()) + " ";
@ -410,7 +413,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
if ( KlamavConfig : : maxScanSize ( ) > 0 )
if ( KlamavConfig : : maxScanSize ( ) > 0 )
options + = " --max-scansize= " + TQString ( " %1 " ) . arg ( KlamavConfig : : maxScanSize ( ) ) + " M " ;
options + = " --max-scansize= " + TQString ( " %1 " ) . arg ( KlamavConfig : : maxScanSize ( ) ) + " M " ;
//config->setGroup("Klamscan");
//config->setGroup("Klamscan");
// if (KlamavConfig::virusLimitsExceeded())
// if (KlamavConfig::virusLimitsExceeded())
// options += "--block-max ";
// options += "--block-max ";
@ -423,7 +426,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
if ( ! ( KlamavConfig : : scanHTML ( ) ) )
if ( ! ( KlamavConfig : : scanHTML ( ) ) )
options + = " --no-html " ;
options + = " --no-html " ;
if ( ! ( KlamavConfig : : scanPE ( ) ) )
if ( ! ( KlamavConfig : : scanPE ( ) ) )
options + = " --no-pe " ;
options + = " --no-pe " ;
@ -449,7 +452,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
else
else
options + = " " ;
options + = " " ;
}
}
if ( KlamavConfig : : scanArj ( ) ) {
if ( KlamavConfig : : scanArj ( ) ) {
options + = " --arj " ;
options + = " --arj " ;
if ( ( KlamavConfig : : arjUsing ( ) ) ! = " " )
if ( ( KlamavConfig : : arjUsing ( ) ) ! = " " )
@ -465,7 +468,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
else
else
options + = " " ;
options + = " " ;
}
}
if ( KlamavConfig : : scanLzh ( ) ) {
if ( KlamavConfig : : scanLzh ( ) ) {
options + = " --lha " ;
options + = " --lha " ;
if ( ( KlamavConfig : : lzhUsing ( ) ) ! = " " )
if ( ( KlamavConfig : : lzhUsing ( ) ) ! = " " )
@ -506,21 +509,59 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur
options + = " " ;
options + = " " ;
}
}
kdDebug ( ) < < " clamscan -v "
if ( clamdscan ) {
< < excludes < < " "
// make sure that clamd is running
< < dbpath < < " "
FILE * clamdpid ;
< < options < < " "
if ( clamdpid = fopen ( " /run/clamav/clamd.pid " , " r " ) )
< < " ' " + m_filepattern . join ( " ' ' " ) + " ' " < < endl ;
fclose ( clamdpid ) ; // it's ok
else {
int choice = KMessageBox : : warningYesNoCancel (
this ,
i18n ( " The ClamAV daemon does not seem to be running on this system. Do you really want to continue with this scan or would you like to launch a standalone scan instead?' " ) ,
i18n ( " Clamd not running " ) ,
i18n ( " Continue this scan " ) ,
i18n ( " Launch standalone scan " ) ,
i18n ( " Do not ask me again " )
) ;
switch ( choice ) {
case 2 : // cancel
return ;
break ;
case 4 : // launch standalone scan
clamdscan = false ;
break ;
}
}
}
childproc = new KProcIO ( ) ;
childproc = new KProcIO ( ) ;
childproc - > setUseShell ( TRUE ) ;
childproc - > setUseShell ( TRUE ) ;
childproc - > setUsePty ( KProcIO : : Stdout , TRUE ) ;
childproc - > setUsePty ( KProcIO : : Stdout , TRUE ) ;
* childproc < < " clamscan -v " ;
if ( clamdscan ) {
* childproc < < excludes < < " " ;
config - > setGroup ( " KlamavBackend " ) ;
* childproc < < dbpath < < " " ;
TQString multiscanOption = config - > readBoolEntry ( " ClamdMultiscan " , true ) ? " -m " : " " ;
* childproc < < options < < " " ;
kdDebug ( ) < < " clamdscan -v "
< < multiscanOption
< < " ' " + m_filepattern . join ( " ' ' " ) + " ' " < < endl ;
* childproc < < " clamdscan -v " ;
* childproc < < multiscanOption ;
} else {
kdDebug ( ) < < " clamscan -v "
< < excludes < < " "
< < dbpath < < " "
< < options < < " "
< < " ' " + m_filepattern . join ( " ' ' " ) + " ' " < < endl ;
* childproc < < " clamscan -v " ;
* childproc < < excludes < < " " ;
* childproc < < dbpath < < " " ;
* childproc < < options < < " " ;
}
* childproc < < " ' " + m_filepattern . join ( " ' ' " ) + " ' " ;
* childproc < < " ' " + m_filepattern . join ( " ' ' " ) + " ' " ;
@ -601,7 +642,7 @@ void ScanViewer::childExited()
int status = childproc - > exitStatus ( ) ;
int status = childproc - > exitStatus ( ) ;
int result ;
int result ;
status2_label - > setText ( i18n ( " Scan Complete " ) ) ;
status2_label - > setText ( i18n ( " Scan Complete " ) ) ;
CollectionDB : : instance ( ) - > insertEvent ( " Manual Scan " , TQString ( " Scan Complete " ) , m_filepattern . join ( " " ) ) ;
CollectionDB : : instance ( ) - > insertEvent ( " Manual Scan " , TQString ( " Scan Complete " ) , m_filepattern . join ( " " ) ) ;
@ -743,7 +784,7 @@ void ScanViewer::Quarantine(){
KMessageBox : : information ( this , i18n ( " <p>There was a problem quarantining <b>%1</b>. Check your diskspace, the permissions on your quarantine location and whether a file with the same name already exists in the quarantine. </p> " ) . arg ( fname ) ) ;
KMessageBox : : information ( this , i18n ( " <p>There was a problem quarantining <b>%1</b>. Check your diskspace, the permissions on your quarantine location and whether a file with the same name already exists in the quarantine. </p> " ) . arg ( fname ) ) ;
}
}
}
}
}
}
if ( allQuarantined )
if ( allQuarantined )
@ -752,7 +793,7 @@ void ScanViewer::Quarantine(){
tdemain - > _tray - > setPixmap ( KSystemTray : : loadIcon ( " klamav_scan_found " ) ) ;
tdemain - > _tray - > setPixmap ( KSystemTray : : loadIcon ( " klamav_scan_found " ) ) ;
config - > writeEntry ( TQString ( " Items %1 " ) . arg ( quarloc ) , lastQuarItems ) ;
config - > writeEntry ( TQString ( " Items %1 " ) . arg ( quarloc ) , lastQuarItems ) ;
config - > sync ( ) ;
config - > sync ( ) ;
//tdemain->kuarantine->refresh();
//tdemain->kuarantine->refresh();
@ -807,7 +848,7 @@ void ScanViewer::slotQuarantineSelected()
TQPtrList < TQListViewItem > list ;
TQPtrList < TQListViewItem > list ;
TQListViewItemIterator it ( resultview , TQListViewItemIterator : : Selected ) ;
TQListViewItemIterator it ( resultview , TQListViewItemIterator : : Selected ) ;
QuarantineList = " " ;
QuarantineList = " " ;
while ( it . current ( ) ) {
while ( it . current ( ) ) {
TQListViewItem * tItem = it . current ( ) ;
TQListViewItem * tItem = it . current ( ) ;
@ -844,7 +885,7 @@ void ScanViewer::slotStartAgain()
calculateTime = TRUE ;
calculateTime = TRUE ;
emit scanStartingAgain ( this ) ;
emit scanStartingAgain ( this ) ;
slotScan ( m_filepattern , m_mode , m_recursive , false ) ;
slotScan ( m_filepattern , m_mode , m_recursive , false ) ;
}
}
@ -865,22 +906,22 @@ void ScanViewer::slotCancelScanTime()
// void ScanViewer::startProgress()
// void ScanViewer::startProgress()
// {
// {
//
//
// cnt = 0;
// cnt = 0;
// //kdDebug() << "m_filepattern" << m_filepattern << endl;
// //kdDebug() << "m_filepattern" << m_filepattern << endl;
// TQDir d( m_filepattern );
// TQDir d( m_filepattern );
// // int num = countFiles(d);
// // int num = countFiles(d);
// // if (countFiles(d) > 0)
// // if (countFiles(d) > 0)
// // //kdDebug() << "count" << num << endl;
// // //kdDebug() << "count" << num << endl;
//
//
// progress = new KProgressDialog (this, "progress", i18n( "Loading .." ), i18n( "Loading..." ), true);
// progress = new KProgressDialog (this, "progress", i18n( "Loading .." ), i18n( "Loading..." ), true);
// progress->setAllowCancel(false);
// progress->setAllowCancel(false);
// prog = progress->progressBar();
// prog = progress->progressBar();
// progress->setLabel(i18n( "Loading lots and lots and lots of virus information" ));
// progress->setLabel(i18n( "Loading lots and lots and lots of virus information" ));
// //int cnt = countFiles(d);
// //int cnt = countFiles(d);
// prog->setTotalSteps(countFiles(d));
// prog->setTotalSteps(countFiles(d));
// //kdDebug() << "COUNT" << countFiles(d) << endl;
// //kdDebug() << "COUNT" << countFiles(d) << endl;
//
//
// }
// }
int ScanViewer : : countFiles ( TQDir & root )
int ScanViewer : : countFiles ( TQDir & root )
@ -894,15 +935,15 @@ int ScanViewer::countFiles( TQDir & root)
}
}
TQStringList entries = root . entryList ( TQDir : : Dirs | TQDir : : Files | TQDir : : Hidden ) ;
TQStringList entries = root . entryList ( TQDir : : Dirs | TQDir : : Files | TQDir : : Hidden ) ;
////kdDebug() << "count" << counter << endl;
////kdDebug() << "count" << counter << endl;
for ( TQStringList : : size_type j = 0 ; j < entries . size ( ) ; j + + )
for ( TQStringList : : size_type j = 0 ; j < entries . size ( ) ; j + + )
{
{
TQString entry = entries [ j ] ;
TQString entry = entries [ j ] ;
if ( entry = = " . " | | entry = = " .. " )
if ( entry = = " . " | | entry = = " .. " )
continue ;
continue ;
TQFileInfo fi ( root , entry ) ;
TQFileInfo fi ( root , entry ) ;
entry = fi . absFilePath ( ) ;
entry = fi . absFilePath ( ) ;
@ -980,7 +1021,7 @@ void ScanViewer::slotOnItem( TQListViewItem * lineitem)
status_label - > setText ( message ) ;
status_label - > setText ( message ) ;
}
}
void ScanViewer : : slotOffItem ( )
void ScanViewer : : slotOffItem ( )