From 7a7c887270215690d37bd8208c7a67c5b5bc050d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 21 Dec 2013 14:18:30 +0000 Subject: - fix for saving messages; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@7318 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/services.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 6 +- plugins/TabSRMM/src/infopanel.cpp | 2 +- plugins/TabSRMM/src/msgdialog.cpp | 631 ++++++++++++++++------------------ plugins/TabSRMM/src/msgoptions.cpp | 4 +- plugins/TabSRMM/src/utils.cpp | 152 ++++---- 6 files changed, 387 insertions(+), 410 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 23914251de..87c5799b55 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -474,7 +474,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT newData.iTabID = newItem; newData.iTabImage = newData.item.iImage; newData.pContainer = pContainer; - newData.iActivate = (int) bActivateTab; + newData.iActivate = bActivateTab; pContainer->iChilds++; newData.bWantPopup = bWantPopup; newData.hdbEvent = (HANDLE)si; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 86c725e219..417be331ec 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2624,7 +2624,7 @@ LABEL_SHOWWINDOW: } if (msg == WM_KEYDOWN && wp == VK_TAB) { - if (((NMHDR *)lParam)->idFrom == IDC_CHAT_LOG) { + if (((NMHDR*)lParam)->idFrom == IDC_CHAT_LOG) { SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)); return(_dlgReturn(hwndDlg, 1)); } @@ -2775,7 +2775,7 @@ LABEL_SHOWWINDOW: TranslateMenu(hSubMenu); pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam); pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam); - ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt); + ClientToScreen(((NMHDR*) lParam)->hwndFrom, &pt); switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) { case ID_NEW: CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW|OUF_TCHAR, (LPARAM)tr.lpstrText); @@ -2822,7 +2822,7 @@ LABEL_SHOWWINDOW: pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam); pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam); - ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt); + ClientToScreen(((NMHDR*) lParam)->hwndFrom, &pt); CopyMemory(&uiNew, ui, sizeof(USERINFO)); UINT uID = CreateGCMenu(hwndDlg, &hMenu, 0, pt, si, uiNew.pszUID, uiNew.pszNick); switch (uID) { diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index dace238737..19fb5e3ecf 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -1635,7 +1635,7 @@ INT_PTR CALLBACK CTip::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam return 1; case WM_NOTIFY: - switch (((NMHDR *) lParam)->code) { + switch (((NMHDR*) lParam)->code) { case EN_LINK: ::SetFocus(m_hRich); switch (((ENLINK *) lParam)->msg) { diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index a0142b5a9d..811b8cd2d2 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1226,13 +1226,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { - RECT rc; int i; - BOOL isThemed = TRUE; - int dwLocalSmAdd = 0; - DBVARIANT dbv = {0}; - TNewWindowData *newData = (TNewWindowData *) lParam; + TNewWindowData *newData = (TNewWindowData*)lParam; dat = (TWindowData*)mir_calloc(sizeof(TWindowData)); if (newData->iTabID >= 0) { @@ -1240,13 +1236,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP m_pContainer = dat->pContainer; hwndContainer = m_pContainer->hwnd; } - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); if (Utils::rtf_ctable == 0) Utils::RTF_CTableInit(); dat->dwFlags |= MWF_INITMODE; - dat->bType = SESSIONTYPE_IM; dat->fInsertMode = FALSE; dat->fLimitedUpdate = false; @@ -1263,7 +1258,6 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP pszIDCSAVE_save = TranslateT("Save and close session"); dat->hContact = newData->hContact; - dat->cache = CContactCache::getContactCache(dat->hContact); dat->cache->updateState(); dat->cache->setWindowData(hwndDlg, dat); @@ -1304,9 +1298,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->iCurrentQueueError = -1; /* - * message history limit - * hHistoryEvents holds up to n event handles - */ + * message history limit + * hHistoryEvents holds up to n event handles + */ dat->maxHistory = M.GetDword(dat->hContact, "maxhist", M.GetDword("maxhist", 0)); dat->curHistory = 0; @@ -1323,12 +1317,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->mayFlashTab = FALSE; GetMyNick(dat); - dat->multiSplitterX = (int) M.GetDword(SRMSGMOD, "multisplit", 150); + dat->multiSplitterX = (int)M.GetDword(SRMSGMOD, "multisplit", 150); dat->nTypeMode = PROTOTYPE_SELFTYPING_OFF; SetTimer(hwndDlg, TIMERID_TYPE, 1000, NULL); dat->iLastEventType = 0xffffffff; - // load log option flags... dat->dwFlags = dat->pContainer->theme.dwFlags; /* @@ -1343,7 +1336,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP * allow disabling emoticons per contact (note: currently unused feature) */ - dwLocalSmAdd = (int)M.GetByte(dat->hContact, "doSmileys", 0xff); + int dwLocalSmAdd = M.GetByte(dat->hContact, "doSmileys", 0xff); if (dwLocalSmAdd != 0xffffffff) dat->doSmileys = dwLocalSmAdd; @@ -1361,6 +1354,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } dat->showPic = GetAvatarVisibility(hwndDlg, dat); + + RECT rc; GetWindowRect(GetDlgItem(hwndDlg, IDC_SMILEYBTN), &rc); Utils::showDlgControl(hwndDlg, IDC_MULTISPLITTER, SW_HIDE); @@ -1380,6 +1375,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP BB_InitDlgButtons(dat); SendMessage(hwndDlg, DM_LOADBUTTONBARICONS, 0, 0); + BOOL isThemed = TRUE; if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) isThemed = FALSE; @@ -1388,7 +1384,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(GetDlgItem(hwndDlg, IDC_CANCELADD), BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTHEMEDBTN, isThemed != 0, 0); + SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTHEMEDBTN, isThemed, 0); SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0); SendDlgItemMessage(hwndDlg, IDC_TOGGLESIDEBAR, BUTTONSETASTOOLBARBUTTON, TRUE, 0); @@ -1406,7 +1402,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SetWindowText(GetDlgItem(hwndDlg, IDC_RETRY), TranslateT("Retry")); UINT _ctrls[] = {IDC_RETRY, IDC_CANCELSEND, IDC_MSGSENDLATER}; - for (i=0; i < 3; i++) { + for (i=0; i < SIZEOF(_ctrls); i++) { SendDlgItemMessage(hwndDlg, _ctrls[i], BUTTONSETASPUSHBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, _ctrls[i], BUTTONSETASFLATBTN, FALSE, 0); SendDlgItemMessage(hwndDlg, _ctrls[i], BUTTONSETASTHEMEDBTN, TRUE, 0); @@ -1430,8 +1426,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETLANGOPTIONS, 0, SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOFONTSIZEADJUST); /* - * add us to the tray list (if it exists) - */ + * add us to the tray list (if it exists) + */ if (PluginConfig.g_hMenuTrayUnread != 0 && dat->hContact != 0 && dat->szProto != NULL) UpdateTrayMenu(0, dat->wStatus, dat->szProto, dat->szStatus, dat->hContact, FALSE); @@ -1439,8 +1435,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, (WPARAM)TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXLIMITTEXT, 0, 0x80000000); /* - * subclassing stuff - */ + * subclassing stuff + */ mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), MessageEditSubclassProc); mir_subclassWindow( GetDlgItem(hwndDlg, IDC_CONTACTPIC), AvatarSubclassProc); @@ -1449,8 +1445,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP mir_subclassWindow( GetDlgItem(hwndDlg, IDC_PANELSPLITTER), SplitterSubclassProc); /* - * load old messages from history (if wanted...) - */ + * load old messages from history (if wanted...) + */ dat->cache->updateStats(TSessionStats::INIT_TIMER); if (dat->hContact) { @@ -1462,87 +1458,76 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP LoadOwnAvatar(dat); /* - * restore saved msg if any... - */ + * restore saved msg if any... + */ if (dat->hContact) { - DBVARIANT dbv; - if (!db_get_s(dat->hContact, SRMSGMOD, "SavedMsg", &dbv)) { - SETTEXTEX stx = {ST_DEFAULT, CP_UTF8}; - - if (dbv.type == DBVT_ASCIIZ && lstrlenA(dbv.pszVal) > 0) - SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)dbv.pszVal); - db_free(&dbv); + ptrT tszSavedMsg(db_get_tsa(dat->hContact, SRMSGMOD, "SavedMsg")); + if (tszSavedMsg != 0) { + SETTEXTEX stx = { ST_DEFAULT, 1200 }; + SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, tszSavedMsg); SendQueue::UpdateSaveAndSendButton(dat); if (m_pContainer->hwndActive == hwndDlg) UpdateReadChars(dat); } } if (newData->szInitialText) { - int len; if (newData->isWchar) SetDlgItemTextW(hwndDlg, IDC_MESSAGE, (TCHAR*)newData->szInitialText); else SetDlgItemTextA(hwndDlg, IDC_MESSAGE, newData->szInitialText); - len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)); + int len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)); PostMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETSEL, len, len); if (len) EnableSendButton(dat, TRUE); } - //dat->dwFlags &= ~MWF_INITMODE; - { - HANDLE hdbEvent = db_event_last(dat->hContact); - if (hdbEvent) { - do { - DBEVENTINFO dbei = { sizeof(dbei) }; - db_event_get(hdbEvent, &dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { - dat->lastMessage = dbei.timestamp; - DM_UpdateLastMessage(dat); - break; - } - } - while (hdbEvent = db_event_prev(hdbEvent)); + + for (HANDLE hdbEvent = db_event_last(dat->hContact); hdbEvent; hdbEvent = db_event_prev(hdbEvent)) { + DBEVENTINFO dbei = { sizeof(dbei) }; + db_event_get(hdbEvent, &dbei); + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { + dat->lastMessage = dbei.timestamp; + DM_UpdateLastMessage(dat); + break; } } + SendMessage(hwndContainer, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); - { - WNDCLASS wndClass = { 0 }; - GetClassInfo(g_hInst, _T("RichEdit20W"), &wndClass); - mir_subclassWindowFull( GetDlgItem(hwndDlg, IDC_LOG), MessageLogSubclassProc, wndClass.lpfnWndProc); - } + WNDCLASS wndClass = { 0 }; + GetClassInfo(g_hInst, _T("RichEdit20W"), &wndClass); + mir_subclassWindowFull(GetDlgItem(hwndDlg, IDC_LOG), MessageLogSubclassProc, wndClass.lpfnWndProc); + SetWindowPos(hwndDlg, 0, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), newData->iActivate ? 0 : SWP_NOZORDER | SWP_NOACTIVATE); LoadSplitter(dat); ShowPicture(dat, TRUE); if (m_pContainer->dwFlags & CNT_CREATE_MINIMIZED || !newData->iActivate || m_pContainer->dwFlags & CNT_DEFERREDTABSELECT) { - DBEVENTINFO dbei = {0}; - - dbei.flags = 0; - dbei.eventType = EVENTTYPE_MESSAGE; dat->iFlashIcon = PluginConfig.g_IconMsgEvent; SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL); - dat->mayFlashTab = TRUE; + dat->mayFlashTab = true; + + DBEVENTINFO dbei = { 0 }; + dbei.eventType = EVENTTYPE_MESSAGE; FlashOnClist(hwndDlg, dat, dat->hDbEventFirst, &dbei); + SendMessage(hwndContainer, DM_SETICON, (WPARAM)dat, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); m_pContainer->dwFlags |= CNT_NEED_UPDATETITLE; - dat->dwFlags |= (MWF_NEEDCHECKSIZE | MWF_WASBACKGROUNDCREATE); - dat->dwFlags |= MWF_DEFERREDSCROLL; + dat->dwFlags |= MWF_NEEDCHECKSIZE | MWF_WASBACKGROUNDCREATE | MWF_DEFERREDSCROLL; } + if (newData->iActivate) { m_pContainer->hwndActive = hwndDlg; ShowWindow(hwndDlg, SW_SHOW); SetActiveWindow(hwndDlg); SetForegroundWindow(hwndDlg); - //SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); - PostMessage(hwndContainer, DM_UPDATETITLE, (WPARAM)dat->hContact, 0); - } else if (m_pContainer->dwFlags & CNT_CREATE_MINIMIZED) { + } + else if (m_pContainer->dwFlags & CNT_CREATE_MINIMIZED) { dat->dwFlags |= MWF_DEFERREDSCROLL; ShowWindow(hwndDlg, SW_SHOWNOACTIVATE); m_pContainer->hwndActive = hwndDlg; m_pContainer->dwFlags |= CNT_DEFERREDCONFIGURE; - PostMessage(hwndContainer, DM_UPDATETITLE, (WPARAM)dat->hContact, 0); } + PostMessage(hwndContainer, DM_UPDATETITLE, (WPARAM)dat->hContact, 0); DM_RecalcPictureSize(dat); dat->dwLastActivity = GetTickCount() - 1000; @@ -1555,8 +1540,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TABSRMM_FireEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_OPEN, 0); /* - * show a popup if wanted... - */ + * show a popup if wanted... + */ if (newData->bWantPopup) { DBEVENTINFO dbei = { sizeof(dbei) }; newData->bWantPopup = FALSE; @@ -1568,7 +1553,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP m_pContainer->hwndActive = hwndDlg; return FALSE; } - return newData->iActivate ? TRUE : FALSE; + return newData->iActivate != 0; } case WM_ERASEBKGND: @@ -1578,12 +1563,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP RECT rcClient, rcWindow, rc; HDC hdcMem = 0; HBITMAP hbm, hbmOld; - DWORD cx, cy; HANDLE hpb = 0; GetClientRect(hwndDlg, &rcClient); - cx = rcClient.right - rcClient.left; - cy = rcClient.bottom - rcClient.top; + DWORD cx = rcClient.right - rcClient.left; + DWORD cy = rcClient.bottom - rcClient.top; if (CMimAPI::m_haveBufferedPaint) hpb = CMimAPI::m_pfnBeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, 0, &hdcMem); @@ -1597,21 +1581,17 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP bool bAero = M.isAero(); if (CSkin::m_skinEnabled) { - CSkinItem *item; UINT item_ids[2] = {ID_EXTBKHISTORY, ID_EXTBKINPUTAREA}; UINT ctl_ids[2] = {IDC_LOG, IDC_MESSAGE}; - int i; BOOL isEditNotesReason = dat->fEditNotesActive; BOOL isSendLaterReason = (dat->sendMode & SMODE_SENDLATER); BOOL isMultipleReason = (dat->sendMode & SMODE_MULTIPLE || dat->sendMode & SMODE_CONTAINER); CSkin::SkinDrawBG(hwndDlg, hwndContainer, m_pContainer, &rcClient, hdcMem); - - for (i=0; i < 2; i++) { - item = &SkinItems[item_ids[i]]; + for (int i=0; i < 2; i++) { + CSkinItem *item = &SkinItems[item_ids[i]]; if (!item->IGNORED) { - GetWindowRect(GetDlgItem(hwndDlg, ctl_ids[i]), &rcWindow); pt.x = rcWindow.left; pt.y = rcWindow.top; @@ -1625,8 +1605,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP FillRect(hdcMem, &rc, br); DeleteObject(br); } - else - CSkin::DrawItem(hdcMem, &rc, item); + else CSkin::DrawItem(hdcMem, &rc, item); } } } @@ -1659,9 +1638,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP */ dat->Panel->renderContent(hdcMem); - if (hpb) { + if (hpb) CSkin::FinalizeBufferedPaint(hpb, &rcClient); - } else { + else { BitBlt(hdc, 0, 0, cx, cy, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteObject(hbm); @@ -1727,9 +1706,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP * size info panel fields */ - LONG cx = rc.right; - LONG panelHeight = dat->Panel->getHeight(); - LONG panelWidth = (dat->panelWidth != -1 ? dat->panelWidth : 0); + LONG cx = rc.right; + LONG panelHeight = dat->Panel->getHeight(); + LONG panelWidth = (dat->panelWidth != -1 ? dat->panelWidth : 0); rc.top = 1; rc.left = cx - (panelWidth > 0 ? panelWidth : panelHeight); @@ -1801,22 +1780,24 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case WM_NOTIFY: - if (dat != 0 && ((NMHDR *)lParam)->hwndFrom == dat->hwndTip) { - if (((NMHDR *)lParam)->code == NM_CLICK) + if (dat != 0 && ((NMHDR*)lParam)->hwndFrom == dat->hwndTip) { + if (((NMHDR*)lParam)->code == NM_CLICK) SendMessage(dat->hwndTip, TTM_TRACKACTIVATE, FALSE, 0); break; } - switch (((NMHDR *) lParam)->idFrom) { + + switch (((NMHDR*)lParam)->idFrom) { case IDC_CLIST: - switch (((NMHDR *) lParam)->code) { + switch (((NMHDR*)lParam)->code) { case CLN_OPTIONSCHANGED: SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0); SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0); } break; + case IDC_LOG: case IDC_MESSAGE: - switch (((NMHDR *) lParam)->code) { + switch (((NMHDR*)lParam)->code) { case EN_MSGFILTER: { DWORD msg = ((MSGFILTER *) lParam)->msg; @@ -1826,7 +1807,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP BOOL isCtrl, isShift, isAlt; KbdState(dat, isShift, isCtrl, isAlt); - MSG message; + MSG message; message.hwnd = hwndDlg; message.message = msg; message.lParam = lp; @@ -1835,10 +1816,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (msg == WM_SYSKEYUP) { UINT ctrlId = 0; - if (wp == VK_MENU) { + if (wp == VK_MENU) if (!dat->fkeyProcessed && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000) && !(lp & (1 << 24))) m_pContainer->MenuBar->autoShow(); - } + return(_dlgReturn(hwndDlg, 0)); } @@ -1846,7 +1827,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP LRESULT mim_hotkey_check = CallService(MS_HOTKEY_CHECK, (WPARAM)&message, (LPARAM)(TABSRMM_HK_SECTION_IM)); if (mim_hotkey_check) dat->fkeyProcessed = true; - switch(mim_hotkey_check) { + + switch (mim_hotkey_check) { case TABSRMM_HK_SETUSERPREFS: CallService(MS_TABMSG_SETUSERPREFS, (WPARAM)dat->hContact, 0); return(_dlgReturn(hwndDlg, 1)); @@ -2032,15 +2014,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP //MAD: tabulation mod if (msg == WM_KEYDOWN && wp == VK_TAB) { if (PluginConfig.m_AllowTab) { - if (((NMHDR *)lParam)->idFrom == IDC_MESSAGE) + if (((NMHDR*)lParam)->idFrom == IDC_MESSAGE) SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)"\t"); _clrMsgFilter(lParam); - if (((NMHDR *)lParam)->idFrom != IDC_MESSAGE) + if (((NMHDR*)lParam)->idFrom != IDC_MESSAGE) SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); return(_dlgReturn(hwndDlg, 1)); } else { - if (((NMHDR *)lParam)->idFrom == IDC_MESSAGE) { + if (((NMHDR*)lParam)->idFrom == IDC_MESSAGE) { if (GetSendButtonState(hwndDlg) != PBS_DISABLED && !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR)) { SetFocus(GetDlgItem(hwndDlg, IDOK)); return(_dlgReturn(hwndDlg, 1)); @@ -2050,7 +2032,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return(_dlgReturn(hwndDlg, 1)); } } - if (((NMHDR *)lParam)->idFrom == IDC_LOG) { + if (((NMHDR*)lParam)->idFrom == IDC_LOG) { SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); return(_dlgReturn(hwndDlg, 1)); } @@ -2058,7 +2040,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return(_dlgReturn(hwndDlg, 0)); } //MAD_ - if (msg == WM_MOUSEWHEEL && (((NMHDR *)lParam)->idFrom == IDC_LOG || ((NMHDR *)lParam)->idFrom == IDC_MESSAGE)) { + if (msg == WM_MOUSEWHEEL && (((NMHDR*)lParam)->idFrom == IDC_LOG || ((NMHDR*)lParam)->idFrom == IDC_MESSAGE)) { RECT rc; GetCursorPos(&pt); GetWindowRect(GetDlgItem(hwndDlg, IDC_LOG), &rc); @@ -2078,17 +2060,16 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (msg == WM_CHAR && wp == 'c') { if (isCtrl) { - SendDlgItemMessage(hwndDlg, ((NMHDR *)lParam)->code, WM_COPY, 0, 0); + SendDlgItemMessage(hwndDlg, ((NMHDR*)lParam)->code, WM_COPY, 0, 0); break; } } - if ((msg == WM_LBUTTONDOWN || msg == WM_KEYUP || msg == WM_LBUTTONUP) && ((NMHDR *)lParam)->idFrom == IDC_MESSAGE) { + if ((msg == WM_LBUTTONDOWN || msg == WM_KEYUP || msg == WM_LBUTTONUP) && ((NMHDR*)lParam)->idFrom == IDC_MESSAGE) { int bBold = IsDlgButtonChecked(hwndDlg, IDC_FONTBOLD); int bItalic = IsDlgButtonChecked(hwndDlg, IDC_FONTITALIC); int bUnder = IsDlgButtonChecked(hwndDlg, IDC_FONTUNDERLINE); - //MAD int bStrikeout = IsDlgButtonChecked(hwndDlg, IDC_FONTSTRIKEOUT); - // + cf2.cbSize = sizeof(CHARFORMAT2); cf2.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_UNDERLINETYPE | CFM_STRIKEOUT; cf2.dwEffects = 0; @@ -2144,7 +2125,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP * holding ctrl-alt does the same, but pastes formatted text */ case WM_LBUTTONUP: - if (((NMHDR *) lParam)->idFrom == IDC_LOG) { + if (((NMHDR*) lParam)->idFrom == IDC_LOG) { CHARRANGE cr; SendMessage(GetDlgItem(hwndDlg, IDC_LOG), EM_EXGETSEL, 0, (LPARAM)&cr); if (cr.cpMax != cr.cpMin) { @@ -2162,7 +2143,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP mir_free(streamOut); } SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); - } else if (M.GetByte("autocopy", 1) && !isShift) { + } + else if (M.GetByte("autocopy", 1) && !isShift) { SendMessage(GetDlgItem(hwndDlg, IDC_LOG), WM_COPY, 0, 0); SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); if (m_pContainer->hwndStatus) @@ -2171,19 +2153,16 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } } break; - case WM_MOUSEMOVE: - { - POINT pt; - HCURSOR hCur = GetCursor(); - GetCursorPos(&pt); - DM_DismissTip(dat, pt); - dat->Panel->trackMouse(pt); - if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE) - || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) - SetCursor(LoadCursor(NULL, IDC_ARROW)); - break; - } + case WM_MOUSEMOVE: + POINT pt; + HCURSOR hCur = GetCursor(); + GetCursorPos(&pt); + DM_DismissTip(dat, pt); + dat->Panel->trackMouse(pt); + if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE) || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) + SetCursor(LoadCursor(NULL, IDC_ARROW)); + break; } } break; @@ -2199,6 +2178,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SetCursor(PluginConfig.hCurHyperlinkHand); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); return TRUE; + case WM_RBUTTONDOWN: case WM_LBUTTONUP: { @@ -2215,42 +2195,42 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1); CopyMemory(tr.lpstrText, _T("mailto:"), 7); } - if (IsStringValidLink(tr.lpstrText)) { - if (((ENLINK*) lParam)->msg == WM_RBUTTONDOWN) { - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); - HMENU hSubMenu = GetSubMenu(hMenu, 1); - TranslateMenu(hSubMenu); - pt.x = (short)LOWORD(((ENLINK*)lParam)->lParam); - pt.y = (short)HIWORD(((ENLINK*)lParam)->lParam); - ClientToScreen(((NMHDR*) lParam)->hwndFrom, &pt); - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) { - case IDM_OPENNEW: - CallService(MS_UTILS_OPENURL, 1 + OUF_TCHAR, (LPARAM)tr.lpstrText); - break; - case IDM_OPENEXISTING: - CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)tr.lpstrText); - break; - case IDM_COPYLINK: - HGLOBAL hData; - if (!OpenClipboard(hwndDlg)) - break; - EmptyClipboard(); - hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(tr.lpstrText)+1)); - lstrcpy((TCHAR*)GlobalLock(hData), tr.lpstrText); - GlobalUnlock(hData); - SetClipboardData(CF_TEXT, hData); - CloseClipboard(); - break; - } - DestroyMenu(hMenu); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); - return TRUE; - } - + if (!IsStringValidLink(tr.lpstrText)) + break; + + if (((ENLINK*)lParam)->msg != WM_RBUTTONDOWN) { CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)tr.lpstrText); SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); + break; } - break; + HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hSubMenu = GetSubMenu(hMenu, 1); + TranslateMenu(hSubMenu); + pt.x = (short)LOWORD(((ENLINK*)lParam)->lParam); + pt.y = (short)HIWORD(((ENLINK*)lParam)->lParam); + ClientToScreen(((NMHDR*) lParam)->hwndFrom, &pt); + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) { + case IDM_OPENNEW: + CallService(MS_UTILS_OPENURL, 1 + OUF_TCHAR, (LPARAM)tr.lpstrText); + break; + case IDM_OPENEXISTING: + CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)tr.lpstrText); + break; + case IDM_COPYLINK: + HGLOBAL hData; + if (!OpenClipboard(hwndDlg)) + break; + EmptyClipboard(); + hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(tr.lpstrText)+1)); + lstrcpy((TCHAR*)GlobalLock(hData), tr.lpstrText); + GlobalUnlock(hData); + SetClipboardData(CF_TEXT, hData); + CloseClipboard(); + break; + } + DestroyMenu(hMenu); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); + return TRUE; } } } @@ -2366,9 +2346,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->Panel->isActive()) { SetParent(fa.hWindow, GetDlgItem(hwndDlg, IDC_CONTACTPIC)); ShowWindow(fa.hWindow, SW_SHOW); - } else { - ShowWindow(fa.hWindow, SW_HIDE); } + else ShowWindow(fa.hWindow, SW_HIDE); } } MsgWindowUpdateState(dat, WM_SETFOCUS); @@ -2394,87 +2373,81 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return 0; case DM_SPLITTERMOVED: - { + if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_MULTISPLITTER)) { + RECT rc; + GetClientRect(hwndDlg, &rc); + pt.x = wParam; + pt.y = 0; + ScreenToClient(hwndDlg, &pt); + int oldSplitterX = dat->multiSplitterX; + dat->multiSplitterX = rc.right - pt.x; + if (dat->multiSplitterX < 25) + dat->multiSplitterX = 25; + + if (dat->multiSplitterX > ((rc.right - rc.left) - 80)) + dat->multiSplitterX = oldSplitterX; + SendMessage(dat->hwnd, WM_SIZE, 0, 0); + } + else if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_SPLITTER)) { + int oldSplitterY, oldDynaSplitter; + int bottomtoolbarH=0; RECT rc; + GetClientRect(hwndDlg, &rc); + rc.top += (dat->Panel->isActive() ? dat->Panel->getHeight() + 40 : 30); + pt.x = 0; + pt.y = wParam; + ScreenToClient(hwndDlg, &pt); - if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_MULTISPLITTER)) { - GetClientRect(hwndDlg, &rc); - pt.x = wParam; - pt.y = 0; - ScreenToClient(hwndDlg, &pt); - int oldSplitterX = dat->multiSplitterX; - dat->multiSplitterX = rc.right - pt.x; - if (dat->multiSplitterX < 25) - dat->multiSplitterX = 25; - - if (dat->multiSplitterX > ((rc.right - rc.left) - 80)) - dat->multiSplitterX = oldSplitterX; - SendMessage(dat->hwnd, WM_SIZE, 0, 0); - } - else if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_SPLITTER)) { - int oldSplitterY, oldDynaSplitter; - int bottomtoolbarH=0; - GetClientRect(hwndDlg, &rc); - rc.top += (dat->Panel->isActive() ? dat->Panel->getHeight() + 40 : 30); - pt.x = 0; - pt.y = wParam; - ScreenToClient(hwndDlg, &pt); - - oldSplitterY = dat->splitterY; - oldDynaSplitter = dat->dynaSplitter; - - dat->splitterY = rc.bottom - pt.y +DPISCALEY_S(23); - /* - * attempt to fix splitter troubles.. - * hardcoded limits... better solution is possible, but this works for now - */ - //mad - if (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) - bottomtoolbarH = 22; - // - if (dat->splitterY < (DPISCALEY_S(MINSPLITTERY) + 5 + bottomtoolbarH)) { // min splitter size - dat->splitterY = (DPISCALEY_S(MINSPLITTERY) + 5 + bottomtoolbarH); - dat->dynaSplitter = dat->splitterY - DPISCALEY_S(34); - DM_RecalcPictureSize(dat); - } - else if (dat->splitterY > (rc.bottom - rc.top)) { - dat->splitterY = oldSplitterY; - dat->dynaSplitter = oldDynaSplitter; - DM_RecalcPictureSize(dat); - } - else { - dat->dynaSplitter = (rc.bottom - pt.y) - DPISCALEY_S(11); - DM_RecalcPictureSize(dat); - } - CSkin::UpdateToolbarBG(dat); - SendMessage(dat->hwnd, WM_SIZE, 0, 0); - } - else if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_PANELSPLITTER)) { - RECT rc; - POINT pt; - - GetClientRect(GetDlgItem(hwndDlg, IDC_LOG), &rc); - pt.x = 0; - pt.y = wParam; - ScreenToClient(hwndDlg, &pt); - if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) - dat->Panel->setHeight(pt.y + 2, true); - dat->panelWidth = -1; - //SetAeroMargins(dat->pContainer); - RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - if (M.isAero()) - InvalidateRect(GetParent(hwndDlg), NULL, FALSE); - break; + oldSplitterY = dat->splitterY; + oldDynaSplitter = dat->dynaSplitter; + + dat->splitterY = rc.bottom - pt.y +DPISCALEY_S(23); + /* + * attempt to fix splitter troubles.. + * hardcoded limits... better solution is possible, but this works for now + */ + //mad + if (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) + bottomtoolbarH = 22; + // + if (dat->splitterY < (DPISCALEY_S(MINSPLITTERY) + 5 + bottomtoolbarH)) { // min splitter size + dat->splitterY = (DPISCALEY_S(MINSPLITTERY) + 5 + bottomtoolbarH); + dat->dynaSplitter = dat->splitterY - DPISCALEY_S(34); + DM_RecalcPictureSize(dat); } - return 0; + else if (dat->splitterY > (rc.bottom - rc.top)) { + dat->splitterY = oldSplitterY; + dat->dynaSplitter = oldDynaSplitter; + DM_RecalcPictureSize(dat); + } + else { + dat->dynaSplitter = (rc.bottom - pt.y) - DPISCALEY_S(11); + DM_RecalcPictureSize(dat); + } + CSkin::UpdateToolbarBG(dat); + SendMessage(dat->hwnd, WM_SIZE, 0, 0); } - /* - * queue a dm_remakelog - * wParam = hwnd of the sender, so we can directly do a DM_REMAKELOG if the msg came - * from ourself. otherwise, the dm_remakelog will be deferred until next window - * activation (focus) - */ + else if ((HWND) lParam == GetDlgItem(hwndDlg, IDC_PANELSPLITTER)) { + RECT rc; + GetClientRect(GetDlgItem(hwndDlg, IDC_LOG), &rc); + POINT pt = { 0, wParam }; + ScreenToClient(hwndDlg, &pt); + if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) + dat->Panel->setHeight(pt.y + 2, true); + dat->panelWidth = -1; + RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + if (M.isAero()) + InvalidateRect(GetParent(hwndDlg), NULL, FALSE); + } + break; + + /* + * queue a dm_remakelog + * wParam = hwnd of the sender, so we can directly do a DM_REMAKELOG if the msg came + * from ourself. otherwise, the dm_remakelog will be deferred until next window + * activation (focus) + */ case DM_DEFERREDREMAKELOG: if ((HWND) wParam == hwndDlg) SendMessage(hwndDlg, DM_REMAKELOG, 0, 0); @@ -2507,9 +2480,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case DM_APPENDTOLOG: StreamInEvents(hwndDlg, (HANDLE)wParam, 1, 1, NULL); return 0; - /* - * replays queued events after the message log has been frozen for a while - */ + + /* + * replays queued events after the message log has been frozen for a while + */ case DM_REPLAYQUEUE: { for (int i=0; i < dat->iNextQueuedEvent; i++) @@ -2536,39 +2510,39 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } return 0; } - case DM_FORCESCROLL: { - SCROLLINFO *psi = (SCROLLINFO *)lParam; - POINT *ppt = (POINT *)wParam; - - HWND hwnd = GetDlgItem(hwndDlg, IDC_LOG); - int len; + case DM_FORCESCROLL: + { + SCROLLINFO *psi = (SCROLLINFO *)lParam; + POINT *ppt = (POINT *)wParam; - if (wParam == 0 && lParam == 0) { - DM_ScrollToBottom(dat, 0, 1); - return 0; - } + HWND hwnd = GetDlgItem(hwndDlg, IDC_LOG); + int len; - if (dat->hwndIEView == 0 && dat->hwndHPP == 0) { - len = GetWindowTextLengthA(GetDlgItem(hwndDlg, IDC_LOG)); - SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETSEL, len - 1, len - 1); - } + if (wParam == 0 && lParam == 0) { + DM_ScrollToBottom(dat, 0, 1); + return 0; + } - if (psi == NULL) { - DM_ScrollToBottom(dat, 0, 0); - return 0; - } + if (dat->hwndIEView == 0 && dat->hwndHPP == 0) { + len = GetWindowTextLengthA(GetDlgItem(hwndDlg, IDC_LOG)); + SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETSEL, len - 1, len - 1); + } - if ((UINT)psi->nPos >= (UINT)psi->nMax - psi->nPage - 5 || psi->nMax - psi->nMin - psi->nPage < 50) - DM_ScrollToBottom(dat, 0, 0); - else - SendMessage((dat->hwndIEView || dat->hwndHPP) ? (dat->hwndIEView ? dat->hwndIEView : dat->hwndHPP) : hwnd, EM_SETSCROLLPOS, 0, (LPARAM)ppt); + if (psi == NULL) { + DM_ScrollToBottom(dat, 0, 0); + return 0; + } + if ((UINT)psi->nPos >= (UINT)psi->nMax - psi->nPage - 5 || psi->nMax - psi->nMin - psi->nPage < 50) + DM_ScrollToBottom(dat, 0, 0); + else + SendMessage((dat->hwndIEView || dat->hwndHPP) ? (dat->hwndIEView ? dat->hwndIEView : dat->hwndHPP) : hwnd, EM_SETSCROLLPOS, 0, (LPARAM)ppt); + } return 0; - } - /* - * this is called whenever a new event has been added to the database. - * this CAN be posted (some sanity checks required). - */ + /* + * this is called whenever a new event has been added to the database. + * this CAN be posted (some sanity checks required). + */ case HM_DBEVENTADDED: if (!dat) return 0; @@ -2578,10 +2552,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return 0; DM_EventAdded(dat, wParam, lParam); return 0; + case WM_TIMER: /* - * timer to control info panel hovering - */ + * timer to control info panel hovering + */ if (wParam == TIMERID_AWAYMSG) { KillTimer(hwndDlg, wParam); GetCursorPos(&pt); @@ -2593,9 +2568,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; } /* - * timer id for message timeouts is composed like: - * for single message sends: basevalue (TIMERID_MSGSEND) + send queue index - */ + * timer id for message timeouts is composed like: + * for single message sends: basevalue (TIMERID_MSGSEND) + send queue index + */ if (wParam >= TIMERID_MSGSEND) { int iIndex = wParam - TIMERID_MSGSEND; @@ -2611,40 +2586,41 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP sendQueue->handleError(dat, iIndex); break; } - } else if (wParam == TIMERID_FLASHWND) { + } + else if (wParam == TIMERID_FLASHWND) { if (dat->mayFlashTab) FlashTab(dat, hwndTab, dat->iTabID, &dat->bTabFlash, TRUE, dat->hTabIcon); break; - } else if (wParam == TIMERID_TYPE) { + } + else if (wParam == TIMERID_TYPE) { DM_Typing(dat); break; } break; + case DM_ERRORDECIDED: switch (wParam) { case MSGERROR_CANCEL: - case MSGERROR_SENDLATER: { - int iNextFailed; - - if (!(dat->dwFlags & MWF_ERRORSTATE)) - break; - - dat->cache->saveHistory(0, 0); - if (wParam == MSGERROR_SENDLATER) - sendQueue->doSendLater(dat->iCurrentQueueError, dat); // to be implemented at a later time - dat->iOpenJobs--; - sendQueue->dec(); - if (dat->iCurrentQueueError >= 0 && dat->iCurrentQueueError < SendQueue::NR_SENDJOBS) - sendQueue->clearJob(dat->iCurrentQueueError); - dat->iCurrentQueueError = -1; - sendQueue->showErrorControls(dat, FALSE); - if (wParam != MSGERROR_CANCEL || (wParam == MSGERROR_CANCEL && lParam == 0)) - SetDlgItemText(hwndDlg, IDC_MESSAGE, _T("")); - sendQueue->checkQueue(dat); - if ((iNextFailed = sendQueue->findNextFailed(dat)) >= 0) - sendQueue->handleError(dat, iNextFailed); + case MSGERROR_SENDLATER: + if (dat->dwFlags & MWF_ERRORSTATE) { + dat->cache->saveHistory(0, 0); + if (wParam == MSGERROR_SENDLATER) + sendQueue->doSendLater(dat->iCurrentQueueError, dat); // to be implemented at a later time + dat->iOpenJobs--; + sendQueue->dec(); + if (dat->iCurrentQueueError >= 0 && dat->iCurrentQueueError < SendQueue::NR_SENDJOBS) + sendQueue->clearJob(dat->iCurrentQueueError); + dat->iCurrentQueueError = -1; + sendQueue->showErrorControls(dat, FALSE); + if (wParam != MSGERROR_CANCEL || (wParam == MSGERROR_CANCEL && lParam == 0)) + SetDlgItemText(hwndDlg, IDC_MESSAGE, _T("")); + sendQueue->checkQueue(dat); + int iNextFailed = sendQueue->findNextFailed(dat); + if (iNextFailed >= 0) + sendQueue->handleError(dat, iNextFailed); + } break; - } + case MSGERROR_RETRY: if (dat->dwFlags & MWF_ERRORSTATE) { int resent = 0; @@ -2692,38 +2668,41 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP ActivateKeyboardLayout(dat->hkl, 0); } return 0; - /* - * return timestamp (in ticks) of last recent message which has not been read yet. - * 0 if there is none - * lParam = pointer to a dword receiving the value. - */ - case DM_QUERYLASTUNREAD: { - DWORD *pdw = (DWORD *)lParam; - if (pdw) - *pdw = dat->dwTickLastEvent; + + /* + * return timestamp (in ticks) of last recent message which has not been read yet. + * 0 if there is none + * lParam = pointer to a dword receiving the value. + */ + case DM_QUERYLASTUNREAD: + { + DWORD *pdw = (DWORD *)lParam; + if (pdw) + *pdw = dat->dwTickLastEvent; + } return 0; - } - case DM_QUERYCONTAINER: { - TContainerData **pc = (TContainerData **) lParam; - if (pc) - *pc = m_pContainer; + + case DM_QUERYCONTAINER: + { + TContainerData **pc = (TContainerData **)lParam; + if (pc) + *pc = m_pContainer; + } return 0; - } - case DM_QUERYHCONTACT: { - HANDLE *phContact = (HANDLE*) lParam; - if (phContact) - *phContact = dat->hContact; + case DM_QUERYHCONTACT: + { + HANDLE *phContact = (HANDLE*) lParam; + if (phContact) + *phContact = dat->hContact; + } return 0; - } case DM_UPDATELASTMESSAGE: DM_UpdateLastMessage(dat); return 0; - case DM_SAVESIZE: { - RECT rcClient; - + case DM_SAVESIZE: if (dat->dwFlags & MWF_NEEDCHECKSIZE) lParam = 0; @@ -2733,6 +2712,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->lastMessage) DM_UpdateLastMessage(dat); } + + RECT rcClient; SendMessage(hwndContainer, DM_QUERYCLIENTAREA, 0, (LPARAM)&rcClient); MoveWindow(hwndDlg, rcClient.left, rcClient.top, (rcClient.right - rcClient.left), (rcClient.bottom - rcClient.top), TRUE); if (dat->dwFlags & MWF_WASBACKGROUNDCREATE) { @@ -2749,19 +2730,21 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); if (dat->pContainer->dwFlags & CNT_SIDEBAR) dat->pContainer->SideBar->Layout(); - } else { + } + else { SendMessage(hwndDlg, WM_SIZE, 0, 0); if (lParam == 0) PostMessage(hwndDlg, DM_FORCESCROLL, 0, 0); } return 0; - } + case DM_CHECKSIZE: dat->dwFlags |= MWF_NEEDCHECKSIZE; return 0; - /* - * sent by the message input area hotkeys. just pass it to our container - */ + + /* + * sent by the message input area hotkeys. just pass it to our container + */ case DM_QUERYPENDING: SendMessage(hwndContainer, DM_QUERYPENDING, wParam, lParam); return 0; @@ -2814,16 +2797,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int iSelection = TrackPopupMenu(subMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); if (iSelection >= IDM_CONTAINERMENU) { - DBVARIANT dbv = {0}; char szIndex[10]; char *szKey = "TAB_ContainersW"; mir_snprintf(szIndex, SIZEOF(szIndex), "%d", iSelection - IDM_CONTAINERMENU); if (iSelection - IDM_CONTAINERMENU >= 0) { - if (!db_get_ts(NULL, szKey, szIndex, &dbv)) { - SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)dbv.ptszVal); - db_free(&dbv); - } + ptrT val(db_get_tsa(NULL, szKey, szIndex)); + if (val) + SendMessage(hwndDlg, DM_CONTAINERSELECTED, 0, (LPARAM)val); } break; } @@ -3569,13 +3550,12 @@ quote_from_last: if (!dat->fEditNotesActive) { char *msg = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat, (CP_UTF8 << 16) | (SF_TEXT | SF_USECODEPAGE)); if (msg) { - db_set_s(dat->hContact, SRMSGMOD, "SavedMsg", msg); + db_set_utf(dat->hContact, SRMSGMOD, "SavedMsg", msg); mir_free(msg); - } else - db_set_s(dat->hContact, SRMSGMOD, "SavedMsg", ""); + } + else db_unset(dat->hContact, SRMSGMOD, "SavedMsg"); } - else - SendMessage(hwndDlg, WM_COMMAND, IDC_PIC, 0); + else SendMessage(hwndDlg, WM_COMMAND, IDC_PIC, 0); } } @@ -3584,10 +3564,8 @@ quote_from_last: DM_FreeTheme(dat); - if (dat->sendBuffer != NULL) - mir_free(dat->sendBuffer); - if (dat->hHistoryEvents) - mir_free(dat->hHistoryEvents); + mir_free(dat->sendBuffer); + mir_free(dat->hHistoryEvents); /* * search the sendqueue for unfinished send jobs and mir_free them. Leave unsent @@ -3611,8 +3589,7 @@ quote_from_last: } } - if (dat->hQueuedEvents) - mir_free(dat->hQueuedEvents); + mir_free(dat->hQueuedEvents); if (dat->hSmileyIcon) DestroyIcon(dat->hSmileyIcon); diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 1fcdddafe8..14662c09fc 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -960,9 +960,9 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam break; case WM_NOTIFY: - switch (((NMHDR *) lParam)->idFrom) { + switch (((NMHDR*) lParam)->idFrom) { case IDC_CLIST: - switch (((NMHDR *) lParam)->code) { + switch (((NMHDR*) lParam)->code) { case CLN_OPTIONSCHANGED: ResetCList(hwndDlg); break; diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 6e8176d2cc..ff48ab50ec 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -49,7 +49,7 @@ static TCHAR *formatting_strings_end[] = { _T("b0 "), _T("i0 "), _T("u0 "), _ LRESULT TSAPI _dlgReturn(HWND hWnd, LRESULT result) { SetWindowLongPtr(hWnd, DWLP_MSGRESULT, result); - return(result); + return result; } void* Utils::safeAlloc(const size_t size) @@ -60,7 +60,8 @@ void* Utils::safeAlloc(const size_t size) return(reinterpret_cast(_p)); } - __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MEMORY_ALLOCATION", false)) { + __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MEMORY_ALLOCATION", false)) + { return 0; } } @@ -72,7 +73,8 @@ void* Utils::safeCalloc(const size_t size) ::ZeroMemory(_p, size); return(_p); } - __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MEMORY_ALLOCATION", false)) { + __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MEMORY_ALLOCATION", false)) + { return 0; } } @@ -85,7 +87,8 @@ void* Utils::safeMirAlloc(const size_t size) return(reinterpret_cast(_p)); } - __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MIR_MEMORY_ALLOCATION", false)) { + __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MIR_MEMORY_ALLOCATION", false)) + { return 0; } } @@ -97,7 +100,8 @@ void* Utils::safeMirCalloc(const size_t size) ::ZeroMemory(_p, size); return(_p); } - __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MIR_MEMORY_ALLOCATION", false)) { + __except(CGlobals::Ex_ShowDialog(GetExceptionInformation(), __FILE__, __LINE__, L"MIR_MEMORY_ALLOCATION", false)) + { return 0; } } @@ -137,10 +141,11 @@ TCHAR* Utils::FilterEventMarkers(TCHAR *wszText) } /** - * this translates formatting tags into rtf sequences... - * flags: loword = words only for simple * /_ formatting - *hiword = bbcode support (strip bbcodes if 0) - */ +* this translates formatting tags into rtf sequences... +* flags: loword = words only for simple * /_ formatting +* hiword = bbcode support (strip bbcodes if 0) +*/ + const TCHAR* Utils::FormatRaw(TWindowData *dat, const TCHAR *msg, int flags, BOOL isSent) { bool clr_was_added = false, was_added; @@ -175,7 +180,7 @@ const TCHAR* Utils::FormatRaw(TWindowData *dat, const TCHAR *msg, int flags, BOO tstring colorname = message.substr(beginmark + 7, 8); search_again: - bool clr_found = false; + bool clr_found = false; for (int ii = 0; ii < rtf_ctable_size; ii++) { if (!_tcsnicmp((TCHAR*)colorname.c_str(), rtf_ctable[ii].szName, lstrlen(rtf_ctable[ii].szName))) { closing = beginmark + 7 + lstrlen(rtf_ctable[ii].szName); @@ -237,7 +242,6 @@ invalid_code: return(message.c_str()); } - while ((beginmark = message.find_first_of(_T("*/_"), beginmark)) != message.npos) { endmarker = message[beginmark]; if (LOWORD(flags)) { @@ -309,9 +313,10 @@ ok: } /** - * format the title bar string for IM chat sessions using placeholders. - * the caller must mir_free() the returned string - */ +* format the title bar string for IM chat sessions using placeholders. +* the caller must mir_free() the returned string +*/ + const TCHAR* Utils::FormatTitleBar(const TWindowData *dat, const TCHAR *szFormat) { TCHAR *szResult = 0; @@ -430,9 +435,9 @@ const TCHAR* Utils::FormatTitleBar(const TWindowData *dat, const TCHAR *szFormat break; } /* - * status message (%T will skip the "No status message" for empty - * messages) - */ + * status message (%T will skip the "No status message" for empty + * messages) + */ case 't': case 'T': { TCHAR *tszStatusMsg = dat->cache->getNormalizedStatusMsg(dat->cache->getStatusMsg(), true); @@ -820,60 +825,55 @@ void Utils::scaleAvatarHeightLimited(const HBITMAP hBm, double& dNewWidth, doubl */ HICON Utils::iconFromAvatar(const TWindowData *dat) { - double dNewWidth, dNewHeight; - bool fFree = false; - HIMAGELIST hIml_c = 0; - HICON hIcon = 0; - - if (!ServiceExists(MS_AV_GETAVATARBITMAP)) + if (!ServiceExists(MS_AV_GETAVATARBITMAP) || dat == NULL) return 0; - if (dat) { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)dat->hContact, 0); - LONG lIconSize = Win7Taskbar->getIconSize(); + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)dat->hContact, 0); + if (ace == NULL || ace->hbmPic == NULL) + return NULL; - if (ace && ace->hbmPic) { - scaleAvatarHeightLimited(ace->hbmPic, dNewWidth, dNewHeight, lIconSize); - /* - * resize picture to fit it on the task bar, use an image list for converting it to - * 32bpp icon format - * dat->hTaskbarIcon will cache it until avatar is changed - */ - HBITMAP hbmResized = CSkin::ResizeBitmap(ace->hbmPic, (LONG)dNewWidth, (LONG)dNewHeight, fFree); - hIml_c = ::ImageList_Create(lIconSize, lIconSize, ILC_COLOR32 | ILC_MASK, 1, 0); - - RECT rc = {0, 0, lIconSize, lIconSize}; - - HDC hdc = ::GetDC(dat->pContainer->hwnd); - HDC dc = ::CreateCompatibleDC(hdc); - HDC dcResized = ::CreateCompatibleDC(hdc); - - ReleaseDC(dat->pContainer->hwnd, hdc); - - HBITMAP hbmNew = CSkin::CreateAeroCompatibleBitmap(rc, dc); - HBITMAP hbmOld = reinterpret_cast(::SelectObject(dc, hbmNew)); - HBITMAP hbmOldResized = reinterpret_cast(::SelectObject(dcResized, hbmResized)); - - LONG ix = (lIconSize - (LONG)dNewWidth) / 2; - LONG iy = (lIconSize - (LONG)dNewHeight) / 2; - CSkin::m_default_bf.SourceConstantAlpha = M.GetByte("taskBarIconAlpha", 255); - GdiAlphaBlend(dc, ix, iy, (LONG)dNewWidth, (LONG)dNewHeight, dcResized, 0, 0, (LONG)dNewWidth, (LONG)dNewHeight, CSkin::m_default_bf); - - CSkin::m_default_bf.SourceConstantAlpha = 255; - ::SelectObject(dc, hbmOld); - ::ImageList_Add(hIml_c, hbmNew, 0); - ::DeleteObject(hbmNew); - ::DeleteDC(dc); - - ::SelectObject(dcResized, hbmOldResized); - if (hbmResized != ace->hbmPic) - ::DeleteObject(hbmResized); - ::DeleteDC(dcResized); - hIcon = ::ImageList_GetIcon(hIml_c, 0, ILD_NORMAL); - ::ImageList_RemoveAll(hIml_c); - ::ImageList_Destroy(hIml_c); - } - } + LONG lIconSize = Win7Taskbar->getIconSize(); + double dNewWidth, dNewHeight; + scaleAvatarHeightLimited(ace->hbmPic, dNewWidth, dNewHeight, lIconSize); + /* + * resize picture to fit it on the task bar, use an image list for converting it to + * 32bpp icon format + * dat->hTaskbarIcon will cache it until avatar is changed + */ + bool fFree = false; + HBITMAP hbmResized = CSkin::ResizeBitmap(ace->hbmPic, (LONG)dNewWidth, (LONG)dNewHeight, fFree); + HIMAGELIST hIml_c = ::ImageList_Create(lIconSize, lIconSize, ILC_COLOR32 | ILC_MASK, 1, 0); + + RECT rc = {0, 0, lIconSize, lIconSize}; + + HDC hdc = ::GetDC(dat->pContainer->hwnd); + HDC dc = ::CreateCompatibleDC(hdc); + HDC dcResized = ::CreateCompatibleDC(hdc); + + ReleaseDC(dat->pContainer->hwnd, hdc); + + HBITMAP hbmNew = CSkin::CreateAeroCompatibleBitmap(rc, dc); + HBITMAP hbmOld = reinterpret_cast(::SelectObject(dc, hbmNew)); + HBITMAP hbmOldResized = reinterpret_cast(::SelectObject(dcResized, hbmResized)); + + LONG ix = (lIconSize - (LONG)dNewWidth) / 2; + LONG iy = (lIconSize - (LONG)dNewHeight) / 2; + CSkin::m_default_bf.SourceConstantAlpha = M.GetByte("taskBarIconAlpha", 255); + GdiAlphaBlend(dc, ix, iy, (LONG)dNewWidth, (LONG)dNewHeight, dcResized, 0, 0, (LONG)dNewWidth, (LONG)dNewHeight, CSkin::m_default_bf); + + CSkin::m_default_bf.SourceConstantAlpha = 255; + ::SelectObject(dc, hbmOld); + ::ImageList_Add(hIml_c, hbmNew, 0); + ::DeleteObject(hbmNew); + ::DeleteDC(dc); + + ::SelectObject(dcResized, hbmOldResized); + if (hbmResized != ace->hbmPic) + ::DeleteObject(hbmResized); + ::DeleteDC(dcResized); + HICON hIcon = ::ImageList_GetIcon(hIml_c, 0, ILD_NORMAL); + ::ImageList_RemoveAll(hIml_c); + ::ImageList_Destroy(hIml_c); return hIcon; } @@ -937,14 +937,14 @@ int TSAPI Utils::mustPlaySound(const TWindowData *dat) bool fIconic = (::IsIconic(dat->pContainer->hwnd) ? true : false); /* - * window minimized, check if sound has to be played - */ + * window minimized, check if sound has to be played + */ if (fIconic) return(dat->pContainer->dwFlagsEx & CNT_EX_SOUNDS_MINIMIZED ? 1 : 0); /* - * window in foreground - */ + * window in foreground + */ if (fActiveWindow) { if (fActiveTab) return(dat->pContainer->dwFlagsEx & CNT_EX_SOUNDS_FOCUSED ? 1 : 0); @@ -1224,9 +1224,9 @@ LRESULT CWarning::show(const int uId, DWORD dwFlags, const wchar_t* tszTxt) hWindowList = reinterpret_cast(::CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0)); /* - * don't open new warnings when shutdown was initiated (modal ones will otherwise - * block the shutdown) - */ + * don't open new warnings when shutdown was initiated (modal ones will otherwise + * block the shutdown) + */ if (CMimAPI::m_shutDown) return -1; @@ -1454,7 +1454,7 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break; case WM_NOTIFY: - switch (((NMHDR *) lParam)->code) { + switch (((NMHDR*) lParam)->code) { case EN_LINK: switch (((ENLINK *) lParam)->msg) { case WM_LBUTTONUP: -- cgit v1.2.3