linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05647
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2933: trim hub addresses
------------------------------------------------------------
revno: 2933
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2012-05-30 19:28:37 +0200
message:
trim hub addresses
modified:
changelog.txt
win32/FavHubProperties.cpp
win32/HubFrame.cpp
win32/HubFrame.h
win32/MainWindow.cpp
win32/UserInfoBase.cpp
win32/WinUtil.cpp
--
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 2012-05-28 21:43:42 +0000
+++ changelog.txt 2012-05-30 17:28:37 +0000
@@ -1,6 +1,7 @@
* Revamp favorite hub settings (poy)
* Reduce resource consumption when slots are full
* [L#984330] Make PM windows more aware of the selected hub
+* [L#927821] Don't choke on hub addresses with spaces
-- 0.799 2012-05-05 --
* Add icons (iceman50)
=== modified file 'win32/FavHubProperties.cpp'
--- win32/FavHubProperties.cpp 2012-05-24 17:47:25 +0000
+++ win32/FavHubProperties.cpp 2012-05-30 17:28:37 +0000
@@ -82,6 +82,7 @@
address = cur->addChild(WinUtil::Seeds::Dialog::textBox);
address->setText(Text::toT(entry->getServer()));
address->setHelpId(IDH_FAVORITE_HUB_ADDRESS);
+ WinUtil::preventSpaces(address);
cur->addChild(Label::Seed(T_("Description")))->setHelpId(IDH_FAVORITE_HUB_DESC);
hubDescription = cur->addChild(WinUtil::Seeds::Dialog::textBox);
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2012-05-24 17:47:25 +0000
+++ win32/HubFrame.cpp 2012-05-30 17:28:37 +0000
@@ -20,6 +20,8 @@
#include "HubFrame.h"
+#include <boost/algorithm/string/trim.hpp>
+
#include <dcpp/AdcHub.h>
#include <dcpp/ChatMessage.h>
#include <dcpp/ClientManager.h>
@@ -67,15 +69,25 @@
HubFrame::FrameList HubFrame::frames;
-void HubFrame::openWindow(TabViewPtr parent, const string& url, bool activate, bool connect) {
+void HubFrame::openWindow(TabViewPtr parent, string url, bool activate, bool connect) {
+ boost::algorithm::trim(url);
+
+ if(url.empty()) {
+ dwt::MessageBox(WinUtil::mainWindow).show(T_("Empty hub address specified"), _T(APPNAME) _T(" ") _T(VERSIONSTRING),
+ dwt::MessageBox::BOX_OK, dwt::MessageBox::BOX_ICONSTOP);
+ return;
+ }
+
auto i = find_if(frames.begin(), frames.end(), [&url](HubFrame* frame) { return frame->url == url; });
if(i == frames.end()) {
- auto frame = new HubFrame(parent, url, connect);
+ // new hub window
+ auto frame = new HubFrame(parent, move(url), connect);
if(activate)
frame->activate();
} else {
+ // signal an existing hub window
auto frame = *i;
if(activate)
frame->activate();
@@ -147,8 +159,8 @@
return false;
}
-HubFrame::HubFrame(TabViewPtr parent, const string& url_, bool connect) :
-BaseType(parent, Text::toT(url_), IDH_HUB, IDI_HUB_OFF, false),
+HubFrame::HubFrame(TabViewPtr parent, string&& url, bool connect) :
+BaseType(parent, Text::toT(url), IDH_HUB, IDI_HUB_OFF, false),
paned(0),
userGrid(0),
users(0),
@@ -156,7 +168,7 @@
filterOpts(0),
showUsers(0),
client(0),
-url(url_),
+url(url),
updateUsers(false),
waitingForPW(false),
resort(false),
@@ -1377,6 +1389,13 @@
}
void HubFrame::redirect(string&& target) {
+ boost::algorithm::trim(target);
+
+ if(target.empty()) {
+ addStatus(T_("Redirect request to an empty hub address"));
+ return;
+ }
+
if(ClientManager::getInstance()->isConnected(target)) {
addStatus(T_("Redirect request received to a hub that's already connected"));
return;
=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h 2012-05-16 11:34:47 +0000
+++ win32/HubFrame.h 2012-05-30 17:28:37 +0000
@@ -66,7 +66,7 @@
static const string id;
const string& getId() const;
- static void openWindow(TabViewPtr parent, const string& url, bool activate = true, bool connect = true);
+ static void openWindow(TabViewPtr parent, string url, bool activate = true, bool connect = true);
static void activateWindow(const string& url);
private:
@@ -184,7 +184,7 @@
typedef std::vector<HubFrame*> FrameList;
static FrameList frames;
- HubFrame(TabViewPtr parent, const string& url, bool connect);
+ HubFrame(TabViewPtr parent, string&& url, bool connect);
virtual ~HubFrame();
void layout();
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2012-05-15 21:40:11 +0000
+++ win32/MainWindow.cpp 2012-05-30 17:28:37 +0000
@@ -786,16 +786,8 @@
return;
ParamDlg dlg(this, T_("Quick Connect"), T_("Address"));
-
- if (dlg.run() == IDOK) {
-
- tstring tmp = dlg.getValue();
- // Strip out all the spaces
- string::size_type i;
- while ((i = tmp.find(' ')) != string::npos)
- tmp.erase(i, 1);
-
- HubFrame::openWindow(getTabView(), Text::fromT(tmp));
+ if(dlg.run() == IDOK) {
+ HubFrame::openWindow(getTabView(), Text::fromT(dlg.getValue()));
}
}
=== modified file 'win32/UserInfoBase.cpp'
--- win32/UserInfoBase.cpp 2012-05-15 23:26:22 +0000
+++ win32/UserInfoBase.cpp 2012-05-30 17:28:37 +0000
@@ -73,12 +73,7 @@
}
void UserInfoBase::connectFav(TabViewPtr parent) {
- std::string url = user.hint;
- if(url.empty())
- url = FavoriteManager::getInstance()->getUserURL(user);
- if(!url.empty()) {
- HubFrame::openWindow(parent, url);
- }
+ HubFrame::openWindow(parent, user.hint.empty() ? FavoriteManager::getInstance()->getUserURL(user) : user.hint);
}
void UserInfoBase::ignoreChat(bool ignore) {
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2012-05-16 11:34:47 +0000
+++ win32/WinUtil.cpp 2012-05-30 17:28:37 +0000
@@ -1417,9 +1417,7 @@
Util::stricmp(proto.c_str(), "adcs") == 0 ||
Util::stricmp(proto.c_str(), "dchub") == 0 )
{
- if(!host.empty()) {
- HubFrame::openWindow(mainWindow->getTabView(), url);
- }
+ HubFrame::openWindow(mainWindow->getTabView(), url);
if(!file.empty()) {
if(file[0] == '/') {
@@ -1438,6 +1436,7 @@
}
return true;
+
} else if(!proto.empty() ||
Util::strnicmp(str.c_str(), _T("www."), 4) == 0 ||
Util::strnicmp(str.c_str(), _T("mailto:"), 7) == 0) {