diff options
Diffstat (limited to 'src/gnunet_chat_handle_intern.c')
-rw-r--r-- | src/gnunet_chat_handle_intern.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c index ede1eb7..bcf0508 100644 --- a/src/gnunet_chat_handle_intern.c +++ b/src/gnunet_chat_handle_intern.c | |||
@@ -279,6 +279,37 @@ on_handle_message (void *cls, | |||
279 | if (!context) | 279 | if (!context) |
280 | return; | 280 | return; |
281 | 281 | ||
282 | const struct GNUNET_TIME_Absolute timestamp = GNUNET_TIME_absolute_ntoh( | ||
283 | msg->header.timestamp | ||
284 | ); | ||
285 | |||
286 | struct GNUNET_ShortHashCode shorthash; | ||
287 | util_shorthash_from_member(sender, &shorthash); | ||
288 | |||
289 | struct GNUNET_TIME_Absolute *time = GNUNET_CONTAINER_multishortmap_get( | ||
290 | context->timestamps, &shorthash | ||
291 | ); | ||
292 | |||
293 | if (time) | ||
294 | { | ||
295 | time = GNUNET_new(struct GNUNET_TIME_Absolute); | ||
296 | *time = timestamp; | ||
297 | |||
298 | if (GNUNET_OK != GNUNET_CONTAINER_multishortmap_put( | ||
299 | context->timestamps, &shorthash, time, | ||
300 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | ||
301 | GNUNET_free(time); | ||
302 | } | ||
303 | else | ||
304 | { | ||
305 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference( | ||
306 | timestamp, *time | ||
307 | ); | ||
308 | |||
309 | if (GNUNET_TIME_relative_get_zero_().rel_value_us == delta.rel_value_us) | ||
310 | *time = timestamp; | ||
311 | } | ||
312 | |||
282 | struct GNUNET_CHAT_Message *message = GNUNET_CONTAINER_multihashmap_get( | 313 | struct GNUNET_CHAT_Message *message = GNUNET_CONTAINER_multihashmap_get( |
283 | context->messages, hash | 314 | context->messages, hash |
284 | ); | 315 | ); |
@@ -319,6 +350,16 @@ on_handle_message (void *cls, | |||
319 | file_destroy(file); | 350 | file_destroy(file); |
320 | break; | 351 | break; |
321 | } | 352 | } |
353 | case GNUNET_MESSENGER_KIND_DELETE: | ||
354 | { | ||
355 | struct GNUNET_CHAT_Message *target = GNUNET_CONTAINER_multihashmap_get( | ||
356 | context->messages, &(msg->body.deletion.hash) | ||
357 | ); | ||
358 | |||
359 | if (target) | ||
360 | target->msg = NULL; | ||
361 | break; | ||
362 | } | ||
322 | default: | 363 | default: |
323 | break; | 364 | break; |
324 | } | 365 | } |