messenger-gtk

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

account.h (2960B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 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 account.h
     23  */
     24 
     25 #ifndef ACCOUNT_H_
     26 #define ACCOUNT_H_
     27 
     28 #include "application.h"
     29 
     30 typedef struct MESSENGER_AccountInfo
     31 {
     32   struct GNUNET_CHAT_Account *account;
     33 
     34   GFile *icon_file;
     35   GIcon *icon;
     36   guint task;
     37 
     38   GList *name_avatars;
     39 } MESSENGER_AccountInfo;
     40 
     41 /**
     42  * Creates an account information struct to potentially
     43  * update all GUI appearances of a specific account at
     44  * once.
     45  *
     46  * @param account Chat account
     47  * @return #GNUNET_YES on info creation, otherwise #GNUNET_NO
     48  */
     49 enum GNUNET_GenericReturnValue
     50 account_create_info(struct GNUNET_CHAT_Account *account);
     51 
     52 /**
     53  * Destroys and frees resources allocated for a given
     54  * account information struct.
     55  *
     56  * @param account Chat account
     57  */
     58 void
     59 account_destroy_info(struct GNUNET_CHAT_Account *account);
     60 
     61 /**
     62  * Destroys and frees all resources allocated for
     63  * account information structs to cleanup everything
     64  * on an accounts refresh.
     65  */
     66 void
     67 account_cleanup_infos();
     68 
     69 /**
     70  * Adds a HdyAvatar to the list of avatars
     71  * which get updated by state changes.
     72  *
     73  * @param account Chat account
     74  * @param avatar Avatar
     75  */
     76 void
     77 account_add_name_avatar_to_info(const struct GNUNET_CHAT_Account *account,
     78 			                          HdyAvatar *avatar);
     79 
     80 /**
     81  * Switches a HdyAvatar to the list of avatars
     82  * in case it's in another list. Otherwise it
     83  * gets added as usual.
     84  *
     85  * @param account Chat account
     86  * @param avatar Avatar
     87  */
     88 void
     89 account_switch_name_avatar_to_info(const struct GNUNET_CHAT_Account *account,
     90 			                             HdyAvatar *avatar);
     91 
     92 /**
     93  * Removes a HdyAvatar from the list of avatars
     94  * which get updated by state changes.
     95  *
     96  * @param account Chat account
     97  * @param avatar Avatar
     98  */
     99 void
    100 account_remove_name_avatar_from_info(const struct GNUNET_CHAT_Account *account,
    101 			                               HdyAvatar *avatar);
    102 
    103 /**
    104  * Updates the connected UI elements for a given
    105  * account based on current attributes changes.
    106  *
    107  * @param account Chat account
    108  * @param app Messenger application
    109  */
    110 void
    111 account_update_attributes(const struct GNUNET_CHAT_Account *account,
    112                           MESSENGER_Application *app);
    113 
    114 #endif /* ACCOUNT_H_ */