diff options
Diffstat (limited to 'plugins/Scriver/src/chat')
-rw-r--r-- | plugins/Scriver/src/chat/log.cpp | 87 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/manager.cpp | 35 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/options.cpp | 10 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/services.cpp | 342 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/tools.cpp | 187 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 27 |
6 files changed, 314 insertions, 374 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;
}
|