From 3d30ed65f9e226b7b183b23ce5dba435ec491f0b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 10 Jan 2025 18:28:28 +0300 Subject: DBEVENTINFO::timestamp to become 64-bit integer --- src/core/stdmsg/src/cmdlist.cpp | 2 +- src/core/stdmsg/src/msgdialog.cpp | 20 ++++++++++---------- src/core/stdmsg/src/msglog.cpp | 18 +++++++++--------- src/core/stduihist/src/history.cpp | 8 +++----- 4 files changed, 23 insertions(+), 25 deletions(-) (limited to 'src/core') diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 4d44e69a67..a0226ee979 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -93,7 +93,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, LPARAM lParam) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & DBEF_RTL ? DBEF_RTL : 0); dbei.szModule = Proto_GetBaseAccountName(hContact); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (uint32_t)(mir_strlen(p->szMsg) + 1); dbei.pBlob = p->szMsg; dbei.szId = (char *)lParam; diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index c1d544a028..fdcea57c48 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -141,8 +141,8 @@ bool CMsgDialog::OnInitDialog() while (MEVENT hdbEvent = pCursor.FetchNext()) { DBEVENTINFO dbei = {}; db_event_get(hdbEvent, &dbei); - if ((dbei.eventType == EVENTTYPE_MESSAGE) && !(dbei.flags & DBEF_SENT)) { - m_lastMessage = dbei.timestamp; + if ((dbei.eventType == EVENTTYPE_MESSAGE) && !dbei.bSent) { + m_lastMessage = dbei.getUnixtime(); bUpdate = true; break; } @@ -1208,18 +1208,18 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) if (m_hDbEventFirst == 0) m_hDbEventFirst = hDbEvent; - bool isMessage = (dbei.eventType == EVENTTYPE_MESSAGE), isSent = ((dbei.flags & DBEF_SENT) != 0); + bool isMessage = (dbei.eventType == EVENTTYPE_MESSAGE); bool isActive = IsActive(); if (DbEventIsShown(dbei)) { // Sounds *only* for sent messages, not for custom events - if (isMessage && !isSent) { + if (isMessage && !dbei.bSent) { if (isActive) Skin_PlaySound("RecvMsgActive"); else Skin_PlaySound("RecvMsgInactive"); } - if (isMessage && !isSent) { - m_lastMessage = dbei.timestamp; + if (isMessage && !dbei.bSent) { + m_lastMessage = dbei.getUnixtime(); UpdateLastMessage(); } @@ -1229,7 +1229,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) RemakeLog(); // Flash window *only* for messages, not for custom events - if (isMessage && !isSent) + if (isMessage && !dbei.bSent) if (!isActive || !m_pLog->AtBottom()) StartFlash(); } @@ -1260,15 +1260,15 @@ bool CMsgDialog::GetFirstEvent() case LOADHISTORY_TIME: DBEVENTINFO dbei = {}; if (m_hDbEventFirst == 0) - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); else db_event_get(m_hDbEventFirst, &dbei); - uint32_t firstTime = dbei.timestamp - 60 * g_plugin.nLoadTime; + uint32_t firstTime = dbei.getUnixtime() - 60 * g_plugin.nLoadTime; while (MEVENT hPrevEvent = pCursor.FetchNext()) { dbei.cbBlob = 0; db_event_get(hPrevEvent, &dbei); - if (dbei.timestamp < firstTime) + if (dbei.getUnixtime() < firstTime) break; m_hDbEventFirst = hPrevEvent; } diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 0156f1fa6b..f120d26c27 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -300,7 +300,7 @@ public: } if (g_plugin.bShowIcons) { - int i = ((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? LOGICON_MSG_OUT : LOGICON_MSG_IN) : LOGICON_MSG_NOTICE); + int i = ((dbei.eventType == EVENTTYPE_MESSAGE) ? (dbei.bSent ? LOGICON_MSG_OUT : LOGICON_MSG_IN) : LOGICON_MSG_NOTICE); buf.Append("\\f0\\fs14"); buf.Append(pLogIconBmpBits[i]); @@ -321,9 +321,9 @@ public: else szFormat = g_plugin.bShowDate ? L"d t" : L"t"; - TimeZone_PrintTimeStamp(nullptr, dbei.timestamp, szFormat, str, _countof(str), 0); + TimeZone_PrintTimeStamp(nullptr, dbei.getUnixtime(), szFormat, str, _countof(str), 0); - SetToStyle((dbei.flags & DBEF_SENT) ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME, buf); + SetToStyle(dbei.bSent ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME, buf); AppendToBufferWithRTF(buf, str); showColon = 1; } @@ -331,7 +331,7 @@ public: if (g_plugin.bShowNames && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) { wchar_t *szName; - if (dbei.flags & DBEF_SENT) { + if (dbei.bSent) { if (wchar_t *p = Contact::GetInfo(CNF_DISPLAY, 0, dbei.szModule)) szName = NEWWSTR_ALLOCA(p); else @@ -339,19 +339,19 @@ public: } else szName = Clist_GetContactDisplayName(dat->hContact); - SetToStyle((dbei.flags & DBEF_SENT) ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME, buf); + SetToStyle(dbei.bSent ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME, buf); AppendToBufferWithRTF(buf, szName); showColon = 1; } if (showColon) - SetToStyle((dbei.flags & DBEF_SENT) ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON, buf); + SetToStyle(dbei.bSent ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON, buf); wchar_t *msg, *szName; switch (dbei.eventType) { case EVENTTYPE_JABBER_CHATSTATES: case EVENTTYPE_JABBER_PRESENCE: - if (dbei.flags & DBEF_SENT) { + if (dbei.bSent) { if (wchar_t *p = Contact::GetInfo(CNF_DISPLAY, 0, dbei.szModule)) { szName = NEWWSTR_ALLOCA(p); mir_free(p); @@ -379,7 +379,7 @@ public: InsertFileLink(buf, dat->hDbEvent, blob); } else { - AppendToBufferWithRTF(buf, (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received")); + AppendToBufferWithRTF(buf, dbei.bSent ? TranslateT("File sent") : TranslateT("File received")); buf.Append(": "); AppendToBufferWithRTF(buf, blob.getName()); @@ -395,7 +395,7 @@ public: case EVENTTYPE_MESSAGE: default: msg = dbei.getText(); - SetToStyle((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG) : MSGFONTID_NOTICE, buf); + SetToStyle((dbei.eventType == EVENTTYPE_MESSAGE) ? (dbei.bSent ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG) : MSGFONTID_NOTICE, buf); AppendToBufferWithRTF(buf, msg); mir_free(msg); } diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index 80dff0c6d3..d99226fd9d 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -73,13 +73,11 @@ static void GetObjectSummary(DBEVENTINFO *dbei, wchar_t *str, int cbStr) switch (dbei->eventType) { case EVENTTYPE_MESSAGE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing message"); - else pszSrc = TranslateT("Incoming message"); + pszSrc = (dbei->bSent) ? TranslateT("Outgoing message") : TranslateT("Incoming message"); break; case EVENTTYPE_FILE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing file"); - else pszSrc = TranslateT("Incoming file"); + pszSrc = (dbei->bSent) ? TranslateT("Outgoing file") : TranslateT("Incoming file"); break; case EVENTTYPE_AUTHREQUEST: @@ -133,7 +131,7 @@ static void FillHistoryThread(THistoryThread *hInfo) wchar_t str[200], eventText[256], strdatetime[64]; GetObjectSummary(&dbei, str, _countof(str)); if (str[0]) { - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, L"d t", strdatetime, _countof(strdatetime), 0); + TimeZone_PrintTimeStamp(NULL, dbei.getUnixtime(), L"d t", strdatetime, _countof(strdatetime), 0); mir_snwprintf(eventText, L"%s: %s", strdatetime, str); i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); -- cgit v1.2.3