summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--protocols/AimOscar/src/server.cpp5
-rw-r--r--protocols/EmLanProto/src/mlan.cpp40
-rw-r--r--protocols/FacebookRM/src/process.cpp2
-rw-r--r--protocols/FacebookRM/src/proto.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp5
-rw-r--r--protocols/IRCG/src/clist.cpp6
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp7
-rw-r--r--protocols/IRCG/src/services.cpp2
-rw-r--r--protocols/IRCG/src/userinfo.cpp8
-rw-r--r--protocols/IcqOscarJ/src/icq_db.cpp7
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp7
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp2
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp30
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp7
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp30
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp22
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp14
-rw-r--r--protocols/MRA/src/MraAntiSpam.cpp11
-rw-r--r--protocols/MRA/src/MraProto.cpp23
-rw-r--r--protocols/MRA/src/Mra_proto.cpp14
-rw-r--r--protocols/MSN/src/msn_commands.cpp2
-rw-r--r--protocols/MSN/src/msn_lists.cpp38
-rw-r--r--protocols/MSN/src/msn_proto.cpp23
-rw-r--r--protocols/Tlen/src/jabber_misc.cpp6
-rw-r--r--protocols/Tlen/src/jabber_svc.cpp60
-rw-r--r--protocols/Tlen/src/jabber_thread.cpp7
-rw-r--r--protocols/Twitter/src/connection.cpp4
-rw-r--r--protocols/Xfire/src/main.cpp44
-rw-r--r--protocols/Yahoo/src/im.cpp4
-rw-r--r--protocols/Yahoo/src/proto.cpp22
-rw-r--r--src/core/stdauth/auth.cpp9
-rw-r--r--src/core/stdauth/authdialogs.cpp27
-rw-r--r--src/core/stdchat/src/clist.cpp2
-rw-r--r--src/core/stdfile/file.cpp25
-rw-r--r--src/core/stdfile/filerecvdlg.cpp9
-rw-r--r--src/core/stdfile/filexferdlg.cpp2
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp138
-rw-r--r--src/core/stdmsg/src/msglog.cpp61
-rw-r--r--src/core/stdmsg/src/msgs.cpp63
-rw-r--r--src/core/stdmsg/src/msgtimedout.cpp15
-rw-r--r--src/core/stduihist/history.cpp78
-rw-r--r--src/core/stdurl/url.cpp45
-rw-r--r--src/core/stdurl/urldialogs.cpp164
-rw-r--r--src/modules/addcontact/addcontact.cpp22
-rw-r--r--src/modules/protocols/protocols.cpp4
133 files changed, 1456 insertions, 2180 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
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp
index 571878833d..a56fbbaab3 100644
--- a/protocols/AimOscar/src/server.cpp
+++ b/protocols/AimOscar/src/server.cpp
@@ -1349,15 +1349,14 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho
mir_snprintf(buf, len, "%s %s", away, s_msg);
mir_free(away);
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (int)len;
dbei.pBlob = (PBYTE)buf;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
aim_send_message(hServerConn, seqno, sn, s_msg, true, getBool(hContact, AIM_KEY_BLS, false));
mir_free(s_msg);
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp
index cd9ea200e0..09627c327f 100644
--- a/protocols/EmLanProto/src/mlan.cpp
+++ b/protocols/EmLanProto/src/mlan.cpp
@@ -127,18 +127,14 @@ void CMLan::SetMirandaStatus(u_int status)
void CMLan::SetAllOffline()
{
- HANDLE hContact =(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- while(hContact!=NULL)
- {
- char* svc = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (svc!=NULL && lstrcmp(PROTONAME,svc)==0)
- {
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL) {
+ char *svc = GetContactProto(hContact);
+ if (svc != NULL && lstrcmp(PROTONAME,svc) == 0) {
DBWriteContactSettingWord(hContact,PROTONAME,"Status",ID_STATUS_OFFLINE);
- //Delet all temp contact settings
DBDeleteContactSetting(hContact, PROTONAME, "IP");
- //DBDeleteContactSetting(hContact, PROTONAME, "UID");
}
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ hContact = db_find_next(hContact);
}
DeleteCache();
}
@@ -247,15 +243,12 @@ void CMLan::SendPacketExt(TPacket& pak, u_long addr)
HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, bool make_permanent, bool make_visible, u_int status)
{
- HANDLE res=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- while(res!=NULL)
- {
- char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)res,0);
- if (szProto!=NULL && !lstrcmp(PROTONAME,szProto))
- {
+ HANDLE res = db_find_first();
+ while (res != NULL) {
+ char *szProto = GetContactProto(res);
+ if (szProto!=NULL && !lstrcmp(PROTONAME, szProto)) {
u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1);
- if (caddr==addr.S_un.S_addr)
- {
+ if (caddr==addr.S_un.S_addr) {
if (make_permanent)
DBDeleteContactSetting(res,"CList","NotOnList");
if (make_visible)
@@ -263,11 +256,10 @@ HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, boo
return res;
}
}
- res=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)res,0);
+ res = db_find_next(res);
}
- if (add_to_list)
- {
+ if (add_to_list) {
res=(HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)res,(LPARAM)PROTONAME);
DBWriteContactSettingDword(res,PROTONAME, "ipaddr", addr.S_un.S_addr);
@@ -467,7 +459,7 @@ void CMLan::RecvMessageUrl(CCSDATA* ccs)
DBDeleteContactSetting(ccs->hContact,"CList","Hidden");
- CallService(MS_DB_EVENT_ADD,(WPARAM)ccs->hContact,(LPARAM)&dbei);
+ db_event_add(ccs->hContact, &dbei);
}
int CMLan::AddToContactList(u_int flags, EMPSEARCHRESULT* psr)
@@ -1125,7 +1117,6 @@ void CMLan::FileRemoveFromList(TFileConnection* conn)
void CMLan::RecvFile(CCSDATA* ccs)
{
- DBEVENTINFO dbei;
PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam;
char *szDesc, *szFile;
@@ -1134,15 +1125,14 @@ void CMLan::RecvFile(CCSDATA* ccs)
szFile = pre->szMessage + sizeof(DWORD);
szDesc = szFile + strlen(szFile) + 1;
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = PROTONAME;
dbei.timestamp = pre->timestamp;
dbei.flags = pre->flags & (PREF_CREATEREAD ? DBEF_READ : 0);
dbei.eventType = EVENTTYPE_FILE;
dbei.cbBlob = DWORD(sizeof(DWORD) + strlen(szFile) + strlen(szDesc) + 2);
dbei.pBlob = (PBYTE)pre->szMessage;
- CallService(MS_DB_EVENT_ADD, (WPARAM)ccs->hContact, (LPARAM)&dbei);
+ db_event_add(ccs->hContact, &dbei);
}
void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock)
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index f7e99ddaf7..a89862a2f4 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -628,7 +628,7 @@ void FacebookProto::ProcessFriendRequests( void* )
*pCurBlob = '\0'; pCurBlob++; // E-mail
*pCurBlob = '\0'; // Reason
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(0, &dbei);
LOG(" (New) Friendship request from: %s (%s) [%s]", fbu->real_name.c_str(), fbu->user_id.c_str(), time.c_str());
} else {
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 8024127dbc..5b88516ffe 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -581,7 +581,7 @@ HANDLE FacebookProto::HContactFromAuthEvent(HANDLE hEvent)
dbei.cbBlob = sizeof(DWORD)*2;
dbei.pBlob = (PBYTE)&body;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
+ if (db_event_get(hEvent, &dbei))
return INVALID_HANDLE_VALUE;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index dd73329a0a..7fb2b52aea 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -941,15 +941,14 @@ retry:
else if (!e->event.multilogon_msg.recipients_count && e->event.multilogon_msg.message && *e->event.multilogon_msg.message
&& strcmp(e->event.multilogon_msg.message, "\xA0\0"))
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)e->event.multilogon_msg.time;
dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (DWORD)strlen(e->event.multilogon_msg.message) + 1;
dbei.pBlob = (PBYTE)e->event.multilogon_msg.message;
- CallService(MS_DB_EVENT_ADD, (WPARAM)getcontact(e->event.multilogon_msg.sender, 1, 0, NULL), (LPARAM)&dbei);
+ db_event_add( getcontact(e->event.multilogon_msg.sender, 1, 0, NULL), &dbei);
}
break;
diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp
index 4d189ce3bb..e2b0454a35 100644
--- a/protocols/IRCG/src/clist.cpp
+++ b/protocols/IRCG/src/clist.cpp
@@ -146,8 +146,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
HANDLE hContact = db_find_first();
while ( hContact ) {
- char* szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0 );
- if ( szProto != NULL && !lstrcmpiA( szProto, m_szModuleName )) {
+ char* szProto = GetContactProto(hContact);
+ if (szProto != NULL && !lstrcmpiA( szProto, m_szModuleName)) {
if ( getByte( hContact, "ChatRoom", 0 ) == 0 ) {
if ( getByte(hContact, "DCC", 0 ) != 0 ) {
if ( ChatsToo )
@@ -184,7 +184,7 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user)
DBVARIANT dbv5;
HANDLE hContact = db_find_first();
while (hContact) {
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, m_szModuleName )) {
if ( getByte( hContact, "ChatRoom", 0) == 0) {
HANDLE hContact_temp = NULL;
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index 83bbd9689e..3108066951 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -143,7 +143,7 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
HANDLE hContact = db_find_first();
while ( hContact ) {
- szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, ppro->m_szModuleName )) {
BYTE bRoom = ppro->getByte(hContact, "ChatRoom", 0);
if ( bRoom == 0 ) {
@@ -223,15 +223,14 @@ int CIrcProto::AddOutgoingMessageToDB(HANDLE hContact, TCHAR* msg)
CMString S = DoColorCodes( msg, TRUE, FALSE );
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_SENT + DBEF_UTF;
dbei.pBlob = ( PBYTE )mir_utf8encodeW( S.c_str());
dbei.cbBlob = (DWORD)strlen(( char* )dbei.pBlob) + 1;
- CallService( MS_DB_EVENT_ADD, (WPARAM) hContact, (LPARAM) & dbei);
+ db_event_add(hContact, &dbei);
mir_free( dbei.pBlob );
return 1;
}
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 54dbfd2ea2..b65c92f728 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -1013,7 +1013,7 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
- char *szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) wParam, 0);
+ char *szProto = GetContactProto(hContact);
if ( szProto && !lstrcmpiA(szProto, m_szModuleName)) {
bool bIsOnline = getWord(hContact, "Status", ID_STATUS_OFFLINE)== ID_STATUS_OFFLINE ? false : true;
if ( getByte(hContact, "ChatRoom", 0) == GCW_CHATROOM) {
diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp
index 9a5793c979..35a23f3ca1 100644
--- a/protocols/IRCG/src/userinfo.cpp
+++ b/protocols/IRCG/src/userinfo.cpp
@@ -188,15 +188,15 @@ INT_PTR CALLBACK UserDetailsDlgProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam)
{
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, lParam, 0);
- HANDLE hContact = (HANDLE) lParam;
+ HANDLE hContact = (HANDLE)lParam;
+ char *szProto = GetContactProto(hContact);
if ( !hContact || !szProto || lstrcmpiA( szProto, m_szModuleName ))
return 0;
- if ( getByte( hContact, "ChatRoom", 0 ) != 0 )
+ if ( getByte( hContact, "ChatRoom", 0) != 0 )
return 0;
- if ( getByte( hContact, "DCC", 0 ) != 0 )
+ if ( getByte( hContact, "DCC", 0) != 0)
return 0;
DBVARIANT dbv;
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp
index ebb0f08ac1..ed45b307db 100644
--- a/protocols/IcqOscarJ/src/icq_db.cpp
+++ b/protocols/IcqOscarJ/src/icq_db.cpp
@@ -292,17 +292,14 @@ int CIcqProto::IsICQContact(HANDLE hContact)
HANDLE CIcqProto::AddEvent(HANDLE hContact, WORD wType, DWORD dwTime, DWORD flags, DWORD cbBlob, PBYTE pBlob)
{
- DBEVENTINFO dbei = {0};
-
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = dwTime;
dbei.flags = flags;
dbei.eventType = wType;
dbei.cbBlob = cbBlob;
dbei.pBlob = pBlob;
-
- return (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ return db_event_add(hContact, &dbei);
}
HANDLE CIcqProto::FindFirstContact()
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index 73ecda2a7c..690e5011dc 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -372,15 +372,14 @@ HANDLE __cdecl CIcqProto::AddToListByEvent( int flags, int iContact, HANDLE hDbE
DWORD uin = 0;
uid_str uid = {0};
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == -1)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
return 0;
dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob + 1);
dbei.pBlob[dbei.cbBlob] = '\0';
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
+ if ( db_event_get(hDbEvent, &dbei))
return 0; // failed to get event
if (strcmpnull(dbei.szModule, m_szModuleName))
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index 53cf92c3f8..633e798259 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -599,7 +599,7 @@ HANDLE CIcqProto::HContactFromAuthEvent(HANDLE hEvent)
dbei.cbBlob = sizeof(DWORD)*2;
dbei.pBlob = (PBYTE)&body;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
+ if (db_event_get(hEvent, &dbei))
return INVALID_HANDLE_VALUE;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index 74aaa227b8..5cfb124a34 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -107,15 +107,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
@@ -133,12 +131,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
@@ -156,7 +154,7 @@ 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) &&
@@ -165,11 +163,11 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO& dbei)
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
@@ -179,7 +177,7 @@ BOOL IsDuplicateEvent(HANDLE hContact, DBEVENTINFO& dbei)
}
hPreviousDbEvent = hExistingDbEvent;
- hExistingDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hExistingDbEvent, 0);
+ hExistingDbEvent = db_event_next(hExistingDbEvent);
}
}
@@ -190,7 +188,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
@@ -212,7 +210,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 {
@@ -220,7 +218,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
@@ -242,7 +240,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
@@ -304,6 +302,6 @@ void CJabberProto::OnIqResultGetCollection(HXML iqNode)
dbei.pBlob = (PBYTE)(char*)szEventText;
dbei.timestamp = tmStart + _ttol(tszSecs) - timezone;
if ( !IsDuplicateEvent(hContact, dbei))
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 0d8167fa89..da614d2e33 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -142,7 +142,7 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
strcpy((char*)pCurBlob, szJid); pCurBlob += strlen(szJid)+1;
*pCurBlob = '\0'; //reason
- CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)NULL, (LPARAM)&dbei);
+ db_event_add(NULL, &dbei);
Log("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
mir_free(szJid);
@@ -227,15 +227,14 @@ BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType)
break;
}
- DBEVENTINFO dbei;
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.pBlob = &btEventType;
dbei.cbBlob = sizeof(btEventType);
dbei.eventType = JABBER_DB_EVENT_TYPE_PRESENCE;
dbei.flags = DBEF_READ;
dbei.timestamp = time(NULL);
dbei.szModule = m_szModuleName;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 684d784dbe..19a4745d34 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -414,18 +414,14 @@ HANDLE CJabberProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
HANDLE __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, HANDLE hDbEvent)
{
- DBEVENTINFO dbei;
- HANDLE hContact;
- char* nick, *firstName, *lastName, *jid;
-
Log("AddToListByEvent");
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return NULL;
if ((dbei.pBlob=(PBYTE)alloca(dbei.cbBlob)) == NULL)
return NULL;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
+ if (db_event_get(hDbEvent, &dbei))
return NULL;
if (strcmp(dbei.szModule, m_szModuleName))
return NULL;
@@ -440,13 +436,13 @@ HANDLE __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, HANDL
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return NULL;
- nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
- firstName = nick + strlen(nick) + 1;
- lastName = firstName + strlen(firstName) + 1;
- jid = lastName + strlen(lastName) + 1;
+ char *nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
TCHAR *newJid = (dbei.flags & DBEF_UTF) ? mir_utf8decodeT(jid) : mir_a2t(jid);
- hContact = (HANDLE)AddToListByJID(newJid, flags);
+ HANDLE hContact = (HANDLE)AddToListByJID(newJid, flags);
mir_free(newJid);
return hContact;
}
@@ -460,11 +456,11 @@ int CJabberProto::Authorize(HANDLE hDbEvent)
return 1;
DBEVENTINFO dbei = { sizeof(dbei) };
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return 1;
if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == NULL)
return 1;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
+ if (db_event_get(hDbEvent, &dbei))
return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return 1;
@@ -510,11 +506,11 @@ int CJabberProto::AuthDeny(HANDLE hDbEvent, const TCHAR*)
Log("Entering AuthDeny");
DBEVENTINFO dbei = { sizeof(dbei) };
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return 1;
if ((dbei.pBlob=(PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
return 1;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) {
+ if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
return 1;
}
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 6a49f9e718..23800fc307 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -483,14 +483,13 @@ int CJabberProto::RcGetUnreadEventsCount()
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
if ( !JGetStringT(hContact, "jid", &dbv)) {
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
- 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 != -1) {
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ int nGetTextResult = db_event_get(hDbEvent, &dbei);
if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
if (szEventText) {
@@ -500,7 +499,7 @@ int CJabberProto::RcGetUnreadEventsCount()
}
mir_free(dbei.pBlob);
}
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
db_free(&dbv);
}
@@ -580,15 +579,14 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
if ( !JGetStringT(hContact, "jid", &dbv)) {
-
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob != -1) {
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ int nGetTextResult = db_event_get(hDbEvent, &dbei);
if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
if (szEventText) {
@@ -619,7 +617,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
nEventsSent++;
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent);
+ db_event_markRead(hContact, hDbEvent);
if (bRemoveCListEvents)
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
@@ -628,7 +626,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
}
mir_free(dbei.pBlob);
}
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_next(hDbEvent);
}
db_free(&dbv);
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 7edfdb49b2..e38dbf1c67 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1078,18 +1078,17 @@ void CJabberProto::OnProcessPubsubEvent(HXML node)
DWORD JabberGetLastContactMessageTime(HANDLE hContact)
{
// TODO: time cache can improve performance
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = db_event_last(hContact);
if ( !hDbEvent)
return 0;
DWORD dwTime = 0;
- 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 != -1) {
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ int nGetTextResult = db_event_get(hDbEvent, &dbei);
if ( !nGetTextResult)
dwTime = dbei.timestamp;
mir_free(dbei.pBlob);
@@ -1248,16 +1247,15 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info)
// chatstates gone event
if (hContact && xmlGetChildByTag(node, "gone", "xmlns", _T(JABBER_FEAT_CHATSTATES)) && m_options.LogChatstates) {
- DBEVENTINFO dbei;
BYTE bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.pBlob = &bEventType;
dbei.cbBlob = 1;
dbei.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
dbei.flags = DBEF_READ;
dbei.timestamp = time(NULL);
dbei.szModule = m_szModuleName;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
if ((n = xmlGetChildByTag(node, "confirm", "xmlns", _T(JABBER_FEAT_HTTP_AUTH))) && m_options.AcceptHttpAuth) {
diff --git a/protocols/MRA/src/MraAntiSpam.cpp b/protocols/MRA/src/MraAntiSpam.cpp
index 4fbbb3c744..8b60ade855 100644
--- a/protocols/MRA/src/MraAntiSpam.cpp
+++ b/protocols/MRA/src/MraAntiSpam.cpp
@@ -398,16 +398,14 @@ DWORD CMraProto::MraAntiSpamReceivedMessageW(LPSTR lpszEMail, size_t dwEMailSize
CHAR szBuff[MRA_MAXLENOFMESSAGE*2];
WideCharToMultiByte(CP_UTF8, 0, wszBuff, DWORD(dwDBMessageSize), szBuff, SIZEOF(szBuff), NULL, NULL);
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = _time32(NULL);
dbei.flags = (DBEF_READ|DBEF_UTF);
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = DWORD(dwDBMessageSize*sizeof(WCHAR));
dbei.pBlob = (PBYTE)szBuff;
-
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(NULL, &dbei);
}
if (hContact && bAntiSpamDeteleSpamBotContacts) {
@@ -423,15 +421,14 @@ DWORD CMraProto::MraAntiSpamReceivedMessageW(LPSTR lpszEMail, size_t dwEMailSize
CHAR szBuff[MRA_MAXLENOFMESSAGE*2];
WideCharToMultiByte(CP_UTF8, 0, wszBuff, DWORD(dwDBMessageSize), szBuff, SIZEOF(szBuff), NULL, NULL);
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = _time32(NULL);
dbei.flags = (DBEF_READ|DBEF_UTF);
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = DWORD(dwDBMessageSize*sizeof(WCHAR));
dbei.pBlob = (PBYTE)szBuff;
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(NULL, &dbei);
}
}
}
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp
index b1294148b5..e28eded3af 100644
--- a/protocols/MRA/src/MraProto.cpp
+++ b/protocols/MRA/src/MraProto.cpp
@@ -227,9 +227,9 @@ HANDLE CMraProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
{
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1) {
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) != -1) {
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- if ( CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0 &&
+ if ( db_event_get(hDbEvent, &dbei) == 0 &&
!strcmp(dbei.szModule, m_szModuleName) &&
(dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS)) {
@@ -259,13 +259,12 @@ int CMraProto::Authorize(HANDLE hDBEvent)
{
if (!m_bLoggedIn) return 1;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDBEvent, 0)) == -1)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDBEvent)) == -1)
return 1;
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- if ( CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei)) return 1;
+ if ( db_event_get(hDBEvent, &dbei)) return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST) return 1;
if ( strcmp(dbei.szModule, m_szModuleName)) return 1;
@@ -281,13 +280,12 @@ int CMraProto::AuthDeny(HANDLE hDBEvent, const TCHAR* szReason)
{
if (!m_bLoggedIn) return 1;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDBEvent, 0)) == -1)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDBEvent)) == -1)
return 1;
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- if ( CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei)) return 1;
+ if ( db_event_get(hDBEvent, &dbei)) return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST) return 1;
if ( strcmp(dbei.szModule, m_szModuleName)) return 1;
@@ -413,15 +411,14 @@ HANDLE CMraProto::SearchByName(const TCHAR *pszNick, const TCHAR *pszFirstName,
int CMraProto::RecvContacts(HANDLE hContact, PROTORECVEVENT* pre)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = pre->timestamp;
dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
dbei.eventType = EVENTTYPE_CONTACTS;
dbei.cbBlob = pre->lParam;
dbei.pBlob = (PBYTE)pre->szMessage;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
return 0;
}
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index ea501f1dcd..162dd9686c 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -655,24 +655,21 @@ DWORD CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader, DWORD *pd
{
BOOL bAdded;
BYTE btBuff[BUFF_SIZE_BLOB];
- DBEVENTINFO dbei = {0};
GetLPS(lpbData, dwDataSize, &lpbDataCurrent, &lpsEMail);
hContact = MraHContactFromEmail(lpsEMail.lpszData, lpsEMail.dwSize, TRUE, TRUE, &bAdded);
if (bAdded) MraUpdateContactInfo(hContact);
if (IsEMailChatAgent(lpsEMail.lpszData, lpsEMail.dwSize) == FALSE) {
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)_time32(NULL);
dbei.flags = 0;
dbei.eventType = EVENTTYPE_ADDED;
- //dbei.cbBlob = 0;
CreateBlobFromContact(hContact, NULL, 0, (LPBYTE)&btBuff, SIZEOF(btBuff), &dwStringSize);
dbei.cbBlob = dwStringSize;
dbei.pBlob = btBuff;
-
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(0, &dbei);
}
GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwTemp, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL);
@@ -2004,17 +2001,14 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, MRA_LPS *pl
DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
if (bAutoGrantAuth) { // auto grant auth
- DBEVENTINFO dbei = {0};
-
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = _time32(NULL);
dbei.flags = DBEF_READ;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
dbei.pBlob = (PBYTE)btBuff;
-
CreateBlobFromContact(hContact, lpwszMessage, dwMessageSize, btBuff, SIZEOF(btBuff), (size_t*)&dbei.cbBlob);
- CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
+ db_event_add(0, &dbei);
MraAuthorize(plpsFrom->lpszData, plpsFrom->dwSize);
}
else {
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index e3da3c541b..c86c1779f8 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -523,7 +523,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
dbei.timestamp = time(NULL);
dbei.cbBlob = (unsigned)strlen(msgBody) + 1;
dbei.pBlob = (PBYTE)msgBody;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
}
}
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp
index 97f632a870..bf23f84ce2 100644
--- a/protocols/MSN/src/msn_lists.cpp
+++ b/protocols/MSN/src/msn_lists.cpp
@@ -265,59 +265,46 @@ void CMsnProto::Lists_Populate(void)
void CMsnProto::MSN_CleanupLists(void)
{
-// EnterCriticalSection(&csLists);
- for (int i=contList.getCount(); i--;)
- {
+ for (int i=contList.getCount(); i--;) {
MsnContact& p = contList[i];
+ if (p.list & LIST_FL)
+ MSN_SetContactDb(p.hContact, p.email);
- if (p.list & LIST_FL) MSN_SetContactDb(p.hContact, p.email);
-
- if (p.list & LIST_PL)
- {
+ if (p.list & LIST_PL) {
if (p.list & (LIST_AL | LIST_BL))
MSN_AddUser(NULL, p.email, p.netId, LIST_PL + LIST_REMOVE);
else
MSN_AddAuthRequest(p.email, p.nick, p.invite);
}
-// if (p.list == LIST_RL)
-// MSN_AddAuthRequest(p.email, NULL, p.invite);
-
- if (p.hContact && !(p.list & (LIST_LL | LIST_FL | LIST_PL)) && p.list != LIST_RL)
- {
- int count = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)p.hContact, 0);
- if (count)
- {
+ if (p.hContact && !(p.list & (LIST_LL | LIST_FL | LIST_PL)) && p.list != LIST_RL) {
+ int count = db_event_count(p.hContact);
+ if (count) {
TCHAR text[256];
- TCHAR* sze = mir_a2t(p.email);
+ TCHAR *sze = mir_a2t(p.email);
mir_sntprintf(text, SIZEOF(text), TranslateT("Contact %s has been removed from the server.\nWould you like to keep it as \"Local Only\" contact to preserve history?"), sze);
mir_free(sze);
TCHAR title[128];
mir_sntprintf(title, SIZEOF(title), TranslateT("%s protocol"), m_tszUserName);
- if (MessageBox(NULL, text, title, MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND) == IDYES)
- {
+ if (MessageBox(NULL, text, title, MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND) == IDYES) {
MSN_AddUser(p.hContact, p.email, 0, LIST_LL);
setByte(p.hContact, "LocalList", 1);
continue;
}
}
- if (!(p.list & (LIST_LL | LIST_FL)))
- {
+ if (!(p.list & (LIST_LL | LIST_FL))) {
CallService(MS_DB_CONTACT_DELETE, (WPARAM)p.hContact, 0);
p.hContact = NULL;
}
-
}
- if (p.list & (LIST_LL | LIST_FL) && p.hContact)
- {
+ if (p.list & (LIST_LL | LIST_FL) && p.hContact) {
TCHAR path[MAX_PATH];
MSN_GetCustomSmileyFileName(p.hContact, path, SIZEOF(path), "", 0);
- if (path[0])
- {
+ if (path[0]) {
SMADD_CONT cont;
cont.cbSize = sizeof(SMADD_CONT);
cont.hContact = p.hContact;
@@ -328,7 +315,6 @@ void CMsnProto::MSN_CleanupLists(void)
}
}
}
-// LeaveCriticalSection(&csLists);
}
void CMsnProto::MSN_CreateContList(void)
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index c1ed5e4f56..8df8e48531 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -282,13 +282,12 @@ HANDLE __cdecl CMsnProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
HANDLE __cdecl CMsnProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return NULL;
dbei.pBlob=(PBYTE) alloca(dbei.cbBlob);
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) return NULL;
+ if (db_event_get(hDbEvent, &dbei)) return NULL;
if (strcmp(dbei.szModule, m_szModuleName)) return NULL;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST) return NULL;
@@ -353,14 +352,12 @@ int CMsnProto::Authorize(HANDLE hDbEvent)
if (!msnLoggedIn)
return 1;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
-
- if ((int)(dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == -1)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
return 1;
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
+ if (db_event_get(hDbEvent, &dbei))
return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
@@ -393,14 +390,12 @@ int CMsnProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
if (!msnLoggedIn)
return 1;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
-
- if ((int)(dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == -1)
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
return 1;
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
+ if (db_event_get(hDbEvent, &dbei))
return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp
index b31dcd7815..fccf376f72 100644
--- a/protocols/Tlen/src/jabber_misc.cpp
+++ b/protocols/Tlen/src/jabber_misc.cpp
@@ -26,16 +26,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void JabberDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(DBEVENTINFO);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = proto->m_szModuleName;
dbei.timestamp = (DWORD) time(NULL);
dbei.flags = flags;
dbei.eventType = eventType;
dbei.cbBlob = cbBlob;
dbei.pBlob = pBlob;
- CallService(MS_DB_EVENT_ADD, (WPARAM) hContact, (LPARAM) &dbei);
+ db_event_add(hContact, &dbei);
}
+
void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick)
{
char *s;
diff --git a/protocols/Tlen/src/jabber_svc.cpp b/protocols/Tlen/src/jabber_svc.cpp
index a064aeb591..30e4764e4f 100644
--- a/protocols/Tlen/src/jabber_svc.cpp
+++ b/protocols/Tlen/src/jabber_svc.cpp
@@ -234,17 +234,12 @@ HANDLE __cdecl TlenProtocol::AddToList(int flags, PROTOSEARCHRESULT *psr)
HANDLE __cdecl TlenProtocol::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent )
{
- DBEVENTINFO dbei;
- HANDLE hContact;
- char *nick, *firstName, *lastName, *jid;
-
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return (HANDLE) NULL;
if ((dbei.pBlob=(PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
return (HANDLE) NULL;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM) &dbei)) {
+ if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
return (HANDLE) NULL;
}
@@ -265,32 +260,27 @@ HANDLE __cdecl TlenProtocol::AddToListByEvent( int flags, int iContact, HANDLE h
return (HANDLE) NULL;
}
- nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
- firstName = nick + strlen(nick) + 1;
- lastName = firstName + strlen(firstName) + 1;
- jid = lastName + strlen(lastName) + 1;
+ char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
- hContact = (HANDLE) AddToListByJID(this, jid, flags);
+ HANDLE hContact = (HANDLE) AddToListByJID(this, jid, flags);
mir_free(dbei.pBlob);
-
return hContact;
}
int __cdecl TlenProtocol::Authorize(HANDLE hDbEvent)
{
- DBEVENTINFO dbei;
- char *nick, *firstName, *lastName, *jid;
-
if (!isOnline)
return 1;
- memset(&dbei, sizeof(dbei), 0);
- dbei.cbSize = sizeof(dbei);
- if (( dbei.cbBlob=CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hDbEvent, 0 )) == ( DWORD )( -1 ))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)-1)
return 1;
if ((dbei.pBlob=(PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
return 1;
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, ( LPARAM )&dbei )){
+ if (db_event_get(hDbEvent, &dbei)){
mir_free(dbei.pBlob);
return 1;
}
@@ -303,10 +293,10 @@ int __cdecl TlenProtocol::Authorize(HANDLE hDbEvent)
return 1;
}
- nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
- firstName = nick + strlen(nick) + 1;
- lastName = firstName + strlen(firstName) + 1;
- jid = lastName + strlen(lastName) + 1;
+ char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
JabberSend(this, "<presence to='%s' type='subscribed'/>", jid);
@@ -331,19 +321,15 @@ int __cdecl TlenProtocol::Authorize(HANDLE hDbEvent)
int __cdecl TlenProtocol::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason)
{
- DBEVENTINFO dbei;
- char *nick, *firstName, *lastName, *jid;
-
if (!isOnline)
return 1;
- memset(&dbei, sizeof(dbei), 0);
- dbei.cbSize = sizeof(dbei);
- if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent/*hContact*/, 0)) == (DWORD)(-1))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1))
return 1;
- if ((dbei.pBlob=(PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
+ if ((dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
return 1;
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent/*hContact*/, (LPARAM) &dbei)) {
+ if (db_event_get(hDbEvent, &dbei)) {
mir_free(dbei.pBlob);
return 1;
}
@@ -356,10 +342,10 @@ int __cdecl TlenProtocol::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason)
return 1;
}
- nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
- firstName = nick + strlen(nick) + 1;
- lastName = firstName + strlen(firstName) + 1;
- jid = lastName + strlen(lastName) + 1;
+ char *nick = (char *)dbei.pBlob + sizeof(DWORD)*2;
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
JabberSend(this, "<presence to='%s' type='unsubscribed'/>", jid);
JabberSend(this, "<iq type='set'><query xmlns='jabber:iq:roster'><item jid='%s' subscription='remove'/></query></iq>", jid);
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp
index d32bd35a32..3b93aa51d5 100644
--- a/protocols/Tlen/src/jabber_thread.cpp
+++ b/protocols/Tlen/src/jabber_thread.cpp
@@ -710,11 +710,10 @@ static void JabberProcessMessage(XmlNode *node, ThreadData *info)
if (msgTime == 0) {
msgTime = time(NULL);
} else {
- HANDLE hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) hContact, 0);
+ HANDLE hDbEvent = db_event_last(hContact);
if (hDbEvent != NULL) {
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) &dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get( hDbEvent, &dbei);
if (msgTime < dbei.timestamp) {
msgTime = dbei.timestamp + 1;
}
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index 178357c36b..0e39bdf63c 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -583,15 +583,13 @@ void TwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg)
// i think we maybe should just do that DBEF_READ line instead of stopping ALL this code. have to test.
if (tweetToMsg) {
DBEVENTINFO dbei = {sizeof(dbei)};
-
dbei.pBlob = (BYTE*)(i->status.text.c_str());
dbei.cbBlob = (int)i->status.text.size()+1;
dbei.eventType = TWITTER_DB_EVENT_TYPE_TWEET;
dbei.flags = DBEF_UTF | DBEF_READ;
- //dbei.flags = DBEF_READ; // i had commented this line out.. can't remember why :( might need to do it again, uncommented for mrQQ for testing (added to the DBEF_UTF line)
dbei.timestamp = static_cast<DWORD>(i->status.time);
dbei.szModule = m_szModuleName;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ db_event_add(hContact, &dbei);
}
db_set_utf(hContact,"CList","StatusMsg",i->status.text.c_str());
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
index 4848b19fe6..ae7fcc07e3 100644
--- a/protocols/Xfire/src/main.cpp
+++ b/protocols/Xfire/src/main.cpp
@@ -1042,8 +1042,7 @@ int ExtraImageApply(WPARAM wparam, LPARAM lparam)
{
HANDLE hContact=(HANDLE)wparam;
// TODO: maybe need to fix extra icons
- char *szProto;
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ) && DBGetContactSettingWord(hContact, protocolname, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) {
int gameid=DBGetContactSettingWord(hContact, protocolname, "GameId", 0);
int gameid2=DBGetContactSettingWord(hContact, protocolname, "VoiceId", 0);
@@ -1384,8 +1383,7 @@ INT_PTR RecvMessage(WPARAM wParam, LPARAM lParam)
CCSDATA *ccs = ( CCSDATA* )lParam;
DBDeleteContactSetting(ccs->hContact, "CList", "Hidden");
- char *szProto;
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) ccs->hContact, 0);
+ char *szProto = GetContactProto(ccs->hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ))
return CallService( MS_PROTO_RECVMSG, wParam, lParam );
@@ -1802,29 +1800,23 @@ HANDLE CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan)
BOOL IsXFireContact(HANDLE hContact)
{
- char *szProto;
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
+ char *szProto = GetContactProto(hContact);
+ if (szProto != NULL && !lstrcmpiA(szProto, protocolname))
return TRUE;
- }
- else
- return FALSE;
+
+ return FALSE;
}
HANDLE CList_FindContact (int uid)
{
- char *szProto;
-
- HANDLE hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDFIRST, 0, 0);
+ HANDLE hContact = db_find_first();
while (hContact) {
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
- if ( DBGetContactSettingDword(hContact, protocolname, "UserId",-1)==uid)
- {
- return (HANDLE)hContact;
- }
+ if ( DBGetContactSettingDword(hContact, protocolname, "UserId",-1)==uid)
+ return hContact;
}
- hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ hContact = db_find_next(hContact);
}
return 0;
}
@@ -1832,10 +1824,9 @@ HANDLE CList_FindContact (int uid)
void CList_MakeAllOffline()
{
vector<HANDLE> fhandles;
- char *szProto;
- HANDLE hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDFIRST, 0, 0);
+ HANDLE hContact = db_find_first();
while (hContact) {
- szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
//freunde von freunden in eine seperate liste setzen
//nur wenn das nicht abgestellt wurde
@@ -1845,9 +1836,6 @@ void CList_MakeAllOffline()
fhandles.push_back(hContact);
}
- //DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
- //DBDeleteContactSetting(hContact, protocolname, "XStatusId");
- //DBDeleteContactSetting(hContact, protocolname, "XStatusName");
DBDeleteContactSetting(hContact, "CList", "StatusMsg");
DBDeleteContactSetting(hContact, protocolname, "ServerIP");
DBDeleteContactSetting(hContact, protocolname, "Port");
@@ -1857,7 +1845,6 @@ void CList_MakeAllOffline()
DBDeleteContactSetting(hContact, protocolname, "Players");
DBDeleteContactSetting(hContact, protocolname, "Passworded");
- //DBWriteContactSettingUTF8String(hContact, "CList", "StatusMsg", "");
DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
DBDeleteContactSetting(hContact, protocolname, "XStatusId");
DBDeleteContactSetting(hContact, protocolname, "XStatusName");
@@ -1898,13 +1885,12 @@ void CList_MakeAllOffline()
}
DBWriteContactSettingWord(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
}
- hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ hContact = db_find_next(hContact);
}
+
//alle gefundenen handles lsöchen
for(uint i=0;i<fhandles.size();i++)
- {
CallService( MS_DB_CONTACT_DELETE, (WPARAM) fhandles.at(i), 0);
- }
}
void SetIcon(HANDLE hcontact,HANDLE hicon,int ctype)
diff --git a/protocols/Yahoo/src/im.cpp b/protocols/Yahoo/src/im.cpp
index 1c07e73903..607221d2c9 100644
--- a/protocols/Yahoo/src/im.cpp
+++ b/protocols/Yahoo/src/im.cpp
@@ -108,14 +108,14 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons
pre.flags = (utf8) ? PREF_UTF : 0;
if (tm) {
- HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ HANDLE hEvent = db_event_last(hContact);
if (hEvent) { // contact has events
DWORD dummy;
DBEVENTINFO dbei = { sizeof (dbei) };
dbei.pBlob = (BYTE*)&dummy;
dbei.cbBlob = 2;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
+ if (!db_event_get(hEvent, &dbei))
// got that event, if newer than ts then reset to current time
if ((DWORD)tm < dbei.timestamp) tm = (long)time(NULL);
}
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp
index d78943f4b7..245a1fbd1f 100644
--- a/protocols/Yahoo/src/proto.cpp
+++ b/protocols/Yahoo/src/proto.cpp
@@ -147,28 +147,28 @@ HANDLE CYahooProto::AddToList( int flags, PROTOSEARCHRESULT* psr )
HANDLE __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, HANDLE hDbEvent )
{
DebugLog("[YahooAddToListByEvent]");
- if ( !m_bLoggedIn )
+ if (!m_bLoggedIn)
return 0;
DBEVENTINFO dbei = { sizeof( dbei ) };
- if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, (LPARAM)hDbEvent, 0)) == -1 ) {
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1 ) {
DebugLog("[YahooAddToListByEvent] ERROR: Can't get blob size.");
return 0;
}
DebugLog("[YahooAddToListByEvent] Got blob size: %lu", dbei.cbBlob);
dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, (LPARAM)&dbei )) {
+ if (db_event_get(hDbEvent, &dbei)) {
DebugLog("[YahooAddToListByEvent] ERROR: Can't get event.");
return 0;
}
- if ( dbei.eventType != EVENTTYPE_AUTHREQUEST ) {
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST) {
DebugLog("[YahooAddToListByEvent] ERROR: Not an authorization request.");
return 0;
}
- if ( strcmp( dbei.szModule, m_szModuleName )) {
+ if ( strcmp(dbei.szModule, m_szModuleName)) {
DebugLog("[YahooAddToListByEvent] ERROR: Not Yahoo protocol.");
return 0;
}
@@ -194,11 +194,11 @@ int CYahooProto::Authorize( HANDLE hdbe )
}
DBEVENTINFO dbei = { sizeof(dbei) };
- if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0)) == -1 )
+ if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 )
return 1;
dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, (LPARAM)&dbei ))
+ if (db_event_get(hdbe, &dbei))
return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
@@ -235,23 +235,23 @@ int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason )
return 1;
DBEVENTINFO dbei = { sizeof( dbei ) };
- if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0)) == -1 ) {
+ if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 ) {
DebugLog("[YahooAuthDeny] ERROR: Can't get blob size");
return 1;
}
dbei.pBlob = ( PBYTE )alloca( dbei.cbBlob );
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, (LPARAM)&dbei )) {
+ if (db_event_get(hdbe, &dbei)) {
DebugLog("YahooAuthDeny - Can't get db event!");
return 1;
}
- if ( dbei.eventType != EVENTTYPE_AUTHREQUEST ) {
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST) {
DebugLog("YahooAuthDeny - not Authorization event");
return 1;
}
- if ( strcmp( dbei.szModule, m_szModuleName )) {
+ if (strcmp( dbei.szModule, m_szModuleName)) {
DebugLog("YahooAuthDeny - wrong module?");
return 1;
}
diff --git a/src/core/stdauth/auth.cpp b/src/core/stdauth/auth.cpp
index 2edd847743..270bbb1436 100644
--- a/src/core/stdauth/auth.cpp
+++ b/src/core/stdauth/auth.cpp
@@ -47,15 +47,14 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
TCHAR szTooltip[256];
const HANDLE hDbEvent = (HANDLE)lParam;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
if (dbei.flags & (DBEF_SENT | DBEF_READ) || (dbei.eventType != EVENTTYPE_AUTHREQUEST && dbei.eventType != EVENTTYPE_ADDED))
return 0;
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, lParam, 0);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
HANDLE hContact = DbGetAuthEventContact(&dbei);
diff --git a/src/core/stdauth/authdialogs.cpp b/src/core/stdauth/authdialogs.cpp
index 3f498cce22..0fd7b44cce 100644
--- a/src/core/stdauth/authdialogs.cpp
+++ b/src/core/stdauth/authdialogs.cpp
@@ -38,11 +38,10 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
//blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- 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);
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
DWORD uin = *(PDWORD)dbei.pBlob;
HANDLE hContact = DbGetAuthEventContact(&dbei);
@@ -162,11 +161,10 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
//blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- 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);
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
DWORD uin = *(PDWORD)dbei.pBlob;
HANDLE hContact = DbGetAuthEventContact(&dbei);
@@ -245,13 +243,11 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case IDOK:
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
CallProtoService(dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0);
- if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK))
- {
+ if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK)) {
ADDCONTACTSTRUCT acs = {0};
acs.handle = hDbEvent;
acs.handleType = HANDLE_EVENT;
@@ -264,9 +260,8 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case IDCANCEL:
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON)))
{
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp
index 83c2e04196..7761fdab1c 100644
--- a/src/core/stdchat/src/clist.cpp
+++ b/src/core/stdchat/src/clist.cpp
@@ -295,7 +295,7 @@ 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 );
+ char *szProto = GetContactProto(hContact);
if ( szProto && !lstrcmpiA( szProto, pszModule )) {
if ( DBGetContactSettingByte( hContact, szProto, "ChatRoom", 0) != 0 ) {
DBVARIANT dbv;
diff --git a/src/core/stdfile/file.cpp b/src/core/stdfile/file.cpp
index a29b71bc33..048125abac 100644
--- a/src/core/stdfile/file.cpp
+++ b/src/core/stdfile/file.cpp
@@ -140,12 +140,11 @@ static int FileEventAdded(WPARAM wParam, LPARAM lParam)
{
DWORD dwSignature;
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = sizeof(DWORD);
dbei.pBlob = (PBYTE)&dwSignature;
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
- if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_FILE || dwSignature == 0)
+ db_event_get((HANDLE)lParam, &dbei);
+ if (dbei.flags & (DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_FILE || dwSignature == 0)
return 0;
PushFileEvent((HANDLE)wParam, (HANDLE)lParam, 0);
@@ -288,19 +287,15 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS
static void RemoveUnreadFileEvents(void)
{
- DBEVENTINFO dbei = {0};
- HANDLE hDbEvent, hContact;
-
- dbei.cbSize = sizeof(dbei);
- hContact = db_find_first();
+ HANDLE hContact = db_find_first();
while (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_FILE)
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent);
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ db_event_markRead(hContact, hDbEvent);
+ hDbEvent = db_event_next(hDbEvent);
}
hContact = db_find_next(hContact);
}
@@ -413,7 +408,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
}
mir_free(szDescr);
- HANDLE hdbe = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)ccs->hContact, (LPARAM)&dbei);
+ HANDLE hdbe = db_event_add(ccs->hContact, &dbei);
PushFileEvent(ccs->hContact, hdbe, pre->lParam);
mir_free(dbei.pBlob);
diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp
index ac082ac140..f9e2c3ddce 100644
--- a/src/core/stdfile/filerecvdlg.cpp
+++ b/src/core/stdfile/filerecvdlg.cpp
@@ -247,14 +247,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
DBFreeVariant(&dbv);
}
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent);
+ db_event_markRead(dat->hContact, dat->hDbEvent);
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent);
if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) {
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1);
- CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei);
+ db_event_get(dat->hDbEvent, &dbei);
dbei.pBlob[dbei.cbBlob] = 0;
dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob;
diff --git a/src/core/stdfile/filexferdlg.cpp b/src/core/stdfile/filexferdlg.cpp
index bcb51e6a62..93354d07d4 100644
--- a/src/core/stdfile/filexferdlg.cpp
+++ b/src/core/stdfile/filexferdlg.cpp
@@ -654,7 +654,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
DBEVENTINFO dbei = {0};
FillSendData(dat, dbei);
- CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei);
+ db_event_add(dat->hContact, &dbei);
if (dbei.pBlob)
mir_free(dbei.pBlob);
dat->files = NULL; //protocol library frees this
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index b078aa10aa..74029cd726 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -132,21 +132,18 @@ HANDLE SendMessageDirect(const TCHAR *szMsg, HANDLE hContact, char *szProto)
}
if (sendBuffer) {
- HANDLE hNewEvent, hSendId;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT | (flags & PREF_UTF ? DBEF_UTF : 0) | (flags & PREF_RTL ? DBEF_RTL : 0);
dbei.szModule = szProto;
dbei.timestamp = (DWORD)time(NULL);
dbei.cbBlob = (DWORD)bufSize;
dbei.pBlob = (PBYTE)sendBuffer;
+ HANDLE hNewEvent = db_event_add(hContact, &dbei);
- hNewEvent = (HANDLE) CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
- hSendId = (HANDLE) CallContactService(hContact, MsgServiceName(hContact), flags, (LPARAM) sendBuffer);
+ HANDLE hSendId = (HANDLE) CallContactService(hContact, MsgServiceName(hContact), flags, (LPARAM) sendBuffer);
msgQueue_add(hContact, hSendId, szMsg, hNewEvent);
mir_free(sendBuffer);
-
return hNewEvent;
}
return NULL;
@@ -786,80 +783,67 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dat->hContact) {
int historyMode = db_get_b(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->hContact, 0);
+ dat->hDbEventFirst = db_event_firstUnread(dat->hContact);
switch (historyMode) {
case LOADHISTORY_COUNT:
{
HANDLE hPrevEvent;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
for (int i = DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); 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) hPrevEvent, (LPARAM) &dbei);
+ db_event_get(hPrevEvent, &dbei);
if ( !DbEventIsShown(&dbei, dat))
i++;
}
break;
}
case LOADHISTORY_TIME:
- {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if (dat->hDbEventFirst == NULL)
+ dbei.timestamp = (DWORD)time(NULL);
+ else
+ db_event_get( dat->hDbEventFirst, &dbei);
+
+ DWORD firstTime = dbei.timestamp - 60 * DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
+ for (;;) {
HANDLE hPrevEvent;
- DBEVENTINFO dbei = { 0 };
- DWORD firstTime;
-
- dbei.cbSize = sizeof(dbei);
if (dat->hDbEventFirst == NULL)
- dbei.timestamp = (DWORD)time(NULL);
+ hPrevEvent = db_event_last(dat->hContact);
else
- CallService(MS_DB_EVENT_GET, (WPARAM) dat->hDbEventFirst, (LPARAM) & dbei);
- firstTime = dbei.timestamp - 60 * DBGetContactSettingWord(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
- for (;;)
- {
- if (dat->hDbEventFirst == NULL)
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->hContact, 0);
- else
- hPrevEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) dat->hDbEventFirst, 0);
- if (hPrevEvent == NULL)
- break;
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM) hPrevEvent, (LPARAM) & dbei);
- if (dbei.timestamp < firstTime)
- break;
- dat->hDbEventFirst = hPrevEvent;
- }
- break;
+ hPrevEvent = db_event_prev(dat->hDbEventFirst);
+ if (hPrevEvent == NULL)
+ break;
+
+ dbei.cbBlob = 0;
+ db_event_get(hPrevEvent, &dbei);
+ if (dbei.timestamp < firstTime)
+ break;
+ dat->hDbEventFirst = hPrevEvent;
}
+ break;
}
}
- {
- DBEVENTINFO dbei = { 0 };
- HANDLE hdbEvent;
-
- dbei.cbSize = sizeof(dbei);
- hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDLAST, (WPARAM) dat->hContact, 0);
- if (hdbEvent)
- {
- do {
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM) hdbEvent, (LPARAM) & dbei);
- if (( dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)) && !(dbei.flags & DBEF_SENT)) {
- dat->lastMessage = dbei.timestamp;
- PostMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
- break;
- }
+ HANDLE hdbEvent = db_event_last(dat->hContact);
+ if (hdbEvent) {
+ do {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get( hdbEvent, &dbei);
+ if (( dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)) && !(dbei.flags & DBEF_SENT)) {
+ dat->lastMessage = dbei.timestamp;
+ PostMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
+ break;
}
- while (hdbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDPREV, (WPARAM) hdbEvent, 0));
}
+ while (hdbEvent = db_event_prev(hdbEvent));
}
SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 1, 0);
@@ -1193,9 +1177,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
// log
if ((dat->wStatus != dat->wOldStatus || lParam != 0) &&
db_get_b(NULL, SRMMMOD, SRMSGSET_SHOWSTATUSCH, SRMSGDEFSET_SHOWSTATUSCH)) {
- DBEVENTINFO dbei;
TCHAR buffer[200];
- HANDLE hNewEvent;
int iLen;
TCHAR *szOldStatus = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM) dat->wOldStatus, GSMDF_TCHAR);
@@ -1210,22 +1192,20 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
else
iLen = mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("is now %s (was %s)"), szNewStatus, szOldStatus);
- {
- char* blob = ( char* )alloca(1000);
- int ansiLen = WideCharToMultiByte(CP_ACP, 0, buffer, -1, blob, 1000, 0, 0);
- memcpy( blob+ansiLen, buffer, sizeof(TCHAR)*(iLen+1));
- dbei.cbBlob = ansiLen + sizeof(TCHAR)*(iLen+1);
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = (PBYTE) blob;
- dbei.eventType = EVENTTYPE_STATUSCHANGE;
- dbei.flags = 0;
- dbei.timestamp = (DWORD)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(hwndDlg, DM_REMAKELOG, 0, 0);
- }
+ char* blob = ( char* )alloca(1000);
+ int ansiLen = WideCharToMultiByte(CP_ACP, 0, buffer, -1, blob, 1000, 0, 0);
+ memcpy( blob+ansiLen, buffer, sizeof(TCHAR)*(iLen+1));
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = ansiLen + sizeof(TCHAR)*(iLen+1);
+ dbei.pBlob = (PBYTE) blob;
+ dbei.eventType = EVENTTYPE_STATUSCHANGE;
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.szModule = dat->szProto;
+ HANDLE hNewEvent = db_event_add(dat->hContact, &dbei);
+ if (dat->hDbEventFirst == NULL) {
+ dat->hDbEventFirst = hNewEvent;
+ SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
}
}
dat->wOldStatus = dat->wStatus;
@@ -1396,15 +1376,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case HM_DBEVENTADDED:
- if ((HANDLE) wParam != dat->hContact)
- break;
- {
- DBEVENTINFO dbei = { 0 };
-
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei);
+ if ((HANDLE)wParam == dat->hContact) {
+ HANDLE hDbEvent = (HANDLE)lParam;
if (dat->hDbEventFirst == NULL)
- dat->hDbEventFirst = (HANDLE) lParam;
+ dat->hDbEventFirst = hDbEvent;
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDbEvent, &dbei);
if (DbEventIsShown(&dbei, dat) && !(dbei.flags & DBEF_READ)) {
if ((dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)) && !(dbei.flags & DBEF_SENT)) {
if (GetForegroundWindow() == hwndDlg)
@@ -1416,7 +1394,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->lastMessage = dbei.timestamp;
SendMessage(hwndDlg, DM_UPDATELASTMESSAGE, 0, 0);
}
- if ((HANDLE) lParam != dat->hDbEventFirst && (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, lParam, 0) == NULL)
+ if (hDbEvent != dat->hDbEventFirst && db_event_next(hDbEvent) == NULL)
SendMessage(hwndDlg, DM_APPENDTOLOG, lParam, 0);
else
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index a76bbeaac5..6dc9aad95e 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -268,26 +268,25 @@ static char *CreateRTFFromDbEvent(struct SrmmWindowData *dat, HANDLE hContact, H
{
char *buffer;
int bufferAlloced, bufferEnd;
- DBEVENTINFO dbei = { 0 };
int showColon = 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 == -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;
}
- if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)))
- {
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM) hContact, (LPARAM) hDbEvent);
+ if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
+ 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);
}
bufferEnd = 0;
bufferAlloced = 1024;
@@ -298,41 +297,38 @@ static char *CreateRTFFromDbEvent(struct SrmmWindowData *dat, HANDLE hContact, H
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
if (dbei.flags & DBEF_RTL) {
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlpar");
dat->bIsAutoRTL = TRUE;
}
- else
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
+ else AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrpar");
streamData->isEmpty = 0;
if (dat->bIsAutoRTL) {
- if(dbei.flags & DBEF_RTL) {
+ if(dbei.flags & DBEF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrch\\rtlch");
- }else{
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlch\\ltrch");
- }
}
if (g_dat.flags & SMF_SHOWICONS) {
int i;
switch (dbei.eventType) {
- case EVENTTYPE_MESSAGE:
- if (dbei.flags & DBEF_SENT) {
- i = LOGICON_MSG_OUT;
- }
- else {
- i = LOGICON_MSG_IN;
- }
- break;
- case EVENTTYPE_JABBER_CHATSTATES:
- case EVENTTYPE_JABBER_PRESENCE:
- case EVENTTYPE_STATUSCHANGE:
- case EVENTTYPE_FILE:
- default:
- i = LOGICON_MSG_NOTICE;
- break;
+ case EVENTTYPE_MESSAGE:
+ if (dbei.flags & DBEF_SENT)
+ i = LOGICON_MSG_OUT;
+ else
+ i = LOGICON_MSG_IN;
+ break;
+
+ case EVENTTYPE_JABBER_CHATSTATES:
+ case EVENTTYPE_JABBER_PRESENCE:
+ case EVENTTYPE_STATUSCHANGE:
+ case EVENTTYPE_FILE:
+ default:
+ i = LOGICON_MSG_NOTICE;
+ break;
}
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\f0\\fs14");
while (bufferAlloced - bufferEnd < logIconBmpSize[i])
@@ -341,8 +337,8 @@ static char *CreateRTFFromDbEvent(struct SrmmWindowData *dat, HANDLE hContact, H
CopyMemory(buffer + bufferEnd, pLogIconBmpBits[i], logIconBmpSize[i]);
bufferEnd += logIconBmpSize[i];
}
- if (g_dat.flags & SMF_SHOWTIME)
- {
+
+ if (g_dat.flags & SMF_SHOWTIME) {
const TCHAR* szFormat;
TCHAR str[64];
@@ -357,6 +353,7 @@ static char *CreateRTFFromDbEvent(struct SrmmWindowData *dat, HANDLE hContact, H
AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, str);
showColon = 1;
}
+
if (!(g_dat.flags&SMF_HIDENAMES) && dbei.eventType != EVENTTYPE_STATUSCHANGE && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) {
TCHAR* szName;
CONTACTINFO ci = {0};
@@ -477,7 +474,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
dat->buffer = CreateRTFFromDbEvent(dat->dlgDat, dat->hContact, dat->hDbEvent, 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);
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index fe65236e7f..7079ff4b65 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -50,29 +50,23 @@ static int SRMMStatusToPf2(int status)
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.flags & (DBEF_SENT | DBEF_READ) || !(dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)))
return 0;
CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1);
/* does a window for the contact exist? */
- hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
- if (hwnd)
- {
- if (!db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS))
- {
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE) wParam);
+ if (hwnd) {
+ if (!db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS)) {
ShowWindow(hwnd, SW_RESTORE);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetForegroundWindow(hwnd);
SkinPlaySound("RecvMsgActive");
}
- else
- {
+ else {
if (GetForegroundWindow() == hwnd)
SkinPlaySound("RecvMsgActive");
else
@@ -244,57 +238,48 @@ static int ContactDeleted(WPARAM wParam, LPARAM lParam)
static void RestoreUnreadMessageAlerts(void)
{
- CLISTEVENT cle = {0};
- DBEVENTINFO dbei = {0};
TCHAR toolTip[256];
int windowAlreadyExists;
- HANDLE hDbEvent, hContact;
int autoPopup;
- 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;
cle.ptszTooltip = toolTip;
- hContact = db_find_first();
- while (hContact)
- {
- hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0);
- while (hDbEvent)
- {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+
+ HANDLE hContact = db_find_first();
+ while (hContact) {
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
+ while (hDbEvent) {
autoPopup = 0;
dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei);
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && ( dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)))
- {
+ db_event_get( hDbEvent, &dbei);
+ if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && ( dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL;
if (windowAlreadyExists)
continue;
- {
- char *szProto = GetContactProto(hContact);
- if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0))))
- {
- autoPopup = 1;
- }
- }
- if (autoPopup && !windowAlreadyExists)
- {
- struct NewMessageWindowLParam newData = {0};
+
+ char *szProto = GetContactProto(hContact);
+ if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0))))
+ autoPopup = 1;
+
+ if (autoPopup && !windowAlreadyExists) {
+ NewMessageWindowLParam newData = {0};
newData.hContact = hContact;
newData.noActivate = db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS);
CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM) & newData);
}
- else
- {
+ else {
cle.hContact = hContact;
cle.hDbEvent = hDbEvent;
mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR));
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/src/core/stdmsg/src/msgtimedout.cpp b/src/core/stdmsg/src/msgtimedout.cpp
index 9e112adb72..3004671f7f 100644
--- a/src/core/stdmsg/src/msgtimedout.cpp
+++ b/src/core/stdmsg/src/msgtimedout.cpp
@@ -88,20 +88,17 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
void MessageFailureProcess(TMsgQueue *item, const char* err)
{
- HWND hwnd;
- ErrorDlgParam param = { err, item };
-
- CallService(MS_DB_EVENT_DELETE, (WPARAM)item->hContact, (LPARAM)item->hDbEvent);
+ db_event_delete(item->hContact, item->hDbEvent);
- hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)item->hContact);
- if (hwnd == NULL)
- {
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)item->hContact);
+ if (hwnd == NULL) {
SendMessageCmd(item->hContact, NULL, 0);
hwnd = WindowList_Find(g_dat.hMessageWindowList, (HANDLE)item->hContact);
}
- else
- SendMessage(hwnd, DM_REMAKELOG, 0, 0);
+ else SendMessage(hwnd, DM_REMAKELOG, 0, 0);
SkinPlaySound("SendError");
+
+ ErrorDlgParam param = { err, item };
CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSENDERROR), hwnd, ErrorDlgProc, (LPARAM) &param);
}
diff --git a/src/core/stduihist/history.cpp b/src/core/stduihist/history.cpp
index dcb8e6e401..da39ccaee2 100644
--- a/src/core/stduihist/history.cpp
+++ b/src/core/stduihist/history.cpp
@@ -142,32 +142,29 @@ static void FillHistoryThread(void* param)
{
Thread_SetName("HistoryWindow::FillHistoryThread");
- TCHAR str[200], eventText[256], strdatetime[64];
- HANDLE hDbEvent;
- DBEVENTINFO dbei;
- int newBlobSize, oldBlobSize, i;
- HWND hwndList;
THistoryThread *hInfo = (THistoryThread*)param;
+ HWND hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST);
SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0);
- i = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0);
+ int i = db_event_count(hInfo->hContact);
SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i*40);
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- oldBlobSize = 0;
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0);
- hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ int oldBlobSize = 0;
+ HANDLE hDbEvent = db_event_last(hInfo->hContact);
+
while (hDbEvent != NULL) {
if ( !IsWindow(hInfo->hwnd))
break;
- newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
- if (newBlobSize>oldBlobSize) {
+ int newBlobSize = db_event_getBlobSize(hDbEvent);
+ if (newBlobSize > oldBlobSize) {
dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize);
oldBlobSize = newBlobSize;
}
dbei.cbBlob = oldBlobSize;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
+
+ TCHAR str[200], eventText[256], strdatetime[64];
GetObjectSummary(&dbei, str, SIZEOF(str));
if (str[0]) {
tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0);
@@ -175,7 +172,7 @@ static void FillHistoryThread(void* param)
i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText);
SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent);
}
- hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0);
+ hDbEvent = db_event_prev(hDbEvent);
}
mir_free(dbei.pBlob);
@@ -275,30 +272,25 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this history item?"), TranslateT("Delete History"), MB_YESNO|MB_ICONQUESTION) == IDYES) {
hDbevent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0);
- CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDbevent);
+ db_event_delete(hContact, hDbevent);
SendMessage(hwndDlg, DM_HREBUILD, 0, 0);
}
return TRUE;
}
case IDC_LIST:
if (HIWORD(wParam) == LBN_SELCHANGE) {
- TCHAR str[8192], *contactName;
- HANDLE hDbEvent;
- DBEVENTINFO dbei;
- int sel;
- sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0);
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0);
if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; }
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE);
- contactName = pcli->pfnGetContactDisplayName(hContact, 0);
- hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0);
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
- if ((int)dbei.cbBlob != -1)
- {
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(hContact, 0);
+ HANDLE hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
+ if ((int)dbei.cbBlob != -1) {
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0)
- {
+ if (db_event_get(hDbEvent, &dbei) == 0) {
+ TCHAR str[8192];
GetObjectDescription(&dbei, str, SIZEOF(str));
if (str[0])
SetDlgItemText(hwndDlg, IDC_EDIT, str);
@@ -311,34 +303,32 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP
break;
case DM_FINDNEXT:
{
- TCHAR str[1024];
- HANDLE hDbEvent, hDbEventStart;
- DBEVENTINFO dbei;
- int newBlobSize, oldBlobSize;
-
int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0);
if (index == LB_ERR)
break;
- hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0);
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.pBlob = NULL;
- oldBlobSize = 0;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ int oldBlobSize = 0;
+ HANDLE hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0);
+
for (;;) {
- hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0);
+ HANDLE hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0);
if (hDbEvent == (HANDLE)LB_ERR) {
index = -1;
continue;
}
- if (hDbEvent == hDbEventStart) break;
- newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ if (hDbEvent == hDbEventStart)
+ break;
+
+ int newBlobSize = db_event_getBlobSize(hDbEvent);
if (newBlobSize>oldBlobSize) {
dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize);
oldBlobSize = newBlobSize;
}
dbei.cbBlob = oldBlobSize;
- CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ db_event_get(hDbEvent, &dbei);
+
+ TCHAR str[1024];
GetObjectDescription(&dbei, str, SIZEOF(str));
if (str[0]) {
CharUpperBuff(str, lstrlen(str));
diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp
index 9f97c4288e..68818744b4 100644
--- a/src/core/stdurl/url.cpp
+++ b/src/core/stdurl/url.cpp
@@ -40,25 +40,22 @@ static INT_PTR ReadUrlCommand(WPARAM, LPARAM lParam)
static int UrlEventAdded(WPARAM wParam, LPARAM lParam)
{
- CLISTEVENT cle;
- DBEVENTINFO dbei;
- TCHAR szTooltip[256];
-
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = 0;
- CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
- if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_URL) return 0;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get((HANDLE)lParam, &dbei);
+ if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_URL)
+ return 0;
SkinPlaySound("RecvUrl");
- ZeroMemory(&cle, sizeof(cle));
- cle.cbSize = sizeof(cle);
+
+ TCHAR szTooltip[256];
+ mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName((HANDLE)wParam, 0));
+
+ CLISTEVENT cle = { sizeof(cle) };
cle.flags = CLEF_TCHAR;
cle.hContact = (HANDLE)wParam;
cle.hDbEvent = (HANDLE)lParam;
cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL);
cle.pszService = "SRUrl/ReadUrl";
- mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName((HANDLE)wParam, 0));
cle.ptszTooltip = szTooltip;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
return 0;
@@ -72,31 +69,27 @@ static INT_PTR SendUrlCommand(WPARAM wParam, LPARAM)
static void RestoreUnreadUrlAlerts(void)
{
- CLISTEVENT cle = {0};
- DBEVENTINFO dbei = {0};
- TCHAR toolTip[256];
- HANDLE hDbEvent, hContact;
-
- dbei.cbSize = sizeof(dbei);
- cle.cbSize = sizeof(cle);
+ CLISTEVENT cle = { sizeof(cle) };
cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL);
cle.pszService = "SRUrl/ReadUrl";
+ cle.flags = CLEF_TCHAR;
- hContact = db_find_first();
+ HANDLE hContact = db_find_first();
while (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_URL) {
+ TCHAR toolTip[256];
+ mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+
cle.hContact = hContact;
cle.hDbEvent = hDbEvent;
- cle.flags = CLEF_TCHAR;
- mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
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);
}
diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp
index dc0ef67bf4..b824c20618 100644
--- a/src/core/stdurl/urldialogs.cpp
+++ b/src/core/stdurl/urldialogs.cpp
@@ -97,30 +97,26 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact);
{
- DBEVENTINFO dbei;
- TCHAR* contactName;
- TCHAR msg[128];
-
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent);
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei);
+ db_event_get(dat->hDbEvent, &dbei);
SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob);
SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+lstrlenA((char*)dbei.pBlob)+1);
mir_free(dbei.pBlob);
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent);
+ db_event_markRead(dat->hContact, dat->hDbEvent);
- contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128];
mir_sntprintf(msg, SIZEOF(msg), TranslateT("URL from %s"), contactName);
SetWindowText(hwndDlg, msg);
SetDlgItemText(hwndDlg, IDC_FROM, contactName);
SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0);
- { TCHAR str[128];
- tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0);
- SetDlgItemText(hwndDlg, IDC_DATE, str);
- } }
+
+ TCHAR str[128];
+ tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0);
+ SetDlgItemText(hwndDlg, IDC_DATE, str);
+ }
// From message dlg
if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0))
@@ -537,13 +533,13 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_COMMAND:
if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
break;
- switch (LOWORD(wParam))
- {
- case IDOK:
+
+ switch (LOWORD(wParam)) {
+ case IDOK:
{
char *body, *url;
int bodySize, urlSize;
-
+
urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1;
url = (char*)mir_alloc(urlSize);
GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize);
@@ -572,72 +568,75 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE;
}
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- return TRUE;
- case IDC_URLS:
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- int i, urlSize;
- char *title;
- i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0);
- title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0);
- SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title);
- urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
- }
- else if (HIWORD(wParam) == CBN_EDITCHANGE) {
- int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS));
- EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
- }
- break;
- case IDC_USERMENU:
- { RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
- DestroyMenu(hMenu);
- }
- break;
- case IDC_HISTORY:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0);
- break;
- case IDC_DETAILS:
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0);
- break;
- case IDC_ADD:
- { ADDCONTACTSTRUCT acs = {0};
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ return TRUE;
- acs.handle = dat->hContact;
- acs.handleType = HANDLE_CONTACT;
- acs.szProto = 0;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
- }
- if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) {
- ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
- }
- break;
+ case IDC_URLS:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int i, urlSize;
+ char *title;
+ i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0);
+ title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0);
+ SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title);
+ urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
+ }
+ else if (HIWORD(wParam) == CBN_EDITCHANGE) {
+ int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS));
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
+ }
+ break;
+ case IDC_USERMENU:
+ {
+ RECT rc;
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
+ DestroyMenu(hMenu);
+ }
+ break;
+
+ case IDC_HISTORY:
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0);
+ break;
+
+ case IDC_DETAILS:
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0);
+ break;
+
+ case IDC_ADD:
+ ADDCONTACTSTRUCT acs = {0};
+ acs.handle = dat->hContact;
+ acs.handleType = HANDLE_CONTACT;
+ acs.szProto = 0;
+ CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
+
+ if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0))
+ ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
}
break;
+
case HM_EVENTSENT:
- { ACKDATA *ack = (ACKDATA*)lParam;
- DBEVENTINFO dbei;
- if (ack->hProcess != dat->hSendId) break;
- if (ack->hContact != dat->hContact) break;
- if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break;
-
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_URL;
- dbei.flags = DBEF_SENT;
- dbei.szModule = GetContactProto(dat->hContact);
- dbei.timestamp = time(NULL);
- dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2);
- dbei.pBlob = (PBYTE)dat->sendBuffer;
- CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei);
- KillTimer(hwndDlg, 0);
- DestroyWindow(hwndDlg);
+ {
+ ACKDATA *ack = (ACKDATA*)lParam;
+ if (ack->hProcess != dat->hSendId) break;
+ if (ack->hContact != dat->hContact) break;
+ if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break;
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.eventType = EVENTTYPE_URL;
+ dbei.flags = DBEF_SENT;
+ dbei.szModule = GetContactProto(dat->hContact);
+ dbei.timestamp = time(NULL);
+ dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2);
+ dbei.pBlob = (PBYTE)dat->sendBuffer;
+ db_event_add(dat->hContact, &dbei);
+ KillTimer(hwndDlg, 0);
+ DestroyWindow(hwndDlg);
+ }
break;
- }
+
case WM_DESTROY:
Window_FreeIcon_IcoLib(hwndDlg);
Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
@@ -650,10 +649,9 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer);
mir_free(dat);
Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send");
- { int i;
- for (i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--)
- mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0));
- }
+
+ for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--)
+ mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0));
break;
}
diff --git a/src/modules/addcontact/addcontact.cpp b/src/modules/addcontact/addcontact.cpp
index 89d0b2d15a..f8a755f9ce 100644
--- a/src/modules/addcontact/addcontact.cpp
+++ b/src/modules/addcontact/addcontact.cpp
@@ -38,11 +38,10 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_ADDCONTACT);
if (acs->handleType == HANDLE_EVENT) {
DWORD dwUin;
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = sizeof(DWORD);
dbei.pBlob = (PBYTE)&dwUin;
- CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei);
+ db_event_get(acs->handle, &dbei);
_ltoa(dwUin, szUin, 10);
acs->szProto = dbei.szModule;
}
@@ -54,15 +53,11 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
int isSet = 0;
if (acs->handleType == HANDLE_EVENT) {
- DBEVENTINFO dbei;
- HANDLE hcontact;
-
- ZeroMemory(&dbei, sizeof(dbei));
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)acs->handle, 0);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(acs->handle);
dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei);
- hcontact = *((PHANDLE)(dbei.pBlob+sizeof(DWORD)));
+ db_event_get(acs->handle, &dbei);
+ HANDLE hcontact = *((PHANDLE)(dbei.pBlob+sizeof(DWORD)));
mir_free(dbei.pBlob);
if (hcontact != INVALID_HANDLE_VALUE) {
szName = cli.pfnGetContactDisplayName(hcontact, 0);
@@ -155,9 +150,8 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
{
case HANDLE_EVENT:
{
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(acs->handle, &dbei);
hContact = (HANDLE)CallProtoServiceInt(NULL,dbei.szModule, PS_ADDTOLISTBYEVENT, 0, (LPARAM)acs->handle);
}
break;
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index e7402b6374..ffc0247a12 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -188,7 +188,7 @@ static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam)
if (pre->flags & PREF_UTF)
dbei.flags |= DBEF_UTF;
- return CallService(MS_DB_EVENT_ADD, (WPARAM) ccs->hContact, (LPARAM)&dbei);
+ return (INT_PTR)db_event_add(ccs->hContact, &dbei);
}
static INT_PTR Proto_AuthRecv(WPARAM wParam, LPARAM lParam)
@@ -204,7 +204,7 @@ static INT_PTR Proto_AuthRecv(WPARAM wParam, LPARAM lParam)
dbei.eventType = EVENTTYPE_AUTHREQUEST;
dbei.cbBlob = pre->lParam;
dbei.pBlob = (PBYTE)pre->szMessage;
- return CallService(MS_DB_EVENT_ADD,0,(LPARAM)&dbei);
+ return (INT_PTR)db_event_add(NULL, &dbei);
}
/////////////////////////////////////////////////////////////////////////////////////////