856824e60cfc822bd57e9ff21acffbe46a7f588e
[oweals/gnunet.git] / src / include / gnunet_psycstore_service.h
1 /*
2      This file is part of GNUnet.
3      (C) 2013 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_psycstore_service.h
23  * @brief PSYCstore service; implements persistent storage for the PSYC service
24  * @author tg
25  * @author Christian Grothoff
26  */
27 #ifndef GNUNET_PSYCSTORE_SERVICE_H
28 #define GNUNET_PSYCSTORE_SERVICE_H
29
30 #ifdef __cplusplus
31 extern "C"
32 {no
33 #if 0                           /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38 #include "gnunet_util_lib.h"
39
40 /**
41  * Version number of GNUnet PSYCstore API.
42  */
43 #define GNUNET_PSYCSTORE_VERSION 0x00000000
44
45 /**
46  * Handle for a PSYCstore
47  */
48 struct GNUNET_PSYCSTORE_Handle;
49
50
51 struct GNUNET_PSYCSTORE_Handle *
52 GNUNET_PSYCSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
53
54
55 void
56 GNUNET_PSYCSTORE_disconnect (struct GNUNET_PSYCSTORE_Handle *h);
57
58
59 /**
60  * Handle for an operation on the PSYCSTORE (useful to cancel the operation).
61  */
62 struct GNUNET_PSYCSTORE_OperationHandle;
63
64
65 /**
66  *
67  * @param result GNUNET_SYSERR on error,
68  *        GNUNET_YES on success or if the peer was a member,
69  *        GNUNET_NO if the peer was not a member
70  */
71 typedef void (*GNUNET_PSYCSTORE_ContinuationCallback)(void *cls,
72                                                       int result);
73
74
75 struct GNUNET_PSYCSTORE_OperationHandle *
76 GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
77                               const struct GNUNET_HashCode *channel_id,
78                               uint64_t message_id,
79                               const struct GNUNET_PeerIdentity *peer,
80                               int did_join,
81                               GNUNET_PSYCSTORE_ContinuationCallback ccb,
82                               void *ccb_cls);
83
84
85 struct GNUNET_PSYCSTORE_OperationHandle *
86 GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
87                                   const struct GNUNET_HashCode *channel_id,
88                                   uint64_t message_id,
89                                   const struct GNUNET_PeerIdentity *peer,
90                                   GNUNET_PSYCSTORE_ContinuationCallback ccb,
91                                   void *ccb_cls);
92
93
94 struct GNUNET_PSYCSTORE_OperationHandle *
95 GNUNET_PSYCSTORE_message_store (struct GNUNET_PSYCSTORE_Handle *h,
96                                 const struct GNUNET_HashCode *channel_id,
97                                 const struct GNUNET_MULTICAST_MessageHeader *message,
98                                 GNUNET_PSYCSTORE_ContinuationCallback ccb,
99                                 void *ccb_cls);
100
101
102 typedef void (*GNUNET_PSYCSTORE_MessageResultCallback)(void *cls,       
103                                                        uint64_t message_id,                                    
104                                                        const struct GNUNET_MULTICAST_MessageHeader *message);
105
106
107 struct GNUNET_PSYCSTORE_OperationHandle *
108 GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
109                               const struct GNUNET_HashCode *channel_id,
110                               uint64_t message_id,
111                               GNUNET_PSYCSTORE_MessageResultCallback rcb,
112                               void *rcb_cls);
113
114
115 struct GNUNET_PSYCSTORE_OperationHandle *
116 GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
117                                      const struct GNUNET_HashCode *channel_id,
118                                      GNUNET_PSYCSTORE_MessageResultCallback rcb,
119                                      void *rcb_cls);
120
121
122 struct GNUNET_PSYCSTORE_OperationHandle *
123 GNUNET_PSYCSTORE_state_set (struct GNUNET_PSYCSTORE_Handle *h,
124                             const struct GNUNET_HashCode *channel_id,
125                             const char *state_name,
126                             size_t size,
127                             const void *value,
128                             GNUNET_PSYCSTORE_ContinuationCallback ccb,
129                             void *ccb_cls);
130
131
132 typedef void (*GNUNET_PSYCSTORE_StateResultCallback)(void *cls,
133                                                      const char *state_name,
134                                                      size_t size,
135                                                      const void *value);
136
137
138 struct GNUNET_PSYCSTORE_OperationHandle *
139 GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
140                             const struct GNUNET_HashCode *channel_id,
141                             const char *state_name,
142                             GNUNET_PSYCSTORE_StateResultCallback rcb,
143                             void *rcb_cls);
144
145
146 struct GNUNET_PSYCSTORE_OperationHandle *
147 GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
148                                 const struct GNUNET_HashCode *channel_id,
149                                 GNUNET_PSYCSTORE_StateResultCallback rcb,
150                                 void *rcb_cls);
151
152
153 void
154 GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *oh);
155
156
157
158
159 #if 0                           /* keep Emacsens' auto-indent happy */
160 {
161 #endif
162 #ifdef __cplusplus
163 }
164 #endif
165
166 /* ifndef GNUNET_PSYCSTORE_SERVICE_H */
167 #endif
168 /* end of gnunet_psycstore_service.h */