← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2985: Allow Magnet links to be pasted in the "Quick connect" box

 

------------------------------------------------------------
revno: 2985
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-07-07 18:36:41 +0200
message:
  Allow Magnet links to be pasted in the "Quick connect" box
modified:
  changelog.txt
  dcpp/PluginApiImpl.cpp
  dcpp/PluginManager.cpp
  dcpp/PluginManager.h
  help/window_main.html
  win32/MainWindow.cpp
  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	2012-07-03 19:15:39 +0000
+++ changelog.txt	2012-07-07 16:36:41 +0000
@@ -24,6 +24,7 @@
 * Greatly improve user command removal time when closing a hub
 * Add plugin API (Crise, iceman50)
 * [dwt] Add a link control (poy)
+* Allow Magnet links to be pasted in the "Quick connect" box (poy)
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'dcpp/PluginApiImpl.cpp'
--- dcpp/PluginApiImpl.cpp	2012-07-02 18:13:18 +0000
+++ dcpp/PluginApiImpl.cpp	2012-07-07 16:36:41 +0000
@@ -28,16 +28,15 @@
 #include "stdinc.h"
 #include "PluginApiImpl.h"
 
+#include "Client.h"
+#include "ClientManager.h"
+#include "ConnectionManager.h"
+#include "FavoriteManager.h"
 #include "File.h"
-
+#include "LogManager.h"
 #include "PluginManager.h"
-#include "ConnectionManager.h"
-#include "FavoriteManager.h"
 #include "QueueManager.h"
-#include "ClientManager.h"
-
 #include "UserConnection.h"
-#include "Client.h"
 
 namespace dcpp {
 

=== modified file 'dcpp/PluginManager.cpp'
--- dcpp/PluginManager.cpp	2012-07-07 16:11:11 +0000
+++ dcpp/PluginManager.cpp	2012-07-07 16:36:41 +0000
@@ -22,6 +22,7 @@
 #include "Client.h"
 #include "ClientManager.h"
 #include "ConnectionManager.h"
+#include "LogManager.h"
 #include "QueueManager.h"
 #include "SimpleXML.h"
 #include "StringTokenizer.h"

=== modified file 'dcpp/PluginManager.h'
--- dcpp/PluginManager.h	2012-07-07 16:11:11 +0000
+++ dcpp/PluginManager.h	2012-07-07 16:36:41 +0000
@@ -30,7 +30,6 @@
 #include "Singleton.h"
 #include "SettingsManager.h"
 #include "TimerManager.h"
-#include "LogManager.h"
 
 #include "QueueManagerListener.h"
 #include "ClientManagerListener.h"

=== modified file 'help/window_main.html'
--- help/window_main.html	2012-06-18 16:32:14 +0000
+++ help/window_main.html	2012-07-07 16:36:41 +0000
@@ -19,7 +19,10 @@
 	    You can find the file input-output functions as well as the basic connection options and the settings in this menu.
 		<dl style="margin-left: 30px;">
 			<dt><img src="HubOn.ico" width="16" height="16" alt="Quick connect..."/> Quick connect...</dt>
-			<dd>Allows you to connect to a hub by manually typing its address.</dd>
+			<dd>
+			Allows you to connect to a hub by specifying its address. This field also handles
+			<a href="http://en.wikipedia.org/wiki/Magnet_link"; target="_blank" class="external">Magnet links</a>.
+			</dd>
 			<dt id="connectfavgroup"><img src="FavoriteHubs.ico" width="16" height="16" alt="Connect to a favorite hub group"/> Connect to a favorite hub group</dt>
 			<dd>
 			<div>Opens a dialog asking to select a favorite hub group; after pressing "OK" in that dialog, <placeholder><a href="window_hub.html">Hub</a></placeholder> windows will be opened for every hub that is part of the selected favorite hub group.</div>

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2012-07-01 18:41:13 +0000
+++ win32/MainWindow.cpp	2012-07-07 16:36:41 +0000
@@ -298,14 +298,18 @@
 		file->appendItem(T_("Open own list"), [this] { DirectoryListingFrame::openOwnList(getTabView(), Util::emptyStringT, DirectoryListingFrame::FORCE_ACTIVE); });
 		file->appendItem(T_("Match downloaded lists"), [this] { handleMatchAll(); });
 		file->appendItem(T_("Refresh file list\tF5"), [this] { handleRefreshFileList(); }, WinUtil::menuIcon(IDI_REFRESH));
+		file->appendSeparator();
+
 		file->appendItem(T_("Open downloads directory"), [this] { handleOpenDownloadsDir(); }, WinUtil::menuIcon(IDI_OPEN_DL_DIR));
 		file->appendItem(T_("Open crash log"), [this] { TextFrame::openWindow(getTabView(), CrashLogger::getPath()); });
 		file->appendSeparator();
 
 		file->appendItem(T_("Settings\tCtrl+F3"), [this] { handleSettings(); }, WinUtil::menuIcon(IDI_SETTINGS));
 		file->appendSeparator();
+
 		file->appendItem(T_("GeoIP database update"), [this] { updateGeo(); });
 		file->appendSeparator();
+
 		file->appendItem(T_("E&xit\tAlt+F4"), [this] { close(true); }, WinUtil::menuIcon(IDI_EXIT));
 	}
 
@@ -824,8 +828,8 @@
 	if(!WinUtil::checkNick())
 		return;
 
-	ParamDlg dlg(this, T_("Quick Connect"), T_("Address"));
-	if(dlg.run() == IDOK) {
+	ParamDlg dlg(this, T_("Quick Connect"), T_("Hub address or Magnet link"));
+	if(dlg.run() == IDOK && !WinUtil::parseLink(dlg.getValue(), false)) {
 		HubFrame::openWindow(getTabView(), Text::fromT(dlg.getValue()));
 	}
 }

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2012-06-23 10:44:48 +0000
+++ win32/WinUtil.cpp	2012-07-07 16:36:41 +0000
@@ -1397,7 +1397,7 @@
 	::ShellExecute(NULL, NULL, url.c_str(), NULL, NULL, SW_SHOWNORMAL);
 }
 
-bool WinUtil::parseLink(const tstring& str) {
+bool WinUtil::parseLink(const tstring& str, bool followExternal) {
 	auto url = Text::fromT(str);
 	string proto, host, port, file, query, fragment;
 	Util::decodeUrl(url, proto, host, port, file, query, fragment);
@@ -1426,9 +1426,10 @@
 
 		return true;
 
-	} else if(!proto.empty() ||
+	} else if(followExternal && (!proto.empty() ||
 		Util::strnicmp(str.c_str(), _T("www."), 4) == 0 ||
-		Util::strnicmp(str.c_str(), _T("mailto:";), 7) == 0) {
+		Util::strnicmp(str.c_str(), _T("mailto:";), 7) == 0))
+	{
 		openLink(str);
 		return true;
 

=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h	2012-06-02 12:48:00 +0000
+++ win32/WinUtil.h	2012-07-07 16:36:41 +0000
@@ -291,7 +291,7 @@
 
 	static bool getUCParams(dwt::Widget* parent, const UserCommand& cmd, ParamMap& params) noexcept;
 
-	static bool parseLink(const tstring& aString);
+	static bool parseLink(const tstring& str, bool followExternal = true);
 
 	static void help(dwt::Control* widget);
 	static void helpId(dwt::Control* widget, unsigned id);