diff options
author | George Hazan <george.hazan@gmail.com> | 2024-05-13 14:23:13 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-05-13 14:23:13 +0300 |
commit | c7d065645853b2e614e8557fa01057efaf5e6517 (patch) | |
tree | 6b5233ed788e31014e868c007ccb469ca4d64e60 | |
parent | 831bffd63776f4ffe82245cadf2b95c48cd44d38 (diff) |
DbEvent_GetTextA: unused function removed
36 files changed, 156 insertions, 189 deletions
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index e7c1d5499a..909bc1ead5 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -297,8 +297,7 @@ function DbEvent_RegisterType(et:PDBEVENTTYPEDESCR) : int; stdcall; external App function DbEvent_GetType(szModule:PAnsiChar; eventType:int) : PDBEVENTTYPEDESCR; stdcall; external AppDll;
-function DbEvent_GetTextA(dbei:PDBEVENTINFO; codepage:int) : PAnsiChar; stdcall; external AppDll;
-function DbEvent_GetTextW(dbei:PDBEVENTINFO) : PWideChar; stdcall; external AppDll;
+function DbEvent_GetText(dbei:PDBEVENTINFO) : PWideChar; stdcall; external AppDll;
function DbEvent_GetIcon(dbei:PDBEVENTINFO; flags:int) : HICON; stdcall; external AppDll;
diff --git a/include/m_database.h b/include/m_database.h index c967d6700e..1a8b5b3dd0 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -533,8 +533,7 @@ __forceinline MCONTACT DbGetAuthEventContact(DBEVENTINFO *dbei) // Function returns a pointer to a string in the required format.
// This string should be freed by a call of mir_free
-EXTERN_C MIR_APP_DLL(char*) DbEvent_GetTextA(const DBEVENTINFO *dbei, int codepage);
-EXTERN_C MIR_APP_DLL(wchar_t*) DbEvent_GetTextW(const DBEVENTINFO *dbei);
+EXTERN_C MIR_APP_DLL(wchar_t*) DbEvent_GetText(const DBEVENTINFO *dbei);
/////////////////////////////////////////////////////////////////////////////////////////
// Retrieves the event's icon
@@ -737,6 +736,7 @@ namespace DB bool isAlertable() const; // should raise SRMM window
wchar_t* getString(const char *str) const;
+ wchar_t* getText() const;
void addReaction(const char *emoji);
void delReaction(const char *emoji);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex f6f98e8974..9b35266f66 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 9f508b4622..80a84c2a02 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index d290a65c78..57ee51f9f4 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -72,7 +72,7 @@ static int MsgEventAdded(WPARAM, LPARAM hDbEvent) DBVARIANT dbv;
if (!g_plugin.getWString("Message", &dbv)) {
ltrimw(rtrimw(dbv.pwszVal));
- ptrW wszMsg(DbEvent_GetTextW(&dbei));
+ ptrW wszMsg(dbei.getText());
if (wszMsg != nullptr && wcsstr(wszMsg, dbv.pwszVal) != nullptr)
ShutdownAndStopWatcher(); /* msg with specified text recvd */
mir_free(dbv.pwszVal); /* does NULL check */
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 2be9c30110..7a5ba2f3b0 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -443,7 +443,7 @@ std::wstring HistoryEventList::GetContactId() static void GetMessageDescription(DBEVENTINFO *dbei, wchar_t* buf, int cbBuf)
{
- wchar_t *msg = DbEvent_GetTextW(dbei);
+ wchar_t *msg = DbEvent_GetText(dbei);
wcsncpy_s(buf, cbBuf, msg ? msg : TranslateT("Invalid message"), _TRUNCATE);
buf[cbBuf - 1] = 0;
mir_free(msg);
diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index 7b691a29be..0d6e1301c2 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -202,7 +202,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) if (Config.MarkAsRead)
db_event_markRead(hContact, hDbEvent);
- AnswerToContact(hContact, ptrW(DbEvent_GetTextW(&dbei)));
+ AnswerToContact(hContact, ptrW(dbei.getText()));
return 0;
}
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index e41ec820a4..4259f9226b 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1223,7 +1223,7 @@ void AddHistoryEvent(DBEVENTINFO *dbEvent, wchar_t *contact, PReply reply) TimeZone_ToString(dbEvent->timestamp, "D, s", timestamp, _countof(timestamp));
wchar_t *sender = (dbEvent->flags & DBEF_SENT) ? TranslateT("[me]") : contact;
- wchar_t *message = DbEvent_GetTextW(dbEvent);
+ wchar_t *message = DbEvent_GetText(dbEvent);
static wchar_t buffer[8192];
mir_snwprintf(buffer, L"[%S] %15s: %s", timestamp, sender, message);
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index 7d3b6d6f7f..e413ea1fe3 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -57,7 +57,7 @@ int ExtractURI(DBEVENTINFO *dbei, MEVENT hEvent, LISTELEMENT *listStart) date[0] = 0;
time[0] = 0;
- msg = DbEvent_GetTextW(dbei);
+ msg = DbEvent_GetText(dbei);
if (msg == nullptr)
return 0;
@@ -382,7 +382,7 @@ void WriteLinkList(HWND hDlg, uint8_t params, LISTELEMENT *listStart, LPCTSTR se {
DB::EventInfo dbe(actualElement->hEvent);
- ptrW msg(DbEvent_GetTextW(&dbe));
+ ptrW msg(dbe.getText());
if (wcsstr(msg, searchString))
filter3 = 1;
}
@@ -611,7 +611,7 @@ void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos) SetDlgItemTextW(hDlg, IDC_MESSAGE, L"");
DB::EventInfo dbe(hEvent);
- SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, ptrW(DbEvent_GetTextW(&dbe)));
+ SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, ptrW(dbe.getText()));
}
break;
}
diff --git a/plugins/HistoryPlusPlus/hpp_events.pas b/plugins/HistoryPlusPlus/hpp_events.pas index 35991b82fc..f1ca2ddf0b 100644 --- a/plugins/HistoryPlusPlus/hpp_events.pas +++ b/plugins/HistoryPlusPlus/hpp_events.pas @@ -525,7 +525,7 @@ begin Result := False;
msg := nil;
try
- msg := DbEvent_GetTextW(@EventInfo);
+ msg := DbEvent_GetText(@EventInfo);
Result := Assigned(msg);
except
if Assigned(msg) then mir_free(msg);
@@ -608,7 +608,7 @@ begin cp := CP_UTF8
else
cp := Hi.CodePage;
- PText := DbEvent_GetTextW(@EventInfo);
+ PText := DbEvent_GetText(@EventInfo);
if not Assigned(PText) then
PText := mir_wstrdup('');
Hi.Text := Format(TranslateUnicodeString(Hi.Text), [PText]);
diff --git a/plugins/IEHistory/src/utils.cpp b/plugins/IEHistory/src/utils.cpp index a16465d843..8508918230 100644 --- a/plugins/IEHistory/src/utils.cpp +++ b/plugins/IEHistory/src/utils.cpp @@ -141,7 +141,7 @@ SearchResult SearchHistory(MCONTACT contact, MEVENT hFirstEvent, void *searchDat switch (type) { case SEARCH_TEXT: { - ptrW data(DbEvent_GetTextW(&dbEvent)); + ptrW data(DbEvent_GetText(&dbEvent)); wchar_t *tmp = wcsstr(data, (wchar_t *)searchData); if (tmp) found = true; diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 6ea13100b7..802998a5cb 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -230,11 +230,11 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) }
if (dbei.eventType == EVENTTYPE_FILE) {
- eventData->szText.w = DbEvent_GetTextW(&dbei);
+ eventData->szText.w = dbei.getText();
eventData->iType = IEED_EVENT_FILE;
}
else if (dbei.isSrmm()) {
- eventData->szText.w = DbEvent_GetTextW(&dbei);
+ eventData->szText.w = dbei.getText();
if (dbei.eventType == EVENTTYPE_MESSAGE)
eventData->iType = IEED_EVENT_MESSAGE;
else
@@ -253,7 +253,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) eventData->iType = IEED_EVENT_SYSTEM;
}
else { // custom event
- eventData->szText.w = DbEvent_GetTextW(&dbei);
+ eventData->szText.w = dbei.getText();
eventData->iType = IEED_EVENT_MESSAGE;
}
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index f660e8f173..19e2d3aee7 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -356,7 +356,7 @@ public: flags += "r";
pRoot.push_back(JSONNode("flags", flags));
- ptrW msg(DbEvent_GetTextW(&dbei));
+ ptrW msg(dbei.getText());
if (msg)
pRoot.push_back(JSONNode("body", T2Utf(msg).get()));
diff --git a/plugins/Msg_Export/src/export.cpp b/plugins/Msg_Export/src/export.cpp index 95675786df..1d53c39269 100644 --- a/plugins/Msg_Export/src/export.cpp +++ b/plugins/Msg_Export/src/export.cpp @@ -318,7 +318,7 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF switch (dbei.eventType) { case EVENTTYPE_MESSAGE: - output += ptrW(DbEvent_GetTextW(&dbei)); + output += ptrW(dbei.getText()); break; case EVENTTYPE_FILE: diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index 4fb80b8342..a33b7f5f4c 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -157,7 +157,7 @@ static wchar_t* ShortenPreview(DB::EventInfo &dbei) if (iPreviewLimit > 500 || iPreviewLimit == 0)
iPreviewLimit = 500;
- wchar_t *buf = DbEvent_GetTextW(&dbei);
+ wchar_t *buf = dbei.getText();
if (mir_wstrlen(buf) > iPreviewLimit) {
fAddEllipsis = true;
size_t iIndex = iPreviewLimit;
@@ -294,7 +294,7 @@ static wchar_t* GetEventPreview(DB::EventInfo &dbei) // support for custom database event types
DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbei.szModule, dbei.eventType);
if (pei && pBlob) {
- comment1 = DbEvent_GetTextW(&dbei);
+ comment1 = dbei.getText();
commentFix = pei->descr;
}
else commentFix = POPUP_COMMENT_OTHER;
@@ -363,12 +363,7 @@ int PopupShow(MCONTACT hContact, MEVENT hEvent, UINT eventType) }
// get DBEVENTINFO with pBlob if preview is needed (when is test then is off)
- DB::EventInfo dbe;
- if (hEvent) {
- if ((g_plugin.bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST))
- dbe.cbBlob = -1;
- db_event_get(hEvent, &dbe);
- }
+ DB::EventInfo dbe(hEvent, g_plugin.bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST);
// retrieve correct hContact for AUTH events
if (dbe.pBlob && (eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST))
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 580234ca0d..d73e137b64 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -59,7 +59,7 @@ bool Filter::check(ItemData *item) const if (!item->fetch())
return false;
- return CheckFilter(ptrW(DbEvent_GetTextW(&item->dbe)), text);
+ return CheckFilter(ptrW(item->dbe.getText()), text);
}
return true;
@@ -370,7 +370,7 @@ void ItemData::load(bool bLoadAlways) switch (dbe.eventType) {
case EVENTTYPE_MESSAGE:
pOwner->MarkRead(this);
- wtext = DbEvent_GetTextW(&dbe);
+ wtext = dbe.getText();
break;
case EVENTTYPE_STATUSCHANGE:
@@ -427,7 +427,7 @@ void ItemData::load(bool bLoadAlways) break;
default:
- wtext = DbEvent_GetTextW(&dbe);
+ wtext = dbe.getText();
break;
}
@@ -452,7 +452,7 @@ void ItemData::load(bool bLoadAlways) str.AppendFormat(L"%s %s %s:\n", wszTime, wszNick.c_str(), TranslateT("wrote"));
- ptrW wszText(DbEvent_GetTextW(&dbei));
+ ptrW wszText(dbei.getText());
if (mir_wstrlen(wszText) > 43)
wcscpy(wszText.get() + 40, L"...");
str.Append(wszText);
diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp index e4a30e114a..b8553dc00d 100644 --- a/plugins/NewStory/src/history_dlg.cpp +++ b/plugins/NewStory/src/history_dlg.cpp @@ -159,7 +159,7 @@ class CHistoryDlg : public CDlgBase if (!dbei)
continue;
- ptrW pwszText(DbEvent_GetTextW(&dbei));
+ ptrW pwszText(dbei.getText());
if (!mir_wstrlen(pwszText))
continue;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 426ff11eab..778503d3ae 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -382,7 +382,7 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) return;
if (dbei.isSrmm()) {
- ptrW wszText(DbEvent_GetTextW(&dbei));
+ ptrW wszText(dbei.getText());
SetMessageText(Srmm_Quote(wszText));
}
}
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index f5566ea31c..9cfc82d963 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -389,7 +389,7 @@ public: }
bool bIsRtl = (dbei.flags & DBEF_RTL) != 0;
- ptrW wszText(DbEvent_GetTextW(&dbei)), wszNick;
+ ptrW wszText(dbei.getText()), wszNick;
// test contact
if (streamData->dbei == 0) {
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 7870fced95..dca1013faa 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -934,7 +934,7 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) if (szQuoted.IsEmpty()) {
DB::EventInfo dbei(hDBEvent);
if (dbei)
- szQuoted = Srmm_Quote(ptrW(DbEvent_GetTextW(&dbei)), iOutputWidth);
+ szQuoted = Srmm_Quote(ptrW(dbei.getText()), iOutputWidth);
}
}
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 143c55b36f..d3ae86f9cf 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -573,7 +573,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe if (!isSent && bIsStatusChangeEvent)
dbei.wipeNotify();
- CMStringW msg(ptrW(DbEvent_GetTextW(&dbei)));
+ CMStringW msg(ptrW(dbei.getText()));
if (msg.IsEmpty())
return false;
@@ -981,7 +981,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe if (blob.isOffline())
InsertFileLink(str, streamData->hDbEvent, blob);
else
- AppendUnicodeToBuffer(str, ptrW(DbEvent_GetTextW(&dbei)), 0);
+ AppendUnicodeToBuffer(str, ptrW(dbei.getText()), 0);
}
break;
@@ -991,7 +991,7 @@ bool CLogWindow::CreateRtfEvent(RtfLogStreamData *streamData, DB::EventInfo &dbe str.AppendChar(' ');
}
- ptrW tszText(DbEvent_GetTextW(&dbei));
+ ptrW tszText(dbei.getText());
AppendUnicodeToBuffer(str, tszText, 0);
}
break;
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 035e90cff6..54a6f9bd5e 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -173,7 +173,7 @@ wchar_t* GetLastMessageText(MCONTACT hContact, bool received) if (dbei.cbBlob == 0 || dbei.pBlob == nullptr) return nullptr; - wchar_t *buff = DbEvent_GetTextW(&dbei); + wchar_t *buff = DbEvent_GetText(&dbei); wchar_t *swzMsg = mir_wstrdup(buff); mir_free(buff); diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 7c15c9cc83..845dfc33ae 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -565,7 +565,7 @@ static wchar_t* parseDbEvent(ARGUMENTSINFO *ai) return nullptr;
DB::EventInfo dbe(hDbEvent);
- return (dbe) ? DbEvent_GetTextW(&dbe) : nullptr;
+ return (dbe) ? dbe.getText() : nullptr;
}
static wchar_t* parseTranslate(ARGUMENTSINFO *ai)
diff --git a/plugins/wbOSD/src/events.cpp b/plugins/wbOSD/src/events.cpp index a408f69655..9083460d92 100644 --- a/plugins/wbOSD/src/events.cpp +++ b/plugins/wbOSD/src/events.cpp @@ -181,12 +181,12 @@ int HookedNewEvent(WPARAM wParam, LPARAM hDBEvent) if (i1 == 1)
c1 = mir_wstrdup(Clist_GetContactDisplayName(wParam));
else if (i1 == 2)
- c1 = DbEvent_GetTextW(&dbe);
+ c1 = dbe.getText();
if (i2 == 1)
c2 = mir_wstrdup(Clist_GetContactDisplayName(wParam));
else if (i2 == 2)
- c2 = DbEvent_GetTextW(&dbe);
+ c2 = dbe.getText();
wchar_t buffer[512];
mir_snwprintf(buffer, buf, c1, c2);
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 8963d4fa7c..be4a7c7e41 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -502,7 +502,7 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) dbei.flags |= DBEF_READ | DBEF_SENT;
if (dbei) {
- ptrW wszOldText(DbEvent_GetTextW(&dbei));
+ ptrW wszOldText(dbei.getText());
if (wszOldText)
wszText.Insert(0, wszOldText);
}
diff --git a/protocols/ICQ-WIM/src/menus.cpp b/protocols/ICQ-WIM/src/menus.cpp index 847ef4d31e..392af5f41b 100644 --- a/protocols/ICQ-WIM/src/menus.cpp +++ b/protocols/ICQ-WIM/src/menus.cpp @@ -32,7 +32,7 @@ int CIcqProto::OnPrebuildMenu(WPARAM hContact, LPARAM lParam) auto *dbei = (DB::EventInfo *)lParam; Menu_ShowItem(hmiForward, dbei->eventType == EVENTTYPE_MESSAGE || dbei->eventType == EVENTTYPE_FILE); - ptrW wszText(DbEvent_GetTextW(dbei)); + ptrW wszText(dbei->getText()); Menu_ShowItem(hmiConvert, fileText2url(wszText.get())); } return 0; @@ -126,7 +126,7 @@ void CIcqProto::ForwardMessage(MEVENT hEvent, MCONTACT to) return; CMStringW wszId(GetUserId(dbei.hContact)); - ptrW wszText(DbEvent_GetTextW(&dbei)); + ptrW wszText(dbei.getText()); JSONNode parts(JSON_ARRAY); JSONNode msgText; msgText << CHAR_PARAM("mediaType", "forward") << WCHAR_PARAM("sn", wszId) << INT_PARAM("time", dbei.timestamp) @@ -158,7 +158,7 @@ INT_PTR CIcqProto::SvcExecMenu(WPARAM iCommand, LPARAM pHandle) return 0; IcqFileInfo *pFileInfo = nullptr; - CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei))); + CMStringW wszText(ptrW(dbei.getText())); if (CheckFile(dbei.hContact, wszText, pFileInfo)) { if (!pFileInfo || pFileInfo->bIsSticker) { // sticker is a simple text message prcoessed by SmileyAdd diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 5c93aa0147..a5548ddb82 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -617,7 +617,7 @@ int CIcqProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *pszSrc CMStringA replyId(GetUserId(dbei.hContact));
replyTo << CHAR_PARAM("mediaType", "quote") << CHAR_PARAM("sn", replyId) << INT_PARAM("time", dbei.timestamp)
<< CHAR_PARAM("msgId", dbei.szId) << WCHAR_PARAM("friendly", Clist_GetContactDisplayName(dbei.hContact, 0))
- << WCHAR_PARAM("text", ptrW(DbEvent_GetTextW(&dbei)));
+ << WCHAR_PARAM("text", ptrW(dbei.getText()));
parts.push_back(replyTo);
}
}
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index f6b35ce727..3a67ea5f23 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -451,7 +451,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)) {
- ptrW szEventText(DbEvent_GetTextW(&dbei));
+ ptrW szEventText(dbei.getText());
if (szEventText)
nEventsSent++;
}
@@ -529,7 +529,7 @@ int CJabberProto::AdhocForwardHandler(const TiXmlElement*, CJabberIqInfo *pInfo, if (dbei.eventType != EVENTTYPE_MESSAGE || (dbei.flags & (DBEF_READ | DBEF_SENT)))
continue;
- ptrW szEventText(DbEvent_GetTextW(&dbei));
+ ptrW szEventText(dbei.getText());
if (szEventText == nullptr)
continue;
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 62cf73ca53..57fabb7510 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -364,7 +364,7 @@ public: AppendToBufferWithRTF(buf, szName);
AppendToBufferWithRTF(buf, L" ");
- msg = DbEvent_GetTextW(&dbei);
+ msg = dbei.getText();
if (msg) {
AppendToBufferWithRTF(buf, msg);
mir_free(msg);
@@ -394,7 +394,7 @@ public: case EVENTTYPE_MESSAGE:
default:
- msg = DbEvent_GetTextW(&dbei);
+ msg = dbei.getText();
SetToStyle((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? 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 498573b9a1..700b42a94a 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -274,7 +274,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP DB::EventInfo dbei(hDbEvent);
if (dbei) {
- ptrW wszDescr(DbEvent_GetTextW(&dbei));
+ ptrW wszDescr(dbei.getText());
if (wszDescr)
SetDlgItemText(hwndDlg, IDC_EDIT, wszDescr);
}
@@ -309,7 +309,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP dbei.cbBlob = oldBlobSize;
db_event_get(hDbEvent, &dbei);
- ptrW wszDescr(DbEvent_GetTextW(&dbei));
+ ptrW wszDescr(DbEvent_GetText(&dbei));
if (wszDescr) {
CharUpperW(wszDescr);
if (wcsstr(wszDescr, (const wchar_t *)lParam) != nullptr) {
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 1068dcff2d..53b7db4ab8 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -330,7 +330,7 @@ void CRtfLogWindow::CreateChatRtfMessage(RtfChatLogStreamData *streamData, const return;
}
}
- lin.write(streamData, false, buf, ptrW(DbEvent_GetTextW(&dbei)));
+ lin.write(streamData, false, buf, ptrW(dbei.getText()));
return;
}
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 172cbf1e8b..c28ba62438 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -734,7 +734,7 @@ void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent) if (mir_strcmp(szProto, dbei.szModule) || !g_chatApi.DbEventIsShown(dbei) || !dbei.szUserId)
return;
- CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei)));
+ CMStringW wszText(ptrW(dbei.getText()));
wszText.Replace(L"%", L"%%");
GCEVENT gce = { si, GC_EVENT_MESSAGE };
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index 45cbdc9022..210e609dff 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -91,138 +91,14 @@ MIR_APP_DLL(DBEVENTTYPEDESCR*) DbEvent_GetType(const char *szModule, int eventTy /////////////////////////////////////////////////////////////////////////////////////////
-static wchar_t* getEventString(const DB::EventInfo *dbei, LPSTR &buf)
-{
- LPSTR in = buf;
- buf += mir_strlen(buf) + 1;
- return dbei->getString(in);
-}
-
-static INT_PTR DbEventGetTextWorker(const DB::EventInfo *dbei, int codepage, int datatype)
+MIR_APP_DLL(wchar_t*) DbEvent_GetText(const DBEVENTINFO *dbei)
{
if (dbei == nullptr || dbei->szModule == nullptr)
return 0;
- DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType);
- if (et && ServiceExists(et->textService))
- return CallService(et->textService, (WPARAM)dbei, datatype);
-
- if (!dbei->pBlob)
- return 0;
-
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST || dbei->eventType == EVENTTYPE_ADDED) {
- DB::AUTH_BLOB blob(dbei->pBlob);
-
- ptrW tszNick(dbei->getString(blob.get_nick()));
- ptrW tszFirst(dbei->getString(blob.get_firstName()));
- ptrW tszLast(dbei->getString(blob.get_lastName()));
- ptrW tszEmail(dbei->getString(blob.get_email()));
-
- CMStringW nick, text;
- if (tszFirst || tszLast) {
- nick.AppendFormat(L"%s %s", tszFirst.get(), tszLast.get());
- nick.Trim();
- }
- if (tszEmail) {
- if (!nick.IsEmpty())
- nick.Append(L", ");
- nick.Append(tszEmail);
- }
- if (blob.get_uin() != 0) {
- if (!nick.IsEmpty())
- nick.Append(L", ");
- nick.AppendFormat(L"%d", blob.get_uin());
- }
- if (!nick.IsEmpty())
- nick = L"(" + nick + L")";
-
- if (dbei->eventType == EVENTTYPE_AUTHREQUEST) {
- ptrW tszReason(dbei->getString(blob.get_reason()));
- text.Format(TranslateT("Authorization request from %s%s: %s"),
- (tszNick == nullptr) ? Clist_GetContactDisplayName(blob.get_contact()) : tszNick.get(), nick.c_str(), tszReason.get());
- }
- else text.Format(TranslateT("You were added by %s%s"),
- (tszNick == nullptr) ? Clist_GetContactDisplayName(blob.get_contact()) : tszNick.get(), nick.c_str());
- return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text);
- }
-
- if (dbei->eventType == EVENTTYPE_CONTACTS) {
- CMStringW text(TranslateT("Contacts: "));
- // blob is: [uin(ASCIIZ), nick(ASCIIZ)]*
- char *buf = LPSTR(dbei->pBlob), *limit = LPSTR(dbei->pBlob) + dbei->cbBlob;
- while (buf < limit) {
- ptrW tszUin(getEventString(dbei, buf));
- ptrW tszNick(getEventString(dbei, buf));
- if (tszNick && *tszNick)
- text.AppendFormat(L"\"%s\" ", tszNick.get());
- if (tszUin && *tszUin)
- text.AppendFormat(L"<%s>; ", tszUin.get());
- }
- return (datatype == DBVT_WCHAR) ? (INT_PTR)mir_wstrdup(text) : (INT_PTR)mir_u2a(text);
- }
-
- if (dbei->eventType == EVENTTYPE_FILE) {
- DB::FILE_BLOB blob(*dbei);
-
- CMStringW wszText(blob.getName());
- if (mir_wstrlen(blob.getDescr())) {
- wszText.Append(L": ");
- wszText.Append(blob.getDescr());
- }
-
- switch (datatype) {
- case DBVT_WCHAR:
- return (INT_PTR)wszText.Detach();
- case DBVT_ASCIIZ:
- return (INT_PTR)mir_u2a(wszText);
- }
- return 0;
- }
-
- if (dbei->flags & DBEF_JSON) {
- JSONNode json = dbei->getJson();
- std::string str = json["b"].as_string();
- switch (datatype) {
- case DBVT_WCHAR:
- return (INT_PTR)mir_utf8decodeW(str.c_str());
- case DBVT_ASCIIZ:
- char *msg = mir_strdup(str.c_str());
- mir_utf8decodecp(msg, codepage, nullptr);
- return (INT_PTR)msg;
- }
- return 0;
- }
-
- // by default treat an event's blob as a string
- if (datatype == DBVT_WCHAR) {
- char *str = (char*)alloca(dbei->cbBlob + 1);
- memcpy(str, dbei->pBlob, dbei->cbBlob);
- str[dbei->cbBlob] = 0;
-
- if (dbei->flags & DBEF_UTF)
- return (INT_PTR)mir_utf8decodeW(str);
-
- return (INT_PTR)mir_a2u_cp(str, codepage);
- }
-
- if (datatype == DBVT_ASCIIZ) {
- char *msg = mir_strdup((char*)dbei->pBlob);
- if (dbei->flags & DBEF_UTF)
- mir_utf8decodecp(msg, codepage, nullptr);
-
- return (INT_PTR)msg;
- }
- return 0;
-}
-
-MIR_APP_DLL(char*) DbEvent_GetTextA(const DBEVENTINFO *dbei, int codepage)
-{
- return (char*)DbEventGetTextWorker((DB::EventInfo *)dbei, codepage, DBVT_ASCIIZ);
-}
-
-MIR_APP_DLL(wchar_t*) DbEvent_GetTextW(const DBEVENTINFO *dbei)
-{
- return (wchar_t*)DbEventGetTextWorker((DB::EventInfo *)dbei, CP_ACP, DBVT_WCHAR);
+ DB::EventInfo tmp;
+ memcpy(&tmp, dbei, sizeof(*dbei));
+ return tmp.getText();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -362,6 +238,103 @@ wchar_t* DB::EventInfo::getString(const char *str) const return mir_a2u(str);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static wchar_t* getEventString(const DB::EventInfo *dbei, LPSTR &buf)
+{
+ LPSTR in = buf;
+ buf += mir_strlen(buf) + 1;
+ return dbei->getString(in);
+}
+
+wchar_t* DB::EventInfo::getText() const
+{
+ DBEVENTTYPEDESCR *et = DbEvent_GetType(szModule, eventType);
+ if (et && ServiceExists(et->textService))
+ return (wchar_t *)CallService(et->textService, (WPARAM)this, DBVT_WCHAR);
+
+ if (!pBlob)
+ return 0;
+
+ if (eventType == EVENTTYPE_AUTHREQUEST || eventType == EVENTTYPE_ADDED) {
+ DB::AUTH_BLOB blob(pBlob);
+
+ ptrW tszNick(getString(blob.get_nick()));
+ ptrW tszFirst(getString(blob.get_firstName()));
+ ptrW tszLast(getString(blob.get_lastName()));
+ ptrW tszEmail(getString(blob.get_email()));
+
+ CMStringW nick, text;
+ if (tszFirst || tszLast) {
+ nick.AppendFormat(L"%s %s", tszFirst.get(), tszLast.get());
+ nick.Trim();
+ }
+ if (tszEmail) {
+ if (!nick.IsEmpty())
+ nick.Append(L", ");
+ nick.Append(tszEmail);
+ }
+ if (blob.get_uin() != 0) {
+ if (!nick.IsEmpty())
+ nick.Append(L", ");
+ nick.AppendFormat(L"%d", blob.get_uin());
+ }
+ if (!nick.IsEmpty())
+ nick = L"(" + nick + L")";
+
+ if (eventType == EVENTTYPE_AUTHREQUEST) {
+ ptrW tszReason(getString(blob.get_reason()));
+ text.Format(TranslateT("Authorization request from %s%s: %s"),
+ (tszNick == nullptr) ? Clist_GetContactDisplayName(blob.get_contact()) : tszNick.get(), nick.c_str(), tszReason.get());
+ }
+ else text.Format(TranslateT("You were added by %s%s"),
+ (tszNick == nullptr) ? Clist_GetContactDisplayName(blob.get_contact()) : tszNick.get(), nick.c_str());
+ return mir_wstrdup(text);
+ }
+
+ if (eventType == EVENTTYPE_CONTACTS) {
+ CMStringW text(TranslateT("Contacts: "));
+ // blob is: [uin(ASCIIZ), nick(ASCIIZ)]*
+ char *buf = LPSTR(pBlob), *limit = LPSTR(pBlob) + cbBlob;
+ while (buf < limit) {
+ ptrW tszUin(getEventString(this, buf));
+ ptrW tszNick(getEventString(this, buf));
+ if (tszNick && *tszNick)
+ text.AppendFormat(L"\"%s\" ", tszNick.get());
+ if (tszUin && *tszUin)
+ text.AppendFormat(L"<%s>; ", tszUin.get());
+ }
+ return mir_wstrdup(text);
+ }
+
+ if (eventType == EVENTTYPE_FILE) {
+ DB::FILE_BLOB blob(*this);
+
+ CMStringW wszText(blob.getName());
+ if (mir_wstrlen(blob.getDescr())) {
+ wszText.Append(L": ");
+ wszText.Append(blob.getDescr());
+ }
+ return wszText.Detach();
+ }
+
+ if (flags & DBEF_JSON) {
+ JSONNode json = getJson();
+ std::string str = json["b"].as_string();
+ return mir_utf8decodeW(str.c_str());
+ }
+
+ // by default treat an event's blob as a string
+ char *str = (char *)alloca(cbBlob + 1);
+ memcpy(str, pBlob, cbBlob);
+ str[cbBlob] = 0;
+
+ if (flags & DBEF_UTF)
+ return mir_utf8decodeW(str);
+
+ return mir_a2u_cp(str, CP_ACP);
+}
+
void DB::EventInfo::flushJson()
{
if (!m_json)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 1e528c19e3..eae8101853 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -202,8 +202,7 @@ Srmm_ModifyIcon @280 Srmm_RemoveIcon @281
ExtraIcon_AddIcon @282
DbEvent_GetIcon @283
-DbEvent_GetTextA @285
-DbEvent_GetTextW @286
+DbEvent_GetText @286
DbEvent_GetType @287
DbEvent_RegisterType @288
Profile_GetNameA @290
@@ -976,3 +975,4 @@ g_hevEventSetJson @1109 NONAME ?flushJson@EventInfo@DB@@QAEXXZ @1112 NONAME
?addReaction@EventInfo@DB@@QAEXPBD@Z @1113 NONAME
?delReaction@EventInfo@DB@@QAEXPBD@Z @1114 NONAME
+?getText@EventInfo@DB@@QBEPA_WXZ @1115 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 08a35f4c16..6811b2d393 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -202,8 +202,7 @@ Srmm_ModifyIcon @280 Srmm_RemoveIcon @281
ExtraIcon_AddIcon @282
DbEvent_GetIcon @283
-DbEvent_GetTextA @285
-DbEvent_GetTextW @286
+DbEvent_GetText @286
DbEvent_GetType @287
DbEvent_RegisterType @288
Profile_GetNameA @290
@@ -976,3 +975,4 @@ g_hevEventSetJson @1103 NONAME ?flushJson@EventInfo@DB@@QEAAXXZ @1106 NONAME
?addReaction@EventInfo@DB@@QEAAXPEBD@Z @1107 NONAME
?delReaction@EventInfo@DB@@QEAAXPEBD@Z @1108 NONAME
+?getText@EventInfo@DB@@QEBAPEA_WXZ @1109 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 0def709503..6549190c3c 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -778,7 +778,7 @@ void CSrmmBaseDialog::UpdateChatLog() DB::EventInfo dbei(hDbEvent);
if (dbei && !mir_strcmp(szProto, dbei.szModule) && g_chatApi.DbEventIsShown(dbei) && dbei.szUserId) {
Utf2T wszUserId(dbei.szUserId);
- CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei)));
+ CMStringW wszText(ptrW(dbei.getText()));
wszText.Replace(L"%", L"%%");
GCEVENT gce = { m_si, GC_EVENT_MESSAGE };
@@ -1140,7 +1140,7 @@ void CSrmmBaseDialog::SetQuoteEvent(MEVENT hEvent) if (dbei) {
CMStringW wszText(TranslateT("In reply to"));
wszText += L": ";
- wszText += ptrW(DbEvent_GetTextW(&dbei)).get();
+ wszText += ptrW(dbei.getText()).get();
m_Quote.SetText(wszText);
m_hQuoteEvent = hEvent;
|