diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 14 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 11 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 29 |
3 files changed, 19 insertions, 35 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index e5acc0d84f..82cf1fb737 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -722,19 +722,13 @@ int CVkProto::IsHystoryMessageExist(MCONTACT hContact) if (!hContact)
return 0;
- MEVENT hDBEvent = db_event_first(hContact);
-
- if (!hDBEvent)
- return 0;
-
- do {
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
- db_event_get(hDBEvent, &dbei);
+ db_event_get(hDbEvent, &dbei);
if (dbei.eventType != VK_USER_DEACTIVATE_ACTION)
return 1;
-
- hDBEvent = db_event_next(hContact, hDBEvent);
- } while (hDBEvent);
+ }
return -1;
}
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index ed39bd871e..d2e92ec6f6 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -860,13 +860,12 @@ void CVkProto::NewsClearHistory() return;
time_t tTime = time(0) - m_vkOptions.iNewsAutoClearHistoryInterval;
- MEVENT hDBEvent = db_event_first(hContact);
- while (hDBEvent) {
- MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
+
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
- db_event_get(hDBEvent, &dbei);
+ db_event_get(hDbEvent, &dbei);
if (dbei.timestamp < tTime)
- db_event_delete(hDBEvent);
- hDBEvent = hDBEventNext;
+ pCursor.DeleteEvent();
}
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index aa5286312b..3e7a05a8e7 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -38,12 +38,9 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistoryForContact(WPARAM hContact, LPAR setByte(hContact, "ActiveHistoryTask", 1);
- 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();
m_bNotifyForEndLoadingHistory = true;
@@ -70,12 +67,9 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM) break;
setByte(hContact, "ActiveHistoryTask", 1);
- 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();
{
mir_cslock lck(m_csLoadHistoryTask);
@@ -86,7 +80,6 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM) db_unset(hContact, m_szModuleName, "lastmsgid");
GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, 0, 0);
-
}
return 1;
@@ -105,14 +98,12 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay) time_t tTime = time(0) - 60 * 60 * 24 * NDay;
if (NDay > 3) {
- MEVENT hDBEvent = db_event_first(hContact);
- while (hDBEvent) {
- MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
- db_event_get(hDBEvent, &dbei);
+ db_event_get(hDbEvent, &dbei);
if (dbei.timestamp > tTime && dbei.eventType != VK_USER_DEACTIVATE_ACTION)
- db_event_delete(hDBEvent);
- hDBEvent = hDBEventNext;
+ pCursor.DeleteEvent();
}
{
|