update copyright year
[claws.git] / src / privacy.h
1 /*
2  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifndef PRIVACY_H
21 #define PRIVACY_H
22
23 typedef struct _PrivacySystem PrivacySystem;
24 typedef struct _PrivacyData PrivacyData;
25
26 typedef enum {
27         SIGNATURE_UNCHECKED,
28         SIGNATURE_OK,
29         SIGNATURE_WARN,
30         SIGNATURE_KEY_EXPIRED,
31         SIGNATURE_INVALID,
32         SIGNATURE_CHECK_FAILED,
33         SIGNATURE_CHECK_TIMEOUT,
34         SIGNATURE_CHECK_ERROR
35 } SignatureStatus;
36
37 typedef struct _SignatureData {
38         SignatureStatus status;
39         gchar *info_short;
40         gchar *info_full;
41 } SignatureData;
42
43 typedef struct _SigCheckTaskResult {
44         SignatureData *sig_data;
45         struct _MimeInfo *newinfo;
46 } SigCheckTaskResult;
47
48 #include <glib.h>
49
50 #include "procmime.h"
51 #include "prefs_account.h"
52
53 void privacy_register_system                    (PrivacySystem *system);
54 void privacy_unregister_system                  (PrivacySystem *system);
55
56 void privacy_free_privacydata                   (PrivacyData *);
57 void privacy_free_signature_data                (SignatureData *sig_data);
58 void privacy_free_sig_check_task_result (gpointer);
59
60 void privacy_msginfo_get_signed_state           (MsgInfo *, gchar **system);
61 gboolean privacy_mimeinfo_is_signed             (MimeInfo *);
62 gint privacy_mimeinfo_check_signature   (MimeInfo *mimeinfo,
63         GCancellable *cancellable,
64         GAsyncReadyCallback callback,
65         gpointer user_data);
66 SignatureStatus privacy_mimeinfo_get_sig_status (MimeInfo *);
67 gchar *privacy_mimeinfo_get_sig_info            (MimeInfo *, gboolean);
68
69 gboolean privacy_mimeinfo_is_encrypted          (MimeInfo *);
70 gint privacy_mimeinfo_decrypt                   (MimeInfo *);
71
72 GSList *privacy_get_system_ids                  ();
73 const gchar *privacy_system_get_name            (const gchar *);
74 gboolean privacy_system_can_sign                (const gchar *);
75 gboolean privacy_system_can_encrypt             (const gchar *);
76
77 gboolean privacy_sign                           (const gchar  *system,
78                                                  MimeInfo     *mimeinfo,
79                                                  PrefsAccount *account,
80                                                  const gchar *from_addr);
81 gchar *privacy_get_encrypt_data                 (const gchar  *system,
82                                                  GSList       *recp_names);
83 const gchar *privacy_get_encrypt_warning        (const gchar  *system);
84 gboolean privacy_encrypt                        (const gchar  *system,
85                                                  MimeInfo     *mimeinfo,
86                                                  const gchar  *encdata);
87
88 void privacy_set_error                          (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
89 void privacy_reset_error                                (void);
90 gboolean privacy_peek_error                             (void);
91 const gchar *privacy_get_error                  (void);
92
93 struct _PrivacySystem {
94         /** Identifier for the PrivacySystem that can use in config files */
95         gchar            *id;
96         /** Human readable name for the PrivacySystem for the user interface */
97         gchar            *name;
98
99         void             (*free_privacydata)    (PrivacyData *data);
100
101         gboolean         (*is_signed)           (MimeInfo *mimeinfo);
102         gint             (*check_signature)     (MimeInfo *mimeinfo,
103                                                  GCancellable *cancellable,
104                                                  GAsyncReadyCallback callback,
105                                                  gpointer user_data);
106
107         gboolean         (*is_encrypted)        (MimeInfo *mimeinfo);
108         MimeInfo        *(*decrypt)             (MimeInfo *mimeinfo);
109
110         gboolean           can_sign;
111         gboolean         (*sign)                (MimeInfo *mimeinfo,
112                                                  PrefsAccount *account, 
113                                                  const gchar *from_addr);
114
115         gboolean           can_encrypt;
116         gchar           *(*get_encrypt_data)    (GSList *recp_names);
117         gboolean         (*encrypt)             (MimeInfo *mimeinfo,
118                                                  const gchar *encrypt_data);
119         const gchar     *(*get_encrypt_warning) (void);
120         void             (*inhibit_encrypt_warning)     (gboolean inhibit);
121         gboolean         (*auto_check_signatures)(void);
122 };
123
124 struct _PrivacyData {
125         PrivacySystem   *system;
126 };
127
128 void privacy_inhibit_encrypt_warning            (const gchar *id,
129                                                  gboolean inhibit);
130 gboolean privacy_auto_check_signatures(MimeInfo *mimeinfo);
131
132 #endif /* PRIVACY_H */