linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02551
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2306: Add magnet keyword search
------------------------------------------------------------
revno: 2306
author: Flow84 <mattias@xxxxxxxxxxxxxx>
committer: eMTee <emtee11@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Wed 2010-11-24 23:14:02 +0100
message:
Add magnet keyword search
modified:
changelog.txt
win32/AboutDlg.cpp
win32/MagnetDlg.cpp
win32/MagnetDlg.h
win32/WinUtil.cpp
win32/WinUtil.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2010-11-24 19:05:54 +0000
+++ changelog.txt 2010-11-24 22:14:02 +0000
@@ -36,6 +36,7 @@
* Keep search history in file list windows (emtee)
* Update OpenSSL to version 1.0.0b (poy)
* [L#378829] Make sure our OpenSSL binaries aren't "optimized for MS-DOS" (poy)
+* [L#674545] Add magnet keyword search (thanks flow84)
-- 0.770 2010-07-05 --
* [L#550300] Catch more potential file corruptions (thanks bigmuscle)
=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp 2010-10-20 20:49:31 +0000
+++ win32/AboutDlg.cpp 2010-11-24 22:14:02 +0000
@@ -46,7 +46,7 @@
"steven sheehy, tobias nygren, poy, dorian, stephan hohe, mafa_45, mikael eman, james ross, "
"stanislav maslovski, david grundberg, pavel andreev, yakov suraev, kulmegil, smir, emtee, individ, "
"pseudonym, crise, ben, ximin luo, radox, razzloss, andrew browne, darkklor, vasily.n, netcelli, "
-"gennady proskurin, iceman50. Keep it coming!";
+"gennady proskurin, iceman50, flow84. Keep it coming!";
AboutDlg::AboutDlg(dwt::Widget* parent) :
dwt::ModalDialog(parent),
=== modified file 'win32/MagnetDlg.cpp'
--- win32/MagnetDlg.cpp 2010-07-10 14:36:48 +0000
+++ win32/MagnetDlg.cpp 2010-11-24 22:14:02 +0000
@@ -24,7 +24,7 @@
#include "WinUtil.h"
-MagnetDlg::MagnetDlg(dwt::Widget* parent, const tstring& aHash, const tstring& aFileName) :
+MagnetDlg::MagnetDlg(dwt::Widget* parent, const tstring& aHash, const tstring& aFileName, const tstring& aKeySearch) :
dwt::ModalDialog(parent),
grid(0),
//queue(0),
@@ -32,7 +32,8 @@
//doNothing(0),
//remember(0),
mHash(aHash),
-mFileName(aFileName)
+mFileName(aFileName),
+mKeySearch(aKeySearch)
{
onInitDialog(std::bind(&MagnetDlg::handleInitDialog, this));
}
@@ -71,8 +72,15 @@
TextBox::Seed seed = WinUtil::Seeds::Dialog::textBox;
seed.style |= ES_READONLY;
- cur->addChild(Label::Seed(T_("File Hash:")));
- cur->addChild(seed)->setText(mHash);
+ if (!mHash.empty()) {
+ cur->addChild(Label::Seed(T_("File Hash:")));
+ cur->addChild(seed)->setText(mHash);
+ }
+ else if (!mKeySearch.empty())
+ {
+ cur->addChild(Label::Seed(T_("Key Search:")));
+ cur->addChild(seed)->setText(mKeySearch);
+ }
cur->addChild(Label::Seed(T_("Filename:")));
cur->addChild(seed)->setText(mFileName);
@@ -132,8 +140,12 @@
//}
if(search->getChecked()) {
- TTHValue tmphash(Text::fromT(mHash));
- WinUtil::searchHash(tmphash);
+ if (!mHash.empty()) {
+ TTHValue tmphash(Text::fromT(mHash));
+ WinUtil::searchHash(tmphash);
+ }else if (!mKeySearch.empty()) {
+ WinUtil::searchAny(mKeySearch);
+ }
} //else if(queue->getChecked()) {
// FIXME: Write this code when the queue is more tth-centric
//}
=== modified file 'win32/MagnetDlg.h'
--- win32/MagnetDlg.h 2010-02-11 21:44:13 +0000
+++ win32/MagnetDlg.h 2010-11-24 22:14:02 +0000
@@ -28,7 +28,7 @@
class MagnetDlg : public dwt::ModalDialog
{
public:
- MagnetDlg(dwt::Widget* parent, const tstring& aHash, const tstring& aFileName);
+ MagnetDlg(dwt::Widget* parent, const tstring& aHash, const tstring& aFileName, const tstring& aKeySearch);
virtual ~MagnetDlg();
int run();
@@ -42,6 +42,7 @@
tstring mHash;
tstring mFileName;
+ tstring mKeySearch;
bool handleInitDialog();
//void handleRadioButtonClicked(RadioButtonPtr radioButton);
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2010-11-24 19:05:54 +0000
+++ win32/WinUtil.cpp 2010-11-24 22:14:02 +0000
@@ -649,6 +649,10 @@
return ret;
}
+void WinUtil::searchAny(const tstring& aSearch) {
+ SearchFrame::openWindow(mainWindow->getTabView(), aSearch, SearchManager::TYPE_ANY);
+}
+
void WinUtil::searchHash(const TTHValue& aHash) {
SearchFrame::openWindow(mainWindow->getTabView(), Text::toT(aHash.toBase32()), SearchManager::TYPE_TTH);
}
@@ -1187,7 +1191,7 @@
StringTokenizer<tstring> mag(aUrl.substr(8), _T('&'));
typedef map<tstring, tstring> MagMap;
MagMap hashes;
- tstring fname, fhash, type, param;
+ tstring fname, fhash, type, param, fkey;
for(TStringList::iterator idx = mag.getTokens().begin(); idx != mag.getTokens().end(); ++idx) {
// break into pairs
string::size_type pos = idx->find(_T('='));
@@ -1209,6 +1213,8 @@
hashes[type] = param.substr(20);
} else if(type.length() == 2 && Util::strnicmp(type.c_str(), _T("dn"), 2) == 0) {
fname = param;
+ } else if(type.length() == 2 && Util::strnicmp(type.c_str(), _T("kt"), 2) == 0) {
+ fkey = param;
}
}
// pick the most authoritative hash out of all of them.
@@ -1221,7 +1227,7 @@
if(hashes.find(_T("xt")) != hashes.end()) {
fhash = hashes[_T("xt")];
}
- if(!fhash.empty()) {
+ if(!fhash.empty() || !fkey.empty()) {
// ok, we have a hash, and maybe a filename.
//if(!BOOLSETTING(MAGNET_ASK)) {
// switch(SETTING(MAGNET_ACTION)) {
@@ -1233,7 +1239,7 @@
// };
//} else {
// use aOverride to force the display of the dialog. used for auto-updating
- MagnetDlg(mainWindow, fhash, fname).run();
+ MagnetDlg(mainWindow, fhash, fname, fkey).run();
//}
} else {
dwt::MessageBox(mainWindow).show(
=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h 2010-11-21 15:59:18 +0000
+++ win32/WinUtil.h 2010-11-24 22:14:02 +0000
@@ -180,6 +180,7 @@
static void addHashItems(const dwt::Menu::ObjectType& menu, const TTHValue& tth, const tstring& filename, int64_t size);
static void bitziLink(const TTHValue& aHash);
static void copyMagnet(const TTHValue& aHash, const tstring& aFile, int64_t size);
+ static void searchAny(const tstring& aSearch);
static void searchHash(const TTHValue& aHash);
static string makeMagnet(const TTHValue& aHash, const string& aFile, int64_t size);