diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-11-20 04:20:03 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-11-20 04:20:03 +0100 |
commit | 788a15d1c82a562e7080d3c523b30340938d8f1d (patch) | |
tree | 3f040e52d14a79b54397526857781531d490b1b3 | |
parent | 41b1445ce9191b4f4a3a6355dad24d39945f3b69 (diff) | |
download | libgnunetchat-788a15d1c82a562e7080d3c523b30340938d8f1d.tar.gz libgnunetchat-788a15d1c82a562e7080d3c523b30340938d8f1d.zip |
Simplified identity keys into basic strings to integrate into ui
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | include/gnunet_chat_lib.h | 4 | ||||
-rw-r--r-- | src/gnunet_chat_contact.c | 25 | ||||
-rw-r--r-- | src/gnunet_chat_contact.h | 4 | ||||
-rw-r--r-- | src/gnunet_chat_handle.c | 25 | ||||
-rw-r--r-- | src/gnunet_chat_handle.h | 4 | ||||
-rw-r--r-- | src/gnunet_chat_handle_intern.c | 11 | ||||
-rw-r--r-- | src/gnunet_chat_lib.c | 8 |
7 files changed, 75 insertions, 6 deletions
diff --git a/include/gnunet_chat_lib.h b/include/gnunet_chat_lib.h index 2023323..ddf58f9 100644 --- a/include/gnunet_chat_lib.h +++ b/include/gnunet_chat_lib.h | |||
@@ -324,7 +324,7 @@ GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle); | |||
324 | * @param[in] handle Chat handle | 324 | * @param[in] handle Chat handle |
325 | * @return Public key of the handles ego or NULL | 325 | * @return Public key of the handles ego or NULL |
326 | */ | 326 | */ |
327 | const struct GNUNET_IDENTITY_PublicKey* | 327 | const char* |
328 | GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle); | 328 | GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle); |
329 | 329 | ||
330 | /** | 330 | /** |
@@ -409,7 +409,7 @@ GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact); | |||
409 | * @param[in] contact Contact | 409 | * @param[in] contact Contact |
410 | * @return Public key of the contacts ego or NULL | 410 | * @return Public key of the contacts ego or NULL |
411 | */ | 411 | */ |
412 | const struct GNUNET_IDENTITY_PublicKey* | 412 | const char* |
413 | GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact); | 413 | GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact); |
414 | 414 | ||
415 | /** | 415 | /** |
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 | } |
diff --git a/src/gnunet_chat_contact.h b/src/gnunet_chat_contact.h index 1d2fdb3..725e8fe 100644 --- a/src/gnunet_chat_contact.h +++ b/src/gnunet_chat_contact.h | |||
@@ -40,6 +40,7 @@ struct GNUNET_CHAT_Contact | |||
40 | 40 | ||
41 | const struct GNUNET_MESSENGER_Contact *member; | 41 | const struct GNUNET_MESSENGER_Contact *member; |
42 | 42 | ||
43 | char *public_key; | ||
43 | void *user_pointer; | 44 | void *user_pointer; |
44 | }; | 45 | }; |
45 | 46 | ||
@@ -48,6 +49,9 @@ contact_create_from_member (struct GNUNET_CHAT_Handle *handle, | |||
48 | const struct GNUNET_MESSENGER_Contact *member); | 49 | const struct GNUNET_MESSENGER_Contact *member); |
49 | 50 | ||
50 | void | 51 | void |
52 | contact_update_key (struct GNUNET_CHAT_Contact *contact); | ||
53 | |||
54 | void | ||
51 | contact_destroy (struct GNUNET_CHAT_Contact* contact); | 55 | contact_destroy (struct GNUNET_CHAT_Contact* contact); |
52 | 56 | ||
53 | #endif /* GNUNET_CHAT_CONTACT_H_ */ | 57 | #endif /* GNUNET_CHAT_CONTACT_H_ */ |
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c index 4c1aa82..b676cc9 100644 --- a/src/gnunet_chat_handle.c +++ b/src/gnunet_chat_handle.c | |||
@@ -84,12 +84,34 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, | |||
84 | on_handle_message, handle | 84 | on_handle_message, handle |
85 | ); | 85 | ); |
86 | 86 | ||
87 | handle->public_key = NULL; | ||
87 | handle->user_pointer = NULL; | 88 | handle->user_pointer = NULL; |
88 | 89 | ||
90 | handle_update_key(handle); | ||
89 | return handle; | 91 | return handle; |
90 | } | 92 | } |
91 | 93 | ||
92 | void | 94 | void |
95 | handle_update_key (struct GNUNET_CHAT_Handle *handle) | ||
96 | { | ||
97 | GNUNET_assert(handle); | ||
98 | |||
99 | if (handle->public_key) | ||
100 | GNUNET_free(handle->public_key); | ||
101 | |||
102 | handle->public_key = NULL; | ||
103 | |||
104 | if (!handle->messenger) | ||
105 | return; | ||
106 | |||
107 | const struct GNUNET_IDENTITY_PublicKey *pubkey; | ||
108 | pubkey = GNUNET_MESSENGER_get_key(handle->messenger); | ||
109 | |||
110 | if (pubkey) | ||
111 | handle->public_key = GNUNET_IDENTITY_public_key_to_string(pubkey); | ||
112 | } | ||
113 | |||
114 | void | ||
93 | handle_destroy (struct GNUNET_CHAT_Handle* handle) | 115 | handle_destroy (struct GNUNET_CHAT_Handle* handle) |
94 | { | 116 | { |
95 | GNUNET_assert((handle) && | 117 | GNUNET_assert((handle) && |
@@ -98,6 +120,9 @@ handle_destroy (struct GNUNET_CHAT_Handle* handle) | |||
98 | (handle->contexts) && | 120 | (handle->contexts) && |
99 | (handle->files)); | 121 | (handle->files)); |
100 | 122 | ||
123 | if (handle->public_key) | ||
124 | GNUNET_free(handle->public_key); | ||
125 | |||
101 | if (handle->messenger) | 126 | if (handle->messenger) |
102 | GNUNET_MESSENGER_disconnect(handle->messenger); | 127 | GNUNET_MESSENGER_disconnect(handle->messenger); |
103 | 128 | ||
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h index 2d3f8e8..dde11d2 100644 --- a/src/gnunet_chat_handle.h +++ b/src/gnunet_chat_handle.h | |||
@@ -54,6 +54,7 @@ struct GNUNET_CHAT_Handle | |||
54 | struct GNUNET_FS_Handle *fs; | 54 | struct GNUNET_FS_Handle *fs; |
55 | struct GNUNET_MESSENGER_Handle *messenger; | 55 | struct GNUNET_MESSENGER_Handle *messenger; |
56 | 56 | ||
57 | char *public_key; | ||
57 | void *user_pointer; | 58 | void *user_pointer; |
58 | }; | 59 | }; |
59 | 60 | ||
@@ -65,6 +66,9 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, | |||
65 | void *msg_cls); | 66 | void *msg_cls); |
66 | 67 | ||
67 | void | 68 | void |
69 | handle_update_key (struct GNUNET_CHAT_Handle *handle); | ||
70 | |||
71 | void | ||
68 | handle_destroy (struct GNUNET_CHAT_Handle* handle); | 72 | handle_destroy (struct GNUNET_CHAT_Handle* handle); |
69 | 73 | ||
70 | #endif /* GNUNET_CHAT_HANDLE_H_ */ | 74 | #endif /* GNUNET_CHAT_HANDLE_H_ */ |
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c index e212699..d275aaf 100644 --- a/src/gnunet_chat_handle_intern.c +++ b/src/gnunet_chat_handle_intern.c | |||
@@ -397,6 +397,8 @@ on_handle_identity(void *cls, | |||
397 | (handle->groups) && | 397 | (handle->groups) && |
398 | (handle->contacts)); | 398 | (handle->contacts)); |
399 | 399 | ||
400 | handle_update_key(handle); | ||
401 | |||
400 | if ((0 < GNUNET_CONTAINER_multihashmap_size(handle->contexts)) || | 402 | if ((0 < GNUNET_CONTAINER_multihashmap_size(handle->contexts)) || |
401 | (0 < GNUNET_CONTAINER_multihashmap_size(handle->groups)) || | 403 | (0 < GNUNET_CONTAINER_multihashmap_size(handle->groups)) || |
402 | (0 < GNUNET_CONTAINER_multishortmap_size(handle->contacts))) | 404 | (0 < GNUNET_CONTAINER_multishortmap_size(handle->contacts))) |
@@ -488,6 +490,15 @@ on_handle_message (void *cls, | |||
488 | 490 | ||
489 | switch (msg->header.kind) | 491 | switch (msg->header.kind) |
490 | { | 492 | { |
493 | case GNUNET_MESSENGER_KIND_KEY: | ||
494 | { | ||
495 | struct GNUNET_CHAT_Contact *contact = GNUNET_CONTAINER_multishortmap_get( | ||
496 | handle->contacts, &shorthash | ||
497 | ); | ||
498 | |||
499 | contact_update_key(contact); | ||
500 | break; | ||
501 | } | ||
491 | case GNUNET_MESSENGER_KIND_INVITE: | 502 | case GNUNET_MESSENGER_KIND_INVITE: |
492 | { | 503 | { |
493 | struct GNUNET_CHAT_Invitation *invitation = invitation_create_from_message( | 504 | struct GNUNET_CHAT_Invitation *invitation = invitation_create_from_message( |
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index ffaa6a0..01a9c78 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -97,13 +97,13 @@ GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | const struct GNUNET_IDENTITY_PublicKey* | 100 | const char* |
101 | GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle) | 101 | GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle) |
102 | { | 102 | { |
103 | if (!handle) | 103 | if (!handle) |
104 | return NULL; | 104 | return NULL; |
105 | 105 | ||
106 | return GNUNET_MESSENGER_get_key(handle->messenger); | 106 | return handle->public_key; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
@@ -277,13 +277,13 @@ GNUNET_CHAT_contact_get_name (const struct GNUNET_CHAT_Contact *contact) | |||
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | const struct GNUNET_IDENTITY_PublicKey* | 280 | const char* |
281 | GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact) | 281 | GNUNET_CHAT_contact_get_key (const struct GNUNET_CHAT_Contact *contact) |
282 | { | 282 | { |
283 | if (!contact) | 283 | if (!contact) |
284 | return NULL; | 284 | return NULL; |
285 | 285 | ||
286 | return GNUNET_MESSENGER_contact_get_key(contact->member); | 286 | return contact->public_key; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||