diff options
author | George Hazan <ghazan@miranda.im> | 2022-11-14 20:04:02 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-11-14 20:04:02 +0300 |
commit | 2d74ff3a09c40efda6ad6e9c6b569820776a54f1 (patch) | |
tree | a30fa0bca0c7dec52fa5b554b7eccd0993d254fa /src | |
parent | e097a96ae55208292e1800c75b6a1f7766e38964 (diff) |
basic set for storing group chat messages in a database + reusing log settings like show 10 recent messages
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 85 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 1 |
4 files changed, 49 insertions, 40 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 63ed7f47fa..8e0c4ff3ed 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -140,50 +140,16 @@ bool CMsgDialog::OnInitDialog() UpdateStatusBar();
UpdateTitle();
- NotifyEvent(MSG_WINDOW_EVT_OPEN);
+ if (m_si->pMI->bDatabase) {
+ FindFirstEvent();
+ RemakeLog();
+ }
}
else {
m_nickList.Hide();
m_splitterX.Hide();
- // This finds the first message to display, it works like shit
- m_hDbEventFirst = db_event_firstUnread(m_hContact);
- {
- DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
-
- switch (g_plugin.iLoadHistory) {
- case LOADHISTORY_COUNT:
- for (int i = g_plugin.nLoadCount; i--;) {
- MEVENT hPrevEvent = pCursor.FetchNext();
- if (hPrevEvent == 0)
- break;
-
- DBEVENTINFO dbei = {};
- m_hDbEventFirst = hPrevEvent;
- db_event_get(hPrevEvent, &dbei);
- if (!DbEventIsShown(&dbei))
- i++;
- }
- break;
-
- case LOADHISTORY_TIME:
- DBEVENTINFO dbei = {};
- if (m_hDbEventFirst == 0)
- dbei.timestamp = (uint32_t)time(0);
- else
- db_event_get(m_hDbEventFirst, &dbei);
-
- uint32_t firstTime = dbei.timestamp - 60 * g_plugin.nLoadTime;
- while (MEVENT hPrevEvent = pCursor.FetchNext()) {
- dbei.cbBlob = 0;
- db_event_get(hPrevEvent, &dbei);
- if (dbei.timestamp < firstTime)
- break;
- m_hDbEventFirst = hPrevEvent;
- }
- break;
- }
- }
+ FindFirstEvent();
bool bUpdate = false;
DB::ECPTR pCursor(DB::EventsRev(m_hContact));
@@ -1335,6 +1301,47 @@ void CMsgDialog::CloseTab() else SendMessage(m_hwndParent, WM_CLOSE, 0, 0);
}
+void CMsgDialog::FindFirstEvent()
+{
+ // This finds the first message to display, it works like shit
+ m_hDbEventFirst = db_event_firstUnread(m_hContact);
+
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
+
+ switch (g_plugin.iLoadHistory) {
+ case LOADHISTORY_COUNT:
+ for (int i = g_plugin.nLoadCount; i--;) {
+ MEVENT hPrevEvent = pCursor.FetchNext();
+ if (hPrevEvent == 0)
+ break;
+
+ DBEVENTINFO dbei = {};
+ m_hDbEventFirst = hPrevEvent;
+ db_event_get(hPrevEvent, &dbei);
+ if (!DbEventIsShown(&dbei))
+ i++;
+ }
+ break;
+
+ case LOADHISTORY_TIME:
+ DBEVENTINFO dbei = {};
+ if (m_hDbEventFirst == 0)
+ dbei.timestamp = (uint32_t)time(0);
+ else
+ db_event_get(m_hDbEventFirst, &dbei);
+
+ uint32_t firstTime = dbei.timestamp - 60 * g_plugin.nLoadTime;
+ while (MEVENT hPrevEvent = pCursor.FetchNext()) {
+ dbei.cbBlob = 0;
+ db_event_get(hPrevEvent, &dbei);
+ if (dbei.timestamp < firstTime)
+ break;
+ m_hDbEventFirst = hPrevEvent;
+ }
+ break;
+ }
+}
+
void CMsgDialog::NotifyTyping(int mode)
{
if (!m_hContact)
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index d9bc5f78dc..f21110e641 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -55,6 +55,7 @@ class CMsgDialog : public CSrmmBaseDialog friend class CTabbedWindow;
typedef CSrmmBaseDialog CSuper;
+ void FindFirstEvent();
void Init(void);
void NotifyTyping(int mode);
void SetButtonsPos(void);
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index ed4e28aa22..cab71e9849 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -81,7 +81,7 @@ SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule); SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem);
STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount);
-uint16_t TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus);
+uint16_t TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus);
BOOL UM_RemoveAll(SESSION_INFO *si);
BOOL UM_SetStatusEx(SESSION_INFO *si, const wchar_t* pszText, int flags);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index e1c3ad4596..0043df7ae6 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -190,6 +190,7 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) mi->bBkgColor = (gcr->dwFlags & GC_BKGCOLOR) != 0;
mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
+ mi->bDatabase = (gcr->dwFlags & GC_DATABASE) != 0;
mi->iMaxText = gcr->iMaxText;
mi->pszHeader = g_chatApi.Log_CreateRtfHeader();
|