summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-26 23:14:10 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-26 23:14:10 +0300
commita3eedb2759dd0c88c9fabee28e2432f71dd2b440 (patch)
treeca637483382ef2dc38a1a4fd21c09d605df8f9ad
parentbb0fc7d8899aa45c6822ce2469235a5dd75a0ce3 (diff)
Chat_Event not to change the original structure, but to use its own copy instead
-rw-r--r--src/mir_app/src/chat_svc.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 1c0bd9d969..dcffda8b06 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -422,30 +422,30 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce)
static INT_PTR CALLBACK sttEventStub(void *_param)
{
- GCEVENT *gce = (GCEVENT*)_param;
- if (gce->dwFlags & GCEF_UTF8) {
- gce->pszID.w = NEWWSTR_ALLOCA(Utf2T(gce->pszID.a));
- gce->pszUID.w = NEWWSTR_ALLOCA(Utf2T(gce->pszUID.a));
- gce->pszNick.w = NEWWSTR_ALLOCA(Utf2T(gce->pszNick.a));
- gce->pszText.w = NEWWSTR_ALLOCA(Utf2T(gce->pszText.a));
- gce->pszStatus.w = NEWWSTR_ALLOCA(Utf2T(gce->pszStatus.a));
- gce->pszUserInfo.w = NEWWSTR_ALLOCA(Utf2T(gce->pszUserInfo.a));
- gce->dwFlags &= ~GCEF_UTF8;
+ GCEVENT gce = *(GCEVENT*)_param;
+ if (gce.dwFlags & GCEF_UTF8) {
+ gce.pszID.w = NEWWSTR_ALLOCA(Utf2T(gce.pszID.a));
+ gce.pszUID.w = NEWWSTR_ALLOCA(Utf2T(gce.pszUID.a));
+ gce.pszNick.w = NEWWSTR_ALLOCA(Utf2T(gce.pszNick.a));
+ gce.pszText.w = NEWWSTR_ALLOCA(Utf2T(gce.pszText.a));
+ gce.pszStatus.w = NEWWSTR_ALLOCA(Utf2T(gce.pszStatus.a));
+ gce.pszUserInfo.w = NEWWSTR_ALLOCA(Utf2T(gce.pszUserInfo.a));
+ gce.dwFlags &= ~GCEF_UTF8;
}
- if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce)))
+ if (NotifyEventHooks(hHookEvent, 0, LPARAM(&gce)))
return 1;
bool bIsHighlighted = false, bRemoveFlag = false;
// Do different things according to type of event
- switch (gce->iType) {
+ switch (gce.iType) {
case GC_EVENT_SETCONTACTSTATUS:
- return SM_SetContactStatus(gce->pszID.w, gce->pszModule, gce->pszUID.w, (WORD)gce->dwItemData);
+ return SM_SetContactStatus(gce.pszID.w, gce.pszModule, gce.pszUID.w, (WORD)gce.dwItemData);
case GC_EVENT_TOPIC:
- if (SESSION_INFO *si = SM_FindSession(gce->pszID.w, gce->pszModule)) {
- wchar_t *pwszNew = RemoveFormatting(gce->pszText.w);
+ if (SESSION_INFO *si = SM_FindSession(gce.pszID.w, gce.pszModule)) {
+ wchar_t *pwszNew = RemoveFormatting(gce.pszText.w);
if (!mir_wstrcmp(si->ptszTopic, pwszNew)) // nothing changed? exiting
return 0;
@@ -468,51 +468,51 @@ static INT_PTR CALLBACK sttEventStub(void *_param)
break;
case GC_EVENT_ADDSTATUS:
- SM_GiveStatus(gce->pszID.w, gce->pszModule, gce->pszUID.w, gce->pszStatus.w);
- bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
+ SM_GiveStatus(gce.pszID.w, gce.pszModule, gce.pszUID.w, gce.pszStatus.w);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, &gce);
break;
case GC_EVENT_REMOVESTATUS:
- SM_TakeStatus(gce->pszID.w, gce->pszModule, gce->pszUID.w, gce->pszStatus.w);
- bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
+ SM_TakeStatus(gce.pszID.w, gce.pszModule, gce.pszUID.w, gce.pszStatus.w);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, &gce);
break;
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
- if (!gce->bIsMe && gce->pszID.w && gce->pszText.w) {
- SESSION_INFO *si = SM_FindSession(gce->pszID.w, gce->pszModule);
- bIsHighlighted = g_chatApi.IsHighlighted(si, gce);
+ if (!gce.bIsMe && gce.pszID.w && gce.pszText.w) {
+ SESSION_INFO *si = SM_FindSession(gce.pszID.w, gce.pszModule);
+ bIsHighlighted = g_chatApi.IsHighlighted(si, &gce);
}
break;
case GC_EVENT_NICK:
- SM_ChangeNick(gce->pszID.w, gce->pszModule, gce);
- bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
+ SM_ChangeNick(gce.pszID.w, gce.pszModule, &gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, &gce);
break;
case GC_EVENT_JOIN:
- AddUser(gce);
- bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
+ AddUser(&gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, &gce);
break;
case GC_EVENT_PART:
case GC_EVENT_QUIT:
case GC_EVENT_KICK:
bRemoveFlag = TRUE;
- bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, &gce);
break;
}
// Decide which window (log) should have the event
LPCTSTR pWnd = nullptr;
LPCSTR pMod = nullptr;
- if (gce->pszID.w) {
- pWnd = gce->pszID.w;
- pMod = gce->pszModule;
+ if (gce.pszID.w) {
+ pWnd = gce.pszID.w;
+ pMod = gce.pszModule;
}
- else if (gce->iType == GC_EVENT_NOTICE || gce->iType == GC_EVENT_INFORMATION) {
+ else if (gce.iType == GC_EVENT_NOTICE || gce.iType == GC_EVENT_INFORMATION) {
SESSION_INFO *si = g_chatApi.GetActiveSession();
- if (si && !mir_strcmp(si->pszModule, gce->pszModule)) {
+ if (si && !mir_strcmp(si->pszModule, gce.pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
}
@@ -520,33 +520,33 @@ static INT_PTR CALLBACK sttEventStub(void *_param)
}
else {
// Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
- AddEventToAllMatchingUID(gce);
+ AddEventToAllMatchingUID(&gce);
if (!bRemoveFlag)
return 0;
}
// add to log
if (pWnd) {
- if (gce->dwFlags & GCEF_SILENT)
+ if (gce.dwFlags & GCEF_SILENT)
return 0;
SESSION_INFO *si = SM_FindSession(pWnd, pMod);
// fix for IRC's old style mode notifications. Should not affect any other protocol
- if ((gce->iType == GC_EVENT_ADDSTATUS || gce->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG))
+ if ((gce.iType == GC_EVENT_ADDSTATUS || gce.iType == GC_EVENT_REMOVESTATUS) && !(gce.dwFlags & GCEF_ADDTOLOG))
return 0;
- if (gce->iType == GC_EVENT_JOIN && gce->time == 0)
+ if (gce.iType == GC_EVENT_JOIN && gce.time == 0)
return 0;
- if (si && (si->bInitDone || gce->iType == GC_EVENT_TOPIC || (gce->iType == GC_EVENT_JOIN && gce->bIsMe))) {
- if (gce->pszNick.w == nullptr && gce->pszUID.w != nullptr) {
- USERINFO *ui = g_chatApi.UM_FindUser(si, gce->pszUID.w);
+ if (si && (si->bInitDone || gce.iType == GC_EVENT_TOPIC || (gce.iType == GC_EVENT_JOIN && gce.bIsMe))) {
+ if (gce.pszNick.w == nullptr && gce.pszUID.w != nullptr) {
+ USERINFO *ui = g_chatApi.UM_FindUser(si, gce.pszUID.w);
if (ui != nullptr)
- gce->pszNick.w = ui->pszNick;
+ gce.pszNick.w = ui->pszNick;
}
- int isOk = SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
+ int isOk = SM_AddEvent(pWnd, pMod, &gce, bIsHighlighted);
if (si->pDlg) {
if (isOk)
si->pDlg->AddLog();
@@ -554,11 +554,11 @@ static INT_PTR CALLBACK sttEventStub(void *_param)
si->pDlg->RedrawLog2();
}
- if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- g_chatApi.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
+ if (!(gce.dwFlags & GCEF_NOTNOTIFY))
+ g_chatApi.DoSoundsFlashPopupTrayStuff(si, &gce, bIsHighlighted, 0);
- if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
- g_chatApi.LogToFile(si, gce);
+ if ((gce.dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
+ g_chatApi.LogToFile(si, &gce);
}
if (!bRemoveFlag)
@@ -566,7 +566,7 @@ static INT_PTR CALLBACK sttEventStub(void *_param)
}
if (bRemoveFlag)
- return SM_RemoveUser(gce->pszID.w, gce->pszModule, gce->pszUID.w) == 0;
+ return SM_RemoveUser(gce.pszID.w, gce.pszModule, gce.pszUID.w) == 0;
return GC_EVENT_ERROR;
}