diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-21 17:18:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-21 17:18:33 +0000 |
commit | 64516fd98ad1dae35864617563ee9963c0f31917 (patch) | |
tree | 5531fe065d5237dac8523fca1f19ff7f3ceeb958 /plugins/TabSRMM | |
parent | 5e4262399fa35d391df2cc86ad0b259a08a25e5a (diff) |
- OnSessionCreate was called too early;
- function names normalization
git-svn-id: http://svn.miranda-ng.org/main/trunk@7818 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 273 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 16 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/services.cpp | 1 |
4 files changed, 142 insertions, 152 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index 9d790b55a3..0d572fb76c 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -67,7 +67,9 @@ struct SESSION_INFO : public GCSessionInfoBase {
TWindowData *dat;
TContainerData *pContainer;
- int iLogTrayFlags, iLogPopupFlags, iDiskLogFlags, iSearchItem;
+ int iLogTrayFlags, iLogPopupFlags, iDiskLogFlags;
+
+ int iSearchItem;
TCHAR szSearch[255];
};
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index be94f1a5c3..dc86a1208a 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -837,7 +837,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) // ### RTF BODY (one iteration per event that should be streamed in)
while (lin) {
// filter
- if (streamData->si->iType != GCW_CHATROOM || !streamData->si->bFilterEnabled || (streamData->si->iLogFilterFlags&lin->iType) != 0) {
+ if (streamData->si->iType != GCW_CHATROOM || !streamData->si->bFilterEnabled || (streamData->si->iLogFilterFlags & lin->iType) != 0) {
if (lin->next != NULL)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\par ");
@@ -999,164 +999,151 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr streamData.bStripFormat = FALSE;
streamData.dat = dat;
- // bPhaseTwo = bRedraw && bPhaseTwo;
+ if (!bRedraw && si->iType == GCW_CHATROOM && si->bFilterEnabled && (si->iLogFilterFlags & lin->iType) == 0)
+ return;
- if (bRedraw || si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags&lin->iType) != 0) {
- bool bFlag = false, fDoReplace;
+ bool bFlag = false, fDoReplace;
- EDITSTREAM stream = { 0 };
- stream.pfnCallback = Log_StreamCallback;
- stream.dwCookie = (DWORD_PTR) & streamData;
+ EDITSTREAM stream = { 0 };
+ stream.pfnCallback = Log_StreamCallback;
+ stream.dwCookie = (DWORD_PTR) & streamData;
- SCROLLINFO scroll = { 0 };
- scroll.cbSize = sizeof(SCROLLINFO);
- scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
- GetScrollInfo(GetDlgItem(hwndDlg, IDC_CHAT_LOG), SB_VERT, &scroll);
- SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point);
+ SCROLLINFO scroll = { 0 };
+ scroll.cbSize = sizeof(SCROLLINFO);
+ scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
+ GetScrollInfo(GetDlgItem(hwndDlg, IDC_CHAT_LOG), SB_VERT, &scroll);
+ SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point);
- // do not scroll to bottom if there is a selection
- SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel);
- if (oldsel.cpMax != oldsel.cpMin)
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+ // do not scroll to bottom if there is a selection
+ SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel);
+ if (oldsel.cpMax != oldsel.cpMin)
+ SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
- //set the insertion point at the bottom
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
+ //set the insertion point at the bottom
+ sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
- // fix for the indent... must be a M$ bug
- if (sel.cpMax == 0)
- bRedraw = TRUE;
-
- // should the event(s) be appended to the current log
- WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF;
-
- //get the number of pixels per logical inch
- if (bRedraw) {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC(NULL, hdc);
- SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
- bFlag = true;
- // SetCursor(LoadCursor(NULL, IDC_ARROW));
- }
+ // fix for the indent... must be a M$ bug
+ if (sel.cpMax == 0)
+ bRedraw = TRUE;
- // stream in the event(s)
- streamData.lin = lin;
- streamData.bRedraw = bRedraw;
- SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream);
-
-
- //SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&newsel);
- /*
- * for new added events, only replace in message or action events.
- * no need to replace smileys or math formulas elsewhere
- */
- fDoReplace = (bRedraw || (lin->ptszText
- && (lin->iType == GC_EVENT_MESSAGE || lin->iType == GC_EVENT_ACTION)));
-
- /*
- * replace marked nicknames with hyperlinks to make the nicks
- * clickable
- */
- if (g_Settings.bClickableNicks) {
- FINDTEXTEX fi, fi2;
-
- CHARFORMAT2 cf2;
- ZeroMemory(&cf2, sizeof(CHARFORMAT2));
- cf2.cbSize = sizeof(cf2);
-
- fi2.lpstrText = _T("#++~~");
- fi.chrg.cpMin = bRedraw ? 0 : sel.cpMin;
- fi.chrg.cpMax = -1;
- fi.lpstrText = _T("~~++#");
-
- while (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) {
- fi2.chrg.cpMin = fi.chrgText.cpMin;
- fi2.chrg.cpMax = -1;
-
- if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) {
-
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi.chrgText);
- SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
- fi2.chrgText.cpMin -= fi.chrgText.cpMax - fi.chrgText.cpMin;
- fi2.chrgText.cpMax -= fi.chrgText.cpMax - fi.chrgText.cpMin;
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
- SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
- fi2.chrgText.cpMax = fi2.chrgText.cpMin;
-
- fi2.chrgText.cpMin = fi.chrgText.cpMin;
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
- cf2.dwMask = CFM_PROTECTED;
- cf2.dwEffects = CFE_PROTECTED;
- SendMessage(hwndRich, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
- }
- fi.chrg.cpMin = fi.chrgText.cpMax;
- }
- SendMessage(hwndRich, EM_SETSEL, -1, -1);
- }
+ // should the event(s) be appended to the current log
+ WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF;
- /*
- * run smileyadd
- */
- if (PluginConfig.g_SmileyAddAvail && fDoReplace) {
- newsel.cpMax = -1;
- newsel.cpMin = sel.cpMin;
- if (newsel.cpMin < 0)
- newsel.cpMin = 0;
-
- SMADD_RICHEDIT3 sm = { sizeof(sm) };
- sm.hwndRichEditControl = hwndRich;
- sm.Protocolname = si->pszModule;
- sm.rangeToReplace = bRedraw ? NULL : &newsel;
- sm.disableRedraw = TRUE;
- sm.hContact = si->hContact;
- CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
- }
+ //get the number of pixels per logical inch
+ if (bRedraw) {
+ HDC hdc;
+ hdc = GetDC(NULL);
+ logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
+ SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
+ bFlag = true;
+ // SetCursor(LoadCursor(NULL, IDC_ARROW));
+ }
+
+ // stream in the event(s)
+ streamData.lin = lin;
+ streamData.bRedraw = bRedraw;
+ SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream);
+
+ // for new added events, only replace in message or action events.
+ // no need to replace smileys or math formulas elsewhere
+ fDoReplace = (bRedraw || (lin->ptszText && (lin->iType == GC_EVENT_MESSAGE || lin->iType == GC_EVENT_ACTION)));
- /*
- * trim the message log to the number of most recent events
- * this uses hidden marks in the rich text to find the events which should be deleted
- */
- if (si->bTrimmed) {
- TCHAR szPattern[50];
- FINDTEXTEX fi;
-
- mir_sntprintf(szPattern, SIZEOF(szPattern), _T("~-+%d+-~"), si->pLogEnd);
- fi.lpstrText = szPattern;
- fi.chrg.cpMin = 0;
- fi.chrg.cpMax = -1;
- if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) {
- CHARRANGE sel;
- sel.cpMin = 0;
- sel.cpMax = 20;
- SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1);
+ // replace marked nicknames with hyperlinks to make the nicks clickable
+ if (g_Settings.bClickableNicks) {
+ FINDTEXTEX fi, fi2;
+
+ CHARFORMAT2 cf2;
+ ZeroMemory(&cf2, sizeof(CHARFORMAT2));
+ cf2.cbSize = sizeof(cf2);
+
+ fi2.lpstrText = _T("#++~~");
+ fi.chrg.cpMin = bRedraw ? 0 : sel.cpMin;
+ fi.chrg.cpMax = -1;
+ fi.lpstrText = _T("~~++#");
+
+ while (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) {
+ fi2.chrg.cpMin = fi.chrgText.cpMin;
+ fi2.chrg.cpMax = -1;
+
+ if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) {
+
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi.chrgText);
SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
+ fi2.chrgText.cpMin -= fi.chrgText.cpMax - fi.chrgText.cpMin;
+ fi2.chrgText.cpMax -= fi.chrgText.cpMax - fi.chrgText.cpMin;
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
+ SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
+ fi2.chrgText.cpMax = fi2.chrgText.cpMin;
+
+ fi2.chrgText.cpMin = fi.chrgText.cpMin;
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText);
+ cf2.dwMask = CFM_PROTECTED;
+ cf2.dwEffects = CFE_PROTECTED;
+ SendMessage(hwndRich, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
}
- si->bTrimmed = FALSE;
+ fi.chrg.cpMin = fi.chrgText.cpMax;
}
+ SendMessage(hwndRich, EM_SETSEL, -1, -1);
+ }
- // scroll log to bottom if the log was previously scrolled to bottom, else restore old position
- if ((bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50))
- SendMessage(GetParent(hwndRich), GC_SCROLLTOBOTTOM, 0, 0);
- else
- SendMessage(hwndRich, EM_SETSCROLLPOS, 0, (LPARAM)&point);
+ // run smileyadd
+ if (PluginConfig.g_SmileyAddAvail && fDoReplace) {
+ newsel.cpMax = -1;
+ newsel.cpMin = sel.cpMin;
+ if (newsel.cpMin < 0)
+ newsel.cpMin = 0;
+
+ SMADD_RICHEDIT3 sm = { sizeof(sm) };
+ sm.hwndRichEditControl = hwndRich;
+ sm.Protocolname = si->pszModule;
+ sm.rangeToReplace = bRedraw ? NULL : &newsel;
+ sm.disableRedraw = TRUE;
+ sm.hContact = si->hContact;
+ CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
+ }
- // do we need to restore the selection
- if (oldsel.cpMax != oldsel.cpMin) {
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&oldsel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, NULL, TRUE);
+ // trim the message log to the number of most recent events
+ // this uses hidden marks in the rich text to find the events which should be deleted
+ if (si->bTrimmed) {
+ TCHAR szPattern[50];
+ FINDTEXTEX fi;
+
+ mir_sntprintf(szPattern, SIZEOF(szPattern), _T("~-+%d+-~"), si->pLogEnd);
+ fi.lpstrText = szPattern;
+ fi.chrg.cpMin = 0;
+ fi.chrg.cpMax = -1;
+ if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) {
+ CHARRANGE sel;
+ sel.cpMin = 0;
+ sel.cpMax = 20;
+ SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1);
+ SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
}
+ si->bTrimmed = FALSE;
+ }
- // need to invalidate the window
- if (bFlag) {
- sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
- SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
- SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(hwndRich, NULL, TRUE);
- }
+ // scroll log to bottom if the log was previously scrolled to bottom, else restore old position
+ if ((bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50))
+ SendMessage(GetParent(hwndRich), GC_SCROLLTOBOTTOM, 0, 0);
+ else
+ SendMessage(hwndRich, EM_SETSCROLLPOS, 0, (LPARAM)&point);
+
+ // do we need to restore the selection
+ if (oldsel.cpMax != oldsel.cpMin) {
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&oldsel);
+ SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(hwndRich, NULL, TRUE);
+ }
+
+ // need to invalidate the window
+ if (bFlag) {
+ sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich);
+ SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel);
+ SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(hwndRich, NULL, TRUE);
}
}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 1d3bbed584..6eb0c2295f 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -56,24 +56,24 @@ static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi) }
}
-static void OnSessionDblClick(SESSION_INFO *si)
+static void OnDblClickSession(SESSION_INFO *si)
{
PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
}
-static void OnSessionRemove(SESSION_INFO *si)
+static void OnRemoveSession(SESSION_INFO *si)
{
if (si->hWnd)
SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
}
-static void OnSessionRename(SESSION_INFO *si)
+static void OnRenameSession(SESSION_INFO *si)
{
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
}
-static void OnSessionReplace(SESSION_INFO *si)
+static void OnReplaceSession(SESSION_INFO *si)
{
if (si->hContact)
Chat_SetFilters(si);
@@ -270,10 +270,10 @@ int Chat_Load() pci->OnAddLog = OnAddLog;
pci->OnCreateSession = OnCreateSession;
- pci->OnSessionRemove = OnSessionRemove;
- pci->OnSessionRename = OnSessionRename;
- pci->OnSessionReplace = OnSessionReplace;
- pci->OnSessionDblClick = OnSessionDblClick;
+ pci->OnRemoveSession = OnRemoveSession;
+ pci->OnRenameSession = OnRenameSession;
+ pci->OnReplaceSession = OnReplaceSession;
+ pci->OnDblClickSession = OnDblClickSession;
pci->OnEventBroadcast = OnEventBroadcast;
pci->OnSetStatusBar = OnSetStatusBar;
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 61beccc984..c0b769a216 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -166,6 +166,7 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) if (si == NULL)
return;
+ Chat_SetFilters(si);
if (si->hWnd != NULL) {
ActivateExistingTab(si->pContainer, si->hWnd);
return;
|