diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-12 13:40:35 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-12 13:40:35 +0000 |
commit | 8d371aa2b1fa5a7bfe835dee9b60d1407b33047b (patch) | |
tree | 66de3db76891d5676ce504d84b844e7912caa144 /plugins | |
parent | 19862a932141daf02cb0ab5cae0f1222315ff49d (diff) |
db_event_next/db_event_prev: first parameter hContact added
git-svn-id: http://svn.miranda-ng.org/main/trunk@8576 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
42 files changed, 229 insertions, 369 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index 16613e8fd8..64ff1338c0 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -433,7 +433,7 @@ int FillAvatarListFromDB(HWND list, MCONTACT hContact) {
int max_pos = 0;
BYTE blob[2048];
- for (HANDLE hDbEvent = db_event_first(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
+ for (HANDLE hDbEvent = db_event_first(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = sizeof(blob);
dbei.pBlob = blob;
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 6335a11e07..b3648456a7 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -198,8 +198,9 @@ void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter, ei.isExternal = false;
HANDLE hDbEvent = db_event_first(_hContact);
while (hDbEvent != NULL) {
- if (isWndLocal && !IsWindow( hWnd ))
+ if (isWndLocal && !IsWindow(hWnd))
break;
+
ei.hEvent = hDbEvent;
if (GetEventData(ei, data)) {
if (noFilter || CanShowHistory(&gdbei)) {
@@ -208,7 +209,7 @@ void EventList::GetTempList(std::list<EventTempIndex>& tempList, bool noFilter, tempList.push_back(ti);
}
}
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(_hContact, hDbEvent);
}
if (!noExt) {
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 4236372df8..cceb8098a7 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -477,7 +477,7 @@ INT_PTR HistoryWindow::DeleteAllUserHistory(WPARAM hContact, LPARAM) CallService(MS_DB_SETSAFETYMODE, FALSE, 0);
HANDLE hDbEvent = db_event_last(hContact);
while (hDbEvent != NULL) {
- HANDLE hPrevEvent = db_event_prev(hDbEvent);
+ HANDLE hPrevEvent = db_event_prev(hContact, hDbEvent);
hDbEvent = ( db_event_delete(hContact, hDbEvent) == 0) ? hPrevEvent : NULL;
}
CallService(MS_DB_SETSAFETYMODE, TRUE, 0);
diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index e8108e505d..1f30bcee9a 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -87,7 +87,7 @@ time_t getLastInputMsg(MCONTACT hContact) db_event_get(hDbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
return dbei.timestamp;
- hDbEvent = db_event_prev(hDbEvent);
+ hDbEvent = db_event_prev(hContact, hDbEvent);
}
return -1;
}
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index db1fe14218..c998d4400c 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -47,7 +47,6 @@ static int GetContactStatus(MCONTACT hContact) return (GetContactCachedStatus(hContact));
}
-
void cli_ChangeContactIcon(MCONTACT hContact, int iIcon, int add)
{
corecli.pfnChangeContactIcon(hContact, iIcon, add);
@@ -55,13 +54,12 @@ void cli_ChangeContactIcon(MCONTACT hContact, int iIcon, int add) static int GetStatusModeOrdering(int statusMode)
{
- int i;
- for (i=0; i < SIZEOF(statusModeOrder); i++)
- if (statusModeOrder[i].m_cache_nStatus == statusMode) return statusModeOrder[i].order;
+ for (int i=0; i < SIZEOF(statusModeOrder); i++)
+ if (statusModeOrder[i].m_cache_nStatus == statusMode)
+ return statusModeOrder[i].order;
return 1000;
}
-
DWORD CompareContacts2_getLMTime(MCONTACT hContact)
{
HANDLE hDbEvent = db_event_last(hContact);
@@ -70,7 +68,7 @@ DWORD CompareContacts2_getLMTime(MCONTACT hContact) db_event_get(hDbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT))
return dbei.timestamp;
- hDbEvent = db_event_prev(hDbEvent);
+ hDbEvent = db_event_prev(hContact, hDbEvent);
}
return 0;
}
diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index e3a7f4ca47..32131c3c8f 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -79,7 +79,7 @@ static void MF_CalcFrequency(MCONTACT hContact, DWORD dwCutoffDays, int doSleep) }
if (eventCount >= 100 || dbei.timestamp < curTime - (dwCutoffDays * 86400))
break;
- hEvent = db_event_prev(hEvent);
+ hEvent = db_event_prev(hContact, hEvent);
if (doSleep && mf_updatethread_running == FALSE)
return;
if (doSleep)
@@ -152,13 +152,11 @@ void LoadContactTree(void) DWORD INTSORT_GetLastMsgTime(MCONTACT hContact)
{
- HANDLE hDbEvent = db_event_last(hContact);
- while(hDbEvent) {
+ for (HANDLE hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, 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;
}
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 5b4eb32537..6552deb408 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1912,11 +1912,11 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re if (hEvent != NULL) {
count = 0;
while (hEvent != NULL) {
- if (!db_event_get( hEvent, &dbEvent))
+ if (!db_event_get(hEvent, &dbEvent))
if (!(dbEvent.flags & DBEF_READ))
count++;
- hEvent = db_event_next(hEvent);
+ hEvent = db_event_next(hContact, hEvent);
}
char protocol[128];
@@ -1964,7 +1964,7 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re if (!(dbEvent.flags & DBEF_READ))
AddHistoryEvent(&dbEvent, contact, reply);
- hEvent = db_event_next(hEvent);
+ hEvent = db_event_next(hContact, hEvent);
}
}
else if (_stricmp(cmd, "show") == 0) {
@@ -2024,7 +2024,7 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re if (index > stop)
break;
- hEvent = db_event_next(hEvent);
+ hEvent = db_event_next(hContact, hEvent);
index++;
}
}
diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp index 07d9597b96..d8cd064f55 100644 --- a/plugins/ContactsPlus/src/main.cpp +++ b/plugins/ContactsPlus/src/main.cpp @@ -92,15 +92,13 @@ static int HookDBEventAdded(WPARAM hContact, LPARAM lParam) static void ProcessUnreadEvents(void)
{
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (hDbEvent) {
+ for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, 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(hContact, (LPARAM)hDbEvent);
}
- hDbEvent = db_event_next(hDbEvent);
}
}
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 3c237c98a4..5f02dd2586 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -349,14 +349,14 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindLastEvent(MCONTACT contactID) return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsLastEvent;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindNextEvent(HANDLE hDbEvent)
+STDMETHODIMP_(HANDLE) CDb3Mmap::FindNextEvent(MCONTACT contactID, HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
return (dbe->signature != DBEVENT_SIGNATURE) ? 0 : (HANDLE)dbe->ofsNext;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindPrevEvent(HANDLE hDbEvent)
+STDMETHODIMP_(HANDLE) CDb3Mmap::FindPrevEvent(MCONTACT contactID, HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index d1e44e56cd..f2793e3c7c 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -218,8 +218,8 @@ public: STDMETHODIMP_(HANDLE) FindFirstEvent(MCONTACT contactID);
STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(MCONTACT contactID);
STDMETHODIMP_(HANDLE) FindLastEvent(MCONTACT contactID);
- STDMETHODIMP_(HANDLE) FindNextEvent(HANDLE hDbEvent);
- STDMETHODIMP_(HANDLE) FindPrevEvent(HANDLE hDbEvent);
+ STDMETHODIMP_(HANDLE) FindNextEvent(MCONTACT contactID, HANDLE hDbEvent);
+ STDMETHODIMP_(HANDLE) FindPrevEvent(MCONTACT contactID, HANDLE hDbEvent);
STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index a42bf9b13a..2ba319b59a 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -85,7 +85,7 @@ void CContactCache::Rebuild() info->hContact = hContact;
info->rate = 0;
- for (HANDLE hEvent = db_event_last(hContact); hEvent; hEvent = db_event_prev(hEvent)) {
+ for (HANDLE hEvent = db_event_last(hContact); hEvent; hEvent = db_event_prev(hContact, hEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
if (!db_event_get(hEvent, &dbei)) {
if (float weight = GetEventWeight(timestamp - dbei.timestamp))
diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp index d6e9ace26f..0609c89971 100644 --- a/plugins/HistoryLinkListPlus/src/linklist.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist.cpp @@ -176,7 +176,7 @@ static INT_PTR LinkList_Main(WPARAM hContact, LPARAM) if ( ((int)(((float)actCount/histCount)*100.00)) % 10 == 0 )
SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount/histCount)*100.00)));
- hEvent = db_event_next(hEvent);
+ hEvent = db_event_next(hContact, hEvent);
if ( hEvent == NULL )
break;
diff --git a/plugins/HistoryPlusPlus/HistoryForm.pas b/plugins/HistoryPlusPlus/HistoryForm.pas index 0ce99caf3d..3cec81369e 100644 --- a/plugins/HistoryPlusPlus/HistoryForm.pas +++ b/plugins/HistoryPlusPlus/HistoryForm.pas @@ -593,7 +593,7 @@ procedure THistoryFrm.LoadHistory(Sender: TObject); ToRead := Max(0, HistoryLength - hppFirstLoadBlock - 1);
LineIdx := HistoryLength - 2;
repeat
- hDBEvent := db_event_prev(hDBEvent);
+ hDBEvent := db_event_prev(hContact,hDBEvent);
History[LineIdx] := NotZero(hDBEvent);
{ if NeedhDBEvent = hDbEvent then begin
Result := HistoryLength-LineIdx-1;
@@ -1490,7 +1490,7 @@ begin begin
if History[ridx] <> 0 then
break;
- hDBEvent := db_event_prev(hDBEvent);
+ hDBEvent := db_event_prev(hContact,hDBEvent);
History[ridx] := NotZero(hDBEvent);
end;
end
@@ -1508,7 +1508,7 @@ begin begin
if History[ridx] <> 0 then
break;
- hDBEvent := db_event_next(hDBEvent);
+ hDBEvent := db_event_next(hContact,hDBEvent);
History[ridx] := NotZero(hDBEvent);
end;
end;
@@ -2050,7 +2050,7 @@ begin begin
if Sessions[idx].hDBEventLast = hDBEvent then
begin
- hDBEvent := db_event_prev(hDBEvent);
+ hDBEvent := db_event_prev(hContact,hDBEvent);
if hDBEvent <> 0 then
begin
Sessions[idx].hDBEventLast := hDBEvent;
diff --git a/plugins/HistoryPlusPlus/hpp_external.pas b/plugins/HistoryPlusPlus/hpp_external.pas index 39eeff99fd..5c61e363fb 100644 --- a/plugins/HistoryPlusPlus/hpp_external.pas +++ b/plugins/HistoryPlusPlus/hpp_external.pas @@ -177,7 +177,7 @@ begin not boolean(event.dwFlags and IEEF_NO_SCROLLING));
if eventCount > 0 then Dec(eventCount);
if eventCount <> 0 then
- hDBNext := db_event_next(hDBNext);
+ hDBNext := db_event_next(event.hContact,hDBNext);
end;
ExtGrid.EndUpdate;
end;
diff --git a/plugins/HistoryPlusPlus/hpp_services.pas b/plugins/HistoryPlusPlus/hpp_services.pas index 05821743bc..3ffda00576 100644 --- a/plugins/HistoryPlusPlus/hpp_services.pas +++ b/plugins/HistoryPlusPlus/hpp_services.pas @@ -193,7 +193,7 @@ begin sel := -1;
while (hDbEvent <> oep.hDbEvent) and (hDbEvent <> 0) do
begin
- hDbEvent := db_event_prev(hDbEvent);
+ hDbEvent := db_event_prev(oep.hContact,hDbEvent);
Inc(item);
end;
if hDbEvent = oep.hDbEvent then
diff --git a/plugins/HistoryStats/src/mirandacontact.cpp b/plugins/HistoryStats/src/mirandacontact.cpp index ee967f1065..4e9ddc482a 100644 --- a/plugins/HistoryStats/src/mirandacontact.cpp +++ b/plugins/HistoryStats/src/mirandacontact.cpp @@ -36,7 +36,7 @@ void MirandaContact::fetchSlot(int i) stripMetaID(ei.dbe);
- ci.hEvent = db_event_next(ci.hEvent);
+ ci.hEvent = db_event_next(ci.hContact, ci.hEvent);
}
void MirandaContact::stripMetaID(DBEVENTINFO& dbe)
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 827481ad65..23687bb7c8 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -183,7 +183,7 @@ void SweepHistoryFromContact(MCONTACT hContact, CriteriaStruct Criteria, BOOL ke }
// find next event
- HANDLE hDBEventNext = db_event_next(hDBEvent);
+ HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
if (doDelete)
db_event_delete(hContact, hDBEvent);
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 827c6dac52..0f035c6ebd 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -333,19 +333,19 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (dbei.cbBlob == 0xFFFFFFFF) {
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(event->hContact, hDbEvent);
continue;
}
dbei.pBlob = (PBYTE) malloc(dbei.cbBlob);
db_event_get( hDbEvent, &dbei);
if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL)) {
db_event_markRead(event->hContact, hDbEvent);
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM) event->hContact, (LPARAM) hDbEvent);
+ CallService(MS_CLIST_REMOVEEVENT, event->hContact, (LPARAM)hDbEvent);
}
if (!isDbEventShown(&dbei)) {
free(dbei.pBlob);
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(event->hContact, hDbEvent);
continue;
}
eventData = new IEVIEWEVENTDATA;
@@ -411,7 +411,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) prevEventData = eventData;
newEvent.count++;
event->hDbEventFirst = hDbEvent;
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(event->hContact, hDbEvent);
}
appendEventNew(view, &newEvent);
for ( IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL; eventData2 = eventData) {
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 3c9e413a22..cc005be35d 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -431,7 +431,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC break;
// Get next event
- hEvent = srcDb->FindNextEvent(hEvent);
+ hEvent = srcDb->FindNextEvent(hContact, hEvent);
i++;
}
mir_free(eventBuf);
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index b6946665ab..79e92bb9cf 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -139,7 +139,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) return TRUE;
// find event with another timestamp
- hExistingDbEvent = db_event_next(hPreviousDbEvent);
+ hExistingDbEvent = db_event_next(hContact, hPreviousDbEvent);
while (hExistingDbEvent != NULL) {
ZeroMemory(&dbeiExisting, sizeof(dbeiExisting));
dbeiExisting.cbSize = sizeof(dbeiExisting);
@@ -153,7 +153,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) }
hPreviousDbEvent = hExistingDbEvent;
- hExistingDbEvent = db_event_next(hExistingDbEvent);
+ hExistingDbEvent = db_event_next(hContact, hExistingDbEvent);
}
}
@@ -186,7 +186,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) }
// Get previous event in chain
- hExistingDbEvent = db_event_prev(hExistingDbEvent);
+ hExistingDbEvent = db_event_prev(hContact, hExistingDbEvent);
}
}
else {
@@ -216,7 +216,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) }
// Get next event in chain
- hExistingDbEvent = db_event_next(hExistingDbEvent);
+ hExistingDbEvent = db_event_next(hContact, hExistingDbEvent);
}
}
// reset last event
diff --git a/plugins/ImportTXT/ImportThrd.pas b/plugins/ImportTXT/ImportThrd.pas index f743b10e5b..31e185bf90 100644 --- a/plugins/ImportTXT/ImportThrd.pas +++ b/plugins/ImportTXT/ImportThrd.pas @@ -154,7 +154,7 @@ begin exit;
end;
// get the previous
- hExistingDbEvent := db_event_prev(hExistingDbEvent);
+ hExistingDbEvent := db_event_prev(hContact,hExistingDbEvent);
end;
end;
end;
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 243042486f..16f00fbdc9 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -346,12 +346,12 @@ static void FlashThreadFunction() }
-BOOL checkMsgTimestamp(HANDLE hEventCurrent, DWORD timestampCurrent)
+BOOL checkMsgTimestamp(MCONTACT hContact, HANDLE hEventCurrent, DWORD timestampCurrent)
{
if (!bFlashIfMsgOlder)
return TRUE;
- for (HANDLE hEvent = db_event_prev(hEventCurrent); hEvent; hEvent = db_event_prev(hEvent)) {
+ for (HANDLE hEvent = db_event_prev(hContact, hEventCurrent); hEvent; hEvent = db_event_prev(hContact, hEvent)) {
DBEVENTINFO einfo = { sizeof(einfo) };
if(!db_event_get(hEvent, &einfo)) {
if ((einfo.timestamp + wSecondsOlder) <= timestampCurrent)
@@ -418,7 +418,7 @@ static int PluginMessageEventHook(WPARAM hContact, LPARAM lParam) //get DBEVENTINFO without pBlob
DBEVENTINFO einfo = { sizeof(einfo) };
if (!db_event_get(hEvent, &einfo) && !(einfo.flags & DBEF_SENT))
- if ((einfo.eventType == EVENTTYPE_MESSAGE && bFlashOnMsg && checkOpenWindow(hContact) && checkMsgTimestamp(hEvent, einfo.timestamp)) ||
+ if ((einfo.eventType == EVENTTYPE_MESSAGE && bFlashOnMsg && checkOpenWindow(hContact) && checkMsgTimestamp(hContact, hEvent, einfo.timestamp)) ||
(einfo.eventType == EVENTTYPE_URL && bFlashOnURL) ||
(einfo.eventType == EVENTTYPE_FILE && bFlashOnFile) ||
(einfo.eventType != EVENTTYPE_MESSAGE && einfo.eventType != EVENTTYPE_URL && einfo.eventType != EVENTTYPE_FILE && bFlashOnOther)) {
diff --git a/plugins/MirandaG15/src/CChatScreen.cpp b/plugins/MirandaG15/src/CChatScreen.cpp index 875331a02d..f519baaae8 100644 --- a/plugins/MirandaG15/src/CChatScreen.cpp +++ b/plugins/MirandaG15/src/CChatScreen.cpp @@ -314,18 +314,18 @@ void CChatScreen::LoadHistory() LHandles.push_front(hEvent);
if(CConfig::GetBoolSetting(SESSION_LOADDB) && *(LHandles.begin()) == hUnread)
break;
- hEvent = db_event_prev(hEvent);
+ hEvent = db_event_prev(m_hContact, hEvent);
}
}
else
{
for (int i = CConfig::GetIntSetting(SESSION_LOGSIZE); i > 0 && hEvent!=NULL; i--)
{
- LHandles.push_front(hEvent);
- hEvent = db_event_prev(hEvent);
+ LHandles.push_front(hEvent);
+ hEvent = db_event_prev(m_hContact, hEvent);
}
}
-
+
bool bRead = true;
while(!(LHandles.empty()))
{
@@ -361,7 +361,8 @@ bool CChatScreen::Update() if(!m_bCloseTimer && CConfig::GetIntSetting(SESSION_CLOSETIMER) != 0) {
m_bCloseTimer = true;
m_dwCloseTimer = GetTickCount();
- } else if(CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
+ }
+ else if(CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
m_bCloseTimer = false;
CAppletManager::GetInstance()->ActivateEventScreen();
return true;
diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp index fad2ae47a5..904090ddd8 100644 --- a/plugins/MirandaG15/src/CContactList.cpp +++ b/plugins/MirandaG15/src/CContactList.cpp @@ -929,7 +929,7 @@ void CContactList::UpdateMessageCounter(CListEntry<CContactListEntry*,CContactLi pEntry->iMessages++;
if(hLastEvent == hEvent)
break;
- hLastEvent = db_event_prev(hLastEvent);
+ hLastEvent = db_event_prev(pEntry->hHandle, hLastEvent);
}
}
if(pEntry->iMessages >= 100)
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 6c8041c7d9..499e0c7f16 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -209,10 +209,8 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected ) for (int nCur = 0 ; nCur < nTotalContacts ; nCur++ )
{
if (bOnlySelected )
- {
if ( !(ListView_GetItemState( hMapUser, nCur, LVIS_SELECTED) & LVIS_SELECTED))
continue;
- }
sItem.iItem = nCur;
if(!ListView_GetItem(hMapUser, &sItem))
@@ -228,7 +226,7 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected ) HANDLE hDbEvent = db_event_first(hContact);
while( hDbEvent) {
rclCurList.push_back(CLDBEvent(hContact, hDbEvent));
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
}
SendMessage( hProg, PBM_SETPOS, nCur, 0);
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index d58176e3f7..e235c3d159 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -328,7 +328,7 @@ VOID CheckCurrentFeed(MCONTACT hContact) MesExist = TRUE;
break;
}
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
mir_free(olddbei.pBlob);
mir_free(pszTemp);
}
@@ -573,7 +573,7 @@ VOID CheckCurrentFeed(MCONTACT hContact) char *pszTemp = mir_utf8encodeT(message);
if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char *)olddbei.pBlob, pszTemp))
MesExist = TRUE;
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
mir_free(olddbei.pBlob);
mir_free(pszTemp);
}
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index 82fc7ce945..52fab9f724 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -101,7 +101,7 @@ void RemoveAllEvents(MCONTACT hContact) {
HANDLE hDBEvent = db_event_first(hContact);
while(hDBEvent) {
- HANDLE hDBEventNext = db_event_next(hDBEvent);
+ HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
db_event_delete(hContact, hDBEvent);
hDBEvent = hDBEventNext;
}
diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index 28c92978d5..a90c9da616 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -386,7 +386,7 @@ INT_PTR OnMenuCommandShowList(WPARAM wParam, LPARAM lParam) curEvent = db_event_last(curContact);
if (curEvent != NULL) {
- for ( ; curEvent != NULL; curEvent = db_event_prev(curEvent)) {
+ for ( ; curEvent != NULL; curEvent = db_event_prev(curContact, curEvent)) {
dbe.cbBlob = 1;
if (db_event_get(curEvent, &dbe) != 0) {
curEvent = NULL;
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index 4ae291fdef..6637f05733 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -135,7 +135,7 @@ void RestoreUnreadMessageAlerts(void) DBEVENTINFO dbei = { sizeof(dbei) };
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
+ for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, 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)))
@@ -143,7 +143,7 @@ void RestoreUnreadMessageAlerts(void) handleNewMessage(hContact,(LPARAM)hDbEvent);
}
- for (HANDLE hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
+ for (HANDLE hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(NULL, 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)))
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 64744ac421..7257c4f69d 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -258,7 +258,7 @@ void SetStatusIcon(struct SrmmWindowData *dat) MCONTACT hContact = dat->windowData.hContact;
if (!strcmp(dat->szProto, META_PROTO) && db_get_b(NULL,"CLC","Meta",0) == 0) {
- hContact = (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)dat->windowData.hContact, 0);
+ hContact = CallService(MS_MC_GETMOSTONLINECONTACT, dat->windowData.hContact, 0);
if (hContact != NULL)
szProto = GetContactProto(hContact);
else
@@ -618,7 +618,7 @@ static void UpdateReadChars(HWND hwndDlg, SrmmWindowData *dat) void ShowAvatar(HWND hwndDlg, SrmmWindowData *dat)
{
- INT_PTR res = CallService(MS_AV_GETAVATARBITMAP, (WPARAM)dat->windowData.hContact, 0);
+ INT_PTR res = CallService(MS_AV_GETAVATARBITMAP, dat->windowData.hContact, 0);
dat->ace = res != CALLSERVICE_NOTFOUND ? (AVATARCACHEENTRY*)res : NULL;
dat->avatarPic = (dat->ace != NULL && (dat->ace->dwFlags & AVS_HIDEONCLIST) == 0) ? dat->ace->hbmPic : NULL;
SendMessage(hwndDlg, WM_SIZE, 0, 0);
@@ -680,7 +680,7 @@ static void NotifyTyping(struct SrmmWindowData *dat, int mode) // End user check
dat->nTypeMode = mode;
- CallService(MS_PROTO_SELFISTYPING, (WPARAM) dat->windowData.hContact, dat->nTypeMode);
+ CallService(MS_PROTO_SELFISTYPING, dat->windowData.hContact, dat->nTypeMode);
}
static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -848,7 +848,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback2);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE | ENM_REQUESTRESIZE);
if (dat->windowData.hContact && dat->szProto) {
- int nMax = CallProtoService(dat->szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, (LPARAM)dat->windowData.hContact);
+ int nMax = CallProtoService(dat->szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, dat->windowData.hContact);
if (nMax)
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, (WPARAM) nMax, 0);
}
@@ -881,57 +881,51 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (DbEventIsMessageOrCustom(&dbei) && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT))
notifyUnread = true;
}
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ HANDLE hPrevEvent;
switch (historyMode) {
case LOADHISTORY_COUNT:
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- HANDLE hPrevEvent;
- for (int i = db_get_w(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i > 0; i--) {
- if (dat->hDbEventFirst == NULL)
- hPrevEvent = db_event_last(dat->windowData.hContact);
- else
- hPrevEvent = db_event_prev(dat->hDbEventFirst);
- if (hPrevEvent == NULL)
- break;
- dbei.cbBlob = 0;
- dat->hDbEventFirst = hPrevEvent;
- db_event_get(dat->hDbEventFirst, &dbei);
- if (!DbEventIsShown(&dbei, dat))
- i++;
- }
+ for (int i = db_get_w(NULL, SRMMMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT); i > 0; i--) {
+ if (dat->hDbEventFirst == NULL)
+ hPrevEvent = db_event_last(dat->windowData.hContact);
+ else
+ hPrevEvent = db_event_prev(dat->windowData.hContact, dat->hDbEventFirst);
+ if (hPrevEvent == NULL)
+ break;
+ dbei.cbBlob = 0;
+ dat->hDbEventFirst = hPrevEvent;
+ db_event_get(dat->hDbEventFirst, &dbei);
+ if (!DbEventIsShown(&dbei, dat))
+ i++;
}
break;
case LOADHISTORY_TIME:
- {
- HANDLE hPrevEvent;
- DBEVENTINFO dbei = { sizeof(dbei) };
-
- if (dat->hDbEventFirst == NULL) {
- dbei.timestamp = time(NULL);
- hPrevEvent = db_event_last(dat->windowData.hContact);
- }
- else {
- db_event_get(dat->hDbEventFirst, &dbei);
- hPrevEvent = db_event_prev(dat->hDbEventFirst);
- }
- DWORD firstTime = dbei.timestamp - 60 * db_get_w(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
- for (;;) {
- if (hPrevEvent == NULL)
- break;
- dbei.cbBlob = 0;
- db_event_get( hPrevEvent, &dbei);
- if (dbei.timestamp < firstTime)
- break;
- if (DbEventIsShown(&dbei, dat))
- dat->hDbEventFirst = hPrevEvent;
- hPrevEvent = db_event_prev(hPrevEvent);
- }
- break;
+ if (dat->hDbEventFirst == NULL) {
+ dbei.timestamp = time(NULL);
+ hPrevEvent = db_event_last(dat->windowData.hContact);
+ }
+ else {
+ db_event_get(dat->hDbEventFirst, &dbei);
+ hPrevEvent = db_event_prev(dat->windowData.hContact, dat->hDbEventFirst);
}
+ DWORD firstTime = dbei.timestamp - 60 * db_get_w(NULL, SRMMMOD, SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
+ for (;;) {
+ if (hPrevEvent == NULL)
+ break;
+ dbei.cbBlob = 0;
+ db_event_get(hPrevEvent, &dbei);
+ if (dbei.timestamp < firstTime)
+ break;
+ if (DbEventIsShown(&dbei, dat))
+ dat->hDbEventFirst = hPrevEvent;
+ hPrevEvent = db_event_prev(dat->windowData.hContact, hPrevEvent);
+ }
+ break;
}
}
- SendMessage(dat->hwndParent, CM_ADDCHILD, (WPARAM) hwndDlg, (LPARAM)dat->windowData.hContact);
+ SendMessage(dat->hwndParent, CM_ADDCHILD, (WPARAM)hwndDlg, dat->windowData.hContact);
{
HANDLE hdbEvent = db_event_last(dat->windowData.hContact);
if (hdbEvent) {
@@ -943,7 +937,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
}
}
- while ((hdbEvent = db_event_prev(hdbEvent)));
+ while ((hdbEvent = db_event_prev(dat->windowData.hContact, hdbEvent)));
}
}
SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0);
@@ -966,7 +960,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case DM_GETCONTEXTMENU:
{
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) dat->windowData.hContact, 0);
+ HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)hMenu);
}
return TRUE;
@@ -974,7 +968,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_CONTEXTMENU:
if (dat->hwndParent == (HWND) wParam) {
POINT pt;
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) dat->windowData.hContact, 0);
+ HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -1024,7 +1018,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename));
AddToFileList(&ppFiles, &totalCount, szFilename);
}
- CallServiceSync(MS_FILE_SENDSPECIFICFILEST, (WPARAM)dat->windowData.hContact, (LPARAM)ppFiles);
+ CallServiceSync(MS_FILE_SENDSPECIFICFILEST, dat->windowData.hContact, (LPARAM)ppFiles);
for(i=0;ppFiles[i];i++) mir_free(ppFiles[i]);
mir_free(ppFiles);
}
@@ -1274,8 +1268,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP 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 = db_event_next(hDbEvent);
+ CallService(MS_CLIST_REMOVEEVENT, dat->windowData.hContact, (LPARAM)hDbEvent);
+ hDbEvent = db_event_next(dat->windowData.hContact, hDbEvent);
}
}
if (dat->showUnread) {
@@ -1401,7 +1395,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->hDbUnreadEventFirst = hDbEvent;
dat->lastMessage = dbei.timestamp;
SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
- if (GetForegroundWindow()==dat->hwndParent && dat->parent->hwndActive == hwndDlg)
+ 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))
@@ -1409,7 +1403,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (IsAutoPopup(dat->windowData.hContact))
SendMessage(GetParent(hwndDlg), CM_POPUPWINDOW, 1, (LPARAM)hwndDlg);
}
- if (hDbEvent != dat->hDbEventFirst && db_event_next(hDbEvent) == NULL)
+ if (hDbEvent != dat->hDbEventFirst && db_event_next(dat->windowData.hContact, hDbEvent) == NULL)
SendMessage(hwndDlg, DM_APPENDTOLOG, WPARAM(hDbEvent), 0);
else
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 247f60ceb8..f2798c44b4 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -797,7 +797,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG }
if (dat->buffer)
dat->hDbEventLast = dat->hDbEvent;
- dat->hDbEvent = db_event_next(dat->hDbEvent);
+ dat->hDbEvent = db_event_next(dat->hContact, dat->hDbEvent);
if (--dat->eventsToInsert == 0)
break;
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index b5aad3f530..cbd8b96559 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -295,7 +295,7 @@ static void RestoreUnreadMessageAlerts(void) CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)& cle);
}
}
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
}
}
}
diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp index 54bbdcea1e..0f939bb946 100644 --- a/plugins/StopSpamPlus/src/utils.cpp +++ b/plugins/StopSpamPlus/src/utils.cpp @@ -26,7 +26,7 @@ bool IsExistMyMessage(MCONTACT hContact) // ...let the event go its way
return true;
}
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
}
return false;
}
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 3c5fa197b0..b0a2f456c0 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1628,7 +1628,7 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam) if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
return;
- if ( !DbEventIsShown(dat, &dbei))
+ if (!DbEventIsShown(dat, &dbei))
return;
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) {
@@ -1667,7 +1667,7 @@ void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam) dat->cache->updateStats(TSessionStats::UPDATE_WITH_LAST_RCV, 0);
if (hDbEvent != dat->hDbEventFirst) {
- HANDLE nextEvent = db_event_next(hDbEvent);
+ HANDLE nextEvent = db_event_next(dat->hContact, hDbEvent);
if (1 || nextEvent == 0) {
if (!(dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED))
SendMessage(hwndDlg, DM_APPENDTOLOG, lParam, 0);
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 891042ecde..2b67db3486 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -592,7 +592,7 @@ void CGlobals::RestoreUnreadMessageAlerts(void) cle.ptszTooltip = toolTip;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
}
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
}
}
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index b2a5898ec1..9598cab24f 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1465,7 +1465,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP EnableSendButton(dat, TRUE);
}
- for (HANDLE hdbEvent = db_event_last(dat->hContact); hdbEvent; hdbEvent = db_event_prev(hdbEvent)) {
+ for (HANDLE hdbEvent = db_event_last(dat->hContact); hdbEvent; hdbEvent = db_event_prev(dat->hContact, hdbEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hdbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index ee8378c24c..df5d69b4c5 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -1385,7 +1385,7 @@ void TSAPI FindFirstEvent(TWindowData *dat) if (dat->hDbEventFirst == NULL)
hPrevEvent = db_event_last(dat->hContact);
else
- hPrevEvent = db_event_prev(dat->hDbEventFirst);
+ hPrevEvent = db_event_prev(dat->hContact, dat->hDbEventFirst);
if (hPrevEvent == NULL)
break;
dbei.cbBlob = 0;
@@ -1411,7 +1411,7 @@ void TSAPI FindFirstEvent(TWindowData *dat) if (dat->hDbEventFirst == NULL)
hPrevEvent = db_event_last(dat->hContact);
else
- hPrevEvent = db_event_prev(dat->hDbEventFirst);
+ hPrevEvent = db_event_prev(dat->hContact, dat->hDbEventFirst);
if (hPrevEvent == NULL)
break;
dbei.cbBlob = 0;
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index a0960614c7..00ba701c84 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1167,7 +1167,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 = db_event_next(dat->hDbEvent);
+ dat->hDbEvent = db_event_next(dat->hContact, dat->hDbEvent);
if (--dat->eventsToInsert == 0)
break;
}
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index ad64b02afe..8bb06815d4 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -28,10 +28,8 @@ bool DBGetContactSettingAsString(MCONTACT hContact, const char *szModuleName, co if (!szModuleName || !szSettingName)
return false;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- switch(dbv.type)
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ switch (dbv.type) {
case DBVT_BYTE:
_itot(dbv.bVal, buff, 10);
break;
@@ -54,7 +52,6 @@ bool DBGetContactSettingAsString(MCONTACT hContact, const char *szModuleName, co if (dbv.pwszVal) wcsncpy(buff, dbv.pwszVal, bufflen);
buff[bufflen - 1] = 0;
break;
-
}
db_free(&dbv);
@@ -90,10 +87,8 @@ void StripBBCodesInPlace(TCHAR *swzText) size_t iRead = 0, iWrite = 0;
size_t iLen = _tcslen(swzText);
- while(iRead <= iLen) // copy terminating null too
- {
- while(iRead <= iLen && swzText[iRead] != '[')
- {
+ while(iRead <= iLen) { // copy terminating null too
+ while (iRead <= iLen && swzText[iRead] != '[') {
if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead];
iRead++; iWrite++;
}
@@ -105,22 +100,19 @@ void StripBBCodesInPlace(TCHAR *swzText) iRead += 3;
else if (iLen - iRead >= 4 && (_tcsnicmp(swzText + iRead, _T("[/b]"), 4) == 0 || _tcsnicmp(swzText + iRead, _T("[/i]"), 4) == 0))
iRead += 4;
- else if (iLen - iRead >= 6 && (_tcsnicmp(swzText + iRead, _T("[color"), 6) == 0))
- {
- while(iRead < iLen && swzText[iRead] != ']') iRead++;
+ else if (iLen - iRead >= 6 && (_tcsnicmp(swzText + iRead, _T("[color"), 6) == 0)) {
+ while (iRead < iLen && swzText[iRead] != ']') iRead++;
iRead++;// skip the ']'
}
else if (iLen - iRead >= 8 && (_tcsnicmp(swzText + iRead, _T("[/color]"), 8) == 0))
iRead += 8;
- else if (iLen - iRead >= 5 && (_tcsnicmp(swzText + iRead, _T("[size"), 5) == 0))
- {
- while(iRead < iLen && swzText[iRead] != ']') iRead++;
+ else if (iLen - iRead >= 5 && (_tcsnicmp(swzText + iRead, _T("[size"), 5) == 0)) {
+ while (iRead < iLen && swzText[iRead] != ']') iRead++;
iRead++;// skip the ']'
}
else if (iLen - iRead >= 7 && (_tcsnicmp(swzText + iRead, _T("[/size]"), 7) == 0))
iRead += 7;
- else
- {
+ else {
if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead];
iRead++; iWrite++;
}
@@ -129,14 +121,11 @@ void StripBBCodesInPlace(TCHAR *swzText) DWORD LastMessageTimestamp(MCONTACT hContact)
{
- HANDLE hDbEvent = db_event_last(hContact);
- while (hDbEvent) {
+ for (HANDLE hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, 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;
@@ -155,14 +144,9 @@ void FormatTimestamp(DWORD ts, char *szFormat, TCHAR *buff, int bufflen) bool Uid(MCONTACT hContact, char *szProto, TCHAR *buff, int bufflen)
{
- char *tmpProto = NULL;
-
- if (hContact) tmpProto = GetContactProto(hContact);
- else tmpProto = szProto;
-
- if (tmpProto)
- {
- char *szUid = ( char* )CallProtoService(tmpProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ char *tmpProto = (hContact) ? tmpProto = GetContactProto(hContact) : szProto;
+ if (tmpProto) {
+ char *szUid = (char*)CallProtoService(tmpProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if (szUid && (INT_PTR)szUid != CALLSERVICE_NOTFOUND)
return DBGetContactSettingAsString(hContact, tmpProto, szUid, buff, bufflen);
}
@@ -172,11 +156,9 @@ bool Uid(MCONTACT hContact, char *szProto, TCHAR *buff, int bufflen) bool UidName(char *szProto, TCHAR *buff, int bufflen)
{
- if (szProto)
- {
- char *szUidName = ( char* )CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
- if (szUidName && (INT_PTR)szUidName != CALLSERVICE_NOTFOUND)
- {
+ if (szProto) {
+ char *szUidName = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
+ if (szUidName && (INT_PTR)szUidName != CALLSERVICE_NOTFOUND) {
a2t(szUidName, buff, bufflen);
return true;
}
@@ -186,8 +168,7 @@ bool UidName(char *szProto, TCHAR *buff, int bufflen) TCHAR *GetLastMessageText(MCONTACT hContact)
{
- HANDLE hDbEvent = db_event_last(hContact);
- while (hDbEvent) {
+ for (HANDLE hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
@@ -203,8 +184,6 @@ TCHAR *GetLastMessageText(MCONTACT hContact) StripBBCodesInPlace(swzMsg);
return swzMsg;
}
-
- hDbEvent = db_event_prev(hDbEvent);
}
return 0;
@@ -212,37 +191,26 @@ TCHAR *GetLastMessageText(MCONTACT hContact) bool CanRetrieveStatusMsg(MCONTACT hContact, char *szProto)
{
- if (opt.bGetNewStatusMsg)
- {
+ if (opt.bGetNewStatusMsg) {
int iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0);
WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- if ((CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && (iFlags & Proto_Status2Flag(wStatus)))
- {
+ if ((CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && (iFlags & Proto_Status2Flag(wStatus))) {
iFlags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & (PF1_VISLIST | PF1_INVISLIST);
- if (opt.bDisableIfInvisible && iFlags)
- {
+ if (opt.bDisableIfInvisible && iFlags) {
int iVisMode = db_get_w(hContact, szProto, "ApparentMode", 0);
int wProtoStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if ((iVisMode == ID_STATUS_OFFLINE) || (wProtoStatus == ID_STATUS_INVISIBLE && iVisMode != ID_STATUS_ONLINE))
return false;
- else
- return true;
- }
- else
- {
return true;
}
- }
- else
- {
- return false;
+ return true;
}
}
return false;
}
-TCHAR *GetStatusMessageText(MCONTACT hContact)
+TCHAR* GetStatusMessageText(MCONTACT hContact)
{
TCHAR *swzMsg = 0;
DBVARIANT dbv;
@@ -263,16 +231,12 @@ TCHAR *GetStatusMessageText(MCONTACT hContact) }
}
- if (!swzMsg)
- {
+ if (!swzMsg) {
if (CanRetrieveStatusMsg(hContact, szProto))
- {
if (CallContactService(hContact, PSS_GETAWAYMSG, 0, 0))
return NULL;
- }
- if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv))
- {
+ if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) {
if (dbv.ptszVal && _tcslen(dbv.ptszVal) != 0)
swzMsg = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
@@ -289,30 +253,23 @@ TCHAR *GetStatusMessageText(MCONTACT hContact) bool GetSysSubstText(MCONTACT hContact, TCHAR *swzRawSpec, TCHAR *buff, int bufflen)
{
if (!_tcscmp(swzRawSpec, _T("uid")))
- {
return Uid(hContact, 0, buff, bufflen);
- }
- else if (!_tcscmp(swzRawSpec, _T("proto")))
- {
+
+ if (!_tcscmp(swzRawSpec, _T("proto"))) {
char *szProto = GetContactProto(hContact);
- if (szProto)
- {
+ if (szProto) {
a2t(szProto, buff, bufflen);
return true;
}
}
- else if (!_tcscmp(swzRawSpec, _T("account")))
- {
- char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEACCOUNT, hContact, 0);
- if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND)
- {
+ else if (!_tcscmp(swzRawSpec, _T("account"))) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, hContact, 0);
+ if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) {
return GetSysSubstText(hContact, _T("proto"), buff, bufflen);
}
- else if (szProto)
- {
+ else if (szProto) {
PROTOACCOUNT *pa = ProtoGetAccount(szProto);
- if (pa && pa->tszAccountName)
- {
+ if (pa && pa->tszAccountName) {
_tcsncpy(buff, pa->tszAccountName, bufflen);
return true;
}
@@ -320,90 +277,77 @@ bool GetSysSubstText(MCONTACT hContact, TCHAR *swzRawSpec, TCHAR *buff, int buff return GetSysSubstText(hContact, _T("proto"), buff, bufflen);
}
}
- else if (!_tcscmp(swzRawSpec, _T("time")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("time"))) {
if (tmi.printDateTime && !tmi.printDateTimeByContact(hContact, _T("t"), buff, bufflen, TZF_KNOWNONLY))
return true;
}
- else if (!_tcscmp(swzRawSpec, _T("uidname")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("uidname"))) {
char *szProto = GetContactProto(hContact);
return UidName(szProto, buff, bufflen);
}
- else if (!_tcscmp(swzRawSpec, _T("status_msg")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("status_msg"))) {
TCHAR *swzMsg = GetStatusMessageText(hContact);
- if (swzMsg)
- {
+ if (swzMsg) {
_tcsncpy(buff, swzMsg, bufflen);
mir_free(swzMsg);
return true;
}
}
- else if (!_tcscmp(swzRawSpec, _T("last_msg")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("last_msg"))) {
TCHAR *swzMsg = GetLastMessageText(hContact);
- if (swzMsg)
- {
+ if (swzMsg) {
_tcsncpy(buff, swzMsg, bufflen);
mir_free(swzMsg);
return true;
}
}
- else if (!_tcscmp(swzRawSpec, _T("meta_subname")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("meta_subname"))) {
// get contact list name of active subcontact
HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false;
- TCHAR *swzNick = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hSubContact, GCDNF_TCHAR);
+ TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hSubContact, GCDNF_TCHAR);
if (swzNick) _tcsncpy(buff, swzNick, bufflen);
return true;
}
- else if (!_tcscmp(swzRawSpec, _T("meta_subuid")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("meta_subuid"))) {
MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND)
return false;
return Uid(hSubContact, 0, buff, bufflen);
}
- else if (!_tcscmp(swzRawSpec, _T("meta_subproto")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("meta_subproto"))) {
// get protocol of active subcontact
MCONTACT hSubContact = (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND)
return false;
return GetSysSubstText(hSubContact, _T("account"), buff, bufflen);
}
- else if (!_tcscmp(swzRawSpec, _T("last_msg_time")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("last_msg_time"))) {
DWORD ts = LastMessageTimestamp(hContact);
if (ts == 0) return false;
FormatTimestamp(ts, "t", buff, bufflen);
return true;
}
- else if (!_tcscmp(swzRawSpec, _T("last_msg_date")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("last_msg_date"))) {
DWORD ts = LastMessageTimestamp(hContact);
if (ts == 0) return false;
FormatTimestamp(ts, "d", buff, bufflen);
return true;
}
- else if (!_tcscmp(swzRawSpec, _T("last_msg_reltime")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("last_msg_reltime"))) {
DWORD ts = LastMessageTimestamp(hContact);
if (ts == 0) return false;
DWORD t = (DWORD)time(0);
DWORD diff = (t - ts);
int d = (diff / 60 / 60 / 24);
int h = (diff - d * 60 * 60 * 24) / 60 / 60;
- int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (d > 0) mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m);
else if (h > 0) mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m);
else mir_sntprintf(buff, bufflen, TranslateT("%dm"), m);
return true;
}
- else if (!_tcscmp(swzRawSpec, _T("msg_count_all")) || !_tcscmp(swzRawSpec, _T("msg_count_out")) || !_tcscmp(swzRawSpec, _T("msg_count_in")))
- {
+ else if (!_tcscmp(swzRawSpec, _T("msg_count_all")) || !_tcscmp(swzRawSpec, _T("msg_count_out")) || !_tcscmp(swzRawSpec, _T("msg_count_in"))) {
DWORD dwCountOut, dwCountIn;
DWORD dwMetaCountOut = 0, dwMetaCountIn = 0;
DWORD dwLastTs, dwNewTs, dwRecountTs;
@@ -448,7 +392,7 @@ bool GetSysSubstText(MCONTACT hContact, TCHAR *swzRawSpec, TCHAR *buff, int buff else break;
}
}
- dbe = db_event_prev(dbe);
+ dbe = db_event_prev(hTmpContact, dbe);
}
if (dwNewTs > dwLastTs) {
@@ -477,33 +421,25 @@ bool GetSubstText(MCONTACT hContact, const DISPLAYSUBST &ds, TCHAR *buff, int bu {
TranslateFunc *transFunc = 0;
for (int i = 0; i < iTransFuncsCount; i++)
- {
- if (translations[i].id == (DWORD)ds.iTranslateFuncId)
- {
+ if (translations[i].id == (DWORD)ds.iTranslateFuncId) {
transFunc = translations[i].transFunc;
break;
}
- }
if (!transFunc)
return false;
- switch (ds.type)
- {
- case DVT_DB:
- return transFunc(hContact, ds.szModuleName, ds.szSettingName, buff, bufflen) != 0;
- case DVT_PROTODB:
- {
- char *szProto = GetContactProto(hContact);
- if (szProto)
- {
- if (transFunc(hContact, szProto, ds.szSettingName, buff, bufflen) != 0)
- return true;
- else
- return transFunc(hContact, "UserInfo", ds.szSettingName, buff, bufflen) != 0;
- }
- break;
+ switch (ds.type) {
+ case DVT_DB:
+ return transFunc(hContact, ds.szModuleName, ds.szSettingName, buff, bufflen) != 0;
+ case DVT_PROTODB:
+ char *szProto = GetContactProto(hContact);
+ if (szProto) {
+ if (transFunc(hContact, szProto, ds.szSettingName, buff, bufflen) != 0)
+ return true;
+ return transFunc(hContact, "UserInfo", ds.szSettingName, buff, bufflen) != 0;
}
+ break;
}
return false;
}
@@ -511,30 +447,19 @@ bool GetSubstText(MCONTACT hContact, const DISPLAYSUBST &ds, TCHAR *buff, int bu bool GetRawSubstText(MCONTACT hContact, char *szRawSpec, TCHAR *buff, int bufflen)
{
size_t lenght = strlen(szRawSpec);
- for (size_t i = 0; i < lenght; i++)
- {
- if (szRawSpec[i] == '/')
- {
+ for (size_t i = 0; i < lenght; i++) {
+ if (szRawSpec[i] == '/') {
szRawSpec[i] = 0;
- if (strlen(szRawSpec) == 0)
- {
+ if (strlen(szRawSpec) == 0) {
char *szProto = GetContactProto(hContact);
- if (szProto)
- {
+ if (szProto) {
if (translations[0].transFunc(hContact, szProto, &szRawSpec[i + 1], buff, bufflen) != 0)
return true;
- else
- return translations[0].transFunc(hContact, "UserInfo", &szRawSpec[i + 1], buff, bufflen) != 0;
+ return translations[0].transFunc(hContact, "UserInfo", &szRawSpec[i + 1], buff, bufflen) != 0;
}
- else
- {
- return false;
- }
- }
- else
- {
- return translations[0].transFunc(hContact, szRawSpec, &szRawSpec[i + 1], buff, bufflen) != 0;
+ return false;
}
+ return translations[0].transFunc(hContact, szRawSpec, &szRawSpec[i + 1], buff, bufflen) != 0;
}
}
return false;
@@ -560,30 +485,20 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF TCHAR swzVName[LABEL_LEN];
TCHAR swzRep[VALUE_LEN], swzAlt[VALUE_LEN];
- while (si < iSourceLen && di < (size_t)iDestLen - 1)
- {
- if (swzVarSrc[si] == _T('%'))
- {
+ while (si < iSourceLen && di < (size_t)iDestLen - 1) {
+ if (swzVarSrc[si] == _T('%')) {
si++;
v = 0;
- while (si < iSourceLen && v < LABEL_LEN)
- {
+ while (si < iSourceLen && v < LABEL_LEN) {
if (swzVarSrc[si] == _T('%'))
- {
- // two %'s in a row in variable name disabled: e.g. %a%%b% - this is atbbguous]
- //if (si + 1 < iSourceLen && swzVarSrc[si + 1] == _T('%')) {
- // si++; // skip first %, allow following code to add the second one to the variable name
- //} else
- break;
- }
+ break;
+
swzVName[v] = swzVarSrc[si];
v++; si++;
}
if (v == 0) // bSubst len is 0 - just a % symbol
- {
swzDest[di] = _T('%');
- }
else if (si < iSourceLen) // we found end %
{
swzVName[v] = 0;
@@ -593,18 +508,14 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF // apply only to specific protocols
TCHAR *p = _tcsrchr(swzVName, _T('^')); // use last '^', so if you want a ^ in swzAlt text, you can just put a '^' on the end
- if (p)
- {
+ if (p) {
*p = 0;
p++;
- if (*p)
- {
+ if (*p) {
char *cp = GetContactProto(hContact);
- if (cp != NULL)
- {
+ if (cp != NULL) {
PROTOACCOUNT *acc = ProtoGetAccount(cp);
- if (acc != NULL)
- {
+ if (acc != NULL) {
cp = acc->szProtoName;
}
}
@@ -613,8 +524,7 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF goto empty;
bool negate = false;
- if (*p == _T('!'))
- {
+ if (*p == _T('!')) {
p++;
if (*p == 0) goto error;
negate = true;
@@ -627,15 +537,13 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF TCHAR *last = _tcsrchr(p, _T(','));
if (!last) last = p;
- while (p <= last + 1)
- {
+ while (p <= last + 1) {
len = (int)_tcscspn(p, _T(","));
t2a(p, sproto, len);
sproto[len] = 0;
p += len + 1;
- if (_stricmp(cp, sproto) == 0)
- {
+ if (_stricmp(cp, sproto) == 0) {
spec = true;
break;
}
@@ -649,28 +557,23 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF // get alternate text, if bSubst fails
swzAlt[0] = 0;
p = _tcschr(swzVName, _T('|')); // use first '|' - so you can use the '|' symbol in swzAlt text
- if (p)
- {
+ if (p) {
*p = 0; // clip swzAlt from swzVName
p++;
- if (_tcslen(p) > 4 && _tcsncmp(p, _T("raw:"), 4) == 0) // raw db substitution
- {
+ if (_tcslen(p) > 4 && _tcsncmp(p, _T("raw:"), 4) == 0) { // raw db substitution
char raw_spec[LABEL_LEN];
p += 4;
t2a(p, raw_spec, LABEL_LEN);
GetRawSubstText(hContact, raw_spec, swzAlt, VALUE_LEN);
}
- else if (_tcslen(p) > 4 && _tcsncmp(p, _T("sys:"), 4) == 0) // 'system' substitution
- {
+ else if (_tcslen(p) > 4 && _tcsncmp(p, _T("sys:"), 4) == 0) { // 'system' substitution
p += 4;
GetSysSubstText(hContact, p, swzAlt, VALUE_LEN);
}
- else
- {
+ else {
// see if we can find the bSubst
DSListNode *ds_node = opt.dsList;
- while(ds_node)
- {
+ while (ds_node) {
if (_tcscmp(ds_node->ds.swzName, p) == 0)
break;
@@ -678,11 +581,8 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF }
if (ds_node)
- {
GetSubstText(hContact, ds_node->ds, swzAlt, VALUE_LEN);
- }
- else
- {
+ else {
_tcsncpy(swzAlt, p, VALUE_LEN);
bAltSubst = true;
}
@@ -703,12 +603,10 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF {
bSubst = GetSysSubstText(hContact, &swzVName[4], swzRep, VALUE_LEN);
}
- else
- {
+ else {
// see if we can find the bSubst
DSListNode *ds_node = opt.dsList;
- while(ds_node)
- {
+ while (ds_node) {
if (_tcscmp(ds_node->ds.swzName, swzVName) == 0)
break;
@@ -721,33 +619,22 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF bSubst = GetSubstText(hContact, ds_node->ds, swzRep, VALUE_LEN);
}
- if (bSubst)
- {
+ if (bSubst) {
size_t rep_len = _tcslen(swzRep);
_tcsncpy(&swzDest[di], swzRep, min(rep_len, iDestLen - di));
di += rep_len - 1; // -1 because we inc at bottom of loop
}
- else if (bAltSubst)
- {
+ else if (bAltSubst) {
size_t alt_len = _tcslen(swzAlt);
_tcsncpy(&swzDest[di], swzAlt, min(alt_len, iDestLen - di));
di += alt_len - 1; // -1 because we inc at bottom of loop
}
- else
- {
- goto empty; // empty value
- }
-
+ else goto empty; // empty value
}
else // no end % - error
- {
goto error;
- }
- }
- else
- {
- swzDest[di] = swzVarSrc[si];
}
+ else swzDest[di] = swzVarSrc[si];
si++;
di++;
@@ -756,8 +643,7 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF mir_free(swzVarSrc);
swzDest[di] = 0;
- if (parseTipperVarsFirst)
- {
+ if (parseTipperVarsFirst) {
swzVarSrc = variables_parsedup((TCHAR *)swzDest, 0, hContact);
_tcscpy(swzDest, swzVarSrc);
mir_free(swzVarSrc);
@@ -765,8 +651,7 @@ bool ApplySubst(MCONTACT hContact, const TCHAR *swzSource, bool parseTipperVarsF // check for a 'blank' string - just spaces etc
- for (si = 0; si <= di; si++)
- {
+ for (si = 0; si <= di; si++) {
if (swzDest[si] != 0 && swzDest[si] != _T(' ') && swzDest[si] != _T('\t') && swzDest[si] != _T('\r') && swzDest[si] != _T('\n'))
return true;
}
@@ -796,10 +681,8 @@ bool GetValueText(MCONTACT hContact, const DISPLAYITEM &di, TCHAR *buff, int buf void TruncateString(TCHAR *swzText)
{
- if (swzText && opt.iLimitCharCount > 3)
- {
- if ((int)_tcslen(swzText) > opt.iLimitCharCount)
- {
+ if (swzText && opt.iLimitCharCount > 3) {
+ if ((int)_tcslen(swzText) > opt.iLimitCharCount) {
swzText[opt.iLimitCharCount - 3] = 0;
_tcscat(swzText, _T("..."));
}
@@ -818,24 +701,19 @@ TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus) TCHAR *swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR);
if ((INT_PTR)swzText == CALLSERVICE_NOTFOUND)
- {
swzText = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, 0);
- }
- else if (swzText == NULL)
- {
+ else if (swzText == NULL) {
// try to use service without SGMA_TCHAR
char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0);
- if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND)
- {
+ if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND) {
swzText = mir_a2t(tmpMsg);
mir_free(tmpMsg);
}
}
- if (swzText && !swzText[0])
- {
+ if (swzText && !swzText[0]) {
mir_free(swzText);
swzText = NULL;
}
@@ -854,15 +732,13 @@ TCHAR *GetProtoExtraStatusTitle(char *szProto) if (!szProto)
return NULL;
- if (!db_get_ts(0, szProto, "XStatusName", &dbv))
- {
+ if (!db_get_ts(0, szProto, "XStatusName", &dbv)) {
if (_tcslen(dbv.ptszVal) != 0)
swzText = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
}
- if (!swzText)
- {
+ if (!swzText) {
TCHAR buff[256];
if (EmptyXStatusToDefaultName(0, szProto, 0, buff, 256))
swzText = mir_tstrdup(buff);
@@ -876,12 +752,11 @@ TCHAR *GetProtoExtraStatusTitle(char *szProto) TCHAR *GetProtoExtraStatusMessage(char *szProto)
{
- DBVARIANT dbv;
- TCHAR *swzText = NULL;
-
if (!szProto)
return NULL;
+ TCHAR *swzText = NULL;
+ DBVARIANT dbv;
if (!db_get_ts(0, szProto, "XStatusMsg", &dbv)) {
if (_tcslen(dbv.ptszVal) != 0)
swzText = mir_tstrdup(dbv.ptszVal);
@@ -890,7 +765,7 @@ TCHAR *GetProtoExtraStatusMessage(char *szProto) if (ServiceExists(MS_VARS_FORMATSTRING)) {
MCONTACT hContact = db_find_first();
char *proto = GetContactProto(hContact);
- while(!proto) {
+ while (!proto) {
hContact = db_find_next(hContact);
if (hContact)
proto = GetContactProto(hContact);
@@ -920,8 +795,7 @@ TCHAR *GetListeningTo(char *szProto) if (!szProto)
return NULL;
- if (!db_get_ts(0, szProto, "ListeningTo", &dbv))
- {
+ if (!db_get_ts(0, szProto, "ListeningTo", &dbv)) {
if (_tcslen(dbv.ptszVal) != 0)
swzText = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
@@ -937,14 +811,13 @@ TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szV {
DBVARIANT dbv;
TCHAR *swzText = NULL;
- char szSetting[128];
if (!szProto)
return NULL;
+ char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, szSlot, szValue);
- if (!db_get_ts(0, "AdvStatus", szSetting, &dbv))
- {
+ if (!db_get_ts(0, "AdvStatus", szSetting, &dbv)) {
if (_tcslen(dbv.ptszVal) != 0)
swzText = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
@@ -960,14 +833,13 @@ HICON GetJabberActivityIcon(MCONTACT hContact, char *szProto) {
DBVARIANT dbv;
HICON hIcon = NULL;
- char szSetting[128];
if (!szProto)
return NULL;
+ char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, "activity", "icon");
- if (!db_get_s(hContact, "AdvStatus", szSetting, &dbv))
- {
+ if (!db_get_s(hContact, "AdvStatus", szSetting, &dbv)) {
hIcon = Skin_GetIcon(dbv.pszVal);
db_free(&dbv);
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index b2c2bf80d4..1cb964a2ac 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -401,7 +401,7 @@ BYTE CExImContactXML::ExportEvents() DWORD cbEventBuf = 0, dwNumEventsAdded = 0;
// read out all events for the current contact
- for (HANDLE hDbEvent = db_event_first(_hContact); hDbEvent != NULL; hDbEvent = db_event_next(hDbEvent)) {
+ for (HANDLE hDbEvent = db_event_first(_hContact); hDbEvent != NULL; hDbEvent = db_event_next(_hContact, hDbEvent)) {
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
if (DB::Event::GetInfoWithData(hDbEvent, &dbei))
continue;
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 4a06374b8d..f91969d216 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -91,7 +91,7 @@ BYTE Delete(MCONTACT hContact) DWORD WhenAdded(DWORD dwUIN, LPCSTR pszProto)
{
DBEVENTINFO dbei = { sizeof(dbei) };
- for (HANDLE edbe = db_event_first(NULL); edbe != NULL; edbe = db_event_next(edbe)) {
+ for (HANDLE edbe = db_event_first(NULL); edbe != NULL; edbe = db_event_next(NULL, edbe)) {
// get eventtype and compare
if (!DB::Event::GetInfo(edbe, &dbei) && dbei.eventType == EVENTTYPE_ADDED) {
if (!DB::Event::GetInfoWithData(edbe, &dbei)) {
@@ -690,7 +690,7 @@ bool Exists(MCONTACT hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei) }
if (hDbExistingEvent) {
HANDLE sdbe = hDbExistingEvent;
- for (HANDLE edbe = sdbe; edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp <= edbei.timestamp); edbe = db_event_prev(edbe)) {
+ for (HANDLE edbe = sdbe; edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp <= edbei.timestamp); edbe = db_event_prev(hContact, edbe)) {
hDbExistingEvent = edbe;
//compare without data (faster)
if ( result = IsEqual(dbei, &edbei, false)) {
@@ -706,7 +706,7 @@ bool Exists(MCONTACT hContact, HANDLE& hDbExistingEvent, DBEVENTINFO *dbei) } /*end for*/
if (!result) {
- for (HANDLE edbe = db_event_next(sdbe); edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp >= edbei.timestamp); edbe = db_event_next(edbe)) {
+ for (HANDLE edbe = db_event_next(hContact, sdbe); edbe && !GetInfo(edbe, &edbei) && (dbei->timestamp >= edbei.timestamp); edbe = db_event_next(hContact, edbe)) {
hDbExistingEvent = edbe;
//compare without data (faster)
if (result = IsEqual(dbei, &edbei, false)) {
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 726e6f2755..30e48f5db5 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -519,9 +519,9 @@ static HANDLE findDbEvent(MCONTACT hContact, HANDLE hDbEvent, int flags) else if (flags & DBE_LAST)
hDbEvent = db_event_last(hContact);
else if (flags & DBE_NEXT)
- hDbEvent = db_event_next(hDbEvent);
+ hDbEvent = db_event_next(hContact, hDbEvent);
else if (flags & DBE_PREV)
- hDbEvent = db_event_prev(hDbEvent);
+ hDbEvent = db_event_prev(hContact, hDbEvent);
}
else {
HANDLE hMatchEvent, hSearchEvent;
|