diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExternalAPI/m_NewStory.h | 12 | ||||
-rw-r--r-- | plugins/NewStory/res/delivered.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewStory/res/remoteread.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewStory/res/resource.rc | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/history.h | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 38 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 14 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 93 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/history_log.cpp | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_svc.cpp | 7 | ||||
-rw-r--r-- | plugins/NewStory/src/main.cpp | 26 | ||||
-rw-r--r-- | plugins/NewStory/src/resource.h | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.cpp | 18 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.h | 2 |
15 files changed, 162 insertions, 62 deletions
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, @@ -76,6 +72,14 @@ __forceinline void NS_NotifyFileReady(const wchar_t *pwszFileName) } ///////////////////////////////////////////////////////////////////////////////////////// +// 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 // lparam = (DB::EventInfo*)dbei - event diff --git a/plugins/NewStory/res/delivered.ico b/plugins/NewStory/res/delivered.ico Binary files differnew file mode 100644 index 0000000000..4908bb7ed6 --- /dev/null +++ b/plugins/NewStory/res/delivered.ico diff --git a/plugins/NewStory/res/remoteread.ico b/plugins/NewStory/res/remoteread.ico Binary files differnew file mode 100644 index 0000000000..3e2aeed274 --- /dev/null +++ b/plugins/NewStory/res/remoteread.ico 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<SearchResult> &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<SearchResult> &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);
|