libgnunetchat

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

gnunet_chat_ticket.h (2421B)


      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.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_TICKET_H_
     26 #define GNUNET_CHAT_TICKET_H_
     27 
     28 #include <gnunet/gnunet_messenger_service.h>
     29 #include <gnunet/gnunet_reclaim_service.h>
     30 #include <gnunet/gnunet_util_lib.h>
     31 
     32 #include "gnunet_chat_lib.h"
     33 
     34 struct GNUNET_CHAT_Ticket
     35 {
     36   struct GNUNET_CHAT_Handle *handle;
     37   struct GNUNET_CHAT_Contact *issuer;
     38 
     39   GNUNET_CHAT_ContactAttributeCallback callback;
     40   void *closure;
     41 
     42   struct GNUNET_RECLAIM_Operation *op;
     43 
     44   struct GNUNET_RECLAIM_Ticket ticket;
     45 };
     46 
     47 /**
     48  * Creates a chat ticket from a ticket body in a
     49  * <i>message</i> received by a chat <i>handle</i>
     50  * from a given <i>issuer</i>.
     51  *
     52  * @param[in,out] handle Chat handle
     53  * @param[in,out] issuer Messenger contact
     54  * @param[in] message Ticket message body
     55  * @return New chat ticket
     56  */
     57 struct GNUNET_CHAT_Ticket*
     58 ticket_create_from_message (struct GNUNET_CHAT_Handle *handle,
     59                             struct GNUNET_CHAT_Contact *issuer,
     60                             const struct GNUNET_MESSENGER_MessageTicket *message);
     61 
     62 /**
     63  * Consumes a chat <i>ticket</i> and calls a selected
     64  * <i>callback</i> for each of its attributes using
     65  * a custom closure.
     66  *
     67  * @param[in,out] ticket Chat ticket
     68  * @param[in] callback Attribute callback
     69  * @param[in,out] cls Closure
     70  */
     71 void
     72 ticket_consume(struct GNUNET_CHAT_Ticket *ticket,
     73                GNUNET_CHAT_ContactAttributeCallback callback,
     74                void *cls);
     75 
     76 /**
     77  * Destroys a chat <i>ticket</i> and frees its memory.
     78  *
     79  * @param[in,out] ticket Chat ticket
     80  */
     81 void
     82 ticket_destroy (struct GNUNET_CHAT_Ticket *ticket);
     83 
     84 #endif /* GNUNET_CHAT_TICKET_H_ */