messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

contact.h (4463B)


      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 contact.h
     23  */
     24 
     25 #ifndef CONTACT_H_
     26 #define CONTACT_H_
     27 
     28 #include "application.h"
     29 
     30 typedef struct MESSENGER_ContactInfo
     31 {
     32   void *last_message;
     33   GFile *icon_file;
     34   GIcon *icon;
     35   guint task;
     36 
     37   GList *name_labels;
     38   GList *name_avatars;
     39   GList *visible_widgets;
     40 } MESSENGER_ContactInfo;
     41 
     42 /**
     43  * Creates a contact information struct to potentially
     44  * update all GUI appearances of a specific contact at
     45  * once.
     46  *
     47  * @param contact Chat contact
     48  * @return #GNUNET_YES on info creation, otherwise #GNUNET_NO
     49  */
     50 enum GNUNET_GenericReturnValue
     51 contact_create_info(struct GNUNET_CHAT_Contact *contact);
     52 
     53 /**
     54  * Destroys and frees resources allocated for a given
     55  * contact information struct.
     56  *
     57  * @param contact Chat contact
     58  */
     59 void
     60 contact_destroy_info(struct GNUNET_CHAT_Contact *contact);
     61 
     62 /**
     63  * Sets the latest join/leave UI message handle so that
     64  * the application can check whether a contact is available.
     65  *
     66  * @param contact Chat contact
     67  * @param message Pointer to UI message handle
     68  */
     69 void
     70 contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact,
     71 				                         void *message);
     72 
     73 /**
     74  * Returns the latest join/leave UI message handle of
     75  * a specific contact.
     76  *
     77  * @param contact Chat contact
     78  */
     79 void*
     80 contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact);
     81 
     82 /**
     83  * Adds a GtkLabel to the list of labels
     84  * which get updated by state changes.
     85  *
     86  * @param contact Chat contact
     87  * @param label Label
     88  */
     89 void
     90 contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact,
     91 			                         GtkLabel *label);
     92 
     93 /**
     94  * Removes a GtkLabel from the list of labels
     95  * which get updated by state changes.
     96  *
     97  * @param contact Chat contact
     98  * @param label Label
     99  */
    100 void
    101 contact_remove_name_label_from_info(const struct GNUNET_CHAT_Contact *contact,
    102 			                              GtkLabel *label);
    103 
    104 /**
    105  * Adds a HdyAvatar to the list of avatars
    106  * which get updated by state changes.
    107  *
    108  * @param contact Chat contact
    109  * @param avatar Avatar
    110  */
    111 void
    112 contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact,
    113 			                          HdyAvatar *avatar);
    114 
    115 /**
    116  * Removes a HdyAvatar from the list of avatars
    117  * which get updated by state changes.
    118  *
    119  * @param contact Chat contact
    120  * @param avatar Avatar
    121  */
    122 void
    123 contact_remove_name_avatar_from_info(const struct GNUNET_CHAT_Contact *contact,
    124 			                               HdyAvatar *avatar);
    125 
    126 /**
    127  * Adds a GtkWidget to the list of widgets
    128  * which get visibility updated by state changes.
    129  *
    130  * @param contact Chat contact
    131  * @param widget Widget
    132  */
    133 void
    134 contact_add_visible_widget_to_info(const struct GNUNET_CHAT_Contact *contact,
    135                                    GtkWidget *widget);
    136 
    137 /**
    138  * Removes a GtkWidget from the list of widgets
    139  * which get visibility updated by state changes.
    140  *
    141  * @param contact Chat contact
    142  * @param widget Widget
    143  */
    144 void
    145 contact_remove_visible_widget_to_info(const struct GNUNET_CHAT_Contact *contact,
    146                                       GtkWidget *widget);
    147 
    148 /**
    149  * Updates the connected UI elements for a given
    150  * contact depending on the current state.
    151  *
    152  * @param contact Chat contact
    153  * @param attributes Flag to check for attributes changes
    154  */
    155 void
    156 contact_update_info(const struct GNUNET_CHAT_Contact *contact);
    157 
    158 /**
    159  * Updates the connected UI elements for a given
    160  * contact based on current attributes changes.
    161  *
    162  * @param contact Chat contact
    163  * @param app Messenger application
    164  */
    165 void
    166 contact_update_attributes(struct GNUNET_CHAT_Contact *contact,
    167                           MESSENGER_Application *app);
    168 
    169 #endif /* CONTACT_H_ */