summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-05-17 19:23:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-05-17 19:23:37 +0000
commit1d9fd398b75a5a6eca9d40db2e2abb60c96ebc7d (patch)
tree8d216553e534f6f34be4374741709aba73fc1739 /protocols
parentc2914d5759e0ba8a3b9a81c8a1f071dba90094b4 (diff)
some more fixes for MS_DB_CONTACT_DELETE & loops
git-svn-id: http://svn.miranda-ng.org/main/trunk@4710 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/AimOscar/src/server.cpp3
-rw-r--r--protocols/FacebookRM/src/contacts.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp39
-rw-r--r--protocols/Tlen/src/jabber_iqid.cpp60
-rw-r--r--protocols/Twitter/src/contacts.cpp4
-rw-r--r--protocols/Twitter/src/proto.cpp5
-rw-r--r--protocols/Xfire/src/main.cpp4
8 files changed, 42 insertions, 81 deletions
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp
index 883905bd86..67af63c1f2 100644
--- a/protocols/AimOscar/src/server.cpp
+++ b/protocols/AimOscar/src/server.cpp
@@ -994,8 +994,7 @@ void CAimProto::delete_ssi_list(SNAC &snac, int &offset)
HANDLE hContact = contact_from_sn(name);
- switch (type)
- {
+ switch (type) {
case 0x0000: //buddy record
for(i=1;;++i)
{
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index d1eaad91cd..b332c48d8d 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -121,9 +121,9 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, (LPARAM)IGNOREEVENT_USERONLINE);
return hContact;
- } else {
- CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
}
+
+ CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
}
return 0;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index 1fd94d1fd1..b619ae97ac 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -143,13 +143,15 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
list_remove(&chats, chat, 1);
// Remove contact from contact list (duh!) should be done by chat.dll !!
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; ) {
+ HANDLE hNext = db_find_next(hContact);
DBVARIANT dbv;
if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR)) {
if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
db_free(&dbv);
}
+ hContact = hNext;
}
return 1;
}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 3dbfd2d69d..104470416d 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -492,10 +492,8 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
db_unset(hContact, "CList", "Hidden");
chatRooms.insert(hContact);
- } else
- {
- UpdateSubscriptionInfo(hContact, item);
}
+ else UpdateSubscriptionInfo(hContact, item);
if ( !m_options.IgnoreRosterGroups) {
if (item->group != NULL) {
@@ -533,32 +531,15 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
// Delete orphaned contacts (if roster sync is enabled)
if (m_options.RosterSync == TRUE) {
- int listSize = 0, listAllocSize = 0;
- HANDLE* list = NULL;
- for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- if ( !ListExist(LIST_ROSTER, dbv.ptszVal)) {
- Log("Syncing roster: preparing to delete %S (hContact=0x%x)", dbv.ptszVal, hContact);
- if (listSize >= listAllocSize) {
- listAllocSize = listSize + 100;
- if ((list=(HANDLE *) mir_realloc(list, listAllocSize * sizeof(HANDLE))) == NULL) {
- listSize = 0;
- break;
- } }
-
- list[listSize++] = hContact;
- }
- db_free(&dbv);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; ) {
+ HANDLE hNext = db_find_next(hContact, m_szModuleName);
+ ptrT jid( db_get_tsa(hContact, m_szModuleName, "jid"));
+ if (jid != NULL && !ListExist(LIST_ROSTER, jid)) {
+ Log("Syncing roster: preparing to delete %S (hContact=0x%x)", jid, hContact);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
+ hContact = hNext;
}
-
- for (i=0; i < listSize; i++) {
- Log("Syncing roster: deleting 0x%x", list[i]);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)list[i], 0);
- }
- if (list != NULL)
- mir_free(list);
}
EnableMenuItems(TRUE);
@@ -567,10 +548,10 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
m_bModeMsgStatusChangePending = FALSE;
SetServerStatus(m_iDesiredStatus);
- if (m_options.AutoJoinConferences) {
+ if (m_options.AutoJoinConferences)
for (i=0; i < chatRooms.getCount(); i++)
GroupchatJoinByHContact((HANDLE)chatRooms[i], true);
- }
+
chatRooms.destroy();
//UI_SAFE_NOTIFY(m_pDlgJabberJoinGroupchat, WM_JABBER_CHECK_ONLINE);
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp
index f0a35837c2..4e39b0fe06 100644
--- a/protocols/Tlen/src/jabber_iqid.cpp
+++ b/protocols/Tlen/src/jabber_iqid.cpp
@@ -159,11 +159,11 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
else sub = SUB_NONE;
//if (str != NULL && (!strcmp(str, "to") || !strcmp(str, "both"))) {
if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) {
- if ((name=JabberXmlGetAttrValue(itemNode, "name")) != NULL) {
+ if ((name=JabberXmlGetAttrValue(itemNode, "name")) != NULL)
nick = JabberTextDecode(name);
- } else {
+ else
nick = JabberLocalNickFromJID(jid);
- }
+
if (nick != NULL) {
HANDLE hContact;
item = JabberListAdd(proto, LIST_ROSTER, jid);
@@ -186,8 +186,7 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
db_set_s(hContact, "CList", "Group", item->group);
db_free(&dbv);
}
- else
- db_set_s(hContact, "CList", "Group", item->group);
+ else db_set_s(hContact, "CList", "Group", item->group);
}
else {
item->group = NULL;
@@ -204,54 +203,33 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
}
}
}
+
// Delete orphaned contacts (if roster sync is enabled)
if (db_get_b(NULL, proto->m_szModuleName, "RosterSync", FALSE) == TRUE) {
- HANDLE *list;
- int listSize, listAllocSize;
-
- listSize = listAllocSize = 0;
- list = NULL;
-
- 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;
- }
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; ) {
+ HANDLE hNext = hContact = db_find_next(hContact, proto->m_szModuleName);
+ ptrA jid( db_get_sa(hContact, proto->m_szModuleName, "jid"));
+ if (jid != NULL) {
+ if (!JabberListExist(proto, LIST_ROSTER, jid)) {
+ JabberLog(proto, "Syncing roster: deleting 0x%x", hContact);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
- list[listSize++] = hContact;
}
- db_free(&dbv);
- }
-
- for (i=0; i<listSize; i++) {
- JabberLog(proto, "Syncing roster: deleting 0x%x", list[i]);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) list[i], 0);
+ hContact = hNext;
}
- if (list != NULL)
- mir_free(list);
- }
- ///////////////////////////////////////
- {
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_FLAGS;
- Menu_ModifyItem(proto->hMenuMUC, &mi);
- if (proto->hMenuChats != NULL)
- Menu_ModifyItem(proto->hMenuChats, &mi);
}
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_FLAGS;
+ Menu_ModifyItem(proto->hMenuMUC, &mi);
+ if (proto->hMenuChats != NULL)
+ Menu_ModifyItem(proto->hMenuChats, &mi);
+
proto->isOnline = TRUE;
JabberLog(proto, "Status changed via THREADSTART");
oldStatus = proto->m_iStatus;
JabberSendPresence(proto, proto->m_iDesiredStatus);
ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus);
- //////////////////////////////////
}
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 3d4d7f9d58..f5568c9a9a 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -272,11 +272,9 @@ HANDLE TwitterProto::AddToClientList(const char *name,const char *status)
db_free(&dbv);
}
-
return hContact;
}
- else
- CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
+ CallService(MS_DB_CONTACT_DELETE,(WPARAM)hContact,0);
}
return 0;
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 5a1aa801f6..deeb0f88c7 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -503,9 +503,12 @@ void TwitterProto::UpdateSettings()
if(in_chat_)
OnLeaveChat(0,0);
- for(HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ for(HANDLE hContact = db_find_first(m_szModuleName); hContact; ) {
+ HANDLE hNext = db_find_next(hContact, m_szModuleName);
if(db_get_b(hContact,m_szModuleName,"ChatRoom",0))
CallService(MS_DB_CONTACT_DELETE,reinterpret_cast<WPARAM>(hContact),0);
+ hContact = hNext;
+ }
}
}
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
index c01716807b..a0b336ffd6 100644
--- a/protocols/Xfire/src/main.cpp
+++ b/protocols/Xfire/src/main.cpp
@@ -1867,7 +1867,7 @@ void CList_MakeAllOffline()
}
//alle gefundenen handles lsöchen
- for(uint i=0;i<fhandles.size();i++)
+ for(uint i=0; i < fhandles.size(); i++)
CallService( MS_DB_CONTACT_DELETE, (WPARAM) fhandles.at(i), 0);
}
@@ -3499,7 +3499,7 @@ INT_PTR BlockFriend(WPARAM wParam,LPARAM lParam) {
}
}
}
- CallService( MS_DB_CONTACT_DELETE, (WPARAM) wParam, 1 );
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM) wParam, 1);
db_free(&dbv);
}
return 0;