members.h (2895B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2022--2023 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/members.h 23 */ 24 25 #ifndef UI_MEMBERS_H_ 26 #define UI_MEMBERS_H_ 27 28 #include <stdbool.h> 29 #include <stdlib.h> 30 #include <curses.h> 31 32 #include <gnunet/gnunet_chat_lib.h> 33 #include <gnunet/gnunet_util_lib.h> 34 35 struct MESSENGER_Application; 36 37 /** 38 * @struct UI_MEMBERS_List 39 */ 40 typedef struct UI_MEMBERS_List 41 { 42 struct GNUNET_CHAT_Contact *contact; 43 44 struct UI_MEMBERS_List *prev; 45 struct UI_MEMBERS_List *next; 46 } UI_MEMBERS_List; 47 48 /** 49 * @struct UI_MEMBERS_Handle 50 */ 51 typedef struct UI_MEMBERS_Handle 52 { 53 WINDOW *window; 54 55 UI_MEMBERS_List *head; 56 UI_MEMBERS_List *tail; 57 58 int line_prev; 59 int line_next; 60 61 int line_index; 62 int line_offset; 63 int line_selected; 64 65 struct GNUNET_CHAT_Contact *selected; 66 } UI_MEMBERS_Handle; 67 68 #define UI_MEMBERS_COLS_MIN 30 69 70 /** 71 * Processes the current key event by the view 72 * to show a chats list of members. 73 * 74 * @param[in,out] members Chat members view 75 * @param[in,out] app Application handle 76 * @param[in] key Key 77 */ 78 void 79 members_event(UI_MEMBERS_Handle *members, 80 struct MESSENGER_Application *app, 81 int key); 82 83 /** 84 * Prints the content of the view to show 85 * a chats list of members to its selected 86 * window view on screen. 87 * 88 * @param[in,out] members Chat members view 89 */ 90 void 91 members_print(UI_MEMBERS_Handle *members); 92 93 /** 94 * Clears the list of members the view 95 * would print to the screen. 96 * 97 * @param[out] members Chat members view 98 */ 99 void 100 members_clear(UI_MEMBERS_Handle *members); 101 102 /** 103 * Adds a new chat contact to the list of 104 * members the view will print to the 105 * screen. 106 * 107 * @param[in,out] members Chat members view 108 * @param[in] contact Chat contact 109 * @return #TRUE if the member is new, otherwise #FALSE 110 */ 111 bool 112 members_add(UI_MEMBERS_Handle *members, 113 struct GNUNET_CHAT_Contact *contact); 114 115 /** 116 * Removes a chat contact from the list of 117 * members the view would print to the 118 * screen. 119 * 120 * @param[in,out] members Chat members view 121 * @param[in] contact Chat contact 122 */ 123 void 124 members_remove(UI_MEMBERS_Handle *members, 125 const struct GNUNET_CHAT_Contact *contact); 126 127 #endif /* UI_MEMBERS_H_ */