diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-12 14:36:58 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-12 14:36:58 +0300 |
commit | 76f9fa91806fe6a47db2dd95930e4985da5b1e3f (patch) | |
tree | cba257359c83a085185e2e54e898ca769508336a /protocols/IRCG/src | |
parent | 74e92c6e3d5f3fb6ffd0ce2af5bd460b0d323a90 (diff) |
IRC: code cleaning
Diffstat (limited to 'protocols/IRCG/src')
-rw-r--r-- | protocols/IRCG/src/commandmonitor.cpp | 14 | ||||
-rw-r--r-- | protocols/IRCG/src/input.cpp | 194 | ||||
-rw-r--r-- | protocols/IRCG/src/irclib.cpp | 10 | ||||
-rw-r--r-- | protocols/IRCG/src/ircproto.cpp | 12 | ||||
-rw-r--r-- | protocols/IRCG/src/options.cpp | 28 | ||||
-rw-r--r-- | protocols/IRCG/src/output.cpp | 14 | ||||
-rw-r--r-- | protocols/IRCG/src/services.cpp | 15 | ||||
-rw-r--r-- | protocols/IRCG/src/stdafx.h | 5 | ||||
-rw-r--r-- | protocols/IRCG/src/tools.cpp | 8 | ||||
-rw-r--r-- | protocols/IRCG/src/userinfo.cpp | 20 | ||||
-rw-r--r-- | protocols/IRCG/src/windows.cpp | 30 |
11 files changed, 177 insertions, 173 deletions
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index eb737428c0..7ed6a27940 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -55,7 +55,7 @@ VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR idEvent, DWORD) ppro->PostIrcMessage(L"/MODE %s -i", ppro->m_info.sNick.c_str());
if (mir_strlen(ppro->m_myHost) == 0 && ppro->IsConnected())
- ppro->DoUserhostWithReason(2, (L"S" + ppro->m_info.sNick), true, L"%s", ppro->m_info.sNick.c_str());
+ ppro->DoUserhostWithReason(2, (L"S" + ppro->m_info.sNick).c_str(), true, L"%s", ppro->m_info.sNick.c_str());
}
VOID CALLBACK KeepAliveTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
@@ -73,7 +73,7 @@ VOID CALLBACK KeepAliveTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD) if (!ppro->m_info.sServerName.IsEmpty())
mir_snwprintf(temp2, L"PING %s", ppro->m_info.sServerName.c_str());
else
- mir_snwprintf(temp2, L"PING %u", time(0));
+ mir_snwprintf(temp2, L"PING %u", (int)time(0));
if (ppro->IsConnected())
ppro->SendIrcMessage(temp2, false);
@@ -445,7 +445,7 @@ bool CIrcProto::OnIrc_MODEQUERY(const CIrcMessage *pmsg) p1++;
}
- AddWindowItemData(pmsg->parameters[1], sLimit.IsEmpty() ? nullptr : sLimit.c_str(), pmsg->parameters[2], sPassword.IsEmpty() ? nullptr : sPassword.c_str(), nullptr);
+ AddWindowItemData(pmsg->parameters[1], s2null(sLimit), pmsg->parameters[2], s2null(sPassword), nullptr);
}
ShowMessage(pmsg);
return true;
@@ -539,7 +539,7 @@ bool CIrcProto::OnIrc_MODE(const CIrcMessage *pmsg) wchar_t temp[4000];
mir_snwprintf(temp, TranslateT("%s sets mode %s%s"), pmsg->prefix.sNick.c_str(), sModes.c_str(), sParams.c_str());
- DoEvent(GC_EVENT_INFORMATION, pmsg->parameters[0].c_str(), pmsg->prefix.sNick, temp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, pmsg->parameters[0], pmsg->prefix.sNick, temp, nullptr, nullptr, NULL, true, false);
}
if (flag)
@@ -624,7 +624,7 @@ bool CIrcProto::OnIrc_NOTICE(const CIrcMessage *pmsg) S2 = GetWord(gci.pszID, 0);
}
}
- DoEvent(GC_EVENT_NOTICE, S2.IsEmpty() ? nullptr : S2.c_str(), S, pmsg->parameters[1], nullptr, S3, NULL, true, false);
+ DoEvent(GC_EVENT_NOTICE, s2null(S2), S, pmsg->parameters[1], nullptr, S3, NULL, true, false);
}
}
else ShowMessage(pmsg);
@@ -1338,7 +1338,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage *pmsg) SetChannelInfo(sChanName, wi);
if (!sTopic.IsEmpty() && !mir_wstrcmpi(GetWord(sTopic, 0), sChanName)) {
- DoEvent(GC_EVENT_TOPIC, sChanName, sTopicName.IsEmpty() ? nullptr : sTopicName.c_str(), GetWordAddress(sTopic, 1), nullptr, sTopicTime.IsEmpty() ? nullptr : sTopicTime.c_str(), NULL, true, false);
+ DoEvent(GC_EVENT_TOPIC, sChanName, s2null(sTopicName), GetWordAddress(sTopic, 1), nullptr, s2null(sTopicTime), NULL, true, false);
AddWindowItemData(sChanName, nullptr, nullptr, nullptr, GetWordAddress(sTopic, 1));
sTopic = L"";
sTopicName = L"";
@@ -1895,7 +1895,7 @@ bool CIrcProto::OnIrc_WHO_END(const CIrcMessage *pmsg) User = GetWord(m_whoReply, 0);
}
- Chat_SetStatusEx(Chat_Find(pmsg->parameters[1], m_szModuleName), GC_SSE_TABDELIMITED, S.IsEmpty() ? nullptr : S.c_str());
+ Chat_SetStatusEx(Chat_Find(pmsg->parameters[1], m_szModuleName), GC_SSE_TABDELIMITED, s2null(S));
return true;
}
diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp index 80c1c1070c..af495bfb9e 100644 --- a/protocols/IRCG/src/input.cpp +++ b/protocols/IRCG/src/input.cpp @@ -27,27 +27,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CIrcProto::FormatMsg(CMStringW& text)
{
wchar_t temp[30];
- mir_wstrncpy(temp, GetWord(text.c_str(), 0).c_str(), 29);
+ mir_wstrncpy(temp, GetWord(text, 0), 29);
CharLower(temp);
CMStringW command = temp;
CMStringW S = L"";
if (command == L"/quit" || command == L"/away")
- S = GetWord(text.c_str(), 0) + L" :" + GetWordAddress(text.c_str(), 1);
+ S = GetWord(text, 0) + L" :" + GetWordAddress(text, 1);
else if (command == L"/privmsg" || command == L"/part" || command == L"/topic" || command == L"/notice") {
- S = GetWord(text.c_str(), 0) + L" " + GetWord(text.c_str(), 1) + L" :";
- if (!GetWord(text.c_str(), 2).IsEmpty())
- S += CMStringW(GetWordAddress(text.c_str(), 2));
+ S = GetWord(text, 0) + L" " + GetWord(text, 1) + L" :";
+ if (!GetWord(text, 2).IsEmpty())
+ S += CMStringW(GetWordAddress(text, 2));
}
else if (command == L"/kick") {
- S = GetWord(text.c_str(), 0) + L" " + GetWord(text.c_str(), 1) + L" " + GetWord(text.c_str(), 2) + L" :" + GetWordAddress(text.c_str(), 3);
+ S = GetWord(text, 0) + L" " + GetWord(text, 1) + L" " + GetWord(text, 2) + L" :" + GetWordAddress(text, 3);
}
else if (command == L"/nick") {
- if (!wcsstr(GetWord(text.c_str(), 1).c_str(), NICKSUBSTITUTE)) {
- sNick4Perform = GetWord(text.c_str(), 1);
- S = GetWordAddress(text.c_str(), 0);
+ if (!wcsstr(GetWord(text, 1), NICKSUBSTITUTE)) {
+ sNick4Perform = GetWord(text, 1);
+ S = GetWordAddress(text, 0);
}
else {
- CMStringW sNewNick = GetWord(text.c_str(), 1);
+ CMStringW sNewNick = GetWord(text, 1);
if (sNick4Perform == L"") {
DBVARIANT dbv;
if (!getWString("PNick", &dbv)) {
@@ -56,11 +56,11 @@ void CIrcProto::FormatMsg(CMStringW& text) }
}
- sNewNick.Replace(NICKSUBSTITUTE, sNick4Perform.c_str());
- S = GetWord(text.c_str(), 0) + L" " + sNewNick;
+ sNewNick.Replace(NICKSUBSTITUTE, sNick4Perform);
+ S = GetWord(text, 0) + L" " + sNewNick;
}
}
- else S = GetWordAddress(text.c_str(), 0);
+ else S = GetWordAddress(text, 0);
S.Delete(0, 1);
text = S;
@@ -98,13 +98,13 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) CMStringW S = line;
delete[] line;
line = new wchar_t[S.GetLength() + 2];
- mir_wstrncpy(line, S.c_str(), S.GetLength() + 1);
+ mir_wstrncpy(line, S, S.GetLength() + 1);
CMStringW alias(m_alias);
- const wchar_t* p3 = wcsstr(alias.c_str(), (GetWord(line, 0) + L" ").c_str());
- if (p3 != alias.c_str()) {
+ const wchar_t* p3 = wcsstr(alias, (GetWord(line, 0) + L" "));
+ if (p3 != alias) {
CMStringW str = L"\r\n";
str += GetWord(line, 0) + L" ";
- p3 = wcsstr(alias.c_str(), str.c_str());
+ p3 = wcsstr(alias, str);
if (p3)
p3 += 2;
}
@@ -123,11 +123,11 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) for (int index = 1; index < 8; index++) {
mir_snwprintf(buf, L"#$%u", index);
if (!GetWord(line, index).IsEmpty() && IsChannel(GetWord(line, index)))
- str.Replace(buf, GetWord(line, index).c_str());
+ str.Replace(buf, GetWord(line, index));
else {
CMStringW S1 = L"#";
S1 += GetWord(line, index);
- str.Replace(buf, S1.c_str());
+ str.Replace(buf, S1);
}
}
for (int index2 = 1; index2 < 8; index2++) {
@@ -136,9 +136,9 @@ CMStringW CIrcProto::DoAlias(const wchar_t *text, wchar_t *window) }
for (int index3 = 1; index3 < 8; index3++) {
mir_snwprintf(buf, L"$%u", index3);
- str.Replace(buf, GetWord(line, index3).c_str());
+ str.Replace(buf, GetWord(line, index3));
}
- Messageout += GetWordAddress(str.c_str(), 1);
+ Messageout += GetWordAddress(str, 1);
}
else Messageout += line;
}
@@ -166,12 +166,12 @@ CMStringW CIrcProto::DoIdentifiers(CMStringW text, const wchar_t*) GetLocalTime(&time);
text.Replace(L"%mnick", m_nick);
text.Replace(L"%anick", m_alternativeNick);
- text.Replace(L"%awaymsg", m_statusMessage.c_str());
+ text.Replace(L"%awaymsg", m_statusMessage);
text.Replace(L"%module", _A2T(m_szModuleName));
text.Replace(L"%name", m_name);
text.Replace(L"%newl", L"\r\n");
text.Replace(L"%network", _A2T(m_szModuleName));
- text.Replace(L"%me", m_info.sNick.c_str());
+ text.Replace(L"%me", m_info.sNick);
char mirver[100];
Miranda_GetVersionText(mirver, _countof(mirver));
@@ -195,7 +195,7 @@ CMStringW CIrcProto::DoIdentifiers(CMStringW text, const wchar_t*) static void __stdcall sttSetTimerOn(void* _pro)
{
CIrcProto *ppro = (CIrcProto*)_pro;
- ppro->DoEvent(GC_EVENT_INFORMATION, nullptr, ppro->m_info.sNick.c_str(), TranslateT("The buddy check function is enabled"), nullptr, nullptr, NULL, true, false);
+ ppro->DoEvent(GC_EVENT_INFORMATION, nullptr, ppro->m_info.sNick, TranslateT("The buddy check function is enabled"), nullptr, nullptr, NULL, true, false);
ppro->SetChatTimer(ppro->OnlineNotifTimer, 500, OnlineNotifTimerProc);
if (ppro->m_channelAwayNotification)
ppro->SetChatTimer(ppro->OnlineNotifTimer3, 1500, OnlineNotifTimerProc3);
@@ -204,7 +204,7 @@ static void __stdcall sttSetTimerOn(void* _pro) static void __stdcall sttSetTimerOff(void* _pro)
{
CIrcProto *ppro = (CIrcProto*)_pro;
- ppro->DoEvent(GC_EVENT_INFORMATION, nullptr, ppro->m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), nullptr, nullptr, NULL, true, false);
+ ppro->DoEvent(GC_EVENT_INFORMATION, nullptr, ppro->m_info.sNick, TranslateT("The buddy check function is disabled"), nullptr, nullptr, NULL, true, false);
ppro->KillChatTimer(ppro->OnlineNotifTimer);
ppro->KillChatTimer(ppro->OnlineNotifTimer3);
}
@@ -227,10 +227,10 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo else if (command == L"/sleep" || command == L"/wait") {
if (!one.IsEmpty()) {
int ms;
- if (swscanf(one.c_str(), L"%d", &ms) == 1 && ms > 0 && ms <= 4000)
+ if (swscanf(one, L"%d", &ms) == 1 && ms > 0 && ms <= 4000)
Sleep(ms);
else
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Incorrect parameters. Usage: /sleep [ms], ms should be greater than 0 and less than 4000."), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Incorrect parameters. Usage: /sleep [ms], ms should be greater than 0 and less than 4000."), nullptr, nullptr, NULL, true, false);
}
return true;
}
@@ -255,58 +255,58 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo wchar_t temp[500];
if (one.IsEmpty()) {
if (m_ignore)
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Ignore system is enabled"), nullptr, nullptr, NULL, true, false);
else
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Ignore system is disabled"), nullptr, nullptr, NULL, true, false);
return true;
}
- if (!mir_wstrcmpi(one.c_str(), L"on")) {
+ if (!mir_wstrcmpi(one, L"on")) {
m_ignore = 1;
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Ignore system is enabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Ignore system is enabled"), nullptr, nullptr, NULL, true, false);
return true;
}
- if (!mir_wstrcmpi(one.c_str(), L"off")) {
+ if (!mir_wstrcmpi(one, L"off")) {
m_ignore = 0;
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Ignore system is disabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Ignore system is disabled"), nullptr, nullptr, NULL, true, false);
return true;
}
- if (!wcschr(one.c_str(), '!') && !wcschr(one.c_str(), '@'))
+ if (!wcschr(one, '!') && !wcschr(one, '@'))
one += L"!*@*";
if (!two.IsEmpty() && two[0] == '+') {
- if (wcschr(two.c_str(), 'q'))
+ if (wcschr(two, 'q'))
IgnoreFlags += 'q';
- if (wcschr(two.c_str(), 'n'))
+ if (wcschr(two, 'n'))
IgnoreFlags += 'n';
- if (wcschr(two.c_str(), 'i'))
+ if (wcschr(two, 'i'))
IgnoreFlags += 'i';
- if (wcschr(two.c_str(), 'd'))
+ if (wcschr(two, 'd'))
IgnoreFlags += 'd';
- if (wcschr(two.c_str(), 'c'))
+ if (wcschr(two, 'c'))
IgnoreFlags += 'c';
- if (wcschr(two.c_str(), 'm'))
+ if (wcschr(two, 'm'))
IgnoreFlags += 'm';
}
else IgnoreFlags = L"qnidc";
- AddIgnore(one.c_str(), IgnoreFlags.c_str());
+ AddIgnore(one, IgnoreFlags);
mir_snwprintf(temp, TranslateT("%s is now ignored (+%s)"), one.c_str(), IgnoreFlags.c_str());
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), temp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, temp, nullptr, nullptr, NULL, true, false);
}
return true;
}
if (command == L"/unignore") {
- if (!wcschr(one.c_str(), '!') && !wcschr(one.c_str(), '@'))
+ if (!wcschr(one, '!') && !wcschr(one, '@'))
one += L"!*@*";
wchar_t temp[500];
- if (RemoveIgnore(one.c_str()))
+ if (RemoveIgnore(one))
mir_snwprintf(temp, TranslateT("%s is not ignored now"), one.c_str());
else
mir_snwprintf(temp, TranslateT("%s was not ignored"), one.c_str());
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), temp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, temp, nullptr, nullptr, NULL, true, false);
return true;
}
@@ -357,7 +357,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (!Chat_GetInfo(&gci))
mir_snwprintf(szTemp, L"users: %u", gci.iCount);
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
return true;
}
@@ -365,13 +365,13 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (one.IsEmpty())
return true;
- if (!mir_wstrcmpi(one.c_str(), L"on")) {
+ if (!mir_wstrcmpi(one, L"on")) {
bEcho = TRUE;
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Outgoing commands are shown"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Outgoing commands are shown"), nullptr, nullptr, NULL, true, false);
}
- if (!mir_wstrcmpi(one.c_str(), L"off")) {
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("Outgoing commands are not shown"), nullptr, nullptr, NULL, true, false);
+ if (!mir_wstrcmpi(one, L"off")) {
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("Outgoing commands are not shown"), nullptr, nullptr, NULL, true, false);
bEcho = FALSE;
}
@@ -381,32 +381,32 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (command == L"/buddycheck") {
if (one.IsEmpty()) {
if ((m_autoOnlineNotification && !bTempDisableCheck) || bTempForceCheck)
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("The buddy check function is enabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("The buddy check function is enabled"), nullptr, nullptr, NULL, true, false);
else
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("The buddy check function is disabled"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("The buddy check function is disabled"), nullptr, nullptr, NULL, true, false);
return true;
}
- if (!mir_wstrcmpi(one.c_str(), L"on")) {
+ if (!mir_wstrcmpi(one, L"on")) {
bTempForceCheck = true;
bTempDisableCheck = false;
CallFunctionAsync(sttSetTimerOn, this);
}
- if (!mir_wstrcmpi(one.c_str(), L"off")) {
+ if (!mir_wstrcmpi(one, L"off")) {
bTempForceCheck = false;
bTempDisableCheck = true;
CallFunctionAsync(sttSetTimerOff, this);
}
- if (!mir_wstrcmpi(one.c_str(), L"time") && !two.IsEmpty()) {
- m_iTempCheckTime = _wtoi(two.c_str());
+ if (!mir_wstrcmpi(one, L"time") && !two.IsEmpty()) {
+ m_iTempCheckTime = _wtoi(two);
if (m_iTempCheckTime < 10 && m_iTempCheckTime != 0)
m_iTempCheckTime = 10;
if (m_iTempCheckTime == 0)
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("The time interval for the buddy check function is now at default setting"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("The time interval for the buddy check function is now at default setting"), nullptr, nullptr, NULL, true, false);
else {
wchar_t temp[200];
mir_snwprintf(temp, TranslateT("The time interval for the buddy check function is now %u seconds"), m_iTempCheckTime);
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), temp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, temp, nullptr, nullptr, NULL, true, false);
}
}
return true;
@@ -486,7 +486,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo return true;
wchar_t szTemp[4000];
- mir_snwprintf(szTemp, L"\001ACTION %s\001", GetWordAddress(text.c_str(), 1));
+ mir_snwprintf(szTemp, L"\001ACTION %s\001", GetWordAddress(text, 1));
PostIrcMessageWnd(window, hContact, szTemp);
return true;
}
@@ -495,7 +495,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (one.IsEmpty())
return true;
- CMStringW S = L"/ME " + DoIdentifiers(GetWordAddress(text.c_str(), 1), window);
+ CMStringW S = L"/ME " + DoIdentifiers(GetWordAddress(text, 1), window);
S.Replace(L"%", L"%%");
Chat_SendUserMessage(m_szModuleName, S);
return true;
@@ -505,7 +505,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (one.IsEmpty())
return true;
- CMStringW S = DoIdentifiers(GetWordAddress(text.c_str(), 1), window);
+ CMStringW S = DoIdentifiers(GetWordAddress(text, 1), window);
S.Replace(L"%", L"%%");
Chat_SendUserMessage(m_szModuleName, S);
return true;
@@ -516,33 +516,33 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo return true;
wchar_t szTemp[4000];
- mir_snwprintf(szTemp, L"/PRIVMSG %s", GetWordAddress(text.c_str(), 1));
+ mir_snwprintf(szTemp, L"/PRIVMSG %s", GetWordAddress(text, 1));
PostIrcMessageWnd(window, hContact, szTemp);
return true;
}
if (command == L"/query") {
- if (one.IsEmpty() || IsChannel(one.c_str()))
+ if (one.IsEmpty() || IsChannel(one))
return true;
CONTACT user = { one, nullptr, nullptr, false, false, false };
MCONTACT hContact2 = CList_AddContact(&user, false, false);
if (hContact2) {
if (getByte(hContact, "AdvancedMode", 0) == 0)
- DoUserhostWithReason(1, (L"S" + one).c_str(), true, one.c_str());
+ DoUserhostWithReason(1, (L"S" + one), true, one);
else {
DBVARIANT dbv1;
if (!getWString(hContact, "UWildcard", &dbv1)) {
CMStringW S = L"S";
S += dbv1.pwszVal;
- DoUserhostWithReason(2, S.c_str(), true, dbv1.pwszVal);
+ DoUserhostWithReason(2, S, true, dbv1.pwszVal);
db_free(&dbv1);
}
else {
CMStringW S = L"S";
S += one;
- DoUserhostWithReason(2, S.c_str(), true, one.c_str());
+ DoUserhostWithReason(2, S, true, one);
}
}
@@ -551,7 +551,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (!two.IsEmpty()) {
wchar_t szTemp[4000];
- mir_snwprintf(szTemp, L"/PRIVMSG %s", GetWordAddress(text.c_str(), 1));
+ mir_snwprintf(szTemp, L"/PRIVMSG %s", GetWordAddress(text, 1));
PostIrcMessageWnd(window, hContact, szTemp);
}
return true;
@@ -569,17 +569,17 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
// if it is not dcc or if it is dcc and a local ip exist
- if (mir_wstrcmpi(two.c_str(), L"dcc") != 0 || ulAdr) {
- if (mir_wstrcmpi(two.c_str(), L"ping") == 0)
- mir_snwprintf(szTemp, L"/PRIVMSG %s \001%s %u\001", one.c_str(), two.c_str(), time(0));
+ if (mir_wstrcmpi(two, L"dcc") != 0 || ulAdr) {
+ if (mir_wstrcmpi(two, L"ping") == 0)
+ mir_snwprintf(szTemp, L"/PRIVMSG %s \001%s %u\001", one.c_str(), two.c_str(), (int)time(0));
else
- mir_snwprintf(szTemp, L"/PRIVMSG %s \001%s\001", one.c_str(), GetWordAddress(text.c_str(), 2));
+ mir_snwprintf(szTemp, L"/PRIVMSG %s \001%s\001", one.c_str(), GetWordAddress(text, 2));
PostIrcMessageWnd(window, hContact, szTemp);
}
- if (mir_wstrcmpi(two.c_str(), L"dcc") != 0) {
- mir_snwprintf(szTemp, TranslateT("CTCP %s request sent to %s"), two.c_str(), one.c_str());
- DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ if (mir_wstrcmpi(two, L"dcc") != 0) {
+ mir_snwprintf(szTemp, TranslateT("CTCP %s request sent to %s"), two.c_str());
+ DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
}
return true;
@@ -589,7 +589,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (one.IsEmpty() || two.IsEmpty())
return true;
- if (mir_wstrcmpi(one.c_str(), L"send") == 0) {
+ if (mir_wstrcmpi(one, L"send") == 0) {
wchar_t szTemp[1000];
unsigned long ulAdr = 0;
@@ -605,25 +605,25 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo CMStringW s;
if (getByte(ccNew, "AdvancedMode", 0) == 0)
- DoUserhostWithReason(1, (L"S" + two).c_str(), true, two.c_str());
+ DoUserhostWithReason(1, (L"S" + two), true, two);
else {
DBVARIANT dbv1;
CMStringW S = L"S";
if (!getWString(ccNew, "UWildcard", &dbv1)) {
S += dbv1.pwszVal;
- DoUserhostWithReason(2, S.c_str(), true, dbv1.pwszVal);
+ DoUserhostWithReason(2, S, true, dbv1.pwszVal);
db_free(&dbv1);
}
else {
S += two;
- DoUserhostWithReason(2, S.c_str(), true, two.c_str());
+ DoUserhostWithReason(2, S, true, two);
}
}
if (three.IsEmpty())
CallService(MS_FILE_SENDFILE, ccNew, 0);
else {
- CMStringW temp = GetWordAddress(text.c_str(), 3);
+ CMStringW temp = GetWordAddress(text, 3);
wchar_t* pp[2];
wchar_t* p = (wchar_t*)temp.c_str();
pp[0] = p;
@@ -634,12 +634,12 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo }
else {
mir_snwprintf(szTemp, TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
}
return true;
}
- if (mir_wstrcmpi(one.c_str(), L"chat") == 0) {
+ if (mir_wstrcmpi(one, L"chat") == 0) {
wchar_t szTemp[1000];
unsigned long ulAdr = 0;
@@ -672,17 +672,17 @@ BOOL CIrcProto::DoHardcodedCommand(CMStringW text, wchar_t *window, MCONTACT hCo if (iPort != 0) {
PostIrcMessage(L"/CTCP %s DCC CHAT chat %u %u", two.c_str(), ulAdr, iPort);
- mir_snwprintf(szTemp, TranslateT("DCC CHAT request sent to %s"), two.c_str(), one.c_str());
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ mir_snwprintf(szTemp, TranslateT("DCC CHAT request sent to %s"), two.c_str());
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
}
else {
mir_snwprintf(szTemp, TranslateT("DCC ERROR: Unable to bind port"));
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
}
}
else {
mir_snwprintf(szTemp, TranslateT("DCC ERROR: Unable to automatically resolve external IP"));
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
}
}
return true;
@@ -756,7 +756,7 @@ static void __stdcall DoInputRequestAliasApcStub(void* _par) if (defaulttext)
SetDlgItemText(question_hWnd, IDC_EDIT, defaulttext);
- SetDlgItemText(question_hWnd, IDC_HIDDENEDIT, command.c_str());
+ SetDlgItemText(question_hWnd, IDC_HIDDENEDIT, command);
dlg->Activate();
mir_free(str);
@@ -809,7 +809,7 @@ bool CIrcProto::PostIrcMessageWnd(wchar_t *window, MCONTACT hContact, const wcha AddCR(Message);
RemoveLinebreaks(Message);
if (!hContact && IsConnected()) {
- Message = DoAlias(Message.c_str(), windowname);
+ Message = DoAlias(Message, windowname);
if (Message.Find(L"%question") != -1) {
CallFunctionAsync(DoInputRequestAliasApcStub, new DoInputRequestParam(this, Message));
@@ -843,18 +843,18 @@ bool CIrcProto::PostIrcMessageWnd(wchar_t *window, MCONTACT hContact, const wcha Message.Delete(0, 2);
//do this if it's a /raw
- if (IsConnected() && (GetWord(DoThis.c_str(), 0) == L"/raw" || GetWord(DoThis.c_str(), 0) == L"/quote")) {
- if (GetWord(DoThis.c_str(), 1).IsEmpty())
+ if (IsConnected() && (GetWord(DoThis, 0) == L"/raw" || GetWord(DoThis, 0) == L"/quote")) {
+ if (GetWord(DoThis, 1).IsEmpty())
continue;
- CMStringW S = GetWordAddress(DoThis.c_str(), 1);
- SendIrcMessage(S.c_str(), true, cp);
+ CMStringW S = GetWordAddress(DoThis, 1);
+ SendIrcMessage(S, true, cp);
continue;
}
// Do this if the message is not a command
- if ((GetWord(DoThis.c_str(), 0)[0] != '/') || // not a command
- ((GetWord(DoThis.c_str(), 0)[0] == '/') && (GetWord(DoThis.c_str(), 0)[1] == '/')) || // or double backslash at the beginning
+ if ((GetWord(DoThis, 0)[0] != '/') || // not a command
+ ((GetWord(DoThis, 0)[0] == '/') && (GetWord(DoThis, 0)[1] == '/')) || // or double backslash at the beginning
hContact) {
CMStringW S = L"/PRIVMSG ";
if (mir_wstrcmpi(window, SERVERWINDOW) == 0 && !m_info.sServerName.IsEmpty())
@@ -881,21 +881,21 @@ bool CIrcProto::PostIrcMessageWnd(wchar_t *window, MCONTACT hContact, const wcha CDccSession *dcc = FindDCCSession(hContact);
if (dcc) {
FormatMsg(DoThis);
- CMStringW mess = GetWordAddress(DoThis.c_str(), 2);
+ CMStringW mess = GetWordAddress(DoThis, 2);
if (mess[0] == ':')
mess.Delete(0, 1);
mess += '\n';
- dcc->SendStuff(mess.c_str());
+ dcc->SendStuff(mess);
}
}
else if (IsConnected()) {
FormatMsg(DoThis);
- SendIrcMessage(DoThis.c_str(), false, cp);
+ SendIrcMessage(DoThis, false, cp);
}
}
else {
FormatMsg(DoThis);
- SendIrcMessage(DoThis.c_str(), true, cp);
+ SendIrcMessage(DoThis, true, cp);
}
}
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index cad89607c5..4b6737f153 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -231,7 +231,7 @@ bool CIrcProto::Connect(const CIrcSessionInfo &info) NLSend(L"NICK %s\r\n", info.sNick.c_str()); - CMStringW userID = GetWord(info.sUserID.c_str(), 0); + CMStringW userID = GetWord(info.sUserID, 0); wchar_t szHostName[MAX_PATH]; DWORD cbHostName = _countof(szHostName); GetComputerName(szHostName, &cbHostName); @@ -613,7 +613,7 @@ void CIrcSessionInfo::Reset() void CIrcProto::OnIrcMessage(const CIrcMessage *pmsg) { if (pmsg != nullptr) { - PfnIrcMessageHandler pfn = FindMethod(pmsg->sCommand.c_str()); + PfnIrcMessageHandler pfn = FindMethod(pmsg->sCommand); if (pfn) { // call member function. if it returns 'false', // call the default handling @@ -910,7 +910,7 @@ int CDccSession::SetupConnection() hBindPort = Netlib_BindPort(m_proto->hNetlibDCC, &nb); if (hBindPort == nullptr) { - m_proto->DoEvent(GC_EVENT_INFORMATION, nullptr, m_proto->m_info.sNick.c_str(), LPGENW("DCC ERROR: Unable to bind local port for passive file transfer"), nullptr, nullptr, NULL, true, false); + m_proto->DoEvent(GC_EVENT_INFORMATION, nullptr, m_proto->m_info.sNick, LPGENW("DCC ERROR: Unable to bind local port for passive file transfer"), nullptr, nullptr, NULL, true, false); delete this; // dcc objects destroy themselves when the connection has been closed or failed for some reasson. return 0; } @@ -1021,7 +1021,7 @@ void CDccSession::DoSendFile() // is there a connection? if (con) { // open the file for reading - int hFile = _wopen(di->sFileAndPath.c_str(), _O_RDONLY | _O_BINARY, _S_IREAD); + int hFile = _wopen(di->sFileAndPath, _O_RDONLY | _O_BINARY, _S_IREAD); if (hFile >= 0) { unsigned __int64 dwLastAck = 0; @@ -1161,7 +1161,7 @@ void CDccSession::DoReceiveFile() ProtoBroadcastAck(m_proto->m_szModuleName, di->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, di); // open the file for writing (and reading in case it is a resume) - int hFile = _wopen(di->sFileAndPath.c_str(), + int hFile = _wopen(di->sFileAndPath, (dwWhatNeedsDoing == FILERESUME_RESUME ? _O_APPEND : _O_TRUNC | _O_CREAT) | _O_RDWR | _O_BINARY, _S_IREAD | _S_IWRITE); if (hFile >= 0) { diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index 08ff522165..475be9220c 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -350,7 +350,7 @@ int CIrcProto::FileResume(HANDLE hTransfer, int action, const wchar_t *szFilenam unsigned __int64 dwPos = 0;
struct _stati64 statbuf;
- if (_wstat64(di->sFileAndPath.c_str(), &statbuf) == 0 && (statbuf.st_mode & _S_IFDIR) == 0)
+ if (_wstat64(di->sFileAndPath, &statbuf) == 0 && (statbuf.st_mode & _S_IFDIR) == 0)
dwPos = statbuf.st_size;
CMStringW sFileWithQuotes = di->sFile;
@@ -461,7 +461,7 @@ HANDLE CIrcProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t** ppszFile ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
if (!m_DCCPassive && !ulAdr) {
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("DCC ERROR: Unable to automatically resolve external IP"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("DCC ERROR: Unable to automatically resolve external IP"), nullptr, nullptr, NULL, true, false);
return nullptr;
}
@@ -478,7 +478,7 @@ HANDLE CIrcProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t** ppszFile }
if (size == 0) {
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), TranslateT("DCC ERROR: No valid files specified"), nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, TranslateT("DCC ERROR: No valid files specified"), nullptr, nullptr, NULL, true, false);
return nullptr;
}
@@ -528,7 +528,7 @@ HANDLE CIrcProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t** ppszFile mir_snwprintf(szTemp,
TranslateT("DCC reversed file transfer request sent to %s [%s]"),
dci->sContactName.c_str(), sFileCorrect.c_str());
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
if (m_sendNotice) {
mir_snwprintf(szTemp,
@@ -547,7 +547,7 @@ HANDLE CIrcProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t** ppszFile mir_snwprintf(szTemp,
TranslateT("DCC file transfer request sent to %s [%s]"),
dci->sContactName.c_str(), sFileCorrect.c_str());
- DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick.c_str(), szTemp, nullptr, nullptr, NULL, true, false);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, m_info.sNick, szTemp, nullptr, nullptr, NULL, true, false);
if (m_sendNotice) {
mir_snwprintf(szTemp,
@@ -672,7 +672,7 @@ HANDLE CIrcProto::GetAwayMsg(MCONTACT hContact) CMStringW S = L"WHOIS ";
S += dbv.pwszVal;
if (IsConnected())
- SendIrcMessage(S.c_str(), false);
+ SendIrcMessage(S, false);
db_free(&dbv);
}
}
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index fdbebce00f..93194bcf6b 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -502,14 +502,14 @@ public: if (m_proto->m_IPFromServer) {
if (m_proto->m_myHost[0]) {
CMStringW s = (CMStringW)TranslateT("<Resolved IP: ") + (wchar_t *)_A2T(m_proto->m_myHost) + L">";
- m_ip.SetText(s.c_str());
+ m_ip.SetText(s);
}
else m_ip.SetText(TranslateT("<Automatic>"));
}
else {
if (m_proto->m_myLocalHost[0]) {
CMStringW s = (CMStringW)TranslateT("<Local IP: ") + (wchar_t *)_A2T(m_proto->m_myLocalHost) + L">";
- m_ip.SetText(s.c_str());
+ m_ip.SetText(s);
}
else m_ip.SetText(TranslateT("<Automatic>"));
}
@@ -532,7 +532,7 @@ public: if (m_enableIP.GetState()) {
char szTemp[500];
m_ip.GetTextA(szTemp, sizeof(szTemp));
- mir_strncpy(m_proto->m_mySpecifiedHost, GetWord(szTemp, 0).c_str(), 499);
+ mir_strncpy(m_proto->m_mySpecifiedHost, GetWord(szTemp, 0), 499);
if (mir_strlen(m_proto->m_mySpecifiedHost))
m_proto->ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(m_proto->m_mySpecifiedHost, IP_MANUAL));
}
@@ -560,14 +560,14 @@ public: if (m_fromServer.GetState()) {
if (m_proto->m_myHost[0]) {
CMStringW s = (CMStringW)TranslateT("<Resolved IP: ") + (wchar_t *)_A2T(m_proto->m_myHost) + L">";
- m_ip.SetText(s.c_str());
+ m_ip.SetText(s);
}
else m_ip.SetText(TranslateT("<Automatic>"));
}
else {
if (m_proto->m_myLocalHost[0]) {
CMStringW s = (CMStringW)TranslateT("<Local IP: ") + (wchar_t *)_A2T(m_proto->m_myLocalHost) + L">";
- m_ip.SetText(s.c_str());
+ m_ip.SetText(s);
}
else m_ip.SetText(TranslateT("<Automatic>"));
}
@@ -685,7 +685,7 @@ public: CMStringA sSetting = CMStringA("PERFORM:") + it;
sSetting.MakeUpper();
- PERFORM_INFO *pPref = new PERFORM_INFO(sSetting.c_str(), m_proto->getMStringW(sSetting.c_str()));
+ PERFORM_INFO *pPref = new PERFORM_INFO(sSetting, m_proto->getMStringW(sSetting));
m_performCombo.AddString(_A2T(Translate(it)), (LPARAM)pPref);
}
@@ -718,9 +718,9 @@ public: continue;
if (pPerf->mText.IsEmpty())
- m_proto->delSetting(pPerf->mSetting.c_str());
+ m_proto->delSetting(pPerf->mSetting);
else
- m_proto->setWString(pPerf->mSetting.c_str(), pPerf->mText.c_str());
+ m_proto->setWString(pPerf->mSetting, pPerf->mText);
}
}
m_proto->WriteSettings(OtherSettings, _countof(OtherSettings));
@@ -748,7 +748,7 @@ public: if (pPerf == nullptr)
m_pertormEdit.SetTextA("");
else
- m_pertormEdit.SetText(pPerf->mText.c_str());
+ m_pertormEdit.SetText(pPerf->mText);
btnAdd.Disable();
if (GetWindowTextLength(m_pertormEdit.GetHwnd()) != 0)
m_delete.Enable();
@@ -883,13 +883,13 @@ public: CMStringW Mask = GetWord(szMask, 0);
if (Mask.GetLength() != 0) {
- if (!wcschr(Mask.c_str(), '!') && !wcschr(Mask.c_str(), '@'))
+ if (!wcschr(Mask, '!') && !wcschr(Mask, '@'))
Mask += L"!*@*";
if (!flags.IsEmpty()) {
if (szOldMask)
m_proto->RemoveIgnore(szOldMask);
- m_proto->AddIgnore(Mask.c_str(), flags.c_str());
+ m_proto->AddIgnore(Mask, flags);
}
}
return true;
@@ -960,7 +960,7 @@ void CIrcProto::InitIgnore(void) CMStringA mask = GetWord(p1, 0);
CMStringA flags = GetWord(p1, 1);
if (!mask.IsEmpty())
- m_ignoreItems.insert(new CIrcIgnoreItem(getCodepage(), mask.c_str(), flags.c_str()));
+ m_ignoreItems.insert(new CIrcIgnoreItem(getCodepage(), mask, flags));
p1 = p2;
}
@@ -982,7 +982,7 @@ void CIrcProto::InitIgnore(void) CMStringW mask = GetWord(dbv.pwszVal, 0);
CMStringW flags = GetWord(dbv.pwszVal, 1);
- m_ignoreItems.insert(new CIrcIgnoreItem(mask.c_str(), flags.c_str()));
+ m_ignoreItems.insert(new CIrcIgnoreItem(mask, flags));
db_free(&dbv);
}
}
@@ -1002,7 +1002,7 @@ void CIrcProto::RewriteIgnoreSettings(void) mir_snprintf(settingName, "IGNORE:%d", i);
CIrcIgnoreItem &C = m_ignoreItems[i];
- setWString(settingName, (C.mask + L" " + C.flags).c_str());
+ setWString(settingName, (C.mask + L" " + C.flags));
}
}
diff --git a/protocols/IRCG/src/output.cpp b/protocols/IRCG/src/output.cpp index 0e8bc3ff0b..be429f5571 100644 --- a/protocols/IRCG/src/output.cpp +++ b/protocols/IRCG/src/output.cpp @@ -40,7 +40,7 @@ static CMStringW FormatOutput(const CIrcMessage *pmsg) goto THE_END;
}
- int index = _wtoi(pmsg->sCommand.c_str());
+ int index = _wtoi(pmsg->sCommand);
if (index == 301 && pmsg->parameters.getCount() > 0) {
sMessage.Format(TranslateT("%s is away"), pmsg->parameters[1].c_str());
for (int i = 2; i < pmsg->parameters.getCount(); i++)
@@ -68,7 +68,7 @@ static CMStringW FormatOutput(const CIrcMessage *pmsg) CMStringW tempstr = pmsg->parameters[1];
tempstr.Delete(0, 1);
tempstr.Delete(tempstr.GetLength() - 1, 1);
- CMStringW type = GetWord(tempstr.c_str(), 0);
+ CMStringW type = GetWord(tempstr, 0);
if (mir_wstrcmpi(type.c_str(), L"ping") == 0)
sMessage.Format(TranslateT("CTCP %s reply sent to %s"), type.c_str(), pmsg->parameters[0].c_str());
else
@@ -112,23 +112,23 @@ BOOL CIrcProto::ShowMessage(const CIrcMessage* pmsg) if (!pmsg->m_bIncoming)
mess.Replace(L"%%", L"%");
- int iTemp = _wtoi(pmsg->sCommand.c_str());
+ int iTemp = _wtoi(pmsg->sCommand);
//To active window
if ((iTemp > 400 || iTemp < 500) && pmsg->sCommand[0] == '4' //all error messages
|| pmsg->sCommand == L"303" //ISON command
|| pmsg->sCommand == L"INVITE"
- || ((pmsg->sCommand == L"NOTICE") && ((pmsg->parameters.getCount() > 2) ? (wcsstr(pmsg->parameters[1].c_str(), L"\001") == nullptr) : false)) // CTCP answers should go to m_network Log window!
+ || ((pmsg->sCommand == L"NOTICE") && ((pmsg->parameters.getCount() > 2) ? (wcsstr(pmsg->parameters[1], L"\001") == nullptr) : false)) // CTCP answers should go to m_network Log window!
|| pmsg->sCommand == L"515") //chanserv error
{
- DoEvent(GC_EVENT_INFORMATION, nullptr, pmsg->m_bIncoming ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(), mess.c_str(), nullptr, nullptr, NULL, true, pmsg->m_bIncoming ? false : true);
+ DoEvent(GC_EVENT_INFORMATION, nullptr, pmsg->m_bIncoming ? pmsg->prefix.sNick : m_info.sNick, mess, nullptr, nullptr, NULL, true, pmsg->m_bIncoming ? false : true);
return TRUE;
}
if (m_useServer) {
DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW,
- (pmsg->m_bIncoming) ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(),
- mess.c_str(), nullptr, nullptr, NULL, true, pmsg->m_bIncoming ? false : true);
+ (pmsg->m_bIncoming) ? pmsg->prefix.sNick : m_info.sNick,
+ mess, nullptr, nullptr, NULL, true, pmsg->m_bIncoming ? false : true);
return true;
}
return false;
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index b2aa2604a8..edcefa6a76 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -157,8 +157,7 @@ INT_PTR __cdecl CIrcProto::OnDoubleclicked(WPARAM, LPARAM lParam) dlg->Show();
HWND hWnd = dlg->GetHwnd();
wchar_t szTemp[500];
- mir_snwprintf(szTemp, TranslateT("%s (%s) is requesting a client-to-client chat connection."),
- pdci->sContactName.c_str(), pdci->sHostmask.c_str());
+ mir_snwprintf(szTemp, TranslateT("%s (%s) is requesting a client-to-client chat connection."), pdci->sContactName.c_str(), pdci->sHostmask.c_str());
SetDlgItemText(hWnd, IDC_TEXT, szTemp);
ShowWindow(hWnd, SW_SHOW);
return 1;
@@ -331,7 +330,7 @@ INT_PTR __cdecl CIrcProto::OnChangeNickMenuCommand(WPARAM, LPARAM) SetDlgItemText(m_nickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Change nickname"));
SetDlgItemText(m_nickDlg->GetHwnd(), IDC_TEXT, TranslateT("Please enter a unique nickname"));
- m_nickDlg->m_Enick.SetText(m_info.sNick.c_str());
+ m_nickDlg->m_Enick.SetText(m_info.sNick);
m_nickDlg->m_Enick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
ShowWindow(m_nickDlg->GetHwnd(), SW_SHOW);
SetActiveWindow(m_nickDlg->GetHwnd());
@@ -790,12 +789,12 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam) nickItems[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; // DCC submenu
auto *wi = GetChannelInfo(gcmi->pszID);
- BOOL bServOwner = strchr(sUserModes.c_str(), 'q') == nullptr ? FALSE : TRUE;
- BOOL bServAdmin = strchr(sUserModes.c_str(), 'a') == nullptr ? FALSE : TRUE;
+ BOOL bServOwner = strchr(sUserModes, 'q') == nullptr ? FALSE : TRUE;
+ BOOL bServAdmin = strchr(sUserModes, 'a') == nullptr ? FALSE : TRUE;
BOOL bOwner = bServOwner ? ((wi->OwnMode >> 4) & 01) : FALSE;
BOOL bAdmin = bServAdmin ? ((wi->OwnMode >> 3) & 01) : FALSE;
- BOOL bOp = strchr(sUserModes.c_str(), 'o') == nullptr ? FALSE : ((wi->OwnMode >> 2) & 01);
- BOOL bHalfop = strchr(sUserModes.c_str(), 'h') == nullptr ? FALSE : ((wi->OwnMode >> 1) & 01);
+ BOOL bOp = strchr(sUserModes, 'o') == nullptr ? FALSE : ((wi->OwnMode >> 2) & 01);
+ BOOL bHalfop = strchr(sUserModes, 'h') == nullptr ? FALSE : ((wi->OwnMode >> 1) & 01);
BOOL bForceEnable = GetAsyncKeyState(VK_CONTROL);
@@ -998,7 +997,7 @@ INT_PTR __cdecl CIrcProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) if ((int)wParam != m_iStatus)
return 0;
- const wchar_t* p = m_statusMessage.c_str();
+ const wchar_t* p = m_statusMessage;
return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_wstrdup(p) : (INT_PTR)mir_u2a(p);
}
diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index d690634e4f..f83906cfcd 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -216,6 +216,11 @@ wchar_t* __stdcall DoColorCodes(const wchar_t* text, bool bStrip, bool bRe CMStringA __stdcall GetWord(const char* text, int index);
+__forceinline const wchar_t* s2null(const CMStringW &str)
+{
+ return (str.IsEmpty()) ? nullptr : str.c_str();
+}
+
#pragma comment(lib,"comctl32.lib")
#endif
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 164f955f0b..34acf7dd3c 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -73,7 +73,7 @@ void CIrcProto::AddToJTemp(wchar_t op, CMStringW& sCommand) db_free(&dbv);
}
- setWString("JTemp", res.c_str());
+ setWString("JTemp", res);
}
CMStringW __stdcall GetWord(const wchar_t* text, int index)
@@ -411,7 +411,7 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const wchar_t *pszWindow, const wchar_t * gce.pszUserInfo.w = m_showAddresses ? pszUserInfo : nullptr;
if (!sText.IsEmpty())
- gce.pszText.w = sText.c_str();
+ gce.pszText.w = sText;
if (timestamp == 1)
gce.time = time(0);
@@ -444,7 +444,7 @@ CMStringW CIrcProto::ModeToStatus(int sMode) CMStringW CIrcProto::PrefixToStatus(int cPrefix)
{
- const wchar_t* p = wcschr(sUserModePrefixes.c_str(), cPrefix);
+ const wchar_t* p = wcschr(sUserModePrefixes, cPrefix);
if (p) {
int index = int(p - sUserModePrefixes.c_str());
return ModeToStatus(sUserModes[index]);
@@ -531,7 +531,7 @@ int CIrcProto::SetChannelSBText(CMStringW sWindow, CHANNELINFO *wi) }
if (wi->pszTopic)
sTemp += wi->pszTopic;
- sTemp = DoColorCodes(sTemp.c_str(), TRUE, FALSE);
+ sTemp = DoColorCodes(sTemp, TRUE, FALSE);
Chat_SetStatusbarText(Chat_Find(sWindow, m_szModuleName), sTemp);
return 0;
}
diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp index c0e18fa0eb..2515886ac9 100644 --- a/protocols/IRCG/src/userinfo.cpp +++ b/protocols/IRCG/src/userinfo.cpp @@ -117,7 +117,7 @@ public: S += dbv.pwszVal;
S += L")";
if ((mir_wstrlen(temp) < 4 && mir_wstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.pwszVal))) {
- MessageBox(nullptr, TranslateW(S.c_str()), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
+ MessageBox(nullptr, TranslateW(S), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
db_free(&dbv);
return;
}
@@ -125,25 +125,25 @@ public: }
GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, _countof(temp));
- if (mir_wstrlen(GetWord(temp, 0).c_str()))
- ppro->setWString(m_hContact, "UWildcard", GetWord(temp, 0).c_str());
+ if (mir_wstrlen(GetWord(temp, 0)))
+ ppro->setWString(m_hContact, "UWildcard", GetWord(temp, 0));
else
- db_unset(m_hContact, ppro->m_szModuleName, "UWildcard");
+ ppro->delSetting(m_hContact, "UWildcard");
}
ppro->setByte(m_hContact, "AdvancedMode", bAdvanced);
GetDlgItemText(m_hwnd, IDC_USER, temp, _countof(temp));
- if (mir_wstrlen(GetWord(temp, 0).c_str()))
- ppro->setWString(m_hContact, "UUser", GetWord(temp, 0).c_str());
+ if (mir_wstrlen(GetWord(temp, 0)))
+ ppro->setWString(m_hContact, "UUser", GetWord(temp, 0));
else
- db_unset(m_hContact, ppro->m_szModuleName, "UUser");
+ ppro->delSetting(m_hContact, "UUser");
GetDlgItemText(m_hwnd, IDC_HOST, temp, _countof(temp));
- if (mir_wstrlen(GetWord(temp, 0).c_str()))
- ppro->setWString(m_hContact, "UHost", GetWord(temp, 0).c_str());
+ if (mir_wstrlen(GetWord(temp, 0)))
+ ppro->setWString(m_hContact, "UHost", GetWord(temp, 0));
else
- db_unset(m_hContact, ppro->m_szModuleName, "UHost");
+ ppro->delSetting(m_hContact, "UHost");
btn1.Disable();
}
diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index 9c3bdafade..e27c60e6d9 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -153,10 +153,10 @@ void CWhoisDlg::ShowMessage(const CIrcMessage* pmsg) m_InfoNick.SendMsg(CB_ADDSTRING, 0, (LPARAM)pmsg->parameters[1].c_str());
int i = m_InfoNick.SendMsg(CB_FINDSTRINGEXACT, -1, (LPARAM)pmsg->parameters[1].c_str());
m_InfoNick.SendMsg(CB_SETCURSEL, i, 0);
- m_Caption.SetText(pmsg->parameters[1].c_str());
- m_InfoName.SetText(pmsg->parameters[5].c_str());
- m_InfoAddress.SetText(pmsg->parameters[3].c_str());
- m_InfoId.SetText(pmsg->parameters[2].c_str());
+ m_Caption.SetText(pmsg->parameters[1]);
+ m_InfoName.SetText(pmsg->parameters[5]);
+ m_InfoAddress.SetText(pmsg->parameters[3]);
+ m_InfoId.SetText(pmsg->parameters[2]);
m_InfoChannels.SetText(L"");
m_InfoServer.SetText(L"");
m_InfoAway2.SetText(L"");
@@ -174,9 +174,9 @@ void CWhoisDlg::ShowMessage(const CIrcMessage* pmsg) void CWhoisDlg::ShowMessageNoUser(const CIrcMessage *pmsg)
{
- m_InfoNick.SetText(pmsg->parameters[2].c_str());
+ m_InfoNick.SetText(pmsg->parameters[2]);
m_InfoNick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
- m_Caption.SetText(pmsg->parameters[2].c_str());
+ m_Caption.SetText(pmsg->parameters[2]);
m_InfoName.SetText(L"");
m_InfoAddress.SetText(L"");
m_InfoId.SetText(L"");
@@ -235,7 +235,7 @@ bool CNickDlg::OnApply() }
db_free(&dbv);
}
- m_proto->setWString("RecentNicks", S.c_str());
+ m_proto->setWString("RecentNicks", S);
return true;
}
@@ -541,7 +541,7 @@ bool CJoinDlg::OnApply() }
db_free(&dbv);
}
- m_proto->setWString("RecentChannels", S.c_str());
+ m_proto->setWString("RecentChannels", S);
return true;
}
@@ -726,7 +726,7 @@ bool CManagerDlg::OnInitDialog() m_list.SendMsg(LB_SETHORIZONTALEXTENT, 750, NULL);
m_radio1.SetState(true);
- const char* modes = m_proto->sChannelModes.c_str();
+ const char* modes = m_proto->sChannelModes;
if (!strchr(modes, 't')) m_check1.Disable();
if (!strchr(modes, 'n')) m_check2.Disable();
if (!strchr(modes, 'i')) m_check3.Disable();
@@ -772,7 +772,7 @@ bool CManagerDlg::OnClose() if (!S.IsEmpty() && m_proto->IsConnected()) {
mir_snwprintf(temp, L"Topic%s", window);
char* p = mir_u2a(temp);
- m_proto->setWString(p, S.c_str());
+ m_proto->setWString(p, S);
mir_free(p);
}
@@ -849,7 +849,7 @@ void CManagerDlg::OnEdit(CCtrlButton*) HWND addban_hWnd = dlg->GetHwnd();
SetDlgItemText(addban_hWnd, IDC_CAPTION, temp);
SetDlgItemText(addban_hWnd, IDC_TEXT, TranslateT("Please enter the hostmask (nick!user@host)"));
- SetDlgItemText(addban_hWnd, IDC_EDIT, user.c_str());
+ SetDlgItemText(addban_hWnd, IDC_EDIT, user);
m_add.Disable();
m_edit.Disable();
@@ -892,7 +892,7 @@ void CManagerDlg::OnRemove(CCtrlButton*) wchar_t window[256];
GetDlgItemText(m_hwnd, IDC_CAPTION, window, _countof(window));
- if (MessageBox(m_hwnd, user.c_str(), temp, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) {
+ if (MessageBox(m_hwnd, user, temp, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) {
m_proto->PostIrcMessage(L"/MODE %s %s %s", window, mode, user.c_str());
ApplyQuestion();
}
@@ -1041,9 +1041,9 @@ void CManagerDlg::OnApplyModes(CCtrlButton*) if (mir_wstrlen(toadd))
mir_snwprintf(temp, L"%s+%s", temp, toadd);
if (!appendixremove.IsEmpty())
- mir_wstrcat(temp, appendixremove.c_str());
+ mir_wstrcat(temp, appendixremove);
if (!appendixadd.IsEmpty())
- mir_wstrcat(temp, appendixadd.c_str());
+ mir_wstrcat(temp, appendixadd);
m_proto->PostIrcMessage(temp);
}
}
@@ -1210,7 +1210,7 @@ void CManagerDlg::InitManager(int mode, const wchar_t* window) }
}
- if (strchr(m_proto->sChannelModes.c_str(), 'b')) {
+ if (strchr(m_proto->sChannelModes, 'b')) {
m_radio1.SetState(true);
m_proto->PostIrcMessage(L"/MODE %s +b", window);
}
|