core: New API gpgme_op_set_uid_flag.
[gpgme.git] / src / engine.h
1 /* engine.h - GPGME engine interface.
2    Copyright (C) 2000 Werner Koch (dd9jn)
3    Copyright (C) 2001, 2002, 2003, 2004, 2010 g10 Code GmbH
4
5    This file is part of GPGME.
6
7    GPGME is free software; you can redistribute it and/or modify it
8    under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 2.1 of
10    the License, or (at your option) any later version.
11
12    GPGME is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20    02111-1307, USA.  */
21
22 #ifndef ENGINE_H
23 #define ENGINE_H
24
25 #include "gpgme.h"
26
27 /* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey.  */
28 #define GENKEY_EXTRAFLAG_ARMOR      1
29 #define GENKEY_EXTRAFLAG_REVOKE     2
30 #define GENKEY_EXTRAFLAG_SETPRIMARY 4
31
32
33 struct engine;
34 typedef struct engine *engine_t;
35
36 typedef gpgme_error_t (*engine_status_handler_t) (void *priv,
37                                                   gpgme_status_code_t code,
38                                                   char *args);
39 typedef gpgme_error_t (*engine_colon_line_handler_t) (void *priv, char *line);
40 typedef gpgme_error_t (*engine_command_handler_t) (void *priv,
41                                                    gpgme_status_code_t code,
42                                                    const char *keyword,
43                                                    int fd, int *processed);
44 typedef gpgme_error_t (*engine_assuan_result_cb_t) (void *priv,
45                                                     gpgme_error_t result);
46
47 /* Helper for gpgme_set_global_flag.  */
48 int _gpgme_set_engine_minimal_version (const char *value);
49
50 /* Get a deep copy of the engine info and return it in INFO.  */
51 gpgme_error_t _gpgme_engine_info_copy (gpgme_engine_info_t *r_info);
52
53 /* Release the engine info INFO.  */
54 void _gpgme_engine_info_release (gpgme_engine_info_t info);
55
56 /* Set the engine info for the info list INFO, protocol PROTO, to the
57    file name FILE_NAME and the home directory HOME_DIR.  */
58 gpgme_error_t _gpgme_set_engine_info (gpgme_engine_info_t info,
59                                       gpgme_protocol_t praoto,
60                                       const char *file_name,
61                                       const char *home_dir);
62
63
64 gpgme_error_t _gpgme_engine_new (gpgme_engine_info_t info,
65                                  engine_t *r_engine);
66 gpgme_error_t _gpgme_engine_reset (engine_t engine);
67
68 gpgme_error_t _gpgme_engine_set_locale (engine_t engine, int category,
69                                         const char *value);
70 gpgme_error_t _gpgme_engine_set_protocol (engine_t engine,
71                                           gpgme_protocol_t protocol);
72 void _gpgme_engine_release (engine_t engine);
73 void _gpgme_engine_set_status_cb (engine_t engine,
74                                   gpgme_status_cb_t cb, void *cb_value);
75 void _gpgme_engine_set_status_handler (engine_t engine,
76                                        engine_status_handler_t fnc,
77                                        void *fnc_value);
78 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
79                                                  engine_command_handler_t fnc,
80                                                  void *fnc_value,
81                                                  gpgme_data_t data);
82 gpgme_error_t
83 _gpgme_engine_set_colon_line_handler (engine_t engine,
84                                       engine_colon_line_handler_t fnc,
85                                       void *fnc_value);
86 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
87                                         gpgme_data_t plain,
88                                         int export_session_key,
89                                         const char *override_session_key);
90 gpgme_error_t _gpgme_engine_op_decrypt_verify (engine_t engine,
91                                                gpgme_data_t ciph,
92                                                gpgme_data_t plain,
93                                                int export_session_key,
94                                                const char *override_session_key
95                                                );
96 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
97                                        int allow_secret);
98 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
99                                      gpgme_key_t key, gpgme_data_t out,
100                                      gpgme_ctx_t ctx /* FIXME */);
101 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
102                                         gpgme_key_t recp[],
103                                         gpgme_encrypt_flags_t flags,
104                                         gpgme_data_t plain, gpgme_data_t ciph,
105                                         int use_armor);
106 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
107                                              gpgme_key_t recp[],
108                                              gpgme_encrypt_flags_t flags,
109                                              gpgme_data_t plain,
110                                              gpgme_data_t ciph,
111                                              int use_armor,
112                                              gpgme_ctx_t ctx /* FIXME */);
113 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
114                                        gpgme_export_mode_t mode,
115                                        gpgme_data_t keydata, int use_armor);
116 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
117                                            const char *pattern[],
118                                            gpgme_export_mode_t mode,
119                                            gpgme_data_t keydata,
120                                            int use_armor);
121 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
122                                        const char *userid, const char *algo,
123                                        unsigned long reserved,
124                                        unsigned long expires,
125                                        gpgme_key_t key, unsigned int flags,
126                                        gpgme_data_t help_data,
127                                        unsigned int extraflags,
128                                        gpgme_data_t pubkey,
129                                        gpgme_data_t seckey);
130 gpgme_error_t _gpgme_engine_op_keysign (engine_t engine,
131                                         gpgme_key_t key, const char *userid,
132                                         unsigned long expires,
133                                         unsigned int flags,
134                                         gpgme_ctx_t ctx);
135 gpgme_error_t _gpgme_engine_op_tofu_policy (engine_t engine,
136                                             gpgme_key_t key,
137                                             gpgme_tofu_policy_t policy);
138 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
139                                        gpgme_data_t keydata,
140                                        gpgme_key_t *keyarray);
141 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
142                                         const char *pattern,
143                                         int secret_only,
144                                         gpgme_keylist_mode_t mode,
145                                         int engine_flags);
146 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
147                                             const char *pattern[],
148                                             int secret_only,
149                                             int reserved,
150                                             gpgme_keylist_mode_t mode,
151                                             int engine_flags);
152 gpgme_error_t _gpgme_engine_op_keylist_data (engine_t engine,
153                                              gpgme_data_t data);
154 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
155                                      gpgme_data_t out, gpgme_sig_mode_t mode,
156                                      int use_armor, int use_textmode,
157                                      int include_certs,
158                                      gpgme_ctx_t ctx /* FIXME */);
159 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
160                                           const char *pattern);
161 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
162                                        gpgme_data_t signed_text,
163                                        gpgme_data_t plaintext,
164                                        gpgme_ctx_t ctx);
165
166 gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
167                                             gpgme_data_t output,
168                                             unsigned int flags);
169 gpgme_error_t _gpgme_engine_op_assuan_transact
170                 (engine_t engine,
171                  const char *command,
172                  gpgme_assuan_data_cb_t data_cb,
173                  void *data_cb_value,
174                  gpgme_assuan_inquire_cb_t inq_cb,
175                  void *inq_cb_value,
176                  gpgme_assuan_status_cb_t status_cb,
177                  void *status_cb_value);
178
179 gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
180                                           gpgme_conf_comp_t *conf_p);
181 gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
182                                           gpgme_conf_comp_t conf);
183
184 gpgme_error_t _gpgme_engine_op_query_swdb (engine_t engine,
185                                            const char *name,
186                                            const char *iversion,
187                                            gpgme_query_swdb_result_t result);
188
189
190 void _gpgme_engine_set_io_cbs (engine_t engine,
191                                gpgme_io_cbs_t io_cbs);
192 void _gpgme_engine_io_event (engine_t engine,
193                              gpgme_event_io_t type, void *type_data);
194
195 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
196
197 gpgme_error_t _gpgme_engine_cancel_op (engine_t engine);
198
199 gpgme_error_t _gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key,
200                                        unsigned int flags);
201
202 gpgme_error_t _gpgme_engine_set_pinentry_mode (engine_t engine,
203                                                gpgme_pinentry_mode_t mode);
204
205 gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
206                                       const char *file, const char *argv[],
207                                       gpgme_data_t datain,
208                                       gpgme_data_t dataout,
209                                       gpgme_data_t dataerr,
210                                       unsigned int flags);
211
212 /* The available engine option flags.  */
213 #define GPGME_ENGINE_FLAG_OFFLINE        1
214
215
216 #endif /* ENGINE_H */