From b51a3e81dd2178c681226458ca4bb73ae98a5e34 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Sat, 20 Nov 2021 13:07:17 +0100 Subject: You can unblock people now and some small fixes - the chatlist is now properly updated on blocking a contact request or contact. - A small message is now displayed after blocking a contact request - A list of blocked contact can be found on the settings page, after clicking 'View blocked users' - The message timestamp is now slightly padded --- context.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'context.cpp') diff --git a/context.cpp b/context.cpp index 59d8211..11372d0 100644 --- a/context.cpp +++ b/context.cpp @@ -100,6 +100,34 @@ Context::acceptChat(uint32_t chatId) dc_accept_chat(m_context, chatId); } +void +Context::blockContact(uint32_t contactId, uint32_t blockMode) +{ + dc_block_contact(m_context, contactId, blockMode); +} + +QVariantMap +Context::getBlockedContacts() +{ + QVariantMap blockList; + uint32_t CID; + char *addr; + dc_contact_t *contact; + dc_array_t *blockedContacts = dc_get_blocked_contacts(m_context); + size_t max = dc_array_get_cnt(blockedContacts); + + for (size_t i = 0; i < max; i++) { + CID = dc_array_get_id(blockedContacts, i); + contact = dc_get_contact(m_context, CID); + addr = dc_contact_get_addr(contact); + blockList.insert(addr, CID); + dc_contact_unref(contact); + dc_str_unref(addr); + } + dc_array_unref(blockedContacts); + return blockList; +} + QString Context::getChatEncrinfo(uint32_t chatId) { -- cgit v1.2.3-70-g09d2