From e3cefc7b6ca803e3f87dbadae54a110332778490 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 5 Jul 2012 22:41:06 +0000 Subject: - first of the /Core standard plugins; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@778 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/ignore/ignore.cpp | 148 +++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 74 deletions(-) (limited to 'src/modules/ignore/ignore.cpp') diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index b5b88343d0..21f1207386 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -24,19 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IGNOREEVENT_MAX 7 -static const DWORD ignoreIdToPf1[IGNOREEVENT_MAX]={PF1_IMRECV, PF1_URLRECV, PF1_FILERECV, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; -static const DWORD ignoreIdToPf4[IGNOREEVENT_MAX]={0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, PF4_SUPPORTTYPING}; +static const DWORD ignoreIdToPf1[IGNOREEVENT_MAX] = {PF1_IMRECV, PF1_URLRECV, PF1_FILERECV, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; +static const DWORD ignoreIdToPf4[IGNOREEVENT_MAX] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, PF4_SUPPORTTYPING}; static DWORD GetMask(HANDLE hContact) { - DWORD mask=DBGetContactSettingDword(hContact, "Ignore", "Mask1", (DWORD)(-1)); + DWORD mask = DBGetContactSettingDword(hContact, "Ignore", "Mask1", (DWORD)(-1)); if (mask == (DWORD)(-1)) { - if (hContact == NULL) mask=0; + if (hContact == NULL) mask = 0; else { if (DBGetContactSettingByte(hContact, "CList", "Hidden", 0) || DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) - mask=DBGetContactSettingDword(NULL, "Ignore", "Mask1", 0); + mask = DBGetContactSettingDword(NULL, "Ignore", "Mask1", 0); else - mask=DBGetContactSettingDword(NULL, "Ignore", "Default1", 0); + mask = DBGetContactSettingDword(NULL, "Ignore", "Default1", 0); } } return mask; @@ -45,32 +45,32 @@ static DWORD GetMask(HANDLE hContact) static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount) { int typeOfFirst; - int iconOn[IGNOREEVENT_MAX]={1, 1, 1, 1, 1, 1, 1}; - int childCount[IGNOREEVENT_MAX]={0, 0, 0, 0, 0, 0, 0}, i; + int iconOn[IGNOREEVENT_MAX] = {1, 1, 1, 1, 1, 1, 1}; + int childCount[IGNOREEVENT_MAX] = {0, 0, 0, 0, 0, 0, 0}, i; int iImage; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount); for (i=0; i < SIZEOF(iconOn); i++) - if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i]=0; - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0; + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { for (i=0; i < SIZEOF(iconOn); i++) { - iImage=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); - if (iconOn[i] && iImage == 0) iconOn[i]=0; + iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); + if (iconOn[i] && iImage == 0) iconOn[i] = 0; if (iImage != 0xFF) childCount[i]++; } - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } //set icons for (i=0; i < SIZEOF(iconOn); i++) { @@ -86,22 +86,22 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int int typeOfFirst, iOldIcon; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetAllChildIcons(hwndList, hChildItem, iColumn, iImage); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - iOldIcon=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); + iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (iOldIcon != 0xFF && iOldIcon != iImage) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } } @@ -115,7 +115,7 @@ static void ResetListOptions(HWND hwndList) SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0); SendMessage(hwndList, CLM_SETINDENT, 10, 0); SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0); - for (i=0;i<=FONTID_MAX;i++) + for (i=0;i <= FONTID_MAX;i++) SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT)); } @@ -123,7 +123,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int { int itemType; - itemType=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0); + itemType = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0); if (itemType == CLCIT_CONTACT) { int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (oldiImage != 0xFF && oldiImage != iImage) @@ -134,7 +134,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int else SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); //hItemUnknown } else if (itemType == CLCIT_GROUP) { - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hItem) SetAllChildIcons(hwndList, hItem, iColumn, iImage); } } @@ -144,7 +144,7 @@ static void InitialiseItem(HWND hwndList, HANDLE hContact, HANDLE hItem, DWORD p DWORD mask; int i; - mask=GetMask(hContact); + mask = GetMask(hContact); for (i=0;iiColumn == -1) break; - hItem=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); + hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); if (hItem == NULL) break; if ( !(hitFlags&CLCHT_ONITEMEXTRA)) break; if (nm->iColumn == IGNOREEVENT_MAX) { //ignore all - for (iImage=0;iImageiColumn == IGNOREEVENT_MAX+1) { //ignore none - for (iImage=0;iImageiColumn, 0)); - if (iImage == 0) iImage=nm->iColumn+3; - else if (iImage != 0xFF) iImage=0; + iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); + if (iImage == 0) iImage = nm->iColumn+3; + else if (iImage != 0xFF) iImage = 0; SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, nm->iColumn, iImage); } SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); @@ -305,15 +305,15 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM case PSN_APPLY: { HANDLE hContact, hItem; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); do { - hItem=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem) SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), hContact, hItem, "Mask1"); if (SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) DBDeleteContactSetting(hContact, "CList", "Hidden"); else DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); - } while (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); + } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemAll, "Default1"); SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemUnknown, "Mask1"); return TRUE; @@ -331,7 +331,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM HIMAGELIST hIml; for (i=0; i < SIZEOF(hIcons); i++) DestroyIcon(hIcons[i]); - hIml=(HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); + hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); break; } @@ -339,7 +339,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM return FALSE; } -static UINT expertOnlyControls[]={IDC_STCHECKMARKS}; +static UINT expertOnlyControls[] = {IDC_STCHECKMARKS}; static int IgnoreOptInitialise(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; @@ -359,16 +359,16 @@ static int IgnoreOptInitialise(WPARAM wParam, LPARAM) static INT_PTR IsIgnored(WPARAM wParam, LPARAM lParam) { - DWORD mask=GetMask((HANDLE)wParam); + DWORD mask = GetMask((HANDLE)wParam); if (lParam<1 || lParam>IGNOREEVENT_MAX) return 1; return (mask>>(lParam-1))&1; } static INT_PTR Ignore(WPARAM wParam, LPARAM lParam) { - DWORD mask=GetMask((HANDLE)wParam); + DWORD mask = GetMask((HANDLE)wParam); if ((lParam<1 || lParam>IGNOREEVENT_MAX) && lParam != IGNOREEVENT_ALL) return 1; - if (lParam == IGNOREEVENT_ALL) mask=(1<IGNOREEVENT_MAX) && lParam != IGNOREEVENT_ALL) return 1; - if (lParam == IGNOREEVENT_ALL) mask=0; + if (lParam == IGNOREEVENT_ALL) mask = 0; else mask&=~(1<<(lParam-1)); DBWriteContactSettingDword((HANDLE)wParam, "Ignore", "Mask1", mask); return 0; @@ -416,11 +416,11 @@ static INT_PTR IgnoreRecvAuth(WPARAM wParam, LPARAM lParam) static int IgnoreAddedNotify(WPARAM, LPARAM lParam) { - DBEVENTINFO *dbei=(DBEVENTINFO*)lParam; + DBEVENTINFO *dbei = (DBEVENTINFO*)lParam; if (dbei && dbei->eventType == EVENTTYPE_ADDED && dbei->pBlob != NULL) { HANDLE hContact; - hContact=*((PHANDLE)(dbei->pBlob+sizeof(DWORD))); + hContact = *((PHANDLE)(dbei->pBlob+sizeof(DWORD))); if (CallService(MS_DB_CONTACT_IS, (WPARAM)hContact, 0) && IsIgnored((WPARAM)hContact, IGNOREEVENT_YOUWEREADDED)) return 1; } @@ -429,7 +429,7 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam) static int IgnoreModernOptInit(WPARAM wParam, LPARAM) { - static int iBoldControls[] = + static int iBoldControls[] = { IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST @@ -453,16 +453,16 @@ static int IgnoreModernOptInit(WPARAM wParam, LPARAM) int LoadIgnoreModule(void) { PROTOCOLDESCRIPTOR pd = { 0 }; - pd.cbSize=sizeof(pd); - pd.szName="Ignore"; - pd.type=PROTOTYPE_IGNORE; + pd.cbSize = sizeof(pd); + pd.szName = "Ignore"; + pd.type = PROTOTYPE_IGNORE; CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { if ( !CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)"Ignore")) CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)"Ignore"); - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } CreateServiceFunction("Ignore"PSR_MESSAGE, IgnoreRecvMessage); -- cgit v1.2.3