libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit 11cd8effe7b6f6f8766dea5501b948f0b8990e82
parent 2af2090cd95d4549213703a7d7124e950f448685
Author: Jacki <jacki@thejackimonster.de>
Date:   Wed,  3 Apr 2024 00:20:22 +0200

Add internal function to return public key from contact

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/gnunet_chat_contact.c | 20++++++++++++++------
Msrc/gnunet_chat_contact.h | 8++++++++
2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gnunet_chat_contact.c b/src/gnunet_chat_contact.c @@ -127,16 +127,24 @@ contact_update_key (struct GNUNET_CHAT_Contact *contact) if (contact->public_key) GNUNET_free(contact->public_key); - contact->public_key = NULL; - - if (!(contact->member)) - return; - const struct GNUNET_CRYPTO_PublicKey *pubkey; - pubkey = GNUNET_MESSENGER_contact_get_key(contact->member); + pubkey = contact_get_key(contact); if (pubkey) contact->public_key = GNUNET_CRYPTO_public_key_to_string(pubkey); + else + contact->public_key = NULL; +} + +const struct GNUNET_CRYPTO_PublicKey* +contact_get_key (const struct GNUNET_CHAT_Contact *contact) +{ + GNUNET_assert(contact); + + if (!(contact->member)) + return NULL; + + return GNUNET_MESSENGER_contact_get_key(contact->member); } struct GNUNET_CHAT_Context* diff --git a/src/gnunet_chat_contact.h b/src/gnunet_chat_contact.h @@ -94,6 +94,14 @@ void contact_update_key (struct GNUNET_CHAT_Contact *contact); /** + * Returns the public key from a given chat <i>contact</i>. + * + * @param[in] contact Chat contact + */ +const struct GNUNET_CRYPTO_PublicKey* +contact_get_key (const struct GNUNET_CHAT_Contact *contact); + +/** * Searches for a chat context containing a given chat * <i>contact</i> and the least amount of other members. *