From 769b537b5e1a99fc53aa7296fd2b21dc77a4071c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 16 Aug 2015 20:33:13 +0000 Subject: name conflicts solved git-svn-id: http://svn.miranda-ng.org/main/trunk@14971 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BASS_interface/src/Main.cpp | 8 +- plugins/Boltun/src/boltun.cpp | 331 +++---- plugins/BuddyPounce/src/dialog.cpp | 54 +- plugins/Clist_modern/src/cluiframes.cpp | 40 +- plugins/Clist_nicer/src/alphablend.cpp | 5 +- plugins/Clist_nicer/src/viewmodes.cpp | 136 +-- plugins/CmdLine/src/mimcmd_handlers.cpp | 1107 ++++++++++------------- plugins/Db3x_mmap/src/ui.cpp | 4 +- plugins/DbEditorPP/src/main_window.cpp | 6 +- plugins/Dropbox/src/http_request.h | 1 - plugins/FavContacts/src/menu.cpp | 63 +- plugins/FloatingContacts/src/main.cpp | 8 +- plugins/IEView/src/IEView.cpp | 16 +- plugins/IgnoreState/src/options.cpp | 71 +- plugins/KeyboardNotify/src/options.cpp | 8 +- plugins/MirandaG15/src/CAppletManager.cpp | 903 +++++++++--------- plugins/MsgPopup/src/options.cpp | 10 +- plugins/Msg_Export/src/FileViewer.cpp | 2 +- plugins/Msg_Export/src/utils.cpp | 609 +++++-------- plugins/NewEventNotify/src/main.cpp | 9 +- plugins/NewEventNotify/src/menuitem.cpp | 6 +- plugins/NewEventNotify/src/options.cpp | 2 +- plugins/NewEventNotify/src/stdafx.h | 2 +- plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 4 +- 24 files changed, 1490 insertions(+), 1915 deletions(-) (limited to 'plugins') diff --git a/plugins/BASS_interface/src/Main.cpp b/plugins/BASS_interface/src/Main.cpp index 8283ee78ce..4fcefa4b21 100644 --- a/plugins/BASS_interface/src/Main.cpp +++ b/plugins/BASS_interface/src/Main.cpp @@ -487,9 +487,9 @@ void DeleteFrame() CallService(MS_CLIST_FRAMES_REMOVEFRAME, (WPARAM)frame_id, 0); } -void LoadBassLibrary(TCHAR CurrBassPath[MAX_PATH]) +void LoadBassLibrary(const TCHAR *ptszPath) { - hBass = LoadLibrary(CurrBassPath); + hBass = LoadLibrary(ptszPath); if (hBass != NULL) { newBass = (BASS_SetConfig(BASS_CONFIG_DEV_DEFAULT, TRUE) != 0); // will use new "Default" device @@ -506,7 +506,7 @@ void LoadBassLibrary(TCHAR CurrBassPath[MAX_PATH]) sndLimSnd = db_get_b(NULL, ModuleName, OPT_MAXCHAN, MAXCHAN); if (sndLimSnd > MAXCHAN) sndLimSnd = MAXCHAN; - + TimeWrd1 = db_get_w(NULL, ModuleName, OPT_TIME1, 0); TimeWrd2 = db_get_w(NULL, ModuleName, OPT_TIME2, 0); QuietTime = db_get_b(NULL, ModuleName, OPT_QUIETTIME, 0); @@ -537,8 +537,8 @@ int OnFoldersChanged(WPARAM, LPARAM) UnhookEvent(hPlaySound); DeleteFrame(); } - LoadBassLibrary(CurrBassPath); + LoadBassLibrary(CurrBassPath); return 0; } diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index a1dc7f0a8c..c9352c3a33 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -31,7 +31,7 @@ TalkBot* bot = NULL; HINSTANCE hInst; BOOL blInit = FALSE; UINT pTimer = 0; -TCHAR *path; +TCHAR tszPath[MAX_PATH]; PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), @@ -57,24 +57,22 @@ static HGENMENU hMenuItemAutoChat, hMenuItemNotToChat, hMenuItemStartChatting; void UpdateEngine() { - if (bot) - { + if (bot) { bot->SetSilent(Config.EngineStaySilent); bot->SetLowercase(Config.EngineMakeLowerCase); bot->SetUnderstandAlways(Config.EngineUnderstandAlways); } } -TCHAR* GetFullName(const TCHAR* filename) +TCHAR* GetFullName(const TCHAR *filename) { size_t flen = mir_tstrlen(filename); TCHAR* fullname = const_cast(filename); - if (!_tcschr(filename, _T(':'))) - { - size_t plen = mir_tstrlen(path); + if (!_tcschr(filename, _T(':'))) { + size_t plen = mir_tstrlen(tszPath); fullname = new TCHAR[plen + flen + 1]; fullname[0] = NULL; - mir_tstrcat(fullname, path); + mir_tstrcat(fullname, tszPath); mir_tstrcat(fullname, filename); } return fullname; @@ -85,17 +83,15 @@ static bool LoadMind(const TCHAR* filename, int &line) TCHAR* fullname = GetFullName(filename); HCURSOR newCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)); HCURSOR oldCur = SetCursor(newCur); -#ifdef DEBUG_LOAD_TIME + #ifdef DEBUG_LOAD_TIME unsigned __int64 t = __rdtsc(); -#endif + #endif Mind* mind = new Mind(); line = -1; - try - { + try { mind->Load(fullname); } - catch (Mind::CorruptedMind c) - { + catch (Mind::CorruptedMind c) { line = c.line; delete mind; if (fullname != filename) @@ -103,8 +99,7 @@ static bool LoadMind(const TCHAR* filename, int &line) SetCursor(oldCur); return false; } - catch (...) - { + catch (...) { delete mind; if (fullname != filename) delete[] fullname; @@ -114,52 +109,45 @@ static bool LoadMind(const TCHAR* filename, int &line) if (fullname != filename) delete[] fullname; -#ifdef DEBUG_LOAD_TIME + #ifdef DEBUG_LOAD_TIME t = __rdtsc() - t; char dest[101]; mir_snprintf(dest, _countof(dest), "%I64d ticks\n", t / 3200000); MessageBoxA(NULL, dest, NULL, 0); //exit(0); -#endif + #endif SetCursor(oldCur); HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(IDR_SMILES), _T("SMILES")); - if (!hRes) - { + if (!hRes) { delete mind; return false; } DWORD size = SizeofResource(hInst, hRes); - if (!size) - { + if (!size) { delete mind; return false; } HGLOBAL hGlob = LoadResource(hInst, hRes); - if (!hGlob) - { + if (!hGlob) { delete mind; return false; } void *data = LockResource(hGlob); - if (!data) - { + if (!data) { FreeResource(hGlob); delete mind; return false; } bool res = true; - try - { + try { mind->LoadSmiles(data, size); } - catch (...) - { + catch (...) { res = false; } UnlockResource(data); FreeResource(hGlob); - if (!res) - { + if (!res) { delete mind; return false; } @@ -187,8 +175,7 @@ static bool BoltunAutoChat(MCONTACT hContact) if (Config.TalkWithEverybody) return true; - if (Config.TalkEveryoneWhileAway) - { + if (Config.TalkEveryoneWhileAway) { int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); if (status == ID_STATUS_AWAY || status == ID_STATUS_DND || @@ -264,8 +251,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR { BOOL bTranslated = FALSE; static bool loading = true; - switch (uMsg) - { + switch (uMsg) { case WM_INITDIALOG: loading = true; TranslateDialogDefault(hwndDlg); @@ -288,11 +274,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR case WM_COMMAND: if (LOWORD(wParam) == IDC_EVERYBODY && HIWORD(wParam) == BN_CLICKED) UpdateEverybodyCheckboxes(hwndDlg); - if (!loading) - { + if (!loading) { bool notify = true; - switch (LOWORD(wParam)) - { + switch (LOWORD(wParam)) { case IDC_WARNTXT: case IDC_WAITTIME: case IDC_THINKTIME: @@ -305,39 +289,38 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR } break; case WM_NOTIFY: - { - NMHDR* nmhdr = (NMHDR*)lParam; - switch (nmhdr->code) - { - case PSN_APPLY: - case PSN_KILLACTIVE: { - Config.TalkWithEverybody = IsDlgButtonChecked(hwndDlg, IDC_EVERYBODY) == BST_CHECKED ? TRUE : FALSE; - Config.TalkWithNotInList = IsDlgButtonChecked(hwndDlg, IDC_NOTINLIST) == BST_CHECKED ? TRUE : FALSE; - Config.TalkEveryoneWhileAway = IsDlgButtonChecked(hwndDlg, IDC_AUTOAWAY) == BST_CHECKED ? TRUE : FALSE; - Config.TalkWarnContacts = IsDlgButtonChecked(hwndDlg, IDC_WARN) == BST_CHECKED ? TRUE : FALSE; - Config.MarkAsRead = IsDlgButtonChecked(hwndDlg, IDC_MARKREAD) == BST_CHECKED ? TRUE : FALSE; - Config.PauseDepends = IsDlgButtonChecked(hwndDlg, IDC_PAUSEDEPENDS) == BST_CHECKED ? TRUE : FALSE; - Config.PauseRandom = IsDlgButtonChecked(hwndDlg, IDC_PAUSERANDOM) == BST_CHECKED ? TRUE : FALSE; - Config.AnswerPauseTime = GetDlgItemInt(hwndDlg, IDC_WAITTIME, &bTranslated, FALSE); - if (!bTranslated) - Config.AnswerPauseTime = 2; - Config.AnswerThinkTime = GetDlgItemInt(hwndDlg, IDC_THINKTIME, &bTranslated, FALSE); - if (!bTranslated) - Config.AnswerThinkTime = 4; - TCHAR c[MAX_WARN_TEXT]; - bTranslated = GetDlgItemText(hwndDlg, IDC_WARNTXT, c, _countof(c)); - if (bTranslated) - Config.WarnText = c; - else - Config.WarnText = TranslateTS(DEFAULT_WARN_TEXT); - } - return TRUE; + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) { + case PSN_APPLY: + case PSN_KILLACTIVE: + { + Config.TalkWithEverybody = IsDlgButtonChecked(hwndDlg, IDC_EVERYBODY) == BST_CHECKED ? TRUE : FALSE; + Config.TalkWithNotInList = IsDlgButtonChecked(hwndDlg, IDC_NOTINLIST) == BST_CHECKED ? TRUE : FALSE; + Config.TalkEveryoneWhileAway = IsDlgButtonChecked(hwndDlg, IDC_AUTOAWAY) == BST_CHECKED ? TRUE : FALSE; + Config.TalkWarnContacts = IsDlgButtonChecked(hwndDlg, IDC_WARN) == BST_CHECKED ? TRUE : FALSE; + Config.MarkAsRead = IsDlgButtonChecked(hwndDlg, IDC_MARKREAD) == BST_CHECKED ? TRUE : FALSE; + Config.PauseDepends = IsDlgButtonChecked(hwndDlg, IDC_PAUSEDEPENDS) == BST_CHECKED ? TRUE : FALSE; + Config.PauseRandom = IsDlgButtonChecked(hwndDlg, IDC_PAUSERANDOM) == BST_CHECKED ? TRUE : FALSE; + Config.AnswerPauseTime = GetDlgItemInt(hwndDlg, IDC_WAITTIME, &bTranslated, FALSE); + if (!bTranslated) + Config.AnswerPauseTime = 2; + Config.AnswerThinkTime = GetDlgItemInt(hwndDlg, IDC_THINKTIME, &bTranslated, FALSE); + if (!bTranslated) + Config.AnswerThinkTime = 4; + TCHAR c[MAX_WARN_TEXT]; + bTranslated = GetDlgItemText(hwndDlg, IDC_WARNTXT, c, _countof(c)); + if (bTranslated) + Config.WarnText = c; + else + Config.WarnText = TranslateTS(DEFAULT_WARN_TEXT); + } + return TRUE; + } + break; } break; } - break; - } return 0; } @@ -355,8 +338,7 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP BOOL bTranslated = FALSE; static bool loading = true; static int changeCount = 0; - switch (uMsg) - { + switch (uMsg) { case WM_INITDIALOG: loading = true; TranslateDialogDefault(hwndDlg); @@ -373,75 +355,70 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP if (param == IDC_ENGINE_SILENT && HIWORD(wParam) == BN_CLICKED) UpdateUnderstandAlwaysCheckbox(hwndDlg); OPENFILENAME ofn; - switch (param) - { + switch (param) { case IDC_BTNPATH: - { - const size_t fileNameSize = 5000; - TCHAR *filename = new TCHAR[fileNameSize]; - TCHAR *fullname = GetFullName(Config.MindFileName); - mir_tstrcpy(filename, fullname); - if (fullname != Config.MindFileName) - delete[] fullname; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = GetParent(hwndDlg); - - TCHAR* mind = TranslateTS(MIND_FILE_DESC); - TCHAR* anyfile = TranslateTS(ALL_FILES_DESC); - size_t l = mir_tstrlen(MIND_DIALOG_FILTER) - + mir_tstrlen(mind) + mir_tstrlen(anyfile); - TCHAR *filt = new TCHAR[l]; - mir_sntprintf(filt, l, MIND_DIALOG_FILTER, mind, anyfile); - for (size_t i = 0; i < l; i++) - if (filt[i] == '\1') - filt[i] = '\0'; - ofn.lpstrFilter = filt; - - ofn.lpstrFile = filename; - ofn.nMaxFile = fileNameSize; - ofn.Flags = OFN_FILEMUSTEXIST; - ofn.lpstrInitialDir = path; - if (!GetOpenFileName(&ofn)) - { - delete[] filename; - delete[] filt; - break; - } - delete[] filt; - TCHAR* origf = filename; - TCHAR* f = filename; - TCHAR* p = path; - while (*p && *f) { - TCHAR p1 = (TCHAR)CharLower((TCHAR*)(long)*p++); - TCHAR f1 = (TCHAR)CharLower((TCHAR*)(long)*f++); - if (p1 != f1) + const size_t fileNameSize = 5000; + TCHAR *filename = new TCHAR[fileNameSize]; + TCHAR *fullname = GetFullName(Config.MindFileName); + mir_tstrcpy(filename, fullname); + if (fullname != Config.MindFileName) + delete[] fullname; + + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = GetParent(hwndDlg); + + TCHAR* mind = TranslateTS(MIND_FILE_DESC); + TCHAR* anyfile = TranslateTS(ALL_FILES_DESC); + size_t l = mir_tstrlen(MIND_DIALOG_FILTER) + + mir_tstrlen(mind) + mir_tstrlen(anyfile); + TCHAR *filt = new TCHAR[l]; + mir_sntprintf(filt, l, MIND_DIALOG_FILTER, mind, anyfile); + for (size_t i = 0; i < l; i++) + if (filt[i] == '\1') + filt[i] = '\0'; + ofn.lpstrFilter = filt; + + ofn.lpstrFile = filename; + ofn.nMaxFile = fileNameSize; + ofn.Flags = OFN_FILEMUSTEXIST; + ofn.lpstrInitialDir = tszPath; + if (!GetOpenFileName(&ofn)) { + delete[] filename; + delete[] filt; break; + } + delete[] filt; + TCHAR* origf = filename; + TCHAR* f = filename; + TCHAR* p = tszPath; + while (*p && *f) { + TCHAR p1 = (TCHAR)CharLower((TCHAR*)(long)*p++); + TCHAR f1 = (TCHAR)CharLower((TCHAR*)(long)*f++); + if (p1 != f1) + break; + } + if (!*p) + filename = f; + Config.MindFileName = filename; + SetDlgItemText(hwndDlg, IDC_MINDFILE, filename); + delete[] origf; } - if (!*p) - filename = f; - Config.MindFileName = filename; - SetDlgItemText(hwndDlg, IDC_MINDFILE, filename); - delete[] origf; - } case IDC_BTNRELOAD: - { - const TCHAR *c = Config.MindFileName; - int line; - bTranslated = blInit = LoadMind(c, line); - if (!bTranslated) { - TCHAR message[5000]; - mir_sntprintf(message, _countof(message), TranslateTS(FAILED_TO_LOAD_BASE), line, c); - MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK); + const TCHAR *c = Config.MindFileName; + int line; + bTranslated = blInit = LoadMind(c, line); + if (!bTranslated) { + TCHAR message[5000]; + mir_sntprintf(message, _countof(message), TranslateTS(FAILED_TO_LOAD_BASE), line, c); + MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK); + } + break; } - break; - } default: - if (!loading) - { + if (!loading) { if (param == IDC_MINDFILE/* && HIWORD(wParam) != EN_CHANGE*/) break; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -449,30 +426,29 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP } break; case WM_NOTIFY: - { - NMHDR* nmhdr = (NMHDR*)lParam; - switch (nmhdr->code) { - case PSN_APPLY: - case PSN_KILLACTIVE: - { - Config.EngineStaySilent = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_SILENT) == BST_CHECKED ? TRUE : FALSE; - Config.EngineMakeLowerCase = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_LOWERCASE) == BST_CHECKED ? TRUE : FALSE; - Config.EngineUnderstandAlways = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS) == BST_CHECKED ? TRUE : FALSE; - UpdateEngine(); - TCHAR c[MAX_MIND_FILE]; - bTranslated = GetDlgItemText(hwndDlg, IDC_MINDFILE, c, _countof(c)); - if (bTranslated) - Config.MindFileName = c; - else - Config.MindFileName = DEFAULT_MIND_FILE; - } - return TRUE; + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) { + case PSN_APPLY: + case PSN_KILLACTIVE: + { + Config.EngineStaySilent = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_SILENT) == BST_CHECKED ? TRUE : FALSE; + Config.EngineMakeLowerCase = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_LOWERCASE) == BST_CHECKED ? TRUE : FALSE; + Config.EngineUnderstandAlways = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS) == BST_CHECKED ? TRUE : FALSE; + UpdateEngine(); + TCHAR c[MAX_MIND_FILE]; + bTranslated = GetDlgItemText(hwndDlg, IDC_MINDFILE, c, _countof(c)); + if (bTranslated) + Config.MindFileName = c; + else + Config.MindFileName = DEFAULT_MIND_FILE; + } + return TRUE; + } + break; } break; } - break; - } return 0; } @@ -500,23 +476,18 @@ static int ContactClick(WPARAM hContact, LPARAM, BOOL clickNotToChat) BOOL boltunautochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, FALSE); BOOL boltunnottochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, FALSE); - if (clickNotToChat) - { + if (clickNotToChat) { boltunnottochat = !boltunnottochat; - if (boltunnottochat) - { + if (boltunnottochat) { boltunautochat = FALSE; } } - else - { + else { boltunautochat = !boltunautochat; - if (boltunautochat) - { + if (boltunautochat) { boltunnottochat = FALSE; } - else - { + else { db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, FALSE); } } @@ -572,20 +543,8 @@ extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); - path = new TCHAR[MAX_PATH]; - int len = GetModuleFileName(hInst, path, MAX_PATH); - if (len > MAX_PATH) - { - delete[] path; - TCHAR *path = new TCHAR[len]; - int len2 = GetModuleFileName(hInst, path, len); - if (len2 != len) - { - delete[] path; - return false; - } - } - *(_tcsrchr(path, _T('\\')) + 1) = _T('\0'); + GetModuleFileName(hInst, tszPath, _countof(tszPath)); + *(_tcsrchr(tszPath, _T('\\')) + 1) = _T('\0'); /*initialize miranda hooks and services on options dialog*/ HookEvent(ME_OPT_INITIALISE, MessageOptInit); @@ -618,8 +577,7 @@ extern "C" int __declspec(dllexport) Load(void) int line; blInit = LoadMind(Config.MindFileName, line); - if (!blInit) - { + if (!blInit) { TCHAR path[2000]; mir_sntprintf(path, _countof(path), TranslateTS(FAILED_TO_LOAD_BASE), line, (const TCHAR*)Config.MindFileName); MessageBox(NULL, path, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK); @@ -631,24 +589,21 @@ extern "C" int __declspec(dllexport) Unload(void) { if (pTimer) KillTimer(NULL, pTimer); - if (blInit) - { -#if 0 //No need to save, we don't have studying algorithm - if(Config.MindFileName && !SaveMind(Config.MindFileName)) - { + if (blInit) { + #if 0 //No need to save, we don't have studying algorithm + if (Config.MindFileName && !SaveMind(Config.MindFileName)) { //This causes errors with development core when calling MessageBox. //It seems that it's now a Boltun problem. //So in case of saving error we will remain silent -#if 0 + #if 0 TCHAR path[MAX_PATH]; mir_sntprintf(path, _countof(path), TranslateTS(FAILED_TO_SAVE_BASE), (const TCHAR*)Config.MindFileName); TCHAR* err = TranslateTS(BOLTUN_ERROR); - MessageBox(NULL, path, err, MB_ICONERROR|MB_TASKMODAL|MB_OK);*/ -#endif + MessageBox(NULL, path, err, MB_ICONERROR | MB_TASKMODAL | MB_OK); */ + #endif } -#endif + #endif delete bot; } - delete[] path; return 0; } diff --git a/plugins/BuddyPounce/src/dialog.cpp b/plugins/BuddyPounce/src/dialog.cpp index 0f02f3037d..4d579257db 100644 --- a/plugins/BuddyPounce/src/dialog.cpp +++ b/plugins/BuddyPounce/src/dialog.cpp @@ -189,31 +189,27 @@ void deletePounce(MCONTACT hContact) db_unset(hContact, modname, "FileToSend"); } -INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); + TCHAR msg[1024]; - switch(msg) { + switch(uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); hContact = lParam; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); getDefaultMessage(hwnd, IDC_MESSAGE, hContact); - { - TCHAR msg[1024]; - mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); - SetDlgItemText(hwnd, GRP_MSG, msg); - } + mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + SetDlgItemText(hwnd, GRP_MSG, msg); return FALSE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_MESSAGE: if (HIWORD(wParam) == EN_CHANGE) { - int length; - TCHAR msg[1024]; - length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); } @@ -243,11 +239,12 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LP return FALSE; } -INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { windowInfo *wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + TCHAR msg[1024]; - switch(msg) { + switch(uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); wi = (windowInfo *)mir_alloc(sizeof(windowInfo)); @@ -260,11 +257,10 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l wi->SendWhenThey = 0; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)wi); getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact); - { - TCHAR msg[1024]; - mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); - SetDlgItemText(hwnd, GRP_MSG, msg); - } + + mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + SetDlgItemText(hwnd, GRP_MSG, msg); + populateSettingsList(GetDlgItem(hwnd, IDC_SETTINGS)); populateContacts(wi->hContact, GetDlgItem(hwnd, IDC_CONTACTS)); SendDlgItemMessage(hwnd, IDC_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG((short)1024, (short)0)); @@ -275,9 +271,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l switch(LOWORD(wParam)) { case IDC_MESSAGE: if (HIWORD(wParam) == EN_CHANGE) { - int length; - TCHAR msg[1024]; - length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); } @@ -320,11 +314,10 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case IDC_DEFAULT: getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact); - { - TCHAR msg[1024]; - mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); - SetDlgItemText(hwnd, GRP_MSG, msg); - } + + mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + SetDlgItemText(hwnd, GRP_MSG, msg); + db_set_w(wi->hContact, modname, "SendIfMyStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfMyStatusIsFLAG",0)); db_set_w(wi->hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfTheirStatusIsFLAG",0)); db_set_b(wi->hContact, modname, "Reuse",(BYTE)db_get_b(NULL, modname, "Reuse",0)); @@ -382,14 +375,15 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l return FALSE; } -INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + TCHAR msg[1024]; + + switch(uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); { windowInfo *wi = (windowInfo *)mir_alloc(sizeof(windowInfo)); - TCHAR msg[1024]; wi->hContact = 0; wi->SendIfMy = 0; wi->SendWhenThey = 0; @@ -438,9 +432,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L switch(LOWORD(wParam)) { case IDC_MESSAGE: if (HIWORD(wParam) == EN_CHANGE) { - int length; - TCHAR msg[1024]; - length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); mir_sntprintf(msg, _countof(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); diff --git a/plugins/Clist_modern/src/cluiframes.cpp b/plugins/Clist_modern/src/cluiframes.cpp index ae06306bb0..db0fceeede 100644 --- a/plugins/Clist_modern/src/cluiframes.cpp +++ b/plugins/Clist_modern/src/cluiframes.cpp @@ -80,13 +80,14 @@ static int GapBetweenFrames = 1; BOOLEAN bMoveTogether; int recurs_prevent = 0; -static BOOL PreventSizeCalling = FALSE; +static BOOL sttPreventSizeCalling = FALSE; + +static HBITMAP sttBmpBackground; +static int sttBackgroundBmpUse; +static COLORREF sttBkColour; +static COLORREF sttSelBkColour; +static BOOL sttBkUseWinColours; -static HBITMAP hBmpBackground; -static int backgroundBmpUse; -static COLORREF bkColour; -static COLORREF SelBkColour; -static BOOL bkUseWinColours; BYTE AlignCOLLIconToLeft; //will hide frame icon COLORREF sttGetColor(char * module, char * color, COLORREF defColor); //for old multiwindow @@ -2355,21 +2356,21 @@ int OnFrameTitleBarBackgroundChange(WPARAM, LPARAM) { AlignCOLLIconToLeft = db_get_b(NULL, "FrameTitleBar", "AlignCOLLIconToLeft", CLCDEFAULT_COLLICONTOLEFT); - bkColour = sttGetColor("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); - bkUseWinColours = db_get_b(NULL, "FrameTitleBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); - SelBkColour = sttGetColor("FrameTitleBar", "TextColour", CLCDEFAULT_TEXTCOLOUR); + sttBkColour = sttGetColor("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); + sttBkUseWinColours = db_get_b(NULL, "FrameTitleBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); + sttSelBkColour = sttGetColor("FrameTitleBar", "TextColour", CLCDEFAULT_TEXTCOLOUR); - if (hBmpBackground) { - DeleteObject(hBmpBackground); - hBmpBackground = NULL; + if (sttBmpBackground) { + DeleteObject(sttBmpBackground); + sttBmpBackground = NULL; } if (g_CluiData.fDisableSkinEngine) { if (db_get_b(NULL, "FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) { ptrT tszBitmapName(db_get_tsa(NULL, "FrameTitleBar", "BkBitmap")); if (tszBitmapName) - hBmpBackground = Bitmap_Load(tszBitmapName); + sttBmpBackground = Bitmap_Load(tszBitmapName); } - backgroundBmpUse = db_get_w(NULL, "FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE); + sttBackgroundBmpUse = db_get_w(NULL, "FrameTitleBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE); } } @@ -2526,14 +2527,14 @@ int DrawTitleBar(HDC hdcMem2, RECT *rect, int Frameid) } else { if (g_CluiData.fDisableSkinEngine) { - if (!hBmpBackground && bkUseWinColours && xpt_IsThemed(_hFrameTitleTheme)) { + if (!sttBmpBackground && sttBkUseWinColours && xpt_IsThemed(_hFrameTitleTheme)) { int state = CS_ACTIVE; // if (GetForegroundWindow() != pcli->hwndContactList) state = CS_INACTIVE; xpt_DrawThemeBackground(_hFrameTitleTheme, hdcMem, WP_SMALLCAPTION, state, &rc, &rc); bThemed = TRUE; } else - DrawBackGround(g_pfwFrames[pos].TitleBar.hwnd, hdcMem, hBmpBackground, bkColour, backgroundBmpUse); + DrawBackGround(g_pfwFrames[pos].TitleBar.hwnd, hdcMem, sttBmpBackground, sttBkColour, sttBackgroundBmpUse); } else if (!g_CluiData.fLayered) { ske_BltBackImage(g_pfwFrames[pos].TitleBar.hwnd, hdcMem, &rc); @@ -2544,7 +2545,7 @@ int DrawTitleBar(HDC hdcMem2, RECT *rect, int Frameid) if (bThemed) SetTextColor(hdcMem, GetSysColor(COLOR_CAPTIONTEXT)); else - SetTextColor(hdcMem, SelBkColour); + SetTextColor(hdcMem, sttSelBkColour); RECT textrc = rc; if (!AlignCOLLIconToLeft) { @@ -3411,7 +3412,10 @@ static INT_PTR UnloadMainMenu() int UnLoadCLUIFramesModule(void) { _fCluiFramesModuleNotStarted = TRUE; - if (hBmpBackground) { DeleteObject(hBmpBackground); hBmpBackground = NULL; } + if (sttBmpBackground) { + DeleteObject(sttBmpBackground); + sttBmpBackground = NULL; + } CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); CLUIFramesStoreAllFrames(); diff --git a/plugins/Clist_nicer/src/alphablend.cpp b/plugins/Clist_nicer/src/alphablend.cpp index 0906dc512f..d14d6b36d6 100644 --- a/plugins/Clist_nicer/src/alphablend.cpp +++ b/plugins/Clist_nicer/src/alphablend.cpp @@ -84,7 +84,6 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor if (rc == NULL) return; - BLENDFUNCTION bf; int ulBitmapWidth, ulBitmapHeight; UCHAR ubAlpha = 0xFF; UCHAR ubRedFinal = 0xFF; @@ -158,6 +157,7 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor basecolor = argb_from_cola(revcolref(basecolor), alpha); basecolor2 = argb_from_cola(revcolref(basecolor2), alpha); + BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; @@ -166,6 +166,7 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor HDC hdc = CreateCompatibleDC(hdcwnd); if (!hdc) return; + HBITMAP hbm = CreateCompatibleBitmap(hdcwnd, width, height); HBITMAP hbmOld = reinterpret_cast(SelectObject(hdc, hbm)); GdiGradientFill(hdc, tvtx, 2, &grect, 1, (FLG_GRADIENT & GRADIENT_TB || FLG_GRADIENT & GRADIENT_BT) ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H); @@ -260,6 +261,8 @@ void DrawAlpha(HDC hdcwnd, PRECT rc, DWORD basecolor, int alpha, DWORD basecolor } } } + + BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = (UCHAR)(basecolor >> 24); diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 5e8ed3b24a..74107561e0 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -32,16 +32,16 @@ extern HPEN g_hPenCLUIFrames; extern FRAMEWND *wndFrameViewMode; typedef int (__cdecl *pfnEnumCallback)(char *szName); -static HWND clvmHwnd = 0; -static int clvm_curItem = 0; +static HWND sttClvmHwnd = 0; +static int sttClvm_curItem = 0; HMENU hViewModeMenu = 0; +static int nullImage; static HWND hwndSelector = 0; -static HIMAGELIST himlViewModes = 0; static HANDLE hInfoItem = 0; -static int nullImage; -static DWORD stickyStatusMask = 0; -static char g_szModename[2048]; +static HIMAGELIST himlViewModes = 0; +static DWORD sttStickyStatusMask = 0; +static char sttModeName[2048]; static int g_ViewModeOptDlg = FALSE; @@ -79,7 +79,7 @@ void CLVM_EnumModes(pfnEnumCallback EnumCallback) int FillModes(char *szsetting) { if (szsetting[0] != 'ö') - SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_INSERTSTRING, -1, (LPARAM)szsetting); + SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_INSERTSTRING, -1, (LPARAM)szsetting); return 1; } @@ -122,7 +122,7 @@ static void ShowPage(HWND hwnd, int page) static int UpdateClistItem(MCONTACT hContact, DWORD mask) { for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) - SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hContact, MAKELONG(i - ID_STATUS_OFFLINE, + SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hContact, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & mask ? i - ID_STATUS_OFFLINE : nullImage)); return 0; @@ -133,7 +133,7 @@ static DWORD GetMaskForItem(HANDLE hItem) DWORD dwMask = 0; for (int i = 0; i <= ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE; i++) - dwMask |= (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == nullImage ? 0 : 1 << i); + dwMask |= (SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == nullImage ? 0 : 1 << i); return dwMask; } @@ -141,24 +141,24 @@ static DWORD GetMaskForItem(HANDLE hItem) static void UpdateStickies() { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - MCONTACT hItem = (MCONTACT)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); + MCONTACT hItem = (MCONTACT)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); if (hItem) - SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, cfg::getByte(hContact, "CLVM", g_szModename, 0) ? 1 : 0); - DWORD localMask = HIWORD(cfg::getDword(hContact, "CLVM", g_szModename, 0)); - UpdateClistItem(hItem, (localMask == 0 || localMask == stickyStatusMask) ? stickyStatusMask : localMask); + SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, cfg::getByte(hContact, "CLVM", sttModeName, 0) ? 1 : 0); + DWORD localMask = HIWORD(cfg::getDword(hContact, "CLVM", sttModeName, 0)); + UpdateClistItem(hItem, (localMask == 0 || localMask == sttStickyStatusMask) ? sttStickyStatusMask : localMask); } for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) - SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hInfoItem, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & stickyStatusMask ? i - ID_STATUS_OFFLINE : ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1)); + SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hInfoItem, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & sttStickyStatusMask ? i - ID_STATUS_OFFLINE : ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1)); - HANDLE hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0); - hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP, (LPARAM)hItem); + HANDLE hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0); + hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP, (LPARAM)hItem); while (hItem) { for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) - SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELONG(i - ID_STATUS_OFFLINE, nullImage)); - hItem=(HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); + SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELONG(i - ID_STATUS_OFFLINE, nullImage)); + hItem=(HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); } - ShowPage(clvmHwnd, 0); + ShowPage(sttClvmHwnd, 0); } static int FillDialog(HWND hwnd) @@ -329,14 +329,14 @@ void SaveState() HANDLE hItem; DWORD operators = 0; - if (clvm_curItem == -1) + if (sttClvm_curItem == -1) return; { LVITEMA item = {0}; char szTemp[256]; - hwndList = GetDlgItem(clvmHwnd, IDC_PROTOCOLS); + hwndList = GetDlgItem(sttClvmHwnd, IDC_PROTOCOLS); for (i = 0; i < ListView_GetItemCount(hwndList); i++) { if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; @@ -355,7 +355,7 @@ void SaveState() LVITEM item = {0}; TCHAR szTemp[256]; - hwndList = GetDlgItem(clvmHwnd, IDC_GROUPS); + hwndList = GetDlgItem(sttClvmHwnd, IDC_GROUPS); operators |= ListView_GetCheckState(hwndList, 0) ? CLVM_INCLUDED_UNGROUPED : 0; @@ -372,12 +372,12 @@ void SaveState() } } } - hwndList = GetDlgItem(clvmHwnd, IDC_STATUSMODES); + hwndList = GetDlgItem(sttClvmHwnd, IDC_STATUSMODES); for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) if (ListView_GetCheckState(hwndList, i - ID_STATUS_OFFLINE)) statusMask |= (1 << (i - ID_STATUS_OFFLINE)); - int iLen = SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, clvm_curItem, 0); + int iLen = SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, sttClvm_curItem, 0); if (iLen) { unsigned int stickies = 0; DWORD dwGlobalMask, dwLocalMask; @@ -386,13 +386,13 @@ void SaveState() szModeName = (char*)malloc(iLen + 1); if (szModeName) { DWORD options, lmdat; - SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szModeName); + SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXT, sttClvm_curItem, (LPARAM)szModeName); dwGlobalMask = GetMaskForItem(hInfoItem); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); + hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); if (hItem) { - if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { + if (SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { dwLocalMask = GetMaskForItem(hItem); cfg::writeDword(hContact, "CLVM", szModeName, MAKELONG(1, (unsigned short)dwLocalMask)); stickies++; @@ -402,16 +402,16 @@ void SaveState() } } - operators |= ((SendDlgItemMessage(clvmHwnd, IDC_PROTOGROUPOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_PROTOGROUP_OP : 0) | - (SendDlgItemMessage(clvmHwnd, IDC_GROUPSTATUSOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_GROUPSTATUS_OP : 0) | - (IsDlgButtonChecked(clvmHwnd, IDC_AUTOCLEAR) ? CLVM_AUTOCLEAR : 0) | - (IsDlgButtonChecked(clvmHwnd, IDC_LASTMSG) ? CLVM_USELASTMSG : 0)); + operators |= ((SendDlgItemMessage(sttClvmHwnd, IDC_PROTOGROUPOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_PROTOGROUP_OP : 0) | + (SendDlgItemMessage(sttClvmHwnd, IDC_GROUPSTATUSOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_GROUPSTATUS_OP : 0) | + (IsDlgButtonChecked(sttClvmHwnd, IDC_AUTOCLEAR) ? CLVM_AUTOCLEAR : 0) | + (IsDlgButtonChecked(sttClvmHwnd, IDC_LASTMSG) ? CLVM_USELASTMSG : 0)); - options = SendDlgItemMessage(clvmHwnd, IDC_AUTOCLEARSPIN, UDM_GETPOS, 0, 0); + options = SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_GETPOS, 0, 0); - lmdat = MAKELONG(GetDlgItemInt(clvmHwnd, IDC_LASTMSGVALUE, &translated, FALSE), - MAKEWORD(SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEOP, CB_GETCURSEL, 0, 0), - SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEUNIT, CB_GETCURSEL, 0, 0))); + lmdat = MAKELONG(GetDlgItemInt(sttClvmHwnd, IDC_LASTMSGVALUE, &translated, FALSE), + MAKEWORD(SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEOP, CB_GETCURSEL, 0, 0), + SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEUNIT, CB_GETCURSEL, 0, 0))); SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, dwGlobalMask, options, stickies, operators, lmdat); @@ -419,7 +419,7 @@ void SaveState() free(szModeName); } } - Utils::enableDlgControl(clvmHwnd, IDC_APPLY, FALSE); + Utils::enableDlgControl(sttClvmHwnd, IDC_APPLY, FALSE); } @@ -434,22 +434,24 @@ void UpdateFilters() DWORD statusMask = 0; DWORD dwFlags; DWORD opt; - char szTemp[100]; - if (clvm_curItem == LB_ERR) + if (sttClvm_curItem == LB_ERR) return; - iLen = SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, clvm_curItem, 0); + iLen = SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, sttClvm_curItem, 0); if (iLen == 0) return; szBuf = (char *)malloc(iLen + 1); - SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szBuf); - strncpy(g_szModename, szBuf, sizeof(g_szModename)); - g_szModename[sizeof(g_szModename) - 1] = 0; - mir_snprintf(szTemp, Translate("Current view mode: %s"), g_szModename); - SetDlgItemTextA(clvmHwnd, IDC_CURVIEWMODE2, szTemp); + SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXT, sttClvm_curItem, (LPARAM)szBuf); + strncpy(sttModeName, szBuf, sizeof(sttModeName)); + sttModeName[sizeof(sttModeName) - 1] = 0; + { + char szTemp[100]; + mir_snprintf(szTemp, Translate("Current view mode: %s"), sttModeName); + SetDlgItemTextA(sttClvmHwnd, IDC_CURVIEWMODE2, szTemp); + } mir_snprintf(szSetting, "%c%s_PF", 246, szBuf); if (db_get(NULL, CLVM_MODULE, szSetting, &dbv_pf)) goto cleanup; @@ -458,19 +460,19 @@ void UpdateFilters() goto cleanup; mir_snprintf(szSetting, "%c%s_OPT", 246, szBuf); if ((opt = cfg::getDword(NULL, CLVM_MODULE, szSetting, -1)) != -1) { - SendDlgItemMessage(clvmHwnd, IDC_AUTOCLEARSPIN, UDM_SETPOS, 0, MAKELONG(LOWORD(opt), 0)); + SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_SETPOS, 0, MAKELONG(LOWORD(opt), 0)); } mir_snprintf(szSetting, "%c%s_SM", 246, szBuf); statusMask = cfg::getDword(CLVM_MODULE, szSetting, -1); mir_snprintf(szSetting, "%c%s_SSM", 246, szBuf); - stickyStatusMask = cfg::getDword(CLVM_MODULE, szSetting, -1); + sttStickyStatusMask = cfg::getDword(CLVM_MODULE, szSetting, -1); dwFlags = cfg::getDword(CLVM_MODULE, szBuf, 0); { LVITEMA item = {0}; char szTemp[256]; char szMask[256]; int i; - HWND hwndList = GetDlgItem(clvmHwnd, IDC_PROTOCOLS); + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_PROTOCOLS); item.mask = LVIF_TEXT; item.pszText = szTemp; @@ -492,7 +494,7 @@ void UpdateFilters() TCHAR szTemp[256]; TCHAR szMask[256]; int i; - HWND hwndList = GetDlgItem(clvmHwnd, IDC_GROUPS); + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_GROUPS); item.mask = LVIF_TEXT; item.pszText = szTemp; @@ -512,7 +514,7 @@ void UpdateFilters() } { - HWND hwndList = GetDlgItem(clvmHwnd, IDC_STATUSMODES); + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_STATUSMODES); int i; for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { @@ -522,9 +524,9 @@ void UpdateFilters() ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, FALSE); } } - SendDlgItemMessage(clvmHwnd, IDC_PROTOGROUPOP, CB_SETCURSEL, dwFlags & CLVM_PROTOGROUP_OP ? 1 : 0, 0); - SendDlgItemMessage(clvmHwnd, IDC_GROUPSTATUSOP, CB_SETCURSEL, dwFlags & CLVM_GROUPSTATUS_OP ? 1 : 0, 0); - CheckDlgButton(clvmHwnd, IDC_AUTOCLEAR, dwFlags & CLVM_AUTOCLEAR ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(sttClvmHwnd, IDC_PROTOGROUPOP, CB_SETCURSEL, dwFlags & CLVM_PROTOGROUP_OP ? 1 : 0, 0); + SendDlgItemMessage(sttClvmHwnd, IDC_GROUPSTATUSOP, CB_SETCURSEL, dwFlags & CLVM_GROUPSTATUS_OP ? 1 : 0, 0); + CheckDlgButton(sttClvmHwnd, IDC_AUTOCLEAR, dwFlags & CLVM_AUTOCLEAR ? BST_CHECKED : BST_UNCHECKED); UpdateStickies(); { @@ -532,22 +534,22 @@ void UpdateFilters() DWORD lmdat; BYTE bTmp; - CheckDlgButton(clvmHwnd, IDC_LASTMSG, useLastMsg ? BST_CHECKED : BST_UNCHECKED); - Utils::enableDlgControl(clvmHwnd, IDC_LASTMESSAGEOP, useLastMsg); - Utils::enableDlgControl(clvmHwnd, IDC_LASTMSGVALUE, useLastMsg); - Utils::enableDlgControl(clvmHwnd, IDC_LASTMESSAGEUNIT, useLastMsg); + CheckDlgButton(sttClvmHwnd, IDC_LASTMSG, useLastMsg ? BST_CHECKED : BST_UNCHECKED); + Utils::enableDlgControl(sttClvmHwnd, IDC_LASTMESSAGEOP, useLastMsg); + Utils::enableDlgControl(sttClvmHwnd, IDC_LASTMSGVALUE, useLastMsg); + Utils::enableDlgControl(sttClvmHwnd, IDC_LASTMESSAGEUNIT, useLastMsg); mir_snprintf(szSetting, "%c%s_LM", 246, szBuf); lmdat = cfg::getDword(CLVM_MODULE, szSetting, 0); - SetDlgItemInt(clvmHwnd, IDC_LASTMSGVALUE, LOWORD(lmdat), FALSE); + SetDlgItemInt(sttClvmHwnd, IDC_LASTMSGVALUE, LOWORD(lmdat), FALSE); bTmp = LOBYTE(HIWORD(lmdat)); - SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEOP, CB_SETCURSEL, bTmp, 0); + SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEOP, CB_SETCURSEL, bTmp, 0); bTmp = HIBYTE(HIWORD(lmdat)); - SendDlgItemMessage(clvmHwnd, IDC_LASTMESSAGEUNIT, CB_SETCURSEL, bTmp, 0); + SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEUNIT, CB_SETCURSEL, bTmp, 0); } - ShowPage(clvmHwnd, 0); + ShowPage(sttClvmHwnd, 0); cleanup: db_free(&dbv_pf); db_free(&dbv_gf); @@ -556,7 +558,7 @@ cleanup: INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - clvmHwnd = hwndDlg; + sttClvmHwnd = hwndDlg; switch (msg) { case WM_INITDIALOG: @@ -601,11 +603,11 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP hInfoItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { - clvm_curItem = 0; + sttClvm_curItem = 0; UpdateFilters(); } else - clvm_curItem = -1; + sttClvm_curItem = -1; g_ViewModeOptDlg = TRUE; i = 0; while (_page2Controls[i] != 0) @@ -673,11 +675,11 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0); if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { - clvm_curItem = 0; + sttClvm_curItem = 0; UpdateFilters(); } else - clvm_curItem = -1; + sttClvm_curItem = -1; free(szBuf); } } @@ -700,7 +702,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (iNewItem != LB_ERR) { SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, (WPARAM)iNewItem, 0); SaveViewMode(szBuf, _T(""), "", -1, -1, 0, 0, 0, 0); - clvm_curItem = iNewItem; + sttClvm_curItem = iNewItem; UpdateStickies(); SendDlgItemMessage(hwndDlg, IDC_PROTOGROUPOP, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwndDlg, IDC_GROUPSTATUSOP, CB_SETCURSEL, 0, 0); @@ -735,7 +737,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, TRUE); if (LOWORD(wParam) == IDC_VIEWMODES && HIWORD(wParam) == LBN_SELCHANGE) { SaveState(); - clvm_curItem = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0); + sttClvm_curItem = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0); UpdateFilters(); } break; diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 09ba726dbc..35530e8ec0 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -50,20 +50,17 @@ int Get2StateValue(char *state) _strlwr(lower); //if ((mir_strcmp(lower, "enable") == 0) || (mir_strcmp(lower, "show") == 0) || (mir_strcmp(lower, "on") == 0)) - if ((matches("enable", lower)) || (matches("show", lower)) || (matches("on", lower))) - { + if ((matches("enable", lower)) || (matches("show", lower)) || (matches("on", lower))) { return STATE_ON; } //if ((mir_strcmp(lower, "disable") == 0) || (mir_strcmp(lower, "hide") == 0) || (mir_strcmp(lower, "off") == 0)) - if ((matches("disable", lower)) || (matches("hide", lower)) || (matches("off", lower))) - { + if ((matches("disable", lower)) || (matches("hide", lower)) || (matches("off", lower))) { return STATE_OFF; } //if (mir_strcmp(lower, "toggle") == 0) - if (matches("toggle", lower)) - { + if (matches("toggle", lower)) { return STATE_TOGGLE; } @@ -107,56 +104,56 @@ int ParseValueParam(char *param, void *&result) if (mir_strlen(param) > 0) { switch (*param) { case 's': - { - size_t len = mir_strlen(param); //- 1 + 1 - result = (char*)malloc(len * sizeof(char)); - strcpy((char*) result, param + 1); - return VALUE_STRING; - } + { + size_t len = mir_strlen(param); //- 1 + 1 + result = (char*)malloc(len * sizeof(char)); + strcpy((char*)result, param + 1); + return VALUE_STRING; + } case 'w': - { - size_t len = mir_strlen(param); - result = (WCHAR *)malloc(len * sizeof(WCHAR)); - char *buffer = (char*)malloc(len * sizeof(WCHAR)); - strncpy_s(buffer, len, param + 1, _TRUNCATE); + { + size_t len = mir_strlen(param); + result = (WCHAR *)malloc(len * sizeof(WCHAR)); + char *buffer = (char*)malloc(len * sizeof(WCHAR)); + strncpy_s(buffer, len, param + 1, _TRUNCATE); - MultiByteToWideChar(CP_ACP, 0, buffer, -1, (WCHAR *) result, (int) len); + MultiByteToWideChar(CP_ACP, 0, buffer, -1, (WCHAR *)result, (int)len); - free(buffer); - return VALUE_WIDE; - } + free(buffer); + return VALUE_WIDE; + } case 'b': - { - result = (char *)malloc(sizeof(char)); + { + result = (char *)malloc(sizeof(char)); - char *stop; - long tmp = strtol(param + 1, &stop, 10); - * ((char *) result) = tmp; + char *stop; + long tmp = strtol(param + 1, &stop, 10); + *((char *)result) = tmp; - return (*stop == 0) ? VALUE_BYTE : VALUE_ERROR; - } + return (*stop == 0) ? VALUE_BYTE : VALUE_ERROR; + } case 'i': - { - result = (int *)malloc(sizeof(int)); - char *stop; + { + result = (int *)malloc(sizeof(int)); + char *stop; - long tmp = strtol(param + 1, &stop, 10); - * ((int *) result) = tmp; + long tmp = strtol(param + 1, &stop, 10); + *((int *)result) = tmp; - return (*stop == 0) ? VALUE_WORD : VALUE_ERROR; - } + return (*stop == 0) ? VALUE_WORD : VALUE_ERROR; + } case 'd': - { - result = (long *)malloc(sizeof(long)); - char *stop; - * ((long *) result) = strtol(param + 1, &stop, 10); + { + result = (long *)malloc(sizeof(long)); + char *stop; + *((long *)result) = strtol(param + 1, &stop, 10); - return (*stop == 0) ? VALUE_DWORD : VALUE_ERROR; - } + return (*stop == 0) ? VALUE_DWORD : VALUE_ERROR; + } default: return VALUE_UNKNOWN; } @@ -169,25 +166,25 @@ int ParseStatusParam(char *status) char *lower = NEWSTR_ALLOCA(status); _strlwr(lower); - if ( !mir_strcmp(lower, "offline")) + if (!mir_strcmp(lower, "offline")) return ID_STATUS_OFFLINE; - else if ( !mir_strcmp(lower, "online")) + else if (!mir_strcmp(lower, "online")) return ID_STATUS_ONLINE; - else if ( !mir_strcmp(lower, "away")) + else if (!mir_strcmp(lower, "away")) return ID_STATUS_AWAY; - else if ( !mir_strcmp(lower, "dnd")) + else if (!mir_strcmp(lower, "dnd")) return ID_STATUS_DND; - else if ( !mir_strcmp(lower, "na")) + else if (!mir_strcmp(lower, "na")) return ID_STATUS_NA; - else if ( !mir_strcmp(lower, "occupied")) + else if (!mir_strcmp(lower, "occupied")) return ID_STATUS_OCCUPIED; - else if ( !mir_strcmp(lower, "freechat")) + else if (!mir_strcmp(lower, "freechat")) return ID_STATUS_FREECHAT; - else if ( !mir_strcmp(lower, "invisible")) + else if (!mir_strcmp(lower, "invisible")) return ID_STATUS_INVISIBLE; - else if ( !mir_strcmp(lower, "onthephone")) + else if (!mir_strcmp(lower, "onthephone")) return ID_STATUS_ONTHEPHONE; - else if ( !mir_strcmp(lower, "outtolunch")) + else if (!mir_strcmp(lower, "outtolunch")) return ID_STATUS_OUTTOLUNCH; else return 0; @@ -198,7 +195,7 @@ char *PrettyStatusMode(int status, char *buffer, int size) TCHAR *data = pcli->pfnGetStatusModeDescription(status, 0); if (data) strncpy_s(buffer, size, _T2A(data), _TRUNCATE); - else + else *buffer = 0; return buffer; @@ -206,9 +203,8 @@ char *PrettyStatusMode(int status, char *buffer, int size) void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 2: + switch (argc) { + case 2: { INT_PTR status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); char pretty[128]; @@ -222,11 +218,9 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep char pn[128]; - for (int i = 0; i < count; i++) - { - if (accounts[i]->bIsEnabled) - { - INT_PTR status = CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0); + for (int i = 0; i < count; i++) { + if (accounts[i]->bIsEnabled) { + status = CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0); PrettyStatusMode(status, pn, sizeof(pn)); perAccountStatus.AppendChar('\n'); @@ -242,15 +236,13 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep return; } - case 3: + case 3: { int status = ParseStatusParam(argv[2]); - if (status) - { + if (status) { INT_PTR old = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); char po[128]; - if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) - { + if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) { announce_status_change(NULL, status, NULL); } @@ -262,26 +254,24 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate("Changed global status to '%s' (previous status was '%s')."), pn, po); } - else{ + else { HandleUnknownParameter(command, argv[2], reply); } return; } - case 4: + case 4: { int status = ParseStatusParam(argv[2]); - if (status) - { + if (status) { char protocol[128]; char *account = argv[3]; AccountName2Protocol(account, protocol, sizeof(protocol)); INT_PTR old = CallProtoService(protocol, PS_GETSTATUS, 0, 0); char po[128]; - if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) - { + if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) { announce_status_change(protocol, status, NULL); } @@ -290,41 +280,39 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep char pn[128]; PrettyStatusMode(status, pn, sizeof(pn)); - switch (res) - { - case 0: - reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, _countof(reply->message), Translate("Changed '%s' status to '%s' (previous status was '%s')."), account, pn, po); - return; + switch (res) { + case 0: + reply->code = MIMRES_SUCCESS; + mir_snprintf(reply->message, _countof(reply->message), Translate("Changed '%s' status to '%s' (previous status was '%s')."), account, pn, po); + return; - case CALLSERVICE_NOTFOUND: - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, _countof(reply->message), Translate("'%s' doesn't seem to be a valid account."), account); - return; + case CALLSERVICE_NOTFOUND: + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, _countof(reply->message), Translate("'%s' doesn't seem to be a valid account."), account); + return; - default: - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, _countof(reply->message), Translate("Failed to change status for account '%s' to '%s'."), account, pn); - return; + default: + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, _countof(reply->message), Translate("Failed to change status for account '%s' to '%s'."), account, pn); + return; } } - else{ + else { HandleUnknownParameter(command, argv[2], reply); } return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 3: + switch (argc) { + case 3: { char *awayMsg = argv[2]; int count = 0; @@ -337,8 +325,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re INT_PTR res = 0; char *protocol; char pn[128]; - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { if (!accounts[i]->bIsEnabled) continue; @@ -353,7 +340,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re res = CallProtoService(protocol, PS_SETAWAYMSG, status, wszAwayMsg); PrettyStatusMode(status, pn, sizeof(pn)); if (res) - szReply.AppendFormat(Translate("Failed to set '%S' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName , awayMsg, pn); + szReply.AppendFormat(Translate("Failed to set '%S' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName, awayMsg, pn); else szReply.AppendFormat(Translate("Successfully set '%S' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName, awayMsg, pn); } @@ -364,7 +351,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re return; } - case 4: + case 4: { char *awayMsg = argv[2]; char protocol[128]; @@ -380,64 +367,59 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re PrettyStatusMode(status, pn, sizeof(pn)); } - else if (CallProtoService(protocol, PS_GETSTATUS, 0, 0) == CALLSERVICE_NOTFOUND) - { + else if (CallProtoService(protocol, PS_GETSTATUS, 0, 0) == CALLSERVICE_NOTFOUND) { res = CALLSERVICE_NOTFOUND; } else { res = -2; } - switch (res) - { - case 0: - reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, _countof(reply->message), Translate("Changed '%s' status message to '%s' (status is '%s')."), account, awayMsg, pn); - return; + switch (res) { + case 0: + reply->code = MIMRES_SUCCESS; + mir_snprintf(reply->message, _countof(reply->message), Translate("Changed '%s' status message to '%s' (status is '%s')."), account, awayMsg, pn); + return; - case CALLSERVICE_NOTFOUND: - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, _countof(reply->message), Translate("'%s' doesn't seem to be a valid account."), account); - return; + case CALLSERVICE_NOTFOUND: + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, _countof(reply->message), Translate("'%s' doesn't seem to be a valid account."), account); + return; - case -2: - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, _countof(reply->message), Translate("Account '%s' does not support away messages, skipping."), account); - return; + case -2: + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, _countof(reply->message), Translate("Account '%s' does not support away messages, skipping."), account); + return; - default: - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, _countof(reply->message), Translate("Failed to change status message for account '%s' to '%s' (status is '%s')."), account, awayMsg, pn); - return; + default: + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, _countof(reply->message), Translate("Failed to change status message for account '%s' to '%s' (status is '%s')."), account, awayMsg, pn); + return; } } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void Set2StateReply(PReply reply, int state, int failure, char *successTrue, char *failureTrue, char *successFalse, char *failureFalse) { - if (state) - { - if (failure) - { + if (state) { + if (failure) { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate(failureTrue)); } - else{ + else { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate(successTrue)); } } - else{ - if (failure) - { + else { + if (failure) { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate(failureFalse)); } - else{ + else { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate(successFalse)); } @@ -446,44 +428,40 @@ void Set2StateReply(PReply reply, int state, int failure, char *successTrue, cha void HandlePopupsCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 2: + switch (argc) { + case 2: { int state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); - Set2StateReply(reply, state, 0, LPGEN("Popups are currently enabled."), "", LPGEN("Popups are currently disabled."), ""); + Set2StateReply(reply, state, 0, LPGEN("Popups are currently enabled."), "", LPGEN("Popups are currently disabled."), ""); return; } - case 3: + case 3: { int failure; int state = 0; - switch (Get2StateValue(argv[2])) - { - case STATE_ON: - failure = CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); - state = TRUE; - break; + switch (Get2StateValue(argv[2])) { + case STATE_ON: + failure = CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); + state = TRUE; + break; - case STATE_OFF: - failure = CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); - state = FALSE; - break; + case STATE_OFF: + failure = CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); + state = FALSE; + break; - case STATE_TOGGLE: - { - int state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); - failure = CallService(MS_POPUP_QUERY, (state) ? PUQS_DISABLEPOPUPS : PUQS_ENABLEPOPUPS, 0); - state = 1 - state; - break; - } + case STATE_TOGGLE: + state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); + failure = CallService(MS_POPUP_QUERY, (state) ? PUQS_DISABLEPOPUPS : PUQS_ENABLEPOPUPS, 0); + state = !state; + break; - default: - HandleUnknownParameter(command, argv[2], reply); - return; + default: + HandleUnknownParameter(command, argv[2], reply); + return; } Set2StateReply(reply, state, failure, LPGEN("Popups were enabled successfully."), LPGEN("Popups could not be enabled."), @@ -492,47 +470,45 @@ void HandlePopupsCommand(PCommand command, TArgument *argv, int argc, PReply rep return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleSoundsCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 2: + switch (argc) { + case 2: { int state = db_get_b(NULL, "Skin", "UseSound", 1); - Set2StateReply(reply, state, 0, LPGEN("Sounds are currently enabled."), "", LPGEN("Sounds are currently disabled."), ""); + Set2StateReply(reply, state, 0, LPGEN("Sounds are currently enabled."), "", LPGEN("Sounds are currently disabled."), ""); return; } - case 3: + case 3: { int state = 0; - switch (Get2StateValue(argv[2])) - { - case STATE_ON: - db_set_b(NULL, "Skin", "UseSound", 1); - state = TRUE; - break; + switch (Get2StateValue(argv[2])) { + case STATE_ON: + db_set_b(NULL, "Skin", "UseSound", 1); + state = TRUE; + break; - case STATE_OFF: - db_set_b(NULL, "Skin", "UseSound", 0); - state = FALSE; - break; + case STATE_OFF: + db_set_b(NULL, "Skin", "UseSound", 0); + state = FALSE; + break; - case STATE_TOGGLE: - state = db_get_b(NULL, "Skin", "UseSound", 1); - state = 1 - state; - db_set_b(NULL, "Skin", "UseSound", state); - break; + case STATE_TOGGLE: + state = db_get_b(NULL, "Skin", "UseSound", 1); + state = 1 - state; + db_set_b(NULL, "Skin", "UseSound", state); + break; - default: - HandleUnknownParameter(command, argv[2], reply); - return; + default: + HandleUnknownParameter(command, argv[2], reply); + return; } Set2StateReply(reply, state, 0, LPGEN("Sounds were enabled successfully."), "", LPGEN("Sounds were disabled successfully."), ""); @@ -540,31 +516,29 @@ void HandleSoundsCommand(PCommand command, TArgument *argv, int argc, PReply rep return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 2: + switch (argc) { + case 2: { int state = IsWindowVisible(pcli->hwndContactList); - Set2StateReply(reply, state, 0, LPGEN("Contact list is currently shown."), "", LPGEN("Contact list is currently hidden."), ""); + Set2StateReply(reply, state, 0, LPGEN("Contact list is currently shown."), "", LPGEN("Contact list is currently hidden."), ""); return; } - case 3: + case 3: { int state = 0; HWND hClist = pcli->hwndContactList; - switch (Get2StateValue(argv[2])) - { - case STATE_ON: + switch (Get2StateValue(argv[2])) { + case STATE_ON: { ShowWindow(hClist, SW_SHOW); @@ -573,7 +547,7 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl break; } - case STATE_OFF: + case STATE_OFF: { ShowWindow(hClist, SW_HIDE); state = FALSE; @@ -581,7 +555,7 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl break; } - case STATE_TOGGLE: + case STATE_TOGGLE: { state = IsWindowVisible(hClist); @@ -591,9 +565,9 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl break; } - default: - HandleUnknownParameter(command, argv[2], reply); - return; + default: + HandleUnknownParameter(command, argv[2], reply); + return; } @@ -603,16 +577,15 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 2: + switch (argc) { + case 2: { CallService("CloseAction", 0, 0); @@ -625,14 +598,13 @@ void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply break; } - case 3: + case 3: { char lower[128]; strncpy_s(lower, argv[2], sizeof(lower)); _strlwr(lower); - if (mir_strcmp(lower, "wait") == 0) - { + if (mir_strcmp(lower, "wait") == 0) { CallService("CloseAction", 0, 0); //try another quit method @@ -646,114 +618,104 @@ void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply bWaitForUnload = 1; - while (bWaitForUnload) - { + while (bWaitForUnload) { Sleep(250); //wait for Miranda to quit. } } - else{ + else { HandleUnknownParameter(command, argv[2], reply); } break; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleExchangeCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 3: + switch (argc) { + case 3: { char lower[128]; strncpy_s(lower, argv[2], sizeof(lower)); _strlwr(lower); - if (mir_strcmp(lower, "check") == 0) - { + if (mir_strcmp(lower, "check") == 0) { INT_PTR ret = CallService(MS_EXCHANGE_CHECKEMAIL, 0, 0); - if (ret != CALLSERVICE_NOTFOUND) - { + if (ret != CALLSERVICE_NOTFOUND) { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate("Issued check email command to Exchange plugin.")); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Exchange plugin is not running.")); } } - else{ + else { HandleUnknownParameter(command, argv[2], reply); } return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleYAMNCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 3: + switch (argc) { + case 3: { char lower[128]; strncpy_s(lower, argv[2], sizeof(lower)); _strlwr(lower); - if (mir_strcmp(lower, "check") == 0) - { - if (ServiceExists(MS_YAMN_FORCECHECK)) - { + if (mir_strcmp(lower, "check") == 0) { + if (ServiceExists(MS_YAMN_FORCECHECK)) { CallService(MS_YAMN_FORCECHECK, 0, 0); reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate("Issued check email command to YAMN plugin.")); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("YAMN plugin is not running.")); } } - else{ + else { HandleUnknownParameter(command, argv[2], reply); } return; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (argc) - { - case 5: + switch (argc) { + case 5: { char *service = argv[2]; - if (ServiceExists(service)) - { + if (ServiceExists(service)) { void *wParam = NULL; void *lParam = NULL; INT_PTR res1 = ParseValueParam(argv[3], wParam); INT_PTR res2 = ParseValueParam(argv[4], lParam); - if ((res1 != 0) && (res2 != 0)) - { + if ((res1 != 0) && (res2 != 0)) { //very dangerous but the user asked - INT_PTR res = CallService(service, ((res1 == 1) ? *((long *) wParam) : (WPARAM) wParam), (LPARAM) ((res2 == 1) ? *((long *) lParam) : (LPARAM) lParam)); + INT_PTR res = CallService(service, ((res1 == 1) ? *((long *)wParam) : (WPARAM)wParam), (LPARAM)((res2 == 1) ? *((long *)lParam) : (LPARAM)lParam)); reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate("CallService call successful: service '%s' returned %p."), service, res); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Invalid parameter '%s' passed to CallService command."), (wParam) ? argv[4] : argv[3]); } @@ -762,7 +724,7 @@ void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PRepl free(lParam); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Service '%s' does not exist."), service); } @@ -770,16 +732,17 @@ void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PRepl break; } - default: - HandleWrongParametersCount(command, reply); + default: + HandleWrongParametersCount(command, reply); } } -void ParseMessage(char buffer[512], const char *message) { +void ParseMessage(char buffer[512], const char *message) +{ unsigned int j = 0; for (unsigned int i = 0; i < mir_strlen(message); ++i) { char c = message[i]; - if (c == '\\' && i < (mir_strlen(message) - 1) && message[i+1] == 'n') { + if (c == '\\' && i < (mir_strlen(message) - 1) && message[i + 1] == 'n') { c = '\n'; i++; } @@ -796,10 +759,10 @@ MCONTACT ParseContactParam(char *contact) char *p = strrchr(contact, ':'); if (p == 0) return GetContactFromID(contact, (char*)NULL); - + *p = 0; strncpy_s(name, contact, _TRUNCATE); - strncpy_s(account, p+1, _TRUNCATE); + strncpy_s(account, p + 1, _TRUNCATE); *p = ':'; AccountName2Protocol(account, protocol, sizeof(protocol)); return GetContactFromID(name, protocol); @@ -807,54 +770,47 @@ MCONTACT ParseContactParam(char *contact) void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc >= 4) - { + if (argc >= 4) { char message[512]; ParseMessage(message, argv[argc - 1]); //get the message CMStringA szReply; ACKDATA *ack = NULL; - for (int i = 2; i < argc - 1; i++) - { + for (int i = 2; i < argc - 1; i++) { char *contact = argv[i]; MCONTACT hContact = ParseContactParam(contact); if (i != 3) szReply.AppendChar('\n'); - if (hContact) - { + if (hContact) { bShouldProcessAcks = TRUE; HANDLE hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)message); const int MAX_COUNT = 60; int counter = 0; - while (((ack = GetAck(hProcess)) == NULL) && (counter < MAX_COUNT)) - { + while (((ack = GetAck(hProcess)) == NULL) && (counter < MAX_COUNT)) { SleepEx(250, TRUE); counter++; } bShouldProcessAcks = FALSE; - if (counter < MAX_COUNT) - { - if (ack->result == ACKRESULT_SUCCESS) - { - if (ack->szModule) - { + if (counter < MAX_COUNT) { + if (ack->result == ACKRESULT_SUCCESS) { + if (ack->szModule) { szReply.AppendFormat(Translate("Message sent to '%s'."), contact); - DBEVENTINFO e = {0}; + DBEVENTINFO e = { 0 }; char module[128]; e.cbSize = sizeof(DBEVENTINFO); e.eventType = EVENTTYPE_MESSAGE; e.flags = DBEF_SENT; - e.pBlob = (PBYTE) message; - e.cbBlob = (DWORD) mir_strlen((char *) message) + 1; + e.pBlob = (PBYTE)message; + e.cbBlob = (DWORD)mir_strlen((char *)message) + 1; strncpy_s(module, ack->szModule, sizeof(module)); e.szModule = module; - e.timestamp = (DWORD) time(NULL); + e.timestamp = (DWORD)time(NULL); db_event_add(ack->hContact, &e); } @@ -873,52 +829,51 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re bool ParseDatabaseData(DBVARIANT *var, char *buffer, int size, int free) { - switch (var->type) - { - case DBVT_BYTE: - mir_snprintf(buffer, size, Translate("byte:%d"), var->bVal); - return true; - - case DBVT_WORD: - mir_snprintf(buffer, size, Translate("word:%d"), var->wVal); - return true; - - case DBVT_DWORD: - mir_snprintf(buffer, size, Translate("dword:%ld"), var->dVal); - return true; - - case DBVT_ASCIIZ: - mir_snprintf(buffer, size, Translate("string:'%s'"), var->pszVal); - if (free) { - mir_free(var->pszVal); - } + switch (var->type) { + case DBVT_BYTE: + mir_snprintf(buffer, size, Translate("byte:%d"), var->bVal); + return true; + + case DBVT_WORD: + mir_snprintf(buffer, size, Translate("word:%d"), var->wVal); + return true; + + case DBVT_DWORD: + mir_snprintf(buffer, size, Translate("dword:%ld"), var->dVal); + return true; + + case DBVT_ASCIIZ: + mir_snprintf(buffer, size, Translate("string:'%s'"), var->pszVal); + if (free) { + mir_free(var->pszVal); + } - return true; + return true; - case DBVT_WCHAR: - mir_snprintf(buffer, size, Translate("wide string:'%S'"), var->pwszVal); - if (free) { - mir_free(var->pwszVal); - } - return true; + case DBVT_WCHAR: + mir_snprintf(buffer, size, Translate("wide string:'%S'"), var->pwszVal); + if (free) { + mir_free(var->pwszVal); + } + return true; - case DBVT_UTF8: - mir_snprintf(buffer, size, Translate("utf8:'%s'"), var->pszVal); - if (free) { - mir_free(var->pszVal); - } - return true; + case DBVT_UTF8: + mir_snprintf(buffer, size, Translate("utf8:'%s'"), var->pszVal); + if (free) { + mir_free(var->pszVal); + } + return true; - case DBVT_BLOB: - mir_snprintf(buffer, size, Translate("blob:N/A")); - if (free) { - mir_free(var->pbVal); - } - return true; + case DBVT_BLOB: + mir_snprintf(buffer, size, Translate("blob:N/A")); + if (free) { + mir_free(var->pbVal); + } + return true; - default: - mir_snprintf(buffer, size, Translate("unknown value")); - return false; + default: + mir_snprintf(buffer, size, Translate("unknown value")); + return false; } } @@ -930,10 +885,8 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r strncpy_s(dbcmd, argv[2], sizeof(dbcmd)); dbcmd[sizeof(dbcmd) - 1] = 0; _strlwr(dbcmd); - if (mir_strcmp(dbcmd, "delete") == 0) - { - if (argc == 5) - { + if (mir_strcmp(dbcmd, "delete") == 0) { + if (argc == 5) { char *module = argv[3]; char *key = argv[4]; @@ -942,14 +895,12 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), Translate("Setting '%s/%s' deleted."), module, key); } - else{ + else { HandleWrongParametersCount(command, reply); } } - else if (mir_strcmp(dbcmd, "set") == 0) - { - if (argc == 6) - { + else if (mir_strcmp(dbcmd, "set") == 0) { + if (argc == 6) { char *module = argv[3]; char *key = argv[4]; @@ -957,37 +908,36 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r char *wrote = NULL; int type = ParseValueParam(argv[5], value); - switch (type) - { - case VALUE_STRING: - db_set_s(NULL, module, key, (char *) value); - wrote = Translate("string"); + switch (type) { + case VALUE_STRING: + db_set_s(NULL, module, key, (char *)value); + wrote = Translate("string"); - break; + break; - case VALUE_BYTE: - db_set_b(NULL, module, key, (* (char *) value)); - wrote = Translate("byte"); - break; + case VALUE_BYTE: + db_set_b(NULL, module, key, (*(char *)value)); + wrote = Translate("byte"); + break; - case VALUE_WORD: - db_set_w(NULL, module, key, (* (WORD *) value)); - wrote = Translate("word"); - break; + case VALUE_WORD: + db_set_w(NULL, module, key, (*(WORD *)value)); + wrote = Translate("word"); + break; - case VALUE_DWORD: - db_set_dw(NULL, module, key, (* (DWORD *) value)); - wrote = Translate("dword"); - break; + case VALUE_DWORD: + db_set_dw(NULL, module, key, (*(DWORD *)value)); + wrote = Translate("dword"); + break; - case VALUE_WIDE: - db_set_ws(NULL, module, key, (WCHAR *) value); - wrote = Translate("wide string"); - break; + case VALUE_WIDE: + db_set_ws(NULL, module, key, (WCHAR *)value); + wrote = Translate("wide string"); + break; - default: - HandleUnknownParameter(command, argv[5], reply); - return; + default: + HandleUnknownParameter(command, argv[5], reply); + return; } reply->code = MIMRES_SUCCESS; @@ -995,49 +945,45 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r free(value); } - else{ + else { HandleWrongParametersCount(command, reply); } } - else if (mir_strcmp(dbcmd, "get") == 0) - { - if (argc == 5) - { + else if (mir_strcmp(dbcmd, "get") == 0) { + if (argc == 5) { char *module = argv[3]; char *key = argv[4]; - DBVARIANT var = {0}; + DBVARIANT var = { 0 }; int res = db_get(NULL, module, key, &var); - if (!res) - { + if (!res) { char buffer[1024]; - if (ParseDatabaseData(&var, buffer, sizeof(buffer), TRUE)) - { + if (ParseDatabaseData(&var, buffer, sizeof(buffer), TRUE)) { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, _countof(reply->message), "'%s/%s' - %s.", module, key, buffer); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Could not retrieve setting '%s/%s': %s."), module, key, buffer); } } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Setting '%s/%s' was not found."), module, key); } } - else{ + else { HandleWrongParametersCount(command, reply); } } - else{ + else { HandleUnknownParameter(command, dbcmd, reply); } } - else{ + else { HandleWrongParametersCount(command, reply); } } @@ -1049,20 +995,16 @@ int ParseProxyType(char *type) lower[sizeof(lower) - 1] = 0; _strlwr(lower); - if (mir_strcmp(lower, "socks4") == 0) - { + if (mir_strcmp(lower, "socks4") == 0) { return PROXY_SOCKS4; } - else if (mir_strcmp(lower, "socks5") == 0) - { + else if (mir_strcmp(lower, "socks5") == 0) { return PROXY_SOCKS5; } - else if (mir_strcmp(lower, "http") == 0) - { + else if (mir_strcmp(lower, "http") == 0) { return PROXY_HTTP; } - else if (mir_strcmp(lower, "https") == 0) - { + else if (mir_strcmp(lower, "https") == 0) { return PROXY_HTTPS; } else @@ -1072,26 +1014,25 @@ int ParseProxyType(char *type) char *PrettyProxyType(int type, char *buffer, int size) { char *pretty = ""; - switch (type) - { - case PROXY_SOCKS4: - pretty = "SOCKS4"; - break; + switch (type) { + case PROXY_SOCKS4: + pretty = "SOCKS4"; + break; - case PROXY_SOCKS5: - pretty = "SOCKS5"; - break; + case PROXY_SOCKS5: + pretty = "SOCKS5"; + break; - case PROXY_HTTP: - pretty = "HTTP"; - break; + case PROXY_HTTP: + pretty = "HTTP"; + break; - case PROXY_HTTPS: - pretty = "HTTPS"; - break; + case PROXY_HTTPS: + pretty = "HTTPS"; + break; - default: - pretty = "Unknown"; + default: + pretty = "Unknown"; } strncpy_s(buffer, size, pretty, _TRUNCATE); @@ -1109,11 +1050,9 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe char buffer[1024]; - if (mir_strcmp(proxycmd, "status") == 0) - {//status command - switch (argc) - { - case 4: + if (mir_strcmp(proxycmd, "status") == 0) {//status command + switch (argc) { + case 4: { int value = db_get_b(NULL, module, "NLUseProxy", 0); @@ -1123,12 +1062,11 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - case 5: + case 5: { int state = Get2StateValue(argv[4]); - switch (state) - { - case STATE_OFF: + switch (state) { + case STATE_OFF: { db_set_b(NULL, module, "NLUseProxy", 0); @@ -1138,7 +1076,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - case STATE_ON: + case STATE_ON: { db_set_b(NULL, module, "NLUseProxy", 1); @@ -1148,7 +1086,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - case STATE_TOGGLE: + case STATE_TOGGLE: { int value = db_get_b(NULL, module, "NLUseProxy", 0); value = 1 - value; @@ -1160,24 +1098,22 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - default: - HandleUnknownParameter(command, argv[4], reply); - return; + default: + HandleUnknownParameter(command, argv[4], reply); + return; } break; } - default: - HandleWrongParametersCount(command, reply); - return; + default: + HandleWrongParametersCount(command, reply); + return; } } - else if (mir_strcmp(proxycmd, "server") == 0) - { - switch (argc) - { - case 4: + else if (mir_strcmp(proxycmd, "server") == 0) { + switch (argc) { + case 4: { char host[256], type[256]; GetStringFromDatabase(NULL, module, "NLProxyServer", "", host, sizeof(host)); @@ -1190,7 +1126,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - case 7: + case 7: { int type = ParseProxyType(argv[4]); char *host = argv[5]; @@ -1198,8 +1134,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe char *stop = NULL; port = strtol(argv[6], &stop, 10); - if ((*stop == 0) && (type > 0)) - { + if ((*stop == 0) && (type > 0)) { db_set_s(NULL, module, "NLProxyServer", host); db_set_w(NULL, module, "NLProxyPort", port); db_set_b(NULL, module, "NLProxyType", type); @@ -1215,32 +1150,30 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe break; } - default: - HandleWrongParametersCount(command, reply); - return; + default: + HandleWrongParametersCount(command, reply); + return; } } - else{ + else { HandleUnknownParameter(command, proxycmd, reply); return; } - if (reply->message[0] != 0) - { + if (reply->message[0] != 0) { mir_strncat(reply->message, "\n", _countof(reply->message) - mir_strlen(reply->message)); mir_strncat(reply->message, buffer, _countof(reply->message) - mir_strlen(reply->message)); reply->message[_countof(reply->message) - 1] = 0; } - else{ + else { mir_snprintf(reply->message, _countof(reply->message), buffer); } } void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc >= 4) - { + if (argc >= 4) { char account[128]; char protocol[128]; strncpy_s(account, argv[2], sizeof(account)); @@ -1258,34 +1191,29 @@ void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply repl reply->message[0] = 0; int found = 0; - if (global) - { + if (global) { HandleProtocolProxyCommand(command, argv, argc, reply, "Netlib", protocol); found = 1; } char *match; - for (i = 0; i < count; i++) - { - if (accounts[i]->bIsEnabled) - { + for (i = 0; i < count; i++) { + if (accounts[i]->bIsEnabled) { match = accounts[i]->szModuleName; - if ((global) || (mir_strcmp(protocol, match) == 0)) - { + if ((global) || (mir_strcmp(protocol, match) == 0)) { HandleProtocolProxyCommand(command, argv, argc, reply, match, match); found = 1; } } } - if (!found) - { + if (!found) { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("'%s' doesn't seem to be a valid account."), account); } } - else{ + else { HandleWrongParametersCount(command, reply); } } @@ -1309,51 +1237,43 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account _strlwr(lwrAccount); _strlwr(lwrID); - for (int i = 0; i < argc; i++) - { + for (int i = 0; i < argc; i++) { strncpy_s(lwrKeyword, argv[i], sizeof(lwrKeyword)); _strlwr(lwrKeyword); pos = strstr(lwrKeyword, "account:"); - if (pos) - { + if (pos) { pos += 8; - if (strstr(lwrAccount, pos) == NULL) - { + if (strstr(lwrAccount, pos) == NULL) { matches = 0; break; } } - else{ + else { pos = strstr(lwrKeyword, "status:"); - if (pos) - { + if (pos) { int searchStatus = ParseStatusParam(pos + 7); char protocol[128]; AccountName2Protocol(account, protocol, sizeof(protocol)); WORD contactStatus = db_get_w(hContact, protocol, "Status", ID_STATUS_ONLINE); - if (searchStatus != contactStatus) - { + if (searchStatus != contactStatus) { matches = 0; break; } } - else{ + else { pos = strstr(lwrKeyword, "id:"); - if (pos) - { + if (pos) { pos += 3; - if (strstr(lwrID, pos) == NULL) - { + if (strstr(lwrID, pos) == NULL) { matches = 0; break; } } - else if ((strstr(lwrName, lwrKeyword) == NULL)) - { + else if ((strstr(lwrName, lwrKeyword) == NULL)) { matches = 0; break; } @@ -1366,9 +1286,8 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account void __cdecl OpenMessageWindowThread(void *data) { - MCONTACT hContact = (MCONTACT) data; - if (hContact) - { + MCONTACT hContact = (MCONTACT)data; + if (hContact) { CallServiceSync(MS_MSG_SENDMESSAGET, hContact, 0); } } @@ -1376,10 +1295,8 @@ void __cdecl OpenMessageWindowThread(void *data) void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc >= 3) - { - if (_stricmp(argv[2], "list") == 0) - { + if (argc >= 3) { + if (_stricmp(argv[2], "list") == 0) { char buffer[1024]; char protocol[128]; @@ -1391,20 +1308,17 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r char *contact = GetContactName(hContact, protocol); char *id = GetContactID(hContact, protocol); - if (ContactMatchSearch(hContact, contact, id, protocol, &argv[3], argc - 3)) - { + if (ContactMatchSearch(hContact, contact, id, protocol, &argv[3], argc - 3)) { mir_snprintf(buffer, _countof(buffer), "%s:[%s]:%s (%08d)", contact, id, protocol, hContact); - if (count) - { + if (count) { mir_strncat(reply->message, "\n", _countof(reply->message) - mir_strlen(reply->message)); mir_strncat(reply->message, buffer, _countof(reply->message) - mir_strlen(reply->message)); } - else{ + else { strncpy_s(reply->message, buffer, _countof(reply->message)); } - if (mir_strlen(reply->message) > 4096) - { + if (mir_strlen(reply->message) > 4096) { SetEvent(heServerBufferFull); Sleep(750); //wait a few milliseconds for the event to be processed count = 0; @@ -1418,10 +1332,8 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r free(id); } } - else if (_stricmp(argv[2], "open") == 0) - { - if (argc > 3) - { + else if (_stricmp(argv[2], "open") == 0) { + if (argc > 3) { char protocol[128]; reply->code = MIMRES_SUCCESS; @@ -1461,23 +1373,21 @@ void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply) TimeZone_ToString(dbEvent->timestamp, "D, s", timestamp, sizeof(timestamp)); char *sender = (dbEvent->flags & DBEF_SENT) ? Translate("[me]") : contact; - char *message = DbGetEventTextA(dbEvent,CP_ACP); + char *message = DbGetEventTextA(dbEvent, CP_ACP); static char buffer[8192]; mir_snprintf(buffer, _countof(buffer), "[%s] %15s: %s", timestamp, sender, message); - if (reply->message[0] != 0) - { + if (reply->message[0] != 0) { mir_strncat(reply->message, "\n", _countof(reply->message) - mir_strlen(reply->message)); mir_strncat(reply->message, buffer, _countof(reply->message) - mir_strlen(reply->message)); } - else{ + else { strncpy_s(reply->message, buffer, _countof(reply->message)); } - if (mir_strlen(reply->message) > (_countof(reply->message) / 2)) - { + if (mir_strlen(reply->message) > (_countof(reply->message) / 2)) { SetEvent(heServerBufferFull); Sleep(750); @@ -1488,68 +1398,60 @@ void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply) void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc >= 3) - { + if (argc >= 3) { char *cmd = argv[2]; - switch (argc) - { + switch (argc) { case 3: - { - if (_stricmp(cmd, "unread") == 0) - { - char buffer[4096]; - int count; - int contacts = 0; - DBEVENTINFO dbEvent = { sizeof(dbEvent) }; + if (_stricmp(cmd, "unread") == 0) { + char buffer[4096]; + int count; + int contacts = 0; + DBEVENTINFO dbEvent = { sizeof(dbEvent) }; - reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, _countof(reply->message), Translate("No unread messages found.")); - - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - MEVENT hEvent = db_event_firstUnread(hContact); - if (hEvent != NULL) { - count = 0; - while (hEvent != NULL) { - if (!db_event_get(hEvent, &dbEvent)) - if (!(dbEvent.flags & DBEF_READ)) - count++; - - hEvent = db_event_next(hContact, hEvent); - } + reply->code = MIMRES_SUCCESS; + mir_snprintf(reply->message, _countof(reply->message), Translate("No unread messages found.")); - char protocol[128]; - GetContactProto(hContact, protocol, sizeof(protocol)); - char *contact = GetContactName(hContact, protocol); - mir_snprintf(buffer, _countof(buffer), Translate("%s:%s - %d unread events."), contact, protocol, count); + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + MEVENT hEvent = db_event_firstUnread(hContact); + if (hEvent != NULL) { + count = 0; + while (hEvent != NULL) { + if (!db_event_get(hEvent, &dbEvent)) + if (!(dbEvent.flags & DBEF_READ)) + count++; - if (contacts > 0) { - mir_strncat(reply->message, "\n", _countof(reply->message) - mir_strlen(reply->message)); - mir_strncat(reply->message, buffer, _countof(reply->message) - mir_strlen(reply->message)); - } - else strncpy_s(reply->message, buffer, _countof(reply->message)); + hEvent = db_event_next(hContact, hEvent); + } - contacts++; + char protocol[128]; + GetContactProto(hContact, protocol, sizeof(protocol)); + char *contact = GetContactName(hContact, protocol); + mir_snprintf(buffer, _countof(buffer), Translate("%s:%s - %d unread events."), contact, protocol, count); - free(contact); + if (contacts > 0) { + mir_strncat(reply->message, "\n", _countof(reply->message) - mir_strlen(reply->message)); + mir_strncat(reply->message, buffer, _countof(reply->message) - mir_strlen(reply->message)); } + else strncpy_s(reply->message, buffer, _countof(reply->message)); + + contacts++; + + free(contact); } } - else if (_stricmp(cmd, "show") == 0) - HandleWrongParametersCount(command, reply); - else - HandleUnknownParameter(command, cmd, reply); - - break; } + else if (_stricmp(cmd, "show") == 0) + HandleWrongParametersCount(command, reply); + else + HandleUnknownParameter(command, cmd, reply); + break; case 4: { char *contact = argv[3]; MCONTACT hContact = ParseContactParam(contact); - if (hContact) - { - if (_stricmp(cmd, "unread") == 0) - { + if (hContact) { + if (_stricmp(cmd, "unread") == 0) { MEVENT hEvent = db_event_firstUnread(hContact); reply->code = MIMRES_SUCCESS; @@ -1573,25 +1475,20 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Could not find contact handle for contact '%s'."), contact); } - - break; } + break; case 6: { char *contact = argv[3]; MCONTACT hContact = ParseContactParam(contact); - - if (hContact) - { - if (_stricmp(cmd, "show") == 0) - { + if (hContact) { + if (_stricmp(cmd, "show") == 0) { char *stop1 = NULL; char *stop2 = NULL; long start = strtol(argv[4], &stop1, 10); long stop = strtol(argv[5], &stop2, 10); - if (!(*stop1) && !(*stop2)) - { + if (!(*stop1) && !(*stop2)) { int size = db_event_count(hContact); if (start < 0) { start = size + start + 1; } if (stop < 0) { stop = size + stop + 1; } @@ -1599,16 +1496,14 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re reply->code = MIMRES_SUCCESS; int count = stop - start + 1; - if (count > 0) - { + if (count > 0) { int index = 0; MEVENT hEvent = db_event_first(hContact); DBEVENTINFO dbEvent = { sizeof(DBEVENTINFO) }; char message[4096]; - dbEvent.pBlob = (PBYTE) message; + dbEvent.pBlob = (PBYTE)message; - while (hEvent) - { + while (hEvent) { dbEvent.cbBlob = sizeof(message); if (!db_event_get(hEvent, &dbEvent)) // if successful call { @@ -1632,13 +1527,12 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re else HandleUnknownParameter(command, cmd, reply); } - else{ + else { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, _countof(reply->message), Translate("Could not find contact handle for contact '%s'."), contact); } - - break; } + break; default: HandleWrongParametersCount(command, reply); @@ -1650,39 +1544,34 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re void HandleVersionCommand(PCommand command, TArgument*, int argc, PReply reply) { - if (argc == 2) - { + if (argc == 2) { reply->code = MIMRES_SUCCESS; - if (ServiceExists(MS_CRASHDUMPER_GETINFO)) - { + if (ServiceExists(MS_CRASHDUMPER_GETINFO)) { char *data; CallService(MS_CRASHDUMPER_GETINFO, (WPARAM)FALSE, (LPARAM)&data); mir_snprintf(reply->message, _countof(reply->message), data); mir_free(data); } - else{ + else { char miranda[512]; DWORD v = pluginInfo.version; - CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(miranda), (LPARAM) miranda); + CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(miranda), (LPARAM)miranda); mir_snprintf(reply->message, _countof(reply->message), "Miranda %s\nCmdLine v.%d.%d.%d.%d", miranda, ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF), (v & 0xFF)); } } - else{ - HandleWrongParametersCount(command, reply); - } + else HandleWrongParametersCount(command, reply); } + void HandleSetNicknameCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc == 4) - { + if (argc == 4) { char protocol[512], nickname[512]; mir_strcpy(protocol, argv[2]); mir_strcpy(nickname, argv[3]); - int res = CallProtoService(protocol, PS_SETMYNICKNAME, SMNN_TCHAR, (LPARAM) nickname); + int res = CallProtoService(protocol, PS_SETMYNICKNAME, SMNN_TCHAR, (LPARAM)nickname); - if (res == 0) - { + if (res == 0) { reply->code = MIMRES_SUCCESS; *reply->message = 0; } @@ -1691,122 +1580,110 @@ void HandleSetNicknameCommand(PCommand command, TArgument *argv, int argc, PRepl mir_snprintf(reply->message, _countof(reply->message), Translate("Error setting nickname to '%s' for protocol '%s'"), nickname, protocol); } } - else { - HandleWrongParametersCount(command, reply); - } + else HandleWrongParametersCount(command, reply); } void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - if (argc >= 4) - { + if (argc >= 4) { BOOL block = FALSE; - if (_stricmp(argv[2], "block") == 0) - { + if (_stricmp(argv[2], "block") == 0) { block = TRUE; } - else if (_stricmp(argv[2], "unblock") == 0) - { + else if (_stricmp(argv[2], "unblock") == 0) { block = FALSE; } - else - { + else { HandleUnknownParameter(command, argv[2], reply); return; } - for (int i = 3; i < argc; i++) - { + for (int i = 3; i < argc; i++) { MCONTACT hContact = ParseContactParam(argv[i]); - if (hContact) - { - CallService(block ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, (WPARAM) hContact, IGNOREEVENT_ALL); + if (hContact) { + CallService(block ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, (WPARAM)hContact, IGNOREEVENT_ALL); } } reply->code = MIMRES_SUCCESS; *reply->message = 0; } - else { - HandleWrongParametersCount(command, reply); - } + else HandleWrongParametersCount(command, reply); } - void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply) { - switch (command->ID) - { - case MIMCMD_STATUS: - HandleStatusCommand(command, argv, argc, reply); - return; + switch (command->ID) { + case MIMCMD_STATUS: + HandleStatusCommand(command, argv, argc, reply); + return; - case MIMCMD_AWAYMSG: - HandleAwayMsgCommand(command, argv, argc, reply); - return; + case MIMCMD_AWAYMSG: + HandleAwayMsgCommand(command, argv, argc, reply); + return; - case MIMCMD_POPUPS: - HandlePopupsCommand(command, argv, argc, reply); - return; + case MIMCMD_POPUPS: + HandlePopupsCommand(command, argv, argc, reply); + return; - case MIMCMD_SOUNDS: - HandleSoundsCommand(command, argv, argc, reply); - return; + case MIMCMD_SOUNDS: + HandleSoundsCommand(command, argv, argc, reply); + return; - case MIMCMD_CLIST: - HandleClistCommand(command, argv, argc, reply); - return; + case MIMCMD_CLIST: + HandleClistCommand(command, argv, argc, reply); + return; - case MIMCMD_QUIT: - HandleQuitCommand(command, argv, argc, reply); - return; + case MIMCMD_QUIT: + HandleQuitCommand(command, argv, argc, reply); + return; - case MIMCMD_EXCHANGE: - HandleExchangeCommand(command, argv, argc, reply); - return; + case MIMCMD_EXCHANGE: + HandleExchangeCommand(command, argv, argc, reply); + return; - case MIMCMD_YAMN: - HandleYAMNCommand(command, argv, argc, reply); - return; + case MIMCMD_YAMN: + HandleYAMNCommand(command, argv, argc, reply); + return; - case MIMCMD_CALLSERVICE: - HandleCallServiceCommand(command, argv, argc, reply); - return; + case MIMCMD_CALLSERVICE: + HandleCallServiceCommand(command, argv, argc, reply); + return; - case MIMCMD_MESSAGE: - HandleMessageCommand(command, argv, argc, reply); - return; + case MIMCMD_MESSAGE: + HandleMessageCommand(command, argv, argc, reply); + return; - case MIMCMD_DATABASE: - HandleDatabaseCommand(command, argv, argc, reply); - return; + case MIMCMD_DATABASE: + HandleDatabaseCommand(command, argv, argc, reply); + return; - case MIMCMD_PROXY: - HandleProxyCommand(command, argv, argc, reply); - return; + case MIMCMD_PROXY: + HandleProxyCommand(command, argv, argc, reply); + return; - case MIMCMD_CONTACTS: - HandleContactsCommand(command, argv, argc, reply); - return; + case MIMCMD_CONTACTS: + HandleContactsCommand(command, argv, argc, reply); + return; - case MIMCMD_HISTORY: - HandleHistoryCommand(command, argv, argc, reply); - break; + case MIMCMD_HISTORY: + HandleHistoryCommand(command, argv, argc, reply); + break; - case MIMCMD_VERSION: - HandleVersionCommand(command, argv, argc, reply); - return; + case MIMCMD_VERSION: + HandleVersionCommand(command, argv, argc, reply); + return; - case MIMCMD_SETNICKNAME: - HandleSetNicknameCommand(command, argv, argc, reply); - return; + case MIMCMD_SETNICKNAME: + HandleSetNicknameCommand(command, argv, argc, reply); + return; - case MIMCMD_IGNORE: - HandleIgnoreCommand(command, argv, argc, reply); - return; + case MIMCMD_IGNORE: + HandleIgnoreCommand(command, argv, argc, reply); + return; - default: - reply->code = MIMRES_NOTFOUND; - mir_snprintf(reply->message, _countof(reply->message), Translate("Command '%s' is not currently supported."), command->command); + default: + reply->code = MIMRES_NOTFOUND; + mir_snprintf(reply->message, _countof(reply->message), Translate("Command '%s' is not currently supported."), command->command); } -} \ No newline at end of file +} diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index fdc788f2f7..83fff934c0 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -40,10 +40,10 @@ static IconItem iconList[] = static HGENMENU hSetPwdMenu; -static UINT oldLangID; +static ULONG_PTR oldLangID; void LanguageChanged(HWND hwndDlg) { - UINT LangID = (UINT)GetKeyboardLayout(0); + ULONG_PTR LangID = (ULONG_PTR)GetKeyboardLayout(0); char Lang[3] = { 0 }; if (LangID != oldLangID) { oldLangID = LangID; diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 6dfe850baf..7249e7bfc7 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -193,6 +193,8 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wPar INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + TCHAR text[256]; + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); @@ -307,7 +309,6 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (item = TreeView_GetSelection(hwnd2Tree)) { int type = MODULE; - TCHAR text[FLD_SIZE]; TVITEM tvi = { 0 }; tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.pszText = text; @@ -394,8 +395,6 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_REFRESH_SETS: TVITEM tvi; - - TCHAR text[FLD_SIZE]; tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.hItem = TreeView_GetSelection(hwnd2Tree); tvi.pszText = text; // modulename @@ -444,7 +443,6 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_FIX_RESIDENT: if (dlg(TranslateT("Delete resident settings from database?"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) { int cnt = fixResidentSettings(); - TCHAR text[MSG_SIZE]; mir_sntprintf(text, TranslateT("%d orphaned items deleted."), cnt); msg(text); } diff --git a/plugins/Dropbox/src/http_request.h b/plugins/Dropbox/src/http_request.h index 7a4bd11bb0..9e50ac9f0c 100644 --- a/plugins/Dropbox/src/http_request.h +++ b/plugins/Dropbox/src/http_request.h @@ -35,7 +35,6 @@ class HttpRequest : protected NETLIBHTTPREQUEST { private: CMStringA m_szUrl; - va_list formatArgs; void Init(int type) { diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp index eaebb50c58..1605aade4f 100644 --- a/plugins/FavContacts/src/menu.cpp +++ b/plugins/FavContacts/src/menu.cpp @@ -35,7 +35,7 @@ static TCHAR* sttGetGroupName(int id) return TranslateT("Favorite Contacts"); } - return pcli->pfnGetGroupName(id-1, NULL); + return pcli->pfnGetGroupName(id - 1, NULL); } static BOOL sttMeasureItem_Group(LPMEASUREITEMSTRUCT lpmis, Options *options) @@ -246,20 +246,20 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL) if (db_get_dw(hContact, proto, "IdleTS", 0)) { ImageList_DrawDimmed(hIml, iIcon, hdcTemp, - lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - ILD_TRANSPARENT); + lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, + ILD_TRANSPARENT); } else { ImageList_Draw(hIml, iIcon, hdcTemp, - lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - ILD_TRANSPARENT); + lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, + ILD_TRANSPARENT); } lpdis->rcItem.left += 20; if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0)) { DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - IcoLib_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL); + IcoLib_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL); lpdis->rcItem.right -= 20; } @@ -362,28 +362,28 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, switch (message) { case WM_MEASUREITEM: - { - LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; - if (lpmis->CtlType != ODT_MENU) - return FALSE; + { + LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; + if (lpmis->CtlType != ODT_MENU) + return FALSE; - if ((lpmis->itemID >= CLISTMENUIDMIN) && (lpmis->itemID <= CLISTMENUIDMAX)) - return Menu_MeasureItem(lpmis); + if ((lpmis->itemID >= CLISTMENUIDMIN) && (lpmis->itemID <= CLISTMENUIDMAX)) + return Menu_MeasureItem(lpmis); - return MenuMeasureItem(lpmis); - } + return MenuMeasureItem(lpmis); + } case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlType != ODT_MENU) - return FALSE; + { + LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; + if (lpdis->CtlType != ODT_MENU) + return FALSE; - if ((lpdis->itemID >= CLISTMENUIDMIN) && (lpdis->itemID <= CLISTMENUIDMAX)) - return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); + if ((lpdis->itemID >= CLISTMENUIDMIN) && (lpdis->itemID <= CLISTMENUIDMAX)) + return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); - return MenuDrawItem(lpdis); - } + return MenuDrawItem(lpdis); + } case WM_MENUCHAR: while (GetMenuItemCount((HMENU)lParam) > 1) @@ -391,7 +391,7 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, if (LOWORD(wParam) == VK_BACK) { if (size_t l = mir_tstrlen(g_filter)) - g_filter[l-1] = 0; + g_filter[l - 1] = 0; } else if (_istalnum(LOWORD(wParam))) { if (mir_tstrlen(g_filter) < _countof(g_filter) - 1) { @@ -402,11 +402,11 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, { int maxRecent = g_Options.wMaxRecent ? g_Options.wMaxRecent : 10; for (int i = 0, nRecent = 0; nRecent < maxRecent; ++i) { - MCONTACT hContact = g_contactCache->get(i); - if (!hContact) break; + MCONTACT cc = g_contactCache->get(i); + if (!cc) break; if (!g_contactCache->filter(i, g_filter)) continue; - AppendMenu((HMENU)lParam, MF_OWNERDRAW, nRecent + 1, (LPCTSTR)hContact); + AppendMenu((HMENU)lParam, MF_OWNERDRAW, nRecent + 1, (LPCTSTR)cc); ++nRecent; } } @@ -417,11 +417,12 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; GetMenuItemInfo((HMENU)lParam, wParam, TRUE, &mii); - MCONTACT hContact = (MCONTACT)mii.dwItemData; - if (!CallService(MS_DB_CONTACT_IS, mii.dwItemData, 0)) + + MCONTACT cc = (MCONTACT)mii.dwItemData; + if (!CallService(MS_DB_CONTACT_IS, cc, 0)) return FALSE; - HMENU hMenu = Menu_BuildContactMenu(hContact); + HMENU hMenu = Menu_BuildContactMenu(cc); POINT pt; GetCursorPos(&pt); @@ -474,8 +475,8 @@ int ShowMenu(bool centered) int groupID = -((int)Clist_GroupExists(favList[i]->getGroup()) + 1); AppendMenu(hMenu, - MF_OWNERDRAW | MF_SEPARATOR | ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0), - ++idItem, (LPCTSTR)groupID); + MF_OWNERDRAW | MF_SEPARATOR | ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0), + ++idItem, (LPCTSTR)groupID); mis.itemData = groupID; mis.itemID = idItem; diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp index 07f15974fb..e96410aef8 100644 --- a/plugins/FloatingContacts/src/main.cpp +++ b/plugins/FloatingContacts/src/main.cpp @@ -426,7 +426,7 @@ static LRESULT __stdcall CommWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM break; case WM_HOTKEY: - ThumbInfo *pThumb = thumbList.FindThumb((HWND)wParam); + pThumb = thumbList.FindThumb((HWND)wParam); if (pThumb) pThumb->PopupMessageDialog(); } @@ -581,7 +581,7 @@ static void CreateBackgroundBrush() hBkBrush = CreateSolidBrush(bkColor); // Attach brush to the window - SetClassLong((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG)hBkBrush); + SetClassLongPtr((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG_PTR)hBkBrush); } static int GetContactStatus(MCONTACT hContact) @@ -839,9 +839,9 @@ static LRESULT __stdcall newMirandaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, if (method) { WORD wBehindEdgeBorderSize = db_get_w(NULL, "ModernData", "HideBehindBorderSize", 0); RECT rc = { wp->x, wp->y, wp->x + wp->cx, wp->y + wp->cy }; - RECT rcScreen = { wBehindEdgeBorderSize*(2 - method), 0, GetSystemMetrics(SM_CXSCREEN) - wBehindEdgeBorderSize*(method - 1), GetSystemMetrics(SM_CYSCREEN) }; + RECT rcScr = { wBehindEdgeBorderSize*(2 - method), 0, GetSystemMetrics(SM_CXSCREEN) - wBehindEdgeBorderSize*(method - 1), GetSystemMetrics(SM_CYSCREEN) }; RECT rcOverlap; - BOOL isIntersect = IntersectRect(&rcOverlap, &rc, &rcScreen); + BOOL isIntersect = IntersectRect(&rcOverlap, &rc, &rcScr); if (!isIntersect && bIsCListShow) { bIsCListShow = FALSE; ShowThumbsOnHideCList(); diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index d92c3ce688..09c7afd088 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -882,12 +882,12 @@ void IEView::clear(IEVIEWEVENT *event) if (document == NULL) { pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL); HRESULT hr = S_OK; - CComPtr document; - while ((document == NULL) && (hr == S_OK)) { + CComPtr doc2; + while ((doc2 == NULL) && (hr == S_OK)) { Sleep(0); CComPtr dispatch; if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && dispatch != NULL) - dispatch.QueryInterface(&document); + dispatch.QueryInterface(&doc2); } } else { @@ -935,9 +935,9 @@ HWND IEView::getHWND() return hwnd; } -void IEView::setContact(MCONTACT hContact) +void IEView::setContact(MCONTACT _hContact) { - this->hContact = hContact; + hContact = _hContact; isContactSet = true; } @@ -1004,9 +1004,9 @@ WCHAR* IEView::getHrefFromAnchor(CComPtr element) return url; } - CComPtr parent; - if (SUCCEEDED(element->get_parentElement(&parent)) && parent != NULL) - return getHrefFromAnchor(parent); + CComPtr pParent; + if (SUCCEEDED(element->get_parentElement(&pParent)) && pParent != NULL) + return getHrefFromAnchor(pParent); return NULL; } diff --git a/plugins/IgnoreState/src/options.cpp b/plugins/IgnoreState/src/options.cpp index 26bd7df886..d6fac3275f 100644 --- a/plugins/IgnoreState/src/options.cpp +++ b/plugins/IgnoreState/src/options.cpp @@ -30,35 +30,35 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP switch (msg) { case WM_INITDIALOG: - { TranslateDialogDefault(hwndDlg); bInitializing = true; fill_filter(); SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE) | TVS_NOHSCROLL); - - HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); - TreeView_SetImageList(hTree, himlButtonIcons, TVSIL_NORMAL); - TreeView_DeleteAllItems(hTree); - - for (int i = 2; i < nII; i++) { // we don`t need it IGNORE_ALL and IGNORE_MESSAGE - TVINSERTSTRUCT tvis = { 0 }; - int index = ImageList_AddIcon(himlButtonIcons, Skin_LoadIcon(ii[i].icon)); - tvis.hParent = NULL; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; - tvis.item.lParam = ii[i].type; - tvis.item.pszText = TranslateTS(ii[i].name); - tvis.item.iImage = tvis.item.iSelectedImage = index; - HTREEITEM hti = TreeView_InsertItem(hTree, &tvis); - TreeView_SetCheckState(hTree, hti, checkState(ii[i].type)); + { + HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); + TreeView_SetImageList(hTree, himlButtonIcons, TVSIL_NORMAL); + TreeView_DeleteAllItems(hTree); + + for (int i = 2; i < nII; i++) { // we don`t need it IGNORE_ALL and IGNORE_MESSAGE + TVINSERTSTRUCT tvis = { 0 }; + int index = ImageList_AddIcon(himlButtonIcons, Skin_LoadIcon(ii[i].icon)); + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; + tvis.item.lParam = ii[i].type; + tvis.item.pszText = TranslateTS(ii[i].name); + tvis.item.iImage = tvis.item.iSelectedImage = index; + HTREEITEM hti = TreeView_InsertItem(hTree, &tvis); + TreeView_SetCheckState(hTree, hti, checkState(ii[i].type)); + } } CheckDlgButton(hwndDlg, IDC_IGNORE_IGNOREALL, bUseMirandaSettings ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), !bUseMirandaSettings); + bInitializing = false; - } - return TRUE; + return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -74,24 +74,23 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - { - DWORD flags = 0; - TVITEM tvi; - tvi.mask = TVIF_HANDLE | TBIF_LPARAM; - HWND hTree = GetDlgItem(hwndDlg, IDC_FILTER); - tvi.hItem = TreeView_GetRoot(hTree); //check ignore all - while (tvi.hItem) { - TreeView_GetItem(hTree, &tvi); - if (TreeView_GetCheckState(hTree, tvi.hItem)) flags |= 1 << (tvi.lParam - 1); - tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); + { + DWORD flags = 0; + TVITEM tvi; + tvi.mask = TVIF_HANDLE | TBIF_LPARAM; + tvi.hItem = TreeView_GetRoot(hTree); //check ignore all + while (tvi.hItem) { + TreeView_GetItem(hTree, &tvi); + if (TreeView_GetCheckState(hTree, tvi.hItem)) flags |= 1 << (tvi.lParam - 1); + tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem); + } + db_set_dw(NULL, MODULENAME, "Filter", flags); + + bUseMirandaSettings = IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL) ? 1 : 0; + db_set_b(NULL, MODULENAME, "UseMirandaSettings", bUseMirandaSettings); + + fill_filter(); } - db_set_dw(NULL, MODULENAME, "Filter", flags); - - bUseMirandaSettings = IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL) ? 1 : 0; - db_set_b(NULL, MODULENAME, "UseMirandaSettings", bUseMirandaSettings); - - fill_filter(); - } } case IDC_FILTER: if (((LPNMHDR)lParam)->code == NM_CLICK) diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp index a4033d0f57..f3ef7bd033 100644 --- a/plugins/KeyboardNotify/src/options.cpp +++ b/plugins/KeyboardNotify/src/options.cpp @@ -516,7 +516,7 @@ INT_PTR CALLBACK DlgProcBasicOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR while (!db_unset(NULL, KEYBDMODULE, fmtDBSettingName("process%d", i++))); if (XstatusListAux) - for (int i = 0; i < ProtoList.protoCount; i++) + for (i = 0; i < ProtoList.protoCount; i++) for (int j = 0; j < (int)XstatusListAux[i].count; j++) db_set_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), (BYTE)XstatusListAux[i].enabled[j]); @@ -930,8 +930,8 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_NOTIFY: { int count; - TCHAR theme[MAX_PATH + 1], themeAux[MAX_PATH + 1], *str; - //Here we have pressed either the OK or the APPLY button. + TCHAR theme[MAX_PATH + 1], themeAux[MAX_PATH + 1]; + // Here we have pressed either the OK or the APPLY button. switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { @@ -1330,6 +1330,7 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (msg) { case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); { WPARAM j; TVINSERTSTRUCT tvis = { 0 }; @@ -1337,7 +1338,6 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA HTREEITEM hSectionItem, hItem; HWND hwndTree = GetDlgItem(hwndDlg, IDC_TREE_XSTATUS); - TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); if (!XstatusListAux) return TRUE; diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 8a8e771d45..d0935dd0f6 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -26,7 +26,7 @@ CAppletManager::CAppletManager() m_uiTimer = NULL; m_pLastScreen = NULL; - + } //************************************************************************ @@ -42,9 +42,9 @@ CAppletManager::~CAppletManager() //************************************************************************ bool CAppletManager::Initialize(tstring strAppletName) { - if(!CLCDOutputManager::Initialize(strAppletName)) + if (!CLCDOutputManager::Initialize(strAppletName)) return false; - + GetLCDConnection()->Connect(CConfig::GetIntSetting(DEVICE)); // set the volumewheel hook @@ -70,16 +70,16 @@ bool CAppletManager::Initialize(tstring strAppletName) ActivateScreen(&m_EventScreen); // hook the neccessary events - m_hMIHookMessageWindowEvent = HookEvent(ME_MSG_WINDOWEVENT,CAppletManager::HookMessageWindowEvent); + m_hMIHookMessageWindowEvent = HookEvent(ME_MSG_WINDOWEVENT, CAppletManager::HookMessageWindowEvent); m_hMIHookEventAdded = HookEvent(ME_DB_EVENT_ADDED, CAppletManager::HookEventAdded); - m_hMIHookStatusChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, CAppletManager::HookStatusChanged); - m_hMIHookProtoAck = HookEvent(ME_PROTO_ACK, CAppletManager::HookProtoAck); - m_hMIHookContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, CAppletManager::HookContactDeleted); - m_hMIHookContactAdded = HookEvent(ME_DB_CONTACT_ADDED, CAppletManager::HookContactAdded); - m_hMIHookSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,CAppletManager::HookSettingChanged); - m_hMIHookContactIsTyping = HookEvent(ME_PROTO_CONTACTISTYPING,CAppletManager::HookContactIsTyping); - m_hMIHookChatEvent = HookEvent(ME_GC_HOOK_EVENT,CAppletManager::HookChatInbound); - + m_hMIHookStatusChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, CAppletManager::HookStatusChanged); + m_hMIHookProtoAck = HookEvent(ME_PROTO_ACK, CAppletManager::HookProtoAck); + m_hMIHookContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, CAppletManager::HookContactDeleted); + m_hMIHookContactAdded = HookEvent(ME_DB_CONTACT_ADDED, CAppletManager::HookContactAdded); + m_hMIHookSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, CAppletManager::HookSettingChanged); + m_hMIHookContactIsTyping = HookEvent(ME_PROTO_CONTACTISTYPING, CAppletManager::HookContactIsTyping); + m_hMIHookChatEvent = HookEvent(ME_GC_HOOK_EVENT, CAppletManager::HookChatInbound); + // enumerate protocols int iCount; int iProtoCount = 0; @@ -88,8 +88,7 @@ bool CAppletManager::Initialize(tstring strAppletName) CIRCConnection *pIRCConnection = NULL; Proto_EnumAccounts(&iCount, &ppAccounts); - for(int i=0;itype != PROTOTYPE_PROTOCOL) continue;**/ if (ppAccounts[i]->bIsEnabled == 0) @@ -100,7 +99,7 @@ bool CAppletManager::Initialize(tstring strAppletName) pProtoData->iStatus = ID_STATUS_OFFLINE; pProtoData->strProtocol = toTstring(ppAccounts[i]->szModuleName); pProtoData->lTimeStamp = 0; - + // try to create an irc connection for that protocol (will fail if it is no irc protocol) pIRCConnection = CreateIRCConnection(pProtoData->strProtocol); @@ -108,27 +107,27 @@ bool CAppletManager::Initialize(tstring strAppletName) } // load status bitmaps - m_ahStatusBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OFFLINE),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_ONLINE),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_AWAY),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_NA),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[4] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OCCUPIED),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[5] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_DND),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[6] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_INVISIBLE),IMAGE_BITMAP,5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[7] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_FFC),IMAGE_BITMAP,5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OFFLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_ONLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_AWAY), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_NA), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[4] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OCCUPIED), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[5] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_DND), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[6] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_INVISIBLE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[7] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_FFC), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); // Load event bitmaps - m_ahEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG),IMAGE_BITMAP,6, 6, LR_MONOCHROME); - m_ahEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON),IMAGE_BITMAP,6, 6, LR_MONOCHROME); - m_ahEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER),IMAGE_BITMAP,6, 6, LR_MONOCHROME); - m_ahEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO),IMAGE_BITMAP,6, 6, LR_MONOCHROME); - - m_ahLargeEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG_LARGE),IMAGE_BITMAP,8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON_LARGE),IMAGE_BITMAP,8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER_LARGE),IMAGE_BITMAP,8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO_LARGE),IMAGE_BITMAP,8, 8, LR_MONOCHROME); + m_ahEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + + m_ahLargeEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); // start the update timer - m_uiTimer = SetTimer(0,0,1000/10,CAppletManager::UpdateTimer); + m_uiTimer = SetTimer(0, 0, 1000 / 10, CAppletManager::UpdateTimer); return true; } @@ -138,20 +137,19 @@ bool CAppletManager::Initialize(tstring strAppletName) //************************************************************************ bool CAppletManager::Shutdown() { - if(!IsInitialized()) + if (!IsInitialized()) return false; // stop the update timer KillTimer(0, m_uiTimer); - + // delete status bitmaps - for(int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) DeleteObject(m_ahStatusBitmaps[i]); // delete event bitmaps - for(int i = 0; i < 4; i++) - { - DeleteObject(m_ahLargeEventBitmaps[i]); + for (int i = 0; i < 4; i++) { + DeleteObject(m_ahLargeEventBitmaps[i]); DeleteObject(m_ahEventBitmaps[i]); } @@ -167,13 +165,12 @@ bool CAppletManager::Shutdown() // unhook all irc protocols, and delete the classes vector::iterator iter = m_vIRCConnections.begin(); - while(iter != m_vIRCConnections.end()) - { + while (iter != m_vIRCConnections.end()) { delete *iter; iter++; } m_vIRCConnections.clear(); - + // Deinitialize the screens m_NotificationScreen.Shutdown(); m_EventScreen.Shutdown(); @@ -184,18 +181,17 @@ bool CAppletManager::Shutdown() // deinitialize the configuration manager CConfig::Shutdown(); - + // delete the protocol information CProtocolData *pProtoData; - for(vector::size_type i = 0; i < m_vProtocolData.size(); i++) - { + for (vector::size_type i = 0; i < m_vProtocolData.size(); i++) { pProtoData = m_vProtocolData[i]; delete pProtoData; } m_vProtocolData.clear(); // deinitialize the outputmanager - if(!CLCDOutputManager::Shutdown()) + if (!CLCDOutputManager::Shutdown()) return false; return true; } @@ -203,7 +199,7 @@ bool CAppletManager::Shutdown() //************************************************************************ // Translates the specified string, and inserts the parameters //************************************************************************ -tstring CAppletManager::TranslateString(TCHAR *szString,...) +tstring CAppletManager::TranslateString(TCHAR *szString, ...) { TCHAR out[1024]; TCHAR *szTranslatedString = TranslateTS(szString); @@ -220,7 +216,7 @@ tstring CAppletManager::TranslateString(TCHAR *szString,...) //************************************************************************ bool CAppletManager::IsIRCHookEnabled() { - if(m_vIRCConnections.size() == NULL) + if (m_vIRCConnections.size() == NULL) return false; return true; } @@ -242,56 +238,52 @@ CProtocolData* CAppletManager::GetProtocolData(tstring strProtocol) //************************************************************************ bool CAppletManager::Update() { - if(!CLCDOutputManager::Update()) + if (!CLCDOutputManager::Update()) return false; - + // Update Messagejobs UpdateMessageJobs(); // Screensaver detection BOOL bActive = false; SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &bActive, 0); - if(bActive != (BOOL)m_bScreensaver) - { - if(CConfig::GetBoolSetting(SCREENSAVER_LOCK)) { - if(!m_bScreensaver) + if (bActive != (BOOL)m_bScreensaver) { + if (CConfig::GetBoolSetting(SCREENSAVER_LOCK)) { + if (!m_bScreensaver) ActivateScreensaverScreen(); else ActivateEventScreen(); } - if(CConfig::GetBoolSetting(CONTROL_BACKLIGHTS)) { - if(GetLCDConnection() && - GetLCDConnection()->GetConnectionType() == TYPE_LOGITECH) - { + if (CConfig::GetBoolSetting(CONTROL_BACKLIGHTS)) { + if (GetLCDConnection() && + GetLCDConnection()->GetConnectionType() == TYPE_LOGITECH) { CLCDConnectionLogitech *pLCDConnection = (CLCDConnectionLogitech*)GetLCDConnection(); - + // Screensaver starts - if(!m_bScreensaver) - { + if (!m_bScreensaver) { m_G15LightStatus = pLCDConnection->GetLightStatus(); pLCDConnection->SetLCDBacklight(LCD_OFF); pLCDConnection->SetKBDBacklight(KBD_OFF); - pLCDConnection->SetMKeyLight(0,0,0,0); + pLCDConnection->SetMKeyLight(0, 0, 0, 0); } // Screensaver ends - else - { + else { SG15LightStatus currentStatus = pLCDConnection->GetLightStatus(); - - if(currentStatus.eLCDBrightness == LCD_OFF) + + if (currentStatus.eLCDBrightness == LCD_OFF) pLCDConnection->SetLCDBacklight(m_G15LightStatus.eLCDBrightness); - if(currentStatus.eKBDBrightness == KBD_OFF) + if (currentStatus.eKBDBrightness == KBD_OFF) pLCDConnection->SetKBDBacklight(m_G15LightStatus.eKBDBrightness); - if(!currentStatus.bMRKey && !currentStatus.bMKey[0] && !currentStatus.bMKey[1] - && !currentStatus.bMKey[2]) - pLCDConnection->SetMKeyLight(m_G15LightStatus.bMKey[0],m_G15LightStatus.bMKey[1],m_G15LightStatus.bMKey[2],m_G15LightStatus.bMRKey); + if (!currentStatus.bMRKey && !currentStatus.bMKey[0] && !currentStatus.bMKey[1] + && !currentStatus.bMKey[2]) + pLCDConnection->SetMKeyLight(m_G15LightStatus.bMKey[0], m_G15LightStatus.bMKey[1], m_G15LightStatus.bMKey[2], m_G15LightStatus.bMRKey); } } } m_bScreensaver = bActive != 0; } - return true; + return true; } //************************************************************************ @@ -300,10 +292,9 @@ bool CAppletManager::Update() void CAppletManager::OnScreenExpired(CLCDScreen *pScreen) { // If the notification screen has expired, activate the last active screen - if(pScreen == (CLCDScreen*)&m_NotificationScreen) - { + if (pScreen == (CLCDScreen*)&m_NotificationScreen) { ActivateScreen(m_pLastScreen); - if(CConfig::GetBoolSetting(TRANSITIONS)) + if (CConfig::GetBoolSetting(TRANSITIONS)) m_pGfx->StartTransition(); } } @@ -322,10 +313,9 @@ VOID CALLBACK CAppletManager::UpdateTimer(HWND, UINT, UINT_PTR, DWORD) void CAppletManager::SetVolumeWheelHook() { // Set the volumewheel hook - if(GetLCDConnection() && GetLCDConnection()->GetConnectionType() == TYPE_LOGITECH) - { + if (GetLCDConnection() && GetLCDConnection()->GetConnectionType() == TYPE_LOGITECH) { CLCDConnectionLogitech *pLCDConnection = (CLCDConnectionLogitech*)GetLCDConnection(); - if(pLCDConnection->GetConnectionState() == CONNECTED) + if (pLCDConnection->GetConnectionState() == CONNECTED) pLCDConnection->SetVolumeWheelHook(CConfig::GetBoolSetting(HOOK_VOLUMEWHEEL)); } } @@ -335,8 +325,7 @@ void CAppletManager::SetVolumeWheelHook() //************************************************************************ void CAppletManager::OnConnectionChanged(int iConnectionState) { - if(iConnectionState == CONNECTED) - { + if (iConnectionState == CONNECTED) { SetVolumeWheelHook(); } CConfig::OnConnectionChanged(); @@ -363,8 +352,9 @@ void CAppletManager::OnConfigChanged() //************************************************************************ // activate a screen //************************************************************************ -void CAppletManager::ActivateScreen(CScreen *pScreen) { - if(GetActiveScreen() && GetActiveScreen() != &m_NotificationScreen) { +void CAppletManager::ActivateScreen(CScreen *pScreen) +{ + if (GetActiveScreen() && GetActiveScreen() != &m_NotificationScreen) { m_pLastScreen = (CScreen*)GetActiveScreen(); } @@ -374,12 +364,13 @@ void CAppletManager::ActivateScreen(CScreen *pScreen) { //************************************************************************ // activates the previous screen //************************************************************************ -void CAppletManager::ActivatePreviousScreen() { - if(m_pLastScreen) { +void CAppletManager::ActivatePreviousScreen() +{ + if (m_pLastScreen) { ActivateScreen(m_pLastScreen); } } - + //************************************************************************ // activates the credits screen //************************************************************************ @@ -406,7 +397,7 @@ void CAppletManager::ActivateEventScreen() m_ChatScreen.SetContact(NULL); ActivateScreen(&m_EventScreen); - if(CConfig::GetBoolSetting(TRANSITIONS)) + if (CConfig::GetBoolSetting(TRANSITIONS)) m_pGfx->StartTransition(); } @@ -419,7 +410,7 @@ void CAppletManager::ActivateCListScreen() m_ContactlistScreen.ResetPosition(); ActivateScreen(&m_ContactlistScreen); - if(CConfig::GetBoolSetting(TRANSITIONS)) + if (CConfig::GetBoolSetting(TRANSITIONS)) m_pGfx->StartTransition(); } @@ -428,13 +419,13 @@ void CAppletManager::ActivateCListScreen() //************************************************************************ bool CAppletManager::ActivateChatScreen(MCONTACT hContact) { - if(!m_ChatScreen.SetContact(hContact)) + if (!m_ChatScreen.SetContact(hContact)) return false; m_ContactlistScreen.OnSessionOpened(hContact); ActivateScreen(&m_ChatScreen); - - if(CConfig::GetBoolSetting(TRANSITIONS)) + + if (CConfig::GetBoolSetting(TRANSITIONS)) m_pGfx->StartTransition(); return true; } @@ -442,15 +433,15 @@ bool CAppletManager::ActivateChatScreen(MCONTACT hContact) //************************************************************************ // returns the contacts displayname //************************************************************************ -tstring CAppletManager::GetContactDisplayname(MCONTACT hContact,bool bShortened) +tstring CAppletManager::GetContactDisplayname(MCONTACT hContact, bool bShortened) { - if(!bShortened || !CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF)) + if (!bShortened || !CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF)) return pcli->pfnGetContactDisplayName(hContact, 0); - - tstring strNick = GetContactDisplayname(hContact,false); - if(strNick.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + + tstring strNick = GetContactDisplayname(hContact, false); + if (strNick.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) return strNick.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); - + return strNick; } @@ -460,12 +451,12 @@ tstring CAppletManager::GetContactDisplayname(MCONTACT hContact,bool bShortened) tstring CAppletManager::GetContactGroup(MCONTACT hContact) { DBVARIANT dbv; - int res = db_get_ts(hContact, "CList", "Group", &dbv); + int res = db_get_ts(hContact, "CList", "Group", &dbv); tstring strGroup = _T(""); - if(!res) + if (!res) strGroup = dbv.ptszVal; - + db_free(&dbv); return strGroup; } @@ -475,32 +466,31 @@ tstring CAppletManager::GetContactGroup(MCONTACT hContact) //************************************************************************ HBITMAP CAppletManager::GetEventBitmap(EventType eType, bool bLarge) { - switch(eType) - { + switch (eType) { case EVENT_MSG_RECEIVED: case EVENT_MSG_SENT: case EVENT_IRC_RECEIVED: case EVENT_IRC_SENT: - if(bLarge) + if (bLarge) return m_ahLargeEventBitmaps[0]; else return m_ahEventBitmaps[0]; case EVENT_PROTO_STATUS: case EVENT_PROTO_CONNECTED: case EVENT_PROTO_DISCONNECTED: - if(bLarge) + if (bLarge) return m_ahLargeEventBitmaps[1]; else return m_ahEventBitmaps[1]; case EVENT_STATUS: case EVENT_SIGNED_ON: case EVENT_SIGNED_OFF: - if(bLarge) + if (bLarge) return m_ahLargeEventBitmaps[2]; else return m_ahEventBitmaps[2]; default: - if(bLarge) + if (bLarge) return m_ahLargeEventBitmaps[3]; else return m_ahEventBitmaps[3]; @@ -512,8 +502,7 @@ HBITMAP CAppletManager::GetEventBitmap(EventType eType, bool bLarge) //************************************************************************ HBITMAP CAppletManager::GetStatusBitmap(int iStatus) { - switch(iStatus) - { + switch (iStatus) { case ID_STATUS_OFFLINE: return m_ahStatusBitmaps[0]; case ID_STATUS_ONLINE: @@ -541,23 +530,21 @@ tstring CAppletManager::GetFormattedTimestamp(tm *tm_time) time_t now; tm tm_now; time(&now); - localtime_s(&tm_now,&now); + localtime_s(&tm_now, &now); TCHAR buffer[128]; - - if(tm_time->tm_mday != tm_now.tm_mday || tm_time->tm_mon != tm_now.tm_mon) - { - if(CConfig::GetBoolSetting(TIMESTAMP_SECONDS)) - _tcsftime(buffer,128,_T("[%x %H:%M:%S]"),tm_time); + + if (tm_time->tm_mday != tm_now.tm_mday || tm_time->tm_mon != tm_now.tm_mon) { + if (CConfig::GetBoolSetting(TIMESTAMP_SECONDS)) + _tcsftime(buffer, 128, _T("[%x %H:%M:%S]"), tm_time); else - _tcsftime(buffer,128,_T("[%x %H:%M]"),tm_time); + _tcsftime(buffer, 128, _T("[%x %H:%M]"), tm_time); } - else - { - if(CConfig::GetBoolSetting(TIMESTAMP_SECONDS)) - _tcsftime(buffer,128,_T("[%H:%M:%S]"),tm_time); + else { + if (CConfig::GetBoolSetting(TIMESTAMP_SECONDS)) + _tcsftime(buffer, 128, _T("[%H:%M:%S]"), tm_time); else - _tcsftime(buffer,128,_T("[%H:%M]"),tm_time); + _tcsftime(buffer, 128, _T("[%H:%M]"), tm_time); } return toTstring(buffer); @@ -568,43 +555,39 @@ tstring CAppletManager::GetFormattedTimestamp(tm *tm_time) //************************************************************************ void CAppletManager::HandleEvent(CEvent *pEvent) { - TRACE(_T("<< Event: %i\n"),(int)pEvent->eType); - + TRACE(_T("<< Event: %i\n"), (int)pEvent->eType); + // check if the event's timestamp needs to be set - if(!pEvent->bTime) - { + if (!pEvent->bTime) { time_t now; time(&now); - localtime_s(&pEvent->Time,&now); + localtime_s(&pEvent->Time, &now); } // check wether the event needs notification - + // check for protocol filters - if(pEvent->hContact != NULL && pEvent->eType != EVENT_CONTACT_ADDED) - { + if (pEvent->hContact != NULL && pEvent->eType != EVENT_CONTACT_ADDED) { char *szProto = GetContactProto(pEvent->hContact); - if(szProto == NULL || !CConfig::GetProtocolNotificationFilter(toTstring(szProto))) + if (szProto == NULL || !CConfig::GetProtocolNotificationFilter(toTstring(szProto))) pEvent->bNotification = false; } pEvent->bLog = pEvent->bNotification; - if(db_mc_isSub(pEvent->hContact)) - { + if (db_mc_isSub(pEvent->hContact)) { pEvent->bLog = false; pEvent->bNotification = false; } // if the applet is in foreground, skip notifications for the chatsession contact - if(pEvent->hContact && GetLCDConnection()->IsForeground() && pEvent->hContact == m_ChatScreen.GetContact() && - (!m_ChatScreen.IsInputActive() || !CConfig::GetBoolSetting(NOTIFY_NO_SKIP_REPLY))) - { - if(pEvent->eType == EVENT_STATUS && CConfig::GetBoolSetting(NOTIFY_SKIP_STATUS)) + if (pEvent->hContact && GetLCDConnection()->IsForeground() && pEvent->hContact == m_ChatScreen.GetContact() && + (!m_ChatScreen.IsInputActive() || !CConfig::GetBoolSetting(NOTIFY_NO_SKIP_REPLY))) { + if (pEvent->eType == EVENT_STATUS && CConfig::GetBoolSetting(NOTIFY_SKIP_STATUS)) pEvent->bNotification = false; - if( pEvent->eType == EVENT_SIGNED_ON && CConfig::GetBoolSetting(NOTIFY_SKIP_SIGNON)) + if (pEvent->eType == EVENT_SIGNED_ON && CConfig::GetBoolSetting(NOTIFY_SKIP_SIGNON)) pEvent->bNotification = false; - if(pEvent->eType == EVENT_SIGNED_OFF && CConfig::GetBoolSetting(NOTIFY_SKIP_SIGNOFF)) + if (pEvent->eType == EVENT_SIGNED_OFF && CConfig::GetBoolSetting(NOTIFY_SKIP_SIGNOFF)) pEvent->bNotification = false; - if((pEvent->eType == EVENT_IRC_RECEIVED || pEvent->eType == EVENT_MSG_RECEIVED) && CConfig::GetBoolSetting(NOTIFY_SKIP_MESSAGES)) + if ((pEvent->eType == EVENT_IRC_RECEIVED || pEvent->eType == EVENT_MSG_RECEIVED) && CConfig::GetBoolSetting(NOTIFY_SKIP_MESSAGES)) pEvent->bNotification = false; } @@ -615,15 +598,13 @@ void CAppletManager::HandleEvent(CEvent *pEvent) m_ContactlistScreen.OnEventReceived(pEvent); // activate notification screen if neccessary (and screensaverscreen is not active) - if(pEvent->bNotification) - { - if(GetActiveScreen() != (CLCDScreen*)&m_NotificationScreen && GetActiveScreen() != (CLCDScreen*)&m_ScreensaverScreen) - { + if (pEvent->bNotification) { + if (GetActiveScreen() != (CLCDScreen*)&m_NotificationScreen && GetActiveScreen() != (CLCDScreen*)&m_ScreensaverScreen) { m_NotificationScreen.SetAlert(true); - m_NotificationScreen.SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION)*1000); + m_NotificationScreen.SetExpiration(CConfig::GetIntSetting(NOTIFY_DURATION) * 1000); ActivateScreen(&m_NotificationScreen); - if(GetLCDConnection()->IsForeground() && CConfig::GetBoolSetting(TRANSITIONS)) + if (GetLCDConnection()->IsForeground() && CConfig::GetBoolSetting(TRANSITIONS)) m_pGfx->StartTransition(); } } @@ -635,11 +616,9 @@ void CAppletManager::HandleEvent(CEvent *pEvent) void CAppletManager::UpdateMessageJobs() { list::iterator iter = m_MessageJobs.begin(); - while(iter != m_MessageJobs.end()) - { + while (iter != m_MessageJobs.end()) { // TODO: Fertigstellen - if((*iter)->dwTimestamp + 15*1000 < GetTickCount()) - { + if ((*iter)->dwTimestamp + 15 * 1000 < GetTickCount()) { CEvent Event; Event.eType = EVENT_MESSAGE_ACK; @@ -647,7 +626,7 @@ void CAppletManager::UpdateMessageJobs() Event.hContact = (*iter)->hContact; Event.iValue = ACKRESULT_FAILED; Event.strValue = TranslateString(_T("Timeout: No response from contact/server")); - + HandleEvent(&Event); SMessageJob *pJob = *iter; @@ -674,34 +653,32 @@ void CAppletManager::AddMessageJob(SMessageJob *pJob) void CAppletManager::FinishMessageJob(SMessageJob *pJob) { list::iterator iter = m_MessageJobs.begin(); - while(iter != m_MessageJobs.end()) - { - if((*iter) == pJob) - { + while (iter != m_MessageJobs.end()) { + if ((*iter) == pJob) { char *szProto = GetContactProto(pJob->hContact); tstring strProto = toTstring(szProto); CIRCConnection *pIRCCon = GetIRCConnection(strProto); // Only add the message to the history if the contact isn't an irc chatroom - if(!(pIRCCon && db_get_b(pJob->hContact, szProto, "ChatRoom", 0) != 0)) - { + if (!(pIRCCon && db_get_b(pJob->hContact, szProto, "ChatRoom", 0) != 0)) { // Add the message to the database DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; - dbei.flags = DBEF_SENT | DBEF_UTF; + dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = szProto; dbei.timestamp = time(NULL); // Check if protocoll is valid - if(dbei.szModule == NULL) + if (dbei.szModule == NULL) return; dbei.cbBlob = pJob->iBufferSize; - dbei.pBlob = (PBYTE) pJob->pcBuffer; + dbei.pBlob = (PBYTE)pJob->pcBuffer; db_event_add(pJob->hContact, &dbei); } - SMessageJob *pJob = *iter; + + pJob = *iter; m_MessageJobs.erase(iter); free(pJob->pcBuffer); delete(pJob); @@ -716,11 +693,9 @@ void CAppletManager::FinishMessageJob(SMessageJob *pJob) void CAppletManager::CancelMessageJob(SMessageJob *pJob) { list::iterator iter = m_MessageJobs.begin(); - while(iter != m_MessageJobs.end()) - { - if((*iter) == pJob) - { - SMessageJob *pJob = *iter; + while (iter != m_MessageJobs.end()) { + if ((*iter) == pJob) { + pJob = *iter; m_MessageJobs.erase(iter); free(pJob->pcBuffer); delete(pJob); @@ -732,47 +707,47 @@ void CAppletManager::CancelMessageJob(SMessageJob *pJob) //************************************************************************ // sends typing notifications to the specified contact //************************************************************************ -void CAppletManager::SendTypingNotification(MCONTACT hContact,bool bEnable) +void CAppletManager::SendTypingNotification(MCONTACT hContact, bool bEnable) { if (!hContact) - return; + return; - // Don't send to protocols who don't support typing - // Don't send to users who are unchecked in the typing notification options - // Don't send to protocols that are offline - // Don't send to users who are not visible and - // Don't send to users who are not on the visible list when you are in invisible mode. - if (!db_get_b(hContact, "SRMsg", "SupportTyping", db_get_b(NULL, "SRMsg", "DefaultTyping", 1))) - return; + // Don't send to protocols who don't support typing + // Don't send to users who are unchecked in the typing notification options + // Don't send to protocols that are offline + // Don't send to users who are not visible and + // Don't send to users who are not on the visible list when you are in invisible mode. + if (!db_get_b(hContact, "SRMsg", "SupportTyping", db_get_b(NULL, "SRMsg", "DefaultTyping", 1))) + return; char *szProto = GetContactProto(hContact); - if (!szProto) - return; - - DWORD typeCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0); - if (!(typeCaps & PF4_SUPPORTTYPING)) - return; - - DWORD protoStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); - if (protoStatus < ID_STATUS_ONLINE) - return; - - DWORD protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); - if (protoCaps & PF1_VISLIST && db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE) - return; - if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(hContact, szProto, "ApparentMode", 0) != ID_STATUS_ONLINE) - return; - if (db_get_b(hContact, "CList", "NotOnList", 0) - && !db_get_b(NULL, "SRMsg", "UnknownTyping", 1)) - return; - // End user check + if (!szProto) + return; + + DWORD typeCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0); + if (!(typeCaps & PF4_SUPPORTTYPING)) + return; + + DWORD protoStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); + if (protoStatus < ID_STATUS_ONLINE) + return; + + DWORD protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); + if (protoCaps & PF1_VISLIST && db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE) + return; + if (protoCaps & PF1_INVISLIST && protoStatus == ID_STATUS_INVISIBLE && db_get_w(hContact, szProto, "ApparentMode", 0) != ID_STATUS_ONLINE) + return; + if (db_get_b(hContact, "CList", "NotOnList", 0) + && !db_get_b(NULL, "SRMsg", "UnknownTyping", 1)) + return; + // End user check CallService(MS_PROTO_SELFISTYPING, hContact, bEnable ? PROTOTYPE_SELFTYPING_ON : PROTOTYPE_SELFTYPING_OFF); } //************************************************************************ // sends a message to the specified contact //************************************************************************ -MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact,tstring strMessage) +MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessage) { tstring strAscii = _A2T(toNarrowString(strMessage).c_str()); SMessageJob *pJob = new SMessageJob(); @@ -784,12 +759,11 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact,tstring strMessage CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(strProto); - if(pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) - { + if (pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) { GCDEST gcd = { szProto, 0, GC_EVENT_SENDMESSAGE }; DBVARIANT dbv; - if (!db_get_ts(hContact, szProto, "Nick", &dbv)) + if (!db_get_ts(hContact, szProto, "Nick", &dbv)) gcd.ptszID = dbv.ptszVal; else return NULL; @@ -802,22 +776,21 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact,tstring strMessage gce.ptszText = (LPTSTR)strAscii.c_str(); gce.time = time(NULL); gce.bIsMe = true; - CallService(MS_GC_EVENT, NULL, (LPARAM) &gce); + CallService(MS_GC_EVENT, NULL, (LPARAM)&gce); pJob->hEvent = NULL; } - else - { + else { char* szMsgUtf = mir_utf8encodeW(strMessage.c_str()); - pJob->iBufferSize = (int)mir_strlen(szMsgUtf)+1; + pJob->iBufferSize = (int)mir_strlen(szMsgUtf) + 1; pJob->pcBuffer = (char *)malloc(pJob->iBufferSize); pJob->dwFlags = 0; - memcpy(pJob->pcBuffer,szMsgUtf,pJob->iBufferSize); + memcpy(pJob->pcBuffer, szMsgUtf, pJob->iBufferSize); mir_free(szMsgUtf); - pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer ); + pJob->hEvent = (MEVENT)CallContactService(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer); CAppletManager::GetInstance()->AddMessageJob(pJob); } @@ -836,8 +809,8 @@ bool CAppletManager::IsMessageWindowOpen(MCONTACT hContact) MessageWindowData mwd; mwd.cbSize = sizeof(MessageWindowData); - CallService(MS_MSG_GETWINDOWDATA,(WPARAM)&mwid,(LPARAM)&mwd); - if(mwd.uState & MSG_WINDOW_STATE_EXISTS) + CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd); + if (mwd.uState & MSG_WINDOW_STATE_EXISTS) return true; return false; } @@ -845,7 +818,7 @@ bool CAppletManager::IsMessageWindowOpen(MCONTACT hContact) //************************************************************************ // marks the given message as read //************************************************************************ -void CAppletManager::MarkMessageAsRead(MCONTACT hContact,MEVENT hEvent) +void CAppletManager::MarkMessageAsRead(MCONTACT hContact, MEVENT hEvent) { db_event_markRead(hContact, hEvent); CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM)hEvent); @@ -862,23 +835,22 @@ bool CAppletManager::TranslateDBEvent(CEvent *pEvent, WPARAM hContact, LPARAM hd //dbevent.flags |= PREF_UNICODE; dbevent.cbSize = sizeof(dbevent); dbevent.cbBlob = db_event_getBlobSize(hdbevent); - if(dbevent.cbBlob == -1) // hdbevent is invalid + if (dbevent.cbBlob == -1) // hdbevent is invalid { return false; } dbevent.pBlob = (PBYTE)malloc(dbevent.cbBlob); - if(db_event_get(hdbevent, &dbevent) != 0) - { + if (db_event_get(hdbevent, &dbevent) != 0) { free(dbevent.pBlob); return false; } - + pEvent->dwFlags = dbevent.flags; pEvent->hContact = hContact; pEvent->hValue = hdbevent; time_t timestamp = (time_t)dbevent.timestamp; - localtime_s(&pEvent->Time,×tamp); + localtime_s(&pEvent->Time, ×tamp); pEvent->bTime = true; /* if(dbevent.eventType == EVENTTYPE_MESSAGE && dbevent.flags & DBEF_READ) { @@ -887,70 +859,70 @@ bool CAppletManager::TranslateDBEvent(CEvent *pEvent, WPARAM hContact, LPARAM hd } */ // Skip events from the user except for messages - if(dbevent.eventType != EVENTTYPE_MESSAGE && (dbevent.flags & DBEF_SENT)) - { + if (dbevent.eventType != EVENTTYPE_MESSAGE && (dbevent.flags & DBEF_SENT)) { free(dbevent.pBlob); return false; } - + int msglen = 0; - tstring strName = CAppletManager::GetContactDisplayname(hContact,true); - - switch(dbevent.eventType) { + tstring strName = CAppletManager::GetContactDisplayname(hContact, true); + + switch (dbevent.eventType) { case EVENTTYPE_MESSAGE: - msglen = (int)mir_strlen((char *) dbevent.pBlob) + 1; + msglen = (int)mir_strlen((char *)dbevent.pBlob) + 1; if (dbevent.flags & DBEF_UTF) { pEvent->strValue = Utf8_Decode((char*)dbevent.pBlob); - } else if ((int) dbevent.cbBlob == msglen*3){ - pEvent->strValue = (TCHAR *) & dbevent.pBlob[msglen]; - } else { + } + else if ((int)dbevent.cbBlob == msglen * 3) { + pEvent->strValue = (TCHAR *)& dbevent.pBlob[msglen]; + } + else { pEvent->strValue = toTstring((char*)dbevent.pBlob); } - pEvent->eType = (dbevent.flags & DBEF_SENT) ? EVENT_MSG_SENT:EVENT_MSG_RECEIVED; - if(pEvent->eType == EVENT_MSG_RECEIVED) - { + pEvent->eType = (dbevent.flags & DBEF_SENT) ? EVENT_MSG_SENT : EVENT_MSG_RECEIVED; + if (pEvent->eType == EVENT_MSG_RECEIVED) { pEvent->dwFlags = MSG_UNREAD; - if(CConfig::GetBoolSetting(NOTIFY_MESSAGES)) + if (CConfig::GetBoolSetting(NOTIFY_MESSAGES)) pEvent->bNotification = true; } - pEvent->strDescription = strName + _T(": ") +pEvent->strValue; - pEvent->strSummary = TranslateString(_T("New message from %s"),strName.c_str()); + pEvent->strDescription = strName + _T(": ") + pEvent->strValue; + pEvent->strSummary = TranslateString(_T("New message from %s"), strName.c_str()); break; case EVENTTYPE_URL: - if(CConfig::GetBoolSetting(NOTIFY_URL)) + if (CConfig::GetBoolSetting(NOTIFY_URL)) pEvent->bNotification = true; pEvent->eType = EVENT_URL; - pEvent->strDescription = TranslateString(_T("Incoming URL from %s"),strName.c_str()); + pEvent->strDescription = TranslateString(_T("Incoming URL from %s"), strName.c_str()); break; case EVENTTYPE_CONTACTS: - if(CConfig::GetBoolSetting(NOTIFY_CONTACTS)) + if (CConfig::GetBoolSetting(NOTIFY_CONTACTS)) pEvent->bNotification = true; - pEvent->strDescription = TranslateString(_T("Incoming contacts from %s"),strName.c_str()); + pEvent->strDescription = TranslateString(_T("Incoming contacts from %s"), strName.c_str()); pEvent->eType = EVENT_CONTACTS; break; case EVENTTYPE_ADDED: - if(CConfig::GetBoolSetting(NOTIFY_CONTACTS)) + if (CConfig::GetBoolSetting(NOTIFY_CONTACTS)) pEvent->bNotification = true; - pEvent->strDescription = TranslateString(_T("You were added by %s"),strName.c_str()); + pEvent->strDescription = TranslateString(_T("You were added by %s"), strName.c_str()); pEvent->eType = EVENT_ADDED; break; case EVENTTYPE_AUTHREQUEST: - if(CConfig::GetBoolSetting(NOTIFY_CONTACTS)) + if (CConfig::GetBoolSetting(NOTIFY_CONTACTS)) pEvent->bNotification = true; pEvent->strDescription = TranslateString(_T("Incoming Authrequest!")); pEvent->eType = EVENT_AUTHREQUEST; break; case EVENTTYPE_FILE: - if(CConfig::GetBoolSetting(NOTIFY_FILE)) + if (CConfig::GetBoolSetting(NOTIFY_FILE)) pEvent->bNotification = true; - pEvent->strDescription = TranslateString(_T("Incoming file from %s"),strName.c_str()); + pEvent->strDescription = TranslateString(_T("Incoming file from %s"), strName.c_str()); pEvent->eType = EVENT_FILE; break; default: @@ -958,10 +930,9 @@ bool CAppletManager::TranslateDBEvent(CEvent *pEvent, WPARAM hContact, LPARAM hd break; } - if(CConfig::GetBoolSetting(NOTIFY_SHOWPROTO)) - { + if (CConfig::GetBoolSetting(NOTIFY_SHOWPROTO)) { char *szProto = GetContactProto(pEvent->hContact); - pEvent->strDescription = _T("(")+toTstring(szProto)+_T(") ") + pEvent->strDescription; + pEvent->strDescription = _T("(") + toTstring(szProto) + _T(") ") + pEvent->strDescription; } // Clean up @@ -978,20 +949,17 @@ tstring CAppletManager::StripIRCFormatting(tstring strText) tstring strEntity = _T(""); tstring strReplace = _T(""); - while(i < strText.length()) - { - start = strText.find(_T("%"),i); - if(start != string::npos && start < strText.length() - 1) - { - strEntity = strText[start+1]; - if(strEntity == _T("%")) - { - strText.replace(start,2,_T("%")); + while (i < strText.length()) { + start = strText.find(_T("%"), i); + if (start != string::npos && start < strText.length() - 1) { + strEntity = strText[start + 1]; + if (strEntity == _T("%")) { + strText.replace(start, 2, _T("%")); i = start + 1; } /* - else if(strEntity == _T("b") || strEntity == _T("B") || - strEntity == _T("i") || strEntity == _T("I") || + else if(strEntity == _T("b") || strEntity == _T("B") || + strEntity == _T("i") || strEntity == _T("I") || strEntity ==_T("u") || strEntity == _T("U") || strEntity == _T("C") ||strEntity == _T("F")) { @@ -999,14 +967,12 @@ tstring CAppletManager::StripIRCFormatting(tstring strText) i = start; } */ - else if(strEntity == _T("c") || strEntity == _T("f")) - { - strText.erase(start,4); + else if (strEntity == _T("c") || strEntity == _T("f")) { + strText.erase(start, 4); i = start; } - else - { - strText.erase(start,2); + else { + strText.erase(start, 2); i = start; } } @@ -1023,9 +989,8 @@ tstring CAppletManager::StripIRCFormatting(tstring strText) CIRCConnection *CAppletManager::GetIRCConnection(tstring strProtocol) { vector::iterator iter = m_vIRCConnections.begin(); - while(iter != m_vIRCConnections.end()) - { - if((*iter)->strProtocol == strProtocol) + while (iter != m_vIRCConnections.end()) { + if ((*iter)->strProtocol == strProtocol) return *iter; iter++; } @@ -1040,7 +1005,7 @@ CIRCConnection *CAppletManager::CreateIRCConnection(tstring strProtocol) CIRCConnection *pIRCCon = new CIRCConnection(); pIRCCon->strProtocol = strProtocol; pIRCCon->strNetwork = _T(""); - + m_vIRCConnections.push_back(pIRCCon); return pIRCCon; @@ -1052,21 +1017,19 @@ CIRCConnection *CAppletManager::CreateIRCConnection(tstring strProtocol) CIRCHistory *CAppletManager::GetIRCHistory(MCONTACT hContact) { list::iterator iter = m_LIRCHistorys.begin(); - while(iter != m_LIRCHistorys.end()) - { - if((*iter)->hContact == hContact) + while (iter != m_LIRCHistorys.end()) { + if ((*iter)->hContact == hContact) return *iter; iter++; } return NULL; } -CIRCHistory *CAppletManager::GetIRCHistoryByName(tstring strProtocol,tstring strChannel) +CIRCHistory *CAppletManager::GetIRCHistoryByName(tstring strProtocol, tstring strChannel) { list::iterator iter = m_LIRCHistorys.begin(); - while(iter != m_LIRCHistorys.end()) - { - if((*iter)->strChannel == strChannel && (*iter)->strProtocol == strProtocol) + while (iter != m_LIRCHistorys.end()) { + if ((*iter)->strChannel == strChannel && (*iter)->strProtocol == strProtocol) return *iter; iter++; } @@ -1079,16 +1042,14 @@ CIRCHistory *CAppletManager::GetIRCHistoryByName(tstring strProtocol,tstring str void CAppletManager::DeleteIRCHistory(MCONTACT hContact) { list::iterator iter = m_LIRCHistorys.begin(); - while(iter != m_LIRCHistorys.end()) - { - if((*iter)->hContact == hContact) - { + while (iter != m_LIRCHistorys.end()) { + if ((*iter)->hContact == hContact) { CIRCHistory *pHistory = *iter; pHistory->LMessages.clear(); pHistory->LUsers.clear(); m_LIRCHistorys.erase(iter); - + delete pHistory; return; @@ -1100,15 +1061,14 @@ void CAppletManager::DeleteIRCHistory(MCONTACT hContact) //************************************************************************ // creates a history class for the specified IRC channel //************************************************************************ -CIRCHistory *CAppletManager::CreateIRCHistory(MCONTACT hContact,tstring strChannel) +CIRCHistory *CAppletManager::CreateIRCHistory(MCONTACT hContact, tstring strChannel) { char *szProto = GetContactProto(hContact); - if(!szProto) + if (!szProto) return NULL; - CIRCHistory *pHistory = GetIRCHistoryByName(toTstring(szProto),strChannel); - if(pHistory) - { + CIRCHistory *pHistory = GetIRCHistoryByName(toTstring(szProto), strChannel); + if (pHistory) { pHistory->hContact = hContact; return pHistory; } @@ -1119,14 +1079,14 @@ CIRCHistory *CAppletManager::CreateIRCHistory(MCONTACT hContact,tstring strChann pHistory->strProtocol = toTstring(szProto); m_LIRCHistorys.push_back(pHistory); - + return pHistory; } -CIRCHistory *CAppletManager::CreateIRCHistoryByName(tstring strProtocol,tstring strChannel) +CIRCHistory *CAppletManager::CreateIRCHistoryByName(tstring strProtocol, tstring strChannel) { - CIRCHistory *pHistory = GetIRCHistoryByName(strProtocol,strChannel); - if(pHistory) + CIRCHistory *pHistory = GetIRCHistoryByName(strProtocol, strChannel); + if (pHistory) return pHistory; pHistory = new CIRCHistory(); @@ -1135,7 +1095,7 @@ CIRCHistory *CAppletManager::CreateIRCHistoryByName(tstring strProtocol,tstring pHistory->strProtocol = strProtocol; m_LIRCHistorys.push_back(pHistory); - + return pHistory; } @@ -1150,113 +1110,103 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; GCDEST *gcd; - + if (gce == NULL || (gcd = gce->pDest) == NULL) { TRACE(_T("<< [%s] skipping invalid event\n")); return 0; } - TRACE(_T("<< [%s:%s] event %04X\n"),toTstring(gcd->pszModule).c_str(), gcd->ptszID, gcd->iType); - + TRACE(_T("<< [%s:%s] event %04X\n"), toTstring(gcd->pszModule).c_str(), gcd->ptszID, gcd->iType); + // get the matching irc connection entry CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(gcd->pszModule)); - if(!pIRCCon) - { - TRACE(_T("<< [%s] connection not found, skipping event\n"),toTstring(gcd->pszModule).c_str()); + if (!pIRCCon) { + TRACE(_T("<< [%s] connection not found, skipping event\n"), toTstring(gcd->pszModule).c_str()); return 0; } // fetch the network name - if(gcd->iType == GC_EVENT_CHANGESESSIONAME) - { - if (gcd->ptszID && !mir_tstrcmpi(gcd->ptszID,_T("Network log"))) - { + if (gcd->iType == GC_EVENT_CHANGESESSIONAME) { + if (gcd->ptszID && !mir_tstrcmpi(gcd->ptszID, _T("Network log"))) { pIRCCon->strNetwork = toTstring(gce->ptszText); - TRACE(_T("\t Found network identifier: %s\n"),pIRCCon->strNetwork.c_str()); + TRACE(_T("\t Found network identifier: %s\n"), pIRCCon->strNetwork.c_str()); return 0; - } + } } - + CEvent Event; - if(gce->bIsMe) + if (gce->bIsMe) Event.eType = EVENT_IRC_SENT; else Event.eType = EVENT_IRC_RECEIVED; Event.iValue = gcd->iType; Event.hValue = lParam; - + CIRCHistory *pHistory = NULL; - if(gcd->ptszID) - { + if (gcd->ptszID) { tstring strChannel = toTstring(gcd->ptszID); tstring::size_type pos = strChannel.find('-'); - if(pos != tstring::npos) - strChannel = strChannel.substr(0,pos-1); - else - { - if(mir_tstrcmpi(gcd->ptszID,_T("Network log"))) + if (pos != tstring::npos) + strChannel = strChannel.substr(0, pos - 1); + else { + if (mir_tstrcmpi(gcd->ptszID, _T("Network log"))) TRACE(_T("\t WARNING: ignoring unknown event!\n")); return 0; } - pHistory = CAppletManager::GetInstance()->GetIRCHistoryByName(pIRCCon->strProtocol,strChannel); - if(!pHistory) - { - if(gcd->iType == GC_EVENT_JOIN) - { - pHistory = CAppletManager::GetInstance()->CreateIRCHistoryByName(pIRCCon->strProtocol,strChannel); - if(pHistory) + pHistory = CAppletManager::GetInstance()->GetIRCHistoryByName(pIRCCon->strProtocol, strChannel); + if (!pHistory) { + if (gcd->iType == GC_EVENT_JOIN) { + pHistory = CAppletManager::GetInstance()->CreateIRCHistoryByName(pIRCCon->strProtocol, strChannel); + if (pHistory) pHistory->LUsers.push_back(toTstring(gce->ptszNick)); } return 0; } Event.hContact = pHistory->hContact; } - else if(gcd->iType != GC_EVENT_INFORMATION) - { + else if (gcd->iType != GC_EVENT_INFORMATION) { TRACE(_T("\t WARNING: ignoring unknown event!\n")); return 0; } else Event.hContact = NULL; - + // Ignore events from hidden chatrooms, except for join events - if(gcd->ptszID != NULL && db_get_b(Event.hContact,"CList","Hidden",0)) - { - if(gcd->iType == GC_EVENT_JOIN && pHistory) + if (gcd->ptszID != NULL && db_get_b(Event.hContact, "CList", "Hidden", 0)) { + if (gcd->iType == GC_EVENT_JOIN && pHistory) pHistory->LUsers.push_back(toTstring(gce->ptszNick)); TRACE(_T("\t Chatroom is hidden, skipping event!\n")); return 0; } - + tstring strText = StripIRCFormatting(toTstring(gce->ptszText)); tstring strNick = toTstring(gce->ptszNick); tstring strStatus = toTstring(gce->ptszStatus); - if(CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + if (CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) strNick = strNick.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); - + TRACE(_T("\t Handling event...\t")); - switch(gcd->iType) - { + switch (gcd->iType) { case GC_EVENT_INFORMATION: - if(CConfig::GetBoolSetting(NOTIFY_IRC_CHANNEL)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_CHANNEL)) Event.bNotification = true; - - if(strText.find(_T("CTCP")) == 0) + + if (strText.find(_T("CTCP")) == 0) Event.strValue = _T("--> ") + strText; else Event.strValue = strText; break; case GC_EVENT_ACTION: - if(CConfig::GetBoolSetting(NOTIFY_IRC_EMOTES)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_EMOTES)) Event.bNotification = true; Event.strValue = strNick + _T(" ") + strText; break; case GC_EVENT_MESSAGE: - if(CConfig::GetBoolSetting(NOTIFY_IRC_MESSAGES)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_MESSAGES)) Event.bNotification = true; Event.strValue = strNick + _T(": ") + strText; break; @@ -1264,63 +1214,58 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) // Add the user to the list pHistory->LUsers.push_back(toTstring(gce->ptszNick)); - if(CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) Event.bNotification = true; // Skip join event for user - if(gce->bIsMe) + if (gce->bIsMe) return 0; - Event.strValue = TranslateString(_T("%s has joined the channel"),strNick.c_str()); - + Event.strValue = TranslateString(_T("%s has joined the channel"), strNick.c_str()); + break; case GC_EVENT_PART: { - if(CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) Event.bNotification = true; tstring strFullNick = toTstring(gce->ptszNick); - Event.strValue = TranslateString(strText.empty()?_T("%s has left"):_T("%s has left: %s"),strNick.c_str(),strText.c_str()); - if(pHistory) - { + Event.strValue = TranslateString(strText.empty() ? _T("%s has left") : _T("%s has left: %s"), strNick.c_str(), strText.c_str()); + if (pHistory) { // Remove the user from the list list::iterator iter = pHistory->LUsers.begin(); - while(iter != pHistory->LUsers.end()) - { - if((*iter) == strFullNick) - { + while (iter != pHistory->LUsers.end()) { + if ((*iter) == strFullNick) { pHistory->LUsers.erase(iter); break; } iter++; - } + } } break; } case GC_EVENT_QUIT: - if(CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) Event.bNotification = true; - Event.strValue = TranslateString(strText.empty()?_T("%s has disconnected"):_T("%s has disconnected: %s"),strNick.c_str(),strText.c_str()); + Event.strValue = TranslateString(strText.empty() ? _T("%s has disconnected") : _T("%s has disconnected: %s"), strNick.c_str(), strText.c_str()); break; case GC_EVENT_KICK: - if(CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) Event.bNotification = true; - Event.strValue = TranslateString(_T("%s has kicked %s: %s"),strStatus.c_str(),strNick.c_str(),strText.c_str()); + Event.strValue = TranslateString(_T("%s has kicked %s: %s"), strStatus.c_str(), strNick.c_str(), strText.c_str()); break; case GC_EVENT_NICK: { - if(CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_USERS)) Event.bNotification = true; tstring strFullNick = toTstring(gce->ptszNick); - - if(CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strText.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + + if (CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strText.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) strText = strText.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); - - Event.strValue = TranslateString(_T("%s is now known as %s"),strNick.c_str(),strText.c_str()); - if(pHistory) - { + + Event.strValue = TranslateString(_T("%s is now known as %s"), strNick.c_str(), strText.c_str()); + if (pHistory) { // change the nick in the userlist list::iterator iter = pHistory->LUsers.begin(); - while(iter != pHistory->LUsers.end()) - { - if((*iter) == strFullNick) + while (iter != pHistory->LUsers.end()) { + if ((*iter) == strFullNick) (*iter) = strText; iter++; } @@ -1328,89 +1273,83 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) break; } case GC_EVENT_NOTICE: - if(CConfig::GetBoolSetting(NOTIFY_IRC_NOTICES)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_NOTICES)) Event.bNotification = true; - Event.strValue = TranslateString(_T("Notice from %s: %s"),strNick.c_str(),strText.c_str()); + Event.strValue = TranslateString(_T("Notice from %s: %s"), strNick.c_str(), strText.c_str()); break; case GC_EVENT_TOPIC: - if(CConfig::GetBoolSetting(NOTIFY_IRC_CHANNEL)) + if (CConfig::GetBoolSetting(NOTIFY_IRC_CHANNEL)) Event.bNotification = true; - Event.strValue = TranslateString(_T("Topic is now '%s' (set by %s)"),strText.c_str(),strNick.c_str()); + Event.strValue = TranslateString(_T("Topic is now '%s' (set by %s)"), strText.c_str(), strNick.c_str()); break; case GC_EVENT_ADDSTATUS: - { - if(CConfig::GetBoolSetting(NOTIFY_IRC_STATUS)) - Event.bNotification = true; - tstring strNick2 = toTstring(gce->ptszStatus); - if(CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick2.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) - strNick2 = strNick2.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); + { + if (CConfig::GetBoolSetting(NOTIFY_IRC_STATUS)) + Event.bNotification = true; + tstring strNick2 = toTstring(gce->ptszStatus); + if (CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick2.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + strNick2 = strNick2.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); - Event.strValue = TranslateString(_T("%s enables '%s' for %s"),strText.c_str(),strNick2.c_str(),strNick.c_str()); - break; - } + Event.strValue = TranslateString(_T("%s enables '%s' for %s"), strText.c_str(), strNick2.c_str(), strNick.c_str()); + break; + } case GC_EVENT_REMOVESTATUS: - { - if(CConfig::GetBoolSetting(NOTIFY_IRC_STATUS)) - Event.bNotification = true; - tstring strNick2 = toTstring(gce->ptszStatus); - if(CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick2.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) - strNick2 = strNick2.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); + { + if (CConfig::GetBoolSetting(NOTIFY_IRC_STATUS)) + Event.bNotification = true; + tstring strNick2 = toTstring(gce->ptszStatus); + if (CConfig::GetBoolSetting(NOTIFY_NICKCUTOFF) && strNick2.length() > (tstring::size_type)CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + strNick2 = strNick2.erase(CConfig::GetIntSetting(NOTIFY_NICKCUTOFF_OFFSET)) + _T("..."); - Event.strValue = TranslateString(_T("%s disables '%s' for %s"),strText.c_str(),strNick2.c_str(),strNick.c_str()); - break; - } + Event.strValue = TranslateString(_T("%s disables '%s' for %s"), strText.c_str(), strNick2.c_str(), strNick.c_str()); + break; + } default: TRACE(_T("OK!\n")); return 0; } - if(gce->bIsMe || gcd->ptszID == NULL) + if (gce->bIsMe || gcd->ptszID == NULL) Event.bNotification = false; // set the event's timestamp Event.bTime = true; time_t now; time(&now); - localtime_s(&Event.Time,&now); - + localtime_s(&Event.Time, &now); + SIRCMessage IRCMsg; IRCMsg.bIsMe = (gce->bIsMe != 0); IRCMsg.strMessage = Event.strValue; IRCMsg.Time = Event.Time; - if(pHistory) - { + if (pHistory) { pHistory->LMessages.push_back(IRCMsg); // Limit the size to the session logsize - if(pHistory->LMessages.size() > CConfig::GetIntSetting(SESSION_LOGSIZE)) + if (pHistory->LMessages.size() > CConfig::GetIntSetting(SESSION_LOGSIZE)) pHistory->LMessages.pop_front(); } - else if(gce->ptszNick && gcd->iType == GC_EVENT_QUIT) - { - tstring strNick = toTstring(gce->ptszNick); - - if(!CAppletManager::GetInstance()->m_LIRCHistorys.empty()) - { + else if (gce->ptszNick && gcd->iType == GC_EVENT_QUIT) { + strNick = toTstring(gce->ptszNick); + + if (!CAppletManager::GetInstance()->m_LIRCHistorys.empty()) { list::iterator iter = CAppletManager::GetInstance()->m_LIRCHistorys.begin(); list::iterator nickiter; - while(iter != CAppletManager::GetInstance()->m_LIRCHistorys.end()) - { + while (iter != CAppletManager::GetInstance()->m_LIRCHistorys.end()) { nickiter = (*iter)->LUsers.begin(); - while(nickiter != (*iter)->LUsers.end()) - { - if((*nickiter) == strNick) - { + while (nickiter != (*iter)->LUsers.end()) { + if ((*nickiter) == strNick) { (*iter)->LMessages.push_back(IRCMsg); // Limit the size to the session logsize - if((*iter)->LMessages.size() > CConfig::GetIntSetting(SESSION_LOGSIZE)) + if ((*iter)->LMessages.size() > CConfig::GetIntSetting(SESSION_LOGSIZE)) (*iter)->LMessages.pop_front(); (*iter)->LUsers.erase(nickiter); - + Event.hContact = (*iter)->hContact; - tstring strName = CAppletManager::GetContactDisplayname((*iter)->hContact,true); - Event.strDescription = strName + _T(" - ")+Event.strValue; - Event.strSummary = _T("(") + toTstring(gcd->pszModule) + _T(") ")+strName; + tstring strName = CAppletManager::GetContactDisplayname((*iter)->hContact, true); + Event.strDescription = strName + _T(" - ") + Event.strValue; + Event.strSummary = _T("(") + toTstring(gcd->pszModule) + _T(") ") + strName; CAppletManager::GetInstance()->HandleEvent(&Event); break; } @@ -1422,26 +1361,24 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(_T("OK!\n")); return 0; } - else if(gcd->ptszID != NULL) - { + if (gcd->ptszID != NULL) { TRACE(_T("OK!\n")); return 0; } - if(pHistory) - { + if (pHistory) { tstring strChannel = pHistory->strChannel; - if(CConfig::GetBoolSetting(NOTIFY_CHANNELCUTOFF) && strChannel.length() > CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) { + if (CConfig::GetBoolSetting(NOTIFY_CHANNELCUTOFF) && strChannel.length() > CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) { strChannel = strChannel.erase(CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) + _T("..."); } - Event.strDescription = strChannel + _T(" - ")+Event.strValue; - Event.strSummary = _T("(") + toTstring(gcd->pszModule) + _T(") ")+pHistory->strChannel; + Event.strDescription = strChannel + _T(" - ") + Event.strValue; + Event.strSummary = _T("(") + toTstring(gcd->pszModule) + _T(") ") + pHistory->strChannel; } else Event.strDescription = Event.strValue; TRACE(_T("OK!\n")); - + CAppletManager::GetInstance()->HandleEvent(&Event); return 0; @@ -1490,11 +1427,11 @@ int CAppletManager::HookEventAdded(WPARAM wParam, LPARAM lParam) { CEvent Event; - if(CAppletManager::TranslateDBEvent(&Event,wParam,lParam)) + if (CAppletManager::TranslateDBEvent(&Event, wParam, lParam)) CAppletManager::GetInstance()->HandleEvent(&Event); return 0; -} +} //************************************************************************ // contact status change hook function @@ -1503,7 +1440,7 @@ int CAppletManager::HookStatusChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if ((wParam == 0) || (mir_strcmp(cws->szSetting,"Status") != NULL)) + if ((wParam == 0) || (mir_strcmp(cws->szSetting, "Status") != NULL)) return 0; @@ -1519,76 +1456,71 @@ int CAppletManager::HookStatusChanged(WPARAM wParam, LPARAM lParam) tstring strProto = toTstring(szProto); CProtocolData *pProtocolData = CAppletManager::GetInstance()->GetProtocolData(toTstring(szProto)); - if(pProtocolData == NULL) + if (pProtocolData == NULL) return false; - + // Fetch the contacts name - tstring strName = CAppletManager::GetContactDisplayname(Event.hContact,true); - + tstring strName = CAppletManager::GetContactDisplayname(Event.hContact, true); + // Get status String Event.strValue = toTstring(pcli->pfnGetStatusModeDescription(iStatus, 0)); - + // check if this is an irc protocol CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(strProto); // Contact signed on - if(iOldStatus == ID_STATUS_OFFLINE && iStatus != ID_STATUS_OFFLINE) - { - if(CConfig::GetBoolSetting(NOTIFY_SIGNOFF)) + if (iOldStatus == ID_STATUS_OFFLINE && iStatus != ID_STATUS_OFFLINE) { + if (CConfig::GetBoolSetting(NOTIFY_SIGNOFF)) Event.bNotification = true; Event.eType = EVENT_SIGNED_ON; - if(pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) - { - Event.strDescription = TranslateString(_T("Joined %s"),strName.c_str()); - + if (pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) { + Event.strDescription = TranslateString(_T("Joined %s"), strName.c_str()); + DBVARIANT dbv; - if (db_get_ts(Event.hContact, szProto, "Nick", &dbv)) + if (db_get_ts(Event.hContact, szProto, "Nick", &dbv)) return 0; - CAppletManager::GetInstance()->CreateIRCHistory(Event.hContact,dbv.ptszVal); + CAppletManager::GetInstance()->CreateIRCHistory(Event.hContact, dbv.ptszVal); db_free(&dbv); } else - Event.strDescription = TranslateString(_T("%s signed on (%s)"),strName.c_str(),Event.strValue.c_str()); + Event.strDescription = TranslateString(_T("%s signed on (%s)"), strName.c_str(), Event.strValue.c_str()); } // Contact signed off - else if(iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) - { - if(CConfig::GetBoolSetting(NOTIFY_SIGNON)) + else if (iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) { + if (CConfig::GetBoolSetting(NOTIFY_SIGNON)) Event.bNotification = true; Event.eType = EVENT_SIGNED_OFF; - if(pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) - { - Event.strDescription = TranslateString(_T("Left %s"),strName.c_str()); + if (pIRCCon && db_get_b(Event.hContact, szProto, "ChatRoom", 0) != 0) { + Event.strDescription = TranslateString(_T("Left %s"), strName.c_str()); // delete IRC-Channel history CAppletManager::GetInstance()->DeleteIRCHistory(Event.hContact); } else - Event.strDescription = TranslateString(_T("%s signed off"),strName.c_str()); + Event.strDescription = TranslateString(_T("%s signed off"), strName.c_str()); } // Contact changed status - else if(iStatus != iOldStatus) - { - if(CConfig::GetBoolSetting(NOTIFY_STATUS)) + else if (iStatus != iOldStatus) { + if (CConfig::GetBoolSetting(NOTIFY_STATUS)) Event.bNotification = true; Event.eType = EVENT_STATUS; - Event.strDescription = TranslateString(_T("%s is now %s"),strName.c_str(),Event.strValue.c_str()); + Event.strDescription = TranslateString(_T("%s is now %s"), strName.c_str(), Event.strValue.c_str()); } // ignore remaining events else return 0; - if(CConfig::GetBoolSetting(NOTIFY_SHOWPROTO)) - Event.strDescription = _T("(")+strProto+_T(") ") + Event.strDescription; + if (CConfig::GetBoolSetting(NOTIFY_SHOWPROTO)) + Event.strDescription = _T("(") + strProto + _T(") ") + Event.strDescription; + - Event.strSummary = TranslateString(_T("Contactlist event")); // Block notifications after connecting/disconnecting - if(pProtocolData->iStatus == ID_STATUS_OFFLINE || (DWORD)pProtocolData->lTimeStamp + PROTOCOL_NOTIFY_DELAY > GetTickCount()) + if (pProtocolData->iStatus == ID_STATUS_OFFLINE || (DWORD)pProtocolData->lTimeStamp + PROTOCOL_NOTIFY_DELAY > GetTickCount()) Event.bNotification = false; //CAppletManager::GetInstance()->ActivateNotificationScreen(&Event); @@ -1602,32 +1534,29 @@ int CAppletManager::HookStatusChanged(WPARAM wParam, LPARAM lParam) //************************************************************************ int CAppletManager::HookProtoAck(WPARAM, LPARAM lParam) { - ACKDATA *pAck = (ACKDATA *) lParam; - - if(lParam == 0) + ACKDATA *pAck = (ACKDATA *)lParam; + + if (lParam == 0) return 0; - + // Prepare message and append to queue CEvent Event; // Message job handling - if(pAck->type == ACKTYPE_MESSAGE) - { + if (pAck->type == ACKTYPE_MESSAGE) { list::iterator iter = CAppletManager::GetInstance()->m_MessageJobs.begin(); - while(iter != CAppletManager::GetInstance()->m_MessageJobs.end()) - { - if((*iter)->hEvent == (MEVENT)pAck->hProcess && (*iter)->hContact == pAck->hContact) - { + while (iter != CAppletManager::GetInstance()->m_MessageJobs.end()) { + if ((*iter)->hEvent == (MEVENT)pAck->hProcess && (*iter)->hContact == pAck->hContact) { Event.eType = EVENT_MESSAGE_ACK; Event.hValue = (MEVENT)pAck->hProcess; Event.hContact = pAck->hContact; Event.iValue = pAck->result; - if(pAck->lParam != 0) + if (pAck->lParam != 0) Event.strValue = toTstring((char*)pAck->lParam); - else + else Event.strValue = _T(""); - if(Event.iValue == ACKRESULT_SUCCESS) + if (Event.iValue == ACKRESULT_SUCCESS) CAppletManager::GetInstance()->FinishMessageJob((*iter)); else CAppletManager::GetInstance()->CancelMessageJob((*iter)); @@ -1640,45 +1569,41 @@ int CAppletManager::HookProtoAck(WPARAM, LPARAM lParam) } } // protocol status changes - else if(pAck->type == ACKTYPE_STATUS && pAck->result == ACKRESULT_SUCCESS) - { + else if (pAck->type == ACKTYPE_STATUS && pAck->result == ACKRESULT_SUCCESS) { int iOldStatus = (int)pAck->hProcess; int iNewStatus = pAck->lParam; - + tstring strProto = toTstring(pAck->szModule); - + // ignore metacontacts status changes - if(toLower(strProto) == _T("metacontacts")) + if (toLower(strProto) == _T("metacontacts")) return 0; CProtocolData *pProtoData = CAppletManager::GetInstance()->GetProtocolData(strProto); - if(pProtoData == NULL) + if (pProtoData == NULL) return 0; - if(iNewStatus == ID_STATUS_CONNECTING) + if (iNewStatus == ID_STATUS_CONNECTING) return 0; - if(iNewStatus == ID_STATUS_OFFLINE) - { - if(CConfig::GetBoolSetting(NOTIFY_PROTO_SIGNOFF)) + if (iNewStatus == ID_STATUS_OFFLINE) { + if (CConfig::GetBoolSetting(NOTIFY_PROTO_SIGNOFF)) Event.bNotification = true; Event.eType = EVENT_PROTO_DISCONNECTED; } - else if(iNewStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_CONNECTING) - { - if(CConfig::GetBoolSetting(NOTIFY_PROTO_SIGNON)) + else if (iNewStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_CONNECTING) { + if (CConfig::GetBoolSetting(NOTIFY_PROTO_SIGNON)) Event.bNotification = true; Event.eType = EVENT_PROTO_CONNECTED; } - else - { - if(CConfig::GetBoolSetting(NOTIFY_PROTO_STATUS)) + else { + if (CConfig::GetBoolSetting(NOTIFY_PROTO_STATUS)) Event.bNotification = true; Event.eType = EVENT_PROTO_STATUS; } // Skip connecting status - if(iNewStatus == ID_STATUS_CONNECTING) + if (iNewStatus == ID_STATUS_CONNECTING) return 0; pProtoData->iStatus = iNewStatus; @@ -1688,10 +1613,10 @@ int CAppletManager::HookProtoAck(WPARAM, LPARAM lParam) // set the event description / summary tstring strStatus = toTstring(pcli->pfnGetStatusModeDescription(iNewStatus, 0)); - Event.strDescription = _T("(") + Event.strValue + _T(") ")+ TranslateString(_T("You are now %s"),strStatus.c_str()); + Event.strDescription = _T("(") + Event.strValue + _T(") ") + TranslateString(_T("You are now %s"), strStatus.c_str()); Event.strSummary = TranslateString(_T("Protocol status change")); - if(Event.eType != EVENT_PROTO_STATUS) + if (Event.eType != EVENT_PROTO_STATUS) pProtoData->lTimeStamp = GetTickCount(); CAppletManager::GetInstance()->HandleEvent(&Event); @@ -1725,9 +1650,9 @@ int CAppletManager::HookContactDeleted(WPARAM wParam, LPARAM) Event.bNotification = CConfig::GetBoolSetting(NOTIFY_CONTACTS); Event.bLog = Event.bNotification; - tstring strName = CAppletManager::GetContactDisplayname(Event.hContact,true); - - Event.strDescription = TranslateString(_T("%s was deleted from contactlist!"),strName.c_str()); + tstring strName = CAppletManager::GetContactDisplayname(Event.hContact, true); + + Event.strDescription = TranslateString(_T("%s was deleted from contactlist!"), strName.c_str()); CAppletManager::GetInstance()->HandleEvent(&Event); return 0; @@ -1736,51 +1661,51 @@ int CAppletManager::HookContactDeleted(WPARAM wParam, LPARAM) //************************************************************************ // setting changed hook function //************************************************************************ -int CAppletManager::HookSettingChanged(WPARAM hContact,LPARAM lParam) +int CAppletManager::HookSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam; - + CEvent Event; Event.hContact = hContact; - if(!mir_strcmp(dbcws->szSetting,"Nick") || !mir_strcmp(dbcws->szSetting,"MyHandle")) { - DBVARIANT dbv={0}; + if (!mir_strcmp(dbcws->szSetting, "Nick") || !mir_strcmp(dbcws->szSetting, "MyHandle")) { + DBVARIANT dbv = { 0 }; // if the protocol nick has changed, check if a custom handle is set - if(!mir_strcmp(dbcws->szSetting,"Nick")) { + if (!mir_strcmp(dbcws->szSetting, "Nick")) { if (!db_get_ts(Event.hContact, "CList", "MyHandle", &dbv)) { // handle found, ignore this event - if(dbv.pszVal && mir_strlen(dbv.pszVal)>0) + if (dbv.pszVal && mir_strlen(dbv.pszVal) > 0) return 0; } db_free(&dbv); } Event.eType = EVENT_CONTACT_NICK; - if(dbcws->value.type != DBVT_DELETED && dbcws->value.pszVal && mir_strlen(dbcws->value.pszVal)>0) { - if(dbcws->value.type == DBVT_UTF8) + if (dbcws->value.type != DBVT_DELETED && dbcws->value.pszVal && mir_strlen(dbcws->value.pszVal) > 0) { + if (dbcws->value.type == DBVT_UTF8) Event.strValue = Utf8_Decode(dbcws->value.pszVal); else Event.strValue = toTstring(dbcws->value.pszVal); } else { char *szProto = GetContactProto(Event.hContact); - if (db_get_ts(Event.hContact, szProto, "Nick", &dbv)) + if (db_get_ts(Event.hContact, szProto, "Nick", &dbv)) return 0; Event.strValue = dbv.ptszVal; db_free(&dbv); } } - else if(!mir_strcmp(dbcws->szModule,"CList")) { - if(!mir_strcmp(dbcws->szSetting,"Hidden")) { + else if (!mir_strcmp(dbcws->szModule, "CList")) { + if (!mir_strcmp(dbcws->szSetting, "Hidden")) { Event.eType = EVENT_CONTACT_HIDDEN; - Event.iValue = db_get_b(hContact,"CList","Hidden",0); + Event.iValue = db_get_b(hContact, "CList", "Hidden", 0); } - else if(!mir_strcmp(dbcws->szSetting,"Group")) { + else if (!mir_strcmp(dbcws->szSetting, "Group")) { Event.eType = EVENT_CONTACT_GROUP; DBVARIANT dbv; - int res = db_get_ts(hContact, "CList", "Group", &dbv); - if(!res) - Event.strValue = dbv.ptszVal; + int res = db_get_ts(hContact, "CList", "Group", &dbv); + if (!res) + Event.strValue = dbv.ptszVal; db_free(&dbv); } else return 0; diff --git a/plugins/MsgPopup/src/options.cpp b/plugins/MsgPopup/src/options.cpp index ab987af80d..7ef6719f42 100644 --- a/plugins/MsgPopup/src/options.cpp +++ b/plugins/MsgPopup/src/options.cpp @@ -38,6 +38,9 @@ static int __inline DBWriteContactSettingDwordDef(MCONTACT hContact, const char INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + int value; + BOOL Translated; + switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hWnd); @@ -50,8 +53,6 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return TRUE; case WM_COMMAND: - int indx, value; - BOOL Translated; if (LOWORD(wParam) == IDC_PREVIEW) { MessageBox(0, TranslateT("Message with question"), TranslateTS(_T(SERVICENAME) _T(" - demo")), MB_ICONQUESTION); MessageBox(0, TranslateT("Message with exclamation"), TranslateTS(_T(SERVICENAME) _T(" - demo")), MB_ICONEXCLAMATION); @@ -64,7 +65,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l if (LOWORD(wParam) == IDC_MESSAGEBEEP) options.Sound = IsDlgButtonChecked(hWnd, IDC_MESSAGEBEEP) == BST_CHECKED; else { - for (indx = 0; indx < 4; indx++) { + for (int indx = 0; indx < 4; indx++) { if (LOWORD(wParam) == idOptionControls[indx][0]) { if (HIWORD(wParam) != CPN_COLOURCHANGED) return FALSE; options.FG[indx] = SendDlgItemMessage(hWnd, LOWORD(wParam), CPM_GETCOLOUR, 0, 0); @@ -96,9 +97,8 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l char szNameFG[4]; char szNameBG[4]; char szNameTO[4]; - int indx; - for (indx = 0; indx < 4; indx++) { + for (int indx = 0; indx < 4; indx++) { mir_snprintf(szNameFG, _countof(szNameFG), "FG%d", indx); mir_snprintf(szNameBG, _countof(szNameBG), "BG%d", indx); mir_snprintf(szNameTO, _countof(szNameTO), "TO%d", indx); diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 75341df4f6..488eda2fd0 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -1049,7 +1049,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, cf.Flags = CF_EFFECTS | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; if (ChooseFont(&cf)) { - DWORD dwEffects = (lf.lfWeight == FW_BOLD ? CFE_BOLD : 0) | + dwEffects = (lf.lfWeight == FW_BOLD ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0) | (lf.lfStrikeOut ? CFE_STRIKEOUT : 0) | (lf.lfUnderline ? CFE_UNDERLINE : 0); diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 26a012403f..45de85d160 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -144,49 +144,13 @@ int nGetFormatCount(const TCHAR *pszToCheck) return 0; int nCount = 0; - for (; pszToCheck[1] != 0; pszToCheck++) - { + for (; pszToCheck[1] != 0; pszToCheck++) { if (pszToCheck[0] == '%' && pszToCheck[1] != '%') nCount++; } return nCount; } -///////////////////////////////////////////////////////////////////// -// Member Function : CheckedTranslate -// Type : Global -// Parameters : szEng - ? -// nFormatCount - ? -// Returns : TCHAR * -// Description : -// -// References : - -// Remarks : - -// Created : 030107, 07 January 2003 -// Developer : KN -///////////////////////////////////////////////////////////////////// -/* -TCHAR *CheckedTranslate( const TCHAR *szEng, int nFormatCount )//= -1 -{ -TCHAR *szRet = TranslateTS( szEng); -if (szEng == szRet ) -return (TCHAR*)szEng; - -if (nFormatCount == -1 ) -nFormatCount = nGetFormatCount( szEng); - -if (nFormatCount != nGetFormatCount( szRet)) -{ -tstring sError = _T("The language pack you are using has an error in the transalation of\r\n"); -sError += szEng; -sError += _T("\r\n--------------- It was translated to ---------------\r\n"); -sError += szRet; -MessageBox(NULL, sError.c_str(),MSG_BOX_TITEL,MB_OK); -return (TCHAR*)szEng; -} -return szRet; -} -*/ ///////////////////////////////////////////////////////////////////// // Member Function : sGetErrorString // Type : Global @@ -284,20 +248,15 @@ tstring _DBGetStringW(MCONTACT hContact, const char *szModule, const char *szSet tstring ret; DBVARIANT dbv = { 0 }; //db_get - if (!db_get_ws(hContact, szModule, szSetting, &dbv)) - { - if (dbv.type != DBVT_WCHAR) - { + if (!db_get_ws(hContact, szModule, szSetting, &dbv)) { + if (dbv.type != DBVT_WCHAR) { MessageBox(NULL, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); ret = pszError; } - else - { - ret = (TCHAR*)dbv.pszVal; - } + else ret = (TCHAR*)dbv.pszVal; } - else - ret = pszError; + else ret = pszError; + db_free(&dbv); return ret; } @@ -306,20 +265,15 @@ string _DBGetStringA(MCONTACT hContact, const char *szModule, const char *szSett { string ret; DBVARIANT dbv = { 0 }; - if (!db_get(hContact, szModule, szSetting, &dbv)) - { - if (dbv.type != DBVT_ASCIIZ) - { + if (!db_get(hContact, szModule, szSetting, &dbv)) { + if (dbv.type != DBVT_ASCIIZ) { MessageBox(NULL, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); ret = pszError; } - else - { - ret = dbv.pszVal; - } + else ret = dbv.pszVal; } - else - ret = pszError; + else ret = pszError; + db_free(&dbv); return ret; } @@ -342,8 +296,7 @@ string _DBGetStringA(MCONTACT hContact, const char *szModule, const char *szSett void ReplaceAll(tstring &sSrc, const TCHAR *pszReplace, const tstring &sNew) { string::size_type nCur = 0; - while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) - { + while ((nCur = sSrc.find(pszReplace, nCur)) != sSrc.npos) { sSrc.replace(nCur, mir_tstrlen(pszReplace), sNew); nCur += sNew.size(); } @@ -355,7 +308,6 @@ void ReplaceAll(tstring &sSrc, const TCHAR *pszReplace, const TCHAR *pszNew) ReplaceAll(sSrc, pszReplace, sNew); } - ///////////////////////////////////////////////////////////////////// // Member Function : bCreatePathToFile // Type : Global @@ -372,31 +324,25 @@ void ReplaceAll(tstring &sSrc, const TCHAR *pszReplace, const TCHAR *pszNew) bool bCreatePathToFile(tstring sFilePath) { string::size_type nPos = sFilePath.rfind('\\'); - if (nPos != string::npos) - { + if (nPos != string::npos) { if (nPos + 1 < sFilePath.size()) sFilePath.erase(nPos + 1); } - else - { - // cant find \ + else // cant find return false; - } // create directory - if (!CreateDirectory(sFilePath.c_str(), NULL)) - { + if (!CreateDirectory(sFilePath.c_str(), NULL)) { DWORD dwE = GetLastError(); if (dwE == 183) // Cannot create a file when that file already exists. return true; + if (!bCreatePathToFile(sFilePath.substr(0, nPos))) return false; // try again if (!CreateDirectory(sFilePath.c_str(), NULL)) - { return false; - } } return true; } @@ -494,6 +440,7 @@ bool bWriteNewLine(HANDLE hFile, DWORD dwIndent) { if (dwIndent > sizeof(szNewLineIndent) - 2) dwIndent = sizeof(szNewLineIndent) - 2; + return bWriteToFile(hFile, szNewLineIndent, dwIndent + 2); } @@ -515,9 +462,8 @@ bool bWriteNewLine(HANDLE hFile, DWORD dwIndent) bool bWriteHexToFile(HANDLE hFile, void * pData, int nSize) { char cBuf[10]; - BYTE * p = (BYTE*)pData; - for (int n = 0; n < nSize; n++) - { + BYTE *p = (BYTE*)pData; + for (int n = 0; n < nSize; n++) { mir_snprintf(cBuf, _countof(cBuf), "%.2X ", p[n]); if (!bWriteToFile(hFile, cBuf, 3)) return false; @@ -571,8 +517,7 @@ void ReplaceDBPath(tstring &sRet) ReplaceAll(sRet, _T("%dbpath%"), sDBPath); // Try to firure out if it is a relative path ( ..\..\MsgExport\ ) if (sRet.size() <= 2 || !(sRet[1] == ':' || - (sRet[0] == '\\' && sRet[1] == '\\'))) - { + (sRet[0] == '\\' && sRet[1] == '\\'))) { // Relative path // we will prepend the mirande exe path to avoid problems // if the current directory changes ( User receives a file ) @@ -609,24 +554,17 @@ tstring GetFilePathFromUser(MCONTACT hContact) // Previous file name check to see if it has changed !! tstring sPrevFileName = _DBGetString(hContact, MODULE, "PrevFileName", _T("")); - if (sNoDBPath != sPrevFileName) - { - if (!sPrevFileName.empty()) - { + if (sNoDBPath != sPrevFileName) { + if (!sPrevFileName.empty()) { ReplaceDBPath(sPrevFileName); // Here we will try to avoide the (Unknown Contact) in cases where the protocol for // this user has been removed. if (bNickUsed && (_tcsstr(NickFromHandle(hContact), LPGENT("(Unknown Contact)")) != 0)) - { - // Then the filename must have changed from a correct path to one including the (Unknown Contact) - return sPrevFileName; - } + return sPrevFileName; // Then the filename must have changed from a correct path to one including the (Unknown Contact) // file name has changed - - if (enRenameAction != eDANothing) - { + if (enRenameAction != eDANothing) { // we can not use FILE_SHARE_DELETE because this is not supported by // win 98 / ME @@ -638,16 +576,14 @@ tstring GetFilePathFromUser(MCONTACT hContact) FILE_ATTRIBUTE_NORMAL, NULL); - if (hPrevFile != INVALID_HANDLE_VALUE) - { + if (hPrevFile != INVALID_HANDLE_VALUE) { CloseHandle(hPrevFile); TCHAR szTemp[500]; // There is a previous file we can move // ask user ? bool bTryRename; - if (enRenameAction != eDAAutomatic) - { + if (enRenameAction != eDAAutomatic) { tstring sRemoteUser = NickFromHandle(hContact); mir_sntprintf(szTemp, TranslateT("File name for the user \"%s\" has changed!\n\nfrom:\t%s\nto:\t%s\n\nDo you wish to rename file?"), @@ -660,16 +596,13 @@ tstring GetFilePathFromUser(MCONTACT hContact) bTryRename = true; - if (bTryRename) - { - if (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str())) - { + if (bTryRename) { + if (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str())) { // this might be because the new path isent created // so we will try to create it bCreatePathToFile(sFilePath); - while (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str())) - { + while (!MoveFile(sPrevFileName.c_str(), sFilePath.c_str())) { mir_sntprintf(szTemp, TranslateT("Failed to rename file\n\nfrom:\t%s\nto:\t%s\n\nFailed with error: %s"), sPrevFileName.c_str(), @@ -755,86 +688,69 @@ void ReplaceAllNoColon(tstring &sSrc, const TCHAR *pszReplace, tstring &sNew) void ReplaceDefines(MCONTACT hContact, tstring & sTarget) { if (sTarget.find(_T("%nick%")) != string::npos) - { ReplaceAll(sTarget, _T("%nick%"), FileNickFromHandle(hContact)); - } bool bUINUsed = sTarget.find(_T("%UIN%")) != string::npos; bool bEMailUsed = sTarget.find(_T("%e-mail%")) != string::npos; bool bProtoUsed = sTarget.find(_T("%protocol%")) != string::npos; bool bIdentifierUsed = sTarget.find(_T("%identifier%")) != string::npos; - if (bUINUsed || bEMailUsed || bProtoUsed || bIdentifierUsed) - { + if (bUINUsed || bEMailUsed || bProtoUsed || bIdentifierUsed) { string sProto = _DBGetStringA(hContact, "Protocol", "p", ""); - if (bUINUsed || (bIdentifierUsed && sProto == "ICQ")) - { + if (bUINUsed || (bIdentifierUsed && sProto == "ICQ")) { DWORD dwUIN = db_get_dw(hContact, sProto.c_str(), "UIN", 0); tstring sReplaceUin; - if (dwUIN) - { + if (dwUIN) { TCHAR sTmp[20]; mir_sntprintf(sTmp, _countof(sTmp), _T("%d"), dwUIN); sReplaceUin = sTmp; } - else - { - sReplaceUin = FileNickFromHandle(hContact); - } + else sReplaceUin = FileNickFromHandle(hContact); if (bUINUsed) ReplaceAll(sTarget, _T("%UIN%"), sReplaceUin); - if (bIdentifierUsed && sProto == "ICQ") - { + if (bIdentifierUsed && sProto == "ICQ") { bIdentifierUsed = false; ReplaceAll(sTarget, _T("%identifier%"), sReplaceUin); } } - if (bEMailUsed || (bIdentifierUsed && sProto == "MSN")) - { + if (bEMailUsed || (bIdentifierUsed && sProto == "MSN")) { tstring sEMail = _DBGetString(hContact, sProto.c_str(), "e-mail", _T("")); - if (sEMail.empty()) - { + if (sEMail.empty()) { sEMail = _DBGetString(hContact, "MSN", "e-mail", _T("")); - if (sEMail.empty()) - { + if (sEMail.empty()) { // We can't finde the E-mail address we will use the the nick sEMail = FileNickFromHandle(hContact); } } if (bEMailUsed) ReplaceAllNoColon(sTarget, _T("%e-mail%"), sEMail); - if (bIdentifierUsed && sProto == "MSN") - { + if (bIdentifierUsed && sProto == "MSN") { bIdentifierUsed = false; ReplaceAllNoColon(sTarget, _T("%identifier%"), sEMail); } } - if (bIdentifierUsed && sProto == "Jabber") - { + + if (bIdentifierUsed && sProto == "Jabber") { tstring sReplace = _DBGetString(hContact, "Jabber", "jid", _T("")); - if (sReplace.empty()) - { + if (sReplace.empty()) { sReplace = FileNickFromHandle(hContact); } bIdentifierUsed = false; ReplaceAll(sTarget, _T("%identifier%"), sReplace); } - if (bProtoUsed) - { + + if (bProtoUsed) { tstring tmp = _DBGetString(hContact, "Protocol", "p", _T("")); ReplaceAllNoColon(sTarget, _T("%protocol%"), tmp); } - if (bIdentifierUsed) - { - // It has still not been replaced we will just use nick + + if (bIdentifierUsed) // It has still not been replaced we will just use nick ReplaceAll(sTarget, _T("%nick%"), FileNickFromHandle(hContact)); - } } - if (sTarget.find(_T("%group%")) != string::npos) - { + if (sTarget.find(_T("%group%")) != string::npos) { tstring sGroup = _DBGetString(hContact, "CList", "Group", _T("")); ReplaceAllNoColon(sTarget, _T("%group%"), sGroup); } @@ -844,10 +760,8 @@ void ReplaceDefines(MCONTACT hContact, tstring & sTarget) string::size_type nCur = 0; while ((nCur = sTarget.find_first_of(_T("/*?<>|\""), nCur)) != sTarget.npos) sTarget[nCur] = cBadCharReplace; - } - ///////////////////////////////////////////////////////////////////// // Member Function : ReplaceTimeVariables // Type : Global @@ -865,8 +779,7 @@ void ReplaceTimeVariables(tstring &sRet) { if (sRet.find(_T("%year%")) != string::npos || sRet.find(_T("%month%")) != string::npos || - sRet.find(_T("%day%")) != string::npos) - { + sRet.find(_T("%day%")) != string::npos) { SYSTEMTIME stTime; GetLocalTime(&stTime); TCHAR sTmp[20]; @@ -905,8 +818,6 @@ void UpdateFileToColWidth() } } - - ///////////////////////////////////////////////////////////////////// // Member Function : DisplayErrorDialog // Type : Global @@ -930,8 +841,7 @@ void DisplayErrorDialog(const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO * sError += sGetErrorString(); sError += TranslateT("\nMessage has not been saved!\n"); sError += TranslateT("Do you wish to save debug information?"); - if (MessageBox(NULL, sError.c_str(), MSG_BOX_TITEL, MB_YESNO) == IDYES) - { + if (MessageBox(NULL, sError.c_str(), MSG_BOX_TITEL, MB_YESNO) == IDYES) { OPENFILENAME ofn; // common dialog box structure TCHAR szFile[260]; // buffer for file name mir_tstrcpy(szFile, _T("DebugInfo.txt")); @@ -951,27 +861,22 @@ void DisplayErrorDialog(const TCHAR *pszError, tstring& sFilePath, DBEVENTINFO * ofn.lpstrDefExt = _T("TXT"); // Display the Open dialog box. - - if (GetSaveFileName(&ofn)) - { + if (GetSaveFileName(&ofn)) { HANDLE hf = CreateFile(ofn.lpstrFile, GENERIC_WRITE, 0, (LPSECURITY_ATTRIBUTES)NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL); // file handle bWriteTextToFile(hf, sError.c_str(), false); - if (dbei) - { + if (dbei) { bWriteToFile(hf, "\r\ndbei :"); bWriteHexToFile(hf, dbei, sizeof(DBEVENTINFO)); - if (dbei->pBlob) - { + if (dbei->pBlob) { bWriteToFile(hf, "\r\ndbei.pBlob :"); bWriteHexToFile(hf, dbei->pBlob, min(dbei->cbBlob, 10000)); } - if (dbei->szModule) - { + if (dbei->szModule) { bWriteToFile(hf, "\r\ndbei.szModule :"); bWriteToFile(hf, dbei->szModule); } @@ -1003,18 +908,15 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) GetLastError();// Clear last error !! HANDLE hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) - { + if (hFile == INVALID_HANDLE_VALUE) { // this might be because the path isent created // so we will try to create it - if (bCreatePathToFile(sFilePath)) - { + if (bCreatePathToFile(sFilePath)) { hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } } - if (hFile == INVALID_HANDLE_VALUE) - { + if (hFile == INVALID_HANDLE_VALUE) { DisplayErrorDialog(LPGENT("Failed to open or create file :\n"), sFilePath, NULL); return; } @@ -1023,14 +925,12 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) tstring sRemoteUser; string::size_type nFirstColumnWidth; - if (bUseLessAndGreaterInExport) - { + if (bUseLessAndGreaterInExport) { sLocalUser = _T("<<"); sRemoteUser = _T(">>"); nFirstColumnWidth = 4; } - else - { + else { sLocalUser = NickFromHandle(0); sRemoteUser = NickFromHandle(hContact); nFirstColumnWidth = max(sRemoteUser.size(), clFileTo1ColWidth[sFilePath]); @@ -1041,22 +941,17 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) bool bWriteUTF8Format = false; { - DWORD dwLowSize; DWORD dwHighSize = 0; + DWORD dwLowSize = GetFileSize(hFile, &dwHighSize); - dwLowSize = GetFileSize(hFile, &dwHighSize); - - if (dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0) - { + if (dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0) { DWORD dwDataRead = 0; BYTE ucByteOrder[3]; if (ReadFile(hFile, ucByteOrder, 3, &dwDataRead, NULL)) - { bWriteUTF8Format = bIsUtf8Header(ucByteOrder); - } + DWORD dwPtr = SetFilePointer(hFile, 0, 0, FILE_END); - if (dwPtr == INVALID_SET_FILE_POINTER) - { + if (dwPtr == INVALID_SET_FILE_POINTER) { // we need to aborte mission here because if we continue we risk // overwriting old log. DisplayErrorDialog(LPGENT("Failed to move to the end of the file :\n"), sFilePath, NULL); @@ -1064,13 +959,10 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) return; } } - else - { + else { bWriteUTF8Format = bUseUtf8InNewFiles; - if (bWriteUTF8Format) - { - if (!bWriteToFile(hFile, szUtf8ByteOrderHeader, sizeof(szUtf8ByteOrderHeader) - 1)) - { + if (bWriteUTF8Format) { + if (!bWriteToFile(hFile, szUtf8ByteOrderHeader, sizeof(szUtf8ByteOrderHeader) - 1)) { DisplayErrorDialog(LPGENT("Failed to UTF8 byte order code to file :\n"), sFilePath, NULL); CloseHandle(hFile); return; @@ -1102,9 +994,7 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) ReplaceAll(output, _T("%Proto%"), _DBGetString(hContact, "Protocol", "p", _T(""))); for (int nCur = 0; nCur < 9; nCur++) - { ReplaceAll(output, pszReplaceList[nCur], _DBGetString(hContact, sProto.c_str(), pszReplaceListA[nCur], _T(""))); - } mir_sntprintf(szTemp, _T("%d"), db_get_dw(hContact, sProto.c_str(), "UIN", 0)); ReplaceAll(output, _T("%UIN%"), szTemp); @@ -1116,8 +1006,7 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) szTemp[1] = 0; ReplaceAll(output, _T("%Gender%"), szTemp); - if (!bWriteTextToFile(hFile, output.data(), bWriteUTF8Format, (int)output.size())) - { + if (!bWriteTextToFile(hFile, output.data(), bWriteUTF8Format, (int)output.size())) { DisplayErrorDialog(LPGENT("Failed to write user details to file :\n"), sFilePath, NULL); CloseHandle(hFile); return; @@ -1138,229 +1027,197 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) szTemp[nIndent++] = ' '; // Write first part of line with name and timestamp - if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, nIndent)) - { + if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, nIndent)) { DisplayErrorDialog(LPGENT("Failed to write timestamp and username to file :\n"), sFilePath, &dbei); CloseHandle(hFile); return; } } - if (dbei.pBlob != NULL && dbei.cbBlob >= 2) - { + if (dbei.pBlob != NULL && dbei.cbBlob >= 2) { dbei.pBlob[dbei.cbBlob] = 0; - switch (dbei.eventType) - { + switch (dbei.eventType) { case EVENTTYPE_MESSAGE: - { - TCHAR* msg = DbGetEventTextT(&dbei, CP_ACP); - if (!bWriteIndentedToFile(hFile, nIndent, msg, bWriteUTF8Format)) { - DisplayErrorDialog(LPGENT("Failed to write message to the file :\n"), sFilePath, &dbei); + TCHAR *msg = DbGetEventTextT(&dbei, CP_ACP); + if (!bWriteIndentedToFile(hFile, nIndent, msg, bWriteUTF8Format)) { + DisplayErrorDialog(LPGENT("Failed to write message to the file :\n"), sFilePath, &dbei); + } + mir_free(msg); } - mir_free(msg); break; - } + case EVENTTYPE_URL: case EVENTTYPE_FILE: - { - const TCHAR *pszType; - const char *pszData; - - if (dbei.eventType == EVENTTYPE_URL) { - pszType = LPGENT("URL: "); - pszData = (char *)dbei.pBlob; - } - else - { - pszType = LPGENT("File: "); - pszData = (char *)(dbei.pBlob + sizeof(DWORD)); - } + const TCHAR *pszType; + const char *pszData; + + if (dbei.eventType == EVENTTYPE_URL) { + pszType = LPGENT("URL: "); + pszData = (char *)dbei.pBlob; + } + else { + pszType = LPGENT("File: "); + pszData = (char *)(dbei.pBlob + sizeof(DWORD)); + } - bool bWriteOk = false; + bool bWriteOk = false; - int nLen = (int)mir_strlen(pszData); - if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) - { - if (bWriteTextToFile(hFile, pszType, bWriteUTF8Format) && - bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format)) - { - pszData += nLen + 1; - if ((pszData - (char *)dbei.pBlob) >= (int)dbei.cbBlob) - { - bWriteOk = true; - } - else - { - nLen = (int)mir_strlen(pszData); - if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) - { - if (bWriteNewLine(hFile, nIndent) && - bWriteTextToFile(hFile, LPGENT("Description: "), bWriteUTF8Format) && - bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format)) - { - bWriteOk = true; + int nLen = (int)mir_strlen(pszData); + if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) { + if (bWriteTextToFile(hFile, pszType, bWriteUTF8Format) && + bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format)) { + pszData += nLen + 1; + if ((pszData - (char *)dbei.pBlob) >= (int)dbei.cbBlob) { + bWriteOk = true; + } + else { + nLen = (int)mir_strlen(pszData); + if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) { + if (bWriteNewLine(hFile, nIndent) && + bWriteTextToFile(hFile, LPGENT("Description: "), bWriteUTF8Format) && + bWriteIndentedToFile(hFile, nIndent, pszData, bWriteUTF8Format)) { + bWriteOk = true; + } } } } } - } - if (!bWriteOk) - DisplayErrorDialog(LPGENT("Failed to write URL/File to the file :\n"), sFilePath, &dbei); + if (!bWriteOk) + DisplayErrorDialog(LPGENT("Failed to write URL/File to the file :\n"), sFilePath, &dbei); + } break; - } + case EVENTTYPE_AUTHREQUEST: case EVENTTYPE_ADDED: - { - const TCHAR *pszTypes[] = { - LPGENT("Nick :"), - LPGENT("FirstName :"), - LPGENT("LastName :"), - LPGENT("e-mail :"), - LPGENT("Reason :") }; - - if (dbei.cbBlob < 8 || dbei.cbBlob > 5000) { - int n = mir_sntprintf(szTemp, TranslateT("Invalid Database event received. Type %d, size %d"), dbei.eventType, dbei.cbBlob); - if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n)) - DisplayErrorDialog(LPGENT("Failed to write Invalid Database event the file :\n"), sFilePath, &dbei); - break; - } + const TCHAR *pszTypes[] = { + LPGENT("Nick :"), + LPGENT("FirstName :"), + LPGENT("LastName :"), + LPGENT("e-mail :"), + LPGENT("Reason :") }; + + if (dbei.cbBlob < 8 || dbei.cbBlob > 5000) { + int n = mir_sntprintf(szTemp, TranslateT("Invalid Database event received. Type %d, size %d"), dbei.eventType, dbei.cbBlob); + if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n)) + DisplayErrorDialog(LPGENT("Failed to write Invalid Database event the file :\n"), sFilePath, &dbei); + break; + } - bool bWriteOk = false; - - int nStringCount; - const TCHAR *pszTitle; - char *pszCurBlobPos; - if (dbei.eventType == EVENTTYPE_AUTHREQUEST) - { // request - //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) - nStringCount = 5; - pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD) * 2; - pszTitle = LPGENT("The following user made an authorization request:"); - } - else - { // Added - //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) - pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD); - nStringCount = 4; - pszTitle = LPGENT("The following user added you to their contact list:"); - } + bool bWriteOk = false; - if (bWriteTextToFile(hFile, pszTitle, bWriteUTF8Format) && - bWriteNewLine(hFile, nIndent) && - bWriteTextToFile(hFile, LPGENT("UIN :"), bWriteUTF8Format)) - { - DWORD uin = *((PDWORD)(dbei.pBlob)); - int n = mir_sntprintf(szTemp, _T("%d"), uin); - if (bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n)) - { - char *pszEnd = (char *)(dbei.pBlob + dbei.cbSize); - for (int n = 0; n < nStringCount && pszCurBlobPos < pszEnd; n++) - { - if (*pszCurBlobPos) - { - if (!bWriteNewLine(hFile, nIndent) || - !bWriteTextToFile(hFile, TranslateTS(pszTypes[n]), bWriteUTF8Format) || - !bWriteIndentedToFile(hFile, nIndent, pszCurBlobPos, bWriteUTF8Format)) - { - break; + int nStringCount; + const TCHAR *pszTitle; + char *pszCurBlobPos; + if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { // request + //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) + nStringCount = 5; + pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD) * 2; + pszTitle = LPGENT("The following user made an authorization request:"); + } + else { // Added + //blob is: uin(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) + pszCurBlobPos = (char *)dbei.pBlob + sizeof(DWORD); + nStringCount = 4; + pszTitle = LPGENT("The following user added you to their contact list:"); + } + + if (bWriteTextToFile(hFile, pszTitle, bWriteUTF8Format) && + bWriteNewLine(hFile, nIndent) && + bWriteTextToFile(hFile, LPGENT("UIN :"), bWriteUTF8Format)) { + DWORD uin = *((PDWORD)(dbei.pBlob)); + int n = mir_sntprintf(szTemp, _T("%d"), uin); + if (bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n)) { + char *pszEnd = (char *)(dbei.pBlob + dbei.cbSize); + for (int n = 0; n < nStringCount && pszCurBlobPos < pszEnd; n++) { + if (*pszCurBlobPos) { + if (!bWriteNewLine(hFile, nIndent) || + !bWriteTextToFile(hFile, TranslateTS(pszTypes[n]), bWriteUTF8Format) || + !bWriteIndentedToFile(hFile, nIndent, pszCurBlobPos, bWriteUTF8Format)) { + break; + } + pszCurBlobPos += mir_strlen(pszCurBlobPos); } - pszCurBlobPos += mir_strlen(pszCurBlobPos); + pszCurBlobPos++; } - pszCurBlobPos++; + bWriteOk = true; } - bWriteOk = true; } - } - - if (!bWriteOk) - DisplayErrorDialog(LPGENT("Failed to write AUTHREQUEST or ADDED to the file :\n"), sFilePath, &dbei); + if (!bWriteOk) + DisplayErrorDialog(LPGENT("Failed to write AUTHREQUEST or ADDED to the file :\n"), sFilePath, &dbei); + } break; - } + case ICQEVENTTYPE_EMAILEXPRESS: case ICQEVENTTYPE_WEBPAGER: - { - //e-mail express - //db event added to NULL contact - //blob format is: - //ASCIIZ text, usually of the form "Subject: %s\r\n%s" - //ASCIIZ from name - //ASCIIZ from e-mail - - //www pager - //db event added to NULL contact - //blob format is: - //ASCIIZ text, usually "Sender IP: xxx.xxx.xxx.xxx\r\n%s" - //ASCIIZ from name - //ASCIIZ from e-mail - const char* pszStr = (const char*)dbei.pBlob; - - if (dbei.eventType == ICQEVENTTYPE_EMAILEXPRESS) - bWriteTextToFile(hFile, LPGENT("EmailExpress from:"), bWriteUTF8Format); - else - bWriteTextToFile(hFile, LPGENT("WebPager from:"), bWriteUTF8Format); - - bWriteNewLine(hFile, nIndent); - - size_t nMsgLenght = mir_strlen(pszStr) + 1; - if (nMsgLenght < dbei.cbBlob) { - size_t nFriendlyLen = mir_strlen(&pszStr[nMsgLenght]); - bWriteTextToFile(hFile, &pszStr[nMsgLenght], bWriteUTF8Format, (int)nFriendlyLen); - size_t nEmailOffset = nMsgLenght + nFriendlyLen + 1; - if (nEmailOffset < dbei.cbBlob) - { - bWriteTextToFile(hFile, _T("<"), bWriteUTF8Format); - size_t nEmailLen = mir_strlen(&pszStr[nEmailOffset]); - bWriteTextToFile(hFile, &pszStr[nEmailOffset], bWriteUTF8Format, (int)nEmailLen); - bWriteTextToFile(hFile, _T(">"), bWriteUTF8Format); + //e-mail express + //db event added to NULL contact + //blob format is: + //ASCIIZ text, usually of the form "Subject: %s\r\n%s" + //ASCIIZ from name + //ASCIIZ from e-mail + + //www pager + //db event added to NULL contact + //blob format is: + //ASCIIZ text, usually "Sender IP: xxx.xxx.xxx.xxx\r\n%s" + //ASCIIZ from name + //ASCIIZ from e-mail + const char* pszStr = (const char*)dbei.pBlob; + + if (dbei.eventType == ICQEVENTTYPE_EMAILEXPRESS) + bWriteTextToFile(hFile, LPGENT("EmailExpress from:"), bWriteUTF8Format); + else + bWriteTextToFile(hFile, LPGENT("WebPager from:"), bWriteUTF8Format); + + bWriteNewLine(hFile, nIndent); + + size_t nMsgLenght = mir_strlen(pszStr) + 1; + if (nMsgLenght < dbei.cbBlob) { + size_t nFriendlyLen = mir_strlen(&pszStr[nMsgLenght]); + bWriteTextToFile(hFile, &pszStr[nMsgLenght], bWriteUTF8Format, (int)nFriendlyLen); + size_t nEmailOffset = nMsgLenght + nFriendlyLen + 1; + if (nEmailOffset < dbei.cbBlob) { + bWriteTextToFile(hFile, _T("<"), bWriteUTF8Format); + size_t nEmailLen = mir_strlen(&pszStr[nEmailOffset]); + bWriteTextToFile(hFile, &pszStr[nEmailOffset], bWriteUTF8Format, (int)nEmailLen); + bWriteTextToFile(hFile, _T(">"), bWriteUTF8Format); + } } - } - else - { - bWriteTextToFile(hFile, LPGENT("No from address"), bWriteUTF8Format); - } + else bWriteTextToFile(hFile, LPGENT("No from address"), bWriteUTF8Format); - if (!bWriteNewLine(hFile, nIndent) || - !bWriteIndentedToFile(hFile, nIndent, pszStr, bWriteUTF8Format)) - { - DisplayErrorDialog(LPGENT("Failed to write EmailExpress to the file :\n"), sFilePath, &dbei); + if (!bWriteNewLine(hFile, nIndent) || + !bWriteIndentedToFile(hFile, nIndent, pszStr, bWriteUTF8Format)) { + DisplayErrorDialog(LPGENT("Failed to write EmailExpress to the file :\n"), sFilePath, &dbei); + } } break; - } + case ICQEVENTTYPE_SMS: - { if (!bWriteIndentedToFile(hFile, nIndent, (const char*)dbei.pBlob, bWriteUTF8Format)) - { DisplayErrorDialog(LPGENT("Failed to write SMS to the file :\n"), sFilePath, &dbei); - } break; - } + default: - { int n = mir_sntprintf(szTemp, TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob); if (!bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n)) - { DisplayErrorDialog(LPGENT("Failed to write Unknown event to the file :\n"), sFilePath, &dbei); - } break; } - } } - else - { + else { int n = mir_sntprintf(szTemp, TranslateT("Unknown event type %d, size %d"), dbei.eventType, dbei.cbBlob); bWriteTextToFile(hFile, szTemp, bWriteUTF8Format, n); } - bWriteToFile(hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n"); + bWriteToFile(hFile, bAppendNewLine ? "\r\n\r\n" : "\r\n"); CloseHandle(hFile); - UpdateFileViews(sFilePath.c_str()); } @@ -1412,8 +1269,7 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const char *pszSrc, bool bU int nLen = (int)mir_strlen(pszSrc); wchar_t * pszWstr = new wchar_t[nLen + 1]; bool bRet = false; - if (MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen) == nLen) - { + if (MultiByteToWideChar(CP_ACP, 0, pszSrc, nLen, pszWstr, nLen) == nLen) { pszWstr[nLen] = NULL; bRet = bWriteIndentedToFile(hFile, nIndent, pszWstr, bUtf8File); } @@ -1446,26 +1302,20 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool b bool bOk = true; bool bFirstLine = true; - while (*pszSrc) - { // first we will scan forward in string to finde either new line or "max line with" + while (*pszSrc) { // first we will scan forward in string to finde either new line or "max line with" int nLineLen = 0; - do - { + do { if (pszSrc[nLineLen] == _T('\n') || pszSrc[nLineLen] == _T('\r')) break; - if (nLineLen >= nMaxLineWidth) - { // ok the line was not broken. we need to force a break + if (nLineLen >= nMaxLineWidth) { // ok the line was not broken. we need to force a break // we will scan backwards again to finde a space !! // then we will look for a ? and so on. const TCHAR ac[] = { _T(' '), _T('?'), _T('-'), _T('.'), _T(',') }; - for (int y = 0; y < _countof(ac); y++) - { - for (int n = nLineLen; n > 0; n--) - { - if (pszSrc[n] == ac[y]) - { + for (int y = 0; y < _countof(ac); y++) { + for (int n = nLineLen; n > 0; n--) { + if (pszSrc[n] == ac[y]) { nLineLen = n; goto SuperBreak; } @@ -1477,43 +1327,20 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool b } while (pszSrc[nLineLen]); // trim away traling spaces !! - if (nLineLen > 0) - { + if (nLineLen > 0) { while (pszSrc[nLineLen - 1] == ' ') nLineLen--; } SuperBreak: - - // nLineLen should contain the number af chars we need to write to the file - if (nLineLen > 0) - { + if (nLineLen > 0) { if (!bFirstLine) - { if (!bWriteNewLine(hFile, nIndent)) - { bOk = false; - } - } - /* if (bUtf8Src ) - { - // Programming error writing UTF8 string to ansi file - if ( !bUtf8File ) - { - MessageBox(NULL, _T("Programming error writing UTF8 string to ansi file") ,MSG_BOX_TITEL,MB_OK); - // bUtf8File must be true here - } - if (!bWriteToFile( hFile, pszSrc, nLineLen)) - { - bOk = false; - } - } - else*/ - {// Text format !! - if (!bWriteTextToFile(hFile, pszSrc, bUtf8File, nLineLen)) - bOk = false; - } + + if (!bWriteTextToFile(hFile, pszSrc, bUtf8File, nLineLen)) + bOk = false; } bFirstLine = false; @@ -1524,8 +1351,7 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool b while (*pszSrc == _T(' ') || *pszSrc == _T('\n') || *pszSrc == _T('\r')) pszSrc++; - if (pszPrev == pszSrc) - { + if (pszPrev == pszSrc) { // this is an programming error we have not moved forward in string MessageBox(NULL, _T("Programming error on line __LINE__ please report this"), MSG_BOX_TITEL, MB_OK); break; @@ -1536,7 +1362,6 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const TCHAR *pszSrc, bool b return bOk; } - ///////////////////////////////////////////////////////////////////// // Member Function : nContactDeleted // Type : Global @@ -1578,8 +1403,7 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) FILE_ATTRIBUTE_NORMAL, NULL); - if (hPrevFile != INVALID_HANDLE_VALUE) - { + if (hPrevFile != INVALID_HANDLE_VALUE) { CloseHandle(hPrevFile); TCHAR szTemp[500]; @@ -1587,10 +1411,8 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) TranslateT("User has been deleted. Do you want to delete the file?"), sFilePath.c_str()); if (enDeleteAction == eDAAutomatic || - MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES) - { - if (!DeleteFile(sFilePath.c_str())) - { + MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES) { + if (!DeleteFile(sFilePath.c_str())) { mir_sntprintf(szTemp, _T("%s\r\n%s"), TranslateT("Failed to delete the file"), @@ -1633,4 +1455,3 @@ void SaveSettings() db_set_b(NULL, MODULE, "RenameAction", (BYTE)enRenameAction); db_set_b(NULL, MODULE, "DeleteAction", (BYTE)enDeleteAction); } - diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp index 1a67cb7d77..b81570c9f6 100644 --- a/plugins/NewEventNotify/src/main.cpp +++ b/plugins/NewEventNotify/src/main.cpp @@ -31,7 +31,7 @@ extern PLUGIN_DATA* PopupList[20]; //---Some global variables for the plugin CLIST_INTERFACE *pcli; -HINSTANCE hInst; +HINSTANCE g_hInst; PLUGIN_OPTIONS pluginOptions; int hLangpack; PLUGININFOEX pluginInfo = { @@ -123,7 +123,7 @@ int HookedInit(WPARAM, LPARAM) //---Called when an options dialog has to be created int HookedOptions(WPARAM wParam, LPARAM) { - OptionsAdd(hInst, wParam); + OptionsAdd(g_hInst, wParam); return 0; } @@ -144,8 +144,7 @@ extern "C" __declspec(dllexport) int Load(void) mir_getCLI(); OptionsInit(&pluginOptions); - pluginOptions.hInst = hInst; - + pluginOptions.hInst = g_hInst; return 0; } @@ -156,7 +155,7 @@ extern "C" __declspec(dllexport) int Unload(void) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) { - hInst = hinstDLL; + g_hInst = hinstDLL; return TRUE; } diff --git a/plugins/NewEventNotify/src/menuitem.cpp b/plugins/NewEventNotify/src/menuitem.cpp index 19b4347ea1..d02ea6d2b6 100644 --- a/plugins/NewEventNotify/src/menuitem.cpp +++ b/plugins/NewEventNotify/src/menuitem.cpp @@ -40,9 +40,9 @@ static INT_PTR MenuitemNotifyCmd(WPARAM, LPARAM) int MenuitemUpdate(BOOL bStatus) { if (bStatus) - Menu_ModifyItem(hMenuitemNotify, _T(MENUITEM_DISABLE), LoadIcon(hInst, MAKEINTRESOURCE(IDI_ENABLED))); + Menu_ModifyItem(hMenuitemNotify, _T(MENUITEM_DISABLE), LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ENABLED))); else - Menu_ModifyItem(hMenuitemNotify, _T(MENUITEM_ENABLE), LoadIcon(hInst, MAKEINTRESOURCE(IDI_DISABLED))); + Menu_ModifyItem(hMenuitemNotify, _T(MENUITEM_ENABLE), LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_DISABLED))); return 0; } @@ -53,7 +53,7 @@ int MenuitemInit(BOOL bStatus) CMenuItem mi; mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Popups"), 0); mi.position = 1; - mi.hIcolibItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ENABLED)); + mi.hIcolibItem = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ENABLED)); mi.pszService = MS_NEN_MENUNOTIFY; mi.flags = 0; hMenuitemNotify = Menu_AddMainMenuItem(&mi); diff --git a/plugins/NewEventNotify/src/options.cpp b/plugins/NewEventNotify/src/options.cpp index c944c10ab2..395c77ec40 100644 --- a/plugins/NewEventNotify/src/options.cpp +++ b/plugins/NewEventNotify/src/options.cpp @@ -288,7 +288,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, L int OptionsAdd(HINSTANCE hInst, WPARAM addInfo) { - if ( ServiceExists(MS_POPUP_ADDPOPUPT)) { + if (ServiceExists(MS_POPUP_ADDPOPUPT)) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); diff --git a/plugins/NewEventNotify/src/stdafx.h b/plugins/NewEventNotify/src/stdafx.h index 9b1e1dcd74..49b4ef9852 100644 --- a/plugins/NewEventNotify/src/stdafx.h +++ b/plugins/NewEventNotify/src/stdafx.h @@ -223,4 +223,4 @@ int MenuitemUpdate(BOOL bStatus); int NumberPopupData(MCONTACT hContact, int eventType); int CheckMsgWnd(MCONTACT hContact); -extern HINSTANCE hInst; +extern HINSTANCE g_hInst; diff --git a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp index 97d0b6f634..36e379aa59 100644 --- a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp @@ -98,8 +98,8 @@ TConnectionSettings::TConnectionSettings(PROTOACCOUNT *pa) tszAccName = pa->tszAccountName; szMsg = NULL; - int status = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - AssignStatus(this, status, status, NULL); + int iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); + AssignStatus(this, iStatus, iStatus, NULL); } TConnectionSettings::~TConnectionSettings() -- cgit v1.2.3