diff options
Diffstat (limited to 'tdenewstuff')
-rw-r--r-- | tdenewstuff/downloaddialog.cpp | 9 | ||||
-rw-r--r-- | tdenewstuff/entry.cpp | 1 | ||||
-rw-r--r-- | tdenewstuff/knewstuffgeneric.cpp | 13 |
3 files changed, 22 insertions, 1 deletions
diff --git a/tdenewstuff/downloaddialog.cpp b/tdenewstuff/downloaddialog.cpp index 9744275e4..0eaa0e685 100644 --- a/tdenewstuff/downloaddialog.cpp +++ b/tdenewstuff/downloaddialog.cpp @@ -46,6 +46,7 @@ #include <tqtimer.h> // hack #define OPENDESKTOP_REDIRECT_URL "opendesktop.org/content/download.php?content=" +#define OPENDESKTOP_REDIRECT_TEXT "If the download does not start in 3 seconds:</span><span class=\"defaulttext\"> <a href=\"" using namespace KNS; @@ -609,7 +610,7 @@ void DownloadDialog::slotInstallPhase2() } else { - m_s = new TDENewStuffGeneric(e->type(), this); + m_s = new TDENewStuffGeneric(m_filter, this); m_entry = e; KURL source = e->payload(); KURL dest = KURL(m_s->downloadDestination(e)); @@ -650,6 +651,12 @@ void DownloadDialog::slotJobResult( TDEIO::Job *job ) realURL = e->payload().protocol() + "://opendesktop.org" + realURL; e->setPayload(realURL); } + else if ((pos = mJobData.find(OPENDESKTOP_REDIRECT_TEXT)) > 0) { + pos = pos + strlen(OPENDESKTOP_REDIRECT_TEXT); + TQString realURL = mJobData.mid(pos); + realURL = realURL.mid(0, realURL.find("\">")); + e->setPayload(realURL); + } } slotInstallPhase2(); diff --git a/tdenewstuff/entry.cpp b/tdenewstuff/entry.cpp index 3213f272e..7539bb679 100644 --- a/tdenewstuff/entry.cpp +++ b/tdenewstuff/entry.cpp @@ -343,6 +343,7 @@ void Entry::parseDomElement( const TQDomElement &element ) } if ( e.tagName() == "score" ) setRating( e.text().toInt() ); if ( e.tagName() == "downloads" ) setDownloads( e.text().toInt() ); +// if ( e.tagName() == "typename" ) setType( e.text() ); } } diff --git a/tdenewstuff/knewstuffgeneric.cpp b/tdenewstuff/knewstuffgeneric.cpp index 16fda977c..757971268 100644 --- a/tdenewstuff/knewstuffgeneric.cpp +++ b/tdenewstuff/knewstuffgeneric.cpp @@ -29,6 +29,7 @@ #include <tdeconfig.h> #include <kstandarddirs.h> #include <tdemessagebox.h> +#include <kmimemagic.h> #include <ktar.h> #include "entry.h" @@ -49,6 +50,18 @@ TDENewStuffGeneric::~TDENewStuffGeneric() bool TDENewStuffGeneric::install( const TQString &fileName ) { + // Try to detect the most common cases where (usually adware) Web pages are downloaded + // instead of the desired file and abort + KMimeMagicResult *res = KMimeMagic::self()->findFileType( fileName ); + if ( res->isValid() && res->accuracy() > 40 ) { + if (type().lower().contains("wallpaper")) { + if (!res->mimeType().startsWith("image/")) { + TQFile::remove(fileName); + return false; + } + } +} + kdDebug() << "TDENewStuffGeneric::install(): " << fileName << endl; TQStringList list, list2; |