summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-20 21:29:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-20 21:29:27 +0000
commit61ebbb725edaec25bd3c2def9a878657d5b568b4 (patch)
tree373738b603617e0f990f0c4c86ae726ce0ecd49e /plugins
parentfba7c419848c0c99caf305fc16c7d37c76a08357 (diff)
Scriver: massive code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4492 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat/log.cpp87
-rw-r--r--plugins/Scriver/src/chat/manager.cpp35
-rw-r--r--plugins/Scriver/src/chat/options.cpp10
-rw-r--r--plugins/Scriver/src/chat/services.cpp342
-rw-r--r--plugins/Scriver/src/chat/tools.cpp187
-rw-r--r--plugins/Scriver/src/chat/window.cpp27
-rw-r--r--plugins/Scriver/src/commonheaders.h2
-rw-r--r--plugins/Scriver/src/globals.cpp2
-rw-r--r--plugins/Scriver/src/infobar.cpp7
-rw-r--r--plugins/Scriver/src/msgdialog.cpp112
-rw-r--r--plugins/Scriver/src/msglog.cpp703
-rw-r--r--plugins/Scriver/src/msgoptions.cpp2
-rw-r--r--plugins/Scriver/src/msgs.cpp4
-rw-r--r--plugins/Scriver/src/msgwindow.cpp2
-rw-r--r--plugins/Scriver/src/srmm.cpp10
-rw-r--r--plugins/Scriver/src/utils.cpp14
16 files changed, 723 insertions, 823 deletions
diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp
index e9b84c405f..27696f1a01 100644
--- a/plugins/Scriver/src/chat/log.cpp
+++ b/plugins/Scriver/src/chat/log.cpp
@@ -108,7 +108,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff
lineLen = lineLen*20 + 8;
if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char*) mir_realloc(*buffer, *cbBufferAlloced);
}
d = *buffer + *cbBufferEnd;
@@ -489,26 +489,18 @@ static void LogEventIEView(LOGSTREAMDATA *streamData, TCHAR *ptszNick)
TCHAR *buffer = NULL;
int bufferEnd = 0;
int bufferAlloced = 0;
- IEVIEWEVENTDATA ied;
- IEVIEWEVENT event;
- ZeroMemory(&event, sizeof(event));
- event.cbSize = sizeof(event);
- event.dwFlags = 0;
+
+ IEVIEWEVENTDATA ied = { 0 };
+
+ IEVIEWEVENT event = { sizeof(event) };
event.hwnd = streamData->si->windowData.hwndLog;
event.hContact = streamData->si->windowData.hContact;
event.codepage = streamData->si->windowData.codePage;
event.pszProto = streamData->si->pszModule;
- /*
- if (!fAppend) {
- event.iType = IEE_CLEAR_LOG;
- CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
- }
- */
event.iType = IEE_LOG_MEM_EVENTS;
event.eventData = &ied;
event.count = 1;
- ZeroMemory(&ied, sizeof(ied));
AddEventToBufferIEView(&buffer, &bufferEnd, &bufferAlloced, streamData, ptszNick);
ied.ptszNick = ptszNick;
ied.ptszText = buffer;
@@ -591,7 +583,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData, BOOL ieviewMode)
// guesstimate amount of memory for the RTF
bufferEnd = 0;
bufferAlloced = streamData->bRedraw ? 1024 * (streamData->si->iEventCount+2) : 2048;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char*) mir_alloc(bufferAlloced);
buffer[0] = '\0';
// ### RTF HEADER
@@ -641,7 +633,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData, BOOL ieviewMode)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fs1 ");
while (bufferAlloced - bufferEnd < logIconBmpSize[0])
bufferAlloced += 4096;
- buffer = (char *) mir_realloc(buffer, bufferAlloced);
+ buffer = (char*) mir_realloc(buffer, bufferAlloced);
CopyMemory(buffer + bufferEnd, pLogIconBmpBits[iIndex], logIconBmpSize[iIndex]);
bufferEnd += logIconBmpSize[iIndex];
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " ");
@@ -749,8 +741,6 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw)
{
- EDITSTREAM stream;
- LOGSTREAMDATA streamData;
CHARRANGE oldsel, sel, newsel;
POINT point ={0};
SCROLLINFO scroll;
@@ -761,20 +751,19 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
return;
hwndRich = GetDlgItem(hwndDlg, IDC_CHAT_LOG);
- ZeroMemory(&streamData, sizeof(LOGSTREAMDATA));
+
+ LOGSTREAMDATA streamData = { 0 };
streamData.hwnd = hwndRich;
streamData.si = si;
streamData.lin = lin;
streamData.bStripFormat = FALSE;
streamData.isFirst = bRedraw ? 1 : (GetRichTextLength(hwndRich, CP_ACP, FALSE) == 0);
- // bPhaseTwo = bRedraw && bPhaseTwo;
-
if (bRedraw || si->iType != GCW_CHATROOM || !si->bFilterEnabled || (si->iLogFilterFlags&lin->iType) != 0)
{
BOOL bFlag = FALSE;
- ZeroMemory(&stream, sizeof(stream));
+ EDITSTREAM stream = { 0 };
stream.pfnCallback = Log_StreamCallback;
stream.dwCookie = (DWORD_PTR) & streamData;
scroll.cbSize= sizeof(SCROLLINFO);
@@ -820,14 +809,12 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
&& lin->iType != GC_EVENT_ADDSTATUS
&& lin->iType != GC_EVENT_REMOVESTATUS )))
{
- SMADD_RICHEDIT3 sm;
-
newsel.cpMax = -1;
newsel.cpMin = sel.cpMin;
if (newsel.cpMin < 0)
newsel.cpMin = 0;
- ZeroMemory(&sm, sizeof(sm));
- sm.cbSize = sizeof(sm);
+
+ SMADD_RICHEDIT3 sm = { sizeof(sm) };
sm.hwndRichEditControl = hwndRich;
sm.Protocolname = si->pszModule;
sm.rangeToReplace = bRedraw?NULL:&newsel;
@@ -872,7 +859,7 @@ char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si)
// guesstimate amount of memory for the RTF header
bufferEnd = 0;
bufferAlloced = 4096;
- buffer = (char *) mir_realloc(si->pszHeader, bufferAlloced);
+ buffer = (char*) mir_realloc(si->pszHeader, bufferAlloced);
buffer[0] = '\0';
// ### RTF HEADER
@@ -918,47 +905,43 @@ char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si)
#define RTFPICTHEADERMAXSIZE 78
void LoadMsgLogBitmaps(void)
{
- HICON hIcon;
- HBITMAP hBmp, hoBmp;
- HDC hdc, hdcMem;
- BITMAPINFOHEADER bih = { 0 };
- int widthBytes, i;
- RECT rc;
- HBRUSH hBkgBrush;
- int rtfHeaderSize;
- PBYTE pBmpBits;
+ HBRUSH hBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW)));
- hBkgBrush = CreateSolidBrush(db_get_dw(NULL, "Chat", "ColorLogBG", GetSysColor(COLOR_WINDOW)));
+ BITMAPINFOHEADER bih = { 0 };
bih.biSize = sizeof(bih);
bih.biBitCount = 24;
bih.biCompression = BI_RGB;
bih.biHeight = 10; //GetSystemMetrics(SM_CYSMICON);
bih.biPlanes = 1;
bih.biWidth = 10; //GetSystemMetrics(SM_CXSMICON);
- widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
+
+ int widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
+
+ RECT rc;
rc.top = rc.left = 0;
rc.right = bih.biWidth;
rc.bottom = bih.biHeight;
- hdc = GetDC(NULL);
- hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
- hdcMem = CreateCompatibleDC(hdc);
- pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
- for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
- hIcon = GetCachedIcon(logIconNames[i]);
+
+ HDC hdc = GetDC(NULL);
+ HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ PBYTE pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
+ for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
+ HICON hIcon = GetCachedIcon(logIconNames[i]);
pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
- rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, (unsigned int)bih.biWidth, (unsigned int)bih.biHeight);
- hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
+ int rtfHeaderSize = sprintf((char*)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, (unsigned int)bih.biWidth, (unsigned int)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]);
- }
+
+ 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] = '}';
}
diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp
index 17a0745726..30dd1e849b 100644
--- a/plugins/Scriver/src/chat/manager.cpp
+++ b/plugins/Scriver/src/chat/manager.cpp
@@ -65,8 +65,7 @@ SESSION_INFO* SM_AddSession( const TCHAR* pszID, const char* pszModule)
return NULL;
if ( !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 );
node->windowData.flags = CWDF_RTF_INPUT;
@@ -126,14 +125,14 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta
if (removeContact)
CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->windowData.hContact, 0);
- mir_free( pTemp->pszModule );
- mir_free( pTemp->ptszID );
- mir_free( pTemp->ptszName );
- mir_free( pTemp->ptszStatusbarText );
- mir_free( pTemp->ptszTopic );
- mir_free( pTemp->pszHeader );
- mir_free( pTemp->pszID );
- mir_free( pTemp->pszName );
+ mir_free(pTemp->pszModule);
+ mir_free(pTemp->ptszID);
+ mir_free(pTemp->ptszName);
+ mir_free(pTemp->ptszStatusbarText);
+ mir_free(pTemp->ptszTopic);
+ mir_free(pTemp->pszHeader);
+ mir_free(pTemp->pszID);
+ mir_free(pTemp->pszName);
// delete commands
tcmdlist_free(pTemp->windowData.cmdList);
@@ -763,7 +762,7 @@ char* SM_GetUsers(SESSION_INFO *si)
do {
int pLen = lstrlenA(p), nameLen = lstrlen(utemp->pszUID);
if ( pLen + nameLen + 2 > alloced )
- p = (char *)mir_realloc( p, alloced += 4096 );
+ p = (char*)mir_realloc( p, alloced += 4096 );
WideCharToMultiByte( CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen+1, 0, 0 );
@@ -925,8 +924,7 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int
return NULL;
if ( !TM_FindStatus(*ppStatusList, pszStatus)) {
- STATUSINFO *node = (STATUSINFO*) mir_alloc(sizeof(STATUSINFO));
- ZeroMemory(node, sizeof(STATUSINFO));
+ STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
replaceStr( &node->pszGroup, pszStatus );
node->hIcon = (HICON)(*iCount);
while ((INT_PTR)node->hIcon > STATUSICONCOUNT - 1)
@@ -1118,8 +1116,7 @@ USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR
// if (!UM_FindUser(*ppUserList, pszUI, wStatus)
{
- USERINFO *node = (USERINFO*) mir_alloc(sizeof(USERINFO));
- ZeroMemory(node, sizeof(USERINFO));
+ USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
replaceStr( &node->pszUID, pszUID );
if (*ppUserList == NULL) { // list is empty
@@ -1327,16 +1324,10 @@ BOOL UM_RemoveAll (USERINFO** ppUserList)
LOGINFO * LM_AddEvent(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd)
{
-
- LOGINFO *node = NULL;
-
if (!ppLogListStart || !ppLogListEnd)
return NULL;
- node = (LOGINFO*) mir_alloc(sizeof(LOGINFO));
- ZeroMemory(node, sizeof(LOGINFO));
-
-
+ LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO));
if (*ppLogListStart == NULL) // list is empty
{
*ppLogListStart = node;
diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp
index 87577884a3..a2cefc7614 100644
--- a/plugins/Scriver/src/chat/options.cpp
+++ b/plugins/Scriver/src/chat/options.cpp
@@ -327,7 +327,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_GROUP));
if (iLen > 0)
{
- pszText = (char *)mir_realloc(pszText, iLen+1);
+ pszText = (char*)mir_realloc(pszText, iLen+1);
GetDlgItemTextA(hwndDlg, IDC_CHAT_GROUP, pszText,iLen+1);
db_set_s(NULL, "Chat", "AddToGroup", pszText);
}
@@ -567,7 +567,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_LOGTIMESTAMP));
if ( iLen > 0 ) {
- pszText = (char *)mir_realloc(pszText, iLen+1);
+ pszText = (char*)mir_realloc(pszText, iLen+1);
GetDlgItemTextA(hwndDlg, IDC_CHAT_LOGTIMESTAMP, pszText,iLen+1);
db_set_s(NULL, "Chat", "LogTimestamp", pszText);
}
@@ -575,7 +575,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_TIMESTAMP));
if ( iLen > 0 ) {
- pszText = (char *)mir_realloc(pszText, iLen+1);
+ pszText = (char*)mir_realloc(pszText, iLen+1);
GetDlgItemTextA(hwndDlg, IDC_CHAT_TIMESTAMP, pszText,iLen+1);
db_set_s(NULL, "Chat", "HeaderTime", pszText);
}
@@ -583,7 +583,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_INSTAMP));
if ( iLen > 0 ) {
- pszText = (char *)mir_realloc(pszText, iLen+1);
+ pszText = (char*)mir_realloc(pszText, iLen+1);
GetDlgItemTextA(hwndDlg, IDC_CHAT_INSTAMP, pszText,iLen+1);
db_set_s(NULL, "Chat", "HeaderIncoming", pszText);
}
@@ -591,7 +591,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_OUTSTAMP));
if ( iLen > 0 ) {
- pszText = (char *)mir_realloc(pszText, iLen+1);
+ pszText = (char*)mir_realloc(pszText, iLen+1);
GetDlgItemTextA(hwndDlg, IDC_CHAT_OUTSTAMP, pszText,iLen+1);
db_set_s(NULL, "Chat", "HeaderOutgoing", pszText);
}
diff --git a/plugins/Scriver/src/chat/services.cpp b/plugins/Scriver/src/chat/services.cpp
index c37df582ea..aaa5e8f604 100644
--- a/plugins/Scriver/src/chat/services.cpp
+++ b/plugins/Scriver/src/chat/services.cpp
@@ -21,10 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../commonheaders.h"
-HANDLE hSendEvent;
-HANDLE hBuildMenuEvent ;
-HANDLE g_hHookContactDblClick, g_hHookPrebuildMenu;
-CRITICAL_SECTION cs;
+HANDLE hSendEvent;
+HANDLE hBuildMenuEvent ;
+HANDLE g_hHookContactDblClick, g_hHookPrebuildMenu;
+CRITICAL_SECTION cs;
#ifdef _WIN64
@@ -78,57 +78,44 @@ int Chat_IconsChanged(WPARAM wParam,LPARAM lParam)
static INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam)
{
- int i;
-
if (!lParam)
return -1;
- EnterCriticalSection(&cs);
-
- i = SM_GetCount((char *)lParam);
-
- LeaveCriticalSection(&cs);
- return i;
+ mir_cslock lock(cs);
+ return SM_GetCount((char*)lParam);
}
static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam)
{
- GC_INFO * gci = (GC_INFO *) lParam;
- SESSION_INFO * si = NULL;
-
+ GC_INFO *gci = (GC_INFO *) lParam;
if (!gci || !gci->pszModule)
return 1;
- EnterCriticalSection(&cs);
+ SESSION_INFO *si = NULL;
- if (gci->Flags&BYINDEX)
+ mir_cslock lock(cs);
+ if (gci->Flags & BYINDEX)
si = SM_FindSessionByIndex( gci->pszModule, gci->iItem );
else
si = SM_FindSession( gci->pszID, gci->pszModule );
- if ( si ) {
- if ( gci->Flags & DATA ) gci->dwItemData = si->dwItemData;
- if ( gci->Flags & HCONTACT ) gci->hContact = si->windowData.hContact;
- if ( gci->Flags & TYPE ) gci->iType = si->iType;
- if ( gci->Flags & COUNT ) gci->iCount = si->nUsersInNicklist;
- if ( gci->Flags & USERS ) gci->pszUsers = SM_GetUsers(si);
- if ( si->dwFlags & GC_UNICODE ) {
- if ( gci->Flags & ID ) gci->pszID = si->ptszID;
- if ( gci->Flags & NAME ) gci->pszName = si->ptszName;
- }
-
+ if (si == NULL)
+ return 1;
- LeaveCriticalSection(&cs);
- return 0;
+ if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
+ if (gci->Flags & HCONTACT) gci->hContact = si->windowData.hContact;
+ if (gci->Flags & TYPE) gci->iType = si->iType;
+ if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist;
+ if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si);
+ if (si->dwFlags & GC_UNICODE) {
+ if (gci->Flags & ID) gci->pszID = si->ptszID;
+ if (gci->Flags & NAME) gci->pszName = si->ptszName;
}
-
- LeaveCriticalSection(&cs);
- return 1;
+ return 0;
}
-void LoadModuleIcons(MODULEINFO * mi) {
- int index;
-
+void LoadModuleIcons(MODULEINFO *mi)
+{
HIMAGELIST hList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 0, 0);
int overlayIcon = ImageList_AddIcon(hList, GetCachedIcon("chat_overlay"));
@@ -136,7 +123,7 @@ void LoadModuleIcons(MODULEINFO * mi) {
mi->hOnlineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_ONLINE);
mi->hOnlineIcon = LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE);
- index = ImageList_AddIcon(hList, mi->hOnlineIcon);
+ int index = ImageList_AddIcon(hList, mi->hOnlineIcon);
mi->hOnlineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
mi->hOfflineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_OFFLINE);
@@ -150,135 +137,123 @@ void LoadModuleIcons(MODULEINFO * mi) {
static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
{
GCREGISTER *gcr = (GCREGISTER *)lParam;
- MODULEINFO * mi = NULL;
- if (gcr== NULL)
+ if (gcr == NULL)
return GC_REGISTER_ERROR;
if (gcr->cbSize != SIZEOF_STRUCT_GCREGISTER_V1)
return GC_REGISTER_WRONGVER;
- EnterCriticalSection(&cs);
-
- mi = MM_AddModule( gcr->pszModule );
- if ( mi ) {
- mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags );
- mi->bBold = gcr->dwFlags&GC_BOLD;
- mi->bUnderline = gcr->dwFlags&GC_UNDERLINE ;
- mi->bItalics = gcr->dwFlags&GC_ITALICS ;
- mi->bColor = gcr->dwFlags&GC_COLOR ;
- mi->bBkgColor = gcr->dwFlags&GC_BKGCOLOR ;
- mi->bFontSize = gcr->dwFlags&GC_FONTSIZE;
- mi->bAckMsg = gcr->dwFlags&GC_ACKMSG ;
- mi->bChanMgr = gcr->dwFlags&GC_CHANMGR ;
- mi->bSingleFormat = gcr->dwFlags&GC_SINGLEFORMAT;
- mi->iMaxText= gcr->iMaxText;
- mi->nColorCount = gcr->nColors;
- if ( gcr->nColors > 0) {
- mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors);
- memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors);
- }
-
- CheckColorsInModule((char*)gcr->pszModule);
- CList_SetAllOffline(TRUE, gcr->pszModule);
+ mir_cslock lock(cs);
+ MODULEINFO *mi = MM_AddModule( gcr->pszModule );
+ if (mi == NULL)
+ return GC_REGISTER_ERROR;
- LeaveCriticalSection(&cs);
- return 0;
+ mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags );
+ mi->bBold = gcr->dwFlags&GC_BOLD;
+ mi->bUnderline = gcr->dwFlags&GC_UNDERLINE ;
+ mi->bItalics = gcr->dwFlags&GC_ITALICS ;
+ mi->bColor = gcr->dwFlags&GC_COLOR ;
+ mi->bBkgColor = gcr->dwFlags&GC_BKGCOLOR ;
+ mi->bFontSize = gcr->dwFlags&GC_FONTSIZE;
+ mi->bAckMsg = gcr->dwFlags&GC_ACKMSG ;
+ mi->bChanMgr = gcr->dwFlags&GC_CHANMGR ;
+ mi->bSingleFormat = gcr->dwFlags&GC_SINGLEFORMAT;
+ mi->iMaxText= gcr->iMaxText;
+ mi->nColorCount = gcr->nColors;
+ if ( gcr->nColors > 0) {
+ mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors);
+ memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors);
}
- LeaveCriticalSection(&cs);
- return GC_REGISTER_ERROR;
+ CheckColorsInModule((char*)gcr->pszModule);
+ CList_SetAllOffline(TRUE, gcr->pszModule);
+ return 0;
}
static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
{
- MODULEINFO* mi;
- GCSESSION *gcw =(GCSESSION *)lParam;
- if (gcw== NULL)
+ GCSESSION *gcw = (GCSESSION*)lParam;
+ if (gcw == NULL)
return GC_NEWSESSION_ERROR;
if (gcw->cbSize != SIZEOF_STRUCT_GCWINDOW_V1)
return GC_NEWSESSION_WRONGVER;
- EnterCriticalSection(&cs);
+ mir_cslock lock(cs);
- if (( mi = MM_FindModule( gcw->pszModule )) != NULL ) {
- TCHAR* ptszID = a2tf( gcw->ptszID, gcw->dwFlags );
- SESSION_INFO *si = SM_AddSession( ptszID, gcw->pszModule);
+ MODULEINFO *mi = MM_FindModule(gcw->pszModule);
+ if (mi == NULL)
+ return GC_NEWSESSION_ERROR;
- if (mi->hOfflineIcon == NULL) {
- LoadModuleIcons(mi);
+ TCHAR *ptszID = a2tf( gcw->ptszID, gcw->dwFlags );
+ SESSION_INFO *si = SM_AddSession( ptszID, gcw->pszModule);
+
+ if (mi->hOfflineIcon == NULL)
+ LoadModuleIcons(mi);
+
+ // create a new session and set the defaults
+ if (si != NULL) {
+ TCHAR szTemp[256];
+
+ si->dwItemData = gcw->dwItemData;
+ if ( gcw->iType != GCW_SERVER )
+ si->wStatus = ID_STATUS_ONLINE;
+ si->iType = gcw->iType;
+ si->dwFlags = gcw->dwFlags;
+ si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags );
+ si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, gcw->dwFlags );
+ si->iSplitterX = g_Settings.iSplitterX;
+ si->iSplitterY = g_Settings.iSplitterY;
+ si->iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
+ si->bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
+ si->bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
+
+ if ( !(gcw->dwFlags & GC_UNICODE)) {
+ si->pszID = mir_strdup( gcw->pszID );
+ si->pszName = mir_strdup( gcw->pszName );
}
- // create a new session and set the defaults
- if ( si != NULL ) {
- TCHAR szTemp[256];
-
- si->dwItemData = gcw->dwItemData;
- if ( gcw->iType != GCW_SERVER )
- si->wStatus = ID_STATUS_ONLINE;
- si->iType = gcw->iType;
- si->dwFlags = gcw->dwFlags;
- si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags );
- si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, gcw->dwFlags );
- si->iSplitterX = g_Settings.iSplitterX;
- si->iSplitterY = g_Settings.iSplitterY;
- si->iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
- si->bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
- si->bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
-
- if ( !( gcw->dwFlags & GC_UNICODE )) {
- si->pszID = mir_strdup( gcw->pszID );
- si->pszName = mir_strdup( gcw->pszName );
- }
-
- if ( mi->bColor ) {
- si->iFG = 4;
- si->bFGSet = TRUE;
- }
- if ( mi->bBkgColor ) {
- si->iBG = 2;
- si->bBGSet = TRUE;
- }
- if (si->iType == GCW_SERVER)
- mir_sntprintf(szTemp, SIZEOF(szTemp), LPGENT("Server: %s"), si->ptszName);
- else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
- si->windowData.hContact = CList_AddRoom( gcw->pszModule, ptszID, szTemp, si->iType);
- si->windowData.codePage = db_get_w(si->windowData.hContact, si->pszModule, "CodePage", (WORD) CP_ACP);
- si->pszHeader = Log_CreateRtfHeader(mi, si);
- db_set_s(si->windowData.hContact, si->pszModule , "Topic", "");
- db_unset(si->windowData.hContact, "CList", "StatusMsg");
- if (si->ptszStatusbarText)
- db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
- else
- db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
+ if (mi->bColor) {
+ si->iFG = 4;
+ si->bFGSet = TRUE;
}
- else {
- SESSION_INFO* si2 = SM_FindSession( ptszID, gcw->pszModule );
- if ( si2 ) {
-
- UM_RemoveAll(&si2->pUsers);
- TM_RemoveAll(&si2->pStatuses);
-
- si2->iStatusCount = 0;
- si2->nUsersInNicklist = 0;
+ if (mi->bBkgColor) {
+ si->iBG = 2;
+ si->bBGSet = TRUE;
+ }
+ if (si->iType == GCW_SERVER)
+ mir_sntprintf(szTemp, SIZEOF(szTemp), LPGENT("Server: %s"), si->ptszName);
+ else
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
+ si->windowData.hContact = CList_AddRoom( gcw->pszModule, ptszID, szTemp, si->iType);
+ si->windowData.codePage = db_get_w(si->windowData.hContact, si->pszModule, "CodePage", (WORD) CP_ACP);
+ si->pszHeader = Log_CreateRtfHeader(mi, si);
+ db_set_s(si->windowData.hContact, si->pszModule , "Topic", "");
+ db_unset(si->windowData.hContact, "CList", "StatusMsg");
+ if (si->ptszStatusbarText)
+ db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
+ else
+ db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
+ }
+ else {
+ SESSION_INFO *si2 = SM_FindSession( ptszID, gcw->pszModule );
+ if (si2) {
+ UM_RemoveAll(&si2->pUsers);
+ TM_RemoveAll(&si2->pStatuses);
- if (si2->hWnd )
- RedrawWindow(GetDlgItem(si2->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
+ si2->iStatusCount = 0;
+ si2->nUsersInNicklist = 0;
- }
+ if (si2->hWnd )
+ RedrawWindow(GetDlgItem(si2->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
}
-
- LeaveCriticalSection(&cs);
- mir_free( ptszID );
- return 0;
}
- LeaveCriticalSection(&cs);
- return GC_NEWSESSION_ERROR;
+ mir_free( ptszID );
+ return 0;
}
-static INT_PTR DoControl(GCEVENT * gce, WPARAM wp)
+static INT_PTR DoControl(GCEVENT *gce, WPARAM wp)
{
if ( gce->pDest->iType == GC_EVENT_CONTROL ) {
switch (wp) {
@@ -344,7 +319,6 @@ static INT_PTR DoControl(GCEVENT * gce, WPARAM wp)
replaceStr( &si->ptszName, gce->ptszText );
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
-
}
}
@@ -372,9 +346,7 @@ static INT_PTR DoControl(GCEVENT * gce, WPARAM wp)
else
db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
if (si->hWnd)
- {
SendMessage(si->hWnd, DM_UPDATESTATUSBAR, 0, 0);
- }
}
}
else if (gce->pDest->iType == GC_EVENT_ACK)
@@ -439,45 +411,46 @@ void ShowRoom(SESSION_INFO * si, WPARAM wp, BOOL bSetForeground)
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
{
GCEVENT *gce = (GCEVENT*)lParam, save_gce;
- GCDEST *gcd = NULL, save_gcd;
+ GCDEST save_gcd;
+ SESSION_INFO *si;
TCHAR* pWnd = NULL;
char* pMod = NULL;
BOOL bIsHighlighted = FALSE;
BOOL bRemoveFlag = FALSE;
int iRetVal = GC_EVENT_ERROR;
- if ( gce == NULL )
+ if (gce == NULL)
return GC_EVENT_ERROR;
- gcd = gce->pDest;
- if ( gcd == NULL )
+ GCDEST *gcd = gce->pDest;
+ if (gcd == NULL)
return GC_EVENT_ERROR;
- if ( gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2 )
+ if (gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2)
return GC_EVENT_WRONGVER;
- if ( !IsEventSupported( gcd->iType ))
+ if ( !IsEventSupported(gcd->iType))
return GC_EVENT_ERROR;
EnterCriticalSection(&cs);
- if ( !( gce->dwFlags & GC_UNICODE )) {
+ if ( !( gce->dwFlags & GC_UNICODE)) {
save_gce = *gce;
save_gcd = *gce->pDest;
- gce->pDest->ptszID = a2tf( gce->pDest->ptszID, gce->dwFlags );
- gce->ptszUID = a2tf( gce->ptszUID, gce->dwFlags );
- gce->ptszNick = a2tf( gce->ptszNick, gce->dwFlags );
- gce->ptszStatus = a2tf( gce->ptszStatus, gce->dwFlags );
- gce->ptszText = a2tf( gce->ptszText, gce->dwFlags );
- gce->ptszUserInfo = a2tf( gce->ptszUserInfo, gce->dwFlags );
+ gce->pDest->ptszID = a2tf(gce->pDest->ptszID, gce->dwFlags);
+ gce->ptszUID = a2tf(gce->ptszUID, gce->dwFlags);
+ gce->ptszNick = a2tf(gce->ptszNick, gce->dwFlags);
+ gce->ptszStatus = a2tf(gce->ptszStatus, gce->dwFlags);
+ gce->ptszText = a2tf(gce->ptszText, gce->dwFlags);
+ gce->ptszUserInfo = a2tf(gce->ptszUserInfo, gce->dwFlags);
}
// Do different things according to type of event
switch(gcd->iType) {
case GC_EVENT_ADDGROUP:
{
- STATUSINFO* si = SM_AddStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
- if ( si && gce->dwItemData)
+ STATUSINFO *si = SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
+ if (si && gce->dwItemData)
si->hIcon = CopyIcon((HICON)gce->dwItemData);
}
iRetVal = 0;
@@ -496,23 +469,22 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
goto LBL_Exit;
case GC_EVENT_SETCONTACTSTATUS:
- iRetVal = SM_SetContactStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData );
+ iRetVal = SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
goto LBL_Exit;
case GC_EVENT_TOPIC:
- {
- SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if ( si ) {
- if ( gce->pszText ) {
+ if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
+ if (gce->pszText) {
replaceStr( &si->ptszTopic, gce->ptszText);
- db_set_ts( si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting( si->ptszTopic ));
+ db_set_ts(si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting(si->ptszTopic));
if ( db_get_b( NULL, "Chat", "TopicOnClist", 0 ))
- db_set_ts( si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting( si->ptszTopic ));
- } }
+ db_set_ts(si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting(si->ptszTopic));
+ }
+ }
break;
- }
+
case GC_EVENT_ADDSTATUS:
- SM_GiveStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus );
+ SM_GiveStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
break;
case GC_EVENT_REMOVESTATUS:
@@ -521,10 +493,9 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
- if ( !gce->bIsMe && gce->pDest->pszID && gce->pszText ) {
- SESSION_INFO *si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule );
- if ( si )
- if ( IsHighlighted( si, gce->ptszText ))
+ if ( !gce->bIsMe && gce->pDest->pszID && gce->pszText) {
+ if (si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule))
+ if ( IsHighlighted(si, gce->ptszText))
bIsHighlighted = TRUE;
}
break;
@@ -551,7 +522,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
}
else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) {
SESSION_INFO *si = GetActiveSession();
- if ( si && !lstrcmpA( si->pszModule, gcd->pszModule )) {
+ if (si && !lstrcmpA( si->pszModule, gcd->pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
}
@@ -566,11 +537,12 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
if ( !bRemoveFlag ) {
iRetVal = 0;
goto LBL_Exit;
- } }
+ }
+ }
// add to log
if ( pWnd ) {
- SESSION_INFO *si = SM_FindSession(pWnd, pMod);
+ si = SM_FindSession(pWnd, pMod);
// fix for IRC's old stuyle mode notifications. Should not affect any other protocol
if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !( gce->dwFlags & GCEF_ADDTOLOG )) {
@@ -584,35 +556,35 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
}
if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) {
+ if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd)
SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
- }
- else if (si->hWnd) {
+ else if (si->hWnd)
SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
- }
+
DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
LogToFile(si, gce);
}
- if ( !bRemoveFlag ) {
+ if (!bRemoveFlag) {
iRetVal = 0;
goto LBL_Exit;
- } }
+ }
+ }
- if ( bRemoveFlag )
+ if (bRemoveFlag)
iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0;
LBL_Exit:
LeaveCriticalSection(&cs);
if ( !( gce->dwFlags & GC_UNICODE )) {
- mir_free((void*)gce->ptszText );
- mir_free((void*)gce->ptszNick );
- mir_free((void*)gce->ptszUID );
- mir_free((void*)gce->ptszStatus );
- mir_free((void*)gce->ptszUserInfo );
- mir_free((void*)gce->pDest->ptszID );
+ mir_free((void*)gce->ptszText);
+ mir_free((void*)gce->ptszNick);
+ mir_free((void*)gce->ptszUID);
+ mir_free((void*)gce->ptszStatus);
+ mir_free((void*)gce->ptszUserInfo);
+ mir_free((void*)gce->pDest->ptszID);
*gce = save_gce;
*gce->pDest = save_gcd;
}
diff --git a/plugins/Scriver/src/chat/tools.cpp b/plugins/Scriver/src/chat/tools.cpp
index 140912f604..f2c309e280 100644
--- a/plugins/Scriver/src/chat/tools.cpp
+++ b/plugins/Scriver/src/chat/tools.cpp
@@ -65,7 +65,8 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord)
szTemp[j] = pszWord[i];
j++;
i++;
- } }
+ }
+ }
return (TCHAR*) &szTemp;
}
@@ -105,17 +106,17 @@ static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
{
- POPUPDATAT pd = {0};
- va_list marker;
static TCHAR szBuf[4*1024];
if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
return 0;
+ va_list marker;
va_start(marker, fmt);
_vsntprintf(szBuf, 4096, fmt, marker);
va_end(marker);
+ POPUPDATAT pd = {0};
pd.lchContact = hContact;
if ( hIcon )
@@ -192,7 +193,8 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce)
case GC_EVENT_REMOVESTATUS:
CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_removestatus"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s disables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName);
break;
- } }
+ }
+ }
return TRUE;
}
@@ -223,21 +225,21 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce)
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_part"), si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
else
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_part"), si->pszModule, si->ptszName, aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
- break;
+ break;
case GC_EVENT_QUIT:
if (!gce->pszText)
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
else
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick,RemoveFormatting(gce->ptszText));
- break;
+ break;
case GC_EVENT_NICK:
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_nick"), si->pszModule, si->ptszName, aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
if (!gce->pszText)
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick);
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s"), (char*)gce->pszStatus, gce->ptszNick);
else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_kick"), si->pszModule, si->ptszName, aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char*)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_notice"), si->pszModule, si->ptszName, aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
@@ -252,10 +254,10 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce)
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_info"), si->pszModule, si->ptszName, aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ADDSTATUS:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_addstatus"), si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick);
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_addstatus"), si->pszModule, si->ptszName, aFonts[13].color, TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_removestatus"), si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick);
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_removestatus"), si->pszModule, si->ptszName, aFonts[14].color, TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick);
break;
}
}
@@ -355,7 +357,8 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh
if (bInactive || !g_Settings.SoundsFocus)
SkinPlaySound("ChatTopic");
break;
- } }
+ }
+ }
return TRUE;
}
@@ -363,12 +366,10 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh
int GetColorIndex(const char* pszModule, COLORREF cr)
{
MODULEINFO * pMod = MM_FindModule(pszModule);
- int i = 0;
-
if (!pMod || pMod->nColorCount == 0)
return -1;
- for (i = 0; i < pMod->nColorCount; i++)
+ for (int i = 0; i < pMod->nColorCount; i++)
if (pMod->crColors[i] == cr)
return i;
@@ -382,8 +383,7 @@ int GetColorIndex(const char* pszModule, COLORREF cr)
void CheckColorsInModule(const char* pszModule)
{
- MODULEINFO * pMod = MM_FindModule( pszModule );
- int i = 0;
+ MODULEINFO *pMod = MM_FindModule( pszModule );
COLORREF crFG;
COLORREF crBG = (COLORREF)db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
@@ -392,13 +392,15 @@ void CheckColorsInModule(const char* pszModule)
if ( !pMod )
return;
- for (i = 0; i < pMod->nColorCount; i++) {
+ for (int i = 0; i < pMod->nColorCount; i++) {
if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) {
if (pMod->crColors[i] == RGB(255,255,255))
pMod->crColors[i]--;
else
pMod->crColors[i]++;
-} } }
+ }
+ }
+}
TCHAR* my_strstri( const TCHAR* s1, const TCHAR* s2)
{
@@ -552,21 +554,21 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce)
break;
case GC_EVENT_JOIN:
p = '>';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char*)pszNick);
break;
case GC_EVENT_PART:
p = '<';
if (!gce->pszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char*)pszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char*)pszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_QUIT:
p = '<';
if (!gce->pszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char*)pszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick,RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char*)pszNick,RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NICK:
p = '^';
@@ -575,9 +577,9 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce)
case GC_EVENT_KICK:
p = '~';
if (!gce->pszText)
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char*)gce->pszStatus, gce->ptszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char*)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
p = 'o';
@@ -596,11 +598,11 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce)
break;
case GC_EVENT_ADDSTATUS:
p = '+';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
p = '-';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick);
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char*)gce->pszStatus, gce->ptszNick);
break;
}
if (p)
@@ -734,7 +736,7 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s
else if (gcmi.Item[i].uType == MENU_CHECK)
AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText);
- mir_free( ptszDescr );
+ mir_free(ptszDescr);
}
return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
}
@@ -790,60 +792,59 @@ BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCH
GCDEST gcd = {0};
gcd.pszModule = (char*)pszModule;
- if (( si = SM_FindSession(pszID, pszModule)) == NULL )
+ if ((si = SM_FindSession(pszID, pszModule)) == NULL)
return FALSE;
- if ( !( si->dwFlags & GC_UNICODE )) {
- gcd.pszID = t2a( pszID );
- gch.pszUID = t2a( pszUID );
- gch.pszText = t2a( pszText );
+ if ( !(si->dwFlags & GC_UNICODE)) {
+ gcd.pszID = t2a(pszID);
+ gch.pszUID = t2a(pszUID);
+ gch.pszText = t2a(pszText);
}
else {
- gcd.ptszID = mir_tstrdup( pszID );
- gch.ptszUID = mir_tstrdup( pszUID );
- gch.ptszText = mir_tstrdup( pszText );
+ gcd.ptszID = mir_tstrdup(pszID);
+ gch.ptszUID = mir_tstrdup(pszUID);
+ gch.ptszText = mir_tstrdup(pszText);
}
gcd.iType = iType;
gch.dwData = dwItem;
gch.pDest = &gcd;
- NotifyEventHooks(hSendEvent,0,(WPARAM)&gch);
+ NotifyEventHooks(hSendEvent, 0, (WPARAM)&gch);
- mir_free( gcd.pszID );
- mir_free( gch.ptszUID );
- mir_free( gch.ptszText );
+ mir_free(gcd.pszID);
+ mir_free(gch.ptszUID);
+ mir_free(gch.ptszText);
return TRUE;
}
BOOL IsEventSupported(int eventType)
{
- switch (eventType)
- {
+ switch (eventType) {
// Supported events
- case GC_EVENT_JOIN:
- case GC_EVENT_PART:
- case GC_EVENT_QUIT:
- case GC_EVENT_KICK:
- case GC_EVENT_NICK:
- case GC_EVENT_NOTICE:
- case GC_EVENT_MESSAGE:
- case GC_EVENT_TOPIC:
- case GC_EVENT_INFORMATION:
- case GC_EVENT_ACTION:
- case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- case GC_EVENT_CHUID:
- case GC_EVENT_CHANGESESSIONAME:
- case GC_EVENT_ADDGROUP:
- case GC_EVENT_SETITEMDATA:
- case GC_EVENT_GETITEMDATA:
- case GC_EVENT_SETSBTEXT:
- case GC_EVENT_ACK:
- case GC_EVENT_SENDMESSAGE:
- case GC_EVENT_SETSTATUSEX:
- case GC_EVENT_CONTROL:
- case GC_EVENT_SETCONTACTSTATUS:
- return TRUE;
+ case GC_EVENT_JOIN:
+ case GC_EVENT_PART:
+ case GC_EVENT_QUIT:
+ case GC_EVENT_KICK:
+ case GC_EVENT_NICK:
+ case GC_EVENT_NOTICE:
+ case GC_EVENT_MESSAGE:
+ case GC_EVENT_TOPIC:
+ case GC_EVENT_INFORMATION:
+ case GC_EVENT_ACTION:
+ case GC_EVENT_ADDSTATUS:
+ case GC_EVENT_REMOVESTATUS:
+ case GC_EVENT_CHUID:
+ case GC_EVENT_CHANGESESSIONAME:
+ case GC_EVENT_ADDGROUP:
+ case GC_EVENT_SETITEMDATA:
+ case GC_EVENT_GETITEMDATA:
+ case GC_EVENT_SETSBTEXT:
+ case GC_EVENT_ACK:
+ case GC_EVENT_SENDMESSAGE:
+ case GC_EVENT_SETSTATUSEX:
+ case GC_EVENT_CONTROL:
+ case GC_EVENT_SETCONTACTSTATUS:
+ return TRUE;
}
// Other events
@@ -852,50 +853,48 @@ BOOL IsEventSupported(int eventType)
TCHAR* a2tf( const TCHAR* str, int flags )
{
- if ( str == NULL )
+ if (str == NULL)
return NULL;
- if ( flags & GC_UNICODE )
- return mir_tstrdup( str );
- else {
- int codepage = CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 );
+ if (flags & GC_UNICODE)
+ return mir_tstrdup(str);
- int cbLen = MultiByteToWideChar( codepage, 0, (char*)str, -1, 0, 0 );
- TCHAR* result = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( cbLen+1 ));
- if ( result == NULL )
- return NULL;
+ int codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
- MultiByteToWideChar( codepage, 0, (char*)str, -1, result, cbLen );
- result[ cbLen ] = 0;
- return result;
- }
+ int cbLen = MultiByteToWideChar(codepage, 0, (char*)str, -1, 0, 0);
+ TCHAR *result = (TCHAR*)mir_alloc( sizeof(TCHAR)*( cbLen+1 ));
+ if (result == NULL)
+ return NULL;
+
+ MultiByteToWideChar(codepage, 0, (char*)str, -1, result, cbLen);
+ result[cbLen] = 0;
+ return result;
}
TCHAR* replaceStr( TCHAR** dest, const TCHAR* src )
{
- mir_free( *dest );
- *dest = mir_tstrdup( src );
+ mir_free(*dest);
+ *dest = mir_tstrdup(src);
return *dest;
}
char* replaceStrA( char** dest, const char* src )
{
- mir_free( *dest );
- *dest = mir_strdup( src );
+ mir_free(*dest);
+ *dest = mir_strdup(src);
return *dest;
}
TCHAR* GetChatLogsFilename (HANDLE hContact, time_t tTime)
-{ REPLACEVARSARRAY rva[11];
- REPLACEVARSDATA dat = {0};
- static TCHAR tszFileName[MAX_PATH];
+{
+ REPLACEVARSARRAY rva[11];
TCHAR *p = {0}, *tszParsedName = {0};
int i;
if (g_Settings.pszLogDir[_tcslen(g_Settings.pszLogDir)-1] == '\\')
_tcscat(g_Settings.pszLogDir, _T("%userid%.log"));
if (!tTime)
- time(&tTime);
+ time(&tTime);
// day 1-31
rva[0].lptzKey = _T("d");
@@ -931,20 +930,22 @@ TCHAR* GetChatLogsFilename (HANDLE hContact, time_t tTime)
rva[10].lptzKey = NULL;
rva[10].lptzValue = NULL;
- dat.cbSize = sizeof(dat);
- dat.dwFlags = RVF_TCHAR;
- dat.hContact = hContact;
+ REPLACEVARSDATA dat = { sizeof(dat) };
+ dat.dwFlags = RVF_TCHAR;
+ dat.hContact = hContact;
dat.variables = rva;
tszParsedName = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)g_Settings.pszLogDir, (LPARAM)&dat);
+
+ static TCHAR tszFileName[MAX_PATH];
_tcsncpy(tszFileName, tszParsedName, MAX_PATH);
mir_free(tszParsedName);
- for (i=0; i < SIZEOF(rva);i++)
+
+ for (int i=0; i < SIZEOF(rva);i++)
mir_free(rva[i].lptzValue);
- for (p = tszFileName + 2; *p; ++p) {
+ for (p = tszFileName + 2; *p; ++p)
if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|' )
*p = _T('_');
- }
return tszFileName;
}
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index ad0a535308..9e0d9cfd69 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -230,8 +230,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
switch (msg) {
case EM_SUBCLASSED:
- dat = (MESSAGESUBDATA *) mir_alloc(sizeof(MESSAGESUBDATA));
- ZeroMemory(dat, sizeof(MESSAGESUBDATA));
+ dat = (MESSAGESUBDATA*) mir_calloc(sizeof(MESSAGESUBDATA));
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
return 0;
@@ -1119,11 +1118,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
SendDlgItemMessage(hwndDlg, IDC_CHAT_LOG, EM_SETOLECALLBACK, 0, (LPARAM)& reOleCallback);
if (db_get_b(NULL, "Chat", "UseIEView", 0)) {
- IEVIEWWINDOW ieWindow;
- IEVIEWEVENT iee;
-
- ZeroMemory(&ieWindow, sizeof(ieWindow));
- ieWindow.cbSize = sizeof(ieWindow);
+ IEVIEWWINDOW ieWindow = { sizeof(ieWindow) };
ieWindow.iType = IEW_CREATE;
ieWindow.dwFlags = 0;
ieWindow.dwMode = IEWM_CHAT;
@@ -1133,9 +1128,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
ieWindow.cx = 200;
ieWindow.cy = 300;
CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
+
si->windowData.hwndLog = ieWindow.hwnd;
- ZeroMemory(&iee, sizeof(iee));
- iee.cbSize = sizeof(iee);
+
+ IEVIEWEVENT iee = { sizeof(iee) };
iee.iType = IEE_CLEAR_LOG;
iee.hwnd = si->windowData.hwndLog;
iee.hContact = si->windowData.hContact;
@@ -1970,7 +1966,6 @@ LABEL_SHOWWINDOW:
}
else {
COLORREF cr;
-
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &cr, FALSE);
cf.dwMask = CFM_COLOR;
cf.crTextColor = cr;
@@ -2045,12 +2040,9 @@ LABEL_SHOWWINDOW:
case WM_RBUTTONUP:
{
int i;
- POINT pt;
- MENUITEMINFO mii;
hToolbarMenu = CreatePopupMenu();
for (i = 0; i < SIZEOF(toolbarButtons); i++) {
- ZeroMemory(&mii, sizeof(mii));
- mii.cbSize = sizeof(mii);
+ MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_BITMAP;
mii.fType = MFT_STRING;
mii.fState = (g_dat.chatBbuttonVisibility & (1<< i)) ? MFS_CHECKED : MFS_UNCHECKED;
@@ -2060,7 +2052,8 @@ LABEL_SHOWWINDOW:
mii.dwTypeData = TranslateTS((toolbarButtons[i].name));
InsertMenuItem(hToolbarMenu, i, TRUE, &mii);
}
- // TranslateMenu(hToolbarMenu);
+
+ POINT pt;
pt.x = (short) LOWORD(GetMessagePos());
pt.y = (short) HIWORD(GetMessagePos());
i = TrackPopupMenu(hToolbarMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
@@ -2083,7 +2076,7 @@ LABEL_SHOWWINDOW:
case WM_CONTEXTMENU:
if (GetParent(hwndDlg) == (HWND) wParam) {
POINT pt;
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) si->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) si->windowData.hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -2117,5 +2110,5 @@ LABEL_SHOWWINDOW:
NotifyLocalWinEvent(si->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
break;
}
- return(FALSE);
+ return FALSE;
}
diff --git a/plugins/Scriver/src/commonheaders.h b/plugins/Scriver/src/commonheaders.h
index 6c18ab90aa..48c0af734b 100644
--- a/plugins/Scriver/src/commonheaders.h
+++ b/plugins/Scriver/src/commonheaders.h
@@ -48,7 +48,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_database.h>
#include <m_langpack.h>
#include <m_button.h>
-#include <m_clist.h>
+#include <m_clistint.h>
#include <m_clc.h>
#include <m_clui.h>
#include <m_protosvc.h>
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index 493f55256c..dd739d10f1 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -428,7 +428,7 @@ static int ackevent(WPARAM wParam, LPARAM lParam)
if (hwndSender != NULL) {
ErrorWindowData *ewd = (ErrorWindowData *) mir_alloc(sizeof(ErrorWindowData));
ewd->szName = GetNickname(item->hContact, item->proto);
- ewd->szDescription = a2t((char *) ack->lParam);
+ ewd->szDescription = a2t((char*) ack->lParam);
ewd->szText = GetSendBufferMsg(item);
ewd->hwndParent = hwndSender;
ewd->queueItem = item;
diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp
index 106b547f21..897c414e77 100644
--- a/plugins/Scriver/src/infobar.cpp
+++ b/plugins/Scriver/src/infobar.cpp
@@ -234,19 +234,16 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
BITMAP bminfo;
GetObject(idat->mwd->avatarPic, sizeof(bminfo), &bminfo);
if ( bminfo.bmWidth != 0 && bminfo.bmHeight != 0 ) {
- AVATARDRAWREQUEST adr;
int avatarHeight = itemHeight;
int avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight;
if (avatarWidth > itemWidth) {
avatarWidth = itemWidth;
avatarHeight = bminfo.bmHeight * avatarWidth / bminfo.bmWidth;
}
- ZeroMemory(&adr, sizeof(adr));
- adr.cbSize = sizeof (AVATARDRAWREQUEST);
+
+ AVATARDRAWREQUEST adr = { sizeof(adr) };
adr.hContact = idat->mwd->windowData.hContact;
adr.hTargetDC = hdcMem;
- adr.rcDraw.left = 0;
- adr.rcDraw.top = 0;
adr.rcDraw.right = avatarWidth - 1;
adr.rcDraw.bottom = avatarHeight - 1;
adr.dwFlags = AVDRQ_DRAWBORDER | AVDRQ_HIDEBORDERONTRANSPARENCY;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 084a91145f..aa665e5a85 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -53,7 +53,7 @@ static ToolbarButton toolbarButtons[] = {
static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
MessageSendQueueItem * msi = (MessageSendQueueItem *) dwCookie;
- msi->sendBuffer = (char *)mir_realloc(msi->sendBuffer, msi->sendBufferSize + cb + 2);
+ msi->sendBuffer = (char*)mir_realloc(msi->sendBuffer, msi->sendBufferSize + cb + 2);
memcpy (msi->sendBuffer + msi->sendBufferSize, pbBuff, cb);
msi->sendBufferSize += cb;
*((TCHAR *)(msi->sendBuffer+msi->sendBufferSize)) = '\0';
@@ -61,19 +61,18 @@ static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
return 0;
}
-static TCHAR *GetIEViewSelection(struct SrmmWindowData *dat) {
- IEVIEWEVENT event;
- ZeroMemory(&event, sizeof(event));
- event.cbSize = sizeof(event);
- event.dwFlags = 0;
- event.codepage = dat->windowData.codePage;
- event.hwnd = dat->windowData.hwndLog;
- event.hContact = dat->windowData.hContact;
- event.iType = IEE_GET_SELECTION;
- return mir_tstrdup((TCHAR *)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event));
+static TCHAR *GetIEViewSelection(struct SrmmWindowData *dat)
+{
+ IEVIEWEVENT evt = { sizeof(evt) };
+ evt.codepage = dat->windowData.codePage;
+ evt.hwnd = dat->windowData.hwndLog;
+ evt.hContact = dat->windowData.hContact;
+ evt.iType = IEE_GET_SELECTION;
+ return mir_tstrdup((TCHAR *)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt));
}
-static TCHAR *GetQuotedTextW(TCHAR * text) {
+static TCHAR *GetQuotedTextW(TCHAR * text)
+{
int i, j, l, newLine, wasCR;
TCHAR *out;
l = (int)wcslen(text);
@@ -134,17 +133,18 @@ static TCHAR *GetQuotedTextW(TCHAR * text) {
return out;
}
-static void saveDraftMessage(HWND hwnd, HANDLE hContact, int codepage) {
+static void saveDraftMessage(HWND hwnd, HANDLE hContact, int codepage)
+{
char *textBuffer = GetRichTextEncoded(hwnd, codepage);
if (textBuffer != NULL) {
g_dat.draftList = tcmdlist_append2(g_dat.draftList, hContact, textBuffer);
mir_free(textBuffer);
- } else {
- g_dat.draftList = tcmdlist_remove2(g_dat.draftList, hContact);
}
+ else g_dat.draftList = tcmdlist_remove2(g_dat.draftList, hContact);
}
-void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type) {
+void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type)
+{
MessageWindowEventData mwe = { 0 };
BOOL bChat = FALSE;
if (hContact==NULL || hwnd==NULL) return;
@@ -251,7 +251,8 @@ static void SetDialogToType(HWND hwndDlg)
SendMessage(hwndDlg, WM_SIZE, 0, 0);
}
-void SetStatusIcon(struct SrmmWindowData *dat) {
+void SetStatusIcon(struct SrmmWindowData *dat)
+{
if (dat->szProto == NULL)
return;
@@ -402,19 +403,17 @@ static LRESULT CALLBACK LogEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- struct MsgEditSubclassData *dat;
- struct SrmmWindowData *pdat;
- CommonWindowData *windowData;
- BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000;
- BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
- dat = (struct MsgEditSubclassData *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
- pdat=(struct SrmmWindowData *)GetWindowLongPtr(GetParent(hwnd),GWLP_USERDATA);
- windowData = &pdat->windowData;
+ struct MsgEditSubclassData *dat = (MsgEditSubclassData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ struct SrmmWindowData *pdat = (SrmmWindowData*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
+ CommonWindowData *windowData = &pdat->windowData;
int result = InputAreaShortcuts(hwnd, msg, wParam, lParam, windowData);
if (result != -1)
return result;
+ BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000;
+ BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
+
switch (msg) {
case EM_SUBCLASSED:
dat = (struct MsgEditSubclassData *) mir_alloc(sizeof(struct MsgEditSubclassData));
@@ -734,9 +733,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
int len = 0;
int notifyUnread = 0;
RECT minEditInit;
- NewMessageWindowLParam *newData = (NewMessageWindowLParam *) lParam;
- dat = (struct SrmmWindowData *) mir_alloc(sizeof(struct SrmmWindowData));
- ZeroMemory(dat, sizeof(struct SrmmWindowData));
+ NewMessageWindowLParam *newData = (NewMessageWindowLParam*)lParam;
+ dat = (SrmmWindowData*)mir_calloc(sizeof(struct SrmmWindowData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat);
dat->windowData.hContact = newData->hContact;
NotifyLocalWinEvent(dat->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_OPENING);
@@ -773,7 +771,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->flags |= g_dat.ieviewInstalled ? g_dat.flags & SMF_USEIEVIEW : 0;
{
PARAFORMAT2 pf2;
- ZeroMemory((void *)&pf2, sizeof(pf2));
+ ZeroMemory(&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
if (!(dat->flags & SMF_RTL)) {
@@ -786,7 +784,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
/* Workaround to make Richedit display RTL messages correctly */
- ZeroMemory((void *)&pf2, sizeof(pf2));
+ ZeroMemory(&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA | PFM_OFFSETINDENT | PFM_RIGHTINDENT;
pf2.wEffects = PFE_RTLPARA;
@@ -994,12 +992,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_RBUTTONUP:
{
int i;
- POINT pt;
- MENUITEMINFO mii;
hToolbarMenu = CreatePopupMenu();
for (i = 0; i < SIZEOF(toolbarButtons); i++) {
- ZeroMemory(&mii, sizeof(mii));
- mii.cbSize = sizeof(mii);
+ MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_BITMAP;
mii.fType = MFT_STRING;
mii.fState = (g_dat.buttonVisibility & (1<< i)) ? MFS_CHECKED : MFS_UNCHECKED;
@@ -1009,8 +1004,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
mii.dwTypeData = TranslateTS((toolbarButtons[i].name));
InsertMenuItem(hToolbarMenu, i, TRUE, &mii);
}
- pt.x = (short) LOWORD(GetMessagePos());
- pt.y = (short) HIWORD(GetMessagePos());
+ POINT pt = { (short)LOWORD(GetMessagePos()), (short) HIWORD(GetMessagePos()) };
i = TrackPopupMenu(hToolbarMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
if (i > 0) {
g_dat.buttonVisibility ^= (1 << (i - 1));
@@ -1273,7 +1267,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_SWITCHRTL:
{
PARAFORMAT2 pf2;
- ZeroMemory((void *)&pf2, sizeof(pf2));
+ ZeroMemory(&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
dat->flags ^= SMF_RTL;
@@ -1516,20 +1510,17 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case DM_CLEARLOG:
- // IEVIew MOD Begin
if (dat->windowData.hwndLog != NULL) {
- IEVIEWEVENT event;
- ZeroMemory(&event, sizeof(event));
- event.cbSize = sizeof(event);
- event.iType = IEE_CLEAR_LOG;
- event.dwFlags = ((dat->flags & SMF_RTL) ? IEEF_RTL : 0);
- event.hwnd = dat->windowData.hwndLog;
- event.hContact = dat->windowData.hContact;
- event.codepage = dat->windowData.codePage;
- event.pszProto = dat->szProto;
- CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
+ IEVIEWEVENT evt = { sizeof(evt) };
+ evt.iType = IEE_CLEAR_LOG;
+ evt.dwFlags = ((dat->flags & SMF_RTL) ? IEEF_RTL : 0);
+ evt.hwnd = dat->windowData.hwndLog;
+ evt.hContact = dat->windowData.hContact;
+ evt.codepage = dat->windowData.codePage;
+ evt.pszProto = dat->szProto;
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt);
}
- // IEVIew MOD End
+
SetDlgItemText(hwndDlg, IDC_LOG, _T(""));
dat->hDbEventFirst = NULL;
dat->lastEventType = -1;
@@ -1581,9 +1572,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if ( IsUtfSendAvailable( dat->windowData.hContact )) {
char *szMsgUtf = mir_utf8encodeW( (TCHAR *)&msi->sendBuffer[strlen(msi->sendBuffer) + 1] );
item->flags &= ~PREF_UNICODE;
- if (!szMsgUtf) {
+ if (!szMsgUtf)
break;
- }
+
if (*szMsgUtf == 0) {
mir_free(szMsgUtf);
break;
@@ -1591,9 +1582,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
item->sendBufferSize = (int)strlen(szMsgUtf) + 1;
item->sendBuffer = szMsgUtf;
item->flags |= PREF_UTF;
- } else {
+ }
+ else {
item->sendBufferSize = msi->sendBufferSize;
- item->sendBuffer = (char *) mir_alloc(msi->sendBufferSize);
+ item->sendBuffer = (char*) mir_alloc(msi->sendBufferSize);
memcpy(item->sendBuffer, msi->sendBuffer, msi->sendBufferSize);
}
SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
@@ -1671,15 +1663,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
BITMAP bminfo;
GetObject(dat->avatarPic, sizeof(bminfo), &bminfo);
if ( bminfo.bmWidth != 0 && bminfo.bmHeight != 0 ) {
- AVATARDRAWREQUEST adr;
avatarHeight = itemHeight;
avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight;
if (avatarWidth > itemWidth) {
avatarWidth = itemWidth;
avatarHeight = bminfo.bmHeight * avatarWidth / bminfo.bmWidth;
}
- ZeroMemory(&adr, sizeof(adr));
- adr.cbSize = sizeof (AVATARDRAWREQUEST);
+
+ AVATARDRAWREQUEST adr = { sizeof(adr) };
adr.hContact = dat->windowData.hContact;
adr.hTargetDC = hdcMem;
adr.rcDraw.left = (itemWidth - avatarWidth) / 2;
@@ -1687,7 +1678,6 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
adr.rcDraw.right = avatarWidth - 1;
adr.rcDraw.bottom = avatarHeight - 1;
adr.dwFlags = AVDRQ_DRAWBORDER | AVDRQ_HIDEBORDERONTRANSPARENCY;
-
CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr);
}
}
@@ -1729,7 +1719,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
int bufSize = ansiBufSize + GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
PARAFORMAT2 pf2;
- ZeroMemory((void *)&pf2, sizeof(pf2));
+ ZeroMemory(&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
@@ -1739,9 +1729,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (pf2.wEffects & PFE_RTLPARA)
msi.flags |= PREF_RTL;
msi.sendBufferSize = bufSize;
- msi.sendBuffer = (char *) mir_alloc(msi.sendBufferSize);
+ msi.sendBuffer = (char*)mir_alloc(msi.sendBufferSize);
- GETTEXTEX gt = {0};
+ GETTEXTEX gt = { 0 };
gt.flags = GT_USECRLF;
gt.cb = ansiBufSize;
gt.codepage = dat->windowData.codePage;
@@ -1749,7 +1739,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
gt.cb = bufSize - ansiBufSize;
gt.codepage = 1200;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM) &gt, (LPARAM)&msi.sendBuffer[ansiBufSize]);
- if ( RTL_Detect((wchar_t *)&msi.sendBuffer[ansiBufSize] ))
+ if ( RTL_Detect((wchar_t*)&msi.sendBuffer[ansiBufSize] ))
msi.flags |= PREF_RTL;
if (msi.sendBuffer[0] == 0) {
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index d65a512194..92f7f0c85b 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -40,13 +40,14 @@ static HIMAGELIST g_hImageList;
#define STREAMSTAGE_TAIL 2
#define STREAMSTAGE_STOP 3
-typedef struct EventDataStruct {
- int cbSize;
- int iType;
+struct EventData
+{
+ int cbSize;
+ int iType;
DWORD dwFlags;
const char *fontName;
- int fontSize;
- int fontStyle;
+ int fontSize;
+ int fontStyle;
COLORREF color;
union {
char *pszNick; // Nick, usage depends on type of event
@@ -65,12 +66,13 @@ typedef struct EventDataStruct {
};
DWORD time;
DWORD eventType;
- int codePage;
- BOOL custom;
- struct EventDataStruct *next;
-}EventData;
+ int codePage;
+ BOOL custom;
+ EventData *next;
+};
-struct LogStreamData {
+struct LogStreamData
+{
int stage;
HANDLE hContact;
HANDLE hDbEvent, hDbEventLast;
@@ -78,57 +80,46 @@ struct LogStreamData {
int bufferOffset, bufferLen;
int eventsToInsert;
int isFirst;
- struct SrmmWindowData *dlgDat;
- struct GlobalMessageData *gdat;
- EventData *events;
+ SrmmWindowData *dlgDat;
+ GlobalMessageData *gdat;
+ EventData *events;
};
-TCHAR *GetNickname(HANDLE hContact, const char* szProto) {
- char * szBaseNick;
- TCHAR *szName = NULL;
- CONTACTINFO ci;
- ZeroMemory(&ci, sizeof(ci));
- ci.cbSize = sizeof(ci);
+TCHAR *GetNickname(HANDLE hContact, const char* szProto)
+{
+ CONTACTINFO ci = { sizeof(ci) };
ci.hContact = hContact;
- ci.szProto = (char *)szProto;
+ ci.szProto = (char*)szProto;
ci.dwFlag = CNF_DISPLAY;
- if (IsUnicodeMIM()) {
+ if (IsUnicodeMIM())
ci.dwFlag |= CNF_UNICODE;
- }
+ TCHAR *szName = NULL;
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
if (ci.type == CNFT_ASCIIZ) {
if (ci.pszVal) {
if (IsUnicodeMIM()) {
if (!_tcscmp((TCHAR *)ci.pszVal, TranslateW(_T("'(Unknown Contact)'")))) {
ci.dwFlag &= ~CNF_UNICODE;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- szName = a2t((char *)ci.pszVal);
- }
- } else {
- szName = mir_tstrdup((TCHAR *)ci.pszVal);
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci))
+ szName = a2t((char*)ci.pszVal);
}
- } else {
- szName = a2t((char *)ci.pszVal);
+ else szName = mir_tstrdup((TCHAR *)ci.pszVal);
}
+ else szName = a2t((char*)ci.pszVal);
mir_free(ci.pszVal);
- if (szName != NULL) {
+ if (szName != NULL)
return szName;
- }
}
}
}
- szBaseNick = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
- if (szBaseNick != NULL) {
- int len;
- len = (int)strlen(szBaseNick) + 1;
- szName = (TCHAR *) mir_alloc(len * 2);
- MultiByteToWideChar(CP_ACP, 0, szBaseNick, -1, szName, len);
- szName[len - 1] = 0;
- return szName;
- }
- return mir_tstrdup(TranslateT("Unknown Contact"));
+
+ TCHAR *tszBaseNick = pcli->pfnGetContactDisplayName(hContact, 0);
+ if (tszBaseNick != NULL)
+ return mir_tstrdup(tszBaseNick);
+
+ return mir_tstrdup(TranslateT("Unknown Contact"));
}
int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei)
@@ -139,7 +130,7 @@ int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei)
int DbEventIsMessageOrCustom(DBEVENTINFO* dbei)
{
- return dbei->eventType == EVENTTYPE_MESSAGE || DbEventIsCustomForMsgWindow(dbei);
+ return dbei->eventType == EVENTTYPE_MESSAGE || DbEventIsCustomForMsgWindow(dbei);
}
int DbEventIsShown(DBEVENTINFO * dbei, struct SrmmWindowData *dat)
@@ -163,125 +154,126 @@ int DbEventIsShown(DBEVENTINFO * dbei, struct SrmmWindowData *dat)
return DbEventIsCustomForMsgWindow(dbei);
}
-EventData *getEventFromDB(struct SrmmWindowData *dat, HANDLE hContact, HANDLE hDbEvent) {
- DBEVENTINFO dbei = { 0 };
- EventData *event;
- dbei.cbSize = sizeof(dbei);
+EventData *getEventFromDB(struct SrmmWindowData *dat, HANDLE hContact, HANDLE hDbEvent)
+{
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob == -1) return NULL;
- dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
+ if (dbei.cbBlob == -1)
+ return NULL;
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
db_event_get(hDbEvent, &dbei);
if (!DbEventIsShown(&dbei, dat)) {
mir_free(dbei.pBlob);
return NULL;
}
- event = (EventData *) mir_alloc(sizeof(EventData));
- memset(event, 0, sizeof(EventData));
- event->custom = DbEventIsCustomForMsgWindow(&dbei);
- if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL || event->custom)) {
+
+ EventData *evt = (EventData*)mir_calloc(sizeof(EventData));
+ evt->custom = DbEventIsCustomForMsgWindow(&dbei);
+ if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL || evt->custom)) {
db_event_markRead(hContact, hDbEvent);
CallService(MS_CLIST_REMOVEEVENT, (WPARAM) hContact, (LPARAM)hDbEvent);
- } else if (dbei.eventType == EVENTTYPE_STATUSCHANGE || dbei.eventType == EVENTTYPE_JABBER_CHATSTATES ||
+ }
+ else if (dbei.eventType == EVENTTYPE_STATUSCHANGE || dbei.eventType == EVENTTYPE_JABBER_CHATSTATES ||
dbei.eventType == EVENTTYPE_JABBER_PRESENCE) {
db_event_markRead(hContact, hDbEvent);
}
- event->eventType = event->custom ? EVENTTYPE_MESSAGE : dbei.eventType;
- event->dwFlags = (dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0);
- event->dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2;
+ evt->eventType = evt->custom ? EVENTTYPE_MESSAGE : dbei.eventType;
+ evt->dwFlags = (dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0);
+ evt->dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2;
- if ( dat->flags & SMF_RTL) {
- event->dwFlags |= IEEDF_RTL;
- }
- event->time = dbei.timestamp;
- event->pszNick = NULL;
- event->codePage = dat->windowData.codePage;
+ if ( dat->flags & SMF_RTL)
+ evt->dwFlags |= IEEDF_RTL;
- if (event->dwFlags & IEEDF_SENT) {
- event->pszNickT = GetNickname(NULL, dat->szProto);
- } else {
- event->pszNickT = GetNickname(hContact, dat->szProto);
- }
+ evt->time = dbei.timestamp;
+ evt->pszNick = NULL;
+ evt->codePage = dat->windowData.codePage;
- if (event->eventType == EVENTTYPE_FILE) {
- char* filename = ((char *)dbei.pBlob) + sizeof(DWORD);
- char* descr = filename + lstrlenA( filename ) + 1;
- event->pszTextT = DbGetEventStringT(&dbei, filename);
- if ( *descr != 0 ) {
- event->pszText2T = DbGetEventStringT(&dbei, descr);
- }
- } else {
- event->pszTextT = DbGetEventTextT( &dbei, dat->windowData.codePage );
- }
- if ( !(dat->flags & SMF_RTL)) {
- if ( RTL_Detect(event->pszTextT)) {
- event->dwFlags |= IEEDF_RTL;
- }
+ if (evt->dwFlags & IEEDF_SENT)
+ evt->pszNickT = GetNickname(NULL, dat->szProto);
+ else
+ evt->pszNickT = GetNickname(hContact, dat->szProto);
+
+ if (evt->eventType == EVENTTYPE_FILE) {
+ char *filename = ((char*)dbei.pBlob) + sizeof(DWORD);
+ char *descr = filename + lstrlenA(filename) + 1;
+ evt->pszTextT = DbGetEventStringT(&dbei, filename);
+ if ( *descr != 0 )
+ evt->pszText2T = DbGetEventStringT(&dbei, descr);
}
+ else evt->pszTextT = DbGetEventTextT( &dbei, dat->windowData.codePage );
+
+ if ( !(dat->flags & SMF_RTL))
+ if ( RTL_Detect(evt->pszTextT))
+ evt->dwFlags |= IEEDF_RTL;
mir_free(dbei.pBlob);
- return event;
+ return evt;
}
static EventData *GetTestEvent(DWORD flags)
{
- EventData *event = (EventData *) mir_alloc(sizeof(EventData));
- memset(event, 0, sizeof(EventData));
- event->eventType = EVENTTYPE_MESSAGE;
- event->dwFlags = IEEDF_READ | flags;
- event->dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2;
- event->time = time(NULL);
- event->codePage = CP_ACP;
- return event;
+ EventData *evt = (EventData *) mir_alloc(sizeof(EventData));
+ memset(evt, 0, sizeof(EventData));
+ evt->eventType = EVENTTYPE_MESSAGE;
+ evt->dwFlags = IEEDF_READ | flags;
+ evt->dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2;
+ evt->time = time(NULL);
+ evt->codePage = CP_ACP;
+ return evt;
}
static EventData *GetTestEvents()
{
- EventData *event, *firstEvent, *prevEvent;
- firstEvent = prevEvent = event = GetTestEvent(IEEDF_SENT);
- event->pszNickT = mir_tstrdup(LPGENT("Me"));
- event->pszTextT = mir_tstrdup(LPGENT("O Lord, bless this Thy hand grenade that with it Thou mayest blow Thine enemies"));
- event = GetTestEvent(IEEDF_SENT);
- event->pszNickT = mir_tstrdup(LPGENT("Me"));
- event->pszTextT = mir_tstrdup(LPGENT("to tiny bits, in Thy mercy"));
- prevEvent->next = event;
- prevEvent = event;
- event = GetTestEvent(0);
- event->pszNickT = mir_tstrdup(LPGENT("My Contact"));
- event->pszTextT = mir_tstrdup(LPGENT("Lorem ipsum dolor sit amet,"));
- prevEvent->next = event;
- prevEvent = event;
- event = GetTestEvent(0);
- event->pszNickT = mir_tstrdup(LPGENT("My Contact"));
- event->pszTextT = mir_tstrdup(LPGENT("consectetur adipisicing elit"));
- prevEvent->next = event;
- prevEvent = event;
+ EventData *evt, *firstEvent, *prevEvent;
+ firstEvent = prevEvent = evt = GetTestEvent(IEEDF_SENT);
+ evt->pszNickT = mir_tstrdup(LPGENT("Me"));
+ evt->pszTextT = mir_tstrdup(LPGENT("O Lord, bless this Thy hand grenade that with it Thou mayest blow Thine enemies"));
+
+ evt = GetTestEvent(IEEDF_SENT);
+ evt->pszNickT = mir_tstrdup(LPGENT("Me"));
+ evt->pszTextT = mir_tstrdup(LPGENT("to tiny bits, in Thy mercy"));
+ prevEvent->next = evt;
+ prevEvent = evt;
+
+ evt = GetTestEvent(0);
+ evt->pszNickT = mir_tstrdup(LPGENT("My Contact"));
+ evt->pszTextT = mir_tstrdup(LPGENT("Lorem ipsum dolor sit amet,"));
+ prevEvent->next = evt;
+ prevEvent = evt;
+
+ evt = GetTestEvent(0);
+ evt->pszNickT = mir_tstrdup(LPGENT("My Contact"));
+ evt->pszTextT = mir_tstrdup(LPGENT("consectetur adipisicing elit"));
+ prevEvent->next = evt;
+ prevEvent = evt;
return firstEvent;
}
-static void freeEvent(EventData *event) {
- if (event->pszNickT != NULL) mir_free (event->pszNickT);
- if (event->pszTextT != NULL) mir_free (event->pszTextT);
- if (event->pszText2T != NULL) mir_free (event->pszText2T);
- mir_free(event);
+static void freeEvent(EventData *evt)
+{
+ mir_free(evt->pszNickT);
+ mir_free(evt->pszTextT);
+ mir_free(evt->pszText2T);
+ mir_free(evt);
}
static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR * line, int maxLen, BOOL isAnsii)
{
int textCharsCount = 0;
- char *d;
int wasEOL = 0;
WCHAR *maxLine = line + maxLen;
int lineLen = (int)wcslen(line) * 9 + 8;
if (*cbBufferEnd + lineLen > *cbBufferAlloced) {
cbBufferAlloced[0] += (lineLen + 1024 - lineLen % 1024);
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char*) mir_realloc(*buffer, *cbBufferAlloced);
}
- d = *buffer + *cbBufferEnd;
+ char *d = *buffer + *cbBufferEnd;
if (isAnsii) {
strcpy(d, "{");
d++;
- } else {
+ }
+ else {
strcpy(d, "{\\uc1 ");
d += 6;
}
@@ -373,7 +365,7 @@ static char *CreateRTFHeader(struct SrmmWindowData *dat, struct GlobalMessageDat
ReleaseDC(NULL, hdc);
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char*) mir_alloc(bufferAlloced);
buffer[0] = '\0';
if (dat->flags & SMF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced,"{\\rtf1\\ansi\\deff0{\\fonttbl");
@@ -403,19 +395,14 @@ static char *CreateRTFHeader(struct SrmmWindowData *dat, struct GlobalMessageDat
colour = gdat->logLineColour;
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(colour), GetGValue(colour), GetBValue(colour));
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}");
-// AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\li30\\ri30\\fi0\\tx0");
return buffer;
}
//mir_free() the return value
static char *CreateRTFTail()
{
- char *buffer;
- int bufferAlloced, bufferEnd;
-
- bufferEnd = 0;
- bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ int bufferAlloced = 1024, bufferEnd = 0;
+ char *buffer = (char*) mir_alloc(bufferAlloced);
buffer[0] = '\0';
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}");
return buffer;
@@ -436,49 +423,49 @@ static char *SetToStyle(int style)
TCHAR *TimestampToString(DWORD dwFlags, time_t check, int mode)
{
- static TCHAR szResult[512];
- TCHAR str[80];
+ static TCHAR szResult[512];
+ TCHAR str[80];
TCHAR format[20];
- szResult[0] = '\0';
- format[0] = '\0';
- if ((mode == 0 || mode == 1) && (dwFlags & SMF_SHOWDATE)) {
+ szResult[0] = '\0';
+ format[0] = '\0';
+ if ((mode == 0 || mode == 1) && (dwFlags & SMF_SHOWDATE)) {
struct tm tm_now, tm_today;
time_t now = time(NULL);
time_t today;
- tm_now = *localtime(&now);
- tm_today = tm_now;
- tm_today.tm_hour = tm_today.tm_min = tm_today.tm_sec = 0;
- today = mktime(&tm_today);
-
- if (dwFlags & SMF_RELATIVEDATE && check >= today) {
- lstrcpy(szResult, TranslateT("Today"));
- if (mode == 0) {
+ tm_now = *localtime(&now);
+ tm_today = tm_now;
+ tm_today.tm_hour = tm_today.tm_min = tm_today.tm_sec = 0;
+ today = mktime(&tm_today);
+
+ if (dwFlags & SMF_RELATIVEDATE && check >= today) {
+ lstrcpy(szResult, TranslateT("Today"));
+ if (mode == 0)
lstrcat(szResult, _T(","));
- }
- } else if (dwFlags & SMF_RELATIVEDATE && check > (today - 86400)) {
- lstrcpy(szResult, TranslateT("Yesterday"));
- if (mode == 0) {
+ }
+ else if (dwFlags & SMF_RELATIVEDATE && check > (today - 86400)) {
+ lstrcpy(szResult, TranslateT("Yesterday"));
+ if (mode == 0)
lstrcat(szResult, _T(","));
- }
- } else {
- if (dwFlags & SMF_LONGDATE)
+ }
+ else {
+ if (dwFlags & SMF_LONGDATE)
lstrcpy(format, _T("D"));
- else
+ else
lstrcpy(format, _T("d"));
- }
- }
- if (mode == 0 || mode == 2) {
- if (mode == 0 && (dwFlags & SMF_SHOWDATE)) {
+ }
+ }
+ if (mode == 0 || mode == 2) {
+ if (mode == 0 && (dwFlags & SMF_SHOWDATE))
lstrcat(format, _T(" "));
- }
+
lstrcat(format, (dwFlags & SMF_SHOWSECONDS) ? _T("s") : _T("t"));
- }
- if (format[0] != '\0') {
+ }
+ if (format[0] != '\0') {
tmi.printTimeStamp(NULL, check, format, str, SIZEOF(str), 0);
_tcsncat(szResult, str, 500);
}
- return szResult;
+ return szResult;
}
int isSameDate(time_t time1, time_t time2)
@@ -537,58 +524,59 @@ static int DetectURL(wchar_t *text, BOOL firstChar) {
return 0;
}
-static void AppendWithCustomLinks(EventData *event, int style, char **buffer, int *bufferEnd, int *bufferAlloced) {
+static void AppendWithCustomLinks(EventData *evt, int style, char **buffer, int *bufferEnd, int *bufferAlloced)
+{
int lasttoken = 0;
int laststart = 0;
int j, len;
WCHAR *wText;
- BOOL isAnsii = (event->dwFlags & IEEDF_UNICODE_TEXT) == 0;
+ BOOL isAnsii = (evt->dwFlags & IEEDF_UNICODE_TEXT) == 0;
- if ( event->pszText == NULL )
+ if (evt->pszText == NULL)
return;
if (isAnsii) {
- len = (int)strlen(event->pszText);
- wText = a2w(event->pszText, len);
- } else {
- wText = event->pszTextW;
- len = (int)wcslen(event->pszTextW);
+ len = (int)strlen(evt->pszText);
+ wText = a2w(evt->pszText, len);
+ }
+ else {
+ wText = evt->pszTextW;
+ len = (int)wcslen(evt->pszTextW);
}
for (j = 0; j < len ; j++) {
int newtoken = 0;
int l = DetectURL(wText + j, j==0);
- if (l > 0) {
+ if (l > 0)
newtoken = 1;
- }
- if (j == 0) {
+
+ if (j == 0)
lasttoken = newtoken;
- }
+
if (newtoken != lasttoken) {
- if (lasttoken == 0) {
+ if (lasttoken == 0)
AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(style));
- } else {
- AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYURL : MSGFONTID_YOURURL));
- }
+ else
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYURL : MSGFONTID_YOURURL));
+
AppendUnicodeOrAnsiiToBufferL(buffer, bufferEnd, bufferAlloced, wText + laststart, j - laststart, isAnsii);
laststart = j;
lasttoken = newtoken;
}
}
if (len - laststart > 0) {
- if (lasttoken == 0) {
+ if (lasttoken == 0)
AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(style));
- } else {
- AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYURL : MSGFONTID_YOURURL));
- }
+ else
+ AppendToBuffer(buffer, bufferEnd, bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYURL : MSGFONTID_YOURURL));
+
AppendUnicodeOrAnsiiToBufferL(buffer, bufferEnd, bufferAlloced, wText + laststart, len - laststart, isAnsii);
}
- if (isAnsii) {
+ if (isAnsii)
mir_free(wText);
- }
}
//mir_free() the return value
-static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, struct GlobalMessageData *gdat, struct LogStreamData *streamData)
+static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *evt, struct GlobalMessageData *gdat, struct LogStreamData *streamData)
{
char *buffer;
int bufferAlloced, bufferEnd;
@@ -597,131 +585,128 @@ static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, st
int highlight = 0;
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
+ buffer = (char*) mir_alloc(bufferAlloced);
buffer[0] = '\0';
- if ((gdat->flags & SMF_GROUPMESSAGES) && event->dwFlags == LOWORD(dat->lastEventType)
- && event->eventType == EVENTTYPE_MESSAGE && HIWORD(dat->lastEventType) == EVENTTYPE_MESSAGE
- && (isSameDate(event->time, dat->lastEventTime))
-// && ((dbei.timestamp - dat->lastEventTime) < 86400)
- && ((((int)event->time < dat->startTime) == (dat->lastEventTime < dat->startTime)) || !(event->dwFlags & IEEDF_READ))) {
+ if ((gdat->flags & SMF_GROUPMESSAGES) && evt->dwFlags == LOWORD(dat->lastEventType) &&
+ evt->eventType == EVENTTYPE_MESSAGE && HIWORD(dat->lastEventType) == EVENTTYPE_MESSAGE &&
+ (isSameDate(evt->time, dat->lastEventTime)) && ((((int)evt->time < dat->startTime) == (dat->lastEventTime < dat->startTime)) || !(evt->dwFlags & IEEDF_READ)))
+ {
isGroupBreak = FALSE;
}
+
if (!streamData->isFirst && !dat->isMixed) {
- if (isGroupBreak || gdat->flags & SMF_MARKFOLLOWUPS) {
+ if (isGroupBreak || gdat->flags & SMF_MARKFOLLOWUPS)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\line");
- }
}
- if (event->dwFlags & IEEDF_RTL) {
+
+ if (evt->dwFlags & IEEDF_RTL)
dat->isMixed = 1;
- }
- if (!streamData->isFirst && isGroupBreak && (gdat->flags & SMF_DRAWLINES)) {
+
+ if (!streamData->isFirst && isGroupBreak && (gdat->flags & SMF_DRAWLINES))
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1\\slmult0\\highlight%d\\cf%d\\fs1 \\par\\sl0", fontOptionsListSize + 4, fontOptionsListSize + 4);
- }
+
if ( streamData->isFirst ) {
- if (event->dwFlags & IEEDF_RTL) {
+ if (evt->dwFlags & IEEDF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
- }
- } else {
- if (event->dwFlags & IEEDF_RTL) {
+ }
+ else {
+ if (evt->dwFlags & IEEDF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
- }
}
- if (event->eventType == EVENTTYPE_MESSAGE) {
- highlight = fontOptionsListSize + 2 + ((event->dwFlags & IEEDF_SENT) ? 1 : 0);
- } else {
+ if (evt->eventType == EVENTTYPE_MESSAGE)
+ highlight = fontOptionsListSize + 2 + ((evt->dwFlags & IEEDF_SENT) ? 1 : 0);
+ else
highlight = fontOptionsListSize + 1;
- }
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\highlight%d\\cf%d", highlight , highlight );
if (!streamData->isFirst && dat->isMixed) {
- if (isGroupBreak) {
+ if (isGroupBreak)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1 \\par\\sl0");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\sl-1 \\line\\sl0");
- }
}
streamData->isFirst = FALSE;
if (dat->isMixed) {
- if (event->dwFlags & IEEDF_RTL) {
+ if (evt->dwFlags & IEEDF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrch\\rtlch");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlch\\ltrch");
- }
}
- if (gdat->flags&SMF_SHOWICONS && isGroupBreak) {
+ if ((gdat->flags & SMF_SHOWICONS) && isGroupBreak) {
int i = LOGICON_MSG_NOTICE;
- switch (event->eventType) {
- case EVENTTYPE_MESSAGE:
- if (event->dwFlags & IEEDF_SENT) {
- i = LOGICON_MSG_OUT;
- }
- else {
- i = LOGICON_MSG_IN;
- }
- break;
- case EVENTTYPE_JABBER_CHATSTATES:
- case EVENTTYPE_JABBER_PRESENCE:
- case EVENTTYPE_STATUSCHANGE:
- case EVENTTYPE_URL:
- case EVENTTYPE_FILE:
- i = LOGICON_MSG_NOTICE;
- break;
+ switch (evt->eventType) {
+ case EVENTTYPE_MESSAGE:
+ if (evt->dwFlags & IEEDF_SENT)
+ i = LOGICON_MSG_OUT;
+ else
+ i = LOGICON_MSG_IN;
+ break;
+
+ case EVENTTYPE_JABBER_CHATSTATES:
+ case EVENTTYPE_JABBER_PRESENCE:
+ case EVENTTYPE_STATUSCHANGE:
+ case EVENTTYPE_URL:
+ case EVENTTYPE_FILE:
+ i = LOGICON_MSG_NOTICE;
+ break;
}
+
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fs1 ");
while (bufferAlloced - bufferEnd < logIconBmpSize[i])
bufferAlloced += 1024;
- buffer = (char *) mir_realloc(buffer, bufferAlloced);
+ buffer = (char*) mir_realloc(buffer, bufferAlloced);
CopyMemory(buffer + bufferEnd, pLogIconBmpBits[i], logIconBmpSize[i]);
bufferEnd += logIconBmpSize[i];
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " ");
}
- if (gdat->flags&SMF_SHOWTIME && (event->eventType != EVENTTYPE_MESSAGE ||
+
+ if (gdat->flags&SMF_SHOWTIME && (evt->eventType != EVENTTYPE_MESSAGE ||
(gdat->flags & SMF_MARKFOLLOWUPS || isGroupBreak || !(gdat->flags & SMF_GROUPMESSAGES)))) {
- TCHAR * timestampString = NULL;
- if (gdat->flags & SMF_GROUPMESSAGES && event->eventType == EVENTTYPE_MESSAGE) {
+ TCHAR *timestampString = NULL;
+ if (gdat->flags & SMF_GROUPMESSAGES && evt->eventType == EVENTTYPE_MESSAGE) {
if (isGroupBreak) {
- if (!(gdat->flags & SMF_MARKFOLLOWUPS)) {
- timestampString = TimestampToString(gdat->flags, event->time, 0);
- } else if (gdat->flags & SMF_SHOWDATE)
- timestampString = TimestampToString(gdat->flags, event->time, 1);
- } else if (gdat->flags & SMF_MARKFOLLOWUPS) {
- timestampString = TimestampToString(gdat->flags, event->time, 2);
+ if (!(gdat->flags & SMF_MARKFOLLOWUPS))
+ timestampString = TimestampToString(gdat->flags, evt->time, 0);
+ else if (gdat->flags & SMF_SHOWDATE)
+ timestampString = TimestampToString(gdat->flags, evt->time, 1);
}
- } else
- timestampString = TimestampToString(gdat->flags, event->time, 0);
+ else if (gdat->flags & SMF_MARKFOLLOWUPS)
+ timestampString = TimestampToString(gdat->flags, evt->time, 2);
+ }
+ else timestampString = TimestampToString(gdat->flags, evt->time, 0);
+
if (timestampString != NULL) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, timestampString);
}
- if (event->eventType != EVENTTYPE_MESSAGE) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
- }
+ if (evt->eventType != EVENTTYPE_MESSAGE)
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
showColon = 1;
}
- if ((!(gdat->flags&SMF_HIDENAMES) && event->eventType == EVENTTYPE_MESSAGE && isGroupBreak) || event->eventType == EVENTTYPE_STATUSCHANGE || event->eventType == EVENTTYPE_JABBER_CHATSTATES || event->eventType == EVENTTYPE_JABBER_PRESENCE) {
- if (event->eventType == EVENTTYPE_MESSAGE) {
+ if ((!(gdat->flags&SMF_HIDENAMES) && evt->eventType == EVENTTYPE_MESSAGE && isGroupBreak) || evt->eventType == EVENTTYPE_STATUSCHANGE || evt->eventType == EVENTTYPE_JABBER_CHATSTATES || evt->eventType == EVENTTYPE_JABBER_PRESENCE) {
+ if (evt->eventType == EVENTTYPE_MESSAGE) {
if (showColon)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
}
else AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(MSGFONTID_NOTICE));
- if (event->dwFlags & IEEDF_UNICODE_NICK)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszNickW);
+ if (evt->dwFlags & IEEDF_UNICODE_NICK)
+ AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszNickW);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszNick);
+ AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszNick);
showColon = 1;
- if (event->eventType == EVENTTYPE_MESSAGE && gdat->flags & SMF_GROUPMESSAGES) {
+ if (evt->eventType == EVENTTYPE_MESSAGE && gdat->flags & SMF_GROUPMESSAGES) {
if (gdat->flags & SMF_MARKFOLLOWUPS)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
else
@@ -730,25 +715,24 @@ static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, st
}
}
- if (gdat->flags&SMF_SHOWTIME && gdat->flags & SMF_GROUPMESSAGES && gdat->flags & SMF_MARKFOLLOWUPS
- && event->eventType == EVENTTYPE_MESSAGE && isGroupBreak) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
- AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TimestampToString(gdat->flags, event->time, 2));
+ if (gdat->flags&SMF_SHOWTIME && gdat->flags & SMF_GROUPMESSAGES && gdat->flags & SMF_MARKFOLLOWUPS && evt->eventType == EVENTTYPE_MESSAGE && isGroupBreak) {
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME));
+ AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TimestampToString(gdat->flags, evt->time, 2));
showColon = 1;
}
- if (showColon && event->eventType == EVENTTYPE_MESSAGE) {
- if (event->dwFlags & IEEDF_RTL)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\~%s: ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
+ if (showColon && evt->eventType == EVENTTYPE_MESSAGE) {
+ if (evt->dwFlags & IEEDF_RTL)
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\~%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(event->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s: ", SetToStyle(evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
}
- switch (event->eventType) {
+ switch (evt->eventType) {
case EVENTTYPE_MESSAGE:
if (gdat->flags & SMF_MSGONNEWLINE && showColon)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\line");
- style = event->dwFlags & IEEDF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG;
- AppendWithCustomLinks(event, style, &buffer, &bufferEnd, &bufferAlloced);
+ style = evt->dwFlags & IEEDF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG;
+ AppendWithCustomLinks(evt, style, &buffer, &bufferEnd, &bufferAlloced);
break;
case EVENTTYPE_JABBER_CHATSTATES:
@@ -758,15 +742,15 @@ static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, st
case EVENTTYPE_FILE:
style = MSGFONTID_NOTICE;
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s ", SetToStyle(style));
- if (event->eventType == EVENTTYPE_FILE) {
- if (event->dwFlags & IEEDF_SENT)
+ if (evt->eventType == EVENTTYPE_FILE) {
+ if (evt->dwFlags & IEEDF_SENT)
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("File sent"));
else
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("File received"));
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(":"));
}
- else if (event->eventType == EVENTTYPE_URL) {
- if (event->dwFlags & IEEDF_SENT)
+ else if (evt->eventType == EVENTTYPE_URL) {
+ if (evt->dwFlags & IEEDF_SENT)
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("URL sent"));
else
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, TranslateT("URL received"));
@@ -774,17 +758,17 @@ static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, st
}
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(" "));
- if (event->dwFlags & IEEDF_UNICODE_TEXT)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszTextW);
+ if (evt->dwFlags & IEEDF_UNICODE_TEXT)
+ AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszTextW);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszText);
+ AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText);
- if (event->pszText2W != NULL) {
+ if (evt->pszText2W != NULL) {
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(" ("));
- if (event->dwFlags & IEEDF_UNICODE_TEXT2)
- AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszText2W);
+ if (evt->dwFlags & IEEDF_UNICODE_TEXT2)
+ AppendUnicodeToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText2W);
else
- AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, event->pszText2);
+ AppendAnsiToBuffer(&buffer, &bufferEnd, &bufferAlloced, evt->pszText2);
AppendTToBuffer(&buffer, &bufferEnd, &bufferAlloced, _T(")"));
}
break;
@@ -792,8 +776,8 @@ static char *CreateRTFFromEvent(struct SrmmWindowData *dat, EventData *event, st
if (dat->isMixed)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
- dat->lastEventTime = event->time;
- dat->lastEventType = MAKELONG(event->dwFlags, event->eventType);
+ dat->lastEventTime = evt->time;
+ dat->lastEventType = MAKELONG(evt->dwFlags, evt->eventType);
return buffer;
}
@@ -810,18 +794,19 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
break;
case STREAMSTAGE_EVENTS:
if (dat->events != NULL) {
- EventData *event = dat->events;
+ EventData *evt = dat->events;
dat->buffer = NULL;
- dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
- dat->events = event->next;
- freeEvent(event);
- } else if (dat->eventsToInsert) {
+ dat->buffer = CreateRTFFromEvent(dat->dlgDat, evt, dat->gdat, dat);
+ dat->events = evt->next;
+ freeEvent(evt);
+ }
+ else if (dat->eventsToInsert) {
do {
- EventData *event = getEventFromDB(dat->dlgDat, dat->hContact, dat->hDbEvent);
+ EventData *evt = getEventFromDB(dat->dlgDat, dat->hContact, dat->hDbEvent);
dat->buffer = NULL;
- if (event != NULL) {
- dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
- freeEvent(event);
+ if (evt != NULL) {
+ dat->buffer = CreateRTFFromEvent(dat->dlgDat, evt, dat->gdat, dat);
+ freeEvent(evt);
}
if (dat->buffer)
dat->hDbEventLast = dat->hDbEvent;
@@ -830,9 +815,9 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
break;
} while (dat->buffer == NULL && dat->hDbEvent);
}
- if (dat->buffer) {
+ if (dat->buffer)
break;
- }
+
dat->stage = STREAMSTAGE_TAIL;
//fall through
case STREAMSTAGE_TAIL:
@@ -869,6 +854,7 @@ void StreamInTestEvents(HWND hEditWnd, struct GlobalMessageData *gdat)
SendMessage(hEditWnd, EM_STREAMIN, SF_RTF, (LPARAM)& stream);
SendMessage(hEditWnd, EM_HIDESELECTION, FALSE, 0);
}
+
void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
{
FINDTEXTEXA fi;
@@ -879,24 +865,24 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
// IEVIew MOD Begin
if (dat->windowData.hwndLog != NULL) {
- IEVIEWEVENT event;
+ IEVIEWEVENT evt;
IEVIEWWINDOW ieWindow;
- ZeroMemory(&event, sizeof(event));
- event.cbSize = sizeof(event);
- event.dwFlags = ((dat->flags & SMF_RTL) ? IEEF_RTL : 0);
- event.hwnd = dat->windowData.hwndLog;
- event.hContact = dat->windowData.hContact;
- event.codepage = dat->windowData.codePage;
- event.pszProto = dat->szProto;
+ ZeroMemory(&evt, sizeof(evt));
+ evt.cbSize = sizeof(evt);
+ evt.dwFlags = ((dat->flags & SMF_RTL) ? IEEF_RTL : 0);
+ evt.hwnd = dat->windowData.hwndLog;
+ evt.hContact = dat->windowData.hContact;
+ evt.codepage = dat->windowData.codePage;
+ evt.pszProto = dat->szProto;
if (!fAppend) {
- event.iType = IEE_CLEAR_LOG;
- CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
+ evt.iType = IEE_CLEAR_LOG;
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt);
}
- event.iType = IEE_LOG_DB_EVENTS;
- event.hDbEventFirst = hDbEventFirst;
- event.count = count;
- CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
- dat->hDbEventLast = event.hDbEventFirst != NULL ? event.hDbEventFirst : dat->hDbEventLast;
+ evt.iType = IEE_LOG_DB_EVENTS;
+ evt.hDbEventFirst = hDbEventFirst;
+ evt.count = count;
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt);
+ dat->hDbEventLast = evt.hDbEventFirst != NULL ? evt.hDbEventFirst : dat->hDbEventLast;
ZeroMemory(&ieWindow, sizeof(ieWindow));
ieWindow.cbSize = sizeof(ieWindow);
@@ -920,20 +906,20 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
stream.dwCookie = (DWORD_PTR) & streamData;
sel.cpMin = 0;
if (fAppend) {
- GETTEXTLENGTHEX gtxl = {0};
- gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS;
+ GETTEXTLENGTHEX gtxl = {0};
+ gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS;
gtxl.codepage = 1200;
gtxl.codepage = 1200;
- fi.chrg.cpMin = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETTEXTLENGTHEX, (WPARAM)&gtxl, 0);
- sel.cpMin = sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG), dat->windowData.codePage, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)& sel);
- } else {
+ fi.chrg.cpMin = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETTEXTLENGTHEX, (WPARAM)&gtxl, 0);
+ sel.cpMin = sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG), dat->windowData.codePage, FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)& sel);
+ } else {
SendDlgItemMessage(hwndDlg, IDC_LOG, WM_SETREDRAW, FALSE, 0);
SetDlgItemText(hwndDlg, IDC_LOG, _T(""));
- sel.cpMin = 0;
+ sel.cpMin = 0;
sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG), dat->windowData.codePage, FALSE);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)& sel);
- fi.chrg.cpMin = 0;
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)& sel);
+ fi.chrg.cpMin = 0;
dat->isMixed = 0;
}
@@ -945,20 +931,18 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
smre.cbSize = sizeof(SMADD_RICHEDIT3);
smre.hwndRichEditControl = GetDlgItem(hwndDlg, IDC_LOG);
smre.Protocolname = dat->szProto;
- if (dat->szProto!=NULL && strcmp(dat->szProto,"MetaContacts")==0) {
- HANDLE hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) dat->windowData.hContact, 0);
- if (hContact!=NULL) {
- smre.Protocolname = GetContactProto(hContact);
- }
- }
+ if (dat->szProto != NULL && strcmp(dat->szProto,"MetaContacts") == 0) {
+ HANDLE hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) dat->windowData.hContact, 0);
+ if (hContact != NULL)
+ smre.Protocolname = GetContactProto(hContact);
+ }
if (fi.chrg.cpMin > 0) {
sel.cpMin = fi.chrg.cpMin;
sel.cpMax = -1;
smre.rangeToReplace = &sel;
- } else {
- smre.rangeToReplace = NULL;
}
- //smre.rangeToReplace = NULL;
+ else smre.rangeToReplace = NULL;
+
smre.disableRedraw = TRUE;
smre.hContact = dat->windowData.hContact;
smre.flags = 0;
@@ -979,72 +963,62 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend)
void LoadMsgLogIcons(void)
{
HICON hIcon = NULL;
- HBITMAP hBmp, hoBmp;
- HDC hdc, hdcMem;
- BITMAPINFOHEADER bih = { 0 };
- int widthBytes, i;
RECT rc;
- HBRUSH hBrush;
- HBRUSH hBkgBrush;
- HBRUSH hInBkgBrush;
- HBRUSH hOutBkgBrush;
- int rtfHeaderSize;
- PBYTE pBmpBits;
g_hImageList = ImageList_Create(10, 10, IsWinVerXPPlus()? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, sizeof(pLogIconBmpBits) / sizeof(pLogIconBmpBits[0]), 0);
- hBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR));
- hInBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_INCOMINGBKGCOLOUR, SRMSGDEFSET_INCOMINGBKGCOLOUR));
- hOutBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_OUTGOINGBKGCOLOUR, SRMSGDEFSET_OUTGOINGBKGCOLOUR));
- bih.biSize = sizeof(bih);
+ HBRUSH hBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR));
+ HBRUSH hInBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_INCOMINGBKGCOLOUR, SRMSGDEFSET_INCOMINGBKGCOLOUR));
+ HBRUSH hOutBkgBrush = CreateSolidBrush(db_get_dw(NULL, SRMMMOD, SRMSGSET_OUTGOINGBKGCOLOUR, SRMSGDEFSET_OUTGOINGBKGCOLOUR));
+
+ BITMAPINFOHEADER bih = { sizeof(bih) };
bih.biBitCount = 24;
bih.biCompression = BI_RGB;
bih.biHeight = 10;
bih.biPlanes = 1;
bih.biWidth = 10;
- widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
+ int widthBytes = ((bih.biWidth * bih.biBitCount + 31) >> 5) * 4;
rc.top = rc.left = 0;
rc.right = bih.biWidth;
rc.bottom = bih.biHeight;
- hdc = GetDC(NULL);
- hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
- hdcMem = CreateCompatibleDC(hdc);
- pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
- hBrush = hBkgBrush;
- for (i = 0; i < sizeof(pLogIconBmpBits) / sizeof(pLogIconBmpBits[0]); i++) {
+ HDC hdc = GetDC(NULL);
+ HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ PBYTE pBmpBits = (PBYTE) mir_alloc(widthBytes * bih.biHeight);
+ HBRUSH hBrush = hBkgBrush;
+ for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) {
switch (i) {
- case LOGICON_MSG_IN:
- ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_INCOMING"));
- hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_IN, ILD_NORMAL);
- hBrush = hInBkgBrush;
- break;
- case LOGICON_MSG_OUT:
- ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_OUTGOING"));
- hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_OUT, ILD_NORMAL);
- hBrush = hOutBkgBrush;
- break;
- case LOGICON_MSG_NOTICE:
- ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_NOTICE"));
- hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_NOTICE, ILD_NORMAL);
- //hBrush = hInBkgBrush;
- hBrush = hBkgBrush;
- break;
+ case LOGICON_MSG_IN:
+ ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_INCOMING"));
+ hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_IN, ILD_NORMAL);
+ hBrush = hInBkgBrush;
+ break;
+ case LOGICON_MSG_OUT:
+ ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_OUTGOING"));
+ hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_OUT, ILD_NORMAL);
+ hBrush = hOutBkgBrush;
+ break;
+ case LOGICON_MSG_NOTICE:
+ ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_NOTICE"));
+ hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_NOTICE, ILD_NORMAL);
+ hBrush = hBkgBrush;
+ break;
}
pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2);
//I can't seem to get binary mode working. No matter.
- rtfHeaderSize = sprintf((char *)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, (UINT) bih.biWidth, (UINT)bih.biHeight);
- hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
+ int rtfHeaderSize = sprintf((char*)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, (UINT) bih.biWidth, (UINT)bih.biHeight);
+ HBITMAP hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBrush);
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);
DestroyIcon(hIcon);
- {
- 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]);
- }
+
+ 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] = '}';
}
@@ -1059,8 +1033,7 @@ void LoadMsgLogIcons(void)
void FreeMsgLogIcons(void)
{
- int i;
- for (i = 0; i < sizeof(pLogIconBmpBits) / sizeof(pLogIconBmpBits[0]); i++)
+ for (int i = 0; i < sizeof(pLogIconBmpBits) / sizeof(pLogIconBmpBits[0]); i++)
mir_free(pLogIconBmpBits[i]);
ImageList_RemoveAll(g_hImageList);
ImageList_Destroy(g_hImageList);
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp
index 16e66f6fb2..41db518bf8 100644
--- a/plugins/Scriver/src/msgoptions.cpp
+++ b/plugins/Scriver/src/msgoptions.cpp
@@ -810,7 +810,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
SendDlgItemMessage(hwndDlg, IDC_LINECOLOUR, CPM_SETCOLOUR, 0, db_get_dw(NULL, SRMMMOD, SRMSGSET_LINECOLOUR, SRMSGDEFSET_LINECOLOUR));
{
PARAFORMAT2 pf2;
- ZeroMemory((void *)&pf2, sizeof(pf2));
+ ZeroMemory(&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_OFFSETINDENT | PFM_RIGHTINDENT;
pf2.dxStartIndent = 30;
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index f98dc86fe8..97ba638b7e 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -183,7 +183,7 @@ static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam)
if (lParam) {
HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
- SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(char *) lParam);
+ SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(char*) lParam);
}
SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
}
@@ -296,7 +296,7 @@ static void RestoreUnreadMessageAlerts(void)
else {
cle.hContact = hContact;
cle.hDbEvent = hDbEvent;
- mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
+ mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), (char*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)& cle);
}
}
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp
index dc2d1c2338..d7763423c4 100644
--- a/plugins/Scriver/src/msgwindow.cpp
+++ b/plugins/Scriver/src/msgwindow.cpp
@@ -78,7 +78,7 @@ TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto)
tokenLen[2] = j;
}
- accModule = (char *) CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM) hContact, 0);
+ accModule = (char*) CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM) hContact, 0);
if (accModule != NULL) {
PROTOACCOUNT* proto = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)accModule);
if (proto != NULL) {
diff --git a/plugins/Scriver/src/srmm.cpp b/plugins/Scriver/src/srmm.cpp
index f7da293973..1bc3f59dff 100644
--- a/plugins/Scriver/src/srmm.cpp
+++ b/plugins/Scriver/src/srmm.cpp
@@ -26,13 +26,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int OnLoadModule(void);
int OnUnloadModule(void);
+int hLangpack;
TIME_API tmi;
-
-
HINSTANCE g_hInst;
-int hLangpack;
+CLIST_INTERFACE *pcli;
-ITaskbarList3 * pTaskbarInterface;
+ITaskbarList3 *pTaskbarInterface;
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -65,7 +64,8 @@ extern "C" __declspec(dllexport) int Load(void)
{
// set the memory manager
mir_getTMI(&tmi);
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
+ mir_getCLI();
if (IsWinVer7Plus())
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface);
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index a29c003844..0c90618d10 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -89,7 +89,7 @@ wchar_t *a2w(const char *src, int len) {
if (len <0) {
len = (int)strlen(src);
}
- wline = (wchar_t *)mir_alloc(2 * (len + 1));
+ wline = (wchar_t*)mir_alloc(2 * (len + 1));
for (i = 0; i < len; i ++) {
wline[i] = src[i];
}
@@ -122,9 +122,9 @@ void logInfo(const char *fmt, ...) {
if (flog!=NULL) {
GetLocalTime(&time);
va_start(vararg, fmt);
- str = (char *) malloc(strsize=2048);
+ str = (char*) malloc(strsize=2048);
while (_vsnprintf(str, strsize, fmt, vararg) == -1)
- str = (char *) realloc(str, strsize+=2048);
+ str = (char*) realloc(str, strsize+=2048);
va_end(vararg);
fprintf(flog,"%04d-%02d-%02d %02d:%02d:%02d,%03d [%s]",time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond,time.wMilliseconds, "INFO");
fprintf(flog," %s\n",str);
@@ -198,14 +198,14 @@ static DWORD CALLBACK RichTextStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff,
char ** ppText = (char **) dwCookie;
if (*ppText == NULL) {
- *ppText = (char *)mir_alloc(cb + 1);
+ *ppText = (char*)mir_alloc(cb + 1);
memcpy(*ppText, pbBuff, cb);
(*ppText)[cb] = 0;
*pcb = cb;
dwRead = cb;
}
else {
- char *p = (char *)mir_alloc(dwRead + cb + 1);
+ char *p = (char*)mir_alloc(dwRead + cb + 1);
memcpy(p, *ppText, dwRead);
memcpy(p+dwRead, pbBuff, cb);
p[dwRead + cb] = 0;
@@ -332,7 +332,7 @@ void AppendToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const
if (charsDone >= 0)
break;
*cbBufferAlloced += 1024;
- *buffer = (char *) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char*) mir_realloc(*buffer, *cbBufferAlloced);
}
va_end(va);
*cbBufferEnd += charsDone;
@@ -410,7 +410,7 @@ char to_hex(char code) {
/* Returns a url-encoded version of str */
/* IMPORTANT: be sure to free() the returned string after use */
char *url_encode(char *str) {
- char *pstr = str, *buf = (char *)mir_alloc(strlen(str) * 3 + 1), *pbuf = buf;
+ char *pstr = str, *buf = (char*)mir_alloc(strlen(str) * 3 + 1), *pbuf = buf;
while (*pstr) {
if ( (48 <= *pstr && *pstr <= 57) ||//0-9
(65 <= *pstr && *pstr <= 90) ||//ABC...XYZ