diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/AvatarHistory/src/AvatarDlg.cpp | 5 | ||||
-rw-r--r-- | plugins/BasicHistory/src/EventList.cpp | 6 | ||||
-rw-r--r-- | plugins/CmdLine/src/mimcmd_handlers.cpp | 6 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist.cpp | 32 | ||||
-rw-r--r-- | plugins/HistorySweeperLight/src/historysweeperlight.cpp | 17 | ||||
-rwxr-xr-x | plugins/Msg_Export/src/options.cpp | 6 | ||||
-rw-r--r-- | plugins/NoHistory/src/dllmain.cpp | 9 | ||||
-rw-r--r-- | plugins/RemovePersonalSettings/src/rps.cpp | 12 | ||||
-rw-r--r-- | plugins/StopSpamPlus/src/utils.cpp | 5 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp | 3 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_db.cpp | 3 |
11 files changed, 44 insertions, 60 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index 8e696d6cf6..245c58005a 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -410,9 +410,10 @@ int FillAvatarListFromFolder(HWND list, MCONTACT hContact) int FillAvatarListFromDB(HWND list, MCONTACT hContact)
{
int max_pos = 0;
- BYTE blob[2048];
- for (MEVENT hDbEvent = db_event_first(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
+ BYTE blob[2048];
dbei.cbBlob = sizeof(blob);
dbei.pBlob = blob;
if (db_event_get(hDbEvent, &dbei) != 0) continue;
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 834cc025fa..f6d03409dd 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -194,8 +194,9 @@ void HistoryEventList::GetTempList(std::list<EventTempIndex>& tempList, bool noF EventIndex ei;
ti.isExternal = false;
ei.isExternal = false;
- MEVENT hDbEvent = db_event_first(hContact);
- while (hDbEvent != NULL) {
+
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
if (isWndLocal && !IsWindow(m_hWnd))
break;
@@ -207,7 +208,6 @@ void HistoryEventList::GetTempList(std::list<EventTempIndex>& tempList, bool noF tempList.push_back(ti);
}
}
- hDbEvent = db_event_next(hContact, hDbEvent);
}
if (!noExt) {
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 74bfa10f37..7427dc3257 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1348,12 +1348,13 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re int count = stop - start + 1;
if (count > 0) {
int index = 0;
- MEVENT hEvent = db_event_first(hContact);
+
DBEVENTINFO dbEvent = {};
char message[4096];
dbEvent.pBlob = (PBYTE)message;
- while (hEvent) {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hEvent = pCursor.FetchNext()) {
dbEvent.cbBlob = _countof(message);
if (!db_event_get(hEvent, &dbEvent)) { // if successful call
dbEvent.pBlob[dbEvent.cbBlob] = 0;
@@ -1364,7 +1365,6 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re if (index > stop)
break;
- hEvent = db_event_next(hContact, hEvent);
index++;
}
}
diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp index 4715aa8bd2..4b0e97f785 100644 --- a/plugins/HistoryLinkListPlus/src/linklist.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist.cpp @@ -65,7 +65,8 @@ static INT_PTR LinkList_Main(WPARAM hContact, LPARAM) return 0;
}
- MEVENT hEvent = db_event_first(hContact);
+ DB::ECPTR pCursor(DB::Events(hContact));
+ MEVENT hEvent = pCursor.FetchNext();
if (hEvent == NULL) {
MessageBox(nullptr, TXT_EMPTYHISTORY, TXT_PLUGINNAME, (MB_OK | MB_ICONINFORMATION));
return 0;
@@ -73,28 +74,28 @@ static INT_PTR LinkList_Main(WPARAM hContact, LPARAM) int histCount = db_event_count(hContact), actCount = 0;
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
- db_event_get(hEvent, &dbe);
- dbe.pBlob[dbe.cbBlob] = 0;
-
RECT DesktopRect;
GetWindowRect(GetDesktopWindow(), &DesktopRect);
HWND hWndProgress = CreateWindow(L"Progressbar", TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, nullptr, nullptr, g_plugin.getInst(), nullptr);
if (hWndProgress == nullptr) {
- mir_free(dbe.pBlob);
MessageBox(nullptr, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION);
return -1;
}
+
SetWindowPos(hWndProgress, HWND_TOP, (int)((DesktopRect.right / 2) - 175), (int)((DesktopRect.bottom / 2) - 22), 0, 0, SWP_NOSIZE);
ShowWindow(hWndProgress, SW_SHOW);
SetForegroundWindow(hWndProgress);
- LISTELEMENT *listStart = (LISTELEMENT*)mir_alloc(sizeof(LISTELEMENT));
+ LISTELEMENT *listStart = (LISTELEMENT *)mir_alloc(sizeof(LISTELEMENT));
memset(listStart, 0, sizeof(LISTELEMENT));
- for (;;) {
+ do {
+ DBEVENTINFO dbe = {};
+ dbe.cbBlob = db_event_getBlobSize(hEvent);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
+ db_event_get(hEvent, &dbe);
+ dbe.pBlob[dbe.cbBlob] = 0;
+
if (dbe.eventType == EVENTTYPE_MESSAGE) {
// Call function to find URIs
if (ExtractURI(&dbe, hEvent, listStart) < 0) {
@@ -108,17 +109,10 @@ static INT_PTR LinkList_Main(WPARAM hContact, LPARAM) actCount++;
if (((int)(((float)actCount / histCount) * 100.00)) % 10 == 0)
SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount / histCount) * 100.00)));
-
- hEvent = db_event_next(hContact, hEvent);
- if (hEvent == NULL)
- break;
mir_free(dbe.pBlob);
- dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
- db_event_get(hEvent, &dbe);
- dbe.pBlob[dbe.cbBlob] = 0;
}
- mir_free(dbe.pBlob);
+ while (hEvent = pCursor.FetchNext());
+
SendMessage(hWndProgress, WM_CLOSE, 0, 0);
if (ListCount(listStart) <= 0) {
RemoveList(listStart);
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 7e32d8aa4e..afd9b155bc 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -140,7 +140,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke if (eventsCnt == 0)
return;
- BOOL doDelete, unsafe = g_plugin.getByte("UnsafeMode", 0);
+ BOOL unsafe = g_plugin.getByte("UnsafeMode", 0);
BEventData *books, *item, ev = { 0 };
size_t bookcnt, btshift;
@@ -153,7 +153,8 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke GetBookmarks(hContact, &books, &bookcnt);
// Get first event
- for (MEVENT hDBEvent = db_event_first(hContact); hDBEvent != NULL; ) {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDBEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
db_event_get(hDBEvent, &dbei);
@@ -161,9 +162,9 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke // lPolicy == 1 - for time criterion, lPolicy == 2 - keep N last events, lPolicy == 3 - delete all events
if ((lPolicy == 1 && (unsigned)Criteria.time < dbei.timestamp) || (lPolicy == 2 && Criteria.keep > --eventsCnt)) break;
- doDelete = TRUE;
-
- if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && keepUnread) doDelete = FALSE; // keep unread events
+ bool doDelete = true;
+ if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && keepUnread)
+ doDelete = false; // keep unread events
if (bookcnt != 0) { // keep bookmarks
ev.hDBEvent = hDBEvent;
@@ -176,12 +177,8 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke }
}
- // find next event
- MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
if (doDelete)
- db_event_delete(hDBEvent);
-
- hDBEvent = hDBEventNext;
+ pCursor.DeleteEvent();
}
mir_free(books);
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 932f9f3778..0d795588bf 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -146,11 +146,9 @@ void __cdecl exportContactsMessages(ExportDialogData *data) list<CLDBEvent> &rclCurList = AllEvents[GetFilePathFromUser(hContact)];
- MEVENT hDbEvent = db_event_first(hContact);
- while (hDbEvent) {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext())
rclCurList.push_back(CLDBEvent(hContact, hDbEvent));
- hDbEvent = db_event_next(hContact, hDbEvent);
- }
SendMessage(hProg, PBM_SETPOS, nCur, 0);
RedrawWindow(hDlg, nullptr, nullptr, RDW_ALLCHILDREN | RDW_UPDATENOW);
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index 21bdc3dec3..4f51522157 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -89,12 +89,9 @@ void RemoveReadEvents(MCONTACT hContact = 0) void RemoveAllEvents(MCONTACT hContact)
{
- MEVENT hDBEvent = db_event_first(hContact);
- while(hDBEvent) {
- MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
- db_event_delete(hDBEvent);
- hDBEvent = hDBEventNext;
- }
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (pCursor.FetchNext())
+ pCursor.DeleteEvent();
}
void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
diff --git a/plugins/RemovePersonalSettings/src/rps.cpp b/plugins/RemovePersonalSettings/src/rps.cpp index 4b274a6a9a..91a1c56cd8 100644 --- a/plugins/RemovePersonalSettings/src/rps.cpp +++ b/plugins/RemovePersonalSettings/src/rps.cpp @@ -363,17 +363,13 @@ void RemoveUsers() hContact = db_find_first();
while (hContact != NULL) {
db_delete_contact(hContact);
-
hContact = db_find_first();
}
- // Delete events for contacts not in list
- MEVENT hDbEvent = db_event_first(0);
-
- while (hDbEvent != NULL) {
- db_event_delete(hDbEvent);
- hDbEvent = db_event_first(0);
- }
+ // Delete events from system history
+ DB::ECPTR pCursor(DB::Events(0));
+ while (pCursor.FetchNext())
+ pCursor.DeleteEvent();
// Now delete groups
DeleteSettingEx("CListGroups", nullptr);
diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp index e01f73802e..427495026c 100644 --- a/plugins/StopSpamPlus/src/utils.cpp +++ b/plugins/StopSpamPlus/src/utils.cpp @@ -14,8 +14,8 @@ tstring& GetDlgItemString(HWND hwnd, int id) bool IsExistMyMessage(MCONTACT hContact)
{
- MEVENT hDbEvent = db_event_first(hContact);
- while (hDbEvent) {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
if (db_event_get(hDbEvent, &dbei))
break;
@@ -26,7 +26,6 @@ bool IsExistMyMessage(MCONTACT hContact) // ...let the event go its way
return true;
}
- hDbEvent = db_event_next(hContact, hDbEvent);
}
return false;
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index 735e2b71d3..bc50caf32e 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -390,7 +390,8 @@ BYTE CExImContactXML::ExportEvents() int dwNumEventsAdded = 0;
// read out all events for the current contact
- for (MEVENT hDbEvent = db_event_first(_hContact); hDbEvent != NULL; hDbEvent = db_event_next(_hContact, hDbEvent)) {
+ DB::ECPTR pCursor(DB::Events(_hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
if (DB::Event::GetInfoWithData(hDbEvent, &dbei))
continue;
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 9b4c936e9d..cbd411f569 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -34,7 +34,8 @@ namespace Contact { DWORD WhenAdded(DWORD dwUIN, LPCSTR)
{
DBEVENTINFO dbei = {};
- for (MEVENT edbe = db_event_first(NULL); edbe != NULL; edbe = db_event_next(NULL, edbe)) {
+ DB::ECPTR pCursor(DB::Events(0));
+ while (MEVENT edbe = pCursor.FetchNext()) {
// get eventtype and compare
if (!DB::Event::GetInfo(edbe, &dbei) && dbei.eventType == EVENTTYPE_ADDED) {
if (!DB::Event::GetInfoWithData(edbe, &dbei)) {
|