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