34bf8e909bddbcee43c16e23f9dd87f70d964616
[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_set_engine_flags (engine_t engine, gpgme_ctx_t ctx);
73 void _gpgme_engine_release (engine_t engine);
74 void _gpgme_engine_set_status_cb (engine_t engine,
75                                   gpgme_status_cb_t cb, void *cb_value);
76 void _gpgme_engine_set_status_handler (engine_t engine,
77                                        engine_status_handler_t fnc,
78                                        void *fnc_value);
79 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
80                                                  engine_command_handler_t fnc,
81                                                  void *fnc_value,
82                                                  gpgme_data_t data);
83 gpgme_error_t
84 _gpgme_engine_set_colon_line_handler (engine_t engine,
85                                       engine_colon_line_handler_t fnc,
86                                       void *fnc_value);
87 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine,
88                                         gpgme_decrypt_flags_t flags,
89                                         gpgme_data_t ciph,
90                                         gpgme_data_t plain,
91                                         int export_session_key,
92                                         const char *override_session_key,
93                                         int auto_key_retrieve);
94 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
95                                        unsigned int flags);
96 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
97                                      gpgme_key_t key, gpgme_data_t out,
98                                      gpgme_ctx_t ctx /* FIXME */);
99 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
100                                         gpgme_key_t recp[],
101                                         gpgme_encrypt_flags_t flags,
102                                         gpgme_data_t plain, gpgme_data_t ciph,
103                                         int use_armor);
104 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
105                                              gpgme_key_t recp[],
106                                              gpgme_encrypt_flags_t flags,
107                                              gpgme_data_t plain,
108                                              gpgme_data_t ciph,
109                                              int use_armor,
110                                              gpgme_ctx_t ctx /* FIXME */);
111 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
112                                        gpgme_export_mode_t mode,
113                                        gpgme_data_t keydata, int use_armor);
114 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
115                                            const char *pattern[],
116                                            gpgme_export_mode_t mode,
117                                            gpgme_data_t keydata,
118                                            int use_armor);
119 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
120                                        const char *userid, const char *algo,
121                                        unsigned long reserved,
122                                        unsigned long expires,
123                                        gpgme_key_t key, unsigned int flags,
124                                        gpgme_data_t help_data,
125                                        unsigned int extraflags,
126                                        gpgme_data_t pubkey,
127                                        gpgme_data_t seckey);
128 gpgme_error_t _gpgme_engine_op_keysign (engine_t engine,
129                                         gpgme_key_t key, const char *userid,
130                                         unsigned long expires,
131                                         unsigned int flags,
132                                         gpgme_ctx_t ctx);
133 gpgme_error_t _gpgme_engine_op_tofu_policy (engine_t engine,
134                                             gpgme_key_t key,
135                                             gpgme_tofu_policy_t policy);
136 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
137                                        gpgme_data_t keydata,
138                                        gpgme_key_t *keyarray);
139 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
140                                         const char *pattern,
141                                         int secret_only,
142                                         gpgme_keylist_mode_t mode,
143                                         int engine_flags);
144 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
145                                             const char *pattern[],
146                                             int secret_only,
147                                             int reserved,
148                                             gpgme_keylist_mode_t mode,
149                                             int engine_flags);
150 gpgme_error_t _gpgme_engine_op_keylist_data (engine_t engine,
151                                              gpgme_data_t data);
152 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
153                                      gpgme_data_t out, gpgme_sig_mode_t mode,
154                                      int use_armor, int use_textmode,
155                                      int include_certs,
156                                      gpgme_ctx_t ctx /* FIXME */);
157 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
158                                           const char *pattern);
159 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
160                                        gpgme_data_t signed_text,
161                                        gpgme_data_t plaintext,
162                                        gpgme_ctx_t ctx);
163
164 gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
165                                             gpgme_data_t output,
166                                             unsigned int flags);
167 gpgme_error_t _gpgme_engine_op_assuan_transact
168                 (engine_t engine,
169                  const char *command,
170                  gpgme_assuan_data_cb_t data_cb,
171                  void *data_cb_value,
172                  gpgme_assuan_inquire_cb_t inq_cb,
173                  void *inq_cb_value,
174                  gpgme_assuan_status_cb_t status_cb,
175                  void *status_cb_value);
176
177 gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
178                                           gpgme_conf_comp_t *conf_p);
179 gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
180                                           gpgme_conf_comp_t conf);
181 gpgme_error_t _gpgme_engine_op_conf_dir (engine_t engine,
182                                          const char *what,
183                                          char **result);
184
185 gpgme_error_t _gpgme_engine_op_query_swdb (engine_t engine,
186                                            const char *name,
187                                            const char *iversion,
188                                            gpgme_query_swdb_result_t result);
189
190
191 void _gpgme_engine_set_io_cbs (engine_t engine,
192                                gpgme_io_cbs_t io_cbs);
193 void _gpgme_engine_io_event (engine_t engine,
194                              gpgme_event_io_t type, void *type_data);
195
196 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
197
198 gpgme_error_t _gpgme_engine_cancel_op (engine_t engine);
199
200 gpgme_error_t _gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key,
201                                        unsigned int flags);
202
203 gpgme_error_t _gpgme_engine_set_pinentry_mode (engine_t engine,
204                                                gpgme_pinentry_mode_t mode);
205
206 gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
207                                       const char *file, const char *argv[],
208                                       gpgme_data_t datain,
209                                       gpgme_data_t dataout,
210                                       gpgme_data_t dataerr,
211                                       unsigned int flags);
212
213 /* The available engine option flags.  */
214 #define GPGME_ENGINE_FLAG_OFFLINE        1
215
216
217 #endif /* ENGINE_H */