From 47b79689fcbe77ab19eb577487ef70642fa291f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 15 Oct 2024 20:00:52 +0300 Subject: =?UTF-8?q?fixes=20#4720=20(NewStory:=20=D0=B2=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B8=D1=82=D1=8C=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=BE=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?MessageState)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/win32/mir_app.lib | Bin 299976 -> 300256 bytes libs/win64/mir_app.lib | Bin 300016 -> 300296 bytes plugins/ExternalAPI/m_NewStory.h | 12 ++-- plugins/NewStory/res/delivered.ico | Bin 0 -> 1150 bytes plugins/NewStory/res/remoteread.ico | Bin 0 -> 1150 bytes plugins/NewStory/res/resource.rc | 4 ++ plugins/NewStory/src/history.h | 2 + plugins/NewStory/src/history_array.cpp | 38 +++++++------ plugins/NewStory/src/history_array.h | 14 +++-- plugins/NewStory/src/history_control.cpp | 93 +++++++++++++++++++++++++------ plugins/NewStory/src/history_control.h | 4 +- plugins/NewStory/src/history_log.cpp | 2 +- plugins/NewStory/src/history_svc.cpp | 7 +++ plugins/NewStory/src/main.cpp | 26 +++------ plugins/NewStory/src/resource.h | 2 + plugins/NewStory/src/utils.cpp | 18 ++++++ plugins/NewStory/src/utils.h | 2 + protocols/Telegram/src/server.cpp | 3 + src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/srmm_main.cpp | 27 +++++++++ src/mir_core/src/db.cpp | 6 +- 22 files changed, 198 insertions(+), 64 deletions(-) create mode 100644 plugins/NewStory/res/delivered.ico create mode 100644 plugins/NewStory/res/remoteread.ico diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 2872634966..d38bea4acc 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 31077d14f9..b77bc8357f 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/ExternalAPI/m_NewStory.h b/plugins/ExternalAPI/m_NewStory.h index ed019f42d9..8fd108fd8f 100644 --- a/plugins/ExternalAPI/m_NewStory.h +++ b/plugins/ExternalAPI/m_NewStory.h @@ -13,10 +13,6 @@ enum // result = number of total selected items NSM_SELECTITEMS = NSM_FIRST, - // wParam = (MCONTACT)hContact = database contact - // lParam = (MEVENT)hDbEvent = database event - NSM_ADDEVENT, - // NSM_SEEKTIME, @@ -75,6 +71,14 @@ __forceinline void NS_NotifyFileReady(const wchar_t *pwszFileName) CallService("NewStory/FileReady", (WPARAM)pwszFileName, 0); } +///////////////////////////////////////////////////////////////////////////////////////// +// service for refreshing downloaded files + +__forceinline void NS_NotifyRemoteRead(MCONTACT hContact, MEVENT hEvent) +{ + CallService("NewStory/RemoteRead", hContact, hEvent); +} + ///////////////////////////////////////////////////////////////////////////////////////// // event for changing NewStory menu items // wparam = (MCONTACT)hContact - contact id diff --git a/plugins/NewStory/res/delivered.ico b/plugins/NewStory/res/delivered.ico new file mode 100644 index 0000000000..4908bb7ed6 Binary files /dev/null and b/plugins/NewStory/res/delivered.ico differ diff --git a/plugins/NewStory/res/remoteread.ico b/plugins/NewStory/res/remoteread.ico new file mode 100644 index 0000000000..3e2aeed274 Binary files /dev/null and b/plugins/NewStory/res/remoteread.ico differ diff --git a/plugins/NewStory/res/resource.rc b/plugins/NewStory/res/resource.rc index 79975d36e0..470db6d250 100644 --- a/plugins/NewStory/res/resource.rc +++ b/plugins/NewStory/res/resource.rc @@ -76,6 +76,10 @@ IDI_REPLY ICON "reply.ico" IDI_NO_IMAGE PNG "no-image-ico.png" +IDI_DELIVERED ICON "delivered.ico" + +IDI_REMOTEREAD ICON "remoteread.ico" + ///////////////////////////////////////////////////////////////////////////// // // Dialog diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index d21c8be1e3..0b3bebe5d9 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -17,6 +17,8 @@ enum UM_ADD_EVENT_FILTER, UM_REMOVE_EVENT, UM_EDIT_EVENT, + UM_DELIVER_EVENT, + UM_REMOTE_READ, UM_SELECTED, diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index d4e2cf5634..b356038208 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -211,7 +211,7 @@ int ItemData::calcHeight(int width) xPos += 18; cx -= xPos; - if (m_bOfflineDownloaded != 0) // Download completed icon + if (m_bOfflineDownloaded != 0 || m_bDelivered || m_bRemoteRead) // Download completed icon cx -= 18; } @@ -559,7 +559,7 @@ void HistoryArray::addChatEvent(NewstoryListData *pOwner, SESSION_INFO *si, cons } } -bool HistoryArray::addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count) +ItemData* HistoryArray::addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count) { if (count == -1) count = MAXINT; @@ -582,27 +582,29 @@ bool HistoryArray::addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT pPrev = p.checkPrevGC(pPrev); } else pPrev = p.checkPrev(pPrev); + return &p; } - else { - DB::ECPTR pCursor(DB::Events(hContact, hEvent)); - for (int i = 0; i < count; i++) { - hEvent = pCursor.FetchNext(); - if (!hEvent) - break; - auto &p = allocateItem(); - p.pOwner = pOwner; - p.dbe.hContact = hContact; - p.dbe = hEvent; - if (isChat) { - checkGC(p, si); - pPrev = p.checkPrevGC(pPrev); - } - else pPrev = p.checkPrev(pPrev); + ItemData *pRet = nullptr; + DB::ECPTR pCursor(DB::Events(hContact, hEvent)); + for (int i = 0; i < count; i++) { + hEvent = pCursor.FetchNext(); + if (!hEvent) + break; + + auto &p = allocateItem(); + p.pOwner = pOwner; + p.dbe.hContact = hContact; + p.dbe = hEvent; + if (isChat) { + checkGC(p, si); + pPrev = p.checkPrevGC(pPrev); } + else pPrev = p.checkPrev(pPrev); + pRet = &p; } - return true; + return pRet; } void HistoryArray::addNick(ItemData &pItem, wchar_t *pwszNick) diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 3ee5eae9e3..9ac69b659d 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -12,9 +12,15 @@ CMStringW TplFormatString(int tpl, MCONTACT hContact, ItemData *item); struct ItemData { - bool m_bSelected, m_bHighlighted; - bool m_bLoaded, m_bIsResult; - bool m_bOfflineFile; + bool m_bSelected : 1; + bool m_bHighlighted : 1; + bool m_bDelivered : 1; + bool m_bRemoteRead : 1; + bool m_bNew : 1; + bool m_bLoaded : 1; + bool m_bIsResult : 1; + bool m_bOfflineFile : 1; + uint8_t m_grouping, m_bOfflineDownloaded; int savedTop, savedHeight, leftOffset; @@ -134,7 +140,7 @@ public: HistoryArray(); ~HistoryArray(); - bool addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count); + ItemData* addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count); void addChatEvent(NewstoryListData *pOwner, SESSION_INFO *si, const LOGINFO *pEvent); void addResults(NewstoryListData *pOwner, const OBJLIST &pArray); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 051c4eff5a..9e7f7c0856 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -129,10 +129,11 @@ void NewstoryListData::AddChatEvent(SESSION_INFO *si, const LOGINFO *lin) ///////////////////////////////////////////////////////////////////////////////////////// -void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount) +void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount, bool bNew) { ScheduleDraw(); - items.addEvent(this, hContact, hFirstEvent, iCount); + if (auto *p = items.addEvent(this, hContact, hFirstEvent, iCount)) + p->m_bNew = bNew; totalCount = items.getCount(); } @@ -435,6 +436,30 @@ void NewstoryListData::DeleteItems(void) ///////////////////////////////////////////////////////////////////////////////////////// +void NewstoryListData::DeliverEvent(MCONTACT hContact, MEVENT hEvent) +{ + bool isChanged = false; + + for (int i = 0; i < totalCount; i++) { + auto *pItem = GetItem(i); + if (pItem->dbe.hContact != hContact || !(pItem->dbe.flags & DBEF_SENT)) + continue; + + if (pItem->dbe.getEvent() > hEvent) + break; + + if (pItem->m_bNew && !pItem->m_bDelivered) { + pItem->m_bDelivered = true; + pItem->savedHeight = -1; + pItem->calcHeight(cachedWindowWidth); + isChanged = true; + } + } + + if (isChanged) + InvalidateRect(m_hwnd, 0, FALSE); +} + void NewstoryListData::Download(int options) { if (auto *p = LoadItem(caret)) @@ -738,7 +763,7 @@ void NewstoryListData::Paint(simpledib::dib &dib) SetBkMode(dib, TRANSPARENT); // left offset of icons & text - int xPos = 2, yPos = top + 2; + int xPos = 2, yPos = top + 2, xRight = 0; if (!bReadOnly) { HICON hIcon; @@ -782,7 +807,7 @@ void NewstoryListData::Paint(simpledib::dib &dib) // Finished icon if (pItem->m_bOfflineDownloaded != 0) { if (pItem->completed()) - DrawIconEx(dib, cachedWindowWidth - 20, yPos, g_plugin.getIcon(IDI_OK), 16, 16, 0, 0, DI_NORMAL); + DrawIconEx(dib, cachedWindowWidth - (xRight = 20), yPos, g_plugin.getIcon(IDI_OK), 16, 16, 0, 0, DI_NORMAL); else { HPEN hpn = (HPEN)SelectObject(dib, CreatePen(PS_SOLID, 4, g_colorTable[COLOR_PROGRESS].cl)); MoveToEx(dib, rc.left, rc.bottom - 4, 0); @@ -790,10 +815,16 @@ void NewstoryListData::Paint(simpledib::dib &dib) DeleteObject(SelectObject(dib, hpn)); } } + + // Delivered & remote read icons + if (pItem->m_bRemoteRead) + DrawIconEx(dib, cachedWindowWidth - (xRight = 20), yPos, g_plugin.getIcon(IDI_REMOTEREAD), 16, 16, 0, 0, DI_NORMAL); + else if (pItem->m_bDelivered) + DrawIconEx(dib, cachedWindowWidth - (xRight = 20), yPos, g_plugin.getIcon(IDI_DELIVERED), 16, 16, 0, 0, DI_NORMAL); } // draw html itself - litehtml::position clip(xPos, yPos, cachedWindowWidth - xPos, iItemHeigth); + litehtml::position clip(xPos, yPos, cachedWindowWidth - xPos - xRight, iItemHeigth); if (auto &pDoc = pItem->m_doc) { if (auto pBody = pDoc->root()->select_one("body")) { litehtml::background back = pBody->css().get_bg(); @@ -834,6 +865,18 @@ void NewstoryListData::Paint(simpledib::dib &dib) } } +void NewstoryListData::Quote() +{ + if (pMsgDlg) { + CMStringW wszText(GatherSelected(true)); + wszText.TrimRight(); + RemoveBbcodes(wszText); + pMsgDlg->SetMessageText(Srmm_Quote(wszText)); + + SetFocus(pMsgDlg->GetInput()); + } +} + void NewstoryListData::RecalcScrollBar() { if (totalCount == 0) @@ -872,16 +915,28 @@ void NewstoryListData::RecalcScrollBar() } } -void NewstoryListData::Quote() +void NewstoryListData::RemoteRead(MCONTACT hContact, MEVENT hEvent) { - if (pMsgDlg) { - CMStringW wszText(GatherSelected(true)); - wszText.TrimRight(); - RemoveBbcodes(wszText); - pMsgDlg->SetMessageText(Srmm_Quote(wszText)); + bool isChanged = false; - SetFocus(pMsgDlg->GetInput()); + for (int i = 0; i < totalCount; i++) { + auto *pItem = GetItem(i); + if (pItem->dbe.hContact != hContact || !(pItem->dbe.flags & DBEF_SENT)) + continue; + + if (pItem->dbe.getEvent() > hEvent) + break; + + if (pItem->m_bNew && !pItem->m_bRemoteRead) { + pItem->m_bRemoteRead = true; + pItem->savedHeight = -1; + pItem->calcHeight(cachedWindowWidth); + isChanged = true; + } } + + if (isChanged) + InvalidateRect(m_hwnd, 0, FALSE); } void NewstoryListData::Reply() @@ -1227,10 +1282,6 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } return TRUE; - case NSM_ADDEVENT: - data->AddEvent(wParam, lParam, 1); - break; - case NSM_SET_OPTIONS: data->bSortAscending = g_plugin.bSortAscending; data->scrollTopPixel = 0; @@ -1240,7 +1291,15 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case UM_ADD_EVENT: if (data->pMsgDlg == nullptr) - data->AddEvent(wParam, lParam, 1); + data->AddEvent(wParam, lParam, 1, true); + break; + + case UM_DELIVER_EVENT: + data->DeliverEvent(wParam, lParam); + break; + + case UM_REMOTE_READ: + data->RemoteRead(wParam, lParam); break; case UM_EDIT_EVENT: diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index ff2e8cd31e..f7fcb8b570 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -127,7 +127,7 @@ struct NewstoryListData : public MZeroedObject void onTimer_Draw(CTimer *pTimer); void AddChatEvent(SESSION_INFO *si, const LOGINFO *lin); - void AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount); + void AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount, bool bNew = false); void AddResults(const OBJLIST &results); void AddSelection(int iFirst, int iLast); bool AtBottom(void) const; @@ -140,6 +140,7 @@ struct NewstoryListData : public MZeroedObject void CopyPath(); void CopyUrl(); void DeleteItems(void); + void DeliverEvent(MCONTACT hContact, MEVENT hEvent); void Download(int iOptions); void EndEditItem(bool bAccept); void EnsureVisible(int item); @@ -168,6 +169,7 @@ struct NewstoryListData : public MZeroedObject void Paint(simpledib::dib &dib); void Quote(); void RecalcScrollBar(); + void RemoteRead(MCONTACT hContact, MEVENT hEvent); void Reply(); void ScheduleDraw(); void ScrollBottom(); diff --git a/plugins/NewStory/src/history_log.cpp b/plugins/NewStory/src/history_log.cpp index 7f1b35bb9b..4221a1a56e 100644 --- a/plugins/NewStory/src/history_log.cpp +++ b/plugins/NewStory/src/history_log.cpp @@ -81,7 +81,7 @@ public: if (!bAppend) Clear(); - m_histCtrl->AddEvent(m_pDlg.m_hContact, hDbEvent, count); + m_histCtrl->AddEvent(m_pDlg.m_hContact, hDbEvent, count, true); } void LogChatEvent(const LOGINFO &lin) override diff --git a/plugins/NewStory/src/history_svc.cpp b/plugins/NewStory/src/history_svc.cpp index a3d5dc2381..fa8771bb7f 100644 --- a/plugins/NewStory/src/history_svc.cpp +++ b/plugins/NewStory/src/history_svc.cpp @@ -51,6 +51,12 @@ static INT_PTR SvcGetSelection(WPARAM wParam, LPARAM lParam) return 0; } +static INT_PTR SvcRemoteRead(WPARAM hContact, LPARAM hEvent) +{ + SmartSendEvent(UM_REMOTE_READ, hContact, hEvent); + return 0; +} + ///////////////////////////////////////////////////////////////////////////////////////// // Module entry point @@ -58,6 +64,7 @@ void InitServices() { CreateServiceFunction("NewStory/GetSrmm", &SvcGetSrmm); CreateServiceFunction("NewStory/FileReady", &SvcFileReady); + CreateServiceFunction("NewStory/RemoteRead", &SvcRemoteRead); CreateServiceFunction("NewStory/GetCurrent", &SvcGetCurrent); CreateServiceFunction("NewStory/GetSelection", &SvcGetSelection); } diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp index 3271b9fe48..e497dce495 100644 --- a/plugins/NewStory/src/main.cpp +++ b/plugins/NewStory/src/main.cpp @@ -94,33 +94,24 @@ static IconItem icons[] = { LPGEN("Template group"), "tplgroup", IDI_TPLGROUP }, { LPGEN("Cancel edit"), "reset", IDI_RESET }, { LPGEN("Downloaded"), "downloaded", IDI_OK }, + { LPGEN("Delivered"), "delivered", IDI_DELIVERED }, + { LPGEN("Remote read"), "remoteread", IDI_REMOTEREAD }, { LPGEN("Help"), "varhelp", IDI_VARHELP } }; -static int SmartSendEvent(int iEvent, MCONTACT hContact, LPARAM lParam) +static int evtEventAdded(WPARAM hContact, LPARAM lParam) { - if (HWND hwnd = WindowList_Find(g_hNewstoryLogs, hContact)) - SendMessage(hwnd, iEvent, hContact, lParam); - - if (db_mc_isMeta(hContact)) { - // Send a message to a real contact too - MCONTACT cc = db_event_getContact(lParam); - if (cc != hContact) - if (HWND hwnd = WindowList_Find(g_hNewstoryLogs, cc)) - SendMessage(hwnd, iEvent, cc, lParam); - } - - return 0; + return SmartSendEvent(UM_ADD_EVENT, hContact, lParam); } -static int evtEventAdded(WPARAM hContact, LPARAM lParam) +static int evtEventDeleted(WPARAM hContact, LPARAM hEvent) { - return SmartSendEvent(UM_ADD_EVENT, hContact, lParam); + return (g_plugin.bDisableDelete) ? 0 : SmartSendEvent(UM_REMOVE_EVENT, hContact, hEvent); } -static int evtEventDeleted(WPARAM hContact, LPARAM lParam) +static int evtEventDelivered(WPARAM hContact, LPARAM hEvent) { - return (g_plugin.bDisableDelete) ? 0 : SmartSendEvent(UM_REMOVE_EVENT, hContact, lParam); + return SmartSendEvent(UM_DELIVER_EVENT, hContact, hEvent); } static int evtEventEdited(WPARAM hContact, LPARAM lParam) @@ -198,6 +189,7 @@ int CMPlugin::Load() HookEvent(ME_DB_EVENT_ADDED, evtEventAdded); HookEvent(ME_DB_EVENT_DELETED, evtEventDeleted); + HookEvent(ME_DB_EVENT_DELIVERED, evtEventDelivered); HookEvent(ME_DB_EVENT_EDITED, evtEventEdited); HookEvent(ME_DB_EVENT_SETJSON, evtEventEdited); HookEvent(ME_OPT_INITIALISE, OptionsInitialize); diff --git a/plugins/NewStory/src/resource.h b/plugins/NewStory/src/resource.h index f6312dcc6a..be213cd879 100644 --- a/plugins/NewStory/src/resource.h +++ b/plugins/NewStory/src/resource.h @@ -33,6 +33,8 @@ #define IDI_TIMETREE 129 #define IDI_REPLY 130 #define IDD_EMPTYHISTORY 131 +#define IDI_REMOTEREAD 132 +#define IDI_DELIVERED 133 #define IDC_USERINFO 1000 #define IDC_USERMENU 1001 #define IDC_MESSAGE 1002 diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp index 5f990fa337..f6aca92604 100644 --- a/plugins/NewStory/src/utils.cpp +++ b/plugins/NewStory/src/utils.cpp @@ -49,6 +49,24 @@ Bitmap* LoadImageFromResource(HINSTANCE hInst, int resourceId, const wchar_t *pw ///////////////////////////////////////////////////////////////////////////////////////// +int SmartSendEvent(int iEventType, MCONTACT hContact, LPARAM hEvent) +{ + if (HWND hwnd = WindowList_Find(g_hNewstoryLogs, hContact)) + SendMessage(hwnd, iEventType, hContact, hEvent); + + if (db_mc_isMeta(hContact)) { + // Send a message to a real contact too + MCONTACT cc = db_event_getContact(hEvent); + if (cc != hContact) + if (HWND hwnd = WindowList_Find(g_hNewstoryLogs, cc)) + SendMessage(hwnd, iEventType, cc, hEvent); + } + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + uint32_t toggleBit(uint32_t dw, uint32_t bit) { if (dw & bit) diff --git a/plugins/NewStory/src/utils.h b/plugins/NewStory/src/utils.h index d6bfb0ad2f..1858c34d9c 100644 --- a/plugins/NewStory/src/utils.h +++ b/plugins/NewStory/src/utils.h @@ -13,3 +13,5 @@ void UrlAutodetect(CMStringW &str); void RemoveBbcodes(CMStringW &pwszText); Bitmap* LoadImageFromResource(HINSTANCE, int, const wchar_t *); + +int SmartSendEvent(int iEvent, MCONTACT hContact, LPARAM lParam); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 191a0d5b1f..2d3062d700 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -1088,6 +1088,9 @@ void CTelegramProto::ProcessRemoteMarkRead(TD::updateChatReadOutbox *pObj) MarkRead(pUser->hContact, szMaxId, true); CallService(MS_MESSAGESTATE_UPDATE, GetRealContact(pUser), MRD_TYPE_READ); + + if (auto hEvent = db_event_getById(m_szModuleName, szMaxId)) + NS_NotifyRemoteRead(GetRealContact(pUser), hEvent); } void CTelegramProto::ProcessScopeNotification(TD::updateScopeNotificationSettings *pObj) diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 0aa5b1fe10..1f7e1d1728 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -990,3 +990,4 @@ _Proto_CanDeleteHistory@8 @1124 NONAME ?isCustom@EventInfo@DB@@QBE_NH@Z @1128 NONAME ?InsertBbcodeString@CSrmmBaseDialog@@IAEXPB_W@Z @1129 NONAME ?markRead@SESSION_INFO@@QAEX_N@Z @1130 NONAME +?Srmm_NotifyRemoteRead@@YGXII@Z @1131 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index a5f99bcaf3..ef42406121 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -990,3 +990,4 @@ Proto_CanDeleteHistory @1118 NONAME ?isCustom@EventInfo@DB@@QEBA_NH@Z @1122 NONAME ?InsertBbcodeString@CSrmmBaseDialog@@IEAAXPEB_W@Z @1123 NONAME ?markRead@SESSION_INFO@@QEAAX_N@Z @1124 NONAME +?Srmm_NotifyRemoteRead@@YAXII@Z @1125 NONAME diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp index 7b07a9c790..b8c0a4cc3c 100644 --- a/src/mir_app/src/srmm_main.cpp +++ b/src/mir_app/src/srmm_main.cpp @@ -19,6 +19,9 @@ along with this program. If not, see . #include "stdafx.h" #include "chat.h" +#include +#include + HCURSOR g_hCurHyperlinkHand; HANDLE hHookIconsChanged, hHookIconPressedEvt, hHookSrmmEvent; @@ -27,6 +30,19 @@ static HGENMENU hmiEmpty; void LoadSrmmToolbarModule(); void UnloadSrmmToolbarModule(); +///////////////////////////////////////////////////////////////////////////////////////// + +static bool g_bHasMessageState, g_bHasNewStory; + +MIR_APP_DLL(void) Srmm_NotifyRemoteRead(MCONTACT hContact, MEVENT hEvent) +{ + if (g_bHasMessageState) + CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_READ); + + if (g_bHasNewStory) + NS_NotifyRemoteRead(hContact, hEvent); +} + ///////////////////////////////////////////////////////////////////////////////////////// // Empty history service for main menu @@ -125,8 +141,19 @@ static int OnPrebuildContactMenu(WPARAM hContact, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// +static int OnModuleLoaded(WPARAM, LPARAM) +{ + g_bHasMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE); + g_bHasNewStory = ServiceExists("NewStory/FileReady"); + return 0; +} + void SrmmModulesLoaded() { + HookEvent(ME_SYSTEM_MODULELOAD, OnModuleLoaded); + HookEvent(ME_SYSTEM_MODULEUNLOAD, OnModuleLoaded); + OnModuleLoaded(0, 0); + // menu item CMenuItem mi(&g_plugin); SET_UID(mi, 0x0d4306aa, 0xe31e, 0x46ee, 0x89, 0x88, 0x3a, 0x2e, 0x05, 0xa6, 0xf3, 0xbc); diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 9527537a4d..b80528320a 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -487,8 +487,10 @@ MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent, bool bFr return 1; // we received remote mark read command - if (bFromServer) - CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_READ); + if (bFromServer) { + MIR_APP_DLL(void) Srmm_NotifyRemoteRead(MCONTACT hContact, MEVENT hEvent); + Srmm_NotifyRemoteRead(hContact, hDbEvent); + } if (!g_pCurrDb->MarkEventRead(hContact, hDbEvent)) return 1; -- cgit v1.2.3