From cb9983144be814ee0ec28d9fed7399f98aab202c Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 15 Jan 2021 00:06:34 +0200 Subject: Freshklam: removed remains of code related to KlamAV updates. Signed-off-by: Mavridis Philippe --- src/Makefile.am | 2 +- src/freshklam.cpp | 2 - src/freshklam.h | 3 - src/update.cpp | 562 ------------------------------------------------------ src/update.h | 125 ------------ 5 files changed, 1 insertion(+), 693 deletions(-) delete mode 100644 src/update.cpp delete mode 100644 src/update.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 37d3161..e377252 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ klamav_SOURCES = main.cpp klamav.cpp freshklam.cpp sigtool.cpp klamscan.cpp \ ctcron.cpp ctmonth.cpp ctdom.cpp ctdow.cpp cttask.cpp ctvariable.cpp \ ktlistitem.cpp ktlisttask.cpp ktlisttasks.cpp ktview.cpp ktlistcron.cpp \ kticon.cpp activityviewer.cpp collectiondb.cpp archivelimits.ui \ - archivetypes.ui specialfiletypes.ui firstrunwizard.ui configdialog.cpp logoptions.ui klamavconfig.kcfgc k3bjobprogressosd_mod.cpp update.cpp + archivetypes.ui specialfiletypes.ui firstrunwizard.ui configdialog.cpp logoptions.ui klamavconfig.kcfgc k3bjobprogressosd_mod.cpp diff --git a/src/freshklam.cpp b/src/freshklam.cpp index ce8d0ae..f551025 100644 --- a/src/freshklam.cpp +++ b/src/freshklam.cpp @@ -80,8 +80,6 @@ Freshklam::Freshklam(TQWidget *parent, const char *name) // MetaDB* updater = new MetaDB(); // updater->update(); - updater = new KlamavUpdate(this); - connect( updater, SIGNAL( getCurrentVersionOfClamAV() ), SLOT( getCurrentVersionOfClamAV() ) ); diff --git a/src/freshklam.h b/src/freshklam.h index 1e2467a..948ec73 100644 --- a/src/freshklam.h +++ b/src/freshklam.h @@ -14,7 +14,6 @@ #include //stack allocated #include //stack allocated #include // namespace -#include "update.h" namespace DOM { class Node; @@ -38,7 +37,6 @@ class KURLRequester; class KLineEdit; class KProgressDialog; class KProcIO; -class KlamavUpdate; /** * This class serves as the main window for Freshklam. It handles the @@ -185,7 +183,6 @@ private: // KDirLister klamav_lister; // KURL klamav_url; KURL m_url; - KlamavUpdate* updater; }; #endif // _Freshklam_H_ diff --git a/src/update.cpp b/src/update.cpp deleted file mode 100644 index 2e8d8a4..0000000 --- a/src/update.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Robert Hogan * - * robert@roberthogan.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -#include "klamav.h" -#include "update.h" -#include "klamavconfig.h" - -#include - -#include -#include - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "version.h" - -#include - -const char *mirrors[] = { - "heanet", - "internap", - "surfnet", - "umn", - "nchc", - "ufpr", - "unc", - "jaist", - "voxel", - "citkit", - "optusnet", - "ovh", - "mesh", - "easynews", - "switch", - "kent", - "puzzle", - 0 -}; - -KlamavUpdate::KlamavUpdate(TQWidget *parent, const char *name) - : TQWidget(parent, name),filelist(new TDEHTMLPart(this)) -{ - - filelist->hide(); - filelist->setJScriptEnabled(false); - filelist->setJavaEnabled(false); - filelist->setAutoloadImages(false); - filelist->setDNDEnabled(false); - filelist->setPluginsEnabled(false); -} - - -KlamavUpdate::~KlamavUpdate() -{ - kdDebug() << "deleting" << endl; - //delete filelist; -} - - - -void KlamavUpdate::downloadComponent(TQString component, TQString version, TQString extension) -{ - - upgradeinprogress = true; - - TQString location = getenv("HOME"); - - location += "/.klamav"; - TQDir klamavdir(location); - if (!klamavdir.exists() && !klamavdir.mkdir(location)) - location = getenv("HOME"); - - TQString currentclamav = location + TQString("/%1-%2").arg(component).arg(version); - TQDir clamavdir(currentclamav); - - TQString configure; -/* if (component == "klamav"){ - configure = TQString("%1/%2-%3/%4-%5/configure").arg(location).arg(component).arg(version).arg(component).arg(version); - - }else{*/ - configure = TQString("%1/%2-%3/configure").arg(location).arg(component).arg(version); -// } - TQFile configurefile(configure); - - bool download = true; - - if (clamavdir.exists() && configurefile.exists()){ - int result = KMessageBox::questionYesNo(this, i18n( "You seem to have downloaded %1-%2 already (in %3/%4-%5). Would you like to skip re-downloading it and just try to compile it?").arg(component).arg(version).arg(location).arg(component).arg(version),i18n( "Compile %1" ).arg(component)); - - switch (result) { - case 2 : - download = true;break; - case 3 : - download = false; - } - } - - while (download){ - - startProgressDialog( i18n( "Downloading %1-%2..." ).arg(component).arg(version) ); - - TQString tmpFile; - if ( !TDEIO::NetAccess::download( TQString("http://%1.dl.sourceforge.net/sourceforge/%2/%3-%4.%5").arg(getMirror()).arg(component).arg(component).arg(version).arg(extension), tmpFile, 0L ) ){ - KMessageBox::information (this,i18n("Couldn't download %1.").arg(component)); - delete timer; - timer=0; - delete progressDialog; - progressDialog = 0; - upgradeinprogress = false; - return; - } - - kdDebug() << "Theme is in temp file: " << tmpFile << endl; - - if ((progressDialog) && (progressDialog->wasCancelled())){ - updateCanceled(); - return; - } - - - - progressDialog->setLabel( i18n( "Unpacking %1-%2 to %3/%4-%5" ).arg(component).arg(version).arg(location).arg(component).arg(version)); - - // unpack the tarball - KTar tar( tmpFile ); - if (!(tar.open( IO_ReadOnly ))){ - int result = KMessageBox::questionYesNo(this, i18n( "The mirror I attempted to download from has not updated yet. Should I try another?")); - kdDebug() << result << endl; - switch (result) { - case KMessageBox::Yes : - download = true; break; - case KMessageBox::No : - download = false; - default: - download = false; - } - }else{ - download = false; - } - tar.directory()->copyTo( location ); - tar.close(); - // remove the temp file - TDEIO::NetAccess::removeTempFile( tmpFile ); - - delete timer; - timer=0; - delete progressDialog; - progressDialog = 0; - } - - if ((progressDialog) && (progressDialog->wasCancelled())){ - updateCanceled(); - delete progressDialog; - progressDialog = 0; - return; - } - - //KTar does not honour executable permissions - - if (clamavdir.exists() && configurefile.exists()){ - - chmod((const char *)configure,0700); -// if (component == "klamav"){ -// TQString dazukoconfigure = i18n("%1/%2-%3/dazuko/configure").arg(location).arg(component).arg(version); -// -// chmod((const char *)dazukoconfigure,0700); -// } - - int result = KMessageBox::warningContinueCancel(this, i18n( "%1-%2 is ready for compiling and installation. Would you like the wizard to ask you for the root password so it can compile and install it for you? (If not, you can compile it yourself later at %3/%4-%5)").arg(component).arg(version).arg(location).arg(component).arg(version),i18n( "Install %1-%2" ).arg(component).arg(version),i18n( "Use the Wizard" )); - - switch (result) { - case 2 : - KMessageBox::information (this,i18n("Installation of %1 Cancelled.").arg(component)); - upgradeinprogress = false; - break; - case 5 : - - TDEProcess* arkollonproc = new KShellProcess(); - //make sure we catch arkollon in the .klamav directory -// TQString curpath = (TQString) getenv("PATH"); -// TQString homedir = (TQString) getenv("HOME"); -// arkollonproc->setEnvironment("PATH",homedir+"/.klamav/bin:" + curpath); - - KMessageBox::information (this,i18n( "

If this the first time you've compiled software then here are a few useful tips:
" - "1. Any error messages in the log file with the words 'TDE', 'TQt','curl' or 'X' in them mean that you need to install " - "the appropriate development libraries.
" - "2. Any package provided by your distribution with 'lib' or 'devel' in the name is a development library, e.g. qt-devel, libkde.
" - "3. If you encounter errors installing Dazuko, just deselect it at installation time and try the instructions at www.dazuko.org.
" - "4. Some distributions provide a dazuko package, see if yours does.

" ),"Compilation Tips","compiler"); - TQString command = TQString("klamarkollon %1/%2-%3").arg(location).arg(component).arg(version); - *arkollonproc << command; - if (component == "klamav") - connect( arkollonproc, SIGNAL(processExited(TDEProcess *)), SLOT(klamavInstallationExited(TDEProcess *)) ); - else - connect( arkollonproc, SIGNAL(processExited(TDEProcess *)), SLOT(clamavInstallationExited(TDEProcess *)) ); - arkollonproc->start(); - } - } - -} - -void KlamavUpdate::checkForNewKlamAV() -{ - - kdDebug() << "Checking for new KlamAV" << endl; - - checkingDirectly = false; - - highestsofarnumeric = 0; - klamav_url = "http://ftp.heanet.ie/mirrors/download.sourceforge.net/pub/sourceforge/k/kl/klamav/"; - getLatestVersionFromSFHack(klamav_url); - -} - -void KlamavUpdate::checkForNewKlamAVDirectly() -{ - - kdDebug() << "Checking for new KlamAV" << endl; - - checkingDirectly = true; - - highestsofarnumeric = 0; - klamav_url = "http://ftp.heanet.ie/mirrors/download.sourceforge.net/pub/sourceforge/k/kl/klamav/"; - startProgressDialog( i18n( "Checking for new version of KlamAV..." ) ); - - getLatestVersionFromSF(klamav_url); - -} - - -void KlamavUpdate::checkForNewClamAVDirectly() -{ - - kdDebug() << "Checking for new ClamAV" << endl; - - checkingDirectly = true; - - highestsofarnumeric = 0; - clamav_url = "http://ftp.heanet.ie/mirrors/download.sourceforge.net/pub/sourceforge/c/cl/clamav/"; - - startProgressDialog( i18n( "Checking for new version of ClamAV..." ) ); - - getLatestVersionFromSF(clamav_url); - -} - -void KlamavUpdate::completedSearchForUpdates(const TQString &component, const TQString &extension) -{ - - double currentversion; - - if (component == "KlamAV") - currentversion = VERSION_KLAMAV; - else{ - TQString currentClamAVVersion = KlamavConfig::clamAVVersion(); - currentversion = numericizeVersion(currentClamAVVersion); - } - - kdDebug() << "in completed search for updates" << endl; - kdDebug() << currentversion << endl; - kdDebug() << highestsofarnumeric << endl; - - if (highestsofarnumeric > currentversion){ - int result = KMessageBox::warningContinueCancel(this, i18n( "It looks like your version of %1 is out of date! %2-%3 is the most recent version available. Would you like KlamAV to download and compile it for you?").arg(component).arg(component).arg(highestsofarraw),i18n( "Download and Install %1-%2" ).arg(component).arg(highestsofarraw),i18n( "Download and Install %1-%2" ).arg(component).arg(highestsofarraw)); - - switch (result) { - case 2 : - break; - case 5 : - downloadComponent(component.lower(), highestsofarraw, extension); - } - }else if (checkingDirectly){ - KMessageBox::information (this,i18n("Your installation of %1 is already up-to-date!").arg(component)); - } - checkingDirectly = false; - emit toggleUpgradeButtons(true); -// if (filelist) -// filelist->deleteLater(); - -} - - - -void KlamavUpdate::startProgressDialog( const TQString & text ) -{ - //if ( progressDialog ) - // delete progressDialog; - - progressDialog = new KProgressDialog( this, "progress_dialog", TQString::null, text, false ); - - progressDialog->setAllowCancel( true ); - progressDialog->showCancelButton( true ); - progressDialog->setPlainCaption( i18n( "Please Wait" ) ); - - progressDialog->progressBar()->setTotalSteps( 0 ); - progressDialog->progressBar()->setPercentageVisible( false ); - - progressDialog->setMinimumDuration( 500 ); - progressDialog->show(); - - timer = new TQTimer( this ); - connect( timer, SIGNAL( timeout() ), this, SLOT( slotProg() ) ); - - timer->start( 200, FALSE ); -} - -void KlamavUpdate::slotProg() -{ - - if (progressDialog) - progressDialog->progressBar()->setProgress(progressDialog->progressBar()->progress() + 4 ); -} - -void KlamavUpdate::clamavInstallationExited(TDEProcess* arkollonproc) -{ - - arkollonproc = 0; - delete arkollonproc; - upgradeinprogress = false; - emit getCurrentVersionOfClamAV( ); - -} - -void KlamavUpdate::klamavInstallationExited(TDEProcess* arkollonproc) -{ - - arkollonproc = 0; - delete arkollonproc; - upgradeinprogress = false; - - KMessageBox::information (this,i18n( "If the installation of KlamAV completed successfully you should restart KlamAV for the new version to take effect." )); - -} - - - - -void KlamavUpdate::getLatestVersionFromSF(KURL url) -{ - - kdDebug() << "getting latest version" << endl; - kdDebug() << url << endl; - emit toggleUpgradeButtons(false); - - connect( filelist, SIGNAL( completed() ), this, - SLOT( parseSFPage() ) ); - - filelist->openURL(url); - if (progressDialog) - connect( progressDialog, SIGNAL( cancelClicked() ), this, - SLOT( updateCanceled() ) ); - -} - -void KlamavUpdate::getLatestVersionFromSFHack(KURL url) -{ - - kdDebug() << "getting latest version" << endl; - kdDebug() << url << endl; - emit toggleUpgradeButtons(false); - - connect( filelist, SIGNAL( completed() ), this, - SLOT( parseSFPageHack() ) ); - - filelist->openURL(url); - -} - - - -void KlamavUpdate::updateCanceled() -{ - - kdDebug() << "cancelled" << endl; - filelist->closeURL(); - emit toggleUpgradeButtons(true); -} - -void KlamavUpdate::parseSFPage() -{ - - - kdDebug() << "parsing sf page" << endl; - - - const DOM::HTMLCollection links = filelist->htmlDocument().links(); - kdDebug() << links.length() << endl; - - if (links.length() == 0){ - KMessageBox::information (this,i18n( "Could not contact update server!" )); - updateCanceled(); - delete progressDialog; - progressDialog = 0; - return; - } - - disconnect( filelist, SIGNAL( completed() ), this, - SLOT( parseSFPage() ) ); - - for (unsigned int j=0; j != links.length(); j++ ){ - const DOM::Node linkNode = links.item( j ); - getVersionFromLink( linkNode ); - } - - delete progressDialog; - progressDialog = 0; - - kdDebug() << highestsofarfilename << endl; - if (highestsofarfilename.contains("klamav")) - completedSearchForUpdates("KlamAV", "tar.bz2"); - else if (highestsofarfilename.contains("clamav")) - completedSearchForUpdates("ClamAV", "tar.gz"); - - -} - -void KlamavUpdate::parseSFPageHack() -{ - - - kdDebug() << "parsing sf page" << endl; - - - const DOM::HTMLCollection links = filelist->htmlDocument().links(); - kdDebug() << links.length() << endl; - - if (links.length() == 0){ - return; - } - - disconnect( filelist, SIGNAL( completed() ), this, - SLOT( parseSFPageHack() ) ); - - for (unsigned int j=0; j != links.length(); j++ ){ - const DOM::Node linkNode = links.item( j ); - getVersionFromLink( linkNode ); - } - - //delete progressDialog; - //progressDialog = 0; - - kdDebug() << highestsofarfilename << endl; - if (highestsofarfilename.contains("klamav")) - completedSearchForUpdates("KlamAV", "tar.bz2"); - else if (highestsofarfilename.contains("clamav")) - completedSearchForUpdates("ClamAV", "tar.gz"); - - -} - - -void KlamavUpdate::getVersionFromLink( const DOM::Node &n ) -{ - double numericversion; - TQString tmpversion; - - if ( n.isNull() || n.nodeType() != DOM::Node::ELEMENT_NODE ) - return; - - DOM::Element elem = static_cast( n ); - - KURL href ( elem.getAttribute( "href" ).string() ); - - kdDebug() << elem.getAttribute( "href" ).string() << endl; - - TQString name = elem.getAttribute( "href" ).string(); - TQString version = name.replace(".tar.bz2","").replace(".tar.gz",""); - version = version.replace("clamav-","").replace("klamav-",""); - - TQString rawversion = version; - - if (m_alpha) - version.remove("-alpha").remove("-beta").remove("-rc"); - - numericversion = numericizeVersion(version); - - if (numericversion > highestsofarnumeric){ - highestsofarnumeric = numericversion; - highestsofarraw = rawversion; - highestsofarfilename = elem.getAttribute( "href" ).string(); - } - - -} - -TQString KlamavUpdate::getMirror() -{ - int r = 1+(int) (16.0*rand()/(RAND_MAX+1.0)); - static int previousmirror = 0; - - while (r == previousmirror) - r=1+(int) (16.0*rand()/(RAND_MAX+1.0)); - - previousmirror = r; - - kdDebug() << r << endl; - return mirrors[r]; -} - -double KlamavUpdate::numericizeVersion(TQString &version) -{ - TQString tmpversion = version; - TQStringList tokens = TQStringList::split(".",tmpversion); - for ( TQStringList::Iterator it = tokens.begin(); it != tokens.end(); it++ ) - { - if ((*it).length() < 2) - (*it).prepend("0"); - } - tmpversion = tokens.join("."); - - unsigned int firstdot = tmpversion.find("."); - for (unsigned int j=tmpversion.length(); j != firstdot; j-- ){ - if (tmpversion.mid(j,1) == "."){ - tmpversion.remove(j,1); - j--; - } - } - - return tmpversion.toDouble(); -} - -#include "update.moc" diff --git a/src/update.h b/src/update.h deleted file mode 100644 index b3fa5aa..0000000 --- a/src/update.h +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Robert Hogan * - * robert@roberthogan.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -#ifndef _UPDATE_H_ -#define _UPDATE_H_ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include //stack allocated -#include //stack allocated -#include // namespace -#include - - -namespace DOM { - class Node; -} - - -using namespace KNetwork; - -class KURL; -class TDEProcess; -class KURLRequester; -class KProgressDialog; -class KProcIO; -class TDEHTMLPart; - -/** - * This class serves as the main window for KlamavUpdate. It handles the - * menus, toolbars, and status bars. - * - * @short Main window class - * @author $AUTHOR <$EMAIL> - * @version $APP_VERSION - */ -class KlamavUpdate : public TQWidget -{ - Q_OBJECT - - public: - - KlamavUpdate(TQWidget *parent = 0, const char *name=0); - - /** - * Default Destrucclamav - */ - virtual ~KlamavUpdate(); - void downloadComponent(TQString component, TQString version, TQString extension); - void checkForNewClamAVDirectly(); - void checkForNewKlamAVDirectly(); - void checkForNewKlamAV(); - -signals: - void getCurrentVersionOfClamAV( ); - void toggleUpgradeButtons(bool); - - -private slots: - void slotProg(); - void klamavInstallationExited(TDEProcess *arkollonproc); - void clamavInstallationExited(TDEProcess *arkollonproc); -/* void resolved(KResolverResults result);*/ -/* void readVersionLine(KProcIO *);*/ - void parseSFPage(); - void parseSFPageHack(); - void updateCanceled(); -/* void versionExited();*/ -private: - void getLatestVersionFromSF(KURL url); - void getLatestVersionFromSFHack(KURL url); - void startProgressDialog( const TQString & text ); - void checkInternet(); - void connectToHost(); - void getVersionFromLink( const DOM::Node &n ); - void completedSearchForUpdates(const TQString &component, const TQString &extension); - double numericizeVersion(TQString &version); - TQString getMirror(); - TDEProcess *childproc; - KProcIO *versionproc; - TQString tempFileName; - TQString errorMessage; - TQString pidFileName; - KProgressDialog *progressDialog; - TQTimer *timer; - bool upgradeinprogress; - bool checkingDirectly; - double highestsofarnumeric; - TQString highestsofarraw; - TQString highestsofarfilename; - KResolver m_resolver; - TQString currentClamavVersion; - bool m_alpha; - TDEHTMLPart *filelist; -private: - KDirLister clamav_lister; - KURL clamav_url; - KDirLister klamav_lister; - KURL klamav_url; - KURL m_url; - -}; - -#endif // _KlamavUpdate_H_ -- cgit v1.2.1