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 --- protocols/JabberG/src/jabber_archive.cpp | 30 ++++++++++++++---------------- protocols/JabberG/src/jabber_misc.cpp | 7 +++---- protocols/JabberG/src/jabber_proto.cpp | 30 +++++++++++++----------------- protocols/JabberG/src/jabber_rc.cpp | 22 ++++++++++------------ protocols/JabberG/src/jabber_thread.cpp | 14 ++++++-------- 5 files changed, 46 insertions(+), 57 deletions(-) (limited to 'protocols/JabberG') 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) { -- cgit v1.2.3