diff options
Diffstat (limited to 'src/event.c')
-rw-r--r-- | src/event.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/event.c b/src/event.c index 17a3a39..8cfdaa7 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -328,6 +328,22 @@ event_update_profile(MESSENGER_Application *app) | |||
328 | GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app); | 328 | GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app); |
329 | } | 329 | } |
330 | 330 | ||
331 | gboolean | ||
332 | _delayed_context_drop(gpointer user_data) | ||
333 | { | ||
334 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) user_data; | ||
335 | |||
336 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); | ||
337 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_context_get_contact(context); | ||
338 | |||
339 | if (group) | ||
340 | GNUNET_CHAT_group_leave(group); | ||
341 | else if (contact) | ||
342 | GNUNET_CHAT_contact_delete(contact); | ||
343 | |||
344 | return FALSE; | ||
345 | } | ||
346 | |||
331 | void | 347 | void |
332 | event_update_chats(MESSENGER_Application *app, | 348 | event_update_chats(MESSENGER_Application *app, |
333 | struct GNUNET_CHAT_Context *context, | 349 | struct GNUNET_CHAT_Context *context, |
@@ -340,10 +356,19 @@ event_update_chats(MESSENGER_Application *app, | |||
340 | ); | 356 | ); |
341 | 357 | ||
342 | if (GNUNET_CHAT_KIND_JOIN == kind) | 358 | if (GNUNET_CHAT_KIND_JOIN == kind) |
359 | { | ||
343 | if (!handle) | 360 | if (!handle) |
344 | _add_new_chat_entry(app, context); | 361 | _add_new_chat_entry(app, context); |
345 | else | 362 | else |
346 | enqueue_chat_entry_update(handle); | 363 | enqueue_chat_entry_update(handle); |
364 | |||
365 | if (app->settings.leave_chats_delay > 0) | ||
366 | g_timeout_add_seconds( | ||
367 | app->settings.leave_chats_delay, | ||
368 | _delayed_context_drop, | ||
369 | context | ||
370 | ); | ||
371 | } | ||
347 | else if (handle) | 372 | else if (handle) |
348 | _clear_chat_entry(gtk_widget_get_parent(handle->entry_box), app); | 373 | _clear_chat_entry(gtk_widget_get_parent(handle->entry_box), app); |
349 | 374 | ||
@@ -485,6 +510,12 @@ event_invitation(MESSENGER_Application *app, | |||
485 | if (!invitation) | 510 | if (!invitation) |
486 | return; | 511 | return; |
487 | 512 | ||
513 | if (app->settings.delete_invitations_delay > 0) | ||
514 | GNUNET_CHAT_message_delete(msg, GNUNET_TIME_relative_multiply( | ||
515 | GNUNET_TIME_relative_get_second_(), | ||
516 | app->settings.delete_invitations_delay | ||
517 | )); | ||
518 | |||
488 | const int sent = GNUNET_CHAT_message_is_sent(msg); | 519 | const int sent = GNUNET_CHAT_message_is_sent(msg); |
489 | 520 | ||
490 | if ((GNUNET_YES != sent) && (app->settings.send_read_receipts)) | 521 | if ((GNUNET_YES != sent) && (app->settings.send_read_receipts)) |
@@ -542,6 +573,14 @@ event_receive_message(MESSENGER_Application *app, | |||
542 | if (!handle) | 573 | if (!handle) |
543 | return; | 574 | return; |
544 | 575 | ||
576 | const int sent = GNUNET_CHAT_message_is_sent(msg); | ||
577 | |||
578 | if ((sent) && (app->settings.auto_delete_delay > 0)) | ||
579 | GNUNET_CHAT_message_delete(msg, GNUNET_TIME_relative_multiply( | ||
580 | GNUNET_TIME_relative_get_second_(), | ||
581 | app->settings.auto_delete_delay | ||
582 | )); | ||
583 | |||
545 | const gboolean whispering = ( | 584 | const gboolean whispering = ( |
546 | GNUNET_CHAT_KIND_WHISPER == GNUNET_CHAT_message_get_kind(msg) | 585 | GNUNET_CHAT_KIND_WHISPER == GNUNET_CHAT_message_get_kind(msg) |
547 | ); | 586 | ); |
@@ -549,7 +588,6 @@ event_receive_message(MESSENGER_Application *app, | |||
549 | if ((whispering) && (!(app->settings.show_whispering))) | 588 | if ((whispering) && (!(app->settings.show_whispering))) |
550 | return; | 589 | return; |
551 | 590 | ||
552 | const int sent = GNUNET_CHAT_message_is_sent(msg); | ||
553 | const gchar *text = GNUNET_CHAT_message_get_text(msg); | 591 | const gchar *text = GNUNET_CHAT_message_get_text(msg); |
554 | 592 | ||
555 | if (whispering) | 593 | if (whispering) |
@@ -573,6 +611,12 @@ event_receive_message(MESSENGER_Application *app, | |||
573 | { | 611 | { |
574 | file_create_info(file); | 612 | file_create_info(file); |
575 | file_add_ui_message_to_info(file, message); | 613 | file_add_ui_message_to_info(file, message); |
614 | |||
615 | if (app->settings.delete_files_delay > 0) | ||
616 | GNUNET_CHAT_message_delete(msg, GNUNET_TIME_relative_multiply( | ||
617 | GNUNET_TIME_relative_get_second_(), | ||
618 | app->settings.delete_files_delay | ||
619 | )); | ||
576 | } | 620 | } |
577 | 621 | ||
578 | ui_message_update(message, app, msg); | 622 | ui_message_update(message, app, msg); |