chat.h (4703B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2021--2024 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 /* 21 * @author Tobias Frisch 22 * @file ui/chat.h 23 */ 24 25 #ifndef UI_CHAT_H_ 26 #define UI_CHAT_H_ 27 28 #include <gstreamer-1.0/gst/gst.h> 29 #include <gtk-3.0/gtk/gtk.h> 30 #include <libhandy-1/handy.h> 31 #include <libnotify/notify.h> 32 #include <stdio.h> 33 34 #include <gnunet/gnunet_chat_lib.h> 35 36 #define UI_CHAT_SEND_BUTTON_HOLD_INTERVAL 500000 // in microseconds 37 38 typedef struct MESSENGER_Application MESSENGER_Application; 39 typedef struct UI_MESSAGE_Handle UI_MESSAGE_Handle; 40 typedef struct UI_PICKER_Handle UI_PICKER_Handle; 41 typedef struct UI_CHAT_TITLE_Handle UI_CHAT_TITLE_Handle; 42 43 typedef struct UI_CHAT_Handle 44 { 45 gint64 send_pressed_time; 46 47 gboolean recorded; 48 gboolean playing; 49 50 char recording_filename [PATH_MAX]; 51 52 guint record_timer; 53 guint record_time; 54 55 guint play_timer; 56 57 GstElement *record_pipeline; 58 GstElement *record_sink; 59 60 GstElement *play_pipeline; 61 GstElement *play_sink; 62 63 guint record_watch; 64 guint play_watch; 65 66 MESSENGER_Application *app; 67 struct GNUNET_CHAT_Context *context; 68 69 UI_CHAT_TITLE_Handle *title; 70 gdouble edge_value; 71 72 GtkBuilder *builder; 73 GtkWidget *chat_box; 74 75 HdyFlap *flap_chat_details; 76 77 HdySearchBar *chat_search_bar; 78 GtkSearchEntry *chat_search_entry; 79 80 GtkLabel *chat_details_label; 81 GtkButton *hide_chat_details_button; 82 GtkBox *chat_details_contacts_box; 83 GtkBox *chat_details_files_box; 84 GtkBox *chat_details_media_box; 85 86 HdyAvatar *chat_details_avatar; 87 88 GtkButton *reveal_identity_button; 89 GtkButton *discourse_button; 90 GtkStack *block_stack; 91 GtkButton *block_button; 92 GtkButton *unblock_button; 93 GtkButton *leave_chat_button; 94 95 GtkSwitch *chat_notifications_switch; 96 97 GtkScrolledWindow *chat_scrolled_window; 98 99 GtkListBox *chat_contacts_listbox; 100 GtkListBox *chat_files_listbox; 101 GtkFlowBox *chat_media_flowbox; 102 GtkListBox *messages_listbox; 103 104 GtkStack *send_stack; 105 GtkWidget *send_text_box; 106 GtkWidget *send_recording_box; 107 108 GtkButton *attach_file_button; 109 GtkTextView *send_text_view; 110 GtkButton *emoji_button; 111 GtkButton *send_record_button; 112 GtkImage *send_record_symbol; 113 114 GtkPopover *send_popover; 115 GtkButton *send_later_button; 116 GtkButton *send_now_button; 117 118 GtkButton *recording_close_button; 119 GtkButton *recording_play_button; 120 GtkImage *play_pause_symbol; 121 GtkLabel *recording_label; 122 GtkProgressBar *recording_progress_bar; 123 124 GtkRevealer *picker_revealer; 125 126 UI_PICKER_Handle *picker; 127 } UI_CHAT_Handle; 128 129 /** 130 * Allocates and creates a new chat handle 131 * to manage a chat for a given messenger 132 * application. 133 * 134 * @param app Messenger application 135 * @param context Chat context 136 * @return New chat handle 137 */ 138 UI_CHAT_Handle* 139 ui_chat_new(MESSENGER_Application *app, 140 struct GNUNET_CHAT_Context *context); 141 142 /** 143 * Updates a given chat handle with the current 144 * state of a messenger application and the chat 145 * context the chat is representing. 146 * 147 * @param handle Chat handle 148 * @param app Messenger application 149 */ 150 void 151 ui_chat_update(UI_CHAT_Handle *handle, 152 MESSENGER_Application *app); 153 154 /** 155 * Frees its resources and destroys a given 156 * chat handle. 157 * 158 * @param handle Chat handle 159 */ 160 void 161 ui_chat_delete(UI_CHAT_Handle *handle); 162 163 /** 164 * Add a message handle to a given chat handle 165 * to get listed by it for a messenger 166 * application. 167 * 168 * @param handle Chat handle 169 * @param app Messenger application 170 * @param message Message handle 171 */ 172 void 173 ui_chat_add_message(UI_CHAT_Handle *handle, 174 MESSENGER_Application *app, 175 UI_MESSAGE_Handle *message); 176 177 /** 178 * Removes a message handle from a given chat 179 * handle to remove it from its list for a 180 * messenger application. 181 * 182 * @param handle Chat handle 183 * @param app Messenger application 184 * @param message Message handle 185 */ 186 void 187 ui_chat_remove_message(UI_CHAT_Handle *handle, 188 MESSENGER_Application *app, 189 UI_MESSAGE_Handle *message); 190 191 #endif /* UI_CHAT_H_ */