summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb (patch)
tree247eed13a5231c3983e343f0b7fc2a95012353c2 /plugins
parent9d0174ebe2bd005418855b18f737c36d5c20ab4a (diff)
all another C++'11 iterators
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CSList/src/cslist.cpp7
-rw-r--r--plugins/DbEditorPP/src/modsettingenum.cpp14
-rw-r--r--plugins/Db_autobackups/src/zip.cpp17
-rw-r--r--plugins/Dbx_mdbx/src/dbcontacts.cpp6
-rw-r--r--plugins/Dbx_mdbx/src/dbsettings.cpp4
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp4
-rw-r--r--plugins/FavContacts/src/favlist.h4
-rw-r--r--plugins/FavContacts/src/menu.cpp10
-rw-r--r--plugins/FloatingContacts/src/main.cpp44
-rw-r--r--plugins/FloatingContacts/src/thumbs.cpp23
-rw-r--r--plugins/Folders/src/dlg_handlers.cpp20
-rw-r--r--plugins/GmailNotifier/src/check.cpp9
-rw-r--r--plugins/GmailNotifier/src/main.cpp8
-rw-r--r--plugins/GmailNotifier/src/options.cpp8
-rw-r--r--plugins/GmailNotifier/src/utility.cpp15
-rw-r--r--plugins/HistorySweeperLight/src/options.cpp4
-rw-r--r--plugins/Import/src/import.cpp54
-rw-r--r--plugins/MirLua/src/mlua_metatable.h10
-rw-r--r--plugins/MirLua/src/mlua_options.cpp9
-rw-r--r--plugins/NewXstatusNotify/src/options.cpp11
-rw-r--r--plugins/Nudge/src/main.cpp94
-rw-r--r--plugins/Nudge/src/options.cpp21
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp74
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp60
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp298
-rw-r--r--plugins/QuickReplies/src/events.cpp4
-rw-r--r--plugins/Scriver/src/chat_manager.cpp3
-rw-r--r--plugins/Scriver/src/msgs.cpp9
-rw-r--r--plugins/SecureIM/src/crypt_icons.cpp10
-rw-r--r--plugins/SecureIM/src/crypt_lists.cpp21
-rw-r--r--plugins/SeenPlugin/src/utils.cpp4
-rw-r--r--plugins/SimpleStatusMsg/src/utils.cpp6
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp12
-rw-r--r--plugins/SpellChecker/src/options.cpp10
-rw-r--r--plugins/SpellChecker/src/spellchecker.cpp6
-rw-r--r--plugins/SpellChecker/src/utils.cpp7
-rw-r--r--plugins/TopToolBar/src/toolbar.cpp19
-rw-r--r--plugins/TopToolBar/src/ttbopt.cpp12
-rw-r--r--plugins/Variables/src/contact.cpp27
-rw-r--r--plugins/Variables/src/parse_alias.cpp12
-rw-r--r--plugins/Variables/src/tokenregister.cpp3
-rw-r--r--plugins/XSoundNotify/src/options.cpp22
-rw-r--r--plugins/YAPP/src/options.cpp3
-rw-r--r--plugins/YAPP/src/services.cpp10
44 files changed, 465 insertions, 563 deletions
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp
index d90e0181d4..2bc27345bb 100644
--- a/plugins/CSList/src/cslist.cpp
+++ b/plugins/CSList/src/cslist.cpp
@@ -106,8 +106,8 @@ static int OnCreateMenuItems(WPARAM, LPARAM)
static int OnPreshutdown(WPARAM, LPARAM)
{
- for (int i = 0; i < arWindows.getCount(); i++)
- DestroyWindow(arWindows[i]->m_handle);
+ for (auto &it : arWindows)
+ DestroyWindow(it->m_handle);
return 0;
}
@@ -208,8 +208,7 @@ void SetStatus(WORD code, StatusItem* item, char *szAccName)
INT_PTR showList(WPARAM, LPARAM, LPARAM param)
{
char* szProto = (char*)param;
- for (int i = 0; i < arWindows.getCount(); i++) {
- CSWindow *p = arWindows[i];
+ for (auto &p : arWindows) {
if (!mir_strcmp(szProto, p->m_protoName)) {
ShowWindow(p->m_handle, SW_SHOW);
SetForegroundWindow(p->m_handle);
diff --git a/plugins/DbEditorPP/src/modsettingenum.cpp b/plugins/DbEditorPP/src/modsettingenum.cpp
index e0a4d40ba1..79e734baf3 100644
--- a/plugins/DbEditorPP/src/modsettingenum.cpp
+++ b/plugins/DbEditorPP/src/modsettingenum.cpp
@@ -103,9 +103,8 @@ int LoadResidentSettings()
void FreeResidentSettings()
{
- for (int i = 0; i < m_lResidentSettings.getCount(); i++)
- mir_free(m_lResidentSettings[i]);
-
+ for (auto &it : m_lResidentSettings)
+ mir_free(it);
m_lResidentSettings.destroy();
}
@@ -132,13 +131,14 @@ int EnumResidentSettings(const char *module, ModuleSettingLL *msll)
int len = (int)mir_strlen(module);
int cnt = 0;
- for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
- if (strncmp(module, m_lResidentSettings[i], len))
+ for (auto &it : m_lResidentSettings) {
+ if (strncmp(module, it, len))
continue;
- if (m_lResidentSettings[i][len] != '/' || m_lResidentSettings[i][len + 1] == 0) continue;
+ if (it[len] != '/' || it[len + 1] == 0)
+ continue;
- enumModulesSettingsProc(&m_lResidentSettings[i][len + 1], msll);
+ enumModulesSettingsProc(&it[len + 1], msll);
cnt++;
}
return cnt;
diff --git a/plugins/Db_autobackups/src/zip.cpp b/plugins/Db_autobackups/src/zip.cpp
index c4a2b145f1..c0c7e08c43 100644
--- a/plugins/Db_autobackups/src/zip.cpp
+++ b/plugins/Db_autobackups/src/zip.cpp
@@ -9,17 +9,14 @@ int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std:
zip_fileinfo fi = { 0 };
int ret = 0;
- for (int i = 0; i < lstFiles.getCount(); i++)
- {
+ for (int i = 0; i < lstFiles.getCount(); i++) {
ZipFile &zf = lstFiles[i];
HANDLE hSrcFile = CreateFileA(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hSrcFile != INVALID_HANDLE_VALUE)
- {
+ if (hSrcFile != INVALID_HANDLE_VALUE) {
int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, nullptr, 0, nullptr, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
- if (iOpenRes == ZIP_OK)
- {
+ if (iOpenRes == ZIP_OK) {
DWORD dwRead;
BYTE buf[0x40000];
@@ -27,17 +24,15 @@ int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std:
zipCloseFileInZip(hZip);
CloseHandle(hSrcFile);
- if (!fnCallback(i))
- {
+ if (!fnCallback(i)) {
ret = 3;
break;
}
}
- else
- CloseHandle(hSrcFile);
+ else CloseHandle(hSrcFile);
}
}
zipClose(hZip, CMStringA(FORMAT, Translate("Miranda NG [%s] database backup"), g_szMirVer));
return ret;
-} \ No newline at end of file
+}
diff --git a/plugins/Dbx_mdbx/src/dbcontacts.cpp b/plugins/Dbx_mdbx/src/dbcontacts.cpp
index 72a88492d1..8c2efb9df1 100644
--- a/plugins/Dbx_mdbx/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdbx/src/dbcontacts.cpp
@@ -130,8 +130,7 @@ BOOL CDbxMDBX::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
LIST<EventItem> list(1000);
GatherContactHistory(ccSub->contactID, list);
- for (int i = 0; i < list.getCount(); i++) {
- EventItem *EI = list[i];
+ for (auto &EI : list) {
{
txn_ptr trnlck(m_env);
@@ -163,8 +162,7 @@ BOOL CDbxMDBX::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
LIST<EventItem> list(1000);
GatherContactHistory(ccSub->contactID, list);
- for (int i = 0; i < list.getCount(); i++) {
- EventItem *EI = list[i];
+ for (auto &EI : list) {
{
txn_ptr trnlck(m_env);
DBEventSortingKey insVal = { ccMeta->contactID, EI->eventId, EI->ts };
diff --git a/plugins/Dbx_mdbx/src/dbsettings.cpp b/plugins/Dbx_mdbx/src/dbsettings.cpp
index 775e69b733..b4491189bf 100644
--- a/plugins/Dbx_mdbx/src/dbsettings.cpp
+++ b/plugins/Dbx_mdbx/src/dbsettings.cpp
@@ -399,8 +399,8 @@ STDMETHODIMP_(BOOL) CDbxMDBX::EnumContactSettings(MCONTACT hContact, DBSETTINGEN
}
int result = -1;
- for (int i=0; i < arKeys.getCount(); i++)
- result = pfnEnumProc(arKeys[i], param);
+ for (auto &it : arKeys)
+ result = pfnEnumProc(it, param);
return result;
}
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp
index d6039f3782..d60cd00d84 100644
--- a/plugins/FavContacts/src/contact_cache.cpp
+++ b/plugins/FavContacts/src/contact_cache.cpp
@@ -19,8 +19,8 @@ CContactCache::CContactCache() :
CContactCache::~CContactCache()
{
- for (int i = 0; i < m_cache.getCount(); i++)
- delete m_cache[i];
+ for (auto &it : m_cache)
+ delete it;
}
int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h
index b6ebc70f2e..c9ed5bc2c3 100644
--- a/plugins/FavContacts/src/favlist.h
+++ b/plugins/FavContacts/src/favlist.h
@@ -99,8 +99,8 @@ public:
~TFavContacts()
{
- for (int i = 0; i < this->getCount(); ++i)
- delete (*this)[i];
+ for (auto &it : *this)
+ delete it;
}
__forceinline int groupCount() const { return nGroups; }
diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp
index f0c8e1072e..4770696e65 100644
--- a/plugins/FavContacts/src/menu.cpp
+++ b/plugins/FavContacts/src/menu.cpp
@@ -458,21 +458,21 @@ int ShowMenu(bool centered)
g_maxItemWidth /= favList.groupCount();
prevGroup = nullptr;
- for (int i = 0; i < favList.getCount(); ++i) {
- hContact = favList[i]->getHandle();
+ for (auto &it : favList) {
+ hContact = it->getHandle();
MEASUREITEMSTRUCT mis = { 0 };
mis.CtlID = 0;
mis.CtlType = ODT_MENU;
- if (!prevGroup || mir_wstrcmp(prevGroup, favList[i]->getGroup())) {
+ if (!prevGroup || mir_wstrcmp(prevGroup, it->getGroup())) {
if (prevGroup && g_Options.bUseColumns) {
szMenu.cx += szColumn.cx;
szMenu.cy = max(szMenu.cy, szColumn.cy);
szColumn.cx = szColumn.cy = 0;
}
- int groupID = -((INT_PTR)Clist_GroupExists(favList[i]->getGroup()) + 1);
+ int groupID = -((INT_PTR)Clist_GroupExists(it->getGroup()) + 1);
AppendMenu(hMenu,
MF_OWNERDRAW | MF_SEPARATOR | ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0),
@@ -493,7 +493,7 @@ int ShowMenu(bool centered)
szColumn.cx = max(szColumn.cx, (int)mis.itemWidth);
szColumn.cy += mis.itemHeight;
- prevGroup = favList[i]->getGroup();
+ prevGroup = it->getGroup();
}
szMenu.cx += szColumn.cx;
szMenu.cy = max(szMenu.cy, szColumn.cy);
diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp
index fb098b2752..80b435b9cd 100644
--- a/plugins/FloatingContacts/src/main.cpp
+++ b/plugins/FloatingContacts/src/main.cpp
@@ -213,8 +213,8 @@ static int OnSkinIconsChanged(WPARAM, LPARAM)
himlMiranda = Clist_GetImageList();
// Update thumbs
- for (int i = 0; i < thumbList.getCount(); ++i)
- thumbList[i].UpdateContent();
+ for (auto &it : thumbList)
+ it->UpdateContent();
return 0;
}
@@ -261,9 +261,9 @@ static int OnContactSettingChanged(WPARAM hContact, LPARAM lParam)
static int OnStatusModeChange(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < thumbList.getCount(); ++i) {
- int idStatus = GetContactStatus(thumbList[i].hContact);
- thumbList[i].RefreshContactStatus(idStatus);
+ for (auto &it : thumbList) {
+ int idStatus = GetContactStatus(it->hContact);
+ it->RefreshContactStatus(idStatus);
}
if (wParam == ID_STATUS_OFFLINE) {
@@ -434,8 +434,8 @@ static LRESULT __stdcall CommWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
extern void SetThumbsOpacity(BYTE btAlpha)
{
- for (int i = 0; i < thumbList.getCount(); ++i)
- thumbList[i].SetThumbOpacity(btAlpha);
+ for (auto &it : thumbList)
+ it->SetThumbOpacity(btAlpha);
}
static void GetScreenRect()
@@ -450,9 +450,9 @@ void OnStatusChanged()
{
int idStatus = ID_STATUS_OFFLINE;
- for (int i = 0; i < thumbList.getCount(); ++i) {
- idStatus = GetContactStatus(thumbList[i].hContact);
- thumbList[i].RefreshContactStatus(idStatus);
+ for (auto &it : thumbList) {
+ idStatus = GetContactStatus(it->hContact);
+ it->RefreshContactStatus(idStatus);
}
}
@@ -475,8 +475,8 @@ void ApplyOptionsChanges()
OnStatusChanged();
- for (int i = 0; i < thumbList.getCount(); ++i)
- thumbList[i].ResizeThumb();
+ for (auto &it : thumbList)
+ it->ResizeThumb();
}
///////////////////////////////////////////////////////
@@ -656,14 +656,14 @@ void RegHotkey(MCONTACT hContact, HWND hwnd)
void SaveContactsPos()
{
- for (int i = 0; i < thumbList.getCount(); ++i) {
+ for (auto &it : thumbList) {
SetLastError(0);
RECT rc;
- thumbList[i].GetThumbRect(&rc);
+ it->GetThumbRect(&rc);
if (0 == GetLastError())
- db_set_dw(thumbList[i].hContact, MODULE, "ThumbsPos", DB_POS_MAKE_XY(rc.left, rc.top));
+ db_set_dw(it->hContact, MODULE, "ThumbsPos", DB_POS_MAKE_XY(rc.left, rc.top));
}
}
@@ -803,8 +803,8 @@ BOOL HideOnFullScreen()
static VOID CALLBACK ToTopTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- for (int i = 0; i < thumbList.getCount(); ++i)
- SetWindowPos(thumbList[i].hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
+ for (auto &it : thumbList)
+ SetWindowPos(it->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
}
void ShowThumbsOnHideCList()
@@ -812,9 +812,9 @@ void ShowThumbsOnHideCList()
if (!fcOpt.bHideWhenCListShow || fcOpt.bHideAll || HideOnFullScreen())
return;
- for (int i = 0; i < thumbList.getCount(); ++i)
- if (!fcOpt.bHideOffline || IsStatusVisible(GetContactStatus(thumbList[i].hContact)))
- ShowWindow(thumbList[i].hwnd, SW_SHOWNA);
+ for (auto &it : thumbList)
+ if (!fcOpt.bHideOffline || IsStatusVisible(GetContactStatus(it->hContact)))
+ ShowWindow(it->hwnd, SW_SHOWNA);
}
@@ -823,8 +823,8 @@ void HideThumbsOnShowCList()
if (!fcOpt.bHideWhenCListShow || fcOpt.bHideAll || HideOnFullScreen())
return;
- for (int i = 0; i < thumbList.getCount(); ++i)
- ShowWindow(thumbList[i].hwnd, SW_HIDE);
+ for (auto &it : thumbList)
+ ShowWindow(it->hwnd, SW_HIDE);
}
static LRESULT __stdcall newMirandaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/FloatingContacts/src/thumbs.cpp b/plugins/FloatingContacts/src/thumbs.cpp
index 27f953a689..46a593c656 100644
--- a/plugins/FloatingContacts/src/thumbs.cpp
+++ b/plugins/FloatingContacts/src/thumbs.cpp
@@ -107,15 +107,14 @@ void ThumbInfo::PositionThumbWorker(int nX, int nY, POINT *newPos)
if (fcOpt.bMoveTogether)
UndockThumbs(this, thumbList.FindThumb(dockOpt.hwndLeft));
- for (int i = 0; i < thumbList.getCount(); ++i) {
- ThumbInfo *pCurThumb = &thumbList[i];
- if (pCurThumb == this)
+ for (auto &it : thumbList) {
+ if (it == this)
continue;
GetThumbRect(&rcThumb);
OffsetRect(&rcThumb, nX - rcThumb.left, nY - rcThumb.top);
- pCurThumb->GetThumbRect(&rc);
+ it->GetThumbRect(&rc);
// These are rects we will dock into
@@ -190,10 +189,10 @@ void ThumbInfo::PositionThumbWorker(int nX, int nY, POINT *newPos)
if (fcOpt.bMoveTogether) {
if (bDockedRight)
- DockThumbs(this, pCurThumb);
+ DockThumbs(this, it);
if (bDockedLeft)
- DockThumbs(pCurThumb, this);
+ DockThumbs(it, this);
}
// Lower-left
@@ -776,9 +775,9 @@ ThumbInfo* ThumbList::FindThumb(HWND hwnd)
{
if (!hwnd) return nullptr;
- for (int i = 0; i < getCount(); ++i)
- if (items[i]->hwnd == hwnd)
- return items[i];
+ for (auto &it : *this)
+ if (it->hwnd == hwnd)
+ return it;
return nullptr;
}
@@ -787,9 +786,9 @@ ThumbInfo *ThumbList::FindThumbByContact(MCONTACT hContact)
{
if (!hContact) return nullptr;
- for (int i = 0; i < getCount(); ++i)
- if (items[i]->hContact == hContact)
- return items[i];
+ for (auto &it : *this)
+ if (it->hContact == hContact)
+ return it;
return nullptr;
}
diff --git a/plugins/Folders/src/dlg_handlers.cpp b/plugins/Folders/src/dlg_handlers.cpp
index 806b0972c7..1135235741 100644
--- a/plugins/Folders/src/dlg_handlers.cpp
+++ b/plugins/Folders/src/dlg_handlers.cpp
@@ -35,12 +35,11 @@ static void LoadRegisteredFolderSections(HWND hWnd)
{
HWND hwndList = GetDlgItem(hWnd, IDC_FOLDERS_SECTIONS_LIST);
- for (int i = 0; i < lstRegisteredFolders.getCount(); i++) {
- CFolderItem &tmp = lstRegisteredFolders[i];
- wchar_t *translated = mir_a2u(tmp.GetSection());
+ for (auto &it : lstRegisteredFolders) {
+ wchar_t *translated = mir_a2u(it->GetSection());
if (!ContainsSection(hWnd, TranslateW(translated))) {
int idx = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)TranslateW(translated));
- SendMessage(hwndList, LB_SETITEMDATA, idx, (LPARAM)tmp.GetSection());
+ SendMessage(hwndList, LB_SETITEMDATA, idx, (LPARAM)it->GetSection());
}
mir_free(translated);
@@ -58,11 +57,10 @@ static void LoadRegisteredFolderItems(HWND hWnd)
HWND hwndItems = GetDlgItem(hWnd, IDC_FOLDERS_ITEMS_LIST);
SendMessage(hwndItems, LB_RESETCONTENT, 0, 0);
- for (int i = 0; i < lstRegisteredFolders.getCount(); i++) {
- CFolderItem &item = lstRegisteredFolders[i];
- if (!mir_strcmp(szSection, item.GetSection())) {
- idx = SendMessage(hwndItems, LB_ADDSTRING, 0, (LPARAM)TranslateW(item.GetUserName()));
- SendMessage(hwndItems, LB_SETITEMDATA, idx, (LPARAM)&item);
+ for (auto &it : lstRegisteredFolders) {
+ if (!mir_strcmp(szSection, it->GetSection())) {
+ idx = SendMessage(hwndItems, LB_ADDSTRING, 0, (LPARAM)TranslateW(it->GetUserName()));
+ SendMessage(hwndItems, LB_SETITEMDATA, idx, (LPARAM)it);
}
}
SendMessage(hwndItems, LB_SETCURSEL, 0, 0); //select the first item
@@ -234,8 +232,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
LoadItem(hWnd, item);
}
- for (int i = 0; i < lstRegisteredFolders.getCount(); i++)
- lstRegisteredFolders[i].Save();
+ for (auto &it : lstRegisteredFolders)
+ it->Save();
CallPathChangedEvents();
}
}
diff --git a/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp
index 0d642a8a42..88cafca600 100644
--- a/plugins/GmailNotifier/src/check.cpp
+++ b/plugins/GmailNotifier/src/check.cpp
@@ -141,11 +141,10 @@ void __cdecl Check_ThreadFunc(void *lpParam)
NotifyUser((Account *)lpParam);
}
else {
- for (int i = 0; i < g_accs.getCount(); i++) {
- Account &acc = g_accs[i];
- if (GetContactProto(acc.hContact)) {
- CheckMailInbox(&acc);
- NotifyUser(&acc);
+ for (auto &it : g_accs) {
+ if (GetContactProto(it->hContact)) {
+ CheckMailInbox(it);
+ NotifyUser(it);
}
}
}
diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp
index 3fc69d130d..3a715ca048 100644
--- a/plugins/GmailNotifier/src/main.cpp
+++ b/plugins/GmailNotifier/src/main.cpp
@@ -133,8 +133,8 @@ extern "C" int __declspec(dllexport) Load()
BuildList();
ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
- for (int i = 0; i < g_accs.getCount(); i++)
- db_set_dw(g_accs[i].hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ for (auto &it : g_accs)
+ db_set_dw(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc);
hMirandaStarted = HookEvent(ME_SYSTEM_MODULESLOADED, OnMirandaStart);
@@ -162,8 +162,8 @@ extern "C" int __declspec(dllexport) Unload(void)
if (hTimer)
KillTimer(nullptr, hTimer);
- for (int i = 0; i < g_accs.getCount(); i++)
- DeleteResults(g_accs[i].results.next);
+ for (auto &it : g_accs)
+ DeleteResults(it->results.next);
g_accs.destroy();
Netlib_CloseHandle(hNetlibUser);
diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp
index a3f781c8b1..cc2bd0ffa9 100644
--- a/plugins/GmailNotifier/src/options.cpp
+++ b/plugins/GmailNotifier/src/options.cpp
@@ -46,8 +46,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
optionWindowIsOpen = TRUE;
BuildList();
- for (int i = 0; i < g_accs.getCount(); i++)
- SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG_PTR)g_accs[i].name);
+ for (auto &it : g_accs)
+ SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG_PTR)it->name);
SendMessage(hwndCombo, CB_SETCURSEL, curIndex, 0);
if (curIndex < g_accs.getCount())
SetDlgItemTextA(hwndDlg, IDC_PASS, g_accs[curIndex].pass);
@@ -256,8 +256,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
db_set_dw(NULL, MODULE_NAME, "LogThreads", opt.LogThreads);
ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
- for (int i = 0; i < g_accs.getCount(); i++)
- db_set_w(g_accs[i].hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ for (auto &it : g_accs)
+ db_set_w(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
}
return TRUE;
diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp
index cadc6820db..840ff28a3c 100644
--- a/plugins/GmailNotifier/src/utility.cpp
+++ b/plugins/GmailNotifier/src/utility.cpp
@@ -19,12 +19,11 @@ void BuildList(void)
}
}
- for (int i = 0; i < g_accs.getCount(); i++) {
- Account &acc = g_accs[i];
- char *tail = strchr(acc.name, '@');
+ for (auto &acc : g_accs) {
+ char *tail = strchr(acc->name, '@');
if (tail && mir_strcmp(tail + 1, "gmail.com") != 0)
- mir_strcpy(acc.hosted, tail + 1);
- acc.IsChecking = false;
+ mir_strcpy(acc->hosted, tail + 1);
+ acc->IsChecking = false;
}
}
@@ -70,9 +69,9 @@ BOOL GetBrowser(char *str)
Account* GetAccountByContact(MCONTACT hContact)
{
- for (int i = 0; i < g_accs.getCount(); i++)
- if (g_accs[i].hContact == hContact)
- return &g_accs[i];
+ for (auto &it : g_accs)
+ if (it->hContact == hContact)
+ return it;
return nullptr;
}
diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp
index 7d8071eb63..60da041125 100644
--- a/plugins/HistorySweeperLight/src/options.cpp
+++ b/plugins/HistorySweeperLight/src/options.cpp
@@ -160,8 +160,8 @@ void SaveSettings(HWND hwndDlg)
db_unset(hContact, ModuleName, "SweepHistory");
}
- for (int i = 0; i < g_hWindows.getCount(); i++)
- SetSrmmIcon(UINT_PTR(g_hWindows[i]));
+ for (auto &it : g_hWindows)
+ SetSrmmIcon(UINT_PTR(it));
// set tooltips
int st = db_get_b(NULL, ModuleName, "SweepHistory", 0);
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 249c998afe..590bce6a5a 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -352,12 +352,11 @@ static char* newStr(const char *s)
static bool FindDestAccount(const char *szProto)
{
- for (int i = 0; i < arAccountMap.getCount(); i++) {
- AccountMap &pam = arAccountMap[i];
- if (pam.pa == nullptr)
+ for (auto &pam : arAccountMap) {
+ if (pam->pa == nullptr)
continue;
- if (!mir_strcmp(pam.pa->szModuleName, szProto))
+ if (!mir_strcmp(pam->pa->szModuleName, szProto))
return true;
}
@@ -458,49 +457,48 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules)
bool bImportSysAll = (nImportOptions & IOPT_SYS_SETTINGS) != 0;
- for (int i = 0; i < arAccountMap.getCount(); i++) {
- AccountMap &p = arAccountMap[i];
- if (p.pa != nullptr || p.szBaseProto == NULL || !mir_strcmp(p.szSrcAcc, META_PROTO))
+ for (auto &p : arAccountMap) {
+ if (p->pa != nullptr || p->szBaseProto == NULL || !mir_strcmp(p->szSrcAcc, META_PROTO))
continue;
- if (!Proto_IsProtocolLoaded(p.szBaseProto)) {
- AddMessage(LPGENW("Protocol %S is not loaded, skipping account %s creation"), p.szBaseProto, p.tszSrcName);
+ if (!Proto_IsProtocolLoaded(p->szBaseProto)) {
+ AddMessage(LPGENW("Protocol %S is not loaded, skipping account %s creation"), p->szBaseProto, p->tszSrcName);
continue;
}
ACC_CREATE newacc;
- newacc.pszBaseProto = p.szBaseProto;
+ newacc.pszBaseProto = p->szBaseProto;
newacc.pszInternal = nullptr;
- newacc.ptszAccountName = p.tszSrcName;
+ newacc.ptszAccountName = p->tszSrcName;
- p.pa = ProtoCreateAccount(&newacc);
- if (p.pa == nullptr) {
- AddMessage(LPGENW("Unable to create an account %s of protocol %S"), p.tszSrcName, p.szBaseProto);
+ p->pa = ProtoCreateAccount(&newacc);
+ if (p->pa == nullptr) {
+ AddMessage(LPGENW("Unable to create an account %s of protocol %S"), p->tszSrcName, p->szBaseProto);
return false;
}
char szSetting[100];
- itoa(400 + p.iSrcIndex, szSetting, 10);
+ itoa(400 + p->iSrcIndex, szSetting, 10);
int iVal = myGetD(NULL, "Protocols", szSetting, 1);
- itoa(400 + p.pa->iOrder, szSetting, 10);
+ itoa(400 + p->pa->iOrder, szSetting, 10);
db_set_dw(NULL, "Protocols", szSetting, iVal);
- p.pa->bIsVisible = iVal != 0;
+ p->pa->bIsVisible = iVal != 0;
- itoa(600 + p.iSrcIndex, szSetting, 10);
+ itoa(600 + p->iSrcIndex, szSetting, 10);
iVal = myGetD(NULL, "Protocols", szSetting, 1);
- itoa(600 + p.pa->iOrder, szSetting, 10);
+ itoa(600 + p->pa->iOrder, szSetting, 10);
db_set_dw(NULL, "Protocols", szSetting, iVal);
- p.pa->bIsEnabled = iVal != 0;
+ p->pa->bIsEnabled = iVal != 0;
- if (p.tszSrcName == NULL) {
- p.pa->tszAccountName = mir_a2u(p.pa->szModuleName);
- itoa(800 + p.pa->iOrder, szSetting, 10);
- db_set_ws(NULL, "Protocols", szSetting, p.pa->tszAccountName);
+ if (p->tszSrcName == NULL) {
+ p->pa->tszAccountName = mir_a2u(p->pa->szModuleName);
+ itoa(800 + p->pa->iOrder, szSetting, 10);
+ db_set_ws(NULL, "Protocols", szSetting, p->pa->tszAccountName);
}
- CopySettings(NULL, p.szSrcAcc, NULL, p.pa->szModuleName);
+ CopySettings(NULL, p->szSrcAcc, NULL, p->pa->szModuleName);
if (bImportSysAll)
- arSkippedModules.insert(newStr(p.szSrcAcc));
+ arSkippedModules.insert(newStr(p->szSrcAcc));
}
CopySettings(NULL, META_PROTO, NULL, META_PROTO);
@@ -1053,8 +1051,8 @@ void MirandaImport(HWND hdlg)
hContact = srcDb->FindNextContact(hContact);
}
- for (i = 0; i < arMetas.getCount(); i++)
- ImportMeta(arMetas[i]);
+ for (auto &it : arMetas)
+ ImportMeta(it);
}
else AddMessage(LPGENW("Skipping new contacts import."));
AddMessage(L"");
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h
index 6b4f916668..7fb8c27578 100644
--- a/plugins/MirLua/src/mlua_metatable.h
+++ b/plugins/MirLua/src/mlua_metatable.h
@@ -217,14 +217,12 @@ private:
CMStringA data(MT::name);
data += "(";
- for (int i = 0; i < fields.getCount(); i++) {
- CMTField &field = fields[i];
-
- data += field.GetName();
+ for (auto &it : fields) {
+ data += it->GetName();
data += "=";
- MTValue value = field.GetValue(obj);
- int type = field.GetType();
+ MTValue value = it->GetValue(obj);
+ int type = it->GetType();
switch (type) {
case LUA_TNIL:
data.Append("nil");
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
index 6a2dbd669b..9a4438d408 100644
--- a/plugins/MirLua/src/mlua_options.cpp
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -34,12 +34,11 @@ CMLuaOptions::CMLuaOptions(int idDialog)
void CMLuaOptions::LoadScripts()
{
- for (int i = 0; i < g_mLua->Scripts.getCount(); i++)
+ for (auto &it : g_mLua->Scripts)
{
- CMLuaScript *script = g_mLua->Scripts[i];
- wchar_t *fileName = NEWWSTR_ALLOCA(script->GetFileName());
- int iIcon = script->GetStatus() - 1;
- int iItem = m_scripts.AddItem(fileName, iIcon, (LPARAM)script);
+ wchar_t *fileName = NEWWSTR_ALLOCA(it->GetFileName());
+ int iIcon = it->GetStatus() - 1;
+ int iItem = m_scripts.AddItem(fileName, iIcon, (LPARAM)it);
if (db_get_b(NULL, MODULE, _T2A(fileName), 1))
m_scripts.SetCheckState(iItem, TRUE);
m_scripts.SetItem(iItem, 1, TranslateT("Open"), 2);
diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp
index 82705d78b0..2b3231a74b 100644
--- a/plugins/NewXstatusNotify/src/options.cpp
+++ b/plugins/NewXstatusNotify/src/options.cpp
@@ -132,13 +132,12 @@ void SaveTemplates()
db_set_b(0, MODULE, "TLogXFlags", templates.LogXFlags);
db_set_b(0, MODULE, "TLogSMsgFlags", templates.LogSMsgFlags);
- for (int i = 0; i < ProtoTemplates.getCount(); i++) {
- PROTOTEMPLATE *prototemplate = ProtoTemplates[i];
+ for (auto &it : ProtoTemplates) {
char str[MAX_PATH];
- mir_snprintf(str, "%s_TPopupSMsgChanged", prototemplate->ProtoName);
- db_set_ws(0, MODULE, str, prototemplate->ProtoTemplateMsg);
- mir_snprintf(str, "%s_TPopupSMsgRemoved", prototemplate->ProtoName);
- db_set_ws(0, MODULE, str, prototemplate->ProtoTemplateRemoved);
+ mir_snprintf(str, "%s_TPopupSMsgChanged", it->ProtoName);
+ db_set_ws(0, MODULE, str, it->ProtoTemplateMsg);
+ mir_snprintf(str, "%s_TPopupSMsgRemoved", it->ProtoName);
+ db_set_ws(0, MODULE, str, it->ProtoTemplateRemoved);
}
}
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index 0524554f05..fc2b9b6fd1 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -32,13 +32,11 @@ PLUGININFOEX pluginInfo = {
INT_PTR NudgeShowMenu(WPARAM wParam, LPARAM lParam)
{
bool bEnabled = false;
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (!mir_strcmp((char*)wParam, p.ProtocolName)) {
- bEnabled = (GlobalNudge.useByProtocol) ? p.enabled : DefaultNudge.enabled;
+ for (auto &p : arNudges)
+ if (!mir_strcmp((char*)wParam, p->ProtocolName)) {
+ bEnabled = (GlobalNudge.useByProtocol) ? p->enabled : DefaultNudge.enabled;
break;
}
- }
Menu_ShowItem(g_hContactMenu, bEnabled && lParam != 0);
return 0;
@@ -52,11 +50,9 @@ INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
wchar_t msg[500];
mir_snwprintf(msg, TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"), GlobalNudge.sendTimeSec, 30 - diff);
if (GlobalNudge.useByProtocol) {
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (!mir_strcmp(protoName, p.ProtocolName))
- Nudge_ShowPopup(&p, hContact, msg);
- }
+ for (auto &p : arNudges)
+ if (!mir_strcmp(protoName, p->ProtocolName))
+ Nudge_ShowPopup(p, hContact, msg);
}
else Nudge_ShowPopup(&DefaultNudge, hContact, msg);
@@ -66,12 +62,10 @@ INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
db_set_dw(hContact, "Nudge", "LastSent", time(nullptr));
if (GlobalNudge.useByProtocol) {
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (!mir_strcmp(protoName, p.ProtocolName))
- if (p.showStatus)
- Nudge_SentStatus(&p, hContact);
- }
+ for (auto &p : arNudges)
+ if (!mir_strcmp(protoName, p->ProtocolName))
+ if (p->showStatus)
+ Nudge_SentStatus(p, hContact);
}
else if (DefaultNudge.showStatus)
Nudge_SentStatus(&DefaultNudge, hContact);
@@ -103,48 +97,47 @@ int NudgeReceived(WPARAM hContact, LPARAM lParam)
db_set_dw(hContact, "Nudge", "LastReceived2", nudgeSentTimestamp);
if (GlobalNudge.useByProtocol) {
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (!mir_strcmp(protoName, p.ProtocolName)) {
+ for (auto &p : arNudges) {
+ if (!mir_strcmp(protoName, p->ProtocolName)) {
- if (p.enabled) {
- if (p.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_USERONLINE))
+ if (p->enabled) {
+ if (p->useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_USERONLINE))
return 0;
DWORD Status = CallProtoService(protoName, PS_GETSTATUS, 0, 0);
- if (((p.statusFlags & NUDGE_ACC_ST0) && (Status <= ID_STATUS_OFFLINE)) ||
- ((p.statusFlags & NUDGE_ACC_ST1) && (Status == ID_STATUS_ONLINE)) ||
- ((p.statusFlags & NUDGE_ACC_ST2) && (Status == ID_STATUS_AWAY)) ||
- ((p.statusFlags & NUDGE_ACC_ST3) && (Status == ID_STATUS_DND)) ||
- ((p.statusFlags & NUDGE_ACC_ST4) && (Status == ID_STATUS_NA)) ||
- ((p.statusFlags & NUDGE_ACC_ST5) && (Status == ID_STATUS_OCCUPIED)) ||
- ((p.statusFlags & NUDGE_ACC_ST6) && (Status == ID_STATUS_FREECHAT)) ||
- ((p.statusFlags & NUDGE_ACC_ST7) && (Status == ID_STATUS_INVISIBLE)) ||
- ((p.statusFlags & NUDGE_ACC_ST8) && (Status == ID_STATUS_ONTHEPHONE)) ||
- ((p.statusFlags & NUDGE_ACC_ST9) && (Status == ID_STATUS_OUTTOLUNCH)))
+ if (((p->statusFlags & NUDGE_ACC_ST0) && (Status <= ID_STATUS_OFFLINE)) ||
+ ((p->statusFlags & NUDGE_ACC_ST1) && (Status == ID_STATUS_ONLINE)) ||
+ ((p->statusFlags & NUDGE_ACC_ST2) && (Status == ID_STATUS_AWAY)) ||
+ ((p->statusFlags & NUDGE_ACC_ST3) && (Status == ID_STATUS_DND)) ||
+ ((p->statusFlags & NUDGE_ACC_ST4) && (Status == ID_STATUS_NA)) ||
+ ((p->statusFlags & NUDGE_ACC_ST5) && (Status == ID_STATUS_OCCUPIED)) ||
+ ((p->statusFlags & NUDGE_ACC_ST6) && (Status == ID_STATUS_FREECHAT)) ||
+ ((p->statusFlags & NUDGE_ACC_ST7) && (Status == ID_STATUS_INVISIBLE)) ||
+ ((p->statusFlags & NUDGE_ACC_ST8) && (Status == ID_STATUS_ONTHEPHONE)) ||
+ ((p->statusFlags & NUDGE_ACC_ST9) && (Status == ID_STATUS_OUTTOLUNCH)))
{
if (diff >= GlobalNudge.recvTimeSec) {
- if (p.showPopup)
- Nudge_ShowPopup(&p, hContact, p.recText);
- if (p.openContactList)
+ if (p->showPopup)
+ Nudge_ShowPopup(p, hContact, p->recText);
+ if (p->openContactList)
OpenContactList();
- if (p.shakeClist)
+ if (p->shakeClist)
ShakeClist(hContact, lParam);
- if (p.openMessageWindow)
+ if (p->openMessageWindow)
CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
- if (p.shakeChat)
+ if (p->shakeChat)
ShakeChat(hContact, lParam);
- if (p.autoResend)
+ if (p->autoResend)
mir_forkthread(AutoResendNudge, (void*)hContact);
- Skin_PlaySound(p.NudgeSoundname);
+ Skin_PlaySound(p->NudgeSoundname);
}
}
if (diff2 >= GlobalNudge.recvTimeSec)
- if (p.showStatus)
- Nudge_ShowStatus(&p, hContact, nudgeSentTimestamp);
+ if (p->showStatus)
+ Nudge_ShowStatus(p, hContact, nudgeSentTimestamp);
}
break;
}
@@ -407,19 +400,18 @@ int Preview()
{
MCONTACT hContact = db_find_first();
if (GlobalNudge.useByProtocol) {
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (p.enabled) {
- Skin_PlaySound(p.NudgeSoundname);
- if (p.showPopup)
- Nudge_ShowPopup(&p, hContact, p.recText);
- if (p.openContactList)
+ for (auto &p : arNudges) {
+ if (p->enabled) {
+ Skin_PlaySound(p->NudgeSoundname);
+ if (p->showPopup)
+ Nudge_ShowPopup(p, hContact, p->recText);
+ if (p->openContactList)
OpenContactList();
- if (p.shakeClist)
+ if (p->shakeClist)
ShakeClist(0, 0);
- if (p.openMessageWindow)
+ if (p->openMessageWindow)
CallService(MS_MSG_SENDMESSAGEW, hContact, NULL);
- if (p.shakeChat)
+ if (p->shakeChat)
ShakeChat(hContact, (LPARAM)time(nullptr));
}
}
diff --git a/plugins/Nudge/src/options.cpp b/plugins/Nudge/src/options.cpp
index fce6159268..c72e07390c 100644
--- a/plugins/Nudge/src/options.cpp
+++ b/plugins/Nudge/src/options.cpp
@@ -21,11 +21,9 @@ static void UpdateControls(HWND hwnd)
if (GlobalNudge.useByProtocol) {
proto = GetSelProto(hwnd, nullptr);
ActualNudge = nullptr;
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (p.iProtoNumber == proto)
- ActualNudge = &p;
- }
+ for (auto &p : arNudges)
+ if (p->iProtoNumber == proto)
+ ActualNudge = p;
}
else ActualNudge = &DefaultNudge;
@@ -71,11 +69,9 @@ static void CheckChange(HWND hwnd, HTREEITEM hItem)
if (GlobalNudge.useByProtocol) {
proto = GetSelProto(hwnd, hItem);
ActualNudge = nullptr;
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- if (p.iProtoNumber == proto)
- ActualNudge = &p;
- }
+ for (auto &p : arNudges)
+ if (p->iProtoNumber == proto)
+ ActualNudge = p;
}
else ActualNudge = &DefaultNudge;
@@ -208,9 +204,8 @@ static void CreateImageList(HWND hWnd)
// Create and populate image list
HIMAGELIST hImList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, nProtocol, 0);
- for (int i = 0; i < arNudges.getCount(); i++) {
- CNudgeElement &p = arNudges[i];
- INT_PTR res = CallProtoService(p.ProtocolName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
+ for (auto &p : arNudges) {
+ INT_PTR res = CallProtoService(p->ProtocolName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
if (res == CALLSERVICE_NOTFOUND)
res = (INT_PTR)IcoLib_GetIcon("Nudge_Default");
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index 12c4853002..fa521bbcfc 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -27,7 +27,7 @@ static void SelectAll(HWND hDlg, bool bEnable)
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
- for (int i=0; i < todo.getCount(); i++) {
+ for (int i = 0; i < todo.getCount(); i++) {
ListView_SetCheckState(hwndList, i, todo[i].bEnabled = bEnable);
}
}
@@ -64,17 +64,18 @@ static void ApplyDownloads(void *param)
VARSW tszMirandaPath(L"%miranda_path%");
HNETLIBCONN nlc = nullptr;
- for (int i=0; i < todo.getCount(); ++i) {
+ for (int i = 0; i < todo.getCount(); ++i) {
+ auto &p = todo[i];
ListView_EnsureVisible(hwndList, i, FALSE);
- if (todo[i].bEnabled) {
+ if (p.bEnabled) {
// download update
ListView_SetItemText(hwndList, i, 1, TranslateT("Downloading..."));
- if (DownloadFile(&todo[i].File, nlc)) {
+ if (DownloadFile(&p.File, nlc)) {
ListView_SetItemText(hwndList, i, 1, TranslateT("Succeeded."));
- if (unzip(todo[i].File.tszDiskPath, tszMirandaPath, tszFileBack,false))
- SafeDeleteFile(todo[i].File.tszDiskPath); // remove .zip after successful update
- db_unset(NULL, DB_MODULE_NEW_FILES, _T2A(todo[i].tszOldName));
+ if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack, false))
+ SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
+ db_unset(NULL, DB_MODULE_NEW_FILES, _T2A(p.tszOldName));
}
else
ListView_SetItemText(hwndList, i, 1, TranslateT("Failed!"));
@@ -104,7 +105,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP
hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam);
ListView_SubItemHitTest(hwnd, &hi);
if ((hi.iSubItem == 0) && (hi.flags & LVHT_ONITEMICON)) {
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_GROUPID;
lvi.stateMask = -1;
lvi.iItem = hi.iItem;
@@ -152,9 +153,9 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_INITDIALOG:
- TranslateDialogDefault( hDlg );
+ TranslateDialogDefault(hDlg);
oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);
-
+
Window_SetIcon_IcoLib(hDlg, iconList[2].hIcolib);
{
HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
@@ -182,7 +183,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
GetClientRect(hwndList, &r);
///
- LVCOLUMN lvc = {0};
+ LVCOLUMN lvc = { 0 };
lvc.mask = LVCF_WIDTH | LVCF_TEXT;
//lvc.fmt = LVCFMT_LEFT;
@@ -206,7 +207,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
lvg.pszHeader = TranslateT("Icons");
lvg.iGroupId = 2;
ListView_InsertGroup(hwndList, 0, &lvg);
-
+
lvg.pszHeader = TranslateT("Languages");
lvg.iGroupId = 3;
ListView_InsertGroup(hwndList, 0, &lvg);
@@ -224,23 +225,24 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
///
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
- for (int i = 0; i < todo.getCount(); ++i) {
- LVITEM lvi = {0};
+ for (int i = 0; i < todo.getCount(); i++) {
+ auto &p = todo[i];
+
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE;
-
+
int groupId = 4;
- if (wcschr(todo[i].tszOldName, L'\\') != nullptr)
- groupId = (wcsstr(todo[i].tszOldName, L"Plugins") != nullptr) ? 1 : ((wcsstr(todo[i].tszOldName, L"Languages") != nullptr) ? 3 : 2);
+ if (wcschr(p.tszOldName, L'\\') != nullptr)
+ groupId = (wcsstr(p.tszOldName, L"Plugins") != nullptr) ? 1 : ((wcsstr(p.tszOldName, L"Languages") != nullptr) ? 3 : 2);
lvi.iItem = i;
lvi.lParam = (LPARAM)&todo[i];
lvi.iGroupId = groupId;
- lvi.iImage = ((groupId ==1) ? 0 : -1);
- lvi.pszText = todo[i].tszOldName;
+ lvi.iImage = ((groupId == 1) ? 0 : -1);
+ lvi.pszText = p.tszOldName;
ListView_InsertItem(hwndList, &lvi);
- if (todo[i].bEnabled)
- {
+ if (p.bEnabled) {
enableOk = true;
ListView_SetCheckState(hwndList, lvi.iItem, 1);
}
@@ -255,13 +257,13 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case WM_NOTIFY:
- if (((LPNMHDR) lParam)->hwndFrom == hwndList) {
- switch (((LPNMHDR) lParam)->code) {
+ if (((LPNMHDR)lParam)->hwndFrom == hwndList) {
+ switch (((LPNMHDR)lParam)->code) {
case LVN_ITEMCHANGED:
if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- LVITEM lvI = {0};
+ LVITEM lvI = { 0 };
lvI.iItem = nmlv->iItem;
lvI.iSubItem = 0;
lvI.mask = LVIF_PARAM;
@@ -272,8 +274,8 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
bool enableOk = false;
- for (int i=0; i < todo.getCount(); ++i) {
- if (todo[i].bEnabled) {
+ for (int i = 0; i < todo.getCount(); ++i) {
+ if (p->bEnabled) {
enableOk = true;
break;
}
@@ -287,11 +289,11 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_COMMAND:
- if (HIWORD( wParam ) == BN_CLICKED) {
- switch(LOWORD(wParam)) {
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
case IDOK:
- EnableWindow( GetDlgItem(hDlg, IDOK), FALSE);
- EnableWindow( GetDlgItem(hDlg, IDC_SELNONE), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_SELNONE), FALSE);
mir_forkthread(ApplyDownloads, hDlg);
return TRUE;
@@ -312,7 +314,7 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Utils_ResizeDialog(hDlg, hInst, MAKEINTRESOURCEA(IDD_LIST), ListDlg_Resize);
break;
- case WM_GETMINMAXINFO:
+ case WM_GETMINMAXINFO:
{
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
@@ -382,10 +384,10 @@ static void GetList(void *)
wchar_t tszTempPath[MAX_PATH];
DWORD dwLen = GetTempPath(_countof(tszTempPath), tszTempPath);
- if (tszTempPath[dwLen-1] == '\\')
- tszTempPath[dwLen-1] = 0;
+ if (tszTempPath[dwLen - 1] == '\\')
+ tszTempPath[dwLen - 1] = 0;
- ptrW updateUrl( GetDefaultUrl()), baseUrl;
+ ptrW updateUrl(GetDefaultUrl()), baseUrl;
SERVLIST hashes(50, CompareHashes);
if (!ParseHashes(updateUrl, baseUrl, hashes)) {
hListThread = nullptr;
@@ -395,7 +397,7 @@ static void GetList(void *)
FILELIST *UpdateFiles = new FILELIST(20);
VARSW dirname(L"%miranda_path%");
- for (int i=0; i < hashes.getCount(); i++) {
+ for (int i = 0; i < hashes.getCount(); i++) {
ServListEntry &hash = hashes[i];
wchar_t tszPath[MAX_PATH];
@@ -436,7 +438,7 @@ void UninitListNew()
DestroyWindow(hwndDialog);
}
-static INT_PTR ShowListCommand(WPARAM,LPARAM)
+static INT_PTR ShowListCommand(WPARAM, LPARAM)
{
DoGetList();
return 0;
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 1c32790add..c7c792cde7 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -97,27 +97,26 @@ static void ApplyUpdates(void *param)
// 3) Unpack all zips
VARSW tszMirandaPath(L"%miranda_path%");
- for (int i = 0; i < todo.getCount(); i++) {
- FILEINFO& p = todo[i];
- if (p.bEnabled) {
- if (p.bDeleteOnly) {
+ for (auto &it : todo) {
+ if (it->bEnabled) {
+ if (it->bDeleteOnly) {
// we need only to backup the old file
- wchar_t *ptszRelPath = p.tszNewName + wcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
+ wchar_t *ptszRelPath = it->tszNewName + wcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, ptszRelPath);
- BackupFile(p.tszNewName, tszBackFile);
+ BackupFile(it->tszNewName, tszBackFile);
}
else {
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
- if (_wcsicmp(p.tszOldName, p.tszNewName)) {
+ if (_wcsicmp(it->tszOldName, it->tszNewName)) {
wchar_t tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
- mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, p.tszOldName);
- mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, p.tszOldName);
+ mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, it->tszOldName);
+ mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, it->tszOldName);
BackupFile(tszSrcPath, tszBackFile);
}
- if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack,true))
- SafeDeleteFile(p.File.tszDiskPath); // remove .zip after successful update
+ if ( unzip(it->File.tszDiskPath, tszMirandaPath, tszFileBack,true))
+ SafeDeleteFile(it->File.tszDiskPath); // remove .zip after successful update
}
}
}
@@ -449,28 +448,27 @@ static void DlgUpdateSilent(void *param)
// 3) Unpack all zips
VARSW tszMirandaPath(L"%miranda_path%");
- for (int i = 0; i < UpdateFiles.getCount(); i++) {
- FILEINFO& p = UpdateFiles[i];
- if (p.bEnabled) {
- if (p.bDeleteOnly) {
+ for (auto &it : UpdateFiles) {
+ if (it->bEnabled) {
+ if (it->bDeleteOnly) {
// we need only to backup the old file
- wchar_t *ptszRelPath = p.tszNewName + wcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
+ wchar_t *ptszRelPath = it->tszNewName + wcslen(tszMirandaPath) + 1, tszBackFile[MAX_PATH];
mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, ptszRelPath);
- BackupFile(p.tszNewName, tszBackFile);
+ BackupFile(it->tszNewName, tszBackFile);
}
else {
// if file name differs, we also need to backup the old file here
// otherwise it would be replaced by unzip
- if (_wcsicmp(p.tszOldName, p.tszNewName)) {
+ if (_wcsicmp(it->tszOldName, it->tszNewName)) {
wchar_t tszSrcPath[MAX_PATH], tszBackFile[MAX_PATH];
- mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, p.tszOldName);
- mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, p.tszOldName);
+ mir_snwprintf(tszSrcPath, L"%s\\%s", tszMirandaPath, it->tszOldName);
+ mir_snwprintf(tszBackFile, L"%s\\%s", tszFileBack, it->tszOldName);
BackupFile(tszSrcPath, tszBackFile);
}
// remove .zip after successful update
- if (unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack, true))
- SafeDeleteFile(p.File.tszDiskPath);
+ if (unzip(it->File.tszDiskPath, tszMirandaPath, tszFileBack, true))
+ SafeDeleteFile(it->File.tszDiskPath);
}
}
}
@@ -532,9 +530,9 @@ struct
}
static renameTable[] =
{
- { L"svc_dbepp.dll", L"Plugins\\dbeditorpp.dll" },
- { L"svc_crshdmp.dll", L"Plugins\\crashdumper.dll" },
- { L"crashdmp.dll", L"Plugins\\crashdumper.dll" },
+ { L"svc_dbepit->dll", L"Plugins\\dbeditorpit->dll" },
+ { L"svc_crshdmit->dll", L"Plugins\\crashdumper.dll" },
+ { L"crashdmit->dll", L"Plugins\\crashdumper.dll" },
{ L"crashrpt.dll", L"Plugins\\crashdumper.dll" },
{ L"attache.dll", L"Plugins\\crashdumper.dll" },
{ L"svc_vi.dll", L"Plugins\\crashdumper.dll" },
@@ -551,7 +549,7 @@ static renameTable[] =
{ L"ttnotify.dll", L"Plugins\\tooltipnotify.dll" },
{ L"newstatusnotify.dll", L"Plugins\\newxstatusnotify.dll" },
{ L"rss.dll", L"Plugins\\newsaggregator.dll" },
- { L"dbx_3x.dll", L"Plugins\\dbx_mmap.dll" },
+ { L"dbx_3x.dll", L"Plugins\\dbx_mmait->dll" },
{ L"actman30.dll", L"Plugins\\actman.dll" },
{ L"skype.dll", L"Plugins\\skypeweb.dll" },
{ L"skypeclassic.dll", L"Plugins\\skypeweb.dll" },
@@ -561,12 +559,12 @@ static renameTable[] =
{ L"startupstatus.dll", L"Plugins\\statusmanager.dll" },
#if MIRANDA_VER >= 0x0A00
- { L"dbx_mmap_sa.dll", L"Plugins\\dbx_mmap.dll" },
- { L"dbx_tree.dll", L"Plugins\\dbx_mmap.dll" },
+ { L"dbx_mmap_sa.dll", L"Plugins\\dbx_mmait->dll" },
+ { L"dbx_tree.dll", L"Plugins\\dbx_mmait->dll" },
{ L"rc4.dll", nullptr },
{ L"athena.dll", nullptr },
{ L"skypekit.exe", nullptr },
- { L"mir_app.dll", nullptr },
+ { L"mir_apit->dll", nullptr },
{ L"mir_core.dll", nullptr },
{ L"zlib.dll", nullptr },
#endif
@@ -598,7 +596,7 @@ static renameTable[] =
{ L"msvcp100.dll", nullptr },
{ L"msvcr100.dll", nullptr },
{ L"tlen.dll", nullptr },
- { L"whatsapp.dll", nullptr },
+ { L"whatsapit->dll", nullptr },
{ L"xfire.dll", nullptr },
{ L"yahoo.dll", nullptr },
{ L"yahoogroups.dll", nullptr },
@@ -643,7 +641,7 @@ static bool isValidDirectory(const wchar_t *ptszDirName)
}
// Scans folders recursively
-static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t *tszBaseUrl, SERVLIST& hashes, OBJLIST<FILEINFO> *UpdateFiles, int level = 0)
+static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t *tszBaseUrl, SERVLIST &hashes, OBJLIST<FILEINFO> *UpdateFiles, int level = 0)
{
wchar_t tszBuf[MAX_PATH];
mir_snwprintf(tszBuf, L"%s\\*", tszFolder);
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index 7407230a1f..b530245b6b 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (C) 2006 Ricardo Pescuma Domenecci
Based on work (C) Heiko Schillinger
@@ -15,14 +15,14 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
// Prototypes ///////////////////////////////////////////////////////////////////////////
-
-PLUGININFOEX pluginInfo={
+
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -50,7 +50,7 @@ HWND hwndMain = nullptr;
int ModulesLoaded(WPARAM wParam, LPARAM lParam);
int EventAdded(WPARAM wparam, LPARAM lparam);
int HotkeyPressed(WPARAM wParam, LPARAM lParam);
-INT_PTR ShowDialog(WPARAM wParam,LPARAM lParam);
+INT_PTR ShowDialog(WPARAM wParam, LPARAM lParam);
void FreeContacts();
int hksModule = 0;
@@ -62,7 +62,7 @@ BOOL hasNewHotkeyModule = FALSE;
// Functions ////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
hInst = hinstDLL;
return TRUE;
@@ -74,7 +74,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfo;
}
-extern "C" __declspec(dllexport) int Load()
+extern "C" __declspec(dllexport) int Load()
{
mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
@@ -88,7 +88,7 @@ extern "C" __declspec(dllexport) int Load()
return 0;
}
-extern "C" __declspec(dllexport) int Unload(void)
+extern "C" __declspec(dllexport) int Unload(void)
{
FreeContacts();
@@ -102,7 +102,7 @@ extern "C" __declspec(dllexport) int Unload(void)
// Called when all the modules are loaded
-int ModulesLoaded(WPARAM, LPARAM)
+int ModulesLoaded(WPARAM, LPARAM)
{
InitOptions();
@@ -110,7 +110,7 @@ int ModulesLoaded(WPARAM, LPARAM)
int pcount = 0;
PROTOACCOUNT** pdesc;
- Proto_EnumAccounts(&pcount,&pdesc);
+ Proto_EnumAccounts(&pcount, &pdesc);
opts.num_protos = pcount;
@@ -124,7 +124,7 @@ int ModulesLoaded(WPARAM, LPARAM)
hkd.szDescription.w = LPGENW("Open dialog");
hkd.szSection.w = LPGENW("Quick Contacts");
hkd.pszService = MS_QC_SHOW_DIALOG;
- hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_ALT, 'Q');
+ hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_ALT, 'Q');
Hotkey_Register(&hkd);
hkd.pszService = nullptr;
@@ -146,28 +146,27 @@ int ModulesLoaded(WPARAM, LPARAM)
hkd.pszName = "Quick Contacts/Info";
hkd.szDescription.w = LPGENW("Open user info");
Hotkey_Register(&hkd);
-
+
hkd.lParam = HOTKEY_HISTORY;
hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'H');
hkd.pszName = "Quick Contacts/History";
hkd.szDescription.w = LPGENW("Open history");
Hotkey_Register(&hkd);
-
+
hkd.lParam = HOTKEY_MENU;
hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'M');
hkd.pszName = "Quick Contacts/Menu";
hkd.szDescription.w = LPGENW("Open contact menu");
Hotkey_Register(&hkd);
-
+
hkd.lParam = HOTKEY_ALL_CONTACTS;
hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'A');
hkd.pszName = "Quick Contacts/All Contacts";
hkd.szDescription.w = LPGENW("Show all contacts");
Hotkey_Register(&hkd);
- if (ServiceExists(MS_SKIN_ADDHOTKEY))
- {
- SKINHOTKEYDESCEX hk = {0};
+ if (ServiceExists(MS_SKIN_ADDHOTKEY)) {
+ SKINHOTKEYDESCEX hk = { 0 };
hk.cbSize = sizeof(hk);
hk.pszSection = Translate("Quick Contacts");
hk.pszName = Translate("Open dialog");
@@ -198,9 +197,9 @@ int EventAdded(WPARAM wparam, LPARAM hDbEvent)
{
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
- if ( !(dbei.flags & DBEF_SENT) || (dbei.flags & DBEF_READ)
- || !db_get_b(NULL, MODULE_NAME, "EnableLastSentTo", 0)
- || db_get_w(NULL, MODULE_NAME, "MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
+ if (!(dbei.flags & DBEF_SENT) || (dbei.flags & DBEF_READ)
+ || !db_get_b(NULL, MODULE_NAME, "EnableLastSentTo", 0)
+ || db_get_w(NULL, MODULE_NAME, "MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
return 0;
db_set_dw(NULL, MODULE_NAME, "LastSentTo", (UINT_PTR)wparam);
@@ -217,7 +216,8 @@ int EventAdded(WPARAM wparam, LPARAM hDbEvent)
// array where the contacts are put into
-struct c_struct {
+struct c_struct
+{
wchar_t szname[120];
wchar_t szgroup[50];
MCONTACT hcontact;
@@ -242,13 +242,11 @@ wchar_t tmp_list_name[120];
wchar_t *GetListName(c_struct *cs)
{
- if (opts.group_append && cs->szgroup[0] != '\0')
- {
+ if (opts.group_append && cs->szgroup[0] != '\0') {
mir_snwprintf(tmp_list_name, L"%s (%s)", cs->szname, cs->szgroup);
return tmp_list_name;
}
- else
- {
+ else {
return cs->szname;
}
}
@@ -273,28 +271,23 @@ int lstreq(wchar_t *a, wchar_t *b, size_t len = -1)
// the contact array in alphabetical order
void SortArray(void)
{
- int loop,doop;
+ int loop, doop;
c_struct *cs_temp;
- SortedList *sl = (SortedList *) &contacts;
- for(loop=0;loop<contacts.getCount();loop++)
- {
- for(doop=loop+1;doop<contacts.getCount();doop++)
- {
- int cmp = lstreq(contacts[loop]->szname,contacts[doop]->szname);
- if (cmp > 0)
- {
- cs_temp=contacts[loop];
- sl->items[loop]=contacts[doop];
- sl->items[doop]=cs_temp;
+ SortedList *sl = (SortedList *)&contacts;
+ for (loop = 0; loop < contacts.getCount(); loop++) {
+ for (doop = loop + 1; doop < contacts.getCount(); doop++) {
+ int cmp = lstreq(contacts[loop]->szname, contacts[doop]->szname);
+ if (cmp > 0) {
+ cs_temp = contacts[loop];
+ sl->items[loop] = contacts[doop];
+ sl->items[doop] = cs_temp;
}
- else if (cmp == 0)
- {
- if(lstreq(contacts[loop]->proto, contacts[doop]->proto) > 0)
- {
- cs_temp=contacts[loop];
- sl->items[loop]=contacts[doop];
- sl->items[doop]=cs_temp;
+ else if (cmp == 0) {
+ if (lstreq(contacts[loop]->proto, contacts[doop]->proto) > 0) {
+ cs_temp = contacts[loop];
+ sl->items[loop] = contacts[doop];
+ sl->items[doop] = cs_temp;
}
}
@@ -317,8 +310,7 @@ int GetStatus(MCONTACT hContact, char *proto = nullptr)
void FreeContacts()
{
- for (int i = contacts.getCount() - 1; i >= 0; i--)
- {
+ for (int i = contacts.getCount() - 1; i >= 0; i--) {
delete contacts[i];
contacts.remove(i);
}
@@ -339,24 +331,21 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
- if(pszProto == nullptr)
+ if (pszProto == nullptr)
continue;
// Get meta
MCONTACT hMeta = NULL;
- if (metacontactsEnabled)
- {
+ if (metacontactsEnabled) {
if ((!show_all && opts.hide_subcontacts) || opts.group_append)
hMeta = db_mc_getMeta(hContact);
}
else if (!mir_strcmp(META_PROTO, pszProto))
continue;
- if (!show_all)
- {
+ if (!show_all) {
// Check if is offline and have to show
- if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE)
- {
+ if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE) {
// See if has to show
char setting[128];
mir_snprintf(setting, "ShowOffline%s", pszProto);
@@ -365,15 +354,14 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
continue;
// Check if proto offline
- else if (opts.hide_from_offline_proto
- && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE)
+ else if (opts.hide_from_offline_proto
+ && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE)
continue;
}
// Check if is subcontact
- if (opts.hide_subcontacts && hMeta != NULL)
- {
+ if (opts.hide_subcontacts && hMeta != NULL) {
if (!opts.keep_subcontacts_from_offline)
continue;
@@ -391,12 +379,10 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
// Get group
c_struct *contact = new c_struct();
-
- if (opts.group_append)
- {
+
+ if (opts.group_append) {
DBVARIANT dbv;
- if (db_get_ws(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0)
- {
+ if (db_get_ws(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) {
if (dbv.ptszVal != nullptr)
mir_wstrncpy(contact->szgroup, dbv.ptszVal, _countof(contact->szgroup));
@@ -405,7 +391,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
}
// Make contact name
- wchar_t *tmp = (wchar_t *) pcli->pfnGetContactDisplayName(hContact, 0);
+ wchar_t *tmp = (wchar_t *)pcli->pfnGetContactDisplayName(hContact, 0);
mir_wstrncpy(contact->szname, tmp, _countof(contact->szname));
PROTOACCOUNT *acc = Proto_GetAccount(pszProto);
@@ -417,14 +403,13 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
}
SortArray();
-
+
SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_RESETCONTENT, 0, 0);
- for(int loop = 0; loop < contacts.getCount(); loop++)
- {
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA,
- (WPARAM)SendDlgItemMessage(hwndDlg, IDC_USERNAME,
- CB_ADDSTRING, 0, (LPARAM) GetListName(contacts[loop])),
- (LPARAM)loop);
+ for (int loop = 0; loop < contacts.getCount(); loop++) {
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA,
+ (WPARAM)SendDlgItemMessage(hwndDlg, IDC_USERNAME,
+ CB_ADDSTRING, 0, (LPARAM)GetListName(contacts[loop])),
+ (LPARAM)loop);
}
}
@@ -432,8 +417,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
// Enable buttons for the selected contact
void EnableButtons(HWND hwndDlg, MCONTACT hContact)
{
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_URL), FALSE);
@@ -443,8 +427,7 @@ void EnableButtons(HWND hwndDlg, MCONTACT hContact)
SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, 0, 0);
}
- else
- {
+ else {
// Is a meta?
MCONTACT hSub = db_mc_getMostOnline(hContact);
if (hSub != NULL)
@@ -465,7 +448,7 @@ void EnableButtons(HWND hwndDlg, MCONTACT hContact)
EnableWindow(GetDlgItem(hwndDlg, IDC_MENU), TRUE);
HICON ico = ImageList_GetIcon(hIml, pcli->pfnGetContactIcon(hContact), ILD_IMAGE);
- SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, (WPARAM) ico, 0);
+ SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, (WPARAM)ico, 0);
}
}
@@ -475,31 +458,25 @@ int CheckText(HWND hdlg, wchar_t *sztext, BOOL only_enable = FALSE)
{
EnableButtons(hwndMain, NULL);
- if(sztext == nullptr || sztext[0] == '\0')
+ if (sztext == nullptr || sztext[0] == '\0')
return 0;
size_t len = mir_wstrlen(sztext);
- if (only_enable)
- {
- for(int loop=0;loop<contacts.getCount();loop++)
- {
- if(lstreq(sztext, contacts[loop]->szname)==0 || lstreq(sztext, GetListName(contacts[loop]))==0)
- {
- EnableButtons(hwndMain, contacts[loop]->hcontact);
+ if (only_enable) {
+ for (auto &it : contacts) {
+ if (lstreq(sztext, it->szname) == 0 || lstreq(sztext, GetListName(it)) == 0) {
+ EnableButtons(hwndMain, it->hcontact);
return 0;
}
}
}
- else
- {
- for(int loop=0;loop<contacts.getCount();loop++)
- {
- if (lstreq(sztext, GetListName(contacts[loop]), len) == 0)
- {
- SetWindowText(hdlg, GetListName(contacts[loop]));
- SendMessage(hdlg, EM_SETSEL, (WPARAM) len, (LPARAM)-1);
- EnableButtons(hwndMain, contacts[loop]->hcontact);
+ else {
+ for (auto &it : contacts) {
+ if (lstreq(sztext, GetListName(it), len) == 0) {
+ SetWindowText(hdlg, GetListName(it));
+ SendMessage(hdlg, EM_SETSEL, (WPARAM)len, (LPARAM)-1);
+ EnableButtons(hwndMain, it->hcontact);
return 0;
}
}
@@ -514,8 +491,7 @@ MCONTACT GetSelectedContact(HWND hwndDlg)
// First try selection
int sel = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
- if (sel != CB_ERR)
- {
+ if (sel != CB_ERR) {
int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETITEMDATA, sel, 0);
if (pos != CB_ERR)
return contacts[pos]->hcontact;
@@ -525,12 +501,10 @@ MCONTACT GetSelectedContact(HWND hwndDlg)
wchar_t cname[120] = L"";
GetDlgItemText(hwndDlg, IDC_USERNAME, cname, _countof(cname));
-
- for(int loop = 0; loop < contacts.getCount(); loop++)
- {
- if(!mir_wstrcmpi(cname, GetListName(contacts[loop])))
- return contacts[loop]->hcontact;
- }
+
+ for (auto &it : contacts)
+ if (!mir_wstrcmpi(cname, GetListName(it)))
+ return it->hcontact;
return NULL;
}
@@ -538,8 +512,8 @@ MCONTACT GetSelectedContact(HWND hwndDlg)
// get array position from handle
int GetItemPos(MCONTACT hcontact)
{
- for(int loop=0; loop < contacts.getCount(); loop++)
- if(hcontact == contacts[loop]->hcontact)
+ for (int loop = 0; loop < contacts.getCount(); loop++)
+ if (hcontact == contacts[loop]->hcontact)
return loop;
return -1;
@@ -549,40 +523,37 @@ int GetItemPos(MCONTACT hcontact)
// callback function for edit-box of the listbox
// without this the autofill function isn't possible
// this was done like ie does it..as far as spy++ could tell ;)
-LRESULT CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
+LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- switch(msg) {
+ switch (msg) {
case WM_CHAR:
{
- if (wparam<32 && wparam != VK_BACK)
+ if (wparam < 32 && wparam != VK_BACK)
break;
wchar_t sztext[120] = L"";
DWORD start;
DWORD end;
- int ret = SendMessage(hdlg,EM_GETSEL,(WPARAM)&start,(LPARAM)&end);
+ int ret = SendMessage(hdlg, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
GetWindowText(hdlg, sztext, _countof(sztext));
BOOL at_end = (mir_wstrlen(sztext) == (int)end);
- if (ret != -1)
- {
- if (wparam == VK_BACK)
- {
+ if (ret != -1) {
+ if (wparam == VK_BACK) {
if (start > 0)
- SendMessage(hdlg,EM_SETSEL,(WPARAM)start-1,(LPARAM)end);
+ SendMessage(hdlg, EM_SETSEL, (WPARAM)start - 1, (LPARAM)end);
- sztext[0]=0;
+ sztext[0] = 0;
}
- else
- {
- sztext[0]=wparam;
- sztext[1]=0;
+ else {
+ sztext[0] = wparam;
+ sztext[1] = 0;
}
- SendMessage(hdlg,EM_REPLACESEL,0,(LPARAM)sztext);
+ SendMessage(hdlg, EM_REPLACESEL, 0, (LPARAM)sztext);
GetWindowText(hdlg, sztext, _countof(sztext));
}
@@ -594,21 +565,18 @@ LRESULT CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
wchar_t sztext[120] = L"";
- if (wparam == VK_RETURN)
- {
- switch(SendMessage(GetParent(hdlg),CB_GETDROPPEDSTATE,0,0))
- {
+ if (wparam == VK_RETURN) {
+ switch (SendMessage(GetParent(hdlg), CB_GETDROPPEDSTATE, 0, 0)) {
case FALSE:
- SendMessage(GetParent(GetParent(hdlg)),WM_COMMAND,MAKEWPARAM(IDC_ENTER,STN_CLICKED),0);
+ SendMessage(GetParent(GetParent(hdlg)), WM_COMMAND, MAKEWPARAM(IDC_ENTER, STN_CLICKED), 0);
break;
case TRUE:
- SendMessage(GetParent(hdlg),CB_SHOWDROPDOWN,FALSE,0);
+ SendMessage(GetParent(hdlg), CB_SHOWDROPDOWN, FALSE, 0);
break;
}
}
- else if (wparam == VK_DELETE)
- {
+ else if (wparam == VK_DELETE) {
GetWindowText(hdlg, sztext, _countof(sztext));
CheckText(hdlg, sztext, TRUE);
}
@@ -617,7 +585,7 @@ LRESULT CALLBACK EditProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
}
case WM_GETDLGCODE:
- return DLGC_WANTCHARS|DLGC_WANTARROWS;
+ return DLGC_WANTCHARS | DLGC_WANTARROWS;
}
return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam);
@@ -630,15 +598,14 @@ HHOOK hHook;
// the keyboard accelerators
LRESULT CALLBACK HookProc(int code, WPARAM, LPARAM lparam)
{
- if (code!=MSGF_DIALOGBOX)
+ if (code != MSGF_DIALOGBOX)
return 0;
MSG *msg = (MSG*)lparam;
if (hasNewHotkeyModule) {
int action = Hotkey_Check(msg, "Quick Contacts");
- if (action != 0)
- {
+ if (action != 0) {
SendMessage(hwndMain, WM_COMMAND, action, 0);
return 1;
}
@@ -649,8 +616,8 @@ LRESULT CALLBACK HookProc(int code, WPARAM, LPARAM lparam)
if (TranslateAccelerator(msg->hwnd, hAcct, msg))
return 1;
-
- msg->hwnd=htemp;
+
+ msg->hwnd = htemp;
}
if (msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE) {
@@ -664,7 +631,7 @@ LRESULT CALLBACK HookProc(int code, WPARAM, LPARAM lparam)
break;
}
}
-
+
return 0;
}
@@ -743,8 +710,8 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
GetWindowRect(GetDlgItem(hwndDlg, IDC_USERNAME), &rc);
ScreenToClient(hwndDlg, &rc);
- CreateWindow(L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE,
- rc.left - 20, rc.top + (rc.bottom - rc.top - 16) / 2, 16, 16, hwndDlg, (HMENU) IDC_ICO,
+ CreateWindow(L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE,
+ rc.left - 20, rc.top + (rc.bottom - rc.top - 16) / 2, 16, 16, hwndDlg, (HMENU)IDC_ICO,
hInst, nullptr);
if (!hasNewHotkeyModule)
@@ -754,7 +721,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Combo
SendDlgItemMessage(hwndDlg, IDC_USERNAME, EM_LIMITTEXT, (WPARAM)119, 0);
- mir_subclassWindow(GetWindow(GetDlgItem(hwndDlg, IDC_USERNAME),GW_CHILD), EditProc);
+ mir_subclassWindow(GetWindow(GetDlgItem(hwndDlg, IDC_USERNAME), GW_CHILD), EditProc);
// Buttons
FillCheckbox(hwndDlg, IDC_SHOW_ALL_CONTACTS, LPGENW("Show all contacts"), hasNewHotkeyModule ? NULL : L"Ctrl+A");
@@ -775,7 +742,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (db_get_b(NULL, MODULE_NAME, "EnableLastSentTo", 0)) {
int pos = GetItemPos((MCONTACT)db_get_dw(NULL, MODULE_NAME, "LastSentTo", -1));
if (pos != -1) {
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETCURSEL, (WPARAM) pos, 0);
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETCURSEL, (WPARAM)pos, 0);
EnableButtons(hwndDlg, contacts[pos]->hcontact);
}
}
@@ -785,10 +752,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_USERNAME:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
EnableButtons(hwndDlg, pos < contacts.getCount() ? contacts[pos]->hcontact : NULL);
}
@@ -809,8 +775,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_MESSAGE:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -831,8 +796,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_FILE:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -853,8 +817,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_URL:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -875,8 +838,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_USERINFO:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -897,8 +859,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_HISTORY:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -919,8 +880,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_MENU:
{
MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
break;
@@ -933,16 +893,15 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
RECT rc;
GetWindowRect(GetDlgItem(hwndDlg, IDC_MENU), &rc);
HMENU hMenu = Menu_BuildContactMenu(hContact);
- int ret = TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, nullptr);
+ int ret = TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, nullptr);
DestroyMenu(hMenu);
- if(ret)
- {
+ if (ret) {
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
Clist_MenuProcessCommand(LOWORD(ret), MPCF_CONTACTMENU, hContact);
}
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", (DWORD) hContact);
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", (DWORD)hContact);
}
break;
@@ -950,7 +909,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_SHOW_ALL_CONTACTS:
{
// Get old text
- HWND hEdit = GetWindow(GetWindow(hwndDlg,GW_CHILD),GW_CHILD);
+ HWND hEdit = GetWindow(GetWindow(hwndDlg, GW_CHILD), GW_CHILD);
wchar_t sztext[120] = L"";
if (SendMessage(hEdit, EM_GETSEL, 0, 0) != -1)
@@ -961,8 +920,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Fill combo
BOOL all = IsDlgButtonChecked(hwndDlg, IDC_SHOW_ALL_CONTACTS);
- if (LOWORD(wParam) == HOTKEY_ALL_CONTACTS)
- {
+ if (LOWORD(wParam) == HOTKEY_ALL_CONTACTS) {
// Toggle checkbox
all = !all;
CheckDlgButton(hwndDlg, IDC_SHOW_ALL_CONTACTS, all ? BST_CHECKED : BST_UNCHECKED);
@@ -994,26 +952,25 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
// Handle contact menu
- if(lpdis->CtlID != IDC_USERNAME)
- {
+ if (lpdis->CtlID != IDC_USERNAME) {
if (lpdis->CtlType == ODT_MENU)
return Menu_DrawItem(lParam);
break;
}
// Handle combo
- if(lpdis->itemID == -1)
+ if (lpdis->itemID == -1)
break;
TEXTMETRIC tm;
- int icon_width=0, icon_height=0;
+ int icon_width = 0, icon_height = 0;
RECT rc;
GetTextMetrics(lpdis->hDC, &tm);
ImageList_GetIconSize(hIml, &icon_width, &icon_height);
- COLORREF clrfore = SetTextColor(lpdis->hDC,GetSysColor(lpdis->itemState & ODS_SELECTED?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
- COLORREF clrback = SetBkColor(lpdis->hDC,GetSysColor(lpdis->itemState & ODS_SELECTED?COLOR_HIGHLIGHT:COLOR_WINDOW));
+ COLORREF clrfore = SetTextColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
+ COLORREF clrback = SetBkColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
@@ -1033,9 +990,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (max_proto_width == 0) {
// Has to be done, else the DC isnt the right one
// Dont ask me why
- for (int loop = 0; loop < contacts.getCount(); loop++) {
+ for (auto &it : contacts) {
RECT rcc = { 0, 0, 0x7FFF, 0x7FFF };
- DrawText(lpdis->hDC, contacts[loop]->proto, -1, &rcc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE | DT_CALCRECT);
+ DrawText(lpdis->hDC, it->proto, -1, &rcc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE | DT_CALCRECT);
max_proto_width = max(max_proto_width, rcc.right - rcc.left);
}
@@ -1090,7 +1047,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
// Handle contact menu
- if(lpmis->CtlID != IDC_USERNAME) {
+ if (lpmis->CtlID != IDC_USERNAME) {
if (lpmis->CtlType == ODT_MENU)
return Menu_MeasureItem(lParam);
break;
@@ -1099,7 +1056,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Handle combo
TEXTMETRIC tm;
- int icon_width = 0, icon_height=0;
+ int icon_width = 0, icon_height = 0;
GetTextMetrics(GetDC(hwndDlg), &tm);
ImageList_GetIconSize(hIml, &icon_width, &icon_height);
@@ -1115,10 +1072,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Show the main dialog
-INT_PTR ShowDialog(WPARAM, LPARAM)
+INT_PTR ShowDialog(WPARAM, LPARAM)
{
- if (!main_dialog_open)
- {
+ if (!main_dialog_open) {
InterlockedExchange(&main_dialog_open, 1);
hwndMain = CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), nullptr, MainDlgProc);
diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp
index 5335379dd1..23ec25f537 100644
--- a/plugins/QuickReplies/src/events.cpp
+++ b/plugins/QuickReplies/src/events.cpp
@@ -97,8 +97,8 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam)
}
}
- for (int i = 0; i < replyList.getCount(); i++)
- mir_free(replyList[i]);
+ for (auto &it : replyList)
+ mir_free(it);
replyList.destroy();
return 1;
diff --git a/plugins/Scriver/src/chat_manager.cpp b/plugins/Scriver/src/chat_manager.cpp
index c763f15e6a..0995b28b74 100644
--- a/plugins/Scriver/src/chat_manager.cpp
+++ b/plugins/Scriver/src/chat_manager.cpp
@@ -31,8 +31,7 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO *cu
if (currSession == prevSession)
pszCurrent = pszOriginal;
- for (int i = 0; i < pci->arSessions.getCount(); i++) {
- SESSION_INFO *si = pci->arSessions[i];
+ for (auto &si : pci->arSessions) {
if (si != currSession && !mir_strcmpi(pszModule, si->pszModule)) {
if (my_strstri(si->ptszName, pszOriginal) == si->ptszName) {
if (prevSession != si && mir_wstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || mir_wstrcmpi(si->ptszName, pszName) < 0)) {
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index e713c569cc..7e0ddb8a4f 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -276,11 +276,10 @@ static void RestoreUnreadMessageAlerts(void)
cle.flags = CLEF_UNICODE;
cle.szTooltip.w = toolTip;
- for (int i = 0; i < arEvents.getCount(); i++) {
- MSavedEvent &e = arEvents[i];
- mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0));
- cle.hContact = e.hContact;
- cle.hDbEvent = e.hEvent;
+ for (auto &e : arEvents) {
+ mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e->hContact, 0));
+ cle.hContact = e->hContact;
+ cle.hDbEvent = e->hEvent;
pcli->pfnAddEvent(&cle);
}
}
diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp
index 59e0059773..2c7eb2fd75 100644
--- a/plugins/SecureIM/src/crypt_icons.cpp
+++ b/plugins/SecureIM/src/crypt_icons.cpp
@@ -19,9 +19,9 @@ static ICON_CACHE& getCacheItem(int mode, int type)
int m = mode & 0x0f, s = (mode & SECURED) >> 4, i; // разобрали на части - режим и состояние
HICON icon;
- for (i = 0; i < arIcoList.getCount(); i++)
- if (arIcoList[i].mode == ((type << 8) | mode))
- return arIcoList[i];
+ for (auto &it : arIcoList)
+ if (it->mode == ((type << 8) | mode))
+ return *it;
i = s;
switch (type) {
@@ -106,8 +106,8 @@ void ShowStatusIconNotify(MCONTACT hContact)
void RefreshContactListIcons(void)
{
- for (int i = 0; i < arIcoList.getCount(); i++)
- arIcoList[i].hCLIcon = nullptr;
+ for (auto &it : arIcoList)
+ it->hCLIcon = nullptr;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (isSecureProtocol(hContact))
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp
index bb97d160f0..be5f6a5e0a 100644
--- a/plugins/SecureIM/src/crypt_lists.cpp
+++ b/plugins/SecureIM/src/crypt_lists.cpp
@@ -56,9 +56,9 @@ void loadSupportedProtocols()
void freeSupportedProtocols()
{
- for (int j = 0; j < arProto.getCount(); j++) {
- mir_free(arProto[j]->name);
- mir_free(arProto[j]);
+ for (auto &it : arProto) {
+ mir_free(it->name);
+ mir_free(it);
}
arProto.destroy();
@@ -66,9 +66,9 @@ void freeSupportedProtocols()
pSupPro getSupPro(MCONTACT hContact)
{
- for (int j = 0; j < arProto.getCount(); j++)
- if (Proto_IsProtoOnContact(hContact, arProto[j]->name))
- return arProto[j];
+ for (auto &it : arProto)
+ if (Proto_IsProtoOnContact(hContact, it->name))
+ return it;
return nullptr;
}
@@ -127,8 +127,7 @@ void loadContactList()
// free list of secureIM users
void freeContactList()
{
- for (int j = 0; j < arClist.getCount(); j++) {
- pUinKey p = arClist[j];
+ for (auto &p : arClist) {
cpp_delete_context(p->cntx); p->cntx = nullptr;
mir_free(p->tmp);
mir_free(p->msgSplitted);
@@ -153,9 +152,9 @@ pUinKey getUinKey(MCONTACT hContact)
pUinKey getUinCtx(HANDLE cntx)
{
- for (int j = 0; j < arClist.getCount(); j++)
- if (arClist[j]->cntx == cntx)
- return arClist[j];
+ for (auto &it : arClist)
+ if (it->cntx == cntx)
+ return it;
return nullptr;
}
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index ef90cd1273..203c2ed258 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -47,8 +47,8 @@ void LoadWatchedProtos()
void UnloadWatchedProtos()
{
- for (int i = 0; i < arWatchedProtos.getCount(); i++)
- mir_free(arWatchedProtos[i]);
+ for (auto &it : arWatchedProtos)
+ mir_free(it);
arWatchedProtos.destroy();
}
diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp
index fda20d04a2..1b046968ff 100644
--- a/plugins/SimpleStatusMsg/src/utils.cpp
+++ b/plugins/SimpleStatusMsg/src/utils.cpp
@@ -48,7 +48,7 @@ HICON LoadIconEx(const char *name)
HANDLE GetIconHandle(int iconId)
{
- for(int i = 0; i < _countof(iconList); i++)
+ for (int i = 0; i < _countof(iconList); i++)
if (iconList[i].defIconID == iconId)
return iconList[i].hIcolib;
@@ -73,8 +73,8 @@ HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARA
void UnhookProtoEvents(void)
{
- for (int i = 0; i < arProtoHooks.getCount(); ++i)
- UnhookEvent( arProtoHooks[i] );
+ for (auto &it : arProtoHooks)
+ UnhookEvent(it);
arProtoHooks.destroy();
}
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 03fa58e5fb..98178f0a23 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -733,8 +733,7 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
wchar_t name[64];
mir_snwprintf(name, L"%s_%s", ini, end);
- for (int i = 0; i < tmp_dicts->getCount(); i++) {
- Dictionary *dict = (*tmp_dicts)[i];
+ for (auto &dict : *tmp_dicts) {
if (mir_wstrcmpi(dict->language, name) == 0) {
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, _countof(dict->english_name));
@@ -772,9 +771,7 @@ void GetDictsInfo(LIST<Dictionary> &dicts)
EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);
// Try to get name from DB
- for (int i = 0; i < dicts.getCount(); i++) {
- Dictionary *dict = dicts[i];
-
+ for (auto &dict : dicts) {
if (dict->full_name[0] == '\0') {
DBVARIANT dbv;
@@ -931,9 +928,8 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use
// Free the list returned by GetAvaibleDictionaries
void FreeDictionaries(LIST<Dictionary> &dicts)
{
- for (int i = 0; i < dicts.getCount(); i++)
- delete dicts[i];
-
+ for (auto &it : dicts)
+ delete it;
dicts.destroy();
}
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp
index 5dd5db0a0d..6f0d0e22e9 100644
--- a/plugins/SpellChecker/src/options.cpp
+++ b/plugins/SpellChecker/src/options.cpp
@@ -98,13 +98,11 @@ void LoadOptions()
db_free(&dbv);
}
- int i;
- for (i = 0; i < languages.getCount(); i++)
- if (mir_wstrcmp(languages[i]->language, opts.default_language) == 0)
- break;
+ for (auto &it : languages)
+ if (mir_wstrcmp(it->language, opts.default_language) == 0)
+ return;
- if (i >= languages.getCount())
- mir_wstrcpy(opts.default_language, languages[0]->language);
+ mir_wstrcpy(opts.default_language, languages[0]->language);
}
static void DrawItem(LPDRAWITEMSTRUCT lpdis, Dictionary *dict)
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp
index 0640f6f10b..4b495303c1 100644
--- a/plugins/SpellChecker/src/spellchecker.cpp
+++ b/plugins/SpellChecker/src/spellchecker.cpp
@@ -145,7 +145,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
// Get language flags
for (int i = 0; i < languages.getCount(); i++) {
- Dictionary *p = languages[i];
+ auto *p = languages[i];
sid.description.w = p->full_name;
char lang[32];
@@ -179,9 +179,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
FreeLibrary(hFlagsDll);
}
- for (int j = 0; j < languages.getCount(); j++) {
- Dictionary *dict = languages[j];
-
+ for (auto &dict : languages) {
wchar_t filename[MAX_PATH];
mir_snwprintf(filename, L"%s\\%s.ar", customDictionariesFolder, dict->language);
dict->autoReplace = new AutoReplaceMap(filename, dict);
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index 1b88e94621..7dfcd12884 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -728,11 +728,8 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch
if (dbv.type == DBVT_WCHAR && dbv.ptszVal != nullptr) {
wchar_t *lang = dbv.ptszVal;
- for (int i = 0; i < languages.getCount(); i++) {
- Dictionary *dict = languages[i];
- if (mir_wstrcmpi(dict->localized_name, lang) == 0
- || mir_wstrcmpi(dict->english_name, lang) == 0
- || mir_wstrcmpi(dict->language, lang) == 0) {
+ for (auto &dict : languages) {
+ if (mir_wstrcmpi(dict->localized_name, lang) == 0 || mir_wstrcmpi(dict->english_name, lang) == 0 || mir_wstrcmpi(dict->language, lang) == 0) {
mir_wstrncpy(dlg->lang_name, dict->language, _countof(dlg->lang_name));
break;
}
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp
index 2bf222f327..413ac69fb5 100644
--- a/plugins/TopToolBar/src/toolbar.cpp
+++ b/plugins/TopToolBar/src/toolbar.cpp
@@ -115,8 +115,8 @@ int SaveAllButtonsOptions()
int LaunchCnt = 0;
{
mir_cslock lck(csButtonsHook);
- for (int i = 0; i < Buttons.getCount(); i++)
- Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt);
+ for (auto &it : Buttons)
+ it->SaveSettings(&SeparatorCnt, &LaunchCnt);
}
db_set_b(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
db_set_b(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt);
@@ -128,8 +128,8 @@ static bool nameexists(const char *name)
if (name == nullptr)
return false;
- for (int i = 0; i < Buttons.getCount(); i++)
- if (!mir_strcmp(Buttons[i]->pszName, name))
+ for (auto &it : Buttons)
+ if (!mir_strcmp(it->pszName, name))
return true;
return false;
@@ -210,8 +210,8 @@ int ArrangeButtons()
int i, nextX = 0, y = 0;
int nButtonCount = 0;
- for (i = 0; i < Buttons.getCount(); i++)
- if (Buttons[i]->hwnd)
+ for (auto &it : Buttons)
+ if (it->hwnd)
nButtonCount++;
if (nButtonCount == 0)
@@ -492,8 +492,7 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
int OnIconChange(WPARAM, LPARAM)
{
mir_cslock lck(csButtonsHook);
- for (int i = 0; i < Buttons.getCount(); i++) {
- TopButtonInt *b = Buttons[i];
+ for (auto &b : Buttons) {
if (!b->hIconHandleUp && !b->hIconHandleDn)
continue;
@@ -678,8 +677,8 @@ int UnloadToolbarModule()
{
DestroyHookableEvent(hTTBModuleLoaded);
- for (int i = 0; i < Buttons.getCount(); i++)
- delete Buttons[i];
+ for (auto &it : Buttons)
+ delete it;
mir_free(g_ctrl);
return 0;
diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp
index 843db24ac6..27d1b36b2a 100644
--- a/plugins/TopToolBar/src/ttbopt.cpp
+++ b/plugins/TopToolBar/src/ttbopt.cpp
@@ -61,8 +61,8 @@ static int BuildTree(HWND hwndDlg)
if (Buttons.getCount() == 0)
return FALSE;
- for (int i = 0; i < Buttons.getCount(); i++)
- AddLine(hTree, Buttons[i], TVI_LAST, dat->himlButtonIcons);
+ for (auto &it : Buttons)
+ AddLine(hTree, it, TVI_LAST, dat->himlButtonIcons);
return TRUE;
}
@@ -95,9 +95,8 @@ static void SaveTree(HWND hwndDlg)
}
{
mir_cslock lck(csButtonsHook);
- for (int i=0; i < Buttons.getCount(); i++)
- delete Buttons[i];
-
+ for (auto &it : Buttons)
+ delete it;
Buttons = tmpList;
}
SaveAllButtonsOptions();
@@ -128,8 +127,7 @@ static void RecreateWindows()
{
{
mir_cslock lck(csButtonsHook);
- for (int i = 0; i < Buttons.getCount(); i++) {
- TopButtonInt *b = Buttons[i];
+ for (auto &b : Buttons) {
if (b->hwnd) {
if (g_ctrl->bHardUpdate) {
DestroyWindow(b->hwnd);
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index 270ae015b8..8574cea41f 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -317,22 +317,21 @@ static int contactSettingChanged(WPARAM hContact, LPARAM lParam)
bool isUid = (((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != nullptr)) && (!strcmp(dbw->szSetting, uid));
mir_cslock lck(csContactCache);
- for (int i = 0; i < arContactCache.getCount(); i++) {
- CONTACTCE &cce = arContactCache[i];
- if (hContact != cce.hContact && (cce.flags & CI_CNFINFO) == 0)
+ for (auto &it : arContactCache) {
+ if (hContact != it->hContact && (it->flags & CI_CNFINFO) == 0)
continue;
- if ((isNick && (cce.flags & CI_NICK)) ||
- (isFirstName && (cce.flags & CI_FIRSTNAME)) ||
- (isLastName && (cce.flags & CI_LASTNAME)) ||
- (isEmail && (cce.flags & CI_EMAIL)) ||
- (isMyHandle && (cce.flags & CI_LISTNAME)) ||
- (cce.flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
- (isUid && (cce.flags & CI_UNIQUEID)))
+ if ((isNick && (it->flags & CI_NICK)) ||
+ (isFirstName && (it->flags & CI_FIRSTNAME)) ||
+ (isLastName && (it->flags & CI_LASTNAME)) ||
+ (isEmail && (it->flags & CI_EMAIL)) ||
+ (isMyHandle && (it->flags & CI_LISTNAME)) ||
+ (it->flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
+ (isUid && (it->flags & CI_UNIQUEID)))
{
/* remove from cache */
- mir_free(cce.tszContact);
- arContactCache.remove(i);
+ mir_free(it->tszContact);
+ arContactCache.remove(it);
break;
}
}
@@ -347,8 +346,8 @@ int initContactModule()
int deinitContactModule()
{
- for (int i = 0; i < arContactCache.getCount(); i++)
- mir_free(arContactCache[i].tszContact);
+ for (auto &it : arContactCache)
+ mir_free(it->tszContact);
arContactCache.destroy();
return 0;
}
diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp
index e90595a68e..aff5f9251c 100644
--- a/plugins/Variables/src/parse_alias.cpp
+++ b/plugins/Variables/src/parse_alias.cpp
@@ -36,9 +36,9 @@ static ALIASREGISTER* searchAliasRegister(wchar_t *szAlias)
return nullptr;
mir_cslock lck(csAliasRegister);
- for (int i = 0; i < arAliases.getCount(); i++)
- if (!mir_wstrcmp(arAliases[i]->szAlias, szAlias))
- return arAliases[i];
+ for (auto &it : arAliases)
+ if (!mir_wstrcmp(it->szAlias, szAlias))
+ return it;
return nullptr;
}
@@ -93,8 +93,7 @@ static int addToAliasRegister(wchar_t *szAlias, unsigned int argc, wchar_t** arg
return -1;
mir_cslock lck(csAliasRegister);
- for (int i = 0; i < arAliases.getCount(); i++) {
- ALIASREGISTER *p = arAliases[i];
+ for (auto &p : arAliases) {
if (mir_wstrcmp(p->szAlias, szAlias))
continue;
@@ -194,8 +193,7 @@ void registerAliasTokens()
void unregisterAliasTokens()
{
- for (int i = 0; i < arAliases.getCount(); i++) {
- ALIASREGISTER *p = arAliases[i];
+ for (auto &p : arAliases) {
for (unsigned j = 0; j < p->argc; j++)
mir_free(p->argv[j]);
mir_free(p->argv);
diff --git a/plugins/Variables/src/tokenregister.cpp b/plugins/Variables/src/tokenregister.cpp
index 11c2212449..77c6af4252 100644
--- a/plugins/Variables/src/tokenregister.cpp
+++ b/plugins/Variables/src/tokenregister.cpp
@@ -238,8 +238,7 @@ int initTokenRegister()
int deinitTokenRegister()
{
- for (int i = 0; i < tokens.getCount(); i++) {
- TokenRegisterEntry *tre = tokens[i];
+ for (auto &tre : tokens) {
if (!(tre->tr.flags & TRF_PARSEFUNC) && tre->tr.szService != nullptr)
mir_free(tre->tr.szService);
diff --git a/plugins/XSoundNotify/src/options.cpp b/plugins/XSoundNotify/src/options.cpp
index 035772e93d..031729c561 100644
--- a/plugins/XSoundNotify/src/options.cpp
+++ b/plugins/XSoundNotify/src/options.cpp
@@ -317,22 +317,22 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
NMHDR *hdr = (NMHDR *)lParam;
switch (hdr->code) {
case PSN_APPLY:
- for (int i = 0; i < XSN_Users.getCount(); i++) {
- if (mir_wstrcmpi(XSN_Users[i]->path, L"")) {
+ for (auto &it : XSN_Users) {
+ if (mir_wstrcmpi(it->path, L"")) {
wchar_t shortpath[MAX_PATH];
- PathToRelativeW(XSN_Users[i]->path, shortpath);
- if (XSN_Users[i]->iscontact)
- db_set_ws(XSN_Users[i]->hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
+ PathToRelativeW(it->path, shortpath);
+ if (it->iscontact)
+ db_set_ws(it->hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
else
- db_set_ws(NULL, SETTINGSNAME, (LPCSTR)XSN_Users[i]->hContact, shortpath);
+ db_set_ws(NULL, SETTINGSNAME, (LPCSTR)it->hContact, shortpath);
}
- if (XSN_Users[i]->iscontact)
- db_set_b(XSN_Users[i]->hContact, SETTINGSNAME, SETTINGSIGNOREKEY, XSN_Users[i]->ignore);
+ if (it->iscontact)
+ db_set_b(it->hContact, SETTINGSNAME, SETTINGSIGNOREKEY, it->ignore);
else {
- size_t value_max_len = mir_strlen((const char*)XSN_Users[i]->hContact) + 8;
+ size_t value_max_len = mir_strlen((const char*)it->hContact) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
- mir_snprintf(value, value_max_len, "%s_ignore", (const char*)XSN_Users[i]->hContact);
- db_set_b(NULL, SETTINGSNAME, value, XSN_Users[i]->ignore);
+ mir_snprintf(value, value_max_len, "%s_ignore", (const char*)it->hContact);
+ db_set_b(NULL, SETTINGSNAME, value, it->ignore);
mir_free(value);
}
}
diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp
index 423299490d..10da330778 100644
--- a/plugins/YAPP/src/options.cpp
+++ b/plugins/YAPP/src/options.cpp
@@ -451,8 +451,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
arClasses = arNewClasses;
char setting[256];
- for (int i = 0; i < arClasses.getCount(); i++) {
- POPUPCLASS *pc = arClasses[i];
+ for (auto &pc : arClasses) {
mir_snprintf(setting, "%s/Timeout", pc->pszName);
db_set_w(0, MODULE, setting, pc->iSeconds);
mir_snprintf(setting, "%s/TextCol", pc->pszName);
diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp
index 71f68a7b05..87ef273df9 100644
--- a/plugins/YAPP/src/services.cpp
+++ b/plugins/YAPP/src/services.cpp
@@ -381,9 +381,9 @@ static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
if (wParam)
pc = (POPUPCLASS *)wParam;
else {
- for (int i = 0; i < arClasses.getCount(); i++) {
- if (mir_strcmp(arClasses[i]->pszName, pdc->pszClassName) == 0) {
- pc = arClasses[i];
+ for (auto &it : arClasses) {
+ if (mir_strcmp(it->pszName, pdc->pszClassName) == 0) {
+ pc = it;
break;
}
}
@@ -446,6 +446,6 @@ void DeinitServices()
{
DestroyHookableEvent(hEventNotify);
- for (int i = 0; i < arClasses.getCount(); i++)
- FreePopupClass(arClasses[i]);
+ for (auto &it : arClasses)
+ FreePopupClass(it);
}