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 --- include/delphi/m_database.inc | 2 +- include/m_database.h | 32 +++++++++++++---- plugins/AvatarHistory/src/AvatarDlg.cpp | 2 +- plugins/AvatarHistory/src/AvatarHistory.cpp | 2 +- plugins/BasicHistory/src/BinaryExport.cpp | 6 ++-- plugins/BasicHistory/src/DatExport.cpp | 4 +-- plugins/BasicHistory/src/EventList.cpp | 10 +++--- plugins/BasicHistory/src/Scheduler.cpp | 2 +- plugins/Boltun/src/actionQueue.cpp | 2 +- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 2 +- plugins/BuddyPounce/src/main.cpp | 2 +- plugins/Clist_modern/src/modern_clc.cpp | 6 ++-- plugins/Clist_modern/src/modern_contact.cpp | 4 +-- plugins/Clist_nicer/src/clc.cpp | 6 ++-- plugins/Clist_nicer/src/contact.cpp | 12 +++---- plugins/CmdLine/src/mimcmd_handlers.cpp | 4 +-- plugins/ContactsPlus/src/send.cpp | 2 +- plugins/Db3x_mmap/src/dbevents.cpp | 6 ++-- plugins/Dbx_mdbx/src/dbevents.cpp | 10 +++--- plugins/Dbx_sqlite/src/dbevents.cpp | 14 ++++---- plugins/FTPFileYM/src/job_upload.cpp | 2 +- plugins/FavContacts/src/contact_cache.cpp | 4 +-- plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 2 +- plugins/HistoryStats/src/mirandacontact.cpp | 26 +++++++------- plugins/HistoryStats/src/statistic.cpp | 2 +- .../src/historysweeperlight.cpp | 4 +-- plugins/IEHistory/src/dlgHandlers.cpp | 2 +- plugins/IEHistory/src/utils.cpp | 2 +- plugins/IEView/src/HTMLBuilder.cpp | 6 ++-- plugins/Import/src/dbrw/dbevents.cpp | 2 +- plugins/Import/src/import.cpp | 10 +++--- plugins/Import/src/mcontacts.cpp | 4 +-- plugins/Import/src/patterns.cpp | 6 ++-- plugins/Import/src/textjson.cpp | 18 +++++----- plugins/Jingle/src/account.cpp | 2 +- plugins/KeyboardNotify/src/main.cpp | 4 +-- plugins/MessageState/src/messagestate.cpp | 2 +- plugins/MirFox/src/MirandaUtils.cpp | 2 +- plugins/MirLua/src/Modules/m_database.cpp | 4 +-- plugins/MirLua/src/Modules/m_message.cpp | 2 +- plugins/MirOTR/src/utils.cpp | 4 +-- plugins/MirandaG15/src/CAppletManager.cpp | 4 +-- plugins/Msg_Export/src/export.cpp | 4 +-- plugins/NewAwaySysMod/src/MsgEventAdded.cpp | 8 ++--- plugins/NewEventNotify/src/main.cpp | 4 +-- plugins/NewEventNotify/src/popup.cpp | 2 +- plugins/NewStory/src/history_array.cpp | 30 ++++++++-------- plugins/NewStory/src/history_control.cpp | 14 ++++---- plugins/NewStory/src/history_dlg.cpp | 8 ++--- plugins/NewStory/src/history_menus.cpp | 2 +- plugins/NewStory/src/options.cpp | 2 +- plugins/NewStory/src/templates.cpp | 10 +++--- plugins/NewXstatusNotify/src/main.cpp | 4 +-- plugins/NewXstatusNotify/src/xstatus.cpp | 2 +- plugins/New_GPG/src/messages.cpp | 2 +- plugins/New_GPG/src/utilities.cpp | 2 +- plugins/Nudge/src/main.cpp | 4 +-- plugins/PasteIt/src/PasteIt.cpp | 2 +- plugins/Popup/src/popup_wnd2.cpp | 2 +- plugins/QuickSearch/src/window_row.cpp | 2 +- plugins/RecentContacts/src/RecentContacts.cpp | 4 +-- plugins/Scriver/src/globals.cpp | 2 +- plugins/Scriver/src/msgdialog.cpp | 6 ++-- plugins/Scriver/src/msglog.cpp | 42 +++++++++++----------- plugins/Scriver/src/msgs.cpp | 4 +-- plugins/Scriver/src/msgutils.cpp | 12 +++---- plugins/SecureIM/src/dbevent.cpp | 2 +- plugins/SendScreenshotPlus/src/CSend.cpp | 2 +- plugins/SimpleAR/src/Main.cpp | 2 +- plugins/StopSpamMod/src/utilities.cpp | 2 +- plugins/StopSpamPlus/src/events.cpp | 6 ++-- plugins/TabSRMM/src/globals.cpp | 2 +- plugins/TabSRMM/src/hotkeyhandler.cpp | 2 +- plugins/TabSRMM/src/mim.cpp | 2 +- plugins/TabSRMM/src/msgdialog.cpp | 4 +-- plugins/TabSRMM/src/msgdlgother.cpp | 24 ++++++------- plugins/TabSRMM/src/msglog.cpp | 28 +++++++-------- plugins/TabSRMM/src/msgoptions.cpp | 2 +- plugins/TabSRMM/src/sendlater.cpp | 2 +- plugins/TabSRMM/src/sendqueue.cpp | 6 ++-- plugins/TipperYM/src/subst.cpp | 12 +++---- .../src/ex_import/classExImContactXML.cpp | 6 ++-- plugins/UserInfoEx/src/mir_db.cpp | 12 +++---- plugins/Variables/src/parse_miranda.cpp | 20 +++++------ plugins/YARelay/src/main.cpp | 4 +-- protocols/CloudFile/src/utils.cpp | 2 +- .../src/CurrencyRatesProviderBase.cpp | 2 +- protocols/Discord/src/dispatch.cpp | 2 +- protocols/Discord/src/server.cpp | 2 +- protocols/Discord/src/utils.cpp | 4 +-- protocols/EmLanProto/src/mlan.cpp | 6 ++-- protocols/Facebook/src/server.cpp | 6 ++-- protocols/Gadu-Gadu/src/core.cpp | 6 ++-- protocols/Gadu-Gadu/src/filetransfer.cpp | 2 +- protocols/Gadu-Gadu/src/image.cpp | 2 +- protocols/GmailNotifier/src/notify.cpp | 2 +- protocols/ICQCorp/src/protocol.cpp | 6 ++-- protocols/IRCG/src/commandmonitor.cpp | 6 ++-- protocols/IRCG/src/irclib.cpp | 2 +- protocols/JabberG/src/jabber_archive.cpp | 8 ++--- protocols/JabberG/src/jabber_file.cpp | 2 +- protocols/JabberG/src/jabber_ft.cpp | 4 +-- protocols/JabberG/src/jabber_iq_handlers.cpp | 2 +- protocols/JabberG/src/jabber_misc.cpp | 6 ++-- protocols/JabberG/src/jabber_omemo.cpp | 2 +- protocols/JabberG/src/jabber_rc.cpp | 4 +-- protocols/JabberG/src/jabber_thread.cpp | 6 ++-- protocols/NewsAggregator/Src/CheckFeed.cpp | 4 +-- protocols/Sametime/src/files.cpp | 2 +- protocols/Sametime/src/messaging.cpp | 2 +- protocols/SkypeWeb/src/skype_contacts.cpp | 2 +- protocols/SkypeWeb/src/skype_history_sync.cpp | 2 +- protocols/SkypeWeb/src/skype_messages.cpp | 4 +-- protocols/Steam/src/steam_chats.cpp | 4 +-- protocols/Steam/src/steam_contacts.cpp | 2 +- protocols/Steam/src/steam_history.cpp | 8 ++--- protocols/Steam/src/steam_messages.cpp | 2 +- protocols/Steam/src/steam_proto.cpp | 2 +- protocols/Telegram/src/proto.cpp | 2 +- protocols/Telegram/src/server.cpp | 4 +-- protocols/Telegram/src/utils.cpp | 5 ++- protocols/Tox/src/tox_contacts.cpp | 2 +- protocols/Tox/src/tox_messages.cpp | 2 +- protocols/Tox/src/tox_transfer.cpp | 2 +- protocols/Tox/src/tox_utils.cpp | 2 +- protocols/Twitter/src/connection.cpp | 4 +-- protocols/VKontakte/src/misc.cpp | 8 ++--- protocols/VKontakte/src/vk_chats.cpp | 2 +- protocols/VKontakte/src/vk_feed.cpp | 4 +-- protocols/VKontakte/src/vk_history.cpp | 4 +-- protocols/VKontakte/src/vk_messages.cpp | 8 ++--- protocols/VKontakte/src/vk_pollserver.cpp | 2 +- protocols/Weather/src/weather_update.cpp | 2 +- protocols/WhatsApp/src/appsync.cpp | 2 +- protocols/WhatsApp/src/message.cpp | 2 +- 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 ++--- src/mir_app/src/chat_tools.cpp | 2 +- src/mir_app/src/db_events.cpp | 30 ++++++++-------- src/mir_app/src/file.cpp | 8 ++--- src/mir_app/src/filerecvdlg.cpp | 2 +- src/mir_app/src/filexferdlg.cpp | 2 +- src/mir_app/src/srmm_base.cpp | 4 +-- src/mir_app/src/srmm_log_rtf.cpp | 2 +- src/mir_app/src/srmm_util.cpp | 4 +-- 147 files changed, 425 insertions(+), 410 deletions(-) diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 909bc1ead5..dd76270478 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -40,7 +40,7 @@ type PDBEVENTINFO = ^TDBEVENTINFO; TDBEVENTINFO = record szModule : PAnsiChar; // module that 'owns' this event and controls the data format - timestamp: dword; // timestamp in UNIX time + timestamp: Int64; // timestamp in UNIX time flags : dword; // the DBEF_* flags above eventType: dword; // event type, such as message, can be module defined hContact : TMCONTACT; // contact to which this event belongs diff --git a/include/m_database.h b/include/m_database.h index 69fdaaa698..582c2c273f 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -191,10 +191,26 @@ struct DBVARIANT struct DBEVENTINFO { const char *szModule; // pointer to name of the module that 'owns' this event - uint32_t timestamp; // seconds since 00:00, 01/01/1970. Gives us times until 2106 - // unless you use the standard C library which is - // signed and can only do until 2038. In GMT. - uint32_t flags; // combination of DBEF_* flags + uint64_t iTimestamp; // seconds or milliseconds since 00:00, 01/01/1970. In GMT. + + union { + uint32_t flags; // combination of DBEF_* flags + struct { + bool bTemporary: 1; // disable notifications about temporary database events + bool bSent : 1; // this event was sent by the user. If not set this event was received. + bool bRead : 1; // event has been read by the user. It does not need to be processed any more except for history. + bool bRtl : 1; // event contains the right-to-left aligned text + bool bUtf : 1; // event contains a text in utf-8 + bool isEncrypted : 1; // event is encrypted (never reported outside a driver) + bool hasId : 1; // event has unique server id + bool bSecure : 1; // event is encrypted + bool bStrong : 1; // event is encrypted by the verified sender + bool isBookmark : 1; // event is bookmarked + bool isJson : 1; // event's body is a JSON structure + bool bMsec : 1; // event's timestamp is in milliseconds + }; + }; + uint32_t eventType; // module-defined event type field MCONTACT hContact; // contact to which this event belongs int cbBlob; // size of pBlob in bytes @@ -203,12 +219,16 @@ struct DBEVENTINFO const char *szUserId; // user id (for group chats only) const char *szReplyId; // this message is a reply to a message with that server id + uint32_t __forceinline getUnixtime() const { + return bMsec ? (iTimestamp / 1000) : iTimestamp; + } + bool __forceinline markedRead() const { - return (flags & (DBEF_SENT | DBEF_READ)) != 0; + return (bSent || bRead); } bool __forceinline operator==(const DBEVENTINFO &e) { - return (timestamp == e.timestamp && eventType == e.eventType && cbBlob == e.cbBlob && (flags & DBEF_SENT) == (e.flags & DBEF_SENT)); + return (iTimestamp == e.iTimestamp && eventType == e.eventType && cbBlob == e.cbBlob && bSent == e.bSent); } }; diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index ef3548e0d0..6e8d42eed3 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -420,7 +420,7 @@ int FillAvatarListFromDB(HWND list, MCONTACT hContact) // Get time wchar_t date[64]; - TimeZone_ToStringW(dbei.timestamp, L"d s", date, _countof(date)); + TimeZone_ToStringW(dbei.getUnixtime(), L"d s", date, _countof(date)); // Get file in disk wchar_t path[MAX_PATH]; diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index ce2257fa7d..ac7993578b 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -205,7 +205,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) DBEVENTINFO dbei = {}; dbei.szModule = Proto_GetBaseAccountName(hContact); dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = time(0); dbei.eventType = EVENTTYPE_AVATAR_CHANGE; dbei.cbBlob = (uint32_t)mir_strlen(blob) + 1; dbei.pBlob = blob; diff --git a/plugins/BasicHistory/src/BinaryExport.cpp b/plugins/BasicHistory/src/BinaryExport.cpp index 1eadefd459..8d716c7868 100644 --- a/plugins/BasicHistory/src/BinaryExport.cpp +++ b/plugins/BasicHistory/src/BinaryExport.cpp @@ -132,14 +132,14 @@ void BinaryExport::WriteGroup(bool, const std::wstring&, const std::wstring&, co void BinaryExport::WriteMessage(bool, const std::wstring&, const std::wstring&, const std::wstring&, const std::wstring &message, const DBEVENTINFO& dbei) { - if (dbei.timestamp >= lTime) { + if (dbei.getUnixtime() >= lTime) { BinaryFileMessageHeader header; header.eventType = dbei.eventType; header.flags = dbei.flags & (~(0x800)); - header.timestamp = dbei.timestamp; + header.timestamp = dbei.getUnixtime(); EXP_FILE.write((char*)&header, sizeof(BinaryFileMessageHeader)); WriteString(message); - lTime = dbei.timestamp; + lTime = dbei.getUnixtime(); } } diff --git a/plugins/BasicHistory/src/DatExport.cpp b/plugins/BasicHistory/src/DatExport.cpp index 9d11a75860..6ef9f857b9 100644 --- a/plugins/BasicHistory/src/DatExport.cpp +++ b/plugins/BasicHistory/src/DatExport.cpp @@ -97,7 +97,7 @@ void DatExport::WriteMessage(bool, const std::wstring&, const std::wstring&, con header.cbSize = sizeof(DBEVENTINFO86); header.eventType = dbei.eventType; header.flags = dbei.flags & (~(0x800)); - header.timestamp = dbei.timestamp; + header.timestamp = dbei.getUnixtime(); header.szModule = 0; header.pBlob = 0; if (dbei.flags & 0x800) { @@ -179,7 +179,7 @@ bool DatExport::GetEventList(std::vector& eventList) info.eventType = messageHeader.eventType; info.flags = messageHeader.flags; - info.timestamp = messageHeader.timestamp; + info.iTimestamp = messageHeader.timestamp; info.cbBlob = messageHeader.cbBlob; info.pBlob = (char *)memBuf.c_str(); HistoryEventList::GetObjectDescription(&info, _str, MAXSELECTSTR); diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 7a5ba2f3b0..e4cf87a0ba 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -63,11 +63,11 @@ bool HistoryEventList::CanShowHistory(DBEVENTINFO* dbei) { if (m_deltaTime != 0) { if (m_deltaTime > 0) { - if (m_now - m_deltaTime < dbei->timestamp) + if (m_now - m_deltaTime < dbei->getUnixtime()) return false; } else { - if (m_now + m_deltaTime > dbei->timestamp) + if (m_now + m_deltaTime > dbei->getUnixtime()) return false; } } @@ -501,7 +501,7 @@ void HistoryEventList::MargeMessages(const std::vector if (it->isExternal) { IImport::ExternalMessage& msg = m_importedMessages[it->exIdx]; dbei.flags |= DBEF_READ; - dbei.timestamp = msg.timestamp; + dbei.iTimestamp = msg.timestamp; // For now I do not convert event data from string to blob, and event type must be message to handle it properly dbei.eventType = EVENTTYPE_MESSAGE; UINT cp = dbei.flags & DBEF_UTF ? CP_UTF8 : CP_ACP; @@ -532,7 +532,7 @@ bool HistoryEventList::GetEventData(const EventIndex& ev, EventData& data) if (db_event_get(ev.hEvent, &m_dbei) == 0) { data.isMe = (m_dbei.flags & DBEF_SENT) != 0; data.eventType = m_dbei.eventType; - data.timestamp = m_dbei.timestamp; + data.timestamp = m_dbei.getUnixtime(); return true; } } @@ -552,7 +552,7 @@ void HistoryEventList::GetExtEventDBei(const EventIndex& ev) IImport::ExternalMessage& em = m_importedMessages[ev.exIdx]; m_dbei.flags = em.flags | 0x800; m_dbei.eventType = em.eventType; - m_dbei.timestamp = em.timestamp; + m_dbei.iTimestamp = em.timestamp; } HICON HistoryEventList::GetEventCoreIcon(const EventIndex& ev) diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp index 98202c2382..e778f152a4 100644 --- a/plugins/BasicHistory/src/Scheduler.cpp +++ b/plugins/BasicHistory/src/Scheduler.cpp @@ -1278,7 +1278,7 @@ void DoError(const TaskOptions& to, const std::wstring _error) DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; dbei.flags = DBEF_UTF | DBEF_READ; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); // For now I do not convert event data from string to blob, and event type must be message to handle it properly dbei.eventType = EVENTTYPE_MESSAGE; int len = (int)error.length() + 1; diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index edc37f2194..41235cbe5a 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -92,7 +92,7 @@ static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = BOLTUN_NAME; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); db_event_add(hContact, &dbei); bot->AnswerGiven(hContact, *info); diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index 641af4fbaf..ca43b1bfd3 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -85,7 +85,7 @@ time_t getLastInputMsg(MCONTACT hContact) DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) - return dbei.timestamp; + return dbei.getUnixtime(); } return -1; } diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index f6a8ea1c9c..8c5828171d 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -49,7 +49,7 @@ int MsgAck(WPARAM, LPARAM lParam) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_UTF | DBEF_SENT; dbei.szModule = (char*)ack->szModule; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(pszUtf) + 1; dbei.pBlob = pszUtf; db_event_add(ack->hContact, &dbei); diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 6e7ae2bf0d..a0627e6f14 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -159,11 +159,11 @@ static int clcHookDbEventAdded(WPARAM hContact, LPARAM hDbEvent) if (hContact && hDbEvent) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) && !(dbei.flags & DBEF_SENT)) { - g_plugin.setDword(hContact, "mf_lastmsg", dbei.timestamp); + if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) && !dbei.bSent) { + g_plugin.setDword(hContact, "mf_lastmsg", dbei.getUnixtime()); ClcCacheEntry *pdnce = Clist_GetCacheEntry(hContact); if (pdnce) { - pdnce->dwLastMsgTime = dbei.timestamp; + pdnce->dwLastMsgTime = dbei.getUnixtime(); if (g_CluiData.hasSort(SORTBY_LASTMSG)) Clist_Broadcast(CLM_AUTOREBUILD, hContact, 0); } diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 707e47604f..9fcbb96c19 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -66,8 +66,8 @@ uint32_t CompareContacts2_getLMTime(MCONTACT hContact) while (MEVENT hDbEvent = pCursor.FetchNext()) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) && !(dbei.flags & DBEF_SENT)) - return dbei.timestamp; + if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) && !dbei.bSent) + return dbei.getUnixtime(); } return 0; } diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 1110a3a3ff..afa208600c 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -72,17 +72,17 @@ static int ClcEventAdded(WPARAM hContact, LPARAM lParam) if (hContact && lParam) { DBEVENTINFO dbei = {}; db_event_get(lParam, &dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { + if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.bSent) { uint32_t firstTime = g_plugin.getDword(hContact, "mf_firstEvent"); uint32_t count = g_plugin.getDword(hContact, "mf_count"); count++; - new_freq = count ? (dbei.timestamp - firstTime) / count : 0x7fffffff; + new_freq = count ? (dbei.getUnixtime() - firstTime) / count : 0x7fffffff; g_plugin.setDword(hContact, "mf_freq", new_freq); g_plugin.setDword(hContact, "mf_count", count); TExtraCache *p = cfg::getCache(hContact, nullptr); if (p) { - p->dwLastMsgTime = dbei.timestamp; + p->dwLastMsgTime = dbei.getUnixtime(); if (new_freq) p->msgFrequency = new_freq; Clist_Broadcast(INTM_FORCESORT, 0, 1); diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index 4b760f933a..f1ed1e3131 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -73,10 +73,10 @@ static void MF_CalcFrequency(MCONTACT hContact, uint32_t dwCutoffDays, int doSle db_event_get(hEvent, &dbei); // record time of last event - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) + if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.bSent) eventCount++; - if (eventCount >= 100 || dbei.timestamp < curTime - (dwCutoffDays * 86400)) + if (eventCount >= 100 || dbei.getUnixtime() < curTime - (dwCutoffDays * 86400)) break; if (doSleep && mf_updatethread_running == FALSE) @@ -90,8 +90,8 @@ static void MF_CalcFrequency(MCONTACT hContact, uint32_t dwCutoffDays, int doSle g_plugin.setDword(hContact, "mf_firstEvent", curTime - (dwCutoffDays * 86400)); } else { - frequency = (curTime - dbei.timestamp) / eventCount; - g_plugin.setDword(hContact, "mf_firstEvent", dbei.timestamp); + frequency = (curTime - dbei.getUnixtime()) / eventCount; + g_plugin.setDword(hContact, "mf_firstEvent", dbei.getUnixtime()); } g_plugin.setDword(hContact, "mf_freq", frequency); @@ -139,8 +139,8 @@ uint32_t INTSORT_GetLastMsgTime(MCONTACT hContact) while (MEVENT hDbEvent = cursor.FetchNext()) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) - return dbei.timestamp; + if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.bSent) + return dbei.getUnixtime(); } return 0; } diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 4259f9226b..d7cdb6a9e4 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -708,7 +708,7 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re dbei.pBlob = szMessage.get(); dbei.cbBlob = (uint32_t)mir_strlen(szMessage) + 1; dbei.szModule = ack->szModule; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); db_event_add(ack->hContact, &dbei); } else szReply.AppendFormat(TranslateT("Message to '%s' was marked as sent but the account seems to be offline"), contact); @@ -1220,7 +1220,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r void AddHistoryEvent(DBEVENTINFO *dbEvent, wchar_t *contact, PReply reply) { char timestamp[256]; - TimeZone_ToString(dbEvent->timestamp, "D, s", timestamp, _countof(timestamp)); + TimeZone_ToString(dbEvent->getUnixtime(), "D, s", timestamp, _countof(timestamp)); wchar_t *sender = (dbEvent->flags & DBEF_SENT) ? TranslateT("[me]") : contact; wchar_t *message = DbEvent_GetText(dbEvent); diff --git a/plugins/ContactsPlus/src/send.cpp b/plugins/ContactsPlus/src/send.cpp index f1efc7edb4..0ba2732d43 100644 --- a/plugins/ContactsPlus/src/send.cpp +++ b/plugins/ContactsPlus/src/send.cpp @@ -399,7 +399,7 @@ INT_PTR CALLBACK SendDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara dbei.szModule = Proto_GetBaseAccountName(ackData->hContact); dbei.eventType = EVENTTYPE_CONTACTS; dbei.flags = DBEF_SENT | DBEF_UTF; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); //make blob TCTSend* maSend = (TCTSend*)_alloca(ackData->nContacts*sizeof(TCTSend)); memset(maSend, 0, (ackData->nContacts * sizeof(TCTSend))); diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index dad9d9000f..9a41a5ace2 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -33,7 +33,7 @@ int CDb3Mmap::GetEventCount(MCONTACT contactID) MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) { if (dbei == nullptr) return 0; - if (dbei->timestamp == 0) return 0; + if (dbei->getUnixtime() == 0) return 0; DBEvent dbe; dbe.signature = DBEVENT_SIGNATURE; @@ -60,7 +60,7 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) if (NotifyEventHooks(g_hevEventFiltered, contactNotifyID, (LPARAM)dbei)) return 0; - dbe.timestamp = dbei->timestamp; + dbe.timestamp = dbei->getUnixtime(); dbe.flags = dbei->flags; dbe.wEventType = dbei->eventType; dbe.cbBlob = dbei->cbBlob; @@ -289,7 +289,7 @@ BOOL CDb3Mmap::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) return 1; dbei->szModule = GetModuleNameByOfs(dbe->ofsModuleName); - dbei->timestamp = dbe->timestamp; + dbei->iTimestamp = dbe->timestamp; dbei->flags = dbe->flags; dbei->eventType = dbe->wEventType; diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index b7c7373955..e844e034c2 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -37,7 +37,7 @@ int CDbxMDBX::GetEventCount(MCONTACT contactID) MEVENT CDbxMDBX::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) { if (dbei == nullptr) return 0; - if (dbei->timestamp == 0) return 0; + if (dbei->iTimestamp == 0) return 0; MEVENT dwEventId = InterlockedIncrement(&m_dwMaxEventId); if (!EditEvent(contactID, dwEventId, dbei, true)) @@ -140,7 +140,7 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent) BOOL CDbxMDBX::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) { if (dbei == nullptr) return 1; - if (dbei->timestamp == 0) return 1; + if (dbei->iTimestamp == 0) return 1; DBEVENTINFO tmp = *dbei; @@ -149,7 +149,7 @@ BOOL CDbxMDBX::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) return 1; DBEvent *dbe = (DBEvent*)data.iov_base; - tmp.timestamp = dbe->timestamp; + tmp.iTimestamp = dbe->timestamp; return !EditEvent(dbe->dwContactID, hDbEvent, &tmp, false); } @@ -184,7 +184,7 @@ bool CDbxMDBX::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO * if (NotifyEventHooks(g_hevEventFiltered, contactNotifyID, (LPARAM)dbei)) return false; - dbe.timestamp = dbei->timestamp; + dbe.timestamp = dbei->getUnixtime(); dbe.flags = dbei->flags; dbe.wEventType = dbei->eventType; dbe.cbBlob = dbei->cbBlob; @@ -306,7 +306,7 @@ BOOL CDbxMDBX::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) } dbei->szModule = GetModuleName(dbe->iModuleId); - dbei->timestamp = dbe->timestamp; + dbei->iTimestamp = dbe->timestamp; dbei->flags = dbe->flags; dbei->eventType = dbe->wEventType; diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index a376f9e8ca..2eb93ce7de 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -85,7 +85,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei) if (dbei == nullptr) return 0; - if (dbei->timestamp == 0) + if (dbei->iTimestamp == 0) return 0; MCONTACT hNotifyContact = hContact; @@ -100,7 +100,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei) return 0; // set default sub to the event's source - if (!(dbei->flags & DBEF_SENT)) + if (!dbei->bSent) db_mc_setDefault(cc->contactID, hContact, false); if (db_mc_isEnabled()) hNotifyContact = cc->contactID; // and add an event to a metahistory @@ -140,7 +140,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei) "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", qEvAdd); sqlite3_bind_int64(stmt, 1, hContact); sqlite3_bind_text(stmt, 2, tmp.szModule, (int)mir_strlen(tmp.szModule), nullptr); - sqlite3_bind_int64(stmt, 3, tmp.timestamp); + sqlite3_bind_int64(stmt, 3, tmp.iTimestamp); sqlite3_bind_int(stmt, 4, tmp.eventType); sqlite3_bind_int64(stmt, 5, tmp.flags); sqlite3_bind_blob(stmt, 6, tmp.pBlob, tmp.cbBlob, nullptr); @@ -154,7 +154,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei) MEVENT hDbEvent = sqlite3_last_insert_rowid(m_db); - int64_t tsSort = (int64_t)tmp.timestamp * 1000; + int64_t tsSort = tmp.bMsec ? tmp.iTimestamp : tmp.iTimestamp * 1000; AddEventSrt(hDbEvent, cc->contactID, tsSort); cc->m_count++; @@ -261,7 +261,7 @@ BOOL CDbxSQLite::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) if (dbei == nullptr) return 1; - if (dbei->timestamp == 0) + if (dbei->iTimestamp == 0) return 1; DBEVENTINFO tmp = *dbei; @@ -288,7 +288,7 @@ BOOL CDbxSQLite::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) int i = 1; sqlite3_bind_text(stmt, i++, tmp.szModule, (int)mir_strlen(tmp.szModule), nullptr); - sqlite3_bind_int64(stmt, i++, tmp.timestamp); + sqlite3_bind_int64(stmt, i++, tmp.iTimestamp); sqlite3_bind_int(stmt, i++, tmp.eventType); sqlite3_bind_int64(stmt, i++, tmp.flags); if (tmp.pBlob) @@ -436,7 +436,7 @@ BOOL CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) if (dbei->szModule == nullptr) return 1; - dbei->timestamp = sqlite3_column_int64(stmt, 1); + dbei->iTimestamp = sqlite3_column_int64(stmt, 1); dbei->eventType = sqlite3_column_int(stmt, 2); dbei->flags = sqlite3_column_int64(stmt, 3); dbei->hContact = sqlite3_column_int(stmt, 9); diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp index 6e4fbc29b3..9d71c41312 100644 --- a/plugins/FTPFileYM/src/job_upload.cpp +++ b/plugins/FTPFileYM/src/job_upload.cpp @@ -88,7 +88,7 @@ void UploadJob::autoSend() dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT; dbei.szModule = szProto; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.cbBlob = (uint32_t)mir_strlen(m_szFileLink) + 1; dbei.pBlob = m_szFileLink; db_event_add(m_hContact, &dbei); diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index 12dabbb2d0..161b3f2d8f 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -30,7 +30,7 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent) if (dbei.eventType != EVENTTYPE_MESSAGE) return 0; - float weight = GetEventWeight(time(0) - dbei.timestamp); + float weight = GetEventWeight(time(0) - dbei.getUnixtime()); float q = GetTimeWeight(time(0) - m_lastUpdate); m_lastUpdate = time(0); if (!weight) @@ -88,7 +88,7 @@ void CContactCache::Rebuild() while (MEVENT hEvent = cursor.FetchNext()) { DBEVENTINFO dbei = {}; if (!db_event_get(hEvent, &dbei)) { - if (float weight = GetEventWeight(timestamp - dbei.timestamp)) { + if (float weight = GetEventWeight(timestamp - dbei.getUnixtime())) { if (dbei.eventType == EVENTTYPE_MESSAGE) info->rate += weight; } diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index e413ea1fe3..7b29de550a 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -147,7 +147,7 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) wcsncpy_s(link, word, LINK_MAX); } - TimeZone_ToStringW(dbei->timestamp, L"d-t", dbdate, _countof(dbdate)); + TimeZone_ToStringW(dbei->getUnixtime(), L"d-t", dbdate, _countof(dbdate)); date_ptr = wcstok_s(dbdate, L"-", &tok_ctx); time_ptr = wcstok_s(nullptr, L"-", &tok_ctx); wcsncpy_s(date, date_ptr, _TRUNCATE); diff --git a/plugins/HistoryStats/src/mirandacontact.cpp b/plugins/HistoryStats/src/mirandacontact.cpp index f0e20dcc76..cd666d9419 100644 --- a/plugins/HistoryStats/src/mirandacontact.cpp +++ b/plugins/HistoryStats/src/mirandacontact.cpp @@ -162,14 +162,14 @@ void MirandaContactTolerantMerge::fillQueue() // assume that items with +/- 30 seconds may be equal static const int timestampTol = 30; - while (!m_CIs.empty() && (m_EIs.size() < 2 || (m_EIs.back().dbe.timestamp - m_EIs.front().dbe.timestamp) <= timestampTol)) { + while (!m_CIs.empty() && (m_EIs.size() < 2 || (m_EIs.back().dbe.getUnixtime() - m_EIs.front().dbe.getUnixtime()) <= timestampTol)) { // find oldest next event in chains int nNext = 0; - uint32_t timestampFirst = m_CIs.front().ei.dbe.timestamp; + uint32_t timestampFirst = m_CIs.front().ei.dbe.getUnixtime(); for (int i = 1; i < m_CIs.size(); ++i) { - if (m_CIs[i].ei.dbe.timestamp < timestampFirst) { - timestampFirst = m_CIs[i].ei.dbe.timestamp; + if (m_CIs[i].ei.dbe.getUnixtime() < timestampFirst) { + timestampFirst = m_CIs[i].ei.dbe.getUnixtime(); nNext = i; } } @@ -183,7 +183,7 @@ void MirandaContactTolerantMerge::fillQueue() iter_each_(std::list, j, m_EIs) { EventInfo& j_ei = *j; - int timestampDelta = j_ei.dbe.timestamp - ci.ei.dbe.timestamp; + int timestampDelta = j_ei.dbe.getUnixtime() - ci.ei.dbe.getUnixtime(); if (timestampDelta > 0) { insPos = j; @@ -227,14 +227,14 @@ void MirandaContactStrictMerge::fillQueue() // assume that items with +/- 30 seconds may be equal static const int timestampTol = 0; - while (!m_CIs.empty() && (m_EIs.size() < 2 || (m_EIs.back().dbe.timestamp - m_EIs.front().dbe.timestamp) <= timestampTol)) { + while (!m_CIs.empty() && (m_EIs.size() < 2 || (m_EIs.back().dbe.getUnixtime() - m_EIs.front().dbe.getUnixtime()) <= timestampTol)) { // find oldest next event in chains int nNext = 0; - uint32_t timestampFirst = m_CIs.front().ei.dbe.timestamp; + uint32_t timestampFirst = m_CIs.front().ei.dbe.getUnixtime(); for (int i = 1; i < m_CIs.size(); ++i) { - if (m_CIs[i].ei.dbe.timestamp < timestampFirst) { - timestampFirst = m_CIs[i].ei.dbe.timestamp; + if (m_CIs[i].ei.dbe.getUnixtime() < timestampFirst) { + timestampFirst = m_CIs[i].ei.dbe.getUnixtime(); nNext = i; } } @@ -248,7 +248,7 @@ void MirandaContactStrictMerge::fillQueue() iter_each_(std::list, j, m_EIs) { EventInfo& j_ei = *j; - int timestampDelta = j_ei.dbe.timestamp - ci.ei.dbe.timestamp; + int timestampDelta = j_ei.dbe.getUnixtime() - ci.ei.dbe.getUnixtime(); if (timestampDelta > 0) insPos = j; @@ -291,11 +291,11 @@ void MirandaContactNoMerge::fillQueue() while (!m_CIs.empty() && m_EIs.size() < 1) { // find oldest next event in chains int nNext = 0; - uint32_t timestampFirst = m_CIs.front().ei.dbe.timestamp; + uint32_t timestampFirst = m_CIs.front().ei.dbe.getUnixtime(); for (int i = 1; i < m_CIs.size(); ++i) { - if (m_CIs[i].ei.dbe.timestamp < timestampFirst) { - timestampFirst = m_CIs[i].ei.dbe.timestamp; + if (m_CIs[i].ei.dbe.getUnixtime() < timestampFirst) { + timestampFirst = m_CIs[i].ei.dbe.getUnixtime(); nNext = i; } } diff --git a/plugins/HistoryStats/src/statistic.cpp b/plugins/HistoryStats/src/statistic.cpp index 37da089c20..f3cbb0a4d9 100644 --- a/plugins/HistoryStats/src/statistic.cpp +++ b/plugins/HistoryStats/src/statistic.cpp @@ -407,7 +407,7 @@ bool Statistic::stepReadDB() // filter logged status messages from tabSRMM if (dbei.eventType == etMessage) { // convert to local time (everything in this plugin is done in local time) - uint32_t localTimestamp = TimeZone_ToLocal(dbei.timestamp); + uint32_t localTimestamp = TimeZone_ToLocal(dbei.getUnixtime()); if (localTimestamp >= m_TimeMin && localTimestamp <= m_TimeMax) { if (dbei.flags & DBEF_UTF) { diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 5ed98ea385..e9fedbc0e2 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -160,7 +160,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke // should we stop processing? // lPolicy == 1 - for time criterion, lPolicy == 2 - keep N last events, lPolicy == 3 - delete all events - if ((lPolicy == 1 && (unsigned)Criteria.time < dbei.timestamp) || (lPolicy == 2 && Criteria.keep > --eventsCnt)) break; + if ((lPolicy == 1 && (unsigned)Criteria.time < dbei.getUnixtime()) || (lPolicy == 2 && Criteria.keep > --eventsCnt)) break; bool doDelete = true; if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && keepUnread) @@ -169,7 +169,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke if (bookcnt != 0) { // keep bookmarks ev.hDBEvent = hDBEvent; item = (BEventData*)bsearch(&ev, books, bookcnt, sizeof(BEventData), CompareBookmarks); - if (item != nullptr && item->Timestamp == dbei.timestamp) { + if (item != nullptr && item->Timestamp == dbei.getUnixtime()) { doDelete = FALSE; btshift = (--bookcnt - (item - books)) * sizeof(BEventData); if (btshift) diff --git a/plugins/IEHistory/src/dlgHandlers.cpp b/plugins/IEHistory/src/dlgHandlers.cpp index 967444332f..72c6436484 100644 --- a/plugins/IEHistory/src/dlgHandlers.cpp +++ b/plugins/IEHistory/src/dlgHandlers.cpp @@ -131,7 +131,7 @@ void FillIEViewInfo(IEVIEWEVENTDATA *fillData, DBEVENTINFO dbInfo, uint8_t *blob fillData->szNick.a = ""; fillData->bIsMe = (dbInfo.flags & DBEF_SENT); fillData->dwFlags = (dbInfo.flags & DBEF_SENT) ? IEEDF_SENT : 0; - fillData->time = dbInfo.timestamp; + fillData->time = dbInfo.getUnixtime(); int len = (int)mir_strlen((char *)blob) + 1; uint8_t *pos; diff --git a/plugins/IEHistory/src/utils.cpp b/plugins/IEHistory/src/utils.cpp index 8508918230..8ad76b8a8b 100644 --- a/plugins/IEHistory/src/utils.cpp +++ b/plugins/IEHistory/src/utils.cpp @@ -152,7 +152,7 @@ SearchResult SearchHistory(MCONTACT contact, MEVENT hFirstEvent, void *searchDat { SYSTEMTIME time; TimeSearchData *data = (TimeSearchData *)searchData; - UnixTimeToSystemTime((time_t)dbEvent.timestamp, &time); + UnixTimeToSystemTime(dbEvent.getUnixtime(), &time); found = ((data->flags & TSDF_DATE_SET) || (data->flags & TSDF_TIME_SET)) ? true : false; if (data->flags & TSDF_DATE_SET) found = ((time.wYear == data->time.wYear) && (time.wMonth == data->time.wMonth) && (time.wDay == data->time.wDay)); diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 802998a5cb..30882781f7 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -214,13 +214,13 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) IEVIEWEVENTDATA *eventData = new IEVIEWEVENTDATA; eventData->dwFlags = IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | - (dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0); + (dbei.bRead ? IEEDF_READ : 0) | (dbei.bSent ? IEEDF_SENT : 0) | (dbei.bRtl ? IEEDF_RTL : 0); if (event->dwFlags & IEEF_RTL) eventData->dwFlags |= IEEDF_RTL; - eventData->time = dbei.timestamp; + eventData->time = dbei.getUnixtime(); eventData->szNick.a = eventData->szText.a = nullptr; - if (dbei.flags & DBEF_SENT) { + if (dbei.bSent) { eventData->szNick.w = getContactName(NULL, szProto); eventData->bIsMe = TRUE; } diff --git a/plugins/Import/src/dbrw/dbevents.cpp b/plugins/Import/src/dbrw/dbevents.cpp index 605dc3683f..86eccc1712 100644 --- a/plugins/Import/src/dbrw/dbevents.cpp +++ b/plugins/Import/src/dbrw/dbevents.cpp @@ -80,7 +80,7 @@ STDMETHODIMP_(BOOL) CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) if (sql_step(stmt) == SQLITE_ROW) { const void *blob = sqlite3_column_blob(stmt, 4); - dbei->timestamp = (uint32_t)sqlite3_column_int(stmt, 1); + dbei->iTimestamp = sqlite3_column_int64(stmt, 1); dbei->flags = (uint32_t)sqlite3_column_int(stmt, 2); dbei->eventType = (uint16_t)sqlite3_column_int(stmt, 3); dbei->szModule = mir_strdup((char*)sqlite3_column_text(stmt, 7)); diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 82109692f1..3ab25a43f6 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -867,9 +867,7 @@ void CImportBatch::ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int // custom filtering if (!bSkipThis) { - bool bIsSent = (dbei.flags & DBEF_SENT) != 0; - - if (dbei.timestamp < (uint32_t)m_dwSinceDate) + if (dbei.getUnixtime() < (uint32_t)m_dwSinceDate) bSkipThis = true; if (!bSkipThis) { @@ -877,15 +875,15 @@ void CImportBatch::ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int bSkipThis = 1; switch (dbei.eventType) { case EVENTTYPE_MESSAGE: - if ((bIsSent ? IOPT_MSGSENT : IOPT_MSGRECV) & m_iOptions) + if ((dbei.bSent ? IOPT_MSGSENT : IOPT_MSGRECV) & m_iOptions) bSkipThis = false; break; case EVENTTYPE_FILE: - if ((bIsSent ? IOPT_FILESENT : IOPT_FILERECV) & m_iOptions) + if ((dbei.bSent ? IOPT_FILESENT : IOPT_FILERECV) & m_iOptions) bSkipThis = false; break; default: - if ((bIsSent ? IOPT_OTHERSENT : IOPT_OTHERRECV) & m_iOptions) + if ((dbei.bSent ? IOPT_OTHERSENT : IOPT_OTHERRECV) & m_iOptions) bSkipThis = false; break; } diff --git a/plugins/Import/src/mcontacts.cpp b/plugins/Import/src/mcontacts.cpp index 3340b3af77..db0a673f67 100644 --- a/plugins/Import/src/mcontacts.cpp +++ b/plugins/Import/src/mcontacts.cpp @@ -212,7 +212,7 @@ public: dbei->eventType = hdr.eventType; cbLen = hdr.cbBlob; dbei->flags = hdr.flags; - dbei->timestamp = hdr.timestamp; + dbei->iTimestamp = hdr.timestamp; } else if (dwSize == sizeof(MC_MsgHeader64)) { MC_MsgHeader64 hdr; @@ -223,7 +223,7 @@ public: dbei->eventType = hdr.eventType; cbLen = hdr.cbBlob; dbei->flags = hdr.flags; - dbei->timestamp = hdr.timestamp; + dbei->iTimestamp = hdr.timestamp; } else return 1; diff --git a/plugins/Import/src/patterns.cpp b/plugins/Import/src/patterns.cpp index 27d8787088..c64cbad570 100644 --- a/plugins/Import/src/patterns.cpp +++ b/plugins/Import/src/patterns.cpp @@ -564,8 +564,8 @@ public: dbei->flags = DBEF_READ | DBEF_UTF; if (pMsg[0x1A] != 0) dbei->flags |= DBEF_SENT; - dbei->timestamp = RLInteger(&pMsg[0x12]); - dbei->timestamp -= TimeZone_ToLocal(dbei->timestamp) - dbei->timestamp; // deduct time zone offset from timestamp + dbei->iTimestamp = RLInteger(&pMsg[0x12]); + dbei->iTimestamp -= TimeZone_ToLocal(dbei->getUnixtime()) - dbei->getUnixtime(); // deduct time zone offset from timestamp dbei->cbBlob = RLWord(&pMsg[m_iMsgHeaderSize - 2]); dbei->pBlob = (char *)mir_alloc(dbei->cbBlob + 1); memcpy(dbei->pBlob, pMsg + m_iMsgHeaderSize, dbei->cbBlob); @@ -631,7 +631,7 @@ public: st.tm_hour = str2int(substrings[pPattern->iHours]); st.tm_min = str2int(substrings[pPattern->iMinutes]); st.tm_sec = (pPattern->iSeconds) ? str2int(substrings[pPattern->iSeconds]) : 0; - dbei->timestamp = mktime(&st); + dbei->iTimestamp = mktime(&st); if (pPattern->iDirection) if (pPattern->wszOutgoing == substrings[pPattern->iDirection]) diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index 3cfa254c8f..c78e031099 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -112,7 +112,7 @@ public: auto &node = *pNode; dbei->eventType = node["type"].as_int(); - dbei->timestamp = 0; + dbei->iTimestamp = 0; std::string szTime = node["time"].as_string(); if (!szTime.empty()) { char c; @@ -123,7 +123,7 @@ public: st.tm_year -= 1900; time_t tm = mktime(&st); if (tm != -1) - dbei->timestamp = tm; + dbei->iTimestamp = tm; } } else { @@ -136,13 +136,13 @@ public: st.tm_year -= 1900; time_t tm = _mkgmtime(&st); if (tm != -1) - dbei->timestamp = tm; + dbei->iTimestamp = tm; } } } - if (dbei->timestamp == 0) - dbei->timestamp = node["timeStamp"].as_int(); + if (dbei->iTimestamp == 0) + dbei->iTimestamp = node["timeStamp"].as_int(); dbei->flags = 0; std::string szFlags = node["flags"].as_string(); @@ -343,16 +343,16 @@ public: if (mir_strcmp(dbei.szModule, szProto)) pRoot.push_back(JSONNode("module", dbei.szModule)); - pRoot.push_back(JSONNode("timestamp", dbei.timestamp)); + pRoot.push_back(JSONNode("timestamp", dbei.getUnixtime())); wchar_t szTemp[500]; - TimeZone_PrintTimeStamp(UTC_TIME_HANDLE, dbei.timestamp, L"I", szTemp, _countof(szTemp), 0); + TimeZone_PrintTimeStamp(UTC_TIME_HANDLE, dbei.getUnixtime(), L"I", szTemp, _countof(szTemp), 0); pRoot.push_back(JSONNode("isotime", T2Utf(szTemp).get())); std::string flags; - if (dbei.flags & DBEF_SENT) + if (dbei.bSent) flags += "m"; - if (dbei.flags & DBEF_READ) + if (dbei.bRead) flags += "r"; pRoot.push_back(JSONNode("flags", flags)); diff --git a/plugins/Jingle/src/account.cpp b/plugins/Jingle/src/account.cpp index 2e92e967bf..7a3ac68481 100644 --- a/plugins/Jingle/src/account.cpp +++ b/plugins/Jingle/src/account.cpp @@ -130,7 +130,7 @@ static BOOL OnProcessJingle(struct IJabberInterface *api, const TiXmlElement *no // Save this event to history DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.pBlob = "** A call while we were busy **"; ProtoChainRecvMsg(api->ContactFromJID(from), dbei); reason = "busy"; diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index f4c1ac3e61..ff8cf7c196 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -334,7 +334,7 @@ BOOL checkMsgTimestamp(MCONTACT hContact, MEVENT hEventCurrent, uint32_t timesta for (MEVENT hEvent = db_event_prev(hContact, hEventCurrent); hEvent; hEvent = db_event_prev(hContact, hEvent)) { DBEVENTINFO einfo = {}; if (!db_event_get(hEvent, &einfo)) { - if ((einfo.timestamp + wSecondsOlder) <= timestampCurrent) + if ((einfo.getUnixtime() + wSecondsOlder) <= timestampCurrent) return TRUE; if (einfo.eventType == EVENTTYPE_MESSAGE) return FALSE; @@ -396,7 +396,7 @@ static int PluginMessageEventHook(WPARAM hContact, LPARAM hEvent) //get DBEVENTINFO without pBlob DBEVENTINFO einfo = {}; if (!db_event_get(hEvent, &einfo) && !(einfo.flags & DBEF_SENT)) - if ((einfo.eventType == EVENTTYPE_MESSAGE && bFlashOnMsg && checkOpenWindow(hContact) && checkMsgTimestamp(hContact, hEvent, einfo.timestamp)) || + if ((einfo.eventType == EVENTTYPE_MESSAGE && bFlashOnMsg && checkOpenWindow(hContact) && checkMsgTimestamp(hContact, hEvent, einfo.getUnixtime())) || (einfo.eventType == EVENTTYPE_FILE && bFlashOnFile) || (einfo.eventType != EVENTTYPE_MESSAGE && einfo.eventType != EVENTTYPE_FILE && bFlashOnOther)) { diff --git a/plugins/MessageState/src/messagestate.cpp b/plugins/MessageState/src/messagestate.cpp index 2dbe670043..40d1d867ad 100644 --- a/plugins/MessageState/src/messagestate.cpp +++ b/plugins/MessageState/src/messagestate.cpp @@ -86,7 +86,7 @@ static int OnEventDelivered(WPARAM hContact, LPARAM) static int OnEventFilterAdd(WPARAM hContact, LPARAM lParam) { DBEVENTINFO *dbei = (DBEVENTINFO *)lParam; - if ((dbei->flags & DBEF_SENT) && CheckProtoSupport(dbei->szModule)) { + if (dbei->bSent && CheckProtoSupport(dbei->szModule)) { time_t dwTime = time(0); FindContact(hContact)->setSent(dwTime); if (db_mc_isSub(hContact)) diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 83db70a709..12ae993190 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -295,7 +295,7 @@ void MirandaUtils::addMessageToDB(MCONTACT hContact, char* msgBuffer, std::size_ dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = targetHandleSzProto; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.cbBlob = (uint32_t)bufSize; dbei.pBlob = msgBuffer; db_event_add(hContact, &dbei); diff --git a/plugins/MirLua/src/Modules/m_database.cpp b/plugins/MirLua/src/Modules/m_database.cpp index e3f4922643..a7e8f43960 100644 --- a/plugins/MirLua/src/Modules/m_database.cpp +++ b/plugins/MirLua/src/Modules/m_database.cpp @@ -294,7 +294,7 @@ void MakeDbEvent(lua_State *L, DBEVENTINFO &dbei) lua_pop(L, 1); lua_getfield(L, -1, "Timestamp"); - dbei.timestamp = lua_tonumber(L, -1); + dbei.iTimestamp = lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Flags"); @@ -692,7 +692,7 @@ LUAMOD_API int luaopen_m_database(lua_State *L) MT(L, MT_DBEVENTINFO) .Field(&DBEVENTINFO::szModule, "Module", LUA_TSTRINGA) - .Field(&DBEVENTINFO::timestamp, "Timestamp", LUA_TINTEGER) + .Field(&DBEVENTINFO::iTimestamp, "Timestamp", LUA_TINTEGER) .Field(&DBEVENTINFO::eventType, "Type", LUA_TINTEGER) .Field(&DBEVENTINFO::flags, "Flags", LUA_TINTEGER); diff --git a/plugins/MirLua/src/Modules/m_message.cpp b/plugins/MirLua/src/Modules/m_message.cpp index 1425771a14..be10f333ab 100644 --- a/plugins/MirLua/src/Modules/m_message.cpp +++ b/plugins/MirLua/src/Modules/m_message.cpp @@ -36,7 +36,7 @@ static int message_Send(lua_State *L) else if ((res = ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message)) != ACKRESULT_FAILED) { DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (uint32_t)mir_strlen(message); dbei.pBlob = mir_strdup(message); diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index af6c8eb928..fd118f41d6 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -216,7 +216,7 @@ void ShowMessageInline(const MCONTACT hContact, const wchar_t *msg) T2Utf utf(buff); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = utf; dbei.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, dbei); @@ -228,7 +228,7 @@ void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) mir_snprintf(buff, "%s%s", LANG_INLINE_PREFIX, msg); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = buff; dbei.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, dbei); diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 3ef8bca1c4..4ecd78fe06 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -649,7 +649,7 @@ void CAppletManager::FinishMessageJob(SMessageJob *pJob) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = szProto; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); // Check if protocoll is valid if (dbei.szModule == nullptr) return; @@ -795,7 +795,7 @@ bool CAppletManager::TranslateDBEvent(CEvent *pEvent, WPARAM hContact, LPARAM hd pEvent->hContact = hContact; pEvent->hValue = hdbevent; - time_t timestamp = (time_t)dbei.timestamp; + time_t timestamp = (time_t)dbei.getUnixtime(); localtime_s(&pEvent->Time, ×tamp); pEvent->bTime = true; diff --git a/plugins/Msg_Export/src/export.cpp b/plugins/Msg_Export/src/export.cpp index ff38216e11..d62e537175 100644 --- a/plugins/Msg_Export/src/export.cpp +++ b/plugins/Msg_Export/src/export.cpp @@ -308,10 +308,10 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF // Get time stamp CMStringW output; - output.AppendFormat(L"%-*s", (int)nFirstColumnWidth, dbei.flags & DBEF_SENT ? sLocalUser.c_str() : sRemoteUser.c_str()); + output.AppendFormat(L"%-*s", (int)nFirstColumnWidth, dbei.bSent ? sLocalUser.c_str() : sRemoteUser.c_str()); { wchar_t buf[100]; - TimeZone_ToStringW(dbei.timestamp, g_sTimeFormat.c_str(), buf, _countof(buf)); + TimeZone_ToStringW(dbei.getUnixtime(), g_sTimeFormat.c_str(), buf, _countof(buf)); output.Append(buf); } diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 8262b848bc..11809f5d3c 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -70,7 +70,7 @@ void __cdecl AutoreplyDelayThread(CAutoreplyData *ad) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = szProto; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = ReplyLen; dbei.pBlob = pszReply; db_event_add(ad->hContact, &dbei); @@ -112,7 +112,7 @@ int MsgEventAdded(WPARAM hContact, LPARAM lParam) if (dbei->flags & DBEF_SENT || (dbei->eventType != EVENTTYPE_MESSAGE && dbei->eventType != EVENTTYPE_FILE)) return 0; - if (time(0) - dbei->timestamp > MAX_REPLY_TIMEDIFF) // don't reply to offline messages + if (time(0) - dbei->getUnixtime() > MAX_REPLY_TIMEDIFF) // don't reply to offline messages return 0; char *szProto = Proto_GetBaseAccountName(hContact); @@ -139,7 +139,7 @@ int MsgEventAdded(WPARAM hContact, LPARAM lParam) // we compare only event timestamps, and do not look at the message itself. it's unlikely that there'll be two events from a contact at the same second, so it's a trade-off between speed and reliability for (i = MetacontactEvents.GetSize() - 1; i >= 0; i--) { - if (MetacontactEvents[i].timestamp == dbei->timestamp && MetacontactEvents[i].hMetaContact == hMetaContact) { + if (MetacontactEvents[i].timestamp == dbei->getUnixtime() && MetacontactEvents[i].hMetaContact == hMetaContact) { bMsgWindowIsOpen = MetacontactEvents[i].bMsgWindowIsOpen; break; } @@ -159,7 +159,7 @@ int MsgEventAdded(WPARAM hContact, LPARAM lParam) MetacontactEvents.RemoveElem(i); // add the new event and wait for a subcontact's event - MetacontactEvents.AddElem(CMetacontactEvent(hContact, dbei->timestamp, IsSRMsgWindowOpen(hContact))); + MetacontactEvents.AddElem(CMetacontactEvent(hContact, dbei->getUnixtime(), IsSRMsgWindowOpen(hContact))); return 0; } diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp index ad633f4da5..5333916d84 100644 --- a/plugins/NewEventNotify/src/main.cpp +++ b/plugins/NewEventNotify/src/main.cpp @@ -80,11 +80,11 @@ int HookedNewEvent(WPARAM hContact, LPARAM hDbEvent) return 0; // if event was allready read don't show it - if (g_plugin.bReadCheck && (dbei.flags & DBEF_READ)) + if (g_plugin.bReadCheck && dbei.bRead) return 0; // is it an event sent by the user? -> don't show - if (dbei.flags & DBEF_SENT) { + if (dbei.bSent) { // JK, only message event, do not influence others auto *pdata = PU_GetByContact(hContact, dbei.eventType); if (g_plugin.bHideSend && pdata) diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index a33b7f5f4c..dc8e7d0502 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -444,7 +444,7 @@ int PopupUpdate(PLUGIN_DATA &pdata, MEVENT hEvent) wszFormat.Append(L"%H:%M"); if (!wszFormat.IsEmpty()) { wchar_t timestamp[MAX_DATASIZE]; - time_t localTime = dbe.timestamp; + time_t localTime = dbe.getUnixtime(); wcsftime(timestamp, _countof(timestamp), wszFormat, localtime(&localTime)); wszText.AppendFormat(L"[b][i]%s[/i][/b]\n", timestamp); } diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 3e979fec62..d10a6218f0 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -25,7 +25,7 @@ bool Filter::check(ItemData *item) const { if (!item) return false; if (!(flags & EVENTONLY)) { - if (item->dbe.flags & DBEF_SENT) { + if (item->dbe.bSent) { if (!(flags & OUTGOING)) return false; } @@ -92,9 +92,9 @@ static bool isEqual(const ItemData *p1, const ItemData *p2) return false; if (p1->dbe.eventType != p2->dbe.eventType) return false; - if ((p1->dbe.flags & DBEF_SENT) != (p2->dbe.flags & DBEF_SENT)) + if (p1->dbe.bSent != p2->dbe.bSent) return false; - if (p1->dbe.timestamp / 86400 != p2->dbe.timestamp / 86400) + if (p1->dbe.getUnixtime() / 86400 != p2->dbe.getUnixtime() / 86400) return false; return true; } @@ -165,7 +165,7 @@ static bool isEqualGC(const ItemData *p1, const ItemData *p2) if (wcscmp(p1->wszNick, p2->wszNick)) return false; - if (p1->dbe.timestamp / 86400 != p2->dbe.timestamp / 86400) + if (p1->dbe.getUnixtime() / 86400 != p2->dbe.getUnixtime() / 86400) return false; return true; } @@ -316,13 +316,13 @@ void ItemData::getFontColor(int &fontId, int &colorId) const { switch (dbe.eventType) { case EVENTTYPE_MESSAGE: - fontId = !(dbe.flags & DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; + fontId = !dbe.bSent ? FONT_INMSG : FONT_OUTMSG; + colorId = !dbe.bSent ? COLOR_INMSG : COLOR_OUTMSG; break; case EVENTTYPE_FILE: - fontId = !(dbe.flags & DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; + fontId = !dbe.bSent ? FONT_INFILE : FONT_OUTFILE; + colorId = !dbe.bSent ? COLOR_INFILE : COLOR_OUTFILE; break; case EVENTTYPE_STATUSCHANGE: @@ -341,13 +341,13 @@ void ItemData::getFontColor(int &fontId, int &colorId) const break; case EVENTTYPE_JABBER_PRESENCE: - fontId = !(dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + fontId = !dbe.bSent ? FONT_INOTHER : FONT_OUTOTHER; + colorId = !dbe.bSent ? COLOR_INOTHER : COLOR_OUTOTHER; break; default: - fontId = !(dbe.flags & DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorId = !(dbe.flags & DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + fontId = !dbe.bSent ? FONT_INOTHER : FONT_OUTOTHER; + colorId = !dbe.bSent ? COLOR_INOTHER : COLOR_OUTOTHER; break; } } @@ -444,11 +444,11 @@ void ItemData::load(bool bLoadAlways) CMStringW str, wszNick; wchar_t wszTime[100]; - TimeZone_PrintTimeStamp(0, dbei.timestamp, L"D t", wszTime, _countof(wszTime), 0); + TimeZone_PrintTimeStamp(0, dbei.getUnixtime(), L"D t", wszTime, _countof(wszTime), 0); if (Contact::IsGroupChat(dbe.hContact) && dbei.szUserId) wszNick = Utf2T(dbei.szUserId); - else if (dbei.flags & DBEF_SENT) { + else if (dbei.bSent) { if (char *szProto = Proto_GetBaseAccountName(dbe.hContact)) wszNick = ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)); else @@ -523,7 +523,7 @@ void HistoryArray::addChatEvent(NewstoryListData *pOwner, SESSION_INFO *si, cons p.wtext = wszText.Detach(); p.m_bLoaded = true; p.m_bHighlighted = lin->bIsHighlighted; - p.dbe.timestamp = lin->time; + p.dbe.iTimestamp = lin->time; if (lin->bIsMe) p.dbe.flags |= DBEF_SENT; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index d651658e94..ac0753693d 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -267,7 +267,7 @@ void NewstoryListData::BeginEditItem() mir_subclassWindow(hwndEditBox, HistoryEditWndProc); SendMessage(hwndEditBox, WM_SETFONT, (WPARAM)g_fontTable[fontid].hfnt, 0); SendMessage(hwndEditBox, EM_SETMARGINS, EC_RIGHTMARGIN, 100); - if (item->dbe.eventType != EVENTTYPE_MESSAGE || !(item->dbe.flags & DBEF_SENT)) + if (item->dbe.eventType != EVENTTYPE_MESSAGE || !item->dbe.bSent) SendMessage(hwndEditBox, EM_SETREADONLY, TRUE, 0); ShowWindow(hwndEditBox, SW_SHOW); @@ -408,7 +408,7 @@ void NewstoryListData::DeleteItems(void) for (int i = totalCount - 1; i >= 0; i--) { auto *pItem = GetItem(i); if (pItem->m_bSelected) { - if ((pItem->dbe.flags & DBEF_SENT) == 0) + if (!pItem->dbe.bSent) bIncoming = true; nSelected++; } @@ -459,7 +459,7 @@ void NewstoryListData::DeliverEvent(MCONTACT hContact, MEVENT hEvent) for (int i = totalCount - 1; i >= 0; i--) { auto *pItem = GetItem(i); - if (pItem->dbe.hContact != hContact || !(pItem->dbe.flags & DBEF_SENT)) + if (pItem->dbe.hContact != hContact || !pItem->dbe.bSent) continue; if (pItem->dbe.getEvent() == hEvent) @@ -822,7 +822,7 @@ void NewstoryListData::Paint(simpledib::dib &dib) // Direction icon if (g_plugin.bShowDirection) { - if (pItem->dbe.flags & DBEF_SENT) + if (pItem->dbe.bSent) hIcon = g_plugin.getIcon(IDI_MSGOUT); else hIcon = g_plugin.getIcon(IDI_MSGIN); @@ -964,7 +964,7 @@ void NewstoryListData::RemoteRead(MCONTACT hContact, MEVENT hEvent) if (!pItem->m_bLoaded) pItem->fetch(); - if (pItem->dbe.hContact != hContact || !(pItem->dbe.flags & DBEF_SENT)) + if (pItem->dbe.hContact != hContact || !pItem->dbe.bSent) continue; if (pItem->dbe.getEvent() == hEvent) @@ -1115,7 +1115,7 @@ void NewstoryListData::TryUp(int iCount) for (int j = 0; j < i + 1; j++) if (auto *pItem = GetItem(j)) { pItem->fetch(); - if (pItem->dbe.flags & DBEF_SENT) + if (pItem->dbe.bSent) pItem->m_bRemoteRead = hasRead; pPrev = pItem->checkNext(pPrev); } @@ -1310,7 +1310,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM int eventCount = data->totalCount; for (int i = 0; i < eventCount; i++) { auto *p = data->GetItem(i); - if (p->dbe.timestamp >= wParam) { + if (p->dbe.getUnixtime() >= wParam) { data->SetSelection(i, i); data->SetCaret(i); break; diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp index 3520e117c6..487d9f07d2 100644 --- a/plugins/NewStory/src/history_dlg.cpp +++ b/plugins/NewStory/src/history_dlg.cpp @@ -165,7 +165,7 @@ class CHistoryDlg : public CDlgBase CharLowerW(pwszText); if (wcsstr(pwszText, pwszPattern)) - m_arResults.insert(new SearchResult(hContact, hDbEvent, dbei.timestamp)); + m_arResults.insert(new SearchResult(hContact, hDbEvent, dbei.getUnixtime())); } } @@ -302,11 +302,11 @@ class CHistoryDlg : public CDlgBase if (!pItem->fetch()) continue; - if (pItem->dbe.timestamp == 0) + if (pItem->dbe.iTimestamp == 0) continue; struct tm ts = { 0 }; - time_t timestamp = pItem->dbe.timestamp; + time_t timestamp = pItem->dbe.getUnixtime(); errno_t err = localtime_s(&ts, ×tamp); /* statically alloced, local time correction */ if (err != 0) return; @@ -1157,7 +1157,7 @@ public: case UM_LOCATETIME: if (m_dwOptions & WND_OPT_TIMETREE) if (auto *pItem = m_histCtrl->GetItem(wParam)) - LocateDateTime(pItem->dbe.timestamp); + LocateDateTime(pItem->dbe.getUnixtime()); break; case UM_UPDATE_WINDOW: diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp index 46de0469d4..c7eba2135b 100644 --- a/plugins/NewStory/src/history_menus.cpp +++ b/plugins/NewStory/src/history_menus.cpp @@ -61,7 +61,7 @@ HMENU NSMenu_Build(NewstoryListData *data, ItemData *item) else if (mir_strlen(item->getUrl())) Menu_ShowItem(hmiCopyUrl, true); - bEditable = (item->dbe.flags & DBEF_SENT) != 0; + bEditable = item->dbe.bSent; bShowEventActions = item->dbe.getEvent() != 0; DB::EventInfo dbei(item->dbe.getEvent()); diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp index ba682a6b76..5c2b4c1238 100644 --- a/plugins/NewStory/src/options.cpp +++ b/plugins/NewStory/src/options.cpp @@ -148,7 +148,7 @@ public: m_tempItem->dbe.flags = DBEF_TEMPORARY | DBEF_BOOKMARK; m_tempItem->dbe.szModule = MODULENAME; m_tempItem->dbe.eventType = EVENTTYPE_MESSAGE; - m_tempItem->dbe.timestamp = time(0); + m_tempItem->dbe.iTimestamp = time(0); m_histCtrl->totalCount++; HTREEITEM hGroup = 0, hFirst = 0; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index f6b27fcf77..fc7d59f3f0 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -236,7 +236,7 @@ CMStringW ItemData::formatHtml(const wchar_t *pwszStr) wchar_t szFont[100]; str.AppendFormat(L"body {margin: 0px; text-align: left; %s; color: NSText; overflow: auto;}\n", font2html(F.lf, szFont)); - str.AppendFormat(L".nick {color: #%06X }\n", color2html(g_colorTable[(dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl)); + str.AppendFormat(L".nick {color: #%06X }\n", color2html(g_colorTable[dbe.bSent ? COLOR_OUTNICK : COLOR_INNICK].cl)); str.AppendFormat(L".link {color: #%06X }\n", color2html(g_colorTable[COLOR_LINK].cl)); str.AppendFormat(L".quote {border-left: 4px solid #%06X; padding-left: 8px; }\n", color2html(g_colorTable[COLOR_QUOTE].cl)); @@ -409,7 +409,7 @@ CMStringA NewstoryListData::GatherSelectedRtf() buf.AppendFormat("{\\uc1\\pard \\cb%d\\cf%d\\f%d\\b0\\i0\\fs%d ", COLOR_BACK + 7, colorID+COLOR_COUNT+7, fontID, GetFontHeight(g_fontTable[fontID].lf)); CMStringW wszText(p->formatString()); wszText.Replace(L"[c0]", CMStringW(FORMAT, L"[c%d]", colorID + COLOR_COUNT + 7)); - wszText.Replace(L"[c1]", CMStringW(FORMAT, L"[c%d]", 7 + ((p->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK))); + wszText.Replace(L"[c1]", CMStringW(FORMAT, L"[c%d]", 7 + (p->dbe.bSent ? COLOR_OUTNICK : COLOR_INNICK))); AppendUnicodeToBuffer(buf, wszText); buf.Append("\\par }"); } @@ -540,7 +540,7 @@ void vfEvent(TemplateVars *vars, MCONTACT, ItemData *pItem) wchar_t buf[100]; // %N: Nickname - if (!pItem->m_bIsResult && (pItem->dbe.flags & DBEF_SENT)) { + if (!pItem->m_bIsResult && pItem->dbe.bSent) { if (!pItem->wszNick) { char *proto = Proto_GetBaseAccountName(pItem->dbe.hContact); ptrW nick(Contact::GetInfo(CNF_DISPLAY, 0, proto)); @@ -554,14 +554,14 @@ void vfEvent(TemplateVars *vars, MCONTACT, ItemData *pItem) } // %D: direction symbol - if (pItem->dbe.flags & DBEF_SENT) + if (pItem->dbe.bSent) vars->SetVar('D', L"<<", false); else vars->SetVar('D', L">>", false); // %t: timestamp SYSTEMTIME st; - if (!TimeZone_GetSystemTime(nullptr, pItem->dbe.timestamp, &st, 0)) { + if (!TimeZone_GetSystemTime(nullptr, pItem->dbe.getUnixtime(), &st, 0)) { int iLocale = Langpack_GetDefaultLocale(); GetDateFormatW(iLocale, 0, &st, L"dd.MM.yyyy, ", buf, _countof(buf)); diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 5b947b20a8..43dc3e60cd 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -275,7 +275,7 @@ void LogSMsgToDB(STATUSMSGINFO *smi, const wchar_t *tmplt) dbei.pBlob = blob; dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.szModule = MODULENAME; MEVENT hDBEvent = db_event_add(smi->hContact, &dbei); @@ -358,7 +358,7 @@ int ContactStatusChanged(MCONTACT hContact, uint16_t oldStatus, uint16_t newStat dbei.pBlob = blob; dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.szModule = MODULENAME; MEVENT hDBEvent = db_event_add(hContact, &dbei); diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 8000ad64fe..f5e5e97b86 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -283,7 +283,7 @@ void LogChangeToDB(XSTATUSCHANGE *xsc) dbei.pBlob = blob; dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.szModule = MODULENAME; MEVENT hDBEvent = db_event_add(xsc->hContact, &dbei); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 498aac0b95..3fad7df8d1 100644 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -497,7 +497,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (!strstr(msg, "-----BEGIN PGP MESSAGE-----")) return Proto_ChainRecv(w, ccs); - mir_forkThread(RecvMsgSvc_func, new RecvParams(ccs->hContact, str, msg, dbei->timestamp)); + mir_forkThread(RecvMsgSvc_func, new RecvParams(ccs->hContact, str, msg, dbei->getUnixtime())); return 0; } diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index b38019b1b3..60c7139104 100644 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -474,7 +474,7 @@ void HistoryLog(MCONTACT hContact, const char *msg, uint32_t _time, uint32_t fla DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; dbei.flags = DBEF_UTF | flags; - dbei.timestamp = (_time) ? _time : (uint32_t)time(0); + dbei.iTimestamp = (_time) ? _time : (uint32_t)time(0); dbei.cbBlob = (uint32_t)mir_strlen(msg) + 1; dbei.pBlob = (char *)msg; db_event_add(hContact, &dbei); diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index 3ca4812eaf..f2cdd3aafc 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -285,7 +285,7 @@ void Nudge_SentStatus(CNudgeElement *n, MCONTACT hContact) DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; dbei.flags = DBEF_SENT | DBEF_UTF; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.eventType = 1; dbei.cbBlob = (uint32_t)mir_strlen(buff) + 1; dbei.pBlob = buff; @@ -300,7 +300,7 @@ void Nudge_ShowStatus(CNudgeElement *n, MCONTACT hContact, uint32_t timestamp) dbei.szModule = MODULENAME; dbei.eventType = 1; dbei.flags = DBEF_UTF; - dbei.timestamp = timestamp; + dbei.iTimestamp = timestamp; dbei.cbBlob = (uint32_t)mir_strlen(buff) + 1; dbei.pBlob = buff; db_event_add(hContact, &dbei); diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index 2ae89ff3f9..2b398222ec 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -116,7 +116,7 @@ static void PasteIt(MCONTACT hContact, int mode) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT; dbei.szModule = szProto; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.cbBlob = (uint32_t)mir_strlen(pasteToWeb->szFileLink) + 1; dbei.pBlob = pasteToWeb->szFileLink; db_event_add(hContact, &dbei); diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index e02ab97999..3511e67e2f 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -796,7 +796,7 @@ void AddMessageToDB(MCONTACT hContact, char *msg) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = Proto_GetBaseAccountName(hContact); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(msg) + 1; dbei.pBlob = msg; db_event_add(hContact, &dbei); diff --git a/plugins/QuickSearch/src/window_row.cpp b/plugins/QuickSearch/src/window_row.cpp index d5fac4247b..1745495d51 100644 --- a/plugins/QuickSearch/src/window_row.cpp +++ b/plugins/QuickSearch/src/window_row.cpp @@ -156,7 +156,7 @@ void CRowItem::Val::LoadOneItem(MCONTACT hContact, const ColumnItem &pCol, QSMai if (MEVENT hDbEvent = db_event_last(hContact)) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - data = dbei.timestamp; + data = dbei.getUnixtime(); text = TimeToStrW(data); } else text = 0; diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index 656434f9c2..80004c646d 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -386,8 +386,8 @@ INT_PTR OnMenuCommandShowList(WPARAM, LPARAM) break; } if (curEvent != NULL) - if (curTime == -1 || (__time64_t)dbe.timestamp > curTime) - curTime = (__time64_t)dbe.timestamp; + if (curTime == -1 || (__time64_t)dbe.getUnixtime() > curTime) + curTime = (__time64_t)dbe.getUnixtime(); } if (curTime != -1) diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 33d1f88998..1055ecf6fb 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -129,7 +129,7 @@ static int ackevent(WPARAM, LPARAM lParam) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_UTF | DBEF_SENT | (item->flags & DBEF_RTL); dbei.szModule = Proto_GetBaseAccountName(hContact); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1; dbei.pBlob = item->sendBuffer; dbei.szId = (char *)pAck->lParam; diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8e2132d2c3..81149e2582 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -187,8 +187,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(); break; } } @@ -783,7 +783,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) m_hDbUnreadEventFirst = 0; while (hDbEvent != 0) { DB::EventInfo dbei(hDbEvent, false); - if (!(dbei.flags & DBEF_SENT) && dbei.isSrmm()) + if (!dbei.bSent && dbei.isSrmm()) Clist_RemoveEvent(-1, hDbEvent); hDbEvent = db_event_next(m_hContact, hDbEvent); } diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 9cfc82d963..f3729e9629 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -384,7 +384,7 @@ public: if ((gdat->flags.bGroupMessages) && dbei.flags == LOWORD(m_lastEventType) && dbei.eventType == EVENTTYPE_MESSAGE && HIWORD(m_lastEventType) == EVENTTYPE_MESSAGE && - (isSameDate(dbei.timestamp, m_lastEventTime)) && ((((int)dbei.timestamp < m_startTime) == (m_lastEventTime < m_startTime)) || !(dbei.flags & DBEF_READ))) { + (isSameDate(dbei.getUnixtime(), m_lastEventTime)) && ((((int)dbei.getUnixtime() < m_startTime) == (m_lastEventTime < m_startTime)) || !dbei.bRead)) { isGroupBreak = FALSE; } @@ -393,7 +393,7 @@ public: // test contact if (streamData->dbei == 0) { - if (dbei.flags & DBEF_SENT) + if (dbei.bSent) wszNick = Contact::GetInfo(CNF_DISPLAY, 0, m_pDlg.m_szProto); else wszNick = mir_wstrdup(Clist_GetContactDisplayName(m_pDlg.m_hContact)); @@ -401,7 +401,7 @@ public: if (!m_pDlg.m_bUseRtl && Utils_IsRtl(wszText)) bIsRtl = true; } - else wszNick = mir_wstrdup((dbei.flags & DBEF_SENT) ? TranslateT("Me") : TranslateT("My contact")); + else wszNick = mir_wstrdup(dbei.bSent ? TranslateT("Me") : TranslateT("My contact")); if (!streamData->isFirst && !m_isMixed) { if (isGroupBreak || gdat->flags.bMarkFollowups) @@ -419,7 +419,7 @@ public: buf.Append(bIsRtl ? "\\rtlpar" : "\\ltrpar"); if (dbei.eventType == EVENTTYPE_MESSAGE) - highlight = fontOptionsListSize + 2 + ((dbei.flags & DBEF_SENT) ? 1 : 0); + highlight = fontOptionsListSize + 2 + (dbei.bSent ? 1 : 0); else highlight = fontOptionsListSize + 1; @@ -444,7 +444,7 @@ public: case EVENTTYPE_MESSAGE: if (dbei.flags & (DBEF_SECURE | DBEF_STRONG)) i = (dbei.flags & DBEF_SECURE) ? LOGICON_MSG_SECURE : LOGICON_MSG_STRONG; - else if (dbei.flags & DBEF_SENT) + else if (dbei.bSent) i = LOGICON_MSG_OUT; else i = LOGICON_MSG_IN; @@ -466,29 +466,29 @@ public: if (gdat->flags.bGroupMessages && dbei.eventType == EVENTTYPE_MESSAGE) { if (isGroupBreak) { if (!gdat->flags.bMarkFollowups) - timestampString = TimestampToString(gdat->flags, dbei.timestamp, 0); + timestampString = TimestampToString(gdat->flags, dbei.getUnixtime(), 0); else if (gdat->flags.bShowDate) - timestampString = TimestampToString(gdat->flags, dbei.timestamp, 1); + timestampString = TimestampToString(gdat->flags, dbei.getUnixtime(), 1); } else if (gdat->flags.bMarkFollowups) - timestampString = TimestampToString(gdat->flags, dbei.timestamp, 2); + timestampString = TimestampToString(gdat->flags, dbei.getUnixtime(), 2); } - else timestampString = TimestampToString(gdat->flags, dbei.timestamp, 0); + else timestampString = TimestampToString(gdat->flags, dbei.getUnixtime(), 0); if (timestampString != nullptr) { - buf.AppendFormat("%s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME)); + buf.AppendFormat("%s ", SetToStyle(dbei.bSent ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME)); AppendUnicodeToBuffer(buf, timestampString); } if (dbei.eventType != EVENTTYPE_MESSAGE) - buf.AppendFormat("%s: ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); + buf.AppendFormat("%s: ", SetToStyle(dbei.bSent ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); showColon = 1; } if ((!(gdat->flags.bHideNames) && dbei.eventType == EVENTTYPE_MESSAGE && isGroupBreak) || dbei.eventType == EVENTTYPE_JABBER_CHATSTATES || dbei.eventType == EVENTTYPE_JABBER_PRESENCE) { if (dbei.eventType == EVENTTYPE_MESSAGE) { if (showColon) - buf.AppendFormat(" %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME)); + buf.AppendFormat(" %s ", SetToStyle(dbei.bSent ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME)); else - buf.AppendFormat("%s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME)); + buf.AppendFormat("%s ", SetToStyle(dbei.bSent ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME)); } else buf.AppendFormat("%s ", SetToStyle(MSGFONTID_NOTICE)); @@ -505,15 +505,15 @@ public: } if (gdat->flags.bShowTime && gdat->flags.bGroupMessages && gdat->flags.bMarkFollowups && dbei.eventType == EVENTTYPE_MESSAGE && isGroupBreak) { - buf.AppendFormat(" %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME)); - AppendUnicodeToBuffer(buf, TimestampToString(gdat->flags, dbei.timestamp, 2)); + buf.AppendFormat(" %s ", SetToStyle(dbei.bSent ? MSGFONTID_MYTIME : MSGFONTID_YOURTIME)); + AppendUnicodeToBuffer(buf, TimestampToString(gdat->flags, dbei.getUnixtime(), 2)); showColon = 1; } if (showColon && dbei.eventType == EVENTTYPE_MESSAGE) { if (bIsRtl) - buf.AppendFormat("\\~%s: ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); + buf.AppendFormat("\\~%s: ", SetToStyle(dbei.bSent ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); else - buf.AppendFormat("%s: ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); + buf.AppendFormat("%s: ", SetToStyle(dbei.bSent ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON)); } switch (dbei.eventType) { case EVENTTYPE_JABBER_CHATSTATES: @@ -528,7 +528,7 @@ public: break; } - if (dbei.flags & DBEF_SENT) + if (dbei.bSent) AppendUnicodeToBuffer(buf, TranslateT("File sent")); else AppendUnicodeToBuffer(buf, TranslateT("File received")); @@ -544,7 +544,7 @@ public: if (gdat->flags.bMsgOnNewline && showColon) buf.Append("\\line"); - style = dbei.flags & DBEF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG; + style = dbei.bSent ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG; AppendWithCustomLinks(dbei, style, buf); break; } @@ -552,7 +552,7 @@ public: if (m_isMixed) buf.Append("\\par"); - m_lastEventTime = dbei.timestamp; + m_lastEventTime = dbei.getUnixtime(); m_lastEventType = MAKELONG(dbei.flags, dbei.eventType); return true; } @@ -810,7 +810,7 @@ void StreamInTestEvents(CDlgBase *pDlg, GlobalMessageData *gdat) DB::EventInfo dbei; dbei.flags = DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.szModule = SRMM_MODULE; auto *pLog = new CLogWindow(*(CMsgDialog*)pDlg); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 599fefe9a7..47f692d0a4 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -121,10 +121,10 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) if (!dbei) return 0; - if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ)) + if (dbei.eventType == EVENTTYPE_MESSAGE && dbei.bRead) return 0; - if (dbei.flags & DBEF_SENT || !dbei.isSrmm()) + if (dbei.bSent || !dbei.isSrmm()) return 0; Utils_InvokeAsync(new CAutoPpopup(hContact, hDbEvent)); diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index 05159ea6ba..89a5b817d2 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -84,7 +84,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) /* store the event when the container is hidden so that clist notifications can be removed */ if (!IsWindowVisible(m_hwndParent) && m_hDbUnreadEventFirst == 0) m_hDbUnreadEventFirst = hDbEvent; - m_lastMessage = dbei.timestamp; + m_lastMessage = dbei.getUnixtime(); UpdateStatusBar(); if (bIsActive) Skin_PlaySound("RecvMsgActive"); @@ -101,7 +101,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) else RemakeLog(); - if (!(dbei.flags & DBEF_SENT) && !dbei.isCustom(DETF_MSGWINDOW)) { + if (!dbei.bSent && !dbei.isCustom(DETF_MSGWINDOW)) { if (!bIsActive) { m_iShowUnread = 1; UpdateIcon(); @@ -122,7 +122,7 @@ bool CMsgDialog::GetFirstEvent() m_hDbEventFirst = db_event_firstUnread(m_hContact); if (m_hDbEventFirst != 0) { DB::EventInfo dbei(m_hDbEventFirst, false); - if (dbei.isSrmm() && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) + if (dbei.isSrmm() && !dbei.bRead && !dbei.bSent) notifyUnread = true; } @@ -147,11 +147,11 @@ bool CMsgDialog::GetFirstEvent() case LOADHISTORY_TIME: if (m_hDbEventFirst == 0) - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); else db_event_get(m_hDbEventFirst, &dbei); - uint32_t firstTime = dbei.timestamp - 60 * g_plugin.iLoadTime; + uint32_t firstTime = dbei.getUnixtime() - 60 * g_plugin.iLoadTime; for (;;) { hPrevEvent = pCursor.FetchNext(); if (hPrevEvent == 0) @@ -159,7 +159,7 @@ bool CMsgDialog::GetFirstEvent() dbei.cbBlob = 0; db_event_get(hPrevEvent, &dbei); - if (dbei.timestamp < firstTime) + if (dbei.getUnixtime() < firstTime) break; if (DbEventIsShown(dbei)) m_hDbEventFirst = hPrevEvent; diff --git a/plugins/SecureIM/src/dbevent.cpp b/plugins/SecureIM/src/dbevent.cpp index 66921acadc..8e6bce3f02 100644 --- a/plugins/SecureIM/src/dbevent.cpp +++ b/plugins/SecureIM/src/dbevent.cpp @@ -5,7 +5,7 @@ void HistoryLog(MCONTACT hContact, LPCSTR szText) DBEVENTINFO dbei = {}; dbei.szModule = Proto_GetBaseAccountName(hContact); dbei.flags = DBEF_SENT | DBEF_READ; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (int)mir_strlen(szText) + 1; dbei.pBlob = (char *)szText; diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index 623d7348ae..c18b247f92 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -323,7 +323,7 @@ void CSend::DB_EventAdd(uint16_t EventType) dbei.szModule = m_pszProto; dbei.eventType = EventType; dbei.flags = DBEF_SENT; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.flags |= DBEF_UTF; dbei.cbBlob = m_cbEventMsg; dbei.pBlob = m_szEventMsg.GetBuffer(); diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index 450ed5dfdd..c50fd5dc38 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -207,7 +207,7 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_UTF | DBEF_SENT; dbei.szModule = pszProto; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(pszUtf) + 1; dbei.pBlob = pszUtf; db_event_add(hContact, &dbei); diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 95581f9b47..7de5e6b749 100644 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -260,7 +260,7 @@ void HistoryLog(MCONTACT hContact, char *data, int event_type, int flags) Event.szModule = MODULENAME; Event.eventType = event_type; Event.flags = flags | DBEF_UTF; - Event.timestamp = (uint32_t)time(0); + Event.iTimestamp = (uint32_t)time(0); Event.cbBlob = (uint32_t)mir_strlen(data) + 1; Event.pBlob = _strdup(data); db_event_add(hContact, &Event); diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index 57fe106521..067be9ac76 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -15,7 +15,7 @@ int OnDbEventAdded(WPARAM, LPARAM lParam) return 0; // event is an auth request - if (!(dbei.flags & DBEF_SENT) && !(dbei.flags & DBEF_READ) && dbei.eventType == EVENTTYPE_AUTHREQUEST) { + if (!dbei.bSent && !dbei.bRead && dbei.eventType == EVENTTYPE_AUTHREQUEST) { MCONTACT hContact = DbGetAuthEventContact(&dbei); // if request is from unknown or not marked Answered contact @@ -49,10 +49,10 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) return 0; // ...let the event go its way // if event is not a message, or if the message has been read or sent... - if (dbei->eventType != EVENTTYPE_MESSAGE || (dbei->flags & DBEF_READ) != 0) + if (dbei->eventType != EVENTTYPE_MESSAGE || dbei->bRead) return 0; - if (dbei->flags & DBEF_SENT) { + if (dbei->bSent) { g_plugin.setByte(hContact, DB_KEY_HASSENT, 1); return 0; } diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 16bee8adfd..f46d7b6fdd 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -509,7 +509,7 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c) dbei.cbBlob = (int)mir_strlen(szUtf); dbei.flags = DBEF_UTF | DBEF_READ; dbei.eventType = EVENTTYPE_STATUSCHANGE; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.szModule = (char *)c->getProto(); dat->LogEvent(dbei); } diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 85918bcd04..553e000912 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -224,7 +224,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (!AutoCreateWindow(0, wParam) && lParam) { // no window created, simply add an unread event to contact list DB::EventInfo dbei(lParam, false); - if (dbei && !(dbei.flags & DBEF_READ)) { + if (dbei && !dbei.bRead) { AddUnreadContact(wParam); Srmm_AddEvent(wParam, lParam); } diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 38c39e84af..fb54eab03f 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -446,7 +446,7 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) nowindowcreate: // for tray support, we add the event to the tray menu. otherwise we send it back to // the contact list for flashing - if (!(dbei.flags & DBEF_READ)) { + if (!dbei.bRead) { AddUnreadContact(hContact); Srmm_AddEvent(hContact, hDbEvent); } diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 56ee17a4bc..af9b6cfd5b 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -576,8 +576,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(); DM_UpdateLastMessage(); break; } diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 2652a42e00..1bf3dde416 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -298,13 +298,13 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) bool bAlertable = dbei.isAlertable(); bool bIsStatusChangeEvent = IsStatusEvent(dbei.eventType); - bool bDisableNotify = (bAlertable && (dbei.flags & DBEF_READ)); + bool bDisableNotify = (bAlertable && dbei.bRead); if (!DbEventIsShown(dbei)) return; - if (bAlertable && !(dbei.flags & DBEF_SENT)) { - m_lastMessage = dbei.timestamp; + if (bAlertable && !dbei.bSent) { + m_lastMessage = dbei.getUnixtime(); m_wszStatusBar[0] = 0; if (m_bShowTyping) { m_nTypeSecs = 0; @@ -318,7 +318,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) // set the message log divider to mark new (maybe unseen) messages, if the container has // been minimized or in the background. - if (!(dbei.flags & DBEF_SENT) && !bIsStatusChangeEvent) { + if (!dbei.bSent && !bIsStatusChangeEvent) { if (g_plugin.bDividersUsePopupConfig && g_plugin.bUseDividers) { if (!MessageWindowOpened(m_hContact, nullptr)) DM_AddDivider(); @@ -342,7 +342,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) // handle tab flashing if (!bDisableNotify && !bIsStatusChangeEvent) - if ((TabCtrl_GetCurSel(m_hwndParent) != m_iTabID) && !(dbei.flags & DBEF_SENT)) { + if ((TabCtrl_GetCurSel(m_hwndParent) != m_iTabID) && !dbei.bSent) { switch (dbei.eventType) { case EVENTTYPE_MESSAGE: m_iFlashIcon = PluginConfig.g_IconMsgEvent; @@ -364,7 +364,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) // autoswitch tab if option is set AND container is minimized (otherwise, we never autoswitch) // never switch for status changes... - if (!(dbei.flags & DBEF_SENT) && !bIsStatusChangeEvent) { + if (!dbei.bSent && !bIsStatusChangeEvent) { if (g_plugin.bAutoSwitchTabs && m_pContainer->m_hwndActive != m_hwnd) { if ((IsIconic(m_pContainer->m_hwnd) && !IsZoomed(m_pContainer->m_hwnd)) || (g_plugin.bHideOnClose && !IsWindowVisible(m_pContainer->m_hwnd))) { int iItem = GetTabIndexFromHWND(GetParent(m_hwnd), m_hwnd); @@ -381,7 +381,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) // flash window if it is not focused if (!bDisableNotify && !bIsStatusChangeEvent) - if (!IsActive() && !(dbei.flags & DBEF_SENT)) { + if (!IsActive() && !dbei.bSent) { if (!m_pContainer->cfg.flags.m_bNoFlash && !m_pContainer->IsActive()) m_pContainer->FlashContainer(1, 0); m_pContainer->SetIcon(this, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); @@ -389,7 +389,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) } // play a sound - if (!bDisableNotify && bAlertable && !(dbei.flags & DBEF_SENT)) + if (!bDisableNotify && bAlertable && !dbei.bSent) PlayIncomingSound(); if (m_pWnd) @@ -435,16 +435,16 @@ bool CMsgDialog::GetFirstEvent() case LOADHISTORY_TIME: if (m_hDbEventFirst == 0) - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); else db_event_get(m_hDbEventFirst, &dbei); - uint32_t firstTime = dbei.timestamp - 60 * g_plugin.getWord(SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME); + uint32_t firstTime = dbei.getUnixtime() - 60 * g_plugin.getWord(SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME); 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; } @@ -493,7 +493,7 @@ int CMsgDialog::FindRTLLocale() void CMsgDialog::FlashOnClist(MEVENT hEvent, const DB::EventInfo &dbei) { m_dwTickLastEvent = GetTickCount(); - bool bSent = dbei.flags & DBEF_SENT; + bool bSent = dbei.bSent; if ((GetForegroundWindow() != m_pContainer->m_hwnd || m_pContainer->m_hwndActive != m_hwnd) && !bSent) { m_dwUnread++; diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index d4cb88232e..1c0085df3f 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -568,8 +568,8 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.markedRead()) dat->m_cache->updateStats(TSessionStats::SET_LAST_RCV, mir_strlen((char *)dbei.pBlob)); - BOOL isSent = (dbei.flags & DBEF_SENT); - BOOL bIsStatusChangeEvent = IsStatusEvent(dbei.eventType); + bool isSent = dbei.bSent; + bool bIsStatusChangeEvent = IsStatusEvent(dbei.eventType); if (!isSent && bIsStatusChangeEvent) dbei.wipeNotify(); @@ -596,7 +596,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe uint32_t dwEffectiveFlags = dat->m_dwFlags; - dat->m_bIsHistory = (dbei.timestamp < dat->m_cache->getSessionStart() && dbei.markedRead()); + dat->m_bIsHistory = (dbei.getUnixtime() < dat->m_cache->getSessionStart() && dbei.markedRead()); int iFontIDOffset = dat->m_bIsHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set) g_groupBreak = TRUE; @@ -610,9 +610,9 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe dat->m_bDividerWanted = false; } - if (dwEffectiveFlags & MWF_LOG_GROUPMODE && ((dbei.flags & (DBEF_SENT | DBEF_READ | DBEF_RTL)) == LOWORD(dat->m_iLastEventType)) && dbei.eventType == EVENTTYPE_MESSAGE && HIWORD(dat->m_iLastEventType) == EVENTTYPE_MESSAGE && (dbei.timestamp - dat->m_lastEventTime) < 86400) { + if (dwEffectiveFlags & MWF_LOG_GROUPMODE && ((dbei.flags & (DBEF_SENT | DBEF_READ | DBEF_RTL)) == LOWORD(dat->m_iLastEventType)) && dbei.eventType == EVENTTYPE_MESSAGE && HIWORD(dat->m_iLastEventType) == EVENTTYPE_MESSAGE && (dbei.getUnixtime() - dat->m_lastEventTime) < 86400) { g_groupBreak = FALSE; - if ((time_t)dbei.timestamp > today && dat->m_lastEventTime < today) + if ((time_t)dbei.getUnixtime() > today && dat->m_lastEventTime < today) g_groupBreak = TRUE; } @@ -642,7 +642,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe // templated code starts here if (dwEffectiveFlags & MWF_LOG_SHOWTIME) { hTimeZone = ((dat->m_dwFlags & MWF_LOG_LOCALTIME) && !isSent) ? dat->m_hTimeZone : nullptr; - time_t local_time = TimeZone_UtcToLocal(hTimeZone, dbei.timestamp); + time_t local_time = TimeZone_UtcToLocal(hTimeZone, dbei.getUnixtime()); event_time = *gmtime(&local_time); } @@ -765,14 +765,14 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe break; case 'D': // long date if (showTime && showDate) { - wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.timestamp, 'D'); + wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.getUnixtime(), 'D'); AppendTimeStamp(szFinalTimestamp, isSent, str, skipFont, dat, iFontIDOffset); } else skipToNext = true; break; case 'E': // short date... if (showTime && showDate) { - wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.timestamp, 'E'); + wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.getUnixtime(), 'E'); AppendTimeStamp(szFinalTimestamp, isSent, str, skipFont, dat, iFontIDOffset); } else skipToNext = true; @@ -871,7 +871,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe case 'R': case 'r': // long date if (showTime && showDate) { - wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.timestamp, cc); + wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.getUnixtime(), cc); AppendTimeStamp(szFinalTimestamp, isSent, str, skipFont, dat, iFontIDOffset); } else skipToNext = true; @@ -879,7 +879,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe case 't': case 'T': if (showTime) { - wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.timestamp, (wchar_t)((dwEffectiveFlags & MWF_LOG_SHOWSECONDS) ? cc : (wchar_t)'t')); + wchar_t *szFinalTimestamp = Template_MakeRelativeDate(hTimeZone, dbei.getUnixtime(), (wchar_t)((dwEffectiveFlags & MWF_LOG_SHOWSECONDS) ? cc : (wchar_t)'t')); AppendTimeStamp(szFinalTimestamp, isSent, str, skipFont, dat, iFontIDOffset); } else skipToNext = true; @@ -1116,7 +1116,7 @@ skip: str.Append("\\par"); dat->m_iLastEventType = MAKELONG((dbei.flags & (DBEF_SENT | DBEF_READ | DBEF_RTL)), dbei.eventType); - dat->m_lastEventTime = dbei.timestamp; + dat->m_lastEventTime = dbei.getUnixtime(); return true; } @@ -1205,12 +1205,12 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool fAppend, DB::Ev m_pDlg.m_bLastParaDeleted = true; } - BOOL isSent; + bool isSent; if (streamData.dbei != nullptr) - isSent = (streamData.dbei->flags & DBEF_SENT) != 0; + isSent = streamData.dbei->bSent; else { DB::EventInfo dbei(hDbEventFirst, false); - isSent = (dbei.flags & DBEF_SENT) != 0; + isSent = dbei.bSent; } ReplaceIcons(startAt, fAppend, isSent); diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 2c4f020055..382af9cd11 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -625,7 +625,7 @@ public: DB::EventInfo dbei; dbei.szModule = m_szProto; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.eventType = (iIndex == 6) ? EVENTTYPE_STATUSCHANGE : EVENTTYPE_MESSAGE; dbei.eventType = (iIndex == 7) ? EVENTTYPE_ERRMSG : dbei.eventType; if (dbei.eventType == EVENTTYPE_ERRMSG) diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index d1d3ec9186..d48b975f39 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -792,7 +792,7 @@ HANDLE SendLater::processAck(const ACKDATA *ack) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = Proto_GetBaseAccountName((p->hContact)); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(p->sendBuffer) + 1; dbei.pBlob = p->sendBuffer; db_event_add(p->hContact, &dbei); diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index e2206515d6..6698e6c563 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -357,7 +357,7 @@ void SendQueue::logError(CMsgDialog *dat, int iSendJobIndex, const wchar_t *szEr dbei.flags = DBEF_SENT | DBEF_UTF; dbei.cbBlob = (int)iMsgLen; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.szModule = (char *)szErrMsg; dat->LogEvent(dbei); @@ -461,7 +461,7 @@ int SendQueue::ackMessage(CMsgDialog *dat, WPARAM wParam, LPARAM lParam) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = Proto_GetBaseAccountName(job.hContact); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = (int)mir_strlen(job.szSendBuffer) + 1; if (dat) @@ -548,7 +548,7 @@ int SendQueue::doSendLater(int iJobIndex, CMsgDialog *dat, MCONTACT hContact, bo dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.szModule = Proto_GetBaseAccountName(dat->m_hContact); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = szUtf; dbei.cbBlob = (int)mir_strlen(szUtf); dat->LogEvent(dbei); diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index bdc900221e..7bdbcbe36f 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -124,8 +124,8 @@ uint32_t LastMessageTimestamp(MCONTACT hContact, bool received) for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT) == received) - return dbei.timestamp; + if (dbei.eventType == EVENTTYPE_MESSAGE && dbei.bSent != received) + return dbei.getUnixtime(); } return 0; @@ -166,7 +166,7 @@ wchar_t* GetLastMessageText(MCONTACT hContact, bool received) { for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) { DB::EventInfo dbei(hDbEvent); - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT) == received) { + if (dbei.eventType == EVENTTYPE_MESSAGE && dbei.bSent != received) { wchar_t *swzMsg = dbei.getText(); StripBBCodesInPlace(swzMsg); return swzMsg; @@ -367,9 +367,9 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int DBEVENTINFO dbei = {}; if (!db_event_get(dbe, &dbei)) { if (dbei.eventType == EVENTTYPE_MESSAGE) { - dwNewTs = max(dwNewTs, dbei.timestamp); - if (dbei.timestamp > dwLastTs) { - if (dbei.flags & DBEF_SENT) dwCountOut++; + dwNewTs = max(dwNewTs, dbei.getUnixtime()); + if (dbei.getUnixtime() > dwLastTs) { + if (dbei.bSent) dwCountOut++; else dwCountIn++; } else break; diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index e26522981f..1f27050971 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -401,7 +401,7 @@ uint8_t CExImContactXML::ExportEvents() TiXmlElement *xmlEvent = _xmlDoc.NewElement("evt"); if (xmlEvent) { xmlEvent->SetAttribute("type", dbei.eventType); - xmlEvent->SetAttribute("time", (int)dbei.timestamp); + xmlEvent->SetAttribute("time", (int)dbei.getUnixtime()); xmlEvent->SetAttribute("flag", (int)dbei.flags); TiXmlText *xmlText = _xmlDoc.NewText(pBase64Data); @@ -914,8 +914,8 @@ int CExImContactXML::ImportEvent(LPCSTR pszModule, const TiXmlElement *xmlEvent) // timestamp must be valid DBEVENTINFO dbei = {}; - dbei.timestamp = xmlEvent->IntAttribute("time"); - if (dbei.timestamp == 0) + dbei.iTimestamp = xmlEvent->IntAttribute("time"); + if (dbei.iTimestamp == 0) return ERROR_INVALID_TIMESTAMP; LPCSTR tmp = xmlEvent->GetText(); diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index c6a1a05ca5..9afb7811f8 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -44,7 +44,7 @@ uint32_t WhenAdded(uint32_t dwUIN, LPCSTR) memcpy(&dwEvtUIN, dbei.pBlob, sizeof(uint32_t)); MIR_FREE(dbei.pBlob); if (dwEvtUIN == dwUIN) - return dbei.timestamp; + return dbei.getUnixtime(); } } } @@ -522,7 +522,7 @@ uint32_t TimeOf(MEVENT hEvent) { DBEVENTINFO dbei; if (!GetInfo(hEvent, &dbei)) - return dbei.timestamp; + return dbei.getUnixtime(); return 0; } @@ -541,7 +541,7 @@ uint32_t TimeOf(MEVENT hEvent) bool __forceinline IsEqual(const DBEVENTINFO *d1, const DBEVENTINFO *d2, bool Data) { bool res = d1 && d2 && - (d1->timestamp == d2->timestamp) && + (d1->getUnixtime() == d2->getUnixtime()) && (d1->eventType == d2->eventType) && (d1->cbBlob == d2->cbBlob) && (!d1->szModule || !d2->szModule || !_stricmp(d1->szModule, d2->szModule)); @@ -574,7 +574,7 @@ bool Exists(MCONTACT hContact, MEVENT& hDbExistingEvent, DBEVENTINFO *dbei) hDbExistingEvent = db_event_first(hContact); if (hDbExistingEvent) { if (!GetInfo(hDbExistingEvent, &edbei)) { - if ((dbei->timestamp < edbei.timestamp)) + if ((dbei->getUnixtime() < edbei.getUnixtime())) return false; if (IsEqual(dbei, &edbei, false)) { @@ -596,7 +596,7 @@ bool Exists(MCONTACT hContact, MEVENT& hDbExistingEvent, DBEVENTINFO *dbei) } if (hDbExistingEvent) { MEVENT sdbe = hDbExistingEvent; - for (MEVENT edbe = sdbe; edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp <= edbei.timestamp); edbe = db_event_prev(hContact, edbe)) { + for (MEVENT edbe = sdbe; edbe && !GetInfo(edbe, &edbei) && (dbei->getUnixtime() <= edbei.getUnixtime()); edbe = db_event_prev(hContact, edbe)) { hDbExistingEvent = edbe; //compare without data (faster) if ( result = IsEqual(dbei, &edbei, false)) { @@ -612,7 +612,7 @@ bool Exists(MCONTACT hContact, MEVENT& hDbExistingEvent, DBEVENTINFO *dbei) } /*end for*/ if (!result) { - for (MEVENT edbe = db_event_next(hContact, sdbe); edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp >= edbei.timestamp); edbe = db_event_next(hContact, edbe)) { + for (MEVENT edbe = db_event_next(hContact, sdbe); edbe && !GetInfo(edbe, &edbei) && (dbei->getUnixtime() >= edbei.getUnixtime()); edbe = db_event_next(hContact, edbe)) { hDbExistingEvent = edbe; //compare without data (faster) if (result = IsEqual(dbei, &edbei, false)) { diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 845dfc33ae..7e87c23ec5 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -442,9 +442,9 @@ static MEVENT findDbEvent(MCONTACT hContact, MEVENT hDbEvent, int flags) hSearchEvent = findDbEvent(hSearchContact, NULL, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { - if ((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) { + if ((dbe.getUnixtime() < matchTimestamp) || (matchTimestamp == 0)) { hMatchEvent = hSearchEvent; - matchTimestamp = dbe.timestamp; + matchTimestamp = dbe.getUnixtime(); } } } @@ -455,9 +455,9 @@ static MEVENT findDbEvent(MCONTACT hContact, MEVENT hDbEvent, int flags) hSearchEvent = findDbEvent(hSearchContact, NULL, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { - if ((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) { + if ((dbe.getUnixtime() > matchTimestamp) || (matchTimestamp == 0)) { hMatchEvent = hSearchEvent; - matchTimestamp = dbe.timestamp; + matchTimestamp = dbe.getUnixtime(); } } } @@ -466,14 +466,14 @@ static MEVENT findDbEvent(MCONTACT hContact, MEVENT hDbEvent, int flags) else if (flags & DBE_NEXT) { dbe.cbBlob = 0; if (!db_event_get(hDbEvent, &dbe)) { - priorTimestamp = dbe.timestamp; + priorTimestamp = dbe.getUnixtime(); for (auto &hSearchContact : Contacts()) { hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { - if (((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp > priorTimestamp)) { + if (((dbe.getUnixtime() < matchTimestamp) || (matchTimestamp == 0)) && (dbe.getUnixtime() > priorTimestamp)) { hMatchEvent = hSearchEvent; - matchTimestamp = dbe.timestamp; + matchTimestamp = dbe.getUnixtime(); } } } @@ -482,14 +482,14 @@ static MEVENT findDbEvent(MCONTACT hContact, MEVENT hDbEvent, int flags) } else if (flags & DBE_PREV) { if (!db_event_get(hDbEvent, &dbe)) { - priorTimestamp = dbe.timestamp; + priorTimestamp = dbe.getUnixtime(); for (auto &hSearchContact : Contacts()) { hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { - if (((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp < priorTimestamp)) { + if (((dbe.getUnixtime() > matchTimestamp) || (matchTimestamp == 0)) && (dbe.getUnixtime() < priorTimestamp)) { hMatchEvent = hSearchEvent; - matchTimestamp = dbe.timestamp; + matchTimestamp = dbe.getUnixtime(); } } } diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index 75ead98cc7..876f6a30a0 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -65,7 +65,7 @@ int ProtoAck(WPARAM,LPARAM lparam) DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; - dbei.timestamp = ltime; + dbei.iTimestamp = ltime; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (uint32_t)mir_strlen(p->msgText) + 1; @@ -118,7 +118,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) return 0; // get time and date - time_t tTime = dbei.timestamp; + time_t tTime = dbei.getUnixtime(); tm *tm_time = gmtime(&tTime); // build a message diff --git a/protocols/CloudFile/src/utils.cpp b/protocols/CloudFile/src/utils.cpp index 755746f197..90832cb861 100644 --- a/protocols/CloudFile/src/utils.cpp +++ b/protocols/CloudFile/src/utils.cpp @@ -27,7 +27,7 @@ MEVENT AddEventToDb(MCONTACT hContact, uint16_t type, uint32_t flags, uint32_t c { DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.eventType = type; dbei.cbBlob = cbBlob; dbei.pBlob = pBlob; diff --git a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp index 3b11bf4700..c4cfc69800 100644 --- a/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp +++ b/protocols/CurrencyRates/src/CurrencyRatesProviderBase.cpp @@ -375,7 +375,7 @@ void log_to_history(const ICurrencyRatesProvider *pProvider, MCONTACT hContact, DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; - dbei.timestamp = static_cast(nTime); + dbei.iTimestamp = static_cast(nTime); dbei.flags = DBEF_READ | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (int)::mir_strlen(psz) + 1; diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 1d4209715f..564e58f623 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -529,7 +529,7 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) debugLogA("store a message from private user %lld, channel id %lld", pUser->id, pUser->channelId); - dbei.timestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring()); + dbei.iTimestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring()); dbei.szId = szMsgId; replaceStr(dbei.pBlob, mir_utf8encodeW(wszText)); dbei.cbBlob = (int)mir_strlen(dbei.pBlob); diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index beef589e30..dae31e4c16 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -103,7 +103,7 @@ void CDiscordProto::OnReceiveHistory(MHttpResponse *pReply, AsyncHttpRequest *pR dbei.szModule = m_szModuleName; dbei.flags = DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; - dbei.timestamp = dwTimeStamp; + dbei.iTimestamp = dwTimeStamp; if (authorid == m_ownId) dbei.flags |= DBEF_SENT; diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index ce5a88ae58..af272db097 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -380,7 +380,7 @@ CMStringW CDiscordProto::PrepareMessageText(const JSONNode &pRoot, CDiscordUser DB::EventInfo dbei(db_event_getById(m_szModuleName, szId)); dbei.flags = DBEF_TEMPORARY; - dbei.timestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring()); + dbei.iTimestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring()); dbei.szId = szId; dbei.szUserId = szUserId; if (_atoi64(szUserId) == m_ownId) @@ -479,7 +479,7 @@ void CDiscordProto::ProcessType(CDiscordUser *pUser, const JSONNode &pRoot) DB::AUTH_BLOB blob(pUser->hContact, T2Utf(pUser->wszUsername), nullptr, nullptr, szId, nullptr); DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.cbBlob = blob.size(); dbei.pBlob = blob; ProtoChainRecv(pUser->hContact, PSR_AUTH, 0, (LPARAM)&dbei); diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index 662df2d566..48b170794c 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -267,7 +267,7 @@ void CMLan::OnRecvPacket(u_char *mes, int len, in_addr from) RequestStatus(true, from.S_un.S_addr); else { DB::EventInfo dbei; - dbei.timestamp = get_time(); + dbei.iTimestamp = get_time(); dbei.pBlob = pak.strMessage; ProtoChainRecvMsg(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), dbei); @@ -286,7 +286,7 @@ void CMLan::OnRecvPacket(u_char *mes, int len, in_addr from) if (pak.strAwayMessage && cont) { DB::EventInfo dbei; - dbei.timestamp = get_time(); + dbei.iTimestamp = get_time(); dbei.pBlob = pak.strAwayMessage; dbei.cbBlob = pak.idAckAwayMessage; ProtoChainRecv(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), PSR_AWAYMSG, 0, (LPARAM)&dbei); @@ -966,7 +966,7 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock) *pf_to++ = *pf_fr++; conn->m_hContact = FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status); - dbei.timestamp = get_time(); + dbei.iTimestamp = get_time(); ProtoChainRecv(conn->m_hContact, PSR_FILE, 0, (LPARAM)&dbei); while (!conn->m_state) diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 166256c9e1..f660fee8bd 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -845,7 +845,7 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) auto szActorFbId(metadata["actorFbId"].as_string()); DB::EventInfo dbei; - dbei.timestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000); + dbei.iTimestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000); dbei.pBlob = (char *)szBody.c_str(); dbei.szId = (char *)szId.c_str(); if (m_uid == _atoi64(szActorFbId.c_str())) @@ -952,10 +952,10 @@ void FacebookProto::OnPublishReadReceipt(const JSONNode &root) if (!dbei) continue; - if (dbei.timestamp > timestamp) + if (dbei.getUnixtime() > timestamp) break; - if (dbei.flags & DBEF_SENT) + if (dbei.bSent) dbei.wipeNotify(); } } diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 6a84c1b251..dbb76cd5fa 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -824,7 +824,7 @@ retry: else if (!e->event.msg.recipients_count && e->event.msg.message && *e->event.msg.message && mir_strcmp(e->event.msg.message, "\xA0\0")) { DB::EventInfo dbei; time_t t = time(0); - dbei.timestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; + dbei.iTimestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time; dbei.pBlob = e->event.msg.message; ProtoChainRecvMsg(getcontact(e->event.msg.sender, 1, 0, nullptr), dbei); } @@ -893,7 +893,7 @@ retry: { DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.timestamp = (uint32_t)e->event.multilogon_msg.time; + dbei.iTimestamp = (uint32_t)e->event.multilogon_msg.time; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (uint32_t)mir_strlen(e->event.multilogon_msg.message) + 1; @@ -1027,7 +1027,7 @@ retry: const char *fileName = (const char*)dcc7->filename; DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvFile((UINT_PTR)dcc7->contact, DB::FILE_BLOB(dcc7, fileName, fileName), dbei); e->event.dcc7_new = nullptr; diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index 9377736402..cc6bb1121c 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -368,7 +368,7 @@ void __cdecl GaduProto::dccmainthread(void*) const char *pszFileName = (const char *)m_dcc->file_info.filename; DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); gg_LeaveCriticalSection(&ft_mutex, "dccmainthread", 37, 7, "ft_mutex", 1); ProtoChainRecvFile((UINT_PTR)local_dcc->contact, DB::FILE_BLOB(local_dcc, pszFileName, pszFileName), dbei); diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 79ffd36e22..89027f1e1e 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -867,7 +867,7 @@ int GaduProto::img_displayasmsg(MCONTACT hContact, void *img) T2Utf szMessage(image_msg); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = szMessage; ProtoChainRecvMsg(hContact, dbei); debugLogW(L"img_displayasmsg(): Image saved to %s.", szPath); diff --git a/protocols/GmailNotifier/src/notify.cpp b/protocols/GmailNotifier/src/notify.cpp index cd4ed69fb9..536bd7f0eb 100644 --- a/protocols/GmailNotifier/src/notify.cpp +++ b/protocols/GmailNotifier/src/notify.cpp @@ -145,7 +145,7 @@ void NotifyUser(Account *curAcc) dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_READ; dbei.szModule = MODULENAME; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); resultLink *prst = curAcc->results.next; for (int i = 0; i < newMails; i++) { diff --git a/protocols/ICQCorp/src/protocol.cpp b/protocols/ICQCorp/src/protocol.cpp index 576bf6eb76..25fa81c8f2 100644 --- a/protocols/ICQCorp/src/protocol.cpp +++ b/protocols/ICQCorp/src/protocol.cpp @@ -1985,7 +1985,7 @@ void ICQ::addMessage(ICQUser *u, char *m, time_t t) Netlib_Logf(hNetlibUser, "message: %s\n", m); DB::EventInfo dbei; - dbei.timestamp = t; + dbei.iTimestamp = t; dbei.pBlob = m; ProtoChainRecvMsg(u->hContact, dbei); } @@ -1997,7 +1997,7 @@ void ICQ::addAwayMsg(ICQUser *u, char *m, unsigned long theSequence, time_t t) Netlib_Logf(hNetlibUser, "away msg: %s\n", m); DB::EventInfo dbei; - dbei.timestamp = t; + dbei.iTimestamp = t; dbei.pBlob = m; dbei.cbBlob = theSequence; @@ -2019,7 +2019,7 @@ void ICQ::addFileReq(ICQUser *u, char *m, char *filename, unsigned long size, un DB::FILE_BLOB blob(transfer, filename, m); DB::EventInfo dbei; - dbei.timestamp = t; + dbei.iTimestamp = t; blob.write(dbei); CCSDATA ccs = { u->hContact, PSR_FILE, 0, (LPARAM)&dbei }; diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 4daf29d855..9ad4727601 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -226,7 +226,7 @@ int CIrcProto::AddOutgoingMessageToDB(MCONTACT hContact, const wchar_t *msg) DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; dbei.eventType = EVENTTYPE_MESSAGE; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.flags = DBEF_SENT | DBEF_UTF; dbei.pBlob = mir_utf8encodeW(S); dbei.cbBlob = (uint32_t)mir_strlen((char*)dbei.pBlob) + 1; @@ -700,7 +700,7 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage *pmsg) T2Utf utf(mess); DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.pBlob = utf; setWString(hContact, "User", pmsg->prefix.sUser); setWString(hContact, "Host", pmsg->prefix.sHost); @@ -1147,7 +1147,7 @@ bool CIrcProto::IsCTCP(const CIrcMessage *pmsg) setWString(hContact, "Host", pmsg->prefix.sHost); DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); ProtoChainRecvFile(hContact, DB::FILE_BLOB(di, T2Utf(sFile)), dbei); } } diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 2861324bb0..281812c903 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -1275,7 +1275,7 @@ void CDccSession::DoChatReceive() if (*pStart) { // send it off to some messaging module DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.pBlob = pStart; ProtoChainRecvMsg(di->hContact, dbei); } diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp index 994f48a840..dde2369d4e 100644 --- a/protocols/JabberG/src/jabber_archive.cpp +++ b/protocols/JabberG/src/jabber_archive.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. bool operator==(const DBEVENTINFO &ev1, const DBEVENTINFO &ev2) { - return ev1.timestamp == ev2.timestamp && ev1.eventType == ev2.eventType && ev1.cbBlob == ev2.cbBlob && (ev1.flags & DBEF_SENT) == (ev2.flags & DBEF_SENT); + return ev1.iTimestamp == ev2.iTimestamp && ev1.eventType == ev2.eventType && ev1.cbBlob == ev2.cbBlob && ev1.bSent == ev2.bSent; } void CJabberProto::EnableArchive(bool bEnable) @@ -117,9 +117,9 @@ void CJabberProto::OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIq msg.process(); - tmStart = msg.dbei.timestamp; - if (msg.dbei.timestamp > tmLast) - tmLast = msg.dbei.timestamp; + tmStart = msg.dbei.getUnixtime(); + if (msg.dbei.getUnixtime() > tmLast) + tmLast = msg.dbei.getUnixtime(); } if (tmLast != 0) diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index bd04905ccd..c43f1509d7 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -177,7 +177,7 @@ void CJabberProto::FileProcessHttpDownload(MCONTACT hContact, const char *jid, c DB::EventInfo dbei; dbei.flags = DBEF_TEMPORARY; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, szName, pszDescr), dbei); } diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index da6cd6425f..97299e6b5d 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -467,7 +467,7 @@ void CJabberProto::FtHandleSiRequest(const TiXmlElement *iqNode) ft->std.totalBytes = ft->std.currentFileSize = filesize; DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, filename, XmlGetChildText(fileNode, "desc")), dbei); return; } @@ -874,7 +874,7 @@ bool CJabberProto::FtTryInlineFile(filetransfer *ft) DB::EventInfo dbei; dbei.flags = DBEF_READ | DBEF_SENT; dbei.pBlob = szMsg.GetBuffer(); - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvMsg(ft->std.hContact, dbei); return true; } diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index d99cabebd4..ede6e546a1 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -324,7 +324,7 @@ bool CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo) str2 = ft->httpPath; DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, str2, desc), dbei); } else { // reject diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index d841716ab2..b50829a943 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -53,7 +53,7 @@ void CJabberProto::DBAddAuthRequest(const char *jid, const char *nick) DB::AUTH_BLOB blob(hContact, nick, nullptr, nullptr, jid, nullptr); DB::EventInfo dbei; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.cbBlob = blob.size(); dbei.pBlob = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei); @@ -126,7 +126,7 @@ bool CJabberProto::AddDbPresenceEvent(MCONTACT hContact, uint8_t btEventType) dbei.cbBlob = sizeof(btEventType); dbei.eventType = EVENTTYPE_JABBER_PRESENCE; dbei.flags = DBEF_READ; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.szModule = m_szModuleName; db_event_add(hContact, &dbei); return true; @@ -500,7 +500,7 @@ void CJabberProto::OnGetBob(const TiXmlElement *node, CJabberIqInfo *pReq) wszFileName.Insert(0, L"[img]"); wszFileName.Append(L"[/img]"); T2Utf szMsg(wszFileName); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = szMsg; ProtoChainRecvMsg(pReq->GetHContact(), dbei); } diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index c9956dda17..e87414d68f 100644 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1405,7 +1405,7 @@ bool CJabberProto::OmemoHandleMessage(XmppMsg *msg, const TiXmlElement *node, co DBEVENTINFO dbei = {}; dbei.szModule = Proto_GetBaseAccountName(hContact); - dbei.timestamp = msgTime; + dbei.iTimestamp = msgTime; dbei.eventType = EVENTTYPE_FILE; if (trusted) dbei.flags = DBEF_SECURE; diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index 7e9800b1c2..e273d169fe 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -450,7 +450,7 @@ int CJabberProto::RcGetUnreadEventsCount() for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DB::EventInfo dbei(hDbEvent); - if (dbei && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) { + if (dbei && dbei.eventType == EVENTTYPE_MESSAGE && !dbei.bRead && !dbei.bSent) { ptrW szEventText(dbei.getText()); if (szEventText) nEventsSent++; @@ -549,7 +549,7 @@ int CJabberProto::AdhocForwardHandler(const TiXmlElement*, CJabberIqInfo *pInfo, addressesNode << XCHILD("address") << XATTR("type", "ofrom") << XATTR("jid", szOFrom); addressesNode << XCHILD("address") << XATTR("type", "oto") << XATTR("jid", m_ThreadInfo->fullJID); - time_t ltime = (time_t)dbei.timestamp; + time_t ltime = dbei.getUnixtime(); struct tm *gmt = gmtime(<ime); char stime[512]; mir_snprintf(stime, "%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 3dd0b1d547..12106c3552 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1021,7 +1021,7 @@ uint32_t JabberGetLastContactMessageTime(MCONTACT hContact) return 0; DB::EventInfo dbei(hDbEvent, false); - return (dbei) ? dbei.timestamp : 0; + return (dbei) ? dbei.getUnixtime() : 0; } MCONTACT CJabberProto::CreateTemporaryContact(const char *szJid, JABBER_LIST_ITEM *chatItem) @@ -1175,7 +1175,7 @@ void CJabberProto::XmppMsg::handle_chatstates() _dbei.cbBlob = 1; _dbei.eventType = EVENTTYPE_JABBER_CHATSTATES; _dbei.flags = DBEF_READ; - _dbei.timestamp = time(0); + _dbei.iTimestamp = time(0); _dbei.szModule = m_proto->m_szModuleName; db_event_add(hContact, &_dbei); } @@ -1463,7 +1463,7 @@ void CJabberProto::XmppMsg::add_to_db() if (bWasSent) dbei.flags |= DBEF_SENT; - dbei.timestamp = (uint32_t)msgTime; + dbei.iTimestamp = (uint32_t)msgTime; dbei.pBlob = szMessage.GetBuffer(); dbei.szId = szMamMsgId; diff --git a/protocols/NewsAggregator/Src/CheckFeed.cpp b/protocols/NewsAggregator/Src/CheckFeed.cpp index b15724266c..954760298d 100644 --- a/protocols/NewsAggregator/Src/CheckFeed.cpp +++ b/protocols/NewsAggregator/Src/CheckFeed.cpp @@ -171,7 +171,7 @@ static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStr db_event_get(hDbEvent, &olddbei); // there's no need to look for the elder events - if (stamp > 0 && olddbei.timestamp < (uint32_t)stamp) + if (stamp > 0 && olddbei.getUnixtime() < (uint32_t)stamp) break; if ((int)mir_strlen((char*)olddbei.pBlob) == cbOrigLen && !mir_strcmp((char*)olddbei.pBlob, pszTemp)) { @@ -188,7 +188,7 @@ static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStr T2Utf pszMessage(message); DB::EventInfo dbei; - dbei.timestamp = (uint32_t)stamp; + dbei.iTimestamp = (uint32_t)stamp; dbei.pBlob = pszMessage; ProtoChainRecvMsg(hContact, dbei); } diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp index d5c375682d..a4f662c566 100644 --- a/protocols/Sametime/src/files.cpp +++ b/protocols/Sametime/src/files.cpp @@ -37,7 +37,7 @@ void mwFileTransfer_offered(mwFileTransfer* ft) strncpy_s(description, filename, _TRUNCATE); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); ProtoChainRecvFile(hContact, DB::FILE_BLOB(ft, filename, description), dbei); } diff --git a/protocols/Sametime/src/messaging.cpp b/protocols/Sametime/src/messaging.cpp index 15650b9c6f..d960d30e51 100644 --- a/protocols/Sametime/src/messaging.cpp +++ b/protocols/Sametime/src/messaging.cpp @@ -82,7 +82,7 @@ void mwIm_conversation_recv(mwConversation* conv, mwImSendType type, gconstpoint return; DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.pBlob = (char*)msg; ProtoChainRecvMsg(hContact, dbei); } diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 4089066833..a96a25262d 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -131,7 +131,7 @@ void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*) DB::AUTH_BLOB blob(hContact, displayName.c_str(), nullptr, nullptr, skypeId.c_str(), reason.c_str()); DB::EventInfo dbei; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.cbBlob = blob.size(); dbei.pBlob = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei); diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 4861c621c3..d455eaf0e5 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -59,7 +59,7 @@ void CSkypeProto::OnGetServerHistory(MHttpResponse *response, AsyncHttpRequest * DB::EventInfo dbei(db_event_getById(m_szModuleName, szMessageId)); dbei.hContact = hContact; dbei.szModule = m_szModuleName; - dbei.timestamp = (bUseLocalTime) ? iLocalTime : IsoToUnixTime(message["composetime"].as_string()); + dbei.iTimestamp = (bUseLocalTime) ? iLocalTime : IsoToUnixTime(message["composetime"].as_string()); dbei.szId = szMessageId; if (iUserType == 19) { dbei.szUserId = szFrom; diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index d944390d5e..c108cef65d 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -119,7 +119,7 @@ LBL_Deleted: } if (strMessageType == "Text" || strMessageType == "RichText") { - if ((dbei.flags & DBEF_SENT) && dbei.szId) { + if (dbei.bSent && dbei.szId) { for (auto &it: m_OutMessages) { if (it->hClientMessageId == _atoi64(dbei.szId)) { ProtoBroadcastAck(dbei.hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)it->hMessage, (LPARAM)dbei.szId); @@ -191,7 +191,7 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) DB::EventInfo dbei(db_event_getById(m_szModuleName, szMessageId)); dbei.hContact = hContact; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.szId = szMessageId; dbei.flags = DBEF_UTF; if (IsMe(szFromSkypename)) diff --git a/protocols/Steam/src/steam_chats.cpp b/protocols/Steam/src/steam_chats.cpp index 650e1bcfe1..248233166f 100644 --- a/protocols/Steam/src/steam_chats.cpp +++ b/protocols/Steam/src/steam_chats.cpp @@ -130,7 +130,7 @@ void CSteamProto::OnGetChatHistory(const CChatRoomGetMessageHistoryResponse &rep dbei.szModule = m_szModuleName; replaceStr(dbei.pBlob, mir_strdup(pMsg->message)); dbei.cbBlob = (int)mir_strlen(dbei.pBlob); - dbei.timestamp = pMsg->server_timestamp; + dbei.iTimestamp = pMsg->server_timestamp; dbei.szId = szMsgId; dbei.szUserId = szUserId; @@ -163,7 +163,7 @@ void CSteamProto::OnGetChatMessage(const CChatRoomIncomingChatMessageNotificatio dbei.szModule = m_szModuleName; replaceStr(dbei.pBlob, mir_strdup(reply.message)); dbei.cbBlob = (int)mir_strlen(dbei.pBlob); - dbei.timestamp = reply.timestamp; + dbei.iTimestamp = reply.timestamp; dbei.szId = szMsgId; dbei.szUserId = szUserId; diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 2cdbdf4ccd..5ce9381f04 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -281,7 +281,7 @@ void CSteamProto::ContactIsAskingAuth(MCONTACT hContact) DB::AUTH_BLOB blob(hContact, nickName, firstName, lastName, steamId, reason); DB::EventInfo dbei; - dbei.timestamp = now(); + dbei.iTimestamp = now(); dbei.pBlob = blob; dbei.cbBlob = blob.size(); ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei); diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index 65c77f490c..c94a0d6b0f 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -41,9 +41,9 @@ void CSteamProto::OnGotRecentMessages(const CFriendMessagesGetRecentMessagesResp setDword(hContact, DBKEY_LASTMSG, pMsg->timestamp); dbei.szId = szMsgId; - dbei.timestamp = pMsg->timestamp; + dbei.iTimestamp = pMsg->timestamp; } - else dbei.timestamp = time(0); + else dbei.iTimestamp = time(0); if (dbei.getEvent()) db_event_edit(hEvent, &dbei, true); @@ -107,10 +107,10 @@ void CSteamProto::OnGotHistoryMessages(const CMsgClientChatGetFriendMessageHisto dbei.cbBlob = (int)mir_strlen(pMsg->message); dbei.pBlob = mir_strdup(pMsg->message); if (pMsg->has_timestamp) { - dbei.timestamp = pMsg->timestamp; + dbei.iTimestamp = pMsg->timestamp; dbei.szId = szMsgId; } - else dbei.timestamp = time(0); + else dbei.iTimestamp = time(0); if (dbei.getEvent()) db_event_edit(hEvent, &dbei, true); diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index da65a5b424..956b1a07db 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -49,7 +49,7 @@ void CSteamProto::OnGotIncomingMessage(const CFriendMessagesIncomingMessageNotif dbei.flags |= DBEF_SENT; dbei.cbBlob = (int)mir_strlen(reply.message); dbei.pBlob = reply.message; - dbei.timestamp = reply.has_rtime32_server_timestamp ? reply.rtime32_server_timestamp : time(0); + dbei.iTimestamp = reply.has_rtime32_server_timestamp ? reply.rtime32_server_timestamp : time(0); ProtoChainRecvMsg(hContact, dbei); } break; diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index f8cee175d0..7fd3eb4d92 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -304,7 +304,7 @@ int CSteamProto::OnPreCreateMessage(WPARAM, LPARAM lParam) if (!mir_strcmp(Proto_GetBaseAccountName(evt->hContact), m_szModuleName)) { mir_cslock lck(m_csOwnMessages); if (auto *pOwn = m_arOwnMessages.find((COwnMessage *)&evt->seq)) { - evt->dbei->timestamp = pOwn->timestamp; + evt->dbei->iTimestamp = pOwn->timestamp; m_arOwnMessages.remove(pOwn); } } diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index b0ce821946..d8d6f3a842 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -462,7 +462,7 @@ void CTelegramProto::ProcessFileMessage(TG_FILE_REQUEST *ft, const TD::message * dbei.szModule = Proto_GetBaseAccountName(ft->m_hContact); dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_SENT | DBEF_UTF; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); TG_FILE_REQUEST localft(TG_FILE_REQUEST::FILE, 0, 0); localft.m_fileName = Utf2T(pFile->local_->path_.c_str()); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 495d46523b..abcd38b677 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -465,7 +465,7 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p DBEVENTINFO dbei = {}; dbei.eventType = EVENTTYPE_MESSAGE; dbei.szModule = m_szModuleName; - dbei.timestamp = pMsg->date_; + dbei.iTimestamp = pMsg->date_; dbei.cbBlob = szBody.GetLength(); dbei.pBlob = szBody.GetBuffer(); dbei.szId = szMsgId; @@ -990,7 +990,7 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) DB::EventInfo dbei(hOldEvent); dbei.szId = szMsgId; dbei.cbBlob = szText.GetLength(); - dbei.timestamp = pMessage->date_; + dbei.iTimestamp = pMessage->date_; if (pMessage->is_outgoing_) dbei.flags |= DBEF_SENT; if (!pUser->bInited) diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 240322d81e..3d33b6b0c8 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -217,8 +217,7 @@ void CTelegramProto::MarkRead(MCONTACT hContact, const CMStringA &szMaxId, bool if (dbei.szId > szMaxId) break; - bool isSent = (dbei.flags & DBEF_SENT) != 0; - if (isSent != bSent) + if (dbei.bSent != bSent) continue; if (!dbei.markedRead()) @@ -462,7 +461,7 @@ bool CTelegramProto::GetMessageFile(const EmbeddedFile &F, TG_FILE_REQUEST::Type DB::EventInfo dbei(db_event_getById(m_szModuleName, F.pszId)); dbei.flags = DBEF_TEMPORARY; - dbei.timestamp = F.pMsg->date_; + dbei.iTimestamp = F.pMsg->date_; dbei.szId = F.pszId; dbei.szUserId = F.pszUser; if (F.pMsg->is_outgoing_) diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 869386523c..d5d5496135 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -235,7 +235,7 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess DB::AUTH_BLOB blob(hContact, nullptr, nullptr, nullptr, (LPCSTR)address, (LPCSTR)message); DB::EventInfo dbei; - dbei.timestamp = now(); + dbei.iTimestamp = now(); dbei.cbBlob = blob.size(); dbei.pBlob = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei); diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index 74994f6ddd..c79be54f6e 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -52,7 +52,7 @@ void CToxProto::OnFriendMessage(Tox *tox, uint32_t friendNumber, TOX_MESSAGE_TYP rawMessage[length] = 0; DB::EventInfo dbei; - dbei.timestamp = now(); + dbei.iTimestamp = now(); dbei.pBlob = rawMessage; switch (type) { case TOX_MESSAGE_TYPE_NORMAL: diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index 1b7b6e4fc3..15b11d062f 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -51,7 +51,7 @@ void CToxProto::OnFriendFile(Tox *tox, uint32_t friendNumber, uint32_t fileNumbe proto->transfers.Add(transfer); DB::EventInfo dbei; - dbei.timestamp = now(); + dbei.iTimestamp = now(); ProtoChainRecvFile(hContact, DB::FILE_BLOB(transfer, rawName), dbei); } break; diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 7b7c39bfa8..51d6859f5d 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -130,7 +130,7 @@ MEVENT CToxProto::AddEventToDb(MCONTACT hContact, uint16_t type, uint32_t timest { DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.timestamp = timestamp; + dbei.iTimestamp = timestamp; dbei.eventType = type; dbei.cbBlob = (uint32_t)cbBlob; dbei.pBlob = pBlob; diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index c5f0b48adf..34f7093a31 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -405,7 +405,7 @@ void CTwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg) dbei.cbBlob = (int)u->status.text.length() + 1; dbei.eventType = TWITTER_DB_EVENT_TYPE_TWEET; dbei.flags = DBEF_UTF; - dbei.timestamp = static_cast(u->status.time); + dbei.iTimestamp = static_cast(u->status.time); dbei.szModule = m_szModuleName; db_event_add(hContact, &dbei); } @@ -478,7 +478,7 @@ void CTwitterProto::UpdateMessages(bool pre_read) if (bIsMe) recv.flags |= PREF_SENT; recv.szMessage = const_cast(text.c_str()); - recv.timestamp = static_cast(time); + recv.iTimestamp = static_cast(time); recv.szMsgId = msgid.c_str(); MEVENT hDbEVent = (MEVENT)ProtoChainRecvMsg(hContact, &recv); diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 422026cdd1..35780ca621 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -719,7 +719,7 @@ void CVkProto::DBAddAuthRequest(const MCONTACT hContact, bool added) DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.flags = DBEF_UTF; dbei.eventType = added ? EVENTTYPE_ADDED : EVENTTYPE_AUTHREQUEST; dbei.cbBlob = blob.size(); @@ -1962,7 +1962,7 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType) DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); dbei.eventType = VK_USER_DEACTIVATE_ACTION; ptrA pszDescription(mir_utf8encode(vkDeactivateEvent[iDEIdx].szDescription)); dbei.cbBlob = (uint32_t)mir_strlen(pszDescription) + 1; @@ -1995,7 +1995,7 @@ MEVENT CVkProto::GetMessageFromDb(const char *szMessageId, time_t& tTimeStamp, C DB::EventInfo dbei(hDbEvent); wszMsg = ptrW(mir_utf8decodeW((char*)dbei.pBlob)); - tTimeStamp = dbei.timestamp; + tTimeStamp = dbei.getUnixtime(); return hDbEvent; } @@ -2023,7 +2023,7 @@ bool CVkProto::IsMessageExist(VKMessageID_t iMessageId, VKMesType vkType) if(db_event_get(hDbEvent, &dbei)) return false; - return ((vkType == vkOUT) == (bool)(dbei.flags & DBEF_SENT)); + return ((vkType == vkOUT) == dbei.bSent); } CMStringW CVkProto::UserProfileUrl(VKUserID_t iUserId) diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 4f3ed443ba..979624a17d 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -577,7 +577,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage DB::EventInfo dbei; dbei.szId = szMid; - dbei.timestamp = tMsgTime; + dbei.iTimestamp = tMsgTime; dbei.pBlob = pszBody; if (iUserId == m_iMyUserId) dbei.flags |= DBEF_SENT; diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 33b4c3cd11..be05063ca0 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -56,7 +56,7 @@ void CVkProto::AddFeedEvent(CVKNewsItem& vkNewsItem) T2Utf pszBody(vkNewsItem.wszText); DB::EventInfo dbei; - dbei.timestamp = vkNewsItem.tDate; + dbei.iTimestamp = vkNewsItem.tDate; dbei.pBlob = pszBody; if (m_vkOptions.bUseNonStandardNotifications) { @@ -868,7 +868,7 @@ void CVkProto::NewsClearHistory() while (MEVENT hDbEvent = pCursor.FetchNext()) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if (dbei.timestamp < tTime) + if (dbei.getUnixtime() < tTime) pCursor.DeleteEvent(); } } \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index a69883a117..23cbc6f821 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -116,7 +116,7 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int iNDay) while (MEVENT hDbEvent = pCursor.FetchNext()) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); - if (dbei.timestamp > tTime && dbei.eventType != VK_USER_DEACTIVATE_ACTION) + if (dbei.getUnixtime() > tTime && dbei.eventType != VK_USER_DEACTIVATE_ACTION) pCursor.DeleteEvent(); } @@ -322,7 +322,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * T2Utf pszBody(wszBody); - dbei.timestamp = tDateTime; + dbei.iTimestamp = tDateTime; dbei.pBlob = pszBody; dbei.szId = szMid; diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 3af8146ed8..03f842609f 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -60,10 +60,10 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector& vForvardEvents, continue; if (!Proto_IsProtoOnContact(dbei.hContact, m_szModuleName)) { - CMStringW wszContactName = (dbei.flags & DBEF_SENT) ? getWStringA(0, "Nick", TranslateT("Me")) : Clist_GetContactDisplayName(dbei.hContact); + CMStringW wszContactName = (dbei.bSent) ? getWStringA(0, "Nick", TranslateT("Me")) : Clist_GetContactDisplayName(dbei.hContact); wchar_t ttime[64]; - time_t tTimestamp(dbei.timestamp); + time_t tTimestamp(dbei.getUnixtime()); _locale_t locale = _create_locale(LC_ALL, ""); _wcsftime_l(ttime, _countof(ttime), TranslateT("%x at %X"), localtime(&tTimestamp), locale); _free_locale(locale); @@ -489,7 +489,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) SetInvisible(hContact); T2Utf pszBody(wszBody); - dbei.timestamp = bEdited ? tDateTime : (m_vkOptions.bUseLocalTime ? time(0) : tDateTime); + dbei.iTimestamp = bEdited ? tDateTime : (m_vkOptions.bUseLocalTime ? time(0) : tDateTime); dbei.pBlob = pszBody; if (!m_vkOptions.bShowReplyInMessage && szReplyId) { @@ -518,7 +518,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) debugLogA("CVkProto::OnReceiveMessages add attachments"); T2Utf pszAttach(wszAttachmentDescr); - dbei.timestamp = isOut ? time(0) : tDateTime; + dbei.iTimestamp = isOut ? time(0) : tDateTime; dbei.pBlob = pszAttach; dbei.szId = strcat(szMid, "_"); ProtoChainRecvMsg(hContact, dbei); diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index adb4ee0580..f462df0d7b 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -143,7 +143,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) _itoa(iMessageId, szMid, 10); T2Utf pszMsg(wszMsg); - dbei.timestamp = tDateTime; + dbei.iTimestamp = tDateTime; dbei.pBlob = pszMsg; dbei.szId = szMid; ProtoChainRecvMsg(hContact, dbei); diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index fc71bfc0a7..f872d2031f 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -189,7 +189,7 @@ int UpdateWeather(MCONTACT hContact) DBEVENTINFO dbei = {}; dbei.szModule = MODULENAME; - dbei.timestamp = (uint32_t)time(0); + dbei.iTimestamp = (uint32_t)time(0); dbei.flags = DBEF_READ | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.pBlob = szMessage; diff --git a/protocols/WhatsApp/src/appsync.cpp b/protocols/WhatsApp/src/appsync.cpp index 145acd39f0..d293e7e177 100644 --- a/protocols/WhatsApp/src/appsync.cpp +++ b/protocols/WhatsApp/src/appsync.cpp @@ -275,7 +275,7 @@ void WhatsAppProto::ProcessHistorySync(const Wa__HistorySync *pSync) auto *key = pMessage->message->key; DB::EventInfo dbei; - dbei.timestamp = pMessage->message->messagetimestamp; + dbei.iTimestamp = pMessage->message->messagetimestamp; dbei.pBlob = szMessageText.GetBuffer(); dbei.szId = key->id; dbei.flags = DBEF_READ; diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp index 199b7b16fa..008452a7d9 100644 --- a/protocols/WhatsApp/src/message.cpp +++ b/protocols/WhatsApp/src/message.cpp @@ -212,7 +212,7 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg) // for chats & group chats store message in profile if (type.bPrivateChat || type.bGroupChat) { DB::EventInfo dbei; - dbei.timestamp = timestamp; + dbei.iTimestamp = timestamp; dbei.pBlob = szMessageText.GetBuffer(); dbei.szId = msgId; if (type.bOffline) 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); diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index f9e468246b..168ac45746 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -704,7 +704,7 @@ void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent) else gce.pszNick.w = wszUserId; gce.pszText.w = wszText; - gce.time = dbei.timestamp; + gce.time = dbei.getUnixtime(); gce.hEvent = hDbEvent; Chat_Event(&gce); } diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index 538350c3be..ac3c9085cb 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -537,10 +537,10 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) DBEVENTINFO dbeiExisting = {}; db_event_get(hExistingDbEvent, &dbeiExisting); - uint32_t dwEventTimeStamp = dbeiExisting.timestamp; + uint32_t dwEventTimeStamp = dbeiExisting.getUnixtime(); // compare with last timestamp - if (dbei.timestamp > dwEventTimeStamp) { + if (dbei.getUnixtime() > dwEventTimeStamp) { // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dwEventTimeStamp; @@ -559,21 +559,21 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); - dwEventTimeStamp = dbeiExisting.timestamp; + dwEventTimeStamp = dbeiExisting.getUnixtime(); // compare with first timestamp - if (dbei.timestamp <= dwEventTimeStamp) { + if (dbei.getUnixtime() <= dwEventTimeStamp) { // remember event dwPreviousTimeStamp = dwEventTimeStamp; hPreviousDbEvent = hExistingDbEvent; - if (dbei.timestamp != dwEventTimeStamp) + if (dbei.getUnixtime() != dwEventTimeStamp) return false; } } // check for equal timestamps - if (dbei.timestamp == dwPreviousTimeStamp) { + if (dbei.iTimestamp == dwPreviousTimeStamp) { memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hPreviousDbEvent, &dbeiExisting); @@ -586,10 +586,10 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); - if (dbeiExisting.timestamp != dwPreviousTimeStamp) { + if (dbeiExisting.getUnixtime() != dwPreviousTimeStamp) { // use found event hPreviousDbEvent = hExistingDbEvent; - dwPreviousTimeStamp = dbeiExisting.timestamp; + dwPreviousTimeStamp = dbeiExisting.getUnixtime(); break; } @@ -600,16 +600,16 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) hExistingDbEvent = hPreviousDbEvent; - if (dbei.timestamp <= dwPreviousTimeStamp) { + if (dbei.getUnixtime() <= dwPreviousTimeStamp) { // look back while (hExistingDbEvent != 0) { memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); - if (dbei.timestamp > dbeiExisting.timestamp) { + if (dbei.getUnixtime() > dbeiExisting.getUnixtime()) { // remember event hPreviousDbEvent = hExistingDbEvent; - dwPreviousTimeStamp = dbeiExisting.timestamp; + dwPreviousTimeStamp = dbeiExisting.getUnixtime(); return false; } @@ -617,7 +617,7 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) if (dbei == dbeiExisting) { // remember event hPreviousDbEvent = hExistingDbEvent; - dwPreviousTimeStamp = dbeiExisting.timestamp; + dwPreviousTimeStamp = dbeiExisting.getUnixtime(); return true; } @@ -631,10 +631,10 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); - if (dbei.timestamp < dbeiExisting.timestamp) { + if (dbei.getUnixtime() < dbeiExisting.getUnixtime()) { // remember event hPreviousDbEvent = hExistingDbEvent; - dwPreviousTimeStamp = dbeiExisting.timestamp; + dwPreviousTimeStamp = dbeiExisting.getUnixtime(); return false; } @@ -642,7 +642,7 @@ MIR_APP_DLL(bool) DB::IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei) if (dbei == dbeiExisting) { // remember event hPreviousDbEvent = hExistingDbEvent; - dwPreviousTimeStamp = dbeiExisting.timestamp; + dwPreviousTimeStamp = dbeiExisting.getUnixtime(); return true; } diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index 5dddd4a952..97323e5efb 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -174,7 +174,7 @@ static int SRFileEventDeleted(WPARAM hContact, LPARAM hDbEvent) GetContactSentFilesDir(hContact, wszReceiveFolder, _countof(wszReceiveFolder)); // we don't remove sent files, located outside Miranda's folder for sent offline files - if ((dbei.flags & DBEF_SENT) == 0 || !wcsnicmp(pwszName, wszReceiveFolder, wcslen(wszReceiveFolder))) + if (!dbei.bSent || !wcsnicmp(pwszName, wszReceiveFolder, wcslen(wszReceiveFolder))) DeleteFileW(pwszName); } } @@ -209,9 +209,9 @@ INT_PTR openRecDir(WPARAM, LPARAM) MEVENT Proto_RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) { - bool bSilent = (dbei.flags & DBEF_TEMPORARY) != 0; - bool bSent = (dbei.flags & DBEF_SENT) != 0; - bool bRead = (dbei.flags & DBEF_READ) != 0; + bool bSilent = dbei.bTemporary; + bool bSent = dbei.bSent; + bool bRead = dbei.bRead; dbei.szModule = Proto_GetBaseAccountName(hContact); dbei.eventType = EVENTTYPE_FILE; diff --git a/src/mir_app/src/filerecvdlg.cpp b/src/mir_app/src/filerecvdlg.cpp index 1bdf5c6179..46dac31cca 100644 --- a/src/mir_app/src/filerecvdlg.cpp +++ b/src/mir_app/src/filerecvdlg.cpp @@ -253,7 +253,7 @@ public: SetDlgItemText(m_hwnd, IDC_MSG, blob.getDescr()); wchar_t datetimestr[64]; - TimeZone_PrintTimeStamp(NULL, dbei.timestamp, L"t d", datetimestr, _countof(datetimestr), 0); + TimeZone_PrintTimeStamp(NULL, dbei.getUnixtime(), L"t d", datetimestr, _countof(datetimestr), 0); SetDlgItemText(m_hwnd, IDC_DATE, datetimestr); ptrW info(Contact::GetInfo(CNF_UNIQUEID, dat->hContact)); diff --git a/src/mir_app/src/filexferdlg.cpp b/src/mir_app/src/filexferdlg.cpp index 604a14f977..d946f4c65f 100644 --- a/src/mir_app/src/filexferdlg.cpp +++ b/src/mir_app/src/filexferdlg.cpp @@ -596,7 +596,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dbei.szModule = Proto_GetBaseAccountName(dat->hContact); dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_SENT | DBEF_UTF; - dbei.timestamp = time(0); + dbei.iTimestamp = time(0); DB::FILE_BLOB blob(dat->szFilenames, dat->szMsg); if (auto *pa = Proto_GetAccount(ack->szModule)) diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 88c470aa90..5407755e30 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -838,7 +838,7 @@ void CSrmmBaseDialog::UpdateChatLog() for (MEVENT hDbEvent = m_hDbEventFirst; hDbEvent; hDbEvent = db_event_next(m_hContact, hDbEvent)) { DB::EventInfo dbei(hDbEvent); if (dbei && !mir_strcmp(szProto, dbei.szModule) && g_chatApi.DbEventIsShown(dbei) && dbei.szUserId) { - if (iHistoryMode == LOADHISTORY_UNREAD && (dbei.flags & DBEF_READ) != 0) + if (iHistoryMode == LOADHISTORY_UNREAD && dbei.bRead) continue; Utf2T wszUserId(dbei.szUserId); @@ -848,7 +848,7 @@ void CSrmmBaseDialog::UpdateChatLog() gce.dwFlags = GCEF_ADDTOLOG; gce.pszUserInfo.w = wszUserId; gce.pszText.w = wszText; - gce.time = dbei.timestamp; + gce.time = dbei.getUnixtime(); gce.hEvent = hDbEvent; if (USERINFO *ui = g_chatApi.UM_FindUser(m_si, wszUserId)) diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp index 396abbed6f..54dfe980f3 100644 --- a/src/mir_app/src/srmm_log_rtf.cpp +++ b/src/mir_app/src/srmm_log_rtf.cpp @@ -334,7 +334,7 @@ static bool CreateRtfFromDbEvent(RtfLogStreamData *dat) if (!dat->pLog->CreateRtfEvent(dat, dbei)) return false; - if (!(dbei.flags & DBEF_SENT)) { + if (!dbei.bSent) { if (dbei.isSrmm()) dat->pLog->GetDialog().MarkEventRead(dbei); diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index 78500bed71..f7e485a2b4 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -179,7 +179,7 @@ void GetContactSentFilesDir(MCONTACT hContact, wchar_t *szDir, int cchDir) static void GenerateLocalName(const DB::EventInfo &dbei, DB::FILE_BLOB &blob, MCONTACT hContact) { wchar_t wszReceiveFolder[MAX_PATH]; - if (dbei.flags & DBEF_SENT) // don't mix sent & received files + if (dbei.bSent) // don't mix sent & received files GetContactSentFilesDir(hContact, wszReceiveFolder, _countof(wszReceiveFolder)); else File::GetReceivedFolder(hContact, wszReceiveFolder, _countof(wszReceiveFolder), true); @@ -227,7 +227,7 @@ void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, DB::EventInfo &dbei OFDTHREAD *ofd = new OFDTHREAD(hContact, hDbEvent, blob.getLocalName(), iCommand); ofd->bLocked = true; - ofd->dwTimestamp = dbei.timestamp; + ofd->dwTimestamp = dbei.getUnixtime(); ofd->pCallback = callback.release(); CallProtoService(dbei.szModule, PS_OFFLINEFILE, (WPARAM)ofd); } -- cgit v1.2.3