diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 2 | ||||
-rw-r--r-- | plugins/DbChecker/src/worker.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbevents.cpp | 26 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 4 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbevents.cpp | 53 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.h | 2 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbsettings.cpp | 2 | ||||
-rw-r--r-- | plugins/IEView/src/HTMLBuilder.cpp | 6 | ||||
-rw-r--r-- | plugins/Import/src/dbrw/dbevents.cpp | 2 | ||||
-rw-r--r-- | plugins/Import/src/dbrw/dbintf.h | 2 | ||||
-rw-r--r-- | plugins/Import/src/textjson.cpp | 18 | ||||
-rw-r--r-- | plugins/Msg_Export/src/utils.cpp | 22 | ||||
-rw-r--r-- | plugins/NewEventNotify/src/popup.cpp | 40 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msglog.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 39 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 31 |
20 files changed, 111 insertions, 162 deletions
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index e566ff120b..d2a694bd53 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -263,7 +263,7 @@ BOOL CDb3Mmap::DeleteEvent(MEVENT hDbEvent) return 0;
}
-BOOL CDb3Mmap::EditEvent(MCONTACT, MEVENT, const DBEVENTINFO*)
+BOOL CDb3Mmap::EditEvent(MEVENT, const DBEVENTINFO*)
{
return 1;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 287d052d02..e9a558dec7 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -210,7 +210,7 @@ public: STDMETHODIMP_(int) GetEventCount(MCONTACT contactID) override;
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override;
- STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
+ STDMETHODIMP_(BOOL) EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(int) GetBlobSize(MEVENT hDbEvent) override;
STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override;
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp index c2e458a921..8ee18e45da 100644 --- a/plugins/DbChecker/src/worker.cpp +++ b/plugins/DbChecker/src/worker.cpp @@ -101,7 +101,7 @@ void __cdecl WorkerThread(DbToolOptions *opts) if (opts->bCheckUtf && dbei.eventType == EVENTTYPE_MESSAGE) {
if (ConvertOldEvent(dbei)) {
- db_event_edit(cc, hEvent, &dbei);
+ db_event_edit(hEvent, &dbei);
nUtfCount++;
}
}
diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index 3b2c0e4650..3cbb5e5e5a 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -137,7 +137,7 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent) /////////////////////////////////////////////////////////////////////////////////////////
-BOOL CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbei)
+BOOL CDbxMDBX::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei)
{
if (dbei == nullptr) return 1;
if (dbei->timestamp == 0) return 1;
@@ -150,19 +150,19 @@ BOOL CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO DBEvent *dbe = (DBEvent*)data.iov_base;
tmp.timestamp = dbe->timestamp;
- return !EditEvent(contactID, hDbEvent, &tmp, false);
+ return !EditEvent(dbe->dwContactID, hDbEvent, &tmp, false);
}
-bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbei, bool bNew)
+bool CDbxMDBX::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO *dbei, bool bNew)
{
DBEvent dbe;
- dbe.dwContactID = contactID; // store native or subcontact's id
+ dbe.dwContactID = hContact; // store native or subcontact's id
dbe.iModuleId = GetModuleID(dbei->szModule);
- MCONTACT contactNotifyID = contactID;
+ MCONTACT contactNotifyID = hContact;
DBCachedContact *cc, *ccSub = nullptr;
- if (contactID != 0) {
- if ((cc = m_cache->GetCachedContact(contactID)) == nullptr)
+ if (hContact != 0) {
+ if ((cc = m_cache->GetCachedContact(hContact)) == nullptr)
return false;
if (cc->IsSub()) {
@@ -172,10 +172,10 @@ bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO // set default sub to the event's source
if (!(dbei->flags & DBEF_SENT))
- db_mc_setDefault(cc->contactID, contactID, false);
- contactID = cc->contactID; // and add an event to a metahistory
+ db_mc_setDefault(cc->contactID, hContact, false);
+ hContact = cc->contactID; // and add an event to a metahistory
if (db_mc_isEnabled())
- contactNotifyID = contactID;
+ contactNotifyID = hContact;
}
}
else cc = &m_ccDummy;
@@ -224,15 +224,15 @@ bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO return false;
// add a sorting key
- DBEventSortingKey key2 = { contactID, hDbEvent, dbe.timestamp };
+ DBEventSortingKey key2 = { hContact, hDbEvent, dbe.timestamp };
key.iov_len = sizeof(key2); key.iov_base = &key2;
data.iov_len = 1; data.iov_base = (char*)("");
if (mdbx_put(trnlck, m_dbEventsSort, &key, &data, MDBX_UPSERT) != MDBX_SUCCESS)
return false;
cc->Advance(hDbEvent, dbe);
- if (contactID != 0) {
- MDBX_val keyc = { &contactID, sizeof(MCONTACT) }, datac = { &cc->dbc, sizeof(DBContact) };
+ if (hContact != 0) {
+ MDBX_val keyc = { &hContact, sizeof(MCONTACT) }, datac = { &cc->dbc, sizeof(DBContact) };
if (mdbx_put(trnlck, m_dbContacts, &keyc, &datac, MDBX_UPSERT) != MDBX_SUCCESS)
return false;
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index f0e931667b..8166864881 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -162,7 +162,7 @@ class CDbxMDBX : public MDatabaseCommon, public MIDatabaseChecker, public MZeroe MDBX_txn* StartTran();
bool CheckEvent(DBCachedContact *cc, const DBEvent *dbe, DBCachedContact *&cc2);
- bool EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe, bool bNew);
+ bool EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO *dbe, bool bNew);
int PrepareCheck(void);
void TouchFile(void);
@@ -249,7 +249,7 @@ public: STDMETHODIMP_(int) GetEventCount(MCONTACT contactID) override;
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override;
- STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
+ STDMETHODIMP_(BOOL) EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(int) GetBlobSize(MEVENT hDbEvent) override;
STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override;
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index b16a1fd91f..bc8ab23c78 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -11,16 +11,45 @@ static const char add_event_sort_query[] = "INSERT INTO events_srt(id, contact_i void CDbxSQLite::InitEvents()
{
- sqlite3_stmt *stmt = nullptr;
- sqlite3_prepare_v2(m_db, "SELECT DISTINCT module FROM events;", -1, &stmt, nullptr);
int rc = 0;
- while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
- const char *module = (char*)sqlite3_column_text(stmt, 0);
- if (mir_strlen(module) > 0)
- m_modules.insert(mir_strdup(module));
+ {
+ sqlite3_stmt *stmt = nullptr;
+ sqlite3_prepare_v2(m_db, "SELECT DISTINCT module FROM events;", -1, &stmt, nullptr);
+ while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
+ const char *module = (char *)sqlite3_column_text(stmt, 0);
+ if (mir_strlen(module) > 0)
+ m_modules.insert(mir_strdup(module));
+ }
+ logError(rc, __FILE__, __LINE__);
+ sqlite3_finalize(stmt);
+ }
+
+ // Events convertor
+ DBVARIANT dbv = { DBVT_BYTE };
+ if (GetContactSettingWorker(0, "Compatibility", "DbEvents", &dbv, 0))
+ dbv.bVal = 0;
+
+ if (dbv.bVal < 1) {
+ sqlite3_stmt *stmt = nullptr;
+ sqlite3_prepare_v2(m_db, "SELECT id FROM events WHERE type=1002;", -1, &stmt, nullptr);
+ while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
+ MEVENT hEvent = sqlite3_column_int(stmt, 0);
+
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ GetEvent(hEvent, &dbei);
+
+ const char *p = (const char*)dbei.pBlob + sizeof(uint32_t);
+ DB::FILE_BLOB blob(DbEvent_GetString(&dbei, p), DbEvent_GetString(&dbei, p + mir_strlen(p) + 1));
+ blob.write(dbei);
+ EditEvent(hEvent, &dbei);
+ }
+ logError(rc, __FILE__, __LINE__);
+ sqlite3_finalize(stmt);
+
+ dbv.bVal = 1;
+ WriteContactSetting(0, "Compatibility", "DbEvents", &dbv);
}
- logError(rc, __FILE__, __LINE__);
- sqlite3_finalize(stmt);
}
void CDbxSQLite::UninitEvents()
@@ -222,7 +251,7 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) /////////////////////////////////////////////////////////////////////////////////////////
-BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO *dbei)
+BOOL CDbxSQLite::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei)
{
if (dbei == nullptr)
return 1;
@@ -230,10 +259,6 @@ BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO if (dbei->timestamp == 0)
return 1;
- DBCachedContact *cc = (hContact) ? m_cache->GetCachedContact(hContact) : &m_system;
- if (cc == nullptr)
- return 1;
-
DBEVENTINFO tmp = *dbei;
mir_ptr<uint8_t> pCryptBlob;
if (m_bEncrypted) {
@@ -266,7 +291,7 @@ BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO lock.unlock();
DBFlush();
- NotifyEventHooks(g_hevEventEdited, hContact, (LPARAM)hDbEvent);
+ NotifyEventHooks(g_hevEventEdited, 0, hDbEvent);
return 0;
}
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index b21abbe51b..6712570cf9 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -126,7 +126,7 @@ public: STDMETHODIMP_(int) GetEventCount(MCONTACT contactID) override;
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override;
- STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
+ STDMETHODIMP_(BOOL) EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(int) GetBlobSize(MEVENT hDbEvent) override;
STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override;
diff --git a/plugins/Dbx_sqlite/src/dbsettings.cpp b/plugins/Dbx_sqlite/src/dbsettings.cpp index 249a8bc059..d9e33abb91 100644 --- a/plugins/Dbx_sqlite/src/dbsettings.cpp +++ b/plugins/Dbx_sqlite/src/dbsettings.cpp @@ -60,7 +60,7 @@ void CDbxSQLite::InitSettings() FillContactSettings();
DBVARIANT dbv = { DBVT_BYTE };
- if (GetContactSetting(0, "Compatibility", "Sqlite", &dbv))
+ if (GetContactSettingWorker(0, "Compatibility", "Sqlite", &dbv, 0))
dbv.bVal = 0;
if (dbv.bVal < 1) {
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index c853a9b97e..aeab02c14f 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -238,10 +238,8 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) eventData->iType = IEED_EVENT_STATUSCHANGE;
}
else if (dbei.eventType == EVENTTYPE_FILE) {
- // blob is: sequenceid(uint32_t),filename(ASCIIZ),description(ASCIIZ)
- char* filename = ((char *)dbei.pBlob) + sizeof(uint32_t);
- char* descr = filename + mir_strlen(filename) + 1;
- eventData->szText.w = DbEvent_GetString(&dbei, filename);
+ DB::FILE_BLOB blob(dbei);
+ eventData->szText.w = mir_wstrdup(blob.getName());
/*if (*descr != '\0') {
CMStringW tmp(FORMAT, L"%s (%s)", eventData->szText.w, ptrW(DbEvent_GetString(&dbei, descr)).get());
mir_free((void*)eventData->szText.w);
diff --git a/plugins/Import/src/dbrw/dbevents.cpp b/plugins/Import/src/dbrw/dbevents.cpp index 06995bd4a9..95fc34eca3 100644 --- a/plugins/Import/src/dbrw/dbevents.cpp +++ b/plugins/Import/src/dbrw/dbevents.cpp @@ -44,7 +44,7 @@ STDMETHODIMP_(BOOL) CDbxSQLite::DeleteEvent(MEVENT) return FALSE;
}
-BOOL CDbxSQLite::EditEvent(MCONTACT, MEVENT, const DBEVENTINFO*)
+BOOL CDbxSQLite::EditEvent(MEVENT, const DBEVENTINFO*)
{
return 1;
}
diff --git a/plugins/Import/src/dbrw/dbintf.h b/plugins/Import/src/dbrw/dbintf.h index 2a843b025d..b3494a44c1 100644 --- a/plugins/Import/src/dbrw/dbintf.h +++ b/plugins/Import/src/dbrw/dbintf.h @@ -134,7 +134,7 @@ public: STDMETHODIMP_(int) GetEventCount(MCONTACT contactID) override;
STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override;
- STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
+ STDMETHODIMP_(BOOL) EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbe) override;
STDMETHODIMP_(int) GetBlobSize(MEVENT hDbEvent) override;
STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override;
STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override;
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index d419807ac0..540a414e32 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -156,23 +156,10 @@ public: }
if (dbei->eventType == EVENTTYPE_FILE) {
- std::string szFile = (*node)["file"].as_string();
- std::string szDescr = (*node)["descr"].as_string();
-
dbei->flags |= DBEF_UTF;
- MBinBuffer buf;
- uint32_t tmp = 0;
- buf.append(&tmp, sizeof(tmp));
- buf.append(szFile.c_str(), szFile.size());
- if (!szDescr.empty()) {
- buf.append(&tmp, 1);
- buf.append(szDescr.c_str(), szDescr.size());
- }
- buf.append(&tmp, 1);
- dbei->cbBlob = (int)buf.length();
- dbei->pBlob = (uint8_t*)mir_alloc(dbei->cbBlob);
- memcpy(dbei->pBlob, buf.data(), buf.length());
+ DB::FILE_BLOB blob((*node)["file"].as_mstring(), (*node)["descr"].as_mstring());
+ blob.write(*(DB::EventInfo*)dbei);
}
else {
std::string szBody = (*node)["body"].as_string();
@@ -180,7 +167,6 @@ public: int offset;
switch (dbei->eventType) {
case EVENTTYPE_ADDED:
- case EVENTTYPE_FILE:
offset = sizeof(uint32_t);
break;
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 6efee874e7..ba97c46228 100644 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -629,7 +629,7 @@ static wchar_t* getEventString(DBEVENTINFO &dbei, char *&buf) return (dbei.flags & DBEF_UTF) ? mir_utf8decodeW(in) : mir_a2u(in);
}
-static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sFilePath, DBEVENTINFO &dbei, bool bAppendOnly)
+static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sFilePath, DB::EventInfo &dbei, bool bAppendOnly)
{
wstring sLocalUser;
wstring sRemoteUser;
@@ -779,13 +779,11 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF pRoot.push_back(JSONNode("flags", flags));
if (dbei.eventType == EVENTTYPE_FILE) {
- char *p = (char*)dbei.pBlob + sizeof(uint32_t);
- ptrW wszFileName(getEventString(dbei, p));
- ptrW wszDescr(getEventString(dbei, p));
+ DB::FILE_BLOB blob(dbei);
- pRoot << WCHAR_PARAM("file", wszFileName);
- if (mir_wstrlen(wszDescr))
- pRoot << WCHAR_PARAM("descr", wszDescr);
+ pRoot << WCHAR_PARAM("file", blob.getName());
+ if (mir_wstrlen(blob.getDescr()))
+ pRoot << WCHAR_PARAM("descr", blob.getDescr());
}
else {
ptrW msg(DbEvent_GetTextW(&dbei, CP_ACP));
@@ -824,18 +822,16 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF case EVENTTYPE_FILE:
{
- char *p = (char*)dbei.pBlob + sizeof(uint32_t);
- ptrW wszFileName(getEventString(dbei, p));
- ptrW wszDescr(getEventString(dbei, p));
+ DB::FILE_BLOB blob(dbei);
const wchar_t *pszType = LPGENW("File: ");
bWriteTextToFile(hFile, pszType, bWriteUTF8Format);
- bWriteIndentedToFile(hFile, nIndent, wszFileName, bWriteUTF8Format);
+ bWriteIndentedToFile(hFile, nIndent, blob.getName(), bWriteUTF8Format);
- if (mir_wstrlen(wszDescr)) {
+ if (mir_wstrlen(blob.getDescr())) {
bWriteNewLine(hFile, nIndent);
bWriteTextToFile(hFile, LPGENW("Description: "), bWriteUTF8Format);
- bWriteIndentedToFile(hFile, nIndent, wszDescr, bWriteUTF8Format);
+ bWriteIndentedToFile(hFile, nIndent, blob.getDescr(), bWriteUTF8Format);
}
}
break;
diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index 535e981af9..870d0b0835 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -144,14 +144,14 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA /////////////////////////////////////////////////////////////////////////////////////////
-static wchar_t* ShortenPreview(DBEVENTINFO *dbe)
+static wchar_t* ShortenPreview(DB::EventInfo &dbei)
{
bool fAddEllipsis = false;
size_t iPreviewLimit = g_plugin.iLimitPreview;
if (iPreviewLimit > 500 || iPreviewLimit == 0)
iPreviewLimit = 500;
- wchar_t *buf = DbEvent_GetTextW(dbe, CP_ACP);
+ wchar_t *buf = DbEvent_GetTextW(&dbei, CP_ACP);
if (mir_wstrlen(buf) > iPreviewLimit) {
fAddEllipsis = true;
size_t iIndex = iPreviewLimit;
@@ -168,15 +168,15 @@ static wchar_t* ShortenPreview(DBEVENTINFO *dbe) return buf;
}
-static wchar_t* GetEventPreview(DBEVENTINFO *dbei)
+static wchar_t* GetEventPreview(DB::EventInfo &dbei)
{
wchar_t *comment1 = nullptr;
wchar_t *comment2 = nullptr;
char *commentFix = nullptr;
- char *pBlob = (char *)dbei->pBlob;
+ char *pBlob = (char *)dbei.pBlob;
// now get text
- switch (dbei->eventType) {
+ switch (dbei.eventType) {
case EVENTTYPE_MESSAGE:
if (pBlob)
comment1 = ShortenPreview(dbei);
@@ -185,13 +185,13 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) case EVENTTYPE_FILE:
if (pBlob) {
- char *p = pBlob + sizeof(uint32_t);
+ DB::FILE_BLOB blob(dbei);
+
// filenames
- comment2 = DbEvent_GetString(dbei, p);
+ comment2 = mir_wstrdup(blob.getName());
// description
- p += mir_strlen(p) + 1;
- if (*p)
- comment1 = DbEvent_GetString(dbei, p);
+ if (*blob.getDescr())
+ comment1 = mir_wstrdup(blob.getDescr());
}
commentFix = POPUP_COMMENT_FILE;
break;
@@ -203,7 +203,7 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) if (pBlob) {
// count contacts in event
char* pcBlob = pBlob;
- char* pcEnd = pBlob + dbei->cbBlob;
+ char* pcEnd = pBlob + dbei.cbBlob;
int nContacts;
wchar_t szBuf[512];
@@ -241,13 +241,13 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) mir_snprintf(szUin, "%d", *((uint32_t*)pBlob));
if (mir_strlen(pszNick) > 0) {
- if (dbei->flags & DBEF_UTF)
+ if (dbei.flags & DBEF_UTF)
szNick = mir_utf8decodeW(pszNick);
else
szNick = mir_a2u(pszNick);
}
else if (mir_strlen(pszEmail) > 0) {
- if (dbei->flags & DBEF_UTF)
+ if (dbei.flags & DBEF_UTF)
szNick = mir_utf8decodeW(pszEmail);
else
szNick = mir_a2u(pszEmail);
@@ -267,13 +267,13 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) case EVENTTYPE_AUTHREQUEST:
if (pBlob) {
- DB::AUTH_BLOB blob(dbei->pBlob);
+ DB::AUTH_BLOB blob(dbei.pBlob);
wchar_t *szNick = nullptr;
if (blob.get_nick())
- szNick = dbei->getString(blob.get_nick());
+ szNick = dbei.getString(blob.get_nick());
else if (blob.get_email())
- szNick = dbei->getString(blob.get_email());
+ szNick = dbei.getString(blob.get_email());
else if (blob.get_uin()) {
char szUin[16];
szNick = mir_a2u(itoa(blob.get_uin(), szUin, 10));
@@ -287,9 +287,9 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) default:
// support for custom database event types
- DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbei->szModule, dbei->eventType);
+ DBEVENTTYPEDESCR *pei = DbEvent_GetType(dbei.szModule, dbei.eventType);
if (pei && pBlob) {
- comment1 = DbEvent_GetTextW(dbei, CP_ACP);
+ comment1 = DbEvent_GetTextW(&dbei, CP_ACP);
commentFix = pei->descr;
}
else commentFix = POPUP_COMMENT_OTHER;
@@ -392,7 +392,7 @@ int PopupShow(MCONTACT hContact, MEVENT hEvent, UINT eventType) }
else { // get the needed event data
wcsncpy(pudw.lpwzContactName, Clist_GetContactDisplayName(hContact), MAX_CONTACTNAME);
- wcsncpy(pudw.lpwzText, ptrW(GetEventPreview(&dbe)), MAX_SECONDLINE);
+ wcsncpy(pudw.lpwzText, ptrW(GetEventPreview(dbe)), MAX_SECONDLINE);
}
// send data to popup plugin
@@ -450,7 +450,7 @@ int PopupUpdate(PLUGIN_DATA &pdata, MEVENT hEvent) }
// prepare event preview
- wszText.Append(ptrW(GetEventPreview(&dbe)));
+ wszText.Append(ptrW(GetEventPreview(dbe)));
wszText.AppendChar('\n');
}
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 6b64e08c63..08baac7ff7 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -127,8 +127,10 @@ void ItemData::load(bool bFullLoad) wchar_t buf[MAX_PATH]; CallService(MS_FILE_GETRECEIVEDFILESFOLDERW, hContact, (LPARAM)buf); { + DB::FILE_BLOB blob(dbe); + CMStringW wszFileName(buf); - wszFileName.Append(ptrW(DbEvent_GetTextW(&dbe, CP_ACP))); + wszFileName.Append(blob.getName()); // if a filename contains spaces, URL will be broken if (wszFileName.Find(' ') != -1) { diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index a57b5f42ca..1df5ee2c76 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -10,7 +10,7 @@ struct ItemData bool bLoaded; int savedTop; - DBEVENTINFO dbe; + DB::EventInfo dbe; wchar_t *wtext; wchar_t *wszNick; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 398c6b24ab..bcb75402f8 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -179,7 +179,7 @@ struct NewstoryListData : public MZeroedObject ptrA szUtf(mir_utf8encodeW(pItem->wtext)); pItem->dbe.cbBlob = (int)mir_strlen(szUtf) + 1; pItem->dbe.pBlob = (uint8_t *)szUtf.get(); - db_event_edit(pItem->hContact, pItem->hEvent, &pItem->dbe); + db_event_edit(pItem->hEvent, &pItem->dbe); if (auto *ppro = Proto_GetInstance(pItem->hContact)) ppro->OnEventEdited(pItem->hContact, pItem->hEvent); diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index f191432ba4..5bd6e406f7 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -108,17 +108,7 @@ EventData* CMsgDialog::GetEventFromDB(MCONTACT hContact, MEVENT hDbEvent) else
evt->szNick.w = mir_wstrdup(Clist_GetContactDisplayName(hContact));
- if (evt->eventType == EVENTTYPE_FILE) {
- char *filename = ((char*)dbei.pBlob) + sizeof(uint32_t);
- char *descr = filename + mir_strlen(filename) + 1;
- evt->szText.w = DbEvent_GetString(&dbei, filename);
- if (*descr != 0) {
- ptrW wszDescr(DbEvent_GetString(&dbei, descr));
- CMStringW tmp(FORMAT, L"%s (%s)", evt->szText.w, wszDescr.get());
- replaceStrW(evt->szText.w, tmp.Detach());
- }
- }
- else evt->szText.w = DbEvent_GetTextW(&dbei, CP_UTF8);
+ evt->szText.w = DbEvent_GetTextW(&dbei, CP_UTF8);
if (!m_bUseRtl && Utils_IsRtl(evt->szText.w))
evt->dwFlags |= IEEDF_RTL;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 5451beac4d..11065a5733 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -935,46 +935,13 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) }
if (!bUseSelection) {
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(hDBEvent);
- wchar_t *szText = (wchar_t*)mir_alloc((dbei.cbBlob + 1) * sizeof(wchar_t)); // URLs are made one char bigger for crlf
- dbei.pBlob = (uint8_t*)szText;
- db_event_get(hDBEvent, &dbei);
- int iSize = int(mir_strlen((char*)dbei.pBlob)) + 1;
-
- bool bNeedsFree = false;
- wchar_t *szConverted;
- if (dbei.flags & DBEF_UTF) {
- szConverted = mir_utf8decodeW((char*)szText);
- bNeedsFree = true;
- }
- else {
- if (iSize != (int)dbei.cbBlob)
- szConverted = (wchar_t*)&dbei.pBlob[iSize];
- else {
- szConverted = (wchar_t*)mir_alloc(sizeof(wchar_t) * iSize);
- bNeedsFree = true;
- MultiByteToWideChar(CP_ACP, 0, (char*)dbei.pBlob, -1, szConverted, iSize);
- }
- }
-
- if (dbei.eventType == EVENTTYPE_FILE) {
- size_t iDescr = mir_strlen((char *)(szText + sizeof(uint32_t)));
- memmove(szText, szText + sizeof(uint32_t), iDescr);
- memmove(szText + iDescr + 2, szText + sizeof(uint32_t) + iDescr, dbei.cbBlob - iDescr - sizeof(uint32_t) - 1);
- szText[iDescr] = '\r';
- szText[iDescr + 1] = '\n';
- szConverted = (wchar_t*)mir_alloc(sizeof(wchar_t)* (1 + mir_strlen((char *)szText)));
- MultiByteToWideChar(CP_ACP, 0, (char *)szText, -1, szConverted, 1 + (int)mir_strlen((char *)szText));
- bNeedsFree = true;
- }
+ DB::EventInfo dbei(hDBEvent);
+ ptrW szConverted(DbEvent_GetTextW(&dbei, CP_ACP));
if (szConverted != nullptr)
m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(szConverted)));
- mir_free(szText);
- if (bNeedsFree)
- mir_free(szConverted);
+ mir_free(szConverted);
}
SetFocus(m_message.GetHwnd());
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 86b0caf93a..3499e97cc3 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -432,16 +432,14 @@ static char* Template_CreateRTFFromDbEvent(CMsgDialog *dat, MCONTACT hContact, M bool skipToNext = false, skipFont = false;
bool isBold = false, isItalic = false, isUnderline = false;
- DBEVENTINFO dbei = {};
+ DB::EventInfo dbei;
if (streamData->dbei != nullptr)
- dbei = *(streamData->dbei);
+ memcpy(&dbei, streamData->dbei, sizeof(DBEVENTINFO));
else {
dbei.cbBlob = -1;
db_event_get(hDbEvent, &dbei);
- if (!DbEventIsShown(&dbei)) {
- mir_free(dbei.pBlob);
+ if (!DbEventIsShown(&dbei))
return nullptr;
- }
}
if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.markedRead())
@@ -455,10 +453,9 @@ static char* Template_CreateRTFFromDbEvent(CMsgDialog *dat, MCONTACT hContact, M }
CMStringW msg(ptrW(DbEvent_GetTextW(&dbei, CP_UTF8)));
- if (msg.IsEmpty()) {
- mir_free(dbei.pBlob);
+ if (msg.IsEmpty())
return nullptr;
- }
+
msg.TrimRight();
dat->FormatRaw(msg, 1, FALSE);
@@ -854,20 +851,8 @@ static char* Template_CreateRTFFromDbEvent(CMsgDialog *dat, MCONTACT hContact, M str.Append(GetRTFFont(iFontIDOffset + (isSent ? MSGFONTID_MYMISC : MSGFONTID_YOURMISC)));
str.AppendChar(' ');
}
- {
- char *szFileName = (char *)dbei.pBlob + sizeof(uint32_t);
- ptrW tszFileName(DbEvent_GetString(&dbei, szFileName));
-
- char *szDescr = szFileName + mir_strlen(szFileName) + 1;
- if (*szDescr != 0) {
- ptrW tszDescr(DbEvent_GetString(&dbei, szDescr));
- wchar_t buf[1000];
- mir_snwprintf(buf, L"%s (%s)", tszFileName.get(), tszDescr.get());
- AppendUnicodeToBuffer(str, buf, 0);
- }
- else AppendUnicodeToBuffer(str, tszFileName, 0);
- }
+ AppendUnicodeToBuffer(str, ptrW(DbEvent_GetTextW(&dbei, CP_ACP)), 0);
break;
default:
@@ -1000,8 +985,8 @@ skip: str.Append("\\par");
- if (streamData->dbei == nullptr)
- mir_free(dbei.pBlob);
+ if (streamData->dbei != nullptr)
+ dbei.pBlob = 0;
dat->m_iLastEventType = MAKELONG((dbei.flags & (DBEF_SENT | DBEF_READ | DBEF_RTL)), dbei.eventType);
dat->m_lastEventTime = dbei.timestamp;
|