messenger-cli

Command-line user interface for GNUnet Messenger
Log | Files | Refs | README | LICENSE

members.h (2881B)


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