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/clist/clistevents.cpp | 3 +- src/modules/clist/clistmenus.cpp | 5 +-- src/modules/clist/clistsettings.cpp | 14 +++---- src/modules/clist/clui.cpp | 77 ++++++++++++++----------------------- 4 files changed, 38 insertions(+), 61 deletions(-) (limited to 'src/modules/clist') 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); -- cgit v1.2.3