diff options
Diffstat (limited to 'src/escrow/escrow_plugin_helper.h')
-rw-r--r-- | src/escrow/escrow_plugin_helper.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/escrow/escrow_plugin_helper.h b/src/escrow/escrow_plugin_helper.h new file mode 100644 index 000000000..f2a54eb6b --- /dev/null +++ b/src/escrow/escrow_plugin_helper.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020 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 | /** | ||
22 | * @author Johannes Späth | ||
23 | * @file escrow/escrow_plugin.h | ||
24 | * | ||
25 | * @brief helper functions for escrow plugins | ||
26 | */ | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_identity_service.h" | ||
31 | #include "gnunet_escrow_plugin.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Maintains the ego list for an escrow plugin. | ||
36 | * This function is an implementation of GNUNET_IDENTITY_Callback. | ||
37 | * | ||
38 | * It is initially called for all egos and then again | ||
39 | * whenever a ego's identifier changes or if it is deleted. At the | ||
40 | * end of the initial pass over all egos, the function is once called | ||
41 | * with 'NULL' for 'ego'. That does NOT mean that the callback won't | ||
42 | * be invoked in the future or that there was an error. | ||
43 | * | ||
44 | * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', | ||
45 | * this function is only called ONCE, and 'NULL' being passed in | ||
46 | * 'ego' does indicate an error (i.e. name is taken or no default | ||
47 | * value is known). If 'ego' is non-NULL and if '*ctx' | ||
48 | * is set in those callbacks, the value WILL be passed to a subsequent | ||
49 | * call to the identity callback of 'GNUNET_IDENTITY_connect' (if | ||
50 | * that one was not NULL). | ||
51 | * | ||
52 | * When an identity is renamed, this function is called with the | ||
53 | * (known) ego but the NEW identifier. | ||
54 | * | ||
55 | * When an identity is deleted, this function is called with the | ||
56 | * (known) ego and "NULL" for the 'identifier'. In this case, | ||
57 | * the 'ego' is henceforth invalid (and the 'ctx' should also be | ||
58 | * cleaned up). | ||
59 | * | ||
60 | * @param cls plugin handle | ||
61 | * @param ego ego handle | ||
62 | * @param ctx context for application to store data for this ego | ||
63 | * (during the lifetime of this process, initially NULL) | ||
64 | * @param identifier identifier assigned by the user for this ego, | ||
65 | * NULL if the user just deleted the ego and it | ||
66 | * must thus no longer be used | ||
67 | */ | ||
68 | void | ||
69 | ESCROW_list_ego (void *cls, | ||
70 | struct GNUNET_IDENTITY_Ego *ego, | ||
71 | void **ctx, | ||
72 | const char *identifier); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Cleanup the ego list of an escrow plugin. | ||
77 | * | ||
78 | * @param ph handle for the plugin | ||
79 | */ | ||
80 | void | ||
81 | ESCROW_cleanup_ego_list (struct ESCROW_PluginHandle *ph); | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Update the status of an escrow in the configuration. | ||
86 | * | ||
87 | * @param h handle for the escrow component | ||
88 | * @param ego the ego of which the escrow status is updated | ||
89 | * @param plugin_name the name of the used plugin | ||
90 | * | ||
91 | * @return GNUNET_OK on success | ||
92 | */ | ||
93 | int | ||
94 | ESCROW_update_escrow_status (struct GNUNET_ESCROW_Handle *h, | ||
95 | struct GNUNET_IDENTITY_Ego *ego, | ||
96 | const char *plugin_name); | ||
97 | |||
98 | /** | ||
99 | * Get the status of an escrow from the configuration. | ||
100 | * | ||
101 | * @param h handle for the escrow component | ||
102 | * @param ego the ego of which the escrow status has to be obtained | ||
103 | * | ||
104 | * @return the status of the escrow, packed into a GNUNET_ESCROW_Status struct | ||
105 | */ | ||
106 | struct GNUNET_ESCROW_Status * | ||
107 | ESCROW_get_escrow_status (struct GNUNET_ESCROW_Handle *h, | ||
108 | struct GNUNET_IDENTITY_Ego *ego); | ||