← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3000: add /topic and /raw commands in HubFrame

 

------------------------------------------------------------
revno: 3000
committer: iceman50 <bdcdevel@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Tue 2012-07-17 21:09:39 -0500
message:
  add /topic and /raw commands in HubFrame
modified:
  dcpp/Util.cpp
  dcpp/Util.h
  win32/HubFrame.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 'dcpp/Util.cpp'
--- dcpp/Util.cpp	2012-07-13 18:50:28 +0000
+++ dcpp/Util.cpp	2012-07-18 02:09:39 +0000
@@ -195,6 +195,47 @@
 
 	File::ensureDirectory(paths[PATH_USER_CONFIG]);
 	File::ensureDirectory(paths[PATH_USER_LOCAL]);
+
+}
+
+string Util::convertCEscapes(string tmp)
+{
+	string::size_type i = 0;
+	while( (i = tmp.find('\\', i)) != string::npos) {
+		switch(tmp[i + 1]) {
+			case '\0':
+				return tmp;
+				break;
+			case 'a': tmp.replace(i, 2, "\a"); break;
+			case 'b': tmp.replace(i, 2, "\b"); break;
+			case 'e': tmp.replace(i, 2, "\033"); break;
+			case 'f': tmp.replace(i, 2, "\f"); break;
+			case 'n': tmp.replace(i, 2, "\n"); break;
+			case 'r': tmp.replace(i, 2, "\r"); break;
+			case 't': tmp.replace(i, 2, "\t"); break;
+			case 'v': tmp.replace(i, 2, "\v"); break;
+			case '\\': tmp.replace(i, 2, "\\"); break;
+			case 'x':
+				if(i < tmp.length() - 3) {
+					int num = strtol(tmp.substr(i + 2, 2).c_str(), NULL, 16);
+					tmp.replace(i, 4, string(1, (char)num));
+				}
+				break;
+			default:
+				if(tmp[i + 1] >= '0' && tmp[i + 1] <= '7') {
+					int c = 1;
+					if(tmp[i + 2] >= '0' && tmp[i + 2] <= '7') {
+						++c;
+						if(tmp[i + 1] <= '3' && tmp[i + 3] >= '0' && tmp[i + 3] <= '7')
+							++c;
+					}
+					int num = strtol(tmp.substr(i + 1, c).c_str(), NULL, 8);
+					tmp.replace(i, c + 1, string(1, (char)num));
+				}
+		}
+		i += 1;
+	}
+	return tmp;
 }
 
 void Util::migrate(const string& file) {

=== modified file 'dcpp/Util.h'
--- dcpp/Util.h	2012-07-13 19:41:18 +0000
+++ dcpp/Util.h	2012-07-18 02:09:39 +0000
@@ -440,6 +440,8 @@
 	static int stricmp(const wstring& a, const wstring& b) { return stricmp(a.c_str(), b.c_str()); }
 	static int strnicmp(const wstring& a, const wstring& b, size_t n) { return strnicmp(a.c_str(), b.c_str(), n); }
 
+	static string convertCEscapes(string tmp);
+
 	static bool getAway();
 	static void incAway();
 	static void decAway();

=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2012-07-13 18:50:28 +0000
+++ win32/HubFrame.cpp	2012-07-18 02:09:39 +0000
@@ -495,12 +495,16 @@
 				openLog();
 			else if(Util::stricmp(param.c_str(), _T("status")) == 0)
 				openLog(true);
+		} else if(Util::stricmp(cmd.c_str(), _T("raw")) == 0) {
+			client->send(Util::convertCEscapes(Text::fromT(param)));
+		} else if(Util::stricmp(cmd.c_str(), _T("topic")) == 0) {
+			addChat(_T("Current hub topic: " + Text::toT(client->getHubDescription())));
 		} 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], /info, ")
 				_T("/pm <user> [message], /getlist <user>, /ignore <user>, /unignore <user>, ")
-				_T("/log <status, system, downloads, uploads>"));
+				_T("/log <status, system, downloads, uploads>, /raw <raw-command>, /topic"));
 		} else if(Util::stricmp(cmd.c_str(), _T("pm")) == 0) {
 			string::size_type j = param.find(_T(' '));
 			if(j != string::npos) {