summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/stdchat/src/chat.h4
-rw-r--r--src/core/stdchat/src/main.cpp3
-rw-r--r--src/modules/chat/chat_opts.cpp34
-rw-r--r--src/modules/chat/chat_svc.cpp44
-rw-r--r--src/modules/chat/log.cpp140
-rw-r--r--src/modules/chat/manager.cpp7
6 files changed, 89 insertions, 143 deletions
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h
index 6c10e9f557..c0221d4f86 100644
--- a/src/core/stdchat/src/chat.h
+++ b/src/core/stdchat/src/chat.h
@@ -68,6 +68,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "version.h"
#include "richutil.h"
+#define EM_SUBCLASSED (WM_USER+200)
+#define EM_UNSUBCLASSED (WM_USER+201)
+#define EM_ACTIVATE (WM_USER+202)
+
struct TABLIST
{
TCHAR* pszID;
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp
index ae73933d2e..b169f56595 100644
--- a/src/core/stdchat/src/main.cpp
+++ b/src/core/stdchat/src/main.cpp
@@ -257,8 +257,7 @@ extern "C" __declspec(dllexport) int Load(void)
mir_getLP(&pluginInfo);
mir_getCLI();
- mir_getCI();
- pci->pSettings = &g_Settings;
+ mir_getCI(&g_Settings);
pci->OnAddUser = OnAddUser;
pci->OnNewUser = OnNewUser;
pci->OnRemoveUser = OnRemoveUser;
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp
index 9702417678..0d5d422310 100644
--- a/src/modules/chat/chat_opts.cpp
+++ b/src/modules/chat/chat_opts.cpp
@@ -32,15 +32,15 @@ HANDLE g_hOptions = NULL;
#define FONTF_ITALIC 2
struct FontOptionsList
{
- const TCHAR* szDescr;
- COLORREF defColour;
- const TCHAR* szDefFace;
- BYTE defCharset, defStyle;
- char defSize;
- COLORREF colour;
- const TCHAR* szFace;
- BYTE charset, style;
- char size;
+ LPCTSTR szDescr;
+ COLORREF defColour;
+ LPCTSTR szDefFace;
+ BYTE defCharset, defStyle;
+ char defSize;
+ COLORREF colour;
+ LPCTSTR szFace;
+ BYTE charset, style;
+ char size;
}
//remeber to put these in the Translate( ) template file too
@@ -71,7 +71,7 @@ const int msgDlgFontCount = SIZEOF(fontOptionsList);
void LoadLogFonts(void)
{
- for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
+ for (int i=0; i < OPTIONS_FONTCOUNT; i++)
LoadMsgDlgFont(i, &ci.aFonts[i].lf, &ci.aFonts[i].color);
}
@@ -115,17 +115,16 @@ void LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF* colour)
void RegisterFonts(void)
{
- FontIDT fontid = { 0 };
- ColourIDT colourid;
- char idstr[10];
- int index = 0, i;
+ int index = 0;
- fontid.cbSize = sizeof(FontIDT);
+ FontIDT fontid = { sizeof(fontid) };
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_NEEDRESTART;
- for (i = 0; i < msgDlgFontCount; i++, index++) {
+ for (int i=0; i < msgDlgFontCount; i++, index++) {
strncpy(fontid.dbSettingsGroup, "ChatFonts", sizeof(fontid.dbSettingsGroup));
_tcsncpy(fontid.group, _T("Chat module"), SIZEOF(fontid.group));
_tcsncpy(fontid.name, fontOptionsList[i].szDescr, SIZEOF(fontid.name));
+
+ char idstr[10];
mir_snprintf(idstr, SIZEOF(idstr), "Font%d", index);
strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
fontid.order = index;
@@ -151,8 +150,7 @@ void RegisterFonts(void)
FontRegisterT(&fontid);
}
- colourid.cbSize = sizeof(ColourIDT);
- colourid.order = 0;
+ ColourIDT colourid = { sizeof(colourid) };
strncpy(colourid.dbSettingsGroup, "Chat", sizeof(colourid.dbSettingsGroup));
strncpy(colourid.setting, "ColorLogBG", SIZEOF(colourid.setting));
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index 44d6be8c1b..d7cf19655d 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -533,28 +533,6 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
char* mods[3] = { "Chat", "ChatFonts" };
CallService("DBEditorpp/RegisterModule", (WPARAM)mods, 2);
- RegisterFonts();
- OptionsInit();
-
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = -2000090001;
- mi.flags = CMIF_DEFAULT;
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN);
- mi.pszName = LPGEN("&Join");
- mi.pszService = "GChat/JoinChat";
- hJoinMenuItem = Menu_AddContactMenuItem(&mi);
-
- mi.position = -2000090000;
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_LEAVE);
- mi.flags = CMIF_NOTOFFLINE;
- mi.pszName = LPGEN("&Leave");
- mi.pszService = "GChat/LeaveChat";
- hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
-
- HookEvent(ME_FONT_RELOAD, FontsChanged);
- HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
- HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileyOptionsChanged);
-
ci.SetAllOffline(TRUE, NULL);
return 0;
}
@@ -595,6 +573,28 @@ void LoadChatModule(void)
ci.hSendEvent = CreateHookableEvent(ME_GC_EVENT);
ci.hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
+
+ RegisterFonts();
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = -2000090001;
+ mi.flags = CMIF_DEFAULT;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN);
+ mi.pszName = LPGEN("&Join");
+ mi.pszService = "GChat/JoinChat";
+ hJoinMenuItem = Menu_AddContactMenuItem(&mi);
+
+ mi.position = -2000090000;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_LEAVE);
+ mi.flags = CMIF_NOTOFFLINE;
+ mi.pszName = LPGEN("&Leave");
+ mi.pszService = "GChat/LeaveChat";
+ hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
+
+ HookEvent(ME_FONT_RELOAD, FontsChanged);
+ HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
+ HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileyOptionsChanged);
+
bInited = true;
}
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index f791809f54..61bbde9585 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -339,20 +339,16 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
if (header)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, header);
-
// ### RTF BODY (one iteration per event that should be streamed in)
- while ( lin )
- {
+ 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) {
// create new line, and set font and color
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\par%s ", Log_SetStyle(0, 0));
// Insert icon
- if (lin->iType&ci.pSettings->dwIconFlags || lin->bIsHighlighted&&ci.pSettings->dwIconFlags&GC_EVENT_HIGHLIGHT)
- {
- int iIndex = (lin->bIsHighlighted&&ci.pSettings->dwIconFlags&GC_EVENT_HIGHLIGHT) ? ICON_HIGHLIGHT : EventToIcon(lin);
+ if (lin->iType & ci.pSettings->dwIconFlags || lin->bIsHighlighted&&ci.pSettings->dwIconFlags & GC_EVENT_HIGHLIGHT) {
+ int iIndex = (lin->bIsHighlighted && ci.pSettings->dwIconFlags & GC_EVENT_HIGHLIGHT) ? ICON_HIGHLIGHT : EventToIcon(lin);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\f0\\fs14");
while (bufferAlloced - bufferEnd < logIconBmpSize[0])
bufferAlloced += 4096;
@@ -361,35 +357,31 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
bufferEnd += logIconBmpSize[iIndex];
}
- if (ci.pSettings->TimeStampEventColour)
- {
+ if (ci.pSettings->TimeStampEventColour) {
LOGFONT &lf = ci.aFonts[0].lf;
// colored timestamps
static char szStyle[256];
int iii;
- if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE)
- {
+ 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\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.logPixelSY);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", szStyle);
}
- else
- {
+ else {
iii = lin->bIsHighlighted?16:EventToIndex(lin);
mir_snprintf(szStyle, SIZEOF(szStyle), "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / ci.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 ", Log_SetStyle(0, 0 ));
+
// insert a TAB if necessary to put the timestamp in the right position
if (ci.pSettings->dwIconFlags)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tab ");
//insert timestamp
- if (ci.pSettings->ShowTime)
- {
+ if (ci.pSettings->ShowTime) {
TCHAR szTimeStamp[30], szOldTimeStamp[30];
lstrcpyn( szTimeStamp, MakeTimeStamp(ci.pSettings->pszTimeStamp, lin->time), 30);
@@ -402,8 +394,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
}
// Insert the nick
- if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE)
- {
+ 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));
@@ -417,13 +408,10 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
}
// Insert the message
- {
- i = lin->bIsHighlighted?16:EventToIndex(lin);
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
- streamData->lin = lin;
- AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
- }
-
+ i = lin->bIsHighlighted?16:EventToIndex(lin);
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(i, i));
+ streamData->lin = lin;
+ AddEventToBuffer(&buffer, &bufferEnd, &bufferAlloced, streamData);
}
lin = lin->prev;
}
@@ -433,49 +421,17 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
return buffer;
}
-static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
+char* Log_CreateRtfHeader(MODULEINFO *mi)
{
- LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA *) dwCookie;
-
- if (lstrdat)
- {
- // create the RTF
- if (lstrdat->buffer == NULL)
- {
- lstrdat->bufferOffset = 0;
- lstrdat->buffer = Log_CreateRTF(lstrdat);
- lstrdat->bufferLen = lstrlenA(lstrdat->buffer);
- }
-
- // give the RTF to the RE control
- *pcb = min(cb, lstrdat->bufferLen - lstrdat->bufferOffset);
- CopyMemory(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
- lstrdat->bufferOffset += *pcb;
-
- // free stuff if the streaming operation is complete
- if (lstrdat->bufferOffset == lstrdat->bufferLen)
- {
- mir_free(lstrdat->buffer);
- lstrdat->buffer = NULL;
- }
- }
-
- return 0;
-}
-
-char* Log_CreateRtfHeader(MODULEINFO * mi)
-{
- char *buffer;
- int bufferAlloced, bufferEnd, i = 0;
+ int bufferAlloced, bufferEnd, i;
// guesstimate amount of memory for the RTF header
bufferEnd = 0;
bufferAlloced = 4096;
- buffer = (char *) mir_realloc(mi->pszHeader, bufferAlloced);
+ char *buffer = (char *)mir_realloc(mi->pszHeader, bufferAlloced);
buffer[0] = '\0';
-
- //get the number of pixels per logical inch
+ // get the number of pixels per logical inch
HDC hdc = GetDC(NULL);
ci.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
ci.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
@@ -501,36 +457,25 @@ char* Log_CreateRtfHeader(MODULEINFO * mi)
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}\\pard");
// set tabs and indents
- {
- int iIndent = 0;
+ int iIndent = 0;
- if (ci.pSettings->dwIconFlags)
- {
- iIndent += (14 * 1440) / ci.logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
- }
- if (ci.pSettings->ShowTime)
- {
- int iSize = (ci.pSettings->LogTextIndent * 1440) / ci.logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
- if (ci.pSettings->LogIndentEnabled)
- iIndent += iSize;
- }
- /*
- { // text indent
- int iSize = (135*1440)/logPixelSX;
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize );
+ if (ci.pSettings->dwIconFlags) {
+ iIndent += (14 * 1440) / ci.logPixelSX;
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
+ }
+ if (ci.pSettings->ShowTime) {
+ int iSize = (ci.pSettings->LogTextIndent * 1440) / ci.logPixelSX;
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
if (ci.pSettings->LogIndentEnabled)
- iIndent += iSize;
-
- }
- */
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
+ iIndent += iSize;
}
+
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
return buffer;
}
-#define RTFPICTHEADERMAXSIZE 78
+#define RTFPICTHEADERMAXSIZE 78
+
void LoadMsgLogBitmaps(void)
{
HBRUSH hBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW)));
@@ -556,20 +501,20 @@ void LoadMsgLogBitmaps(void)
for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
HICON hIcon = ci.hIcons[i];
size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2;
- pLogIconBmpBits[i] = (PBYTE) mir_alloc(size);
+ pLogIconBmpBits[i] = (PBYTE)mir_alloc(size);
int rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBkgBrush);
DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
SelectObject(hdcMem, hoBmp);
- GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *) & bih, DIB_RGB_COLORS);
- {
- int n;
- for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!!!
- for (n = 0; n < widthBytes * bih.biHeight; n += 4)
- sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
- }
+ GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *)& bih, DIB_RGB_COLORS);
+
+ int n;
+ for (n = 0; n < sizeof(BITMAPINFOHEADER); n++)
+ sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE)& bih)[n]); //!!!!!!!!!!!!!
+ for (n = 0; n < widthBytes * bih.biHeight; n += 4)
+ sprintf((char *)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!!
+
logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1;
pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}';
}
@@ -582,7 +527,6 @@ void LoadMsgLogBitmaps(void)
void FreeMsgLogBitmaps(void)
{
- int i;
- for (i = 0; i < SIZEOF(pLogIconBmpBits); i++)
+ for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++)
mir_free(pLogIconBmpBits[i]);
}
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index 4b2194df98..cacb05eb50 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -66,8 +66,7 @@ static SESSION_INFO* SM_AddSession(const TCHAR *pszID, const char *pszModule)
return NULL;
if (!ci.SM_FindSession(pszID, pszModule)) {
- SESSION_INFO *node = (SESSION_INFO*)mir_alloc(sizeof(SESSION_INFO));
- ZeroMemory(node, sizeof(SESSION_INFO));
+ SESSION_INFO *node = (SESSION_INFO*)mir_calloc(sizeof(SESSION_INFO));
node->ptszID = mir_tstrdup(pszID);
node->pszModule = mir_strdup(pszModule);
@@ -1483,8 +1482,10 @@ CHAT_MANAGER ci =
LoadMsgDlgFont
};
-INT_PTR SvcGetChatManager(WPARAM, LPARAM)
+INT_PTR SvcGetChatManager(WPARAM, LPARAM lParam)
{
LoadChatModule();
+ ci.pSettings = (GlobalLogSettingsBase*)lParam;
+ OptionsInit();
return (INT_PTR)&ci;
}