From 6895d635acb37ba42e53ba95ca3eee2ddbbef24d Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 28 Nov 2014 21:19:14 +0000 Subject: Massive code cleanup and fixes for a lot of warnings reported in #837 git-svn-id: http://svn.miranda-ng.org/main/trunk@11136 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/LotusNotify/src/LotusNotify.cpp | 134 +++++++++++++++----------------- 1 file changed, 63 insertions(+), 71 deletions(-) (limited to 'plugins/LotusNotify/src') diff --git a/plugins/LotusNotify/src/LotusNotify.cpp b/plugins/LotusNotify/src/LotusNotify.cpp index fd18559cf1..4898650d87 100644 --- a/plugins/LotusNotify/src/LotusNotify.cpp +++ b/plugins/LotusNotify/src/LotusNotify.cpp @@ -31,7 +31,7 @@ boolean volatile Plugin_Terminated = false; CRITICAL_SECTION checkthreadCS; HANDLE hMenuService = NULL; -HANDLE hMenuHandle = NULL; +HGENMENU hMenuHandle = NULL; HANDLE hCheckEvent = NULL; HANDLE hCheckHook = NULL; HANDLE hHookModulesLoaded = NULL; @@ -127,8 +127,7 @@ STATUS LNPUBLIC __stdcall EMCallBack (EMRECORD * pData) //It don't work (don't know why), and Mirandas Load function is called with value 1 or 0 as parameter... __declspec(dllexport)STATUS LNPUBLIC MainEntryPoint (void) { - STATUS rc; - rc = EMRegister1 (EM_GETPASSWORD, EM_REG_BEFORE | EM_REG_AFTER, EMCallBack, 0, &hLotusRegister); //Extension Manager must know that we are here + STATUS rc = EMRegister1 (EM_GETPASSWORD, EM_REG_BEFORE | EM_REG_AFTER, EMCallBack, 0, &hLotusRegister); //Extension Manager must know that we are here if(rc) { //Extension magager don't know who we are :( startuperror+=8; @@ -227,12 +226,12 @@ void init_pluginname() { char text[MAX_PATH], *p, *q; WIN32_FIND_DATAA ffd; - HANDLE hFind; // Try to find name of the file having original letter sizes GetModuleFileNameA(hInst, text, sizeof(text)); - if((hFind = FindFirstFileA(text, &ffd)) != INVALID_HANDLE_VALUE) { + HANDLE hFind = FindFirstFileA(text, &ffd); + if(hFind != INVALID_HANDLE_VALUE) { strncpy_s(text, SIZEOF(text), ffd.cFileName, strlen(ffd.cFileName)); FindClose(hFind); } @@ -319,8 +318,7 @@ BOOL checkFilters(TCHAR* str, int field) //subfunction called from popup plugin callback function void Click(HWND hWnd,BOOL execute) { - POPUPATT *pid=NULL; - pid = (POPUPATT*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)pid); + POPUPATT *pid = (POPUPATT*)PUGetPluginData(hWnd); if(settingOnceOnly&&settingNonClickedOnly) (getEl(pid->id))->clicked=TRUE;//add to msgs list @@ -370,8 +368,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA case UM_INITPOPUP: { - POPUPATT *pid=NULL; - pid = (POPUPATT*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)pid); + POPUPATT *pid = (POPUPATT*)PUGetPluginData(hWnd); addPopup(pid->id,hWnd); //PUDeletePopUp(hWnd); break; @@ -379,8 +376,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA case UM_FREEPLUGINDATA: { - POPUPATT * mpd = NULL; - mpd = (POPUPATT*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)mpd); + POPUPATT *mpd = (POPUPATT*)PUGetPluginData(hWnd); if (mpd > 0) free(mpd); return TRUE; //TRUE or FALSE is the same, it gets ignored. } @@ -537,7 +533,7 @@ void ErMsgByLotusCode(STATUS erno) //set menu avainability -static void LNEnableMenuItem(HANDLE hMenuItem, BOOL bEnable) +static void LNEnableMenuItem(HGENMENU hMenuItem, BOOL bEnable) { log_p(L"LNEnableMenuItem: bEnable=%d", bEnable); CLISTMENUITEM clmi = {0}; @@ -546,7 +542,7 @@ static void LNEnableMenuItem(HANDLE hMenuItem, BOOL bEnable) if ( !bEnable ) clmi.flags |= CMIF_GRAYED; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&clmi); + Menu_ModifyItem(hMenuItem, &clmi); } @@ -755,10 +751,9 @@ void checkthread(void*) field_copy_UNICODE[field_len] = '\0'; - WCHAR msgFrom[512]; - WCHAR msgSubject[512]; - ZeroMemory(msgFrom,512); - ZeroMemory(msgSubject,512); + WCHAR msgFrom[512], msgSubject[512]; + ZeroMemory(msgFrom,sizeof(msgFrom)); + ZeroMemory(msgSubject,sizeof(msgSubject)); if(wcslen(field_from_UNICODE) < 512 && wcslen(field_from_UNICODE) > 3 && wcsstr(field_from_UNICODE, L"CN=") == field_from_UNICODE) _tcsncpy_s(msgFrom, &(field_from_UNICODE[3]), wcscspn(field_from_UNICODE, L"/")-3 ); @@ -857,7 +852,7 @@ errorblock: //hooked notification from service that listning to check lotus -static int eventCheck(WPARAM wParam,LPARAM lParam) +static int eventCheck(WPARAM,LPARAM) { log(L"check event..."); check(); @@ -874,7 +869,7 @@ INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) //window timer callback function, called on timer event -VOID CALLBACK atTime(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) +void CALLBACK atTime(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { log(L"atTime: start"); BOOL b = KillTimer(hTimerWnd, idEvent); @@ -883,7 +878,7 @@ VOID CALLBACK atTime(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) check(); if(settingInterval != 0){ log_p(L"atTime: SetTimer settingInterval=%d", settingInterval * 60000); - SetTimer(hTimerWnd, TID, settingInterval * 60000, (TIMERPROC)atTime); + SetTimer(hTimerWnd, TID, settingInterval * 60000, atTime); } } } @@ -965,44 +960,49 @@ void lookupLotusDefaultSettings(HWND hwndDlg) //get variables values stored in db. void LoadSettings() { - DBVARIANT dbv; - char buff[128]; - int i=0; - settingInterval = (INT)db_get_dw(NULL, PLUGINNAME, "LNInterval", 15); settingInterval1 = (INT)db_get_dw(NULL, PLUGINNAME, "LNInterval1", 0); //if(!db_get(NULL, PLUGINNAME, "LNInterval1",&dbv)) // settingInterval1 = int(dbv.lVal); //db_free(&dbv); //settingInterval=dbv.lVal; - if(!db_get_s(NULL, PLUGINNAME, "LNDatabase", &dbv)) + if(!db_get_s(NULL, PLUGINNAME, "LNDatabase", &dbv)){ strncpy_s(settingDatabase, _countof(settingDatabase), dbv.pszVal, SIZEOF(settingDatabase)); - db_free(&dbv); - if(!db_get_s(NULL, PLUGINNAME, "LNServer", &dbv)) + db_free(&dbv); + } + if(!db_get_s(NULL, PLUGINNAME, "LNServer", &dbv)) { strncpy_s(settingServer, _countof(settingServer), dbv.pszVal, SIZEOF(settingServer)); - db_free(&dbv); - if(!db_get_s(NULL, PLUGINNAME, "LNServerSec", &dbv)) + db_free(&dbv); + } + if(!db_get_s(NULL, PLUGINNAME, "LNServerSec", &dbv)) { strncpy_s(settingServerSec, _countof(settingServerSec), dbv.pszVal, SIZEOF(settingServerSec)); - db_free(&dbv); - if(!db_get(NULL, PLUGINNAME, "LNPassword", &dbv)) + db_free(&dbv); + } + if(!db_get(NULL, PLUGINNAME, "LNPassword", &dbv)) { strncpy_s(settingPassword, _countof(settingPassword), dbv.pszVal, SIZEOF(settingPassword)); - db_free(&dbv); - if(!db_get_s(NULL, PLUGINNAME, "LNCommand", &dbv, DBVT_ASCIIZ)) + db_free(&dbv); + } + if(!db_get_s(NULL, PLUGINNAME, "LNCommand", &dbv, DBVT_ASCIIZ)) { strncpy_s(settingCommand, _countof(settingCommand), dbv.pszVal, SIZEOF(settingCommand)); - db_free(&dbv); - if(!db_get_s(NULL, PLUGINNAME, "LNParameters", &dbv, DBVT_ASCIIZ)) + db_free(&dbv); + } + if(!db_get_s(NULL, PLUGINNAME, "LNParameters", &dbv, DBVT_ASCIIZ)) { strncpy_s(settingParameters, _countof(settingParameters), dbv.pszVal, SIZEOF(settingParameters)); - db_free(&dbv); + db_free(&dbv); + } - if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSender",&dbv)) + if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSender",&dbv)) { _tcsncpy_s(settingFilterSender, dbv.ptszVal, _TRUNCATE); - db_free(&dbv); - if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSubject",&dbv)) + db_free(&dbv); + } + if(!db_get_ts(NULL, PLUGINNAME, "LNFilterSubject",&dbv)) { _tcsncpy_s(settingFilterSubject, dbv.ptszVal, _TRUNCATE); - db_free(&dbv); - if(!db_get_ts(NULL, PLUGINNAME, "LNFilterTo",&dbv)) + db_free(&dbv); + } + if(!db_get_ts(NULL, PLUGINNAME, "LNFilterTo",&dbv)) { _tcsncpy_s(settingFilterTo, dbv.ptszVal, _TRUNCATE); - db_free(&dbv); + db_free(&dbv); + } settingOnceOnly = db_get_b (NULL, PLUGINNAME, "LNOnceOnly",0); @@ -1015,8 +1015,10 @@ void LoadSettings() settingNewestID = (DWORD)db_get_dw(NULL, PLUGINNAME, "LNNewestID", 0); settingIniAnswer = db_get_b(NULL, PLUGINNAME, "LNIniAnswer", 0); settingIniCheck = db_get_b(NULL, PLUGINNAME, "LNIniCheck", 0); - - for(i = 0; i < STATUS_COUNT; i++) { + + DBVARIANT dbv; + for(int i = 0; i < STATUS_COUNT; i++) { + char buff[128]; mir_snprintf(buff, SIZEOF(buff), "LNStatus%d", i); settingStatus[i] = (db_get_b(0, PLUGINNAME, buff, 0) == 1); } @@ -1142,7 +1144,7 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L int i; char text[MAXENVVALUE]; i=SendDlgItemMessage(hwndDlg,IDC_SERVER,CB_GETCURSEL,0,0); - SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_GETLBTEXT,(WPARAM)i,(LONG)/* (LPSTR) */text); + SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_GETLBTEXT,(WPARAM)i,(LPARAM)text); SetDlgItemTextA(hwndDlg,IDC_SERVER,text); break; } @@ -1154,7 +1156,7 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_RESETCONTENT ,0, 0); fillServersList(hwndDlg); SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)settingServer); - SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_SELECTSTRING , -1, (LPARAM)(LPCSTR)settingServer); + SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_SELECTSTRING , -1, (LPARAM)settingServer); break; } } @@ -1263,7 +1265,6 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { char buff[128]; - int i=0; GetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer, sizeof(settingServer)); db_set_s(NULL, PLUGINNAME, "LNServer", settingServer ); db_set_s(NULL, PLUGINNAME, "LNServerSec", settingServerSec); @@ -1283,34 +1284,34 @@ INT_PTR CALLBACK DlgProcLotusNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(NULL, PLUGINNAME, "LNIniCheck", settingIniCheck); db_set_b(NULL, PLUGINNAME, "LNIniAnswer", settingIniAnswer); - for(i = 0; i < STATUS_COUNT ; i++){ + for(int i = 0; i < STATUS_COUNT ; i++){ mir_snprintf(buff, SIZEOF(buff), "LNStatus%d", i); settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE); db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0); } settingFilterSender[0] = 0; - for(i=0; i