libgnunetchat

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

gnunet_chat_account.h (3133B)


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