diff options
author | George Hazan <george.hazan@gmail.com> | 2013-05-17 19:23:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-05-17 19:23:37 +0000 |
commit | 1d9fd398b75a5a6eca9d40db2e2abb60c96ebc7d (patch) | |
tree | 8d216553e534f6f34be4374741709aba73fc1739 | |
parent | c2914d5759e0ba8a3b9a81c8a1f071dba90094b4 (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
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 30 | ||||
-rw-r--r-- | plugins/StopSpamPlus/src/services.cpp | 16 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 7 | ||||
-rw-r--r-- | protocols/AimOscar/src/server.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 4 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/groupchat.cpp | 4 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 39 | ||||
-rw-r--r-- | protocols/Tlen/src/jabber_iqid.cpp | 60 | ||||
-rw-r--r-- | protocols/Twitter/src/contacts.cpp | 4 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.cpp | 5 | ||||
-rw-r--r-- | protocols/Xfire/src/main.cpp | 4 | ||||
-rw-r--r-- | src/core/stdchat/src/manager.cpp | 2 | ||||
-rw-r--r-- | src/modules/clist/clistmod.cpp | 11 |
13 files changed, 73 insertions, 116 deletions
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 697d5d8bc7..6a18c492bc 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -491,23 +491,21 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
- DBVARIANT dbNick = {0};
- if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick"));
+ if (dbNick == NULL)
break;
- else if (lstrcmp(dbNick.ptszVal, nick) == 0) {
- db_free(&dbNick);
- DBVARIANT dbURL = {0};
- if (db_get_ts(hContact, MODULE, "URL", &dbURL))
- break;
- else if (lstrcmp(dbURL.ptszVal, url) == 0) {
- db_free(&dbURL);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
- ListView_DeleteItem(hwndList, sel);
- break;
- }
- db_free(&dbURL);
- }
- db_free(&dbNick);
+ if ( lstrcmp(dbNick, nick))
+ continue;
+
+ ptrT dbURL( db_get_tsa(hContact, MODULE, "URL"));
+ if (dbURL == NULL)
+ break;
+ if ( lstrcmp(dbURL, url))
+ continue;
+
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ ListView_DeleteItem(hwndList, sel);
+ break;
}
}
return FALSE;
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 43470f8de7..c6ea59fe31 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -22,19 +22,17 @@ INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/) INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- DBVARIANT dbv = { 0 };
- if ( db_get_ts( hContact, "CList", "Group", &dbv ))
- dbv.ptszVal = NULL;
+ for (HANDLE hContact = db_find_first(); hContact; ) {
+ HANDLE hNext = db_find_next(hContact);
+ ptrT szGroup( db_get_tsa( hContact, "CList", "Group"));
- if ( db_get_b(hContact, "CList", "NotOnList", 0) || db_get_b(hContact, "CList", "Hidden", 0 ) || (dbv.ptszVal != NULL && (_tcsstr(dbv.ptszVal, _T("Not In List")) || _tcsstr(dbv.ptszVal, TranslateT("Not In List"))))) {
+ if ( db_get_b(hContact, "CList", "NotOnList", 0) || db_get_b(hContact, "CList", "Hidden", 0 ) || (szGroup != NULL && (_tcsstr(szGroup, _T("Not In List")) || _tcsstr(szGroup, TranslateT("Not In List"))))) {
char *szProto = GetContactProto(hContact);
- if ( szProto != NULL ) {
+ if (szProto != NULL) {
// Check if protocol uses server side lists
DWORD caps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
if ( caps & PF1_SERVERCLIST ) {
- int status;
- status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+ int status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if (status == ID_STATUS_OFFLINE || (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES))
// Set a flag so we remember to delete the contact when the protocol goes online the next time
db_set_b( hContact, "CList", "Delete", 1 );
@@ -44,7 +42,7 @@ INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) }
}
- db_free( &dbv );
+ hContact = hNext;
}
int hGroup = 1;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index d8f8d03799..3e109d2a20 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -3763,11 +3763,10 @@ quote_from_last: if (m_pContainer->dwFlags & CNT_SIDEBAR)
m_pContainer->SideBar->removeSession(dat);
dat->cache->setWindowData();
- if (dat->cache->isValid() && !dat->fIsReattach && dat->hContact && M->GetByte("deletetemp", 0)) {
- if (M->GetByte(dat->hContact, "CList", "NotOnList", 0)) {
+ if (dat->cache->isValid() && !dat->fIsReattach && dat->hContact && M->GetByte("deletetemp", 0))
+ if (M->GetByte(dat->hContact, "CList", "NotOnList", 0))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)dat->hContact, 0);
- }
- }
+
delete dat->Panel;
free(dat);
}
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;
diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp index 5dead6fe83..ac718a9452 100644 --- a/src/core/stdchat/src/manager.cpp +++ b/src/core/stdchat/src/manager.cpp @@ -134,8 +134,6 @@ int SM_RemoveSession(const TCHAR* pszID, const char* pszModule, BOOL removeConta if (pTemp->hContact && db_get_b( pTemp->hContact, pTemp->pszModule, "ChatRoom", 0 ) != 0)
{
CList_SetOffline(pTemp->hContact, pTemp->iType == GCW_CHATROOM?TRUE:FALSE);
-/* if (pTemp->iType != GCW_SERVER)
- db_set_b(pTemp->hContact, "CList", "Hidden", 1);*/
db_set_s(pTemp->hContact, pTemp->pszModule, "Topic", "");
db_set_s(pTemp->hContact, pTemp->pszModule, "StatusBar", "");
db_unset(pTemp->hContact, "CList", "StatusMsg");
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp index 9ab769b65a..e25dcad0d3 100644 --- a/src/modules/clist/clistmod.cpp +++ b/src/modules/clist/clistmod.cpp @@ -143,10 +143,14 @@ static int ProtocolAck(WPARAM, LPARAM lParam) if ((int)ack->hProcess < ID_STATUS_ONLINE && ack->lParam >= ID_STATUS_ONLINE) {
DWORD caps = (DWORD)CallProtoServiceInt(NULL,ack->szModule, PS_GETCAPS, PFLAGNUM_1, 0);
- if (caps & PF1_SERVERCLIST)
- for (HANDLE hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule))
+ if (caps & PF1_SERVERCLIST) {
+ for (HANDLE hContact = db_find_first(ack->szModule); hContact; ) {
+ HANDLE hNext = db_find_next(hContact, ack->szModule);
if (db_get_b(hContact, "CList", "Delete", 0))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ hContact = hNext;
+ }
+ }
}
cli.pfnTrayIconUpdateBase(ack->szModule);
@@ -544,8 +548,7 @@ void UnloadContactListModule() return;
//remove transitory contacts
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact != NULL; ) {
HANDLE hNext = db_find_next(hContact);
if (db_get_b(hContact, "CList", "NotOnList", 0))
CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
|