diff options
author | George Hazan <ghazan@miranda.im> | 2023-02-10 12:54:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-02-10 12:54:20 +0300 |
commit | ef0ba268b340eaf1217a96d763342c25668588b4 (patch) | |
tree | 17396375e213043c2ce1c59b50b7f30488dcb83d /protocols/Twitter | |
parent | 33733576589076f080ddfa000b899843016a2597 (diff) |
Protocols: preventing recursive contact deletion
Diffstat (limited to 'protocols/Twitter')
-rw-r--r-- | protocols/Twitter/src/contacts.cpp | 18 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.h | 2 |
3 files changed, 8 insertions, 15 deletions
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index dc3b2668ee..ce4795132b 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -154,25 +154,19 @@ HANDLE CTwitterProto::GetAwayMsg(MCONTACT hContact) return (HANDLE)1;
}
-int CTwitterProto::OnContactDeleted(WPARAM wParam, LPARAM)
+void CTwitterProto::OnContactDeleted(MCONTACT hContact)
{
- MCONTACT hContact = (MCONTACT)wParam;
if (m_iStatus != ID_STATUS_ONLINE)
- return 0;
-
- if (!IsMyContact(hContact))
- return 0;
+ return;
- DBVARIANT dbv;
- if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
+ ptrA szId(getStringA(hContact, TWITTER_KEY_UN));
+ if (szId) {
if (m_si)
- DeleteChatContact(dbv.pszVal);
+ DeleteChatContact(szId);
mir_cslock s(twitter_lock_);
- remove_friend(dbv.pszVal); // Be careful about this until Miranda is fixed
- db_free(&dbv);
+ remove_friend(szId.get()); // Be careful about this until Miranda is fixed
}
- return 0;
}
int CTwitterProto::OnMarkedRead(WPARAM, LPARAM hDbEvent)
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index 3bdb0ee542..0ee353ac67 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -36,7 +36,6 @@ CTwitterProto::CTwitterProto(const char *proto_name, const wchar_t *username) : CreateProtoService(PS_SETMYAVATAR, &CTwitterProto::SetAvatar);
HookProtoEvent(ME_OPT_INITIALISE, &CTwitterProto::OnOptionsInit);
- HookProtoEvent(ME_DB_CONTACT_DELETED, &CTwitterProto::OnContactDeleted);
HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CTwitterProto::OnMarkedRead);
HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CTwitterProto::OnBuildStatusMenu);
@@ -355,7 +354,7 @@ void CTwitterProto::UpdateSettings() for (MCONTACT hContact = db_find_first(m_szModuleName); hContact;) {
MCONTACT hNext = db_find_next(hContact, m_szModuleName);
if (isChatRoom(hContact))
- db_delete_contact(hContact);
+ db_delete_contact(hContact, true);
hContact = hNext;
}
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 6868386c29..7fe4922552 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -166,6 +166,7 @@ public: HANDLE GetAwayMsg(MCONTACT) override;
+ void OnContactDeleted(MCONTACT) override;
void OnModulesLoaded() override;
void UpdateSettings();
@@ -189,7 +190,6 @@ public: int __cdecl OnBuildStatusMenu(WPARAM, LPARAM);
int __cdecl OnChatOutgoing(WPARAM, LPARAM);
- int __cdecl OnContactDeleted(WPARAM,LPARAM);
int __cdecl OnMarkedRead(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
|