libgnunetchat

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

gnunet_chat_attribute_process.h (4712B)


      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_attribute_process.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_INTERNAL_ATTRIBUTE_PROCESS_H_
     26 #define GNUNET_CHAT_INTERNAL_ATTRIBUTE_PROCESS_H_
     27 
     28 #include <gnunet/gnunet_reclaim_service.h>
     29 
     30 #include "gnunet_chat_lib.h"
     31 
     32 struct GNUNET_CHAT_Handle;
     33 struct GNUNET_CHAT_Account;
     34 struct GNUNET_CHAT_Contact;
     35 
     36 struct GNUNET_CHAT_AttributeProcess
     37 {
     38   struct GNUNET_CHAT_Handle *handle;
     39 
     40   struct GNUNET_CHAT_Account *account;
     41   struct GNUNET_CHAT_Contact *contact;
     42 
     43   struct GNUNET_RECLAIM_Attribute *attribute;
     44   struct GNUNET_TIME_Relative expires;
     45   char *name;
     46   void *data;
     47 
     48   GNUNET_CHAT_AttributeCallback callback;
     49   GNUNET_CHAT_AccountAttributeCallback account_callback;
     50 
     51   void *closure;
     52 
     53   struct GNUNET_RECLAIM_AttributeIterator *iter;
     54   struct GNUNET_RECLAIM_Operation *op;
     55 
     56   struct GNUNET_CHAT_AttributeProcess *next;
     57   struct GNUNET_CHAT_AttributeProcess *prev;
     58 };
     59 
     60 /**
     61  * Creates a new attribute process resource to
     62  * handle general attribute management using
     63  * a given chat <i>handle</i>.
     64  *
     65  * The attribute process gets appended to the
     66  * list of processes from the handle implicitly.
     67  *
     68  * @param[in,out] handle Chat handle
     69  * @param[in] name Attribute name or NULL
     70  * @return New attribute process
     71  */
     72 struct GNUNET_CHAT_AttributeProcess*
     73 internal_attributes_create(struct GNUNET_CHAT_Handle *handle,
     74                            const char *name);
     75 
     76 /**
     77  * Creates a new attribute process resource to
     78  * handle attribute storage of an attribute with
     79  * a specific <i>name</i> using a given chat
     80  * <i>handle</i> and a relative datetime it
     81  * <i>expires</i>.
     82  *
     83  * @see internal_attributes_create()
     84  *
     85  * @param[in,out] handle Chat handle
     86  * @param[in] Attribute name
     87  * @param[in] expires Relative time for expiration
     88  * @return New attribute storage process
     89  */
     90 struct GNUNET_CHAT_AttributeProcess*
     91 internal_attributes_create_store(struct GNUNET_CHAT_Handle *handle,
     92                                  const char *name,
     93                                  struct GNUNET_TIME_Relative expires);
     94 
     95 /**
     96  * Creates a new attribute process resource to
     97  * handle attribute sharing of an attribute with
     98  * a specific <i>name</i> for a certain chat 
     99  * <i>contact</i> using a given chat <i>handle</i>.
    100  *
    101  * @see internal_attributes_create()
    102  *
    103  * @param[in,out] handle Chat handle
    104  * @param[in,out] contact Chat contact
    105  * @param[in] Attribute name
    106  * @return New attribute sharing process
    107  */
    108 struct GNUNET_CHAT_AttributeProcess*
    109 internal_attributes_create_share(struct GNUNET_CHAT_Handle *handle,
    110                                  struct GNUNET_CHAT_Contact *contact,
    111                                  const char *name);
    112 
    113 /**
    114  * Creates a new attribute process resource to
    115  * request attributes from a specific chat 
    116  * <i>account</i> using a given chat <i>handle</i>.
    117  *
    118  * @see internal_attributes_create()
    119  *
    120  * @param[in,out] handle Chat handle
    121  * @param[in,out] account Chat account
    122  * @return New attribute request process
    123  */
    124 struct GNUNET_CHAT_AttributeProcess*
    125 internal_attributes_create_request(struct GNUNET_CHAT_Handle *handle,
    126                                    struct GNUNET_CHAT_Account *account);
    127 
    128 /**
    129  * Destroys and frees a given <i>attributes</i> 
    130  * process resource. This will implicitly remove
    131  * it from its chat handles list of processes.
    132  *
    133  * @param[out] attributes Attribute process
    134  */
    135 void
    136 internal_attributes_destroy(struct GNUNET_CHAT_AttributeProcess *attributes);
    137 
    138 /**
    139  * Continues the iteration of a given <i>attributes</i> 
    140  * process resource to its next step.
    141  *
    142  * @param[in,out] attributes Attribute process
    143  */
    144 void
    145 internal_attributes_next_iter(struct GNUNET_CHAT_AttributeProcess *attributes);
    146 
    147 /**
    148  * Stops the iteration of a given <i>attributes</i> 
    149  * process resource.
    150  *
    151  * @param[in,out] attributes Attribute process
    152  */
    153 void
    154 internal_attributes_stop_iter(struct GNUNET_CHAT_AttributeProcess *attributes);
    155 
    156 #endif /* GNUNET_CHAT_INTERNAL_ATTRIBUTE_PROCESS_H_ */