summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat_int.h1
-rw-r--r--plugins/TabSRMM/src/chat/chat.h1
-rw-r--r--plugins/TabSRMM/src/chat/log.cpp74
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/options.cpp4
-rw-r--r--plugins/TabSRMM/src/chat/services.cpp1
-rw-r--r--plugins/TabSRMM/src/msglog.cpp5
-rw-r--r--src/modules/chat/chat.h1
-rw-r--r--src/modules/chat/log.cpp193
-rw-r--r--src/modules/chat/manager.cpp1
10 files changed, 130 insertions, 153 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 2ac9b5bd0e..4df6029480 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -389,6 +389,7 @@ struct CHAT_MANAGER
int (*ShowPopup)(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...);
BOOL (*LogToFile)(SESSION_INFO *si, GCEVENT *gce);
TCHAR* (*GetChatLogsFilename)(SESSION_INFO *si, time_t tTime);
+ char* (*Log_SetStyle)(int style);
BOOL (*IsHighlighted)(SESSION_INFO *si, GCEVENT *pszText);
TCHAR* (*RemoveFormatting)(const TCHAR *pszText);
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 0d572fb76c..f8a4769b54 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -133,7 +133,6 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L
// log.c
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
char* Log_CreateRtfHeader(MODULEINFO *mi);
-void Log_SetStyles();
// window.c
INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp
index dc86a1208a..d869165204 100644
--- a/plugins/TabSRMM/src/chat/log.cpp
+++ b/plugins/TabSRMM/src/chat/log.cpp
@@ -42,11 +42,7 @@
* the srmm module and then modified to fit the chat module.
*/
-static int logPixelSY = 0;
-static int logPixelSX = 0;
static char *szDivider = "\\strike----------------------------------------------------------------------------\\strike0";
-static char CHAT_rtfFontsGlobal[OPTIONS_FONTCOUNT + 2][RTFCACHELINESIZE];
-static char *CHAT_rtffonts = 0;
/*
* ieview MUC support - mostly from scriver
@@ -486,14 +482,6 @@ static TCHAR * _tcsnrplc(TCHAR *src, size_t n, const TCHAR *ptrn, const TCHAR *r
return src;
}
-static char *Log_SetStyle(int style, int fontindex)
-{
- if (style < OPTIONS_FONTCOUNT)
- return CHAT_rtffonts + (style * RTFCACHELINESIZE);
-
- return "";
-}
-
static void Log_Append(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *fmt, ...)
{
va_list va;
@@ -597,7 +585,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
case 'r':
if (!streamData->bStripFormat) {
int index = EventToIndex(streamData->lin);
- mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index));
+ mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", pci->Log_SetStyle(index));
}
break;
}
@@ -748,11 +736,10 @@ char* Log_CreateRtfHeader(MODULEINFO *mi)
//get the number of pixels per logical inch
- if (logPixelSY == 0) {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ if (pci->logPixelSY == 0) {
+ HDC hdc = GetDC(NULL);
+ pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(NULL, hdc);
}
@@ -791,15 +778,15 @@ char* Log_CreateRtfHeader(MODULEINFO *mi)
HFONT hFont = CreateFontIndirect(&lf);
int iText = GetTextPixelSize(szString, hFont, true) + 3;
DeleteObject(hFont);
- iIndent += (iText * 1440) / logPixelSX;
+ iIndent += (iText * 1440) / pci->logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
else if (g_Settings.dwIconFlags) {
- iIndent += ((g_Settings.bScaleIcons ? 14 : 20) * 1440) / logPixelSX;
+ iIndent += ((g_Settings.bScaleIcons ? 14 : 20) * 1440) / pci->logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
}
if (g_Settings.bShowTime) {
- int iSize = (g_Settings.LogTextIndent * 1440) / logPixelSX;
+ int iSize = (g_Settings.LogTextIndent * 1440) / pci->logPixelSX;
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
if (g_Settings.bLogIndentEnabled)
iIndent += iSize;
@@ -812,7 +799,7 @@ char* Log_CreateRtfHeader(MODULEINFO *mi)
static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
- int bufferAlloced, bufferEnd, i, me = 0;
+ int bufferAlloced, bufferEnd, me = 0;
LOGINFO * lin = streamData->lin;
MODULEINFO *mi = pci->MM_FindModule(streamData->si->pszModule);
@@ -852,12 +839,12 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
streamData->dat->dwFlags &= ~MWF_DIVIDERWANTED;
}
// create new line, and set font and color
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\ql\\sl0%s ", Log_SetStyle(0, 0));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\ql\\sl0%s ", pci->Log_SetStyle(0));
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\v~-+%d+-~\\v0 ", lin);
// Insert icon
if (g_Settings.bLogSymbols) // use symbols
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s %c", Log_SetStyle(17, 17), EventToSymbol(lin));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s %c", pci->Log_SetStyle(17), EventToSymbol(lin));
else if (g_Settings.dwIconFlags) {
int iIndex = lin->bIsHighlighted ? ICON_HIGHLIGHT : EventToIcon(lin);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\f0\\fs14");
@@ -875,16 +862,18 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
int iii;
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) {
iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0,F.lfItalic,F.lfUnderline, 2 * abs(F.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u",
+ iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0,F.lfItalic,F.lfUnderline, 2 * abs(F.lfHeight) * 74 / pci->logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
else {
iii = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic,F.lfUnderline ,2 * abs(F.lfHeight) * 74 / logPixelSY);
+ mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u",
+ iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic,F.lfUnderline ,2 * abs(F.lfHeight) * 74 / pci->logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
}
- else Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(0, 0));
+ else Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", pci->Log_SetStyle(0));
// insert a TAB if necessary to put the timestamp in the right position
if (g_Settings.dwIconFlags)
@@ -912,7 +901,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog)
pszIndicator[0] = GetIndicator(streamData->si, lin->ptszNick, &crNickIndex);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsMe ? 2 : 1, lin->bIsMe ? 2 : 1));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", pci->Log_SetStyle(lin->bIsMe ? 2 : 1));
if (g_Settings.bLogClassicIndicators)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s", pszIndicator);
@@ -937,8 +926,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
}
// Insert the message
- i = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", pci->Log_SetStyle(lin->bIsHighlighted ? 16 : EventToIndex(lin)));
streamData->lin = lin;
AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
}
@@ -1032,10 +1020,9 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr
//get the number of pixels per logical inch
if (bRedraw) {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ HDC hdc = GetDC(NULL);
+ pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(NULL, hdc);
SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0);
bFlag = true;
@@ -1146,22 +1133,3 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedr
InvalidateRect(hwndRich, NULL, TRUE);
}
}
-
-void Log_SetStyles()
-{
- if (logPixelSY == 0) {
- HDC hdc;
- hdc = GetDC(NULL);
- logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
- ReleaseDC(NULL, hdc);
- }
-
- for (int i = 0; i < OPTIONS_FONTCOUNT; i++) {
- LOGFONT &F = pci->aFonts[i].lf;
- mir_snprintf(CHAT_rtfFontsGlobal[i], RTFCACHELINESIZE,
- "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", i, i + 1,
- F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / logPixelSY);
- }
- CHAT_rtffonts = &(CHAT_rtfFontsGlobal[0][0]);
-}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 6eb0c2295f..914084cf02 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -196,8 +196,6 @@ static void OnLoadSettings()
if (g_Settings.SelectionBGBrush)
DeleteObject(g_Settings.SelectionBGBrush);
g_Settings.SelectionBGBrush = CreateSolidBrush(g_Settings.nickColors[5]);
-
- Log_SetStyles();
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp
index ba995964ef..42b2baf55c 100644
--- a/plugins/TabSRMM/src/chat/options.cpp
+++ b/plugins/TabSRMM/src/chat/options.cpp
@@ -545,7 +545,6 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
pci->ReloadSettings();
pci->MM_IconsChanged();
pci->MM_FontsChanged();
- Log_SetStyles();
pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
SM_ReconfigureFilters();
return TRUE;
@@ -736,7 +735,6 @@ void RegisterFontServiceFonts() {
int FontServiceFontsChanged(WPARAM,LPARAM)
{
- Log_SetStyles();
PluginConfig.reloadSettings();
CSkin::initAeroEffect();
CacheMsgLogIcons();
@@ -984,7 +982,6 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
pci->ReloadSettings();
pci->MM_FontsChanged();
- Log_SetStyles();
pci->MM_FixColors();
pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
@@ -1105,7 +1102,6 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
pci->ReloadSettings();
pci->MM_FontsChanged();
- Log_SetStyles();
pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
SM_ReconfigureFilters();
return TRUE;
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp
index c0b769a216..61beccc984 100644
--- a/plugins/TabSRMM/src/chat/services.cpp
+++ b/plugins/TabSRMM/src/chat/services.cpp
@@ -166,7 +166,6 @@ 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;
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 68b58bf296..eb1afae46e 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -156,7 +156,6 @@ void TSAPI CacheLogFonts()
if (CInfoPanel::m_ipConfig.hFonts[i])
DeleteObject(CInfoPanel::m_ipConfig.hFonts[i]);
LoadLogfont(i + 100, &lf, &clr, FONTMODULE);
- //lf.lfHeight =-MulDiv(lf.lfHeight, logPixelSY, 72);
lf.lfUnderline = 0;
CInfoPanel::m_ipConfig.hFonts[i] = CreateFontIndirectA(&lf);
CInfoPanel::m_ipConfig.clrs[i] = clr;
@@ -164,9 +163,9 @@ void TSAPI CacheLogFonts()
hdc = GetDC(PluginConfig.g_hwndHotkeyHandler);
- HFONT hOldFont = (HFONT)SelectObject(hdc, CInfoPanel::m_ipConfig.hFonts[IPFONTID_NICK]);
- SIZE sz;
+ HFONT hOldFont = (HFONT)SelectObject(hdc, CInfoPanel::m_ipConfig.hFonts[IPFONTID_NICK]);
+ SIZE sz;
GetTextExtentPoint32(hdc, _T("WMA"), 3, &sz);
CInfoPanel::m_ipConfig.height1 = sz.cy;
SelectObject(hdc, CInfoPanel::m_ipConfig.hFonts[IPFONTID_UIN]);
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h
index d16fa6bcd8..de8dac8906 100644
--- a/src/modules/chat/chat.h
+++ b/src/modules/chat/chat.h
@@ -52,6 +52,7 @@ TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time);
TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
char* Log_CreateRtfHeader(MODULEINFO *mi);
char* Log_CreateRTF(LOGSTREAMDATA *streamData);
+char* Log_SetStyle(int style);
// clist.c
BOOL AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ...);
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index 6aeb1132c3..e042d23f99 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -28,7 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
PBYTE pLogIconBmpBits[14];
int logIconBmpSize[ SIZEOF(pLogIconBmpBits) ];
-static int EventToIndex(LOGINFO * lin)
+#define RTFCACHELINESIZE 128
+static char CHAT_rtfFontsGlobal[OPTIONS_FONTCOUNT][RTFCACHELINESIZE];
+
+static int EventToIndex(LOGINFO *lin)
{
switch (lin->iType) {
case GC_EVENT_MESSAGE:
@@ -52,7 +55,7 @@ static int EventToIndex(LOGINFO * lin)
return 0;
}
-static int EventToIcon(LOGINFO * lin)
+static int EventToIcon(LOGINFO *lin)
{
switch (lin->iType) {
case GC_EVENT_MESSAGE:
@@ -76,14 +79,12 @@ static int EventToIcon(LOGINFO * lin)
return 0;
}
-static char* Log_SetStyle(int style, int fontindex)
+char* Log_SetStyle(int style)
{
- LOGFONT &lf = ci.aFonts[fontindex].lf;
+ if (style < OPTIONS_FONTCOUNT)
+ return CHAT_rtfFontsGlobal[style];
- static char szStyle[128];
- mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u",
- style, style + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
- return szStyle;
+ return "";
}
static void Log_Append(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *fmt, ...)
@@ -191,7 +192,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
case 'r':
if ( !streamData->bStripFormat ) {
int index = EventToIndex(streamData->lin);
- mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index, index));
+ mir_snprintf(szTemp, SIZEOF(szTemp), "%s ", Log_SetStyle(index));
}
break;
}
@@ -238,79 +239,79 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced,
pszNick = szTemp;
}
- if (streamData && streamData->lin) {
- switch (streamData->lin->iType) {
- case GC_EVENT_MESSAGE:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_ACTION:
- if (streamData->lin->ptszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick);
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_JOIN:
- if (pszNick) {
- if (!streamData->lin->bIsMe)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has joined"), pszNick);
- else
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName);
- }
- break;
- case GC_EVENT_PART:
- if (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_QUIT:
- if (pszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_NICK:
- if (pszNick && streamData->lin->ptszText) {
- if (!streamData->lin->bIsMe)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText);
- else
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_KICK:
- if (streamData->lin->ptszNick && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, streamData->lin->ptszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_NOTICE:
- if (pszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s: "), pszNick);
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
- }
- break;
- case GC_EVENT_TOPIC:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r"));
- if (streamData->lin->ptszNick)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced,
- streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)") : TranslateT(" (set by %s)"),
- streamData->lin->ptszNick, streamData->lin->ptszUserInfo);
- break;
- case GC_EVENT_INFORMATION:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText);
- break;
- case GC_EVENT_ADDSTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s enables \'%s\' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
- break;
- case GC_EVENT_REMOVESTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s disables \'%s\' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
- break;
-} } }
+ switch (streamData->lin->iType) {
+ case GC_EVENT_MESSAGE:
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
+ break;
+ case GC_EVENT_ACTION:
+ if (streamData->lin->ptszNick && streamData->lin->ptszText) {
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T("%s "), streamData->lin->ptszNick);
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
+ }
+ break;
+ case GC_EVENT_JOIN:
+ if (pszNick) {
+ if (!streamData->lin->bIsMe)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has joined"), pszNick);
+ else
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("You have joined %s"), streamData->si->ptszName);
+ }
+ break;
+ case GC_EVENT_PART:
+ if (pszNick)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has left"), pszNick);
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
+ break;
+ case GC_EVENT_QUIT:
+ if (pszNick)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s has disconnected"), pszNick);
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
+ break;
+ case GC_EVENT_NICK:
+ if (pszNick && streamData->lin->ptszText) {
+ if (!streamData->lin->bIsMe)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText);
+ else
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("You are now known as %s"), streamData->lin->ptszText);
+ }
+ break;
+ case GC_EVENT_KICK:
+ if (streamData->lin->ptszNick && streamData->lin->ptszStatus)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, streamData->lin->ptszNick);
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T(": %s"), streamData->lin->ptszText);
+ break;
+ case GC_EVENT_NOTICE:
+ if (pszNick && streamData->lin->ptszText) {
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("Notice from %s: "), pszNick);
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), streamData->lin->ptszText);
+ }
+ break;
+ case GC_EVENT_TOPIC:
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, TranslateT("The topic is \'%s%s\'"), streamData->lin->ptszText, _T("%r"));
+ if (streamData->lin->ptszNick)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced,
+ streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)") : TranslateT(" (set by %s)"),
+ streamData->lin->ptszNick, streamData->lin->ptszUserInfo);
+ break;
+ case GC_EVENT_INFORMATION:
+ if (streamData->lin->ptszText)
+ Log_AppendRTF(streamData, FALSE, buffer, bufferEnd, bufferAlloced, (streamData->lin->bIsMe) ? _T("--> %s") : _T("%s"), streamData->lin->ptszText);
+ break;
+ case GC_EVENT_ADDSTATUS:
+ if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s enables \'%s\' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
+ break;
+ case GC_EVENT_REMOVESTATUS:
+ if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
+ Log_AppendRTF(streamData, TRUE, buffer, bufferEnd, bufferAlloced, TranslateT("%s disables \'%s\' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
+ break;
+ }
+}
TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time)
{
@@ -323,8 +324,8 @@ TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time)
char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
- int bufferAlloced, bufferEnd, i, me = 0;
- LOGINFO * lin = streamData->lin;
+ int bufferAlloced, bufferEnd, me = 0;
+ LOGINFO *lin = streamData->lin;
MODULEINFO *mi = ci.MM_FindModule(streamData->si->pszModule);
// guesstimate amount of memory for the RTF
@@ -343,7 +344,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
// filter
if (streamData->si->iType != GCW_CHATROOM || !streamData->si->bFilterEnabled || (streamData->si->iLogFilterFlags&lin->iType) != 0) {
// create new line, and set font and color
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\par%s ", Log_SetStyle(0, 0));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\par%s ", Log_SetStyle(0));
// Insert icon
if ((lin->iType & g_Settings->dwIconFlags) || lin->bIsHighlighted && (g_Settings->dwIconFlags & GC_EVENT_HIGHLIGHT)) {
@@ -373,7 +374,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
}
- else Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(0, 0));
+ else Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(0));
// insert a TAB if necessary to put the timestamp in the right position
if (g_Settings->dwIconFlags)
@@ -396,7 +397,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) {
TCHAR pszTemp[300], *p1;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsMe ? 2 : 1, lin->bIsMe ? 2 : 1));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsMe ? 2 : 1));
lstrcpyn(pszTemp, lin->bIsMe ? g_Settings->pszOutgoingNick : g_Settings->pszIncomingNick, 299);
p1 = _tcsstr(pszTemp, _T("%n"));
if (p1)
@@ -407,8 +408,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
}
// Insert the message
- i = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsHighlighted ? 16 : EventToIndex(lin)));
streamData->lin = lin;
AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
}
@@ -521,6 +521,21 @@ void LoadMsgLogBitmaps(void)
DeleteObject(hBmp);
ReleaseDC(NULL, hdc);
DeleteObject(hBkgBrush);
+
+ if (ci.logPixelSY == 0) {
+ HDC hdc;
+ hdc = GetDC(NULL);
+ ci.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ ci.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
+ }
+
+ for (int i = 0; i < OPTIONS_FONTCOUNT; i++) {
+ LOGFONT &F = ci.aFonts[i].lf;
+ mir_snprintf(CHAT_rtfFontsGlobal[i], RTFCACHELINESIZE,
+ "\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", i, i + 1,
+ F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / ci.logPixelSY);
+ }
}
void FreeMsgLogBitmaps(void)
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index 1b8b498d49..9a5e0fcf83 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -1465,6 +1465,7 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam)
ci.ShowPopup = ShowPopup;
ci.LogToFile = LogToFile;
ci.GetChatLogsFilename = GetChatLogsFilename;
+ ci.Log_SetStyle = Log_SetStyle;
ci.IsHighlighted = IsHighlighted;
ci.RemoveFormatting = RemoveFormatting;