diff options
author | George Hazan <ghazan@miranda.im> | 2018-02-21 18:40:03 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-02-21 18:40:14 +0300 |
commit | 477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb (patch) | |
tree | 247eed13a5231c3983e343f0b7fc2a95012353c2 /protocols | |
parent | 9d0174ebe2bd005418855b18f737c36d5c20ab4a (diff) |
all another C++'11 iterators
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/stdafx.h | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/theme.cpp | 6 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.cpp | 6 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/links.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 55 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 255 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 7 | ||||
-rw-r--r-- | protocols/Steam/src/steam_accounts.cpp | 6 | ||||
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 7 | ||||
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 6 | ||||
-rw-r--r-- | protocols/Twitter/src/theme.cpp | 6 |
14 files changed, 184 insertions, 206 deletions
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 263f33a462..b502a1f471 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -320,8 +320,8 @@ HttpRequest* facebook_client::markMessageReadRequest(const LIST<char> &ids) p->Url << INT_PARAM("__a", 1); - for (int i = 0; i < ids.getCount(); i++) { - std::string id_ = ids[i]; + for (auto &it : ids) { + std::string id_ = it; // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId if (id_.substr(0, 3) == "id.") id_ = id_.substr(3); diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h index 83efa47cf7..ea411d908f 100644 --- a/protocols/FacebookRM/src/stdafx.h +++ b/protocols/FacebookRM/src/stdafx.h @@ -86,6 +86,6 @@ extern DWORD g_mirandaVersion; template <typename T>
__inline static void FreeList(const LIST<T> &lst)
{
- for (int i = 0; i < lst.getCount(); i++)
- mir_free(lst[i]);
+ for (auto &it : lst)
+ mir_free(it);
}
\ No newline at end of file diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index 70c0835308..91d7931076 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -75,9 +75,9 @@ static FacebookProto * GetInstanceByHContact(MCONTACT hContact) if (!proto)
return nullptr;
- for (int i = 0; i < g_Instances.getCount(); i++)
- if (!mir_strcmp(proto, g_Instances[i].m_szModuleName))
- return &g_Instances[i];
+ for (auto &it : g_Instances)
+ if (!mir_strcmp(proto, it->m_szModuleName))
+ return it;
return nullptr;
}
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 65e71a7456..ab7356ec0a 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -291,14 +291,14 @@ void __cdecl GaduProto::avatarrequestthread(void*) gg_sleep(100, FALSE, "avatarrequestthread", 101, 1);
}
- for (int i = 0; i < avatar_requests.getCount(); i++)
- mir_free(avatar_requests[i]);
-
- for (int k = 0; k < avatar_transfers.getCount(); k++)
- mir_free(avatar_transfers[k]);
-
+ for (auto &it : avatar_requests)
+ mir_free(it);
avatar_requests.destroy();
+
+ for (auto &it : avatar_transfers)
+ mir_free(it);
avatar_transfers.destroy();
+
debugLogA("avatarrequestthread(): end. Avatar Request Thread Ending");
}
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 1d7c253dc5..bb7855c744 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -222,9 +222,9 @@ static GaduProto* gg_getprotoinstance(MCONTACT hContact) if (szProto == nullptr)
return nullptr;
- for (int i = 0; i < g_Instances.getCount(); i++)
- if (mir_strcmp(szProto, g_Instances[i]->m_szModuleName) == 0)
- return g_Instances[i];
+ for (auto &it : g_Instances)
+ if (mir_strcmp(szProto, it->m_szModuleName) == 0)
+ return it;
return nullptr;
}
diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index 02e4986236..295e9dbcf2 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -60,15 +60,13 @@ static INT_PTR gg_parselink(WPARAM, LPARAM lParam) GaduProto *gg = nullptr;
int items = 0;
- for (int i = 0; i < g_Instances.getCount(); i++) {
- gg = g_Instances[i];
-
- if (gg->m_iStatus > ID_STATUS_OFFLINE) {
+ for (auto &it : g_Instances) {
+ gg = it;
+ if (it->m_iStatus > ID_STATUS_OFFLINE) {
++items;
- Menu_ModifyItem(gg->hInstanceMenuItem, nullptr, Skin_LoadProtoIcon(gg->m_szModuleName, gg->m_iStatus));
+ Menu_ModifyItem(it->hInstanceMenuItem, nullptr, Skin_LoadProtoIcon(it->m_szModuleName, it->m_iStatus));
}
- else
- Menu_ShowItem(gg->hInstanceMenuItem, false);
+ else Menu_ShowItem(it->hInstanceMenuItem, false);
}
if (items > 1) {
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index da0df144b6..cfe7942297 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -82,7 +82,6 @@ char *oauth_uri_escape(const char *str) char *oauth_generate_signature(LIST<OAUTHPARAMETER> ¶ms, const char *httpmethod, const char *url)
{
char *res;
- OAUTHPARAMETER *p;
int ix = 0;
if (httpmethod == nullptr || url == nullptr || !params.getCount()) return mir_strdup("");
@@ -103,10 +102,9 @@ char *oauth_generate_signature(LIST<OAUTHPARAMETER> ¶ms, const char *httpmet mir_free(urlnorm);
int size = (int)mir_strlen(httpmethod) + (int)mir_strlen(urlenc) + 1 + 2;
- for (int i = 0; i < params.getCount(); i++) {
- p = params[i];
+ for (auto &p : params) {
if (!mir_strcmp(p->name, "oauth_signature")) continue;
- if (i > 0) size += 3;
+ if (p != params[0]) size += 3;
size += (int)mir_strlen(p->name) + (int)mir_strlen(p->value) + 3;
}
@@ -117,10 +115,9 @@ char *oauth_generate_signature(LIST<OAUTHPARAMETER> ¶ms, const char *httpmet mir_free(urlenc);
mir_strcat(res, "&");
- for (int i = 0; i < params.getCount(); i++) {
- p = params[i];
+ for (auto &p : params) {
if (!mir_strcmp(p->name, "oauth_signature")) continue;
- if (i > 0) mir_strcat(res, "%26");
+ if (p != params[0]) mir_strcat(res, "%26");
mir_strcat(res, p->name);
mir_strcat(res, "%3D");
mir_strcat(res, p->value);
@@ -136,11 +133,9 @@ char *oauth_getparam(LIST<OAUTHPARAMETER> ¶ms, const char *name) if (name == nullptr)
return nullptr;
- for (int i = 0; i < params.getCount(); i++) {
- p = params[i];
+ for (auto &p : params)
if (!mir_strcmp(p->name, name))
return p->value;
- }
return nullptr;
}
@@ -152,14 +147,12 @@ void oauth_setparam(LIST<OAUTHPARAMETER> ¶ms, const char *name, const char * if (name == nullptr)
return;
- for (int i = 0; i < params.getCount(); i++) {
- p = params[i];
+ for (auto &p : params)
if (!mir_strcmp(p->name, name)) {
mir_free(p->value);
p->value = oauth_uri_escape(value);
return;
}
- }
p = (OAUTHPARAMETER*)mir_alloc(sizeof(OAUTHPARAMETER));
p->name = oauth_uri_escape(name);
@@ -169,10 +162,7 @@ void oauth_setparam(LIST<OAUTHPARAMETER> ¶ms, const char *name, const char * void oauth_freeparams(LIST<OAUTHPARAMETER> ¶ms)
{
- OAUTHPARAMETER *p;
-
- for (int i = 0; i < params.getCount(); i++) {
- p = params[i];
+ for (auto &p : params) {
mir_free(p->name);
mir_free(p->value);
}
@@ -236,8 +226,6 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD const char *consumer_key, const char *consumer_secret,
const char *token, const char *token_secret)
{
- char *res, timestamp[22];
-
if (httpmethod == nullptr || url == nullptr)
return nullptr;
@@ -257,6 +245,8 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD oauth_setparam(oauth_parameters, "oauth_signature_method", "PLAINTEXT");
break;
};
+
+ char timestamp[22];
mir_snprintf(timestamp, "%ld", time(nullptr));
oauth_setparam(oauth_parameters, "oauth_timestamp", timestamp);
oauth_setparam(oauth_parameters, "oauth_nonce", ptrA(oauth_generate_nonce()));
@@ -268,27 +258,18 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD return nullptr;
}
- int size = 7;
- for (int i = 0; i < oauth_parameters.getCount(); i++) {
- OAUTHPARAMETER *p = oauth_parameters[i];
- if (i > 0) size++;
- size += (int)mir_strlen(p->name) + (int)mir_strlen(p->value) + 3;
- }
-
- res = (char *)mir_alloc(size);
- mir_strcpy(res, "OAuth ");
-
- for (int i = 0; i < oauth_parameters.getCount(); i++) {
- OAUTHPARAMETER *p = oauth_parameters[i];
- if (i > 0) mir_strcat(res, ",");
- mir_strcat(res, p->name);
- mir_strcat(res, "=\"");
- mir_strcat(res, p->value);
- mir_strcat(res, "\"");
+ CMStringA res("OAuth ");
+ for (auto &p : oauth_parameters) {
+ if (res.GetLength() > 6)
+ res.AppendChar(',');
+ res.Append(p->name);
+ res.Append("=\"");
+ res.Append(p->value);
+ res.Append("\"");
}
oauth_freeparams(oauth_parameters);
- return res;
+ return res.Detach();
}
int GaduProto::oauth_receivetoken()
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index 980313d4fd..03cd7f2336 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -2,8 +2,8 @@ static int MraExtraIconsApplyAll(WPARAM, LPARAM)
{
- for (int i = 0; i < g_Instances.getCount(); i++)
- g_Instances[i]->MraExtraIconsApply(0, 0);
+ for (auto &it : g_Instances)
+ it->MraExtraIconsApply(0, 0);
return 0;
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index dd1768c5c3..7acb2c8b80 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -47,14 +47,14 @@ static DWORD GetParamValue(const CMStringA &szData, LPCSTR szParamName, DWORD dw LPSTR lpszParamDataStart = strstr(tmp, szParamName);
if (lpszParamDataStart)
- if ((*((WORD*)(lpszParamDataStart + dwParamNameSize))) == (*((WORD*)"=\""))) {
- lpszParamDataStart += dwParamNameSize + 2;
- LPSTR lpszParamDataEnd = strchr(lpszParamDataStart, '"');
- if (lpszParamDataEnd) {
- szParamValue = CMStringA(szData.c_str() + (lpszParamDataStart - tmp), lpszParamDataEnd - lpszParamDataStart);
- return NO_ERROR;
+ if ((*((WORD*)(lpszParamDataStart + dwParamNameSize))) == (*((WORD*)"=\""))) {
+ lpszParamDataStart += dwParamNameSize + 2;
+ LPSTR lpszParamDataEnd = strchr(lpszParamDataStart, '"');
+ if (lpszParamDataEnd) {
+ szParamValue = CMStringA(szData.c_str() + (lpszParamDataStart - tmp), lpszParamDataEnd - lpszParamDataStart);
+ return NO_ERROR;
+ }
}
- }
return ERROR_NOT_FOUND;
}
@@ -66,10 +66,10 @@ CMStringA MraGetVersionStringFromFormatted(const CMStringA &szUserAgentFormatted CMStringA res, tmp;
if (!GetParamValue(szUserAgentFormatted, "name", 4, tmp))
- if (tmp == "Miranda IM" || tmp == "Miranda NG") {
- GetParamValue(szUserAgentFormatted, "title", 5, res);
- return res;
- }
+ if (tmp == "Miranda IM" || tmp == "Miranda NG") {
+ GetParamValue(szUserAgentFormatted, "title", 5, res);
+ return res;
+ }
if (!GetParamValue(szUserAgentFormatted, "client", 6, tmp)) {
if (tmp == "wmagent")
@@ -184,7 +184,7 @@ void MraAddrListFree(MRA_ADDR_LIST *pmalAddrList) bool DB_GetStaticStringA(MCONTACT hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
{
bool bRet = false;
-
+
DBVARIANT dbv = { 0 };
if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv) == 0) {
size_t dwRetBuffSizeLocal, dwReadedStringLen = mir_wstrlen(dbv.pwszVal);
@@ -217,7 +217,7 @@ bool DB_GetStaticStringW(MCONTACT hContact, LPCSTR lpszModule, LPCSTR lpszValueN if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv) == 0) {
dwReadedStringLen = mir_wstrlen(dbv.pwszVal);
if (lpwszRetBuff && (dwRetBuffSize > dwReadedStringLen)) {
- memcpy(lpwszRetBuff, dbv.pszVal, (dwReadedStringLen*sizeof(WCHAR)));//include null terminated
+ memcpy(lpwszRetBuff, dbv.pszVal, (dwReadedStringLen * sizeof(WCHAR)));//include null terminated
(*((WCHAR*)(lpwszRetBuff + dwReadedStringLen))) = 0;
bRet = true;
}
@@ -307,11 +307,11 @@ DWORD CMraProto::MraMoveContactToGroup(MCONTACT hContact, DWORD dwGroupID, LPCTS {
MraGroupItem *p = NULL;
- for (int i = 0; i < m_groups.getCount(); i++)
- if (m_groups[i].m_name == ptszName) {
- p = &m_groups[i];
- break;
- }
+ for (auto &it : m_groups)
+ if (it->m_name == ptszName) {
+ p = it;
+ break;
+ }
if (p == NULL) {
if (m_groups.getCount() == 20)
@@ -319,8 +319,8 @@ DWORD CMraProto::MraMoveContactToGroup(MCONTACT hContact, DWORD dwGroupID, LPCTS DWORD id;
for (id = 0; id < 20; id++)
- if (m_groups.find((MraGroupItem*)&id) == NULL)
- break;
+ if (m_groups.find((MraGroupItem*)&id) == NULL)
+ break;
DWORD dwContactFlags = CONTACT_FLAG_UNICODE_NAME | CONTACT_FLAG_GROUP | (id << 24);
p = new MraGroupItem(id, dwContactFlags, ptszName);
@@ -346,8 +346,8 @@ DWORD CMraProto::GetContactFlags(MCONTACT hContact) CMStringA szEmail;
if (mraGetStringA(hContact, "e-mail", szEmail))
- if (IsEMailChatAgent(szEmail))
- dwRet |= CONTACT_FLAG_MULTICHAT;
+ if (IsEMailChatAgent(szEmail))
+ dwRet |= CONTACT_FLAG_MULTICHAT;
if (db_get_b(hContact, "CList", "Hidden", 0))
dwRet |= CONTACT_FLAG_SHADOW;
@@ -512,12 +512,12 @@ MCONTACT CMraProto::MraHContactFromEmail(const CMStringA &szEmail, BOOL bAddIfNe CMStringA szEMailLocal;
for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (mraGetStringA(hContact, "e-mail", szEMailLocal))
- if (szEMailLocal == szEmail) {
- if (bTemporary == FALSE)
- db_unset(hContact, "CList", "NotOnList");
- bFound = true;
- break;
- }
+ if (szEMailLocal == szEmail) {
+ if (bTemporary == FALSE)
+ db_unset(hContact, "CList", "NotOnList");
+ bFound = true;
+ break;
+ }
}
if (!bFound && bAddIfNeeded) {
@@ -557,14 +557,14 @@ MCONTACT CMraProto::MraHContactFromEmail(const CMStringA &szEmail, BOOL bAddIfNe bool CMraProto::MraUpdateContactInfo(MCONTACT hContact)
{
if (m_bLoggedIn && hContact)
- if (IsContactMra(hContact)) {
- CMStringA szEmail;
- if (mraGetStringA(hContact, "e-mail", szEmail)) {
- MraAvatarsQueueGetAvatarSimple(hAvatarsQueueHandle, GAIF_FORCE, hContact);
- if (MraWPRequestByEMail(hContact, ACKTYPE_GETINFO, szEmail))
- return true;
+ if (IsContactMra(hContact)) {
+ CMStringA szEmail;
+ if (mraGetStringA(hContact, "e-mail", szEmail)) {
+ MraAvatarsQueueGetAvatarSimple(hAvatarsQueueHandle, GAIF_FORCE, hContact);
+ if (MraWPRequestByEMail(hContact, ACKTYPE_GETINFO, szEmail))
+ return true;
+ }
}
- }
return false;
}
@@ -671,7 +671,7 @@ void CMraProto::MraUpdateEmailStatus(const CMStringA &pszFrom, const CMStringA & else MraPopupShowFromAgentW(MRA_POPUP_TYPE_EMAIL_STATUS, szStatusText);
}
else {
- if ( !force_display && getByte("IncrementalNewMailNotify", MRA_DEFAULT_INC_NEW_MAIL_NOTIFY)) {
+ if (!force_display && getByte("IncrementalNewMailNotify", MRA_DEFAULT_INC_NEW_MAIL_NOTIFY)) {
if (bTrayIconNewMailNotify)
pcli->pfnRemoveEvent(0, (LPARAM)m_szModuleName);
PUDeletePopup(hWndEMailPopupStatus);
@@ -707,8 +707,8 @@ bool IsContactMraProto(MCONTACT hContact) if (lpszProto) {
CMStringW szBuff;
if (DB_GetStringW(hContact, lpszProto, "AvatarLastCheckTime", szBuff))
- if (DB_GetStringW(hContact, lpszProto, "AvatarLastModifiedTime", szBuff))
- return true;
+ if (DB_GetStringW(hContact, lpszProto, "AvatarLastModifiedTime", szBuff))
+ return true;
}
return false;
}
@@ -719,8 +719,8 @@ bool CMraProto::IsEMailMy(const CMStringA &szEmail) CMStringA szEmailMy;
if (mraGetStringA(NULL, "e-mail", szEmailMy)) {
if (szEmail.GetLength() == szEmailMy.GetLength())
- if (!_stricmp(szEmail, szEmailMy))
- return true;
+ if (!_stricmp(szEmail, szEmailMy))
+ return true;
}
}
return false;
@@ -752,9 +752,9 @@ bool IsEMailMR(const CMStringA &szEmail) for (int i = 0; lpcszMailRuDomains[i]; i++) {
size_t dwDomainLen = mir_strlen(lpcszMailRuDomains[i]);
if (dwDomainLen < szEmail.GetLength())
- if (!_stricmp(lpcszMailRuDomains[i], szEmail.c_str() + szEmail.GetLength() - dwDomainLen))
- if (szEmail[szEmail.GetLength() - (int)dwDomainLen - 1] == '@')
- return true;
+ if (!_stricmp(lpcszMailRuDomains[i], szEmail.c_str() + szEmail.GetLength() - dwDomainLen))
+ if (szEmail[szEmail.GetLength() - (int)dwDomainLen - 1] == '@')
+ return true;
}
}
return false;
@@ -819,10 +819,10 @@ bool GetContactFirstEMailParam(MCONTACT hContact, BOOL bMRAOnly, LPSTR lpszModul CMStringA szEmail;
if (DB_GetStringA(hContact, lpszModule, lpszValueName, szEmail))
- if (bMRAOnly == FALSE || IsEMailMR(szEmail)) {
- res = szEmail;
- return true;
- }
+ if (bMRAOnly == FALSE || IsEMailMR(szEmail)) {
+ res = szEmail;
+ return true;
+ }
for (int i = 0; true; i++) {
char szBuff[100];
@@ -874,7 +874,7 @@ static void FakeThread(void* param) {
Thread_SetName("MRA: ProtoBroadcastAckAsync");
Sleep(100);
-
+
ACKDATA *ack = (ACKDATA*)param;
ProtoBroadcastAck(ack->szModule, ack->hContact, ack->type, ack->result, ack->hProcess, ack->lParam);
mir_free(param);
@@ -937,20 +937,20 @@ void EnableControlsArray(HWND hWndDlg, WORD *pwControlsList, size_t dwControlsLi static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_CHAR)
- if (GetKeyState(VK_CONTROL) & 0x8000) {
- if (wParam == '\n') {
- PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
- return 0;
- }
- if (wParam == 1) { // ctrl-a
- SendMessage(hwnd, EM_SETSEL, 0, -1);
- return 0;
- }
- if (wParam == 23) { // ctrl-w
- SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
- return 0;
+ if (GetKeyState(VK_CONTROL) & 0x8000) {
+ if (wParam == '\n') {
+ PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
+ return 0;
+ }
+ if (wParam == 1) { // ctrl-a
+ SendMessage(hwnd, EM_SETSEL, 0, -1);
+ return 0;
+ }
+ if (wParam == 23) { // ctrl-w
+ SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
+ return 0;
+ }
}
- }
return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam);
}
@@ -1109,7 +1109,7 @@ INT_PTR CALLBACK SendReplyBlogStatusDlgProc(HWND hWndDlg, UINT message, WPARAM w DWORD dwTime = dat->ppro->getDword(dat->hContact, DBSETTING_BLOGSTATUSTIME, 0);
if (dwTime && MakeLocalSystemTimeFromTime32(dwTime, &stBlogStatusTime))
szBuff.Format(L"%s: %04ld.%02ld.%02ld %02ld:%02ld", TranslateT("Written"),
- stBlogStatusTime.wYear, stBlogStatusTime.wMonth, stBlogStatusTime.wDay, stBlogStatusTime.wHour, stBlogStatusTime.wMinute);
+ stBlogStatusTime.wYear, stBlogStatusTime.wMonth, stBlogStatusTime.wDay, stBlogStatusTime.wHour, stBlogStatusTime.wMinute);
else
szBuff.Empty();
@@ -1202,8 +1202,8 @@ DWORD GetYears(CONST PSYSTEMTIME pcstSystemTime) // др в этом месяце
if (stTime.wMonth == pcstSystemTime->wMonth)
// ещё только будет, не сегодня
- if (stTime.wDay < pcstSystemTime->wDay)
- dwRet--;
+ if (stTime.wDay < pcstSystemTime->wDay)
+ dwRet--;
}
}
return dwRet;
@@ -1225,10 +1225,10 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD dwRecDeepCurPos = 0;
dwRecDeepAllocated = RECURSION_DATA_STACK_ITEMS_MIN;
- prdsiItems = (RECURSION_DATA_STACK_ITEM*)mir_calloc(dwRecDeepAllocated*sizeof(RECURSION_DATA_STACK_ITEM));
+ prdsiItems = (RECURSION_DATA_STACK_ITEM*)mir_calloc(dwRecDeepAllocated * sizeof(RECURSION_DATA_STACK_ITEM));
if (prdsiItems) {
dwPathLen = dwFolderLen;
- memcpy(szPath, lpszFolder, (dwPathLen*sizeof(WCHAR)));
+ memcpy(szPath, lpszFolder, (dwPathLen * sizeof(WCHAR)));
if (szPath[(dwPathLen - 1)] != '\\') {
szPath[dwPathLen] = '\\';
dwPathLen++;
@@ -1246,35 +1246,35 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD while (dwRetErrorCode == ERROR_FILE_NOT_FOUND && FindNextFile(prdsiItems[dwRecDeepCurPos].hFind, &prdsiItems[dwRecDeepCurPos].w32fdFindFileData)) {
if (prdsiItems[dwRecDeepCurPos].w32fdFindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {// folder
if (CompareString(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, L".", 1) != CSTR_EQUAL)
- if (CompareString(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, L"..", 2) != CSTR_EQUAL) {
- prdsiItems[dwRecDeepCurPos].dwFileNameLen = (int)mir_wstrlen(prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName) + 1;
- memcpy((szPath + dwPathLen), prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, (prdsiItems[dwRecDeepCurPos].dwFileNameLen*sizeof(WCHAR)));
- mir_wstrcat(szPath, L"\\*.*");
- dwPathLen += prdsiItems[dwRecDeepCurPos].dwFileNameLen;
-
- dwRecDeepCurPos++;
- if (dwRecDeepCurPos == dwRecDeepAllocated) { // need more space
- dwRecDeepAllocated += RECURSION_DATA_STACK_ITEMS_MIN;
- prdsiItems = (RECURSION_DATA_STACK_ITEM*)mir_realloc(prdsiItems, dwRecDeepAllocated*sizeof(RECURSION_DATA_STACK_ITEM));
- if (prdsiItems == NULL) {
- dwRecDeepCurPos = 0;
- dwRetErrorCode = GetLastError();
- break;
+ if (CompareString(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, L"..", 2) != CSTR_EQUAL) {
+ prdsiItems[dwRecDeepCurPos].dwFileNameLen = (int)mir_wstrlen(prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName) + 1;
+ memcpy((szPath + dwPathLen), prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, (prdsiItems[dwRecDeepCurPos].dwFileNameLen * sizeof(WCHAR)));
+ mir_wstrcat(szPath, L"\\*.*");
+ dwPathLen += prdsiItems[dwRecDeepCurPos].dwFileNameLen;
+
+ dwRecDeepCurPos++;
+ if (dwRecDeepCurPos == dwRecDeepAllocated) { // need more space
+ dwRecDeepAllocated += RECURSION_DATA_STACK_ITEMS_MIN;
+ prdsiItems = (RECURSION_DATA_STACK_ITEM*)mir_realloc(prdsiItems, dwRecDeepAllocated * sizeof(RECURSION_DATA_STACK_ITEM));
+ if (prdsiItems == NULL) {
+ dwRecDeepCurPos = 0;
+ dwRetErrorCode = GetLastError();
+ break;
+ }
}
+ prdsiItems[dwRecDeepCurPos].hFind = FindFirstFileEx(szPath, FindExInfoStandard, &prdsiItems[dwRecDeepCurPos].w32fdFindFileData, FindExSearchNameMatch, NULL, 0);
}
- prdsiItems[dwRecDeepCurPos].hFind = FindFirstFileEx(szPath, FindExInfoStandard, &prdsiItems[dwRecDeepCurPos].w32fdFindFileData, FindExSearchNameMatch, NULL, 0);
- }
}
else {// file
if (CompareString(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, lpszFileName, dwFileNameLen) == CSTR_EQUAL) {
prdsiItems[dwRecDeepCurPos].dwFileNameLen = (int)mir_wstrlen(prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName);
- memcpy((szPath + dwPathLen), prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, ((prdsiItems[dwRecDeepCurPos].dwFileNameLen + 1)*sizeof(WCHAR)));
+ memcpy((szPath + dwPathLen), prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, ((prdsiItems[dwRecDeepCurPos].dwFileNameLen + 1) * sizeof(WCHAR)));
dwFilePathLen = (dwPathLen + prdsiItems[dwRecDeepCurPos].dwFileNameLen);
if (pdwRetFilePathLen) (*pdwRetFilePathLen) = dwFilePathLen;
if (lpszRetFilePathName && dwRetFilePathLen) {
dwFilePathLen = min(dwFilePathLen, dwRetFilePathLen);
- memcpy(lpszRetFilePathName, szPath, ((dwFilePathLen + 1)*sizeof(WCHAR)));
+ memcpy(lpszRetFilePathName, szPath, ((dwFilePathLen + 1) * sizeof(WCHAR)));
}
dwRetErrorCode = NO_ERROR;
@@ -1284,8 +1284,7 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD if (prdsiItems) FindClose(prdsiItems[dwRecDeepCurPos].hFind);
dwRecDeepCurPos--;
- }
- while (dwRecDeepCurPos != -1);
+ } while (dwRecDeepCurPos != -1);
}
mir_free(prdsiItems);
}
@@ -1309,43 +1308,43 @@ bool CMraProto::GetPassDB(CMStringA &res) CMStringA szEmail;
if (mraGetContactSettingBlob(NULL, "pCryptData", btRandomData, sizeof(btRandomData), &dwRandomDataSize))
- if (dwRandomDataSize == sizeof(btRandomData))
- if (mraGetContactSettingBlob(NULL, "pCryptPass", btCryptedPass, sizeof(btCryptedPass), &dwCryptedPass))
- if (dwCryptedPass == sizeof(btCryptedPass))
- if (mraGetStringA(NULL, "e-mail", szEmail)) {
- mir_hmac_sha1(bthmacSHA1, (BYTE*)szEmail.c_str(), szEmail.GetLength(), btRandomData, sizeof(btRandomData));
-
- if (storageType == 2) {
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
- CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
- RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
-
- dwPassSize = btCryptedPass[0];
- SHA1GetDigest(&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], dwPassSize, btRandomData);
- if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
- return false;
-
- res = CMStringA((char*)&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], (int)dwPassSize);
- }
- else if (storageType == 1) {
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
- CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
- RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
- RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
-
- dwPassSize = (*btCryptedPass);
- btCryptedPass[dwPassSize + 1 + MIR_SHA1_HASH_SIZE] = 0;
-
- size_t dwDecodedSize;
- mir_ptr<BYTE> pDecoded((PBYTE)mir_base64_decode((LPCSTR)&btCryptedPass[1 + MIR_SHA1_HASH_SIZE], &dwDecodedSize));
- SHA1GetDigest(pDecoded, dwDecodedSize, btRandomData);
- if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
- return false;
- res = CMStringA((LPSTR)(PBYTE)pDecoded, dwDecodedSize);
- }
- else return false;
- }
+ if (dwRandomDataSize == sizeof(btRandomData))
+ if (mraGetContactSettingBlob(NULL, "pCryptPass", btCryptedPass, sizeof(btCryptedPass), &dwCryptedPass))
+ if (dwCryptedPass == sizeof(btCryptedPass))
+ if (mraGetStringA(NULL, "e-mail", szEmail)) {
+ mir_hmac_sha1(bthmacSHA1, (BYTE*)szEmail.c_str(), szEmail.GetLength(), btRandomData, sizeof(btRandomData));
+
+ if (storageType == 2) {
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+ CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
+ RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+
+ dwPassSize = btCryptedPass[0];
+ SHA1GetDigest(&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], dwPassSize, btRandomData);
+ if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
+ return false;
+
+ res = CMStringA((char*)&btCryptedPass[(1 + MIR_SHA1_HASH_SIZE)], (int)dwPassSize);
+ }
+ else if (storageType == 1) {
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+ CopyMemoryReverseDWORD(btCryptedPass, btCryptedPass, sizeof(btCryptedPass));
+ RC4(btCryptedPass, sizeof(btCryptedPass), btRandomData, dwRandomDataSize);
+ RC4(btCryptedPass, sizeof(btCryptedPass), bthmacSHA1, MIR_SHA1_HASH_SIZE);
+
+ dwPassSize = (*btCryptedPass);
+ btCryptedPass[dwPassSize + 1 + MIR_SHA1_HASH_SIZE] = 0;
+
+ size_t dwDecodedSize;
+ mir_ptr<BYTE> pDecoded((PBYTE)mir_base64_decode((LPCSTR)&btCryptedPass[1 + MIR_SHA1_HASH_SIZE], &dwDecodedSize));
+ SHA1GetDigest(pDecoded, dwDecodedSize, btRandomData);
+ if (0 != memcmp(&btCryptedPass[1], btRandomData, MIR_SHA1_HASH_SIZE))
+ return false;
+ res = CMStringA((LPSTR)(PBYTE)pDecoded, dwDecodedSize);
+ }
+ else return false;
+ }
delSetting("pCryptData");
delSetting("pCryptPass");
@@ -1376,12 +1375,12 @@ static DWORD ReplaceInBuff(LPVOID lpInBuff, size_t dwInBuffSize, size_t dwReplac while (dwFoundCount) {
for (i = 0; i < dwReplaceItemsCount; i++)
- if (plpbtFounded[i] && (plpbtFounded[i] < plpbtFounded[dwFirstFoundIndex] || plpbtFounded[dwFirstFoundIndex] == NULL))
- dwFirstFoundIndex = i;
+ if (plpbtFounded[i] && (plpbtFounded[i] < plpbtFounded[dwFirstFoundIndex] || plpbtFounded[dwFirstFoundIndex] == NULL))
+ dwFirstFoundIndex = i;
if (plpbtFounded[dwFirstFoundIndex]) {// in found
dwMemPartToCopy = (plpbtFounded[dwFirstFoundIndex] - lpbtInBuffCurPrev);
- if (lpbtOutBuffMax>(lpbtOutBuffCur + (dwMemPartToCopy + pdwInReplaceItemsCounts[dwFirstFoundIndex]))) {
+ if (lpbtOutBuffMax > (lpbtOutBuffCur + (dwMemPartToCopy + pdwInReplaceItemsCounts[dwFirstFoundIndex]))) {
memmove(lpbtOutBuffCur, lpbtInBuffCurPrev, dwMemPartToCopy); lpbtOutBuffCur += dwMemPartToCopy;
memmove(lpbtOutBuffCur, plpOutReplaceItems[dwFirstFoundIndex], pdwOutReplaceItemsCounts[dwFirstFoundIndex]); lpbtOutBuffCur += pdwOutReplaceItemsCounts[dwFirstFoundIndex];
lpbtInBuffCurPrev = (plpbtFounded[dwFirstFoundIndex] + pdwInReplaceItemsCounts[dwFirstFoundIndex]);
@@ -1426,7 +1425,7 @@ static const size_t dwXMLSymbolsCount[] = { sizeof(wchar_t), sizeof(wchar_t), si CMStringW DecodeXML(const CMStringW &lptszMessage)
{
CMStringW ret('\0', (lptszMessage.GetLength() * 4));
- ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength()*sizeof(wchar_t), _countof(lpszXMLTags), (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, ret);
+ ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength() * sizeof(wchar_t), _countof(lpszXMLTags), (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, ret);
return ret;
}
@@ -1434,6 +1433,6 @@ CMStringW DecodeXML(const CMStringW &lptszMessage) CMStringW EncodeXML(const CMStringW &lptszMessage)
{
CMStringW ret('\0', (lptszMessage.GetLength() * 4));
- ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength()*sizeof(wchar_t), _countof(lpszXMLTags), (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, ret);
+ ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength() * sizeof(wchar_t), _countof(lpszXMLTags), (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, ret);
return ret;
}
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 430bc38a1b..d06d267532 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -642,10 +642,9 @@ int CMraProto::OnGroupChanged(WPARAM hContact, LPARAM lParam) return 0;
MraGroupItem *pGrp = nullptr;
- for (int i = 0; i < m_groups.getCount(); i++) {
- MraGroupItem &p = m_groups[i];
- if (!mir_wstrcmp(p.m_name, cgc->pszOldName)) {
- pGrp = &p;
+ for (auto &it : m_groups) {
+ if (!mir_wstrcmp(it->m_name, cgc->pszOldName)) {
+ pGrp = it;
break;
}
}
diff --git a/protocols/Steam/src/steam_accounts.cpp b/protocols/Steam/src/steam_accounts.cpp index 43ec787c5f..8fedcc6181 100644 --- a/protocols/Steam/src/steam_accounts.cpp +++ b/protocols/Steam/src/steam_accounts.cpp @@ -27,9 +27,9 @@ CSteamProto* CSteamProto::GetContactAccount(MCONTACT hContact) if (proto == nullptr) return nullptr; - for (int i = 0; i < Accounts.getCount(); i++) - if (!mir_strcmp(proto, Accounts[i]->m_szModuleName)) - return Accounts[i]; + for (auto &it : Accounts) + if (!mir_strcmp(proto, it->m_szModuleName)) + return it; return nullptr; }
\ No newline at end of file diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index 866a0dbd3b..ad948974a8 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -23,9 +23,10 @@ int CToxProto::UninitAccount(CToxProto *proto) CToxProto* CToxProto::GetContactAccount(MCONTACT hContact)
{
- for (int i = 0; i < Accounts.getCount(); i++)
- if (mir_strcmpi(GetContactProto(hContact), Accounts[i]->m_szModuleName) == 0)
- return Accounts[i];
+ for (auto &it : Accounts)
+ if (mir_strcmpi(GetContactProto(hContact), it->m_szModuleName) == 0)
+ return it;
+
return nullptr;
}
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 130e08eaec..d7c2d1408b 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -150,9 +150,9 @@ INT_PTR CToxProto::ParseToxUri(WPARAM, LPARAM lParam) return 1;
CToxProto *proto = nullptr;
- for (int i = 0; i < Accounts.getCount(); i++) {
- if (Accounts[i]->IsOnline()) {
- proto = Accounts[i];
+ for (auto &it : Accounts) {
+ if (it->IsOnline()) {
+ proto = it;
break;
}
}
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp index c7e7c69f55..ca6338edc7 100644 --- a/protocols/Twitter/src/theme.cpp +++ b/protocols/Twitter/src/theme.cpp @@ -63,9 +63,9 @@ static TwitterProto* GetInstanceByHContact(MCONTACT hContact) if (!proto)
return nullptr;
- for (int i = 0; i < g_Instances.getCount(); i++)
- if (!mir_strcmp(proto, g_Instances[i].m_szModuleName))
- return &g_Instances[i];
+ for (auto &it : g_Instances)
+ if (!mir_strcmp(proto, it->m_szModuleName))
+ return it;
return nullptr;
}
|