summaryrefslogtreecommitdiff
path: root/protocols/Tlen
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
commit3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch)
treeefee912ee654baafeb98efcd117921db6b7489bc /protocols/Tlen
parentbcb27264ba737778e5d3edad36088bacf74f0236 (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/Tlen')
-rw-r--r--protocols/Tlen/src/jabber_iqid.cpp28
-rw-r--r--protocols/Tlen/src/jabber_misc.cpp18
-rw-r--r--protocols/Tlen/src/jabber_thread.cpp26
-rw-r--r--protocols/Tlen/src/tlen.cpp11
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp51
5 files changed, 55 insertions, 79 deletions
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp
index b77a367170..f0a35837c2 100644
--- a/protocols/Tlen/src/jabber_iqid.cpp
+++ b/protocols/Tlen/src/jabber_iqid.cpp
@@ -212,24 +212,22 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
listSize = listAllocSize = 0;
list = NULL;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- str = GetContactProto(hContact);
- if (str != NULL && !strcmp(str, proto->m_szModuleName)) {
- if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
- if (!JabberListExist(proto, LIST_ROSTER, dbv.pszVal)) {
- JabberLog(proto, "Syncing roster: preparing to delete %s (hContact=0x%x)", dbv.pszVal, hContact);
- if (listSize >= listAllocSize) {
- listAllocSize = listSize + 100;
- if ((list=(HANDLE *) mir_realloc(list, listAllocSize)) == NULL) {
- listSize = 0;
- break;
- }
- }
- list[listSize++] = hContact;
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
+ if ( db_get(hContact, proto->m_szModuleName, "jid", &dbv))
+ continue;
+
+ if (!JabberListExist(proto, LIST_ROSTER, dbv.pszVal)) {
+ JabberLog(proto, "Syncing roster: preparing to delete %s (hContact=0x%x)", dbv.pszVal, hContact);
+ if (listSize >= listAllocSize) {
+ listAllocSize = listSize + 100;
+ if ((list=(HANDLE *) mir_realloc(list, listAllocSize)) == NULL) {
+ listSize = 0;
+ break;
}
- db_free(&dbv);
}
+ list[listSize++] = hContact;
}
+ db_free(&dbv);
}
for (i=0; i<listSize; i++) {
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp
index c20cc63c06..73ac847836 100644
--- a/protocols/Tlen/src/jabber_misc.cpp
+++ b/protocols/Tlen/src/jabber_misc.cpp
@@ -91,19 +91,17 @@ HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid)
if (jid == NULL)
return NULL;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(proto->m_szModuleName, szProto)) {
- if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
- if ((p=dbv.pszVal) != NULL) {
- if (!stricmp(p, jid)) { // exact match (node@domain/resource)
- db_free(&dbv);
- return hContact;
- }
- }
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
+ if ( db_get(hContact, proto->m_szModuleName, "jid", &dbv))
+ continue;
+
+ if ((p=dbv.pszVal) != NULL) {
+ if (!stricmp(p, jid)) { // exact match (node@domain/resource)
db_free(&dbv);
+ return hContact;
}
}
+ db_free(&dbv);
}
return NULL;
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp
index 896bf29016..0cc09e86c4 100644
--- a/protocols/Tlen/src/jabber_thread.cpp
+++ b/protocols/Tlen/src/jabber_thread.cpp
@@ -274,18 +274,6 @@ void __cdecl JabberServerThread(ThreadData *info)
return;
}
- // Determine local IP
- /*
- socket = CallService(MS_NETLIB_GETSOCKET, (WPARAM) proto, 0);
- struct sockaddr_in saddr;
- int len;
-
- len = sizeof(saddr);
- getsockname(socket, (struct sockaddr *) &saddr, &len);
- jabberLocalIP = saddr.sin_addr.S_un.S_addr;
- JabberLog("Local IP = %s", inet_ntoa(saddr.sin_addr));
- */
-
// User may change status to OFFLINE while we are connecting above
if (info->proto->m_iDesiredStatus != ID_STATUS_OFFLINE) {
@@ -357,19 +345,15 @@ void __cdecl JabberServerThread(ThreadData *info)
Menu_ModifyItem(info->proto->hMenuChats, &mi);
// Set status to offline
+ char *szProto = info->proto->m_szModuleName;
oldStatus = info->proto->m_iStatus;
info->proto->m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
+ ProtoBroadcastAck(szProto, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
// Set all contacts to offline
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- str = GetContactProto(hContact);
- if (str != NULL && !strcmp(str, info->proto->m_szModuleName)) {
- if (db_get_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
- db_set_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
- }
- }
- }
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto))
+ if (db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
JabberListWipeSpecial(info->proto);
}
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index 8c76e78b42..19267b90c2 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -256,14 +256,9 @@ int TlenOnModulesLoaded(void *ptr, WPARAM wParam, LPARAM lParam)
TlenProtocol *proto = (TlenProtocol *)ptr;
/* Set all contacts to offline */
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, proto->m_szModuleName)) {
- if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
- db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
- }
- }
- }
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName))
+ if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
TlenMUCInit(proto);
sprintf(str, "%s", LPGEN("Incoming mail"));
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index bf18a4a5ce..9498f12ead 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -948,47 +948,48 @@ typedef struct {
static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
{
- MUCCQUERYRESULT queryResult;
DBVARIANT dbv;
MUCSENDQUERYTHREADDATA* threadData = (MUCSENDQUERYTHREADDATA*)ptr;
+ char *szProto = threadData->proto->m_szModuleName;
+
+ MUCCQUERYRESULT queryResult;
queryResult.cbSize = sizeof (MUCCQUERYRESULT);
queryResult.iType = MUCC_EVENT_QUERY_CONTACTS;
- queryResult.pszModule = threadData->proto->m_szModuleName;
+ queryResult.pszModule = szProto;
queryResult.pszParent = threadData->roomId;
queryResult.iItemsNum = 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *str = GetContactProto(hContact);
- if (str != NULL && !strcmp(str, threadData->proto->m_szModuleName)) {
- if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
- if (!db_get(hContact, threadData->proto->m_szModuleName, "jid", &dbv)) {
- if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
- queryResult.iItemsNum++;
- }
- db_free(&dbv);
- }
- }
+
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
+ if ( db_get_b(hContact, szProto, "bChat", FALSE))
+ continue;
+
+ if ( !db_get_s(hContact, szProto, "jid", &dbv)) {
+ if (strcmp(dbv.pszVal, "b73@tlen.pl"))
+ queryResult.iItemsNum++;
+
+ db_free(&dbv);
}
}
+
queryResult.pItems = (MUCCQUERYITEM*)mir_alloc(sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
memset(queryResult.pItems, 0, sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
queryResult.iItemsNum = 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *baseProto = GetContactProto(hContact);
- if (baseProto != NULL && !strcmp(baseProto, threadData->proto->m_szModuleName)) {
- if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
- if (!db_get(hContact, threadData->proto->m_szModuleName, "jid", &dbv)) {
- if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
- queryResult.pItems[queryResult.iItemsNum].pszID = mir_strdup(dbv.pszVal);
- queryResult.pItems[queryResult.iItemsNum].pszName = mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0));
- queryResult.iItemsNum++;
- }
- db_free(&dbv);
- }
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
+ if ( db_get_b(hContact, szProto, "bChat", FALSE))
+ continue;
+
+ if (!db_get(hContact, szProto, "jid", &dbv)) {
+ if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
+ queryResult.pItems[queryResult.iItemsNum].pszID = mir_strdup(dbv.pszVal);
+ queryResult.pItems[queryResult.iItemsNum].pszName = mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0));
+ queryResult.iItemsNum++;
}
+ db_free(&dbv);
}
}
+
CallService(MS_MUCC_QUERY_RESULT, 0, (LPARAM) &queryResult);
TlenMUCFreeQueryResult(&queryResult);
mir_free(threadData->roomId);