libgnunetchat

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

gnunet_chat_accounts.h (3329B)


      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 gnunet_chat_accounts.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_INTERNAL_ACCOUNTS_H_
     26 #define GNUNET_CHAT_INTERNAL_ACCOUNTS_H_
     27 
     28 #include <gnunet/gnunet_identity_service.h>
     29 
     30 enum GNUNET_CHAT_AccountMethod
     31 {
     32   GNUNET_CHAT_ACCOUNT_CREATION = 1,
     33   GNUNET_CHAT_ACCOUNT_DELETION = 2,
     34   GNUNET_CHAT_ACCOUNT_RENAMING = 3,
     35   GNUNET_CHAT_ACCOUNT_UPDATING = 4,
     36 
     37   GNUNET_CHAT_ACCOUNT_NONE = 0
     38 };
     39 
     40 struct GNUNET_CHAT_Handle;
     41 struct GNUNET_CHAT_Account;
     42 
     43 struct GNUNET_CHAT_InternalAccounts
     44 {
     45   struct GNUNET_CHAT_Handle *handle;
     46   struct GNUNET_CHAT_Account *account;
     47 
     48   char *identifier;
     49   struct GNUNET_IDENTITY_Operation *op;
     50   enum GNUNET_CHAT_AccountMethod method;
     51 
     52   struct GNUNET_CHAT_InternalAccounts *next;
     53   struct GNUNET_CHAT_InternalAccounts *prev;
     54 };
     55 
     56 /**
     57  * Creates a new internal account resource to
     58  * manage accounts for a given chat <i>handle</i>.
     59  *
     60  * The internal account gets appended to the
     61  * list of accounts from the handle implicitly.
     62  *
     63  * An internal account might represent only an
     64  * operation regarding a certain account while not
     65  * representing the actual account. In most cases
     66  * however this will be equivalent 
     67  * (for example iteration).
     68  *
     69  * @param[in,out] handle Chat handle
     70  * @param[in,out] account Chat account or NULL
     71  * @return New internal account resource
     72  */
     73 struct GNUNET_CHAT_InternalAccounts*
     74 internal_accounts_create(struct GNUNET_CHAT_Handle *handle,
     75                          struct GNUNET_CHAT_Account *account);
     76 
     77 /**
     78  * Destroys and frees an internal <i>accounts</i> 
     79  * resource while implicitly removing it from its 
     80  * chat handles list of accounts.
     81  *
     82  * @param[out] accounts Internal account resource
     83  */
     84 void
     85 internal_accounts_destroy(struct GNUNET_CHAT_InternalAccounts *accounts);
     86 
     87 /**
     88  * Initializes a given internal <i>accounts</i>
     89  * resource with a selected account <i>method</i>
     90  * to start further internal operations.
     91  *
     92  * @param[in,out] accounts Internal account resource
     93  * @param[in] method Account method
     94  * @param[in] identifier Account identifier or NULL
     95  */
     96 void
     97 internal_accounts_start_method(struct GNUNET_CHAT_InternalAccounts *accounts,
     98                                enum GNUNET_CHAT_AccountMethod method,
     99                                const char *identifier);
    100 
    101 /**
    102  * Resets a given internal <i>accounts</i>
    103  * resource to a neutral method state and stops
    104  * its current operation.
    105  *
    106  * @param[in,out] accounts Internal account resource
    107  */
    108 void
    109 internal_accounts_stop_method(struct GNUNET_CHAT_InternalAccounts *accounts);
    110 
    111 #endif /* GNUNET_CHAT_ACCOUNTS_H_ */