diff options
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 212 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.h | 63 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/trayicon.cpp | 6 |
5 files changed, 136 insertions, 163 deletions
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index ed591ba6d1..37756aecbe 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2664,9 +2664,9 @@ LABEL_SHOWWINDOW: }
break;
- case GC_SCROLLTOBOTTOM: {
- return(DM_ScrollToBottom(dat, wParam, lParam));
- }
+ case GC_SCROLLTOBOTTOM:
+ DM_ScrollToBottom(dat, wParam, lParam);
+ return 0;
case WM_TIMER:
if (wParam == TIMERID_FLASHWND)
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index e8654cfacb..182bfc68ab 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1087,47 +1087,47 @@ void TSAPI DM_SetDBButtonStates(HWND hwndChild, struct TWindowData *dat) }
}
-LRESULT TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam)
+void TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
- if (dat) {
+ if (dat == NULL)
+ return;
- if (dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED)
- return 0;
+ if (dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED)
+ return;
- if (IsIconic(dat->pContainer->hwnd))
- dat->dwFlags |= MWF_DEFERREDSCROLL;
+ if ( IsIconic(dat->pContainer->hwnd))
+ dat->dwFlags |= MWF_DEFERREDSCROLL;
- if (dat->hwndIEView) {
- PostMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
- return 0;
- } else if (dat->hwndHPP) {
- SendMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
- return 0;
- } else {
- HWND hwnd = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_LOG : IDC_CHAT_LOG);
- if (lParam)
- SendMessage(hwnd, WM_SIZE, 0, 0);
+ if (dat->hwndIEView) {
+ PostMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
+ return;
+ }
+ if (dat->hwndHPP) {
+ SendMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
+ return;
+ }
- if (wParam == 1 && lParam == 1) {
- RECT rc;
- int len;
+ HWND hwnd = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_LOG : IDC_CHAT_LOG);
+ if (lParam)
+ SendMessage(hwnd, WM_SIZE, 0, 0);
- GetClientRect(hwnd, &rc);
- len = GetWindowTextLengthA(hwnd);
- SendMessage(hwnd, EM_SETSEL, len - 1, len - 1);
- }
- if (wParam)
- SendMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- else
- PostMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- if (lParam)
- InvalidateRect(hwnd, NULL, FALSE);
- }
+ if (wParam == 1 && lParam == 1) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ int len = GetWindowTextLengthA(hwnd);
+ SendMessage(hwnd, EM_SETSEL, len - 1, len - 1);
}
- return 0;
+
+ if (wParam)
+ SendMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+ else
+ PostMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+
+ if (lParam)
+ InvalidateRect(hwnd, NULL, FALSE);
}
-static unsigned __stdcall LoadKLThread(LPVOID vParam)
+static void LoadKLThread(LPVOID vParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(vParam);
DBVARIANT dbv = {0};
@@ -1138,54 +1138,34 @@ static unsigned __stdcall LoadKLThread(LPVOID vParam) PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SETLOCALE, (WPARAM)hContact, (LPARAM)hkl);
DBFreeVariant(&dbv);
}
- return 0;
}
-
-LRESULT TSAPI DM_LoadLocale(TWindowData *dat)
+void TSAPI DM_LoadLocale(TWindowData *dat)
{
- /*
- * set locale if saved to contact
- */
- if (dat) {
- if (dat->dwFlags & MWF_WASBACKGROUNDCREATE)
- return 0;
-
- if (PluginConfig.m_AutoLocaleSupport) {
- DBVARIANT dbv;
- int res;
- TCHAR szKLName[KL_NAMELENGTH+1];
- UINT flags = KLF_ACTIVATE;
+ if (dat == NULL || !PluginConfig.m_AutoLocaleSupport)
+ return;
- res = DBGetContactSettingTString(dat->hContact, SRMSGMOD_T, "locale", &dbv);
- if (res == 0) {
+ if (dat->dwFlags & MWF_WASBACKGROUNDCREATE)
+ return;
- /*
- dat->hkl = LoadKeyboardLayout(dbv.ptszVal, KLF_REPLACELANG | KLF_NOTELLSHELL);
- GetLocaleID(dat, dbv.ptszVal);
- PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0);*/
- DBFreeVariant(&dbv);
- CloseHandle((HANDLE)mir_forkthreadex(LoadKLThread, dat->hContact, NULL));
- } else {
- if (!PluginConfig.m_dontUseDefaultKbd) {
- TCHAR szBuf[20];
-
- GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, szBuf, 20);
- mir_sntprintf(szKLName, KL_NAMELENGTH, _T("0000%s"), szBuf);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- }
- else {
- GetKeyboardLayoutName(szKLName);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- }
- /*dat->hkl = LoadKeyboardLayout(szKLName, KLF_NOTELLSHELL | KLF_REPLACELANG);
- GetLocaleID(dat, szKLName);
- PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0);*/
- CloseHandle((HANDLE)mir_forkthreadex(LoadKLThread, reinterpret_cast<void *>(dat->hContact), NULL));
- }
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString(dat->hContact, SRMSGMOD_T, "locale", &dbv))
+ DBFreeVariant(&dbv);
+ else {
+ TCHAR szKLName[KL_NAMELENGTH+1];
+ if (!PluginConfig.m_dontUseDefaultKbd) {
+ TCHAR szBuf[20];
+ GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, szBuf, 20);
+ mir_sntprintf(szKLName, KL_NAMELENGTH, _T("0000%s"), szBuf);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
+ }
+ else {
+ GetKeyboardLayoutName(szKLName);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
}
}
- return 0;
+
+ mir_forkthread(LoadKLThread, dat->hContact);
}
LRESULT TSAPI DM_RecalcPictureSize(TWindowData *dat)
@@ -1207,68 +1187,58 @@ LRESULT TSAPI DM_RecalcPictureSize(TWindowData *dat) return 0;
}
-LRESULT TSAPI DM_UpdateLastMessage(const TWindowData *dat)
+void TSAPI DM_UpdateLastMessage(const TWindowData *dat)
{
- if (dat) {
- if (dat->pContainer->hwndStatus == 0)
- return 0;
- if (dat->pContainer->hwndActive != dat->hwnd)
- return 0;
- if (dat->showTyping) {
- TCHAR szBuf[80];
+ if (dat == NULL)
+ return;
- mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message."), dat->cache->getNick());
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM) szBuf);
- SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, (LPARAM) PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
- return 0;
- }
- else
- SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, 0);
+ if (dat->pContainer->hwndStatus == 0 || dat->pContainer->hwndActive != dat->hwnd)
+ return;
- if (dat->lastMessage || dat->pContainer->dwFlags & CNT_UINSTATUSBAR) {
- TCHAR date[64], time[64];
+ TCHAR szBuf[100];
+ if (dat->showTyping) {
+ SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, (LPARAM) PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
+ mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message."), dat->cache->getNick());
+ }
+ else {
+ SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, 0);
- if (!(dat->pContainer->dwFlags & CNT_UINSTATUSBAR)) {
- tmi.printTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0);
- if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR && lstrlen(date) > 6)
- date[lstrlen(date) - 5] = 0;
- tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
- }
- if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR) {
- TCHAR fmt[100];
- mir_sntprintf(fmt, SIZEOF(fmt), _T("UID: %s"), dat->cache->getUIN());
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt);
- } else {
- TCHAR fmt[100];
- mir_sntprintf(fmt, SIZEOF(fmt), TranslateT("Last received: %s at %s"), date, time);
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM) fmt);
- }
- } else
- SendMessageA(dat->pContainer->hwndStatus, SB_SETTEXTA, 0, (LPARAM) "");
+ if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR)
+ mir_sntprintf(szBuf, SIZEOF(szBuf), _T("UID: %s"), dat->cache->getUIN());
+ else if (dat->lastMessage) {
+ TCHAR date[64], time[64];
+ tmi.printTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0);
+ if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR && lstrlen(date) > 6)
+ date[lstrlen(date) - 5] = 0;
+ tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
+ mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("Last received: %s at %s"), date, time);
+ }
+ else szBuf[0] = 0;
}
- return 0;
+
+ SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
}
/*
* save current keyboard layout for the given contact
*/
-LRESULT TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam)
+void TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
- if (dat) {
- if (PluginConfig.m_AutoLocaleSupport && dat->hContact && dat->pContainer->hwndActive == dat->hwnd) {
- TCHAR szKLName[KL_NAMELENGTH + 1];
- if ((HKL)lParam != dat->hkl) {
- dat->hkl = (HKL)lParam;
- ActivateKeyboardLayout(dat->hkl, 0);
- GetKeyboardLayoutName(szKLName);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- GetLocaleID(dat, szKLName);
- UpdateReadChars(dat);
- }
+ if (!dat)
+ return;
+
+ if (PluginConfig.m_AutoLocaleSupport && dat->hContact && dat->pContainer->hwndActive == dat->hwnd) {
+ TCHAR szKLName[KL_NAMELENGTH + 1];
+ if ((HKL)lParam != dat->hkl) {
+ dat->hkl = (HKL)lParam;
+ ActivateKeyboardLayout(dat->hkl, 0);
+ GetKeyboardLayoutName(szKLName);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
+ GetLocaleID(dat, szKLName);
+ UpdateReadChars(dat);
}
}
- return 0;
}
/*
diff --git a/plugins/TabSRMM/src/generic_msghandlers.h b/plugins/TabSRMM/src/generic_msghandlers.h index 4916a90c06..a355d0538d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.h +++ b/plugins/TabSRMM/src/generic_msghandlers.h @@ -30,36 +30,37 @@ *
*/
-void TSAPI DM_SetDBButtonStates (HWND hwndChild, struct TWindowData *dat);
-int TSAPI BTN_GetStockItem (ButtonItem *item, const TCHAR *szName);
-HWND TSAPI DM_CreateClist (TWindowData *dat);
+void TSAPI DM_SetDBButtonStates(HWND hwndChild, struct TWindowData *dat);
+int TSAPI BTN_GetStockItem (ButtonItem *item, const TCHAR *szName);
+HWND TSAPI DM_CreateClist(TWindowData *dat);
-void TSAPI DM_OptionsApplied (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI DM_UpdateTitle (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_ScrollToBottom (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_LoadLocale (TWindowData *dat);
-LRESULT TSAPI DM_SaveLocale (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_UpdateLastMessage (const TWindowData *dat);
-LRESULT __stdcall DM_RecalcPictureSize (TWindowData *dat);
-LRESULT TSAPI DM_WMCopyHandler (HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_MouseWheelHandler (HWND hwnd, HWND hwndParent, struct TWindowData *mwdat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_ThemeChanged (TWindowData *dat);
-void TSAPI DM_Typing (TWindowData *dat, bool fForceOff = false);
-void TSAPI DM_FreeTheme (TWindowData *dat);
-void TSAPI DM_NotifyTyping (TWindowData *dat, int mode);
-int TSAPI DM_SplitterGlobalEvent (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI BB_InitDlgButtons (TWindowData *dat);
+void TSAPI DM_OptionsApplied(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_LoadLocale(TWindowData *dat);
+void TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_UpdateLastMessage(const TWindowData *dat);
+LRESULT TSAPI DM_WMCopyHandler(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_MouseWheelHandler(HWND hwnd, HWND hwndParent, struct TWindowData *mwdat, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_ThemeChanged(TWindowData *dat);
+void TSAPI DM_Typing(TWindowData *dat, bool fForceOff = false);
+void TSAPI DM_FreeTheme(TWindowData *dat);
+void TSAPI DM_NotifyTyping(TWindowData *dat, int mode);
+int TSAPI DM_SplitterGlobalEvent(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI BB_InitDlgButtons(TWindowData *dat);
-BOOL TSAPI BB_SetButtonsPos (TWindowData *dat);
-void TSAPI BB_RedrawButtons (TWindowData *dat);
-void TSAPI BB_CustomButtonClick (TWindowData *dat,DWORD idFrom ,HWND hwndFrom, BOOL code) ;
-void TSAPI DM_EventAdded (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI DM_InitRichEdit (TWindowData *dat);
-LRESULT TSAPI DM_ContainerCmdHandler (TContainerData *pContainer, UINT cmd, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_MsgWindowCmdHandler (HWND hwndDlg, TContainerData *pContainer, TWindowData *dat, UINT cmd, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_GenericHotkeysCheck (MSG *message, TWindowData *dat);
-void TSAPI DM_DismissTip (TWindowData *dat, const POINT& pt);
-void TSAPI DM_InitTip (TWindowData *dat);
-void TSAPI DM_HandleAutoSizeRequest(TWindowData *dat, REQRESIZE* rr);
-void TSAPI DM_SaveLogAsRTF (const TWindowData* dat);
-void TSAPI DM_CheckAutoHide (const TWindowData* dat, WPARAM wParam, LPARAM lParam);
+BOOL TSAPI BB_SetButtonsPos(TWindowData *dat);
+void TSAPI BB_RedrawButtons(TWindowData *dat);
+void TSAPI BB_CustomButtonClick(TWindowData *dat,DWORD idFrom ,HWND hwndFrom, BOOL code) ;
+void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_InitRichEdit(TWindowData *dat);
+LRESULT TSAPI DM_ContainerCmdHandler(TContainerData *pContainer, UINT cmd, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_MsgWindowCmdHandler(HWND hwndDlg, TContainerData *pContainer, TWindowData *dat, UINT cmd, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_GenericHotkeysCheck(MSG *message, TWindowData *dat);
+void TSAPI DM_DismissTip(TWindowData *dat, const POINT& pt);
+void TSAPI DM_InitTip(TWindowData *dat);
+void TSAPI DM_HandleAutoSizeRequest(TWindowData *dat, REQRESIZE* rr);
+void TSAPI DM_SaveLogAsRTF(const TWindowData* dat);
+void TSAPI DM_CheckAutoHide(const TWindowData* dat, WPARAM wParam, LPARAM lParam);
+
+LRESULT __stdcall DM_RecalcPictureSize(TWindowData *dat);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index bb3424ad7b..a9838ac9d2 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2611,16 +2611,20 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP HWND hwnd = GetDlgItem(hwndDlg, IDC_LOG);
int len;
- if (wParam == 0 && lParam == 0)
- return(DM_ScrollToBottom(dat, 0, 1));
+ if (wParam == 0 && lParam == 0) {
+ DM_ScrollToBottom(dat, 0, 1);
+ return 0;
+ }
if (dat->hwndIEView == 0 && dat->hwndHPP == 0) {
len = GetWindowTextLengthA(GetDlgItem(hwndDlg, IDC_LOG));
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETSEL, len - 1, len - 1);
}
- if (psi == NULL)
- return(DM_ScrollToBottom(dat, 0, 0));
+ if (psi == NULL) {
+ DM_ScrollToBottom(dat, 0, 0);
+ return 0;
+ }
if ((UINT)psi->nPos >= (UINT)psi->nMax - psi->nPage - 5 || psi->nMax - psi->nMin - psi->nPage < 50)
DM_ScrollToBottom(dat, 0, 0);
diff --git a/plugins/TabSRMM/src/trayicon.cpp b/plugins/TabSRMM/src/trayicon.cpp index 48d6cb2417..1684601ae2 100644 --- a/plugins/TabSRMM/src/trayicon.cpp +++ b/plugins/TabSRMM/src/trayicon.cpp @@ -43,7 +43,7 @@ HANDLE g_hEvent = 0; static TCHAR g_eventName[100];
-static unsigned __stdcall TrayAnimThread(LPVOID vParam)
+static void TrayAnimThread(LPVOID vParam)
{
int iAnimMode = (PluginConfig.m_AnimTrayIcons[0] && PluginConfig.m_AnimTrayIcons[1] && PluginConfig.m_AnimTrayIcons[2] &&
PluginConfig.m_AnimTrayIcons[3]);
@@ -94,7 +94,6 @@ static unsigned __stdcall TrayAnimThread(LPVOID vParam) }
while (isAnimThreadRunning);
CloseHandle(hEvent);
- return 0;
}
void TSAPI CreateTrayMenus(int mode)
@@ -103,7 +102,7 @@ void TSAPI CreateTrayMenus(int mode) mir_sntprintf(g_eventName, 100, _T("tsr_evt_%d"), GetCurrentThreadId());
g_hEvent = CreateEvent(NULL, FALSE, FALSE, g_eventName);
isAnimThreadRunning = TRUE;
- hTrayAnimThread = (HANDLE)mir_forkthreadex(TrayAnimThread, NULL, NULL);
+ hTrayAnimThread = mir_forkthread(TrayAnimThread, NULL);
PluginConfig.g_hMenuTrayUnread = CreatePopupMenu();
PluginConfig.g_hMenuFavorites = CreatePopupMenu();
@@ -119,7 +118,6 @@ void TSAPI CreateTrayMenus(int mode) isAnimThreadRunning = FALSE;
SetEvent(g_hEvent);
WaitForSingleObject(hTrayAnimThread, 5000);
- CloseHandle(hTrayAnimThread);
CloseHandle(g_hEvent);
g_hEvent = 0;
hTrayAnimThread = 0;
|