summaryrefslogtreecommitdiff
path: root/plugins
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
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')
-rw-r--r--plugins/AutoShutdown/src/watcher.cpp21
-rw-r--r--plugins/AvatarHistory/src/AvatarDlg.cpp10
-rw-r--r--plugins/AvatarHistory/src/AvatarHistory.cpp2
-rw-r--r--plugins/BasicHistory/src/EventList.cpp69
-rw-r--r--plugins/BasicHistory/src/EventList.h2
-rw-r--r--plugins/BasicHistory/src/HistoryWindow.cpp16
-rw-r--r--plugins/BasicHistory/src/Scheduler.cpp6
-rw-r--r--plugins/Boltun/src/actionQueue.cpp2
-rw-r--r--plugins/Boltun/src/boltun.cpp9
-rw-r--r--plugins/BuddyExpectator/src/BuddyExpectator.cpp22
-rw-r--r--plugins/BuddyPounce/src/dialog.cpp16
-rw-r--r--plugins/BuddyPounce/src/main.cpp37
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp10
-rw-r--r--plugins/Clist_modern/src/modern_contact.cpp13
-rw-r--r--plugins/Clist_nicer/src/clc.cpp7
-rw-r--r--plugins/Clist_nicer/src/contact.cpp225
-rw-r--r--plugins/CmdLine/src/mimcmd_handlers.cpp190
-rw-r--r--plugins/ContactsPlus/src/main.cpp32
-rw-r--r--plugins/ContactsPlus/src/receive.cpp6
-rw-r--r--plugins/ContactsPlus/src/send.cpp2
-rw-r--r--plugins/FTPFileYM/src/job_upload.cpp2
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp16
-rw-r--r--plugins/FlashAvatars/src/cflash.cpp7
-rw-r--r--plugins/HistoryLinkListPlus/src/linklist.cpp68
-rw-r--r--plugins/HistoryLinkListPlus/src/linklist_fct.cpp75
-rw-r--r--plugins/HistorySweeperLight/src/historysweeperlight.cpp32
-rw-r--r--plugins/IEView/src/HTMLBuilder.cpp17
-rw-r--r--plugins/Import/src/utils.cpp30
-rw-r--r--plugins/KeyboardNotify/src/main.cpp29
-rw-r--r--plugins/MenuItemEx/src/main.cpp2
-rwxr-xr-xplugins/MetaContacts/src/meta_services.cpp11
-rw-r--r--plugins/MetaContacts/src/meta_utils.cpp11
-rw-r--r--plugins/MirOTR/MirOTR/src/dbfilter.cpp37
-rwxr-xr-xplugins/Msg_Export/src/FileViewer.cpp30
-rwxr-xr-xplugins/Msg_Export/src/options.cpp14
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp38
-rw-r--r--plugins/NewEventNotify/src/main.cpp5
-rw-r--r--plugins/NewEventNotify/src/popup.cpp22
-rw-r--r--plugins/NewXstatusNotify/src/xstatus.cpp4
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp5
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp22
-rw-r--r--plugins/NoHistory/src/dllmain.cpp27
-rw-r--r--plugins/Nudge/src/main.cpp18
-rw-r--r--plugins/PasteIt/src/PasteIt.cpp2
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp2
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp17
-rw-r--r--plugins/Quotes/src/QuotesProviderBase.cppbin57792 -> 57572 bytes
-rw-r--r--plugins/RecentContacts/src/RecentContacts.cpp46
-rw-r--r--plugins/SMS/src/SMS_svc.cpp116
-rw-r--r--plugins/SMS/src/common.h1
-rw-r--r--plugins/SMS/src/functions.cpp21
-rw-r--r--plugins/SMS/src/receive.cpp116
-rw-r--r--plugins/SMS/src/senddlg.cpp42
-rw-r--r--plugins/Scriver/src/chat/clist.cpp4
-rw-r--r--plugins/Scriver/src/globals.cpp2
-rw-r--r--plugins/Scriver/src/msgdialog.cpp119
-rw-r--r--plugins/Scriver/src/msglog.cpp10
-rw-r--r--plugins/Scriver/src/msgs.cpp20
-rw-r--r--plugins/SecureIM/src/dbevent.cpp12
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp13
-rw-r--r--plugins/SimpleAR/src/Main.cpp6
-rw-r--r--plugins/SmileyAdd/src/regexp/WCPattern.cpp14
-rw-r--r--plugins/StatusChange/src/main.cpp6
-rwxr-xr-xplugins/StopSpamMod/src/stopspam.cpp38
-rwxr-xr-xplugins/StopSpamMod/src/utilities.cpp5
-rw-r--r--plugins/StopSpamPlus/src/events.cpp8
-rw-r--r--plugins/StopSpamPlus/src/services.cpp8
-rw-r--r--plugins/StopSpamPlus/src/utils.cpp11
-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
-rw-r--r--plugins/TipperYM/src/subst.cpp100
-rw-r--r--plugins/TipperYM/src/tipper.cpp7
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp100
-rw-r--r--plugins/UserInfoEx/src/mir_db.cpp75
-rw-r--r--plugins/UserInfoEx/src/mir_db.h4
-rw-r--r--plugins/Variables/src/parse_miranda.cpp30
-rw-r--r--plugins/Variables/src/parse_str.cpp15
-rw-r--r--plugins/Variables/src/parse_xml.cpp4
-rw-r--r--plugins/Weather/src/weather_update.cpp8
88 files changed, 982 insertions, 1536 deletions
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp
index 0162ca5867..10323614d6 100644
--- a/plugins/AutoShutdown/src/watcher.cpp
+++ b/plugins/AutoShutdown/src/watcher.cpp
@@ -91,19 +91,20 @@ static TCHAR* GetMessageText(BYTE **ppBlob,DWORD *pcbBlob)
static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
{
- if(currentWatcherType&SDWTF_MESSAGE) {
- DBEVENTINFO dbe;
- dbe.cbSize=sizeof(dbe);
- dbe.cbBlob=(DWORD)CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)lParam,0);
- dbe.pBlob=(BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
- if(dbe.pBlob==NULL) return 0;
- if(!CallService(MS_DB_EVENT_GET,(WPARAM)lParam,(LPARAM)&dbe))
- if(dbe.eventType==EVENTTYPE_MESSAGE && !(dbe.flags&DBEF_SENT)) {
+ HANDLE hDbEvent = (HANDLE)lParam;
+
+ if (currentWatcherType & SDWTF_MESSAGE) {
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(hDbEvent);
+ dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
+ if (dbe.pBlob == NULL)
+ return 0;
+ if (!db_event_get(hDbEvent, &dbe))
+ if(dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
DBVARIANT dbv;
- TCHAR *pszMsg;
if(!DBGetContactSettingTString(NULL,"AutoShutdown","Message",&dbv)) {
TrimString(dbv.ptszVal);
- pszMsg=GetMessageText(&dbe.pBlob,&dbe.cbBlob);
+ TCHAR *pszMsg = GetMessageText(&dbe.pBlob,&dbe.cbBlob);
if(pszMsg!=NULL && _tcsstr(pszMsg,dbv.ptszVal)!=NULL)
ShutdownAndStopWatcher(); /* msg with specified text recvd */
mir_free(dbv.ptszVal); /* does NULL check */
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp
index d71bbc1880..3adf17107c 100644
--- a/plugins/AvatarHistory/src/AvatarDlg.cpp
+++ b/plugins/AvatarHistory/src/AvatarDlg.cpp
@@ -244,7 +244,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM l
HANDLE hContact = (HANDLE) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (le->hDbEvent)
- CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)le->hDbEvent);
+ db_event_delete(hContact, le->hDbEvent);
else
DeleteFile(le->filelink);
@@ -283,7 +283,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM l
DeleteFile(le->filename);
if (le->hDbEvent)
- CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)le->hDbEvent);
+ db_event_delete(hContact, le->hDbEvent);
else
DeleteFile(le->filelink);
@@ -407,13 +407,11 @@ int FillAvatarListFromDB(HWND list, HANDLE hContact)
{
int max_pos = 0;
BYTE blob[2048];
- for (HANDLE hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
- hDbEvent != NULL;
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0)) {
+ for (HANDLE hDbEvent = db_event_first(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = sizeof(blob);
dbei.pBlob = blob;
- if ( CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) != 0) continue;
+ if (db_event_get(hDbEvent, &dbei) != 0) continue;
if (dbei.eventType != EVENTTYPE_AVATAR_CHANGE) continue;
// Get time
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp
index 4087b1fec5..2c4e8e1ee2 100644
--- a/plugins/AvatarHistory/src/AvatarHistory.cpp
+++ b/plugins/AvatarHistory/src/AvatarHistory.cpp
@@ -227,7 +227,7 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam)
dbei.eventType = EVENTTYPE_AVATAR_CHANGE;
dbei.cbBlob = (DWORD) strlen(blob) + 1;
dbei.pBlob = (PBYTE)(char*)blob;
- CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
}
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp
index 930f8827bc..31a4f62506 100644
--- a/plugins/BasicHistory/src/EventList.cpp
+++ b/plugins/BasicHistory/src/EventList.cpp
@@ -232,14 +232,13 @@ std::wstring EventList::GetFilterName()
void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter, bool noExt, HANDLE _hContact)
{
- HANDLE hDbEvent;
bool isWndLocal = isWnd;
EventTempIndex ti;
- EventIndex ei;
EventData data;
+ EventIndex ei;
ti.isExternal = false;
ei.isExternal = false;
- hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRST,(WPARAM)_hContact,0);
+ HANDLE hDbEvent = db_event_first(_hContact);
while ( hDbEvent != NULL )
{
if (isWndLocal && !IsWindow( hWnd ))
@@ -254,7 +253,7 @@ void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter,
tempList.push_back(ti);
}
}
- hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0);
+ hDbEvent = db_event_next(hDbEvent);
}
if(!noExt)
@@ -721,14 +720,13 @@ void EventList::MargeMessages(const std::vector<IImport::ExternalMessage>& messa
ImportMessages(messages);
std::list<EventTempIndex> tempList;
GetTempList(tempList, true, false, hContact);
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(DBEVENTINFO);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(hContact);
+
CallService(MS_DB_SETSAFETYMODE, (WPARAM)FALSE, 0);
- for(std::list<EventTempIndex>::iterator it = tempList.begin(); it != tempList.end(); ++it)
- {
- if(it->isExternal)
- {
+ for(std::list<EventTempIndex>::iterator it = tempList.begin(); it != tempList.end(); ++it) {
+ if(it->isExternal) {
IImport::ExternalMessage& msg = importedMessages[it->exIdx];
dbei.flags = msg.flags & (~(DBEF_FIRST));
dbei.flags |= DBEF_READ;
@@ -740,7 +738,7 @@ void EventList::MargeMessages(const std::vector<IImport::ExternalMessage>& messa
char* buf = new char[dbei.cbBlob];
dbei.cbBlob = WideCharToMultiByte(cp, 0, msg.message.c_str(), (int)msg.message.length() + 1, buf, dbei.cbBlob, NULL, NULL);
dbei.pBlob = (PBYTE)buf;
- CallService(MS_DB_EVENT_ADD, (WPARAM) hContact, (LPARAM) & dbei);
+ db_event_add(hContact, &dbei);
delete buf;
}
}
@@ -752,34 +750,27 @@ void EventList::MargeMessages(const std::vector<IImport::ExternalMessage>& messa
bool EventList::GetEventData(const EventIndex& ev, EventData& data)
{
- if(!ev.isExternal)
- {
- DWORD newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)ev.hEvent,0);
- if(newBlobSize>goldBlobSize)
- {
- gdbei.pBlob=(PBYTE)mir_realloc(gdbei.pBlob,newBlobSize);
- goldBlobSize=newBlobSize;
+ if(!ev.isExternal) {
+ int newBlobSize = db_event_getBlobSize(ev.hEvent);
+ if(newBlobSize > goldBlobSize) {
+ gdbei.pBlob = (PBYTE)mir_realloc(gdbei.pBlob,newBlobSize);
+ goldBlobSize = newBlobSize;
}
gdbei.cbBlob = goldBlobSize;
- if (CallService(MS_DB_EVENT_GET,(WPARAM)ev.hEvent,(LPARAM)&gdbei) == 0)
- {
+ if (db_event_get(ev.hEvent, &gdbei) == 0) {
data.isMe = (gdbei.flags & DBEF_SENT) != 0;
data.eventType = gdbei.eventType;
data.timestamp = gdbei.timestamp;
return true;
}
}
- else
- {
- if(ev.exIdx >= 0 && ev.exIdx < (int)importedMessages.size())
- {
- IImport::ExternalMessage& em = importedMessages[ev.exIdx];
- data.isMe = (em.flags & DBEF_SENT) != 0;
- data.eventType = em.eventType;
- data.timestamp = em.timestamp;
- return true;
- }
+ else if(ev.exIdx >= 0 && ev.exIdx < (int)importedMessages.size()) {
+ IImport::ExternalMessage& em = importedMessages[ev.exIdx];
+ data.isMe = (em.flags & DBEF_SENT) != 0;
+ data.eventType = em.eventType;
+ data.timestamp = em.timestamp;
+ return true;
}
return false;
@@ -814,18 +805,12 @@ void EventList::RebuildGroup(int selected)
for(size_t i = 0; i < eventList[selected].size(); ++i)
{
EventIndex& ev = eventList[selected][i];
- if(!ev.isExternal)
- {
- if(CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)(HANDLE)ev.hEvent,0) >= 0)
- {
- // If event exist, we add it to new group
+ if(!ev.isExternal) {
+ // If event exist, we add it to new group
+ if (db_event_getBlobSize(ev.hEvent) >= 0)
newGroup.push_back(eventList[selected][i]);
- }
- }
- else
- {
- newGroup.push_back(eventList[selected][i]);
}
+ else newGroup.push_back(eventList[selected][i]);
}
eventList[selected].clear();
eventList[selected].insert(eventList[selected].begin(), newGroup.begin(), newGroup.end());
@@ -868,13 +853,11 @@ void EventList::Deinit()
int EventList::GetContactMessageNumber(HANDLE hContact)
{
- int count = CallService(MS_DB_EVENT_GETCOUNT,(WPARAM)hContact,0);
+ int count = db_event_count(hContact);
EnterCriticalSection(&criticalSection);
std::map<HANDLE, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
if(it != contactFileMap.end())
- {
++count;
- }
LeaveCriticalSection(&criticalSection);
return count;
diff --git a/plugins/BasicHistory/src/EventList.h b/plugins/BasicHistory/src/EventList.h
index 36628ff278..cfb76e4779 100644
--- a/plugins/BasicHistory/src/EventList.h
+++ b/plugins/BasicHistory/src/EventList.h
@@ -96,7 +96,7 @@ protected:
void DeleteEvent(const EventIndex& ev)
{
if(!ev.isExternal)
- CallService(MS_DB_EVENT_DELETE,(WPARAM)hContact,(LPARAM)(HANDLE)ev.hEvent);
+ db_event_delete(hContact, ev.hEvent);
}
void RebuildGroup(int selected);
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp
index 8fefc1062b..ea2e1edc69 100644
--- a/plugins/BasicHistory/src/HistoryWindow.cpp
+++ b/plugins/BasicHistory/src/HistoryWindow.cpp
@@ -476,25 +476,19 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM wParam, LPARAM lParam)
return FALSE;
std::deque<HANDLE> toRemove;
- HANDLE hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRST,(WPARAM)hContact,0);
- while ( hDbEvent != NULL )
- {
+ HANDLE hDbEvent = db_event_first(hContact);
+ while ( hDbEvent != NULL ) {
toRemove.push_back(hDbEvent);
- hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0);
+ hDbEvent = db_event_next(hDbEvent);
}
for(std::deque<HANDLE>::iterator it = toRemove.begin(); it != toRemove.end(); ++it)
- {
- CallService(MS_DB_EVENT_DELETE,(WPARAM)hContact,(LPARAM)(HANDLE)*it);
- }
+ db_event_delete(hContact, *it);
- if(EventList::IsImportedHistory(hContact))
- {
+ if(EventList::IsImportedHistory(hContact)) {
TCHAR *message = TranslateT("Do you want delete all imported messages for this contact?\nNote that next scheduler task import this messages again.");
if(MessageBox(hWnd, message, TranslateT("Are You sure?"), MB_YESNO | MB_ICONERROR) == IDYES)
- {
EventList::DeleteImporter(hContact);
- }
}
RebuildEvents(hContact);
diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp
index d408563e72..dcc35024fd 100644
--- a/plugins/BasicHistory/src/Scheduler.cpp
+++ b/plugins/BasicHistory/src/Scheduler.cpp
@@ -1541,8 +1541,8 @@ void DoError(const TaskOptions& to, const std::wstring _error)
std::wstring error = msg;
error += L"\n";
error += _error;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(DBEVENTINFO);
+
+ DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = MODULE;
dbei.flags = DBEF_UTF | DBEF_READ;
dbei.timestamp = time(NULL);
@@ -1553,7 +1553,7 @@ void DoError(const TaskOptions& to, const std::wstring _error)
char* buf = new char[dbei.cbBlob];
dbei.cbBlob = WideCharToMultiByte(CP_UTF8, 0, error.c_str(), len, buf, dbei.cbBlob, NULL, NULL);
dbei.pBlob = (PBYTE)buf;
- CallService(MS_DB_EVENT_ADD, NULL, (LPARAM) & dbei);
+ db_event_add(NULL, &dbei);
}
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp
index c8e8e02aa4..e652ce8061 100644
--- a/plugins/Boltun/src/actionQueue.cpp
+++ b/plugins/Boltun/src/actionQueue.cpp
@@ -125,7 +125,7 @@ static void TimerAnswer(HANDLE hContact, const TalkBot::MessageInfo* info)
ldbei.szModule = BOLTUN_NAME;
ldbei.timestamp = (DWORD)time(NULL);
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&ldbei);
+ db_event_add(hContact, &ldbei);
bot->AnswerGiven(hContact, *info);
delete info;
diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp
index 99eb76ef2b..fdf9fbf78c 100644
--- a/plugins/Boltun/src/boltun.cpp
+++ b/plugins/Boltun/src/boltun.cpp
@@ -220,8 +220,7 @@ static bool BoltunAutoChat(HANDLE hContact)
static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
{
- //DBEVENTINFO ldbei;
- HANDLE hContact = (HANDLE)wParam;
+ HANDLE hContact = (HANDLE)wParam, hDbEvent = (HANDLE)lParam;
if (!BoltunAutoChat(hContact))
return 0;
@@ -230,7 +229,7 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
dbei.cbSize = sizeof(dbei);
dbei.cbBlob = 0;
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, lParam, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob == -1)
return 0;
@@ -238,7 +237,7 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
if (dbei.pBlob == NULL)
return 0;
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
if (dbei.flags & DBEF_SENT || dbei.flags & DBEF_READ || dbei.eventType != EVENTTYPE_MESSAGE)
return 0;
DBEVENTGETTEXT egt;
@@ -248,7 +247,7 @@ static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
TCHAR* s = (TCHAR*)(void*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&egt);
free(dbei.pBlob);
if (Config.MarkAsRead)
- CallService(MS_DB_EVENT_MARKREAD, wParam, lParam);
+ db_event_markRead(hContact, hDbEvent);
AnswerToContact(hContact, s);
mir_free(s);
diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp
index d6e425ea36..bdaff06159 100644
--- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp
+++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp
@@ -81,20 +81,14 @@ void setLastSeen(HANDLE hContact)
time_t getLastInputMsg(HANDLE hContact)
{
- HANDLE hDbEvent;
- DBEVENTINFO dbei = {0};
-
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
- while (hDbEvent)
- {
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = 0;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
- return dbei.timestamp;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
- }
+ HANDLE hDbEvent = db_event_last(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
+ return dbei.timestamp;
+ hDbEvent = db_event_prev(hDbEvent);
+ }
return -1;
}
diff --git a/plugins/BuddyPounce/src/dialog.cpp b/plugins/BuddyPounce/src/dialog.cpp
index 5b466b98df..64a218848e 100644
--- a/plugins/BuddyPounce/src/dialog.cpp
+++ b/plugins/BuddyPounce/src/dialog.cpp
@@ -8,29 +8,23 @@ void populateSettingsList(HWND hwnd2List)
SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Reuse Pounce"));
SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Give Up delay"));
SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Confirmation Window"));
-// SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)"----------------------------"));
-// SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Send a File"));
}
void populateContacts(HANDLE BPhContact,HWND hwnd2CB)
{
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- while (hContact)
- {
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
+ if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) {
TCHAR name[300];
mir_sntprintf(name, SIZEOF(name), _T("%s (%s)"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR), _A2T(szProto));
int index = SendMessage(hwnd2CB, CB_ADDSTRING, 0, (LPARAM)name);
SendMessage(hwnd2CB, CB_SETITEMDATA, index, (LPARAM)hContact);
- if (BPhContact == hContact) SendMessage(hwnd2CB, CB_SETCURSEL, index, 0);
+ if (BPhContact == hContact)
+ SendMessage(hwnd2CB, CB_SETCURSEL, index, 0);
}
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
}
-
void saveLastSetting(HANDLE hContact, HWND hwnd)
{
TCHAR number[8];//, string[1024];//for sending file name
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp
index 5dc859eb9b..77d86a0afc 100644
--- a/plugins/BuddyPounce/src/main.cpp
+++ b/plugins/BuddyPounce/src/main.cpp
@@ -72,18 +72,16 @@ int MsgAck(WPARAM wParam, LPARAM lParam)
DBEVENTINFO dbei = { 0 };
DBVARIANT dbv;
int reuse = db_get_b(ack->hContact,modname, "Reuse", 0);
- if (!db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0'))
- {
- char* pszUtf = mir_utf8encodeT(dbv.ptszVal);
+ if ( !db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
+ mir_ptr<char> pszUtf( mir_utf8encodeT(dbv.ptszVal));
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_UTF | DBEF_SENT;
dbei.szModule = (char*)ack->szModule;
dbei.timestamp = time(NULL);
dbei.cbBlob = lstrlenA(pszUtf) + 1;
- dbei.pBlob = (PBYTE)pszUtf;
- CallService(MS_DB_EVENT_ADD, (WPARAM)ack->hContact, (LPARAM)&dbei);
- mir_free(pszUtf);
+ dbei.pBlob = (PBYTE)(char*)pszUtf;
+ db_event_add(ack->hContact, &dbei);
}
// check to reuse
if (reuse > 1)
@@ -162,31 +160,25 @@ void SendPounce(TCHAR *text, HANDLE hContact)
int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam)
{
+ HANDLE hContact = (HANDLE)wParam;
DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
- char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)wParam, 0);
+
+ char *szProto = GetContactProto(hContact);
if((HANDLE)wParam == NULL || strcmp(cws->szSetting,"Status")) return 0;
- if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM))
- {
+ if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) {
int newStatus = cws->value.wVal;
int oldStatus = db_get_w((HANDLE)wParam,"UserOnline","OldStatus",ID_STATUS_OFFLINE);
- if ( ( newStatus != oldStatus ) && ( (HANDLE)wParam != NULL) && ( newStatus != ID_STATUS_OFFLINE) )
- {
- HANDLE hContact = (HANDLE)wParam;
+ if (newStatus != oldStatus && wParam != NULL && newStatus != ID_STATUS_OFFLINE) {
DBVARIANT dbv;
- if (!db_get_ts(hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0'))
- {
+ if (!db_get_ts(hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
// check my status
if (statusCheck(db_get_w(hContact, modname, "SendIfMyStatusIsFLAG", 0), CallProtoService(szProto, PS_GETSTATUS,0,0))
// check the contacts status
- && statusCheck(db_get_w(hContact, modname, "SendIfTheirStatusIsFLAG", 0), newStatus) )
- {
+ && statusCheck(db_get_w(hContact, modname, "SendIfTheirStatusIsFLAG", 0), newStatus)) {
// check if we r giving up after x days
- if (CheckDate(hContact))
- {
-
- if (db_get_b(hContact, modname, "ConfirmTimeout", 0))
- {
+ if (CheckDate(hContact)) {
+ if (db_get_b(hContact, modname, "ConfirmTimeout", 0)) {
struct SendPounceDlgProcStruct *spdps = (struct SendPounceDlgProcStruct *)mir_alloc(sizeof(struct SendPounceDlgProcStruct));
TCHAR *message = mir_tstrdup(dbv.ptszVal); // will get free()ed in the send confirm window proc
spdps->hContact = hContact;
@@ -195,8 +187,7 @@ int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam)
// set the confirmation window to send the msg when the timeout is done
mir_free(message);
}
- else
- SendPounce(dbv.ptszVal, hContact);
+ else SendPounce(dbv.ptszVal, hContact);
}
}
DBFreeVariant(&dbv);
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 6c02f808bc..88b725647b 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -257,14 +257,10 @@ static int clcHookSettingChanged(WPARAM wParam,LPARAM lParam)
static int clcHookDbEventAdded(WPARAM wParam,LPARAM lParam)
{
- DBEVENTINFO dbei = {0};
g_CluiData.t_now = time(NULL);
- if (wParam && lParam)
- {
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = 0;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbei);
+ if (wParam && lParam) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry((HANDLE)wParam);
db_set_dw((HANDLE)wParam, "CList", "mf_lastmsg", dbei.timestamp);
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp
index f28495e9f1..180b4a2939 100644
--- a/plugins/Clist_modern/src/modern_contact.cpp
+++ b/plugins/Clist_modern/src/modern_contact.cpp
@@ -62,18 +62,13 @@ static int GetStatusModeOrdering(int statusMode)
DWORD CompareContacts2_getLMTime(HANDLE hContact)
{
- HANDLE hDbEvent;
- DBEVENTINFO dbei = {0};
-
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_last(hContact);
while(hDbEvent) {
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = 0;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
return dbei.timestamp;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_prev(hDbEvent);
}
return 0;
}
diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp
index ca2838d337..93811cec7d 100644
--- a/plugins/Clist_nicer/src/clc.cpp
+++ b/plugins/Clist_nicer/src/clc.cpp
@@ -78,16 +78,13 @@ int __forceinline __strcmp(const char * src, const char * dst)
static int ClcEventAdded(WPARAM wParam, LPARAM lParam)
{
- DBEVENTINFO dbei = {0};
DWORD new_freq = 0;
cfg::dat.t_now = time(NULL);
if (wParam && lParam) {
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = 0;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
DWORD firstTime = cfg::getDword((HANDLE)wParam, "CList", "mf_firstEvent", 0);
DWORD count = cfg::getDword((HANDLE)wParam, "CList", "mf_count", 0);
diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp
index 672c10b3bb..b6f3de75a3 100644
--- a/plugins/Clist_nicer/src/contact.cpp
+++ b/plugins/Clist_nicer/src/contact.cpp
@@ -49,22 +49,21 @@ struct {
static int GetContactStatus(HANDLE hContact)
{
- char *szProto;
+ char *szProto;
- szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return ID_STATUS_OFFLINE;
- return cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ szProto = GetContactProto(hContact);
+ if (szProto == NULL)
+ return ID_STATUS_OFFLINE;
+ return cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);
}
int __forceinline GetStatusModeOrdering(int statusMode)
{
- int i;
- for (i = 0; i < sizeof(statusModeOrder) / sizeof(statusModeOrder[0]); i++) {
- if (statusModeOrder[i].status == statusMode)
- return statusModeOrder[i].order;
- }
- return 1000;
+ for (int i = 0; i < sizeof(statusModeOrder) / sizeof(statusModeOrder[0]); i++)
+ if (statusModeOrder[i].status == statusMode)
+ return statusModeOrder[i].order;
+
+ return 1000;
}
int mf_updatethread_running = TRUE;
@@ -72,44 +71,40 @@ HANDLE hThreadMFUpdate = 0;
static void MF_CalcFrequency(HANDLE hContact, DWORD dwCutoffDays, int doSleep)
{
- DWORD curTime = time(NULL);
- DWORD frequency, eventCount;
- DBEVENTINFO dbei = {0};
- HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
- DWORD firstEventTime = 0, lastEventTime = 0;
+ DWORD curTime = time(NULL);
+ DWORD frequency, eventCount;
+ HANDLE hEvent = db_event_last(hContact);
+ DWORD firstEventTime = 0, lastEventTime = 0;
eventCount = 0;
- dbei.cbSize = sizeof(dbei);
- dbei.timestamp = 0;
-
- while(hEvent) {
- dbei.cbBlob = 0;
- dbei.pBlob = NULL;
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei);
-
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { // record time of last event
- eventCount++;
- }
- if (eventCount >= 100 || dbei.timestamp < curTime - (dwCutoffDays * 86400))
- break;
- hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0);
- if (doSleep && mf_updatethread_running == FALSE)
- return;
- if (doSleep)
- Sleep(100);
- }
-
- if (eventCount == 0) {
- frequency = 0x7fffffff;
- cfg::writeDword(hContact, "CList", "mf_firstEvent", curTime - (dwCutoffDays * 86400));
- }
- else {
- frequency = (curTime - dbei.timestamp) / eventCount;
- cfg::writeDword(hContact, "CList", "mf_firstEvent", dbei.timestamp);
- }
-
- cfg::writeDword(hContact, "CList", "mf_freq", frequency);
- cfg::writeDword(hContact, "CList", "mf_count", eventCount);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ while(hEvent) {
+ db_event_get(hEvent, &dbei);
+
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) { // record time of last event
+ eventCount++;
+ }
+ if (eventCount >= 100 || dbei.timestamp < curTime - (dwCutoffDays * 86400))
+ break;
+ hEvent = db_event_prev(hEvent);
+ if (doSleep && mf_updatethread_running == FALSE)
+ return;
+ if (doSleep)
+ Sleep(100);
+ }
+
+ if (eventCount == 0) {
+ frequency = 0x7fffffff;
+ cfg::writeDword(hContact, "CList", "mf_firstEvent", curTime - (dwCutoffDays * 86400));
+ }
+ else {
+ frequency = (curTime - dbei.timestamp) / eventCount;
+ cfg::writeDword(hContact, "CList", "mf_firstEvent", dbei.timestamp);
+ }
+
+ cfg::writeDword(hContact, "CList", "mf_freq", frequency);
+ cfg::writeDword(hContact, "CList", "mf_count", eventCount);
}
extern TCHAR g_ptszEventName[];
@@ -142,61 +137,56 @@ static BOOL mc_hgh_removed = FALSE;
void LoadContactTree(void)
{
- HANDLE hContact;
- int i, status, hideOffline;
- BOOL mc_disablehgh = ServiceExists(MS_MC_DISABLEHIDDENGROUP);
- DBVARIANT dbv = {0};
- BYTE bMsgFrequency = cfg::getByte("CList", "fhistdata", 0);
-
- CallService(MS_CLUI_LISTBEGINREBUILD, 0, 0);
- for (i = 1; ; i++) {
- if (pcli->pfnGetGroupName(i, NULL) == NULL)
- break;
- CallService(MS_CLUI_GROUPADDED, i, 0);
- }
-
- hideOffline = cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
- hContact = db_find_first();
- while (hContact != NULL) {
- status = GetContactStatus(hContact);
- if ((!hideOffline || status != ID_STATUS_OFFLINE) && !CLVM_GetContactHiddenStatus(hContact, NULL, NULL))
- pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(GetContactProto(hContact), status, hContact, NULL), 1);
-
- if (mc_disablehgh && !mc_hgh_removed) {
- if ( !DBGetContactSetting(hContact, "CList", "Group", &dbv)) {
- if ( !strcmp(dbv.pszVal, "MetaContacts Hidden Group"))
- DBDeleteContactSetting(hContact, "CList", "Group");
- mir_free(dbv.pszVal);
- }
- }
-
- // build initial data for message frequency
- if ( !bMsgFrequency)
- MF_CalcFrequency(hContact, 100, 0);
-
- hContact = db_find_next(hContact);
- }
- cfg::writeByte("CList", "fhistdata", 1);
- mc_hgh_removed = TRUE;
- CallService(MS_CLUI_SORTLIST, 0, 0);
- CallService(MS_CLUI_LISTENDREBUILD, 0, 0);
+ HANDLE hContact;
+ int i, status, hideOffline;
+ BOOL mc_disablehgh = ServiceExists(MS_MC_DISABLEHIDDENGROUP);
+ DBVARIANT dbv = {0};
+ BYTE bMsgFrequency = cfg::getByte("CList", "fhistdata", 0);
+
+ CallService(MS_CLUI_LISTBEGINREBUILD, 0, 0);
+ for (i = 1; ; i++) {
+ if (pcli->pfnGetGroupName(i, NULL) == NULL)
+ break;
+ CallService(MS_CLUI_GROUPADDED, i, 0);
+ }
+
+ hideOffline = cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
+ hContact = db_find_first();
+ while (hContact != NULL) {
+ status = GetContactStatus(hContact);
+ if ((!hideOffline || status != ID_STATUS_OFFLINE) && !CLVM_GetContactHiddenStatus(hContact, NULL, NULL))
+ pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(GetContactProto(hContact), status, hContact, NULL), 1);
+
+ if (mc_disablehgh && !mc_hgh_removed) {
+ if ( !DBGetContactSetting(hContact, "CList", "Group", &dbv)) {
+ if ( !strcmp(dbv.pszVal, "MetaContacts Hidden Group"))
+ DBDeleteContactSetting(hContact, "CList", "Group");
+ mir_free(dbv.pszVal);
+ }
+ }
+
+ // build initial data for message frequency
+ if ( !bMsgFrequency)
+ MF_CalcFrequency(hContact, 100, 0);
+
+ hContact = db_find_next(hContact);
+ }
+ cfg::writeByte("CList", "fhistdata", 1);
+ mc_hgh_removed = TRUE;
+ CallService(MS_CLUI_SORTLIST, 0, 0);
+ CallService(MS_CLUI_LISTENDREBUILD, 0, 0);
}
DWORD INTSORT_GetLastMsgTime(HANDLE hContact)
{
- HANDLE hDbEvent;
- DBEVENTINFO dbei = {0};
-
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
- while(hDbEvent) {
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = 0;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
- return dbei.timestamp;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
- }
+ HANDLE hDbEvent = db_event_last(hContact);
+ while(hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
+ return dbei.timestamp;
+ hDbEvent = db_event_prev(hDbEvent);
+ }
return 0;
}
@@ -204,10 +194,9 @@ int __forceinline GetProtoIndex(char * szName)
{
if ( !szName )
return -1;
- else {
- PROTOACCOUNT* pa = ProtoGetAccount( szName );
- return ( pa == NULL ) ? -1 : pa->iOrder;
- }
+
+ PROTOACCOUNT* pa = ProtoGetAccount( szName );
+ return ( pa == NULL ) ? -1 : pa->iOrder;
}
int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact* c2, UINT bywhat)
@@ -289,13 +278,11 @@ int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact
int CompareContacts(const ClcContact* c1, const ClcContact* c2)
{
- int i, result;
-
- result = INTSORT_CompareContacts(c1, c2, SORTBY_PRIOCONTACTS);
+ int result = INTSORT_CompareContacts(c1, c2, SORTBY_PRIOCONTACTS);
if (result)
return result;
- for (i = 0; i <= 2; i++) {
+ for (int i = 0; i <= 2; i++) {
if (cfg::dat.sortOrder[i]) {
result = INTSORT_CompareContacts(c1, c2, cfg::dat.sortOrder[i]);
if (result != 0)
@@ -310,21 +297,21 @@ int CompareContacts(const ClcContact* c1, const ClcContact* c2)
static int resortTimerId = 0;
static VOID CALLBACK SortContactsTimer(HWND hwnd, UINT message, UINT idEvent, DWORD dwTime)
{
- KillTimer(NULL, resortTimerId);
- resortTimerId = 0;
- CallService(MS_CLUI_SORTLIST, 0, 0);
+ KillTimer(NULL, resortTimerId);
+ resortTimerId = 0;
+ CallService(MS_CLUI_SORTLIST, 0, 0);
}
int SetHideOffline(WPARAM wParam, LPARAM lParam)
{
- switch ((int) wParam) {
- case 0:
- cfg::writeByte("CList", "HideOffline", 0); break;
- case 1:
- cfg::writeByte("CList", "HideOffline", 1); break;
- case -1:
- cfg::writeByte("CList", "HideOffline", (BYTE) ! cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)); break;
- }
- LoadContactTree();
- return 0;
+ switch ((int)wParam) {
+ case 0:
+ cfg::writeByte("CList", "HideOffline", 0); break;
+ case 1:
+ cfg::writeByte("CList", "HideOffline", 1); break;
+ case -1:
+ cfg::writeByte("CList", "HideOffline", (BYTE) ! cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT)); break;
+ }
+ LoadContactTree();
+ return 0;
}
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp
index 3e12950c61..13a73e109f 100644
--- a/plugins/CmdLine/src/mimcmd_handlers.cpp
+++ b/plugins/CmdLine/src/mimcmd_handlers.cpp
@@ -1193,29 +1193,21 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re
e.szModule = module;
e.timestamp = (DWORD) time(NULL);
- CallService(MS_DB_EVENT_ADD, (WPARAM) ack->hContact, (LPARAM) &e);
+ db_event_add(ack->hContact, &e);
}
- else{
- mir_snprintf(buffer, sizeof(buffer), Translate("Message to '%s' was marked as sent but the account seems to be offline"), contact);
- }
- }
- else{
- mir_snprintf(buffer, sizeof(buffer), Translate("Could not send message to '%s'."), contact);
+ else mir_snprintf(buffer, sizeof(buffer), Translate("Message to '%s' was marked as sent but the account seems to be offline"), contact);
}
+ else mir_snprintf(buffer, sizeof(buffer), Translate("Could not send message to '%s'."), contact);
}
- else{
- mir_snprintf(buffer, sizeof(buffer), Translate("Timed out while waiting for acknowledgement for contact '%s'."), contact);
- }
- }
- else{
- mir_snprintf(buffer, sizeof(buffer), Translate("Could not find contact handle for contact '%s'."), contact);
+ else mir_snprintf(buffer, sizeof(buffer), Translate("Timed out while waiting for acknowledgement for contact '%s'."), contact);
}
+ else mir_snprintf(buffer, sizeof(buffer), Translate("Could not find contact handle for contact '%s'."), contact);
if (i == 3)
{
STRNCPY(reply->message, buffer, reply->cMessage);
}
- else{
+ else {
strncat(reply->message, "\n", reply->cMessage);
strncat(reply->message, buffer, reply->cMessage);
}
@@ -1919,11 +1911,9 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r
reply->code = MIMRES_SUCCESS;
*reply->message = 0;
- while (hContact)
- {
- HANDLE hUnreadEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
- if (hUnreadEvent != NULL)
- {
+ while (hContact) {
+ HANDLE hUnreadEvent = db_event_firstUnread(hContact);
+ if (hUnreadEvent != NULL) {
DWORD threadID;
HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, hContact, NULL, &threadID);
}
@@ -1994,59 +1984,47 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re
char *cmd = argv[2];
switch (argc)
{
- case 3:
+ case 3:
{
if (_stricmp(cmd, "unread") == 0)
{
- HANDLE hContact = db_find_first();
char buffer[4096];
int count;
int contacts = 0;
- DBEVENTINFO dbEvent = {0};
- dbEvent.cbSize = sizeof(DBEVENTINFO);
-
+ DBEVENTINFO dbEvent = { sizeof(dbEvent) };
+
reply->code = MIMRES_SUCCESS;
mir_snprintf(reply->message, reply->cMessage, Translate("No unread messages found."));
-
- while (hContact)
- {
- HANDLE hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
- if (hEvent != NULL)
- {
- char *contact;
- char protocol[128];
-
+
+ HANDLE hContact = db_find_first();
+ while (hContact) {
+ HANDLE hEvent = db_event_firstUnread(hContact);
+ if (hEvent != NULL) {
count = 0;
- while (hEvent != NULL)
- {
- if (!CallService(MS_DB_EVENT_GET, (WPARAM) hEvent, (LPARAM) &dbEvent))
- {
+ while (hEvent != NULL) {
+ if (!db_event_get( hEvent, &dbEvent))
if (!(dbEvent.flags & DBEF_READ))
- {
count++;
- }
- }
-
- hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hEvent, 0);
+
+ hEvent = db_event_next(hEvent);
}
-
+
+ char protocol[128];
GetContactProto(hContact, protocol, sizeof(protocol));
- contact = GetContactName(hContact, protocol);
+ char *contact = GetContactName(hContact, protocol);
mir_snprintf(buffer, sizeof(buffer), Translate("%s:%s - %d unread events."), contact, protocol, count);
-
- if (contacts > 0)
- {
+
+ if (contacts > 0) {
strncat(reply->message, "\n", reply->cMessage);
strncat(reply->message, buffer, reply->cMessage);
}
- else{
- STRNCPY(reply->message, buffer, reply->cMessage);
- }
+ else STRNCPY(reply->message, buffer, reply->cMessage);
+
contacts++;
-
+
free(contact);
}
-
+
hContact = db_find_next(hContact);
}
}
@@ -2059,11 +2037,11 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re
HandleUnknownParameter(command, cmd, reply);
}
}
-
+
break;
}
-
- case 4:
+
+ case 4:
{
char *contact = argv[3];
HANDLE hContact = ParseContactParam(contact);
@@ -2071,55 +2049,38 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re
{
if (_stricmp(cmd, "unread") == 0)
{
- HANDLE hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
- DBEVENTINFO dbEvent = {0};
- dbEvent.cbSize = sizeof(DBEVENTINFO);
-
- char *message[4096];
- dbEvent.pBlob = (PBYTE) message;
-
+ HANDLE hEvent = db_event_firstUnread(hContact);
+
reply->code = MIMRES_SUCCESS;
-
- while (hEvent)
- {
- dbEvent.cbBlob = sizeof(message);
- if (!CallService(MS_DB_EVENT_GET, (WPARAM) hEvent, (LPARAM) &dbEvent)) //if successful call
- {
+
+ while (hEvent) {
+ DBEVENTINFO dbEvent = { sizeof(dbEvent) };
+ if (!db_event_get(hEvent, &dbEvent)) //if successful call
if (!(dbEvent.flags & DBEF_READ))
- {
AddHistoryEvent(&dbEvent, contact, reply);
- }
- }
-
- hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hEvent, 0);
+
+ hEvent = db_event_next(hEvent);
}
}
- else{
- if (_stricmp(cmd, "show") == 0)
- {
- int count = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM) hContact, 0);
-
- reply->code = MIMRES_SUCCESS;
- mir_snprintf(reply->message, reply->cMessage, Translate("Contact '%s' has '%d' events in history."), contact, count);
- }
- else{
- HandleUnknownParameter(command, cmd, reply);
- }
+ else if (_stricmp(cmd, "show") == 0) {
+ reply->code = MIMRES_SUCCESS;
+ mir_snprintf(reply->message, reply->cMessage, Translate("Contact '%s' has '%d' events in history."), contact, db_event_count(hContact));
}
+ else HandleUnknownParameter(command, cmd, reply);
}
- else{
+ else {
reply->code = MIMRES_FAILURE;
mir_snprintf(reply->message, reply->cMessage, Translate("Could not find contact handle for contact '%s'."), contact);
}
-
+
break;
}
-
- case 6:
+
+ case 6:
{
char *contact = argv[3];
HANDLE hContact = ParseContactParam(contact);
-
+
if (hContact)
{
if (_stricmp(cmd, "show") == 0)
@@ -2130,77 +2091,62 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re
long stop = strtol(argv[5], &stop2, 10);
if (!(*stop1) && !(*stop2))
{
- int size = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM) hContact, 0);
+ int size = db_event_count(hContact);
if (start < 0) { start = size + start + 1; }
if (stop < 0) { stop = size + stop + 1; }
-
+
reply->code = MIMRES_SUCCESS;
-
+
int count = stop - start + 1;
if (count > 0)
{
int index = 0;
- HANDLE hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST, (WPARAM) hContact, 0);
- DBEVENTINFO dbEvent = {0};
- dbEvent.cbSize = sizeof(DBEVENTINFO);
+ HANDLE hEvent = db_event_first(hContact);
+ DBEVENTINFO dbEvent = { sizeof(DBEVENTINFO) };
char message[4096];
dbEvent.pBlob = (PBYTE) message;
-
+
while (hEvent)
{
dbEvent.cbBlob = sizeof(message);
- if (!CallService(MS_DB_EVENT_GET, (WPARAM) hEvent, (LPARAM) &dbEvent)) // if successful call
+ if (!db_event_get( hEvent, &dbEvent)) // if successful call
{
dbEvent.pBlob[dbEvent.cbBlob] = 0;
if ((index >= start) && (index <= stop))
- {
AddHistoryEvent(&dbEvent, contact, reply);
- }
}
-
+
if (index > stop)
- {
break;
- }
-
- hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hEvent, 0);
+
+ hEvent = db_event_next(hEvent);
index++;
}
}
}
- else{
- HandleUnknownParameter(command, (*stop1) ? argv[4] : argv[5], reply);
- }
+ else HandleUnknownParameter(command, (*stop1) ? argv[4] : argv[5], reply);
}
else{
if (_stricmp(cmd, "unread") == 0)
- {
HandleWrongParametersCount(command, reply);
- }
- else{
+ else
HandleUnknownParameter(command, cmd, reply);
- }
}
}
else{
reply->code = MIMRES_FAILURE;
mir_snprintf(reply->message, reply->cMessage, Translate("Could not find contact handle for contact '%s'."), contact);
}
-
- break;
- }
-
- default:
- {
- HandleWrongParametersCount(command, reply);
-
+
break;
}
+
+ default:
+ HandleWrongParametersCount(command, reply);
+ break;
}
}
- else{
- HandleWrongParametersCount(command, reply);
- }
+ else HandleWrongParametersCount(command, reply);
}
void HandleVersionCommand(PCommand command, TArgument *argv, int argc, PReply reply)
diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp
index 1bac904867..32534bea8f 100644
--- a/plugins/ContactsPlus/src/main.cpp
+++ b/plugins/ContactsPlus/src/main.cpp
@@ -61,18 +61,15 @@ static int HookDBEventAdded(WPARAM wParam, LPARAM lParam)
HANDLE hContact = (HANDLE)wParam;
HANDLE hDbEvent = (HANDLE)lParam;
//process the event
- DBEVENTINFO dbe = {0};
-
- dbe.cbSize = sizeof(DBEVENTINFO);
- //get event details
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ db_event_get(hDbEvent, &dbe);
//check if we should process the event
if (dbe.flags & (DBEF_SENT|DBEF_READ) || dbe.eventType != EVENTTYPE_CONTACTS) return 0;
//get event contents
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbe.cbBlob != -1)
dbe.pBlob = (PBYTE)_alloca(dbe.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe);
+ db_event_get(hDbEvent, &dbe);
//play received sound
SkinPlaySound("RecvContacts");
{ //add event to the contact list
@@ -97,24 +94,17 @@ static int HookDBEventAdded(WPARAM wParam, LPARAM lParam)
static void ProcessUnreadEvents(void)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
-
HANDLE hContact = db_find_first();
- while (hContact)
- {
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD,(WPARAM)hContact,0);
-
- while (hDbEvent)
- {
- dbei.cbBlob=0;
- CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei);
- if (!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType==EVENTTYPE_CONTACTS)
- {
+ while (hContact) {
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
+ if (!(dbei.flags & (DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_CONTACTS) {
//process the event
HookDBEventAdded((WPARAM)hContact, (LPARAM)hDbEvent);
}
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0);
+ hDbEvent = db_event_next(hDbEvent);
}
hContact = db_find_next(hContact);
}
diff --git a/plugins/ContactsPlus/src/receive.cpp b/plugins/ContactsPlus/src/receive.cpp
index 5e9e80c39f..7b1c876a3e 100644
--- a/plugins/ContactsPlus/src/receive.cpp
+++ b/plugins/ContactsPlus/src/receive.cpp
@@ -211,10 +211,10 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
DBEVENTINFO dbe = {0};
dbe.cbSize = sizeof(DBEVENTINFO);
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)wndData->mhDbEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(wndData->mhDbEvent);
if (dbe.cbBlob != -1) // this marks an invalid hDbEvent - all smashed anyway...
dbe.pBlob = (PBYTE)_alloca(dbe.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)wndData->mhDbEvent, (LPARAM)&dbe);
+ db_event_get(wndData->mhDbEvent, &dbe);
char* pcBlob = (char*)dbe.pBlob;
char* pcEnd = (char*)dbe.pBlob + dbe.cbBlob;
@@ -471,7 +471,7 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
}
case WM_DESTROY: // last message received by this dialog, cleanup
{
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)wndData->mhContact, (LPARAM)wndData->mhDbEvent);
+ db_event_markRead(wndData->mhContact, wndData->mhDbEvent);
Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "");
ImageList_Destroy(wndData->mhListIcon);
UnhookEvent(wndData->hHook);
diff --git a/plugins/ContactsPlus/src/send.cpp b/plugins/ContactsPlus/src/send.cpp
index 40bd74c993..03d9356062 100644
--- a/plugins/ContactsPlus/src/send.cpp
+++ b/plugins/ContactsPlus/src/send.cpp
@@ -476,7 +476,7 @@ INT_PTR CALLBACK SendDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
strcpy(pBlob, maSend[i].mcaUIN);
pBlob += strlennull(pBlob) + 1;
}
- CallService(MS_DB_EVENT_ADD, (WPARAM)ackData->hContact,(LPARAM)&dbei);
+ db_event_add(ackData->hContact, &dbei);
gaAckData.Remove(ack->hProcess); // do not release here, still needed
wndData->uacklist.Remove(ack->hProcess); // packet confirmed
for (i=0; i<ackData->nContacts; i++)
diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp
index 1a3ce80352..2d6eba3e54 100644
--- a/plugins/FTPFileYM/src/job_upload.cpp
+++ b/plugins/FTPFileYM/src/job_upload.cpp
@@ -90,7 +90,7 @@ void UploadJob::autoSend()
dbei.timestamp = (DWORD)time(NULL);
dbei.cbBlob = (DWORD)strlen(this->szFileLink) + 1;
dbei.pBlob = (PBYTE)this->szFileLink;
- CallService(MS_DB_EVENT_ADD, (WPARAM)this->hContact, (LPARAM)&dbei);
+ db_event_add(this->hContact, &dbei);
CallContactService(this->hContact, PSS_MESSAGE, 0, (LPARAM)this->szFileLink);
CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)this->hContact, 0);
}
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp
index e535738ffb..1167d98f0d 100644
--- a/plugins/FavContacts/src/contact_cache.cpp
+++ b/plugins/FavContacts/src/contact_cache.cpp
@@ -7,7 +7,7 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM wParam, LPARAM lParam)
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei);
+ db_event_get(hEvent, &dbei);
if (dbei.eventType != EVENTTYPE_MESSAGE) return 0;
float weight = GetEventWeight(time(NULL) - dbei.timestamp);
@@ -88,23 +88,19 @@ void CContactCache::Rebuild()
info->hContact = hContact;
info->rate = 0;
- HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ HANDLE hEvent = db_event_last(hContact);
while (hEvent)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
- {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if (!db_event_get(hEvent, &dbei)) {
if (float weight = GetEventWeight(timestamp - dbei.timestamp))
{
if (dbei.eventType == EVENTTYPE_MESSAGE)
info->rate += weight;
- } else
- {
- break;
}
+ else break;
}
- hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0);
+ hEvent = db_event_prev(hEvent);
}
m_cache.insert(info);
diff --git a/plugins/FlashAvatars/src/cflash.cpp b/plugins/FlashAvatars/src/cflash.cpp
index e4eb392101..711a3b2f1c 100644
--- a/plugins/FlashAvatars/src/cflash.cpp
+++ b/plugins/FlashAvatars/src/cflash.cpp
@@ -494,14 +494,13 @@ static int statusChanged(WPARAM wParam, LPARAM lParam)
static int eventAdded(WPARAM wParam, LPARAM lParam)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)lParam , 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize((HANDLE)lParam);
if (dbei.cbBlob == 0xFFFFFFFF)
return 0;
dbei.pBlob = new BYTE[dbei.cbBlob];
- CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM) & dbei);
+ db_event_get((HANDLE)lParam, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ)) {
Lock l(cs);
diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp
index d3889376a5..6a2cf70e02 100644
--- a/plugins/HistoryLinkListPlus/src/linklist.cpp
+++ b/plugins/HistoryLinkListPlus/src/linklist.cpp
@@ -124,29 +124,11 @@ int InitOptionsDlg(WPARAM wParam, LPARAM lParam)
return 0;
}
-static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam)
+static INT_PTR LinkList_Main(WPARAM wParam, LPARAM)
{
- HANDLE hEvent;
HANDLE hContact = (HANDLE)wParam;
- DBEVENTINFO dbe;
- HWND hWnd;
- HWND hWndProgress;
- HWND hWndMain;
-
- int histCount = 0;
- int actCount = 0;
-
- RECT DesktopRect;
- LISTELEMENT *listStart;
-
- UNREFERENCED_PARAMETER(lParam);
-
- listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT));
- ZeroMemory(listStart, sizeof(LISTELEMENT));
-
- hWnd = WindowList_Find(hWindowList,hContact);
- if ( hWnd != NULL )
- {
+ HWND hWnd = WindowList_Find(hWindowList, hContact);
+ if ( hWnd != NULL ) {
int len;
SetForegroundWindow(hWnd);
SetFocus(hWnd);
@@ -155,25 +137,24 @@ static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam)
return 0;
}
- hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
- if ( hEvent == NULL )
- {
+ HANDLE hEvent = db_event_first(hContact);
+ if (hEvent == NULL) {
MessageBox(NULL, TXT_EMPTYHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION );
return 0;
}
- histCount = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hContact, 0);
- ZeroMemory(&dbe, sizeof(dbe));
- dbe.cbSize = sizeof(dbe);
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ int histCount = db_event_count(hContact), actCount = 0;
+
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
+ db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
+ RECT DesktopRect;
GetWindowRect(GetDesktopWindow(), &DesktopRect);
- hWndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL);
- if ( hWndProgress == 0 )
- {
+ HWND hWndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL);
+ if ( hWndProgress == 0 ) {
free(dbe.pBlob);
MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
return -1;
@@ -182,13 +163,13 @@ static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam)
ShowWindow(hWndProgress, SW_SHOW);
SetForegroundWindow(hWndProgress);
- while( 1 )
- {
- if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE )
- {
+ LISTELEMENT *listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT));
+ ZeroMemory(listStart, sizeof(LISTELEMENT));
+
+ while( 1 ) {
+ if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE ) {
// Call function to find URIs
- if ( ExtractURI(&dbe, hEvent, listStart) < 0 )
- {
+ if ( ExtractURI(&dbe, hEvent, listStart) < 0 ) {
free(dbe.pBlob);
RemoveList(listStart);
MessageBox(NULL, TranslateT("Could not allocate memory!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION);
@@ -199,14 +180,14 @@ static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam)
if ( ((int)(((float)actCount/histCount)*100.00)) % 10 == 0 )
SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount/histCount)*100.00)));
- hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hEvent, 0);
+ hEvent = db_event_next(hEvent);
if ( hEvent == NULL )
break;
free(dbe.pBlob);
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
+ db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
}
free(dbe.pBlob);
@@ -224,9 +205,8 @@ static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam)
DlgParam->chrg.cpMax = -1;
DlgParam->chrg.cpMin = -1;
- hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam);
- if ( hWndMain == 0 )
- {
+ HWND hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam);
+ if (hWndMain == 0) {
RemoveList(listStart);
MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
return -1;
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp
index eb2e0ea98a..bc5c5abe61 100644
--- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp
+++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp
@@ -290,7 +290,6 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc
LISTOPTIONS options;
CHARRANGE sel;
GETTEXTLENGTHEX gtl;
- DBEVENTINFO dbe;
GetListInfo(params, listStart, searchString, &lineLen, &listCount, &realListCount);
GetColour(&colourSet);
@@ -412,30 +411,24 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc
// Perform deep scan
if ( actualElement->hEvent != NULL )
{
- LPCTSTR msg;
- dbe.cbSize = sizeof(dbe);
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)actualElement->hEvent, 0);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET, (WPARAM)actualElement->hEvent, (LPARAM)&dbe);
+ db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
- msg = DbGetEventTextT(&dbe, CP_ACP);
+ LPTSTR msg = DbGetEventTextT(&dbe, CP_ACP);
if ( _tcsstr(msg, searchString))
filter3 = 1;
free(dbe.pBlob);
- mir_free((void*)msg);
+ mir_free(msg);
}
- else
- filter3 = 0;
- }
- else
- {
- if ( _tcsstr(actualElement->link, searchString))
- filter3 = 1;
+ else filter3 = 0;
}
+ else if ( _tcsstr(actualElement->link, searchString))
+ filter3 = 1;
}
- else
- filter3 = 1;
+ else filter3 = 1;
if ( (filter1 == 1) && (filter2 == 1) && (filter3 == 1))
{
@@ -647,25 +640,17 @@ Write Message to window
*/
void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos)
{
- LISTELEMENT *actualElement;
- HANDLE hEvent;
- DBEVENTINFO dbe;
-
- actualElement = listStart->nextElement;
- while ( actualElement != NULL )
- {
- if ( actualElement->linePos == actLinePos )
- {
- hEvent = actualElement->hEvent;
- if (hEvent != NULL )
- {
- LPCTSTR msg;
- dbe.cbSize = sizeof(dbe);
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ LISTELEMENT *actualElement = listStart->nextElement;
+ while (actualElement != NULL) {
+ if (actualElement->linePos == actLinePos) {
+ HANDLE hEvent = actualElement->hEvent;
+ if (hEvent != NULL ) {
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET,(WPARAM)hEvent,(LPARAM)&dbe);
+ db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
- msg = DbGetEventTextT(&dbe, CP_ACP);
+ LPCTSTR msg = DbGetEventTextT(&dbe, CP_ACP);
SendDlgItemMessage(hDlg, IDC_MESSAGE, WM_SETTEXT , 0, 0);
SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
mir_free((void*)msg);
@@ -786,7 +771,6 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, siz
size_t tempLen;
LISTELEMENT *actualElement;
char filter1, filter2, filter3;
- DBEVENTINFO dbe;
*maxLen = 0;
*elementCount = 0;
@@ -818,11 +802,10 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, siz
// Perform deep scan
if ( actualElement->hEvent != NULL )
{
- dbe.cbSize = sizeof(dbe);
- dbe.pBlob = NULL;
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)actualElement->hEvent, 0);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET, (WPARAM)actualElement->hEvent, (LPARAM)&dbe);
+ db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
if ( _tcsstr((LPTSTR)dbe.pBlob, searchString))
filter3 = 1;
@@ -1220,7 +1203,6 @@ int DBUpdate(WPARAM wParam, LPARAM lParam)
{
HANDLE hEvent=(HANDLE)lParam;
HWND hDlg = WindowList_Find(hWindowList, (HANDLE)wParam);
- DBEVENTINFO dbe;
DIALOGPARAM *DlgParam;
HMENU listMenu = GetMenu(hDlg);
int linkNum = 0;
@@ -1230,17 +1212,12 @@ int DBUpdate(WPARAM wParam, LPARAM lParam)
if(GetUpdateSetting() != 1)
return 0;
- if(hDlg)
- {
- ZeroMemory(&dbe, sizeof(dbe));
- dbe.cbSize = sizeof(dbe);
-
- dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ if(hDlg) {
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc((size_t)dbe.cbBlob+1);
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
-
- if ( (dbe.eventType == EVENTTYPE_URL) || (dbe.eventType == EVENTTYPE_MESSAGE))
- {
+ db_event_get(hEvent, &dbe);
+ if (dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE) {
// Call function to find URIs
linkNum = ExtractURI(&dbe, hEvent, DlgParam->listStart);
if ( linkNum > 0 )
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
index ce59001dda..8783aafa34 100644
--- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp
+++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
@@ -139,8 +139,7 @@ static void GetBookmarks(HANDLE hContact, BEventData** books, size_t* bookcnt )
//Sweep history from specified contact
void SweepHistoryFromContact(HANDLE hContact, CriteriaStruct Criteria, BOOL keepUnread)
{
- int lPolicy, eventsCnt;
-
+ int lPolicy;
if (hContact == NULL) // for system history
lPolicy = DBGetContactSettingByte(NULL, ModuleName, "SweepSHistory", 0);
else // for contact history (or "SweepHistory" - default action)
@@ -148,13 +147,11 @@ void SweepHistoryFromContact(HANDLE hContact, CriteriaStruct Criteria, BOOL keep
if (lPolicy == 0) return; // nothing to do
- eventsCnt = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hContact, 0);
-
- if (eventsCnt != 0)
- {
+ int eventsCnt = db_event_count(hContact);
+ if (eventsCnt != 0) {
BOOL doDelete, unsafe = DBGetContactSettingByte(NULL, ModuleName, "UnsafeMode", 0);
- HANDLE hDBEvent, hDBEventNext; BEventData *books, *item, ev = { 0 };
- DBEVENTINFO dbei; size_t bookcnt, btshift;
+ BEventData *books, *item, ev = { 0 };
+ size_t bookcnt, btshift;
SetCursor(LoadCursor(0, IDC_WAIT));
@@ -164,14 +161,10 @@ void SweepHistoryFromContact(HANDLE hContact, CriteriaStruct Criteria, BOOL keep
GetBookmarks(hContact, &books, &bookcnt);
//Get first event
- hDBEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
-
- while (hDBEvent != NULL)
- {
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
-
- CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei);
+ HANDLE hDBEvent = db_event_first(hContact);
+ while (hDBEvent != NULL) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDBEvent, &dbei);
// should we stop processing?
// lPolicy == 1 - for time criterion, lPolicy == 2 - keep N last events, lPolicy == 3 - delete all events
@@ -195,12 +188,13 @@ void SweepHistoryFromContact(HANDLE hContact, CriteriaStruct Criteria, BOOL keep
}
// find next event
- hDBEventNext = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDBEvent, 0);
+ HANDLE hDBEventNext = db_event_next(hDBEvent);
- if (doDelete) CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDBEvent);
+ if (doDelete)
+ db_event_delete(hContact, hDBEvent);
hDBEvent = hDBEventNext;
- } // while (hDBEvent != NULL)
+ }
mir_free(books);
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp
index 8bfcf658e2..bfee0b82b2 100644
--- a/plugins/IEView/src/HTMLBuilder.cpp
+++ b/plugins/IEView/src/HTMLBuilder.cpp
@@ -322,24 +322,23 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
newEvent.hwnd = event->hwnd;
newEvent.eventData = NULL;
for (int eventIdx = 0; hDbEvent!=NULL && (eventIdx < event->count || event->count==-1); eventIdx++) {
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) hDbEvent, 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob == 0xFFFFFFFF) {
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
continue;
}
dbei.pBlob = (PBYTE) malloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
+ db_event_get( hDbEvent, &dbei);
if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL)) {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM) event->hContact, (LPARAM) hDbEvent);
+ db_event_markRead(event->hContact, hDbEvent);
CallService(MS_CLIST_REMOVEEVENT, (WPARAM) event->hContact, (LPARAM) hDbEvent);
} else if (dbei.eventType == EVENTTYPE_STATUSCHANGE) {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM) event->hContact, (LPARAM) hDbEvent);
+ db_event_markRead(event->hContact, hDbEvent);
}
if (!isDbEventShown(&dbei)) {
free(dbei.pBlob);
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
continue;
}
eventData = new IEVIEWEVENTDATA;
@@ -410,7 +409,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
prevEventData = eventData;
newEvent.count++;
event->hDbEventFirst = hDbEvent;
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
appendEventNew(view, &newEvent);
for ( IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL; eventData2 = eventData) {
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp
index 1795b3b2c8..397f5df370 100644
--- a/plugins/Import/src/utils.cpp
+++ b/plugins/Import/src/utils.cpp
@@ -83,15 +83,13 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
HANDLE hExistingDbEvent;
DWORD dwEventTimeStamp;
- DBEVENTINFO dbeiExisting;
// get last event
- if (!(hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0)))
+ if (!(hExistingDbEvent = db_event_last(hContact)))
return FALSE;
- ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
- dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hExistingDbEvent, (LPARAM)&dbeiExisting);
+ DBEVENTINFO dbeiExisting = { sizeof(dbeiExisting) };
+ db_event_get(hExistingDbEvent, &dbeiExisting);
dwEventTimeStamp = dbeiExisting.timestamp;
// compare with last timestamp
@@ -109,12 +107,12 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
dwPreviousTimeStamp = dwEventTimeStamp;
// get first event
- if (!(hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0)))
+ if (!(hExistingDbEvent = db_event_first(hContact)))
return FALSE;
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hExistingDbEvent, (LPARAM)&dbeiExisting);
+ db_event_get(hExistingDbEvent, &dbeiExisting);
dwEventTimeStamp = dbeiExisting.timestamp;
// compare with first timestamp
@@ -132,20 +130,20 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
if (dbei.timestamp == dwPreviousTimeStamp) {
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hPreviousDbEvent, (LPARAM)&dbeiExisting);
+ db_event_get(hPreviousDbEvent, &dbeiExisting);
if ((dbei.timestamp == dbeiExisting.timestamp) &&
(dbei.eventType == dbeiExisting.eventType) &&
(dbei.cbBlob == dbeiExisting.cbBlob) &&
- ((dbei.flags&DBEF_SENT) == (dbeiExisting.flags&DBEF_SENT)))
+ ((dbei.flags & DBEF_SENT) == (dbeiExisting.flags & DBEF_SENT)))
return TRUE;
// find event with another timestamp
- hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hPreviousDbEvent, 0);
+ hExistingDbEvent = db_event_next(hPreviousDbEvent);
while (hExistingDbEvent != NULL) {
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hExistingDbEvent, (LPARAM)&dbeiExisting);
+ db_event_get(hExistingDbEvent, &dbeiExisting);
if (dbeiExisting.timestamp != dwPreviousTimeStamp) {
// use found event
@@ -155,7 +153,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
}
hPreviousDbEvent = hExistingDbEvent;
- hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hExistingDbEvent, 0);
+ hExistingDbEvent = db_event_next(hExistingDbEvent);
}
}
@@ -166,7 +164,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
while (hExistingDbEvent != NULL) {
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hExistingDbEvent, (LPARAM)&dbeiExisting);
+ db_event_get(hExistingDbEvent, &dbeiExisting);
if (dbei.timestamp > dbeiExisting.timestamp) {
// remember event
@@ -188,7 +186,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
}
// Get previous event in chain
- hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hExistingDbEvent, 0);
+ hExistingDbEvent = db_event_prev(hExistingDbEvent);
}
}
else {
@@ -196,7 +194,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
while (hExistingDbEvent != NULL) {
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
- CallService(MS_DB_EVENT_GET, (WPARAM)hExistingDbEvent, (LPARAM)&dbeiExisting);
+ db_event_get(hExistingDbEvent, &dbeiExisting);
if (dbei.timestamp < dbeiExisting.timestamp) {
// remember event
@@ -218,7 +216,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO dbei)
}
// Get next event in chain
- hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hExistingDbEvent, 0);
+ hExistingDbEvent = db_event_next(hExistingDbEvent);
}
}
// reset last event
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp
index b3bdaea314..31b3f94623 100644
--- a/plugins/KeyboardNotify/src/main.cpp
+++ b/plugins/KeyboardNotify/src/main.cpp
@@ -326,16 +326,11 @@ DBEVENTINFO createMsgEventInfo(HANDLE hContact)
DBEVENTINFO readEventInfo(HANDLE hDbEvent, HANDLE hContact)
{
- DBEVENTINFO einfo = {0};
-
if (hDbEvent == NCONVERS_BLINKID) // we need to handle nconvers' blink event
return createMsgEventInfo(hContact);
- einfo.cbSize = sizeof(einfo);
- einfo.cbBlob = 0;
- einfo.pBlob = NULL;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&einfo);
-
+ DBEVENTINFO einfo = { sizeof(einfo) };
+ db_event_get(hDbEvent, &einfo);
return einfo;
}
@@ -468,18 +463,12 @@ static void FlashThreadFunction()
BOOL checkMsgTimestamp(HANDLE hEventCurrent, DWORD timestampCurrent)
{
- HANDLE hEvent;
-
if (!bFlashIfMsgOlder)
return TRUE;
- for (hEvent=(HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEventCurrent, 0); hEvent; hEvent=(HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0)) {
- DBEVENTINFO einfo = {0};
-
- einfo.cbSize = sizeof(einfo);
- einfo.cbBlob = 0;
- einfo.pBlob = NULL;
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&einfo);
+ for (HANDLE hEvent = db_event_prev(hEventCurrent); hEvent; hEvent = db_event_prev(hEvent)) {
+ DBEVENTINFO einfo = { sizeof(einfo) };
+ db_event_get(hEvent, &einfo);
if ((einfo.timestamp + wSecondsOlder) <= timestampCurrent)
return TRUE;
if (einfo.eventType == EVENTTYPE_MESSAGE)
@@ -539,16 +528,12 @@ BOOL checkXstatus(char *szProto)
// 'Pings' the FlashThread to keep the LEDs flashing.
static int PluginMessageEventHook(WPARAM wParam, LPARAM lParam)
{
- DBEVENTINFO einfo = {0};
HANDLE hContact = (HANDLE)wParam;
HANDLE hEvent = (HANDLE)lParam;
//get DBEVENTINFO without pBlob
- einfo.cbSize = sizeof(einfo);
- einfo.cbBlob = 0;
- einfo.pBlob = NULL;
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&einfo);
-
+ DBEVENTINFO einfo = { sizeof(einfo) };
+ db_event_get(hEvent, &einfo);
if (!(einfo.flags & DBEF_SENT))
if ((einfo.eventType == EVENTTYPE_MESSAGE && bFlashOnMsg && checkOpenWindow(hContact) && checkMsgTimestamp(hEvent, einfo.timestamp)) ||
(einfo.eventType == EVENTTYPE_URL && bFlashOnURL) ||
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp
index 66579bdfb0..75be3cdacf 100644
--- a/plugins/MenuItemEx/src/main.cpp
+++ b/plugins/MenuItemEx/src/main.cpp
@@ -1102,7 +1102,7 @@ static int ContactSettingChanged( WPARAM wParam, LPARAM lParam )
if (oldStatus == newStatus)
return 0;
- char *lpzProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )wParam, 0);
+ char *lpzProto = GetContactProto(hContact);
// ignore chat rooms
if (DBGetContactSettingByte(hContact, lpzProto, "ChatRoom", 0))
diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp
index a86b255730..20b76c484d 100755
--- a/plugins/MetaContacts/src/meta_services.cpp
+++ b/plugins/MetaContacts/src/meta_services.cpp
@@ -253,8 +253,7 @@ INT_PTR MetaFilter_SendMessage(WPARAM wParam,LPARAM lParam)
if ( ccs->wParam & PREF_UNICODE )
dbei.cbBlob *= ( sizeof( wchar_t )+1 );
dbei.pBlob = (PBYTE)ccs->lParam;
-
- CallService(MS_DB_EVENT_ADD, (WPARAM)hMeta, (LPARAM)&dbei);
+ db_event_add(hMeta, &dbei);
}
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
@@ -348,8 +347,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam)
if ( ccs->wParam & PREF_UNICODE )
dbei.cbBlob *= ( sizeof( wchar_t )+1 );
dbei.pBlob = (PBYTE)ccs->lParam;
-
- CallService(MS_DB_EVENT_ADD, (WPARAM) ccs->hContact, (LPARAM)&dbei);
+ db_event_add(ccs->hContact, &dbei);
}
}
@@ -449,8 +447,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam)
dbei.cbBlob *= ( sizeof( wchar_t )+1 );
}
dbei.pBlob = (PBYTE) pre->szMessage;
-
- CallService(MS_DB_EVENT_ADD, (WPARAM) hMeta, (LPARAM)&dbei);
+ db_event_add(hMeta, &dbei);
}
}
@@ -510,7 +507,7 @@ INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam)
if ( pre->flags & PREF_UNICODE )
dbei.cbBlob *= ( sizeof( wchar_t )+1 );
dbei.pBlob = (PBYTE) pre->szMessage;
- CallService(MS_DB_EVENT_ADD, (WPARAM) ccs->hContact, (LPARAM)&dbei);
+ db_event_add(ccs->hContact, &dbei);
return 0;
}
diff --git a/plugins/MetaContacts/src/meta_utils.cpp b/plugins/MetaContacts/src/meta_utils.cpp
index ca2fc7abf3..6e722ea08d 100644
--- a/plugins/MetaContacts/src/meta_utils.cpp
+++ b/plugins/MetaContacts/src/meta_utils.cpp
@@ -1462,21 +1462,18 @@ void copyHistory(HANDLE hContactFrom,HANDLE hContactTo)
prog = GetDlgItem(progress_dialog, IDC_PROG);
//CallService(MS_DB_SETSAFETYMODE, (WPARAM)FALSE, 0);
- for (hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST,(WPARAM)hContactFrom, 0);
- hDbEvent;
- hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0))
+ for (hDbEvent = db_event_first(hContactFrom); hDbEvent; hDbEvent = db_event_next(hDbEvent))
{
// get the event
ZeroMemory(&dbei, sizeof(dbei));
dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == -1)
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
break;
buffer = (BYTE *)mir_realloc(buffer, dbei.cbBlob);// + id_length);
dbei.pBlob = buffer;
-
- if (CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei))
+ if ( db_event_get(hDbEvent, &dbei))
break;
// i.e. optoins.days_history == 0;
@@ -1495,7 +1492,7 @@ void copyHistory(HANDLE hContactFrom,HANDLE hContactTo)
dbei.szModule = META_PROTO;
dbei.flags &= ~DBEF_FIRST;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContactTo, (LPARAM)&dbei);
+ db_event_add(hContactTo, &dbei);
}
DestroyWindow(progress_dialog);
diff --git a/plugins/MirOTR/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/MirOTR/src/dbfilter.cpp
index 5db0963dc1..9c0739fad3 100644
--- a/plugins/MirOTR/MirOTR/src/dbfilter.cpp
+++ b/plugins/MirOTR/MirOTR/src/dbfilter.cpp
@@ -20,19 +20,19 @@ VOID CALLBACK DeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi
if (!DeleteEvents.first) return;
EnterCriticalSection(lpRemoveChainCS);
DeleteEventNode *prev =0, *current, *next;
- DBEVENTINFO info = {0};
- info.cbSize = sizeof(info);
+ DBEVENTINFO info = { sizeof(info) };
next = DeleteEvents.first;
while (current = next) {
if (difftime(time(0), current->timestamp) < 1) break;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)current->hDbEvent, (LPARAM)&info)) // && info.flags&DBEF_READ)
+ if (!db_event_get(current->hDbEvent, &info)) // && info.flags&DBEF_READ)
{
- CallService(MS_DB_EVENT_DELETE, (WPARAM)current->hContact, (LPARAM)current->hDbEvent);
+ db_event_delete(current->hContact, current->hDbEvent);
next = current->next;
if (prev) prev->next = next;
else if (DeleteEvents.first == current) DeleteEvents.first = next;
delete current;
- } else {
+ }
+ else {
prev = current;
next = current->next;
}
@@ -138,8 +138,8 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
memcpy(newmsg+alloclen, msg+len2, datalen);
alloclen += datalen;
}
-
- } else {
+ }
+ else {
char *prefix = mir_utf8decodeA(options.prefix);
int prefixlen = strlen(prefix);
if (strncmp(msg, prefix, prefixlen) == 0) {
@@ -170,40 +170,37 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
my_dbei.cbBlob = alloclen;
my_dbei.flags |= DBEF_OTR_PREFIXED;
- CallService(MS_DB_EVENT_ADD, wParam, (LPARAM)&my_dbei);
+ db_event_add(hContact, &my_dbei);
if (newmsg) mir_free(newmsg);
// stop original event from being added
return 1;
}
- int OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam) {
+ int OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam)
+ {
if (!options.delete_history) return 0;
- DBEVENTINFO info = {0};
- info.cbSize = sizeof(info);
-
static char* prefixutf = mir_utf8encodeT(TranslateT(LANG_INLINE_PREFIX));
static char* prefix = Translate(LANG_INLINE_PREFIX);
static DWORD lenutf = strlen(prefixutf);
static DWORD len = strlen(prefix);
+
+ DBEVENTINFO info = { sizeof(info) };
info.cbBlob = lenutf*2;
info.pBlob = (PBYTE)mir_alloc(info.cbBlob);
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&info)) {
+ if (!db_event_get((HANDLE)lParam, &info)) {
if(info.eventType == EVENTTYPE_MESSAGE) {
HANDLE hContact = (HANDLE)wParam, hSub;
- if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService
- (MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
- hContact = hSub;
- }
+ if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
+ hContact = hSub;
+
ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
if (context && otr_context_get_trust(context) != TRUST_NOT_PRIVATE ) {
// only delete encrypted messages that are no OTR system messages
if ( options.delete_systeminfo ||
((info.flags&DBEF_UTF && !(info.cbBlob >lenutf && 0==strncmp((char*)info.pBlob, prefixutf, lenutf)))
- || (!(info.flags&DBEF_UTF) && !(info.cbBlob >len && 0==strncmp((char*)info.pBlob, prefix, len)))
- )
- )
+ || (!(info.flags&DBEF_UTF) && !(info.cbBlob >len && 0==strncmp((char*)info.pBlob, prefix, len)))))
{
DeleteEventNode *node = new DeleteEventNode();
node->hContact = hContact;
diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp
index 5de43566b3..3b4a2f12fb 100755
--- a/plugins/Msg_Export/src/FileViewer.cpp
+++ b/plugins/Msg_Export/src/FileViewer.cpp
@@ -649,32 +649,23 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
{
DWORD dwStart = GetTickCount();
- HWND hRichEdit = GetDlgItem( hwndDlg, IDC_RICHEDIT );
- if (!hRichEdit )
- {
+ HWND hRichEdit = GetDlgItem( hwndDlg, IDC_RICHEDIT);
+ if (!hRichEdit) {
MessageBox( hwndDlg, TranslateT("Failed to get handle to RichEdit!"), MSG_BOX_TITEL, MB_OK );
return false;
}
-
- HANDLE hFile = CreateFile( pclDlg->sPath.c_str(), GENERIC_READ,
+ HANDLE hFile = CreateFile( pclDlg->sPath.c_str(), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
-
-
- if (hFile == INVALID_HANDLE_VALUE )
- {
- int nDBCount = (int)CallService( MS_DB_EVENT_GETCOUNT, (WPARAM)(pclDlg->hContact),0 );
+ if (hFile == INVALID_HANDLE_VALUE) {
+ int nDBCount = db_event_count(pclDlg->hContact);
TCHAR szTmp[1500];
if (nDBCount == -1 )
- {
mir_sntprintf(szTmp, 1499, LPGENT("Failed to open file\r\n%s\r\n\r\nContact handle is invalid"), pclDlg->sPath.c_str());
- }
else
- {
mir_sntprintf( szTmp, 1499, LPGENT("Failed to open file\r\n%s\r\n\r\nMiranda database contains %d events"), pclDlg->sPath.c_str(), nDBCount );
- }
SETTEXTEX stText = {0};
stText.codepage = CP_ACP;
@@ -688,8 +679,7 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
bool bScrollToBottom = true;
if (pclDlg->bFirstLoad )
pclDlg->bFirstLoad = false;
- else
- {
+ else {
SCROLLINFO sScrollInfo = { 0 };
sScrollInfo.cbSize = sizeof( SCROLLINFO );
sScrollInfo.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
@@ -697,7 +687,6 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
bScrollToBottom = sScrollInfo.nPos + (int)sScrollInfo.nPage + 50 > sScrollInfo.nMax;
}
-
HMENU hSysMenu = GetSystemMenu( hwndDlg, FALSE );
bool bUseSyntaxHL = (GetMenuState( hSysMenu , ID_FV_SYNTAX_HL, MF_BYCOMMAND) & MF_CHECKED)!=0;
@@ -717,8 +706,7 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
EDITSTREAM eds;
eds.dwError = 0;
- if (bUseSyntaxHL )
- {
+ if (bUseSyntaxHL ) {
SendMessage( hRichEdit, // handle to destination window
EM_EXLIMITTEXT, // message to send
0, // not used; must be zero
@@ -731,8 +719,7 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
SendMessage(hRichEdit, EM_STREAMIN, (WPARAM)SF_RTF, (LPARAM)&eds);
pclDlg->bUtf8File = clInfo.bUtf8File;
}
- else
- {
+ else {
eds.dwCookie = (DWORD )hFile;
eds.pfnCallback = RichEditStreamLoadFile;
@@ -746,7 +733,6 @@ bool bLoadFile( HWND hwndDlg, CLHistoryDlg * pclDlg )
mir_sntprintf( szTmp, 99, _T("File open time %d\n"), GetTickCount() - dwStart );
OutputDebugString( szTmp );
-
GETTEXTLENGTHEX sData = { 0 };
sData.flags = GTL_NUMCHARS;
sData.flags = GTL_DEFAULT;
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp
index 9280c3fc1c..a691f2da31 100755
--- a/plugins/Msg_Export/src/options.cpp
+++ b/plugins/Msg_Export/src/options.cpp
@@ -64,9 +64,8 @@ class CLDBEvent
hUser = hU;
hDbEvent = hDBE;
- DBEVENTINFO dbei={0}; //dbei.cbBlob=0;
- dbei.cbSize=sizeof(dbei);
- CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
time = dbei.timestamp;
}
bool operator <(const CLDBEvent& rOther) const
@@ -240,13 +239,10 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected )
list< CLDBEvent > & rclCurList = AllEvents[ GetFilePathFromUser( hContact) ];
- HANDLE hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST,(WPARAM)hContact,0);
- while( hDbEvent)
- {
+ HANDLE hDbEvent = db_event_first(hContact);
+ while( hDbEvent) {
rclCurList.push_back( CLDBEvent( hContact, hDbEvent));
-
- // Get next event in chain
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0);
+ hDbEvent = db_event_next(hDbEvent);
}
SendMessage( hProg, PBM_SETPOS, nCur, 0);
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index a2accf6a7d..f614520b28 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -1417,39 +1417,27 @@ void ExportDBEventInfo(HANDLE hContact, DBEVENTINFO &dbei )
int nExportEvent(WPARAM wparam,LPARAM lparam)
{
- HANDLE hContact = (HANDLE)wparam;
-
+ HANDLE hContact = (HANDLE)wparam, hDbEvent = (HANDLE)lparam;
if ( !db_get_b(hContact,MODULE,"EnableLog",1))
return 0;
- DBEVENTINFO dbei={0};
- dbei.cbSize=sizeof(dbei);
- char szTemp[500];
-
- { // Get Blob data size
-
- int nSize = (int)CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)lparam,0);
- if (nSize > 0 )
- {
- dbei.cbBlob = nSize;
- dbei.pBlob = (PBYTE)malloc(dbei.cbBlob + 2 );
- dbei.pBlob[dbei.cbBlob] = 0;
- dbei.pBlob[dbei.cbBlob+1] = 0;
- // Double null terminate, this shut pervent most errors
- // where the blob received has an invalid format
- }
- // else dbei.cbBlob will be 0
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ int nSize = db_event_getBlobSize(hDbEvent);
+ if (nSize > 0) {
+ dbei.cbBlob = nSize;
+ dbei.pBlob = (PBYTE)malloc(dbei.cbBlob + 2 );
+ dbei.pBlob[dbei.cbBlob] = 0;
+ dbei.pBlob[dbei.cbBlob+1] = 0;
+ // Double null terminate, this shut pervent most errors
+ // where the blob received has an invalid format
}
- if ( !CallService(MS_DB_EVENT_GET,(WPARAM)lparam,(LPARAM)&dbei))
- {
- if (dbei.eventType != EVENTTYPE_STATUSCHANGE )
- {
+ if ( !db_event_get(hDbEvent, &dbei)) {
+ if (dbei.eventType != EVENTTYPE_STATUSCHANGE) {
+ char szTemp[500];
_snprintf( szTemp, sizeof( szTemp ), "DisableProt_%s", dbei.szModule );
if (db_get_b(NULL,MODULE,szTemp,1))
- {
ExportDBEventInfo( hContact, dbei );
- }
}
}
if (dbei.pBlob )
diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp
index 67f3efd4ab..8d7c95c0e3 100644
--- a/plugins/NewEventNotify/src/main.cpp
+++ b/plugins/NewEventNotify/src/main.cpp
@@ -63,7 +63,6 @@ int HookedNewEvent(WPARAM wParam, LPARAM lParam)
//lParam: dbevent-handle
{
HANDLE hContact = (HANDLE)wParam;
- DBEVENTINFO dbe = {0};
PLUGIN_DATA* pdata;
DBEVENTTYPEDESCR* pei;
@@ -72,8 +71,8 @@ int HookedNewEvent(WPARAM wParam, LPARAM lParam)
return 0;
//get DBEVENTINFO without pBlob
- dbe.cbSize = sizeof(dbe);
- CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbe);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ db_event_get((HANDLE)lParam, &dbe);
//do not show popups for sub-contacts
if (hContact && ServiceExists(MS_MC_GETMETACONTACT) && CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0))
diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp
index 2da7db7fdd..3dd32db00d 100644
--- a/plugins/NewEventNotify/src/popup.cpp
+++ b/plugins/NewEventNotify/src/popup.cpp
@@ -109,7 +109,7 @@ int PopupAct(HWND hWnd, UINT mask, PLUGIN_DATA* pdata)
pdata->iLock = 1;
while (eventData) {
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)pdata->hContact, (LPARAM)eventData->hEvent);
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)pdata->hContact, (LPARAM)eventData->hEvent);
+ db_event_markRead(pdata->hContact, eventData->hEvent);
eventData = eventData->next;
}
FreePopupEventData(pdata);
@@ -438,17 +438,15 @@ int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UIN
}
//get DBEVENTINFO with pBlob if preview is needed (when is test then is off)
- DBEVENTINFO dbe = {0};
- dbe.cbSize = sizeof(dbe);
-
- if ((pluginOptions->bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST) && hEvent) {
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ if (hEvent) {
+ if ((pluginOptions->bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST)) {
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
+ }
+ db_event_get(hEvent, &dbe);
}
- if (hEvent)
- CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
-
eventData = (EVENT_DATA_EX*)mir_alloc(sizeof(EVENT_DATA_EX));
eventData->hEvent = hEvent;
eventData->number = 1;
@@ -560,12 +558,12 @@ int PopupUpdate(HANDLE hContact, HANDLE hEvent)
dbe.pBlob = NULL;
dbe.cbBlob = 0;
if (pdata->pluginOptions->bPreview && eventData->hEvent) {
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)eventData->hEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(eventData->hEvent);
dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
}
if (eventData->hEvent)
- CallService(MS_DB_EVENT_GET, (WPARAM)eventData->hEvent, (LPARAM)&dbe);
+ db_event_get(eventData->hEvent, &dbe);
if (pdata->pluginOptions->bShowDate || pdata->pluginOptions->bShowTime) {
TCHAR timestamp[MAX_DATASIZE];
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp
index 3fc36c9f64..3394286462 100644
--- a/plugins/NewXstatusNotify/src/xstatus.cpp
+++ b/plugins/NewXstatusNotify/src/xstatus.cpp
@@ -46,7 +46,7 @@ void RemoveLoggedEvents(HANDLE hContact)
for (int i = eventList.getCount()-1; i >= 0; i--) {
DBEVENT *dbevent = eventList[i];
if (dbevent->hContact == hContact) {
- CallService(MS_DB_EVENT_DELETE, (WPARAM)dbevent->hContact, (LPARAM)dbevent->hDBEvent);
+ db_event_delete(dbevent->hContact, dbevent->hDBEvent);
eventList.remove(i);
mir_free(dbevent);
}
@@ -267,7 +267,7 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening)
dbei.timestamp = (DWORD)time(NULL);
dbei.szModule = xsc->szProto;
- HANDLE hDBEvent = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)xsc->hContact, (LPARAM)&dbei);
+ HANDLE hDBEvent = db_event_add(xsc->hContact, &dbei);
mir_free(blob);
if (!opt.KeepInHistory) {
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index c0ef7ab162..82976fa50d 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -640,8 +640,7 @@ int onSendFile(WPARAM w, LPARAM l)
void HistoryLog(HANDLE hContact, db_event evt)
{
- DBEVENTINFO Event = {0};
- Event.cbSize = sizeof(Event);
+ DBEVENTINFO Event = { sizeof(Event) };
Event.szModule = szGPGModuleName;
Event.eventType = evt.eventType;
Event.flags = evt.flags;
@@ -651,7 +650,7 @@ void HistoryLog(HANDLE hContact, db_event evt)
Event.timestamp = evt.timestamp;
Event.cbBlob = strlen((char*)evt.pBlob)+1;
Event.pBlob = (PBYTE)_strdup((char*)evt.pBlob);
- CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)hContact,(LPARAM)&Event);
+ db_event_add(hContact, &Event);
}
static int ControlAddStringUtf(HWND ctrl, DWORD msg, const TCHAR *szString)
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index f55d1ea9b0..8ec665374a 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -1059,19 +1059,18 @@ VOID CheckCurrentFeed(HANDLE hContact)
else
stamp = DateToUnixTime(datetime, 0);
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_first(hContact);
BOOL MesExist = FALSE;
while (hDbEvent)
{
- DBEVENTINFO olddbei = {0};
- olddbei.cbSize = sizeof(olddbei);
- olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ DBEVENTINFO olddbei = { sizeof(olddbei) };
+ olddbei.cbBlob = db_event_getBlobSize(hDbEvent);
olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
+ db_event_get(hDbEvent, &olddbei);
char *pszTemp = mir_utf8encodeT(message);
if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
MesExist = TRUE;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
mir_free(olddbei.pBlob);
mir_free(pszTemp);
}
@@ -1352,19 +1351,18 @@ VOID CheckCurrentFeed(HANDLE hContact)
else
stamp = DateToUnixTime(datetime, 1);
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_first(hContact);
BOOL MesExist = FALSE;
while (hDbEvent)
{
- DBEVENTINFO olddbei = {0};
- olddbei.cbSize = sizeof(olddbei);
- olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ DBEVENTINFO olddbei = { sizeof(olddbei) };
+ olddbei.cbBlob = db_event_getBlobSize(hDbEvent);
olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
+ db_event_get(hDbEvent, &olddbei);
char *pszTemp = mir_utf8encodeT(message);
if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
MesExist = TRUE;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
mir_free(olddbei.pBlob);
mir_free(pszTemp);
}
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp
index dfa1b2c124..c2f571526e 100644
--- a/plugins/NoHistory/src/dllmain.cpp
+++ b/plugins/NoHistory/src/dllmain.cpp
@@ -54,8 +54,7 @@ extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirand
void RemoveReadEvents(HANDLE hContact = 0)
{
- DBEVENTINFO info = {0};
- info.cbSize = sizeof(info);
+ DBEVENTINFO info = { sizeof(info) };
bool remove;
EnterCriticalSection(&list_cs);
@@ -64,7 +63,7 @@ void RemoveReadEvents(HANDLE hContact = 0)
remove = false;
if (hContact == 0 || hContact == node->hContact) {
info.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)node->hDBEvent, (LPARAM)&info)) {
+ if (!db_event_get(node->hDBEvent, &info)) {
if ((info.flags & DBEF_READ) || (info.flags & DBEF_SENT)) // note: already checked event type when added to list
remove = true;
}
@@ -76,7 +75,7 @@ void RemoveReadEvents(HANDLE hContact = 0)
if (remove) {
if (db_get_b(node->hContact, MODULE, DBSETTING_REMOVE, 0)) // is history disabled for this contact?
- CallService(MS_DB_EVENT_DELETE, (WPARAM)node->hContact, (LPARAM)node->hDBEvent);
+ db_event_delete(node->hContact, node->hDBEvent);
// remove list node anyway
if (event_list == node) event_list = node->next;
@@ -98,10 +97,10 @@ void RemoveReadEvents(HANDLE hContact = 0)
void RemoveAllEvents(HANDLE hContact)
{
- HANDLE hDBEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDBEvent = db_event_first(hContact);
while(hDBEvent) {
- HANDLE hDBEventNext = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDBEvent, 0);
- CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDBEvent);
+ HANDLE hDBEventNext = db_event_next(hDBEvent);
+ db_event_delete(hContact, hDBEvent);
hDBEvent = hDBEventNext;
}
}
@@ -119,9 +118,8 @@ int OnDatabaseEventAdd(WPARAM wParam, LPARAM lParam)
if (db_get_b(hContact, MODULE, DBSETTING_REMOVE, 0) == 0)
return 0;
- DBEVENTINFO info = {0};
- info.cbSize = sizeof(info);
- if ( !CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&info)) {
+ DBEVENTINFO info = { sizeof(info) };
+ if ( !db_event_get(hDBEvent, &info)) {
if (info.eventType == EVENTTYPE_MESSAGE) {
EventListNode *node = (EventListNode *)malloc(sizeof(EventListNode));
node->hContact = hContact;
@@ -166,13 +164,10 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuToggle, (LPARAM)&mi);
mi.flags = CMIM_FLAGS;
- if (chat_room) mi.flags |= CMIF_HIDDEN;
- else {
- int event_count = (int)CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hContact, 0);
- if (event_count <= 0) mi.flags |= CMIF_HIDDEN;
- }
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuClear, (LPARAM)&mi);
+ if (chat_room || db_event_count(hContact) <= 0)
+ mi.flags |= CMIF_HIDDEN;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuClear, (LPARAM)&mi);
return 0;
}
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index e9216bc737..d94994b68a 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -572,15 +572,13 @@ void Nudge_SentStatus(CNudgeElement n, HANDLE hContact)
NudgeEvent.pBlob = ( PBYTE ) buff;
INT_PTR res = CallService( MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 ); //try to retrieve the metacontact if some
- if(res != CALLSERVICE_NOTFOUND)
- {
+ if(res != CALLSERVICE_NOTFOUND) {
HANDLE hMetaContact = (HANDLE) res;
if(hMetaContact != NULL) //metacontact
- CallService(MS_DB_EVENT_ADD,(WPARAM)hMetaContact,(LPARAM)&NudgeEvent);
+ db_event_add(hMetaContact, &NudgeEvent);
}
-
- CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&NudgeEvent);
+ db_event_add(hContact, &NudgeEvent);
}
void Nudge_ShowStatus(CNudgeElement n, HANDLE hContact, DWORD timestamp)
@@ -600,17 +598,15 @@ void Nudge_ShowStatus(CNudgeElement n, HANDLE hContact, DWORD timestamp)
INT_PTR res = CallService( MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 ); //try to retrieve the metacontact if some
- if(res != CALLSERVICE_NOTFOUND)
- {
+ if(res != CALLSERVICE_NOTFOUND) {
HANDLE hMetaContact = (HANDLE) res;
- if(hMetaContact != NULL) //metacontact
- {
- CallService(MS_DB_EVENT_ADD,(WPARAM)hMetaContact,(LPARAM)&NudgeEvent);
+ if(hMetaContact != NULL) { //metacontact
+ db_event_add(hMetaContact, &NudgeEvent);
NudgeEvent.flags |= DBEF_READ;
}
}
- CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&NudgeEvent);
+ db_event_add(hContact, &NudgeEvent);
}
HANDLE Nudge_GethContact(HANDLE hContact)
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp
index 37781aee6d..7600d2a4bb 100644
--- a/plugins/PasteIt/src/PasteIt.cpp
+++ b/plugins/PasteIt/src/PasteIt.cpp
@@ -137,7 +137,7 @@ void PasteIt(HANDLE hContact, int mode)
dbei.timestamp = (DWORD)time(NULL);
dbei.cbBlob = (DWORD)strlen(pasteToWeb->szFileLink) + 1;
dbei.pBlob = (PBYTE)pasteToWeb->szFileLink;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)pasteToWeb->szFileLink);
}
else
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index ba4703f153..7a7782602e 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -980,7 +980,7 @@ void AddMessageToDB(HANDLE hContact, char *msg, int flag/*bool utf*/)
else
dbei.cbBlob = lstrlenA(msg) + 1;
dbei.pBlob = (PBYTE)msg;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index 3bc7f4f355..2a653dbd21 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -217,18 +217,11 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
// handle of contact is set as window-userdata
int EventAdded(WPARAM wparam, LPARAM lparam)
{
- DBEVENTINFO dbei;
-
- ZeroMemory(&dbei,sizeof(dbei));
- dbei.cbSize=sizeof(dbei);
- dbei.cbBlob=0;
-
- CallService(MS_DB_EVENT_GET,lparam,(LPARAM)&dbei);
-
- if( !(dbei.flags & DBEF_SENT)
- || dbei.flags & DBEF_READ
- || !DBGetContactSettingByte(NULL, MODULE_NAME, "EnableLastSentTo", 0)
- || DBGetContactSettingWord(NULL, MODULE_NAME, "MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lparam, &dbei);
+ if ( !(dbei.flags & DBEF_SENT) || (dbei.flags & DBEF_READ)
+ || !DBGetContactSettingByte(NULL, MODULE_NAME, "EnableLastSentTo", 0)
+ || DBGetContactSettingWord(NULL, MODULE_NAME, "MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
return 0;
DBWriteContactSettingDword(NULL, MODULE_NAME, "LastSentTo", (DWORD)(HANDLE)wparam);
diff --git a/plugins/Quotes/src/QuotesProviderBase.cpp b/plugins/Quotes/src/QuotesProviderBase.cpp
index d0d9c5fa6f..92f9203e39 100644
--- a/plugins/Quotes/src/QuotesProviderBase.cpp
+++ b/plugins/Quotes/src/QuotesProviderBase.cpp
Binary files differ
diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp
index c68219706b..8099152f09 100644
--- a/plugins/RecentContacts/src/RecentContacts.cpp
+++ b/plugins/RecentContacts/src/RecentContacts.cpp
@@ -382,39 +382,25 @@ INT_PTR OnMenuCommandShowList(WPARAM wParam, LPARAM lParam)
HANDLE curContact = db_find_first();
for (; curContact != NULL; curContact = db_find_next(curContact))
{
-// if (IsMessageAPI)
- {
- curTime = ((__time64_t)db_get_dw(curContact, dbLastUC_ModuleName, dbLastUC_LastUsedTimeLo, -1)) |
- (((__time64_t)db_get_dw(curContact, dbLastUC_ModuleName, dbLastUC_LastUsedTimeHi, -1)) << 32);
- //use TabSRMM last used time. ! NOT used, because bug: TabSRMM reset last used time to time when miranda started at miranda start!
- //t = ((DWORD)db_get_dw(curContact, "Tab_SRMsg", "isRecent", -1));
- //if (t != -1)
- //{
- // if (curTime == -1 || (__time64_t)t > curTime)
- // curTime = (__time64_t)t;
- //}
- }
-// else
- {
- curEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)curContact, 0);
- if (curEvent != NULL)
- {
- for ( ; curEvent != NULL; curEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)curEvent, 0))
- {
- dbe.cbBlob = 1;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)curEvent, (LPARAM)&dbe) != 0)
- {
- curEvent = NULL;
- break;
- }
- if ((dbe.flags & (DBEF_READ | DBEF_SENT)) && dbe.eventType < 2000)
- break;
+ curTime = ((__time64_t)db_get_dw(curContact, dbLastUC_ModuleName, dbLastUC_LastUsedTimeLo, -1)) |
+ (((__time64_t)db_get_dw(curContact, dbLastUC_ModuleName, dbLastUC_LastUsedTimeHi, -1)) << 32);
+
+ curEvent = db_event_last(curContact);
+ if (curEvent != NULL) {
+ for ( ; curEvent != NULL; curEvent = db_event_prev(curEvent)) {
+ dbe.cbBlob = 1;
+ if (db_event_get(curEvent, &dbe) != 0) {
+ curEvent = NULL;
+ break;
}
- if (curEvent != NULL)
- if (curTime == -1 || (__time64_t)dbe.timestamp > curTime)
- curTime = (__time64_t)dbe.timestamp;
+ if ((dbe.flags & (DBEF_READ | DBEF_SENT)) && dbe.eventType < 2000)
+ break;
}
+ if (curEvent != NULL)
+ if (curTime == -1 || (__time64_t)dbe.timestamp > curTime)
+ curTime = (__time64_t)dbe.timestamp;
}
+
if (curTime != -1)
contacts->insert(cpair(curTime, curContact));
}
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp
index cf86f77220..4a60c271fd 100644
--- a/plugins/SMS/src/SMS_svc.cpp
+++ b/plugins/SMS/src/SMS_svc.cpp
@@ -112,24 +112,20 @@ int SendSMSMenuCommand(WPARAM wParam,LPARAM lParam)
{// user clicked on the "SMS Message" on one of the users
hwndSendSms=SendSMSWindowIsOtherInstanceHContact((HANDLE)wParam);
if (hwndSendSms)
- {
SetFocus(hwndSendSms);
- }else{
+ else
hwndSendSms=SendSMSWindowAdd((HANDLE)wParam);
- }
- }else{// user clicked on the "SMS Send" in the Main Menu
+ }
+ else{// user clicked on the "SMS Send" in the Main Menu
hwndSendSms=SendSMSWindowAdd(NULL);
EnableWindow(GetDlgItem(hwndSendSms,IDC_NAME),TRUE);
EnableWindow(GetDlgItem(hwndSendSms,IDC_SAVENUMBER),FALSE);
- for(HANDLE hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);hContact!=NULL;hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))
- {
- if (GetContactPhonesCount(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if (GetContactPhonesCount(hContact)) {
SEND_DLG_ITEM_MESSAGEW(hwndSendSms,IDC_NAME,CB_ADDSTRING,0,(LPARAM)GetContactNameW(hContact));
SendSMSWindowSMSContactAdd(hwndSendSms,hContact);
}
- }
}
return 0;
}
@@ -138,88 +134,64 @@ int SendSMSMenuCommand(WPARAM wParam,LPARAM lParam)
//This function used to popup a read SMS window after the user clicked on the received SMS message.
int ReadMsgSMS(WPARAM wParam,LPARAM lParam)
{
- int iRet=1;
- DBEVENTINFO dbei={0};
-
- dbei.cbSize=sizeof(dbei);
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)((CLISTEVENT*)lParam)->hDbEvent,0))!=-1)
- {
- dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob)
- {
- if (CallService(MS_DB_EVENT_GET,(WPARAM)((CLISTEVENT*)lParam)->hDbEvent,(LPARAM)&dbei)==0)
- if (dbei.eventType==ICQEVENTTYPE_SMS || dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- {
- if (RecvSMSWindowAdd(((CLISTEVENT*)lParam)->hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- {
- CallService(MS_DB_EVENT_MARKREAD,(WPARAM)((CLISTEVENT*)lParam)->hContact,(LPARAM)((CLISTEVENT*)lParam)->hDbEvent);
- iRet=0;
- }
+ CLISTEVENT *cle = (CLISTEVENT*)lParam;
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(((CLISTEVENT*)lParam)->hDbEvent)) != -1) {
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
+
+ if (db_event_get(cle->hDbEvent, &dbei) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
+ if (RecvSMSWindowAdd(cle->hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
+ db_event_markRead(cle->hContact, cle->hDbEvent);
+ return 0;
}
- MEMFREE(dbei.pBlob);
}
}
-return(iRet);
+ return 1;
}
//This function used to popup a read SMS window after the user clicked on the received SMS confirmation.
int ReadAckSMS(WPARAM wParam,LPARAM lParam)
{
- int iRet=1;
- DBEVENTINFO dbei={0};
-
- dbei.cbSize=sizeof(dbei);
- CLISTEVENT *cle = ((CLISTEVENT*)lParam);
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)cle->hDbEvent,0))!=-1)
- {
- dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob)
- {
- if (CallService(MS_DB_EVENT_GET,(WPARAM)cle->hDbEvent,(LPARAM)&dbei)==0)
- if (dbei.eventType==ICQEVENTTYPE_SMS || dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- {
- if (RecvSMSWindowAdd(cle->hContact,ICQEVENTTYPE_SMSCONFIRMATION,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- {
- CallService(MS_DB_EVENT_DELETE,(WPARAM)cle->hContact,(LPARAM)cle->hDbEvent);
- iRet=0;
- }
+ CLISTEVENT *cle = (CLISTEVENT*)lParam;
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(cle->hDbEvent)) != -1) {
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
+
+ if (db_event_get(cle->hDbEvent, &dbei) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
+ if (RecvSMSWindowAdd(cle->hContact, ICQEVENTTYPE_SMSCONFIRMATION, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
+ db_event_delete(cle->hContact, cle->hDbEvent);
+ return 0;
}
- MEMFREE(dbei.pBlob);
}
}
-return(iRet);
+ return 1;
}
void RestoreUnreadMessageAlerts(void)
{
- DBEVENTINFO dbei={0};
- HANDLE hDbEvent,hContact;
+ DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbSize=sizeof(dbei);
- for(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);hContact!=NULL;hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))
- for(hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD,(WPARAM)hContact,0);hDbEvent!=NULL;hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0))
- {
- dbei.cbBlob=0;
- if (CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei)==0)
- if ((dbei.flags&(DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- {
- handleNewMessage((WPARAM)hContact,(LPARAM)hDbEvent);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
+ dbei.cbBlob=0;
+ if (db_event_get(hDbEvent, &dbei) == 0)
+ if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
+ if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
+ handleNewMessage((WPARAM)hContact,(LPARAM)hDbEvent);
}
- }
- hContact=NULL;
- for(hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD,(WPARAM)hContact,0);hDbEvent!=NULL;hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0))
- {
+ for (HANDLE hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
dbei.cbBlob=0;
- if (CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei)==0)
- if ((dbei.flags&(DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- {
- handleNewMessage((WPARAM)hContact,(LPARAM)hDbEvent);
- }
+ if (db_event_get(hDbEvent, &dbei) == 0)
+ if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN)
+ handleNewMessage(NULL, (LPARAM)hDbEvent);
}
}
diff --git a/plugins/SMS/src/common.h b/plugins/SMS/src/common.h
index 495aa6a7ae..14e04c614d 100644
--- a/plugins/SMS/src/common.h
+++ b/plugins/SMS/src/common.h
@@ -11,6 +11,7 @@
#include <windows.h>
#include <commctrl.h>
+#include <malloc.h>
#include <time.h>
#include <newpluginapi.h>
diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp
index 157b85d78f..0bdb9ce46e 100644
--- a/plugins/SMS/src/functions.cpp
+++ b/plugins/SMS/src/functions.cpp
@@ -66,16 +66,15 @@ LPSTR GetModuleName(HANDLE hContact)
{
LPSTR lpszRet;
- if (hContact)
- {
- lpszRet=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (lpszRet==NULL) lpszRet=PROTOCOL_NAMEA;
- }else{
- lpszRet=PROTOCOL_NAMEA;
+ if (hContact) {
+ lpszRet = GetContactProto(hContact);
+ if (lpszRet == NULL)
+ lpszRet = PROTOCOL_NAMEA;
}
-return(lpszRet);
-}
+ else lpszRet = PROTOCOL_NAMEA;
+ return lpszRet;
+}
void EnableControlsArray(HWND hWndDlg,WORD *pwControlsList,SIZE_T dwControlsListCount,BOOL bEnabled)
{
@@ -211,11 +210,9 @@ BOOL IsContactPhone(HANDLE hContact,LPWSTR lpwszPhone,SIZE_T dwPhoneSize)
{
BOOL bRet=FALSE;
WCHAR wszPhoneLocal[MAX_PHONE_LEN];
- LPSTR lpszProto;
- SIZE_T dwPhoneSizeLocal;
- dwPhoneSizeLocal=CopyNumberW(wszPhoneLocal,lpwszPhone,dwPhoneSize);
- lpszProto=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ SIZE_T dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal,lpwszPhone,dwPhoneSize);
+ LPSTR lpszProto = GetContactProto(hContact);
if (lpszProto) {
if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,lpszProto,"Phone",wszPhoneLocal,dwPhoneSizeLocal);
if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,lpszProto,"Cellular",wszPhoneLocal,dwPhoneSizeLocal);
diff --git a/plugins/SMS/src/receive.cpp b/plugins/SMS/src/receive.cpp
index b201f82db9..5e167739d0 100644
--- a/plugins/SMS/src/receive.cpp
+++ b/plugins/SMS/src/receive.cpp
@@ -47,7 +47,7 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam)
LPWSTR lpwszMessageXMLEncoded,lpwszMessageXMLDecoded;
SIZE_T dwBuffLen,dwMessageXMLEncodedSize,dwMessageXMLDecodedSize;
HANDLE hContact;
- DBEVENTINFO dbei={0};
+ DBEVENTINFO dbei = { sizeof(dbei) };
dwBuffLen=(dwDataSize+MAX_PATH);
dbei.pBlob=(LPBYTE)MEMALLOC((dwBuffLen+dwPhoneSize));
@@ -64,7 +64,6 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam)
dwPhoneSize=MultiByteToWideChar(CP_UTF8,0,szPhone,dwPhoneSize,wszPhone,MAX_PHONE_LEN);
hContact=HContactFromPhone(wszPhone,dwPhoneSize);
- dbei.cbSize=sizeof(dbei);
dbei.szModule=GetModuleName(hContact);
dbei.timestamp=time(NULL);
dbei.flags=(DBEF_UTF);
@@ -72,12 +71,10 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam)
dbei.cbBlob=(mir_snprintf((LPSTR)dbei.pBlob,((dwBuffLen+dwPhoneSize)),"SMS From: +%s\r\n%s",szPhone,lpszMessageUTF)+sizeof(DWORD));
//dbei.pBlob=(LPBYTE)lpszBuff;
(*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
- CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&dbei);
- if (hContact==NULL)
- {
- if (RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMS,wszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob))
- {
- CallService(MS_DB_EVENT_MARKREAD,(WPARAM)hContact,(LPARAM)&dbei);
+ HANDLE hResult = db_event_add(hContact, &dbei);
+ if (hContact==NULL) {
+ if ( RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMS,wszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
+ db_event_markRead(hContact, hResult);
SkinPlaySound("RecvSMSMsg");
}
}
@@ -124,14 +121,12 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam)
}
}
- if (dbei.pBlob)
- {
+ if (dbei.pBlob) {
if (hContact)
- {
- CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&dbei);
- }else{
+ db_event_add(hContact, &dbei);
+ else
RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMSCONFIRMATION,wszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob);
- }
+
MEMFREE(dbei.pBlob);
}
}
@@ -217,75 +212,62 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam)
}
//Handles new SMS messages added to the database
-int handleNewMessage(WPARAM wParam,LPARAM lParam)
+int handleNewMessage(WPARAM wParam, LPARAM lParam)
{
- CHAR szServiceFunction[MAX_PATH],*pszServiceFunctionName;
+ CHAR szServiceFunction[MAX_PATH], *pszServiceFunctionName;
WCHAR szToolTip[MAX_PATH];
- HANDLE hContact=(HANDLE)wParam,hDbEvent=(HANDLE)lParam;
- CLISTEVENT cle={0};
- DBEVENTINFO dbei={0};
+ HANDLE hContact = (HANDLE)wParam, hDbEvent = (HANDLE)lParam;
- dbei.cbSize=sizeof(dbei);
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,lParam,0))!=-1)
- {
- dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob)
- {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) != -1) {
+ dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
+ if (dbei.pBlob) {
CopyMemory(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
- pszServiceFunctionName=szServiceFunction+PROTOCOL_NAME_LEN;
+ pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
- if (CallService(MS_DB_EVENT_GET,lParam,(LPARAM)&dbei)==0)
- if ((dbei.flags&DBEF_SENT)==0)
- if (dbei.eventType==ICQEVENTTYPE_SMS)
- {
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- {
+ if (db_event_get(hDbEvent, &dbei) == 0)
+ if ((dbei.flags & DBEF_SENT) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS) {
+ if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN) {
SkinPlaySound("RecvSMSMsg");
- if (DB_SMS_GetByte(NULL,"AutoPopup",0))
- {
+ if (DB_SMS_GetByte(NULL,"AutoPopup",0)) {
if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- {
- CallService(MS_DB_EVENT_MARKREAD,(WPARAM)hContact,(LPARAM)&dbei);
- }
- }else{
+ db_event_markRead(hContact, hDbEvent);
+ }
+ else {
CopyMemory(pszServiceFunctionName,SMS_READ,sizeof(SMS_READ));
-
- cle.cbSize=sizeof(cle);
- cle.flags=CLEF_TCHAR;
- cle.hContact=hContact;
- cle.hDbEvent=hDbEvent;
- cle.hIcon=LoadSkinnedIcon(SKINICON_OTHER_SMS);
- cle.pszService=szServiceFunction;
mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Message from %s"),GetContactNameW(hContact));
- cle.ptszTooltip=szToolTip;
+
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.flags = CLEF_TCHAR;
+ cle.hContact = hContact;
+ cle.hDbEvent = hDbEvent;
+ cle.hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMS);
+ cle.pszService = szServiceFunction;
+ cle.ptszTooltip = szToolTip;
CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
}
}
- }else
- if (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)
- {
+ }
+ else if (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION) {
SkinPlaySound("RecvSMSConfirmation");
- if (DB_SMS_GetByte(NULL,"AutoPopup",0))
- {
+ if (DB_SMS_GetByte(NULL, "AutoPopup", 0)) {
if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMSCONFIRMATION,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- {
- CallService(MS_DB_EVENT_DELETE,(WPARAM)hContact,(LPARAM)&dbei);
- }
- }else{
+ db_event_delete(hContact, &dbei);
+ }
+ else {
UINT iIcon;
-
- if (GetDataFromMessage((LPSTR)dbei.pBlob,dbei.cbBlob,NULL,NULL,0,NULL,&iIcon))
- {
+ if (GetDataFromMessage((LPSTR)dbei.pBlob, dbei.cbBlob, NULL, NULL, 0, NULL, &iIcon)) {
CopyMemory(pszServiceFunctionName,SMS_READ_ACK,sizeof(SMS_READ_ACK));
-
- cle.cbSize=sizeof(cle);
- cle.flags=CLEF_TCHAR;
- cle.hContact=hContact;
- cle.hDbEvent=hDbEvent;
- cle.hIcon=(HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
- cle.pszService=szServiceFunction;
mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Confirmation from %s"),GetContactNameW(hContact));
- cle.ptszTooltip=szToolTip;
+
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.flags = CLEF_TCHAR;
+ cle.hContact = hContact;
+ cle.hDbEvent = hDbEvent;
+ cle.hIcon = (HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
+ cle.pszService = szServiceFunction;
+ cle.ptszTooltip = szToolTip;
CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
}
}
@@ -295,5 +277,3 @@ int handleNewMessage(WPARAM wParam,LPARAM lParam)
}
return 0;
}
-
-
diff --git a/plugins/SMS/src/senddlg.cpp b/plugins/SMS/src/senddlg.cpp
index e4a0361ac2..965e7fcb6e 100644
--- a/plugins/SMS/src/senddlg.cpp
+++ b/plugins/SMS/src/senddlg.cpp
@@ -748,13 +748,10 @@ void SendSMSWindowDbeiSet(HWND hWndDlg,DBEVENTINFO *pdbei)
void SendSMSWindowDBAdd(HWND hWndDlg)
{
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
-
- if (psswdWindowData)
- {
- psswdWindowData->pdbei->cbSize=sizeof(DBEVENTINFO);
- psswdWindowData->pdbei->szModule=GetModuleName(psswdWindowData->hContact);
-
- CallService(MS_DB_EVENT_ADD,(WPARAM)psswdWindowData->hContact,(LPARAM)psswdWindowData->pdbei);
+ if (psswdWindowData) {
+ psswdWindowData->pdbei->cbSize = sizeof(DBEVENTINFO);
+ psswdWindowData->pdbei->szModule = GetModuleName(psswdWindowData->hContact);
+ db_event_add(psswdWindowData->hContact, psswdWindowData->pdbei);
MEMFREE(psswdWindowData->pdbei);
}
}
@@ -763,7 +760,8 @@ void SendSMSWindowDBAdd(HWND hWndDlg)
void SendSMSWindowHItemSendSet(HWND hWndDlg,HTREEITEM hItemSend)
{
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
- if (psswdWindowData) psswdWindowData->hItemSend=hItemSend;
+ if (psswdWindowData)
+ psswdWindowData->hItemSend=hItemSend;
}
//
@@ -773,7 +771,7 @@ HTREEITEM SendSMSWindowHItemSendGet(HWND hWndDlg)
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
if (psswdWindowData) hRet=psswdWindowData->hItemSend;
-return(hRet);
+ return hRet;
}
//
@@ -1017,15 +1015,11 @@ void AddContactPhonesToComboToListParam(HANDLE hContact,LPSTR lpszModule,LPSTR l
void AddContactPhonesToCombo(HWND hWnd,HANDLE hContact)
{
- HWND hWndList;
- LPSTR lpszProto;
-
- hWndList=GetDlgItem(hWnd,IDC_ADDRESS);
+ HWND hWndList = GetDlgItem(hWnd,IDC_ADDRESS);
SEND_DLG_ITEM_MESSAGE(hWnd,IDC_ADDRESS,CB_RESETCONTENT,0,0);
- lpszProto=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (lpszProto)
- {
+ LPSTR lpszProto = GetContactProto(hContact);
+ if (lpszProto) {
AddContactPhonesToComboToListParam(hContact,lpszProto,"Phone",hWndList);
AddContactPhonesToComboToListParam(hContact,lpszProto,"Cellular",hWndList);
AddContactPhonesToComboToListParam(hContact,lpszProto,"Fax",hWndList);
@@ -1095,19 +1089,13 @@ void AddContactPhonesToTreeViewParam(HANDLE hContact,LPSTR lpszModule,LPSTR lpsz
void SendSMSWindowFillTreeView(HWND hWnd)
{
- HWND hWndTreeView;
- LPSTR lpszProto;
- HTREEITEM hParent;
-
- hWndTreeView=GetDlgItem(hWnd,IDC_NUMBERSLIST);
+ HWND hWndTreeView=GetDlgItem(hWnd,IDC_NUMBERSLIST);
TreeView_DeleteAllItems(hWndTreeView);
- for(HANDLE hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);hContact!=NULL;hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))
- {
- hParent=NULL;
- lpszProto=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (lpszProto)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HTREEITEM hParent = NULL;
+ LPSTR lpszProto = GetContactProto(hContact);
+ if (lpszProto) {
AddContactPhonesToTreeViewParam(hContact,lpszProto,"Phone",hWndTreeView,&hParent);
AddContactPhonesToTreeViewParam(hContact,lpszProto,"Cellular",hWndTreeView,&hParent);
AddContactPhonesToTreeViewParam(hContact,lpszProto,"Fax",hWndTreeView,&hParent);
diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp
index 9beff76bcf..130ddeff2d 100644
--- a/plugins/Scriver/src/chat/clist.cpp
+++ b/plugins/Scriver/src/chat/clist.cpp
@@ -294,8 +294,8 @@ HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom)
{
HANDLE hContact = db_find_first();
while (hContact) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0 );
- if ( szProto && !lstrcmpiA( szProto, pszModule )) {
+ char *szProto = GetContactProto(hContact);
+ if (szProto && !lstrcmpiA(szProto, pszModule)) {
if ( DBGetContactSettingByte( hContact, szProto, "ChatRoom", 0) != 0 ) {
DBVARIANT dbv;
if ( !DBGetContactSettingTString( hContact, szProto, "ChatRoomID", &dbv )) {
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index f4a44692b4..e535e6c47c 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -451,7 +451,7 @@ static int ackevent(WPARAM wParam, LPARAM lParam)
if ( !( item->flags & PREF_UTF ))
dbei.cbBlob *= sizeof(TCHAR) + 1;
dbei.pBlob = (PBYTE) item->sendBuffer;
- CallService(MS_DB_EVENT_ADD, (WPARAM) item->hContact, (LPARAM) & dbei);
+ db_event_add(item->hContact, &dbei);
if (item->hwndErrorDlg != NULL)
DestroyWindow(item->hwndErrorDlg);
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 702a890bad..cebcd462aa 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -904,11 +904,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dat->windowData.hContact) {
int historyMode = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_LOADHISTORY, SRMSGDEFSET_LOADHISTORY);
// This finds the first message to display, it works like shit
- dat->hDbEventFirst = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) dat->windowData.hContact, 0);
+ dat->hDbEventFirst = db_event_firstUnread(dat->windowData.hContact);
if (dat->hDbEventFirst != NULL) {
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventFirst, (LPARAM) & dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(dat->hDbEventFirst, &dbei);
if (DbEventIsMessageOrCustom(&dbei) && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
notifyUnread = 1;
}
@@ -916,20 +915,18 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
switch (historyMode) {
case LOADHISTORY_COUNT:
{
- int i;
HANDLE hPrevEvent;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- for (i = DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i > 0; i--) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ for (int i = DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i > 0; i--) {
if (dat->hDbEventFirst == NULL)
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->windowData.hContact, 0);
+ hPrevEvent = db_event_last(dat->windowData.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(&dbei, dat))
i++;
}
@@ -938,28 +935,27 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case LOADHISTORY_TIME:
{
HANDLE hPrevEvent;
- DBEVENTINFO dbei = { 0 };
- DWORD firstTime;
+ DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbSize = sizeof(dbei);
if (dat->hDbEventFirst == NULL) {
dbei.timestamp = time(NULL);
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->windowData.hContact, 0);
- } else {
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventFirst, (LPARAM) & dbei);
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) dat->hDbEventFirst, 0);
+ hPrevEvent = db_event_last(dat->windowData.hContact);
+ }
+ else {
+ db_event_get(dat->hDbEventFirst, &dbei);
+ hPrevEvent = db_event_prev(dat->hDbEventFirst);
}
- firstTime = dbei.timestamp - 60 * DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
+ DWORD firstTime = dbei.timestamp - 60 * DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
for (;;) {
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;
if (DbEventIsShown(&dbei, dat))
dat->hDbEventFirst = hPrevEvent;
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) hPrevEvent, 0);
+ hPrevEvent = db_event_prev(hPrevEvent);
}
break;
}
@@ -967,22 +963,17 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
SendMessage(dat->hwndParent, CM_ADDCHILD, (WPARAM) hwndDlg, (LPARAM) dat->windowData.hContact);
{
- DBEVENTINFO dbei = { 0 };
- HANDLE hdbEvent;
-
- dbei.cbSize = sizeof(dbei);
- hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->windowData.hContact, 0);
+ HANDLE hdbEvent = db_event_last(dat->windowData.hContact);
if (hdbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
do {
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = 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;
break;
}
}
- while ((hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) hdbEvent, 0)));
+ while ((hdbEvent = db_event_prev(hdbEvent)));
}
}
SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0);
@@ -1178,7 +1169,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dbei.flags = 0;
dbei.timestamp = time(NULL);
dbei.szModule = dat->szProto;
- hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM) dat->windowData.hContact, (LPARAM) & dbei);
+ hNewEvent = db_event_add(dat->windowData.hContact, &dbei);
if (dat->hDbEventFirst == NULL) {
dat->hDbEventFirst = hNewEvent;
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
@@ -1357,15 +1348,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
HANDLE hDbEvent = dat->hDbUnreadEventFirst;
dat->hDbUnreadEventFirst = NULL;
while (hDbEvent != NULL) {
- DBEVENTINFO dbei;
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- 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) && (DbEventIsMessageOrCustom(&dbei) || dbei.eventType == EVENTTYPE_URL)) {
CallService(MS_CLIST_REMOVEEVENT, (WPARAM) dat->windowData.hContact, (LPARAM) hDbEvent);
}
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
}
if (dat->showUnread) {
@@ -1486,15 +1474,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
break;
case HM_DBEVENTADDED:
- if ((HANDLE) wParam == dat->windowData.hContact)
- {
- DBEVENTINFO dbei = { 0 };
-
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
+ if ((HANDLE)wParam == dat->windowData.hContact) {
+ HANDLE hDbEvent = (HANDLE)lParam;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (dat->hDbEventFirst == NULL)
- dat->hDbEventFirst = (HANDLE) lParam;
+ dat->hDbEventFirst = hDbEvent;
if (DbEventIsShown(&dbei, dat)) {
int heFlags = HistoryEvents_GetFlags(dbei.eventType);
if (heFlags != -1 && (heFlags & HISTORYEVENTS_FLAG_DEFAULT))
@@ -1503,21 +1488,21 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (DbEventIsMessageOrCustom(&dbei) && !(dbei.flags & (DBEF_SENT))) {
/* store the event when the container is hidden so that clist notifications can be removed */
if (!IsWindowVisible(GetParent(hwndDlg)) && dat->hDbUnreadEventFirst == NULL)
- dat->hDbUnreadEventFirst = (HANDLE) lParam;
+ dat->hDbUnreadEventFirst = hDbEvent;
dat->lastMessage = dbei.timestamp;
SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
if (GetForegroundWindow()==dat->hwndParent && dat->parent->hwndActive == hwndDlg)
SkinPlaySound("RecvMsgActive");
else SkinPlaySound("RecvMsgInactive");
if ((g_dat.flags2 & SMF2_SWITCHTOACTIVE) && (IsIconic(dat->hwndParent) || GetActiveWindow() != dat->hwndParent) && IsWindowVisible(dat->hwndParent)) {
- SendMessage(dat->hwndParent, CM_ACTIVATECHILD, 0, (LPARAM) hwndDlg);
+ SendMessage(dat->hwndParent, CM_ACTIVATECHILD, 0, (LPARAM)hwndDlg);
}
if (IsAutoPopup(dat->windowData.hContact)) {
- SendMessage(GetParent(hwndDlg), CM_POPUPWINDOW, (WPARAM) 1, (LPARAM) hwndDlg);
+ SendMessage(GetParent(hwndDlg), CM_POPUPWINDOW, 1, (LPARAM)hwndDlg);
}
}
- if ((HANDLE) lParam != dat->hDbEventFirst && (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, lParam, 0) == NULL)
- SendMessage(hwndDlg, DM_APPENDTOLOG, lParam, 0);
+ if (hDbEvent != dat->hDbEventFirst && db_event_next(hDbEvent) == NULL)
+ SendMessage(hwndDlg, DM_APPENDTOLOG, WPARAM(hDbEvent), 0);
else
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
if (!(dbei.flags & DBEF_SENT) && dbei.eventType != EVENTTYPE_STATUSCHANGE && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE && (heFlags == -1 || (heFlags & HISTORYEVENTS_FLAG_FLASH_MSG_WINDOW))) {
@@ -1914,23 +1899,23 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
mir_free(quotedBuffer);
mir_free(buffer);
} else {
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) dat->hDbEventLast, 0);
- if (dbei.cbBlob == 0xFFFFFFFF) break;
- dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventLast, (LPARAM) & dbei);
- if (DbEventIsMessageOrCustom(&dbei) || dbei.eventType == EVENTTYPE_STATUSCHANGE) {
- TCHAR *buffer = DbGetEventTextT( &dbei, CP_ACP );
- if (buffer!=NULL) {
- TCHAR *quotedBuffer = GetQuotedTextW(buffer);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETTEXTEX, (WPARAM) &st, (LPARAM)quotedBuffer);
- mir_free(quotedBuffer);
- mir_free(buffer);
- }
- }
- mir_free(dbei.pBlob);
- }
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ dbei.cbSize = sizeof(dbei);
+ dbei.cbBlob = db_event_getBlobSize(dat->hDbEventLast);
+ if (dbei.cbBlob == 0xFFFFFFFF) break;
+ dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
+ db_event_get(dat->hDbEventLast, &dbei);
+ if (DbEventIsMessageOrCustom(&dbei) || dbei.eventType == EVENTTYPE_STATUSCHANGE) {
+ TCHAR *buffer = DbGetEventTextT( &dbei, CP_ACP );
+ if (buffer!=NULL) {
+ TCHAR *quotedBuffer = GetQuotedTextW(buffer);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETTEXTEX, (WPARAM) &st, (LPARAM)quotedBuffer);
+ mir_free(quotedBuffer);
+ mir_free(buffer);
+ }
+ }
+ mir_free(dbei.pBlob);
+ }
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
break;
}
case IDC_ADD:
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index 91e9c2a9b7..2e6c95e393 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -173,10 +173,10 @@ EventData *getEventFromDB(struct SrmmWindowData *dat, HANDLE hContact, HANDLE hD
DBEVENTINFO dbei = { 0 };
EventData *event;
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) hDbEvent, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob == -1) return NULL;
dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
+ db_event_get(hDbEvent, &dbei);
if (!DbEventIsShown(&dbei, dat)) {
mir_free(dbei.pBlob);
return NULL;
@@ -185,11 +185,11 @@ EventData *getEventFromDB(struct SrmmWindowData *dat, HANDLE hContact, HANDLE hD
memset(event, 0, sizeof(EventData));
event->custom = DbEventIsCustomForMsgWindow(&dbei);
if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL || event->custom)) {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM) hContact, (LPARAM) hDbEvent);
+ db_event_markRead(hContact, hDbEvent);
CallService(MS_CLIST_REMOVEEVENT, (WPARAM) hContact, (LPARAM) hDbEvent);
} else if (dbei.eventType == EVENTTYPE_STATUSCHANGE || dbei.eventType == EVENTTYPE_JABBER_CHATSTATES ||
dbei.eventType == EVENTTYPE_JABBER_PRESENCE) {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM) hContact, (LPARAM) hDbEvent);
+ db_event_markRead(hContact, hDbEvent);
}
event->eventType = event->custom ? EVENTTYPE_MESSAGE : dbei.eventType;
event->dwFlags = (dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0);
@@ -877,7 +877,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
}
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);
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index 41ac0e86d0..88a8f458b3 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -95,17 +95,15 @@ static INT_PTR ReadMessageCommand(WPARAM wParam, LPARAM lParam)
static int MessageEventAdded(WPARAM wParam, LPARAM lParam)
{
- DBEVENTINFO dbei = {0};
- HWND hwnd;
-
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
return 0;
- hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
- if (hwnd) {
+
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
+ if (hwnd)
SendMessage(hwnd, HM_DBEVENTADDED, wParam, lParam);
- }
+
if (dbei.flags & DBEF_SENT || !DbEventIsMessageOrCustom(&dbei))
return 0;
@@ -309,10 +307,10 @@ static void RestoreUnreadMessageAlerts(void)
HANDLE hContact = db_find_first();
while (hContact) {
- HANDLE 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);
+ db_event_get(hDbEvent, &dbei);
if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && DbEventIsMessageOrCustom(&dbei)) {
int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
if (windowAlreadyExists)
@@ -332,7 +330,7 @@ static void RestoreUnreadMessageAlerts(void)
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);
}
diff --git a/plugins/SecureIM/src/dbevent.cpp b/plugins/SecureIM/src/dbevent.cpp
index 6f5f1bc80b..6e43318dad 100644
--- a/plugins/SecureIM/src/dbevent.cpp
+++ b/plugins/SecureIM/src/dbevent.cpp
@@ -1,20 +1,16 @@
#include "commonheaders.h"
-void HistoryLog(HANDLE hContact, LPCSTR szText) {
-
- DBEVENTINFO dbei;
- memset(&dbei, 0, sizeof(dbei));
-
- dbei.cbSize = sizeof(dbei);
+void HistoryLog(HANDLE hContact, LPCSTR szText)
+{
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = GetContactProto(hContact);
dbei.flags = DBEF_SENT|DBEF_READ;
dbei.timestamp = time(NULL);
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (int)strlen(szText) + 1;
dbei.pBlob = (PBYTE)szText;
-
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(0, &dbei);
}
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 7251cde058..d7498d21b6 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -269,9 +269,7 @@ int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
DB_EventAdd((WORD)EVENTTYPE_URL);
break;
case ACKTYPE_FILE:
- //MS_DB_EVENT_ADD need 4byte extra at the beginning of m_szEventMsg for ACKTYPE_FILE
m_szEventMsg = (char*) mir_realloc(m_szEventMsg, sizeof(DWORD) + m_cbEventMsg);
- //memmove_s(m_szEventMsg+sizeof(DWORD), m_cbEventMsg, m_szEventMsg, m_cbEventMsg);
memmove(m_szEventMsg+sizeof(DWORD), m_szEventMsg, m_cbEventMsg);
m_cbEventMsg += sizeof(DWORD);
DB_EventAdd((WORD)EVENTTYPE_FILE);
@@ -288,18 +286,17 @@ int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
return 0;
}
-void CSend::DB_EventAdd(WORD EventType) {
- DBEVENTINFO dbei={0};
- dbei.cbSize = sizeof(dbei);
+void CSend::DB_EventAdd(WORD EventType)
+{
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_pszProto;
dbei.eventType = EventType;
dbei.flags = DBEF_SENT;
dbei.timestamp = time(NULL);
dbei.flags |= DBEF_UTF;
dbei.cbBlob= m_cbEventMsg;
- dbei.pBlob=(PBYTE)m_szEventMsg;
-
- CallService(MS_DB_EVENT_ADD,(WPARAM)m_hContact,(LPARAM)&dbei);
+ dbei.pBlob = (PBYTE)m_szEventMsg;
+ db_event_add(m_hContact, &dbei);
}
//---------------------------------------------------------------------------
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp
index a1041d4d06..5888a54353 100644
--- a/plugins/SimpleAR/src/Main.cpp
+++ b/plugins/SimpleAR/src/Main.cpp
@@ -188,7 +188,6 @@ INT addEvent(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
HANDLE hDBEvent = (HANDLE)lParam;
- DBEVENTINFO dbei = {sizeof(dbei)};
if (!fEnabled || !hContact || !hDBEvent)
return FALSE; /// unspecifyed error
@@ -198,7 +197,8 @@ INT addEvent(WPARAM wParam, LPARAM lParam)
if (status == 40072 || status == 40077 || status == 40078)
return FALSE;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei); /// detect size of msg
+ DBEVENTINFO dbei = {sizeof(dbei)};
+ db_event_get(hDBEvent, &dbei); /// detect size of msg
if ((dbei.eventType != EVENTTYPE_MESSAGE) || (dbei.flags == DBEF_READ))
return FALSE; /// we need EVENTTYPE_MESSAGE event..
@@ -278,7 +278,7 @@ INT addEvent(WPARAM wParam, LPARAM lParam)
dbei.timestamp = time(NULL);
dbei.cbBlob = lstrlenA(pszUtf) + 1;
dbei.pBlob = (PBYTE)pszUtf;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
mir_free(ptszTemp);
mir_free(ptszTemp2);
diff --git a/plugins/SmileyAdd/src/regexp/WCPattern.cpp b/plugins/SmileyAdd/src/regexp/WCPattern.cpp
index 26a4054dfe..3ab5e35f88 100644
--- a/plugins/SmileyAdd/src/regexp/WCPattern.cpp
+++ b/plugins/SmileyAdd/src/regexp/WCPattern.cpp
@@ -153,7 +153,7 @@ bool WCPattern::quantifyCurly(int & sNum, int & eNum)
{
bool good = 1;
int i, ci = curInd + 1;
- int commaInd = ci, endInd = ci, len = pattern.size();
+ int commaInd = ci, endInd = ci, len = (int)pattern.size();
sNum = eNum = 0;
while (endInd < len && pattern[endInd ] != (wchar_t)'}') ++endInd;
@@ -325,7 +325,7 @@ bkstring WCPattern::parseClass()
if (pattern[++curInd] != (wchar_t)'[')
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else
{
@@ -340,7 +340,7 @@ bkstring WCPattern::parseClass()
if (quo)
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else if (inv || t.size() > 1) // cant be part of a range (a-z)
{
@@ -361,7 +361,7 @@ bkstring WCPattern::parseClass()
if (quo)
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else if (inv || t.size() > 1) raiseError();
else ret = classUnion(ret, classCreateRange(c1, c2));
@@ -369,7 +369,7 @@ bkstring WCPattern::parseClass()
else if (c2 == (wchar_t)'[' || c2 == (wchar_t)']' || c2 == (wchar_t)'-' || c2 == (wchar_t)'&')
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else ret = classUnion(ret, classCreateRange(c1, c2));
}
@@ -393,7 +393,7 @@ bkstring WCPattern::parseClass()
if (quo)
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else if (inv || t.size() > 1) raiseError();
else ret = classUnion(ret, classCreateRange(c1, c2));
@@ -401,7 +401,7 @@ bkstring WCPattern::parseClass()
else if (c2 == (wchar_t)'[' || c2 == (wchar_t)']' || c2 == (wchar_t)'-' || c2 == (wchar_t)'&')
{
raiseError();
- curInd = pattern.size();
+ curInd = (int)pattern.size();
}
else
{
diff --git a/plugins/StatusChange/src/main.cpp b/plugins/StatusChange/src/main.cpp
index 1b28339f68..012dabeeaa 100644
--- a/plugins/StatusChange/src/main.cpp
+++ b/plugins/StatusChange/src/main.cpp
@@ -46,13 +46,11 @@ void LoadOptions()
static int StatusChangeGetMessage(WPARAM wParam, LPARAM lParam)
{
HANDLE hDbEvent = (HANDLE)lParam;
- DBEVENTINFO dbe;
int status;
BOOL read, send, change_status;
- dbe.cbSize = sizeof(dbe);
- dbe.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe);
+ DBEVENTINFO dbe = { sizeof(dbe) };
+ db_event_get(hDbEvent, &dbe);
status = (int)CallProtoService(dbe.szModule, PS_GETSTATUS, 0, 0);
if(!status)
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp
index d5eba48f04..7de3bc5c96 100755
--- a/plugins/StopSpamMod/src/stopspam.cpp
+++ b/plugins/StopSpamMod/src/stopspam.cpp
@@ -29,34 +29,28 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
HANDLE hContact = (HANDLE)wParam;
HANDLE hDbEvent = (HANDLE)lParam;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
- if(-1 == dbei.cbBlob)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
+ if (dbei.cbBlob == -1)
return 0;
- dbei.pBlob = new BYTE[dbei.cbBlob];
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
+ dbei.pBlob = (BYTE*)alloca(dbei.cbBlob);
+ db_event_get(hDbEvent, &dbei);
// if event is in protocol that is not despammed
- if(!ProtoInList(dbei.szModule)) {
- delete dbei.pBlob;
+ if(!ProtoInList(dbei.szModule))
return 0;
- }
// event is an auth request
- if(gbHandleAuthReq)
- {
- if(!(dbei.flags & DBEF_SENT) && !(dbei.flags & DBEF_READ) && dbei.eventType == EVENTTYPE_AUTHREQUEST)
- {
+ if(gbHandleAuthReq) {
+ if(!(dbei.flags & DBEF_SENT) && !(dbei.flags & DBEF_READ) && dbei.eventType == EVENTTYPE_AUTHREQUEST) {
HANDLE hcntct = DbGetAuthEventContact(&dbei);
// if request is from unknown or not marked Answered contact
int a = db_get_b(hcntct, "CList", "NotOnList", 0);
int b = !db_get_b(hcntct, pluginName, "Answered", 0);
- if(a && b)//
- {
+ if(a && b) {
// ...send message
if(gbHideContacts)
@@ -68,26 +62,22 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
TCHAR* EventText = ReqGetText(&dbei); //else return NULL
msg=!IsUrlContains(EventText);
mir_free(EventText);
- };
- if(gbInvisDisable)
- {
+ }
+ if(gbInvisDisable) {
if(CallProtoService(dbei.szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE)
msg = 0;
else if(db_get_w(hContact,dbei.szModule,"ApparentMode",0) == ID_STATUS_OFFLINE)
msg = 0; //is it useful ?
}
- if(msg)
- {
+ if(msg) {
char * buff=mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str());
CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM) buff);
mir_free(buff);
- };
- delete dbei.pBlob;
+ }
return 1;
}
}
}
- delete dbei.pBlob;
return 0;
}
@@ -346,7 +336,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// save first message from contact
if (db_get_dw(hContact, pluginName, "QuestionCount", 0)<2){
dbei->flags |= DBEF_READ;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei);
+ db_event_add(hContact, dbei);
};
// reject processing of the event
LogSpamToFile(hContact, message);
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp
index 30bdf639b4..0ce304e59f 100755
--- a/plugins/StopSpamMod/src/utilities.cpp
+++ b/plugins/StopSpamMod/src/utilities.cpp
@@ -475,15 +475,14 @@ void CleanThread()
void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
{
- DBEVENTINFO Event = {0};
- Event.cbSize = sizeof(Event);
+ DBEVENTINFO Event = { sizeof(Event) };
Event.szModule = pluginName;
Event.eventType = event_type;
Event.flags = flags | DBEF_UTF;
Event.timestamp = (DWORD)time(NULL);
Event.cbBlob = strlen(data)+1;
Event.pBlob = (PBYTE)_strdup(data);
- CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)hContact,(LPARAM)&Event);
+ db_event_add(hContact, &Event);
}
void HistoryLogFunc(HANDLE hContact, std::string message)
diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp
index 9499793ea4..48aa3269e4 100644
--- a/plugins/StopSpamPlus/src/events.cpp
+++ b/plugins/StopSpamPlus/src/events.cpp
@@ -6,12 +6,12 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (-1 == dbei.cbBlob)
return 0;
dbei.pBlob = new BYTE[dbei.cbBlob];
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
// if event is in protocol that is not despammed
if(plSets->ProtoDisabled(dbei.szModule)) {
@@ -53,7 +53,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
DBWriteContactSettingByte(hcntct, "CList", "NotOnList", 1);
DBWriteContactSettingByte(hcntct, "CList", "Hidden", 1);
if (!plSets->HistLog.Get())
- CallService(MS_DB_EVENT_DELETE, 0, (LPARAM)hDbEvent);
+ db_event_delete(0, hDbEvent);
delete [] dbei.pBlob;
return 1;
}
@@ -182,7 +182,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// save message from contact
dbei->flags |= DBEF_READ;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei);
+ db_event_add(hContact, dbei);
// reject processing of the event
return 1;
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp
index 534fbc9a40..905a87ee89 100644
--- a/plugins/StopSpamPlus/src/services.cpp
+++ b/plugins/StopSpamPlus/src/services.cpp
@@ -3,18 +3,18 @@
INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/)
{
HANDLE hContact = ( HANDLE )wParam;
- std::string proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0 );
+ std::string proto = GetContactProto(hContact);
if ( !plSets->ProtoDisabled( proto.c_str()))
return CS_PASSED;
- if ( DBGetContactSettingByte( hContact, pluginName, answeredSetting, 0 ))
+ if ( DBGetContactSettingByte(hContact, pluginName, answeredSetting, 0))
return CS_PASSED;
- if ( !DBGetContactSettingByte( hContact, "CList", "NotOnList", 0) && DBGetContactSettingWord( hContact, proto.c_str(), "SrvGroupId", -1 ) != 1 )
+ if ( !DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingWord( hContact, proto.c_str(), "SrvGroupId", -1 ) != 1)
return CS_PASSED;
- if ( IsExistMyMessage( hContact ))
+ if ( IsExistMyMessage(hContact))
return CS_PASSED;
return CS_NOTPASSED;
diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp
index b069e6dd21..b1329ccd0c 100644
--- a/plugins/StopSpamPlus/src/utils.cpp
+++ b/plugins/StopSpamPlus/src/utils.cpp
@@ -14,20 +14,19 @@ tstring &GetDlgItemString(HWND hwnd, int id)
bool IsExistMyMessage(HANDLE hContact)
{
- DBEVENTINFO dbei = { 0 };
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_first(hContact);
while(hDbEvent){
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if (db_event_get(hDbEvent, &dbei))
+ break;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) break;
if(dbei.flags & DBEF_SENT){
// mark contact as Answered
DBWriteContactSettingByte(hContact, pluginName, answeredSetting, 1);
// ...let the event go its way
return true;
}
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
return false;
}
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))
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp
index 60f42074ad..41fb8eda43 100644
--- a/plugins/TipperYM/src/subst.cpp
+++ b/plugins/TipperYM/src/subst.cpp
@@ -121,22 +121,16 @@ void StripBBCodesInPlace(TCHAR *swzText)
DWORD LastMessageTimestamp(HANDLE hContact)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
- while (hDbEvent)
- {
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ HANDLE hDbEvent = db_event_last(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
- break;
+ return dbei.timestamp;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_prev(hDbEvent);
}
- if (hDbEvent)
- return dbei.timestamp;
-
return 0;
}
@@ -184,34 +178,25 @@ bool UidName(char *szProto, TCHAR *buff, int bufflen)
TCHAR *GetLastMessageText(HANDLE hContact)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
-
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
- while (hDbEvent)
- {
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
- break;
-
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
- }
-
- if (hDbEvent)
- {
- dbei.pBlob = (BYTE *)alloca(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
-
- if (dbei.cbBlob == 0 || dbei.pBlob == 0)
- return 0;
-
- TCHAR *buff = DbGetEventTextT( &dbei, CP_ACP );
- TCHAR *swzMsg = mir_tstrdup(buff);
- mir_free(buff);
+ HANDLE hDbEvent = db_event_last(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
+ dbei.pBlob = (BYTE *)alloca(dbei.cbBlob);
+ db_event_get(hDbEvent, &dbei);
+ if (dbei.cbBlob == 0 || dbei.pBlob == 0)
+ return 0;
+
+ TCHAR *buff = DbGetEventTextT( &dbei, CP_ACP );
+ TCHAR *swzMsg = mir_tstrdup(buff);
+ mir_free(buff);
+
+ StripBBCodesInPlace(swzMsg);
+ return swzMsg;
+ }
- StripBBCodesInPlace(swzMsg);
- return swzMsg;
+ hDbEvent = db_event_prev(hDbEvent);
}
return 0;
@@ -429,19 +414,17 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int buffle
hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, 0);
}
- for (int i = 0; i < iNumber; i++)
- {
- if (i > 0) hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, i);
+ for (int i = 0; i < iNumber; i++) {
+ if (i > 0)
+ hTmpContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, i);
dwRecountTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastCountTS", 0);
dwTime = (DWORD)time(0);
dwDiff = (dwTime - dwRecountTs);
- if (dwDiff > (60 * 60 * 24 * 3))
- {
+ if (dwDiff > (60 * 60 * 24 * 3)) {
DBWriteContactSettingDword(hTmpContact, MODULE, "LastCountTS", dwTime);
dwCountOut = dwCountIn = dwLastTs = 0;
}
- else
- {
+ else {
dwCountOut = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountOut", 0);
dwCountIn = DBGetContactSettingDword(hTmpContact, MODULE, "MsgCountIn", 0);
dwLastTs = DBGetContactSettingDword(hTmpContact, MODULE, "LastMsgTS", 0);
@@ -449,30 +432,23 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int buffle
dwNewTs = dwLastTs;
- HANDLE dbe = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hTmpContact, 0);
- while (dbe != NULL)
- {
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)dbe, (LPARAM)&dbei))
- {
- if (dbei.eventType == EVENTTYPE_MESSAGE)
- {
+ HANDLE dbe = db_event_last(hTmpContact);
+ while (dbe != NULL) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if (!db_event_get(dbe, &dbei)) {
+ if (dbei.eventType == EVENTTYPE_MESSAGE) {
dwNewTs = max(dwNewTs, dbei.timestamp);
- if (dbei.timestamp > dwLastTs)
- {
+ if (dbei.timestamp > dwLastTs) {
if (dbei.flags & DBEF_SENT) dwCountOut++;
else dwCountIn++;
}
- else
- break;
+ else break;
}
}
- dbe = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)dbe, 0);
+ dbe = db_event_prev(dbe);
}
- if (dwNewTs > dwLastTs)
- {
+ if (dwNewTs > dwLastTs) {
DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountOut", dwCountOut);
DBWriteContactSettingDword(hTmpContact, MODULE, "MsgCountIn", dwCountIn);
DBWriteContactSettingDword(hTmpContact, MODULE, "LastMsgTS", dwNewTs);
diff --git a/plugins/TipperYM/src/tipper.cpp b/plugins/TipperYM/src/tipper.cpp
index a8a7b67b82..b5b2ae04ae 100644
--- a/plugins/TipperYM/src/tipper.cpp
+++ b/plugins/TipperYM/src/tipper.cpp
@@ -110,13 +110,10 @@ int SettingChanged(WPARAM wParam, LPARAM lParam)
// needed for msg_count_xxx substitutions
int EventDeleted(WPARAM wParam, LPARAM lParam)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if (!CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei))
- {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ( !db_event_get((HANDLE)lParam, &dbei))
if (dbei.eventType == EVENTTYPE_MESSAGE)
DBDeleteContactSetting((HANDLE)wParam, MODULE, "LastCountTS");
- }
return 0;
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
index 1fe64c96bf..6ec7ac7bdd 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp
@@ -460,32 +460,25 @@ int CExImContactXML::ExportSetting(TiXmlElement *xmlModule, LPCSTR pszModule, LP
**/
BYTE CExImContactXML::ExportEvents()
{
- DBEVENTINFO dbei;
- HANDLE hDbEvent;
PBYTE pbEventBuf = NULL;
DWORD cbEventBuf = 0,
- dwNumEvents = 0,
dwNumEventsAdded = 0;
LPSTR pBase64Data = NULL;
- INT_PTR cbBase64Data = 0,
- cbNewBase64Data = 0;
- TiXmlNode *xmlModule = NULL;
- TiXmlElement *xmlEvent = NULL;
- TiXmlText *xmlText = NULL;
+ int dwNumEvents = db_event_count(_hContact);
+ if (dwNumEvents == 0)
+ return FALSE;
- dwNumEvents = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)_hContact, NULL);
- if(dwNumEvents == 0) return FALSE;
+ INT_PTR cbBase64Data = 0;
- try {
- ZeroMemory(&dbei, sizeof(DBEVENTINFO));
- dbei.cbSize = sizeof(DBEVENTINFO);
+ DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
+ try {
// read out all events for the current contact
- for (hDbEvent = DB::Event::FindFirst(_hContact); hDbEvent != NULL; hDbEvent = DB::Event::FindNext(hDbEvent)) {
+ for (HANDLE hDbEvent = db_event_first(_hContact); hDbEvent != NULL; hDbEvent = db_event_next(hDbEvent)) {
if (!DB::Event::GetInfoWithData(hDbEvent, &dbei)) {
// new buffer for base64 encoded data
- cbNewBase64Data = Base64EncodeGetRequiredLength(dbei.cbBlob, BASE64_FLAG_NOCRLF);
+ INT_PTR cbNewBase64Data = Base64EncodeGetRequiredLength(dbei.cbBlob, BASE64_FLAG_NOCRLF);
if (cbNewBase64Data > cbBase64Data) {
pBase64Data = (LPSTR)mir_realloc(pBase64Data, cbNewBase64Data + 5);
if (pBase64Data == NULL) {
@@ -498,16 +491,17 @@ BYTE CExImContactXML::ExportEvents()
// encode data
if (Base64Encode(dbei.pBlob, dbei.cbBlob, pBase64Data, &cbNewBase64Data, BASE64_FLAG_NOCRLF)) {
pBase64Data[cbNewBase64Data] = 0;
- xmlEvent = new TiXmlElement("evt");
+ TiXmlElement *xmlEvent = new TiXmlElement("evt");
if (xmlEvent) {
xmlEvent->SetAttribute("type", dbei.eventType);
xmlEvent->SetAttribute("time", dbei.timestamp);
xmlEvent->SetAttribute("flag", dbei.flags);
- xmlText = new TiXmlText(pBase64Data);
+ TiXmlText *xmlText = new TiXmlText(pBase64Data);
xmlEvent->LinkEndChild(xmlText);
// find module
+ TiXmlNode *xmlModule;
for (xmlModule = _xmlNode->FirstChild(); xmlModule != NULL; xmlModule = xmlModule->NextSibling())
if (!mir_stricmp(((TiXmlElement*)xmlModule)->Attribute("key"), dbei.szModule))
break;
@@ -515,13 +509,13 @@ BYTE CExImContactXML::ExportEvents()
// create new module
if (!xmlModule) {
xmlModule = _xmlNode->InsertEndChild(TiXmlElement(XKEY_MOD));
- if (!xmlModule) break;
+ if (!xmlModule)
+ break;
((TiXmlElement*)xmlModule)->SetAttribute("key", dbei.szModule);
}
xmlModule->LinkEndChild(xmlEvent);
dwNumEventsAdded++;
- xmlEvent = NULL; // avoid final deleting
}
}
MIR_FREE(dbei.pBlob);
@@ -536,7 +530,6 @@ BYTE CExImContactXML::ExportEvents()
mir_free(pbEventBuf);
mir_free(pBase64Data);
- if (xmlEvent) delete xmlEvent;
return dwNumEventsAdded == dwNumEvents;
}
@@ -1057,16 +1050,9 @@ int CExImContactXML::ImportSetting(LPCSTR pszModule, TiXmlElement *xmlEntry)
**/
int CExImContactXML::ImportEvent(LPCSTR pszModule, TiXmlElement *xmlEvent)
{
- DBEVENTINFO dbei;
- TiXmlText *xmlValue;
- LPCSTR tmp;
- size_t cbSrc;
- INT_PTR baselen;
-
// dont import events from metacontact
- if (isMeta()) {
+ if (isMeta())
return ERROR_DUPLICATED;
- }
if (!xmlEvent || !pszModule || !*pszModule)
return ERROR_INVALID_PARAMS;
@@ -1075,48 +1061,42 @@ int CExImContactXML::ImportEvent(LPCSTR pszModule, TiXmlElement *xmlEvent)
return ERROR_NOT_ADDED;
// timestamp must be valid
+ DBEVENTINFO dbei = { sizeof(dbei) };
xmlEvent->Attribute("time", (LPINT)&dbei.timestamp);
- if (dbei.timestamp == 0) return ERROR_INVALID_TIMESTAMP;
+ if (dbei.timestamp == 0)
+ return ERROR_INVALID_TIMESTAMP;
- xmlValue = (TiXmlText*)xmlEvent->FirstChild();
+ TiXmlText *xmlValue = (TiXmlText*)xmlEvent->FirstChild();
if (!xmlValue || xmlValue->Type() != TiXmlText::TEXT)
return ERROR_INVALID_VALUE;
- tmp = xmlValue->Value();
+
+ LPCSTR tmp = xmlValue->Value();
if (!tmp || tmp[0] == 0)
return ERROR_INVALID_VALUE;
- cbSrc = strlen(tmp);
- baselen = Base64DecodeGetRequiredLength(cbSrc);
- dbei.cbBlob = NULL;
- dbei.pBlob = NULL;
- dbei.pBlob = (PBYTE)mir_alloc(baselen + 1);
- if (dbei.pBlob != NULL) {
- if (Base64Decode(tmp, cbSrc, dbei.pBlob, &baselen)) {
- INT_PTR hEvent;
-
- // event owning module
- dbei.cbSize = sizeof(dbei);
- dbei.szModule = (LPSTR)pszModule;
- dbei.cbBlob = baselen;
-
- xmlEvent->Attribute("type", (LPINT)&dbei.eventType);
- xmlEvent->Attribute("flag", (LPINT)&dbei.flags);
- if (dbei.flags == 0) dbei.flags = DBEF_READ;
-
- // search in new and existing contact for existing event to avoid duplicates
- if (/*!_isNewContact && */DB::Event::Exists(_hContact, _hEvent, &dbei)) {
- mir_free(dbei.pBlob);
- return ERROR_DUPLICATED;
- }
+ size_t cbSrc = strlen(tmp);
+ INT_PTR baselen = Base64DecodeGetRequiredLength(cbSrc);
- hEvent = CallService(MS_DB_EVENT_ADD, (WPARAM)_hContact, (LPARAM)&dbei);
+ dbei.pBlob = (PBYTE)_alloca(baselen+1);
+ if (Base64Decode(tmp, cbSrc, dbei.pBlob, &baselen)) {
+ // event owning module
+ dbei.szModule = (LPSTR)pszModule;
+ dbei.cbBlob = baselen;
+
+ xmlEvent->Attribute("type", (LPINT)&dbei.eventType);
+ xmlEvent->Attribute("flag", (LPINT)&dbei.flags);
+ if (dbei.flags == 0)
+ dbei.flags = DBEF_READ;
+
+ // search in new and existing contact for existing event to avoid duplicates
+ if (/*!_isNewContact && */DB::Event::Exists(_hContact, _hEvent, &dbei)) {
mir_free(dbei.pBlob);
- if (hEvent) {
- _hEvent = (HANDLE)hEvent;
- return ERROR_OK;
- }
+ return ERROR_DUPLICATED;
}
- mir_free(dbei.pBlob);
+
+ if ((_hEvent = db_event_add(_hContact, &dbei)) != 0)
+ return ERROR_OK;
}
+
return ERROR_NOT_ADDED;
}
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp
index ed1501abed..9f9d3b8ed6 100644
--- a/plugins/UserInfoEx/src/mir_db.cpp
+++ b/plugins/UserInfoEx/src/mir_db.cpp
@@ -181,7 +181,7 @@ DWORD WhenAdded(DWORD dwUIN, LPCSTR pszProto)
ZeroMemory(&dbei, sizeof(dbei));
dbei.cbSize = sizeof(dbei);
- for (edbe = DB::Event::FindFirst(NULL); edbe != NULL; edbe = DB::Event::FindNext(edbe)) {
+ for (edbe = db_event_first(NULL); edbe != NULL; edbe = db_event_next(edbe)) {
// get eventtype and compare
if (!DB::Event::GetInfo(edbe, &dbei) && dbei.eventType == EVENTTYPE_ADDED) {
if (!DB::Event::GetInfoWithData(edbe, &dbei)) {
@@ -1010,52 +1010,8 @@ BYTE dbv2String(DBVARIANT* dbv, const BYTE destType)
namespace Event {
/**
- * This function searches for the first event for the given contact.
- * @param hContact - the handle of the contact to search events for
- *
- * @return This function returns the HANDLE of the first event for the given contact.
- **/
-HANDLE FindFirst(HANDLE hContact)
-{
- return (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
-}
-
-/**
- * This function searches for the last event for the given contact.
- * @param hContact - the handle of the contact to search events for
- *
- * @return This function returns the HANDLE of the last event for the given contact.
- **/
-HANDLE FindLast(HANDLE hContact)
-{
- return (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
-}
-
-/**
- * This function searches for the next event in the chain, which follows the given event.
- * @param hEvent - the handle of the event where to continue searching
- *
- * @return This function returns the HANDLE of the next event in the event chain.
- **/
-HANDLE FindNext(HANDLE hEvent)
-{
- return (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hEvent, 0);
-}
-
-/**
- * This function searches for the previous event in the chain, which follows the given event.
- * @param hEvent - the handle of the event where to continue searching
- *
- * @return This function returns the HANDLE of the previous event in the event chain.
- **/
-HANDLE FindPrev(HANDLE hEvent)
-{
- return (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0);
-}
-
-/**
* This function initializes the DBEVENTINFO structure and calls
- * the MS_DB_EVENT_GET service to retrieve information about an event.
+ * db_event_get() to retrieve information about an event.
* @param hEvent - the handle of the event to get information for
* @param dbei - the pointer to a DBEVENTINFO structure, which retrieves all information.
*
@@ -1067,12 +1023,12 @@ BYTE GetInfo(HANDLE hEvent, DBEVENTINFO *dbei)
dbei->cbSize = sizeof(DBEVENTINFO);
dbei->cbBlob = 0;
dbei->pBlob = NULL;
- return CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)dbei) != 0;
+ return db_event_get(hEvent, dbei) != 0;
}
/**
* This function initializes the DBEVENTINFO structure and calls
- * the MS_DB_EVENT_GET service to retrieve information about an event.
+ * db_event_get() to retrieve information about an event.
* @param hEvent - the handle of the event to get information for
* @param dbei - the pointer to a DBEVENTINFO structure, which retrieves all information.
*
@@ -1081,7 +1037,6 @@ BYTE GetInfo(HANDLE hEvent, DBEVENTINFO *dbei)
**/
BYTE GetInfoWithData(HANDLE hEvent, DBEVENTINFO *dbei)
{
- BYTE result;
dbei->cbSize = sizeof(DBEVENTINFO);
if (!dbei->cbBlob) {
INT_PTR size = BlobSizeOf(hEvent);
@@ -1093,11 +1048,9 @@ BYTE GetInfoWithData(HANDLE hEvent, DBEVENTINFO *dbei)
dbei->cbBlob = 0;
}
}
- else {
- dbei->pBlob = NULL;
- }
+ else dbei->pBlob = NULL;
- result = CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)dbei) != 0;
+ BYTE result = db_event_get(hEvent, dbei) != 0;
if (result && dbei->pBlob) {
mir_free(dbei->pBlob);
dbei->pBlob = NULL;
@@ -1131,7 +1084,7 @@ DWORD TimeOf(HANDLE hEvent)
**/
INT_PTR BlobSizeOf(HANDLE hEvent)
{
- return CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
+ return db_event_getBlobSize(hEvent);
}
/**
@@ -1182,7 +1135,7 @@ BYTE Exists(HANDLE hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei)
edbe;
if (!hDbExistingEvent) {
- hDbExistingEvent = FindFirst(hContact);
+ hDbExistingEvent = db_event_first(hContact);
if (hDbExistingEvent) {
if (!GetInfo(hDbExistingEvent, &edbei)) {
if ((dbei->timestamp < edbei.timestamp)) {
@@ -1198,10 +1151,10 @@ BYTE Exists(HANDLE hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei)
}
}
}
- edbe = FindLast(hContact);
- if (edbe == hDbExistingEvent) {
+ edbe = db_event_last(hContact);
+ if (edbe == hDbExistingEvent)
return FALSE;
- }
+
hDbExistingEvent = edbe;
}
}
@@ -1209,7 +1162,7 @@ BYTE Exists(HANDLE hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei)
sdbe = hDbExistingEvent;
for ( edbe = sdbe;
edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp <= edbei.timestamp);
- edbe = FindPrev(edbe)) {
+ edbe = db_event_prev(edbe)) {
hDbExistingEvent = edbe;
//compare without data (faster)
if ( result = IsEqual(dbei, &edbei, false)) {
@@ -1224,9 +1177,9 @@ BYTE Exists(HANDLE hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei)
} /*end for*/
if (!result) {
- for ( edbe = FindNext(sdbe);
+ for ( edbe = db_event_next(sdbe);
edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp >= edbei.timestamp);
- edbe = FindNext(edbe)) {
+ edbe = db_event_next(edbe)) {
hDbExistingEvent = edbe;
//compare without data (faster)
if ( result = IsEqual(dbei, &edbei, false)) {
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h
index c2383fc590..5bc5504374 100644
--- a/plugins/UserInfoEx/src/mir_db.h
+++ b/plugins/UserInfoEx/src/mir_db.h
@@ -182,11 +182,7 @@ namespace Variant {
} /* namespace Variant */
namespace Event {
-
- HANDLE FindFirst (HANDLE hContact);
HANDLE FindLast (HANDLE hContact);
- HANDLE FindNext (HANDLE hEvent);
- HANDLE FindPrev (HANDLE hEvent);
BYTE GetInfo (HANDLE hEvent, DBEVENTINFO *dbei);
BYTE GetInfoWithData(HANDLE hEvent, DBEVENTINFO *dbei);
DWORD GetTime (HANDLE hEvent);
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp
index 7216811be9..3a28fcde05 100644
--- a/plugins/Variables/src/parse_miranda.cpp
+++ b/plugins/Variables/src/parse_miranda.cpp
@@ -532,18 +532,18 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
dbe.pBlob = NULL;
if (hContact != NULL) {
if ((flags & DBE_FIRST) && (flags & DBE_UNREAD)) {
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0);
+ hDbEvent = db_event_firstUnread(hContact);
if (hDbEvent == NULL && (flags & DBE_READ))
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ hDbEvent = db_event_first(hContact);
}
else if (flags & DBE_FIRST)
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ hDbEvent = db_event_first(hContact);
else if (flags & DBE_LAST)
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ hDbEvent = db_event_last(hContact);
else if (flags & DBE_NEXT)
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
else if (flags & DBE_PREV)
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_prev(hDbEvent);
}
else {
HANDLE hMatchEvent, hSearchEvent, hSearchContact;
@@ -556,7 +556,7 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
do {
hSearchEvent = findDbEvent(hSearchContact, NULL, flags);
dbe.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hSearchEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hSearchEvent, &dbe)) {
if ((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) {
hMatchEvent = hSearchEvent;
matchTimestamp = dbe.timestamp;
@@ -571,7 +571,7 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
do {
hSearchEvent = findDbEvent(hSearchContact, NULL, flags);
dbe.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hSearchEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hSearchEvent, &dbe)) {
if ((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) {
hMatchEvent = hSearchEvent;
matchTimestamp = dbe.timestamp;
@@ -583,13 +583,13 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
}
else if (flags&DBE_NEXT) {
dbe.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hDbEvent, &dbe)) {
priorTimestamp = dbe.timestamp;
hSearchContact = db_find_first();
do {
hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags);
dbe.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hSearchEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hSearchEvent, &dbe)) {
if (((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp > priorTimestamp)) {
hMatchEvent = hSearchEvent;
matchTimestamp = dbe.timestamp;
@@ -601,13 +601,13 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
}
}
else if (flags&DBE_PREV) {
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hDbEvent, &dbe)) {
priorTimestamp = dbe.timestamp;
hSearchContact = db_find_first();
do {
hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags);
dbe.cbBlob = 0;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hSearchEvent, (LPARAM)&dbe)) {
+ if (!db_event_get(hSearchEvent, &dbe)) {
if (((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp < priorTimestamp)) {
hMatchEvent = hSearchEvent;
matchTimestamp = dbe.timestamp;
@@ -620,7 +620,7 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags)
}
}
dbe.cbBlob = 0;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe))
+ if (db_event_get(hDbEvent, &dbe))
bEventOk = FALSE;
else
bEventOk = isValidDbEvent(&dbe, flags);
@@ -698,9 +698,9 @@ static TCHAR *parseDbEvent(ARGUMENTSINFO *ai)
DBEVENTINFO dbe = { 0 };
dbe.cbSize = sizeof(DBEVENTINFO);
- dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ dbe.cbBlob = db_event_getBlobSize(hDbEvent);
dbe.pBlob = (PBYTE)mir_calloc(dbe.cbBlob);
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe)) {
+ if (db_event_get(hDbEvent, &dbe)) {
mir_free(dbe.pBlob);
return NULL;
}
diff --git a/plugins/Variables/src/parse_str.cpp b/plugins/Variables/src/parse_str.cpp
index 37b8c4af4b..3061ae7bf6 100644
--- a/plugins/Variables/src/parse_str.cpp
+++ b/plugins/Variables/src/parse_str.cpp
@@ -633,15 +633,14 @@ static TCHAR *parseSubstr(ARGUMENTSINFO *ai) {
return NULL;
}
from = max(ttoi(ai->targv[2])-1, 0);
- if (ai->argc > 3) {
- to = min(ttoi(ai->targv[3]), (signed int)_tcslen(ai->targv[1]));
- }
- else {
- to = _tcslen(ai->targv[1]);
- }
- if (to < from) {
+ if (ai->argc > 3)
+ to = min(ttoi(ai->targv[3]), (int)_tcslen(ai->targv[1]));
+ else
+ to = (int)_tcslen(ai->targv[1]);
+
+ if (to < from)
return NULL;
- }
+
res = (TCHAR*)mir_alloc((to-from+1)*sizeof(TCHAR));
ZeroMemory(res, (to-from+1)*sizeof(TCHAR));
_tcsncpy(res, ai->targv[1]+from, to-from);
diff --git a/plugins/Variables/src/parse_xml.cpp b/plugins/Variables/src/parse_xml.cpp
index 98c622622b..9407aa7ee9 100644
--- a/plugins/Variables/src/parse_xml.cpp
+++ b/plugins/Variables/src/parse_xml.cpp
@@ -52,7 +52,7 @@ static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
log_debugA("calling xsltParseMemory");
- xmlDocPtr sdoc = pXmlParseMemory(szStyleSheet, strlen(szStyleSheet));
+ xmlDocPtr sdoc = pXmlParseMemory(szStyleSheet, (int)strlen(szStyleSheet));
if (sdoc == NULL) {
return NULL;
}
@@ -67,7 +67,7 @@ static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
}
log_debugA("calling xsltParseMemory");
- xmlDocPtr doc = pXmlParseMemory(szDoc, strlen(szDoc));
+ xmlDocPtr doc = pXmlParseMemory(szDoc, (int)strlen(szDoc));
if (doc == NULL) {
log_debugA("calling xsltFreeDoc");
pXmlFreeDoc(sdoc);
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp
index 465abe5d74..da46dc8709 100644
--- a/plugins/Weather/src/weather_update.cpp
+++ b/plugins/Weather/src/weather_update.cpp
@@ -181,19 +181,17 @@ int UpdateWeather(HANDLE hContact)
} } }
if (db_get_b(hContact, WEATHERPROTONAME, "History", 0)) {
- DBEVENTINFO dbei = {0};
// internal log using history
GetDisplay(&winfo, opt.hText, str2);
- dbei.cbSize = sizeof(dbei);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = WEATHERPROTONAME;
dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_READ|DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.pBlob = (PBYTE)mir_utf8encodeT(str2);
dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob)+1;
-
- // add the history event
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
// show the popup