First take on the low-level assuan interface.
[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 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 struct engine;
28 typedef struct engine *engine_t;
29
30 typedef gpgme_error_t (*engine_status_handler_t) (void *priv,
31                                                   gpgme_status_code_t code,
32                                                   char *args);
33 typedef gpgme_error_t (*engine_colon_line_handler_t) (void *priv, char *line);
34 typedef gpgme_error_t (*engine_command_handler_t) (void *priv,
35                                                    gpgme_status_code_t code,
36                                                    const char *keyword,
37                                                    int fd, int *processed);
38 typedef gpgme_error_t (*engine_assuan_result_cb_t) (void *priv,
39                                                     gpgme_error_t result);
40
41
42 /* Get a deep copy of the engine info and return it in INFO.  */
43 gpgme_error_t _gpgme_engine_info_copy (gpgme_engine_info_t *r_info);
44
45 /* Release the engine info INFO.  */
46 void _gpgme_engine_info_release (gpgme_engine_info_t info);
47
48 /* Set the engine info for the info list INFO, protocol PROTO, to the
49    file name FILE_NAME and the home directory HOME_DIR.  */
50 gpgme_error_t _gpgme_set_engine_info (gpgme_engine_info_t info,
51                                       gpgme_protocol_t praoto,
52                                       const char *file_name,
53                                       const char *home_dir);
54
55
56 gpgme_error_t _gpgme_engine_new (gpgme_engine_info_t info,
57                                  engine_t *r_engine);
58 gpgme_error_t _gpgme_engine_reset (engine_t engine);
59
60 gpgme_error_t _gpgme_engine_set_locale (engine_t engine, int category,
61                                         const char *value);
62
63 void _gpgme_engine_release (engine_t engine);
64 void _gpgme_engine_set_status_handler (engine_t engine,
65                                        engine_status_handler_t fnc,
66                                        void *fnc_value);
67 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
68                                                  engine_command_handler_t fnc,
69                                                  void *fnc_value,
70                                                  gpgme_data_t data);
71 gpgme_error_t
72 _gpgme_engine_set_colon_line_handler (engine_t engine,
73                                       engine_colon_line_handler_t fnc,
74                                       void *fnc_value);
75 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine,
76                                         gpgme_data_t ciph,
77                                         gpgme_data_t plain);
78 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
79                                        int allow_secret);
80 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
81                                      gpgme_key_t key, gpgme_data_t out,
82                                      gpgme_ctx_t ctx /* FIXME */);
83 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
84                                         gpgme_key_t recp[],
85                                         gpgme_encrypt_flags_t flags,
86                                         gpgme_data_t plain, gpgme_data_t ciph,
87                                         int use_armor);
88 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
89                                              gpgme_key_t recp[],
90                                              gpgme_encrypt_flags_t flags,
91                                              gpgme_data_t plain,
92                                              gpgme_data_t ciph,
93                                              int use_armor,
94                                              gpgme_ctx_t ctx /* FIXME */);
95 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
96                                        unsigned int reserved,
97                                        gpgme_data_t keydata, int use_armor);
98 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
99                                            const char *pattern[],
100                                            unsigned int reserved,
101                                            gpgme_data_t keydata,
102                                            int use_armor);
103 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
104                                        gpgme_data_t help_data,
105                                        int use_armor, gpgme_data_t pubkey,
106                                        gpgme_data_t seckey);
107 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
108                                        gpgme_data_t keydata);
109 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
110                                         const char *pattern,
111                                         int secret_only,
112                                         gpgme_keylist_mode_t mode);
113 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
114                                             const char *pattern[],
115                                             int secret_only,
116                                             int reserved,
117                                             gpgme_keylist_mode_t mode);
118 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
119                                      gpgme_data_t out, gpgme_sig_mode_t mode,
120                                      int use_armor, int use_textmode,
121                                      int include_certs,
122                                      gpgme_ctx_t ctx /* FIXME */);
123 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
124                                           const char *pattern);
125 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
126                                        gpgme_data_t signed_text,
127                                        gpgme_data_t plaintext);
128
129 gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
130                                             gpgme_data_t output,
131                                             unsigned int flags);
132 gpgme_error_t _gpgme_engine_op_assuan_transact 
133                 (engine_t engine, 
134                  const char *command,
135                  engine_assuan_result_cb_t result_cb,
136                  void *result_cb_value,
137                  gpgme_assuan_data_cb_t data_cb,
138                  void *data_cb_value,
139                  gpgme_assuan_inquire_cb_t inq_cb,
140                  void *inq_cb_value,
141                  gpgme_assuan_status_cb_t status_cb,
142                  void *status_cb_value);
143
144 gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
145                                           gpgme_conf_comp_t *conf_p);
146 gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
147                                           gpgme_conf_comp_t conf);
148
149 void _gpgme_engine_set_io_cbs (engine_t engine,
150                                gpgme_io_cbs_t io_cbs);
151 void _gpgme_engine_io_event (engine_t engine,
152                              gpgme_event_io_t type, void *type_data);
153
154 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
155
156 #endif /* ENGINE_H */