aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_ticket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_ticket.c')
-rw-r--r--src/gnunet_chat_ticket.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gnunet_chat_ticket.c b/src/gnunet_chat_ticket.c
index 332b4ae..4aa0066 100644
--- a/src/gnunet_chat_ticket.c
+++ b/src/gnunet_chat_ticket.c
@@ -24,8 +24,11 @@
24 24
25#include "gnunet_chat_ticket.h" 25#include "gnunet_chat_ticket.h"
26 26
27#include "gnunet_chat_ticket_intern.c"
27#include "gnunet_chat_handle.h" 28#include "gnunet_chat_handle.h"
28#include <gnunet/gnunet_messenger_service.h> 29#include <gnunet/gnunet_messenger_service.h>
30#include <gnunet/gnunet_reclaim_service.h>
31#include <string.h>
29 32
30struct GNUNET_CHAT_Ticket* 33struct GNUNET_CHAT_Ticket*
31ticket_create_from_message (struct GNUNET_CHAT_Handle *handle, 34ticket_create_from_message (struct GNUNET_CHAT_Handle *handle,
@@ -45,6 +48,8 @@ ticket_create_from_message (struct GNUNET_CHAT_Handle *handle,
45 48
46 struct GNUNET_CHAT_Ticket *ticket = GNUNET_new(struct GNUNET_CHAT_Ticket); 49 struct GNUNET_CHAT_Ticket *ticket = GNUNET_new(struct GNUNET_CHAT_Ticket);
47 50
51 memset(ticket, 0, sizeof(struct GNUNET_CHAT_Ticket));
52
48 ticket->handle = handle; 53 ticket->handle = handle;
49 ticket->issuer = issuer; 54 ticket->issuer = issuer;
50 55
@@ -56,9 +61,41 @@ ticket_create_from_message (struct GNUNET_CHAT_Handle *handle,
56} 61}
57 62
58void 63void
64ticket_consume(struct GNUNET_CHAT_Ticket *ticket,
65 GNUNET_CHAT_TicketAttributeCallback callback,
66 void *cls)
67{
68 GNUNET_assert(ticket);
69
70 const struct GNUNET_CRYPTO_PrivateKey *key = handle_get_key(
71 ticket->handle
72 );
73
74 if (!key)
75 return;
76
77 if (ticket->op)
78 GNUNET_RECLAIM_cancel(ticket->op);
79
80 ticket->callback = callback;
81 ticket->closure = cls;
82
83 ticket->op = GNUNET_RECLAIM_ticket_consume(
84 ticket->handle->reclaim,
85 key,
86 &(ticket->ticket),
87 cb_ticket_consume_attribute,
88 ticket
89 );
90}
91
92void
59ticket_destroy (struct GNUNET_CHAT_Ticket *ticket) 93ticket_destroy (struct GNUNET_CHAT_Ticket *ticket)
60{ 94{
61 GNUNET_assert(ticket); 95 GNUNET_assert(ticket);
62 96
97 if (ticket->op)
98 GNUNET_RECLAIM_cancel(ticket->op);
99
63 GNUNET_free(ticket); 100 GNUNET_free(ticket);
64} 101}