Fix CID 1596595: Resource leak
[claws.git] / src / privacy.h
blob65051dafc8f0c6b128384070754e58b73700c86f
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
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.
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.
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/>.
20 #ifndef PRIVACY_H
21 #define PRIVACY_H
23 typedef struct _PrivacySystem PrivacySystem;
24 typedef struct _PrivacyData PrivacyData;
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;
37 typedef struct _SignatureData {
38 SignatureStatus status;
39 gchar *info_short;
40 gchar *info_full;
41 } SignatureData;
43 typedef struct _SigCheckTaskResult {
44 SignatureData *sig_data;
45 struct _MimeInfo *newinfo;
46 } SigCheckTaskResult;
48 #include <glib.h>
50 #include "procmime.h"
51 #include "prefs_account.h"
53 void privacy_register_system (PrivacySystem *system);
54 void privacy_unregister_system (PrivacySystem *system);
56 void privacy_free_privacydata (PrivacyData *);
57 void privacy_free_signature_data (SignatureData *sig_data);
58 void privacy_free_sig_check_task_result (gpointer);
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);
69 gboolean privacy_mimeinfo_is_encrypted (MimeInfo *);
70 gint privacy_mimeinfo_decrypt (MimeInfo *);
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 *);
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);
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);
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;
99 void (*free_privacydata) (PrivacyData *data);
101 gboolean (*is_signed) (MimeInfo *mimeinfo);
102 gint (*check_signature) (MimeInfo *mimeinfo,
103 GCancellable *cancellable,
104 GAsyncReadyCallback callback,
105 gpointer user_data);
107 gboolean (*is_encrypted) (MimeInfo *mimeinfo);
108 MimeInfo *(*decrypt) (MimeInfo *mimeinfo);
110 gboolean can_sign;
111 gboolean (*sign) (MimeInfo *mimeinfo,
112 PrefsAccount *account,
113 const gchar *from_addr);
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);
124 struct _PrivacyData {
125 PrivacySystem *system;
128 void privacy_inhibit_encrypt_warning (const gchar *id,
129 gboolean inhibit);
130 gboolean privacy_auto_check_signatures(MimeInfo *mimeinfo);
132 #endif /* PRIVACY_H */