diff options
Diffstat (limited to 'protocols/Tlen/src')
-rw-r--r-- | protocols/Tlen/src/jabber_iqid.cpp | 8 | ||||
-rw-r--r-- | protocols/Tlen/src/jabber_misc.cpp | 17 | ||||
-rw-r--r-- | protocols/Tlen/src/jabber_thread.cpp | 5 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen.cpp | 7 | ||||
-rw-r--r-- | protocols/Tlen/src/tlen_muc.cpp | 11 |
5 files changed, 18 insertions, 30 deletions
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp index a94630b628..b77a367170 100644 --- a/protocols/Tlen/src/jabber_iqid.cpp +++ b/protocols/Tlen/src/jabber_iqid.cpp @@ -145,7 +145,6 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) XmlNode *itemNode, *groupNode;
JABBER_SUBSCRIPTION sub;
JABBER_LIST_ITEM *item;
- HANDLE hContact;
char *jid, *name, *nick;
int i, oldStatus;
@@ -166,6 +165,7 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) nick = JabberLocalNickFromJID(jid);
}
if (nick != NULL) {
+ HANDLE hContact;
item = JabberListAdd(proto, LIST_ROSTER, jid);
if (item->nick) mir_free(item->nick);
item->nick = nick;
@@ -211,8 +211,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) listSize = listAllocSize = 0;
list = NULL;
- hContact = db_find_first();
- while (hContact != 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)) {
@@ -230,8 +230,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
+
for (i=0; i<listSize; i++) {
JabberLog(proto, "Syncing roster: deleting 0x%x", list[i]);
CallService(MS_DB_CONTACT_DELETE, (WPARAM) list[i], 0);
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp index 30ec49b67d..c20cc63c06 100644 --- a/protocols/Tlen/src/jabber_misc.cpp +++ b/protocols/Tlen/src/jabber_misc.cpp @@ -85,32 +85,27 @@ char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact) HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid)
{
- HANDLE hContact, hContactMatched;
DBVARIANT dbv;
char *szProto;
char *p;
- if (jid == NULL) return (HANDLE) NULL;
- hContactMatched = NULL;
- hContact = db_find_first();
- while (hContact != NULL) {
+ 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)
- hContactMatched = hContact;
db_free(&dbv);
- break;
+ return hContact;
}
}
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
- }
- if (hContactMatched != NULL) {
- return hContactMatched;
}
+
return NULL;
}
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp index ce4a95f539..896bf29016 100644 --- a/protocols/Tlen/src/jabber_thread.cpp +++ b/protocols/Tlen/src/jabber_thread.cpp @@ -107,7 +107,6 @@ void __cdecl JabberServerThread(ThreadData *info) char *buffer;
int datalen;
XmlState xmlState;
- HANDLE hContact;
int jabberNetworkBufferSize;
int oldStatus = ID_STATUS_OFFLINE;
int reconnectMaxTime;
@@ -363,15 +362,13 @@ void __cdecl JabberServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
// Set all contacts to offline
- hContact = db_find_first();
- while (hContact != NULL) {
+ 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);
}
}
- hContact = db_find_next(hContact);
}
JabberListWipeSpecial(info->proto);
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index 34e03d3071..8c76e78b42 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -252,20 +252,19 @@ INT_PTR TlenMenuHandleInbox(void *ptr, LPARAM wParam, LPARAM lParam) int TlenOnModulesLoaded(void *ptr, WPARAM wParam, LPARAM lParam)
{
-
char str[128];
TlenProtocol *proto = (TlenProtocol *)ptr;
/* Set all contacts to offline */
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+
+ 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);
}
}
- hContact = db_find_next(hContact);
}
+
TlenMUCInit(proto);
sprintf(str, "%s", LPGEN("Incoming mail"));
SkinAddNewSoundEx("TlenMailNotify", proto->m_szModuleName, str);
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index c43ee11edd..bf18a4a5ce 100644 --- a/protocols/Tlen/src/tlen_muc.cpp +++ b/protocols/Tlen/src/tlen_muc.cpp @@ -948,7 +948,6 @@ typedef struct { static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
{
- HANDLE hContact;
MUCCQUERYRESULT queryResult;
DBVARIANT dbv;
MUCSENDQUERYTHREADDATA* threadData = (MUCSENDQUERYTHREADDATA*)ptr;
@@ -957,8 +956,8 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) queryResult.pszModule = threadData->proto->m_szModuleName;
queryResult.pszParent = threadData->roomId;
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ 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)) {
@@ -970,13 +969,12 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) }
}
}
- hContact = db_find_next(hContact);
}
queryResult.pItems = (MUCCQUERYITEM*)mir_alloc(sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
memset(queryResult.pItems, 0, sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ 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)) {
@@ -990,7 +988,6 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) }
}
}
- hContact = db_find_next(hContact);
}
CallService(MS_MUCC_QUERY_RESULT, 0, (LPARAM) &queryResult);
TlenMUCFreeQueryResult(&queryResult);
|