1 /*
2  * Seahorse
3  *
4  * Copyright (C) 2005 Stefan Walter
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as
8  * published by the Free Software Foundation; either version 2.1 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __CRYPTUI_H__
21 #define __CRYPTUI_H__
22 
23 #include <glib.h>
24 
25 G_BEGIN_DECLS
26 
27 #ifndef LIBCRYPTUI_API_SUBJECT_TO_CHANGE
28 #error "Please define LIBCRYPTUI_API_SUBJECT_TO_CHANGE to acknowledge your understanding that this API is not yet stable."
29 #endif
30 
31 #include "cryptui-keyset.h"
32 
33 /**
34  * CryptUIEncType:
35  * @CRYPTUI_ENCTYPE_NONE: the key is none of the below types
36  * @CRYPTUI_ENCTYPE_SYMMETRIC: the key's type is symmetric
37  * @CRYPTUI_ENCTYPE_PUBLIC: the key's type is public
38  * @CRYPTUI_ENCTYPE_PRIVATE: the key's type is private
39  * @CRYPTUI_ENCTYPE_MAXVALUE: for internal use only
40  *
41  * Used in key properties to indicate what kind of key it is
42  *
43  * Never ever change a values already present. These values are used
44  * across applications, DBus etc...
45  */
46 typedef enum {
47     CRYPTUI_ENCTYPE_NONE =       0,
48     CRYPTUI_ENCTYPE_SYMMETRIC =  1,
49     CRYPTUI_ENCTYPE_PUBLIC =     2,
50     CRYPTUI_ENCTYPE_PRIVATE =    3,
51 
52     /* Used internally */
53     CRYPTUI_ENCTYPE_MAXVALUE
54 } CryptUIEncType;
55 
56 /**
57  * CryptUIKeyFlags:
58  * @CRYPTUI_FLAG_IS_VALID: whether the key is valid
59  * @CRYPTUI_FLAG_CAN_ENCRYPT: whether the key can encrypt
60  * @CRYPTUI_FLAG_CAN_SIGN: whether the key can sign
61  * @CRYPTUI_FLAG_EXPIRED: whether the key is expired
62  * @CRYPTUI_FLAG_REVOKED: whether the key is revoked
63  * @CRYPTUI_FLAG_DISABLED: whether the key is disabled
64  * @CRYPTUI_FLAG_TRUSTED: whether the key is trusted
65  * @CRYPTUI_FLAG_EXPORTABLE: whether the key is exportable
66  *
67  * Used in key properties to indicate a key's status.  These values are
68  * logically OR'd together.
69  *
70  * Never ever change a values already present. These values are used
71  * across applications, DBus etc...
72  */
73 typedef enum {
74     CRYPTUI_FLAG_IS_VALID =    0x00000001,
75     CRYPTUI_FLAG_CAN_ENCRYPT = 0x00000002,
76     CRYPTUI_FLAG_CAN_SIGN =    0x00000004,
77     CRYPTUI_FLAG_EXPIRED =     0x00000100,
78     CRYPTUI_FLAG_REVOKED =     0x00000200,
79     CRYPTUI_FLAG_DISABLED =    0x00000400,
80     CRYPTUI_FLAG_TRUSTED =     0x00001000,
81     CRYPTUI_FLAG_EXPORTABLE =  0x00100000
82 } CryptUIKeyFlags;
83 
84 /**
85  * CryptUILocation:
86  * @CRYPTUI_LOC_INVALID: An invalid key
87  * @CRYPTUI_LOC_MISSING: A key we don't know anything about
88  * @CRYPTUI_LOC_SEARCHING: A key we're searching for but haven't found yet
89  * @CRYPTUI_LOC_REMOTE: A key that we've found is present remotely
90  * @CRYPTUI_LOC_LOCAL: A key on the local machine
91  *
92  * Indicates where a key is located.
93  *
94  * Never ever change a values already present. These values are used
95  * across applications, DBus etc...
96  */
97 typedef enum {
98     CRYPTUI_LOC_INVALID =        0,
99     CRYPTUI_LOC_MISSING =       10,
100     CRYPTUI_LOC_SEARCHING =     20,
101     CRYPTUI_LOC_REMOTE =        50,
102     CRYPTUI_LOC_LOCAL =        100,
103 } CryptUILocation;
104 
105 /**
106  * CryptUIValidity:
107  * @CRYPTUI_VALIDITY_REVOKED: the key is revoked
108  * @CRYPTUI_VALIDITY_DISABLED: the key is disabled
109  * @CRYPTUI_VALIDITY_NEVER: the key has never been valid
110  * @CRYPTUI_VALIDITY_UNKNOWN: the key's validity is unknown
111  * @CRYPTUI_VALIDITY_MARGINAL: the key's validity is marginal
112  * @CRYPTUI_VALIDITY_FULL: the key's validity is full
113  * @CRYPTUI_VALIDITY_ULTIMATE: the key's validity is ultimate
114  *
115  * What the validity of the key is.
116  *
117  * Never ever change a values already present. These values are used
118  * across applications, DBus etc...
119  */
120 typedef enum {
121     CRYPTUI_VALIDITY_REVOKED =   -3,
122     CRYPTUI_VALIDITY_DISABLED =  -2,
123     CRYPTUI_VALIDITY_NEVER =     -1,
124     CRYPTUI_VALIDITY_UNKNOWN =    0,
125     CRYPTUI_VALIDITY_MARGINAL =   1,
126     CRYPTUI_VALIDITY_FULL =       5,
127     CRYPTUI_VALIDITY_ULTIMATE =  10
128 } CryptUIValidity;
129 
130 /*
131  * Key Properties:
132  *
133  * display-name: G_TYPE_STRING
134  * display-id:   G_TYPE_STRING
135  * enc-type:     G_TYPE_UINT (CryptUIEncType)
136  *
137  *
138  * TODO: Flesh this list out
139  */
140 
141 gchar*              cryptui_key_get_base (const gchar *key);
142 
143 CryptUIEncType      cryptui_key_get_enctype (const gchar *key);
144 
145 void                cryptui_display_notification (const gchar *title, const gchar *body,
146                                                   const gchar *icon, gboolean urgent);
147 
148 gchar**             cryptui_prompt_recipients_with_symmetric (CryptUIKeyset *keyset,
149                                                               const gchar *title,
150                                                               gchar **signer,
151                                                               gboolean *symmetric);
152 gchar**             cryptui_prompt_recipients (CryptUIKeyset *keyset,
153                                                const gchar *title, gchar **signer);
154 
155 gchar*              cryptui_prompt_signer (CryptUIKeyset *keyset, const gchar *title);
156 
157 /*
158  * This function creates a dialog when a consumer of the library needs the user to
159  * create or import at least one key for the application to perform the necessary
160  * action.  It will inform the user of the need to create or import a key and launch
161  * the seahorse (Passwords and Encryption Keys) application so that they may do so.
162  *
163  * quit: whether to run gtk_main_quit () after launching seahorse
164  */
165 void                cryptui_need_to_get_keys ();
166 
167 gboolean            cryptui_need_to_get_keys_or_symmetric (void);
168 
169 G_END_DECLS
170 
171 #endif /* __CRYPT_UI_H__ */
172