← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3109: dev plugin: add a Port column

 

------------------------------------------------------------
revno: 3109
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2012-11-06 18:50:04 +0100
message:
  dev plugin: add a Port column
modified:
  SConstruct
  dcpp/FavoriteManager.cpp
  plugins/Dev/Dialog.cpp
  plugins/Dev/Dialog.h
  plugins/Dev/Plugin.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 'SConstruct'
--- SConstruct	2012-11-05 00:44:33 +0000
+++ SConstruct	2012-11-06 17:50:04 +0000
@@ -69,9 +69,8 @@
 	'release' : []
 }
 
-# TODO remove _VARIADIC_MAX if/when VC has proper variadic template support
 msvc_defs = {
-	'common' : ['_REENTRANT', '_VARIADIC_MAX=10', 'snprintf=_snprintf'],
+	'common' : ['_REENTRANT', 'snprintf=_snprintf'],
 	'debug' : ['_DEBUG', '_HAS_ITERATOR_DEBUGGING=0', '_SECURE_SCL=0'],
 	'release' : ['NDEBUG']
 }

=== modified file 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp	2012-10-20 16:10:39 +0000
+++ dcpp/FavoriteManager.cpp	2012-11-06 17:50:04 +0000
@@ -287,8 +287,7 @@
 			const string& maxUsers = getAttrib(attribs, "Maxusers", 5);
 			const string& reliability = getAttrib(attribs, "Reliability", 5);
 			const string& rating = getAttrib(attribs, "Rating", 5);
-			/// @todo change to emplace_back when MSVC has templates with var args, thus allowing these 12 arguments! (its current emulation only goes up to 10)
-			publicHubs.push_back(HubEntry(name, server, description, users, country, shared, minShare, minSlots, maxHubs, maxUsers, reliability, rating));
+			publicHubs.emplace_back(name, server, description, users, country, shared, minShare, minSlots, maxHubs, maxUsers, reliability, rating);
 		}
 	}
 private:

=== modified file 'plugins/Dev/Dialog.cpp'
--- plugins/Dev/Dialog.cpp	2012-11-04 19:15:24 +0000
+++ plugins/Dev/Dialog.cpp	2012-11-06 17:50:04 +0000
@@ -71,8 +71,8 @@
 	}
 }
 
-void Dialog::write(bool hubOrUser, bool sending, string ip, string peer, string message) {
-	Message msg = { hubOrUser, sending, move(ip), move(peer), move(message) };
+void Dialog::write(bool hubOrUser, bool sending, string ip, decltype(ConnectionData().port) port, string peer, string message) {
+	Message msg = { hubOrUser, sending, move(ip), port, move(peer), move(message) };
 	messages.push(msg);
 }
 
@@ -132,13 +132,17 @@
 	col.pszText = _T("IP");
 	ListView_InsertColumn(control, 2, &col);
 
+	col.cx = 50;
+	col.pszText = _T("Port");
+	ListView_InsertColumn(control, 3, &col);
+
 	col.cx = 200;
 	col.pszText = _T("Peer info");
-	ListView_InsertColumn(control, 3, &col);
+	ListView_InsertColumn(control, 4, &col);
 
-	col.cx = rect.right - rect.left - 50 - 50 - 100 - 200 - 30;
+	col.cx = rect.right - rect.left - 50 - 50 - 100 - 50 - 200 - 30;
 	col.pszText = _T("Message");
-	ListView_InsertColumn(control, 4, &col);
+	ListView_InsertColumn(control, 5, &col);
 
 	SendMessage(GetDlgItem(hwnd, IDC_SCROLL), BM_SETCHECK, BST_CHECKED, 0);
 	SendMessage(GetDlgItem(hwnd, IDC_HUB_MESSAGES), BM_SETCHECK, BST_CHECKED, 0);
@@ -183,6 +187,7 @@
 		item->index = Util::toT(boost::lexical_cast<string>(counter));
 		item->dir = message.sending ? _T("Out") : _T("In");
 		item->ip = move(ip);
+		item->port = Util::toT(boost::lexical_cast<string>(message.port));
 		item->peer = Util::toT(message.peer);
 		item->message = Util::toT(message.message);
 
@@ -206,10 +211,14 @@
 		ListView_SetItem(control, &lvi);
 
 		lvi.iSubItem = 3;
+		lvi.pszText = const_cast<LPTSTR>(item->port.c_str());
+		ListView_SetItem(control, &lvi);
+
+		lvi.iSubItem = 4;
 		lvi.pszText = const_cast<LPTSTR>(item->peer.c_str());
 		ListView_SetItem(control, &lvi);
 
-		lvi.iSubItem = 4;
+		lvi.iSubItem = 5;
 		lvi.pszText = const_cast<LPTSTR>(item->message.c_str());
 		ListView_SetItem(control, &lvi);
 
@@ -329,7 +338,7 @@
 		if(ListView_GetItem(control, &lvi)) {
 			auto& item = *reinterpret_cast<Item*>(lvi.lParam);
 			if(!str.empty()) { str += _T("\r\n"); }
-			str += item.index + _T(" [") + item.dir + _T("] ") + item.ip + _T(" (") + item.peer + _T("): ") + item.message;
+			str += item.index + _T(" [") + item.dir + _T("] ") + item.ip + _T(":") + item.port + _T(" (") + item.peer + _T("): ") + item.message;
 		}
 	}
 

=== modified file 'plugins/Dev/Dialog.h'
--- plugins/Dev/Dialog.h	2012-10-30 18:48:58 +0000
+++ plugins/Dev/Dialog.h	2012-11-06 17:50:04 +0000
@@ -35,7 +35,7 @@
 	~Dialog();
 
 	void create();
-	void write(bool hubOrUser, bool sending, string ip, string peer, string message);
+	void write(bool hubOrUser, bool sending, string ip, decltype(ConnectionData().port) port, string peer, string message);
 	void close();
 
 	static HINSTANCE instance;
@@ -58,7 +58,7 @@
 	HWND hwnd;
 
 	// store the messages to be displayed here; process them with a timer.
-	struct Message { bool hubOrUser; bool sending; string ip; string peer; string message; };
+	struct Message { bool hubOrUser; bool sending; string ip; decltype(ConnectionData().port) port; string peer; string message; };
 	boost::lockfree::queue<Message> messages;
 
 	uint16_t counter;
@@ -74,6 +74,7 @@
 		tstring index;
 		tstring dir;
 		tstring ip;
+		tstring port;
 		tstring peer;
 		tstring message;
 	};

=== modified file 'plugins/Dev/Plugin.cpp'
--- plugins/Dev/Plugin.cpp	2012-11-04 19:15:24 +0000
+++ plugins/Dev/Plugin.cpp	2012-11-06 17:50:04 +0000
@@ -136,22 +136,22 @@
 }
 
 Bool Plugin::onHubDataIn(HubDataPtr hHub, const char* message) {
-	dialog.write(true, false, hHub->ip, "Hub " + string(hHub->url), message);
+	dialog.write(true, false, hHub->ip, hHub->port, "Hub " + string(hHub->url), message);
 	return False;
 }
 
 Bool Plugin::onHubDataOut(HubDataPtr hHub, const char* message) {
-	dialog.write(true, true, hHub->ip, "Hub " + string(hHub->url), message);
+	dialog.write(true, true, hHub->ip, hHub->port, "Hub " + string(hHub->url), message);
 	return False;
 }
 
 Bool Plugin::onConnectionDataIn(ConnectionDataPtr hConn, const char* message) {
-	dialog.write(false, false, hConn->ip, "User" /** @todo get user's nick */, message);
+	dialog.write(false, false, hConn->ip, hConn->port, "User" /** @todo get user's nick */, message);
 	return False;
 }
 
 Bool Plugin::onConnectionDataOut(ConnectionDataPtr hConn, const char* message) {
-	dialog.write(false, true, hConn->ip, "User" /** @todo get user's nick */, message);
+	dialog.write(false, true, hConn->ip, hConn->port, "User" /** @todo get user's nick */, message);
 	return False;
 }