summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-04-25 20:45:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-04-25 20:45:50 +0300
commit9aad59651c77743717e36c3c9860964012258a00 (patch)
treed8c7aecd883730b0e02445acf094303084a784d7
parent7dc8f0c12ed80977d1092e0c18f053e294b971f2 (diff)
NewStory: fix for groupchat nicks
-rw-r--r--plugins/NewStory/src/history_array.cpp16
-rw-r--r--plugins/NewStory/src/history_array.h3
-rw-r--r--plugins/NewStory/src/templates.cpp2
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<wchar_t> strings;
OBJLIST<ItemBlock> 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);
}