From 109877a3c75cb290c55755dcfc88794d2453669d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 30 Mar 2013 17:32:39 +0000 Subject: 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 --- plugins/BasicHistory/src/EventList.cpp | 69 +++++++++++------------------- plugins/BasicHistory/src/EventList.h | 2 +- plugins/BasicHistory/src/HistoryWindow.cpp | 16 +++---- plugins/BasicHistory/src/Scheduler.cpp | 6 +-- 4 files changed, 35 insertions(+), 58 deletions(-) (limited to 'plugins/BasicHistory/src') 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& 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& 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& messa ImportMessages(messages); std::list 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::iterator it = tempList.begin(); it != tempList.end(); ++it) - { - if(it->isExternal) - { + for(std::list::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& 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& 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::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 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::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); } -- cgit v1.2.3