From 1925d3521846f4e6683d3d537cc41de9c9bd7250 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Feb 2014 19:01:03 +0000 Subject: "we don't need these variables" (c) Pink Floyd git-svn-id: http://svn.miranda-ng.org/main/trunk@8101 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/chat/clist.cpp | 20 +++----- src/modules/clist/clistevents.cpp | 3 +- src/modules/clist/clistmenus.cpp | 5 +- src/modules/clist/clistsettings.cpp | 14 +++-- src/modules/clist/clui.cpp | 77 +++++++++++----------------- src/modules/extraicons/DefaultExtraIcons.cpp | 9 ++-- src/modules/extraicons/extraicons.cpp | 6 +-- src/modules/protocols/protoaccs.cpp | 12 ++--- src/modules/srmm/statusicon.cpp | 5 +- 9 files changed, 58 insertions(+), 93 deletions(-) (limited to 'src/modules') diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp index 1400bc8d07..64af00ea2c 100644 --- a/src/modules/chat/clist.cpp +++ b/src/modules/chat/clist.cpp @@ -101,9 +101,8 @@ BOOL SetAllOffline(BOOL bHide, const char *pszModule) return TRUE; } -int RoomDoubleclicked(WPARAM wParam, LPARAM lParam) +int RoomDoubleclicked(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (!hContact) return 0; @@ -139,37 +138,34 @@ INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam) return RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0); } -INT_PTR JoinChat(WPARAM wParam, LPARAM lParam) +INT_PTR JoinChat(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact) { char *szProto = GetContactProto(hContact); if (szProto) { if (db_get_w(hContact, szProto, "Status", 0) == ID_STATUS_OFFLINE) - CallProtoService(szProto, PS_JOINCHAT, wParam, lParam); + CallProtoService(szProto, PS_JOINCHAT, hContact, lParam); else - RoomDoubleclicked(wParam, 0); + RoomDoubleclicked(hContact, 0); } } return 0; } -INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam) +INT_PTR LeaveChat(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact) { char *szProto = GetContactProto(hContact); if (szProto) - CallProtoService(szProto, PS_LEAVECHAT, wParam, lParam); + CallProtoService(szProto, PS_LEAVECHAT, hContact, lParam); } return 0; } -int PrebuildContactMenu(WPARAM wParam, LPARAM) +int PrebuildContactMenu(WPARAM hContact, LPARAM) { - MCONTACT hContact = wParam; - if (hContact == NULL) + if (hContact == 0) return 0; bool bEnabled = false; diff --git a/src/modules/clist/clistevents.cpp b/src/modules/clist/clistevents.cpp index afea5bcfc7..73b3abfb4c 100644 --- a/src/modules/clist/clistevents.cpp +++ b/src/modules/clist/clistevents.cpp @@ -382,9 +382,8 @@ static int RemoveEventsForContact(WPARAM wParam, LPARAM) return 0; } -static int CListEventSettingsChanged(WPARAM wParam, LPARAM lParam) +static int CListEventSettingsChanged(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; if (hContact == NULL && cws && cws->szModule && cws->szSetting && strcmp(cws->szModule, "CList") == 0) { if (strcmp(cws->szSetting, "DisableTrayFlash") == 0) diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index dd5b278f86..56b6cd7720 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -318,10 +318,9 @@ static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam) return (INT_PTR)menuHandle; } -static INT_PTR BuildContactMenu(WPARAM wParam, LPARAM) +static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM) { - MCONTACT hContact = wParam; - NotifyEventHooks(hPreBuildContactMenuEvent, (WPARAM)hContact, 0); + NotifyEventHooks(hPreBuildContactMenuEvent, hContact, 0); char *szProto = GetContactProto(hContact); diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp index 81dc9c3008..196daf1b51 100644 --- a/src/modules/clist/clistsettings.cpp +++ b/src/modules/clist/clistsettings.cpp @@ -156,11 +156,10 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode) return (cacheEntry == NULL) ? mir_tstrdup(buffer) : buffer; } -INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam) +INT_PTR GetContactDisplayName(WPARAM hContact, LPARAM lParam) { static char retVal[200]; ClcCacheEntry *cacheEntry = NULL; - MCONTACT hContact = wParam; if (lParam & GCDNF_UNICODE) return (INT_PTR)cli.pfnGetContactDisplayName(hContact, lParam & ~GCDNF_UNICODE); @@ -226,11 +225,10 @@ int ContactDeleted(WPARAM wParam, LPARAM) return 0; } -int ContactSettingChanged(WPARAM wParam, LPARAM lParam) +int ContactSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; DBVARIANT dbv; - MCONTACT hContact = wParam; // Early exit if (hContact == NULL) @@ -242,7 +240,7 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) cli.pfnInvalidateDisplayNameCacheEntry(hContact); if (!strcmp(cws->szSetting, "UIN") || !strcmp(cws->szSetting, "Nick") || !strcmp(cws->szSetting, "FirstName") || !strcmp(cws->szSetting, "LastName") || !strcmp(cws->szSetting, "e-mail")) { - CallService(MS_CLUI_CONTACTRENAMED, wParam, 0); + CallService(MS_CLUI_CONTACTRENAMED, hContact, 0); } else if (!strcmp(cws->szSetting, "Status")) { if (!db_get_b(hContact, "CList", "Hidden", 0)) { @@ -250,7 +248,7 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) // User's state is changing, and we are hideOffline-ing if (cws->value.wVal == ID_STATUS_OFFLINE) { cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(cws->szModule, cws->value.wVal, hContact), 0); - CallService(MS_CLUI_CONTACTDELETED, wParam, 0); + CallService(MS_CLUI_CONTACTDELETED, hContact, 0); mir_free(dbv.pszVal); return 0; } @@ -270,11 +268,11 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) if (!strcmp(cws->szModule, "CList")) { if (!strcmp(cws->szSetting, "Hidden")) { if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) { - char *szProto = GetContactProto(wParam); + char *szProto = GetContactProto(hContact); cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(szProto, szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact), 1); } else - CallService(MS_CLUI_CONTACTDELETED, wParam, 0); + CallService(MS_CLUI_CONTACTDELETED, hContact, 0); } if (!strcmp(cws->szSetting, "MyHandle")) cli.pfnInvalidateDisplayNameCacheEntry(hContact); diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp index 4242f183c8..3c332f7042 100644 --- a/src/modules/clist/clui.cpp +++ b/src/modules/clist/clui.cpp @@ -73,9 +73,8 @@ static int CluiModulesLoaded(WPARAM, LPARAM) // Happens on shutdown and standby. static void DisconnectAll() { - int nProto; - for (nProto = 0; nProto < accounts.getCount(); nProto++) - CallProtoServiceInt(NULL,accounts[nProto]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0); + for (int i = 0; i < accounts.getCount(); i++) + CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0); } static int CluiIconsChanged(WPARAM, LPARAM) @@ -89,12 +88,10 @@ static HGENMENU hRenameMenuItem; static int MenuItem_PreBuild(WPARAM, LPARAM) { TCHAR cls[128]; - HANDLE hItem; HWND hwndClist = GetFocus(); - GetClassName(hwndClist, cls, SIZEOF(cls)); hwndClist = (!lstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList; - hItem = (HANDLE) SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); + HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); Menu_ShowItem(hRenameMenuItem, hItem != 0); return 0; } @@ -102,12 +99,11 @@ static int MenuItem_PreBuild(WPARAM, LPARAM) static INT_PTR MenuItem_RenameContact(WPARAM, LPARAM) { TCHAR cls[128]; - HANDLE hItem; HWND hwndClist = GetFocus(); GetClassName(hwndClist, cls, SIZEOF(cls)); // worst case scenario, the rename is sent to the main contact list hwndClist = (!lstrcmp( _T(CLISTCONTROL_CLASS), cls)) ? hwndClist : cli.hwndContactList; - hItem = (HANDLE) SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); + HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0); if (hItem) { SetFocus(hwndClist); SendMessage(hwndClist, CLM_EDITLABEL, (WPARAM) hItem, 0); @@ -122,17 +118,12 @@ static INT_PTR CALLBACK AskForConfirmationDlgProc(HWND hWnd, UINT msg, WPARAM wP TranslateDialogDefault(hWnd); { LOGFONT lf; - HFONT hFont; - - hFont = (HFONT) SendDlgItemMessage(hWnd, IDYES, WM_GETFONT, 0, 0); + HFONT hFont = (HFONT)SendDlgItemMessage(hWnd, IDYES, WM_GETFONT, 0, 0); GetObject(hFont, sizeof(lf), &lf); lf.lfWeight = FW_BOLD; SendDlgItemMessage(hWnd, IDC_TOPLINE, WM_SETFONT, (WPARAM) CreateFontIndirect(&lf), 0); - } - { - TCHAR szFormat[256]; - TCHAR szFinal[256]; - + + TCHAR szFormat[256], szFinal[256]; GetDlgItemText(hWnd, IDC_TOPLINE, szFormat, SIZEOF(szFormat)); mir_sntprintf(szFinal, SIZEOF(szFinal), szFormat, cli.pfnGetContactDisplayName(lParam, 0)); SetDlgItemText(hWnd, IDC_TOPLINE, szFinal); @@ -173,56 +164,46 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam) //see notes about deleting contacts on PF1_SERVERCLIST servers in m_protosvc.h UINT_PTR action; - if (db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) && - !(GetKeyState(VK_SHIFT)&0x8000)) + if (db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) && !(GetKeyState(VK_SHIFT) & 0x8000)) // Ask user for confirmation, and if the contact should be archived (hidden, not deleted) action = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DELETECONTACT), (HWND) lParam, AskForConfirmationDlgProc, wParam); else action = IDYES; switch (action) { - - // Delete contact - case IDYES: - { - char *szProto = GetContactProto(wParam); - if (szProto != NULL) { - // Check if protocol uses server side lists - DWORD caps; - - caps = (DWORD) CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); - if (caps & PF1_SERVERCLIST) { - int status; - - status = CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0); - if (status == ID_STATUS_OFFLINE || (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) { - // Set a flag so we remember to delete the contact when the protocol goes online the next time - db_set_b(wParam, "CList", "Delete", 1); - MessageBox(NULL, - TranslateT("This contact is on an instant messaging system which stores its contact list on a central server. The contact will be removed from the server and from your contact list when you next connect to that network."), - TranslateT("Delete contact"), MB_ICONINFORMATION | MB_OK); - return 0; - } + case IDC_HIDE: // Archive contact + db_set_b(wParam, "CList", "Hidden", 1); + break; + + case IDYES: // Delete contact + char *szProto = GetContactProto(wParam); + if (szProto != NULL) { + // Check if protocol uses server side lists + DWORD caps = CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_1, 0); + if (caps & PF1_SERVERCLIST) { + int status = CallProtoServiceInt(NULL, szProto, PS_GETSTATUS, 0, 0); + if (status == ID_STATUS_OFFLINE || (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) { + // Set a flag so we remember to delete the contact when the protocol goes online the next time + db_set_b(wParam, "CList", "Delete", 1); + MessageBox(NULL, + TranslateT("This contact is on an instant messaging system which stores its contact list on a central server. The contact will be removed from the server and from your contact list when you next connect to that network."), + TranslateT("Delete contact"), MB_ICONINFORMATION | MB_OK); + return 0; } } - - CallService(MS_DB_CONTACT_DELETE, wParam, 0); } - break; - // Archive contact - case IDC_HIDE: - db_set_b(wParam, "CList", "Hidden", 1); + CallService(MS_DB_CONTACT_DELETE, wParam, 0); break; } return 0; } -static INT_PTR MenuItem_AddContactToList(WPARAM wParam, LPARAM) +static INT_PTR MenuItem_AddContactToList(WPARAM hContact, LPARAM) { ADDCONTACTSTRUCT acs = { 0 }; - acs.hContact = wParam; + acs.hContact = hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs); diff --git a/src/modules/extraicons/DefaultExtraIcons.cpp b/src/modules/extraicons/DefaultExtraIcons.cpp index a47ce5e7a9..7fa9fc17de 100644 --- a/src/modules/extraicons/DefaultExtraIcons.cpp +++ b/src/modules/extraicons/DefaultExtraIcons.cpp @@ -159,9 +159,8 @@ static void SetExtraIcons(MCONTACT hContact) } } -static int SettingChanged(WPARAM wParam, LPARAM lParam) +static int SettingChanged(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact == NULL) return 0; @@ -203,13 +202,12 @@ static int SettingChanged(WPARAM wParam, LPARAM lParam) return 0; } -static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) +static int DefaultOnClick(WPARAM hContact, LPARAM lParam, LPARAM param) { Info *p = (Info*)param; if (p == NULL) return 0; - MCONTACT hContact = wParam; if (hContact == NULL) return 0; @@ -277,9 +275,8 @@ static ProtoInfo* FindProto(const char *proto) return p; } -static int ProtocolApplyIcon(WPARAM wParam, LPARAM lParam) +static int ProtocolApplyIcon(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; char *proto = GetContactProto(hContact); if (IsEmpty(proto)) return 0; diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp index 7fae900021..037c97e142 100644 --- a/src/modules/extraicons/extraicons.cpp +++ b/src/modules/extraicons/extraicons.cpp @@ -246,9 +246,8 @@ int ClistExtraListRebuild(WPARAM wParam, LPARAM lParam) return 0; } -int ClistExtraImageApply(WPARAM wParam, LPARAM lParam) +int ClistExtraImageApply(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact == NULL) return 0; @@ -260,9 +259,8 @@ int ClistExtraImageApply(WPARAM wParam, LPARAM lParam) return 0; } -int ClistExtraClick(WPARAM wParam, LPARAM lParam) +int ClistExtraClick(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact == NULL) return 0; diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 94a96366e4..9f7480390b 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -197,24 +197,22 @@ void WriteDbAccounts() } ///////////////////////////////////////////////////////////////////////////////////////// -static int OnContactDeleted(WPARAM wParam, LPARAM lParam) +static int OnContactDeleted(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact) { - PROTOACCOUNT* pa = Proto_GetAccount(hContact); + PROTOACCOUNT *pa = Proto_GetAccount(hContact); if (Proto_IsAccountEnabled(pa) && pa->ppro) - pa->ppro->OnEvent(EV_PROTO_ONCONTACTDELETED, wParam, lParam); + pa->ppro->OnEvent(EV_PROTO_ONCONTACTDELETED, hContact, lParam); } return 0; } -static int OnDbSettingsChanged(WPARAM wParam, LPARAM lParam) +static int OnDbSettingsChanged(WPARAM hContact, LPARAM lParam) { - MCONTACT hContact = wParam; if (hContact) { PROTOACCOUNT* pa = Proto_GetAccount(hContact); if (Proto_IsAccountEnabled(pa) && pa->ppro) - pa->ppro->OnEvent(EV_PROTO_DBSETTINGSCHANGED, wParam, lParam); + pa->ppro->OnEvent(EV_PROTO_DBSETTINGSCHANGED, hContact, lParam); } return 0; } diff --git a/src/modules/srmm/statusicon.cpp b/src/modules/srmm/statusicon.cpp index 17d48c3a32..5ca2c8740e 100644 --- a/src/modules/srmm/statusicon.cpp +++ b/src/modules/srmm/statusicon.cpp @@ -78,7 +78,7 @@ static OBJLIST arIcons(3, CompareIcons); static HANDLE hHookIconsChanged; -INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam) +INT_PTR ModifyStatusIcon(WPARAM hContact, LPARAM lParam) { StatusIconData *sid = (StatusIconData *)lParam; if (sid == NULL || sid->cbSize != sizeof(StatusIconData)) @@ -88,7 +88,6 @@ INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam) if (p == NULL) return 1; - MCONTACT hContact = wParam; if (hContact == NULL) { mir_free(p->sid.szModule); mir_free(p->sid.szTooltip); @@ -115,7 +114,7 @@ INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam) mir_free(pc->tszTooltip); pc->tszTooltip = (sid->flags & MBF_UNICODE) ? mir_u2t(sid->wszTooltip) : mir_a2t(sid->szTooltip); - NotifyEventHooks(hHookIconsChanged, wParam, (LPARAM)p); + NotifyEventHooks(hHookIconsChanged, hContact, (LPARAM)p); return 0; } -- cgit v1.2.3