libgnunetchat

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

gnunet_chat_ticket_process.h (3292B)


      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_ticket_process.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_INTERNAL_TICKET_PROCESS_H_
     26 #define GNUNET_CHAT_INTERNAL_TICKET_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_Contact;
     34 
     35 struct GNUNET_CHAT_TicketProcess
     36 {
     37   struct GNUNET_CHAT_Handle *handle;
     38   struct GNUNET_CHAT_Contact *contact;
     39 
     40   struct GNUNET_RECLAIM_Ticket *ticket;
     41   char *name;
     42 
     43   GNUNET_CHAT_ContactAttributeCallback callback;
     44   void *closure;
     45 
     46   struct GNUNET_RECLAIM_TicketIterator *iter;
     47   struct GNUNET_RECLAIM_Operation *op;
     48 
     49   struct GNUNET_CHAT_TicketProcess *next;
     50   struct GNUNET_CHAT_TicketProcess *prev;
     51 };
     52 
     53 /**
     54  * Creates a new ticket process resource to
     55  * handle general ticket management from
     56  * a specific char <i>contact</i> using
     57  * a given chat <i>handle</i>.
     58  *
     59  * The ticket process gets appended to the
     60  * list of processes from the handle implicitly.
     61  *
     62  * @param[in,out] handle Chat handle
     63  * @param[in,out] contact Chat contact
     64  * @param[in] name Attribute name or NULL
     65  * @return New ticket process
     66  */
     67 struct GNUNET_CHAT_TicketProcess*
     68 internal_tickets_create(struct GNUNET_CHAT_Handle *handle,
     69                         struct GNUNET_CHAT_Contact *contact,
     70                         const char *name);
     71 
     72 /**
     73  * Creates a new copy of a given <i>tickets</i> 
     74  * process with additional information about a 
     75  * valid reclaim <i>ticket</i>.
     76  *
     77  * @see internal_tickets_create()
     78  *
     79  * @param[in] tickets Original ticket process
     80  * @param[in] ticket Reclaim ticket or NULL
     81  * @return New ticket process
     82  */
     83 struct GNUNET_CHAT_TicketProcess*
     84 internal_tickets_copy(const struct GNUNET_CHAT_TicketProcess* tickets,
     85                       const struct GNUNET_RECLAIM_Ticket *ticket);
     86 
     87 /**
     88  * Destroys and frees a given <i>tickets</i> 
     89  * process resource. This will implicitly remove
     90  * it from its chat handles list of processes.
     91  *
     92  * @param[out] tickets Ticket process
     93  */
     94 void
     95 internal_tickets_destroy(struct GNUNET_CHAT_TicketProcess *tickets);
     96 
     97 /**
     98  * Continues the iteration of a given <i>tickets</i> 
     99  * process resource to its next step.
    100  *
    101  * @param[in,out] tickets Ticket process
    102  */
    103 void
    104 internal_tickets_next_iter(struct GNUNET_CHAT_TicketProcess *tickets);
    105 
    106 /**
    107  * Stops the iteration of a given <i>tickets</i> 
    108  * process resource.
    109  *
    110  * @param[in,out] tickets Ticket process
    111  */
    112 void
    113 internal_tickets_stop_iter(struct GNUNET_CHAT_TicketProcess *tickets);
    114 
    115 #endif /* GNUNET_CHAT_INTERNAL_TICKET_PROCESS_H_ */