diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-05 22:14:09 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-03-05 22:14:09 +0000 |
commit | 18a91339f2d9e1449887f5d993ab2f038ff56833 (patch) | |
tree | c5ee079c530794040fee8d2cfb497bd799545735 | |
parent | b915069a9d7ad8d4da5da7a7d92d3e73a0a65346 (diff) |
TabSRMM: code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@12344 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/TabSRMM/src/TSButton.cpp | 24 | ||||
-rw-r--r-- | plugins/TabSRMM/src/buttonsbar.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 25 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/controls.cpp | 30 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 8 | ||||
-rw-r--r-- | plugins/TabSRMM/src/hotkeyhandler.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/infopanel.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/mim.cpp | 11 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 7 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgoptions.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 1968 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendlater.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendqueue.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sidebar.cpp | 11 | ||||
-rw-r--r-- | plugins/TabSRMM/src/tabctrl.cpp | 43 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themeio.cpp | 5 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themes.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 13 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.h | 2 |
22 files changed, 1085 insertions, 1102 deletions
diff --git a/plugins/TabSRMM/src/TSButton.cpp b/plugins/TabSRMM/src/TSButton.cpp index b55e8ff26e..fd81fd31a3 100644 --- a/plugins/TabSRMM/src/TSButton.cpp +++ b/plugins/TabSRMM/src/TSButton.cpp @@ -95,7 +95,11 @@ static void PaintWorker(TSButtonCtrl *ctl, HDC hdcPaint) bf_buttonglyph.AlphaFormat = 0;
}
- if (hdcPaint == NULL)
+ if (ctl == NULL || hdcPaint == NULL)
+ return;
+
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(GetParent(ctl->hwnd), GWLP_USERDATA);
+ if (dat == NULL)
return;
HDC hdcMem;
@@ -103,8 +107,6 @@ static void PaintWorker(TSButtonCtrl *ctl, HDC hdcPaint) HANDLE hbp = 0;
bool bAero = M.isAero();
- TWindowData *dat = (TWindowData*)GetWindowLongPtr(GetParent(ctl->hwnd), GWLP_USERDATA);
-
RECT rcClient, rcContent;
GetClientRect(ctl->hwnd, const_cast<RECT *>(&rcClient));
CopyRect(&rcContent, &rcClient);
@@ -149,15 +151,13 @@ static void PaintWorker(TSButtonCtrl *ctl, HDC hdcPaint) int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->bIsDefault ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
if (ctl->bToolbarButton) {
- if (dat) {
- RECT rcWin;
- GetWindowRect(ctl->hwnd, &rcWin);
- POINT pt;
- pt.x = rcWin.left;
- ScreenToClient(dat->hwnd, &pt);
- BitBlt(hdcMem, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- dat->pContainer->cachedToolbarDC, pt.x, 1, SRCCOPY);
- }
+ RECT rcWin;
+ GetWindowRect(ctl->hwnd, &rcWin);
+ POINT pt;
+ pt.x = rcWin.left;
+ ScreenToClient(dat->hwnd, &pt);
+ BitBlt(hdcMem, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ dat->pContainer->cachedToolbarDC, pt.x, 1, SRCCOPY);
}
if (ctl->hThemeToolbar && ctl->bIsThemed && 1 == dat->pContainer->bTBRenderingMode) {
if (bAero || PluginConfig.m_WinVerMajor >= 6)
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index ecfdb438fe..2ab2a65e7c 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -337,7 +337,7 @@ static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam) if (!bbdi) return 1; - bool bFound = 1; + bool bFound = false; CustomButtonData *cbd = NULL; { mir_cslock lck(ToolBarCS); diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 19b489d1db..57928f9c74 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -291,7 +291,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p) }
if (p->bMustFlash && p->bInactive)
- UpdateTrayMenu(dat, si->wStatus, si->pszModule, dat->szStatus, si->hContact, p->bHighlight ? 1 : 1);
+ UpdateTrayMenu(dat, si->wStatus, si->pszModule, dat->szStatus, si->hContact, 1);
}
mir_free(p);
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index c580683474..8cb418bd01 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -384,7 +384,7 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) case IDC_SPLITTERX: urc->rcItem.right = urc->dlgNewSize.cx - si->iSplitterX + 2; urc->rcItem.left = urc->dlgNewSize.cx - si->iSplitterX; - urc->rcItem.bottom = (bToolbar && !bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(23)) : (urc->dlgNewSize.cy - si->iSplitterY - DPISCALEY_S(2)); + urc->rcItem.bottom = urc->dlgNewSize.cy - si->iSplitterY - ((bToolbar && !bBottomToolbar) ? DPISCALEY_S(23) : DPISCALEY_S(2)); urc->rcItem.top = 0; if (bInfoPanel) urc->rcItem.top += panelHeight; @@ -392,8 +392,8 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) case IDC_SPLITTERY: urc->rcItem.right = urc->dlgNewSize.cx; - urc->rcItem.top = (bToolbar && !bBottomToolbar) ? urc->dlgNewSize.cy - si->iSplitterY : urc->dlgNewSize.cy - si->iSplitterY; - urc->rcItem.bottom = (bToolbar && !bBottomToolbar) ? (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)) : (urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2)); + urc->rcItem.top = urc->dlgNewSize.cy - si->iSplitterY; + urc->rcItem.bottom = urc->dlgNewSize.cy - si->iSplitterY + DPISCALEY_S(2); urc->rcItem.left = 0; urc->rcItem.bottom++; urc->rcItem.top++; @@ -518,7 +518,6 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { HWND hwndParent = GetParent(hwnd); TWindowData *mwdat = (TWindowData*)GetWindowLongPtr(hwndParent, GWLP_USERDATA); - SESSION_INFO *si = (SESSION_INFO*)mwdat->si; MESSAGESUBDATA *dat = (MESSAGESUBDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -529,6 +528,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return 0; } + SESSION_INFO *si = (SESSION_INFO*)mwdat->si; switch (msg) { case WM_NCCALCSIZE: return CSkin::NcCalcRichEditFrame(hwnd, mwdat, ID_EXTBKINPUTAREA, msg, wParam, lParam, MessageSubclassProc); @@ -545,7 +545,6 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, { MODULEINFO *mi = pci->MM_FindModule(si->pszModule); CHARRANGE sel, all = { 0, -1 }; - int idFrom = IDC_CHAT_MESSAGE; POINT pt; GetCursorPos(&pt); @@ -560,13 +559,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin == sel.cpMax) { EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); - if (idFrom == IDC_CHAT_MESSAGE) - EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED); } MessageWindowPopupData mwpd = { sizeof(mwpd) }; mwpd.uType = MSG_WINDOWPOPUP_SHOWING; - mwpd.uFlags = (idFrom == IDC_LOG ? MSG_WINDOWPOPUP_LOG : MSG_WINDOWPOPUP_INPUT); + mwpd.uFlags = MSG_WINDOWPOPUP_INPUT; mwpd.hContact = mwdat->hContact; mwpd.hwnd = hwnd; mwpd.hMenu = hSubMenu; @@ -588,8 +586,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case IDM_PASTE: case IDM_PASTEFORMATTED: - if (idFrom == IDC_CHAT_MESSAGE) - SendMessage(hwnd, EM_PASTESPECIAL, (iSelection == IDM_PASTE) ? CF_UNICODETEXT : 0, 0); + SendMessage(hwnd, EM_PASTESPECIAL, (iSelection == IDM_PASTE) ? CF_UNICODETEXT : 0, 0); break; case IDM_COPYALL: SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&all); @@ -2569,7 +2566,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (iRes > 0) { size_t iLen = mir_tstrlen(pszWord) - 1; - while (iLen >= 0 && strchr(szTrimString, pszWord[iLen])) { + while (strchr(szTrimString, pszWord[iLen])) { pszWord[iLen] = '\0'; iLen--; } @@ -2875,6 +2872,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case IDOK: if (GetSendButtonState(hwndDlg) != PBS_DISABLED) { MODULEINFO *mi = pci->MM_FindModule(si->pszModule); + if (mi == NULL) + break; ptrA pszRtf(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE))); pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf); @@ -2887,7 +2886,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar ptszText.Trim(); ptszText.Replace(_T("%"), _T("%%")); - if (mi && mi->bAckMsg) { + if (mi->bAckMsg) { Utils::enableDlgControl(hwndDlg, IDC_CHAT_MESSAGE, false); SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, TRUE, 0); } @@ -3485,6 +3484,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case WM_DESTROY: + if(si == NULL) + break; if (CallService(MS_CLIST_GETEVENT, si->hContact, 0)) CallService(MS_CLIST_REMOVEEVENT, si->hContact, (LPARAM)GC_FAKE_EVENT); si->wState &= ~STATE_TALK; diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 84682def1c..c80af6993f 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -653,12 +653,7 @@ static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, if (lParam) { DWORD dwSWPFlags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_DEFERERASE | SWP_NOCOPYBITS; // | SWP_NOSENDCHANGING | SWP_ASYNCWINDOWPOS; - if (pContainer->dwFlags & CNT_TABSBOTTOM) - SetWindowPos(hwndTab, 0, pContainer->tBorder_outer_left + sbarWidth_left, pContainer->tBorder_outer_top + rebarHeight, - (rcClient.right - rcClient.left) - (pContainer->tBorder_outer_left + pContainer->tBorder_outer_right + sbarWidth), - (rcClient.bottom - rcClient.top) - pContainer->statusBarHeight - (pContainer->tBorder_outer_top + pContainer->tBorder_outer_bottom) - rebarHeight, dwSWPFlags); - else - SetWindowPos(hwndTab, 0, pContainer->tBorder_outer_left + sbarWidth_left, pContainer->tBorder_outer_top + rebarHeight, + SetWindowPos(hwndTab, 0, pContainer->tBorder_outer_left + sbarWidth_left, pContainer->tBorder_outer_top + rebarHeight, (rcClient.right - rcClient.left) - (pContainer->tBorder_outer_left + pContainer->tBorder_outer_right + sbarWidth), (rcClient.bottom - rcClient.top) - pContainer->statusBarHeight - (pContainer->tBorder_outer_top + pContainer->tBorder_outer_bottom) - rebarHeight, dwSWPFlags); } @@ -1153,12 +1148,11 @@ static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, iNewTab = iCurrent ? iCurrent - 1 : iItems - 1; // cycle if current is already the leftmost tab.. else if (wParam == DM_SELECT_NEXT) iNewTab = (iCurrent == (iItems - 1)) ? 0 : iCurrent + 1; - else if (wParam == DM_SELECT_BY_INDEX) { + else { if ((int)lParam > iItems) break; iNewTab = lParam - 1; } - else iNewTab = -1; if (iNewTab != iCurrent) { memset(&item, 0, sizeof(item)); @@ -2219,6 +2213,8 @@ void TSAPI ReflashContainer(TContainerData *pContainer) void TSAPI BroadCastContainer(const TContainerData *pContainer, UINT message, WPARAM wParam, LPARAM lParam, BYTE bType) { + if (pContainer == NULL) + return; HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS); TCITEM item = { 0 }; diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index 980010ba5f..f2d45375b9 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -227,14 +227,12 @@ LRESULT CALLBACK CMenuBar::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm)
{
- bool fMustDraw = true;
-
if (nm->hdr.hwndFrom == m_hwndToolbar) {
NMTBCUSTOMDRAW *nmtb = (NMTBCUSTOMDRAW *)(nm);
switch (nmtb->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
- if (fMustDraw) {
+ {
if (nmtb->nmcd.dwItemSpec == 0) {
m_hdcDraw = ::CreateCompatibleDC(nmtb->nmcd.hdc);
//m_rcItem = nmtb->nmcd.rc;
@@ -276,7 +274,7 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) return CDRF_DODEFAULT;
case CDDS_ITEMPREPAINT:
- if (fMustDraw) {
+ {
TCHAR *szText = 0;
bool fDraw = true;
@@ -330,16 +328,15 @@ LONG_PTR CMenuBar::customDrawWorker(NMCUSTOMDRAW *nm) return CDRF_SKIPDEFAULT;
}
- else return CDRF_DODEFAULT;
case CDDS_PREERASE:
case CDDS_ITEMPOSTERASE:
case CDDS_ITEMPOSTPAINT:
case CDDS_ITEMPREERASE:
- return fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT;
+ return CDRF_SKIPDEFAULT;
case CDDS_POSTERASE:
- return fMustDraw ? CDRF_SKIPDEFAULT : CDRF_DODEFAULT;
+ return CDRF_SKIPDEFAULT;
case CDDS_POSTPAINT:
if (nmtb->nmcd.dwItemSpec == 0 && m_hdcDraw) {
@@ -489,8 +486,6 @@ void CMenuBar::updateState(const HMENU hMenu) const void CMenuBar::configureMenu() const
{
- BOOL fDisable = FALSE;
-
TWindowData *dat = (TWindowData*)::GetWindowLongPtr(m_pContainer->hwndActive, GWLP_USERDATA);
if (dat) {
bool fChat = (dat->bType == SESSIONTYPE_CHAT);
@@ -500,7 +495,7 @@ void CMenuBar::configureMenu() const ::SendMessage(m_hwndToolbar, TB_SETSTATE, 105, fChat ? TBSTATE_HIDDEN : TBSTATE_ENABLED);
if (dat->bType == SESSIONTYPE_IM)
- ::EnableWindow(GetDlgItem(dat->hwnd, IDC_TIME), fDisable ? FALSE : TRUE);
+ ::EnableWindow(GetDlgItem(dat->hwnd, IDC_TIME), TRUE);
}
}
@@ -956,7 +951,7 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR break;
case WM_TIMER:
- if (wParam != TIMERID_HOVER)
+ if (pContainer == NULL || wParam != TIMERID_HOVER)
break;
KillTimer(hWnd, TIMERID_HOVER);
GetCursorPos(&pt);
@@ -979,7 +974,7 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR break;
if (!strcmp(sid->szModule, MSG_ICON_MODULE)) {
- if (sid->dwId == MSG_ICON_SOUND && pContainer)
+ if (sid->dwId == MSG_ICON_SOUND)
mir_sntprintf(wBuf, SIZEOF(wBuf), TranslateT("Sounds are %s. Click to toggle status, hold SHIFT and click to set for all open containers"),
pContainer->dwFlags & CNT_NOSOUND ? TranslateT("disabled") : TranslateT("enabled"));
@@ -1026,12 +1021,11 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR DBVARIANT dbv = { 0 };
if (dat->bType == SESSIONTYPE_CHAT)
- db_get_ts(dat->hContact, dat->szProto, "Topic", &dbv);
-
- tooltip_active = TRUE;
- CallService("mToolTip/ShowTipW", (WPARAM)dbv.ptszVal, (LPARAM)&ti);
- if (dbv.pszVal)
- db_free(&dbv);
+ if(!db_get_ts(dat->hContact, dat->szProto, "Topic", &dbv)) {
+ tooltip_active = TRUE;
+ CallService("mToolTip/ShowTipW", (WPARAM)dbv.ptszVal, (LPARAM)&ti);
+ db_free(&dbv);
+ }
}
}
}
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 4cdb399389..2afa7e3a03 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -831,7 +831,7 @@ void TSAPI DM_InitRichEdit(TWindowData *dat) cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.crTextColor = inputcharcolor; cf2.bCharSet = lf.lfCharSet; - strncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE); + strncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE-1); cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0) | (lf.lfUnderline ? CFE_UNDERLINE : 0) | (lf.lfStrikeOut ? CFE_STRIKEOUT : 0); cf2.wWeight = (WORD)lf.lfWeight; cf2.bPitchAndFamily = lf.lfPitchAndFamily; @@ -1763,7 +1763,7 @@ void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM, LPARAM lParam) Utils::DoubleAmpersands(newcontactname); - if (mir_tstrlen(newcontactname) != 0 && dat->szStatus != NULL) { + if (mir_tstrlen(newcontactname) != 0) { if (PluginConfig.m_bStatusOnTabs) mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s (%s)"), newcontactname, dat->szStatus); else @@ -1907,7 +1907,9 @@ void CheckStatusIconClick(TWindowData *dat, POINT pt, const RECT &rc, int gap, i } UINT iconNum = (pt.x - (rc.left + 0)) / (PluginConfig.m_smcxicon + gap); - StatusIconData *si = Srmm_GetNthIcon((dat) ? dat->hContact : 0, iconNum); + if (dat == NULL) + return; + StatusIconData *si = Srmm_GetNthIcon(dat->hContact, iconNum); if (si == NULL) return; diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 9181a03d29..ba31f8a055 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -207,7 +207,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (hWnd)
dat = (TWindowData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (dis->itemData >= 0) {
+ {
HICON hIcon;
if (dis->itemData > 0)
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index 85889fd2ec..9e660bcf3d 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -356,8 +356,10 @@ void CInfoPanel::renderContent(const HDC hdc) else {
RECT rc = m_dat->rcNick;
- if (m_height >= DEGRADE_THRESHOLD)
- rc.top -= 2; rc.bottom -= 2;
+ if (m_height >= DEGRADE_THRESHOLD) {
+ rc.top -= 2;
+ rc.bottom -= 2;
+ }
Chat_RenderIPNickname(hdc, rc);
if (m_height >= DEGRADE_THRESHOLD) {
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index bc905e8c68..9f487ad79d 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -335,13 +335,10 @@ int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode) int CMimAPI::ProtoAck(WPARAM, LPARAM lParam) { ACKDATA *pAck = (ACKDATA*)lParam; - if (lParam == 0) - return 0; - - int i = 0, iFound = SendQueue::NR_SENDJOBS; - SendJob *jobs = sendQueue->getJobByIndex(0); - if (pAck->type == ACKTYPE_MESSAGE) { + if ((pAck != 0) && (pAck->type == ACKTYPE_MESSAGE)) { + int i = 0, iFound = SendQueue::NR_SENDJOBS; + SendJob *jobs = sendQueue->getJobByIndex(0); MCONTACT hMeta = db_mc_getMeta(pAck->hContact); for (int j = 0; j < SendQueue::NR_SENDJOBS; j++) { SendJob &p = jobs[j]; @@ -356,8 +353,6 @@ int CMimAPI::ProtoAck(WPARAM, LPARAM lParam) break; } } - if (iFound != SendQueue::NR_SENDJOBS) // no mathing entry found in this queue entry.. continue - break; } if (iFound == SendQueue::NR_SENDJOBS) // no matching send info found in the queue sendLater->processAck(pAck); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 6e992dacb1..39dd1d3f10 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -728,8 +728,6 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar return 0;
}
}
- if (wParam == VK_RETURN)
- break;
case WM_SYSKEYDOWN:
mwdat->fkeyProcessed = false;
@@ -2589,7 +2587,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP menuID = MENU_PICMENU;
if ((menuID == MENU_PICMENU && ((dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown) || dat->hOwnPic) && dat->bShowAvatar != 0)) {
- HMENU submenu = GetSubMenu(m_pContainer->hMenuContext, menuID == MENU_PICMENU ? 1 : 11);
+ HMENU submenu = GetSubMenu(m_pContainer->hMenuContext, 1);
GetCursorPos(&pt);
MsgWindowUpdateMenu(dat, submenu, menuID);
int iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 9d7e81d12e..6be4a99bd9 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -1533,10 +1533,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat) SelectClipRgn(hdcDraw, clipRgn);
HBRUSH hbr = CreateSolidBrush(CSkin::m_avatarBorderClr);
- if (bPanelPic)
- FrameRgn(dis->hDC, clipRgn, hbr, 1, 1);
- else
- FrameRgn(hdcDraw, clipRgn, hbr, 1, 1);
+ FrameRgn(hdcDraw, clipRgn, hbr, 1, 1);
DeleteObject(hbr);
DeleteObject(clipRgn);
}
@@ -1667,7 +1664,7 @@ void TSAPI LoadOverrideTheme(TContainerData *pContainer) pContainer->theme.fontColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * (MSGDLGFONTCOUNT + 2));
pContainer->theme.rtfFonts = (char *)mir_alloc((MSGDLGFONTCOUNT + 2) * RTFCACHELINESIZE);
- ReadThemeFromINI(pContainer->szAbsThemeFile, pContainer, bReadTemplates ? 0 : 1, THEME_READ_ALL);
+ ReadThemeFromINI(pContainer->szAbsThemeFile, pContainer, 0, THEME_READ_ALL);
pContainer->theme.left_indent *= 15;
pContainer->theme.right_indent *= 15;
pContainer->theme.isPrivate = true;
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 34cc300a76..72ea66691f 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -496,7 +496,7 @@ BOOL TreeViewHandleClick(HWND hwndDlg, HWND hwndTree, WPARAM, LPARAM lParam) case TVN_KEYDOWN:
if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
return FALSE;
- hti.flags |= TVHT_ONITEMSTATEICON;
+ hti.flags = TVHT_ONITEMSTATEICON;
item.hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
break;
case NM_CLICK:
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index fc4d66b153..8fcf781352 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -1,983 +1,991 @@ -///////////////////////////////////////////////////////////////////////////////////////// -// Miranda NG: the free IM client for Microsoft* Windows* -// -// Copyright (ñ) 2012-15 Miranda NG project, -// Copyright (c) 2000-09 Miranda ICQ/IM project, -// all portions of this codebase are copyrighted to the people -// listed in contributors.txt. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// you should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// part of tabSRMM messaging plugin for Miranda. -// -// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors -// -// Load, setup and shutdown the plugin -// core plugin messaging services (single IM chats only). - -#include "commonheaders.h" - -#define IDI_CORE_LOAD 132 // icon id for the "connecting" icon - -NEN_OPTIONS nen_options; -static HANDLE hUserPrefsWindowLis = 0; -HMODULE g_hIconDLL = 0; - -static void UnloadIcons(); - -void Chat_AddIcons(void); - -///////////////////////////////////////////////////////////////////////////////////////// -// fired event when user changes IEView plugin options. Apply them to all open tabs - -int IEViewOptionsChanged(WPARAM, LPARAM) -{ - M.BroadcastMessage(DM_IEVIEWOPTIONSCHANGED, 0, 0); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// fired event when user changes smileyadd options. Notify all open tabs about the changes - -int SmileyAddOptionsChanged(WPARAM, LPARAM) -{ - M.BroadcastMessage(DM_SMILEYOPTIONSCHANGED, 0, 0); - pci->SM_BroadcastMessage(NULL, DM_SMILEYOPTIONSCHANGED, 0, 0, FALSE); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Message API 0.0.0.3 services - -static INT_PTR GetWindowClass(WPARAM wParam, LPARAM lParam) -{ - char *szBuf = (char*)wParam; - size_t size = (size_t)lParam; - mir_snprintf(szBuf, size, "tabSRMM"); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// wparam = (MessageWindowInputData*) -// lparam = (MessageWindowData*) -// returns 0 on success and returns non-zero (1) on error or if no window data exists for that hcontact - -static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam) -{ - MessageWindowInputData *mwid = (MessageWindowInputData*)wParam; - if (mwid == NULL || (mwid->cbSize != sizeof(MessageWindowInputData)) || (mwid->hContact == NULL) || (mwid->uFlags != MSG_WINDOW_UFLAG_MSG_BOTH)) - return 1; - - MessageWindowData *mwd = (MessageWindowData*)lParam; - if (mwd == NULL || (mwd->cbSize != sizeof(MessageWindowData))) - return 1; - - HWND hwnd = M.FindWindow(mwid->hContact); - if (hwnd) { - mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH; - mwd->hwndWindow = hwnd; - mwd->local = GetParent(GetParent(hwnd)); - SendMessage(hwnd, DM_GETWINDOWSTATE, 0, 0); - mwd->uState = GetWindowLongPtr(hwnd, DWLP_MSGRESULT); - return 0; - } - else - { - SESSION_INFO *si = SM_FindSessionByHCONTACT(mwid->hContact); - if (si != NULL && si->hWnd != 0) { - mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH; - mwd->hwndWindow = si->hWnd; - mwd->local = GetParent(GetParent(si->hWnd)); - SendMessage(si->hWnd, DM_GETWINDOWSTATE, 0, 0); - mwd->uState = GetWindowLongPtr(si->hWnd, DWLP_MSGRESULT); - return 0; - } - else { - mwd->uState = 0; - mwd->hContact = 0; - mwd->hwndWindow = 0; - mwd->uFlags = 0; - } - } - return 1; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// service function. Sets a status bar text for a contact - -static void SetStatusTextWorker(TWindowData *dat, StatusTextData *st) -{ - if (!dat) - return; - - // delete old custom data - if (dat->sbCustom) { - delete dat->sbCustom; - dat->sbCustom = NULL; - } - - if (st != NULL && st->cbSize == sizeof(StatusTextData)) - dat->sbCustom = new StatusTextData(*st); - - UpdateStatusBar(dat); -} - -static INT_PTR SetStatusText(WPARAM hContact, LPARAM lParam) -{ - SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact); - if (si == NULL) { - HWND hwnd = M.FindWindow(hContact); - if (hwnd != NULL) - SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam); - - if (hContact = db_mc_getMeta(hContact)) - if (hwnd = M.FindWindow(hContact)) - SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam); - } - else SetStatusTextWorker(si->dat, (StatusTextData*)lParam); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// service function. Invoke the user preferences dialog for the contact given (by handle) in wParam - -static INT_PTR SetUserPrefs(WPARAM wParam, LPARAM) -{ - HWND hWnd = WindowList_Find(PluginConfig.hUserPrefsWindowList, wParam); - if (hWnd) { - SetForegroundWindow(hWnd); // already open, bring it to front - return 0; - } - CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_USERPREFS_FRAME), 0, DlgProcUserPrefsFrame, (LPARAM)wParam); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// service function - open the tray menu from the TTB button - -static INT_PTR Service_OpenTrayMenu(WPARAM, LPARAM lParam) -{ - SendMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, lParam == 0 ? WM_LBUTTONUP : WM_RBUTTONUP); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// service function. retrieves the message window flags for a given hcontact or window -// wParam == hContact of the window to find -// lParam == window handle (set it to 0 if you want search for hcontact, otherwise it -// is directly used as the handle for the target window - -static INT_PTR GetMessageWindowFlags(WPARAM wParam, LPARAM lParam) -{ - HWND hwndTarget = (HWND)lParam; - if (hwndTarget == 0) - hwndTarget = M.FindWindow(wParam); - - if (hwndTarget == 0) - return 0; - - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndTarget, GWLP_USERDATA); - return (dat) ? dat->dwFlags : 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// return the version of the window api supported - -static INT_PTR GetWindowAPI(WPARAM, LPARAM) -{ - return PLUGIN_MAKE_VERSION(0, 0, 0, 2); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// service function finds a message session -// wParam = contact handle for which we want the window handle -// thanks to bio for the suggestion of this service -// if wParam == 0, then lParam is considered to be a valid window handle and -// the function tests the popup mode of the target container - -// returns the hwnd if there is an open window or tab for the given hcontact (wParam), -// or (if lParam was specified) the hwnd if the window exists. -// 0 if there is none (or the popup mode of the target container was configured to "hide" -// the window.. - -INT_PTR MessageWindowOpened(WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = 0; - TContainerData *pContainer = NULL; - - if (wParam) - hwnd = M.FindWindow(wParam); - else if (lParam) - hwnd = (HWND)lParam; - else - return NULL; - - if (!hwnd) - return 0; - - SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); - if (pContainer) { - if (pContainer->dwFlags & CNT_DONTREPORT) { - if (IsIconic(pContainer->hwnd)) - return 0; - } - if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) { - if (!IsIconic(pContainer->hwnd) && GetForegroundWindow() != pContainer->hwnd && GetActiveWindow() != pContainer->hwnd) - return 0; - } - if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) { - if (pContainer->dwFlags & CNT_DONTREPORTFOCUSED) - return 0; - - return pContainer->hwndActive == hwnd; - } - } - return 1; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// ReadMessageCommand is executed whenever the user wants to manually open a window. -// This can happen when double clicking a contact on the clist OR when opening a new -// message (clicking on a popup, clicking the flashing tray icon and so on). - -static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) -{ - MCONTACT hContact = ((CLISTEVENT *)lParam)->hContact; - - HWND hwndExisting = M.FindWindow(hContact); - if (hwndExisting != 0) - SendMessage(hwndExisting, DM_ACTIVATEME, 0, 0); - else { - TCHAR szName[CONTAINER_NAMELEN + 1]; - GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); - TContainerData *pContainer = FindContainerByName(szName); - if (pContainer == NULL) - pContainer = CreateContainer(szName, FALSE, hContact); - if (pContainer) - CreateNewTabForContact(pContainer, hContact, 0, NULL, TRUE, TRUE, FALSE, 0); - } - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// the SendMessageCommand() invokes a message session window for the given contact. -// e.g. it is called when user double clicks a contact on the contact list -// it is implemented as a service, so external plugins can use it to open a message window. -// contacts handle must be passed in wParam. - -INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar) -{ - // make sure that only the main UI thread will handle window creation - if (GetCurrentThreadId() != PluginConfig.dwThreadID) { - if (pszMsg) { - wchar_t *tszText = (isWchar) ? mir_wstrdup((WCHAR*)pszMsg) : mir_a2u(pszMsg); - PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, (LPARAM)tszText); - } - else PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, 0); - return 0; - } - - // does the MCONTACT's protocol support IM messages? - char *szProto = GetContactProto(hContact); - if (szProto == NULL) - return 0; // unknown contact - if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) - return 0; - - HWND hwnd = M.FindWindow(hContact); - if (hwnd) { - if (pszMsg) { - HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE); - SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit)); - if (isWchar) - SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg); - else - SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg); - } - SendMessage(hwnd, DM_ACTIVATEME, 0, 0); - } - else { - TCHAR szName[CONTAINER_NAMELEN + 1]; - GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); - - TContainerData *pContainer = FindContainerByName(szName); - if (pContainer == NULL) - pContainer = CreateContainer(szName, FALSE, hContact); - if (pContainer) - CreateNewTabForContact(pContainer, hContact, isWchar, pszMsg, TRUE, TRUE, FALSE, 0); - } - return 0; -} - -INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam) -{ - return SendMessageCommand_Worker(hContact, LPCSTR(lParam), false); -} - -INT_PTR SendMessageCommand_W(WPARAM hContact, LPARAM lParam) -{ - return SendMessageCommand_Worker(hContact, LPCSTR(lParam), true); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// open a window when user clicks on the flashing "typing message" tray icon. -// just calls SendMessageCommand() for the given contact. - -static INT_PTR TypingMessageCommand(WPARAM, LPARAM lParam) -{ - CLISTEVENT *cle = (CLISTEVENT*)lParam; - if (cle) - SendMessageCommand((WPARAM)cle->hContact, 0); - return 0; -} - -int SplitmsgShutdown(void) -{ - WindowList_Destroy(M.m_hMessageWindowList); - WindowList_Destroy(PluginConfig.hUserPrefsWindowList); - - DestroyCursor(PluginConfig.hCurSplitNS); - DestroyCursor(PluginConfig.hCurHyperlinkHand); - DestroyCursor(PluginConfig.hCurSplitWE); - - FreeLibrary(GetModuleHandleA("Msftedit.dll")); - - if (g_hIconDLL) { - FreeLibrary(g_hIconDLL); - g_hIconDLL = NULL; - } - - ImageList_RemoveAll(PluginConfig.g_hImageList); - ImageList_Destroy(PluginConfig.g_hImageList); - - delete Win7Taskbar; - - DestroyMenu(PluginConfig.g_hMenuContext); - if (PluginConfig.g_hMenuContainer) - DestroyMenu(PluginConfig.g_hMenuContainer); - if (PluginConfig.g_hMenuEncoding) - DestroyMenu(PluginConfig.g_hMenuEncoding); - - UnloadIcons(); - FreeTabConfig(); - - if (Utils::rtf_ctable) - mir_free(Utils::rtf_ctable); - - UnloadTSButtonModule(); - return 0; -} - -int MyAvatarChanged(WPARAM wParam, LPARAM lParam) -{ - if (wParam == 0 || IsBadReadPtr((void*)wParam, 4)) - return 0; - - for (TContainerData *p = pFirstContainer; p; p = p->pNext) - BroadCastContainer(p, DM_MYAVATARCHANGED, wParam, lParam); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// tabbed mode support functions... -// (C) by Nightwish -// -// this function searches and activates the tab belonging to the given hwnd (which is the -// hwnd of a message dialog window) - -int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) -{ - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndChild, GWLP_USERDATA); // needed to obtain the hContact for the message window - if (!dat || !pContainer) - return FALSE; - - NMHDR nmhdr = { 0 }; - nmhdr.code = TCN_SELCHANGE; - if (TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)) > 1 && !(pContainer->dwFlags & CNT_DEFERREDTABSELECT)) { - TabCtrl_SetCurSel(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), GetTabIndexFromHWND(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), hwndChild)); - SendMessage(pContainer->hwnd, WM_NOTIFY, 0, (LPARAM)&nmhdr); // just select the tab and let WM_NOTIFY do the rest - } - if (dat->bType == SESSIONTYPE_IM) - SendMessage(pContainer->hwnd, DM_UPDATETITLE, dat->hContact, 0); - if (IsIconic(pContainer->hwnd)) { - SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); - SetForegroundWindow(pContainer->hwnd); - } - - // hide on close feature - if (!IsWindowVisible(pContainer->hwnd)) { - WINDOWPLACEMENT wp = { 0 }; - wp.length = sizeof(wp); - GetWindowPlacement(pContainer->hwnd, &wp); - - // all tabs must re-check the layout on activation because adding a tab while - // the container was hidden can make this necessary - BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); - if (wp.showCmd == SW_SHOWMAXIMIZED) - ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED); - else { - ShowWindow(pContainer->hwnd, SW_SHOWNA); - SetForegroundWindow(pContainer->hwnd); - } - SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); // make sure the active tab resizes its layout properly - } - else if (GetForegroundWindow() != pContainer->hwnd) - SetForegroundWindow(pContainer->hwnd); - - if (dat->bType == SESSIONTYPE_IM) - SetFocus(GetDlgItem(hwndChild, IDC_MESSAGE)); - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// this function creates and activates a new tab within the given container. -// bActivateTab: make the new tab the active one -// bPopupContainer: restore container if it was minimized, otherwise flash it... - -HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, int isSend, const char *pszInitialText, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup, MEVENT hdbEvent) -{ - if (M.FindWindow(hContact) != 0) { - _DebugPopup(hContact, _T("Warning: trying to create duplicate window")); - return 0; - } - - // if we have a max # of tabs/container set and want to open something in the default container... - if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) { - if ((pContainer = FindMatchingContainer(_T("default"))) == NULL) { - TCHAR szName[CONTAINER_NAMELEN + 1]; - mir_sntprintf(szName, SIZEOF(szName), _T("default")); - if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact)) == NULL) - return 0; - } - } - - TNewWindowData newData = { 0 }; - newData.hContact = hContact; - newData.isWchar = isSend; - newData.szInitialText = pszInitialText; - char *szProto = GetContactProto(newData.hContact); - - memset(&newData.item, 0, sizeof(newData.item)); - - // obtain various status information about the contact - TCHAR *contactName = pcli->pfnGetContactDisplayName(newData.hContact, 0); - - // cut nickname if larger than x chars... - TCHAR newcontactname[128], tabtitle[128]; - if (contactName && mir_tstrlen(contactName) > 0) { - if (M.GetByte("cuttitle", 0)) - CutContactName(contactName, newcontactname, SIZEOF(newcontactname)); - else - _tcsncpy_s(newcontactname, contactName, _TRUNCATE); - - Utils::DoubleAmpersands(newcontactname); - } - else _tcsncpy_s(newcontactname, _T("_U_"), _TRUNCATE); - - TCHAR *szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); - - if (M.GetByte("tabstatus", 1)) - mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s (%s) "), newcontactname, szStatus); - else - mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s "), newcontactname); - - newData.item.pszText = tabtitle; - newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; - newData.item.iImage = 0; - newData.item.cchTextMax = SIZEOF(tabtitle); - - HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS); - // hide the active tab - if (pContainer->hwndActive && bActivateTab) - ShowWindow(pContainer->hwndActive, SW_HIDE); - - int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->iChilds * 100); - int iCount = TabCtrl_GetItemCount(hwndTab); - TCITEM item = { 0 }; - - pContainer->iTabIndex = iCount; - if (iCount > 0) { - for (int i = iCount - 1; i >= 0; i--) { - item.mask = TCIF_PARAM; - TabCtrl_GetItem(hwndTab, i, &item); - HWND hwnd = (HWND)item.lParam; - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (dat) { - int relPos = M.GetDword(dat->hContact, "tabindex", i * 100); - if (iTabIndex_wanted <= relPos) - pContainer->iTabIndex = i; - } - } - } - - int newItem = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &newData.item); - SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0); - if (bActivateTab) - TabCtrl_SetCurSel(hwndTab, newItem); - newData.iTabID = newItem; - newData.iTabImage = newData.item.iImage; - newData.pContainer = pContainer; - newData.iActivate = (int)bActivateTab; - pContainer->iChilds++; - newData.bWantPopup = bWantPopup; - newData.hdbEvent = hdbEvent; - HWND hwndNew = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSPLITNEW), hwndTab, DlgProcMessage, (LPARAM)&newData); - - // switchbar support - if (pContainer->dwFlags & CNT_SIDEBAR) { - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndNew, GWLP_USERDATA); - if (dat) - pContainer->SideBar->addSession(dat, pContainer->iTabIndex); - } - SendMessage(pContainer->hwnd, WM_SIZE, 0, 0); - - // if the container is minimized, then pop it up... - if (IsIconic(pContainer->hwnd)) { - if (bPopupContainer) { - SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); - SetFocus(pContainer->hwndActive); - } - else { - if (pContainer->dwFlags & CNT_NOFLASH) - SendMessage(pContainer->hwnd, DM_SETICON, 0, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); - else - FlashContainer(pContainer, 1, 0); - } - } - - if (bActivateTab) { - ActivateExistingTab(pContainer, hwndNew); - SetFocus(hwndNew); - RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASENOW); - UpdateWindow(pContainer->hwnd); - if (GetForegroundWindow() != pContainer->hwnd && bPopupContainer == TRUE) - SetForegroundWindow(pContainer->hwnd); - } - else if (!IsIconic(pContainer->hwnd) && IsWindowVisible(pContainer->hwnd)) { - SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); - RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); - RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_ERASENOW | RDW_UPDATENOW); - } - - if (PluginConfig.m_bHideOnClose&&!IsWindowVisible(pContainer->hwnd)) { - WINDOWPLACEMENT wp = { 0 }; - wp.length = sizeof(wp); - GetWindowPlacement(pContainer->hwnd, &wp); - - BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation - if (wp.showCmd == SW_SHOWMAXIMIZED) - ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED); - else { - if (bPopupContainer) - ShowWindow(pContainer->hwnd, SW_SHOWNORMAL); - else - ShowWindow(pContainer->hwnd, SW_SHOWMINNOACTIVE); - } - SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); - } - - if (PluginConfig.m_bIsWin7 && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled) - CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING | MB_OK); - - if (ServiceExists(MS_HPP_EG_EVENT) && ServiceExists(MS_IEVIEW_EVENT) && db_get_b(0, "HistoryPlusPlus", "IEViewAPI", 0)) - if (IDYES == CWarning::show(CWarning::WARN_HPP_APICHECK, MB_ICONWARNING | MB_YESNO)) - db_set_b(0, "HistoryPlusPlus", "IEViewAPI", 0); - - return hwndNew; // return handle of the new dialog -} - -///////////////////////////////////////////////////////////////////////////////////////// -// this is used by the 2nd containermode (limit tabs on default containers). -// it searches a container with "room" for the new tabs or otherwise creates -// a new (cloned) one. - -TContainerData* TSAPI FindMatchingContainer(const TCHAR *szName) -{ - int iMaxTabs = M.GetDword("maxtabs", 0); - if (iMaxTabs > 0 && M.GetByte("limittabs", 0) && !_tcsncmp(szName, _T("default"), 6)) { - // search a "default" with less than iMaxTabs opened... - for (TContainerData *p = pFirstContainer; p; p = p->pNext) - if (!_tcsncmp(p->szName, _T("default"), 6) && p->iChilds < iMaxTabs) - return p; - - return NULL; - } - return FindContainerByName(szName); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// load some global icons. - -void TSAPI CreateImageList(BOOL bInitial) -{ - // the imagelist is now a fake. It is still needed to provide the tab control with a - // image list handle. This will make sure that the tab control will reserve space for - // an icon on each tab. This is a blank and empty icon - if (bInitial) { - PluginConfig.g_hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - HICON hIcon = CreateIcon(g_hInst, 16, 16, 1, 4, NULL, NULL); - ImageList_AddIcon(PluginConfig.g_hImageList, hIcon); - DestroyIcon(hIcon); - } - - PluginConfig.g_IconFileEvent = LoadSkinnedIcon(SKINICON_EVENT_FILE); - PluginConfig.g_IconMsgEvent = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); - PluginConfig.g_IconMsgEventBig = LoadSkinnedIconBig(SKINICON_EVENT_MESSAGE); - if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconMsgEventBig) - PluginConfig.g_IconMsgEventBig = 0; - PluginConfig.g_IconTypingEventBig = LoadSkinnedIconBig(SKINICON_OTHER_TYPING); - if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconTypingEventBig) - PluginConfig.g_IconTypingEventBig = 0; - PluginConfig.g_IconSend = PluginConfig.g_buttonBarIcons[9]; - PluginConfig.g_IconTypingEvent = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; -} - -int TABSRMM_FireEvent(MCONTACT hContact, HWND hwnd, unsigned int type, unsigned int subType) -{ - if (hContact == NULL || hwnd == NULL) - return 0; - - TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - BYTE bType = dat ? dat->bType : SESSIONTYPE_IM; - - MessageWindowEventData mwe = { sizeof(mwe) }; - mwe.hContact = hContact; - mwe.hwndWindow = hwnd; - mwe.szModule = "tabSRMsgW"; - mwe.uType = type; - mwe.hwndInput = GetDlgItem(hwnd, bType == SESSIONTYPE_IM ? IDC_MESSAGE : IDC_CHAT_MESSAGE); - mwe.hwndLog = GetDlgItem(hwnd, bType == SESSIONTYPE_IM ? IDC_LOG : IDC_CHAT_LOG); - - if (type == MSG_WINDOW_EVT_CUSTOM) { - TABSRMM_SessionInfo se = { sizeof(se) }; - se.evtCode = HIWORD(subType); - se.hwnd = hwnd; - se.extraFlags = (unsigned int)(LOWORD(subType)); - se.local = (void*)dat->sendBuffer; - mwe.local = (void*)&se; - } - - return NotifyEventHooks(PluginConfig.m_event_MsgWin, 0, (LPARAM)&mwe); -} - -///////////////////////////////////////////////////////////////////////////////////////// -// standard icon definitions - -static TIconDesc _toolbaricons[] = -{ - { "tabSRMM_mlog", LPGEN("Message Log Options"), &PluginConfig.g_buttonBarIcons[2], -IDI_MSGLOGOPT, 1 }, - { "tabSRMM_multi", LPGEN("Image tag"), &PluginConfig.g_buttonBarIcons[3], -IDI_IMAGETAG, 1 }, - { "tabSRMM_quote", LPGEN("Quote text"), &PluginConfig.g_buttonBarIcons[8], -IDI_QUOTE, 1 }, - { "tabSRMM_save", LPGEN("Save and close"), &PluginConfig.g_buttonBarIcons[7], -IDI_SAVE, 1 }, - { "tabSRMM_send", LPGEN("Send message"), &PluginConfig.g_buttonBarIcons[9], -IDI_SEND, 1 }, - { "tabSRMM_avatar", LPGEN("Edit user notes"), &PluginConfig.g_buttonBarIcons[10], -IDI_CONTACTPIC, 1 }, - { "tabSRMM_close", LPGEN("Close"), &PluginConfig.g_buttonBarIcons[6], -IDI_CLOSEMSGDLG, 1 } -}; - -static TIconDesc _exttoolbaricons[] = -{ - { "tabSRMM_emoticon", LPGEN("Smiley button"), &PluginConfig.g_buttonBarIcons[11], -IDI_SMILEYICON, 1 }, - { "tabSRMM_bold", LPGEN("Format bold"), &PluginConfig.g_buttonBarIcons[17], -IDI_FONTBOLD, 1 }, - { "tabSRMM_italic", LPGEN("Format italic"), &PluginConfig.g_buttonBarIcons[18], -IDI_FONTITALIC, 1 }, - { "tabSRMM_underline", LPGEN("Format underline"), &PluginConfig.g_buttonBarIcons[19], -IDI_FONTUNDERLINE, 1 }, - { "tabSRMM_face", LPGEN("Font face"), &PluginConfig.g_buttonBarIcons[20], -IDI_FONTFACE, 1 }, - { "tabSRMM_color", LPGEN("Font color"), &PluginConfig.g_buttonBarIcons[21], -IDI_FONTCOLOR, 1 }, - { "tabSRMM_strikeout", LPGEN("Format strike-through"), &PluginConfig.g_buttonBarIcons[30], -IDI_STRIKEOUT, 1 } -}; - -static TIconDesc _chattoolbaricons[] = -{ - { "chat_bkgcol", LPGEN("Background color"), &PluginConfig.g_buttonBarIcons[31], -IDI_BKGCOLOR, 1 }, - { "chat_settings", LPGEN("Room settings"), &PluginConfig.g_buttonBarIcons[32], -IDI_TOPICBUT, 1 }, - { "chat_filter", LPGEN("Event filter"), &PluginConfig.g_buttonBarIcons[33], -IDI_FILTER2, 1 }, - { "chat_shownicklist", LPGEN("Nick list"), &PluginConfig.g_buttonBarIcons[35], -IDI_SHOWNICKLIST, 1 } -}; - -static TIconDesc _logicons[] = -{ - { "tabSRMM_error", LPGEN("Message delivery error"), &PluginConfig.g_iconErr, -IDI_MSGERROR, 1 }, - { "tabSRMM_in", LPGEN("Incoming message"), &PluginConfig.g_iconIn, -IDI_ICONIN, 0 }, - { "tabSRMM_out", LPGEN("Outgoing message"), &PluginConfig.g_iconOut, -IDI_ICONOUT, 0 }, - { "tabSRMM_status", LPGEN("Status change"), &PluginConfig.g_iconStatus, -IDI_STATUSCHANGE, 0 } -}; - -static TIconDesc _deficons[] = -{ - { "tabSRMM_container", LPGEN("Static container icon"), &PluginConfig.g_iconContainer, -IDI_CONTAINER, 1 }, - { "tabSRMM_sounds_on", LPGEN("Sounds (status bar)"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_SOUNDS], -IDI_SOUNDSON, 1 }, - { "tabSRMM_pulldown", LPGEN("Pulldown Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_PULLDOWN], -IDI_PULLDOWNARROW, 1 }, - { "tabSRMM_Leftarrow", LPGEN("Left Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_LEFT], -IDI_LEFTARROW, 1 }, - { "tabSRMM_Rightarrow", LPGEN("Right Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_RIGHT], -IDI_RIGHTARROW, 1 }, - { "tabSRMM_Pulluparrow", LPGEN("Up Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_UP], -IDI_PULLUPARROW, 1 }, - { "tabSRMM_sb_slist", LPGEN("Session List"), &PluginConfig.g_sideBarIcons[0], -IDI_SESSIONLIST, 1 }, -}; - -static TIconDesc _trayIcon[] = -{ - { "tabSRMM_frame1", LPGEN("Frame 1"), &PluginConfig.m_AnimTrayIcons[0], -IDI_TRAYANIM1, 1 }, - { "tabSRMM_frame2", LPGEN("Frame 2"), &PluginConfig.m_AnimTrayIcons[1], -IDI_TRAYANIM2, 1 }, - { "tabSRMM_frame3", LPGEN("Frame 3"), &PluginConfig.m_AnimTrayIcons[2], -IDI_TRAYANIM3, 1 }, - { "tabSRMM_frame4", LPGEN("Frame 4"), &PluginConfig.m_AnimTrayIcons[3], -IDI_TRAYANIM4, 1 }, -}; - -struct { - char *szSection; - TIconDesc *idesc; - int nItems; -} -static ICONBLOCKS[] = { - { LPGEN("Message Sessions")"/"LPGEN("Default"), _deficons, SIZEOF(_deficons) }, - { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _toolbaricons, SIZEOF(_toolbaricons) }, - { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _exttoolbaricons, SIZEOF(_exttoolbaricons) }, - { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _chattoolbaricons, SIZEOF(_chattoolbaricons) }, - { LPGEN("Message Sessions")"/"LPGEN("Message Log"), _logicons, SIZEOF(_logicons) }, - { LPGEN("Message Sessions")"/"LPGEN("Animated Tray"), _trayIcon, SIZEOF(_trayIcon) } -}; - -static int GetIconPackVersion(HMODULE hDLL) -{ - char szIDString[256]; - int version = 0; - - if (LoadStringA(hDLL, IDS_IDENTIFY, szIDString, sizeof(szIDString)) == 0) - version = 0; - else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 1.0__")) - version = 1; - else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 2.0__")) - version = 2; - else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 3.0__")) - version = 3; - else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 3.5__")) - version = 4; - else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 5.0__")) - version = 5; - - if (version < 5) - CWarning::show(CWarning::WARN_ICONPACK_VERSION, MB_OK | MB_ICONERROR); - return version; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// setup default icons for the IcoLib service. This needs to be done every time the -// plugin is loaded default icons are taken from the icon pack in either \icons or \plugins - -static int TSAPI SetupIconLibConfig() -{ - int j = 2, version = 0; - - TCHAR szFilename[MAX_PATH]; - _tcsncpy(szFilename, _T("icons\\tabsrmm_icons.dll"), MAX_PATH); - g_hIconDLL = LoadLibrary(szFilename); - if (g_hIconDLL == 0) { - CWarning::show(CWarning::WARN_ICONPACKMISSING, CWarning::CWF_NOALLOWHIDE | MB_ICONERROR | MB_OK); - return 0; - } - - GetModuleFileName(g_hIconDLL, szFilename, MAX_PATH); - Chat_AddIcons(); - version = GetIconPackVersion(g_hIconDLL); - FreeLibrary(g_hIconDLL); - g_hIconDLL = 0; - - SKINICONDESC sid = { sizeof(sid) }; - sid.ptszDefaultFile = szFilename; - sid.flags = SIDF_PATH_TCHAR; - - for (int n = 0; n < SIZEOF(ICONBLOCKS); n++) { - sid.pszSection = ICONBLOCKS[n].szSection; - for (int i = 0; i < ICONBLOCKS[n].nItems; i++) { - sid.pszName = ICONBLOCKS[n].idesc[i].szName; - sid.pszDescription = ICONBLOCKS[n].idesc[i].szDesc; - sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem) - - if (n > 0 && n < 4) - PluginConfig.g_buttonBarIconHandles[j++] = Skin_AddIcon(&sid); - else - Skin_AddIcon(&sid); - } - } - - sid.pszSection = LPGEN("Message Sessions")"/"LPGEN("Default"); - sid.pszName = "tabSRMM_clock_symbol"; - sid.pszDescription = LPGEN("Clock symbol (for the info panel clock)"); - sid.iDefaultIndex = -IDI_CLOCK; - Skin_AddIcon(&sid); - - _tcsncpy(szFilename, _T("plugins\\tabsrmm.dll"), MAX_PATH); - - sid.pszName = "tabSRMM_overlay_disabled"; - sid.pszDescription = LPGEN("Feature disabled (used as overlay)"); - sid.iDefaultIndex = -IDI_FEATURE_DISABLED; - Skin_AddIcon(&sid); - - sid.pszName = "tabSRMM_overlay_enabled"; - sid.pszDescription = LPGEN("Feature enabled (used as overlay)"); - sid.iDefaultIndex = -IDI_FEATURE_ENABLED; - Skin_AddIcon(&sid); - return 1; -} - -// load the icon theme from IconLib - check if it exists... - -static int TSAPI LoadFromIconLib() -{ - for (int n = 0; n < SIZEOF(ICONBLOCKS); n++) - for (int i = 0; i < ICONBLOCKS[n].nItems; i++) - *(ICONBLOCKS[n].idesc[i].phIcon) = Skin_GetIcon(ICONBLOCKS[n].idesc[i].szName); - - PluginConfig.g_buttonBarIcons[0] = LoadSkinnedIcon(SKINICON_OTHER_ADDCONTACT); - PluginConfig.g_buttonBarIcons[1] = LoadSkinnedIcon(SKINICON_OTHER_HISTORY); - PluginConfig.g_buttonBarIconHandles[0] = LoadSkinnedIconHandle(SKINICON_OTHER_HISTORY); - PluginConfig.g_buttonBarIconHandles[1] = LoadSkinnedIconHandle(SKINICON_OTHER_ADDCONTACT); - PluginConfig.g_buttonBarIconHandles[20] = LoadSkinnedIconHandle(SKINICON_OTHER_USERDETAILS); - - PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING] = - PluginConfig.g_buttonBarIcons[12] = LoadSkinnedIcon(SKINICON_OTHER_TYPING); - PluginConfig.g_IconChecked = LoadSkinnedIcon(SKINICON_OTHER_TICK); - PluginConfig.g_IconUnchecked = LoadSkinnedIcon(SKINICON_OTHER_NOTICK); - PluginConfig.g_IconGroupOpen = LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN); - PluginConfig.g_IconGroupClose = LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT); - - PluginConfig.g_iconOverlayEnabled = Skin_GetIcon("tabSRMM_overlay_enabled"); - PluginConfig.g_iconOverlayDisabled = Skin_GetIcon("tabSRMM_overlay_disabled"); - - PluginConfig.g_iconClock = Skin_GetIcon("tabSRMM_clock_symbol"); - - CacheMsgLogIcons(); - M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// load icon theme from either icon pack or IcoLib - -void TSAPI LoadIconTheme() -{ - if (SetupIconLibConfig() == 0) - return; - else - LoadFromIconLib(); - - Skin->setupTabCloseBitmap(); -} - -static void UnloadIcons() -{ - for (int n = 0; n < SIZEOF(ICONBLOCKS); n++) - for (int i = 0; i < ICONBLOCKS[n].nItems; i++) - if (*(ICONBLOCKS[n].idesc[i].phIcon) != 0) { - DestroyIcon(*(ICONBLOCKS[n].idesc[i].phIcon)); - *(ICONBLOCKS[n].idesc[i].phIcon) = 0; - } - - if (PluginConfig.g_hbmUnknown) - DeleteObject(PluginConfig.g_hbmUnknown); - - for (int i = 0; i < 4; i++) - if (PluginConfig.m_AnimTrayIcons[i]) - DestroyIcon(PluginConfig.m_AnimTrayIcons[i]); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int IcoLibIconsChanged(WPARAM, LPARAM) -{ - LoadFromIconLib(); - CacheMsgLogIcons(); - return 0; -} - -int IconsChanged(WPARAM, LPARAM) -{ - CreateImageList(FALSE); - CacheMsgLogIcons(); - M.BroadcastMessage(DM_OPTIONSAPPLIED, 0, 0); - M.BroadcastMessage(DM_UPDATEWINICON, 0, 0); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// initialises the internal API, services, events etc... - -static void TSAPI InitAPI() -{ - CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand); - CreateServiceFunction(MS_MSG_SENDMESSAGE "W", SendMessageCommand_W); - CreateServiceFunction(MS_MSG_GETWINDOWAPI, GetWindowAPI); - CreateServiceFunction(MS_MSG_GETWINDOWCLASS, GetWindowClass); - CreateServiceFunction(MS_MSG_GETWINDOWDATA, GetWindowData); - CreateServiceFunction(MS_MSG_SETSTATUSTEXT, SetStatusText); - - CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand); - CreateServiceFunction("SRMsg/TypingMessage", TypingMessageCommand); - CreateServiceFunction(MS_TABMSG_SETUSERPREFS, SetUserPrefs); - CreateServiceFunction(MS_TABMSG_TRAYSUPPORT, Service_OpenTrayMenu); - CreateServiceFunction(MS_TABMSG_SLQMGR, CSendLater::svcQMgr); - - CreateServiceFunction(MS_MSG_MOD_GETWINDOWFLAGS, GetMessageWindowFlags); - CreateServiceFunction(MS_MSG_MOD_MESSAGEDIALOGOPENED, MessageWindowOpened); - - SI_InitStatusIcons(); - CB_InitCustomButtons(); - - // the event API - PluginConfig.m_event_MsgWin = CreateHookableEvent(ME_MSG_WINDOWEVENT); - PluginConfig.m_event_MsgPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP); - PluginConfig.m_event_WriteEvent = CreateHookableEvent(ME_MSG_PRECREATEEVENT); -} - -int LoadSendRecvMessageModule(void) -{ - if (FIF == 0) { - MessageBox(0, TranslateT("The image service plugin (advaimg.dll) is not properly installed.\n\nTabSRMM is disabled."), TranslateT("TabSRMM fatal error"), MB_OK | MB_ICONERROR); - return 1; - } - - INITCOMMONCONTROLSEX icex; - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES; - InitCommonControlsEx(&icex); - - Utils::loadSystemLibrary(L"\\Msftedit.dll"); - - Win7Taskbar = new CTaskbarInteract; - Win7Taskbar->updateMetrics(); - - memset(&nen_options, 0, sizeof(nen_options)); - M.m_hMessageWindowList = WindowList_Create(); - PluginConfig.hUserPrefsWindowList = WindowList_Create(); - sendQueue = new SendQueue; - Skin = new CSkin; - sendLater = new CSendLater; - - InitOptions(); - - InitAPI(); - - PluginConfig.reloadSystemStartup(); - ReloadTabConfig(); - NEN_ReadOptions(&nen_options); - - db_set_b(0, TEMPLATES_MODULE, "setup", 2); - LoadDefaultTemplates(); - - BuildCodePageList(); - return 0; -} - +/////////////////////////////////////////////////////////////////////////////////////////
+// Miranda NG: the free IM client for Microsoft* Windows*
+//
+// Copyright (ñ) 2012-15 Miranda NG project,
+// Copyright (c) 2000-09 Miranda ICQ/IM project,
+// all portions of this codebase are copyrighted to the people
+// listed in contributors.txt.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// you should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// part of tabSRMM messaging plugin for Miranda.
+//
+// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
+//
+// Load, setup and shutdown the plugin
+// core plugin messaging services (single IM chats only).
+
+#include "commonheaders.h"
+
+#define IDI_CORE_LOAD 132 // icon id for the "connecting" icon
+
+NEN_OPTIONS nen_options;
+static HANDLE hUserPrefsWindowLis = 0;
+HMODULE g_hIconDLL = 0;
+
+static void UnloadIcons();
+
+void Chat_AddIcons(void);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// fired event when user changes IEView plugin options. Apply them to all open tabs
+
+int IEViewOptionsChanged(WPARAM, LPARAM)
+{
+ M.BroadcastMessage(DM_IEVIEWOPTIONSCHANGED, 0, 0);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// fired event when user changes smileyadd options. Notify all open tabs about the changes
+
+int SmileyAddOptionsChanged(WPARAM, LPARAM)
+{
+ M.BroadcastMessage(DM_SMILEYOPTIONSCHANGED, 0, 0);
+ pci->SM_BroadcastMessage(NULL, DM_SMILEYOPTIONSCHANGED, 0, 0, FALSE);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Message API 0.0.0.3 services
+
+static INT_PTR GetWindowClass(WPARAM wParam, LPARAM lParam)
+{
+ char *szBuf = (char*)wParam;
+ size_t size = (size_t)lParam;
+ mir_snprintf(szBuf, size, "tabSRMM");
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// wparam = (MessageWindowInputData*)
+// lparam = (MessageWindowData*)
+// returns 0 on success and returns non-zero (1) on error or if no window data exists for that hcontact
+
+static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam)
+{
+ MessageWindowInputData *mwid = (MessageWindowInputData*)wParam;
+ if (mwid == NULL || (mwid->cbSize != sizeof(MessageWindowInputData)) || (mwid->hContact == NULL) || (mwid->uFlags != MSG_WINDOW_UFLAG_MSG_BOTH))
+ return 1;
+
+ MessageWindowData *mwd = (MessageWindowData*)lParam;
+ if (mwd == NULL || (mwd->cbSize != sizeof(MessageWindowData)))
+ return 1;
+
+ HWND hwnd = M.FindWindow(mwid->hContact);
+ if (hwnd) {
+ mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+ mwd->hwndWindow = hwnd;
+ mwd->local = GetParent(GetParent(hwnd));
+ SendMessage(hwnd, DM_GETWINDOWSTATE, 0, 0);
+ mwd->uState = GetWindowLongPtr(hwnd, DWLP_MSGRESULT);
+ return 0;
+ }
+ else
+ {
+ SESSION_INFO *si = SM_FindSessionByHCONTACT(mwid->hContact);
+ if (si != NULL && si->hWnd != 0) {
+ mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+ mwd->hwndWindow = si->hWnd;
+ mwd->local = GetParent(GetParent(si->hWnd));
+ SendMessage(si->hWnd, DM_GETWINDOWSTATE, 0, 0);
+ mwd->uState = GetWindowLongPtr(si->hWnd, DWLP_MSGRESULT);
+ return 0;
+ }
+ else {
+ mwd->uState = 0;
+ mwd->hContact = 0;
+ mwd->hwndWindow = 0;
+ mwd->uFlags = 0;
+ }
+ }
+ return 1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// service function. Sets a status bar text for a contact
+
+static void SetStatusTextWorker(TWindowData *dat, StatusTextData *st)
+{
+ if (!dat)
+ return;
+
+ // delete old custom data
+ if (dat->sbCustom) {
+ delete dat->sbCustom;
+ dat->sbCustom = NULL;
+ }
+
+ if (st != NULL && st->cbSize == sizeof(StatusTextData))
+ dat->sbCustom = new StatusTextData(*st);
+
+ UpdateStatusBar(dat);
+}
+
+static INT_PTR SetStatusText(WPARAM hContact, LPARAM lParam)
+{
+ SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact);
+ if (si == NULL) {
+ HWND hwnd = M.FindWindow(hContact);
+ if (hwnd != NULL)
+ SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam);
+
+ if (hContact = db_mc_getMeta(hContact))
+ if (hwnd = M.FindWindow(hContact))
+ SetStatusTextWorker((TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA), (StatusTextData*)lParam);
+ }
+ else SetStatusTextWorker(si->dat, (StatusTextData*)lParam);
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// service function. Invoke the user preferences dialog for the contact given (by handle) in wParam
+
+static INT_PTR SetUserPrefs(WPARAM wParam, LPARAM)
+{
+ HWND hWnd = WindowList_Find(PluginConfig.hUserPrefsWindowList, wParam);
+ if (hWnd) {
+ SetForegroundWindow(hWnd); // already open, bring it to front
+ return 0;
+ }
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_USERPREFS_FRAME), 0, DlgProcUserPrefsFrame, (LPARAM)wParam);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// service function - open the tray menu from the TTB button
+
+static INT_PTR Service_OpenTrayMenu(WPARAM, LPARAM lParam)
+{
+ SendMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, lParam == 0 ? WM_LBUTTONUP : WM_RBUTTONUP);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// service function. retrieves the message window flags for a given hcontact or window
+// wParam == hContact of the window to find
+// lParam == window handle (set it to 0 if you want search for hcontact, otherwise it
+// is directly used as the handle for the target window
+
+static INT_PTR GetMessageWindowFlags(WPARAM wParam, LPARAM lParam)
+{
+ HWND hwndTarget = (HWND)lParam;
+ if (hwndTarget == 0)
+ hwndTarget = M.FindWindow(wParam);
+
+ if (hwndTarget == 0)
+ return 0;
+
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndTarget, GWLP_USERDATA);
+ return (dat) ? dat->dwFlags : 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// return the version of the window api supported
+
+static INT_PTR GetWindowAPI(WPARAM, LPARAM)
+{
+ return PLUGIN_MAKE_VERSION(0, 0, 0, 2);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// service function finds a message session
+// wParam = contact handle for which we want the window handle
+// thanks to bio for the suggestion of this service
+// if wParam == 0, then lParam is considered to be a valid window handle and
+// the function tests the popup mode of the target container
+
+// returns the hwnd if there is an open window or tab for the given hcontact (wParam),
+// or (if lParam was specified) the hwnd if the window exists.
+// 0 if there is none (or the popup mode of the target container was configured to "hide"
+// the window..
+
+INT_PTR MessageWindowOpened(WPARAM wParam, LPARAM lParam)
+{
+ HWND hwnd = 0;
+ TContainerData *pContainer = NULL;
+
+ if (wParam)
+ hwnd = M.FindWindow(wParam);
+ else if (lParam)
+ hwnd = (HWND)lParam;
+ else
+ return NULL;
+
+ if (!hwnd)
+ return 0;
+
+ SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
+ if (pContainer) {
+ if (pContainer->dwFlags & CNT_DONTREPORT) {
+ if (IsIconic(pContainer->hwnd))
+ return 0;
+ }
+ if (pContainer->dwFlags & CNT_DONTREPORTUNFOCUSED) {
+ if (!IsIconic(pContainer->hwnd) && GetForegroundWindow() != pContainer->hwnd && GetActiveWindow() != pContainer->hwnd)
+ return 0;
+ }
+ if (pContainer->dwFlags & CNT_ALWAYSREPORTINACTIVE) {
+ if (pContainer->dwFlags & CNT_DONTREPORTFOCUSED)
+ return 0;
+
+ return pContainer->hwndActive == hwnd;
+ }
+ }
+ return 1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// ReadMessageCommand is executed whenever the user wants to manually open a window.
+// This can happen when double clicking a contact on the clist OR when opening a new
+// message (clicking on a popup, clicking the flashing tray icon and so on).
+
+static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)
+{
+ MCONTACT hContact = ((CLISTEVENT *)lParam)->hContact;
+
+ HWND hwndExisting = M.FindWindow(hContact);
+ if (hwndExisting != 0)
+ SendMessage(hwndExisting, DM_ACTIVATEME, 0, 0);
+ else {
+ TCHAR szName[CONTAINER_NAMELEN + 1];
+ GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN);
+ TContainerData *pContainer = FindContainerByName(szName);
+ if (pContainer == NULL)
+ pContainer = CreateContainer(szName, FALSE, hContact);
+ if (pContainer)
+ CreateNewTabForContact(pContainer, hContact, 0, NULL, TRUE, TRUE, FALSE, 0);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// the SendMessageCommand() invokes a message session window for the given contact.
+// e.g. it is called when user double clicks a contact on the contact list
+// it is implemented as a service, so external plugins can use it to open a message window.
+// contacts handle must be passed in wParam.
+
+INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar)
+{
+ // make sure that only the main UI thread will handle window creation
+ if (GetCurrentThreadId() != PluginConfig.dwThreadID) {
+ if (pszMsg) {
+ wchar_t *tszText = (isWchar) ? mir_wstrdup((WCHAR*)pszMsg) : mir_a2u(pszMsg);
+ PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, (LPARAM)tszText);
+ }
+ else PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, 0);
+ return 0;
+ }
+
+ // does the MCONTACT's protocol support IM messages?
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL)
+ return 0; // unknown contact
+ if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
+ return 0;
+
+ HWND hwnd = M.FindWindow(hContact);
+ if (hwnd) {
+ if (pszMsg) {
+ HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
+ SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit));
+ if (isWchar)
+ SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
+ else
+ SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
+ }
+ SendMessage(hwnd, DM_ACTIVATEME, 0, 0);
+ }
+ else {
+ TCHAR szName[CONTAINER_NAMELEN + 1];
+ GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN);
+
+ TContainerData *pContainer = FindContainerByName(szName);
+ if (pContainer == NULL)
+ pContainer = CreateContainer(szName, FALSE, hContact);
+ if (pContainer)
+ CreateNewTabForContact(pContainer, hContact, isWchar, pszMsg, TRUE, TRUE, FALSE, 0);
+ }
+ return 0;
+}
+
+INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam)
+{
+ return SendMessageCommand_Worker(hContact, LPCSTR(lParam), false);
+}
+
+INT_PTR SendMessageCommand_W(WPARAM hContact, LPARAM lParam)
+{
+ return SendMessageCommand_Worker(hContact, LPCSTR(lParam), true);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// open a window when user clicks on the flashing "typing message" tray icon.
+// just calls SendMessageCommand() for the given contact.
+
+static INT_PTR TypingMessageCommand(WPARAM, LPARAM lParam)
+{
+ CLISTEVENT *cle = (CLISTEVENT*)lParam;
+ if (cle)
+ SendMessageCommand((WPARAM)cle->hContact, 0);
+ return 0;
+}
+
+int SplitmsgShutdown(void)
+{
+ WindowList_Destroy(M.m_hMessageWindowList);
+ WindowList_Destroy(PluginConfig.hUserPrefsWindowList);
+
+ DestroyCursor(PluginConfig.hCurSplitNS);
+ DestroyCursor(PluginConfig.hCurHyperlinkHand);
+ DestroyCursor(PluginConfig.hCurSplitWE);
+
+ FreeLibrary(GetModuleHandleA("Msftedit.dll"));
+
+ if (g_hIconDLL) {
+ FreeLibrary(g_hIconDLL);
+ g_hIconDLL = NULL;
+ }
+
+ ImageList_RemoveAll(PluginConfig.g_hImageList);
+ ImageList_Destroy(PluginConfig.g_hImageList);
+
+ delete Win7Taskbar;
+
+ DestroyMenu(PluginConfig.g_hMenuContext);
+ if (PluginConfig.g_hMenuContainer)
+ DestroyMenu(PluginConfig.g_hMenuContainer);
+ if (PluginConfig.g_hMenuEncoding)
+ DestroyMenu(PluginConfig.g_hMenuEncoding);
+
+ UnloadIcons();
+ FreeTabConfig();
+
+ if (Utils::rtf_ctable)
+ mir_free(Utils::rtf_ctable);
+
+ UnloadTSButtonModule();
+ return 0;
+}
+
+int MyAvatarChanged(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam == 0 || IsBadReadPtr((void*)wParam, 4))
+ return 0;
+
+ for (TContainerData *p = pFirstContainer; p; p = p->pNext)
+ BroadCastContainer(p, DM_MYAVATARCHANGED, wParam, lParam);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// tabbed mode support functions...
+// (C) by Nightwish
+//
+// this function searches and activates the tab belonging to the given hwnd (which is the
+// hwnd of a message dialog window)
+
+int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild)
+{
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndChild, GWLP_USERDATA); // needed to obtain the hContact for the message window
+ if (!dat || !pContainer)
+ return FALSE;
+
+ NMHDR nmhdr = { 0 };
+ nmhdr.code = TCN_SELCHANGE;
+ if (TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)) > 1 && !(pContainer->dwFlags & CNT_DEFERREDTABSELECT)) {
+ TabCtrl_SetCurSel(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), GetTabIndexFromHWND(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), hwndChild));
+ SendMessage(pContainer->hwnd, WM_NOTIFY, 0, (LPARAM)&nmhdr); // just select the tab and let WM_NOTIFY do the rest
+ }
+ if (dat->bType == SESSIONTYPE_IM)
+ SendMessage(pContainer->hwnd, DM_UPDATETITLE, dat->hContact, 0);
+ if (IsIconic(pContainer->hwnd)) {
+ SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ SetForegroundWindow(pContainer->hwnd);
+ }
+
+ // hide on close feature
+ if (!IsWindowVisible(pContainer->hwnd)) {
+ WINDOWPLACEMENT wp = { 0 };
+ wp.length = sizeof(wp);
+ GetWindowPlacement(pContainer->hwnd, &wp);
+
+ // all tabs must re-check the layout on activation because adding a tab while
+ // the container was hidden can make this necessary
+ BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0);
+ if (wp.showCmd == SW_SHOWMAXIMIZED)
+ ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED);
+ else {
+ ShowWindow(pContainer->hwnd, SW_SHOWNA);
+ SetForegroundWindow(pContainer->hwnd);
+ }
+ SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); // make sure the active tab resizes its layout properly
+ }
+ else if (GetForegroundWindow() != pContainer->hwnd)
+ SetForegroundWindow(pContainer->hwnd);
+
+ if (dat->bType == SESSIONTYPE_IM)
+ SetFocus(GetDlgItem(hwndChild, IDC_MESSAGE));
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// this function creates and activates a new tab within the given container.
+// bActivateTab: make the new tab the active one
+// bPopupContainer: restore container if it was minimized, otherwise flash it...
+
+HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, int isSend, const char *pszInitialText, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup, MEVENT hdbEvent)
+{
+ if (M.FindWindow(hContact) != 0) {
+ _DebugPopup(hContact, _T("Warning: trying to create duplicate window"));
+ return 0;
+ }
+
+ // if we have a max # of tabs/container set and want to open something in the default container...
+ if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) {
+ if ((pContainer = FindMatchingContainer(_T("default"))) == NULL) {
+ TCHAR szName[CONTAINER_NAMELEN + 1];
+ mir_sntprintf(szName, SIZEOF(szName), _T("default"));
+ if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact)) == NULL)
+ return 0;
+ }
+ }
+
+ TNewWindowData newData = { 0 };
+ newData.hContact = hContact;
+ newData.isWchar = isSend;
+ newData.szInitialText = pszInitialText;
+ char *szProto = GetContactProto(newData.hContact);
+
+ memset(&newData.item, 0, sizeof(newData.item));
+
+ // obtain various status information about the contact
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(newData.hContact, 0);
+
+ // cut nickname if larger than x chars...
+ TCHAR newcontactname[128], tabtitle[128];
+ if (contactName && mir_tstrlen(contactName) > 0) {
+ if (M.GetByte("cuttitle", 0))
+ CutContactName(contactName, newcontactname, SIZEOF(newcontactname));
+ else
+ _tcsncpy_s(newcontactname, contactName, _TRUNCATE);
+
+ Utils::DoubleAmpersands(newcontactname);
+ }
+ else _tcsncpy_s(newcontactname, _T("_U_"), _TRUNCATE);
+
+ TCHAR *szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0);
+
+ if (M.GetByte("tabstatus", 1))
+ mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s (%s) "), newcontactname, szStatus);
+ else
+ mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s "), newcontactname);
+
+ newData.item.pszText = tabtitle;
+ newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
+ newData.item.iImage = 0;
+ newData.item.cchTextMax = SIZEOF(tabtitle);
+
+ HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS);
+ // hide the active tab
+ if (pContainer->hwndActive && bActivateTab)
+ ShowWindow(pContainer->hwndActive, SW_HIDE);
+
+ int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->iChilds * 100);
+ int iCount = TabCtrl_GetItemCount(hwndTab);
+ TCITEM item = { 0 };
+
+ pContainer->iTabIndex = iCount;
+ if (iCount > 0) {
+ for (int i = iCount - 1; i >= 0; i--) {
+ item.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwndTab, i, &item);
+ HWND hwnd = (HWND)item.lParam;
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (dat) {
+ int relPos = M.GetDword(dat->hContact, "tabindex", i * 100);
+ if (iTabIndex_wanted <= relPos)
+ pContainer->iTabIndex = i;
+ }
+ }
+ }
+
+ int newItem = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &newData.item);
+ SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0);
+ if (bActivateTab)
+ TabCtrl_SetCurSel(hwndTab, newItem);
+ newData.iTabID = newItem;
+ newData.iTabImage = newData.item.iImage;
+ newData.pContainer = pContainer;
+ newData.iActivate = (int)bActivateTab;
+ pContainer->iChilds++;
+ newData.bWantPopup = bWantPopup;
+ newData.hdbEvent = hdbEvent;
+ HWND hwndNew = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSPLITNEW), hwndTab, DlgProcMessage, (LPARAM)&newData);
+
+ // switchbar support
+ if (pContainer->dwFlags & CNT_SIDEBAR) {
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndNew, GWLP_USERDATA);
+ if (dat)
+ pContainer->SideBar->addSession(dat, pContainer->iTabIndex);
+ }
+ SendMessage(pContainer->hwnd, WM_SIZE, 0, 0);
+
+ // if the container is minimized, then pop it up...
+ if (IsIconic(pContainer->hwnd)) {
+ if (bPopupContainer) {
+ SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ SetFocus(pContainer->hwndActive);
+ }
+ else {
+ if (pContainer->dwFlags & CNT_NOFLASH)
+ SendMessage(pContainer->hwnd, DM_SETICON, 0, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
+ else
+ FlashContainer(pContainer, 1, 0);
+ }
+ }
+
+ if (bActivateTab) {
+ ActivateExistingTab(pContainer, hwndNew);
+ SetFocus(hwndNew);
+ RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASENOW);
+ UpdateWindow(pContainer->hwnd);
+ if (GetForegroundWindow() != pContainer->hwnd && bPopupContainer == TRUE)
+ SetForegroundWindow(pContainer->hwnd);
+ }
+ else if (!IsIconic(pContainer->hwnd) && IsWindowVisible(pContainer->hwnd)) {
+ SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0);
+ RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW);
+ RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_ERASENOW | RDW_UPDATENOW);
+ }
+
+ if (PluginConfig.m_bHideOnClose&&!IsWindowVisible(pContainer->hwnd)) {
+ WINDOWPLACEMENT wp = { 0 };
+ wp.length = sizeof(wp);
+ GetWindowPlacement(pContainer->hwnd, &wp);
+
+ BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation
+ if (wp.showCmd == SW_SHOWMAXIMIZED)
+ ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED);
+ else {
+ if (bPopupContainer)
+ ShowWindow(pContainer->hwnd, SW_SHOWNORMAL);
+ else
+ ShowWindow(pContainer->hwnd, SW_SHOWMINNOACTIVE);
+ }
+ SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0);
+ }
+
+ if (PluginConfig.m_bIsWin7 && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled)
+ CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING | MB_OK);
+
+ if (ServiceExists(MS_HPP_EG_EVENT) && ServiceExists(MS_IEVIEW_EVENT) && db_get_b(0, "HistoryPlusPlus", "IEViewAPI", 0))
+ if (IDYES == CWarning::show(CWarning::WARN_HPP_APICHECK, MB_ICONWARNING | MB_YESNO))
+ db_set_b(0, "HistoryPlusPlus", "IEViewAPI", 0);
+
+ return hwndNew; // return handle of the new dialog
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// this is used by the 2nd containermode (limit tabs on default containers).
+// it searches a container with "room" for the new tabs or otherwise creates
+// a new (cloned) one.
+
+TContainerData* TSAPI FindMatchingContainer(const TCHAR *szName)
+{
+ int iMaxTabs = M.GetDword("maxtabs", 0);
+ if (iMaxTabs > 0 && M.GetByte("limittabs", 0) && !_tcsncmp(szName, _T("default"), 6)) {
+ // search a "default" with less than iMaxTabs opened...
+ for (TContainerData *p = pFirstContainer; p; p = p->pNext)
+ if (!_tcsncmp(p->szName, _T("default"), 6) && p->iChilds < iMaxTabs)
+ return p;
+
+ return NULL;
+ }
+ return FindContainerByName(szName);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// load some global icons.
+
+void TSAPI CreateImageList(BOOL bInitial)
+{
+ // the imagelist is now a fake. It is still needed to provide the tab control with a
+ // image list handle. This will make sure that the tab control will reserve space for
+ // an icon on each tab. This is a blank and empty icon
+ if (bInitial) {
+ PluginConfig.g_hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0);
+ HICON hIcon = CreateIcon(g_hInst, 16, 16, 1, 4, NULL, NULL);
+ ImageList_AddIcon(PluginConfig.g_hImageList, hIcon);
+ DestroyIcon(hIcon);
+ }
+
+ PluginConfig.g_IconFileEvent = LoadSkinnedIcon(SKINICON_EVENT_FILE);
+ PluginConfig.g_IconMsgEvent = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
+ PluginConfig.g_IconMsgEventBig = LoadSkinnedIconBig(SKINICON_EVENT_MESSAGE);
+ if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconMsgEventBig)
+ PluginConfig.g_IconMsgEventBig = 0;
+ PluginConfig.g_IconTypingEventBig = LoadSkinnedIconBig(SKINICON_OTHER_TYPING);
+ if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconTypingEventBig)
+ PluginConfig.g_IconTypingEventBig = 0;
+ PluginConfig.g_IconSend = PluginConfig.g_buttonBarIcons[9];
+ PluginConfig.g_IconTypingEvent = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING];
+}
+
+int TABSRMM_FireEvent(MCONTACT hContact, HWND hwnd, unsigned int type, unsigned int subType)
+{
+ if (hContact == NULL || hwnd == NULL)
+ return 0;
+
+ TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (dat == NULL)
+ return 0;
+ BYTE bType = dat->bType;
+
+ MessageWindowEventData mwe = { sizeof(mwe) };
+ mwe.hContact = hContact;
+ mwe.hwndWindow = hwnd;
+ mwe.szModule = "tabSRMsgW";
+ mwe.uType = type;
+ if (bType == SESSIONTYPE_IM) {
+ mwe.hwndInput = GetDlgItem(hwnd, IDC_MESSAGE);
+ mwe.hwndLog = GetDlgItem(hwnd, IDC_LOG);
+ }
+ else {
+ mwe.hwndInput = GetDlgItem(hwnd, IDC_CHAT_MESSAGE);
+ mwe.hwndLog = GetDlgItem(hwnd, IDC_CHAT_LOG);
+ }
+
+ if (type == MSG_WINDOW_EVT_CUSTOM) {
+ TABSRMM_SessionInfo se = { sizeof(se) };
+ se.evtCode = HIWORD(subType);
+ se.hwnd = hwnd;
+ se.extraFlags = (unsigned int)(LOWORD(subType));
+ se.local = dat->sendBuffer;
+ mwe.local = &se;
+ }
+
+ return NotifyEventHooks(PluginConfig.m_event_MsgWin, 0, (LPARAM)&mwe);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// standard icon definitions
+
+static TIconDesc _toolbaricons[] =
+{
+ { "tabSRMM_mlog", LPGEN("Message Log Options"), &PluginConfig.g_buttonBarIcons[2], -IDI_MSGLOGOPT, 1 },
+ { "tabSRMM_multi", LPGEN("Image tag"), &PluginConfig.g_buttonBarIcons[3], -IDI_IMAGETAG, 1 },
+ { "tabSRMM_quote", LPGEN("Quote text"), &PluginConfig.g_buttonBarIcons[8], -IDI_QUOTE, 1 },
+ { "tabSRMM_save", LPGEN("Save and close"), &PluginConfig.g_buttonBarIcons[7], -IDI_SAVE, 1 },
+ { "tabSRMM_send", LPGEN("Send message"), &PluginConfig.g_buttonBarIcons[9], -IDI_SEND, 1 },
+ { "tabSRMM_avatar", LPGEN("Edit user notes"), &PluginConfig.g_buttonBarIcons[10], -IDI_CONTACTPIC, 1 },
+ { "tabSRMM_close", LPGEN("Close"), &PluginConfig.g_buttonBarIcons[6], -IDI_CLOSEMSGDLG, 1 }
+};
+
+static TIconDesc _exttoolbaricons[] =
+{
+ { "tabSRMM_emoticon", LPGEN("Smiley button"), &PluginConfig.g_buttonBarIcons[11], -IDI_SMILEYICON, 1 },
+ { "tabSRMM_bold", LPGEN("Format bold"), &PluginConfig.g_buttonBarIcons[17], -IDI_FONTBOLD, 1 },
+ { "tabSRMM_italic", LPGEN("Format italic"), &PluginConfig.g_buttonBarIcons[18], -IDI_FONTITALIC, 1 },
+ { "tabSRMM_underline", LPGEN("Format underline"), &PluginConfig.g_buttonBarIcons[19], -IDI_FONTUNDERLINE, 1 },
+ { "tabSRMM_face", LPGEN("Font face"), &PluginConfig.g_buttonBarIcons[20], -IDI_FONTFACE, 1 },
+ { "tabSRMM_color", LPGEN("Font color"), &PluginConfig.g_buttonBarIcons[21], -IDI_FONTCOLOR, 1 },
+ { "tabSRMM_strikeout", LPGEN("Format strike-through"), &PluginConfig.g_buttonBarIcons[30], -IDI_STRIKEOUT, 1 }
+};
+
+static TIconDesc _chattoolbaricons[] =
+{
+ { "chat_bkgcol", LPGEN("Background color"), &PluginConfig.g_buttonBarIcons[31], -IDI_BKGCOLOR, 1 },
+ { "chat_settings", LPGEN("Room settings"), &PluginConfig.g_buttonBarIcons[32], -IDI_TOPICBUT, 1 },
+ { "chat_filter", LPGEN("Event filter"), &PluginConfig.g_buttonBarIcons[33], -IDI_FILTER2, 1 },
+ { "chat_shownicklist", LPGEN("Nick list"), &PluginConfig.g_buttonBarIcons[35], -IDI_SHOWNICKLIST, 1 }
+};
+
+static TIconDesc _logicons[] =
+{
+ { "tabSRMM_error", LPGEN("Message delivery error"), &PluginConfig.g_iconErr, -IDI_MSGERROR, 1 },
+ { "tabSRMM_in", LPGEN("Incoming message"), &PluginConfig.g_iconIn, -IDI_ICONIN, 0 },
+ { "tabSRMM_out", LPGEN("Outgoing message"), &PluginConfig.g_iconOut, -IDI_ICONOUT, 0 },
+ { "tabSRMM_status", LPGEN("Status change"), &PluginConfig.g_iconStatus, -IDI_STATUSCHANGE, 0 }
+};
+
+static TIconDesc _deficons[] =
+{
+ { "tabSRMM_container", LPGEN("Static container icon"), &PluginConfig.g_iconContainer, -IDI_CONTAINER, 1 },
+ { "tabSRMM_sounds_on", LPGEN("Sounds (status bar)"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_SOUNDS], -IDI_SOUNDSON, 1 },
+ { "tabSRMM_pulldown", LPGEN("Pulldown Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_PULLDOWN], -IDI_PULLDOWNARROW, 1 },
+ { "tabSRMM_Leftarrow", LPGEN("Left Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_LEFT], -IDI_LEFTARROW, 1 },
+ { "tabSRMM_Rightarrow", LPGEN("Right Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_RIGHT], -IDI_RIGHTARROW, 1 },
+ { "tabSRMM_Pulluparrow", LPGEN("Up Arrow"), &PluginConfig.g_buttonBarIcons[ICON_DEFAULT_UP], -IDI_PULLUPARROW, 1 },
+ { "tabSRMM_sb_slist", LPGEN("Session List"), &PluginConfig.g_sideBarIcons[0], -IDI_SESSIONLIST, 1 },
+};
+
+static TIconDesc _trayIcon[] =
+{
+ { "tabSRMM_frame1", LPGEN("Frame 1"), &PluginConfig.m_AnimTrayIcons[0], -IDI_TRAYANIM1, 1 },
+ { "tabSRMM_frame2", LPGEN("Frame 2"), &PluginConfig.m_AnimTrayIcons[1], -IDI_TRAYANIM2, 1 },
+ { "tabSRMM_frame3", LPGEN("Frame 3"), &PluginConfig.m_AnimTrayIcons[2], -IDI_TRAYANIM3, 1 },
+ { "tabSRMM_frame4", LPGEN("Frame 4"), &PluginConfig.m_AnimTrayIcons[3], -IDI_TRAYANIM4, 1 },
+};
+
+struct {
+ char *szSection;
+ TIconDesc *idesc;
+ int nItems;
+}
+static ICONBLOCKS[] = {
+ { LPGEN("Message Sessions")"/"LPGEN("Default"), _deficons, SIZEOF(_deficons) },
+ { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _toolbaricons, SIZEOF(_toolbaricons) },
+ { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _exttoolbaricons, SIZEOF(_exttoolbaricons) },
+ { LPGEN("Message Sessions")"/"LPGEN("Toolbar"), _chattoolbaricons, SIZEOF(_chattoolbaricons) },
+ { LPGEN("Message Sessions")"/"LPGEN("Message Log"), _logicons, SIZEOF(_logicons) },
+ { LPGEN("Message Sessions")"/"LPGEN("Animated Tray"), _trayIcon, SIZEOF(_trayIcon) }
+};
+
+static int GetIconPackVersion(HMODULE hDLL)
+{
+ char szIDString[256];
+ int version = 0;
+
+ if (LoadStringA(hDLL, IDS_IDENTIFY, szIDString, sizeof(szIDString)) == 0)
+ version = 0;
+ else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 1.0__"))
+ version = 1;
+ else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 2.0__"))
+ version = 2;
+ else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 3.0__"))
+ version = 3;
+ else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 3.5__"))
+ version = 4;
+ else if (!strcmp(szIDString, "__tabSRMM_ICONPACK 5.0__"))
+ version = 5;
+
+ if (version < 5)
+ CWarning::show(CWarning::WARN_ICONPACK_VERSION, MB_OK | MB_ICONERROR);
+ return version;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// setup default icons for the IcoLib service. This needs to be done every time the
+// plugin is loaded default icons are taken from the icon pack in either \icons or \plugins
+
+static int TSAPI SetupIconLibConfig()
+{
+ int j = 2, version = 0;
+
+ TCHAR szFilename[MAX_PATH];
+ _tcsncpy(szFilename, _T("icons\\tabsrmm_icons.dll"), MAX_PATH);
+ g_hIconDLL = LoadLibrary(szFilename);
+ if (g_hIconDLL == 0) {
+ CWarning::show(CWarning::WARN_ICONPACKMISSING, CWarning::CWF_NOALLOWHIDE | MB_ICONERROR | MB_OK);
+ return 0;
+ }
+
+ GetModuleFileName(g_hIconDLL, szFilename, MAX_PATH);
+ Chat_AddIcons();
+ version = GetIconPackVersion(g_hIconDLL);
+ FreeLibrary(g_hIconDLL);
+ g_hIconDLL = 0;
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.ptszDefaultFile = szFilename;
+ sid.flags = SIDF_PATH_TCHAR;
+
+ for (int n = 0; n < SIZEOF(ICONBLOCKS); n++) {
+ sid.pszSection = ICONBLOCKS[n].szSection;
+ for (int i = 0; i < ICONBLOCKS[n].nItems; i++) {
+ sid.pszName = ICONBLOCKS[n].idesc[i].szName;
+ sid.pszDescription = ICONBLOCKS[n].idesc[i].szDesc;
+ sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem)
+
+ if (n > 0 && n < 4)
+ PluginConfig.g_buttonBarIconHandles[j++] = Skin_AddIcon(&sid);
+ else
+ Skin_AddIcon(&sid);
+ }
+ }
+
+ sid.pszSection = LPGEN("Message Sessions")"/"LPGEN("Default");
+ sid.pszName = "tabSRMM_clock_symbol";
+ sid.pszDescription = LPGEN("Clock symbol (for the info panel clock)");
+ sid.iDefaultIndex = -IDI_CLOCK;
+ Skin_AddIcon(&sid);
+
+ _tcsncpy(szFilename, _T("plugins\\tabsrmm.dll"), MAX_PATH);
+
+ sid.pszName = "tabSRMM_overlay_disabled";
+ sid.pszDescription = LPGEN("Feature disabled (used as overlay)");
+ sid.iDefaultIndex = -IDI_FEATURE_DISABLED;
+ Skin_AddIcon(&sid);
+
+ sid.pszName = "tabSRMM_overlay_enabled";
+ sid.pszDescription = LPGEN("Feature enabled (used as overlay)");
+ sid.iDefaultIndex = -IDI_FEATURE_ENABLED;
+ Skin_AddIcon(&sid);
+ return 1;
+}
+
+// load the icon theme from IconLib - check if it exists...
+
+static int TSAPI LoadFromIconLib()
+{
+ for (int n = 0; n < SIZEOF(ICONBLOCKS); n++)
+ for (int i = 0; i < ICONBLOCKS[n].nItems; i++)
+ *(ICONBLOCKS[n].idesc[i].phIcon) = Skin_GetIcon(ICONBLOCKS[n].idesc[i].szName);
+
+ PluginConfig.g_buttonBarIcons[0] = LoadSkinnedIcon(SKINICON_OTHER_ADDCONTACT);
+ PluginConfig.g_buttonBarIcons[1] = LoadSkinnedIcon(SKINICON_OTHER_HISTORY);
+ PluginConfig.g_buttonBarIconHandles[0] = LoadSkinnedIconHandle(SKINICON_OTHER_HISTORY);
+ PluginConfig.g_buttonBarIconHandles[1] = LoadSkinnedIconHandle(SKINICON_OTHER_ADDCONTACT);
+ PluginConfig.g_buttonBarIconHandles[20] = LoadSkinnedIconHandle(SKINICON_OTHER_USERDETAILS);
+
+ PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING] =
+ PluginConfig.g_buttonBarIcons[12] = LoadSkinnedIcon(SKINICON_OTHER_TYPING);
+ PluginConfig.g_IconChecked = LoadSkinnedIcon(SKINICON_OTHER_TICK);
+ PluginConfig.g_IconUnchecked = LoadSkinnedIcon(SKINICON_OTHER_NOTICK);
+ PluginConfig.g_IconGroupOpen = LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN);
+ PluginConfig.g_IconGroupClose = LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT);
+
+ PluginConfig.g_iconOverlayEnabled = Skin_GetIcon("tabSRMM_overlay_enabled");
+ PluginConfig.g_iconOverlayDisabled = Skin_GetIcon("tabSRMM_overlay_disabled");
+
+ PluginConfig.g_iconClock = Skin_GetIcon("tabSRMM_clock_symbol");
+
+ CacheMsgLogIcons();
+ M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// load icon theme from either icon pack or IcoLib
+
+void TSAPI LoadIconTheme()
+{
+ if (SetupIconLibConfig() == 0)
+ return;
+ else
+ LoadFromIconLib();
+
+ Skin->setupTabCloseBitmap();
+}
+
+static void UnloadIcons()
+{
+ for (int n = 0; n < SIZEOF(ICONBLOCKS); n++)
+ for (int i = 0; i < ICONBLOCKS[n].nItems; i++)
+ if (*(ICONBLOCKS[n].idesc[i].phIcon) != 0) {
+ DestroyIcon(*(ICONBLOCKS[n].idesc[i].phIcon));
+ *(ICONBLOCKS[n].idesc[i].phIcon) = 0;
+ }
+
+ if (PluginConfig.g_hbmUnknown)
+ DeleteObject(PluginConfig.g_hbmUnknown);
+
+ for (int i = 0; i < 4; i++)
+ if (PluginConfig.m_AnimTrayIcons[i])
+ DestroyIcon(PluginConfig.m_AnimTrayIcons[i]);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int IcoLibIconsChanged(WPARAM, LPARAM)
+{
+ LoadFromIconLib();
+ CacheMsgLogIcons();
+ return 0;
+}
+
+int IconsChanged(WPARAM, LPARAM)
+{
+ CreateImageList(FALSE);
+ CacheMsgLogIcons();
+ M.BroadcastMessage(DM_OPTIONSAPPLIED, 0, 0);
+ M.BroadcastMessage(DM_UPDATEWINICON, 0, 0);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// initialises the internal API, services, events etc...
+
+static void TSAPI InitAPI()
+{
+ CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
+ CreateServiceFunction(MS_MSG_SENDMESSAGE "W", SendMessageCommand_W);
+ CreateServiceFunction(MS_MSG_GETWINDOWAPI, GetWindowAPI);
+ CreateServiceFunction(MS_MSG_GETWINDOWCLASS, GetWindowClass);
+ CreateServiceFunction(MS_MSG_GETWINDOWDATA, GetWindowData);
+ CreateServiceFunction(MS_MSG_SETSTATUSTEXT, SetStatusText);
+
+ CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand);
+ CreateServiceFunction("SRMsg/TypingMessage", TypingMessageCommand);
+ CreateServiceFunction(MS_TABMSG_SETUSERPREFS, SetUserPrefs);
+ CreateServiceFunction(MS_TABMSG_TRAYSUPPORT, Service_OpenTrayMenu);
+ CreateServiceFunction(MS_TABMSG_SLQMGR, CSendLater::svcQMgr);
+
+ CreateServiceFunction(MS_MSG_MOD_GETWINDOWFLAGS, GetMessageWindowFlags);
+ CreateServiceFunction(MS_MSG_MOD_MESSAGEDIALOGOPENED, MessageWindowOpened);
+
+ SI_InitStatusIcons();
+ CB_InitCustomButtons();
+
+ // the event API
+ PluginConfig.m_event_MsgWin = CreateHookableEvent(ME_MSG_WINDOWEVENT);
+ PluginConfig.m_event_MsgPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
+ PluginConfig.m_event_WriteEvent = CreateHookableEvent(ME_MSG_PRECREATEEVENT);
+}
+
+int LoadSendRecvMessageModule(void)
+{
+ if (FIF == 0) {
+ MessageBox(0, TranslateT("The image service plugin (advaimg.dll) is not properly installed.\n\nTabSRMM is disabled."), TranslateT("TabSRMM fatal error"), MB_OK | MB_ICONERROR);
+ return 1;
+ }
+
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ Utils::loadSystemLibrary(L"\\Msftedit.dll");
+
+ Win7Taskbar = new CTaskbarInteract;
+ Win7Taskbar->updateMetrics();
+
+ memset(&nen_options, 0, sizeof(nen_options));
+ M.m_hMessageWindowList = WindowList_Create();
+ PluginConfig.hUserPrefsWindowList = WindowList_Create();
+ sendQueue = new SendQueue;
+ Skin = new CSkin;
+ sendLater = new CSendLater;
+
+ InitOptions();
+
+ InitAPI();
+
+ PluginConfig.reloadSystemStartup();
+ ReloadTabConfig();
+ NEN_ReadOptions(&nen_options);
+
+ db_set_b(0, TEMPLATES_MODULE, "setup", 2);
+ LoadDefaultTemplates();
+
+ BuildCodePageList();
+ return 0;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////////
CREOleCallback reOleCallback;
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index ca88da7714..fddb95208a 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -144,9 +144,9 @@ CSendLaterJob::~CSendLaterJob() */
ppd.colorText = fFailed ? RGB(255, 245, 225) : nen_options.colTextMsg;
ppd.colorBack = fFailed ? RGB(191, 0, 0) : nen_options.colBackMsg;
- ppd.PluginWindowProc = reinterpret_cast<WNDPROC>(Utils::PopupDlgProcError);
+ ppd.PluginWindowProc = Utils::PopupDlgProcError;
ppd.lchIcon = fFailed ? PluginConfig.g_iconErr : PluginConfig.g_IconMsgEvent;
- ppd.PluginData = (void*)hContact;
+ ppd.PluginData = 0;
ppd.iSeconds = fFailed ? -1 : nen_options.iDelayMsg;
PUAddPopupT(&ppd);
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index a7169c8485..98b9932f7f 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -606,9 +606,9 @@ void SendQueue::NotifyDeliveryFailure(const TWindowData *dat) } else ppd.colorText = ppd.colorBack = 0; - ppd.PluginWindowProc = reinterpret_cast<WNDPROC>(Utils::PopupDlgProcError); + ppd.PluginWindowProc = Utils::PopupDlgProcError; ppd.lchIcon = PluginConfig.g_iconErr; - ppd.PluginData = (void*)dat->hContact; + ppd.PluginData = 0; ppd.iSeconds = (int)M.GetDword(MODULE, OPT_DELAY_ERR, (DWORD)DEFAULT_DELAY); PUAddPopupT(&ppd); } diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index 6ac9628f17..01cf0661bc 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -384,7 +384,7 @@ void CSideBar::Init() m_totalItemHeight = 0;
m_uLayout = (m_pContainer->dwFlagsEx & 0xff000000) >> 24;
- m_uLayout = ((m_uLayout >= 0 && m_uLayout < NR_LAYOUTS) ? m_uLayout : 0);
+ m_uLayout = ((m_uLayout < NR_LAYOUTS) ? m_uLayout : 0);
m_currentLayout = &m_layouts[m_uLayout];
@@ -971,14 +971,7 @@ void __fastcall CSideBar::m_DefaultBackgroundRenderer(const HDC hdc, const RECT TContainerData *pContainer = const_cast<TContainerData *>(item->m_sideBar->getContainer());
int id = stateId == PBS_PRESSED || fIsActiveItem ? ID_EXTBKBUTTONSPRESSED : (stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : ID_EXTBKBUTTONSNPRESSED);
CSkinItem *skinItem = &SkinItems[id];
- HWND hwnd;
-
- if (id == IDC_SIDEBARUP)
- hwnd = item->m_sideBar->getScrollUp()->m_buttonControl->hwnd;
- else if (id == IDC_SIDEBARDOWN)
- hwnd = item->m_sideBar->getScrollDown()->m_buttonControl->hwnd;
- else
- hwnd = item->m_buttonControl->hwnd;
+ HWND hwnd = item->m_buttonControl->hwnd;
CSkin::SkinDrawBG(hwnd, pContainer->hwnd, pContainer, const_cast<RECT *>(rc), hdc);
CSkin::DrawItem(hdc, rc, skinItem);
diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp index da55d7f0da..612a253363 100644 --- a/plugins/TabSRMM/src/tabctrl.cpp +++ b/plugins/TabSRMM/src/tabctrl.cpp @@ -33,20 +33,20 @@ static WNDPROC OldTabControlClassProc; #define FIXED_TAB_SIZE 100
-// returns the index of the tab under the mouse pointer. Used for -// context menu popup and tooltips -// pt: mouse coordinates, obtained from GetCursorPos() - -int TSAPI GetTabItemFromMouse(HWND hwndTab, POINT *pt) -{ - TCHITTESTINFO tch; - tch.pt = (*pt); - tch.flags = 0; - ScreenToClient(hwndTab, &tch.pt); - - return TabCtrl_HitTest(hwndTab, &tch); -} - +// returns the index of the tab under the mouse pointer. Used for
+// context menu popup and tooltips
+// pt: mouse coordinates, obtained from GetCursorPos()
+
+int TSAPI GetTabItemFromMouse(HWND hwndTab, POINT *pt)
+{
+ TCHITTESTINFO tch;
+ tch.pt = (*pt);
+ tch.flags = 0;
+ ScreenToClient(hwndTab, &tch.pt);
+
+ return TabCtrl_HitTest(hwndTab, &tch);
+}
+
static int TabCtrl_TestForCloseButton(const TabControlData *tabdat, HWND hwnd, POINT *pt)
{
int iTab;
@@ -343,8 +343,10 @@ static void DrawItemRect(TabControlData *tabdat, HDC dc, RECT *rcItem, int nHint CSkinItem *item = &SkinItems[dwStyle & TCS_BOTTOM ? (nHint & HINT_HOTTRACK ? ID_EXTBKTABITEMHOTTRACKBOTTOM : ID_EXTBKTABITEMBOTTOM) :
(nHint & HINT_HOTTRACK ? ID_EXTBKTABITEMHOTTRACK : ID_EXTBKTABITEM)];
if (!item->IGNORED) {
- if (dwStyle & TCS_BOTTOM)
- rcItem->top = (rcItem->top > rcTabPage.bottom + 5) ? --rcItem->top : rcItem->top;
+ if (dwStyle & TCS_BOTTOM) {
+ rcItem->top = (rcItem->top > rcTabPage.bottom + 5) ? (rcItem->top-1) : rcItem->top;
+ rcItem->top--;
+ }
else
rcItem->bottom++;
@@ -588,6 +590,9 @@ static POINT ptMouseT = { 0 }; static void PaintWorker(HWND hwnd, TabControlData *tabdat)
{
+ if (tabdat == NULL || tabdat->pContainer == NULL)
+ return;
+
PAINTSTRUCT ps;
HDC hdc;
RECT rectTemp, rctPage, rctActive, rcItem, rctClip, rctOrig;
@@ -615,10 +620,10 @@ static void PaintWorker(HWND hwnd, TabControlData *tabdat) item.mask = TCIF_PARAM;
tabdat->fAeroTabs = (CSkin::m_fAeroSkinsValid && (isAero || PluginConfig.m_fillColor)) ? TRUE : FALSE;
- tabdat->fCloseButton = tabdat->pContainer ? (tabdat->pContainer->dwFlagsEx & TCF_CLOSEBUTTON ? TRUE : FALSE) : FALSE;
+ tabdat->fCloseButton = (tabdat->pContainer->dwFlagsEx & TCF_CLOSEBUTTON ? TRUE : FALSE);
tabdat->helperDat = 0;
- if (tabdat->fAeroTabs && tabdat->pContainer) {
+ if (tabdat->fAeroTabs) {
TWindowData *dat = (TWindowData*)GetWindowLongPtr(tabdat->pContainer->hwndActive, GWLP_USERDATA);
if (dat)
tabdat->helperDat = dat;
@@ -1176,7 +1181,7 @@ static LRESULT CALLBACK TabControlSubclassProc(HWND hwnd, UINT msg, WPARAM wPara case WM_MOUSEMOVE:
if (tabdat->bDragging) {
- pt.x = GET_X_LPARAM(lParam); + pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ImageList_DragMove(pt.x, pt.y);
}
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp index 04e29e1ede..263cf56bf3 100644 --- a/plugins/TabSRMM/src/themeio.cpp +++ b/plugins/TabSRMM/src/themeio.cpp @@ -334,10 +334,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in for (i = 0; i < CUSTOM_COLORS; i++) {
mir_snprintf(szTemp, SIZEOF(szTemp), "cc%d", i + 1);
- if (dat == 0)
- db_set_dw(0, SRMSGMOD_T, szTemp, GetPrivateProfileIntA("Custom Colors", szTemp, RGB(224, 224, 224), szIniFilename));
- else
- dat->theme.custom_colors[i] = GetPrivateProfileIntA("Custom Colors", szTemp, RGB(224, 224, 224), szIniFilename);
+ db_set_dw(0, SRMSGMOD_T, szTemp, GetPrivateProfileIntA("Custom Colors", szTemp, RGB(224, 224, 224), szIniFilename));
}
for (i = 0; i <= 7; i++) {
if (i == 5)
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index 010b1cab5e..8829380568 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -2237,7 +2237,7 @@ void CSkin::RenderToolbarBG(const TWindowData *dat, HDC hdc, const RECT &rcWindo }
else {
GetWindowRect(::GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_CHAT ? IDC_CHAT_MESSAGE : IDC_MESSAGE), &rc);
- pt.y = rc.bottom - (dat->bType == SESSIONTYPE_IM ? 2 : 2);
+ pt.y = rc.bottom - 2;
ScreenToClient(dat->hwnd, &pt);
rcToolbar.top = pt.y + 1;
rcToolbar.left = 0;
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index e0fa5dde0a..580a6bccc1 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -479,7 +479,7 @@ TCHAR* Utils::GetPreviewWithEllipsis(TCHAR *szText, size_t iMaxLen) cSaved = 0;
}
else {
- TCHAR *p = &szText[iMaxLen - 1];
+ p = &szText[iMaxLen - 1];
fEllipsis = true;
while (p >= szText && *p != ' ')
@@ -560,9 +560,9 @@ void Utils::RTF_ColorAdd(const TCHAR *tszColname, size_t length) /////////////////////////////////////////////////////////////////////////////////////////
// generic error popup dialog procedure
-INT_PTR CALLBACK Utils::PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK Utils::PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- MCONTACT hContact = (MCONTACT)PUGetPluginData(hWnd);
+ MCONTACT hContact = PUGetContact(hWnd);
switch (message) {
case WM_COMMAND:
@@ -1192,12 +1192,7 @@ LRESULT CWarning::show(const int uId, DWORD dwFlags, const wchar_t* tszTxt) _s = TranslateTS(warnings[uId]);
}
}
- else if (-1 == uId && tszTxt) {
- dwFlags |= CWF_NOALLOWHIDE;
- _s = (dwFlags & CWF_UNTRANSLATED ? const_cast<wchar_t *>(tszTxt) : TranslateW(tszTxt));
- }
- else
- return -1;
+ return -1;
}
if ((wcslen(_s) > 3) && ((separator_pos = wcschr(_s, '|')) != 0)) {
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index b37a022c27..7dabdf9235 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -91,7 +91,7 @@ public: static HMODULE loadSystemLibrary(const wchar_t* szFilename);
- static INT_PTR CALLBACK PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static LPTSTR extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich);
static size_t CopyToClipBoard(const wchar_t *str, const HWND hwndOwner);
|