From 7ec44c6c0d9dcd8a5311ce1800830c2644947b1a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 4 Oct 2014 21:02:35 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@10694 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/miranda.cpp | 57 +++++++-------- src/core/modules.cpp | 2 +- src/modules/protocols/protoaccs.cpp | 61 +++++++--------- src/modules/protocols/protochains.cpp | 20 ++--- src/modules/protocols/protocols.cpp | 133 ++++++++++++++++------------------ src/modules/protocols/protoint.cpp | 9 +-- src/modules/protocols/protoopts.cpp | 29 ++++---- 7 files changed, 145 insertions(+), 166 deletions(-) (limited to 'src') diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index e814704e9e..efe76924ef 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -71,7 +71,7 @@ static INT_PTR srvSetExceptionFilter(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -typedef LONG (WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG); +typedef LONG(WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG); #define ThreadQuerySetWin32StartAddress 9 INT_PTR MirandaIsTerminated(WPARAM, LPARAM) @@ -86,7 +86,7 @@ static void __cdecl compactHeapsThread(void*) while (!Miranda_Terminated()) { HANDLE hHeaps[256]; DWORD hc; - SleepEx((1000*60)*5, TRUE); // every 5 minutes + SleepEx((1000 * 60) * 5, TRUE); // every 5 minutes hc = GetProcessHeaps(255, (PHANDLE)&hHeaps); if (hc != 0 && hc < 256) { DWORD j; @@ -96,12 +96,12 @@ static void __cdecl compactHeapsThread(void*) } //while } -void (*SetIdleCallback) (void) = NULL; +void(*SetIdleCallback) (void) = NULL; static INT_PTR SystemSetIdleCallback(WPARAM, LPARAM lParam) { if (lParam && SetIdleCallback == NULL) { - SetIdleCallback = (void (*)(void))lParam; + SetIdleCallback = (void(*)(void))lParam; return 1; } return 0; @@ -110,7 +110,7 @@ static INT_PTR SystemSetIdleCallback(WPARAM, LPARAM lParam) static DWORD dwEventTime = 0; void checkIdle(MSG * msg) { - switch(msg->message) { + switch (msg->message) { case WM_MOUSEACTIVATE: case WM_MOUSEMOVE: case WM_CHAR: @@ -145,16 +145,16 @@ static INT_PTR CALLBACK WaitForProcessDlgProc(HWND hwnd, UINT msg, WPARAM wParam break; case WM_TIMER: - if ( SendDlgItemMessage(hwnd, IDC_PROGRESSBAR, PBM_STEPIT, 0, 0) == MIRANDA_PROCESS_WAIT_STEPS) + if (SendDlgItemMessage(hwnd, IDC_PROGRESSBAR, PBM_STEPIT, 0, 0) == MIRANDA_PROCESS_WAIT_STEPS) EndDialog(hwnd, 0); - if ( WaitForSingleObject((HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA), 1) != WAIT_TIMEOUT) { + if (WaitForSingleObject((HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA), 1) != WAIT_TIMEOUT) { SendDlgItemMessage(hwnd, IDC_PROGRESSBAR, PBM_SETPOS, MIRANDA_PROCESS_WAIT_STEPS, 0); EndDialog(hwnd, 0); } break; case WM_COMMAND: - if ( LOWORD(wParam) == IDCANCEL) { + if (LOWORD(wParam) == IDCANCEL) { SendDlgItemMessage(hwnd, IDC_PROGRESSBAR, PBM_SETPOS, MIRANDA_PROCESS_WAIT_STEPS, 0); EndDialog(hwnd, 1); } @@ -166,7 +166,7 @@ static INT_PTR CALLBACK WaitForProcessDlgProc(HWND hwnd, UINT msg, WPARAM wParam int CheckRestart() { int result = 0; - LPCTSTR tszPID = CmdLine_GetOption( _T("restart")); + LPCTSTR tszPID = CmdLine_GetOption(_T("restart")); if (tszPID) { HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, _ttol(tszPID)); if (hProcess) { @@ -178,8 +178,7 @@ int CheckRestart() } static void crtErrorHandler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, uintptr_t) -{ -} +{} int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) { @@ -187,17 +186,17 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) hMainThreadId = GetCurrentThreadId(); _set_invalid_parameter_handler(&crtErrorHandler); - #ifdef _DEBUG - _CrtSetReportMode(_CRT_ASSERT, 0); - #endif +#ifdef _DEBUG + _CrtSetReportMode(_CRT_ASSERT, 0); +#endif CmdLine_Parse(cmdLine); setlocale(LC_ALL, ""); - #ifdef _DEBUG - if ( CmdLine_GetOption( _T("memdebug"))) +#ifdef _DEBUG + if (CmdLine_GetOption(_T("memdebug"))) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); - #endif +#endif if (IsWinVerVistaPlus()) { HINSTANCE hDwmApi = LoadLibraryA("dwmapi.dll"); @@ -256,7 +255,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) rc = MsgWaitForMultipleObjectsEx(waitObjectCount, hWaitObjects, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE); if (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0 + waitObjectCount) { rc -= WAIT_OBJECT_0; - CallService(pszWaitServices[rc], (WPARAM) hWaitObjects[rc], 0); + CallService(pszWaitServices[rc], (WPARAM)hWaitObjects[rc], 0); } // while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { @@ -321,10 +320,10 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) UINT blockSize; VS_FIXEDFILEINFO *vsffi; VerQueryValue(pVerInfo, _T("\\"), (PVOID*)&vsffi, &blockSize); - DWORD ver = (((vsffi->dwProductVersionMS>>16)&0xFF)<<24)| - ((vsffi->dwProductVersionMS&0xFF)<<16)| - (((vsffi->dwProductVersionLS>>16)&0xFF)<<8)| - (vsffi->dwProductVersionLS&0xFF); + DWORD ver = (((vsffi->dwProductVersionMS >> 16) & 0xFF) << 24) | + ((vsffi->dwProductVersionMS & 0xFF) << 16) | + (((vsffi->dwProductVersionLS >> 16) & 0xFF) << 8) | + (vsffi->dwProductVersionLS & 0xFF); return (INT_PTR)ver; } @@ -361,15 +360,15 @@ static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam) UINT blockSize; VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\ProductVersion"), (LPVOID*)&productVersion, &blockSize); strncpy((char*)lParam, _T2A(productVersion), wParam); - #if defined(_WIN64) - strcat_s((char*)lParam, wParam, " x64"); - #endif +#if defined(_WIN64) + strcat_s((char*)lParam, wParam, " x64"); +#endif return 0; } INT_PTR WaitOnHandle(WPARAM wParam, LPARAM lParam) { - if (waitObjectCount >= MAXIMUM_WAIT_OBJECTS-1) + if (waitObjectCount >= MAXIMUM_WAIT_OBJECTS - 1) return 1; hWaitObjects[waitObjectCount] = (HANDLE)wParam; @@ -382,7 +381,7 @@ static INT_PTR RemoveWait(WPARAM wParam, LPARAM) { int i; - for (i=0;iszModuleName = mir_strdup(dbv.pszVal); db_free(&dbv); - _itoa(OFFSET_VISIBLE+i, buf, 10); + _itoa(OFFSET_VISIBLE + i, buf, 10); pa->bIsVisible = db_get_dw(NULL, "Protocols", buf, 1) != 0; - _itoa(OFFSET_PROTOPOS+i, buf, 10); + _itoa(OFFSET_PROTOPOS + i, buf, 10); pa->iOrder = db_get_dw(NULL, "Protocols", buf, 1); if (ver >= 4) { db_free(&dbv); - _itoa(OFFSET_NAME+i, buf, 10); + _itoa(OFFSET_NAME + i, buf, 10); if (!db_get_ts(NULL, "Protocols", buf, &dbv)) { pa->tszAccountName = mir_tstrdup(dbv.ptszVal); db_free(&dbv); } - _itoa(OFFSET_ENABLED+i, buf, 10); + _itoa(OFFSET_ENABLED + i, buf, 10); pa->bIsEnabled = db_get_dw(NULL, "Protocols", buf, 1) != 0; if (!db_get_s(NULL, pa->szModuleName, "AM_BaseProto", &dbv)) { @@ -135,7 +135,7 @@ typedef struct int arrlen; char **pszSettingName; } - enumDB_ProtoProcParam; +enumDB_ProtoProcParam; static int enumDB_ProtoProc(const char* szSetting, LPARAM lParam) { @@ -144,7 +144,7 @@ static int enumDB_ProtoProc(const char* szSetting, LPARAM lParam) p->arrlen++; p->pszSettingName = (char**)mir_realloc(p->pszSettingName, p->arrlen*sizeof(char*)); - p->pszSettingName[ p->arrlen-1 ] = mir_strdup(szSetting); + p->pszSettingName[p->arrlen - 1] = mir_strdup(szSetting); } return 0; } @@ -163,7 +163,7 @@ void WriteDbAccounts() // delete all settings if (param.arrlen) { - for (int i=0; i < param.arrlen; i++) { + for (int i = 0; i < param.arrlen; i++) { db_unset(0, "Protocols", param.pszSettingName[i]); mir_free(param.pszSettingName[i]); } @@ -171,23 +171,23 @@ void WriteDbAccounts() } // write new data - for (int i=0; i < accounts.getCount(); i++) { + for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; - char buf[ 20 ]; + char buf[20]; _itoa(i, buf, 10); db_set_s(NULL, "Protocols", buf, pa->szModuleName); - _itoa(OFFSET_PROTOPOS+i, buf, 10); + _itoa(OFFSET_PROTOPOS + i, buf, 10); db_set_dw(NULL, "Protocols", buf, pa->iOrder); - _itoa(OFFSET_VISIBLE+i, buf, 10); + _itoa(OFFSET_VISIBLE + i, buf, 10); db_set_dw(NULL, "Protocols", buf, pa->bIsVisible); - _itoa(OFFSET_ENABLED+i, buf, 10); + _itoa(OFFSET_ENABLED + i, buf, 10); db_set_dw(NULL, "Protocols", buf, pa->bIsEnabled); - _itoa(OFFSET_NAME+i, buf, 10); + _itoa(OFFSET_NAME + i, buf, 10); db_set_ts(NULL, "Protocols", buf, pa->tszAccountName); } @@ -222,7 +222,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) { int count = 0; - for (int i=0; i < accounts.getCount(); i++) { + for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; if (!pa->ppro || !Proto_IsAccountEnabled(pa)) continue; @@ -240,7 +240,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) CallService(MS_PROTO_SHOWACCMGR, 0, 0); } // This is for pack creators with a profile with predefined accounts - else if(db_get_b(NULL, "FirstRun", "ForceShowAccManager", 0)) { + else if (db_get_b(NULL, "FirstRun", "ForceShowAccManager", 0)) { CallService(MS_PROTO_SHOWACCMGR, 0, 0); db_unset(NULL, "FirstRun", "ForceShowAccManager"); } @@ -252,19 +252,16 @@ static int UninitializeStaticAccounts(WPARAM, LPARAM) for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; if (pa->ppro && Proto_IsAccountEnabled(pa)) - if (pa->ppro->OnEvent(EV_PROTO_ONREADYTOEXIT, 0, 0) != 0) + if (pa->ppro->OnEvent(EV_PROTO_ONREADYTOEXIT, 0, 0) != TRUE) return 1; } - return 0; -} -static int ShutdownStaticAccounts(WPARAM, LPARAM) -{ for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; if (pa->ppro && Proto_IsAccountEnabled(pa)) pa->ppro->OnEvent(EV_PROTO_ONEXIT, 0, 0); } + return 0; } @@ -272,7 +269,7 @@ int LoadAccountsModule(void) { bModuleInitialized = TRUE; - for (int i=0; i < accounts.getCount(); i++) { + for (int i = 0; i < accounts.getCount(); i++) { PROTOACCOUNT *pa = accounts[i]; pa->bDynDisabled = !Proto_IsProtocolLoaded(pa->szProtoName); if (pa->ppro) @@ -287,7 +284,6 @@ int LoadAccountsModule(void) hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, InitializeStaticAccounts); hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, UninitializeStaticAccounts); - hHooks[1] = HookEvent(ME_SYSTEM_SHUTDOWN, ShutdownStaticAccounts); hHooks[2] = HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted); hHooks[3] = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnDbSettingsChanged); return 0; @@ -355,7 +351,7 @@ static INT_PTR stub18(PROTO_INTERFACE* ppi, WPARAM, LPARAM lParam) static INT_PTR stub19(PROTO_INTERFACE* ppi, WPARAM, LPARAM lParam) { - return (INT_PTR)ppi->CreateExtendedSearchUI ((HWND)lParam); + return (INT_PTR)ppi->CreateExtendedSearchUI((HWND)lParam); } static INT_PTR stub22(PROTO_INTERFACE* ppi, WPARAM, LPARAM lParam) @@ -393,7 +389,7 @@ static INT_PTR stub43(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) PROTO_AVATAR_INFORMATIONW tmp = { 0 }; tmp.cbSize = sizeof(tmp); tmp.hContact = p->hContact; - int result = CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_GETAVATARINFOW, wParam, (LPARAM)&tmp); + int result = CallProtoServiceInt(NULL, ppi->m_szModuleName, PS_GETAVATARINFOW, wParam, (LPARAM)&tmp); p->format = tmp.format; @@ -408,9 +404,8 @@ static INT_PTR stub43(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) static INT_PTR stub44(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) { wchar_t* buf = (wchar_t*)_alloca(sizeof(wchar_t) * (lParam + 1)); - int result = CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_GETMYAVATARW, WPARAM(buf), lParam); - if (result == 0) - { + int result = CallProtoServiceInt(NULL, ppi->m_szModuleName, PS_GETMYAVATARW, WPARAM(buf), lParam); + if (result == 0) { wchar_t* filename = (wchar_t*)_alloca(sizeof(wchar_t) * (lParam + 1)); wcscpy(filename, buf); GetShortPathNameW(buf, filename, lParam + 1); @@ -423,7 +418,7 @@ static INT_PTR stub44(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) static INT_PTR stub45(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) { - return CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_SETMYAVATARW, wParam, (LPARAM)(LPCTSTR)StrConvT((char*)lParam)); + return CallProtoServiceInt(NULL, ppi->m_szModuleName, PS_SETMYAVATARW, wParam, (LPARAM)(LPCTSTR)StrConvT((char*)lParam)); } static HANDLE CreateProtoServiceEx(const char* szModule, const char* szService, MIRANDASERVICEOBJ pFunc, void* param) @@ -586,8 +581,8 @@ void UnloadAccountsModule() { if (!bModuleInitialized) return; - for (int i = accounts.getCount()-1; i >= 0; i--) { - PROTOACCOUNT *pa = accounts[ i ]; + for (int i = accounts.getCount() - 1; i >= 0; i--) { + PROTOACCOUNT *pa = accounts[i]; UnloadAccount(pa, false, false); accounts.remove(i); } @@ -601,8 +596,8 @@ void UnloadAccountsModule() void BuildProtoMenus() { - for (int i=0; i < accounts.getCount(); i++) { - PROTOACCOUNT *pa = accounts[ i ]; + for (int i = 0; i < accounts.getCount(); i++) { + PROTOACCOUNT *pa = accounts[i]; if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0) continue; diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp index 16bf1cb4db..0e07f03ca4 100644 --- a/src/modules/protocols/protochains.cpp +++ b/src/modules/protocols/protochains.cpp @@ -35,7 +35,7 @@ static int GetProtocolP(MCONTACT hContact, char *szBuf, int cbLen) DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact); if (cc && cc->szProto != NULL) { strncpy(szBuf, cc->szProto, cbLen); - szBuf[cbLen-1] = 0; + szBuf[cbLen - 1] = 0; return 0; } @@ -61,15 +61,15 @@ INT_PTR CallContactService(MCONTACT hContact, const char *szProtoService, WPARAM INT_PTR ret; CCSDATA ccs = { hContact, szProtoService, wParam, lParam }; - for (int i=0; i < filters.getCount(); i++) { - if ((ret = CallProtoServiceInt(hContact, filters[i]->szName, szProtoService, i+1, (LPARAM)&ccs)) != CALLSERVICE_NOTFOUND) { + for (int i = 0; i < filters.getCount(); i++) { + if ((ret = CallProtoServiceInt(hContact, filters[i]->szName, szProtoService, i + 1, (LPARAM)&ccs)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } } char szProto[40]; - if ( GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto))) + if (GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); @@ -97,7 +97,7 @@ INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam) return 1; for (int i = wParam; i < filters.getCount(); i++) { - if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) { + if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i + 1, lParam)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } @@ -137,8 +137,8 @@ static INT_PTR Proto_RecvChain(WPARAM wParam, LPARAM lParam) } else wParam--; - for (int i = wParam-1; i >= 0; i--) - if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) + for (int i = wParam - 1; i >= 0; i--) + if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i + 1, lParam)) != CALLSERVICE_NOTFOUND) //chain was started, exit return ret; @@ -196,9 +196,9 @@ static INT_PTR Proto_IsProtoOnContact(WPARAM wParam, LPARAM lParam) if (!_stricmp(szProto, szContactProto)) return -1; - for (int i=0; i < filters.getCount(); i++) + for (int i = 0; i < filters.getCount(); i++) if (!strcmp(szProto, filters[i]->szName)) - return i+1; + return i + 1; return 0; } @@ -224,7 +224,7 @@ static INT_PTR Proto_AddToContact(WPARAM wParam, LPARAM lParam) static INT_PTR Proto_RemoveFromContact(WPARAM wParam, LPARAM lParam) { - switch ( Proto_IsProtoOnContact(wParam, lParam)) { + switch (Proto_IsProtoOnContact(wParam, lParam)) { case 0: return 1; case -1: diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 83004cbac7..4cd162a278 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -36,7 +36,7 @@ typedef struct const char* name; int id; } - TServiceListItem; +TServiceListItem; static int CompareServiceItems(const TServiceListItem* p1, const TServiceListItem* p2) { @@ -193,7 +193,7 @@ static INT_PTR Proto_AuthRecv(WPARAM wParam, LPARAM lParam) DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = (char*)wParam; dbei.timestamp = pre->timestamp; - dbei.flags = pre->flags & (PREF_CREATEREAD?DBEF_READ:0); + dbei.flags = pre->flags & (PREF_CREATEREAD ? DBEF_READ : 0); dbei.flags |= (pre->flags & PREF_UTF) ? DBEF_UTF : 0; dbei.eventType = EVENTTYPE_AUTHREQUEST; dbei.cbBlob = pre->lParam; @@ -209,7 +209,7 @@ static int Proto_ValidTypingContact(MCONTACT hContact, char *szProto) if (!hContact || !szProto) return 0; - return (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SUPPORTTYPING) ? 1 : 0; + return (CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SUPPORTTYPING) ? 1 : 0; } static INT_PTR Proto_SelfIsTyping(WPARAM wParam, LPARAM lParam) @@ -220,7 +220,7 @@ static INT_PTR Proto_SelfIsTyping(WPARAM wParam, LPARAM lParam) return 0; if (Proto_ValidTypingContact(wParam, szProto)) - CallProtoServiceInt(NULL,szProto, PSS_USERISTYPING, wParam, lParam); + CallProtoServiceInt(NULL, szProto, PSS_USERISTYPING, wParam, lParam); } return 0; @@ -260,11 +260,11 @@ char** __fastcall Proto_FilesMatrixA(wchar_t **files) if (files == NULL) return NULL; int count = 0; - while (files[ count++ ]); + while (files[count++]); char** filesA = (char**)mir_alloc(count * sizeof(char*)); - for (int i=0; i < count; i++) - filesA[ i ] = mir_u2a(files[ i ]); + for (int i = 0; i < count; i++) + filesA[i] = mir_u2a(files[i]); return filesA; } @@ -274,11 +274,11 @@ static wchar_t** __fastcall Proto_FilesMatrixU(char **files) if (files == NULL) return NULL; int count = 0; - while (files[ count++ ]); + while (files[count++]); wchar_t** filesU = (wchar_t**)mir_alloc(count * sizeof(wchar_t*)); - for (int i=0; i < count; i++) - filesU[ i ] = mir_a2u(files[ i ]); + for (int i = 0; i < count; i++) + filesU[i] = mir_a2u(files[i]); return filesU; } @@ -388,7 +388,7 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService); if (item) { - switch(item->id) { + switch (item->id) { case 1: if (ppi->m_iVersion > 1 || !(((PROTOSEARCHRESULT*)lParam)->flags & PSR_UNICODE)) return (INT_PTR)ppi->AddToList(wParam, (PROTOSEARCHRESULT*)lParam); @@ -416,21 +416,21 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char case 3: return (INT_PTR)ppi->Authorize((HANDLE)wParam); case 4: if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvT((char*)lParam)); + return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvT((char*)lParam)); return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, (PROTOCHAR*)lParam); case 5: return (INT_PTR)ppi->AuthRecv(hContact, (PROTORECVEVENT*)lParam); case 6: if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->AuthRequest(hContact, StrConvT((char*)lParam)); + return (INT_PTR)ppi->AuthRequest(hContact, StrConvT((char*)lParam)); return (INT_PTR)ppi->AuthRequest(hContact, (PROTOCHAR*)lParam); case 8: if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvT((char*)lParam)); + return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvT((char*)lParam)); return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam); case 9: return (INT_PTR)ppi->FileCancel(hContact, (HANDLE)wParam); case 10: if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvT((char*)lParam)); + return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvT((char*)lParam)); return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam); case 11: { PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam; @@ -457,13 +457,12 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char case 17: { PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam; if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->SearchByName(StrConvT((char*)psbn->pszNick), - StrConvT((char*)psbn->pszFirstName), StrConvT((char*)psbn->pszLastName)); + return (INT_PTR)ppi->SearchByName(StrConvT((char*)psbn->pszNick), StrConvT((char*)psbn->pszFirstName), StrConvT((char*)psbn->pszLastName)); else return (INT_PTR)ppi->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName); } case 18: return (INT_PTR)ppi->SearchAdvanced((HWND)lParam); - case 19: return (INT_PTR)ppi->CreateExtendedSearchUI ((HWND)lParam); + case 19: return (INT_PTR)ppi->CreateExtendedSearchUI((HWND)lParam); case 20: return (INT_PTR)ppi->RecvContacts(hContact, (PROTORECVEVENT*)lParam); case 21: return (INT_PTR)ppi->RecvFile(hContact, (PROTOFILEEVENT*)lParam); case 22: return (INT_PTR)ppi->RecvMsg(hContact, (PROTORECVEVENT*)lParam); @@ -516,8 +515,7 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char case 105: { PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam; if (ppi->m_iVersion > 1) - return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, - (const PROTOCHAR**)&pfr->szFilename); + return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, (const PROTOCHAR**)&pfr->szFilename); else { char* szFname = mir_t2a(pfr->szFilename); INT_PTR res = (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, @@ -579,39 +577,34 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService); if (!item) return res; - switch(item->id) { - case 100: - return (INT_PTR)pa->ppro->SetAwayMsg(wParam, (TCHAR*)lParam); - case 102: { - CCSDATA *ccs = (CCSDATA*)lParam; - return (INT_PTR)pa->ppro->SendFile(ccs->hContact, (TCHAR*)ccs->wParam, (TCHAR**)ccs->lParam); - } - case 103: { - CCSDATA *ccs = (CCSDATA*)lParam; - return (INT_PTR)pa->ppro->FileAllow(ccs->hContact, (HANDLE)ccs->wParam, (TCHAR*)ccs->lParam); - } - case 104: { - CCSDATA *ccs = (CCSDATA*)lParam; - return (INT_PTR)pa->ppro->FileDeny(ccs->hContact, (HANDLE)ccs->wParam, (TCHAR*)ccs->lParam); - } - case 105: { + CCSDATA *ccs = (CCSDATA*)lParam; + switch (item->id) { + case 100: + return (INT_PTR)pa->ppro->SetAwayMsg(wParam, (TCHAR*)lParam); + case 102: + return (INT_PTR)pa->ppro->SendFile(ccs->hContact, (TCHAR*)ccs->wParam, (TCHAR**)ccs->lParam); + case 103: + return (INT_PTR)pa->ppro->FileAllow(ccs->hContact, (HANDLE)ccs->wParam, (TCHAR*)ccs->lParam); + case 104: + return (INT_PTR)pa->ppro->FileDeny(ccs->hContact, (HANDLE)ccs->wParam, (TCHAR*)ccs->lParam); + case 105: + { PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam; return (INT_PTR)pa->ppro->FileResume((HANDLE)wParam, &pfr->action, &pfr->szFilename); } - case 106: { - CCSDATA *ccs = (CCSDATA*)lParam; - return (INT_PTR)pa->ppro->AuthRequest(ccs->hContact, (const TCHAR*)ccs->lParam); - } - case 107: - return (INT_PTR)pa->ppro->AuthDeny((HANDLE)wParam, (const TCHAR*)lParam); - case 108: - return (INT_PTR)pa->ppro->SearchBasic((const TCHAR*)lParam); - case 109: { + case 106: + return (INT_PTR)pa->ppro->AuthRequest(ccs->hContact, (const TCHAR*)ccs->lParam); + case 107: + return (INT_PTR)pa->ppro->AuthDeny((HANDLE)wParam, (const TCHAR*)lParam); + case 108: + return (INT_PTR)pa->ppro->SearchBasic((const TCHAR*)lParam); + case 109: + { PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam; return (INT_PTR)pa->ppro->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName); } - case 110: - return (INT_PTR)pa->ppro->SearchByEmail((const TCHAR*)lParam); + case 110: + return (INT_PTR)pa->ppro->SearchByEmail((const TCHAR*)lParam); } } @@ -632,17 +625,17 @@ int LoadProtocolsModule(void) { bModuleInitialized = TRUE; - if ( LoadProtoChains()) + if (LoadProtoChains()) return 1; - InsertServiceListItem( 1, PS_ADDTOLIST); - InsertServiceListItem( 2, PS_ADDTOLISTBYEVENT); - InsertServiceListItem( 3, PS_AUTHALLOW); - InsertServiceListItem( 4, PS_AUTHDENY); - InsertServiceListItem( 5, PSR_AUTH); - InsertServiceListItem( 6, PSS_AUTHREQUEST); - InsertServiceListItem( 8, PSS_FILEALLOW); - InsertServiceListItem( 9, PSS_FILECANCEL); + InsertServiceListItem(1, PS_ADDTOLIST); + InsertServiceListItem(2, PS_ADDTOLISTBYEVENT); + InsertServiceListItem(3, PS_AUTHALLOW); + InsertServiceListItem(4, PS_AUTHDENY); + InsertServiceListItem(5, PSR_AUTH); + InsertServiceListItem(6, PSS_AUTHREQUEST); + InsertServiceListItem(8, PSS_FILEALLOW); + InsertServiceListItem(9, PSS_FILECANCEL); InsertServiceListItem(10, PSS_FILEDENY); InsertServiceListItem(11, PS_FILERESUME); InsertServiceListItem(12, PS_GETCAPS); @@ -684,23 +677,23 @@ int LoadProtocolsModule(void) hTypeEvent = CreateHookableEvent(ME_PROTO_CONTACTISTYPING); hAccListChanged = CreateHookableEvent(ME_PROTO_ACCLISTCHANGED); - CreateServiceFunction(MS_PROTO_BROADCASTACK, Proto_BroadcastAck); + CreateServiceFunction(MS_PROTO_BROADCASTACK, Proto_BroadcastAck); CreateServiceFunction(MS_PROTO_ISPROTOCOLLOADED, srvProto_IsLoaded); - CreateServiceFunction(MS_PROTO_ENUMPROTOS, Proto_EnumProtocols); - CreateServiceFunction(MS_PROTO_REGISTERMODULE, Proto_RegisterModule); - CreateServiceFunction(MS_PROTO_SELFISTYPING, Proto_SelfIsTyping); - CreateServiceFunction(MS_PROTO_CONTACTISTYPING, Proto_ContactIsTyping); + CreateServiceFunction(MS_PROTO_ENUMPROTOS, Proto_EnumProtocols); + CreateServiceFunction(MS_PROTO_REGISTERMODULE, Proto_RegisterModule); + CreateServiceFunction(MS_PROTO_SELFISTYPING, Proto_SelfIsTyping); + CreateServiceFunction(MS_PROTO_CONTACTISTYPING, Proto_ContactIsTyping); - CreateServiceFunction(MS_PROTO_RECVMSG, Proto_RecvMessage); - CreateServiceFunction(MS_PROTO_AUTHRECV, Proto_AuthRecv); + CreateServiceFunction(MS_PROTO_RECVMSG, Proto_RecvMessage); + CreateServiceFunction(MS_PROTO_AUTHRECV, Proto_AuthRecv); - CreateServiceFunction("Proto/EnumProtocols", Proto_EnumAccounts); - CreateServiceFunction(MS_PROTO_ENUMACCOUNTS, Proto_EnumAccounts); - CreateServiceFunction(MS_PROTO_CREATEACCOUNT, srvProto_CreateAccount); - CreateServiceFunction(MS_PROTO_GETACCOUNT, srvProto_GetAccount); + CreateServiceFunction("Proto/EnumProtocols", Proto_EnumAccounts); + CreateServiceFunction(MS_PROTO_ENUMACCOUNTS, Proto_EnumAccounts); + CreateServiceFunction(MS_PROTO_CREATEACCOUNT, srvProto_CreateAccount); + CreateServiceFunction(MS_PROTO_GETACCOUNT, srvProto_GetAccount); CreateServiceFunction(MS_PROTO_ISACCOUNTENABLED, srvProto_IsAccountEnabled); - CreateServiceFunction(MS_PROTO_ISACCOUNTLOCKED, srvProto_IsAccountLocked); + CreateServiceFunction(MS_PROTO_ISACCOUNTLOCKED, srvProto_IsAccountLocked); return LoadProtoOptions(); } @@ -715,14 +708,14 @@ void UnloadProtocolsModule() } if (protos.getCount()) { - for (int i=0; i < protos.getCount(); i++) { + for (int i = 0; i < protos.getCount(); i++) { mir_free(protos[i]->szName); mir_free(protos[i]); } protos.destroy(); } - for (int i=0; i < serviceItems.getCount(); i++) + for (int i = 0; i < serviceItems.getCount(); i++) mir_free(serviceItems[i]); serviceItems.destroy(); } diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp index d74ec1a5c4..e97f25c38d 100644 --- a/src/modules/protocols/protoint.cpp +++ b/src/modules/protocols/protoint.cpp @@ -33,8 +33,7 @@ void FreeFilesMatrix(TCHAR ***files) // Free each filename in the pointer array TCHAR **pFile = *files; - while (*pFile != NULL) - { + while (*pFile != NULL) { mir_free(*pFile); *pFile = NULL; pFile++; @@ -85,7 +84,6 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath) { CCSDATA ccs = { hContact, PSS_FILEALLOW, (WPARAM)hTransfer, (LPARAM)szPath }; - ccs.lParam = (LPARAM)mir_t2a(szPath); HANDLE res = (HANDLE)ProtoCallService(m_szModuleName, PSS_FILEALLOW, 0, (LPARAM)&ccs); mir_free((char*)ccs.lParam); @@ -101,7 +99,6 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason) { CCSDATA ccs = { hContact, PSS_FILEDENY, (WPARAM)hTransfer, (LPARAM)szReason }; - ccs.lParam = (LPARAM)mir_t2a(szReason); int res = (int)ProtoCallService(m_szModuleName, PSS_FILEDENY, 0, (LPARAM)&ccs); mir_free((char*)ccs.lParam); @@ -111,7 +108,6 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename) { PROTOFILERESUME pfr = { *action, *szFilename }; - pfr.szFilename = (PROTOCHAR*)mir_t2a(pfr.szFilename); int res = (int)ProtoCallService(m_szModuleName, PS_FILERESUME, (WPARAM)hTransfer, (LPARAM)&pfr); mir_free((PROTOCHAR*)*szFilename); @@ -149,7 +145,6 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE HANDLE __cdecl SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName) { PROTOSEARCHBYNAME psn; - psn.pszNick = (PROTOCHAR*)mir_t2a(nick); psn.pszFirstName = (PROTOCHAR*)mir_t2a(firstName); psn.pszLastName = (PROTOCHAR*)mir_t2a(lastName); @@ -261,7 +256,7 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE int __cdecl OnEvent(PROTOEVENTTYPE, WPARAM, LPARAM) { - return 0; + return 1; } }; diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index a60f91558e..ce801ca8fe 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -254,7 +254,7 @@ struct TAccListData static void sttClickButton(HWND hwndDlg, int idcButton) { - if (IsWindowEnabled( GetDlgItem(hwndDlg, idcButton))) + if (IsWindowEnabled(GetDlgItem(hwndDlg, idcButton))) PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(idcButton, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, idcButton)); } @@ -280,12 +280,10 @@ static LRESULT CALLBACK sttEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_KILLFOCUS: - { - int length = GetWindowTextLength(hwnd) + 1; - TCHAR *str = (TCHAR*)mir_alloc(sizeof(TCHAR) * length); - GetWindowText(hwnd, str, length); - SendMessage(GetParent(GetParent(hwnd)), WM_COMMAND, MAKEWPARAM(GetWindowLongPtr(GetParent(hwnd), GWL_ID), LBN_MY_RENAME), (LPARAM)str); - } + int length = GetWindowTextLength(hwnd) + 1; + TCHAR *str = (TCHAR*)mir_alloc(sizeof(TCHAR) * length); + GetWindowText(hwnd, str, length); + SendMessage(GetParent(GetParent(hwnd)), WM_COMMAND, MAKEWPARAM(GetWindowLongPtr(GetParent(hwnd), GWL_ID), LBN_MY_RENAME), (LPARAM)str); DestroyWindow(hwnd); return 0; } @@ -342,8 +340,8 @@ static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA break; case WM_MY_RENAME: + RECT rc; { - RECT rc; struct TAccMgrData *parentDat = (struct TAccMgrData *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwnd, ListBox_GetCurSel(hwnd)); if (!pa || pa->bOldProto || pa->bDynDisabled) @@ -559,10 +557,9 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM return TRUE; case WM_DRAWITEM: + HBRUSH hbrBack; + SIZE sz; { - HBRUSH hbrBack; - SIZE sz; - int cxIcon = GetSystemMetrics(SM_CXSMICON); int cyIcon = GetSystemMetrics(SM_CYSMICON); @@ -834,11 +831,11 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM break; case IDC_ADD: - { - AccFormDlgParam param = { PRAC_ADDED, NULL }; - if (IDOK == DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)¶m)) - SendMessage(hwndDlg, WM_MY_REFRESH, 0, 0); - } + { + AccFormDlgParam param = { PRAC_ADDED, NULL }; + if (IDOK == DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)¶m)) + SendMessage(hwndDlg, WM_MY_REFRESH, 0, 0); + } break; case IDC_EDIT: -- cgit v1.2.3