From 7ba28b7ff398cc9a018237407eebbf5a91382018 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 15 Nov 2017 13:31:14 +0300 Subject: IRC: - octal sequences replaced with hex constants; - code cleaning; - version bump --- protocols/IRCG/src/irclib.cpp | 2 +- protocols/IRCG/src/irclib.h | 6 ++++++ protocols/IRCG/src/options.cpp | 2 +- protocols/IRCG/src/services.cpp | 11 +++++------ protocols/IRCG/src/stdafx.h | 4 ++-- protocols/IRCG/src/tools.cpp | 10 +++++----- protocols/IRCG/src/version.h | 6 +++--- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 1fe7a849f1..c0be7a3e87 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -201,7 +201,7 @@ bool CIrcProto::Connect(const CIrcSessionInfo& info) con = Netlib_OpenConnection(m_hNetlibUser, &ncon); if (con == nullptr) { wchar_t szTemp[300]; - mir_snwprintf(szTemp, L"\0035%s \002%s\002 (%S: %u).", TranslateT("Failed to connect to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort); + mir_snwprintf(szTemp, L"%c5%s %c%s%c (%S: %u).", irc::COLOR, TranslateT("Failed to connect to"), irc::BOLD, si.sNetwork.c_str(), irc::BOLD, si.sServer.c_str(), si.iPort); DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, nullptr, szTemp, nullptr, nullptr, NULL, true, false); return false; } diff --git a/protocols/IRCG/src/irclib.h b/protocols/IRCG/src/irclib.h index e75d5205a9..a6df9a0d8d 100644 --- a/protocols/IRCG/src/irclib.h +++ b/protocols/IRCG/src/irclib.h @@ -33,6 +33,12 @@ char* ConvertIntegerToIP(unsigned long int_ip_addr); namespace irc { //////////////////////////////////////////////////////////////////// +const int BOLD = 0x02; +const int COLOR = 0x03; +const int RESET = 0x0F; +const int ITALICS = 0x1D; +const int UNDERLINE = 0x1F; + struct DCCINFO : public MZeroedObject { DWORD dwAdr; diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 749df2f0e8..49e3049c9e 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -923,7 +923,7 @@ void CCtcpPrefsDlg::OnApply() static TDbSetting OtherSettings[] = { { FIELD_OFFSET(CIrcProto, m_quitMessage), "QuitMessage", DBVT_WCHAR, _countof(pZero->m_quitMessage) }, - { FIELD_OFFSET(CIrcProto, m_alias), "Alias", DBVT_WCHAR, -1 }, + { FIELD_OFFSET(CIrcProto, m_alias), "Alias", DBVT_WCHAR, (size_t)-1 }, { FIELD_OFFSET(CIrcProto, m_codepage), "Codepage", DBVT_DWORD, 0, CP_ACP }, { FIELD_OFFSET(CIrcProto, m_utfAutodetect), "UtfAutodetect", DBVT_BYTE }, { FIELD_OFFSET(CIrcProto, m_perform), "Perform", DBVT_BYTE }, diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 7c3443a98a..00bb276d8a 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -379,7 +379,7 @@ static int mapSrmm2irc[] = { 1, 2, 10, 6, 3, 7, 5, 14, 15, 12, 11, 13, 9, 8, 4, static wchar_t* DoPrintColor(wchar_t *pDest, int iFG, int iBG) { - *pDest = 3; + *pDest = irc::COLOR; if (iFG == -1) { if (iBG == -1) pDest[1] = 0; @@ -409,17 +409,17 @@ static void DoChatFormatting(CMStringW &wszText) case 'B': case 'b': wszText.Delete(i, 2); - wszText.Insert(i, L"\002"); + wszText.Insert(i, irc::BOLD); break; case 'I': case 'i': wszText.Delete(i, 2); - wszText.Insert(i, L"\026"); + wszText.Insert(i, irc::ITALICS); break; case 'U': case 'u': wszText.Delete(i, 2); - wszText.Insert(i, L"\037"); + wszText.Insert(i, irc::UNDERLINE); break; case 'c': @@ -1026,8 +1026,7 @@ void CIrcProto::ConnectToServer(void) InterlockedIncrement((long *)&m_bConnectRequested); wchar_t szTemp[300]; - mir_snwprintf(szTemp, L"\033%s \002%s\002 (%S: %u)", - TranslateT("Connecting to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort); + mir_snwprintf(szTemp, L"\033%s %c%s%c (%S: %u)", TranslateT("Connecting to"), irc::BOLD, si.sNetwork.c_str(), irc::BOLD, si.sServer.c_str(), si.iPort); DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, nullptr, szTemp, nullptr, nullptr, NULL, true, false); } diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index a96192f873..4a5c6eea79 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -79,12 +79,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IRC_UM_DISCONNECT "/UMenuDisconnect" #define IRC_UM_IGNORE "/UMenuIgnore" -#define STR_QUITMESSAGE L"\002Miranda NG!\002 Smaller, Faster, Easier. https://miranda-ng.org/" +#define STR_QUITMESSAGE L"Miranda NG! Smaller, Faster, Easier. https://miranda-ng.org/" #define STR_USERINFO L"I'm a happy Miranda NG user! Get it here: https://miranda-ng.org/" #define STR_AWAYMESSAGE L"I'm away from the computer." // Default away #define DCCSTRING L" (DCC)" #define SERVERSMODULE "IRC Servers" -#define SERVERWINDOW L"Network log" +#define SERVERWINDOW L"Network log" #define DCC_CHAT 1 #define DCC_SEND 2 diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 8c71220aae..a174921927 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -273,7 +273,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP text++; break; - case 2: // bold + case irc::BOLD: if (!bStrip) { *p++ = '%'; *p++ = bBold ? 'B' : 'b'; @@ -282,7 +282,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP text++; break; - case 15: // reset + case irc::RESET: if (!bStrip) { *p++ = '%'; *p++ = 'r'; @@ -291,7 +291,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP text++; break; - case 22: // italics + case irc::ITALICS: if (!bStrip) { *p++ = '%'; *p++ = bItalics ? 'I' : 'i'; @@ -300,7 +300,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP text++; break; - case 31: //underlined + case irc::UNDERLINE: if (!bStrip) { *p++ = '%'; *p++ = bUnderline ? 'U' : 'u'; @@ -309,7 +309,7 @@ wchar_t* __stdcall DoColorCodes(const wchar_t *text, bool bStrip, bool bReplaceP text++; break; - case 3: // colors + case irc::COLOR: int iOldBG, iOldFG; iOldBG = iBG, iOldFG = iFG; diff --git a/protocols/IRCG/src/version.h b/protocols/IRCG/src/version.h index 7b3cf028c6..129365f6fc 100644 --- a/protocols/IRCG/src/version.h +++ b/protocols/IRCG/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 11 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 3 +#define __MINOR_VERSION 95 +#define __RELEASE_NUM 7 +#define __BUILD_NUM 1 #include -- cgit v1.2.3