summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-30 17:32:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-30 17:32:39 +0000
commit109877a3c75cb290c55755dcfc88794d2453669d (patch)
tree3ede8b9170b2fc3f6f35dc2cea6742d44b19d631 /plugins/TabSRMM/src
parentfee8d991bdf4a59b563d1b92165ea0ed2f7bacb8 (diff)
MS_DB_EVENT_* services remained, but their calls removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@4255 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/eventpopups.cpp132
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp27
-rw-r--r--plugins/TabSRMM/src/globals.cpp45
-rw-r--r--plugins/TabSRMM/src/hotkeyhandler.cpp2
-rw-r--r--plugins/TabSRMM/src/mim.cpp15
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp28
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp45
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.h1
-rw-r--r--plugins/TabSRMM/src/msglog.cpp14
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp6
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp2
11 files changed, 123 insertions, 194 deletions
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp
index 79d92f7689..1e243e18f8 100644
--- a/plugins/TabSRMM/src/eventpopups.cpp
+++ b/plugins/TabSRMM/src/eventpopups.cpp
@@ -582,82 +582,70 @@ static TCHAR *GetPreviewT(WORD eventType, DBEVENTINFO* dbe)
static int PopupUpdateT(HANDLE hContact, HANDLE hEvent)
{
- PLUGIN_DATAT *pdata = 0;
- DBEVENTINFO dbe;
- TCHAR lpzText[MAX_SECONDLINE] = _T("");
- TCHAR timestamp[MAX_DATASIZE] = _T("\0");
- TCHAR formatTime[MAX_DATASIZE] = _T("\0");
- int iEvent = 0;
- TCHAR *p = lpzText;
- int available = 0, i;
- TCHAR *szPreview = NULL;
-
- pdata = const_cast<PLUGIN_DATAT *>(PU_GetByContact(hContact));
-
+ PLUGIN_DATAT *pdata = const_cast<PLUGIN_DATAT *>(PU_GetByContact(hContact));
if (!pdata)
return 1;
- ZeroMemory((void*)&dbe, sizeof(dbe));
+ if (hEvent == NULL)
+ return 0;
- if (hEvent) {
- if (pdata->pluginOptions->bShowHeaders) {
- mir_sntprintf(pdata->szHeader, SIZEOF(pdata->szHeader), _T("%s %d\n"),
- TranslateT("New messages: "), pdata->nrMerged + 1);
- pdata->szHeader[255] = 0;
- }
- ZeroMemory(&dbe, sizeof(dbe));
- dbe.cbSize = sizeof(dbe);
- if (pdata->pluginOptions->bPreview && hContact) {
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob);
- }
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
-
- formatTime[0] = 0;
- _tcsncpy(formatTime, _T("%Y.%m.%d %H:%M"), MAX_DATASIZE);
- _tcsftime(timestamp, MAX_DATASIZE, formatTime, _localtime32((__time32_t *)&dbe.timestamp));
- mir_sntprintf(pdata->eventData[pdata->nrMerged].szText, MAX_SECONDLINE, _T("\n\n%s\n"), timestamp);
-
- szPreview = GetPreviewT(dbe.eventType, &dbe);
- if (szPreview) {
- _tcsncat(pdata->eventData[pdata->nrMerged].szText, szPreview, MAX_SECONDLINE);
- mir_free(szPreview);
- } else
- _tcsncat(pdata->eventData[pdata->nrMerged].szText, _T(" "), MAX_SECONDLINE);
-
- pdata->eventData[pdata->nrMerged].szText[MAX_SECONDLINE - 1] = 0;
-
- /*
- * now, reassemble the popup text, make sure the *last* event is shown, and then show the most recent events
- * for which there is enough space in the popup text
- */
-
- available = MAX_SECONDLINE - 1;
- if (pdata->pluginOptions->bShowHeaders) {
- _tcsncpy(lpzText, pdata->szHeader, MAX_SECONDLINE);
- available -= lstrlen(pdata->szHeader);
- }
- for (i = pdata->nrMerged; i >= 0; i--) {
- available -= lstrlen(pdata->eventData[i].szText);
- if (available <= 0)
- break;
- }
- i = (available > 0) ? i + 1 : i + 2;
- for (; i <= pdata->nrMerged; i++) {
- _tcsncat(lpzText, pdata->eventData[i].szText, MAX_SECONDLINE);
- }
- pdata->eventData[pdata->nrMerged].hEvent = hEvent;
- pdata->eventData[pdata->nrMerged].timestamp = dbe.timestamp;
- pdata->nrMerged++;
- if (pdata->nrMerged >= pdata->nrEventsAlloced) {
- pdata->nrEventsAlloced += 5;
- pdata->eventData = (EVENT_DATAT *)mir_realloc(pdata->eventData, pdata->nrEventsAlloced * sizeof(EVENT_DATAT));
- }
- if (dbe.pBlob)
- free(dbe.pBlob);
+ if (pdata->pluginOptions->bShowHeaders) {
+ mir_sntprintf(pdata->szHeader, SIZEOF(pdata->szHeader), _T("%s %d\n"),
+ TranslateT("New messages: "), pdata->nrMerged + 1);
+ pdata->szHeader[255] = 0;
+ }
- CallService(MS_POPUP_CHANGETEXTT, (WPARAM)pdata->hWnd, (LPARAM)lpzText);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ if (pdata->pluginOptions->bPreview && hContact) {
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
+ dbe.pBlob = (PBYTE)malloc(dbe.cbBlob);
}
+ db_event_get(hEvent, &dbe);
+
+ TCHAR timestamp[MAX_DATASIZE];
+ _tcsftime(timestamp, MAX_DATASIZE, _T("%Y.%m.%d %H:%M"), _localtime32((__time32_t *)&dbe.timestamp));
+ mir_sntprintf(pdata->eventData[pdata->nrMerged].szText, MAX_SECONDLINE, _T("\n\n%s\n"), timestamp);
+
+ TCHAR *szPreview = GetPreviewT(dbe.eventType, &dbe);
+ if (szPreview) {
+ _tcsncat(pdata->eventData[pdata->nrMerged].szText, szPreview, MAX_SECONDLINE);
+ mir_free(szPreview);
+ }
+ else _tcsncat(pdata->eventData[pdata->nrMerged].szText, _T(" "), MAX_SECONDLINE);
+
+ pdata->eventData[pdata->nrMerged].szText[MAX_SECONDLINE - 1] = 0;
+
+ /*
+ * now, reassemble the popup text, make sure the *last* event is shown, and then show the most recent events
+ * for which there is enough space in the popup text
+ */
+
+ TCHAR lpzText[MAX_SECONDLINE] = _T("");
+ int i, available = MAX_SECONDLINE - 1;
+ if (pdata->pluginOptions->bShowHeaders) {
+ _tcsncpy(lpzText, pdata->szHeader, MAX_SECONDLINE);
+ available -= lstrlen(pdata->szHeader);
+ }
+ for (i = pdata->nrMerged; i >= 0; i--) {
+ available -= lstrlen(pdata->eventData[i].szText);
+ if (available <= 0)
+ break;
+ }
+ i = (available > 0) ? i + 1 : i + 2;
+ for (; i <= pdata->nrMerged; i++)
+ _tcsncat(lpzText, pdata->eventData[i].szText, MAX_SECONDLINE);
+
+ pdata->eventData[pdata->nrMerged].hEvent = hEvent;
+ pdata->eventData[pdata->nrMerged].timestamp = dbe.timestamp;
+ pdata->nrMerged++;
+ if (pdata->nrMerged >= pdata->nrEventsAlloced) {
+ pdata->nrEventsAlloced += 5;
+ pdata->eventData = (EVENT_DATAT *)mir_realloc(pdata->eventData, pdata->nrEventsAlloced * sizeof(EVENT_DATAT));
+ }
+ if (dbe.pBlob)
+ free(dbe.pBlob);
+
+ CallService(MS_POPUP_CHANGETEXTT, (WPARAM)pdata->hWnd, (LPARAM)lpzText);
return 0;
}
@@ -692,10 +680,10 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, HANDLE hContact, HANDLE hEvent
DBEVENTINFO dbe = { sizeof(dbe) };
// fix for a crash
if (hEvent && (pluginOptions->bPreview || hContact == 0)) {
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob);
}
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
+ db_event_get(hEvent, &dbe);
if (hEvent == 0 && hContact == 0)
dbe.szModule = Translate("Unknown module or contact");
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 243003ab24..172e758b0a 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -1701,20 +1701,17 @@ int TSAPI DM_SplitterGlobalEvent(TWindowData *dat, WPARAM wParam, LPARAM lParam)
void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
TContainerData *m_pContainer = dat->pContainer;
- DBEVENTINFO dbei = {0};
- DWORD dwTimestamp = 0;
- BOOL fIsStatusChangeEvent = FALSE, fIsNotifyEvent = FALSE;
- HWND hwndDlg = dat->hwnd, hwndContainer = m_pContainer->hwnd, hwndTab = GetParent(dat->hwnd);
+ DWORD dwTimestamp = 0;
+ HWND hwndDlg = dat->hwnd, hwndContainer = m_pContainer->hwnd, hwndTab = GetParent(dat->hwnd);
+ HANDLE hDbEvent = (HANDLE)lParam;
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = 0;
-
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (dat->hDbEventFirst == NULL)
- dat->hDbEventFirst = (HANDLE) lParam;
+ dat->hDbEventFirst = hDbEvent;
- fIsStatusChangeEvent = IsStatusEvent(dbei.eventType);
- fIsNotifyEvent = (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE);
+ BOOL fIsStatusChangeEvent = IsStatusEvent(dbei.eventType);
+ BOOL fIsNotifyEvent = (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE);
if (!fIsStatusChangeEvent) {
int heFlags = HistoryEvents_GetFlags(dbei.eventType);
@@ -1761,8 +1758,8 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam)
}
dat->cache->updateStats(TSessionStats::UPDATE_WITH_LAST_RCV, 0);
- if ((HANDLE) lParam != dat->hDbEventFirst) {
- HANDLE nextEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, lParam, 0);
+ if (hDbEvent != dat->hDbEventFirst) {
+ HANDLE nextEvent = db_event_next(hDbEvent);
if (1 || nextEvent == 0) {
if (!(dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED))
SendMessage(hwndDlg, DM_APPENDTOLOG, lParam, 0);
@@ -1773,7 +1770,7 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam)
dat->hQueuedEvents = (HANDLE *)realloc(dat->hQueuedEvents, (dat->iEventQueueSize + 10) * sizeof(HANDLE));
dat->iEventQueueSize += 10;
}
- dat->hQueuedEvents[dat->iNextQueuedEvent++] = (HANDLE)lParam;
+ dat->hQueuedEvents[dat->iNextQueuedEvent++] = hDbEvent;
mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("Autoscrolling is disabled, %d message(s) queued (press F12 to enable it)"),
dat->iNextQueuedEvent);
SetDlgItemText(hwndDlg, IDC_LOGFROZENTEXT, szBuf);
@@ -1805,7 +1802,7 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam)
* try to flash the contact list...
*/
- FlashOnClist(hwndDlg, dat, (HANDLE)lParam, &dbei);
+ FlashOnClist(hwndDlg, dat, hDbEvent, &dbei);
/*
* autoswitch tab if option is set AND container is minimized (otherwise, we never autoswitch)
* never switch for status changes...
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index f358f550bd..394849f8f5 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -647,44 +647,34 @@ int CGlobals::OkToExit(WPARAM wParam, LPARAM lParam)
void CGlobals::RestoreUnreadMessageAlerts(void)
{
- CLISTEVENT cle = { 0 };
- DBEVENTINFO dbei = { 0 };
- TCHAR toolTip[256];
- int windowAlreadyExists;
- int usingReadNext = 0;
-
- int autoPopup = M->GetByte(SRMSGMOD, SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP);
- HANDLE hDbEvent, hContact;
-
- dbei.cbSize = sizeof(dbei);
- cle.cbSize = sizeof(cle);
+ CLISTEVENT cle = { sizeof(cle) };
cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
cle.pszService = "SRMsg/ReadMessage";
cle.flags = CLEF_TCHAR;
- hContact = db_find_first();
+ HANDLE hContact = db_find_first();
while (hContact) {
-
if (M->GetDword(hContact, "SendLater", "count", 0))
sendLater->addContact(hContact);
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && dbei.eventType == EVENTTYPE_MESSAGE) {
- windowAlreadyExists = M->FindWindow(hContact) != NULL;
- if (!usingReadNext && windowAlreadyExists)
+ if (M->FindWindow(hContact) != NULL)
continue;
cle.hContact = hContact;
cle.hDbEvent = hDbEvent;
+
+ TCHAR toolTip[256];
mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"),
(TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
cle.ptszTooltip = toolTip;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle);
}
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
hContact = db_find_next(hContact);
}
@@ -718,12 +708,10 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c)
if (wStatus == wOldStatus)
return;
- DBEVENTINFO dbei;
TCHAR buffer[450];
- HANDLE hNewEvent;
- TCHAR* szOldStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wOldStatus, GSMDF_TCHAR);
- TCHAR* szNewStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, GSMDF_TCHAR);
+ TCHAR *szOldStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wOldStatus, GSMDF_TCHAR);
+ TCHAR *szNewStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, GSMDF_TCHAR);
if (szOldStatus == 0 || szNewStatus == 0)
return;
@@ -737,18 +725,15 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c)
mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("changed status from %s to %s."), szOldStatus, szNewStatus);
}
- char *szMsg = mir_utf8encodeT(buffer);
-
- dbei.pBlob = (PBYTE)szMsg;
+ mir_ptr<char> szMsg( mir_utf8encodeT(buffer));
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.pBlob = (PBYTE)(char*)szMsg;
dbei.cbBlob = lstrlenA(szMsg) + 1;
dbei.flags = DBEF_UTF | DBEF_READ;
- dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_STATUSCHANGE;
dbei.timestamp = time(NULL);
dbei.szModule = const_cast<char *>(c->getProto());
- hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM) hContact, (LPARAM) & dbei);
-
- mir_free(szMsg);
+ db_event_add(hContact, &dbei);
}
}
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp
index 936d1991b7..2c13a771a2 100644
--- a/plugins/TabSRMM/src/hotkeyhandler.cpp
+++ b/plugins/TabSRMM/src/hotkeyhandler.cpp
@@ -451,7 +451,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
*/
case DM_REMOVECLISTEVENT:
CallService(MS_CLIST_REMOVEEVENT, wParam, lParam);
- CallService(MS_DB_EVENT_MARKREAD, wParam, lParam);
+ db_event_markRead((HANDLE)wParam, (HANDLE)lParam);
return 0;
case DM_SETLOCALE:
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp
index 0c9f5a33f9..51106b4cfb 100644
--- a/plugins/TabSRMM/src/mim.cpp
+++ b/plugins/TabSRMM/src/mim.cpp
@@ -693,21 +693,16 @@ int CMimAPI::DispatchNewEvent(WPARAM wParam, LPARAM lParam)
int CMimAPI::MessageEventAdded(WPARAM wParam, LPARAM lParam)
{
- HWND hwnd;
- CLISTEVENT cle;
- DBEVENTINFO dbei;
BYTE bAutoPopup = FALSE, bAutoCreate = FALSE, bAutoContainer = FALSE, bAllowAutoCreate = 0;
struct TContainerData *pContainer = 0;
TCHAR szName[CONTAINER_NAMELEN + 1];
DWORD dwStatusMask = 0;
struct TWindowData *mwdat=NULL;
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
- hwnd = M->FindWindow((HANDLE) wParam);
+ HWND hwnd = M->FindWindow((HANDLE)wParam);
if (dbei.flags & DBEF_SENT || !(dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) || dbei.flags & DBEF_READ)
return 0;
@@ -855,8 +850,8 @@ nowindowcreate:
UpdateTrayMenu(0, 0, dbei.szModule, NULL, (HANDLE)wParam, 1);
if (!nen_options.bTraySupport) {
TCHAR toolTip[256], *contactName;
- ZeroMemory(&cle, sizeof(cle));
- cle.cbSize = sizeof(cle);
+
+ CLISTEVENT cle = { sizeof(cle) };
cle.hContact = (HANDLE) wParam;
cle.hDbEvent = (HANDLE) lParam;
cle.flags = CLEF_TCHAR;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index fc6860a91f..4a894d1405 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1539,18 +1539,18 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
//dat->dwFlags &= ~MWF_INITMODE;
{
- HANDLE hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->hContact, 0);
+ HANDLE hdbEvent = db_event_last(dat->hContact);
if (hdbEvent) {
do {
DBEVENTINFO dbei = { sizeof(dbei) };
- CallService(MS_DB_EVENT_GET, (WPARAM) hdbEvent, (LPARAM) & dbei);
+ db_event_get(hdbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
dat->lastMessage = dbei.timestamp;
DM_UpdateLastMessage(dat);
break;
}
}
- while (hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) hdbEvent, 0));
+ while (hdbEvent = db_event_prev(hdbEvent));
}
}
SendMessage(hwndContainer, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
@@ -1612,9 +1612,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
* show a popup if wanted...
*/
if (newData->bWantPopup) {
- DBEVENTINFO dbei = {0};
+ DBEVENTINFO dbei = { sizeof(dbei) };
newData->bWantPopup = FALSE;
- CallService(MS_DB_EVENT_GET, (WPARAM)newData->hdbEvent, (LPARAM)&dbei);
+ db_event_get(newData->hdbEvent, &dbei);
tabSRMM_ShowPopup((WPARAM)dat->hContact, (LPARAM)newData->hdbEvent, dbei.eventType, 0, 0, hwndDlg, dat->cache->getActiveProto(), dat);
}
if (m_pContainer->dwFlags & CNT_CREATE_MINIMIZED) {
@@ -3116,7 +3116,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
free(szQuoted);
break;
} else {
- hDBEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)dat->hContact, 0);
+ hDBEvent = db_event_last(dat->hContact);
goto quote_from_last;
}
}
@@ -3127,14 +3127,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
quote_from_last:
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
- DBEVENTINFO dbei = {0};
- int iDescr;
-
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDBEvent, 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(hDBEvent);
szText = (TCHAR *)malloc((dbei.cbBlob + 1) * sizeof(TCHAR)); //URLs are made one char bigger for crlf
dbei.pBlob = (BYTE *)szText;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei);
+ db_event_get(hDBEvent, &dbei);
iSize = (int)(strlen((char *)dbei.pBlob)) + 1;
if (dbei.flags & DBEF_UTF) {
szConverted = mir_utf8decodeW((char*)szText);
@@ -3149,7 +3146,7 @@ quote_from_last:
}
}
if (dbei.eventType == EVENTTYPE_FILE) {
- iDescr = lstrlenA((char *)(szText + sizeof(DWORD)));
+ int iDescr = lstrlenA((char *)(szText + sizeof(DWORD)));
MoveMemory(szText, szText + sizeof(DWORD), iDescr);
MoveMemory(szText + iDescr + 2, szText + sizeof(DWORD) + iDescr, dbei.cbBlob - iDescr - sizeof(DWORD) - 1);
szText[iDescr] = '\r';
@@ -3731,10 +3728,9 @@ quote_from_last:
DeleteMenu(PluginConfig.g_hMenuTrayUnread, (UINT_PTR)dat->hContact, MF_BYCOMMAND);
M->RemoveWindow(hwndDlg);
- if (dat->cache->isValid()) {
+ if (dat->cache->isValid())
M->WriteDword(SRMSGMOD, "multisplit", dat->multiSplitterX);
- WriteStatsOnClose(dat);
- }
+
{
HFONT hFont = (HFONT) SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETFONT, 0, 0);
if (hFont != NULL && hFont != (HFONT) SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index cbea9ed83e..8f0708a686 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -288,35 +288,6 @@ void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo)
dat->pic.cx = (int)newWidth + 2;
}
-void TSAPI WriteStatsOnClose(TWindowData *dat)
-{
- /*
- DBEVENTINFO dbei;
- char buffer[450];
- HANDLE hNewEvent;
- time_t now = time(NULL);
- now = now - dat->stats.started;
-
- return;
-
- if (dat->hContact != 0 &&(PluginConfig.m_LogStatusChanges != 0) && M->GetByte(dat->hContact, "logstatuschanges", 0)) {
- mir_snprintf(buffer, sizeof(buffer), "Session close - active for: %d:%02d:%02d, Sent: %d (%d), Rcvd: %d (%d)", now / 3600, now / 60, now % 60, dat->stats.iSent, dat->stats.iSentBytes, dat->stats.iReceived, dat->stats.iReceivedBytes);
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = (PBYTE) buffer;
- dbei.cbBlob = (int)(strlen(buffer)) + 1;
- dbei.eventType = EVENTTYPE_STATUSCHANGE;
- dbei.flags = DBEF_READ;
- dbei.timestamp = time(NULL);
- dbei.szModule = dat->szProto;
- hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM) dat->hContact, (LPARAM) & dbei);
- if (dat->hDbEventFirst == NULL) {
- dat->hDbEventFirst = hNewEvent;
- SendMessage(dat->hwnd, DM_REMAKELOG, 0, 0);
- }
- }
- */
-}
-
int TSAPI MsgWindowUpdateMenu(TWindowData *dat, HMENU submenu, int menuID)
{
HWND hwndDlg = dat->hwnd;
@@ -1413,7 +1384,7 @@ void TSAPI FindFirstEvent(TWindowData *dat)
if (historyMode == -1)
historyMode = (int)M->GetByte(SRMSGMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
- dat->hDbEventFirst = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) dat->hContact, 0);
+ dat->hDbEventFirst = db_event_firstUnread(dat->hContact);
if (dat->bActualHistory)
historyMode = LOADHISTORY_COUNT;
@@ -1432,14 +1403,14 @@ void TSAPI FindFirstEvent(TWindowData *dat)
//
for (; i > 0; i--) {
if (dat->hDbEventFirst == NULL)
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->hContact, 0);
+ hPrevEvent = db_event_last(dat->hContact);
else
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) dat->hDbEventFirst, 0);
+ hPrevEvent = db_event_prev(dat->hDbEventFirst);
if (hPrevEvent == NULL)
break;
dbei.cbBlob = 0;
dat->hDbEventFirst = hPrevEvent;
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventFirst, (LPARAM) & dbei);
+ db_event_get(dat->hDbEventFirst, &dbei);
if (!DbEventIsShown(dat, &dbei))
i++;
}
@@ -1454,17 +1425,17 @@ void TSAPI FindFirstEvent(TWindowData *dat)
if (dat->hDbEventFirst == NULL)
dbei.timestamp = time(NULL);
else
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventFirst, (LPARAM) & dbei);
+ db_event_get(dat->hDbEventFirst, &dbei);
firstTime = dbei.timestamp - 60 * DBGetContactSettingWord(NULL, SRMSGMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
for (;;) {
if (dat->hDbEventFirst == NULL)
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->hContact, 0);
+ hPrevEvent = db_event_last(dat->hContact);
else
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) dat->hDbEventFirst, 0);
+ hPrevEvent = db_event_prev(dat->hDbEventFirst);
if (hPrevEvent == NULL)
break;
dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM) hPrevEvent, (LPARAM) & dbei);
+ db_event_get(hPrevEvent, &dbei);
if (dbei.timestamp < firstTime)
break;
dat->hDbEventFirst = hPrevEvent;
diff --git a/plugins/TabSRMM/src/msgdlgutils.h b/plugins/TabSRMM/src/msgdlgutils.h
index 40141064a2..7b29990778 100644
--- a/plugins/TabSRMM/src/msgdlgutils.h
+++ b/plugins/TabSRMM/src/msgdlgutils.h
@@ -36,7 +36,6 @@
void TSAPI CalcDynamicAvatarSize (TWindowData *dat, BITMAP *bminfo);
char* TSAPI GetCurrentMetaContactProto (TWindowData *dat);
-void TSAPI WriteStatsOnClose (TWindowData *dat);
int TSAPI MsgWindowUpdateMenu (TWindowData *dat, HMENU submenu, int menuID);
int TSAPI MsgWindowMenuHandler (TWindowData *dat, int selection, int menuId);
int TSAPI GetAvatarVisibility (HWND hwndDlg, TWindowData *dat);
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 8f3e09f1f5..fabeb63f2a 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -600,13 +600,13 @@ static char *Template_CreateRTFFromDbEvent(struct TWindowData *dat, HANDLE hCont
dbei = *(streamData->dbei);
else {
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) hDbEvent, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob == -1) {
free(buffer);
return NULL;
}
dbei.pBlob = (PBYTE) malloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
+ db_event_get(hDbEvent, &dbei);
if (!DbEventIsShown(dat, &dbei)) {
free(dbei.pBlob);
free(buffer);
@@ -656,7 +656,7 @@ static char *Template_CreateRTFFromDbEvent(struct TWindowData *dat, HANDLE hCont
isSent = (dbei.flags & DBEF_SENT);
if (!isSent && (fIsStatusChangeEvent || dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent);
+ db_event_markRead(hContact, hDbEvent);
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
}
@@ -1195,7 +1195,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
dat->buffer = Template_CreateRTFFromDbEvent(dat->dlgDat, dat->hContact, dat->hDbEvent, !dat->isEmpty, dat);
if (dat->buffer)
dat->hDbEventLast = dat->hDbEvent;
- dat->hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) dat->hDbEvent, 0);
+ dat->hDbEvent = db_event_next(dat->hDbEvent);
if (--dat->eventsToInsert == 0)
break;
} while (dat->buffer == NULL && dat->hDbEvent);
@@ -1308,7 +1308,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp
if (fAppend)
dat->hDbEventLast = hDbEventFirst;
else
- dat->hDbEventLast = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)dat->hContact, 0);
+ dat->hDbEventLast = db_event_last(dat->hContact);
return;
}
if (dat->hwndHPP != 0) {
@@ -1336,7 +1336,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp
if (fAppend)
dat->hDbEventLast = hDbEventFirst;
else
- dat->hDbEventLast = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)dat->hContact, 0);
+ dat->hDbEventLast = db_event_last(dat->hContact);
return;
}
@@ -1411,7 +1411,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp
else {
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEventFirst, (LPARAM)&dbei);
+ db_event_get(hDbEventFirst, &dbei);
isSent = (dbei.flags & DBEF_SENT) != 0;
}
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index 500b8c22e9..5b740bb503 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -525,10 +525,8 @@ HANDLE CSendLater::processAck(const ACKDATA *ack)
while(it != m_sendLaterJobList.end()) {
if ((*it)->hProcess == ack->hProcess && (*it)->hTargetContact == ack->hContact && !((*it)->fSuccess || (*it)->fFailed)) {
- DBEVENTINFO dbei = {0};
-
if (!(*it)->fSuccess) {
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT;
dbei.szModule = GetContactProto(((*it)->hContact));
@@ -536,7 +534,7 @@ HANDLE CSendLater::processAck(const ACKDATA *ack)
dbei.cbBlob = lstrlenA((*it)->sendBuffer) + 1;
dbei.flags |= DBEF_UTF;
dbei.pBlob = (PBYTE)((*it)->sendBuffer);
- HANDLE hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM)((*it)->hContact), (LPARAM)&dbei);
+ db_event_add((*it)->hContact, &dbei);
(*it)->cleanDB();
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index e2a609db61..4998c3ad45 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -820,7 +820,7 @@ inform_and_discard:
if (m_jobs[iFound].dwFlags & PREF_UTF)
dbei.flags |= DBEF_UTF;
dbei.pBlob = (PBYTE) m_jobs[iFound].sendBuffer;
- hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM) m_jobs[iFound].hOwner, (LPARAM) & dbei);
+ hNewEvent = db_event_add(m_jobs[iFound].hOwner, &dbei);
if (m_pContainer) {
if (!nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND))