Commit 76752ff0 authored by Joris Guisson's avatar Joris Guisson
Browse files

Merged rev 795188 (search fixes)

svn path=/branches/ktorrent/3.0/; revision=795190
parent 236ab231
......@@ -7,6 +7,8 @@ Changes in 3.0.2 :
- Fix crash in torrent creator when there are no trackers
- Fix sorting in files tab
- Fix crash when unloading plugins with Qt4.4 (160565)
- Fix update search engines from internet
- Remove torrentspy and update piratebay URL
Changes in 3.0.1 :
- Fix sessionTTL not being able to be bigger then 99
......
......@@ -25,10 +25,21 @@
using namespace bt;
namespace kt
{
{
SearchEngineList::SearchEngineList()
{}
{
m_default_list.append(SearchEngine("KTorrents",KUrl("http://www.ktorrents.com/search.php?lg=0&sourceid=ktorrent&q=FOOBAR&f=0")));
m_default_list.append(SearchEngine("bittorrent.com",KUrl("http://www.bittorrent.com/search_result.myt?search=FOOBAR")));
m_default_list.append(SearchEngine("mininova.org",KUrl("http://www.mininova.org/search.php?search=FOOBAR")));
m_default_list.append(SearchEngine("isohunt.com",KUrl("http://isohunt.com/torrents.php?ihq=FOOBAR&op=and")));
m_default_list.append(SearchEngine("thepiratebay.org",KUrl("http://thepiratebay.org/search/FOOBAR")));
m_default_list.append(SearchEngine("bitoogle.com",KUrl("http://bitoogle.com/search.php?q=FOOBAR")));
m_default_list.append(SearchEngine("bytenova.org",KUrl("http://www.bitenova.org/search.php?search=FOOBAR&start=0&start=0&ie=utf-8&oe=utf-8")));
m_default_list.append(SearchEngine("torrentz.com",KUrl("http://www.torrentz.com/search_FOOBAR")));
m_default_list.append(SearchEngine("btjunkie.org",KUrl("http://btjunkie.org/search?q=FOOBAR")));
}
SearchEngineList::~SearchEngineList()
......@@ -85,6 +96,17 @@ namespace kt
for (Uint32 i=2; i < (Uint32)tokens.count(); ++i)
se.url.addQueryItem(tokens[i].section("=",0,0), tokens[i].section("=", 1, 1));
// check if we need to update the URL of a default item
foreach (const SearchEngine & e,m_default_list)
{
if (e.name == se.name)
{
if (e.url != se.url)
se.url = e.url;
break;
}
}
m_search_engines.append(se);
}
}
......@@ -98,15 +120,10 @@ namespace kt
QTextStream out(&fptr);
out << "# PLEASE DO NOT MODIFY THIS FILE. Use KTorrent configuration dialog for adding new search engines." << ::endl;
out << "# SEARCH ENGINES list" << ::endl;
out << "KTorrents http://www.ktorrents.com/search.php?lg=0&sourceid=ktorrent&q=FOOBAR&f=0" << ::endl;
out << "bittorrent.com http://www.bittorrent.com/search_result.myt?search=FOOBAR" << ::endl;
out << "isohunt.com http://isohunt.com/torrents.php?ihq=FOOBAR&op=and" << ::endl;
out << "mininova.org http://www.mininova.org/search.php?search=FOOBAR" << ::endl;
out << "thepiratebay.org http://thepiratebay.org/search.php?q=FOOBAR" << ::endl;
out << "bitoogle.com http://bitoogle.com/search.php?q=FOOBAR" << ::endl;
out << "bytenova.org http://www.bitenova.org/search.php?search=FOOBAR&start=0&start=0&ie=utf-8&oe=utf-8" << ::endl;
out << "torrentspy.com http://torrentspy.com/search.asp?query=FOOBAR" << ::endl;
out << "torrentz.com http://www.torrentz.com/search_FOOBAR" << ::endl;
foreach (const SearchEngine & e,m_default_list)
{
out << e.name << " " << e.url.prettyUrl() << endl;
}
}
KUrl SearchEngineList::getSearchURL(bt::Uint32 engine) const
......
......@@ -26,23 +26,27 @@
namespace kt
{
struct SearchEngine
{
QString name;
KUrl url;
SearchEngine() {}
SearchEngine(const QString & name,const KUrl & url) : name(name),url(url) {}
};
/**
@author Joris Guisson <joris.guisson@gmail.com>
*/
class SearchEngineList
{
struct SearchEngine
{
QString name;
KUrl url;
};
QList<SearchEngine> m_search_engines;
QList<SearchEngine> m_default_list;
public:
SearchEngineList();
virtual ~SearchEngineList();
const QList<SearchEngine> & defaultList() const {return m_default_list;}
void save(const QString& file);
void load(const QString& file);
......
......@@ -37,6 +37,7 @@
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <util/log.h>
#include <util/constants.h>
#include <util/functions.h>
#include <util/fileops.h>
......@@ -59,7 +60,7 @@ namespace kt
" (capital letters) on the search engine you want to add. <br> "
"Then copy the URL in the addressbar after the search is finished, and paste it here.<br><br>Searching for %1"
" on Google for example, will result in http://www.google.com/search?q=FOOBAR&ie=UTF-8&oe=UTF-8. <br> "
"If you add this URL here, ktorrent can search using Google.",foobar);
"If you add this URL here, ktorrent can search using ,SGoogle.",foobar);
QString info_short = i18n("Use your web browser to search for the string %1 (capital letters) "
"on the search engine you want to add. Use the resulting URL below.",foobar);
m_info_label->setText(info_short);
......@@ -70,6 +71,7 @@ namespace kt
connect(m_add_default, SIGNAL(clicked()), this, SLOT(addDefaultClicked()));
connect(m_remove_all, SIGNAL(clicked()), this, SLOT(removeAllClicked()));
connect(m_clear_history,SIGNAL(clicked()),this,SLOT(clearHistory()));
connect(m_update,SIGNAL(clicked()),this,SLOT(updateClicked()));
connect(kcfg_useCustomBrowser, SIGNAL(toggled(bool)), this, SLOT(customToggled( bool )));
connect(kcfg_openInExternal,SIGNAL(toggled(bool)),this, SLOT(openInExternalToggled(bool)));
......@@ -178,15 +180,12 @@ namespace kt
void SearchPrefPage::addDefaultClicked()
{
newItem( "KTorrents", KUrl("http://www.ktorrents.com/search.php?lg=0&sourceid=ktorrent&q=FOOBAR&f=0"));
newItem( "bittorrent.com", KUrl("http://search.bittorrent.com/search.jsp?query=FOOBAR"));
newItem( "isohunt.com", KUrl("http://isohunt.com/torrents.php?ihq=FOOBAR&op=and"));
newItem( "mininova.org", KUrl("http://www.mininova.org/search.php?search=FOOBAR"));
newItem( "thepiratebay.org", KUrl("http://thepiratebay.org/search.php?q=FOOBAR"));
newItem( "bitoogle.com", KUrl("http://bitoogle.com/search.php?q=FOOBAR"));
newItem( "bytenova.org", KUrl("http://www.bitenova.org/search.php?search=FOOBAR&start=0&start=0&ie=utf-8&oe=utf-8"));
newItem( "torrentspy.com", KUrl("http://torrentspy.com/search.asp?query=FOOBAR"));
newItem( "torrentz.com", KUrl("http://www.torrentz.com/search_FOOBAR"));
const SearchEngineList & se = m_plugin->getSearchEngineList();
foreach (const SearchEngine & e,se.defaultList())
{
newItem(e.name,e.url);
}
saveSearchEngines();
}
......@@ -203,7 +202,7 @@ namespace kt
((KIO::Job*)j)->ui()->showErrorMessage();
return;
}
Out(SYS_SRC|LOG_DEBUG) << "Downloaded search_engines file" << endl;
QString fn = kt::DataDir() + "search_engines.tmp";
updateList(fn);
saveSearchEngines();
......@@ -223,7 +222,10 @@ namespace kt
QFile fptr(source);
if (!fptr.open(QIODevice::ReadOnly))
{
Out(SYS_SRC|LOG_DEBUG) << "Failed to open " << source << endl;
return;
}
QTextStream in(&fptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment