← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2940: Add a /info hub command (very basic - to be extended)

 

------------------------------------------------------------
revno: 2940
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2012-06-03 19:49:39 +0200
message:
  Add a /info hub command (very basic - to be extended)
modified:
  changelog.txt
  win32/HubFrame.cpp
  win32/HubFrame.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-06-03 17:22:16 +0000
+++ changelog.txt	2012-06-03 17:49:39 +0000
@@ -6,6 +6,7 @@
 * Fix a mixup between IPs and hostnames leading to wrong search results (poy)
 * Tweak help tooltips in the settings dialog (poy)
 * Make the menu bar hideable (poy)
+* Add a /info hub command (poy)
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2012-05-30 17:28:37 +0000
+++ win32/HubFrame.cpp	2012-06-03 17:49:39 +0000
@@ -405,6 +405,21 @@
 			if(!status.empty()) {
 				addStatus(status);
 			}
+		} else if(Util::stricmp(cmd.c_str(), _T("info")) == 0) {
+			map<tstring, string> info;
+			info[T_("Hub address")] = url;
+			info[T_("Hub IP & port")] = client->getIpPort();
+			info[T_("Online users")] = Util::toString(getUserCount());
+			info[T_("Shared")] = Util::formatBytes(client->getAvailable());
+			info[T_("Nick")] = client->get(HubSettings::Nick);
+			info[T_("Description")] = client->get(HubSettings::Description);
+			info[T_("Email")] = client->get(HubSettings::Email);
+			info[T_("External / WAN IP")] = client->get(HubSettings::UserIp);
+			tstring text;
+			for(auto& i: info) {
+				text += _T("\r\n") + i.first + _T(": ") + Text::toT(i.second);
+			}
+			addChat(_T("*** ") + text);
 		} else if(Util::stricmp(cmd.c_str(), _T("join"))==0) {
 			if(!param.empty()) {
 				if(BOOLSETTING(JOIN_OPEN_NEW_WINDOW)) {
@@ -473,7 +488,7 @@
 		} else if(Util::stricmp(cmd.c_str(), _T("help")) == 0) {
 			addChat(_T("*** ") + WinUtil::commands +
 				_T(", /join <hub-ip>, /showjoins, /favshowjoins, /close, /userlist, ")
-				_T("/conn[ection], /fav[orite], /removefav[orite], ")
+				_T("/conn[ection], /fav[orite], /removefav[orite], /info, ")
 				_T("/pm <user> [message], /getlist <user>, /ignore <user>, /unignore <user>, ")
 				_T("/log <status, system, downloads, uploads>"));
 		} else if(Util::stricmp(cmd.c_str(), _T("pm")) == 0) {
@@ -984,19 +999,25 @@
 	return Text::toT(Util::formatBytes(available));
 }
 
+size_t HubFrame::getUserCount() const {
+	size_t userCount = 0;
+	for(auto& i: userMap) {
+		if(!i.second->isHidden()) {
+			++userCount;
+		}
+	}
+	return userCount;
+}
+
 pair<size_t, tstring> HubFrame::getStatusUsers() const {
-	size_t userCount = 0;
-	for(auto& i: userMap) {
-		UserInfo* ui = i.second;
-		if(!ui->isHidden())
-			userCount++;
-	}
+	auto userCount = getUserCount();
 
 	tstring textForUsers;
 	if (users->countSelected() > 1)
 		textForUsers += Text::toT(Util::toString(users->countSelected()) + "/");
 	if (showUsers->getChecked() && users->size() < userCount)
 		textForUsers += Text::toT(Util::toString(users->size()) + "/");
+
 	return make_pair(userCount, textForUsers);
 }
 

=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h	2012-05-30 17:28:37 +0000
+++ win32/HubFrame.h	2012-06-03 17:49:39 +0000
@@ -196,6 +196,7 @@
 	void addedChat(const tstring& message);
 	void addStatus(const tstring& text, bool legitimate = true);
 
+	size_t getUserCount() const;
 	pair<size_t, tstring> getStatusUsers() const;
 	tstring getStatusShared() const;
 	tstring getStatusAverageShared() const;