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 /plugins/PluginUpdater | |
parent | 9d0174ebe2bd005418855b18f737c36d5c20ab4a (diff) |
all another C++'11 iterators
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 74 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 60 |
2 files changed, 67 insertions, 67 deletions
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);
|