linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05439
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2878: Move the "follow redirect" command to inline chat links
------------------------------------------------------------
revno: 2878
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2012-03-11 17:36:44 +0100
message:
Move the "follow redirect" command to inline chat links
removed:
res/Follow.ico
modified:
changelog.txt
help/keyboard_commands.html
help/settings_advanced.html
help/window_main.html
win32/DCPlusPlus.rc
win32/HubFrame.cpp
win32/HubFrame.h
win32/MainWindow.cpp
win32/MainWindow.h
win32/resource.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 2012-03-05 20:48:24 +0000
+++ changelog.txt 2012-03-11 16:36:44 +0000
@@ -24,6 +24,7 @@
* Re-add lost user information tooltips (poy)
* Fix discrepancies in the /conn chat command (poy)
* Update boost to version 1.49
+* [L#947895] Move the "follow redirect" command to inline chat links (poy)
-- 0.791 2012-01-14 --
* Update translations
=== modified file 'help/keyboard_commands.html'
--- help/keyboard_commands.html 2011-10-15 22:58:51 +0000
+++ help/keyboard_commands.html 2012-03-11 16:36:44 +0000
@@ -51,8 +51,6 @@
<dd>Reconnect.</dd>
<dt>Ctrl + S</dt>
<dd>Open the <placeholder><a href="window_search.html">Search</a></placeholder> window.</dd>
- <dt>Ctrl + T (in <placeholder><a href="window_hub.html">Hub</a></placeholder> windows)</dt>
- <dd>Follow last redirect.</dd>
<dt>Ctrl + U</dt>
<dd>Open the <placeholder><a href="window_users.html">Users</a></placeholder> window.</dd>
<dt>Ctrl + F3</dt>
=== modified file 'help/settings_advanced.html'
--- help/settings_advanced.html 2012-01-15 16:08:29 +0000
+++ help/settings_advanced.html 2012-03-11 16:36:44 +0000
@@ -8,13 +8,14 @@
<body>
<h1>Advanced</h1>
<dl style="margin-left: 40px;">
- <dt>Automatically follow redirects</dt>
- <dd cshelp="IDH_SETTINGS_ADVANCED_AUTO_FOLLOW">A connected hub can send out a redirect request, asking your
-client to disconnect from the current hub and joining another one.
-Enable this to automatically join that other hub. (You will be
-disconnected from the current hub no matter what.) If you leave it
-disabled, you can use the Follow Redirect button to manually follow the
-redirect.</dd>
+ <dt>Automatically follow redirects</dt>
+ <dd cshelp="IDH_SETTINGS_ADVANCED_AUTO_FOLLOW">
+ A connected hub can send out a redirect request, asking your client to disconnect from the
+ current hub in order to join another one. When this setting is enabled, DC++ automatically
+ follows these requests and connects to the hubs it has been asked to be redirected to. When
+ this setting is disabled, DC++ displays a link one can click on to follow the redirect request.
+ Note that DC++ disconnects hubs that have sent a redirect request no matter what.
+ </dd>
<dt>Clear search box after each search</dt>
<dd cshelp="IDH_SETTINGS_ADVANCED_CLEAR_SEARCH">After each search, your search terms will be cleared. The last
terms will be accessible through the drop-down. You can set how many terms that you want to save by using <a href="settings_history.html#searchhistory">Search history</a>.</dd>
=== modified file 'help/window_main.html'
--- help/window_main.html 2012-01-15 16:08:29 +0000
+++ help/window_main.html 2012-03-11 16:36:44 +0000
@@ -27,8 +27,6 @@
</dd>
<dt><img src="Reconnect.ico" width="16" height="16" alt="Reconnect"/> Reconnect</dt>
<dd>To reconnect (disconnect and connect again) the hub which is currently in the foreground. If the active window is not a hub, it does nothing.</dd>
- <dt><img src="Follow.ico" width="16" height="16" alt="Follow last redirect"/> Follow last redirect</dt>
- <dd>You are able to follow the redirection offered by the hub which is currently in the foreground. If the active window is not a hub, it does nothing.</dd>
<dt><img src="OpenFileList.ico" width="16" height="16" alt="Open file list..."/> Open file list...</dt>
<dd>This menu is for opening a previously downloaded filelist. It defaults to the FileLists folder inside the <a href="faq_settings_files.html">directory used to store DC++ settings files</a>.</dd>
<dt>Open own list</dt>
@@ -198,7 +196,6 @@
<p>
<a href="window_public_hubs.html" title="Public Hubs"><img src="PublicHubs.ico" width="20" height="20" alt="Public Hubs"/></a>
<a href="#tb_reconnect" title="Reconnect"><img src="Reconnect.ico" width="20" height="20" alt="Reconnect"/></a>
-<a href="#tb_follow" title="Follow last redirect"><img src="Follow.ico" width="20" height="20" alt="Follow last redirect"/></a>
<a href="window_favorite_hubs.html" title="Favorite Hubs"><img src="FavoriteHubs.ico" width="20" height="20" alt="Favorite Hubs"/></a>
<a href="window_users.html" title="Users"><img src="Users.ico" width="20" height="20" alt="Users"/></a>
<a href="window_download_queue.html" title="Download Queue"><img src="Queue.ico" width="20" height="20" alt="Download Queue"/></a>
@@ -230,9 +227,6 @@
<dt id="tb_reconnect">Reconnect</dt>
<dd cshelp="IDH_TOOLBAR_RECONNECT">Reconnect (disconnect and connect again) the hub which is currently in the foreground.</dd>
- <dt id="tb_follow">Follow last redirect</dt>
- <dd cshelp="IDH_TOOLBAR_FOLLOW">Follow the redirection offered by the hub which is currently in the foreground.</dd>
-
<dt id="tb_favhubs">Favorite Hubs</dt>
<dd cshelp="IDH_TOOLBAR_FAVORITE_HUBS">
<div>Open the <placeholder><a href="window_favorite_hubs.html">Favorite Hubs</a></placeholder> window.</div>
=== removed file 'res/Follow.ico'
Binary files res/Follow.ico 2010-03-11 17:25:17 +0000 and res/Follow.ico 1970-01-01 00:00:00 +0000 differ
=== modified file 'win32/DCPlusPlus.rc'
--- win32/DCPlusPlus.rc 2012-03-03 15:04:23 +0000
+++ win32/DCPlusPlus.rc 2012-03-11 16:36:44 +0000
@@ -38,7 +38,6 @@
IDI_GROUPED_BY_FILES ICON "res/GroupedByFiles.ico"
IDI_GROUPED_BY_USERS ICON "res/GroupedByUsers.ico"
IDI_EXIT ICON "res/Exit.ico"
-IDI_FOLLOW ICON "res/Follow.ico"
IDI_HELP ICON "res/Help.ico"
IDI_OPEN_DL_DIR ICON "res/OpenDLDir.ico"
IDI_OPEN_FILE_LIST ICON "res/OpenFileList.ico"
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2012-03-03 19:33:45 +0000
+++ win32/HubFrame.cpp 2012-03-11 16:36:44 +0000
@@ -172,6 +172,7 @@
createChat(paned);
chat->setHelpId(IDH_HUB_CHAT);
addWidget(chat);
+ chat->onLink([this](const tstring& link) { return handleChatLink(link); });
chat->onContextMenu([this](const dwt::ScreenCoordinate &sc) { return handleChatContextMenu(sc); });
message->setHelpId(IDH_HUB_MESSAGE);
@@ -243,7 +244,6 @@
addAccel(FALT, 'G', [this] { handleGetList(); });
addAccel(FCONTROL, 'R', [this] { handleReconnect(); });
- addAccel(FCONTROL, 'T', [this] { handleFollow(); });
addAccel(FALT, 'P', [this] { handlePrivateMessage(getParent()); });
addAccel(FALT, 'U', [this] { users->setFocus(); });
initAccels();
@@ -397,11 +397,10 @@
}
} else if(Util::stricmp(cmd.c_str(), _T("join"))==0) {
if(!param.empty()) {
- redirect = Text::fromT(param);
if(BOOLSETTING(JOIN_OPEN_NEW_WINDOW)) {
HubFrame::openWindow(getParent(), Text::fromT(param));
} else {
- handleFollow();
+ redirect(Text::fromT(param));
}
} else {
addStatus(T_("Specify a server to connect to"));
@@ -866,9 +865,11 @@
}
void HubFrame::on(Connecting, Client*) noexcept {
- tstring hubUrl = Text::toT(client->getHubUrl());
- callAsync([this, hubUrl] { addStatus(str(TF_("Connecting to %1%...") % hubUrl), true); });
- callAsync([this, hubUrl] { setText(hubUrl); });
+ tstring hubUrl = Text::toT(Util::addBrackets(client->getHubUrl()));
+ callAsync([this, hubUrl] {
+ addStatus(str(TF_("Connecting to %1%...") % hubUrl));
+ setText(hubUrl);
+ });
}
void HubFrame::on(Connected, Client*) noexcept {
callAsync([this] { onConnected(); });
@@ -892,17 +893,28 @@
callAsync([this] { addStatus(T_("Redirect request received to a hub that's already connected"), true); });
return;
}
- redirect = line;
- if(BOOLSETTING(AUTO_FOLLOW)) {
- callAsync([this] { handleFollow(); });
- } else {
- callAsync([=] { addStatus(str(TF_("Press the follow redirect button to connect to %1%") % Text::toT(line)), true); });
- }
+ callAsync([this, line] {
+ if(BOOLSETTING(AUTO_FOLLOW)) {
+ auto copy = line; /// @todo shouldn't the lambda have already created a copy?
+ redirect(std::move(copy));
+ } else {
+ string msg = str(F_("Received a redirect request to %1%, click here to follow it") % Util::addBrackets(line));
+ tstring msgT = Text::toT(msg);
+ string tmp;
+ addStatus(msgT, false);
+ /// @todo change to "javascript: external.redirect" when switching to an HTML control
+ addChatHTML("<span>*** </span><a href=\"redirect: " + SimpleXML::escape(line, tmp, true) + "\">" +
+ SimpleXML::escape(msg, tmp, false) + "</a>");
+ addedChat(_T("*** ") + msgT);
+ }
+ });
}
void HubFrame::on(Failed, Client*, const string& line) noexcept {
- callAsync([=] { addStatus(Text::toT(line), true); });
- callAsync([this] { onDisconnected(); });
+ callAsync([this, line] {
+ addStatus(Text::toT(line));
+ onDisconnected();
+ });
}
void HubFrame::on(GetPassword, Client*) noexcept {
@@ -1106,6 +1118,15 @@
return true;
}
+bool HubFrame::handleChatLink(const tstring& link) {
+ if(link.size() > 10 && !link.compare(0, 10, _T("redirect: "))) {
+ redirect(Text::fromT(link.substr(10)));
+ return true;
+ }
+
+ return false;
+}
+
bool HubFrame::handleChatContextMenu(dwt::ScreenCoordinate pt) {
if(pt.x() == -1 || pt.y() == -1) {
pt = chat->getContextMenuPos();
@@ -1358,24 +1379,22 @@
client->reconnect();
}
-void HubFrame::handleFollow() {
- if(!redirect.empty()) {
- if(ClientManager::getInstance()->isConnected(redirect)) {
- addStatus(T_("Redirect request received to a hub that's already connected"));
- return;
- }
-
- url = redirect;
-
- // the client is dead, long live the client!
- client->removeListener(this);
- ClientManager::getInstance()->putClient(client);
- client = 0;
- onDisconnected();
- client = ClientManager::getInstance()->getClient(url);
- client->addListener(this);
- client->connect();
+void HubFrame::redirect(string&& target) {
+ if(ClientManager::getInstance()->isConnected(target)) {
+ addStatus(T_("Redirect request received to a hub that's already connected"));
+ return;
}
+
+ url = std::forward<string>(target);
+
+ // the client is dead, long live the client!
+ client->removeListener(this);
+ ClientManager::getInstance()->putClient(client);
+ client = 0;
+ onDisconnected();
+ client = ClientManager::getInstance()->getClient(url);
+ client->addListener(this);
+ client->connect();
}
void HubFrame::showFilterOpts() {
=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h 2012-02-17 23:34:33 +0000
+++ win32/HubFrame.h 2012-03-11 16:36:44 +0000
@@ -165,7 +165,6 @@
Client* client;
string url;
- string redirect;
bool updateUsers;
bool waitingForPW;
bool resort;
@@ -228,6 +227,7 @@
bool handleMessageChar(int c);
bool handleMessageKeyDown(int c);
bool handleUsersKeyDown(int c);
+ bool handleChatLink(const tstring& link);
bool handleChatContextMenu(dwt::ScreenCoordinate pt);
bool handleUsersContextMenu(dwt::ScreenCoordinate pt);
void handleShowUsersClicked();
@@ -236,7 +236,6 @@
void handleCopyHub();
void handleAddAsFavorite();
void handleReconnect();
- void handleFollow();
void showFilterOpts();
void hideFilterOpts(dwt::Widget* w);
@@ -247,6 +246,8 @@
string stripNick(const string& nick) const;
tstring scanNickPrefix(const tstring& prefix);
+ void redirect(string&& target);
+
// MDIChildFrame
void tabMenuImpl(dwt::Menu* menu);
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2012-03-03 19:33:45 +0000
+++ win32/MainWindow.cpp 2012-03-11 16:36:44 +0000
@@ -288,7 +288,6 @@
file->appendSeparator();
file->appendItem(T_("&Reconnect\tCtrl+R"), [this] { handleReconnect(); }, WinUtil::menuIcon(IDI_RECONNECT));
- file->appendItem(T_("Follow last redirec&t\tCtrl+T"), [this] { handleRedirect(); }, WinUtil::menuIcon(IDI_FOLLOW));
file->appendSeparator();
file->appendItem(T_("Open file list...\tCtrl+L"), [this] { handleOpenFileList(); }, WinUtil::menuIcon(IDI_OPEN_FILE_LIST));
@@ -398,8 +397,6 @@
IDH_TOOLBAR_PUBLIC_HUBS, [this] { PublicHubsFrame::openWindow(getTabView()); });
toolbar->addButton("Reconnect", WinUtil::toolbarIcon(IDI_RECONNECT), 0, T_("Reconnect"), false,
IDH_TOOLBAR_RECONNECT, [this] { handleReconnect(); });
- toolbar->addButton("Redirect", WinUtil::toolbarIcon(IDI_FOLLOW), 0, T_("Follow last redirect"), false,
- IDH_TOOLBAR_FOLLOW, [this] { handleRedirect(); });
toolbar->addButton(FavHubsFrame::id, WinUtil::toolbarIcon(IDI_FAVORITE_HUBS), 0, T_("Favorite Hubs"), false,
IDH_TOOLBAR_FAVORITE_HUBS, [this] { FavHubsFrame::openWindow(getTabView()); },
[this](const dwt::ScreenCoordinate& pt) { handleFavHubsDropDown(pt); });
@@ -439,7 +436,6 @@
PublicHubsFrame::id + comma +
comma +
"Reconnect" + comma +
- "Redirect" + comma +
FavHubsFrame::id + comma +
UsersFrame::id + comma +
comma +
@@ -772,10 +768,6 @@
forwardHub(&HubFrame::handleReconnect);
}
-void MainWindow::handleRedirect() {
- forwardHub(&HubFrame::handleFollow);
-}
-
void MainWindow::forwardHub(void (HubFrame::*f)()) {
HubFrame* active = dynamic_cast<HubFrame*>(getTabView()->getActive());
if(active) {
@@ -1448,15 +1440,14 @@
void MainWindow::parseCommandLine(const tstring& cmdLine)
{
- string::size_type i = 0;
- string::size_type j;
+ string::size_type i;
- if( (j = cmdLine.find(_T("dchub://"), i)) != string::npos ||
- (j = cmdLine.find(_T("adc://"), i)) != string::npos ||
- (j = cmdLine.find(_T("adcs://"), i)) != string::npos ||
- (j = cmdLine.find(_T("magnet:?"), i)) != string::npos )
+ if( (i = cmdLine.find(_T("dchub://"))) != string::npos ||
+ (i = cmdLine.find(_T("adc://"))) != string::npos ||
+ (i = cmdLine.find(_T("adcs://"))) != string::npos ||
+ (i = cmdLine.find(_T("magnet:?"))) != string::npos )
{
- WinUtil::parseDBLClick(cmdLine.substr(j));
+ WinUtil::parseLink(cmdLine.substr(i));
}
}
=== modified file 'win32/MainWindow.h'
--- win32/MainWindow.h 2012-01-22 20:27:14 +0000
+++ win32/MainWindow.h 2012-03-11 16:36:44 +0000
@@ -179,7 +179,6 @@
void switchStatus();
bool handleSlotsUpdate(int delta);
void handleReconnect();
- void handleRedirect();
void forwardHub(void (HubFrame::*f_t)());
// Other events
=== modified file 'win32/resource.h'
--- win32/resource.h 2011-11-19 00:10:54 +0000
+++ win32/resource.h 2012-03-11 16:36:44 +0000
@@ -26,7 +26,6 @@
#define IDI_GROUPED_BY_FILES 119
#define IDI_GROUPED_BY_USERS 120
#define IDI_EXIT 121
-#define IDI_FOLLOW 122
#define IDI_HELP 123
#define IDI_OPEN_DL_DIR 124
#define IDI_OPEN_FILE_LIST 125