From 9aad59651c77743717e36c3c9860964012258a00 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 25 Apr 2020 20:45:50 +0300 Subject: NewStory: fix for groupchat nicks --- plugins/NewStory/src/history_array.cpp | 16 +++++++++++++++- plugins/NewStory/src/history_array.h | 3 +++ plugins/NewStory/src/templates.cpp | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index b5d03d0b23..984076b92e 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -112,7 +112,8 @@ ItemData::~ItemData() // Array HistoryArray::HistoryArray() : - pages(50) + pages(50), + strings(50, wcscmp) { pages.insert(new ItemBlock()); } @@ -124,6 +125,10 @@ HistoryArray::~HistoryArray() void HistoryArray::clear() { + for (auto &str : strings) + mir_free(str); + strings.destroy(); + pages.destroy(); iLastPageCounter = 0; } @@ -134,9 +139,18 @@ void HistoryArray::addChatEvent(MCONTACT hContact, LOGINFO *pEvent) p.hContact = hContact; p.wtext = mir_wstrdup(pEvent->ptszText); p.dbeOk = true; + p.dbe.cbBlob = 1; p.dbe.pBlob = (BYTE *)p.wtext; p.dbe.eventType = EVENTTYPE_MESSAGE; p.dbe.timestamp = pEvent->time; + + if (pEvent->ptszNick) { + p.wszNick = strings.find(pEvent->ptszNick); + if (p.wszNick == nullptr) { + p.wszNick = mir_wstrdup(pEvent->ptszNick); + strings.insert(p.wszNick); + } + } } bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count, ItemData::EventLoadMode mode) diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 019e54db09..3f5b0fbc1e 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -21,6 +21,8 @@ struct ItemData bool wtext_del = false; wchar_t *wtext = 0; + wchar_t *wszNick = 0; + HANDLE data = 0; ItemData() { memset(&dbe, 0, sizeof(dbe)); } @@ -119,6 +121,7 @@ struct ItemBlock : public MZeroedObject class HistoryArray { + LIST strings; OBJLIST pages; int iLastPageCounter = 0; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 1d033d1254..7ccf117a7f 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -151,7 +151,7 @@ void vfEvent(int, TemplateVars *vars, MCONTACT, ItemData *item) vars->SetVar('N', nick, false); } else { - wchar_t *nick = Clist_GetContactDisplayName(item->hContact, 0); + wchar_t *nick = (item->wszNick) ? item->wszNick : Clist_GetContactDisplayName(item->hContact, 0); vars->SetVar('N', nick, false); } -- cgit v1.2.3