summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-26 13:53:10 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-26 13:53:10 +0300
commit9e755a4a7ed43f1c79e1b0149326078b4e87576a (patch)
tree06b86bb7ac14447e0fe4d66bccd7a91f6eaf1000 /plugins
parent1662a4421fecfdf03e68637e9a5969085644586e (diff)
fixes #3964 (NewStory+Telegram: add incoming replies support)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/src/history_array.cpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index edb47276b6..7b0f4d47b4 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -74,6 +74,8 @@ ItemData::ItemData()
ItemData::~ItemData()
{
mir_free(wtext);
+ if (dbe.szReplyId)
+ mir_free((char*)dbe.szReplyId);
if (data)
MTextDestroy(data);
}
@@ -334,6 +336,9 @@ void ItemData::load(bool bFullLoad)
m_bLoaded = true;
+ if (dbe.szReplyId)
+ dbe.szReplyId = mir_strdup(dbe.szReplyId);
+
switch (dbe.eventType) {
case EVENTTYPE_MESSAGE:
if (!(dbe.flags & DBEF_SENT)) {
@@ -398,6 +403,30 @@ void ItemData::load(bool bFullLoad)
break;
}
+ if (dbe.szReplyId)
+ if (MEVENT hReply = db_event_getById(dbe.szModule, dbe.szReplyId)) {
+ DB::EventInfo dbei(hReply);
+ if (dbei) {
+ CMStringW str(L"> ");
+
+ if (dbei.flags & DBEF_SENT) {
+ if (char *szProto = Proto_GetBaseAccountName(hContact))
+ str.AppendFormat(L"%s %s: ", ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)).get(), TranslateT("wrote"));
+ }
+ else str.AppendFormat(L"%s %s: ", Clist_GetContactDisplayName(hContact, 0), TranslateT("wrote"));
+
+ ptrW wszText(DbEvent_GetTextW(&dbei, CP_ACP));
+ if (mir_wstrlen(wszText) > 43)
+ wcscpy(wszText.get() + 40, L"...");
+ str.Append(wszText);
+ str.Append(L"\r\n");
+ str.Append(wtext);
+
+ mir_free(wtext);
+ wtext = str.Detach();
+ }
+ }
+
mir_free(dbe.pBlob);
dbe.pBlob = nullptr;
}
@@ -497,17 +526,25 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count)
int numItems = getCount();
auto *pPrev = (numItems == 0) ? nullptr : get(numItems - 1);
- DB::ECPTR pCursor(DB::Events(hContact, hEvent));
- for (int i = 0; i < count; i++) {
- hEvent = pCursor.FetchNext();
- if (!hEvent)
- break;
-
+ if (count == 1) {
auto &p = allocateItem();
p.hContact = hContact;
p.hEvent = hEvent;
pPrev = p.checkPrev(pPrev);
}
+ else {
+ DB::ECPTR pCursor(DB::Events(hContact, hEvent));
+ for (int i = 0; i < count; i++) {
+ hEvent = pCursor.FetchNext();
+ if (!hEvent)
+ break;
+
+ auto &p = allocateItem();
+ p.hContact = hContact;
+ p.hEvent = hEvent;
+ pPrev = p.checkPrev(pPrev);
+ }
+ }
return true;
}