diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-09 21:40:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-09 21:40:22 +0000 |
commit | 3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch) | |
tree | efee912ee654baafeb98efcd117921db6b7489bc /protocols/JabberG/src/jabber_util.cpp | |
parent | bcb27264ba737778e5d3edad36088bacf74f0236 (diff) |
- the kernel filters out contacts by proto names much faster than a plugin;
- database cycles simplified
git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_util.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 96 |
1 files changed, 44 insertions, 52 deletions
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 2f5a02f792..35acf12005 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -72,27 +72,23 @@ void CJabberProto::Log(const char* fmt, ...) HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
{
if (jid == NULL)
- return (HANDLE)NULL;
+ return NULL;
- HANDLE hContactMatched = NULL;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
- DBVARIANT dbv;
- int result = JGetStringT(hContact, "ChatRoomID", &dbv);
- if (result)
- result = JGetStringT(hContact, "jid", &dbv);
-
- if ( !result) {
- int result;
- result = lstrcmpi(jid, dbv.ptszVal);
- db_free(&dbv);
- if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0) {
- hContactMatched = hContact;
- break;
- } } } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ int result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ if (result)
+ result = JGetStringT(hContact, "jid", &dbv);
- return hContactMatched;
+ if ( !result) {
+ int result;
+ result = lstrcmpi(jid, dbv.ptszVal);
+ db_free(&dbv);
+ if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0)
+ return hContact;
+ } }
+
+ return NULL;
}
///////////////////////////////////////////////////////////////////////////////
@@ -105,44 +101,40 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource) JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid);
- HANDLE hContactMatched = NULL;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ int result;
+ //safer way to check UID (coz some contact have both setting from convert to chat)
+ if (db_get_b(hContact, m_szModuleName, "ChatRoom",0))
+ result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ else
+ result = JGetStringT(hContact, "jid", &dbv);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
- DBVARIANT dbv;
+ if ( !result) {
int result;
- //safer way to check UID (coz some contact have both setting from convert to chat)
- if (db_get_b(hContact, szProto, "ChatRoom",0))
- result = JGetStringT(hContact, "ChatRoomID", &dbv);
- else
- result = JGetStringT(hContact, "jid", &dbv);
-
- if ( !result) {
- int result;
- if (item != NULL)
- result = lstrcmpi(jid, dbv.ptszVal);
- else {
- if (bStripResource == 3) {
- if (JGetByte(hContact, "ChatRoom", 0))
- result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
- else if (TRUE)
- result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
- else
- result = JabberCompareJids(jid, dbv.ptszVal);
- }
- // most probably it should just look full matching contact
+ if (item != NULL)
+ result = lstrcmpi(jid, dbv.ptszVal);
+ else {
+ if (bStripResource == 3) {
+ if (JGetByte(hContact, "ChatRoom", 0))
+ result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
+ else if (TRUE)
+ result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
else
- result = lstrcmpi(jid, dbv.ptszVal);
-
+ result = JabberCompareJids(jid, dbv.ptszVal);
}
- db_free(&dbv);
- if ( !result) {
- hContactMatched = hContact;
- break;
- } } } }
+ // most probably it should just look full matching contact
+ else
+ result = lstrcmpi(jid, dbv.ptszVal);
- return hContactMatched;
+ }
+ db_free(&dbv);
+ if ( !result)
+ return hContact;
+ }
+ }
+
+ return NULL;
}
TCHAR* __stdcall JabberNickFromJID(const TCHAR *jid)
|