libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

gnunet_chat_account.h (2920B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2022--2025 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 gnunet_chat_account.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_ACCOUNT_H_
     26 #define GNUNET_CHAT_ACCOUNT_H_
     27 
     28 #include <gnunet/gnunet_common.h>
     29 #include <gnunet/gnunet_identity_service.h>
     30 #include <gnunet/gnunet_util_lib.h>
     31 
     32 struct GNUNET_CHAT_Handle;
     33 
     34 struct GNUNET_CHAT_Account
     35 {
     36   struct GNUNET_IDENTITY_Ego *ego;
     37   enum GNUNET_GenericReturnValue created;
     38 
     39   char *name;
     40 
     41   void *user_pointer;
     42 };
     43 
     44 /**
     45  * Creates a chat account using a given <i>name</i>.
     46  *
     47  * @param[in] name Name
     48  * @return New chat account
     49  */
     50 struct GNUNET_CHAT_Account*
     51 account_create (const char *name);
     52 
     53 /**
     54  * Creates a chat account using a given <i>ego</i> and
     55  * a matching <i>name</i>.
     56  *
     57  * @param[in] ego EGO
     58  * @param[in] name Name
     59  * @return New chat account
     60  */
     61 struct GNUNET_CHAT_Account*
     62 account_create_from_ego (struct GNUNET_IDENTITY_Ego *ego,
     63 			                   const char *name);
     64 
     65 /**
     66  * Returns the private key from a given chat
     67  * <i>account</i>.
     68  *
     69  * @param[in] account Chat account
     70  * @return EGOs private key or NULL
     71  */
     72 const struct GNUNET_CRYPTO_BlindablePrivateKey*
     73 account_get_key (const struct GNUNET_CHAT_Account *account);
     74 
     75 /**
     76  * Returns the name from a given chat <i>account</i>.
     77  *
     78  * @param[in] account Chat account
     79  * @return Name or NULL
     80  */
     81 const char*
     82 account_get_name (const struct GNUNET_CHAT_Account *account);
     83 
     84 /**
     85  * Updates the key from a given chat <i>account</i> using
     86  * the chat <i>handle</i> and a specific <i>ego</i> matching 
     87  * the accounts name.
     88  *
     89  * @param[in,out] account Chat account
     90  * @param[in,out] handle Chat handle
     91  * @param[in] ego EGO
     92  */
     93 void
     94 account_update_ego (struct GNUNET_CHAT_Account *account,
     95                     struct GNUNET_CHAT_Handle *handle,
     96                     struct GNUNET_IDENTITY_Ego *ego);
     97 
     98 /**
     99  * Deletes all data remaining a given chat <i>account</i>.
    100  *
    101  * @param[in,out] account Chat account
    102  */
    103 void
    104 account_delete (struct GNUNET_CHAT_Account *account);
    105 
    106 /**
    107  * Destroys a chat <i>account</i> and frees its memory.
    108  *
    109  * @param[in,out] account Chat account
    110  */
    111 void
    112 account_destroy (struct GNUNET_CHAT_Account *account);
    113 
    114 #endif /* GNUNET_CHAT_ACCOUNT_H_ */