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