From 20d29f4aba3a58ab515275ecd2d3f4affcba9643 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 25 Nov 2018 17:16:50 +0300 Subject: NewStory: more code cleaning --- plugins/NewStory/src/calendartool.cpp | 2 +- plugins/NewStory/src/history.cpp | 14 +++++++------- plugins/NewStory/src/history_array.cpp | 4 +--- plugins/NewStory/src/history_control.cpp | 33 ++++++++++++++++---------------- plugins/NewStory/src/icons.cpp | 2 +- plugins/NewStory/src/icons.h | 2 +- plugins/NewStory/src/main.cpp | 2 +- plugins/NewStory/src/opt_passwords.cpp | 14 ++------------ plugins/NewStory/src/password.cpp | 2 +- plugins/NewStory/src/templates.cpp | 29 ++++++++++++---------------- plugins/NewStory/src/version.h | 2 +- 11 files changed, 44 insertions(+), 62 deletions(-) (limited to 'plugins/NewStory') diff --git a/plugins/NewStory/src/calendartool.cpp b/plugins/NewStory/src/calendartool.cpp index 64e837e913..e7cd6041dd 100644 --- a/plugins/NewStory/src/calendartool.cpp +++ b/plugins/NewStory/src/calendartool.cpp @@ -84,5 +84,5 @@ time_t CalendarTool_Show(HWND hwnd, int x, int y) CalendarToolData *data = new CalendarToolData; data->x = x; data->y = y; - return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), 0, CalendarToolDlgProc, (LPARAM)data); + return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), hwnd, CalendarToolDlgProc, (LPARAM)data); } \ No newline at end of file diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp index f853b67299..267b2f42c1 100644 --- a/plugins/NewStory/src/history.cpp +++ b/plugins/NewStory/src/history.cpp @@ -114,7 +114,7 @@ struct WindowData InfoBarEvents ibMessages, ibFiles, ibUrls, ibTotal; }; -void LayoutFilterBar(HDWP hDwp, HWND hwnd, int x, int y, int w, InfoBarEvents *ib) +void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents *ib) { hDwp = DeferWindowPos(hDwp, ib->hwndIco, 0, x, y, 16, 16, SWP_NOZORDER); @@ -232,10 +232,10 @@ void LayoutHistoryWnd(HWND hwnd, WindowData *data) if (data->wndOptions & WND_OPT_FILTERBAR) { hFilterBar = WND_SPACING + (16 + WND_SPACING)*3; - LayoutFilterBar(hDwp, hwnd, WND_SPACING+(WND_SPACING+75)*0, WND_SPACING*2 + hToolBar, 75, &data->ibMessages); - LayoutFilterBar(hDwp, hwnd, WND_SPACING+(WND_SPACING+75)*1, WND_SPACING*2 + hToolBar, 75, &data->ibFiles); - LayoutFilterBar(hDwp, hwnd, WND_SPACING+(WND_SPACING+75)*2, WND_SPACING*2 + hToolBar, 75, &data->ibUrls); - LayoutFilterBar(hDwp, hwnd, WND_SPACING+(WND_SPACING+75)*3, WND_SPACING*2 + hToolBar, 75, &data->ibTotal); + LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*0, WND_SPACING*2 + hToolBar, 75, &data->ibMessages); + LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*1, WND_SPACING*2 + hToolBar, 75, &data->ibFiles); + LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*2, WND_SPACING*2 + hToolBar, 75, &data->ibUrls); + LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*3, WND_SPACING*2 + hToolBar, 75, &data->ibTotal); GetWindowRect(data->hwndChkDateFrom, &rc); x = rc.right - rc.left; @@ -1031,7 +1031,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return FALSE; //DefWindowProc(hwnd, msg, wParam, lParam); } -INT_PTR svcShowNewstory(WPARAM wParam, LPARAM lParam) +INT_PTR svcShowNewstory(WPARAM wParam, LPARAM) { HWND hwnd = (HWND)WindowList_Find(hNewstoryWindows, (MCONTACT)wParam); if (hwnd && IsWindow(hwnd)) @@ -1047,7 +1047,7 @@ INT_PTR svcShowNewstory(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR svcShowSystemNewstory(WPARAM wParam, LPARAM lParam) +INT_PTR svcShowSystemNewstory(WPARAM, LPARAM) { HWND hwnd = (HWND)WindowList_Find(hNewstoryWindows, 0); if (hwnd && IsWindow(hwnd)) diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index ed2ceadcdb..6d34d9043d 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" -void CacheThreadFunc(void *arg); - // Event bool HistoryArray::ItemData::load(EventLoadMode mode) { @@ -168,7 +166,7 @@ void HistoryArray::clear() preIndex = 0; } -bool HistoryArray::addHistory(MCONTACT hContact, EventLoadMode mode) +bool HistoryArray::addHistory(MCONTACT hContact, EventLoadMode) { int count = db_event_count(hContact); allocateBlock(count); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 801a578f0f..8467503026 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -55,7 +55,7 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData *data); static void RecalcScrollBar(HWND hwnd, NewstoryListData *data); static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index); static void EndEditItem(HWND hwnd, NewstoryListData *data); -static int LayoutItem(HWND hwnd, HistoryArray *items, int index, bool force); +static int LayoutItem(HWND hwnd, HistoryArray *items, int index); static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width); @@ -231,7 +231,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM DWORD count = data->items.getCount(); DWORD current = data->scrollTopItem; int top = data->scrollTopPixel; - int bottom = top + LayoutItem(hwnd, &data->items, current, false); + int bottom = top + LayoutItem(hwnd, &data->items, current); while (top <= height) { if ((lParam >= top) && (lParam <= bottom)) @@ -239,7 +239,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (++current >= count) return -1; top = bottom; - bottom = top + LayoutItem(hwnd, &data->items, current, false); + bottom = top + LayoutItem(hwnd, &data->items, current); } return -1; } @@ -287,8 +287,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { TCHAR *res = 0; TCHAR *buf; - int size = 0; - + int eventCount = data->items.getCount(); for (int i = 0; i < eventCount; i++) { @@ -586,7 +585,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } else { data->scrollTopItem = pos/AVERAGE_ITEM_HEIGHT; - int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem, false); + int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); data->scrollTopPixel = -pos%AVERAGE_ITEM_HEIGHT * itemHeight / AVERAGE_ITEM_HEIGHT; } FixScrollPosition(hwnd, data); @@ -630,7 +629,7 @@ static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int while ((data->scrollTopPixel > 0) && data->scrollTopItem) { data->scrollTopItem--; - int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem, false); + int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); data->scrollTopPixel -= itemHeight; } @@ -642,12 +641,12 @@ static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int if (data->scrollTopPixel < 0) { int maxItem = data->items.getCount(); - int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem, false); + int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); while ((-data->scrollTopPixel > itemHeight) && (data->scrollTopItem < maxItem)) { data->scrollTopPixel += itemHeight; data->scrollTopItem++; - itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem, false); + itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); } } } @@ -666,13 +665,13 @@ static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) int height = rc.bottom - rc.top; int top = data->scrollTopPixel; int idx = data->scrollTopItem; - int itemHeight = LayoutItem(hwnd, &data->items, idx, false); + int itemHeight = LayoutItem(hwnd, &data->items, idx); bool found = false; while (top < height) { if (idx == item) { - itemHeight = LayoutItem(hwnd, &data->items, idx, false); + itemHeight = LayoutItem(hwnd, &data->items, idx); if (top + itemHeight > height) ScrollListBy(hwnd, data, 0, height-top-itemHeight); found = true; @@ -680,7 +679,7 @@ static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) } top += itemHeight; idx++; - itemHeight = LayoutItem(hwnd, &data->items, idx, false); + itemHeight = LayoutItem(hwnd, &data->items, idx); } if (!found) { @@ -704,7 +703,7 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData *data) int maxTopItem = 0; int tmp = 0; for (maxTopItem = data->items.getCount(); (maxTopItem>0) && (tmp < windowHeight); maxTopItem--) - tmp += LayoutItem(hwnd, &data->items, maxTopItem-1, false); + tmp += LayoutItem(hwnd, &data->items, maxTopItem-1); data->cachedMaxTopItem = maxTopItem; data->cachedWindowHeight = windowHeight; data->cachedMaxTopPixel = (windowHeight < tmp) ? windowHeight - tmp : 0; @@ -751,7 +750,7 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) int top = data->scrollTopPixel; int idx = data->scrollTopItem; - int itemHeight = LayoutItem(hwnd, &data->items, idx, false); + int itemHeight = LayoutItem(hwnd, &data->items, idx); while (top < height) { if (idx == index) @@ -819,17 +818,17 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) } top += itemHeight; idx++; - itemHeight = LayoutItem(hwnd, &data->items, idx, false); + itemHeight = LayoutItem(hwnd, &data->items, idx); } } -static void EndEditItem(HWND hwnd, NewstoryListData *data) +static void EndEditItem(HWND, NewstoryListData *data) { DestroyWindow(data->hwndEditBox); data->hwndEditBox = 0; } -static int LayoutItem(HWND hwnd, HistoryArray *items, int index, bool force) +static int LayoutItem(HWND hwnd, HistoryArray *items, int index) { HDC hdc = GetDC(hwnd); RECT rc; GetClientRect(hwnd, &rc); diff --git a/plugins/NewStory/src/icons.cpp b/plugins/NewStory/src/icons.cpp index 61f9cd4211..26a8f01360 100644 --- a/plugins/NewStory/src/icons.cpp +++ b/plugins/NewStory/src/icons.cpp @@ -42,7 +42,7 @@ int evtIconsChanged(WPARAM, LPARAM) return 0; } -void InitIcons(LPSTR szFilename, int count) +void InitIcons() { g_plugin.registerIcon(MODULETITLE, icons); HookEvent(ME_SKIN2_ICONSCHANGED, evtIconsChanged); diff --git a/plugins/NewStory/src/icons.h b/plugins/NewStory/src/icons.h index 635ece3f7a..de29414d19 100644 --- a/plugins/NewStory/src/icons.h +++ b/plugins/NewStory/src/icons.h @@ -34,5 +34,5 @@ enum HICON GetIcon(int iconId); -void InitIcons(LPSTR szFilename, int count); +void InitIcons(); void RefreshIcons(IconItem *icons, int count); \ No newline at end of file diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp index a88a597399..7adffe0f83 100644 --- a/plugins/NewStory/src/main.cpp +++ b/plugins/NewStory/src/main.cpp @@ -43,7 +43,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_UIHIST int evtModulesLoaded(WPARAM, LPARAM) { - InitIcons("icons\\newstory_icons.dll", 0); + InitIcons(); InitFonts(); InitNewstoryControl(); InitHistory(); diff --git a/plugins/NewStory/src/opt_passwords.cpp b/plugins/NewStory/src/opt_passwords.cpp index e23cdcf0f3..16efd37ec2 100644 --- a/plugins/NewStory/src/opt_passwords.cpp +++ b/plugins/NewStory/src/opt_passwords.cpp @@ -4,10 +4,8 @@ int icoidNoPassword, icoidPassword; void SetAllContactIcons(HWND hwndList) { - MCONTACT hContact, hItem; - hContact = db_find_first(); for (auto &hContact : Contacts()) { - hItem = (MCONTACT)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); + MCONTACT hItem = (MCONTACT)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, CheckPassword(hContact, "") ? icoidNoPassword : icoidPassword)); } } @@ -24,7 +22,7 @@ static void ResetListOptions(HWND hwndList) SetWindowLong(hwndList, GWL_STYLE, GetWindowLong(hwndList, GWL_STYLE) | CLS_SHOWHIDDEN); } -INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) { HTREEITEM hitmGlobal, hitmMaster; switch (msg) @@ -51,8 +49,6 @@ INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hitmMaster = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); SendMessage(GetDlgItem(hwnd, IDC_LIST), CLM_SETEXTRAIMAGE, (WPARAM)hitmMaster, MAKELPARAM(0, icoidNoPassword)); - HWND hwndList = GetDlgItem(hwnd, IDC_LIST); - SetAllContactIcons(GetDlgItem(hwnd, IDC_LIST)); ResetListOptions(GetDlgItem(hwnd, IDC_LIST)); @@ -62,12 +58,6 @@ INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM SendMessage(GetDlgItem(hwnd, IDC_SAVEPASSWORD), BUTTONSETASFLATBTN, 0, 0); SendMessage(GetDlgItem(hwnd, IDC_SAVEPASSWORD), BUTTONADDTOOLTIP, (WPARAM)Translate("Save Password"), 0); SendMessage(GetDlgItem(hwnd, IDC_SAVEPASSWORD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SAVEPASS)); - - // hVisibleIcon=ImageList_GetIcon(hIml,1,ILD_NORMAL); - // SendDlgItemMessage(hwndDlg,IDC_VISIBLEICON,STM_SETICON,(WPARAM)hVisibleIcon,0); - // hInvisibleIcon=ImageList_GetIcon(hIml,2,ILD_NORMAL); - // SendDlgItemMessage(hwndDlg,IDC_INVISIBLEICON,STM_SETICON,(WPARAM)hInvisibleIcon,0); - return TRUE; } diff --git a/plugins/NewStory/src/password.cpp b/plugins/NewStory/src/password.cpp index 36854d6dfb..31cd062b8e 100644 --- a/plugins/NewStory/src/password.cpp +++ b/plugins/NewStory/src/password.cpp @@ -231,7 +231,7 @@ INT_PTR CALLBACK ChangePasswordDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return FALSE; } -void ChangePassword(HWND hwnd, HANDLE hContact) +void ChangePassword(HWND hwnd, MCONTACT hContact) { DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHANGEPASSWORD), hwnd, ChangePasswordDlgProc, (LPARAM)hContact); } diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 84e72ed00d..a112f33032 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -243,7 +243,7 @@ int TplMeasureVars(TemplateVars *vars, TCHAR *str) } // Loading variables -void vfGlobal(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfGlobal(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData*) { // %%: simply % character TplSetVar(vars, '%', _T("%"), false); @@ -256,7 +256,7 @@ void vfGlobal(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemD TplSetVar(vars, 'M', buf, false); } -void vfContact(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *item) +void vfContact(int, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData*) { // %N: buddy's nick (not for messages) wchar_t *buff = Clist_GetContactDisplayName(hContact, 0); @@ -268,7 +268,7 @@ void vfContact(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::It TplSetVar(vars, 'c', buf, false); } -void vfSystem(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *item) +void vfSystem(int, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData*) { // %N: buddy's nick (not for messages) TplSetVar(vars, 'N', /*TranslateTS*/_T("System Event"), false); @@ -279,7 +279,7 @@ void vfSystem(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::Ite TplSetVar(vars, 'c', buf, false); } -void vfEvent(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *item) +void vfEvent(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { HICON hIcon; TCHAR *s; @@ -404,54 +404,49 @@ void vfEvent(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::Item TplSetVar(vars, 'O', TranslateW(buf), false); } -void vfMessage(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfMessage(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); } -void vfFile(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfFile(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); - // TplSetVar(vars, 'M', _T("File event"), false); } -void vfUrl(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfUrl(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); - // TplSetVar(vars, 'M', _T("URL Event"), false); } -void vfSign(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfSign(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); } -void vfAuth(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfAuth(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); - // TplSetVar(vars, 'M', _T("Auth Rq"), false); } -void vfAdded(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfAdded(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); - // TplSetVar(vars, 'M', _T("Added"), false); } -void vfDeleted(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfDeleted(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) { // %M: the message string itself TplSetVar(vars, 'M', item->getTBuf(), false); - // TplSetVar(vars, 'M', _T("Deleted"), false); } -void vfOther(int mode, TemplateVars *vars, HANDLE hContact, HistoryArray::ItemData *item) +void vfOther(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData*) { // %M: the message string itself TplSetVar(vars, 'M', _T("Unknown Event"), false); diff --git a/plugins/NewStory/src/version.h b/plugins/NewStory/src/version.h index 426a9ff76f..46fba6c7ba 100644 --- a/plugins/NewStory/src/version.h +++ b/plugins/NewStory/src/version.h @@ -1,4 +1,4 @@ -#define __MAJOR_VERSION 0 +#define __MAJOR_VERSION 0 #define __MINOR_VERSION 0 #define __RELEASE_NUM 0 #define __BUILD_NUM 4 -- cgit v1.2.3