summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-17 16:08:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-17 16:08:10 +0000
commit6256386699ebcb343383e10efc8143d50c9e7885 (patch)
tree5d4fc144b45c1d4af39620e33d6f9b6c96be1645 /plugins/TabSRMM/src/chat
parent800d1885d036ef2f7f1bc6f52f8855c03fb64705 (diff)
- fix for the main threat hanging;
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@9839 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp55
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp36
2 files changed, 43 insertions, 48 deletions
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 19c6f67327..2c803e4b98 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -37,32 +37,25 @@ int GetRichTextLength(HWND hwnd)
{
GETTEXTLENGTHEX gtl;
gtl.flags = GTL_PRECISE;
- gtl.codepage = CP_ACP ;
- return (int) SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
+ gtl.codepage = CP_ACP;
+ return (int)SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
}
-static void __stdcall ShowRoomFromPopup(void * pi)
+static void __stdcall ShowRoomFromPopup(void *pi)
{
- SESSION_INFO *si = (SESSION_INFO*) pi;
+ SESSION_INFO *si = (SESSION_INFO*)pi;
ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
-static void TSAPI Chat_OpenPopup(SESSION_INFO *si, HWND hwndPopup)
-{
- CallFunctionAsync(ShowRoomFromPopup, si);
- PUDeletePopup(hwndPopup);
-}
-
-static void TSAPI Chat_DismissPopup(const SESSION_INFO *si, HWND hwndPopup)
+static void __stdcall Chat_DismissPopup(void *pi)
{
+ SESSION_INFO *si = (SESSION_INFO*)pi;
if (si->hContact)
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT);
+ if (CallService(MS_CLIST_GETEVENT, si->hContact, 0))
+ CallServiceSync(MS_CLIST_REMOVEEVENT, si->hContact, (LPARAM)GC_FAKE_EVENT);
if (si->hWnd && KillTimer(si->hWnd, TIMERID_FLASHWND))
FlashWindow(si->hWnd, FALSE);
-
- PUDeletePopup(hwndPopup);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -71,12 +64,13 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
switch (message) {
case WM_COMMAND:
- if ( HIWORD(wParam) == STN_CLICKED) {
+ if (HIWORD(wParam) == STN_CLICKED) {
if (si) {
if (nen_options.maskActL & MASK_OPEN)
- Chat_OpenPopup(si, hWnd);
+ CallFunctionAsync(ShowRoomFromPopup, si);
else
- Chat_DismissPopup(si, hWnd);
+ CallFunctionAsync(Chat_DismissPopup, si);
+ PUDeletePopup(hWnd);
}
return TRUE;
}
@@ -85,9 +79,10 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
case WM_CONTEXTMENU:
if (si && si->hContact) {
if (nen_options.maskActR & MASK_OPEN)
- Chat_OpenPopup(si, hWnd);
+ CallFunctionAsync(ShowRoomFromPopup, si);
else
- Chat_DismissPopup(si, hWnd);
+ CallFunctionAsync(Chat_DismissPopup, si);
+ PUDeletePopup(hWnd);
}
break;
}
@@ -124,8 +119,8 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa
PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
- (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
- pcli->pfnGetContactDisplayName(hContact, 0));
+ (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
+ pcli->pfnGetContactDisplayName(hContact, 0));
lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
pd.iSeconds = g_Settings.iPopupTimeout;
@@ -215,7 +210,7 @@ passed:
if (iNewEvent == GC_EVENT_MESSAGE) {
ShowPopup(si->hContact, si, pci->hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : pci->aFonts[9].color,
- TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, pci->RemoveFormatting(gce->ptszText));
+ TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, pci->RemoveFormatting(gce->ptszText));
}
else saveCI.DoPopup(si, gce);
@@ -289,7 +284,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p)
else if (dat->iFlashIcon) {
dat->hTabIcon = dat->iFlashIcon;
- TCITEM item = {0};
+ TCITEM item = { 0 };
item.mask = TCIF_IMAGE;
item.iImage = 0;
TabCtrl_SetItem(GetParent(si->hWnd), dat->iTabID, &item);
@@ -400,7 +395,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
params->sound = "ChatMessage";
if (params->bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
- db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD) 40071);
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", ID_STATUS_OFFLINE);
}
break;
case GC_EVENT_ACTION:
@@ -494,8 +489,8 @@ TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2)
int i, j, k;
_tsetlocale(LC_ALL, _T(""));
- for (i=0;s1[i];i++)
- for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]);j++, k++)
+ for (i = 0; s1[i]; i++)
+ for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++)
if (!s2[k+1])
return (TCHAR*)(s1 + i);
@@ -528,7 +523,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO
*hMenu = GetSubMenu(g_hMenu, iIndex);
TranslateMenu(*hMenu);
- GCMENUITEMS gcmi = {0};
+ GCMENUITEMS gcmi = { 0 };
gcmi.pszID = si->ptszID;
gcmi.pszModule = si->pszModule;
gcmi.pszUID = pszUID;
@@ -691,7 +686,7 @@ BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
int dwMask = 0;
if (gce->ptszText != NULL)
dwMask |= CMUCHighlight::MATCH_TEXT;
-
+
if (gce->ptszNick != NULL) {
dwMask |= CMUCHighlight::MATCH_NICKNAME;
if (si && g_Settings.bLogClassicIndicators) {
@@ -701,6 +696,6 @@ BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
_tcscpy(tmp + 1, gce->ptszNick);
evTmp.ptszNick = tmp;
}
- }
+ }
return g_Settings.Highlight->match(&evTmp, si, dwMask);
}
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 8cb081d5aa..75fa4acf88 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -200,7 +200,7 @@ static BOOL CheckCustomLink(HWND hwndDlg, POINT* ptClient, UINT uMsg, WPARAM wPa
enlink.lParam = lParam;
enlink.chrg.cpMin = cpMin;
enlink.chrg.cpMax = cpMax;
- SendMessage(GetParent(hwndDlg), WM_NOTIFY, (WPARAM)IDC_CHAT_LOG, (LPARAM)&enlink);
+ SendMessage(GetParent(hwndDlg), WM_NOTIFY, IDC_CHAT_LOG, (LPARAM)&enlink);
}
return bIsCustomLink;
}
@@ -277,8 +277,8 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
if (dat->iTabID >= 0) {
if (db_get_w(si->hContact, si->pszModule, "ApparentMode", 0) != 0)
db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT);
+ if (CallService(MS_CLIST_GETEVENT, si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, si->hContact, (LPARAM)GC_FAKE_EVENT);
SendMessage(hwndDlg, GC_UPDATETITLE, 0, 1);
dat->dwTickLastEvent = 0;
@@ -923,7 +923,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
- int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)& gtl, 0);
+ int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
@@ -948,7 +948,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
- int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)& gtl, 0);
+ int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
@@ -1189,7 +1189,7 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
db_set_dw(si->hContact, CHAT_MODULE, "TrayIconMask", dwMask);
}
Chat_SetFilters(si);
- SendMessage(si->hWnd, GC_CHANGEFILTERFLAG, 0, (LPARAM)iFlags);
+ SendMessage(si->hWnd, GC_CHANGEFILTERFLAG, 0, iFlags);
if (si->bFilterEnabled)
SendMessage(si->hWnd, GC_REDRAWLOG, 0, 0);
}
@@ -1222,9 +1222,9 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L
if (hFilter == hwnd)
SendMessage(hwndParent, GC_SHOWFILTERMENU, 0, 0);
if (hColor == hwnd)
- SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_COLOR);
+ SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
if (hBGColor == hwnd)
- SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_BKGCOLOR);
+ SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
}
break;
}
@@ -1672,7 +1672,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (iSelectedItems != LB_ERR) {
int *pItems = (int *)mir_alloc(sizeof(int) * (iSelectedItems + 1));
if (pItems) {
- if (SendMessage(hwnd, LB_GETSELITEMS, (WPARAM)iSelectedItems, (LPARAM)pItems) != LB_ERR) {
+ if (SendMessage(hwnd, LB_GETSELITEMS, iSelectedItems, (LPARAM)pItems) != LB_ERR) {
for (int i=0; i < iSelectedItems; i++) {
USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, pItems[i]);
if (ui1)
@@ -1913,7 +1913,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
int mask = (int)SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_GETEVENTMASK, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS | ENM_KEYEVENTS);
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETEVENTMASK, 0, ENM_REQUESTRESIZE | ENM_MOUSEEVENTS | ENM_SCROLL | ENM_KEYEVENTS | ENM_CHANGE);
- SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_LIMITTEXT, (WPARAM)0x7FFFFFFF, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_LIMITTEXT, 0x7FFFFFFF, 0);
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
dat->Panel->loadHeight();
@@ -2390,8 +2390,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
return TRUE;
case SESSION_TERMINATE:
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT);
+ if (CallService(MS_CLIST_GETEVENT, si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, si->hContact, (LPARAM)GC_FAKE_EVENT);
si->wState &= ~STATE_TALK;
dat->bWasDeleted = 1;
@@ -2652,8 +2652,8 @@ LABEL_SHOWWINDOW:
if (iCharIndex < 0)
break;
- int iLineIndex = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_EXLINEFROMCHAR, 0, (LPARAM)iCharIndex);
- int iChars = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_LINEINDEX, (WPARAM)iLineIndex, 0);
+ int iLineIndex = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_EXLINEFROMCHAR, 0, iCharIndex);
+ int iChars = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_LINEINDEX, iLineIndex, 0);
int start = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_FINDWORDBREAK, WB_LEFT, iCharIndex);
int end = SendMessage(GetDlgItem(hwndDlg, IDC_CHAT_LOG), EM_FINDWORDBREAK, WB_RIGHT, iCharIndex);
@@ -3137,7 +3137,7 @@ LABEL_SHOWWINDOW:
if (IsDlgButtonChecked(hwndDlg, IDC_BKGCOLOR)) {
if (M.GetByte(CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_BKGCOLOR);
+ SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
else if (si->bBGSet) {
cf.dwMask = CFM_BACKCOLOR;
cf.crBackColor = pci->MM_FindModule(si->pszModule)->crColors[si->iBG];
@@ -3160,7 +3160,7 @@ LABEL_SHOWWINDOW:
if (IsDlgButtonChecked(hwndDlg, IDC_COLOR)) {
if (M.GetByte(CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, (LPARAM)IDC_COLOR);
+ SendMessage(hwndDlg, GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
else if (si->bFGSet) {
cf.dwMask = CFM_COLOR;
cf.crTextColor = pci->MM_FindModule(si->pszModule)->crColors[si->iFG];
@@ -3591,8 +3591,8 @@ LABEL_SHOWWINDOW:
break;
case WM_DESTROY:
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT);
+ if (CallService(MS_CLIST_GETEVENT, si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, si->hContact, (LPARAM)GC_FAKE_EVENT);
si->wState &= ~STATE_TALK;
si->hWnd = NULL;
si->dat = NULL;