diff options
Diffstat (limited to 'src/gnunet_chat_contact.c')
-rw-r--r-- | src/gnunet_chat_contact.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gnunet_chat_contact.c b/src/gnunet_chat_contact.c index 6ef6506..a955088 100644 --- a/src/gnunet_chat_contact.c +++ b/src/gnunet_chat_contact.c | |||
@@ -37,15 +37,40 @@ contact_create_from_member (struct GNUNET_CHAT_Handle *handle, | |||
37 | 37 | ||
38 | contact->member = member; | 38 | contact->member = member; |
39 | 39 | ||
40 | contact->public_key = NULL; | ||
40 | contact->user_pointer = NULL; | 41 | contact->user_pointer = NULL; |
41 | 42 | ||
43 | contact_update_key (contact); | ||
42 | return contact; | 44 | return contact; |
43 | } | 45 | } |
44 | 46 | ||
45 | void | 47 | void |
48 | contact_update_key (struct GNUNET_CHAT_Contact *contact) | ||
49 | { | ||
50 | GNUNET_assert(contact); | ||
51 | |||
52 | if (contact->public_key) | ||
53 | GNUNET_free(contact->public_key); | ||
54 | |||
55 | contact->public_key = NULL; | ||
56 | |||
57 | if (!contact->member) | ||
58 | return; | ||
59 | |||
60 | const struct GNUNET_IDENTITY_PublicKey *pubkey; | ||
61 | pubkey = GNUNET_MESSENGER_contact_get_key(contact->member); | ||
62 | |||
63 | if (pubkey) | ||
64 | contact->public_key = GNUNET_IDENTITY_public_key_to_string(pubkey); | ||
65 | } | ||
66 | |||
67 | void | ||
46 | contact_destroy (struct GNUNET_CHAT_Contact* contact) | 68 | contact_destroy (struct GNUNET_CHAT_Contact* contact) |
47 | { | 69 | { |
48 | GNUNET_assert(contact); | 70 | GNUNET_assert(contact); |
49 | 71 | ||
72 | if (contact->public_key) | ||
73 | GNUNET_free(contact->public_key); | ||
74 | |||
50 | GNUNET_free(contact); | 75 | GNUNET_free(contact); |
51 | } | 76 | } |