2008-06-27 [paul] 3.4.0cvs114
[claws.git] / src / privacy.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 Hiroyuki Yamamoto & the Claws Mail team
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 } SignatureStatus;
35
36 #include <glib.h>
37
38 #include "procmime.h"
39 #include "prefs_account.h"
40
41 void privacy_register_system                    (PrivacySystem *system);
42 void privacy_unregister_system                  (PrivacySystem *system);
43
44 void privacy_free_privacydata                   (PrivacyData *);
45
46 gboolean privacy_mimeinfo_is_signed             (MimeInfo *);
47 gint privacy_mimeinfo_check_signature           (MimeInfo *);
48 SignatureStatus privacy_mimeinfo_get_sig_status (MimeInfo *);
49 gchar *privacy_mimeinfo_sig_info_short          (MimeInfo *);
50 gchar *privacy_mimeinfo_sig_info_full           (MimeInfo *);
51
52 gboolean privacy_mimeinfo_is_encrypted          (MimeInfo *);
53 gint privacy_mimeinfo_decrypt                   (MimeInfo *);
54
55 GSList *privacy_get_system_ids                  ();
56 const gchar *privacy_system_get_name            (const gchar *);
57 gboolean privacy_system_can_sign                (const gchar *);
58 gboolean privacy_system_can_encrypt             (const gchar *);
59
60 gboolean privacy_sign                           (const gchar  *system,
61                                                  MimeInfo     *mimeinfo,
62                                                  PrefsAccount *account);
63 gchar *privacy_get_encrypt_data                 (const gchar  *system,
64                                                  GSList       *recp_names);
65 const gchar *privacy_get_encrypt_warning        (const gchar  *system);
66 gboolean privacy_encrypt                        (const gchar  *system,
67                                                  MimeInfo     *mimeinfo,
68                                                  const gchar  *encdata);
69
70 void privacy_set_error                          (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
71 void privacy_reset_error                                (void);
72 gboolean privacy_peek_error                             (void);
73 const gchar *privacy_get_error                  (void);
74
75 struct _PrivacySystem {
76         /** Identifier for the PrivacySystem that can use in config files */
77         gchar            *id;
78         /** Human readable name for the PrivacySystem for the user interface */
79         gchar            *name;
80
81         void             (*free_privacydata)    (PrivacyData *data);
82
83         gboolean         (*is_signed)           (MimeInfo *mimeinfo);
84         gint             (*check_signature)     (MimeInfo *mimeinfo);
85         SignatureStatus  (*get_sig_status)      (MimeInfo *mimeinfo);
86         gchar           *(*get_sig_info_short)  (MimeInfo *mimeinfo);
87         gchar           *(*get_sig_info_full)   (MimeInfo *mimeinfo);
88
89         gboolean         (*is_encrypted)        (MimeInfo *mimeinfo);
90         MimeInfo        *(*decrypt)             (MimeInfo *mimeinfo);
91
92         gboolean           can_sign;
93         gboolean         (*sign)                (MimeInfo *mimeinfo,
94                                                  PrefsAccount *account);
95
96         gboolean           can_encrypt;
97         gchar           *(*get_encrypt_data)    (GSList *recp_names);
98         gboolean         (*encrypt)             (MimeInfo *mimeinfo,
99                                                  const gchar *encrypt_data);
100         const gchar     *(*get_encrypt_warning) (void);
101         void             (*inhibit_encrypt_warning)     (gboolean inhibit);
102 };
103
104 struct _PrivacyData {
105         PrivacySystem   *system;
106 };
107
108 void privacy_inhibit_encrypt_warning            (const gchar *id,
109                                                  gboolean inhibit);
110
111 #endif /* PRIVACY_H */