summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/stdfile/src/filerecvdlg.cpp9
-rw-r--r--src/core/stdmsg/src/msglog.cpp13
-rw-r--r--src/core/stduihist/src/history.cpp33
-rw-r--r--src/mir_app/src/auth.cpp17
4 files changed, 22 insertions, 50 deletions
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp
index d9b54d4f8a..a1e11bafb5 100644
--- a/src/core/stdfile/src/filerecvdlg.cpp
+++ b/src/core/stdfile/src/filerecvdlg.cpp
@@ -222,12 +222,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
db_event_markRead(dat->hContact, dat->hDbEvent);
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent);
- if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) {
- dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1);
- db_event_get(dat->hDbEvent, &dbei);
- dbei.pBlob[dbei.cbBlob] = 0;
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (!db_event_get(dat->hDbEvent, &dbei)) {
dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob;
char *str = (char*)dbei.pBlob + 4;
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index 3161dff215..7905452248 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -201,17 +201,13 @@ int DbEventIsShown(DBEVENTINFO *dbei)
//mir_free() the return value
static bool CreateRTFFromDbEvent(LogStreamData *dat)
{
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent);
- if (dbei.cbBlob == -1)
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (db_event_get(dat->hDbEvent, &dbei))
return false;
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- db_event_get(dat->hDbEvent, &dbei);
- if (!DbEventIsShown(&dbei)) {
- mir_free(dbei.pBlob);
+ if (!DbEventIsShown(&dbei))
return false;
- }
if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
db_event_markRead(dat->hContact, dat->hDbEvent);
@@ -338,7 +334,6 @@ static bool CreateRTFFromDbEvent(LogStreamData *dat)
if (bIsRtl)
buf.Append("\\par");
- mir_free(dbei.pBlob);
return true;
}
diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp
index f76bf5c6cb..aadf8491e5 100644
--- a/src/core/stduihist/src/history.cpp
+++ b/src/core/stduihist/src/history.cpp
@@ -122,19 +122,12 @@ static void FillHistoryThread(THistoryThread *hInfo)
int i = db_event_count(hInfo->hContact);
SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i * 40);
- DBEVENTINFO dbei = {};
- int oldBlobSize = 0;
- MEVENT hDbEvent = db_event_last(hInfo->hContact);
-
- while (hDbEvent != NULL) {
+ DB::ECPTR pCursor(DB::EventsRev(hInfo->hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
if (!IsWindow(hInfo->hwnd))
break;
- int newBlobSize = db_event_getBlobSize(hDbEvent);
- if (newBlobSize > oldBlobSize) {
- dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize);
- oldBlobSize = newBlobSize;
- }
- dbei.cbBlob = oldBlobSize;
+
+ DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
wchar_t str[200], eventText[256], strdatetime[64];
@@ -145,9 +138,7 @@ static void FillHistoryThread(THistoryThread *hInfo)
i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText);
SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent);
}
- hDbEvent = db_event_prev(hInfo->hContact, hDbEvent);
}
- mir_free(dbei.pBlob);
SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_SETCURSEL, 0, 0);
SendMessage(hInfo->hwnd, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0);
@@ -281,16 +272,12 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE);
MEVENT hDbEvent = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0);
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if ((int)dbei.cbBlob != -1) {
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- if (db_event_get(hDbEvent, &dbei) == 0) {
- ptrW wszDescr(DbEvent_GetTextW(&dbei, CP_ACP));
- if (wszDescr)
- SetDlgItemText(hwndDlg, IDC_EDIT, wszDescr);
- }
- mir_free(dbei.pBlob);
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (!db_event_get(hDbEvent, &dbei)) {
+ ptrW wszDescr(DbEvent_GetTextW(&dbei, CP_ACP));
+ if (wszDescr)
+ SetDlgItemText(hwndDlg, IDC_EDIT, wszDescr);
}
}
return TRUE;
diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp
index 7419de4513..dd448a2b61 100644
--- a/src/mir_app/src/auth.cpp
+++ b/src/mir_app/src/auth.cpp
@@ -53,14 +53,9 @@ public:
Button_SetSkin_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details"));
Button_SetSkin_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list"));
- int iBlobSize = db_event_getBlobSize(m_hDbEvent);
- if (iBlobSize == -1)
- return false;
-
// blob is: uin(DWORD), hcontact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
DBEVENTINFO dbei = {};
- dbei.cbBlob = iBlobSize;
- dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
+ dbei.cbBlob = -1;
if (db_event_get(m_hDbEvent, &dbei))
return false;
@@ -200,9 +195,8 @@ public:
Button_SetSkin_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list"));
// blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(m_hDbEvent);
- dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
db_event_get(m_hDbEvent, &dbei);
m_hContact = DbGetAuthEventContact(&dbei);
@@ -298,13 +292,12 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
wchar_t szTooltip[256];
MEVENT hDbEvent = (MEVENT)lParam;
- DBEVENTINFO dbei = {};
+ DB::EventInfo dbei;
db_event_get(lParam, &dbei);
if (dbei.flags & (DBEF_SENT | DBEF_READ) || (dbei.eventType != EVENTTYPE_AUTHREQUEST && dbei.eventType != EVENTTYPE_ADDED))
return 0;
- dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
+ dbei.cbBlob = -1;
db_event_get(hDbEvent, &dbei);
MCONTACT hContact = DbGetAuthEventContact(&dbei);